pdf.combined.js 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190
  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.7.227';
  27. var pdfjsBuild = 'e132fa9';
  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 (this._scheme === 'file') {
  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 (this._scheme === 'file') {
  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 (cp === '\t' || cp === '\n' || cp === '\r') {
  4590. err('Invalid whitespace in authority.');
  4591. continue;
  4592. }
  4593. if (cp === ':' && this._password === null) {
  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 (c === EOF || 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 (c === EOF || 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 (c === '\t' || c === '\n' || c === '\r') {
  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 (stateOverride === 'hostname') {
  4639. break loop;
  4640. }
  4641. } else if (c === EOF || 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 (c === EOF || 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 (c === '\t' || c === '\n' || c === '\r') {
  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 (c === EOF || 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 (this._scheme === 'file' && 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 (numBidi / strLength < 0.3) {
  5542. isLTR = true;
  5543. startLevel = 0;
  5544. } else {
  5545. isLTR = false;
  5546. startLevel = 1;
  5547. }
  5548. }
  5549. var levels = [];
  5550. for (i = 0; i < strLength; ++i) {
  5551. levels[i] = startLevel;
  5552. }
  5553. var e = isOdd(startLevel) ? 'R' : 'L';
  5554. var sor = e;
  5555. var eor = sor;
  5556. var lastType = sor;
  5557. for (i = 0; i < strLength; ++i) {
  5558. if (types[i] === 'NSM') {
  5559. types[i] = lastType;
  5560. } else {
  5561. lastType = types[i];
  5562. }
  5563. }
  5564. lastType = sor;
  5565. var t;
  5566. for (i = 0; i < strLength; ++i) {
  5567. t = types[i];
  5568. if (t === 'EN') {
  5569. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  5570. } else if (t === 'R' || t === 'L' || t === 'AL') {
  5571. lastType = t;
  5572. }
  5573. }
  5574. for (i = 0; i < strLength; ++i) {
  5575. t = types[i];
  5576. if (t === 'AL') {
  5577. types[i] = 'R';
  5578. }
  5579. }
  5580. for (i = 1; i < strLength - 1; ++i) {
  5581. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  5582. types[i] = 'EN';
  5583. }
  5584. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  5585. types[i] = types[i - 1];
  5586. }
  5587. }
  5588. for (i = 0; i < strLength; ++i) {
  5589. if (types[i] === 'EN') {
  5590. var j;
  5591. for (j = i - 1; j >= 0; --j) {
  5592. if (types[j] !== 'ET') {
  5593. break;
  5594. }
  5595. types[j] = 'EN';
  5596. }
  5597. for (j = i + 1; j < strLength; ++j) {
  5598. if (types[j] !== 'ET') {
  5599. break;
  5600. }
  5601. types[j] = 'EN';
  5602. }
  5603. }
  5604. }
  5605. for (i = 0; i < strLength; ++i) {
  5606. t = types[i];
  5607. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  5608. types[i] = 'ON';
  5609. }
  5610. }
  5611. lastType = sor;
  5612. for (i = 0; i < strLength; ++i) {
  5613. t = types[i];
  5614. if (t === 'EN') {
  5615. types[i] = lastType === 'L' ? 'L' : 'EN';
  5616. } else if (t === 'R' || t === 'L') {
  5617. lastType = t;
  5618. }
  5619. }
  5620. for (i = 0; i < strLength; ++i) {
  5621. if (types[i] === 'ON') {
  5622. var end = findUnequal(types, i + 1, 'ON');
  5623. var before = sor;
  5624. if (i > 0) {
  5625. before = types[i - 1];
  5626. }
  5627. var after = eor;
  5628. if (end + 1 < strLength) {
  5629. after = types[end + 1];
  5630. }
  5631. if (before !== 'L') {
  5632. before = 'R';
  5633. }
  5634. if (after !== 'L') {
  5635. after = 'R';
  5636. }
  5637. if (before === after) {
  5638. setValues(types, i, end, before);
  5639. }
  5640. i = end - 1;
  5641. }
  5642. }
  5643. for (i = 0; i < strLength; ++i) {
  5644. if (types[i] === 'ON') {
  5645. types[i] = e;
  5646. }
  5647. }
  5648. for (i = 0; i < strLength; ++i) {
  5649. t = types[i];
  5650. if (isEven(levels[i])) {
  5651. if (t === 'R') {
  5652. levels[i] += 1;
  5653. } else if (t === 'AN' || t === 'EN') {
  5654. levels[i] += 2;
  5655. }
  5656. } else {
  5657. if (t === 'L' || t === 'AN' || t === 'EN') {
  5658. levels[i] += 1;
  5659. }
  5660. }
  5661. }
  5662. var highestLevel = -1;
  5663. var lowestOddLevel = 99;
  5664. var level;
  5665. for (i = 0, ii = levels.length; i < ii; ++i) {
  5666. level = levels[i];
  5667. if (highestLevel < level) {
  5668. highestLevel = level;
  5669. }
  5670. if (lowestOddLevel > level && isOdd(level)) {
  5671. lowestOddLevel = level;
  5672. }
  5673. }
  5674. for (level = highestLevel; level >= lowestOddLevel; --level) {
  5675. var start = -1;
  5676. for (i = 0, ii = levels.length; i < ii; ++i) {
  5677. if (levels[i] < level) {
  5678. if (start >= 0) {
  5679. reverseValues(chars, start, i);
  5680. start = -1;
  5681. }
  5682. } else if (start < 0) {
  5683. start = i;
  5684. }
  5685. }
  5686. if (start >= 0) {
  5687. reverseValues(chars, start, levels.length);
  5688. }
  5689. }
  5690. for (i = 0, ii = chars.length; i < ii; ++i) {
  5691. var ch = chars[i];
  5692. if (ch === '<' || ch === '>') {
  5693. chars[i] = '';
  5694. }
  5695. }
  5696. return createBidiText(chars.join(''), isLTR);
  5697. }
  5698. exports.bidi = bidi;
  5699. }));
  5700. (function (root, factory) {
  5701. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5702. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5703. var error = sharedUtil.error;
  5704. var info = sharedUtil.info;
  5705. var bytesToString = sharedUtil.bytesToString;
  5706. var warn = sharedUtil.warn;
  5707. var isArray = sharedUtil.isArray;
  5708. var Util = sharedUtil.Util;
  5709. var stringToBytes = sharedUtil.stringToBytes;
  5710. var assert = sharedUtil.assert;
  5711. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5712. var ExpertCharset = coreCharsets.ExpertCharset;
  5713. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5714. var StandardEncoding = coreEncodings.StandardEncoding;
  5715. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5716. var MAX_SUBR_NESTING = 10;
  5717. var CFFStandardStrings = [
  5718. '.notdef',
  5719. 'space',
  5720. 'exclam',
  5721. 'quotedbl',
  5722. 'numbersign',
  5723. 'dollar',
  5724. 'percent',
  5725. 'ampersand',
  5726. 'quoteright',
  5727. 'parenleft',
  5728. 'parenright',
  5729. 'asterisk',
  5730. 'plus',
  5731. 'comma',
  5732. 'hyphen',
  5733. 'period',
  5734. 'slash',
  5735. 'zero',
  5736. 'one',
  5737. 'two',
  5738. 'three',
  5739. 'four',
  5740. 'five',
  5741. 'six',
  5742. 'seven',
  5743. 'eight',
  5744. 'nine',
  5745. 'colon',
  5746. 'semicolon',
  5747. 'less',
  5748. 'equal',
  5749. 'greater',
  5750. 'question',
  5751. 'at',
  5752. 'A',
  5753. 'B',
  5754. 'C',
  5755. 'D',
  5756. 'E',
  5757. 'F',
  5758. 'G',
  5759. 'H',
  5760. 'I',
  5761. 'J',
  5762. 'K',
  5763. 'L',
  5764. 'M',
  5765. 'N',
  5766. 'O',
  5767. 'P',
  5768. 'Q',
  5769. 'R',
  5770. 'S',
  5771. 'T',
  5772. 'U',
  5773. 'V',
  5774. 'W',
  5775. 'X',
  5776. 'Y',
  5777. 'Z',
  5778. 'bracketleft',
  5779. 'backslash',
  5780. 'bracketright',
  5781. 'asciicircum',
  5782. 'underscore',
  5783. 'quoteleft',
  5784. 'a',
  5785. 'b',
  5786. 'c',
  5787. 'd',
  5788. 'e',
  5789. 'f',
  5790. 'g',
  5791. 'h',
  5792. 'i',
  5793. 'j',
  5794. 'k',
  5795. 'l',
  5796. 'm',
  5797. 'n',
  5798. 'o',
  5799. 'p',
  5800. 'q',
  5801. 'r',
  5802. 's',
  5803. 't',
  5804. 'u',
  5805. 'v',
  5806. 'w',
  5807. 'x',
  5808. 'y',
  5809. 'z',
  5810. 'braceleft',
  5811. 'bar',
  5812. 'braceright',
  5813. 'asciitilde',
  5814. 'exclamdown',
  5815. 'cent',
  5816. 'sterling',
  5817. 'fraction',
  5818. 'yen',
  5819. 'florin',
  5820. 'section',
  5821. 'currency',
  5822. 'quotesingle',
  5823. 'quotedblleft',
  5824. 'guillemotleft',
  5825. 'guilsinglleft',
  5826. 'guilsinglright',
  5827. 'fi',
  5828. 'fl',
  5829. 'endash',
  5830. 'dagger',
  5831. 'daggerdbl',
  5832. 'periodcentered',
  5833. 'paragraph',
  5834. 'bullet',
  5835. 'quotesinglbase',
  5836. 'quotedblbase',
  5837. 'quotedblright',
  5838. 'guillemotright',
  5839. 'ellipsis',
  5840. 'perthousand',
  5841. 'questiondown',
  5842. 'grave',
  5843. 'acute',
  5844. 'circumflex',
  5845. 'tilde',
  5846. 'macron',
  5847. 'breve',
  5848. 'dotaccent',
  5849. 'dieresis',
  5850. 'ring',
  5851. 'cedilla',
  5852. 'hungarumlaut',
  5853. 'ogonek',
  5854. 'caron',
  5855. 'emdash',
  5856. 'AE',
  5857. 'ordfeminine',
  5858. 'Lslash',
  5859. 'Oslash',
  5860. 'OE',
  5861. 'ordmasculine',
  5862. 'ae',
  5863. 'dotlessi',
  5864. 'lslash',
  5865. 'oslash',
  5866. 'oe',
  5867. 'germandbls',
  5868. 'onesuperior',
  5869. 'logicalnot',
  5870. 'mu',
  5871. 'trademark',
  5872. 'Eth',
  5873. 'onehalf',
  5874. 'plusminus',
  5875. 'Thorn',
  5876. 'onequarter',
  5877. 'divide',
  5878. 'brokenbar',
  5879. 'degree',
  5880. 'thorn',
  5881. 'threequarters',
  5882. 'twosuperior',
  5883. 'registered',
  5884. 'minus',
  5885. 'eth',
  5886. 'multiply',
  5887. 'threesuperior',
  5888. 'copyright',
  5889. 'Aacute',
  5890. 'Acircumflex',
  5891. 'Adieresis',
  5892. 'Agrave',
  5893. 'Aring',
  5894. 'Atilde',
  5895. 'Ccedilla',
  5896. 'Eacute',
  5897. 'Ecircumflex',
  5898. 'Edieresis',
  5899. 'Egrave',
  5900. 'Iacute',
  5901. 'Icircumflex',
  5902. 'Idieresis',
  5903. 'Igrave',
  5904. 'Ntilde',
  5905. 'Oacute',
  5906. 'Ocircumflex',
  5907. 'Odieresis',
  5908. 'Ograve',
  5909. 'Otilde',
  5910. 'Scaron',
  5911. 'Uacute',
  5912. 'Ucircumflex',
  5913. 'Udieresis',
  5914. 'Ugrave',
  5915. 'Yacute',
  5916. 'Ydieresis',
  5917. 'Zcaron',
  5918. 'aacute',
  5919. 'acircumflex',
  5920. 'adieresis',
  5921. 'agrave',
  5922. 'aring',
  5923. 'atilde',
  5924. 'ccedilla',
  5925. 'eacute',
  5926. 'ecircumflex',
  5927. 'edieresis',
  5928. 'egrave',
  5929. 'iacute',
  5930. 'icircumflex',
  5931. 'idieresis',
  5932. 'igrave',
  5933. 'ntilde',
  5934. 'oacute',
  5935. 'ocircumflex',
  5936. 'odieresis',
  5937. 'ograve',
  5938. 'otilde',
  5939. 'scaron',
  5940. 'uacute',
  5941. 'ucircumflex',
  5942. 'udieresis',
  5943. 'ugrave',
  5944. 'yacute',
  5945. 'ydieresis',
  5946. 'zcaron',
  5947. 'exclamsmall',
  5948. 'Hungarumlautsmall',
  5949. 'dollaroldstyle',
  5950. 'dollarsuperior',
  5951. 'ampersandsmall',
  5952. 'Acutesmall',
  5953. 'parenleftsuperior',
  5954. 'parenrightsuperior',
  5955. 'twodotenleader',
  5956. 'onedotenleader',
  5957. 'zerooldstyle',
  5958. 'oneoldstyle',
  5959. 'twooldstyle',
  5960. 'threeoldstyle',
  5961. 'fouroldstyle',
  5962. 'fiveoldstyle',
  5963. 'sixoldstyle',
  5964. 'sevenoldstyle',
  5965. 'eightoldstyle',
  5966. 'nineoldstyle',
  5967. 'commasuperior',
  5968. 'threequartersemdash',
  5969. 'periodsuperior',
  5970. 'questionsmall',
  5971. 'asuperior',
  5972. 'bsuperior',
  5973. 'centsuperior',
  5974. 'dsuperior',
  5975. 'esuperior',
  5976. 'isuperior',
  5977. 'lsuperior',
  5978. 'msuperior',
  5979. 'nsuperior',
  5980. 'osuperior',
  5981. 'rsuperior',
  5982. 'ssuperior',
  5983. 'tsuperior',
  5984. 'ff',
  5985. 'ffi',
  5986. 'ffl',
  5987. 'parenleftinferior',
  5988. 'parenrightinferior',
  5989. 'Circumflexsmall',
  5990. 'hyphensuperior',
  5991. 'Gravesmall',
  5992. 'Asmall',
  5993. 'Bsmall',
  5994. 'Csmall',
  5995. 'Dsmall',
  5996. 'Esmall',
  5997. 'Fsmall',
  5998. 'Gsmall',
  5999. 'Hsmall',
  6000. 'Ismall',
  6001. 'Jsmall',
  6002. 'Ksmall',
  6003. 'Lsmall',
  6004. 'Msmall',
  6005. 'Nsmall',
  6006. 'Osmall',
  6007. 'Psmall',
  6008. 'Qsmall',
  6009. 'Rsmall',
  6010. 'Ssmall',
  6011. 'Tsmall',
  6012. 'Usmall',
  6013. 'Vsmall',
  6014. 'Wsmall',
  6015. 'Xsmall',
  6016. 'Ysmall',
  6017. 'Zsmall',
  6018. 'colonmonetary',
  6019. 'onefitted',
  6020. 'rupiah',
  6021. 'Tildesmall',
  6022. 'exclamdownsmall',
  6023. 'centoldstyle',
  6024. 'Lslashsmall',
  6025. 'Scaronsmall',
  6026. 'Zcaronsmall',
  6027. 'Dieresissmall',
  6028. 'Brevesmall',
  6029. 'Caronsmall',
  6030. 'Dotaccentsmall',
  6031. 'Macronsmall',
  6032. 'figuredash',
  6033. 'hypheninferior',
  6034. 'Ogoneksmall',
  6035. 'Ringsmall',
  6036. 'Cedillasmall',
  6037. 'questiondownsmall',
  6038. 'oneeighth',
  6039. 'threeeighths',
  6040. 'fiveeighths',
  6041. 'seveneighths',
  6042. 'onethird',
  6043. 'twothirds',
  6044. 'zerosuperior',
  6045. 'foursuperior',
  6046. 'fivesuperior',
  6047. 'sixsuperior',
  6048. 'sevensuperior',
  6049. 'eightsuperior',
  6050. 'ninesuperior',
  6051. 'zeroinferior',
  6052. 'oneinferior',
  6053. 'twoinferior',
  6054. 'threeinferior',
  6055. 'fourinferior',
  6056. 'fiveinferior',
  6057. 'sixinferior',
  6058. 'seveninferior',
  6059. 'eightinferior',
  6060. 'nineinferior',
  6061. 'centinferior',
  6062. 'dollarinferior',
  6063. 'periodinferior',
  6064. 'commainferior',
  6065. 'Agravesmall',
  6066. 'Aacutesmall',
  6067. 'Acircumflexsmall',
  6068. 'Atildesmall',
  6069. 'Adieresissmall',
  6070. 'Aringsmall',
  6071. 'AEsmall',
  6072. 'Ccedillasmall',
  6073. 'Egravesmall',
  6074. 'Eacutesmall',
  6075. 'Ecircumflexsmall',
  6076. 'Edieresissmall',
  6077. 'Igravesmall',
  6078. 'Iacutesmall',
  6079. 'Icircumflexsmall',
  6080. 'Idieresissmall',
  6081. 'Ethsmall',
  6082. 'Ntildesmall',
  6083. 'Ogravesmall',
  6084. 'Oacutesmall',
  6085. 'Ocircumflexsmall',
  6086. 'Otildesmall',
  6087. 'Odieresissmall',
  6088. 'OEsmall',
  6089. 'Oslashsmall',
  6090. 'Ugravesmall',
  6091. 'Uacutesmall',
  6092. 'Ucircumflexsmall',
  6093. 'Udieresissmall',
  6094. 'Yacutesmall',
  6095. 'Thornsmall',
  6096. 'Ydieresissmall',
  6097. '001.000',
  6098. '001.001',
  6099. '001.002',
  6100. '001.003',
  6101. 'Black',
  6102. 'Bold',
  6103. 'Book',
  6104. 'Light',
  6105. 'Medium',
  6106. 'Regular',
  6107. 'Roman',
  6108. 'Semibold'
  6109. ];
  6110. var CFFParser = function CFFParserClosure() {
  6111. var CharstringValidationData = [
  6112. null,
  6113. {
  6114. id: 'hstem',
  6115. min: 2,
  6116. stackClearing: true,
  6117. stem: true
  6118. },
  6119. null,
  6120. {
  6121. id: 'vstem',
  6122. min: 2,
  6123. stackClearing: true,
  6124. stem: true
  6125. },
  6126. {
  6127. id: 'vmoveto',
  6128. min: 1,
  6129. stackClearing: true
  6130. },
  6131. {
  6132. id: 'rlineto',
  6133. min: 2,
  6134. resetStack: true
  6135. },
  6136. {
  6137. id: 'hlineto',
  6138. min: 1,
  6139. resetStack: true
  6140. },
  6141. {
  6142. id: 'vlineto',
  6143. min: 1,
  6144. resetStack: true
  6145. },
  6146. {
  6147. id: 'rrcurveto',
  6148. min: 6,
  6149. resetStack: true
  6150. },
  6151. null,
  6152. {
  6153. id: 'callsubr',
  6154. min: 1,
  6155. undefStack: true
  6156. },
  6157. {
  6158. id: 'return',
  6159. min: 0,
  6160. undefStack: true
  6161. },
  6162. null,
  6163. null,
  6164. {
  6165. id: 'endchar',
  6166. min: 0,
  6167. stackClearing: true
  6168. },
  6169. null,
  6170. null,
  6171. null,
  6172. {
  6173. id: 'hstemhm',
  6174. min: 2,
  6175. stackClearing: true,
  6176. stem: true
  6177. },
  6178. {
  6179. id: 'hintmask',
  6180. min: 0,
  6181. stackClearing: true
  6182. },
  6183. {
  6184. id: 'cntrmask',
  6185. min: 0,
  6186. stackClearing: true
  6187. },
  6188. {
  6189. id: 'rmoveto',
  6190. min: 2,
  6191. stackClearing: true
  6192. },
  6193. {
  6194. id: 'hmoveto',
  6195. min: 1,
  6196. stackClearing: true
  6197. },
  6198. {
  6199. id: 'vstemhm',
  6200. min: 2,
  6201. stackClearing: true,
  6202. stem: true
  6203. },
  6204. {
  6205. id: 'rcurveline',
  6206. min: 8,
  6207. resetStack: true
  6208. },
  6209. {
  6210. id: 'rlinecurve',
  6211. min: 8,
  6212. resetStack: true
  6213. },
  6214. {
  6215. id: 'vvcurveto',
  6216. min: 4,
  6217. resetStack: true
  6218. },
  6219. {
  6220. id: 'hhcurveto',
  6221. min: 4,
  6222. resetStack: true
  6223. },
  6224. null,
  6225. {
  6226. id: 'callgsubr',
  6227. min: 1,
  6228. undefStack: true
  6229. },
  6230. {
  6231. id: 'vhcurveto',
  6232. min: 4,
  6233. resetStack: true
  6234. },
  6235. {
  6236. id: 'hvcurveto',
  6237. min: 4,
  6238. resetStack: true
  6239. }
  6240. ];
  6241. var CharstringValidationData12 = [
  6242. null,
  6243. null,
  6244. null,
  6245. {
  6246. id: 'and',
  6247. min: 2,
  6248. stackDelta: -1
  6249. },
  6250. {
  6251. id: 'or',
  6252. min: 2,
  6253. stackDelta: -1
  6254. },
  6255. {
  6256. id: 'not',
  6257. min: 1,
  6258. stackDelta: 0
  6259. },
  6260. null,
  6261. null,
  6262. null,
  6263. {
  6264. id: 'abs',
  6265. min: 1,
  6266. stackDelta: 0
  6267. },
  6268. {
  6269. id: 'add',
  6270. min: 2,
  6271. stackDelta: -1,
  6272. stackFn: function stack_div(stack, index) {
  6273. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6274. }
  6275. },
  6276. {
  6277. id: 'sub',
  6278. min: 2,
  6279. stackDelta: -1,
  6280. stackFn: function stack_div(stack, index) {
  6281. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6282. }
  6283. },
  6284. {
  6285. id: 'div',
  6286. min: 2,
  6287. stackDelta: -1,
  6288. stackFn: function stack_div(stack, index) {
  6289. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6290. }
  6291. },
  6292. null,
  6293. {
  6294. id: 'neg',
  6295. min: 1,
  6296. stackDelta: 0,
  6297. stackFn: function stack_div(stack, index) {
  6298. stack[index - 1] = -stack[index - 1];
  6299. }
  6300. },
  6301. {
  6302. id: 'eq',
  6303. min: 2,
  6304. stackDelta: -1
  6305. },
  6306. null,
  6307. null,
  6308. {
  6309. id: 'drop',
  6310. min: 1,
  6311. stackDelta: -1
  6312. },
  6313. null,
  6314. {
  6315. id: 'put',
  6316. min: 2,
  6317. stackDelta: -2
  6318. },
  6319. {
  6320. id: 'get',
  6321. min: 1,
  6322. stackDelta: 0
  6323. },
  6324. {
  6325. id: 'ifelse',
  6326. min: 4,
  6327. stackDelta: -3
  6328. },
  6329. {
  6330. id: 'random',
  6331. min: 0,
  6332. stackDelta: 1
  6333. },
  6334. {
  6335. id: 'mul',
  6336. min: 2,
  6337. stackDelta: -1,
  6338. stackFn: function stack_div(stack, index) {
  6339. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6340. }
  6341. },
  6342. null,
  6343. {
  6344. id: 'sqrt',
  6345. min: 1,
  6346. stackDelta: 0
  6347. },
  6348. {
  6349. id: 'dup',
  6350. min: 1,
  6351. stackDelta: 1
  6352. },
  6353. {
  6354. id: 'exch',
  6355. min: 2,
  6356. stackDelta: 0
  6357. },
  6358. {
  6359. id: 'index',
  6360. min: 2,
  6361. stackDelta: 0
  6362. },
  6363. {
  6364. id: 'roll',
  6365. min: 3,
  6366. stackDelta: -2
  6367. },
  6368. null,
  6369. null,
  6370. null,
  6371. {
  6372. id: 'hflex',
  6373. min: 7,
  6374. resetStack: true
  6375. },
  6376. {
  6377. id: 'flex',
  6378. min: 13,
  6379. resetStack: true
  6380. },
  6381. {
  6382. id: 'hflex1',
  6383. min: 9,
  6384. resetStack: true
  6385. },
  6386. {
  6387. id: 'flex1',
  6388. min: 11,
  6389. resetStack: true
  6390. }
  6391. ];
  6392. function CFFParser(file, properties, seacAnalysisEnabled) {
  6393. this.bytes = file.getBytes();
  6394. this.properties = properties;
  6395. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6396. }
  6397. CFFParser.prototype = {
  6398. parse: function CFFParser_parse() {
  6399. var properties = this.properties;
  6400. var cff = new CFF();
  6401. this.cff = cff;
  6402. var header = this.parseHeader();
  6403. var nameIndex = this.parseIndex(header.endPos);
  6404. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6405. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6406. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6407. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6408. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6409. cff.header = header.obj;
  6410. cff.names = this.parseNameIndex(nameIndex.obj);
  6411. cff.strings = this.parseStringIndex(stringIndex.obj);
  6412. cff.topDict = topDict;
  6413. cff.globalSubrIndex = globalSubrIndex.obj;
  6414. this.parsePrivateDict(cff.topDict);
  6415. cff.isCIDFont = topDict.hasName('ROS');
  6416. var charStringOffset = topDict.getByName('CharStrings');
  6417. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6418. var fontMatrix = topDict.getByName('FontMatrix');
  6419. if (fontMatrix) {
  6420. properties.fontMatrix = fontMatrix;
  6421. }
  6422. var fontBBox = topDict.getByName('FontBBox');
  6423. if (fontBBox) {
  6424. properties.ascent = fontBBox[3];
  6425. properties.descent = fontBBox[1];
  6426. properties.ascentScaled = true;
  6427. }
  6428. var charset, encoding;
  6429. if (cff.isCIDFont) {
  6430. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6431. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6432. var dictRaw = fdArrayIndex.get(i);
  6433. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6434. this.parsePrivateDict(fontDict);
  6435. cff.fdArray.push(fontDict);
  6436. }
  6437. encoding = null;
  6438. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6439. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6440. } else {
  6441. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6442. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6443. }
  6444. cff.charset = charset;
  6445. cff.encoding = encoding;
  6446. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6447. cff.charStrings = charStringsAndSeacs.charStrings;
  6448. cff.seacs = charStringsAndSeacs.seacs;
  6449. cff.widths = charStringsAndSeacs.widths;
  6450. return cff;
  6451. },
  6452. parseHeader: function CFFParser_parseHeader() {
  6453. var bytes = this.bytes;
  6454. var bytesLength = bytes.length;
  6455. var offset = 0;
  6456. while (offset < bytesLength && bytes[offset] !== 1) {
  6457. ++offset;
  6458. }
  6459. if (offset >= bytesLength) {
  6460. error('Invalid CFF header');
  6461. } else if (offset !== 0) {
  6462. info('cff data is shifted');
  6463. bytes = bytes.subarray(offset);
  6464. this.bytes = bytes;
  6465. }
  6466. var major = bytes[0];
  6467. var minor = bytes[1];
  6468. var hdrSize = bytes[2];
  6469. var offSize = bytes[3];
  6470. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6471. return {
  6472. obj: header,
  6473. endPos: hdrSize
  6474. };
  6475. },
  6476. parseDict: function CFFParser_parseDict(dict) {
  6477. var pos = 0;
  6478. function parseOperand() {
  6479. var value = dict[pos++];
  6480. if (value === 30) {
  6481. return parseFloatOperand();
  6482. } else if (value === 28) {
  6483. value = dict[pos++];
  6484. value = (value << 24 | dict[pos++] << 16) >> 16;
  6485. return value;
  6486. } else if (value === 29) {
  6487. value = dict[pos++];
  6488. value = value << 8 | dict[pos++];
  6489. value = value << 8 | dict[pos++];
  6490. value = value << 8 | dict[pos++];
  6491. return value;
  6492. } else if (value >= 32 && value <= 246) {
  6493. return value - 139;
  6494. } else if (value >= 247 && value <= 250) {
  6495. return (value - 247) * 256 + dict[pos++] + 108;
  6496. } else if (value >= 251 && value <= 254) {
  6497. return -((value - 251) * 256) - dict[pos++] - 108;
  6498. }
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. function parseFloatOperand() {
  6503. var str = '';
  6504. var eof = 15;
  6505. var lookup = [
  6506. '0',
  6507. '1',
  6508. '2',
  6509. '3',
  6510. '4',
  6511. '5',
  6512. '6',
  6513. '7',
  6514. '8',
  6515. '9',
  6516. '.',
  6517. 'E',
  6518. 'E-',
  6519. null,
  6520. '-'
  6521. ];
  6522. var length = dict.length;
  6523. while (pos < length) {
  6524. var b = dict[pos++];
  6525. var b1 = b >> 4;
  6526. var b2 = b & 15;
  6527. if (b1 === eof) {
  6528. break;
  6529. }
  6530. str += lookup[b1];
  6531. if (b2 === eof) {
  6532. break;
  6533. }
  6534. str += lookup[b2];
  6535. }
  6536. return parseFloat(str);
  6537. }
  6538. var operands = [];
  6539. var entries = [];
  6540. pos = 0;
  6541. var end = dict.length;
  6542. while (pos < end) {
  6543. var b = dict[pos];
  6544. if (b <= 21) {
  6545. if (b === 12) {
  6546. b = b << 8 | dict[++pos];
  6547. }
  6548. entries.push([
  6549. b,
  6550. operands
  6551. ]);
  6552. operands = [];
  6553. ++pos;
  6554. } else {
  6555. operands.push(parseOperand());
  6556. }
  6557. }
  6558. return entries;
  6559. },
  6560. parseIndex: function CFFParser_parseIndex(pos) {
  6561. var cffIndex = new CFFIndex();
  6562. var bytes = this.bytes;
  6563. var count = bytes[pos++] << 8 | bytes[pos++];
  6564. var offsets = [];
  6565. var end = pos;
  6566. var i, ii;
  6567. if (count !== 0) {
  6568. var offsetSize = bytes[pos++];
  6569. var startPos = pos + (count + 1) * offsetSize - 1;
  6570. for (i = 0, ii = count + 1; i < ii; ++i) {
  6571. var offset = 0;
  6572. for (var j = 0; j < offsetSize; ++j) {
  6573. offset <<= 8;
  6574. offset += bytes[pos++];
  6575. }
  6576. offsets.push(startPos + offset);
  6577. }
  6578. end = offsets[count];
  6579. }
  6580. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6581. var offsetStart = offsets[i];
  6582. var offsetEnd = offsets[i + 1];
  6583. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6584. }
  6585. return {
  6586. obj: cffIndex,
  6587. endPos: end
  6588. };
  6589. },
  6590. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6591. var names = [];
  6592. for (var i = 0, ii = index.count; i < ii; ++i) {
  6593. var name = index.get(i);
  6594. var length = Math.min(name.length, 127);
  6595. var data = [];
  6596. for (var j = 0; j < length; ++j) {
  6597. var c = name[j];
  6598. if (j === 0 && c === 0) {
  6599. data[j] = c;
  6600. continue;
  6601. }
  6602. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35)
  6603. {
  6604. data[j] = 95;
  6605. continue;
  6606. }
  6607. data[j] = c;
  6608. }
  6609. names.push(bytesToString(data));
  6610. }
  6611. return names;
  6612. },
  6613. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6614. var strings = new CFFStrings();
  6615. for (var i = 0, ii = index.count; i < ii; ++i) {
  6616. var data = index.get(i);
  6617. strings.add(bytesToString(data));
  6618. }
  6619. return strings;
  6620. },
  6621. createDict: function CFFParser_createDict(Type, dict, strings) {
  6622. var cffDict = new Type(strings);
  6623. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6624. var pair = dict[i];
  6625. var key = pair[0];
  6626. var value = pair[1];
  6627. cffDict.setByKey(key, value);
  6628. }
  6629. return cffDict;
  6630. },
  6631. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6632. if (state.callDepth > MAX_SUBR_NESTING) {
  6633. return false;
  6634. }
  6635. var stackSize = state.stackSize;
  6636. var stack = state.stack;
  6637. var length = data.length;
  6638. for (var j = 0; j < length;) {
  6639. var value = data[j++];
  6640. var validationCommand = null;
  6641. if (value === 12) {
  6642. var q = data[j++];
  6643. if (q === 0) {
  6644. data[j - 2] = 139;
  6645. data[j - 1] = 22;
  6646. stackSize = 0;
  6647. } else {
  6648. validationCommand = CharstringValidationData12[q];
  6649. }
  6650. } else if (value === 28) {
  6651. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6652. j += 2;
  6653. stackSize++;
  6654. } else if (value === 14) {
  6655. if (stackSize >= 4) {
  6656. stackSize -= 4;
  6657. if (this.seacAnalysisEnabled) {
  6658. state.seac = stack.slice(stackSize, stackSize + 4);
  6659. return false;
  6660. }
  6661. }
  6662. validationCommand = CharstringValidationData[value];
  6663. } else if (value >= 32 && value <= 246) {
  6664. stack[stackSize] = value - 139;
  6665. stackSize++;
  6666. } else if (value >= 247 && value <= 254) {
  6667. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6668. j++;
  6669. stackSize++;
  6670. } else if (value === 255) {
  6671. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6672. j += 4;
  6673. stackSize++;
  6674. } else if (value === 19 || value === 20) {
  6675. state.hints += stackSize >> 1;
  6676. j += state.hints + 7 >> 3;
  6677. stackSize %= 2;
  6678. validationCommand = CharstringValidationData[value];
  6679. } else if (value === 10 || value === 29) {
  6680. var subrsIndex;
  6681. if (value === 10) {
  6682. subrsIndex = localSubrIndex;
  6683. } else {
  6684. subrsIndex = globalSubrIndex;
  6685. }
  6686. if (!subrsIndex) {
  6687. validationCommand = CharstringValidationData[value];
  6688. warn('Missing subrsIndex for ' + validationCommand.id);
  6689. return false;
  6690. }
  6691. var bias = 32768;
  6692. if (subrsIndex.count < 1240) {
  6693. bias = 107;
  6694. } else if (subrsIndex.count < 33900) {
  6695. bias = 1131;
  6696. }
  6697. var subrNumber = stack[--stackSize] + bias;
  6698. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6699. validationCommand = CharstringValidationData[value];
  6700. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6701. return false;
  6702. }
  6703. state.stackSize = stackSize;
  6704. state.callDepth++;
  6705. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6706. if (!valid) {
  6707. return false;
  6708. }
  6709. state.callDepth--;
  6710. stackSize = state.stackSize;
  6711. continue;
  6712. } else if (value === 11) {
  6713. state.stackSize = stackSize;
  6714. return true;
  6715. } else {
  6716. validationCommand = CharstringValidationData[value];
  6717. }
  6718. if (validationCommand) {
  6719. if (validationCommand.stem) {
  6720. state.hints += stackSize >> 1;
  6721. }
  6722. if ('min' in validationCommand) {
  6723. if (!state.undefStack && stackSize < validationCommand.min) {
  6724. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6725. return false;
  6726. }
  6727. }
  6728. if (state.firstStackClearing && validationCommand.stackClearing) {
  6729. state.firstStackClearing = false;
  6730. stackSize -= validationCommand.min;
  6731. if (stackSize >= 2 && validationCommand.stem) {
  6732. stackSize %= 2;
  6733. } else if (stackSize > 1) {
  6734. warn('Found too many parameters for stack-clearing command');
  6735. }
  6736. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6737. state.width = stack[stackSize - 1];
  6738. }
  6739. }
  6740. if ('stackDelta' in validationCommand) {
  6741. if ('stackFn' in validationCommand) {
  6742. validationCommand.stackFn(stack, stackSize);
  6743. }
  6744. stackSize += validationCommand.stackDelta;
  6745. } else if (validationCommand.stackClearing) {
  6746. stackSize = 0;
  6747. } else if (validationCommand.resetStack) {
  6748. stackSize = 0;
  6749. state.undefStack = false;
  6750. } else if (validationCommand.undefStack) {
  6751. stackSize = 0;
  6752. state.undefStack = true;
  6753. state.firstStackClearing = false;
  6754. }
  6755. }
  6756. }
  6757. state.stackSize = stackSize;
  6758. return true;
  6759. },
  6760. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6761. var seacs = [];
  6762. var widths = [];
  6763. var count = charStrings.count;
  6764. for (var i = 0; i < count; i++) {
  6765. var charstring = charStrings.get(i);
  6766. var state = {
  6767. callDepth: 0,
  6768. stackSize: 0,
  6769. stack: [],
  6770. undefStack: true,
  6771. hints: 0,
  6772. firstStackClearing: true,
  6773. seac: null,
  6774. width: null
  6775. };
  6776. var valid = true;
  6777. var localSubrToUse = null;
  6778. if (fdSelect && fdArray.length) {
  6779. var fdIndex = fdSelect.getFDIndex(i);
  6780. if (fdIndex === -1) {
  6781. warn('Glyph index is not in fd select.');
  6782. valid = false;
  6783. }
  6784. if (fdIndex >= fdArray.length) {
  6785. warn('Invalid fd index for glyph index.');
  6786. valid = false;
  6787. }
  6788. if (valid) {
  6789. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6790. }
  6791. } else if (localSubrIndex) {
  6792. localSubrToUse = localSubrIndex;
  6793. }
  6794. if (valid) {
  6795. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6796. }
  6797. if (state.width !== null) {
  6798. widths[i] = state.width;
  6799. }
  6800. if (state.seac !== null) {
  6801. seacs[i] = state.seac;
  6802. }
  6803. if (!valid) {
  6804. charStrings.set(i, new Uint8Array([14]));
  6805. }
  6806. }
  6807. return {
  6808. charStrings: charStrings,
  6809. seacs: seacs,
  6810. widths: widths
  6811. };
  6812. },
  6813. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6814. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6815. parentDict.setByKey(18, [
  6816. 0,
  6817. 0
  6818. ]);
  6819. parentDict.privateDict = privateDict;
  6820. },
  6821. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6822. if (!parentDict.hasName('Private')) {
  6823. this.emptyPrivateDictionary(parentDict);
  6824. return;
  6825. }
  6826. var privateOffset = parentDict.getByName('Private');
  6827. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6828. parentDict.removeByName('Private');
  6829. return;
  6830. }
  6831. var size = privateOffset[0];
  6832. var offset = privateOffset[1];
  6833. if (size === 0 || offset >= this.bytes.length) {
  6834. this.emptyPrivateDictionary(parentDict);
  6835. return;
  6836. }
  6837. var privateDictEnd = offset + size;
  6838. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6839. var dict = this.parseDict(dictData);
  6840. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6841. parentDict.privateDict = privateDict;
  6842. if (!privateDict.getByName('Subrs')) {
  6843. return;
  6844. }
  6845. var subrsOffset = privateDict.getByName('Subrs');
  6846. var relativeOffset = offset + subrsOffset;
  6847. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6848. this.emptyPrivateDictionary(parentDict);
  6849. return;
  6850. }
  6851. var subrsIndex = this.parseIndex(relativeOffset);
  6852. privateDict.subrsIndex = subrsIndex.obj;
  6853. },
  6854. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6855. if (pos === 0) {
  6856. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6857. } else if (pos === 1) {
  6858. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6859. } else if (pos === 2) {
  6860. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6861. }
  6862. var bytes = this.bytes;
  6863. var start = pos;
  6864. var format = bytes[pos++];
  6865. var charset = ['.notdef'];
  6866. var id, count, i;
  6867. length -= 1;
  6868. switch (format) {
  6869. case 0:
  6870. for (i = 0; i < length; i++) {
  6871. id = bytes[pos++] << 8 | bytes[pos++];
  6872. charset.push(cid ? id : strings.get(id));
  6873. }
  6874. break;
  6875. case 1:
  6876. while (charset.length <= length) {
  6877. id = bytes[pos++] << 8 | bytes[pos++];
  6878. count = bytes[pos++];
  6879. for (i = 0; i <= count; i++) {
  6880. charset.push(cid ? id++ : strings.get(id++));
  6881. }
  6882. }
  6883. break;
  6884. case 2:
  6885. while (charset.length <= length) {
  6886. id = bytes[pos++] << 8 | bytes[pos++];
  6887. count = bytes[pos++] << 8 | bytes[pos++];
  6888. for (i = 0; i <= count; i++) {
  6889. charset.push(cid ? id++ : strings.get(id++));
  6890. }
  6891. }
  6892. break;
  6893. default:
  6894. error('Unknown charset format');
  6895. }
  6896. var end = pos;
  6897. var raw = bytes.subarray(start, end);
  6898. return new CFFCharset(false, format, charset, raw);
  6899. },
  6900. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6901. var encoding = Object.create(null);
  6902. var bytes = this.bytes;
  6903. var predefined = false;
  6904. var hasSupplement = false;
  6905. var format, i, ii;
  6906. var raw = null;
  6907. function readSupplement() {
  6908. var supplementsCount = bytes[pos++];
  6909. for (i = 0; i < supplementsCount; i++) {
  6910. var code = bytes[pos++];
  6911. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6912. encoding[code] = charset.indexOf(strings.get(sid));
  6913. }
  6914. }
  6915. if (pos === 0 || pos === 1) {
  6916. predefined = true;
  6917. format = pos;
  6918. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6919. for (i = 0, ii = charset.length; i < ii; i++) {
  6920. var index = baseEncoding.indexOf(charset[i]);
  6921. if (index !== -1) {
  6922. encoding[index] = i;
  6923. }
  6924. }
  6925. } else {
  6926. var dataStart = pos;
  6927. format = bytes[pos++];
  6928. switch (format & 0x7f) {
  6929. case 0:
  6930. var glyphsCount = bytes[pos++];
  6931. for (i = 1; i <= glyphsCount; i++) {
  6932. encoding[bytes[pos++]] = i;
  6933. }
  6934. break;
  6935. case 1:
  6936. var rangesCount = bytes[pos++];
  6937. var gid = 1;
  6938. for (i = 0; i < rangesCount; i++) {
  6939. var start = bytes[pos++];
  6940. var left = bytes[pos++];
  6941. for (var j = start; j <= start + left; j++) {
  6942. encoding[j] = gid++;
  6943. }
  6944. }
  6945. break;
  6946. default:
  6947. error('Unknown encoding format: ' + format + ' in CFF');
  6948. break;
  6949. }
  6950. var dataEnd = pos;
  6951. if (format & 0x80) {
  6952. bytes[dataStart] &= 0x7f;
  6953. readSupplement();
  6954. hasSupplement = true;
  6955. }
  6956. raw = bytes.subarray(dataStart, dataEnd);
  6957. }
  6958. format = format & 0x7f;
  6959. return new CFFEncoding(predefined, format, encoding, raw);
  6960. },
  6961. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6962. var start = pos;
  6963. var bytes = this.bytes;
  6964. var format = bytes[pos++];
  6965. var fdSelect = [], rawBytes;
  6966. var i, invalidFirstGID = false;
  6967. switch (format) {
  6968. case 0:
  6969. for (i = 0; i < length; ++i) {
  6970. var id = bytes[pos++];
  6971. fdSelect.push(id);
  6972. }
  6973. rawBytes = bytes.subarray(start, pos);
  6974. break;
  6975. case 3:
  6976. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6977. for (i = 0; i < rangesCount; ++i) {
  6978. var first = bytes[pos++] << 8 | bytes[pos++];
  6979. if (i === 0 && first !== 0) {
  6980. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6981. invalidFirstGID = true;
  6982. first = 0;
  6983. }
  6984. var fdIndex = bytes[pos++];
  6985. var next = bytes[pos] << 8 | bytes[pos + 1];
  6986. for (var j = first; j < next; ++j) {
  6987. fdSelect.push(fdIndex);
  6988. }
  6989. }
  6990. pos += 2;
  6991. rawBytes = bytes.subarray(start, pos);
  6992. if (invalidFirstGID) {
  6993. rawBytes[3] = rawBytes[4] = 0;
  6994. }
  6995. break;
  6996. default:
  6997. error('parseFDSelect: Unknown format "' + format + '".');
  6998. break;
  6999. }
  7000. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  7001. return new CFFFDSelect(fdSelect, rawBytes);
  7002. }
  7003. };
  7004. return CFFParser;
  7005. }();
  7006. var CFF = function CFFClosure() {
  7007. function CFF() {
  7008. this.header = null;
  7009. this.names = [];
  7010. this.topDict = null;
  7011. this.strings = new CFFStrings();
  7012. this.globalSubrIndex = null;
  7013. this.encoding = null;
  7014. this.charset = null;
  7015. this.charStrings = null;
  7016. this.fdArray = [];
  7017. this.fdSelect = null;
  7018. this.isCIDFont = false;
  7019. }
  7020. return CFF;
  7021. }();
  7022. var CFFHeader = function CFFHeaderClosure() {
  7023. function CFFHeader(major, minor, hdrSize, offSize) {
  7024. this.major = major;
  7025. this.minor = minor;
  7026. this.hdrSize = hdrSize;
  7027. this.offSize = offSize;
  7028. }
  7029. return CFFHeader;
  7030. }();
  7031. var CFFStrings = function CFFStringsClosure() {
  7032. function CFFStrings() {
  7033. this.strings = [];
  7034. }
  7035. CFFStrings.prototype = {
  7036. get: function CFFStrings_get(index) {
  7037. if (index >= 0 && index <= 390) {
  7038. return CFFStandardStrings[index];
  7039. }
  7040. if (index - 391 <= this.strings.length) {
  7041. return this.strings[index - 391];
  7042. }
  7043. return CFFStandardStrings[0];
  7044. },
  7045. add: function CFFStrings_add(value) {
  7046. this.strings.push(value);
  7047. },
  7048. get count() {
  7049. return this.strings.length;
  7050. }
  7051. };
  7052. return CFFStrings;
  7053. }();
  7054. var CFFIndex = function CFFIndexClosure() {
  7055. function CFFIndex() {
  7056. this.objects = [];
  7057. this.length = 0;
  7058. }
  7059. CFFIndex.prototype = {
  7060. add: function CFFIndex_add(data) {
  7061. this.length += data.length;
  7062. this.objects.push(data);
  7063. },
  7064. set: function CFFIndex_set(index, data) {
  7065. this.length += data.length - this.objects[index].length;
  7066. this.objects[index] = data;
  7067. },
  7068. get: function CFFIndex_get(index) {
  7069. return this.objects[index];
  7070. },
  7071. get count() {
  7072. return this.objects.length;
  7073. }
  7074. };
  7075. return CFFIndex;
  7076. }();
  7077. var CFFDict = function CFFDictClosure() {
  7078. function CFFDict(tables, strings) {
  7079. this.keyToNameMap = tables.keyToNameMap;
  7080. this.nameToKeyMap = tables.nameToKeyMap;
  7081. this.defaults = tables.defaults;
  7082. this.types = tables.types;
  7083. this.opcodes = tables.opcodes;
  7084. this.order = tables.order;
  7085. this.strings = strings;
  7086. this.values = Object.create(null);
  7087. }
  7088. CFFDict.prototype = {
  7089. setByKey: function CFFDict_setByKey(key, value) {
  7090. if (!(key in this.keyToNameMap)) {
  7091. return false;
  7092. }
  7093. var valueLength = value.length;
  7094. if (valueLength === 0) {
  7095. return true;
  7096. }
  7097. for (var i = 0; i < valueLength; i++) {
  7098. if (isNaN(value[i])) {
  7099. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7100. return true;
  7101. }
  7102. }
  7103. var type = this.types[key];
  7104. if (type === 'num' || type === 'sid' || type === 'offset') {
  7105. value = value[0];
  7106. }
  7107. this.values[key] = value;
  7108. return true;
  7109. },
  7110. setByName: function CFFDict_setByName(name, value) {
  7111. if (!(name in this.nameToKeyMap)) {
  7112. error('Invalid dictionary name "' + name + '"');
  7113. }
  7114. this.values[this.nameToKeyMap[name]] = value;
  7115. },
  7116. hasName: function CFFDict_hasName(name) {
  7117. return this.nameToKeyMap[name] in this.values;
  7118. },
  7119. getByName: function CFFDict_getByName(name) {
  7120. if (!(name in this.nameToKeyMap)) {
  7121. error('Invalid dictionary name "' + name + '"');
  7122. }
  7123. var key = this.nameToKeyMap[name];
  7124. if (!(key in this.values)) {
  7125. return this.defaults[key];
  7126. }
  7127. return this.values[key];
  7128. },
  7129. removeByName: function CFFDict_removeByName(name) {
  7130. delete this.values[this.nameToKeyMap[name]];
  7131. }
  7132. };
  7133. CFFDict.createTables = function CFFDict_createTables(layout) {
  7134. var tables = {
  7135. keyToNameMap: {},
  7136. nameToKeyMap: {},
  7137. defaults: {},
  7138. types: {},
  7139. opcodes: {},
  7140. order: []
  7141. };
  7142. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7143. var entry = layout[i];
  7144. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7145. tables.keyToNameMap[key] = entry[1];
  7146. tables.nameToKeyMap[entry[1]] = key;
  7147. tables.types[key] = entry[2];
  7148. tables.defaults[key] = entry[3];
  7149. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7150. tables.order.push(key);
  7151. }
  7152. return tables;
  7153. };
  7154. return CFFDict;
  7155. }();
  7156. var CFFTopDict = function CFFTopDictClosure() {
  7157. var layout = [
  7158. [
  7159. [
  7160. 12,
  7161. 30
  7162. ],
  7163. 'ROS',
  7164. [
  7165. 'sid',
  7166. 'sid',
  7167. 'num'
  7168. ],
  7169. null
  7170. ],
  7171. [
  7172. [
  7173. 12,
  7174. 20
  7175. ],
  7176. 'SyntheticBase',
  7177. 'num',
  7178. null
  7179. ],
  7180. [
  7181. 0,
  7182. 'version',
  7183. 'sid',
  7184. null
  7185. ],
  7186. [
  7187. 1,
  7188. 'Notice',
  7189. 'sid',
  7190. null
  7191. ],
  7192. [
  7193. [
  7194. 12,
  7195. 0
  7196. ],
  7197. 'Copyright',
  7198. 'sid',
  7199. null
  7200. ],
  7201. [
  7202. 2,
  7203. 'FullName',
  7204. 'sid',
  7205. null
  7206. ],
  7207. [
  7208. 3,
  7209. 'FamilyName',
  7210. 'sid',
  7211. null
  7212. ],
  7213. [
  7214. 4,
  7215. 'Weight',
  7216. 'sid',
  7217. null
  7218. ],
  7219. [
  7220. [
  7221. 12,
  7222. 1
  7223. ],
  7224. 'isFixedPitch',
  7225. 'num',
  7226. 0
  7227. ],
  7228. [
  7229. [
  7230. 12,
  7231. 2
  7232. ],
  7233. 'ItalicAngle',
  7234. 'num',
  7235. 0
  7236. ],
  7237. [
  7238. [
  7239. 12,
  7240. 3
  7241. ],
  7242. 'UnderlinePosition',
  7243. 'num',
  7244. -100
  7245. ],
  7246. [
  7247. [
  7248. 12,
  7249. 4
  7250. ],
  7251. 'UnderlineThickness',
  7252. 'num',
  7253. 50
  7254. ],
  7255. [
  7256. [
  7257. 12,
  7258. 5
  7259. ],
  7260. 'PaintType',
  7261. 'num',
  7262. 0
  7263. ],
  7264. [
  7265. [
  7266. 12,
  7267. 6
  7268. ],
  7269. 'CharstringType',
  7270. 'num',
  7271. 2
  7272. ],
  7273. [
  7274. [
  7275. 12,
  7276. 7
  7277. ],
  7278. 'FontMatrix',
  7279. [
  7280. 'num',
  7281. 'num',
  7282. 'num',
  7283. 'num',
  7284. 'num',
  7285. 'num'
  7286. ],
  7287. [
  7288. 0.001,
  7289. 0,
  7290. 0,
  7291. 0.001,
  7292. 0,
  7293. 0
  7294. ]
  7295. ],
  7296. [
  7297. 13,
  7298. 'UniqueID',
  7299. 'num',
  7300. null
  7301. ],
  7302. [
  7303. 5,
  7304. 'FontBBox',
  7305. [
  7306. 'num',
  7307. 'num',
  7308. 'num',
  7309. 'num'
  7310. ],
  7311. [
  7312. 0,
  7313. 0,
  7314. 0,
  7315. 0
  7316. ]
  7317. ],
  7318. [
  7319. [
  7320. 12,
  7321. 8
  7322. ],
  7323. 'StrokeWidth',
  7324. 'num',
  7325. 0
  7326. ],
  7327. [
  7328. 14,
  7329. 'XUID',
  7330. 'array',
  7331. null
  7332. ],
  7333. [
  7334. 15,
  7335. 'charset',
  7336. 'offset',
  7337. 0
  7338. ],
  7339. [
  7340. 16,
  7341. 'Encoding',
  7342. 'offset',
  7343. 0
  7344. ],
  7345. [
  7346. 17,
  7347. 'CharStrings',
  7348. 'offset',
  7349. 0
  7350. ],
  7351. [
  7352. 18,
  7353. 'Private',
  7354. [
  7355. 'offset',
  7356. 'offset'
  7357. ],
  7358. null
  7359. ],
  7360. [
  7361. [
  7362. 12,
  7363. 21
  7364. ],
  7365. 'PostScript',
  7366. 'sid',
  7367. null
  7368. ],
  7369. [
  7370. [
  7371. 12,
  7372. 22
  7373. ],
  7374. 'BaseFontName',
  7375. 'sid',
  7376. null
  7377. ],
  7378. [
  7379. [
  7380. 12,
  7381. 23
  7382. ],
  7383. 'BaseFontBlend',
  7384. 'delta',
  7385. null
  7386. ],
  7387. [
  7388. [
  7389. 12,
  7390. 31
  7391. ],
  7392. 'CIDFontVersion',
  7393. 'num',
  7394. 0
  7395. ],
  7396. [
  7397. [
  7398. 12,
  7399. 32
  7400. ],
  7401. 'CIDFontRevision',
  7402. 'num',
  7403. 0
  7404. ],
  7405. [
  7406. [
  7407. 12,
  7408. 33
  7409. ],
  7410. 'CIDFontType',
  7411. 'num',
  7412. 0
  7413. ],
  7414. [
  7415. [
  7416. 12,
  7417. 34
  7418. ],
  7419. 'CIDCount',
  7420. 'num',
  7421. 8720
  7422. ],
  7423. [
  7424. [
  7425. 12,
  7426. 35
  7427. ],
  7428. 'UIDBase',
  7429. 'num',
  7430. null
  7431. ],
  7432. [
  7433. [
  7434. 12,
  7435. 37
  7436. ],
  7437. 'FDSelect',
  7438. 'offset',
  7439. null
  7440. ],
  7441. [
  7442. [
  7443. 12,
  7444. 36
  7445. ],
  7446. 'FDArray',
  7447. 'offset',
  7448. null
  7449. ],
  7450. [
  7451. [
  7452. 12,
  7453. 38
  7454. ],
  7455. 'FontName',
  7456. 'sid',
  7457. null
  7458. ]
  7459. ];
  7460. var tables = null;
  7461. function CFFTopDict(strings) {
  7462. if (tables === null) {
  7463. tables = CFFDict.createTables(layout);
  7464. }
  7465. CFFDict.call(this, tables, strings);
  7466. this.privateDict = null;
  7467. }
  7468. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7469. return CFFTopDict;
  7470. }();
  7471. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7472. var layout = [
  7473. [
  7474. 6,
  7475. 'BlueValues',
  7476. 'delta',
  7477. null
  7478. ],
  7479. [
  7480. 7,
  7481. 'OtherBlues',
  7482. 'delta',
  7483. null
  7484. ],
  7485. [
  7486. 8,
  7487. 'FamilyBlues',
  7488. 'delta',
  7489. null
  7490. ],
  7491. [
  7492. 9,
  7493. 'FamilyOtherBlues',
  7494. 'delta',
  7495. null
  7496. ],
  7497. [
  7498. [
  7499. 12,
  7500. 9
  7501. ],
  7502. 'BlueScale',
  7503. 'num',
  7504. 0.039625
  7505. ],
  7506. [
  7507. [
  7508. 12,
  7509. 10
  7510. ],
  7511. 'BlueShift',
  7512. 'num',
  7513. 7
  7514. ],
  7515. [
  7516. [
  7517. 12,
  7518. 11
  7519. ],
  7520. 'BlueFuzz',
  7521. 'num',
  7522. 1
  7523. ],
  7524. [
  7525. 10,
  7526. 'StdHW',
  7527. 'num',
  7528. null
  7529. ],
  7530. [
  7531. 11,
  7532. 'StdVW',
  7533. 'num',
  7534. null
  7535. ],
  7536. [
  7537. [
  7538. 12,
  7539. 12
  7540. ],
  7541. 'StemSnapH',
  7542. 'delta',
  7543. null
  7544. ],
  7545. [
  7546. [
  7547. 12,
  7548. 13
  7549. ],
  7550. 'StemSnapV',
  7551. 'delta',
  7552. null
  7553. ],
  7554. [
  7555. [
  7556. 12,
  7557. 14
  7558. ],
  7559. 'ForceBold',
  7560. 'num',
  7561. 0
  7562. ],
  7563. [
  7564. [
  7565. 12,
  7566. 17
  7567. ],
  7568. 'LanguageGroup',
  7569. 'num',
  7570. 0
  7571. ],
  7572. [
  7573. [
  7574. 12,
  7575. 18
  7576. ],
  7577. 'ExpansionFactor',
  7578. 'num',
  7579. 0.06
  7580. ],
  7581. [
  7582. [
  7583. 12,
  7584. 19
  7585. ],
  7586. 'initialRandomSeed',
  7587. 'num',
  7588. 0
  7589. ],
  7590. [
  7591. 20,
  7592. 'defaultWidthX',
  7593. 'num',
  7594. 0
  7595. ],
  7596. [
  7597. 21,
  7598. 'nominalWidthX',
  7599. 'num',
  7600. 0
  7601. ],
  7602. [
  7603. 19,
  7604. 'Subrs',
  7605. 'offset',
  7606. null
  7607. ]
  7608. ];
  7609. var tables = null;
  7610. function CFFPrivateDict(strings) {
  7611. if (tables === null) {
  7612. tables = CFFDict.createTables(layout);
  7613. }
  7614. CFFDict.call(this, tables, strings);
  7615. this.subrsIndex = null;
  7616. }
  7617. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7618. return CFFPrivateDict;
  7619. }();
  7620. var CFFCharsetPredefinedTypes = {
  7621. ISO_ADOBE: 0,
  7622. EXPERT: 1,
  7623. EXPERT_SUBSET: 2
  7624. };
  7625. var CFFCharset = function CFFCharsetClosure() {
  7626. function CFFCharset(predefined, format, charset, raw) {
  7627. this.predefined = predefined;
  7628. this.format = format;
  7629. this.charset = charset;
  7630. this.raw = raw;
  7631. }
  7632. return CFFCharset;
  7633. }();
  7634. var CFFEncoding = function CFFEncodingClosure() {
  7635. function CFFEncoding(predefined, format, encoding, raw) {
  7636. this.predefined = predefined;
  7637. this.format = format;
  7638. this.encoding = encoding;
  7639. this.raw = raw;
  7640. }
  7641. return CFFEncoding;
  7642. }();
  7643. var CFFFDSelect = function CFFFDSelectClosure() {
  7644. function CFFFDSelect(fdSelect, raw) {
  7645. this.fdSelect = fdSelect;
  7646. this.raw = raw;
  7647. }
  7648. CFFFDSelect.prototype = {
  7649. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7650. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7651. return -1;
  7652. }
  7653. return this.fdSelect[glyphIndex];
  7654. }
  7655. };
  7656. return CFFFDSelect;
  7657. }();
  7658. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7659. function CFFOffsetTracker() {
  7660. this.offsets = Object.create(null);
  7661. }
  7662. CFFOffsetTracker.prototype = {
  7663. isTracking: function CFFOffsetTracker_isTracking(key) {
  7664. return key in this.offsets;
  7665. },
  7666. track: function CFFOffsetTracker_track(key, location) {
  7667. if (key in this.offsets) {
  7668. error('Already tracking location of ' + key);
  7669. }
  7670. this.offsets[key] = location;
  7671. },
  7672. offset: function CFFOffsetTracker_offset(value) {
  7673. for (var key in this.offsets) {
  7674. this.offsets[key] += value;
  7675. }
  7676. },
  7677. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7678. if (!(key in this.offsets)) {
  7679. error('Not tracking location of ' + key);
  7680. }
  7681. var data = output.data;
  7682. var dataOffset = this.offsets[key];
  7683. var size = 5;
  7684. for (var i = 0, ii = values.length; i < ii; ++i) {
  7685. var offset0 = i * size + dataOffset;
  7686. var offset1 = offset0 + 1;
  7687. var offset2 = offset0 + 2;
  7688. var offset3 = offset0 + 3;
  7689. var offset4 = offset0 + 4;
  7690. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7691. error('writing to an offset that is not empty');
  7692. }
  7693. var value = values[i];
  7694. data[offset0] = 0x1d;
  7695. data[offset1] = value >> 24 & 0xFF;
  7696. data[offset2] = value >> 16 & 0xFF;
  7697. data[offset3] = value >> 8 & 0xFF;
  7698. data[offset4] = value & 0xFF;
  7699. }
  7700. }
  7701. };
  7702. return CFFOffsetTracker;
  7703. }();
  7704. var CFFCompiler = function CFFCompilerClosure() {
  7705. function CFFCompiler(cff) {
  7706. this.cff = cff;
  7707. }
  7708. CFFCompiler.prototype = {
  7709. compile: function CFFCompiler_compile() {
  7710. var cff = this.cff;
  7711. var output = {
  7712. data: [],
  7713. length: 0,
  7714. add: function CFFCompiler_add(data) {
  7715. this.data = this.data.concat(data);
  7716. this.length = this.data.length;
  7717. }
  7718. };
  7719. var header = this.compileHeader(cff.header);
  7720. output.add(header);
  7721. var nameIndex = this.compileNameIndex(cff.names);
  7722. output.add(nameIndex);
  7723. if (cff.isCIDFont) {
  7724. if (cff.topDict.hasName('FontMatrix')) {
  7725. var base = cff.topDict.getByName('FontMatrix');
  7726. cff.topDict.removeByName('FontMatrix');
  7727. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7728. var subDict = cff.fdArray[i];
  7729. var matrix = base.slice(0);
  7730. if (subDict.hasName('FontMatrix')) {
  7731. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7732. }
  7733. subDict.setByName('FontMatrix', matrix);
  7734. }
  7735. }
  7736. }
  7737. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7738. output.add(compiled.output);
  7739. var topDictTracker = compiled.trackers[0];
  7740. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7741. output.add(stringIndex);
  7742. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7743. output.add(globalSubrIndex);
  7744. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7745. if (cff.encoding.predefined) {
  7746. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7747. } else {
  7748. var encoding = this.compileEncoding(cff.encoding);
  7749. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7750. output.add(encoding);
  7751. }
  7752. }
  7753. if (cff.charset && cff.topDict.hasName('charset')) {
  7754. if (cff.charset.predefined) {
  7755. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7756. } else {
  7757. var charset = this.compileCharset(cff.charset);
  7758. topDictTracker.setEntryLocation('charset', [output.length], output);
  7759. output.add(charset);
  7760. }
  7761. }
  7762. var charStrings = this.compileCharStrings(cff.charStrings);
  7763. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7764. output.add(charStrings);
  7765. if (cff.isCIDFont) {
  7766. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7767. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7768. output.add(fdSelect);
  7769. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7770. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7771. output.add(compiled.output);
  7772. var fontDictTrackers = compiled.trackers;
  7773. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7774. }
  7775. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7776. output.add([0]);
  7777. return output.data;
  7778. },
  7779. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7780. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7781. return this.encodeInteger(value);
  7782. }
  7783. return this.encodeFloat(value);
  7784. },
  7785. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7786. var value = num.toString();
  7787. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7788. if (m) {
  7789. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7790. value = (Math.round(num * epsilon) / epsilon).toString();
  7791. }
  7792. var nibbles = '';
  7793. var i, ii;
  7794. for (i = 0, ii = value.length; i < ii; ++i) {
  7795. var a = value[i];
  7796. if (a === 'e') {
  7797. nibbles += value[++i] === '-' ? 'c' : 'b';
  7798. } else if (a === '.') {
  7799. nibbles += 'a';
  7800. } else if (a === '-') {
  7801. nibbles += 'e';
  7802. } else {
  7803. nibbles += a;
  7804. }
  7805. }
  7806. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7807. var out = [30];
  7808. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7809. out.push(parseInt(nibbles.substr(i, 2), 16));
  7810. }
  7811. return out;
  7812. },
  7813. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7814. var code;
  7815. if (value >= -107 && value <= 107) {
  7816. code = [value + 139];
  7817. } else if (value >= 108 && value <= 1131) {
  7818. value = value - 108;
  7819. code = [
  7820. (value >> 8) + 247,
  7821. value & 0xFF
  7822. ];
  7823. } else if (value >= -1131 && value <= -108) {
  7824. value = -value - 108;
  7825. code = [
  7826. (value >> 8) + 251,
  7827. value & 0xFF
  7828. ];
  7829. } else if (value >= -32768 && value <= 32767) {
  7830. code = [
  7831. 0x1c,
  7832. value >> 8 & 0xFF,
  7833. value & 0xFF
  7834. ];
  7835. } else {
  7836. code = [
  7837. 0x1d,
  7838. value >> 24 & 0xFF,
  7839. value >> 16 & 0xFF,
  7840. value >> 8 & 0xFF,
  7841. value & 0xFF
  7842. ];
  7843. }
  7844. return code;
  7845. },
  7846. compileHeader: function CFFCompiler_compileHeader(header) {
  7847. return [
  7848. header.major,
  7849. header.minor,
  7850. header.hdrSize,
  7851. header.offSize
  7852. ];
  7853. },
  7854. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7855. var nameIndex = new CFFIndex();
  7856. for (var i = 0, ii = names.length; i < ii; ++i) {
  7857. nameIndex.add(stringToBytes(names[i]));
  7858. }
  7859. return this.compileIndex(nameIndex);
  7860. },
  7861. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7862. var fontDictTrackers = [];
  7863. var fdArrayIndex = new CFFIndex();
  7864. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7865. var fontDict = dicts[i];
  7866. if (removeCidKeys) {
  7867. fontDict.removeByName('CIDFontVersion');
  7868. fontDict.removeByName('CIDFontRevision');
  7869. fontDict.removeByName('CIDFontType');
  7870. fontDict.removeByName('CIDCount');
  7871. fontDict.removeByName('UIDBase');
  7872. }
  7873. var fontDictTracker = new CFFOffsetTracker();
  7874. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7875. fontDictTrackers.push(fontDictTracker);
  7876. fdArrayIndex.add(fontDictData);
  7877. fontDictTracker.offset(length);
  7878. }
  7879. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7880. return {
  7881. trackers: fontDictTrackers,
  7882. output: fdArrayIndex
  7883. };
  7884. },
  7885. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7886. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7887. var fontDict = dicts[i];
  7888. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7889. var privateDict = fontDict.privateDict;
  7890. var privateDictTracker = new CFFOffsetTracker();
  7891. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7892. var outputLength = output.length;
  7893. privateDictTracker.offset(outputLength);
  7894. if (!privateDictData.length) {
  7895. outputLength = 0;
  7896. }
  7897. trackers[i].setEntryLocation('Private', [
  7898. privateDictData.length,
  7899. outputLength
  7900. ], output);
  7901. output.add(privateDictData);
  7902. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7903. var subrs = this.compileIndex(privateDict.subrsIndex);
  7904. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7905. output.add(subrs);
  7906. }
  7907. }
  7908. },
  7909. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7910. var out = [];
  7911. var order = dict.order;
  7912. for (var i = 0; i < order.length; ++i) {
  7913. var key = order[i];
  7914. if (!(key in dict.values)) {
  7915. continue;
  7916. }
  7917. var values = dict.values[key];
  7918. var types = dict.types[key];
  7919. if (!isArray(types)) {
  7920. types = [types];
  7921. }
  7922. if (!isArray(values)) {
  7923. values = [values];
  7924. }
  7925. if (values.length === 0) {
  7926. continue;
  7927. }
  7928. for (var j = 0, jj = types.length; j < jj; ++j) {
  7929. var type = types[j];
  7930. var value = values[j];
  7931. switch (type) {
  7932. case 'num':
  7933. case 'sid':
  7934. out = out.concat(this.encodeNumber(value));
  7935. break;
  7936. case 'offset':
  7937. var name = dict.keyToNameMap[key];
  7938. if (!offsetTracker.isTracking(name)) {
  7939. offsetTracker.track(name, out.length);
  7940. }
  7941. out = out.concat([
  7942. 0x1d,
  7943. 0,
  7944. 0,
  7945. 0,
  7946. 0
  7947. ]);
  7948. break;
  7949. case 'array':
  7950. case 'delta':
  7951. out = out.concat(this.encodeNumber(value));
  7952. for (var k = 1, kk = values.length; k < kk; ++k) {
  7953. out = out.concat(this.encodeNumber(values[k]));
  7954. }
  7955. break;
  7956. default:
  7957. error('Unknown data type of ' + type);
  7958. break;
  7959. }
  7960. }
  7961. out = out.concat(dict.opcodes[key]);
  7962. }
  7963. return out;
  7964. },
  7965. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7966. var stringIndex = new CFFIndex();
  7967. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7968. stringIndex.add(stringToBytes(strings[i]));
  7969. }
  7970. return this.compileIndex(stringIndex);
  7971. },
  7972. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7973. var globalSubrIndex = this.cff.globalSubrIndex;
  7974. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7975. },
  7976. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7977. return this.compileIndex(charStrings);
  7978. },
  7979. compileCharset: function CFFCompiler_compileCharset(charset) {
  7980. return this.compileTypedArray(charset.raw);
  7981. },
  7982. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7983. return this.compileTypedArray(encoding.raw);
  7984. },
  7985. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7986. return this.compileTypedArray(fdSelect);
  7987. },
  7988. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7989. var out = [];
  7990. for (var i = 0, ii = data.length; i < ii; ++i) {
  7991. out[i] = data[i];
  7992. }
  7993. return out;
  7994. },
  7995. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7996. trackers = trackers || [];
  7997. var objects = index.objects;
  7998. var count = objects.length;
  7999. if (count === 0) {
  8000. return [
  8001. 0,
  8002. 0,
  8003. 0
  8004. ];
  8005. }
  8006. var data = [
  8007. count >> 8 & 0xFF,
  8008. count & 0xff
  8009. ];
  8010. var lastOffset = 1, i;
  8011. for (i = 0; i < count; ++i) {
  8012. lastOffset += objects[i].length;
  8013. }
  8014. var offsetSize;
  8015. if (lastOffset < 0x100) {
  8016. offsetSize = 1;
  8017. } else if (lastOffset < 0x10000) {
  8018. offsetSize = 2;
  8019. } else if (lastOffset < 0x1000000) {
  8020. offsetSize = 3;
  8021. } else {
  8022. offsetSize = 4;
  8023. }
  8024. data.push(offsetSize);
  8025. var relativeOffset = 1;
  8026. for (i = 0; i < count + 1; i++) {
  8027. if (offsetSize === 1) {
  8028. data.push(relativeOffset & 0xFF);
  8029. } else if (offsetSize === 2) {
  8030. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8031. } else if (offsetSize === 3) {
  8032. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. } else {
  8034. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8035. }
  8036. if (objects[i]) {
  8037. relativeOffset += objects[i].length;
  8038. }
  8039. }
  8040. for (i = 0; i < count; i++) {
  8041. if (trackers[i]) {
  8042. trackers[i].offset(data.length);
  8043. }
  8044. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8045. data.push(objects[i][j]);
  8046. }
  8047. }
  8048. return data;
  8049. }
  8050. };
  8051. return CFFCompiler;
  8052. }();
  8053. exports.CFFStandardStrings = CFFStandardStrings;
  8054. exports.CFFParser = CFFParser;
  8055. exports.CFF = CFF;
  8056. exports.CFFHeader = CFFHeader;
  8057. exports.CFFStrings = CFFStrings;
  8058. exports.CFFIndex = CFFIndex;
  8059. exports.CFFCharset = CFFCharset;
  8060. exports.CFFTopDict = CFFTopDict;
  8061. exports.CFFPrivateDict = CFFPrivateDict;
  8062. exports.CFFCompiler = CFFCompiler;
  8063. }));
  8064. (function (root, factory) {
  8065. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8066. }(this, function (exports, sharedUtil) {
  8067. var MissingDataException = sharedUtil.MissingDataException;
  8068. var arrayByteLength = sharedUtil.arrayByteLength;
  8069. var arraysToBytes = sharedUtil.arraysToBytes;
  8070. var assert = sharedUtil.assert;
  8071. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8072. var isInt = sharedUtil.isInt;
  8073. var isEmptyObj = sharedUtil.isEmptyObj;
  8074. var ChunkedStream = function ChunkedStreamClosure() {
  8075. function ChunkedStream(length, chunkSize, manager) {
  8076. this.bytes = new Uint8Array(length);
  8077. this.start = 0;
  8078. this.pos = 0;
  8079. this.end = length;
  8080. this.chunkSize = chunkSize;
  8081. this.loadedChunks = [];
  8082. this.numChunksLoaded = 0;
  8083. this.numChunks = Math.ceil(length / chunkSize);
  8084. this.manager = manager;
  8085. this.progressiveDataLength = 0;
  8086. this.lastSuccessfulEnsureByteChunk = -1;
  8087. }
  8088. ChunkedStream.prototype = {
  8089. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8090. var chunks = [];
  8091. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8092. if (!this.loadedChunks[chunk]) {
  8093. chunks.push(chunk);
  8094. }
  8095. }
  8096. return chunks;
  8097. },
  8098. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8099. return [this];
  8100. },
  8101. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8102. return this.numChunksLoaded === this.numChunks;
  8103. },
  8104. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8105. var end = begin + chunk.byteLength;
  8106. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8107. var length = this.bytes.length;
  8108. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8109. this.bytes.set(new Uint8Array(chunk), begin);
  8110. var chunkSize = this.chunkSize;
  8111. var beginChunk = Math.floor(begin / chunkSize);
  8112. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8113. var curChunk;
  8114. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8115. if (!this.loadedChunks[curChunk]) {
  8116. this.loadedChunks[curChunk] = true;
  8117. ++this.numChunksLoaded;
  8118. }
  8119. }
  8120. },
  8121. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8122. var position = this.progressiveDataLength;
  8123. var beginChunk = Math.floor(position / this.chunkSize);
  8124. this.bytes.set(new Uint8Array(data), position);
  8125. position += data.byteLength;
  8126. this.progressiveDataLength = position;
  8127. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8128. var curChunk;
  8129. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8130. if (!this.loadedChunks[curChunk]) {
  8131. this.loadedChunks[curChunk] = true;
  8132. ++this.numChunksLoaded;
  8133. }
  8134. }
  8135. },
  8136. ensureByte: function ChunkedStream_ensureByte(pos) {
  8137. var chunk = Math.floor(pos / this.chunkSize);
  8138. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8139. return;
  8140. }
  8141. if (!this.loadedChunks[chunk]) {
  8142. throw new MissingDataException(pos, pos + 1);
  8143. }
  8144. this.lastSuccessfulEnsureByteChunk = chunk;
  8145. },
  8146. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8147. if (begin >= end) {
  8148. return;
  8149. }
  8150. if (end <= this.progressiveDataLength) {
  8151. return;
  8152. }
  8153. var chunkSize = this.chunkSize;
  8154. var beginChunk = Math.floor(begin / chunkSize);
  8155. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8156. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8157. if (!this.loadedChunks[chunk]) {
  8158. throw new MissingDataException(begin, end);
  8159. }
  8160. }
  8161. },
  8162. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8163. var chunk, numChunks = this.numChunks;
  8164. for (var i = 0; i < numChunks; ++i) {
  8165. chunk = (beginChunk + i) % numChunks;
  8166. if (!this.loadedChunks[chunk]) {
  8167. return chunk;
  8168. }
  8169. }
  8170. return null;
  8171. },
  8172. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8173. return !!this.loadedChunks[chunk];
  8174. },
  8175. get length() {
  8176. return this.end - this.start;
  8177. },
  8178. get isEmpty() {
  8179. return this.length === 0;
  8180. },
  8181. getByte: function ChunkedStream_getByte() {
  8182. var pos = this.pos;
  8183. if (pos >= this.end) {
  8184. return -1;
  8185. }
  8186. this.ensureByte(pos);
  8187. return this.bytes[this.pos++];
  8188. },
  8189. getUint16: function ChunkedStream_getUint16() {
  8190. var b0 = this.getByte();
  8191. var b1 = this.getByte();
  8192. if (b0 === -1 || b1 === -1) {
  8193. return -1;
  8194. }
  8195. return (b0 << 8) + b1;
  8196. },
  8197. getInt32: function ChunkedStream_getInt32() {
  8198. var b0 = this.getByte();
  8199. var b1 = this.getByte();
  8200. var b2 = this.getByte();
  8201. var b3 = this.getByte();
  8202. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8203. },
  8204. getBytes: function ChunkedStream_getBytes(length) {
  8205. var bytes = this.bytes;
  8206. var pos = this.pos;
  8207. var strEnd = this.end;
  8208. if (!length) {
  8209. this.ensureRange(pos, strEnd);
  8210. return bytes.subarray(pos, strEnd);
  8211. }
  8212. var end = pos + length;
  8213. if (end > strEnd) {
  8214. end = strEnd;
  8215. }
  8216. this.ensureRange(pos, end);
  8217. this.pos = end;
  8218. return bytes.subarray(pos, end);
  8219. },
  8220. peekByte: function ChunkedStream_peekByte() {
  8221. var peekedByte = this.getByte();
  8222. this.pos--;
  8223. return peekedByte;
  8224. },
  8225. peekBytes: function ChunkedStream_peekBytes(length) {
  8226. var bytes = this.getBytes(length);
  8227. this.pos -= bytes.length;
  8228. return bytes;
  8229. },
  8230. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8231. this.ensureRange(begin, end);
  8232. return this.bytes.subarray(begin, end);
  8233. },
  8234. skip: function ChunkedStream_skip(n) {
  8235. if (!n) {
  8236. n = 1;
  8237. }
  8238. this.pos += n;
  8239. },
  8240. reset: function ChunkedStream_reset() {
  8241. this.pos = this.start;
  8242. },
  8243. moveStart: function ChunkedStream_moveStart() {
  8244. this.start = this.pos;
  8245. },
  8246. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8247. this.ensureRange(start, start + length);
  8248. function ChunkedStreamSubstream() {
  8249. }
  8250. ChunkedStreamSubstream.prototype = Object.create(this);
  8251. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8252. var chunkSize = this.chunkSize;
  8253. var beginChunk = Math.floor(this.start / chunkSize);
  8254. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8255. var missingChunks = [];
  8256. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8257. if (!this.loadedChunks[chunk]) {
  8258. missingChunks.push(chunk);
  8259. }
  8260. }
  8261. return missingChunks;
  8262. };
  8263. var subStream = new ChunkedStreamSubstream();
  8264. subStream.pos = subStream.start = start;
  8265. subStream.end = start + length || this.end;
  8266. subStream.dict = dict;
  8267. return subStream;
  8268. },
  8269. isStream: true
  8270. };
  8271. return ChunkedStream;
  8272. }();
  8273. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8274. function ChunkedStreamManager(pdfNetworkStream, args) {
  8275. var chunkSize = args.rangeChunkSize;
  8276. var length = args.length;
  8277. this.stream = new ChunkedStream(length, chunkSize, this);
  8278. this.length = length;
  8279. this.chunkSize = chunkSize;
  8280. this.pdfNetworkStream = pdfNetworkStream;
  8281. this.url = args.url;
  8282. this.disableAutoFetch = args.disableAutoFetch;
  8283. this.msgHandler = args.msgHandler;
  8284. this.currRequestId = 0;
  8285. this.chunksNeededByRequest = Object.create(null);
  8286. this.requestsByChunk = Object.create(null);
  8287. this.promisesByRequest = Object.create(null);
  8288. this.progressiveDataLength = 0;
  8289. this.aborted = false;
  8290. this._loadedStreamCapability = createPromiseCapability();
  8291. }
  8292. ChunkedStreamManager.prototype = {
  8293. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8294. return this._loadedStreamCapability.promise;
  8295. },
  8296. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8297. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8298. if (!rangeReader.isStreamingSupported) {
  8299. rangeReader.onProgress = this.onProgress.bind(this);
  8300. }
  8301. var chunks = [], loaded = 0;
  8302. var manager = this;
  8303. var promise = new Promise(function (resolve, reject) {
  8304. var readChunk = function (chunk) {
  8305. try {
  8306. if (!chunk.done) {
  8307. var data = chunk.value;
  8308. chunks.push(data);
  8309. loaded += arrayByteLength(data);
  8310. if (rangeReader.isStreamingSupported) {
  8311. manager.onProgress({ loaded: loaded });
  8312. }
  8313. rangeReader.read().then(readChunk, reject);
  8314. return;
  8315. }
  8316. var chunkData = arraysToBytes(chunks);
  8317. chunks = null;
  8318. resolve(chunkData);
  8319. } catch (e) {
  8320. reject(e);
  8321. }
  8322. };
  8323. rangeReader.read().then(readChunk, reject);
  8324. });
  8325. promise.then(function (data) {
  8326. if (this.aborted) {
  8327. return;
  8328. }
  8329. this.onReceiveData({
  8330. chunk: data,
  8331. begin: begin
  8332. });
  8333. }.bind(this));
  8334. },
  8335. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8336. var missingChunks = this.stream.getMissingChunks();
  8337. this._requestChunks(missingChunks);
  8338. return this._loadedStreamCapability.promise;
  8339. },
  8340. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8341. var requestId = this.currRequestId++;
  8342. var i, ii;
  8343. var chunksNeeded = Object.create(null);
  8344. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8345. for (i = 0, ii = chunks.length; i < ii; i++) {
  8346. if (!this.stream.hasChunk(chunks[i])) {
  8347. chunksNeeded[chunks[i]] = true;
  8348. }
  8349. }
  8350. if (isEmptyObj(chunksNeeded)) {
  8351. return Promise.resolve();
  8352. }
  8353. var capability = createPromiseCapability();
  8354. this.promisesByRequest[requestId] = capability;
  8355. var chunksToRequest = [];
  8356. for (var chunk in chunksNeeded) {
  8357. chunk = chunk | 0;
  8358. if (!(chunk in this.requestsByChunk)) {
  8359. this.requestsByChunk[chunk] = [];
  8360. chunksToRequest.push(chunk);
  8361. }
  8362. this.requestsByChunk[chunk].push(requestId);
  8363. }
  8364. if (!chunksToRequest.length) {
  8365. return capability.promise;
  8366. }
  8367. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8368. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8369. var groupedChunk = groupedChunksToRequest[i];
  8370. var begin = groupedChunk.beginChunk * this.chunkSize;
  8371. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8372. this.sendRequest(begin, end);
  8373. }
  8374. return capability.promise;
  8375. },
  8376. getStream: function ChunkedStreamManager_getStream() {
  8377. return this.stream;
  8378. },
  8379. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8380. end = Math.min(end, this.length);
  8381. var beginChunk = this.getBeginChunk(begin);
  8382. var endChunk = this.getEndChunk(end);
  8383. var chunks = [];
  8384. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8385. chunks.push(chunk);
  8386. }
  8387. return this._requestChunks(chunks);
  8388. },
  8389. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8390. ranges = ranges || [];
  8391. var chunksToRequest = [];
  8392. for (var i = 0; i < ranges.length; i++) {
  8393. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8394. var endChunk = this.getEndChunk(ranges[i].end);
  8395. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8396. if (chunksToRequest.indexOf(chunk) < 0) {
  8397. chunksToRequest.push(chunk);
  8398. }
  8399. }
  8400. }
  8401. chunksToRequest.sort(function (a, b) {
  8402. return a - b;
  8403. });
  8404. return this._requestChunks(chunksToRequest);
  8405. },
  8406. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8407. var groupedChunks = [];
  8408. var beginChunk = -1;
  8409. var prevChunk = -1;
  8410. for (var i = 0; i < chunks.length; ++i) {
  8411. var chunk = chunks[i];
  8412. if (beginChunk < 0) {
  8413. beginChunk = chunk;
  8414. }
  8415. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8416. groupedChunks.push({
  8417. beginChunk: beginChunk,
  8418. endChunk: prevChunk + 1
  8419. });
  8420. beginChunk = chunk;
  8421. }
  8422. if (i + 1 === chunks.length) {
  8423. groupedChunks.push({
  8424. beginChunk: beginChunk,
  8425. endChunk: chunk + 1
  8426. });
  8427. }
  8428. prevChunk = chunk;
  8429. }
  8430. return groupedChunks;
  8431. },
  8432. onProgress: function ChunkedStreamManager_onProgress(args) {
  8433. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8434. this.msgHandler.send('DocProgress', {
  8435. loaded: bytesLoaded,
  8436. total: this.length
  8437. });
  8438. },
  8439. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8440. var chunk = args.chunk;
  8441. var isProgressive = args.begin === undefined;
  8442. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8443. var end = begin + chunk.byteLength;
  8444. var beginChunk = Math.floor(begin / this.chunkSize);
  8445. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8446. if (isProgressive) {
  8447. this.stream.onReceiveProgressiveData(chunk);
  8448. this.progressiveDataLength = end;
  8449. } else {
  8450. this.stream.onReceiveData(begin, chunk);
  8451. }
  8452. if (this.stream.allChunksLoaded()) {
  8453. this._loadedStreamCapability.resolve(this.stream);
  8454. }
  8455. var loadedRequests = [];
  8456. var i, requestId;
  8457. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8458. var requestIds = this.requestsByChunk[chunk] || [];
  8459. delete this.requestsByChunk[chunk];
  8460. for (i = 0; i < requestIds.length; ++i) {
  8461. requestId = requestIds[i];
  8462. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8463. if (chunk in chunksNeeded) {
  8464. delete chunksNeeded[chunk];
  8465. }
  8466. if (!isEmptyObj(chunksNeeded)) {
  8467. continue;
  8468. }
  8469. loadedRequests.push(requestId);
  8470. }
  8471. }
  8472. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8473. var nextEmptyChunk;
  8474. if (this.stream.numChunksLoaded === 1) {
  8475. var lastChunk = this.stream.numChunks - 1;
  8476. if (!this.stream.hasChunk(lastChunk)) {
  8477. nextEmptyChunk = lastChunk;
  8478. }
  8479. } else {
  8480. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8481. }
  8482. if (isInt(nextEmptyChunk)) {
  8483. this._requestChunks([nextEmptyChunk]);
  8484. }
  8485. }
  8486. for (i = 0; i < loadedRequests.length; ++i) {
  8487. requestId = loadedRequests[i];
  8488. var capability = this.promisesByRequest[requestId];
  8489. delete this.promisesByRequest[requestId];
  8490. capability.resolve();
  8491. }
  8492. this.msgHandler.send('DocProgress', {
  8493. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8494. total: this.length
  8495. });
  8496. },
  8497. onError: function ChunkedStreamManager_onError(err) {
  8498. this._loadedStreamCapability.reject(err);
  8499. },
  8500. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8501. var chunk = Math.floor(begin / this.chunkSize);
  8502. return chunk;
  8503. },
  8504. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8505. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8506. return chunk;
  8507. },
  8508. abort: function ChunkedStreamManager_abort() {
  8509. this.aborted = true;
  8510. if (this.pdfNetworkStream) {
  8511. this.pdfNetworkStream.cancelAllRequests('abort');
  8512. }
  8513. for (var requestId in this.promisesByRequest) {
  8514. var capability = this.promisesByRequest[requestId];
  8515. capability.reject(new Error('Request was aborted'));
  8516. }
  8517. }
  8518. };
  8519. return ChunkedStreamManager;
  8520. }();
  8521. exports.ChunkedStream = ChunkedStream;
  8522. exports.ChunkedStreamManager = ChunkedStreamManager;
  8523. }));
  8524. (function (root, factory) {
  8525. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8526. }(this, function (exports, sharedUtil) {
  8527. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8528. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8529. t['A'] = 0x0041;
  8530. t['AE'] = 0x00C6;
  8531. t['AEacute'] = 0x01FC;
  8532. t['AEmacron'] = 0x01E2;
  8533. t['AEsmall'] = 0xF7E6;
  8534. t['Aacute'] = 0x00C1;
  8535. t['Aacutesmall'] = 0xF7E1;
  8536. t['Abreve'] = 0x0102;
  8537. t['Abreveacute'] = 0x1EAE;
  8538. t['Abrevecyrillic'] = 0x04D0;
  8539. t['Abrevedotbelow'] = 0x1EB6;
  8540. t['Abrevegrave'] = 0x1EB0;
  8541. t['Abrevehookabove'] = 0x1EB2;
  8542. t['Abrevetilde'] = 0x1EB4;
  8543. t['Acaron'] = 0x01CD;
  8544. t['Acircle'] = 0x24B6;
  8545. t['Acircumflex'] = 0x00C2;
  8546. t['Acircumflexacute'] = 0x1EA4;
  8547. t['Acircumflexdotbelow'] = 0x1EAC;
  8548. t['Acircumflexgrave'] = 0x1EA6;
  8549. t['Acircumflexhookabove'] = 0x1EA8;
  8550. t['Acircumflexsmall'] = 0xF7E2;
  8551. t['Acircumflextilde'] = 0x1EAA;
  8552. t['Acute'] = 0xF6C9;
  8553. t['Acutesmall'] = 0xF7B4;
  8554. t['Acyrillic'] = 0x0410;
  8555. t['Adblgrave'] = 0x0200;
  8556. t['Adieresis'] = 0x00C4;
  8557. t['Adieresiscyrillic'] = 0x04D2;
  8558. t['Adieresismacron'] = 0x01DE;
  8559. t['Adieresissmall'] = 0xF7E4;
  8560. t['Adotbelow'] = 0x1EA0;
  8561. t['Adotmacron'] = 0x01E0;
  8562. t['Agrave'] = 0x00C0;
  8563. t['Agravesmall'] = 0xF7E0;
  8564. t['Ahookabove'] = 0x1EA2;
  8565. t['Aiecyrillic'] = 0x04D4;
  8566. t['Ainvertedbreve'] = 0x0202;
  8567. t['Alpha'] = 0x0391;
  8568. t['Alphatonos'] = 0x0386;
  8569. t['Amacron'] = 0x0100;
  8570. t['Amonospace'] = 0xFF21;
  8571. t['Aogonek'] = 0x0104;
  8572. t['Aring'] = 0x00C5;
  8573. t['Aringacute'] = 0x01FA;
  8574. t['Aringbelow'] = 0x1E00;
  8575. t['Aringsmall'] = 0xF7E5;
  8576. t['Asmall'] = 0xF761;
  8577. t['Atilde'] = 0x00C3;
  8578. t['Atildesmall'] = 0xF7E3;
  8579. t['Aybarmenian'] = 0x0531;
  8580. t['B'] = 0x0042;
  8581. t['Bcircle'] = 0x24B7;
  8582. t['Bdotaccent'] = 0x1E02;
  8583. t['Bdotbelow'] = 0x1E04;
  8584. t['Becyrillic'] = 0x0411;
  8585. t['Benarmenian'] = 0x0532;
  8586. t['Beta'] = 0x0392;
  8587. t['Bhook'] = 0x0181;
  8588. t['Blinebelow'] = 0x1E06;
  8589. t['Bmonospace'] = 0xFF22;
  8590. t['Brevesmall'] = 0xF6F4;
  8591. t['Bsmall'] = 0xF762;
  8592. t['Btopbar'] = 0x0182;
  8593. t['C'] = 0x0043;
  8594. t['Caarmenian'] = 0x053E;
  8595. t['Cacute'] = 0x0106;
  8596. t['Caron'] = 0xF6CA;
  8597. t['Caronsmall'] = 0xF6F5;
  8598. t['Ccaron'] = 0x010C;
  8599. t['Ccedilla'] = 0x00C7;
  8600. t['Ccedillaacute'] = 0x1E08;
  8601. t['Ccedillasmall'] = 0xF7E7;
  8602. t['Ccircle'] = 0x24B8;
  8603. t['Ccircumflex'] = 0x0108;
  8604. t['Cdot'] = 0x010A;
  8605. t['Cdotaccent'] = 0x010A;
  8606. t['Cedillasmall'] = 0xF7B8;
  8607. t['Chaarmenian'] = 0x0549;
  8608. t['Cheabkhasiancyrillic'] = 0x04BC;
  8609. t['Checyrillic'] = 0x0427;
  8610. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8611. t['Chedescendercyrillic'] = 0x04B6;
  8612. t['Chedieresiscyrillic'] = 0x04F4;
  8613. t['Cheharmenian'] = 0x0543;
  8614. t['Chekhakassiancyrillic'] = 0x04CB;
  8615. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8616. t['Chi'] = 0x03A7;
  8617. t['Chook'] = 0x0187;
  8618. t['Circumflexsmall'] = 0xF6F6;
  8619. t['Cmonospace'] = 0xFF23;
  8620. t['Coarmenian'] = 0x0551;
  8621. t['Csmall'] = 0xF763;
  8622. t['D'] = 0x0044;
  8623. t['DZ'] = 0x01F1;
  8624. t['DZcaron'] = 0x01C4;
  8625. t['Daarmenian'] = 0x0534;
  8626. t['Dafrican'] = 0x0189;
  8627. t['Dcaron'] = 0x010E;
  8628. t['Dcedilla'] = 0x1E10;
  8629. t['Dcircle'] = 0x24B9;
  8630. t['Dcircumflexbelow'] = 0x1E12;
  8631. t['Dcroat'] = 0x0110;
  8632. t['Ddotaccent'] = 0x1E0A;
  8633. t['Ddotbelow'] = 0x1E0C;
  8634. t['Decyrillic'] = 0x0414;
  8635. t['Deicoptic'] = 0x03EE;
  8636. t['Delta'] = 0x2206;
  8637. t['Deltagreek'] = 0x0394;
  8638. t['Dhook'] = 0x018A;
  8639. t['Dieresis'] = 0xF6CB;
  8640. t['DieresisAcute'] = 0xF6CC;
  8641. t['DieresisGrave'] = 0xF6CD;
  8642. t['Dieresissmall'] = 0xF7A8;
  8643. t['Digammagreek'] = 0x03DC;
  8644. t['Djecyrillic'] = 0x0402;
  8645. t['Dlinebelow'] = 0x1E0E;
  8646. t['Dmonospace'] = 0xFF24;
  8647. t['Dotaccentsmall'] = 0xF6F7;
  8648. t['Dslash'] = 0x0110;
  8649. t['Dsmall'] = 0xF764;
  8650. t['Dtopbar'] = 0x018B;
  8651. t['Dz'] = 0x01F2;
  8652. t['Dzcaron'] = 0x01C5;
  8653. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8654. t['Dzecyrillic'] = 0x0405;
  8655. t['Dzhecyrillic'] = 0x040F;
  8656. t['E'] = 0x0045;
  8657. t['Eacute'] = 0x00C9;
  8658. t['Eacutesmall'] = 0xF7E9;
  8659. t['Ebreve'] = 0x0114;
  8660. t['Ecaron'] = 0x011A;
  8661. t['Ecedillabreve'] = 0x1E1C;
  8662. t['Echarmenian'] = 0x0535;
  8663. t['Ecircle'] = 0x24BA;
  8664. t['Ecircumflex'] = 0x00CA;
  8665. t['Ecircumflexacute'] = 0x1EBE;
  8666. t['Ecircumflexbelow'] = 0x1E18;
  8667. t['Ecircumflexdotbelow'] = 0x1EC6;
  8668. t['Ecircumflexgrave'] = 0x1EC0;
  8669. t['Ecircumflexhookabove'] = 0x1EC2;
  8670. t['Ecircumflexsmall'] = 0xF7EA;
  8671. t['Ecircumflextilde'] = 0x1EC4;
  8672. t['Ecyrillic'] = 0x0404;
  8673. t['Edblgrave'] = 0x0204;
  8674. t['Edieresis'] = 0x00CB;
  8675. t['Edieresissmall'] = 0xF7EB;
  8676. t['Edot'] = 0x0116;
  8677. t['Edotaccent'] = 0x0116;
  8678. t['Edotbelow'] = 0x1EB8;
  8679. t['Efcyrillic'] = 0x0424;
  8680. t['Egrave'] = 0x00C8;
  8681. t['Egravesmall'] = 0xF7E8;
  8682. t['Eharmenian'] = 0x0537;
  8683. t['Ehookabove'] = 0x1EBA;
  8684. t['Eightroman'] = 0x2167;
  8685. t['Einvertedbreve'] = 0x0206;
  8686. t['Eiotifiedcyrillic'] = 0x0464;
  8687. t['Elcyrillic'] = 0x041B;
  8688. t['Elevenroman'] = 0x216A;
  8689. t['Emacron'] = 0x0112;
  8690. t['Emacronacute'] = 0x1E16;
  8691. t['Emacrongrave'] = 0x1E14;
  8692. t['Emcyrillic'] = 0x041C;
  8693. t['Emonospace'] = 0xFF25;
  8694. t['Encyrillic'] = 0x041D;
  8695. t['Endescendercyrillic'] = 0x04A2;
  8696. t['Eng'] = 0x014A;
  8697. t['Enghecyrillic'] = 0x04A4;
  8698. t['Enhookcyrillic'] = 0x04C7;
  8699. t['Eogonek'] = 0x0118;
  8700. t['Eopen'] = 0x0190;
  8701. t['Epsilon'] = 0x0395;
  8702. t['Epsilontonos'] = 0x0388;
  8703. t['Ercyrillic'] = 0x0420;
  8704. t['Ereversed'] = 0x018E;
  8705. t['Ereversedcyrillic'] = 0x042D;
  8706. t['Escyrillic'] = 0x0421;
  8707. t['Esdescendercyrillic'] = 0x04AA;
  8708. t['Esh'] = 0x01A9;
  8709. t['Esmall'] = 0xF765;
  8710. t['Eta'] = 0x0397;
  8711. t['Etarmenian'] = 0x0538;
  8712. t['Etatonos'] = 0x0389;
  8713. t['Eth'] = 0x00D0;
  8714. t['Ethsmall'] = 0xF7F0;
  8715. t['Etilde'] = 0x1EBC;
  8716. t['Etildebelow'] = 0x1E1A;
  8717. t['Euro'] = 0x20AC;
  8718. t['Ezh'] = 0x01B7;
  8719. t['Ezhcaron'] = 0x01EE;
  8720. t['Ezhreversed'] = 0x01B8;
  8721. t['F'] = 0x0046;
  8722. t['Fcircle'] = 0x24BB;
  8723. t['Fdotaccent'] = 0x1E1E;
  8724. t['Feharmenian'] = 0x0556;
  8725. t['Feicoptic'] = 0x03E4;
  8726. t['Fhook'] = 0x0191;
  8727. t['Fitacyrillic'] = 0x0472;
  8728. t['Fiveroman'] = 0x2164;
  8729. t['Fmonospace'] = 0xFF26;
  8730. t['Fourroman'] = 0x2163;
  8731. t['Fsmall'] = 0xF766;
  8732. t['G'] = 0x0047;
  8733. t['GBsquare'] = 0x3387;
  8734. t['Gacute'] = 0x01F4;
  8735. t['Gamma'] = 0x0393;
  8736. t['Gammaafrican'] = 0x0194;
  8737. t['Gangiacoptic'] = 0x03EA;
  8738. t['Gbreve'] = 0x011E;
  8739. t['Gcaron'] = 0x01E6;
  8740. t['Gcedilla'] = 0x0122;
  8741. t['Gcircle'] = 0x24BC;
  8742. t['Gcircumflex'] = 0x011C;
  8743. t['Gcommaaccent'] = 0x0122;
  8744. t['Gdot'] = 0x0120;
  8745. t['Gdotaccent'] = 0x0120;
  8746. t['Gecyrillic'] = 0x0413;
  8747. t['Ghadarmenian'] = 0x0542;
  8748. t['Ghemiddlehookcyrillic'] = 0x0494;
  8749. t['Ghestrokecyrillic'] = 0x0492;
  8750. t['Gheupturncyrillic'] = 0x0490;
  8751. t['Ghook'] = 0x0193;
  8752. t['Gimarmenian'] = 0x0533;
  8753. t['Gjecyrillic'] = 0x0403;
  8754. t['Gmacron'] = 0x1E20;
  8755. t['Gmonospace'] = 0xFF27;
  8756. t['Grave'] = 0xF6CE;
  8757. t['Gravesmall'] = 0xF760;
  8758. t['Gsmall'] = 0xF767;
  8759. t['Gsmallhook'] = 0x029B;
  8760. t['Gstroke'] = 0x01E4;
  8761. t['H'] = 0x0048;
  8762. t['H18533'] = 0x25CF;
  8763. t['H18543'] = 0x25AA;
  8764. t['H18551'] = 0x25AB;
  8765. t['H22073'] = 0x25A1;
  8766. t['HPsquare'] = 0x33CB;
  8767. t['Haabkhasiancyrillic'] = 0x04A8;
  8768. t['Hadescendercyrillic'] = 0x04B2;
  8769. t['Hardsigncyrillic'] = 0x042A;
  8770. t['Hbar'] = 0x0126;
  8771. t['Hbrevebelow'] = 0x1E2A;
  8772. t['Hcedilla'] = 0x1E28;
  8773. t['Hcircle'] = 0x24BD;
  8774. t['Hcircumflex'] = 0x0124;
  8775. t['Hdieresis'] = 0x1E26;
  8776. t['Hdotaccent'] = 0x1E22;
  8777. t['Hdotbelow'] = 0x1E24;
  8778. t['Hmonospace'] = 0xFF28;
  8779. t['Hoarmenian'] = 0x0540;
  8780. t['Horicoptic'] = 0x03E8;
  8781. t['Hsmall'] = 0xF768;
  8782. t['Hungarumlaut'] = 0xF6CF;
  8783. t['Hungarumlautsmall'] = 0xF6F8;
  8784. t['Hzsquare'] = 0x3390;
  8785. t['I'] = 0x0049;
  8786. t['IAcyrillic'] = 0x042F;
  8787. t['IJ'] = 0x0132;
  8788. t['IUcyrillic'] = 0x042E;
  8789. t['Iacute'] = 0x00CD;
  8790. t['Iacutesmall'] = 0xF7ED;
  8791. t['Ibreve'] = 0x012C;
  8792. t['Icaron'] = 0x01CF;
  8793. t['Icircle'] = 0x24BE;
  8794. t['Icircumflex'] = 0x00CE;
  8795. t['Icircumflexsmall'] = 0xF7EE;
  8796. t['Icyrillic'] = 0x0406;
  8797. t['Idblgrave'] = 0x0208;
  8798. t['Idieresis'] = 0x00CF;
  8799. t['Idieresisacute'] = 0x1E2E;
  8800. t['Idieresiscyrillic'] = 0x04E4;
  8801. t['Idieresissmall'] = 0xF7EF;
  8802. t['Idot'] = 0x0130;
  8803. t['Idotaccent'] = 0x0130;
  8804. t['Idotbelow'] = 0x1ECA;
  8805. t['Iebrevecyrillic'] = 0x04D6;
  8806. t['Iecyrillic'] = 0x0415;
  8807. t['Ifraktur'] = 0x2111;
  8808. t['Igrave'] = 0x00CC;
  8809. t['Igravesmall'] = 0xF7EC;
  8810. t['Ihookabove'] = 0x1EC8;
  8811. t['Iicyrillic'] = 0x0418;
  8812. t['Iinvertedbreve'] = 0x020A;
  8813. t['Iishortcyrillic'] = 0x0419;
  8814. t['Imacron'] = 0x012A;
  8815. t['Imacroncyrillic'] = 0x04E2;
  8816. t['Imonospace'] = 0xFF29;
  8817. t['Iniarmenian'] = 0x053B;
  8818. t['Iocyrillic'] = 0x0401;
  8819. t['Iogonek'] = 0x012E;
  8820. t['Iota'] = 0x0399;
  8821. t['Iotaafrican'] = 0x0196;
  8822. t['Iotadieresis'] = 0x03AA;
  8823. t['Iotatonos'] = 0x038A;
  8824. t['Ismall'] = 0xF769;
  8825. t['Istroke'] = 0x0197;
  8826. t['Itilde'] = 0x0128;
  8827. t['Itildebelow'] = 0x1E2C;
  8828. t['Izhitsacyrillic'] = 0x0474;
  8829. t['Izhitsadblgravecyrillic'] = 0x0476;
  8830. t['J'] = 0x004A;
  8831. t['Jaarmenian'] = 0x0541;
  8832. t['Jcircle'] = 0x24BF;
  8833. t['Jcircumflex'] = 0x0134;
  8834. t['Jecyrillic'] = 0x0408;
  8835. t['Jheharmenian'] = 0x054B;
  8836. t['Jmonospace'] = 0xFF2A;
  8837. t['Jsmall'] = 0xF76A;
  8838. t['K'] = 0x004B;
  8839. t['KBsquare'] = 0x3385;
  8840. t['KKsquare'] = 0x33CD;
  8841. t['Kabashkircyrillic'] = 0x04A0;
  8842. t['Kacute'] = 0x1E30;
  8843. t['Kacyrillic'] = 0x041A;
  8844. t['Kadescendercyrillic'] = 0x049A;
  8845. t['Kahookcyrillic'] = 0x04C3;
  8846. t['Kappa'] = 0x039A;
  8847. t['Kastrokecyrillic'] = 0x049E;
  8848. t['Kaverticalstrokecyrillic'] = 0x049C;
  8849. t['Kcaron'] = 0x01E8;
  8850. t['Kcedilla'] = 0x0136;
  8851. t['Kcircle'] = 0x24C0;
  8852. t['Kcommaaccent'] = 0x0136;
  8853. t['Kdotbelow'] = 0x1E32;
  8854. t['Keharmenian'] = 0x0554;
  8855. t['Kenarmenian'] = 0x053F;
  8856. t['Khacyrillic'] = 0x0425;
  8857. t['Kheicoptic'] = 0x03E6;
  8858. t['Khook'] = 0x0198;
  8859. t['Kjecyrillic'] = 0x040C;
  8860. t['Klinebelow'] = 0x1E34;
  8861. t['Kmonospace'] = 0xFF2B;
  8862. t['Koppacyrillic'] = 0x0480;
  8863. t['Koppagreek'] = 0x03DE;
  8864. t['Ksicyrillic'] = 0x046E;
  8865. t['Ksmall'] = 0xF76B;
  8866. t['L'] = 0x004C;
  8867. t['LJ'] = 0x01C7;
  8868. t['LL'] = 0xF6BF;
  8869. t['Lacute'] = 0x0139;
  8870. t['Lambda'] = 0x039B;
  8871. t['Lcaron'] = 0x013D;
  8872. t['Lcedilla'] = 0x013B;
  8873. t['Lcircle'] = 0x24C1;
  8874. t['Lcircumflexbelow'] = 0x1E3C;
  8875. t['Lcommaaccent'] = 0x013B;
  8876. t['Ldot'] = 0x013F;
  8877. t['Ldotaccent'] = 0x013F;
  8878. t['Ldotbelow'] = 0x1E36;
  8879. t['Ldotbelowmacron'] = 0x1E38;
  8880. t['Liwnarmenian'] = 0x053C;
  8881. t['Lj'] = 0x01C8;
  8882. t['Ljecyrillic'] = 0x0409;
  8883. t['Llinebelow'] = 0x1E3A;
  8884. t['Lmonospace'] = 0xFF2C;
  8885. t['Lslash'] = 0x0141;
  8886. t['Lslashsmall'] = 0xF6F9;
  8887. t['Lsmall'] = 0xF76C;
  8888. t['M'] = 0x004D;
  8889. t['MBsquare'] = 0x3386;
  8890. t['Macron'] = 0xF6D0;
  8891. t['Macronsmall'] = 0xF7AF;
  8892. t['Macute'] = 0x1E3E;
  8893. t['Mcircle'] = 0x24C2;
  8894. t['Mdotaccent'] = 0x1E40;
  8895. t['Mdotbelow'] = 0x1E42;
  8896. t['Menarmenian'] = 0x0544;
  8897. t['Mmonospace'] = 0xFF2D;
  8898. t['Msmall'] = 0xF76D;
  8899. t['Mturned'] = 0x019C;
  8900. t['Mu'] = 0x039C;
  8901. t['N'] = 0x004E;
  8902. t['NJ'] = 0x01CA;
  8903. t['Nacute'] = 0x0143;
  8904. t['Ncaron'] = 0x0147;
  8905. t['Ncedilla'] = 0x0145;
  8906. t['Ncircle'] = 0x24C3;
  8907. t['Ncircumflexbelow'] = 0x1E4A;
  8908. t['Ncommaaccent'] = 0x0145;
  8909. t['Ndotaccent'] = 0x1E44;
  8910. t['Ndotbelow'] = 0x1E46;
  8911. t['Nhookleft'] = 0x019D;
  8912. t['Nineroman'] = 0x2168;
  8913. t['Nj'] = 0x01CB;
  8914. t['Njecyrillic'] = 0x040A;
  8915. t['Nlinebelow'] = 0x1E48;
  8916. t['Nmonospace'] = 0xFF2E;
  8917. t['Nowarmenian'] = 0x0546;
  8918. t['Nsmall'] = 0xF76E;
  8919. t['Ntilde'] = 0x00D1;
  8920. t['Ntildesmall'] = 0xF7F1;
  8921. t['Nu'] = 0x039D;
  8922. t['O'] = 0x004F;
  8923. t['OE'] = 0x0152;
  8924. t['OEsmall'] = 0xF6FA;
  8925. t['Oacute'] = 0x00D3;
  8926. t['Oacutesmall'] = 0xF7F3;
  8927. t['Obarredcyrillic'] = 0x04E8;
  8928. t['Obarreddieresiscyrillic'] = 0x04EA;
  8929. t['Obreve'] = 0x014E;
  8930. t['Ocaron'] = 0x01D1;
  8931. t['Ocenteredtilde'] = 0x019F;
  8932. t['Ocircle'] = 0x24C4;
  8933. t['Ocircumflex'] = 0x00D4;
  8934. t['Ocircumflexacute'] = 0x1ED0;
  8935. t['Ocircumflexdotbelow'] = 0x1ED8;
  8936. t['Ocircumflexgrave'] = 0x1ED2;
  8937. t['Ocircumflexhookabove'] = 0x1ED4;
  8938. t['Ocircumflexsmall'] = 0xF7F4;
  8939. t['Ocircumflextilde'] = 0x1ED6;
  8940. t['Ocyrillic'] = 0x041E;
  8941. t['Odblacute'] = 0x0150;
  8942. t['Odblgrave'] = 0x020C;
  8943. t['Odieresis'] = 0x00D6;
  8944. t['Odieresiscyrillic'] = 0x04E6;
  8945. t['Odieresissmall'] = 0xF7F6;
  8946. t['Odotbelow'] = 0x1ECC;
  8947. t['Ogoneksmall'] = 0xF6FB;
  8948. t['Ograve'] = 0x00D2;
  8949. t['Ogravesmall'] = 0xF7F2;
  8950. t['Oharmenian'] = 0x0555;
  8951. t['Ohm'] = 0x2126;
  8952. t['Ohookabove'] = 0x1ECE;
  8953. t['Ohorn'] = 0x01A0;
  8954. t['Ohornacute'] = 0x1EDA;
  8955. t['Ohorndotbelow'] = 0x1EE2;
  8956. t['Ohorngrave'] = 0x1EDC;
  8957. t['Ohornhookabove'] = 0x1EDE;
  8958. t['Ohorntilde'] = 0x1EE0;
  8959. t['Ohungarumlaut'] = 0x0150;
  8960. t['Oi'] = 0x01A2;
  8961. t['Oinvertedbreve'] = 0x020E;
  8962. t['Omacron'] = 0x014C;
  8963. t['Omacronacute'] = 0x1E52;
  8964. t['Omacrongrave'] = 0x1E50;
  8965. t['Omega'] = 0x2126;
  8966. t['Omegacyrillic'] = 0x0460;
  8967. t['Omegagreek'] = 0x03A9;
  8968. t['Omegaroundcyrillic'] = 0x047A;
  8969. t['Omegatitlocyrillic'] = 0x047C;
  8970. t['Omegatonos'] = 0x038F;
  8971. t['Omicron'] = 0x039F;
  8972. t['Omicrontonos'] = 0x038C;
  8973. t['Omonospace'] = 0xFF2F;
  8974. t['Oneroman'] = 0x2160;
  8975. t['Oogonek'] = 0x01EA;
  8976. t['Oogonekmacron'] = 0x01EC;
  8977. t['Oopen'] = 0x0186;
  8978. t['Oslash'] = 0x00D8;
  8979. t['Oslashacute'] = 0x01FE;
  8980. t['Oslashsmall'] = 0xF7F8;
  8981. t['Osmall'] = 0xF76F;
  8982. t['Ostrokeacute'] = 0x01FE;
  8983. t['Otcyrillic'] = 0x047E;
  8984. t['Otilde'] = 0x00D5;
  8985. t['Otildeacute'] = 0x1E4C;
  8986. t['Otildedieresis'] = 0x1E4E;
  8987. t['Otildesmall'] = 0xF7F5;
  8988. t['P'] = 0x0050;
  8989. t['Pacute'] = 0x1E54;
  8990. t['Pcircle'] = 0x24C5;
  8991. t['Pdotaccent'] = 0x1E56;
  8992. t['Pecyrillic'] = 0x041F;
  8993. t['Peharmenian'] = 0x054A;
  8994. t['Pemiddlehookcyrillic'] = 0x04A6;
  8995. t['Phi'] = 0x03A6;
  8996. t['Phook'] = 0x01A4;
  8997. t['Pi'] = 0x03A0;
  8998. t['Piwrarmenian'] = 0x0553;
  8999. t['Pmonospace'] = 0xFF30;
  9000. t['Psi'] = 0x03A8;
  9001. t['Psicyrillic'] = 0x0470;
  9002. t['Psmall'] = 0xF770;
  9003. t['Q'] = 0x0051;
  9004. t['Qcircle'] = 0x24C6;
  9005. t['Qmonospace'] = 0xFF31;
  9006. t['Qsmall'] = 0xF771;
  9007. t['R'] = 0x0052;
  9008. t['Raarmenian'] = 0x054C;
  9009. t['Racute'] = 0x0154;
  9010. t['Rcaron'] = 0x0158;
  9011. t['Rcedilla'] = 0x0156;
  9012. t['Rcircle'] = 0x24C7;
  9013. t['Rcommaaccent'] = 0x0156;
  9014. t['Rdblgrave'] = 0x0210;
  9015. t['Rdotaccent'] = 0x1E58;
  9016. t['Rdotbelow'] = 0x1E5A;
  9017. t['Rdotbelowmacron'] = 0x1E5C;
  9018. t['Reharmenian'] = 0x0550;
  9019. t['Rfraktur'] = 0x211C;
  9020. t['Rho'] = 0x03A1;
  9021. t['Ringsmall'] = 0xF6FC;
  9022. t['Rinvertedbreve'] = 0x0212;
  9023. t['Rlinebelow'] = 0x1E5E;
  9024. t['Rmonospace'] = 0xFF32;
  9025. t['Rsmall'] = 0xF772;
  9026. t['Rsmallinverted'] = 0x0281;
  9027. t['Rsmallinvertedsuperior'] = 0x02B6;
  9028. t['S'] = 0x0053;
  9029. t['SF010000'] = 0x250C;
  9030. t['SF020000'] = 0x2514;
  9031. t['SF030000'] = 0x2510;
  9032. t['SF040000'] = 0x2518;
  9033. t['SF050000'] = 0x253C;
  9034. t['SF060000'] = 0x252C;
  9035. t['SF070000'] = 0x2534;
  9036. t['SF080000'] = 0x251C;
  9037. t['SF090000'] = 0x2524;
  9038. t['SF100000'] = 0x2500;
  9039. t['SF110000'] = 0x2502;
  9040. t['SF190000'] = 0x2561;
  9041. t['SF200000'] = 0x2562;
  9042. t['SF210000'] = 0x2556;
  9043. t['SF220000'] = 0x2555;
  9044. t['SF230000'] = 0x2563;
  9045. t['SF240000'] = 0x2551;
  9046. t['SF250000'] = 0x2557;
  9047. t['SF260000'] = 0x255D;
  9048. t['SF270000'] = 0x255C;
  9049. t['SF280000'] = 0x255B;
  9050. t['SF360000'] = 0x255E;
  9051. t['SF370000'] = 0x255F;
  9052. t['SF380000'] = 0x255A;
  9053. t['SF390000'] = 0x2554;
  9054. t['SF400000'] = 0x2569;
  9055. t['SF410000'] = 0x2566;
  9056. t['SF420000'] = 0x2560;
  9057. t['SF430000'] = 0x2550;
  9058. t['SF440000'] = 0x256C;
  9059. t['SF450000'] = 0x2567;
  9060. t['SF460000'] = 0x2568;
  9061. t['SF470000'] = 0x2564;
  9062. t['SF480000'] = 0x2565;
  9063. t['SF490000'] = 0x2559;
  9064. t['SF500000'] = 0x2558;
  9065. t['SF510000'] = 0x2552;
  9066. t['SF520000'] = 0x2553;
  9067. t['SF530000'] = 0x256B;
  9068. t['SF540000'] = 0x256A;
  9069. t['Sacute'] = 0x015A;
  9070. t['Sacutedotaccent'] = 0x1E64;
  9071. t['Sampigreek'] = 0x03E0;
  9072. t['Scaron'] = 0x0160;
  9073. t['Scarondotaccent'] = 0x1E66;
  9074. t['Scaronsmall'] = 0xF6FD;
  9075. t['Scedilla'] = 0x015E;
  9076. t['Schwa'] = 0x018F;
  9077. t['Schwacyrillic'] = 0x04D8;
  9078. t['Schwadieresiscyrillic'] = 0x04DA;
  9079. t['Scircle'] = 0x24C8;
  9080. t['Scircumflex'] = 0x015C;
  9081. t['Scommaaccent'] = 0x0218;
  9082. t['Sdotaccent'] = 0x1E60;
  9083. t['Sdotbelow'] = 0x1E62;
  9084. t['Sdotbelowdotaccent'] = 0x1E68;
  9085. t['Seharmenian'] = 0x054D;
  9086. t['Sevenroman'] = 0x2166;
  9087. t['Shaarmenian'] = 0x0547;
  9088. t['Shacyrillic'] = 0x0428;
  9089. t['Shchacyrillic'] = 0x0429;
  9090. t['Sheicoptic'] = 0x03E2;
  9091. t['Shhacyrillic'] = 0x04BA;
  9092. t['Shimacoptic'] = 0x03EC;
  9093. t['Sigma'] = 0x03A3;
  9094. t['Sixroman'] = 0x2165;
  9095. t['Smonospace'] = 0xFF33;
  9096. t['Softsigncyrillic'] = 0x042C;
  9097. t['Ssmall'] = 0xF773;
  9098. t['Stigmagreek'] = 0x03DA;
  9099. t['T'] = 0x0054;
  9100. t['Tau'] = 0x03A4;
  9101. t['Tbar'] = 0x0166;
  9102. t['Tcaron'] = 0x0164;
  9103. t['Tcedilla'] = 0x0162;
  9104. t['Tcircle'] = 0x24C9;
  9105. t['Tcircumflexbelow'] = 0x1E70;
  9106. t['Tcommaaccent'] = 0x0162;
  9107. t['Tdotaccent'] = 0x1E6A;
  9108. t['Tdotbelow'] = 0x1E6C;
  9109. t['Tecyrillic'] = 0x0422;
  9110. t['Tedescendercyrillic'] = 0x04AC;
  9111. t['Tenroman'] = 0x2169;
  9112. t['Tetsecyrillic'] = 0x04B4;
  9113. t['Theta'] = 0x0398;
  9114. t['Thook'] = 0x01AC;
  9115. t['Thorn'] = 0x00DE;
  9116. t['Thornsmall'] = 0xF7FE;
  9117. t['Threeroman'] = 0x2162;
  9118. t['Tildesmall'] = 0xF6FE;
  9119. t['Tiwnarmenian'] = 0x054F;
  9120. t['Tlinebelow'] = 0x1E6E;
  9121. t['Tmonospace'] = 0xFF34;
  9122. t['Toarmenian'] = 0x0539;
  9123. t['Tonefive'] = 0x01BC;
  9124. t['Tonesix'] = 0x0184;
  9125. t['Tonetwo'] = 0x01A7;
  9126. t['Tretroflexhook'] = 0x01AE;
  9127. t['Tsecyrillic'] = 0x0426;
  9128. t['Tshecyrillic'] = 0x040B;
  9129. t['Tsmall'] = 0xF774;
  9130. t['Twelveroman'] = 0x216B;
  9131. t['Tworoman'] = 0x2161;
  9132. t['U'] = 0x0055;
  9133. t['Uacute'] = 0x00DA;
  9134. t['Uacutesmall'] = 0xF7FA;
  9135. t['Ubreve'] = 0x016C;
  9136. t['Ucaron'] = 0x01D3;
  9137. t['Ucircle'] = 0x24CA;
  9138. t['Ucircumflex'] = 0x00DB;
  9139. t['Ucircumflexbelow'] = 0x1E76;
  9140. t['Ucircumflexsmall'] = 0xF7FB;
  9141. t['Ucyrillic'] = 0x0423;
  9142. t['Udblacute'] = 0x0170;
  9143. t['Udblgrave'] = 0x0214;
  9144. t['Udieresis'] = 0x00DC;
  9145. t['Udieresisacute'] = 0x01D7;
  9146. t['Udieresisbelow'] = 0x1E72;
  9147. t['Udieresiscaron'] = 0x01D9;
  9148. t['Udieresiscyrillic'] = 0x04F0;
  9149. t['Udieresisgrave'] = 0x01DB;
  9150. t['Udieresismacron'] = 0x01D5;
  9151. t['Udieresissmall'] = 0xF7FC;
  9152. t['Udotbelow'] = 0x1EE4;
  9153. t['Ugrave'] = 0x00D9;
  9154. t['Ugravesmall'] = 0xF7F9;
  9155. t['Uhookabove'] = 0x1EE6;
  9156. t['Uhorn'] = 0x01AF;
  9157. t['Uhornacute'] = 0x1EE8;
  9158. t['Uhorndotbelow'] = 0x1EF0;
  9159. t['Uhorngrave'] = 0x1EEA;
  9160. t['Uhornhookabove'] = 0x1EEC;
  9161. t['Uhorntilde'] = 0x1EEE;
  9162. t['Uhungarumlaut'] = 0x0170;
  9163. t['Uhungarumlautcyrillic'] = 0x04F2;
  9164. t['Uinvertedbreve'] = 0x0216;
  9165. t['Ukcyrillic'] = 0x0478;
  9166. t['Umacron'] = 0x016A;
  9167. t['Umacroncyrillic'] = 0x04EE;
  9168. t['Umacrondieresis'] = 0x1E7A;
  9169. t['Umonospace'] = 0xFF35;
  9170. t['Uogonek'] = 0x0172;
  9171. t['Upsilon'] = 0x03A5;
  9172. t['Upsilon1'] = 0x03D2;
  9173. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9174. t['Upsilonafrican'] = 0x01B1;
  9175. t['Upsilondieresis'] = 0x03AB;
  9176. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9177. t['Upsilonhooksymbol'] = 0x03D2;
  9178. t['Upsilontonos'] = 0x038E;
  9179. t['Uring'] = 0x016E;
  9180. t['Ushortcyrillic'] = 0x040E;
  9181. t['Usmall'] = 0xF775;
  9182. t['Ustraightcyrillic'] = 0x04AE;
  9183. t['Ustraightstrokecyrillic'] = 0x04B0;
  9184. t['Utilde'] = 0x0168;
  9185. t['Utildeacute'] = 0x1E78;
  9186. t['Utildebelow'] = 0x1E74;
  9187. t['V'] = 0x0056;
  9188. t['Vcircle'] = 0x24CB;
  9189. t['Vdotbelow'] = 0x1E7E;
  9190. t['Vecyrillic'] = 0x0412;
  9191. t['Vewarmenian'] = 0x054E;
  9192. t['Vhook'] = 0x01B2;
  9193. t['Vmonospace'] = 0xFF36;
  9194. t['Voarmenian'] = 0x0548;
  9195. t['Vsmall'] = 0xF776;
  9196. t['Vtilde'] = 0x1E7C;
  9197. t['W'] = 0x0057;
  9198. t['Wacute'] = 0x1E82;
  9199. t['Wcircle'] = 0x24CC;
  9200. t['Wcircumflex'] = 0x0174;
  9201. t['Wdieresis'] = 0x1E84;
  9202. t['Wdotaccent'] = 0x1E86;
  9203. t['Wdotbelow'] = 0x1E88;
  9204. t['Wgrave'] = 0x1E80;
  9205. t['Wmonospace'] = 0xFF37;
  9206. t['Wsmall'] = 0xF777;
  9207. t['X'] = 0x0058;
  9208. t['Xcircle'] = 0x24CD;
  9209. t['Xdieresis'] = 0x1E8C;
  9210. t['Xdotaccent'] = 0x1E8A;
  9211. t['Xeharmenian'] = 0x053D;
  9212. t['Xi'] = 0x039E;
  9213. t['Xmonospace'] = 0xFF38;
  9214. t['Xsmall'] = 0xF778;
  9215. t['Y'] = 0x0059;
  9216. t['Yacute'] = 0x00DD;
  9217. t['Yacutesmall'] = 0xF7FD;
  9218. t['Yatcyrillic'] = 0x0462;
  9219. t['Ycircle'] = 0x24CE;
  9220. t['Ycircumflex'] = 0x0176;
  9221. t['Ydieresis'] = 0x0178;
  9222. t['Ydieresissmall'] = 0xF7FF;
  9223. t['Ydotaccent'] = 0x1E8E;
  9224. t['Ydotbelow'] = 0x1EF4;
  9225. t['Yericyrillic'] = 0x042B;
  9226. t['Yerudieresiscyrillic'] = 0x04F8;
  9227. t['Ygrave'] = 0x1EF2;
  9228. t['Yhook'] = 0x01B3;
  9229. t['Yhookabove'] = 0x1EF6;
  9230. t['Yiarmenian'] = 0x0545;
  9231. t['Yicyrillic'] = 0x0407;
  9232. t['Yiwnarmenian'] = 0x0552;
  9233. t['Ymonospace'] = 0xFF39;
  9234. t['Ysmall'] = 0xF779;
  9235. t['Ytilde'] = 0x1EF8;
  9236. t['Yusbigcyrillic'] = 0x046A;
  9237. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9238. t['Yuslittlecyrillic'] = 0x0466;
  9239. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9240. t['Z'] = 0x005A;
  9241. t['Zaarmenian'] = 0x0536;
  9242. t['Zacute'] = 0x0179;
  9243. t['Zcaron'] = 0x017D;
  9244. t['Zcaronsmall'] = 0xF6FF;
  9245. t['Zcircle'] = 0x24CF;
  9246. t['Zcircumflex'] = 0x1E90;
  9247. t['Zdot'] = 0x017B;
  9248. t['Zdotaccent'] = 0x017B;
  9249. t['Zdotbelow'] = 0x1E92;
  9250. t['Zecyrillic'] = 0x0417;
  9251. t['Zedescendercyrillic'] = 0x0498;
  9252. t['Zedieresiscyrillic'] = 0x04DE;
  9253. t['Zeta'] = 0x0396;
  9254. t['Zhearmenian'] = 0x053A;
  9255. t['Zhebrevecyrillic'] = 0x04C1;
  9256. t['Zhecyrillic'] = 0x0416;
  9257. t['Zhedescendercyrillic'] = 0x0496;
  9258. t['Zhedieresiscyrillic'] = 0x04DC;
  9259. t['Zlinebelow'] = 0x1E94;
  9260. t['Zmonospace'] = 0xFF3A;
  9261. t['Zsmall'] = 0xF77A;
  9262. t['Zstroke'] = 0x01B5;
  9263. t['a'] = 0x0061;
  9264. t['aabengali'] = 0x0986;
  9265. t['aacute'] = 0x00E1;
  9266. t['aadeva'] = 0x0906;
  9267. t['aagujarati'] = 0x0A86;
  9268. t['aagurmukhi'] = 0x0A06;
  9269. t['aamatragurmukhi'] = 0x0A3E;
  9270. t['aarusquare'] = 0x3303;
  9271. t['aavowelsignbengali'] = 0x09BE;
  9272. t['aavowelsigndeva'] = 0x093E;
  9273. t['aavowelsigngujarati'] = 0x0ABE;
  9274. t['abbreviationmarkarmenian'] = 0x055F;
  9275. t['abbreviationsigndeva'] = 0x0970;
  9276. t['abengali'] = 0x0985;
  9277. t['abopomofo'] = 0x311A;
  9278. t['abreve'] = 0x0103;
  9279. t['abreveacute'] = 0x1EAF;
  9280. t['abrevecyrillic'] = 0x04D1;
  9281. t['abrevedotbelow'] = 0x1EB7;
  9282. t['abrevegrave'] = 0x1EB1;
  9283. t['abrevehookabove'] = 0x1EB3;
  9284. t['abrevetilde'] = 0x1EB5;
  9285. t['acaron'] = 0x01CE;
  9286. t['acircle'] = 0x24D0;
  9287. t['acircumflex'] = 0x00E2;
  9288. t['acircumflexacute'] = 0x1EA5;
  9289. t['acircumflexdotbelow'] = 0x1EAD;
  9290. t['acircumflexgrave'] = 0x1EA7;
  9291. t['acircumflexhookabove'] = 0x1EA9;
  9292. t['acircumflextilde'] = 0x1EAB;
  9293. t['acute'] = 0x00B4;
  9294. t['acutebelowcmb'] = 0x0317;
  9295. t['acutecmb'] = 0x0301;
  9296. t['acutecomb'] = 0x0301;
  9297. t['acutedeva'] = 0x0954;
  9298. t['acutelowmod'] = 0x02CF;
  9299. t['acutetonecmb'] = 0x0341;
  9300. t['acyrillic'] = 0x0430;
  9301. t['adblgrave'] = 0x0201;
  9302. t['addakgurmukhi'] = 0x0A71;
  9303. t['adeva'] = 0x0905;
  9304. t['adieresis'] = 0x00E4;
  9305. t['adieresiscyrillic'] = 0x04D3;
  9306. t['adieresismacron'] = 0x01DF;
  9307. t['adotbelow'] = 0x1EA1;
  9308. t['adotmacron'] = 0x01E1;
  9309. t['ae'] = 0x00E6;
  9310. t['aeacute'] = 0x01FD;
  9311. t['aekorean'] = 0x3150;
  9312. t['aemacron'] = 0x01E3;
  9313. t['afii00208'] = 0x2015;
  9314. t['afii08941'] = 0x20A4;
  9315. t['afii10017'] = 0x0410;
  9316. t['afii10018'] = 0x0411;
  9317. t['afii10019'] = 0x0412;
  9318. t['afii10020'] = 0x0413;
  9319. t['afii10021'] = 0x0414;
  9320. t['afii10022'] = 0x0415;
  9321. t['afii10023'] = 0x0401;
  9322. t['afii10024'] = 0x0416;
  9323. t['afii10025'] = 0x0417;
  9324. t['afii10026'] = 0x0418;
  9325. t['afii10027'] = 0x0419;
  9326. t['afii10028'] = 0x041A;
  9327. t['afii10029'] = 0x041B;
  9328. t['afii10030'] = 0x041C;
  9329. t['afii10031'] = 0x041D;
  9330. t['afii10032'] = 0x041E;
  9331. t['afii10033'] = 0x041F;
  9332. t['afii10034'] = 0x0420;
  9333. t['afii10035'] = 0x0421;
  9334. t['afii10036'] = 0x0422;
  9335. t['afii10037'] = 0x0423;
  9336. t['afii10038'] = 0x0424;
  9337. t['afii10039'] = 0x0425;
  9338. t['afii10040'] = 0x0426;
  9339. t['afii10041'] = 0x0427;
  9340. t['afii10042'] = 0x0428;
  9341. t['afii10043'] = 0x0429;
  9342. t['afii10044'] = 0x042A;
  9343. t['afii10045'] = 0x042B;
  9344. t['afii10046'] = 0x042C;
  9345. t['afii10047'] = 0x042D;
  9346. t['afii10048'] = 0x042E;
  9347. t['afii10049'] = 0x042F;
  9348. t['afii10050'] = 0x0490;
  9349. t['afii10051'] = 0x0402;
  9350. t['afii10052'] = 0x0403;
  9351. t['afii10053'] = 0x0404;
  9352. t['afii10054'] = 0x0405;
  9353. t['afii10055'] = 0x0406;
  9354. t['afii10056'] = 0x0407;
  9355. t['afii10057'] = 0x0408;
  9356. t['afii10058'] = 0x0409;
  9357. t['afii10059'] = 0x040A;
  9358. t['afii10060'] = 0x040B;
  9359. t['afii10061'] = 0x040C;
  9360. t['afii10062'] = 0x040E;
  9361. t['afii10063'] = 0xF6C4;
  9362. t['afii10064'] = 0xF6C5;
  9363. t['afii10065'] = 0x0430;
  9364. t['afii10066'] = 0x0431;
  9365. t['afii10067'] = 0x0432;
  9366. t['afii10068'] = 0x0433;
  9367. t['afii10069'] = 0x0434;
  9368. t['afii10070'] = 0x0435;
  9369. t['afii10071'] = 0x0451;
  9370. t['afii10072'] = 0x0436;
  9371. t['afii10073'] = 0x0437;
  9372. t['afii10074'] = 0x0438;
  9373. t['afii10075'] = 0x0439;
  9374. t['afii10076'] = 0x043A;
  9375. t['afii10077'] = 0x043B;
  9376. t['afii10078'] = 0x043C;
  9377. t['afii10079'] = 0x043D;
  9378. t['afii10080'] = 0x043E;
  9379. t['afii10081'] = 0x043F;
  9380. t['afii10082'] = 0x0440;
  9381. t['afii10083'] = 0x0441;
  9382. t['afii10084'] = 0x0442;
  9383. t['afii10085'] = 0x0443;
  9384. t['afii10086'] = 0x0444;
  9385. t['afii10087'] = 0x0445;
  9386. t['afii10088'] = 0x0446;
  9387. t['afii10089'] = 0x0447;
  9388. t['afii10090'] = 0x0448;
  9389. t['afii10091'] = 0x0449;
  9390. t['afii10092'] = 0x044A;
  9391. t['afii10093'] = 0x044B;
  9392. t['afii10094'] = 0x044C;
  9393. t['afii10095'] = 0x044D;
  9394. t['afii10096'] = 0x044E;
  9395. t['afii10097'] = 0x044F;
  9396. t['afii10098'] = 0x0491;
  9397. t['afii10099'] = 0x0452;
  9398. t['afii10100'] = 0x0453;
  9399. t['afii10101'] = 0x0454;
  9400. t['afii10102'] = 0x0455;
  9401. t['afii10103'] = 0x0456;
  9402. t['afii10104'] = 0x0457;
  9403. t['afii10105'] = 0x0458;
  9404. t['afii10106'] = 0x0459;
  9405. t['afii10107'] = 0x045A;
  9406. t['afii10108'] = 0x045B;
  9407. t['afii10109'] = 0x045C;
  9408. t['afii10110'] = 0x045E;
  9409. t['afii10145'] = 0x040F;
  9410. t['afii10146'] = 0x0462;
  9411. t['afii10147'] = 0x0472;
  9412. t['afii10148'] = 0x0474;
  9413. t['afii10192'] = 0xF6C6;
  9414. t['afii10193'] = 0x045F;
  9415. t['afii10194'] = 0x0463;
  9416. t['afii10195'] = 0x0473;
  9417. t['afii10196'] = 0x0475;
  9418. t['afii10831'] = 0xF6C7;
  9419. t['afii10832'] = 0xF6C8;
  9420. t['afii10846'] = 0x04D9;
  9421. t['afii299'] = 0x200E;
  9422. t['afii300'] = 0x200F;
  9423. t['afii301'] = 0x200D;
  9424. t['afii57381'] = 0x066A;
  9425. t['afii57388'] = 0x060C;
  9426. t['afii57392'] = 0x0660;
  9427. t['afii57393'] = 0x0661;
  9428. t['afii57394'] = 0x0662;
  9429. t['afii57395'] = 0x0663;
  9430. t['afii57396'] = 0x0664;
  9431. t['afii57397'] = 0x0665;
  9432. t['afii57398'] = 0x0666;
  9433. t['afii57399'] = 0x0667;
  9434. t['afii57400'] = 0x0668;
  9435. t['afii57401'] = 0x0669;
  9436. t['afii57403'] = 0x061B;
  9437. t['afii57407'] = 0x061F;
  9438. t['afii57409'] = 0x0621;
  9439. t['afii57410'] = 0x0622;
  9440. t['afii57411'] = 0x0623;
  9441. t['afii57412'] = 0x0624;
  9442. t['afii57413'] = 0x0625;
  9443. t['afii57414'] = 0x0626;
  9444. t['afii57415'] = 0x0627;
  9445. t['afii57416'] = 0x0628;
  9446. t['afii57417'] = 0x0629;
  9447. t['afii57418'] = 0x062A;
  9448. t['afii57419'] = 0x062B;
  9449. t['afii57420'] = 0x062C;
  9450. t['afii57421'] = 0x062D;
  9451. t['afii57422'] = 0x062E;
  9452. t['afii57423'] = 0x062F;
  9453. t['afii57424'] = 0x0630;
  9454. t['afii57425'] = 0x0631;
  9455. t['afii57426'] = 0x0632;
  9456. t['afii57427'] = 0x0633;
  9457. t['afii57428'] = 0x0634;
  9458. t['afii57429'] = 0x0635;
  9459. t['afii57430'] = 0x0636;
  9460. t['afii57431'] = 0x0637;
  9461. t['afii57432'] = 0x0638;
  9462. t['afii57433'] = 0x0639;
  9463. t['afii57434'] = 0x063A;
  9464. t['afii57440'] = 0x0640;
  9465. t['afii57441'] = 0x0641;
  9466. t['afii57442'] = 0x0642;
  9467. t['afii57443'] = 0x0643;
  9468. t['afii57444'] = 0x0644;
  9469. t['afii57445'] = 0x0645;
  9470. t['afii57446'] = 0x0646;
  9471. t['afii57448'] = 0x0648;
  9472. t['afii57449'] = 0x0649;
  9473. t['afii57450'] = 0x064A;
  9474. t['afii57451'] = 0x064B;
  9475. t['afii57452'] = 0x064C;
  9476. t['afii57453'] = 0x064D;
  9477. t['afii57454'] = 0x064E;
  9478. t['afii57455'] = 0x064F;
  9479. t['afii57456'] = 0x0650;
  9480. t['afii57457'] = 0x0651;
  9481. t['afii57458'] = 0x0652;
  9482. t['afii57470'] = 0x0647;
  9483. t['afii57505'] = 0x06A4;
  9484. t['afii57506'] = 0x067E;
  9485. t['afii57507'] = 0x0686;
  9486. t['afii57508'] = 0x0698;
  9487. t['afii57509'] = 0x06AF;
  9488. t['afii57511'] = 0x0679;
  9489. t['afii57512'] = 0x0688;
  9490. t['afii57513'] = 0x0691;
  9491. t['afii57514'] = 0x06BA;
  9492. t['afii57519'] = 0x06D2;
  9493. t['afii57534'] = 0x06D5;
  9494. t['afii57636'] = 0x20AA;
  9495. t['afii57645'] = 0x05BE;
  9496. t['afii57658'] = 0x05C3;
  9497. t['afii57664'] = 0x05D0;
  9498. t['afii57665'] = 0x05D1;
  9499. t['afii57666'] = 0x05D2;
  9500. t['afii57667'] = 0x05D3;
  9501. t['afii57668'] = 0x05D4;
  9502. t['afii57669'] = 0x05D5;
  9503. t['afii57670'] = 0x05D6;
  9504. t['afii57671'] = 0x05D7;
  9505. t['afii57672'] = 0x05D8;
  9506. t['afii57673'] = 0x05D9;
  9507. t['afii57674'] = 0x05DA;
  9508. t['afii57675'] = 0x05DB;
  9509. t['afii57676'] = 0x05DC;
  9510. t['afii57677'] = 0x05DD;
  9511. t['afii57678'] = 0x05DE;
  9512. t['afii57679'] = 0x05DF;
  9513. t['afii57680'] = 0x05E0;
  9514. t['afii57681'] = 0x05E1;
  9515. t['afii57682'] = 0x05E2;
  9516. t['afii57683'] = 0x05E3;
  9517. t['afii57684'] = 0x05E4;
  9518. t['afii57685'] = 0x05E5;
  9519. t['afii57686'] = 0x05E6;
  9520. t['afii57687'] = 0x05E7;
  9521. t['afii57688'] = 0x05E8;
  9522. t['afii57689'] = 0x05E9;
  9523. t['afii57690'] = 0x05EA;
  9524. t['afii57694'] = 0xFB2A;
  9525. t['afii57695'] = 0xFB2B;
  9526. t['afii57700'] = 0xFB4B;
  9527. t['afii57705'] = 0xFB1F;
  9528. t['afii57716'] = 0x05F0;
  9529. t['afii57717'] = 0x05F1;
  9530. t['afii57718'] = 0x05F2;
  9531. t['afii57723'] = 0xFB35;
  9532. t['afii57793'] = 0x05B4;
  9533. t['afii57794'] = 0x05B5;
  9534. t['afii57795'] = 0x05B6;
  9535. t['afii57796'] = 0x05BB;
  9536. t['afii57797'] = 0x05B8;
  9537. t['afii57798'] = 0x05B7;
  9538. t['afii57799'] = 0x05B0;
  9539. t['afii57800'] = 0x05B2;
  9540. t['afii57801'] = 0x05B1;
  9541. t['afii57802'] = 0x05B3;
  9542. t['afii57803'] = 0x05C2;
  9543. t['afii57804'] = 0x05C1;
  9544. t['afii57806'] = 0x05B9;
  9545. t['afii57807'] = 0x05BC;
  9546. t['afii57839'] = 0x05BD;
  9547. t['afii57841'] = 0x05BF;
  9548. t['afii57842'] = 0x05C0;
  9549. t['afii57929'] = 0x02BC;
  9550. t['afii61248'] = 0x2105;
  9551. t['afii61289'] = 0x2113;
  9552. t['afii61352'] = 0x2116;
  9553. t['afii61573'] = 0x202C;
  9554. t['afii61574'] = 0x202D;
  9555. t['afii61575'] = 0x202E;
  9556. t['afii61664'] = 0x200C;
  9557. t['afii63167'] = 0x066D;
  9558. t['afii64937'] = 0x02BD;
  9559. t['agrave'] = 0x00E0;
  9560. t['agujarati'] = 0x0A85;
  9561. t['agurmukhi'] = 0x0A05;
  9562. t['ahiragana'] = 0x3042;
  9563. t['ahookabove'] = 0x1EA3;
  9564. t['aibengali'] = 0x0990;
  9565. t['aibopomofo'] = 0x311E;
  9566. t['aideva'] = 0x0910;
  9567. t['aiecyrillic'] = 0x04D5;
  9568. t['aigujarati'] = 0x0A90;
  9569. t['aigurmukhi'] = 0x0A10;
  9570. t['aimatragurmukhi'] = 0x0A48;
  9571. t['ainarabic'] = 0x0639;
  9572. t['ainfinalarabic'] = 0xFECA;
  9573. t['aininitialarabic'] = 0xFECB;
  9574. t['ainmedialarabic'] = 0xFECC;
  9575. t['ainvertedbreve'] = 0x0203;
  9576. t['aivowelsignbengali'] = 0x09C8;
  9577. t['aivowelsigndeva'] = 0x0948;
  9578. t['aivowelsigngujarati'] = 0x0AC8;
  9579. t['akatakana'] = 0x30A2;
  9580. t['akatakanahalfwidth'] = 0xFF71;
  9581. t['akorean'] = 0x314F;
  9582. t['alef'] = 0x05D0;
  9583. t['alefarabic'] = 0x0627;
  9584. t['alefdageshhebrew'] = 0xFB30;
  9585. t['aleffinalarabic'] = 0xFE8E;
  9586. t['alefhamzaabovearabic'] = 0x0623;
  9587. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9588. t['alefhamzabelowarabic'] = 0x0625;
  9589. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9590. t['alefhebrew'] = 0x05D0;
  9591. t['aleflamedhebrew'] = 0xFB4F;
  9592. t['alefmaddaabovearabic'] = 0x0622;
  9593. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9594. t['alefmaksuraarabic'] = 0x0649;
  9595. t['alefmaksurafinalarabic'] = 0xFEF0;
  9596. t['alefmaksurainitialarabic'] = 0xFEF3;
  9597. t['alefmaksuramedialarabic'] = 0xFEF4;
  9598. t['alefpatahhebrew'] = 0xFB2E;
  9599. t['alefqamatshebrew'] = 0xFB2F;
  9600. t['aleph'] = 0x2135;
  9601. t['allequal'] = 0x224C;
  9602. t['alpha'] = 0x03B1;
  9603. t['alphatonos'] = 0x03AC;
  9604. t['amacron'] = 0x0101;
  9605. t['amonospace'] = 0xFF41;
  9606. t['ampersand'] = 0x0026;
  9607. t['ampersandmonospace'] = 0xFF06;
  9608. t['ampersandsmall'] = 0xF726;
  9609. t['amsquare'] = 0x33C2;
  9610. t['anbopomofo'] = 0x3122;
  9611. t['angbopomofo'] = 0x3124;
  9612. t['angbracketleft'] = 0x3008;
  9613. t['angbracketright'] = 0x3009;
  9614. t['angkhankhuthai'] = 0x0E5A;
  9615. t['angle'] = 0x2220;
  9616. t['anglebracketleft'] = 0x3008;
  9617. t['anglebracketleftvertical'] = 0xFE3F;
  9618. t['anglebracketright'] = 0x3009;
  9619. t['anglebracketrightvertical'] = 0xFE40;
  9620. t['angleleft'] = 0x2329;
  9621. t['angleright'] = 0x232A;
  9622. t['angstrom'] = 0x212B;
  9623. t['anoteleia'] = 0x0387;
  9624. t['anudattadeva'] = 0x0952;
  9625. t['anusvarabengali'] = 0x0982;
  9626. t['anusvaradeva'] = 0x0902;
  9627. t['anusvaragujarati'] = 0x0A82;
  9628. t['aogonek'] = 0x0105;
  9629. t['apaatosquare'] = 0x3300;
  9630. t['aparen'] = 0x249C;
  9631. t['apostrophearmenian'] = 0x055A;
  9632. t['apostrophemod'] = 0x02BC;
  9633. t['apple'] = 0xF8FF;
  9634. t['approaches'] = 0x2250;
  9635. t['approxequal'] = 0x2248;
  9636. t['approxequalorimage'] = 0x2252;
  9637. t['approximatelyequal'] = 0x2245;
  9638. t['araeaekorean'] = 0x318E;
  9639. t['araeakorean'] = 0x318D;
  9640. t['arc'] = 0x2312;
  9641. t['arighthalfring'] = 0x1E9A;
  9642. t['aring'] = 0x00E5;
  9643. t['aringacute'] = 0x01FB;
  9644. t['aringbelow'] = 0x1E01;
  9645. t['arrowboth'] = 0x2194;
  9646. t['arrowdashdown'] = 0x21E3;
  9647. t['arrowdashleft'] = 0x21E0;
  9648. t['arrowdashright'] = 0x21E2;
  9649. t['arrowdashup'] = 0x21E1;
  9650. t['arrowdblboth'] = 0x21D4;
  9651. t['arrowdbldown'] = 0x21D3;
  9652. t['arrowdblleft'] = 0x21D0;
  9653. t['arrowdblright'] = 0x21D2;
  9654. t['arrowdblup'] = 0x21D1;
  9655. t['arrowdown'] = 0x2193;
  9656. t['arrowdownleft'] = 0x2199;
  9657. t['arrowdownright'] = 0x2198;
  9658. t['arrowdownwhite'] = 0x21E9;
  9659. t['arrowheaddownmod'] = 0x02C5;
  9660. t['arrowheadleftmod'] = 0x02C2;
  9661. t['arrowheadrightmod'] = 0x02C3;
  9662. t['arrowheadupmod'] = 0x02C4;
  9663. t['arrowhorizex'] = 0xF8E7;
  9664. t['arrowleft'] = 0x2190;
  9665. t['arrowleftdbl'] = 0x21D0;
  9666. t['arrowleftdblstroke'] = 0x21CD;
  9667. t['arrowleftoverright'] = 0x21C6;
  9668. t['arrowleftwhite'] = 0x21E6;
  9669. t['arrowright'] = 0x2192;
  9670. t['arrowrightdblstroke'] = 0x21CF;
  9671. t['arrowrightheavy'] = 0x279E;
  9672. t['arrowrightoverleft'] = 0x21C4;
  9673. t['arrowrightwhite'] = 0x21E8;
  9674. t['arrowtableft'] = 0x21E4;
  9675. t['arrowtabright'] = 0x21E5;
  9676. t['arrowup'] = 0x2191;
  9677. t['arrowupdn'] = 0x2195;
  9678. t['arrowupdnbse'] = 0x21A8;
  9679. t['arrowupdownbase'] = 0x21A8;
  9680. t['arrowupleft'] = 0x2196;
  9681. t['arrowupleftofdown'] = 0x21C5;
  9682. t['arrowupright'] = 0x2197;
  9683. t['arrowupwhite'] = 0x21E7;
  9684. t['arrowvertex'] = 0xF8E6;
  9685. t['asciicircum'] = 0x005E;
  9686. t['asciicircummonospace'] = 0xFF3E;
  9687. t['asciitilde'] = 0x007E;
  9688. t['asciitildemonospace'] = 0xFF5E;
  9689. t['ascript'] = 0x0251;
  9690. t['ascriptturned'] = 0x0252;
  9691. t['asmallhiragana'] = 0x3041;
  9692. t['asmallkatakana'] = 0x30A1;
  9693. t['asmallkatakanahalfwidth'] = 0xFF67;
  9694. t['asterisk'] = 0x002A;
  9695. t['asteriskaltonearabic'] = 0x066D;
  9696. t['asteriskarabic'] = 0x066D;
  9697. t['asteriskmath'] = 0x2217;
  9698. t['asteriskmonospace'] = 0xFF0A;
  9699. t['asterisksmall'] = 0xFE61;
  9700. t['asterism'] = 0x2042;
  9701. t['asuperior'] = 0xF6E9;
  9702. t['asymptoticallyequal'] = 0x2243;
  9703. t['at'] = 0x0040;
  9704. t['atilde'] = 0x00E3;
  9705. t['atmonospace'] = 0xFF20;
  9706. t['atsmall'] = 0xFE6B;
  9707. t['aturned'] = 0x0250;
  9708. t['aubengali'] = 0x0994;
  9709. t['aubopomofo'] = 0x3120;
  9710. t['audeva'] = 0x0914;
  9711. t['augujarati'] = 0x0A94;
  9712. t['augurmukhi'] = 0x0A14;
  9713. t['aulengthmarkbengali'] = 0x09D7;
  9714. t['aumatragurmukhi'] = 0x0A4C;
  9715. t['auvowelsignbengali'] = 0x09CC;
  9716. t['auvowelsigndeva'] = 0x094C;
  9717. t['auvowelsigngujarati'] = 0x0ACC;
  9718. t['avagrahadeva'] = 0x093D;
  9719. t['aybarmenian'] = 0x0561;
  9720. t['ayin'] = 0x05E2;
  9721. t['ayinaltonehebrew'] = 0xFB20;
  9722. t['ayinhebrew'] = 0x05E2;
  9723. t['b'] = 0x0062;
  9724. t['babengali'] = 0x09AC;
  9725. t['backslash'] = 0x005C;
  9726. t['backslashmonospace'] = 0xFF3C;
  9727. t['badeva'] = 0x092C;
  9728. t['bagujarati'] = 0x0AAC;
  9729. t['bagurmukhi'] = 0x0A2C;
  9730. t['bahiragana'] = 0x3070;
  9731. t['bahtthai'] = 0x0E3F;
  9732. t['bakatakana'] = 0x30D0;
  9733. t['bar'] = 0x007C;
  9734. t['barmonospace'] = 0xFF5C;
  9735. t['bbopomofo'] = 0x3105;
  9736. t['bcircle'] = 0x24D1;
  9737. t['bdotaccent'] = 0x1E03;
  9738. t['bdotbelow'] = 0x1E05;
  9739. t['beamedsixteenthnotes'] = 0x266C;
  9740. t['because'] = 0x2235;
  9741. t['becyrillic'] = 0x0431;
  9742. t['beharabic'] = 0x0628;
  9743. t['behfinalarabic'] = 0xFE90;
  9744. t['behinitialarabic'] = 0xFE91;
  9745. t['behiragana'] = 0x3079;
  9746. t['behmedialarabic'] = 0xFE92;
  9747. t['behmeeminitialarabic'] = 0xFC9F;
  9748. t['behmeemisolatedarabic'] = 0xFC08;
  9749. t['behnoonfinalarabic'] = 0xFC6D;
  9750. t['bekatakana'] = 0x30D9;
  9751. t['benarmenian'] = 0x0562;
  9752. t['bet'] = 0x05D1;
  9753. t['beta'] = 0x03B2;
  9754. t['betasymbolgreek'] = 0x03D0;
  9755. t['betdagesh'] = 0xFB31;
  9756. t['betdageshhebrew'] = 0xFB31;
  9757. t['bethebrew'] = 0x05D1;
  9758. t['betrafehebrew'] = 0xFB4C;
  9759. t['bhabengali'] = 0x09AD;
  9760. t['bhadeva'] = 0x092D;
  9761. t['bhagujarati'] = 0x0AAD;
  9762. t['bhagurmukhi'] = 0x0A2D;
  9763. t['bhook'] = 0x0253;
  9764. t['bihiragana'] = 0x3073;
  9765. t['bikatakana'] = 0x30D3;
  9766. t['bilabialclick'] = 0x0298;
  9767. t['bindigurmukhi'] = 0x0A02;
  9768. t['birusquare'] = 0x3331;
  9769. t['blackcircle'] = 0x25CF;
  9770. t['blackdiamond'] = 0x25C6;
  9771. t['blackdownpointingtriangle'] = 0x25BC;
  9772. t['blackleftpointingpointer'] = 0x25C4;
  9773. t['blackleftpointingtriangle'] = 0x25C0;
  9774. t['blacklenticularbracketleft'] = 0x3010;
  9775. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9776. t['blacklenticularbracketright'] = 0x3011;
  9777. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9778. t['blacklowerlefttriangle'] = 0x25E3;
  9779. t['blacklowerrighttriangle'] = 0x25E2;
  9780. t['blackrectangle'] = 0x25AC;
  9781. t['blackrightpointingpointer'] = 0x25BA;
  9782. t['blackrightpointingtriangle'] = 0x25B6;
  9783. t['blacksmallsquare'] = 0x25AA;
  9784. t['blacksmilingface'] = 0x263B;
  9785. t['blacksquare'] = 0x25A0;
  9786. t['blackstar'] = 0x2605;
  9787. t['blackupperlefttriangle'] = 0x25E4;
  9788. t['blackupperrighttriangle'] = 0x25E5;
  9789. t['blackuppointingsmalltriangle'] = 0x25B4;
  9790. t['blackuppointingtriangle'] = 0x25B2;
  9791. t['blank'] = 0x2423;
  9792. t['blinebelow'] = 0x1E07;
  9793. t['block'] = 0x2588;
  9794. t['bmonospace'] = 0xFF42;
  9795. t['bobaimaithai'] = 0x0E1A;
  9796. t['bohiragana'] = 0x307C;
  9797. t['bokatakana'] = 0x30DC;
  9798. t['bparen'] = 0x249D;
  9799. t['bqsquare'] = 0x33C3;
  9800. t['braceex'] = 0xF8F4;
  9801. t['braceleft'] = 0x007B;
  9802. t['braceleftbt'] = 0xF8F3;
  9803. t['braceleftmid'] = 0xF8F2;
  9804. t['braceleftmonospace'] = 0xFF5B;
  9805. t['braceleftsmall'] = 0xFE5B;
  9806. t['bracelefttp'] = 0xF8F1;
  9807. t['braceleftvertical'] = 0xFE37;
  9808. t['braceright'] = 0x007D;
  9809. t['bracerightbt'] = 0xF8FE;
  9810. t['bracerightmid'] = 0xF8FD;
  9811. t['bracerightmonospace'] = 0xFF5D;
  9812. t['bracerightsmall'] = 0xFE5C;
  9813. t['bracerighttp'] = 0xF8FC;
  9814. t['bracerightvertical'] = 0xFE38;
  9815. t['bracketleft'] = 0x005B;
  9816. t['bracketleftbt'] = 0xF8F0;
  9817. t['bracketleftex'] = 0xF8EF;
  9818. t['bracketleftmonospace'] = 0xFF3B;
  9819. t['bracketlefttp'] = 0xF8EE;
  9820. t['bracketright'] = 0x005D;
  9821. t['bracketrightbt'] = 0xF8FB;
  9822. t['bracketrightex'] = 0xF8FA;
  9823. t['bracketrightmonospace'] = 0xFF3D;
  9824. t['bracketrighttp'] = 0xF8F9;
  9825. t['breve'] = 0x02D8;
  9826. t['brevebelowcmb'] = 0x032E;
  9827. t['brevecmb'] = 0x0306;
  9828. t['breveinvertedbelowcmb'] = 0x032F;
  9829. t['breveinvertedcmb'] = 0x0311;
  9830. t['breveinverteddoublecmb'] = 0x0361;
  9831. t['bridgebelowcmb'] = 0x032A;
  9832. t['bridgeinvertedbelowcmb'] = 0x033A;
  9833. t['brokenbar'] = 0x00A6;
  9834. t['bstroke'] = 0x0180;
  9835. t['bsuperior'] = 0xF6EA;
  9836. t['btopbar'] = 0x0183;
  9837. t['buhiragana'] = 0x3076;
  9838. t['bukatakana'] = 0x30D6;
  9839. t['bullet'] = 0x2022;
  9840. t['bulletinverse'] = 0x25D8;
  9841. t['bulletoperator'] = 0x2219;
  9842. t['bullseye'] = 0x25CE;
  9843. t['c'] = 0x0063;
  9844. t['caarmenian'] = 0x056E;
  9845. t['cabengali'] = 0x099A;
  9846. t['cacute'] = 0x0107;
  9847. t['cadeva'] = 0x091A;
  9848. t['cagujarati'] = 0x0A9A;
  9849. t['cagurmukhi'] = 0x0A1A;
  9850. t['calsquare'] = 0x3388;
  9851. t['candrabindubengali'] = 0x0981;
  9852. t['candrabinducmb'] = 0x0310;
  9853. t['candrabindudeva'] = 0x0901;
  9854. t['candrabindugujarati'] = 0x0A81;
  9855. t['capslock'] = 0x21EA;
  9856. t['careof'] = 0x2105;
  9857. t['caron'] = 0x02C7;
  9858. t['caronbelowcmb'] = 0x032C;
  9859. t['caroncmb'] = 0x030C;
  9860. t['carriagereturn'] = 0x21B5;
  9861. t['cbopomofo'] = 0x3118;
  9862. t['ccaron'] = 0x010D;
  9863. t['ccedilla'] = 0x00E7;
  9864. t['ccedillaacute'] = 0x1E09;
  9865. t['ccircle'] = 0x24D2;
  9866. t['ccircumflex'] = 0x0109;
  9867. t['ccurl'] = 0x0255;
  9868. t['cdot'] = 0x010B;
  9869. t['cdotaccent'] = 0x010B;
  9870. t['cdsquare'] = 0x33C5;
  9871. t['cedilla'] = 0x00B8;
  9872. t['cedillacmb'] = 0x0327;
  9873. t['cent'] = 0x00A2;
  9874. t['centigrade'] = 0x2103;
  9875. t['centinferior'] = 0xF6DF;
  9876. t['centmonospace'] = 0xFFE0;
  9877. t['centoldstyle'] = 0xF7A2;
  9878. t['centsuperior'] = 0xF6E0;
  9879. t['chaarmenian'] = 0x0579;
  9880. t['chabengali'] = 0x099B;
  9881. t['chadeva'] = 0x091B;
  9882. t['chagujarati'] = 0x0A9B;
  9883. t['chagurmukhi'] = 0x0A1B;
  9884. t['chbopomofo'] = 0x3114;
  9885. t['cheabkhasiancyrillic'] = 0x04BD;
  9886. t['checkmark'] = 0x2713;
  9887. t['checyrillic'] = 0x0447;
  9888. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9889. t['chedescendercyrillic'] = 0x04B7;
  9890. t['chedieresiscyrillic'] = 0x04F5;
  9891. t['cheharmenian'] = 0x0573;
  9892. t['chekhakassiancyrillic'] = 0x04CC;
  9893. t['cheverticalstrokecyrillic'] = 0x04B9;
  9894. t['chi'] = 0x03C7;
  9895. t['chieuchacirclekorean'] = 0x3277;
  9896. t['chieuchaparenkorean'] = 0x3217;
  9897. t['chieuchcirclekorean'] = 0x3269;
  9898. t['chieuchkorean'] = 0x314A;
  9899. t['chieuchparenkorean'] = 0x3209;
  9900. t['chochangthai'] = 0x0E0A;
  9901. t['chochanthai'] = 0x0E08;
  9902. t['chochingthai'] = 0x0E09;
  9903. t['chochoethai'] = 0x0E0C;
  9904. t['chook'] = 0x0188;
  9905. t['cieucacirclekorean'] = 0x3276;
  9906. t['cieucaparenkorean'] = 0x3216;
  9907. t['cieuccirclekorean'] = 0x3268;
  9908. t['cieuckorean'] = 0x3148;
  9909. t['cieucparenkorean'] = 0x3208;
  9910. t['cieucuparenkorean'] = 0x321C;
  9911. t['circle'] = 0x25CB;
  9912. t['circlecopyrt'] = 0x00A9;
  9913. t['circlemultiply'] = 0x2297;
  9914. t['circleot'] = 0x2299;
  9915. t['circleplus'] = 0x2295;
  9916. t['circlepostalmark'] = 0x3036;
  9917. t['circlewithlefthalfblack'] = 0x25D0;
  9918. t['circlewithrighthalfblack'] = 0x25D1;
  9919. t['circumflex'] = 0x02C6;
  9920. t['circumflexbelowcmb'] = 0x032D;
  9921. t['circumflexcmb'] = 0x0302;
  9922. t['clear'] = 0x2327;
  9923. t['clickalveolar'] = 0x01C2;
  9924. t['clickdental'] = 0x01C0;
  9925. t['clicklateral'] = 0x01C1;
  9926. t['clickretroflex'] = 0x01C3;
  9927. t['club'] = 0x2663;
  9928. t['clubsuitblack'] = 0x2663;
  9929. t['clubsuitwhite'] = 0x2667;
  9930. t['cmcubedsquare'] = 0x33A4;
  9931. t['cmonospace'] = 0xFF43;
  9932. t['cmsquaredsquare'] = 0x33A0;
  9933. t['coarmenian'] = 0x0581;
  9934. t['colon'] = 0x003A;
  9935. t['colonmonetary'] = 0x20A1;
  9936. t['colonmonospace'] = 0xFF1A;
  9937. t['colonsign'] = 0x20A1;
  9938. t['colonsmall'] = 0xFE55;
  9939. t['colontriangularhalfmod'] = 0x02D1;
  9940. t['colontriangularmod'] = 0x02D0;
  9941. t['comma'] = 0x002C;
  9942. t['commaabovecmb'] = 0x0313;
  9943. t['commaaboverightcmb'] = 0x0315;
  9944. t['commaaccent'] = 0xF6C3;
  9945. t['commaarabic'] = 0x060C;
  9946. t['commaarmenian'] = 0x055D;
  9947. t['commainferior'] = 0xF6E1;
  9948. t['commamonospace'] = 0xFF0C;
  9949. t['commareversedabovecmb'] = 0x0314;
  9950. t['commareversedmod'] = 0x02BD;
  9951. t['commasmall'] = 0xFE50;
  9952. t['commasuperior'] = 0xF6E2;
  9953. t['commaturnedabovecmb'] = 0x0312;
  9954. t['commaturnedmod'] = 0x02BB;
  9955. t['compass'] = 0x263C;
  9956. t['congruent'] = 0x2245;
  9957. t['contourintegral'] = 0x222E;
  9958. t['control'] = 0x2303;
  9959. t['controlACK'] = 0x0006;
  9960. t['controlBEL'] = 0x0007;
  9961. t['controlBS'] = 0x0008;
  9962. t['controlCAN'] = 0x0018;
  9963. t['controlCR'] = 0x000D;
  9964. t['controlDC1'] = 0x0011;
  9965. t['controlDC2'] = 0x0012;
  9966. t['controlDC3'] = 0x0013;
  9967. t['controlDC4'] = 0x0014;
  9968. t['controlDEL'] = 0x007F;
  9969. t['controlDLE'] = 0x0010;
  9970. t['controlEM'] = 0x0019;
  9971. t['controlENQ'] = 0x0005;
  9972. t['controlEOT'] = 0x0004;
  9973. t['controlESC'] = 0x001B;
  9974. t['controlETB'] = 0x0017;
  9975. t['controlETX'] = 0x0003;
  9976. t['controlFF'] = 0x000C;
  9977. t['controlFS'] = 0x001C;
  9978. t['controlGS'] = 0x001D;
  9979. t['controlHT'] = 0x0009;
  9980. t['controlLF'] = 0x000A;
  9981. t['controlNAK'] = 0x0015;
  9982. t['controlNULL'] = 0x0000;
  9983. t['controlRS'] = 0x001E;
  9984. t['controlSI'] = 0x000F;
  9985. t['controlSO'] = 0x000E;
  9986. t['controlSOT'] = 0x0002;
  9987. t['controlSTX'] = 0x0001;
  9988. t['controlSUB'] = 0x001A;
  9989. t['controlSYN'] = 0x0016;
  9990. t['controlUS'] = 0x001F;
  9991. t['controlVT'] = 0x000B;
  9992. t['copyright'] = 0x00A9;
  9993. t['copyrightsans'] = 0xF8E9;
  9994. t['copyrightserif'] = 0xF6D9;
  9995. t['cornerbracketleft'] = 0x300C;
  9996. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9997. t['cornerbracketleftvertical'] = 0xFE41;
  9998. t['cornerbracketright'] = 0x300D;
  9999. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10000. t['cornerbracketrightvertical'] = 0xFE42;
  10001. t['corporationsquare'] = 0x337F;
  10002. t['cosquare'] = 0x33C7;
  10003. t['coverkgsquare'] = 0x33C6;
  10004. t['cparen'] = 0x249E;
  10005. t['cruzeiro'] = 0x20A2;
  10006. t['cstretched'] = 0x0297;
  10007. t['curlyand'] = 0x22CF;
  10008. t['curlyor'] = 0x22CE;
  10009. t['currency'] = 0x00A4;
  10010. t['cyrBreve'] = 0xF6D1;
  10011. t['cyrFlex'] = 0xF6D2;
  10012. t['cyrbreve'] = 0xF6D4;
  10013. t['cyrflex'] = 0xF6D5;
  10014. t['d'] = 0x0064;
  10015. t['daarmenian'] = 0x0564;
  10016. t['dabengali'] = 0x09A6;
  10017. t['dadarabic'] = 0x0636;
  10018. t['dadeva'] = 0x0926;
  10019. t['dadfinalarabic'] = 0xFEBE;
  10020. t['dadinitialarabic'] = 0xFEBF;
  10021. t['dadmedialarabic'] = 0xFEC0;
  10022. t['dagesh'] = 0x05BC;
  10023. t['dageshhebrew'] = 0x05BC;
  10024. t['dagger'] = 0x2020;
  10025. t['daggerdbl'] = 0x2021;
  10026. t['dagujarati'] = 0x0AA6;
  10027. t['dagurmukhi'] = 0x0A26;
  10028. t['dahiragana'] = 0x3060;
  10029. t['dakatakana'] = 0x30C0;
  10030. t['dalarabic'] = 0x062F;
  10031. t['dalet'] = 0x05D3;
  10032. t['daletdagesh'] = 0xFB33;
  10033. t['daletdageshhebrew'] = 0xFB33;
  10034. t['dalethebrew'] = 0x05D3;
  10035. t['dalfinalarabic'] = 0xFEAA;
  10036. t['dammaarabic'] = 0x064F;
  10037. t['dammalowarabic'] = 0x064F;
  10038. t['dammatanaltonearabic'] = 0x064C;
  10039. t['dammatanarabic'] = 0x064C;
  10040. t['danda'] = 0x0964;
  10041. t['dargahebrew'] = 0x05A7;
  10042. t['dargalefthebrew'] = 0x05A7;
  10043. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10044. t['dblGrave'] = 0xF6D3;
  10045. t['dblanglebracketleft'] = 0x300A;
  10046. t['dblanglebracketleftvertical'] = 0xFE3D;
  10047. t['dblanglebracketright'] = 0x300B;
  10048. t['dblanglebracketrightvertical'] = 0xFE3E;
  10049. t['dblarchinvertedbelowcmb'] = 0x032B;
  10050. t['dblarrowleft'] = 0x21D4;
  10051. t['dblarrowright'] = 0x21D2;
  10052. t['dbldanda'] = 0x0965;
  10053. t['dblgrave'] = 0xF6D6;
  10054. t['dblgravecmb'] = 0x030F;
  10055. t['dblintegral'] = 0x222C;
  10056. t['dbllowline'] = 0x2017;
  10057. t['dbllowlinecmb'] = 0x0333;
  10058. t['dbloverlinecmb'] = 0x033F;
  10059. t['dblprimemod'] = 0x02BA;
  10060. t['dblverticalbar'] = 0x2016;
  10061. t['dblverticallineabovecmb'] = 0x030E;
  10062. t['dbopomofo'] = 0x3109;
  10063. t['dbsquare'] = 0x33C8;
  10064. t['dcaron'] = 0x010F;
  10065. t['dcedilla'] = 0x1E11;
  10066. t['dcircle'] = 0x24D3;
  10067. t['dcircumflexbelow'] = 0x1E13;
  10068. t['dcroat'] = 0x0111;
  10069. t['ddabengali'] = 0x09A1;
  10070. t['ddadeva'] = 0x0921;
  10071. t['ddagujarati'] = 0x0AA1;
  10072. t['ddagurmukhi'] = 0x0A21;
  10073. t['ddalarabic'] = 0x0688;
  10074. t['ddalfinalarabic'] = 0xFB89;
  10075. t['dddhadeva'] = 0x095C;
  10076. t['ddhabengali'] = 0x09A2;
  10077. t['ddhadeva'] = 0x0922;
  10078. t['ddhagujarati'] = 0x0AA2;
  10079. t['ddhagurmukhi'] = 0x0A22;
  10080. t['ddotaccent'] = 0x1E0B;
  10081. t['ddotbelow'] = 0x1E0D;
  10082. t['decimalseparatorarabic'] = 0x066B;
  10083. t['decimalseparatorpersian'] = 0x066B;
  10084. t['decyrillic'] = 0x0434;
  10085. t['degree'] = 0x00B0;
  10086. t['dehihebrew'] = 0x05AD;
  10087. t['dehiragana'] = 0x3067;
  10088. t['deicoptic'] = 0x03EF;
  10089. t['dekatakana'] = 0x30C7;
  10090. t['deleteleft'] = 0x232B;
  10091. t['deleteright'] = 0x2326;
  10092. t['delta'] = 0x03B4;
  10093. t['deltaturned'] = 0x018D;
  10094. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10095. t['dezh'] = 0x02A4;
  10096. t['dhabengali'] = 0x09A7;
  10097. t['dhadeva'] = 0x0927;
  10098. t['dhagujarati'] = 0x0AA7;
  10099. t['dhagurmukhi'] = 0x0A27;
  10100. t['dhook'] = 0x0257;
  10101. t['dialytikatonos'] = 0x0385;
  10102. t['dialytikatonoscmb'] = 0x0344;
  10103. t['diamond'] = 0x2666;
  10104. t['diamondsuitwhite'] = 0x2662;
  10105. t['dieresis'] = 0x00A8;
  10106. t['dieresisacute'] = 0xF6D7;
  10107. t['dieresisbelowcmb'] = 0x0324;
  10108. t['dieresiscmb'] = 0x0308;
  10109. t['dieresisgrave'] = 0xF6D8;
  10110. t['dieresistonos'] = 0x0385;
  10111. t['dihiragana'] = 0x3062;
  10112. t['dikatakana'] = 0x30C2;
  10113. t['dittomark'] = 0x3003;
  10114. t['divide'] = 0x00F7;
  10115. t['divides'] = 0x2223;
  10116. t['divisionslash'] = 0x2215;
  10117. t['djecyrillic'] = 0x0452;
  10118. t['dkshade'] = 0x2593;
  10119. t['dlinebelow'] = 0x1E0F;
  10120. t['dlsquare'] = 0x3397;
  10121. t['dmacron'] = 0x0111;
  10122. t['dmonospace'] = 0xFF44;
  10123. t['dnblock'] = 0x2584;
  10124. t['dochadathai'] = 0x0E0E;
  10125. t['dodekthai'] = 0x0E14;
  10126. t['dohiragana'] = 0x3069;
  10127. t['dokatakana'] = 0x30C9;
  10128. t['dollar'] = 0x0024;
  10129. t['dollarinferior'] = 0xF6E3;
  10130. t['dollarmonospace'] = 0xFF04;
  10131. t['dollaroldstyle'] = 0xF724;
  10132. t['dollarsmall'] = 0xFE69;
  10133. t['dollarsuperior'] = 0xF6E4;
  10134. t['dong'] = 0x20AB;
  10135. t['dorusquare'] = 0x3326;
  10136. t['dotaccent'] = 0x02D9;
  10137. t['dotaccentcmb'] = 0x0307;
  10138. t['dotbelowcmb'] = 0x0323;
  10139. t['dotbelowcomb'] = 0x0323;
  10140. t['dotkatakana'] = 0x30FB;
  10141. t['dotlessi'] = 0x0131;
  10142. t['dotlessj'] = 0xF6BE;
  10143. t['dotlessjstrokehook'] = 0x0284;
  10144. t['dotmath'] = 0x22C5;
  10145. t['dottedcircle'] = 0x25CC;
  10146. t['doubleyodpatah'] = 0xFB1F;
  10147. t['doubleyodpatahhebrew'] = 0xFB1F;
  10148. t['downtackbelowcmb'] = 0x031E;
  10149. t['downtackmod'] = 0x02D5;
  10150. t['dparen'] = 0x249F;
  10151. t['dsuperior'] = 0xF6EB;
  10152. t['dtail'] = 0x0256;
  10153. t['dtopbar'] = 0x018C;
  10154. t['duhiragana'] = 0x3065;
  10155. t['dukatakana'] = 0x30C5;
  10156. t['dz'] = 0x01F3;
  10157. t['dzaltone'] = 0x02A3;
  10158. t['dzcaron'] = 0x01C6;
  10159. t['dzcurl'] = 0x02A5;
  10160. t['dzeabkhasiancyrillic'] = 0x04E1;
  10161. t['dzecyrillic'] = 0x0455;
  10162. t['dzhecyrillic'] = 0x045F;
  10163. t['e'] = 0x0065;
  10164. t['eacute'] = 0x00E9;
  10165. t['earth'] = 0x2641;
  10166. t['ebengali'] = 0x098F;
  10167. t['ebopomofo'] = 0x311C;
  10168. t['ebreve'] = 0x0115;
  10169. t['ecandradeva'] = 0x090D;
  10170. t['ecandragujarati'] = 0x0A8D;
  10171. t['ecandravowelsigndeva'] = 0x0945;
  10172. t['ecandravowelsigngujarati'] = 0x0AC5;
  10173. t['ecaron'] = 0x011B;
  10174. t['ecedillabreve'] = 0x1E1D;
  10175. t['echarmenian'] = 0x0565;
  10176. t['echyiwnarmenian'] = 0x0587;
  10177. t['ecircle'] = 0x24D4;
  10178. t['ecircumflex'] = 0x00EA;
  10179. t['ecircumflexacute'] = 0x1EBF;
  10180. t['ecircumflexbelow'] = 0x1E19;
  10181. t['ecircumflexdotbelow'] = 0x1EC7;
  10182. t['ecircumflexgrave'] = 0x1EC1;
  10183. t['ecircumflexhookabove'] = 0x1EC3;
  10184. t['ecircumflextilde'] = 0x1EC5;
  10185. t['ecyrillic'] = 0x0454;
  10186. t['edblgrave'] = 0x0205;
  10187. t['edeva'] = 0x090F;
  10188. t['edieresis'] = 0x00EB;
  10189. t['edot'] = 0x0117;
  10190. t['edotaccent'] = 0x0117;
  10191. t['edotbelow'] = 0x1EB9;
  10192. t['eegurmukhi'] = 0x0A0F;
  10193. t['eematragurmukhi'] = 0x0A47;
  10194. t['efcyrillic'] = 0x0444;
  10195. t['egrave'] = 0x00E8;
  10196. t['egujarati'] = 0x0A8F;
  10197. t['eharmenian'] = 0x0567;
  10198. t['ehbopomofo'] = 0x311D;
  10199. t['ehiragana'] = 0x3048;
  10200. t['ehookabove'] = 0x1EBB;
  10201. t['eibopomofo'] = 0x311F;
  10202. t['eight'] = 0x0038;
  10203. t['eightarabic'] = 0x0668;
  10204. t['eightbengali'] = 0x09EE;
  10205. t['eightcircle'] = 0x2467;
  10206. t['eightcircleinversesansserif'] = 0x2791;
  10207. t['eightdeva'] = 0x096E;
  10208. t['eighteencircle'] = 0x2471;
  10209. t['eighteenparen'] = 0x2485;
  10210. t['eighteenperiod'] = 0x2499;
  10211. t['eightgujarati'] = 0x0AEE;
  10212. t['eightgurmukhi'] = 0x0A6E;
  10213. t['eighthackarabic'] = 0x0668;
  10214. t['eighthangzhou'] = 0x3028;
  10215. t['eighthnotebeamed'] = 0x266B;
  10216. t['eightideographicparen'] = 0x3227;
  10217. t['eightinferior'] = 0x2088;
  10218. t['eightmonospace'] = 0xFF18;
  10219. t['eightoldstyle'] = 0xF738;
  10220. t['eightparen'] = 0x247B;
  10221. t['eightperiod'] = 0x248F;
  10222. t['eightpersian'] = 0x06F8;
  10223. t['eightroman'] = 0x2177;
  10224. t['eightsuperior'] = 0x2078;
  10225. t['eightthai'] = 0x0E58;
  10226. t['einvertedbreve'] = 0x0207;
  10227. t['eiotifiedcyrillic'] = 0x0465;
  10228. t['ekatakana'] = 0x30A8;
  10229. t['ekatakanahalfwidth'] = 0xFF74;
  10230. t['ekonkargurmukhi'] = 0x0A74;
  10231. t['ekorean'] = 0x3154;
  10232. t['elcyrillic'] = 0x043B;
  10233. t['element'] = 0x2208;
  10234. t['elevencircle'] = 0x246A;
  10235. t['elevenparen'] = 0x247E;
  10236. t['elevenperiod'] = 0x2492;
  10237. t['elevenroman'] = 0x217A;
  10238. t['ellipsis'] = 0x2026;
  10239. t['ellipsisvertical'] = 0x22EE;
  10240. t['emacron'] = 0x0113;
  10241. t['emacronacute'] = 0x1E17;
  10242. t['emacrongrave'] = 0x1E15;
  10243. t['emcyrillic'] = 0x043C;
  10244. t['emdash'] = 0x2014;
  10245. t['emdashvertical'] = 0xFE31;
  10246. t['emonospace'] = 0xFF45;
  10247. t['emphasismarkarmenian'] = 0x055B;
  10248. t['emptyset'] = 0x2205;
  10249. t['enbopomofo'] = 0x3123;
  10250. t['encyrillic'] = 0x043D;
  10251. t['endash'] = 0x2013;
  10252. t['endashvertical'] = 0xFE32;
  10253. t['endescendercyrillic'] = 0x04A3;
  10254. t['eng'] = 0x014B;
  10255. t['engbopomofo'] = 0x3125;
  10256. t['enghecyrillic'] = 0x04A5;
  10257. t['enhookcyrillic'] = 0x04C8;
  10258. t['enspace'] = 0x2002;
  10259. t['eogonek'] = 0x0119;
  10260. t['eokorean'] = 0x3153;
  10261. t['eopen'] = 0x025B;
  10262. t['eopenclosed'] = 0x029A;
  10263. t['eopenreversed'] = 0x025C;
  10264. t['eopenreversedclosed'] = 0x025E;
  10265. t['eopenreversedhook'] = 0x025D;
  10266. t['eparen'] = 0x24A0;
  10267. t['epsilon'] = 0x03B5;
  10268. t['epsilontonos'] = 0x03AD;
  10269. t['equal'] = 0x003D;
  10270. t['equalmonospace'] = 0xFF1D;
  10271. t['equalsmall'] = 0xFE66;
  10272. t['equalsuperior'] = 0x207C;
  10273. t['equivalence'] = 0x2261;
  10274. t['erbopomofo'] = 0x3126;
  10275. t['ercyrillic'] = 0x0440;
  10276. t['ereversed'] = 0x0258;
  10277. t['ereversedcyrillic'] = 0x044D;
  10278. t['escyrillic'] = 0x0441;
  10279. t['esdescendercyrillic'] = 0x04AB;
  10280. t['esh'] = 0x0283;
  10281. t['eshcurl'] = 0x0286;
  10282. t['eshortdeva'] = 0x090E;
  10283. t['eshortvowelsigndeva'] = 0x0946;
  10284. t['eshreversedloop'] = 0x01AA;
  10285. t['eshsquatreversed'] = 0x0285;
  10286. t['esmallhiragana'] = 0x3047;
  10287. t['esmallkatakana'] = 0x30A7;
  10288. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10289. t['estimated'] = 0x212E;
  10290. t['esuperior'] = 0xF6EC;
  10291. t['eta'] = 0x03B7;
  10292. t['etarmenian'] = 0x0568;
  10293. t['etatonos'] = 0x03AE;
  10294. t['eth'] = 0x00F0;
  10295. t['etilde'] = 0x1EBD;
  10296. t['etildebelow'] = 0x1E1B;
  10297. t['etnahtafoukhhebrew'] = 0x0591;
  10298. t['etnahtafoukhlefthebrew'] = 0x0591;
  10299. t['etnahtahebrew'] = 0x0591;
  10300. t['etnahtalefthebrew'] = 0x0591;
  10301. t['eturned'] = 0x01DD;
  10302. t['eukorean'] = 0x3161;
  10303. t['euro'] = 0x20AC;
  10304. t['evowelsignbengali'] = 0x09C7;
  10305. t['evowelsigndeva'] = 0x0947;
  10306. t['evowelsigngujarati'] = 0x0AC7;
  10307. t['exclam'] = 0x0021;
  10308. t['exclamarmenian'] = 0x055C;
  10309. t['exclamdbl'] = 0x203C;
  10310. t['exclamdown'] = 0x00A1;
  10311. t['exclamdownsmall'] = 0xF7A1;
  10312. t['exclammonospace'] = 0xFF01;
  10313. t['exclamsmall'] = 0xF721;
  10314. t['existential'] = 0x2203;
  10315. t['ezh'] = 0x0292;
  10316. t['ezhcaron'] = 0x01EF;
  10317. t['ezhcurl'] = 0x0293;
  10318. t['ezhreversed'] = 0x01B9;
  10319. t['ezhtail'] = 0x01BA;
  10320. t['f'] = 0x0066;
  10321. t['fadeva'] = 0x095E;
  10322. t['fagurmukhi'] = 0x0A5E;
  10323. t['fahrenheit'] = 0x2109;
  10324. t['fathaarabic'] = 0x064E;
  10325. t['fathalowarabic'] = 0x064E;
  10326. t['fathatanarabic'] = 0x064B;
  10327. t['fbopomofo'] = 0x3108;
  10328. t['fcircle'] = 0x24D5;
  10329. t['fdotaccent'] = 0x1E1F;
  10330. t['feharabic'] = 0x0641;
  10331. t['feharmenian'] = 0x0586;
  10332. t['fehfinalarabic'] = 0xFED2;
  10333. t['fehinitialarabic'] = 0xFED3;
  10334. t['fehmedialarabic'] = 0xFED4;
  10335. t['feicoptic'] = 0x03E5;
  10336. t['female'] = 0x2640;
  10337. t['ff'] = 0xFB00;
  10338. t['ffi'] = 0xFB03;
  10339. t['ffl'] = 0xFB04;
  10340. t['fi'] = 0xFB01;
  10341. t['fifteencircle'] = 0x246E;
  10342. t['fifteenparen'] = 0x2482;
  10343. t['fifteenperiod'] = 0x2496;
  10344. t['figuredash'] = 0x2012;
  10345. t['filledbox'] = 0x25A0;
  10346. t['filledrect'] = 0x25AC;
  10347. t['finalkaf'] = 0x05DA;
  10348. t['finalkafdagesh'] = 0xFB3A;
  10349. t['finalkafdageshhebrew'] = 0xFB3A;
  10350. t['finalkafhebrew'] = 0x05DA;
  10351. t['finalmem'] = 0x05DD;
  10352. t['finalmemhebrew'] = 0x05DD;
  10353. t['finalnun'] = 0x05DF;
  10354. t['finalnunhebrew'] = 0x05DF;
  10355. t['finalpe'] = 0x05E3;
  10356. t['finalpehebrew'] = 0x05E3;
  10357. t['finaltsadi'] = 0x05E5;
  10358. t['finaltsadihebrew'] = 0x05E5;
  10359. t['firsttonechinese'] = 0x02C9;
  10360. t['fisheye'] = 0x25C9;
  10361. t['fitacyrillic'] = 0x0473;
  10362. t['five'] = 0x0035;
  10363. t['fivearabic'] = 0x0665;
  10364. t['fivebengali'] = 0x09EB;
  10365. t['fivecircle'] = 0x2464;
  10366. t['fivecircleinversesansserif'] = 0x278E;
  10367. t['fivedeva'] = 0x096B;
  10368. t['fiveeighths'] = 0x215D;
  10369. t['fivegujarati'] = 0x0AEB;
  10370. t['fivegurmukhi'] = 0x0A6B;
  10371. t['fivehackarabic'] = 0x0665;
  10372. t['fivehangzhou'] = 0x3025;
  10373. t['fiveideographicparen'] = 0x3224;
  10374. t['fiveinferior'] = 0x2085;
  10375. t['fivemonospace'] = 0xFF15;
  10376. t['fiveoldstyle'] = 0xF735;
  10377. t['fiveparen'] = 0x2478;
  10378. t['fiveperiod'] = 0x248C;
  10379. t['fivepersian'] = 0x06F5;
  10380. t['fiveroman'] = 0x2174;
  10381. t['fivesuperior'] = 0x2075;
  10382. t['fivethai'] = 0x0E55;
  10383. t['fl'] = 0xFB02;
  10384. t['florin'] = 0x0192;
  10385. t['fmonospace'] = 0xFF46;
  10386. t['fmsquare'] = 0x3399;
  10387. t['fofanthai'] = 0x0E1F;
  10388. t['fofathai'] = 0x0E1D;
  10389. t['fongmanthai'] = 0x0E4F;
  10390. t['forall'] = 0x2200;
  10391. t['four'] = 0x0034;
  10392. t['fourarabic'] = 0x0664;
  10393. t['fourbengali'] = 0x09EA;
  10394. t['fourcircle'] = 0x2463;
  10395. t['fourcircleinversesansserif'] = 0x278D;
  10396. t['fourdeva'] = 0x096A;
  10397. t['fourgujarati'] = 0x0AEA;
  10398. t['fourgurmukhi'] = 0x0A6A;
  10399. t['fourhackarabic'] = 0x0664;
  10400. t['fourhangzhou'] = 0x3024;
  10401. t['fourideographicparen'] = 0x3223;
  10402. t['fourinferior'] = 0x2084;
  10403. t['fourmonospace'] = 0xFF14;
  10404. t['fournumeratorbengali'] = 0x09F7;
  10405. t['fouroldstyle'] = 0xF734;
  10406. t['fourparen'] = 0x2477;
  10407. t['fourperiod'] = 0x248B;
  10408. t['fourpersian'] = 0x06F4;
  10409. t['fourroman'] = 0x2173;
  10410. t['foursuperior'] = 0x2074;
  10411. t['fourteencircle'] = 0x246D;
  10412. t['fourteenparen'] = 0x2481;
  10413. t['fourteenperiod'] = 0x2495;
  10414. t['fourthai'] = 0x0E54;
  10415. t['fourthtonechinese'] = 0x02CB;
  10416. t['fparen'] = 0x24A1;
  10417. t['fraction'] = 0x2044;
  10418. t['franc'] = 0x20A3;
  10419. t['g'] = 0x0067;
  10420. t['gabengali'] = 0x0997;
  10421. t['gacute'] = 0x01F5;
  10422. t['gadeva'] = 0x0917;
  10423. t['gafarabic'] = 0x06AF;
  10424. t['gaffinalarabic'] = 0xFB93;
  10425. t['gafinitialarabic'] = 0xFB94;
  10426. t['gafmedialarabic'] = 0xFB95;
  10427. t['gagujarati'] = 0x0A97;
  10428. t['gagurmukhi'] = 0x0A17;
  10429. t['gahiragana'] = 0x304C;
  10430. t['gakatakana'] = 0x30AC;
  10431. t['gamma'] = 0x03B3;
  10432. t['gammalatinsmall'] = 0x0263;
  10433. t['gammasuperior'] = 0x02E0;
  10434. t['gangiacoptic'] = 0x03EB;
  10435. t['gbopomofo'] = 0x310D;
  10436. t['gbreve'] = 0x011F;
  10437. t['gcaron'] = 0x01E7;
  10438. t['gcedilla'] = 0x0123;
  10439. t['gcircle'] = 0x24D6;
  10440. t['gcircumflex'] = 0x011D;
  10441. t['gcommaaccent'] = 0x0123;
  10442. t['gdot'] = 0x0121;
  10443. t['gdotaccent'] = 0x0121;
  10444. t['gecyrillic'] = 0x0433;
  10445. t['gehiragana'] = 0x3052;
  10446. t['gekatakana'] = 0x30B2;
  10447. t['geometricallyequal'] = 0x2251;
  10448. t['gereshaccenthebrew'] = 0x059C;
  10449. t['gereshhebrew'] = 0x05F3;
  10450. t['gereshmuqdamhebrew'] = 0x059D;
  10451. t['germandbls'] = 0x00DF;
  10452. t['gershayimaccenthebrew'] = 0x059E;
  10453. t['gershayimhebrew'] = 0x05F4;
  10454. t['getamark'] = 0x3013;
  10455. t['ghabengali'] = 0x0998;
  10456. t['ghadarmenian'] = 0x0572;
  10457. t['ghadeva'] = 0x0918;
  10458. t['ghagujarati'] = 0x0A98;
  10459. t['ghagurmukhi'] = 0x0A18;
  10460. t['ghainarabic'] = 0x063A;
  10461. t['ghainfinalarabic'] = 0xFECE;
  10462. t['ghaininitialarabic'] = 0xFECF;
  10463. t['ghainmedialarabic'] = 0xFED0;
  10464. t['ghemiddlehookcyrillic'] = 0x0495;
  10465. t['ghestrokecyrillic'] = 0x0493;
  10466. t['gheupturncyrillic'] = 0x0491;
  10467. t['ghhadeva'] = 0x095A;
  10468. t['ghhagurmukhi'] = 0x0A5A;
  10469. t['ghook'] = 0x0260;
  10470. t['ghzsquare'] = 0x3393;
  10471. t['gihiragana'] = 0x304E;
  10472. t['gikatakana'] = 0x30AE;
  10473. t['gimarmenian'] = 0x0563;
  10474. t['gimel'] = 0x05D2;
  10475. t['gimeldagesh'] = 0xFB32;
  10476. t['gimeldageshhebrew'] = 0xFB32;
  10477. t['gimelhebrew'] = 0x05D2;
  10478. t['gjecyrillic'] = 0x0453;
  10479. t['glottalinvertedstroke'] = 0x01BE;
  10480. t['glottalstop'] = 0x0294;
  10481. t['glottalstopinverted'] = 0x0296;
  10482. t['glottalstopmod'] = 0x02C0;
  10483. t['glottalstopreversed'] = 0x0295;
  10484. t['glottalstopreversedmod'] = 0x02C1;
  10485. t['glottalstopreversedsuperior'] = 0x02E4;
  10486. t['glottalstopstroke'] = 0x02A1;
  10487. t['glottalstopstrokereversed'] = 0x02A2;
  10488. t['gmacron'] = 0x1E21;
  10489. t['gmonospace'] = 0xFF47;
  10490. t['gohiragana'] = 0x3054;
  10491. t['gokatakana'] = 0x30B4;
  10492. t['gparen'] = 0x24A2;
  10493. t['gpasquare'] = 0x33AC;
  10494. t['gradient'] = 0x2207;
  10495. t['grave'] = 0x0060;
  10496. t['gravebelowcmb'] = 0x0316;
  10497. t['gravecmb'] = 0x0300;
  10498. t['gravecomb'] = 0x0300;
  10499. t['gravedeva'] = 0x0953;
  10500. t['gravelowmod'] = 0x02CE;
  10501. t['gravemonospace'] = 0xFF40;
  10502. t['gravetonecmb'] = 0x0340;
  10503. t['greater'] = 0x003E;
  10504. t['greaterequal'] = 0x2265;
  10505. t['greaterequalorless'] = 0x22DB;
  10506. t['greatermonospace'] = 0xFF1E;
  10507. t['greaterorequivalent'] = 0x2273;
  10508. t['greaterorless'] = 0x2277;
  10509. t['greateroverequal'] = 0x2267;
  10510. t['greatersmall'] = 0xFE65;
  10511. t['gscript'] = 0x0261;
  10512. t['gstroke'] = 0x01E5;
  10513. t['guhiragana'] = 0x3050;
  10514. t['guillemotleft'] = 0x00AB;
  10515. t['guillemotright'] = 0x00BB;
  10516. t['guilsinglleft'] = 0x2039;
  10517. t['guilsinglright'] = 0x203A;
  10518. t['gukatakana'] = 0x30B0;
  10519. t['guramusquare'] = 0x3318;
  10520. t['gysquare'] = 0x33C9;
  10521. t['h'] = 0x0068;
  10522. t['haabkhasiancyrillic'] = 0x04A9;
  10523. t['haaltonearabic'] = 0x06C1;
  10524. t['habengali'] = 0x09B9;
  10525. t['hadescendercyrillic'] = 0x04B3;
  10526. t['hadeva'] = 0x0939;
  10527. t['hagujarati'] = 0x0AB9;
  10528. t['hagurmukhi'] = 0x0A39;
  10529. t['haharabic'] = 0x062D;
  10530. t['hahfinalarabic'] = 0xFEA2;
  10531. t['hahinitialarabic'] = 0xFEA3;
  10532. t['hahiragana'] = 0x306F;
  10533. t['hahmedialarabic'] = 0xFEA4;
  10534. t['haitusquare'] = 0x332A;
  10535. t['hakatakana'] = 0x30CF;
  10536. t['hakatakanahalfwidth'] = 0xFF8A;
  10537. t['halantgurmukhi'] = 0x0A4D;
  10538. t['hamzaarabic'] = 0x0621;
  10539. t['hamzalowarabic'] = 0x0621;
  10540. t['hangulfiller'] = 0x3164;
  10541. t['hardsigncyrillic'] = 0x044A;
  10542. t['harpoonleftbarbup'] = 0x21BC;
  10543. t['harpoonrightbarbup'] = 0x21C0;
  10544. t['hasquare'] = 0x33CA;
  10545. t['hatafpatah'] = 0x05B2;
  10546. t['hatafpatah16'] = 0x05B2;
  10547. t['hatafpatah23'] = 0x05B2;
  10548. t['hatafpatah2f'] = 0x05B2;
  10549. t['hatafpatahhebrew'] = 0x05B2;
  10550. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10551. t['hatafpatahquarterhebrew'] = 0x05B2;
  10552. t['hatafpatahwidehebrew'] = 0x05B2;
  10553. t['hatafqamats'] = 0x05B3;
  10554. t['hatafqamats1b'] = 0x05B3;
  10555. t['hatafqamats28'] = 0x05B3;
  10556. t['hatafqamats34'] = 0x05B3;
  10557. t['hatafqamatshebrew'] = 0x05B3;
  10558. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10559. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10560. t['hatafqamatswidehebrew'] = 0x05B3;
  10561. t['hatafsegol'] = 0x05B1;
  10562. t['hatafsegol17'] = 0x05B1;
  10563. t['hatafsegol24'] = 0x05B1;
  10564. t['hatafsegol30'] = 0x05B1;
  10565. t['hatafsegolhebrew'] = 0x05B1;
  10566. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10567. t['hatafsegolquarterhebrew'] = 0x05B1;
  10568. t['hatafsegolwidehebrew'] = 0x05B1;
  10569. t['hbar'] = 0x0127;
  10570. t['hbopomofo'] = 0x310F;
  10571. t['hbrevebelow'] = 0x1E2B;
  10572. t['hcedilla'] = 0x1E29;
  10573. t['hcircle'] = 0x24D7;
  10574. t['hcircumflex'] = 0x0125;
  10575. t['hdieresis'] = 0x1E27;
  10576. t['hdotaccent'] = 0x1E23;
  10577. t['hdotbelow'] = 0x1E25;
  10578. t['he'] = 0x05D4;
  10579. t['heart'] = 0x2665;
  10580. t['heartsuitblack'] = 0x2665;
  10581. t['heartsuitwhite'] = 0x2661;
  10582. t['hedagesh'] = 0xFB34;
  10583. t['hedageshhebrew'] = 0xFB34;
  10584. t['hehaltonearabic'] = 0x06C1;
  10585. t['heharabic'] = 0x0647;
  10586. t['hehebrew'] = 0x05D4;
  10587. t['hehfinalaltonearabic'] = 0xFBA7;
  10588. t['hehfinalalttwoarabic'] = 0xFEEA;
  10589. t['hehfinalarabic'] = 0xFEEA;
  10590. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10591. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10592. t['hehinitialaltonearabic'] = 0xFBA8;
  10593. t['hehinitialarabic'] = 0xFEEB;
  10594. t['hehiragana'] = 0x3078;
  10595. t['hehmedialaltonearabic'] = 0xFBA9;
  10596. t['hehmedialarabic'] = 0xFEEC;
  10597. t['heiseierasquare'] = 0x337B;
  10598. t['hekatakana'] = 0x30D8;
  10599. t['hekatakanahalfwidth'] = 0xFF8D;
  10600. t['hekutaarusquare'] = 0x3336;
  10601. t['henghook'] = 0x0267;
  10602. t['herutusquare'] = 0x3339;
  10603. t['het'] = 0x05D7;
  10604. t['hethebrew'] = 0x05D7;
  10605. t['hhook'] = 0x0266;
  10606. t['hhooksuperior'] = 0x02B1;
  10607. t['hieuhacirclekorean'] = 0x327B;
  10608. t['hieuhaparenkorean'] = 0x321B;
  10609. t['hieuhcirclekorean'] = 0x326D;
  10610. t['hieuhkorean'] = 0x314E;
  10611. t['hieuhparenkorean'] = 0x320D;
  10612. t['hihiragana'] = 0x3072;
  10613. t['hikatakana'] = 0x30D2;
  10614. t['hikatakanahalfwidth'] = 0xFF8B;
  10615. t['hiriq'] = 0x05B4;
  10616. t['hiriq14'] = 0x05B4;
  10617. t['hiriq21'] = 0x05B4;
  10618. t['hiriq2d'] = 0x05B4;
  10619. t['hiriqhebrew'] = 0x05B4;
  10620. t['hiriqnarrowhebrew'] = 0x05B4;
  10621. t['hiriqquarterhebrew'] = 0x05B4;
  10622. t['hiriqwidehebrew'] = 0x05B4;
  10623. t['hlinebelow'] = 0x1E96;
  10624. t['hmonospace'] = 0xFF48;
  10625. t['hoarmenian'] = 0x0570;
  10626. t['hohipthai'] = 0x0E2B;
  10627. t['hohiragana'] = 0x307B;
  10628. t['hokatakana'] = 0x30DB;
  10629. t['hokatakanahalfwidth'] = 0xFF8E;
  10630. t['holam'] = 0x05B9;
  10631. t['holam19'] = 0x05B9;
  10632. t['holam26'] = 0x05B9;
  10633. t['holam32'] = 0x05B9;
  10634. t['holamhebrew'] = 0x05B9;
  10635. t['holamnarrowhebrew'] = 0x05B9;
  10636. t['holamquarterhebrew'] = 0x05B9;
  10637. t['holamwidehebrew'] = 0x05B9;
  10638. t['honokhukthai'] = 0x0E2E;
  10639. t['hookabovecomb'] = 0x0309;
  10640. t['hookcmb'] = 0x0309;
  10641. t['hookpalatalizedbelowcmb'] = 0x0321;
  10642. t['hookretroflexbelowcmb'] = 0x0322;
  10643. t['hoonsquare'] = 0x3342;
  10644. t['horicoptic'] = 0x03E9;
  10645. t['horizontalbar'] = 0x2015;
  10646. t['horncmb'] = 0x031B;
  10647. t['hotsprings'] = 0x2668;
  10648. t['house'] = 0x2302;
  10649. t['hparen'] = 0x24A3;
  10650. t['hsuperior'] = 0x02B0;
  10651. t['hturned'] = 0x0265;
  10652. t['huhiragana'] = 0x3075;
  10653. t['huiitosquare'] = 0x3333;
  10654. t['hukatakana'] = 0x30D5;
  10655. t['hukatakanahalfwidth'] = 0xFF8C;
  10656. t['hungarumlaut'] = 0x02DD;
  10657. t['hungarumlautcmb'] = 0x030B;
  10658. t['hv'] = 0x0195;
  10659. t['hyphen'] = 0x002D;
  10660. t['hypheninferior'] = 0xF6E5;
  10661. t['hyphenmonospace'] = 0xFF0D;
  10662. t['hyphensmall'] = 0xFE63;
  10663. t['hyphensuperior'] = 0xF6E6;
  10664. t['hyphentwo'] = 0x2010;
  10665. t['i'] = 0x0069;
  10666. t['iacute'] = 0x00ED;
  10667. t['iacyrillic'] = 0x044F;
  10668. t['ibengali'] = 0x0987;
  10669. t['ibopomofo'] = 0x3127;
  10670. t['ibreve'] = 0x012D;
  10671. t['icaron'] = 0x01D0;
  10672. t['icircle'] = 0x24D8;
  10673. t['icircumflex'] = 0x00EE;
  10674. t['icyrillic'] = 0x0456;
  10675. t['idblgrave'] = 0x0209;
  10676. t['ideographearthcircle'] = 0x328F;
  10677. t['ideographfirecircle'] = 0x328B;
  10678. t['ideographicallianceparen'] = 0x323F;
  10679. t['ideographiccallparen'] = 0x323A;
  10680. t['ideographiccentrecircle'] = 0x32A5;
  10681. t['ideographicclose'] = 0x3006;
  10682. t['ideographiccomma'] = 0x3001;
  10683. t['ideographiccommaleft'] = 0xFF64;
  10684. t['ideographiccongratulationparen'] = 0x3237;
  10685. t['ideographiccorrectcircle'] = 0x32A3;
  10686. t['ideographicearthparen'] = 0x322F;
  10687. t['ideographicenterpriseparen'] = 0x323D;
  10688. t['ideographicexcellentcircle'] = 0x329D;
  10689. t['ideographicfestivalparen'] = 0x3240;
  10690. t['ideographicfinancialcircle'] = 0x3296;
  10691. t['ideographicfinancialparen'] = 0x3236;
  10692. t['ideographicfireparen'] = 0x322B;
  10693. t['ideographichaveparen'] = 0x3232;
  10694. t['ideographichighcircle'] = 0x32A4;
  10695. t['ideographiciterationmark'] = 0x3005;
  10696. t['ideographiclaborcircle'] = 0x3298;
  10697. t['ideographiclaborparen'] = 0x3238;
  10698. t['ideographicleftcircle'] = 0x32A7;
  10699. t['ideographiclowcircle'] = 0x32A6;
  10700. t['ideographicmedicinecircle'] = 0x32A9;
  10701. t['ideographicmetalparen'] = 0x322E;
  10702. t['ideographicmoonparen'] = 0x322A;
  10703. t['ideographicnameparen'] = 0x3234;
  10704. t['ideographicperiod'] = 0x3002;
  10705. t['ideographicprintcircle'] = 0x329E;
  10706. t['ideographicreachparen'] = 0x3243;
  10707. t['ideographicrepresentparen'] = 0x3239;
  10708. t['ideographicresourceparen'] = 0x323E;
  10709. t['ideographicrightcircle'] = 0x32A8;
  10710. t['ideographicsecretcircle'] = 0x3299;
  10711. t['ideographicselfparen'] = 0x3242;
  10712. t['ideographicsocietyparen'] = 0x3233;
  10713. t['ideographicspace'] = 0x3000;
  10714. t['ideographicspecialparen'] = 0x3235;
  10715. t['ideographicstockparen'] = 0x3231;
  10716. t['ideographicstudyparen'] = 0x323B;
  10717. t['ideographicsunparen'] = 0x3230;
  10718. t['ideographicsuperviseparen'] = 0x323C;
  10719. t['ideographicwaterparen'] = 0x322C;
  10720. t['ideographicwoodparen'] = 0x322D;
  10721. t['ideographiczero'] = 0x3007;
  10722. t['ideographmetalcircle'] = 0x328E;
  10723. t['ideographmooncircle'] = 0x328A;
  10724. t['ideographnamecircle'] = 0x3294;
  10725. t['ideographsuncircle'] = 0x3290;
  10726. t['ideographwatercircle'] = 0x328C;
  10727. t['ideographwoodcircle'] = 0x328D;
  10728. t['ideva'] = 0x0907;
  10729. t['idieresis'] = 0x00EF;
  10730. t['idieresisacute'] = 0x1E2F;
  10731. t['idieresiscyrillic'] = 0x04E5;
  10732. t['idotbelow'] = 0x1ECB;
  10733. t['iebrevecyrillic'] = 0x04D7;
  10734. t['iecyrillic'] = 0x0435;
  10735. t['ieungacirclekorean'] = 0x3275;
  10736. t['ieungaparenkorean'] = 0x3215;
  10737. t['ieungcirclekorean'] = 0x3267;
  10738. t['ieungkorean'] = 0x3147;
  10739. t['ieungparenkorean'] = 0x3207;
  10740. t['igrave'] = 0x00EC;
  10741. t['igujarati'] = 0x0A87;
  10742. t['igurmukhi'] = 0x0A07;
  10743. t['ihiragana'] = 0x3044;
  10744. t['ihookabove'] = 0x1EC9;
  10745. t['iibengali'] = 0x0988;
  10746. t['iicyrillic'] = 0x0438;
  10747. t['iideva'] = 0x0908;
  10748. t['iigujarati'] = 0x0A88;
  10749. t['iigurmukhi'] = 0x0A08;
  10750. t['iimatragurmukhi'] = 0x0A40;
  10751. t['iinvertedbreve'] = 0x020B;
  10752. t['iishortcyrillic'] = 0x0439;
  10753. t['iivowelsignbengali'] = 0x09C0;
  10754. t['iivowelsigndeva'] = 0x0940;
  10755. t['iivowelsigngujarati'] = 0x0AC0;
  10756. t['ij'] = 0x0133;
  10757. t['ikatakana'] = 0x30A4;
  10758. t['ikatakanahalfwidth'] = 0xFF72;
  10759. t['ikorean'] = 0x3163;
  10760. t['ilde'] = 0x02DC;
  10761. t['iluyhebrew'] = 0x05AC;
  10762. t['imacron'] = 0x012B;
  10763. t['imacroncyrillic'] = 0x04E3;
  10764. t['imageorapproximatelyequal'] = 0x2253;
  10765. t['imatragurmukhi'] = 0x0A3F;
  10766. t['imonospace'] = 0xFF49;
  10767. t['increment'] = 0x2206;
  10768. t['infinity'] = 0x221E;
  10769. t['iniarmenian'] = 0x056B;
  10770. t['integral'] = 0x222B;
  10771. t['integralbottom'] = 0x2321;
  10772. t['integralbt'] = 0x2321;
  10773. t['integralex'] = 0xF8F5;
  10774. t['integraltop'] = 0x2320;
  10775. t['integraltp'] = 0x2320;
  10776. t['intersection'] = 0x2229;
  10777. t['intisquare'] = 0x3305;
  10778. t['invbullet'] = 0x25D8;
  10779. t['invcircle'] = 0x25D9;
  10780. t['invsmileface'] = 0x263B;
  10781. t['iocyrillic'] = 0x0451;
  10782. t['iogonek'] = 0x012F;
  10783. t['iota'] = 0x03B9;
  10784. t['iotadieresis'] = 0x03CA;
  10785. t['iotadieresistonos'] = 0x0390;
  10786. t['iotalatin'] = 0x0269;
  10787. t['iotatonos'] = 0x03AF;
  10788. t['iparen'] = 0x24A4;
  10789. t['irigurmukhi'] = 0x0A72;
  10790. t['ismallhiragana'] = 0x3043;
  10791. t['ismallkatakana'] = 0x30A3;
  10792. t['ismallkatakanahalfwidth'] = 0xFF68;
  10793. t['issharbengali'] = 0x09FA;
  10794. t['istroke'] = 0x0268;
  10795. t['isuperior'] = 0xF6ED;
  10796. t['iterationhiragana'] = 0x309D;
  10797. t['iterationkatakana'] = 0x30FD;
  10798. t['itilde'] = 0x0129;
  10799. t['itildebelow'] = 0x1E2D;
  10800. t['iubopomofo'] = 0x3129;
  10801. t['iucyrillic'] = 0x044E;
  10802. t['ivowelsignbengali'] = 0x09BF;
  10803. t['ivowelsigndeva'] = 0x093F;
  10804. t['ivowelsigngujarati'] = 0x0ABF;
  10805. t['izhitsacyrillic'] = 0x0475;
  10806. t['izhitsadblgravecyrillic'] = 0x0477;
  10807. t['j'] = 0x006A;
  10808. t['jaarmenian'] = 0x0571;
  10809. t['jabengali'] = 0x099C;
  10810. t['jadeva'] = 0x091C;
  10811. t['jagujarati'] = 0x0A9C;
  10812. t['jagurmukhi'] = 0x0A1C;
  10813. t['jbopomofo'] = 0x3110;
  10814. t['jcaron'] = 0x01F0;
  10815. t['jcircle'] = 0x24D9;
  10816. t['jcircumflex'] = 0x0135;
  10817. t['jcrossedtail'] = 0x029D;
  10818. t['jdotlessstroke'] = 0x025F;
  10819. t['jecyrillic'] = 0x0458;
  10820. t['jeemarabic'] = 0x062C;
  10821. t['jeemfinalarabic'] = 0xFE9E;
  10822. t['jeeminitialarabic'] = 0xFE9F;
  10823. t['jeemmedialarabic'] = 0xFEA0;
  10824. t['jeharabic'] = 0x0698;
  10825. t['jehfinalarabic'] = 0xFB8B;
  10826. t['jhabengali'] = 0x099D;
  10827. t['jhadeva'] = 0x091D;
  10828. t['jhagujarati'] = 0x0A9D;
  10829. t['jhagurmukhi'] = 0x0A1D;
  10830. t['jheharmenian'] = 0x057B;
  10831. t['jis'] = 0x3004;
  10832. t['jmonospace'] = 0xFF4A;
  10833. t['jparen'] = 0x24A5;
  10834. t['jsuperior'] = 0x02B2;
  10835. t['k'] = 0x006B;
  10836. t['kabashkircyrillic'] = 0x04A1;
  10837. t['kabengali'] = 0x0995;
  10838. t['kacute'] = 0x1E31;
  10839. t['kacyrillic'] = 0x043A;
  10840. t['kadescendercyrillic'] = 0x049B;
  10841. t['kadeva'] = 0x0915;
  10842. t['kaf'] = 0x05DB;
  10843. t['kafarabic'] = 0x0643;
  10844. t['kafdagesh'] = 0xFB3B;
  10845. t['kafdageshhebrew'] = 0xFB3B;
  10846. t['kaffinalarabic'] = 0xFEDA;
  10847. t['kafhebrew'] = 0x05DB;
  10848. t['kafinitialarabic'] = 0xFEDB;
  10849. t['kafmedialarabic'] = 0xFEDC;
  10850. t['kafrafehebrew'] = 0xFB4D;
  10851. t['kagujarati'] = 0x0A95;
  10852. t['kagurmukhi'] = 0x0A15;
  10853. t['kahiragana'] = 0x304B;
  10854. t['kahookcyrillic'] = 0x04C4;
  10855. t['kakatakana'] = 0x30AB;
  10856. t['kakatakanahalfwidth'] = 0xFF76;
  10857. t['kappa'] = 0x03BA;
  10858. t['kappasymbolgreek'] = 0x03F0;
  10859. t['kapyeounmieumkorean'] = 0x3171;
  10860. t['kapyeounphieuphkorean'] = 0x3184;
  10861. t['kapyeounpieupkorean'] = 0x3178;
  10862. t['kapyeounssangpieupkorean'] = 0x3179;
  10863. t['karoriisquare'] = 0x330D;
  10864. t['kashidaautoarabic'] = 0x0640;
  10865. t['kashidaautonosidebearingarabic'] = 0x0640;
  10866. t['kasmallkatakana'] = 0x30F5;
  10867. t['kasquare'] = 0x3384;
  10868. t['kasraarabic'] = 0x0650;
  10869. t['kasratanarabic'] = 0x064D;
  10870. t['kastrokecyrillic'] = 0x049F;
  10871. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10872. t['kaverticalstrokecyrillic'] = 0x049D;
  10873. t['kbopomofo'] = 0x310E;
  10874. t['kcalsquare'] = 0x3389;
  10875. t['kcaron'] = 0x01E9;
  10876. t['kcedilla'] = 0x0137;
  10877. t['kcircle'] = 0x24DA;
  10878. t['kcommaaccent'] = 0x0137;
  10879. t['kdotbelow'] = 0x1E33;
  10880. t['keharmenian'] = 0x0584;
  10881. t['kehiragana'] = 0x3051;
  10882. t['kekatakana'] = 0x30B1;
  10883. t['kekatakanahalfwidth'] = 0xFF79;
  10884. t['kenarmenian'] = 0x056F;
  10885. t['kesmallkatakana'] = 0x30F6;
  10886. t['kgreenlandic'] = 0x0138;
  10887. t['khabengali'] = 0x0996;
  10888. t['khacyrillic'] = 0x0445;
  10889. t['khadeva'] = 0x0916;
  10890. t['khagujarati'] = 0x0A96;
  10891. t['khagurmukhi'] = 0x0A16;
  10892. t['khaharabic'] = 0x062E;
  10893. t['khahfinalarabic'] = 0xFEA6;
  10894. t['khahinitialarabic'] = 0xFEA7;
  10895. t['khahmedialarabic'] = 0xFEA8;
  10896. t['kheicoptic'] = 0x03E7;
  10897. t['khhadeva'] = 0x0959;
  10898. t['khhagurmukhi'] = 0x0A59;
  10899. t['khieukhacirclekorean'] = 0x3278;
  10900. t['khieukhaparenkorean'] = 0x3218;
  10901. t['khieukhcirclekorean'] = 0x326A;
  10902. t['khieukhkorean'] = 0x314B;
  10903. t['khieukhparenkorean'] = 0x320A;
  10904. t['khokhaithai'] = 0x0E02;
  10905. t['khokhonthai'] = 0x0E05;
  10906. t['khokhuatthai'] = 0x0E03;
  10907. t['khokhwaithai'] = 0x0E04;
  10908. t['khomutthai'] = 0x0E5B;
  10909. t['khook'] = 0x0199;
  10910. t['khorakhangthai'] = 0x0E06;
  10911. t['khzsquare'] = 0x3391;
  10912. t['kihiragana'] = 0x304D;
  10913. t['kikatakana'] = 0x30AD;
  10914. t['kikatakanahalfwidth'] = 0xFF77;
  10915. t['kiroguramusquare'] = 0x3315;
  10916. t['kiromeetorusquare'] = 0x3316;
  10917. t['kirosquare'] = 0x3314;
  10918. t['kiyeokacirclekorean'] = 0x326E;
  10919. t['kiyeokaparenkorean'] = 0x320E;
  10920. t['kiyeokcirclekorean'] = 0x3260;
  10921. t['kiyeokkorean'] = 0x3131;
  10922. t['kiyeokparenkorean'] = 0x3200;
  10923. t['kiyeoksioskorean'] = 0x3133;
  10924. t['kjecyrillic'] = 0x045C;
  10925. t['klinebelow'] = 0x1E35;
  10926. t['klsquare'] = 0x3398;
  10927. t['kmcubedsquare'] = 0x33A6;
  10928. t['kmonospace'] = 0xFF4B;
  10929. t['kmsquaredsquare'] = 0x33A2;
  10930. t['kohiragana'] = 0x3053;
  10931. t['kohmsquare'] = 0x33C0;
  10932. t['kokaithai'] = 0x0E01;
  10933. t['kokatakana'] = 0x30B3;
  10934. t['kokatakanahalfwidth'] = 0xFF7A;
  10935. t['kooposquare'] = 0x331E;
  10936. t['koppacyrillic'] = 0x0481;
  10937. t['koreanstandardsymbol'] = 0x327F;
  10938. t['koroniscmb'] = 0x0343;
  10939. t['kparen'] = 0x24A6;
  10940. t['kpasquare'] = 0x33AA;
  10941. t['ksicyrillic'] = 0x046F;
  10942. t['ktsquare'] = 0x33CF;
  10943. t['kturned'] = 0x029E;
  10944. t['kuhiragana'] = 0x304F;
  10945. t['kukatakana'] = 0x30AF;
  10946. t['kukatakanahalfwidth'] = 0xFF78;
  10947. t['kvsquare'] = 0x33B8;
  10948. t['kwsquare'] = 0x33BE;
  10949. t['l'] = 0x006C;
  10950. t['labengali'] = 0x09B2;
  10951. t['lacute'] = 0x013A;
  10952. t['ladeva'] = 0x0932;
  10953. t['lagujarati'] = 0x0AB2;
  10954. t['lagurmukhi'] = 0x0A32;
  10955. t['lakkhangyaothai'] = 0x0E45;
  10956. t['lamaleffinalarabic'] = 0xFEFC;
  10957. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10958. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10959. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10960. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10961. t['lamalefisolatedarabic'] = 0xFEFB;
  10962. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10963. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10964. t['lamarabic'] = 0x0644;
  10965. t['lambda'] = 0x03BB;
  10966. t['lambdastroke'] = 0x019B;
  10967. t['lamed'] = 0x05DC;
  10968. t['lameddagesh'] = 0xFB3C;
  10969. t['lameddageshhebrew'] = 0xFB3C;
  10970. t['lamedhebrew'] = 0x05DC;
  10971. t['lamfinalarabic'] = 0xFEDE;
  10972. t['lamhahinitialarabic'] = 0xFCCA;
  10973. t['laminitialarabic'] = 0xFEDF;
  10974. t['lamjeeminitialarabic'] = 0xFCC9;
  10975. t['lamkhahinitialarabic'] = 0xFCCB;
  10976. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10977. t['lammedialarabic'] = 0xFEE0;
  10978. t['lammeemhahinitialarabic'] = 0xFD88;
  10979. t['lammeeminitialarabic'] = 0xFCCC;
  10980. t['largecircle'] = 0x25EF;
  10981. t['lbar'] = 0x019A;
  10982. t['lbelt'] = 0x026C;
  10983. t['lbopomofo'] = 0x310C;
  10984. t['lcaron'] = 0x013E;
  10985. t['lcedilla'] = 0x013C;
  10986. t['lcircle'] = 0x24DB;
  10987. t['lcircumflexbelow'] = 0x1E3D;
  10988. t['lcommaaccent'] = 0x013C;
  10989. t['ldot'] = 0x0140;
  10990. t['ldotaccent'] = 0x0140;
  10991. t['ldotbelow'] = 0x1E37;
  10992. t['ldotbelowmacron'] = 0x1E39;
  10993. t['leftangleabovecmb'] = 0x031A;
  10994. t['lefttackbelowcmb'] = 0x0318;
  10995. t['less'] = 0x003C;
  10996. t['lessequal'] = 0x2264;
  10997. t['lessequalorgreater'] = 0x22DA;
  10998. t['lessmonospace'] = 0xFF1C;
  10999. t['lessorequivalent'] = 0x2272;
  11000. t['lessorgreater'] = 0x2276;
  11001. t['lessoverequal'] = 0x2266;
  11002. t['lesssmall'] = 0xFE64;
  11003. t['lezh'] = 0x026E;
  11004. t['lfblock'] = 0x258C;
  11005. t['lhookretroflex'] = 0x026D;
  11006. t['lira'] = 0x20A4;
  11007. t['liwnarmenian'] = 0x056C;
  11008. t['lj'] = 0x01C9;
  11009. t['ljecyrillic'] = 0x0459;
  11010. t['ll'] = 0xF6C0;
  11011. t['lladeva'] = 0x0933;
  11012. t['llagujarati'] = 0x0AB3;
  11013. t['llinebelow'] = 0x1E3B;
  11014. t['llladeva'] = 0x0934;
  11015. t['llvocalicbengali'] = 0x09E1;
  11016. t['llvocalicdeva'] = 0x0961;
  11017. t['llvocalicvowelsignbengali'] = 0x09E3;
  11018. t['llvocalicvowelsigndeva'] = 0x0963;
  11019. t['lmiddletilde'] = 0x026B;
  11020. t['lmonospace'] = 0xFF4C;
  11021. t['lmsquare'] = 0x33D0;
  11022. t['lochulathai'] = 0x0E2C;
  11023. t['logicaland'] = 0x2227;
  11024. t['logicalnot'] = 0x00AC;
  11025. t['logicalnotreversed'] = 0x2310;
  11026. t['logicalor'] = 0x2228;
  11027. t['lolingthai'] = 0x0E25;
  11028. t['longs'] = 0x017F;
  11029. t['lowlinecenterline'] = 0xFE4E;
  11030. t['lowlinecmb'] = 0x0332;
  11031. t['lowlinedashed'] = 0xFE4D;
  11032. t['lozenge'] = 0x25CA;
  11033. t['lparen'] = 0x24A7;
  11034. t['lslash'] = 0x0142;
  11035. t['lsquare'] = 0x2113;
  11036. t['lsuperior'] = 0xF6EE;
  11037. t['ltshade'] = 0x2591;
  11038. t['luthai'] = 0x0E26;
  11039. t['lvocalicbengali'] = 0x098C;
  11040. t['lvocalicdeva'] = 0x090C;
  11041. t['lvocalicvowelsignbengali'] = 0x09E2;
  11042. t['lvocalicvowelsigndeva'] = 0x0962;
  11043. t['lxsquare'] = 0x33D3;
  11044. t['m'] = 0x006D;
  11045. t['mabengali'] = 0x09AE;
  11046. t['macron'] = 0x00AF;
  11047. t['macronbelowcmb'] = 0x0331;
  11048. t['macroncmb'] = 0x0304;
  11049. t['macronlowmod'] = 0x02CD;
  11050. t['macronmonospace'] = 0xFFE3;
  11051. t['macute'] = 0x1E3F;
  11052. t['madeva'] = 0x092E;
  11053. t['magujarati'] = 0x0AAE;
  11054. t['magurmukhi'] = 0x0A2E;
  11055. t['mahapakhhebrew'] = 0x05A4;
  11056. t['mahapakhlefthebrew'] = 0x05A4;
  11057. t['mahiragana'] = 0x307E;
  11058. t['maichattawalowleftthai'] = 0xF895;
  11059. t['maichattawalowrightthai'] = 0xF894;
  11060. t['maichattawathai'] = 0x0E4B;
  11061. t['maichattawaupperleftthai'] = 0xF893;
  11062. t['maieklowleftthai'] = 0xF88C;
  11063. t['maieklowrightthai'] = 0xF88B;
  11064. t['maiekthai'] = 0x0E48;
  11065. t['maiekupperleftthai'] = 0xF88A;
  11066. t['maihanakatleftthai'] = 0xF884;
  11067. t['maihanakatthai'] = 0x0E31;
  11068. t['maitaikhuleftthai'] = 0xF889;
  11069. t['maitaikhuthai'] = 0x0E47;
  11070. t['maitholowleftthai'] = 0xF88F;
  11071. t['maitholowrightthai'] = 0xF88E;
  11072. t['maithothai'] = 0x0E49;
  11073. t['maithoupperleftthai'] = 0xF88D;
  11074. t['maitrilowleftthai'] = 0xF892;
  11075. t['maitrilowrightthai'] = 0xF891;
  11076. t['maitrithai'] = 0x0E4A;
  11077. t['maitriupperleftthai'] = 0xF890;
  11078. t['maiyamokthai'] = 0x0E46;
  11079. t['makatakana'] = 0x30DE;
  11080. t['makatakanahalfwidth'] = 0xFF8F;
  11081. t['male'] = 0x2642;
  11082. t['mansyonsquare'] = 0x3347;
  11083. t['maqafhebrew'] = 0x05BE;
  11084. t['mars'] = 0x2642;
  11085. t['masoracirclehebrew'] = 0x05AF;
  11086. t['masquare'] = 0x3383;
  11087. t['mbopomofo'] = 0x3107;
  11088. t['mbsquare'] = 0x33D4;
  11089. t['mcircle'] = 0x24DC;
  11090. t['mcubedsquare'] = 0x33A5;
  11091. t['mdotaccent'] = 0x1E41;
  11092. t['mdotbelow'] = 0x1E43;
  11093. t['meemarabic'] = 0x0645;
  11094. t['meemfinalarabic'] = 0xFEE2;
  11095. t['meeminitialarabic'] = 0xFEE3;
  11096. t['meemmedialarabic'] = 0xFEE4;
  11097. t['meemmeeminitialarabic'] = 0xFCD1;
  11098. t['meemmeemisolatedarabic'] = 0xFC48;
  11099. t['meetorusquare'] = 0x334D;
  11100. t['mehiragana'] = 0x3081;
  11101. t['meizierasquare'] = 0x337E;
  11102. t['mekatakana'] = 0x30E1;
  11103. t['mekatakanahalfwidth'] = 0xFF92;
  11104. t['mem'] = 0x05DE;
  11105. t['memdagesh'] = 0xFB3E;
  11106. t['memdageshhebrew'] = 0xFB3E;
  11107. t['memhebrew'] = 0x05DE;
  11108. t['menarmenian'] = 0x0574;
  11109. t['merkhahebrew'] = 0x05A5;
  11110. t['merkhakefulahebrew'] = 0x05A6;
  11111. t['merkhakefulalefthebrew'] = 0x05A6;
  11112. t['merkhalefthebrew'] = 0x05A5;
  11113. t['mhook'] = 0x0271;
  11114. t['mhzsquare'] = 0x3392;
  11115. t['middledotkatakanahalfwidth'] = 0xFF65;
  11116. t['middot'] = 0x00B7;
  11117. t['mieumacirclekorean'] = 0x3272;
  11118. t['mieumaparenkorean'] = 0x3212;
  11119. t['mieumcirclekorean'] = 0x3264;
  11120. t['mieumkorean'] = 0x3141;
  11121. t['mieumpansioskorean'] = 0x3170;
  11122. t['mieumparenkorean'] = 0x3204;
  11123. t['mieumpieupkorean'] = 0x316E;
  11124. t['mieumsioskorean'] = 0x316F;
  11125. t['mihiragana'] = 0x307F;
  11126. t['mikatakana'] = 0x30DF;
  11127. t['mikatakanahalfwidth'] = 0xFF90;
  11128. t['minus'] = 0x2212;
  11129. t['minusbelowcmb'] = 0x0320;
  11130. t['minuscircle'] = 0x2296;
  11131. t['minusmod'] = 0x02D7;
  11132. t['minusplus'] = 0x2213;
  11133. t['minute'] = 0x2032;
  11134. t['miribaarusquare'] = 0x334A;
  11135. t['mirisquare'] = 0x3349;
  11136. t['mlonglegturned'] = 0x0270;
  11137. t['mlsquare'] = 0x3396;
  11138. t['mmcubedsquare'] = 0x33A3;
  11139. t['mmonospace'] = 0xFF4D;
  11140. t['mmsquaredsquare'] = 0x339F;
  11141. t['mohiragana'] = 0x3082;
  11142. t['mohmsquare'] = 0x33C1;
  11143. t['mokatakana'] = 0x30E2;
  11144. t['mokatakanahalfwidth'] = 0xFF93;
  11145. t['molsquare'] = 0x33D6;
  11146. t['momathai'] = 0x0E21;
  11147. t['moverssquare'] = 0x33A7;
  11148. t['moverssquaredsquare'] = 0x33A8;
  11149. t['mparen'] = 0x24A8;
  11150. t['mpasquare'] = 0x33AB;
  11151. t['mssquare'] = 0x33B3;
  11152. t['msuperior'] = 0xF6EF;
  11153. t['mturned'] = 0x026F;
  11154. t['mu'] = 0x00B5;
  11155. t['mu1'] = 0x00B5;
  11156. t['muasquare'] = 0x3382;
  11157. t['muchgreater'] = 0x226B;
  11158. t['muchless'] = 0x226A;
  11159. t['mufsquare'] = 0x338C;
  11160. t['mugreek'] = 0x03BC;
  11161. t['mugsquare'] = 0x338D;
  11162. t['muhiragana'] = 0x3080;
  11163. t['mukatakana'] = 0x30E0;
  11164. t['mukatakanahalfwidth'] = 0xFF91;
  11165. t['mulsquare'] = 0x3395;
  11166. t['multiply'] = 0x00D7;
  11167. t['mumsquare'] = 0x339B;
  11168. t['munahhebrew'] = 0x05A3;
  11169. t['munahlefthebrew'] = 0x05A3;
  11170. t['musicalnote'] = 0x266A;
  11171. t['musicalnotedbl'] = 0x266B;
  11172. t['musicflatsign'] = 0x266D;
  11173. t['musicsharpsign'] = 0x266F;
  11174. t['mussquare'] = 0x33B2;
  11175. t['muvsquare'] = 0x33B6;
  11176. t['muwsquare'] = 0x33BC;
  11177. t['mvmegasquare'] = 0x33B9;
  11178. t['mvsquare'] = 0x33B7;
  11179. t['mwmegasquare'] = 0x33BF;
  11180. t['mwsquare'] = 0x33BD;
  11181. t['n'] = 0x006E;
  11182. t['nabengali'] = 0x09A8;
  11183. t['nabla'] = 0x2207;
  11184. t['nacute'] = 0x0144;
  11185. t['nadeva'] = 0x0928;
  11186. t['nagujarati'] = 0x0AA8;
  11187. t['nagurmukhi'] = 0x0A28;
  11188. t['nahiragana'] = 0x306A;
  11189. t['nakatakana'] = 0x30CA;
  11190. t['nakatakanahalfwidth'] = 0xFF85;
  11191. t['napostrophe'] = 0x0149;
  11192. t['nasquare'] = 0x3381;
  11193. t['nbopomofo'] = 0x310B;
  11194. t['nbspace'] = 0x00A0;
  11195. t['ncaron'] = 0x0148;
  11196. t['ncedilla'] = 0x0146;
  11197. t['ncircle'] = 0x24DD;
  11198. t['ncircumflexbelow'] = 0x1E4B;
  11199. t['ncommaaccent'] = 0x0146;
  11200. t['ndotaccent'] = 0x1E45;
  11201. t['ndotbelow'] = 0x1E47;
  11202. t['nehiragana'] = 0x306D;
  11203. t['nekatakana'] = 0x30CD;
  11204. t['nekatakanahalfwidth'] = 0xFF88;
  11205. t['newsheqelsign'] = 0x20AA;
  11206. t['nfsquare'] = 0x338B;
  11207. t['ngabengali'] = 0x0999;
  11208. t['ngadeva'] = 0x0919;
  11209. t['ngagujarati'] = 0x0A99;
  11210. t['ngagurmukhi'] = 0x0A19;
  11211. t['ngonguthai'] = 0x0E07;
  11212. t['nhiragana'] = 0x3093;
  11213. t['nhookleft'] = 0x0272;
  11214. t['nhookretroflex'] = 0x0273;
  11215. t['nieunacirclekorean'] = 0x326F;
  11216. t['nieunaparenkorean'] = 0x320F;
  11217. t['nieuncieuckorean'] = 0x3135;
  11218. t['nieuncirclekorean'] = 0x3261;
  11219. t['nieunhieuhkorean'] = 0x3136;
  11220. t['nieunkorean'] = 0x3134;
  11221. t['nieunpansioskorean'] = 0x3168;
  11222. t['nieunparenkorean'] = 0x3201;
  11223. t['nieunsioskorean'] = 0x3167;
  11224. t['nieuntikeutkorean'] = 0x3166;
  11225. t['nihiragana'] = 0x306B;
  11226. t['nikatakana'] = 0x30CB;
  11227. t['nikatakanahalfwidth'] = 0xFF86;
  11228. t['nikhahitleftthai'] = 0xF899;
  11229. t['nikhahitthai'] = 0x0E4D;
  11230. t['nine'] = 0x0039;
  11231. t['ninearabic'] = 0x0669;
  11232. t['ninebengali'] = 0x09EF;
  11233. t['ninecircle'] = 0x2468;
  11234. t['ninecircleinversesansserif'] = 0x2792;
  11235. t['ninedeva'] = 0x096F;
  11236. t['ninegujarati'] = 0x0AEF;
  11237. t['ninegurmukhi'] = 0x0A6F;
  11238. t['ninehackarabic'] = 0x0669;
  11239. t['ninehangzhou'] = 0x3029;
  11240. t['nineideographicparen'] = 0x3228;
  11241. t['nineinferior'] = 0x2089;
  11242. t['ninemonospace'] = 0xFF19;
  11243. t['nineoldstyle'] = 0xF739;
  11244. t['nineparen'] = 0x247C;
  11245. t['nineperiod'] = 0x2490;
  11246. t['ninepersian'] = 0x06F9;
  11247. t['nineroman'] = 0x2178;
  11248. t['ninesuperior'] = 0x2079;
  11249. t['nineteencircle'] = 0x2472;
  11250. t['nineteenparen'] = 0x2486;
  11251. t['nineteenperiod'] = 0x249A;
  11252. t['ninethai'] = 0x0E59;
  11253. t['nj'] = 0x01CC;
  11254. t['njecyrillic'] = 0x045A;
  11255. t['nkatakana'] = 0x30F3;
  11256. t['nkatakanahalfwidth'] = 0xFF9D;
  11257. t['nlegrightlong'] = 0x019E;
  11258. t['nlinebelow'] = 0x1E49;
  11259. t['nmonospace'] = 0xFF4E;
  11260. t['nmsquare'] = 0x339A;
  11261. t['nnabengali'] = 0x09A3;
  11262. t['nnadeva'] = 0x0923;
  11263. t['nnagujarati'] = 0x0AA3;
  11264. t['nnagurmukhi'] = 0x0A23;
  11265. t['nnnadeva'] = 0x0929;
  11266. t['nohiragana'] = 0x306E;
  11267. t['nokatakana'] = 0x30CE;
  11268. t['nokatakanahalfwidth'] = 0xFF89;
  11269. t['nonbreakingspace'] = 0x00A0;
  11270. t['nonenthai'] = 0x0E13;
  11271. t['nonuthai'] = 0x0E19;
  11272. t['noonarabic'] = 0x0646;
  11273. t['noonfinalarabic'] = 0xFEE6;
  11274. t['noonghunnaarabic'] = 0x06BA;
  11275. t['noonghunnafinalarabic'] = 0xFB9F;
  11276. t['nooninitialarabic'] = 0xFEE7;
  11277. t['noonjeeminitialarabic'] = 0xFCD2;
  11278. t['noonjeemisolatedarabic'] = 0xFC4B;
  11279. t['noonmedialarabic'] = 0xFEE8;
  11280. t['noonmeeminitialarabic'] = 0xFCD5;
  11281. t['noonmeemisolatedarabic'] = 0xFC4E;
  11282. t['noonnoonfinalarabic'] = 0xFC8D;
  11283. t['notcontains'] = 0x220C;
  11284. t['notelement'] = 0x2209;
  11285. t['notelementof'] = 0x2209;
  11286. t['notequal'] = 0x2260;
  11287. t['notgreater'] = 0x226F;
  11288. t['notgreaternorequal'] = 0x2271;
  11289. t['notgreaternorless'] = 0x2279;
  11290. t['notidentical'] = 0x2262;
  11291. t['notless'] = 0x226E;
  11292. t['notlessnorequal'] = 0x2270;
  11293. t['notparallel'] = 0x2226;
  11294. t['notprecedes'] = 0x2280;
  11295. t['notsubset'] = 0x2284;
  11296. t['notsucceeds'] = 0x2281;
  11297. t['notsuperset'] = 0x2285;
  11298. t['nowarmenian'] = 0x0576;
  11299. t['nparen'] = 0x24A9;
  11300. t['nssquare'] = 0x33B1;
  11301. t['nsuperior'] = 0x207F;
  11302. t['ntilde'] = 0x00F1;
  11303. t['nu'] = 0x03BD;
  11304. t['nuhiragana'] = 0x306C;
  11305. t['nukatakana'] = 0x30CC;
  11306. t['nukatakanahalfwidth'] = 0xFF87;
  11307. t['nuktabengali'] = 0x09BC;
  11308. t['nuktadeva'] = 0x093C;
  11309. t['nuktagujarati'] = 0x0ABC;
  11310. t['nuktagurmukhi'] = 0x0A3C;
  11311. t['numbersign'] = 0x0023;
  11312. t['numbersignmonospace'] = 0xFF03;
  11313. t['numbersignsmall'] = 0xFE5F;
  11314. t['numeralsigngreek'] = 0x0374;
  11315. t['numeralsignlowergreek'] = 0x0375;
  11316. t['numero'] = 0x2116;
  11317. t['nun'] = 0x05E0;
  11318. t['nundagesh'] = 0xFB40;
  11319. t['nundageshhebrew'] = 0xFB40;
  11320. t['nunhebrew'] = 0x05E0;
  11321. t['nvsquare'] = 0x33B5;
  11322. t['nwsquare'] = 0x33BB;
  11323. t['nyabengali'] = 0x099E;
  11324. t['nyadeva'] = 0x091E;
  11325. t['nyagujarati'] = 0x0A9E;
  11326. t['nyagurmukhi'] = 0x0A1E;
  11327. t['o'] = 0x006F;
  11328. t['oacute'] = 0x00F3;
  11329. t['oangthai'] = 0x0E2D;
  11330. t['obarred'] = 0x0275;
  11331. t['obarredcyrillic'] = 0x04E9;
  11332. t['obarreddieresiscyrillic'] = 0x04EB;
  11333. t['obengali'] = 0x0993;
  11334. t['obopomofo'] = 0x311B;
  11335. t['obreve'] = 0x014F;
  11336. t['ocandradeva'] = 0x0911;
  11337. t['ocandragujarati'] = 0x0A91;
  11338. t['ocandravowelsigndeva'] = 0x0949;
  11339. t['ocandravowelsigngujarati'] = 0x0AC9;
  11340. t['ocaron'] = 0x01D2;
  11341. t['ocircle'] = 0x24DE;
  11342. t['ocircumflex'] = 0x00F4;
  11343. t['ocircumflexacute'] = 0x1ED1;
  11344. t['ocircumflexdotbelow'] = 0x1ED9;
  11345. t['ocircumflexgrave'] = 0x1ED3;
  11346. t['ocircumflexhookabove'] = 0x1ED5;
  11347. t['ocircumflextilde'] = 0x1ED7;
  11348. t['ocyrillic'] = 0x043E;
  11349. t['odblacute'] = 0x0151;
  11350. t['odblgrave'] = 0x020D;
  11351. t['odeva'] = 0x0913;
  11352. t['odieresis'] = 0x00F6;
  11353. t['odieresiscyrillic'] = 0x04E7;
  11354. t['odotbelow'] = 0x1ECD;
  11355. t['oe'] = 0x0153;
  11356. t['oekorean'] = 0x315A;
  11357. t['ogonek'] = 0x02DB;
  11358. t['ogonekcmb'] = 0x0328;
  11359. t['ograve'] = 0x00F2;
  11360. t['ogujarati'] = 0x0A93;
  11361. t['oharmenian'] = 0x0585;
  11362. t['ohiragana'] = 0x304A;
  11363. t['ohookabove'] = 0x1ECF;
  11364. t['ohorn'] = 0x01A1;
  11365. t['ohornacute'] = 0x1EDB;
  11366. t['ohorndotbelow'] = 0x1EE3;
  11367. t['ohorngrave'] = 0x1EDD;
  11368. t['ohornhookabove'] = 0x1EDF;
  11369. t['ohorntilde'] = 0x1EE1;
  11370. t['ohungarumlaut'] = 0x0151;
  11371. t['oi'] = 0x01A3;
  11372. t['oinvertedbreve'] = 0x020F;
  11373. t['okatakana'] = 0x30AA;
  11374. t['okatakanahalfwidth'] = 0xFF75;
  11375. t['okorean'] = 0x3157;
  11376. t['olehebrew'] = 0x05AB;
  11377. t['omacron'] = 0x014D;
  11378. t['omacronacute'] = 0x1E53;
  11379. t['omacrongrave'] = 0x1E51;
  11380. t['omdeva'] = 0x0950;
  11381. t['omega'] = 0x03C9;
  11382. t['omega1'] = 0x03D6;
  11383. t['omegacyrillic'] = 0x0461;
  11384. t['omegalatinclosed'] = 0x0277;
  11385. t['omegaroundcyrillic'] = 0x047B;
  11386. t['omegatitlocyrillic'] = 0x047D;
  11387. t['omegatonos'] = 0x03CE;
  11388. t['omgujarati'] = 0x0AD0;
  11389. t['omicron'] = 0x03BF;
  11390. t['omicrontonos'] = 0x03CC;
  11391. t['omonospace'] = 0xFF4F;
  11392. t['one'] = 0x0031;
  11393. t['onearabic'] = 0x0661;
  11394. t['onebengali'] = 0x09E7;
  11395. t['onecircle'] = 0x2460;
  11396. t['onecircleinversesansserif'] = 0x278A;
  11397. t['onedeva'] = 0x0967;
  11398. t['onedotenleader'] = 0x2024;
  11399. t['oneeighth'] = 0x215B;
  11400. t['onefitted'] = 0xF6DC;
  11401. t['onegujarati'] = 0x0AE7;
  11402. t['onegurmukhi'] = 0x0A67;
  11403. t['onehackarabic'] = 0x0661;
  11404. t['onehalf'] = 0x00BD;
  11405. t['onehangzhou'] = 0x3021;
  11406. t['oneideographicparen'] = 0x3220;
  11407. t['oneinferior'] = 0x2081;
  11408. t['onemonospace'] = 0xFF11;
  11409. t['onenumeratorbengali'] = 0x09F4;
  11410. t['oneoldstyle'] = 0xF731;
  11411. t['oneparen'] = 0x2474;
  11412. t['oneperiod'] = 0x2488;
  11413. t['onepersian'] = 0x06F1;
  11414. t['onequarter'] = 0x00BC;
  11415. t['oneroman'] = 0x2170;
  11416. t['onesuperior'] = 0x00B9;
  11417. t['onethai'] = 0x0E51;
  11418. t['onethird'] = 0x2153;
  11419. t['oogonek'] = 0x01EB;
  11420. t['oogonekmacron'] = 0x01ED;
  11421. t['oogurmukhi'] = 0x0A13;
  11422. t['oomatragurmukhi'] = 0x0A4B;
  11423. t['oopen'] = 0x0254;
  11424. t['oparen'] = 0x24AA;
  11425. t['openbullet'] = 0x25E6;
  11426. t['option'] = 0x2325;
  11427. t['ordfeminine'] = 0x00AA;
  11428. t['ordmasculine'] = 0x00BA;
  11429. t['orthogonal'] = 0x221F;
  11430. t['oshortdeva'] = 0x0912;
  11431. t['oshortvowelsigndeva'] = 0x094A;
  11432. t['oslash'] = 0x00F8;
  11433. t['oslashacute'] = 0x01FF;
  11434. t['osmallhiragana'] = 0x3049;
  11435. t['osmallkatakana'] = 0x30A9;
  11436. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11437. t['ostrokeacute'] = 0x01FF;
  11438. t['osuperior'] = 0xF6F0;
  11439. t['otcyrillic'] = 0x047F;
  11440. t['otilde'] = 0x00F5;
  11441. t['otildeacute'] = 0x1E4D;
  11442. t['otildedieresis'] = 0x1E4F;
  11443. t['oubopomofo'] = 0x3121;
  11444. t['overline'] = 0x203E;
  11445. t['overlinecenterline'] = 0xFE4A;
  11446. t['overlinecmb'] = 0x0305;
  11447. t['overlinedashed'] = 0xFE49;
  11448. t['overlinedblwavy'] = 0xFE4C;
  11449. t['overlinewavy'] = 0xFE4B;
  11450. t['overscore'] = 0x00AF;
  11451. t['ovowelsignbengali'] = 0x09CB;
  11452. t['ovowelsigndeva'] = 0x094B;
  11453. t['ovowelsigngujarati'] = 0x0ACB;
  11454. t['p'] = 0x0070;
  11455. t['paampssquare'] = 0x3380;
  11456. t['paasentosquare'] = 0x332B;
  11457. t['pabengali'] = 0x09AA;
  11458. t['pacute'] = 0x1E55;
  11459. t['padeva'] = 0x092A;
  11460. t['pagedown'] = 0x21DF;
  11461. t['pageup'] = 0x21DE;
  11462. t['pagujarati'] = 0x0AAA;
  11463. t['pagurmukhi'] = 0x0A2A;
  11464. t['pahiragana'] = 0x3071;
  11465. t['paiyannoithai'] = 0x0E2F;
  11466. t['pakatakana'] = 0x30D1;
  11467. t['palatalizationcyrilliccmb'] = 0x0484;
  11468. t['palochkacyrillic'] = 0x04C0;
  11469. t['pansioskorean'] = 0x317F;
  11470. t['paragraph'] = 0x00B6;
  11471. t['parallel'] = 0x2225;
  11472. t['parenleft'] = 0x0028;
  11473. t['parenleftaltonearabic'] = 0xFD3E;
  11474. t['parenleftbt'] = 0xF8ED;
  11475. t['parenleftex'] = 0xF8EC;
  11476. t['parenleftinferior'] = 0x208D;
  11477. t['parenleftmonospace'] = 0xFF08;
  11478. t['parenleftsmall'] = 0xFE59;
  11479. t['parenleftsuperior'] = 0x207D;
  11480. t['parenlefttp'] = 0xF8EB;
  11481. t['parenleftvertical'] = 0xFE35;
  11482. t['parenright'] = 0x0029;
  11483. t['parenrightaltonearabic'] = 0xFD3F;
  11484. t['parenrightbt'] = 0xF8F8;
  11485. t['parenrightex'] = 0xF8F7;
  11486. t['parenrightinferior'] = 0x208E;
  11487. t['parenrightmonospace'] = 0xFF09;
  11488. t['parenrightsmall'] = 0xFE5A;
  11489. t['parenrightsuperior'] = 0x207E;
  11490. t['parenrighttp'] = 0xF8F6;
  11491. t['parenrightvertical'] = 0xFE36;
  11492. t['partialdiff'] = 0x2202;
  11493. t['paseqhebrew'] = 0x05C0;
  11494. t['pashtahebrew'] = 0x0599;
  11495. t['pasquare'] = 0x33A9;
  11496. t['patah'] = 0x05B7;
  11497. t['patah11'] = 0x05B7;
  11498. t['patah1d'] = 0x05B7;
  11499. t['patah2a'] = 0x05B7;
  11500. t['patahhebrew'] = 0x05B7;
  11501. t['patahnarrowhebrew'] = 0x05B7;
  11502. t['patahquarterhebrew'] = 0x05B7;
  11503. t['patahwidehebrew'] = 0x05B7;
  11504. t['pazerhebrew'] = 0x05A1;
  11505. t['pbopomofo'] = 0x3106;
  11506. t['pcircle'] = 0x24DF;
  11507. t['pdotaccent'] = 0x1E57;
  11508. t['pe'] = 0x05E4;
  11509. t['pecyrillic'] = 0x043F;
  11510. t['pedagesh'] = 0xFB44;
  11511. t['pedageshhebrew'] = 0xFB44;
  11512. t['peezisquare'] = 0x333B;
  11513. t['pefinaldageshhebrew'] = 0xFB43;
  11514. t['peharabic'] = 0x067E;
  11515. t['peharmenian'] = 0x057A;
  11516. t['pehebrew'] = 0x05E4;
  11517. t['pehfinalarabic'] = 0xFB57;
  11518. t['pehinitialarabic'] = 0xFB58;
  11519. t['pehiragana'] = 0x307A;
  11520. t['pehmedialarabic'] = 0xFB59;
  11521. t['pekatakana'] = 0x30DA;
  11522. t['pemiddlehookcyrillic'] = 0x04A7;
  11523. t['perafehebrew'] = 0xFB4E;
  11524. t['percent'] = 0x0025;
  11525. t['percentarabic'] = 0x066A;
  11526. t['percentmonospace'] = 0xFF05;
  11527. t['percentsmall'] = 0xFE6A;
  11528. t['period'] = 0x002E;
  11529. t['periodarmenian'] = 0x0589;
  11530. t['periodcentered'] = 0x00B7;
  11531. t['periodhalfwidth'] = 0xFF61;
  11532. t['periodinferior'] = 0xF6E7;
  11533. t['periodmonospace'] = 0xFF0E;
  11534. t['periodsmall'] = 0xFE52;
  11535. t['periodsuperior'] = 0xF6E8;
  11536. t['perispomenigreekcmb'] = 0x0342;
  11537. t['perpendicular'] = 0x22A5;
  11538. t['perthousand'] = 0x2030;
  11539. t['peseta'] = 0x20A7;
  11540. t['pfsquare'] = 0x338A;
  11541. t['phabengali'] = 0x09AB;
  11542. t['phadeva'] = 0x092B;
  11543. t['phagujarati'] = 0x0AAB;
  11544. t['phagurmukhi'] = 0x0A2B;
  11545. t['phi'] = 0x03C6;
  11546. t['phi1'] = 0x03D5;
  11547. t['phieuphacirclekorean'] = 0x327A;
  11548. t['phieuphaparenkorean'] = 0x321A;
  11549. t['phieuphcirclekorean'] = 0x326C;
  11550. t['phieuphkorean'] = 0x314D;
  11551. t['phieuphparenkorean'] = 0x320C;
  11552. t['philatin'] = 0x0278;
  11553. t['phinthuthai'] = 0x0E3A;
  11554. t['phisymbolgreek'] = 0x03D5;
  11555. t['phook'] = 0x01A5;
  11556. t['phophanthai'] = 0x0E1E;
  11557. t['phophungthai'] = 0x0E1C;
  11558. t['phosamphaothai'] = 0x0E20;
  11559. t['pi'] = 0x03C0;
  11560. t['pieupacirclekorean'] = 0x3273;
  11561. t['pieupaparenkorean'] = 0x3213;
  11562. t['pieupcieuckorean'] = 0x3176;
  11563. t['pieupcirclekorean'] = 0x3265;
  11564. t['pieupkiyeokkorean'] = 0x3172;
  11565. t['pieupkorean'] = 0x3142;
  11566. t['pieupparenkorean'] = 0x3205;
  11567. t['pieupsioskiyeokkorean'] = 0x3174;
  11568. t['pieupsioskorean'] = 0x3144;
  11569. t['pieupsiostikeutkorean'] = 0x3175;
  11570. t['pieupthieuthkorean'] = 0x3177;
  11571. t['pieuptikeutkorean'] = 0x3173;
  11572. t['pihiragana'] = 0x3074;
  11573. t['pikatakana'] = 0x30D4;
  11574. t['pisymbolgreek'] = 0x03D6;
  11575. t['piwrarmenian'] = 0x0583;
  11576. t['plus'] = 0x002B;
  11577. t['plusbelowcmb'] = 0x031F;
  11578. t['pluscircle'] = 0x2295;
  11579. t['plusminus'] = 0x00B1;
  11580. t['plusmod'] = 0x02D6;
  11581. t['plusmonospace'] = 0xFF0B;
  11582. t['plussmall'] = 0xFE62;
  11583. t['plussuperior'] = 0x207A;
  11584. t['pmonospace'] = 0xFF50;
  11585. t['pmsquare'] = 0x33D8;
  11586. t['pohiragana'] = 0x307D;
  11587. t['pointingindexdownwhite'] = 0x261F;
  11588. t['pointingindexleftwhite'] = 0x261C;
  11589. t['pointingindexrightwhite'] = 0x261E;
  11590. t['pointingindexupwhite'] = 0x261D;
  11591. t['pokatakana'] = 0x30DD;
  11592. t['poplathai'] = 0x0E1B;
  11593. t['postalmark'] = 0x3012;
  11594. t['postalmarkface'] = 0x3020;
  11595. t['pparen'] = 0x24AB;
  11596. t['precedes'] = 0x227A;
  11597. t['prescription'] = 0x211E;
  11598. t['primemod'] = 0x02B9;
  11599. t['primereversed'] = 0x2035;
  11600. t['product'] = 0x220F;
  11601. t['projective'] = 0x2305;
  11602. t['prolongedkana'] = 0x30FC;
  11603. t['propellor'] = 0x2318;
  11604. t['propersubset'] = 0x2282;
  11605. t['propersuperset'] = 0x2283;
  11606. t['proportion'] = 0x2237;
  11607. t['proportional'] = 0x221D;
  11608. t['psi'] = 0x03C8;
  11609. t['psicyrillic'] = 0x0471;
  11610. t['psilipneumatacyrilliccmb'] = 0x0486;
  11611. t['pssquare'] = 0x33B0;
  11612. t['puhiragana'] = 0x3077;
  11613. t['pukatakana'] = 0x30D7;
  11614. t['pvsquare'] = 0x33B4;
  11615. t['pwsquare'] = 0x33BA;
  11616. t['q'] = 0x0071;
  11617. t['qadeva'] = 0x0958;
  11618. t['qadmahebrew'] = 0x05A8;
  11619. t['qafarabic'] = 0x0642;
  11620. t['qaffinalarabic'] = 0xFED6;
  11621. t['qafinitialarabic'] = 0xFED7;
  11622. t['qafmedialarabic'] = 0xFED8;
  11623. t['qamats'] = 0x05B8;
  11624. t['qamats10'] = 0x05B8;
  11625. t['qamats1a'] = 0x05B8;
  11626. t['qamats1c'] = 0x05B8;
  11627. t['qamats27'] = 0x05B8;
  11628. t['qamats29'] = 0x05B8;
  11629. t['qamats33'] = 0x05B8;
  11630. t['qamatsde'] = 0x05B8;
  11631. t['qamatshebrew'] = 0x05B8;
  11632. t['qamatsnarrowhebrew'] = 0x05B8;
  11633. t['qamatsqatanhebrew'] = 0x05B8;
  11634. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11635. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11636. t['qamatsqatanwidehebrew'] = 0x05B8;
  11637. t['qamatsquarterhebrew'] = 0x05B8;
  11638. t['qamatswidehebrew'] = 0x05B8;
  11639. t['qarneyparahebrew'] = 0x059F;
  11640. t['qbopomofo'] = 0x3111;
  11641. t['qcircle'] = 0x24E0;
  11642. t['qhook'] = 0x02A0;
  11643. t['qmonospace'] = 0xFF51;
  11644. t['qof'] = 0x05E7;
  11645. t['qofdagesh'] = 0xFB47;
  11646. t['qofdageshhebrew'] = 0xFB47;
  11647. t['qofhebrew'] = 0x05E7;
  11648. t['qparen'] = 0x24AC;
  11649. t['quarternote'] = 0x2669;
  11650. t['qubuts'] = 0x05BB;
  11651. t['qubuts18'] = 0x05BB;
  11652. t['qubuts25'] = 0x05BB;
  11653. t['qubuts31'] = 0x05BB;
  11654. t['qubutshebrew'] = 0x05BB;
  11655. t['qubutsnarrowhebrew'] = 0x05BB;
  11656. t['qubutsquarterhebrew'] = 0x05BB;
  11657. t['qubutswidehebrew'] = 0x05BB;
  11658. t['question'] = 0x003F;
  11659. t['questionarabic'] = 0x061F;
  11660. t['questionarmenian'] = 0x055E;
  11661. t['questiondown'] = 0x00BF;
  11662. t['questiondownsmall'] = 0xF7BF;
  11663. t['questiongreek'] = 0x037E;
  11664. t['questionmonospace'] = 0xFF1F;
  11665. t['questionsmall'] = 0xF73F;
  11666. t['quotedbl'] = 0x0022;
  11667. t['quotedblbase'] = 0x201E;
  11668. t['quotedblleft'] = 0x201C;
  11669. t['quotedblmonospace'] = 0xFF02;
  11670. t['quotedblprime'] = 0x301E;
  11671. t['quotedblprimereversed'] = 0x301D;
  11672. t['quotedblright'] = 0x201D;
  11673. t['quoteleft'] = 0x2018;
  11674. t['quoteleftreversed'] = 0x201B;
  11675. t['quotereversed'] = 0x201B;
  11676. t['quoteright'] = 0x2019;
  11677. t['quoterightn'] = 0x0149;
  11678. t['quotesinglbase'] = 0x201A;
  11679. t['quotesingle'] = 0x0027;
  11680. t['quotesinglemonospace'] = 0xFF07;
  11681. t['r'] = 0x0072;
  11682. t['raarmenian'] = 0x057C;
  11683. t['rabengali'] = 0x09B0;
  11684. t['racute'] = 0x0155;
  11685. t['radeva'] = 0x0930;
  11686. t['radical'] = 0x221A;
  11687. t['radicalex'] = 0xF8E5;
  11688. t['radoverssquare'] = 0x33AE;
  11689. t['radoverssquaredsquare'] = 0x33AF;
  11690. t['radsquare'] = 0x33AD;
  11691. t['rafe'] = 0x05BF;
  11692. t['rafehebrew'] = 0x05BF;
  11693. t['ragujarati'] = 0x0AB0;
  11694. t['ragurmukhi'] = 0x0A30;
  11695. t['rahiragana'] = 0x3089;
  11696. t['rakatakana'] = 0x30E9;
  11697. t['rakatakanahalfwidth'] = 0xFF97;
  11698. t['ralowerdiagonalbengali'] = 0x09F1;
  11699. t['ramiddlediagonalbengali'] = 0x09F0;
  11700. t['ramshorn'] = 0x0264;
  11701. t['ratio'] = 0x2236;
  11702. t['rbopomofo'] = 0x3116;
  11703. t['rcaron'] = 0x0159;
  11704. t['rcedilla'] = 0x0157;
  11705. t['rcircle'] = 0x24E1;
  11706. t['rcommaaccent'] = 0x0157;
  11707. t['rdblgrave'] = 0x0211;
  11708. t['rdotaccent'] = 0x1E59;
  11709. t['rdotbelow'] = 0x1E5B;
  11710. t['rdotbelowmacron'] = 0x1E5D;
  11711. t['referencemark'] = 0x203B;
  11712. t['reflexsubset'] = 0x2286;
  11713. t['reflexsuperset'] = 0x2287;
  11714. t['registered'] = 0x00AE;
  11715. t['registersans'] = 0xF8E8;
  11716. t['registerserif'] = 0xF6DA;
  11717. t['reharabic'] = 0x0631;
  11718. t['reharmenian'] = 0x0580;
  11719. t['rehfinalarabic'] = 0xFEAE;
  11720. t['rehiragana'] = 0x308C;
  11721. t['rekatakana'] = 0x30EC;
  11722. t['rekatakanahalfwidth'] = 0xFF9A;
  11723. t['resh'] = 0x05E8;
  11724. t['reshdageshhebrew'] = 0xFB48;
  11725. t['reshhebrew'] = 0x05E8;
  11726. t['reversedtilde'] = 0x223D;
  11727. t['reviahebrew'] = 0x0597;
  11728. t['reviamugrashhebrew'] = 0x0597;
  11729. t['revlogicalnot'] = 0x2310;
  11730. t['rfishhook'] = 0x027E;
  11731. t['rfishhookreversed'] = 0x027F;
  11732. t['rhabengali'] = 0x09DD;
  11733. t['rhadeva'] = 0x095D;
  11734. t['rho'] = 0x03C1;
  11735. t['rhook'] = 0x027D;
  11736. t['rhookturned'] = 0x027B;
  11737. t['rhookturnedsuperior'] = 0x02B5;
  11738. t['rhosymbolgreek'] = 0x03F1;
  11739. t['rhotichookmod'] = 0x02DE;
  11740. t['rieulacirclekorean'] = 0x3271;
  11741. t['rieulaparenkorean'] = 0x3211;
  11742. t['rieulcirclekorean'] = 0x3263;
  11743. t['rieulhieuhkorean'] = 0x3140;
  11744. t['rieulkiyeokkorean'] = 0x313A;
  11745. t['rieulkiyeoksioskorean'] = 0x3169;
  11746. t['rieulkorean'] = 0x3139;
  11747. t['rieulmieumkorean'] = 0x313B;
  11748. t['rieulpansioskorean'] = 0x316C;
  11749. t['rieulparenkorean'] = 0x3203;
  11750. t['rieulphieuphkorean'] = 0x313F;
  11751. t['rieulpieupkorean'] = 0x313C;
  11752. t['rieulpieupsioskorean'] = 0x316B;
  11753. t['rieulsioskorean'] = 0x313D;
  11754. t['rieulthieuthkorean'] = 0x313E;
  11755. t['rieultikeutkorean'] = 0x316A;
  11756. t['rieulyeorinhieuhkorean'] = 0x316D;
  11757. t['rightangle'] = 0x221F;
  11758. t['righttackbelowcmb'] = 0x0319;
  11759. t['righttriangle'] = 0x22BF;
  11760. t['rihiragana'] = 0x308A;
  11761. t['rikatakana'] = 0x30EA;
  11762. t['rikatakanahalfwidth'] = 0xFF98;
  11763. t['ring'] = 0x02DA;
  11764. t['ringbelowcmb'] = 0x0325;
  11765. t['ringcmb'] = 0x030A;
  11766. t['ringhalfleft'] = 0x02BF;
  11767. t['ringhalfleftarmenian'] = 0x0559;
  11768. t['ringhalfleftbelowcmb'] = 0x031C;
  11769. t['ringhalfleftcentered'] = 0x02D3;
  11770. t['ringhalfright'] = 0x02BE;
  11771. t['ringhalfrightbelowcmb'] = 0x0339;
  11772. t['ringhalfrightcentered'] = 0x02D2;
  11773. t['rinvertedbreve'] = 0x0213;
  11774. t['rittorusquare'] = 0x3351;
  11775. t['rlinebelow'] = 0x1E5F;
  11776. t['rlongleg'] = 0x027C;
  11777. t['rlonglegturned'] = 0x027A;
  11778. t['rmonospace'] = 0xFF52;
  11779. t['rohiragana'] = 0x308D;
  11780. t['rokatakana'] = 0x30ED;
  11781. t['rokatakanahalfwidth'] = 0xFF9B;
  11782. t['roruathai'] = 0x0E23;
  11783. t['rparen'] = 0x24AD;
  11784. t['rrabengali'] = 0x09DC;
  11785. t['rradeva'] = 0x0931;
  11786. t['rragurmukhi'] = 0x0A5C;
  11787. t['rreharabic'] = 0x0691;
  11788. t['rrehfinalarabic'] = 0xFB8D;
  11789. t['rrvocalicbengali'] = 0x09E0;
  11790. t['rrvocalicdeva'] = 0x0960;
  11791. t['rrvocalicgujarati'] = 0x0AE0;
  11792. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11793. t['rrvocalicvowelsigndeva'] = 0x0944;
  11794. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11795. t['rsuperior'] = 0xF6F1;
  11796. t['rtblock'] = 0x2590;
  11797. t['rturned'] = 0x0279;
  11798. t['rturnedsuperior'] = 0x02B4;
  11799. t['ruhiragana'] = 0x308B;
  11800. t['rukatakana'] = 0x30EB;
  11801. t['rukatakanahalfwidth'] = 0xFF99;
  11802. t['rupeemarkbengali'] = 0x09F2;
  11803. t['rupeesignbengali'] = 0x09F3;
  11804. t['rupiah'] = 0xF6DD;
  11805. t['ruthai'] = 0x0E24;
  11806. t['rvocalicbengali'] = 0x098B;
  11807. t['rvocalicdeva'] = 0x090B;
  11808. t['rvocalicgujarati'] = 0x0A8B;
  11809. t['rvocalicvowelsignbengali'] = 0x09C3;
  11810. t['rvocalicvowelsigndeva'] = 0x0943;
  11811. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11812. t['s'] = 0x0073;
  11813. t['sabengali'] = 0x09B8;
  11814. t['sacute'] = 0x015B;
  11815. t['sacutedotaccent'] = 0x1E65;
  11816. t['sadarabic'] = 0x0635;
  11817. t['sadeva'] = 0x0938;
  11818. t['sadfinalarabic'] = 0xFEBA;
  11819. t['sadinitialarabic'] = 0xFEBB;
  11820. t['sadmedialarabic'] = 0xFEBC;
  11821. t['sagujarati'] = 0x0AB8;
  11822. t['sagurmukhi'] = 0x0A38;
  11823. t['sahiragana'] = 0x3055;
  11824. t['sakatakana'] = 0x30B5;
  11825. t['sakatakanahalfwidth'] = 0xFF7B;
  11826. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11827. t['samekh'] = 0x05E1;
  11828. t['samekhdagesh'] = 0xFB41;
  11829. t['samekhdageshhebrew'] = 0xFB41;
  11830. t['samekhhebrew'] = 0x05E1;
  11831. t['saraaathai'] = 0x0E32;
  11832. t['saraaethai'] = 0x0E41;
  11833. t['saraaimaimalaithai'] = 0x0E44;
  11834. t['saraaimaimuanthai'] = 0x0E43;
  11835. t['saraamthai'] = 0x0E33;
  11836. t['saraathai'] = 0x0E30;
  11837. t['saraethai'] = 0x0E40;
  11838. t['saraiileftthai'] = 0xF886;
  11839. t['saraiithai'] = 0x0E35;
  11840. t['saraileftthai'] = 0xF885;
  11841. t['saraithai'] = 0x0E34;
  11842. t['saraothai'] = 0x0E42;
  11843. t['saraueeleftthai'] = 0xF888;
  11844. t['saraueethai'] = 0x0E37;
  11845. t['saraueleftthai'] = 0xF887;
  11846. t['sarauethai'] = 0x0E36;
  11847. t['sarauthai'] = 0x0E38;
  11848. t['sarauuthai'] = 0x0E39;
  11849. t['sbopomofo'] = 0x3119;
  11850. t['scaron'] = 0x0161;
  11851. t['scarondotaccent'] = 0x1E67;
  11852. t['scedilla'] = 0x015F;
  11853. t['schwa'] = 0x0259;
  11854. t['schwacyrillic'] = 0x04D9;
  11855. t['schwadieresiscyrillic'] = 0x04DB;
  11856. t['schwahook'] = 0x025A;
  11857. t['scircle'] = 0x24E2;
  11858. t['scircumflex'] = 0x015D;
  11859. t['scommaaccent'] = 0x0219;
  11860. t['sdotaccent'] = 0x1E61;
  11861. t['sdotbelow'] = 0x1E63;
  11862. t['sdotbelowdotaccent'] = 0x1E69;
  11863. t['seagullbelowcmb'] = 0x033C;
  11864. t['second'] = 0x2033;
  11865. t['secondtonechinese'] = 0x02CA;
  11866. t['section'] = 0x00A7;
  11867. t['seenarabic'] = 0x0633;
  11868. t['seenfinalarabic'] = 0xFEB2;
  11869. t['seeninitialarabic'] = 0xFEB3;
  11870. t['seenmedialarabic'] = 0xFEB4;
  11871. t['segol'] = 0x05B6;
  11872. t['segol13'] = 0x05B6;
  11873. t['segol1f'] = 0x05B6;
  11874. t['segol2c'] = 0x05B6;
  11875. t['segolhebrew'] = 0x05B6;
  11876. t['segolnarrowhebrew'] = 0x05B6;
  11877. t['segolquarterhebrew'] = 0x05B6;
  11878. t['segoltahebrew'] = 0x0592;
  11879. t['segolwidehebrew'] = 0x05B6;
  11880. t['seharmenian'] = 0x057D;
  11881. t['sehiragana'] = 0x305B;
  11882. t['sekatakana'] = 0x30BB;
  11883. t['sekatakanahalfwidth'] = 0xFF7E;
  11884. t['semicolon'] = 0x003B;
  11885. t['semicolonarabic'] = 0x061B;
  11886. t['semicolonmonospace'] = 0xFF1B;
  11887. t['semicolonsmall'] = 0xFE54;
  11888. t['semivoicedmarkkana'] = 0x309C;
  11889. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11890. t['sentisquare'] = 0x3322;
  11891. t['sentosquare'] = 0x3323;
  11892. t['seven'] = 0x0037;
  11893. t['sevenarabic'] = 0x0667;
  11894. t['sevenbengali'] = 0x09ED;
  11895. t['sevencircle'] = 0x2466;
  11896. t['sevencircleinversesansserif'] = 0x2790;
  11897. t['sevendeva'] = 0x096D;
  11898. t['seveneighths'] = 0x215E;
  11899. t['sevengujarati'] = 0x0AED;
  11900. t['sevengurmukhi'] = 0x0A6D;
  11901. t['sevenhackarabic'] = 0x0667;
  11902. t['sevenhangzhou'] = 0x3027;
  11903. t['sevenideographicparen'] = 0x3226;
  11904. t['seveninferior'] = 0x2087;
  11905. t['sevenmonospace'] = 0xFF17;
  11906. t['sevenoldstyle'] = 0xF737;
  11907. t['sevenparen'] = 0x247A;
  11908. t['sevenperiod'] = 0x248E;
  11909. t['sevenpersian'] = 0x06F7;
  11910. t['sevenroman'] = 0x2176;
  11911. t['sevensuperior'] = 0x2077;
  11912. t['seventeencircle'] = 0x2470;
  11913. t['seventeenparen'] = 0x2484;
  11914. t['seventeenperiod'] = 0x2498;
  11915. t['seventhai'] = 0x0E57;
  11916. t['sfthyphen'] = 0x00AD;
  11917. t['shaarmenian'] = 0x0577;
  11918. t['shabengali'] = 0x09B6;
  11919. t['shacyrillic'] = 0x0448;
  11920. t['shaddaarabic'] = 0x0651;
  11921. t['shaddadammaarabic'] = 0xFC61;
  11922. t['shaddadammatanarabic'] = 0xFC5E;
  11923. t['shaddafathaarabic'] = 0xFC60;
  11924. t['shaddakasraarabic'] = 0xFC62;
  11925. t['shaddakasratanarabic'] = 0xFC5F;
  11926. t['shade'] = 0x2592;
  11927. t['shadedark'] = 0x2593;
  11928. t['shadelight'] = 0x2591;
  11929. t['shademedium'] = 0x2592;
  11930. t['shadeva'] = 0x0936;
  11931. t['shagujarati'] = 0x0AB6;
  11932. t['shagurmukhi'] = 0x0A36;
  11933. t['shalshelethebrew'] = 0x0593;
  11934. t['shbopomofo'] = 0x3115;
  11935. t['shchacyrillic'] = 0x0449;
  11936. t['sheenarabic'] = 0x0634;
  11937. t['sheenfinalarabic'] = 0xFEB6;
  11938. t['sheeninitialarabic'] = 0xFEB7;
  11939. t['sheenmedialarabic'] = 0xFEB8;
  11940. t['sheicoptic'] = 0x03E3;
  11941. t['sheqel'] = 0x20AA;
  11942. t['sheqelhebrew'] = 0x20AA;
  11943. t['sheva'] = 0x05B0;
  11944. t['sheva115'] = 0x05B0;
  11945. t['sheva15'] = 0x05B0;
  11946. t['sheva22'] = 0x05B0;
  11947. t['sheva2e'] = 0x05B0;
  11948. t['shevahebrew'] = 0x05B0;
  11949. t['shevanarrowhebrew'] = 0x05B0;
  11950. t['shevaquarterhebrew'] = 0x05B0;
  11951. t['shevawidehebrew'] = 0x05B0;
  11952. t['shhacyrillic'] = 0x04BB;
  11953. t['shimacoptic'] = 0x03ED;
  11954. t['shin'] = 0x05E9;
  11955. t['shindagesh'] = 0xFB49;
  11956. t['shindageshhebrew'] = 0xFB49;
  11957. t['shindageshshindot'] = 0xFB2C;
  11958. t['shindageshshindothebrew'] = 0xFB2C;
  11959. t['shindageshsindot'] = 0xFB2D;
  11960. t['shindageshsindothebrew'] = 0xFB2D;
  11961. t['shindothebrew'] = 0x05C1;
  11962. t['shinhebrew'] = 0x05E9;
  11963. t['shinshindot'] = 0xFB2A;
  11964. t['shinshindothebrew'] = 0xFB2A;
  11965. t['shinsindot'] = 0xFB2B;
  11966. t['shinsindothebrew'] = 0xFB2B;
  11967. t['shook'] = 0x0282;
  11968. t['sigma'] = 0x03C3;
  11969. t['sigma1'] = 0x03C2;
  11970. t['sigmafinal'] = 0x03C2;
  11971. t['sigmalunatesymbolgreek'] = 0x03F2;
  11972. t['sihiragana'] = 0x3057;
  11973. t['sikatakana'] = 0x30B7;
  11974. t['sikatakanahalfwidth'] = 0xFF7C;
  11975. t['siluqhebrew'] = 0x05BD;
  11976. t['siluqlefthebrew'] = 0x05BD;
  11977. t['similar'] = 0x223C;
  11978. t['sindothebrew'] = 0x05C2;
  11979. t['siosacirclekorean'] = 0x3274;
  11980. t['siosaparenkorean'] = 0x3214;
  11981. t['sioscieuckorean'] = 0x317E;
  11982. t['sioscirclekorean'] = 0x3266;
  11983. t['sioskiyeokkorean'] = 0x317A;
  11984. t['sioskorean'] = 0x3145;
  11985. t['siosnieunkorean'] = 0x317B;
  11986. t['siosparenkorean'] = 0x3206;
  11987. t['siospieupkorean'] = 0x317D;
  11988. t['siostikeutkorean'] = 0x317C;
  11989. t['six'] = 0x0036;
  11990. t['sixarabic'] = 0x0666;
  11991. t['sixbengali'] = 0x09EC;
  11992. t['sixcircle'] = 0x2465;
  11993. t['sixcircleinversesansserif'] = 0x278F;
  11994. t['sixdeva'] = 0x096C;
  11995. t['sixgujarati'] = 0x0AEC;
  11996. t['sixgurmukhi'] = 0x0A6C;
  11997. t['sixhackarabic'] = 0x0666;
  11998. t['sixhangzhou'] = 0x3026;
  11999. t['sixideographicparen'] = 0x3225;
  12000. t['sixinferior'] = 0x2086;
  12001. t['sixmonospace'] = 0xFF16;
  12002. t['sixoldstyle'] = 0xF736;
  12003. t['sixparen'] = 0x2479;
  12004. t['sixperiod'] = 0x248D;
  12005. t['sixpersian'] = 0x06F6;
  12006. t['sixroman'] = 0x2175;
  12007. t['sixsuperior'] = 0x2076;
  12008. t['sixteencircle'] = 0x246F;
  12009. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12010. t['sixteenparen'] = 0x2483;
  12011. t['sixteenperiod'] = 0x2497;
  12012. t['sixthai'] = 0x0E56;
  12013. t['slash'] = 0x002F;
  12014. t['slashmonospace'] = 0xFF0F;
  12015. t['slong'] = 0x017F;
  12016. t['slongdotaccent'] = 0x1E9B;
  12017. t['smileface'] = 0x263A;
  12018. t['smonospace'] = 0xFF53;
  12019. t['sofpasuqhebrew'] = 0x05C3;
  12020. t['softhyphen'] = 0x00AD;
  12021. t['softsigncyrillic'] = 0x044C;
  12022. t['sohiragana'] = 0x305D;
  12023. t['sokatakana'] = 0x30BD;
  12024. t['sokatakanahalfwidth'] = 0xFF7F;
  12025. t['soliduslongoverlaycmb'] = 0x0338;
  12026. t['solidusshortoverlaycmb'] = 0x0337;
  12027. t['sorusithai'] = 0x0E29;
  12028. t['sosalathai'] = 0x0E28;
  12029. t['sosothai'] = 0x0E0B;
  12030. t['sosuathai'] = 0x0E2A;
  12031. t['space'] = 0x0020;
  12032. t['spacehackarabic'] = 0x0020;
  12033. t['spade'] = 0x2660;
  12034. t['spadesuitblack'] = 0x2660;
  12035. t['spadesuitwhite'] = 0x2664;
  12036. t['sparen'] = 0x24AE;
  12037. t['squarebelowcmb'] = 0x033B;
  12038. t['squarecc'] = 0x33C4;
  12039. t['squarecm'] = 0x339D;
  12040. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12041. t['squarehorizontalfill'] = 0x25A4;
  12042. t['squarekg'] = 0x338F;
  12043. t['squarekm'] = 0x339E;
  12044. t['squarekmcapital'] = 0x33CE;
  12045. t['squareln'] = 0x33D1;
  12046. t['squarelog'] = 0x33D2;
  12047. t['squaremg'] = 0x338E;
  12048. t['squaremil'] = 0x33D5;
  12049. t['squaremm'] = 0x339C;
  12050. t['squaremsquared'] = 0x33A1;
  12051. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12052. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12053. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12054. t['squareverticalfill'] = 0x25A5;
  12055. t['squarewhitewithsmallblack'] = 0x25A3;
  12056. t['srsquare'] = 0x33DB;
  12057. t['ssabengali'] = 0x09B7;
  12058. t['ssadeva'] = 0x0937;
  12059. t['ssagujarati'] = 0x0AB7;
  12060. t['ssangcieuckorean'] = 0x3149;
  12061. t['ssanghieuhkorean'] = 0x3185;
  12062. t['ssangieungkorean'] = 0x3180;
  12063. t['ssangkiyeokkorean'] = 0x3132;
  12064. t['ssangnieunkorean'] = 0x3165;
  12065. t['ssangpieupkorean'] = 0x3143;
  12066. t['ssangsioskorean'] = 0x3146;
  12067. t['ssangtikeutkorean'] = 0x3138;
  12068. t['ssuperior'] = 0xF6F2;
  12069. t['sterling'] = 0x00A3;
  12070. t['sterlingmonospace'] = 0xFFE1;
  12071. t['strokelongoverlaycmb'] = 0x0336;
  12072. t['strokeshortoverlaycmb'] = 0x0335;
  12073. t['subset'] = 0x2282;
  12074. t['subsetnotequal'] = 0x228A;
  12075. t['subsetorequal'] = 0x2286;
  12076. t['succeeds'] = 0x227B;
  12077. t['suchthat'] = 0x220B;
  12078. t['suhiragana'] = 0x3059;
  12079. t['sukatakana'] = 0x30B9;
  12080. t['sukatakanahalfwidth'] = 0xFF7D;
  12081. t['sukunarabic'] = 0x0652;
  12082. t['summation'] = 0x2211;
  12083. t['sun'] = 0x263C;
  12084. t['superset'] = 0x2283;
  12085. t['supersetnotequal'] = 0x228B;
  12086. t['supersetorequal'] = 0x2287;
  12087. t['svsquare'] = 0x33DC;
  12088. t['syouwaerasquare'] = 0x337C;
  12089. t['t'] = 0x0074;
  12090. t['tabengali'] = 0x09A4;
  12091. t['tackdown'] = 0x22A4;
  12092. t['tackleft'] = 0x22A3;
  12093. t['tadeva'] = 0x0924;
  12094. t['tagujarati'] = 0x0AA4;
  12095. t['tagurmukhi'] = 0x0A24;
  12096. t['taharabic'] = 0x0637;
  12097. t['tahfinalarabic'] = 0xFEC2;
  12098. t['tahinitialarabic'] = 0xFEC3;
  12099. t['tahiragana'] = 0x305F;
  12100. t['tahmedialarabic'] = 0xFEC4;
  12101. t['taisyouerasquare'] = 0x337D;
  12102. t['takatakana'] = 0x30BF;
  12103. t['takatakanahalfwidth'] = 0xFF80;
  12104. t['tatweelarabic'] = 0x0640;
  12105. t['tau'] = 0x03C4;
  12106. t['tav'] = 0x05EA;
  12107. t['tavdages'] = 0xFB4A;
  12108. t['tavdagesh'] = 0xFB4A;
  12109. t['tavdageshhebrew'] = 0xFB4A;
  12110. t['tavhebrew'] = 0x05EA;
  12111. t['tbar'] = 0x0167;
  12112. t['tbopomofo'] = 0x310A;
  12113. t['tcaron'] = 0x0165;
  12114. t['tccurl'] = 0x02A8;
  12115. t['tcedilla'] = 0x0163;
  12116. t['tcheharabic'] = 0x0686;
  12117. t['tchehfinalarabic'] = 0xFB7B;
  12118. t['tchehinitialarabic'] = 0xFB7C;
  12119. t['tchehmedialarabic'] = 0xFB7D;
  12120. t['tcircle'] = 0x24E3;
  12121. t['tcircumflexbelow'] = 0x1E71;
  12122. t['tcommaaccent'] = 0x0163;
  12123. t['tdieresis'] = 0x1E97;
  12124. t['tdotaccent'] = 0x1E6B;
  12125. t['tdotbelow'] = 0x1E6D;
  12126. t['tecyrillic'] = 0x0442;
  12127. t['tedescendercyrillic'] = 0x04AD;
  12128. t['teharabic'] = 0x062A;
  12129. t['tehfinalarabic'] = 0xFE96;
  12130. t['tehhahinitialarabic'] = 0xFCA2;
  12131. t['tehhahisolatedarabic'] = 0xFC0C;
  12132. t['tehinitialarabic'] = 0xFE97;
  12133. t['tehiragana'] = 0x3066;
  12134. t['tehjeeminitialarabic'] = 0xFCA1;
  12135. t['tehjeemisolatedarabic'] = 0xFC0B;
  12136. t['tehmarbutaarabic'] = 0x0629;
  12137. t['tehmarbutafinalarabic'] = 0xFE94;
  12138. t['tehmedialarabic'] = 0xFE98;
  12139. t['tehmeeminitialarabic'] = 0xFCA4;
  12140. t['tehmeemisolatedarabic'] = 0xFC0E;
  12141. t['tehnoonfinalarabic'] = 0xFC73;
  12142. t['tekatakana'] = 0x30C6;
  12143. t['tekatakanahalfwidth'] = 0xFF83;
  12144. t['telephone'] = 0x2121;
  12145. t['telephoneblack'] = 0x260E;
  12146. t['telishagedolahebrew'] = 0x05A0;
  12147. t['telishaqetanahebrew'] = 0x05A9;
  12148. t['tencircle'] = 0x2469;
  12149. t['tenideographicparen'] = 0x3229;
  12150. t['tenparen'] = 0x247D;
  12151. t['tenperiod'] = 0x2491;
  12152. t['tenroman'] = 0x2179;
  12153. t['tesh'] = 0x02A7;
  12154. t['tet'] = 0x05D8;
  12155. t['tetdagesh'] = 0xFB38;
  12156. t['tetdageshhebrew'] = 0xFB38;
  12157. t['tethebrew'] = 0x05D8;
  12158. t['tetsecyrillic'] = 0x04B5;
  12159. t['tevirhebrew'] = 0x059B;
  12160. t['tevirlefthebrew'] = 0x059B;
  12161. t['thabengali'] = 0x09A5;
  12162. t['thadeva'] = 0x0925;
  12163. t['thagujarati'] = 0x0AA5;
  12164. t['thagurmukhi'] = 0x0A25;
  12165. t['thalarabic'] = 0x0630;
  12166. t['thalfinalarabic'] = 0xFEAC;
  12167. t['thanthakhatlowleftthai'] = 0xF898;
  12168. t['thanthakhatlowrightthai'] = 0xF897;
  12169. t['thanthakhatthai'] = 0x0E4C;
  12170. t['thanthakhatupperleftthai'] = 0xF896;
  12171. t['theharabic'] = 0x062B;
  12172. t['thehfinalarabic'] = 0xFE9A;
  12173. t['thehinitialarabic'] = 0xFE9B;
  12174. t['thehmedialarabic'] = 0xFE9C;
  12175. t['thereexists'] = 0x2203;
  12176. t['therefore'] = 0x2234;
  12177. t['theta'] = 0x03B8;
  12178. t['theta1'] = 0x03D1;
  12179. t['thetasymbolgreek'] = 0x03D1;
  12180. t['thieuthacirclekorean'] = 0x3279;
  12181. t['thieuthaparenkorean'] = 0x3219;
  12182. t['thieuthcirclekorean'] = 0x326B;
  12183. t['thieuthkorean'] = 0x314C;
  12184. t['thieuthparenkorean'] = 0x320B;
  12185. t['thirteencircle'] = 0x246C;
  12186. t['thirteenparen'] = 0x2480;
  12187. t['thirteenperiod'] = 0x2494;
  12188. t['thonangmonthothai'] = 0x0E11;
  12189. t['thook'] = 0x01AD;
  12190. t['thophuthaothai'] = 0x0E12;
  12191. t['thorn'] = 0x00FE;
  12192. t['thothahanthai'] = 0x0E17;
  12193. t['thothanthai'] = 0x0E10;
  12194. t['thothongthai'] = 0x0E18;
  12195. t['thothungthai'] = 0x0E16;
  12196. t['thousandcyrillic'] = 0x0482;
  12197. t['thousandsseparatorarabic'] = 0x066C;
  12198. t['thousandsseparatorpersian'] = 0x066C;
  12199. t['three'] = 0x0033;
  12200. t['threearabic'] = 0x0663;
  12201. t['threebengali'] = 0x09E9;
  12202. t['threecircle'] = 0x2462;
  12203. t['threecircleinversesansserif'] = 0x278C;
  12204. t['threedeva'] = 0x0969;
  12205. t['threeeighths'] = 0x215C;
  12206. t['threegujarati'] = 0x0AE9;
  12207. t['threegurmukhi'] = 0x0A69;
  12208. t['threehackarabic'] = 0x0663;
  12209. t['threehangzhou'] = 0x3023;
  12210. t['threeideographicparen'] = 0x3222;
  12211. t['threeinferior'] = 0x2083;
  12212. t['threemonospace'] = 0xFF13;
  12213. t['threenumeratorbengali'] = 0x09F6;
  12214. t['threeoldstyle'] = 0xF733;
  12215. t['threeparen'] = 0x2476;
  12216. t['threeperiod'] = 0x248A;
  12217. t['threepersian'] = 0x06F3;
  12218. t['threequarters'] = 0x00BE;
  12219. t['threequartersemdash'] = 0xF6DE;
  12220. t['threeroman'] = 0x2172;
  12221. t['threesuperior'] = 0x00B3;
  12222. t['threethai'] = 0x0E53;
  12223. t['thzsquare'] = 0x3394;
  12224. t['tihiragana'] = 0x3061;
  12225. t['tikatakana'] = 0x30C1;
  12226. t['tikatakanahalfwidth'] = 0xFF81;
  12227. t['tikeutacirclekorean'] = 0x3270;
  12228. t['tikeutaparenkorean'] = 0x3210;
  12229. t['tikeutcirclekorean'] = 0x3262;
  12230. t['tikeutkorean'] = 0x3137;
  12231. t['tikeutparenkorean'] = 0x3202;
  12232. t['tilde'] = 0x02DC;
  12233. t['tildebelowcmb'] = 0x0330;
  12234. t['tildecmb'] = 0x0303;
  12235. t['tildecomb'] = 0x0303;
  12236. t['tildedoublecmb'] = 0x0360;
  12237. t['tildeoperator'] = 0x223C;
  12238. t['tildeoverlaycmb'] = 0x0334;
  12239. t['tildeverticalcmb'] = 0x033E;
  12240. t['timescircle'] = 0x2297;
  12241. t['tipehahebrew'] = 0x0596;
  12242. t['tipehalefthebrew'] = 0x0596;
  12243. t['tippigurmukhi'] = 0x0A70;
  12244. t['titlocyrilliccmb'] = 0x0483;
  12245. t['tiwnarmenian'] = 0x057F;
  12246. t['tlinebelow'] = 0x1E6F;
  12247. t['tmonospace'] = 0xFF54;
  12248. t['toarmenian'] = 0x0569;
  12249. t['tohiragana'] = 0x3068;
  12250. t['tokatakana'] = 0x30C8;
  12251. t['tokatakanahalfwidth'] = 0xFF84;
  12252. t['tonebarextrahighmod'] = 0x02E5;
  12253. t['tonebarextralowmod'] = 0x02E9;
  12254. t['tonebarhighmod'] = 0x02E6;
  12255. t['tonebarlowmod'] = 0x02E8;
  12256. t['tonebarmidmod'] = 0x02E7;
  12257. t['tonefive'] = 0x01BD;
  12258. t['tonesix'] = 0x0185;
  12259. t['tonetwo'] = 0x01A8;
  12260. t['tonos'] = 0x0384;
  12261. t['tonsquare'] = 0x3327;
  12262. t['topatakthai'] = 0x0E0F;
  12263. t['tortoiseshellbracketleft'] = 0x3014;
  12264. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12265. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12266. t['tortoiseshellbracketright'] = 0x3015;
  12267. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12268. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12269. t['totaothai'] = 0x0E15;
  12270. t['tpalatalhook'] = 0x01AB;
  12271. t['tparen'] = 0x24AF;
  12272. t['trademark'] = 0x2122;
  12273. t['trademarksans'] = 0xF8EA;
  12274. t['trademarkserif'] = 0xF6DB;
  12275. t['tretroflexhook'] = 0x0288;
  12276. t['triagdn'] = 0x25BC;
  12277. t['triaglf'] = 0x25C4;
  12278. t['triagrt'] = 0x25BA;
  12279. t['triagup'] = 0x25B2;
  12280. t['ts'] = 0x02A6;
  12281. t['tsadi'] = 0x05E6;
  12282. t['tsadidagesh'] = 0xFB46;
  12283. t['tsadidageshhebrew'] = 0xFB46;
  12284. t['tsadihebrew'] = 0x05E6;
  12285. t['tsecyrillic'] = 0x0446;
  12286. t['tsere'] = 0x05B5;
  12287. t['tsere12'] = 0x05B5;
  12288. t['tsere1e'] = 0x05B5;
  12289. t['tsere2b'] = 0x05B5;
  12290. t['tserehebrew'] = 0x05B5;
  12291. t['tserenarrowhebrew'] = 0x05B5;
  12292. t['tserequarterhebrew'] = 0x05B5;
  12293. t['tserewidehebrew'] = 0x05B5;
  12294. t['tshecyrillic'] = 0x045B;
  12295. t['tsuperior'] = 0xF6F3;
  12296. t['ttabengali'] = 0x099F;
  12297. t['ttadeva'] = 0x091F;
  12298. t['ttagujarati'] = 0x0A9F;
  12299. t['ttagurmukhi'] = 0x0A1F;
  12300. t['tteharabic'] = 0x0679;
  12301. t['ttehfinalarabic'] = 0xFB67;
  12302. t['ttehinitialarabic'] = 0xFB68;
  12303. t['ttehmedialarabic'] = 0xFB69;
  12304. t['tthabengali'] = 0x09A0;
  12305. t['tthadeva'] = 0x0920;
  12306. t['tthagujarati'] = 0x0AA0;
  12307. t['tthagurmukhi'] = 0x0A20;
  12308. t['tturned'] = 0x0287;
  12309. t['tuhiragana'] = 0x3064;
  12310. t['tukatakana'] = 0x30C4;
  12311. t['tukatakanahalfwidth'] = 0xFF82;
  12312. t['tusmallhiragana'] = 0x3063;
  12313. t['tusmallkatakana'] = 0x30C3;
  12314. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12315. t['twelvecircle'] = 0x246B;
  12316. t['twelveparen'] = 0x247F;
  12317. t['twelveperiod'] = 0x2493;
  12318. t['twelveroman'] = 0x217B;
  12319. t['twentycircle'] = 0x2473;
  12320. t['twentyhangzhou'] = 0x5344;
  12321. t['twentyparen'] = 0x2487;
  12322. t['twentyperiod'] = 0x249B;
  12323. t['two'] = 0x0032;
  12324. t['twoarabic'] = 0x0662;
  12325. t['twobengali'] = 0x09E8;
  12326. t['twocircle'] = 0x2461;
  12327. t['twocircleinversesansserif'] = 0x278B;
  12328. t['twodeva'] = 0x0968;
  12329. t['twodotenleader'] = 0x2025;
  12330. t['twodotleader'] = 0x2025;
  12331. t['twodotleadervertical'] = 0xFE30;
  12332. t['twogujarati'] = 0x0AE8;
  12333. t['twogurmukhi'] = 0x0A68;
  12334. t['twohackarabic'] = 0x0662;
  12335. t['twohangzhou'] = 0x3022;
  12336. t['twoideographicparen'] = 0x3221;
  12337. t['twoinferior'] = 0x2082;
  12338. t['twomonospace'] = 0xFF12;
  12339. t['twonumeratorbengali'] = 0x09F5;
  12340. t['twooldstyle'] = 0xF732;
  12341. t['twoparen'] = 0x2475;
  12342. t['twoperiod'] = 0x2489;
  12343. t['twopersian'] = 0x06F2;
  12344. t['tworoman'] = 0x2171;
  12345. t['twostroke'] = 0x01BB;
  12346. t['twosuperior'] = 0x00B2;
  12347. t['twothai'] = 0x0E52;
  12348. t['twothirds'] = 0x2154;
  12349. t['u'] = 0x0075;
  12350. t['uacute'] = 0x00FA;
  12351. t['ubar'] = 0x0289;
  12352. t['ubengali'] = 0x0989;
  12353. t['ubopomofo'] = 0x3128;
  12354. t['ubreve'] = 0x016D;
  12355. t['ucaron'] = 0x01D4;
  12356. t['ucircle'] = 0x24E4;
  12357. t['ucircumflex'] = 0x00FB;
  12358. t['ucircumflexbelow'] = 0x1E77;
  12359. t['ucyrillic'] = 0x0443;
  12360. t['udattadeva'] = 0x0951;
  12361. t['udblacute'] = 0x0171;
  12362. t['udblgrave'] = 0x0215;
  12363. t['udeva'] = 0x0909;
  12364. t['udieresis'] = 0x00FC;
  12365. t['udieresisacute'] = 0x01D8;
  12366. t['udieresisbelow'] = 0x1E73;
  12367. t['udieresiscaron'] = 0x01DA;
  12368. t['udieresiscyrillic'] = 0x04F1;
  12369. t['udieresisgrave'] = 0x01DC;
  12370. t['udieresismacron'] = 0x01D6;
  12371. t['udotbelow'] = 0x1EE5;
  12372. t['ugrave'] = 0x00F9;
  12373. t['ugujarati'] = 0x0A89;
  12374. t['ugurmukhi'] = 0x0A09;
  12375. t['uhiragana'] = 0x3046;
  12376. t['uhookabove'] = 0x1EE7;
  12377. t['uhorn'] = 0x01B0;
  12378. t['uhornacute'] = 0x1EE9;
  12379. t['uhorndotbelow'] = 0x1EF1;
  12380. t['uhorngrave'] = 0x1EEB;
  12381. t['uhornhookabove'] = 0x1EED;
  12382. t['uhorntilde'] = 0x1EEF;
  12383. t['uhungarumlaut'] = 0x0171;
  12384. t['uhungarumlautcyrillic'] = 0x04F3;
  12385. t['uinvertedbreve'] = 0x0217;
  12386. t['ukatakana'] = 0x30A6;
  12387. t['ukatakanahalfwidth'] = 0xFF73;
  12388. t['ukcyrillic'] = 0x0479;
  12389. t['ukorean'] = 0x315C;
  12390. t['umacron'] = 0x016B;
  12391. t['umacroncyrillic'] = 0x04EF;
  12392. t['umacrondieresis'] = 0x1E7B;
  12393. t['umatragurmukhi'] = 0x0A41;
  12394. t['umonospace'] = 0xFF55;
  12395. t['underscore'] = 0x005F;
  12396. t['underscoredbl'] = 0x2017;
  12397. t['underscoremonospace'] = 0xFF3F;
  12398. t['underscorevertical'] = 0xFE33;
  12399. t['underscorewavy'] = 0xFE4F;
  12400. t['union'] = 0x222A;
  12401. t['universal'] = 0x2200;
  12402. t['uogonek'] = 0x0173;
  12403. t['uparen'] = 0x24B0;
  12404. t['upblock'] = 0x2580;
  12405. t['upperdothebrew'] = 0x05C4;
  12406. t['upsilon'] = 0x03C5;
  12407. t['upsilondieresis'] = 0x03CB;
  12408. t['upsilondieresistonos'] = 0x03B0;
  12409. t['upsilonlatin'] = 0x028A;
  12410. t['upsilontonos'] = 0x03CD;
  12411. t['uptackbelowcmb'] = 0x031D;
  12412. t['uptackmod'] = 0x02D4;
  12413. t['uragurmukhi'] = 0x0A73;
  12414. t['uring'] = 0x016F;
  12415. t['ushortcyrillic'] = 0x045E;
  12416. t['usmallhiragana'] = 0x3045;
  12417. t['usmallkatakana'] = 0x30A5;
  12418. t['usmallkatakanahalfwidth'] = 0xFF69;
  12419. t['ustraightcyrillic'] = 0x04AF;
  12420. t['ustraightstrokecyrillic'] = 0x04B1;
  12421. t['utilde'] = 0x0169;
  12422. t['utildeacute'] = 0x1E79;
  12423. t['utildebelow'] = 0x1E75;
  12424. t['uubengali'] = 0x098A;
  12425. t['uudeva'] = 0x090A;
  12426. t['uugujarati'] = 0x0A8A;
  12427. t['uugurmukhi'] = 0x0A0A;
  12428. t['uumatragurmukhi'] = 0x0A42;
  12429. t['uuvowelsignbengali'] = 0x09C2;
  12430. t['uuvowelsigndeva'] = 0x0942;
  12431. t['uuvowelsigngujarati'] = 0x0AC2;
  12432. t['uvowelsignbengali'] = 0x09C1;
  12433. t['uvowelsigndeva'] = 0x0941;
  12434. t['uvowelsigngujarati'] = 0x0AC1;
  12435. t['v'] = 0x0076;
  12436. t['vadeva'] = 0x0935;
  12437. t['vagujarati'] = 0x0AB5;
  12438. t['vagurmukhi'] = 0x0A35;
  12439. t['vakatakana'] = 0x30F7;
  12440. t['vav'] = 0x05D5;
  12441. t['vavdagesh'] = 0xFB35;
  12442. t['vavdagesh65'] = 0xFB35;
  12443. t['vavdageshhebrew'] = 0xFB35;
  12444. t['vavhebrew'] = 0x05D5;
  12445. t['vavholam'] = 0xFB4B;
  12446. t['vavholamhebrew'] = 0xFB4B;
  12447. t['vavvavhebrew'] = 0x05F0;
  12448. t['vavyodhebrew'] = 0x05F1;
  12449. t['vcircle'] = 0x24E5;
  12450. t['vdotbelow'] = 0x1E7F;
  12451. t['vecyrillic'] = 0x0432;
  12452. t['veharabic'] = 0x06A4;
  12453. t['vehfinalarabic'] = 0xFB6B;
  12454. t['vehinitialarabic'] = 0xFB6C;
  12455. t['vehmedialarabic'] = 0xFB6D;
  12456. t['vekatakana'] = 0x30F9;
  12457. t['venus'] = 0x2640;
  12458. t['verticalbar'] = 0x007C;
  12459. t['verticallineabovecmb'] = 0x030D;
  12460. t['verticallinebelowcmb'] = 0x0329;
  12461. t['verticallinelowmod'] = 0x02CC;
  12462. t['verticallinemod'] = 0x02C8;
  12463. t['vewarmenian'] = 0x057E;
  12464. t['vhook'] = 0x028B;
  12465. t['vikatakana'] = 0x30F8;
  12466. t['viramabengali'] = 0x09CD;
  12467. t['viramadeva'] = 0x094D;
  12468. t['viramagujarati'] = 0x0ACD;
  12469. t['visargabengali'] = 0x0983;
  12470. t['visargadeva'] = 0x0903;
  12471. t['visargagujarati'] = 0x0A83;
  12472. t['vmonospace'] = 0xFF56;
  12473. t['voarmenian'] = 0x0578;
  12474. t['voicediterationhiragana'] = 0x309E;
  12475. t['voicediterationkatakana'] = 0x30FE;
  12476. t['voicedmarkkana'] = 0x309B;
  12477. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12478. t['vokatakana'] = 0x30FA;
  12479. t['vparen'] = 0x24B1;
  12480. t['vtilde'] = 0x1E7D;
  12481. t['vturned'] = 0x028C;
  12482. t['vuhiragana'] = 0x3094;
  12483. t['vukatakana'] = 0x30F4;
  12484. t['w'] = 0x0077;
  12485. t['wacute'] = 0x1E83;
  12486. t['waekorean'] = 0x3159;
  12487. t['wahiragana'] = 0x308F;
  12488. t['wakatakana'] = 0x30EF;
  12489. t['wakatakanahalfwidth'] = 0xFF9C;
  12490. t['wakorean'] = 0x3158;
  12491. t['wasmallhiragana'] = 0x308E;
  12492. t['wasmallkatakana'] = 0x30EE;
  12493. t['wattosquare'] = 0x3357;
  12494. t['wavedash'] = 0x301C;
  12495. t['wavyunderscorevertical'] = 0xFE34;
  12496. t['wawarabic'] = 0x0648;
  12497. t['wawfinalarabic'] = 0xFEEE;
  12498. t['wawhamzaabovearabic'] = 0x0624;
  12499. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12500. t['wbsquare'] = 0x33DD;
  12501. t['wcircle'] = 0x24E6;
  12502. t['wcircumflex'] = 0x0175;
  12503. t['wdieresis'] = 0x1E85;
  12504. t['wdotaccent'] = 0x1E87;
  12505. t['wdotbelow'] = 0x1E89;
  12506. t['wehiragana'] = 0x3091;
  12507. t['weierstrass'] = 0x2118;
  12508. t['wekatakana'] = 0x30F1;
  12509. t['wekorean'] = 0x315E;
  12510. t['weokorean'] = 0x315D;
  12511. t['wgrave'] = 0x1E81;
  12512. t['whitebullet'] = 0x25E6;
  12513. t['whitecircle'] = 0x25CB;
  12514. t['whitecircleinverse'] = 0x25D9;
  12515. t['whitecornerbracketleft'] = 0x300E;
  12516. t['whitecornerbracketleftvertical'] = 0xFE43;
  12517. t['whitecornerbracketright'] = 0x300F;
  12518. t['whitecornerbracketrightvertical'] = 0xFE44;
  12519. t['whitediamond'] = 0x25C7;
  12520. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12521. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12522. t['whitedownpointingtriangle'] = 0x25BD;
  12523. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12524. t['whiteleftpointingtriangle'] = 0x25C1;
  12525. t['whitelenticularbracketleft'] = 0x3016;
  12526. t['whitelenticularbracketright'] = 0x3017;
  12527. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12528. t['whiterightpointingtriangle'] = 0x25B7;
  12529. t['whitesmallsquare'] = 0x25AB;
  12530. t['whitesmilingface'] = 0x263A;
  12531. t['whitesquare'] = 0x25A1;
  12532. t['whitestar'] = 0x2606;
  12533. t['whitetelephone'] = 0x260F;
  12534. t['whitetortoiseshellbracketleft'] = 0x3018;
  12535. t['whitetortoiseshellbracketright'] = 0x3019;
  12536. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12537. t['whiteuppointingtriangle'] = 0x25B3;
  12538. t['wihiragana'] = 0x3090;
  12539. t['wikatakana'] = 0x30F0;
  12540. t['wikorean'] = 0x315F;
  12541. t['wmonospace'] = 0xFF57;
  12542. t['wohiragana'] = 0x3092;
  12543. t['wokatakana'] = 0x30F2;
  12544. t['wokatakanahalfwidth'] = 0xFF66;
  12545. t['won'] = 0x20A9;
  12546. t['wonmonospace'] = 0xFFE6;
  12547. t['wowaenthai'] = 0x0E27;
  12548. t['wparen'] = 0x24B2;
  12549. t['wring'] = 0x1E98;
  12550. t['wsuperior'] = 0x02B7;
  12551. t['wturned'] = 0x028D;
  12552. t['wynn'] = 0x01BF;
  12553. t['x'] = 0x0078;
  12554. t['xabovecmb'] = 0x033D;
  12555. t['xbopomofo'] = 0x3112;
  12556. t['xcircle'] = 0x24E7;
  12557. t['xdieresis'] = 0x1E8D;
  12558. t['xdotaccent'] = 0x1E8B;
  12559. t['xeharmenian'] = 0x056D;
  12560. t['xi'] = 0x03BE;
  12561. t['xmonospace'] = 0xFF58;
  12562. t['xparen'] = 0x24B3;
  12563. t['xsuperior'] = 0x02E3;
  12564. t['y'] = 0x0079;
  12565. t['yaadosquare'] = 0x334E;
  12566. t['yabengali'] = 0x09AF;
  12567. t['yacute'] = 0x00FD;
  12568. t['yadeva'] = 0x092F;
  12569. t['yaekorean'] = 0x3152;
  12570. t['yagujarati'] = 0x0AAF;
  12571. t['yagurmukhi'] = 0x0A2F;
  12572. t['yahiragana'] = 0x3084;
  12573. t['yakatakana'] = 0x30E4;
  12574. t['yakatakanahalfwidth'] = 0xFF94;
  12575. t['yakorean'] = 0x3151;
  12576. t['yamakkanthai'] = 0x0E4E;
  12577. t['yasmallhiragana'] = 0x3083;
  12578. t['yasmallkatakana'] = 0x30E3;
  12579. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12580. t['yatcyrillic'] = 0x0463;
  12581. t['ycircle'] = 0x24E8;
  12582. t['ycircumflex'] = 0x0177;
  12583. t['ydieresis'] = 0x00FF;
  12584. t['ydotaccent'] = 0x1E8F;
  12585. t['ydotbelow'] = 0x1EF5;
  12586. t['yeharabic'] = 0x064A;
  12587. t['yehbarreearabic'] = 0x06D2;
  12588. t['yehbarreefinalarabic'] = 0xFBAF;
  12589. t['yehfinalarabic'] = 0xFEF2;
  12590. t['yehhamzaabovearabic'] = 0x0626;
  12591. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12592. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12593. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12594. t['yehinitialarabic'] = 0xFEF3;
  12595. t['yehmedialarabic'] = 0xFEF4;
  12596. t['yehmeeminitialarabic'] = 0xFCDD;
  12597. t['yehmeemisolatedarabic'] = 0xFC58;
  12598. t['yehnoonfinalarabic'] = 0xFC94;
  12599. t['yehthreedotsbelowarabic'] = 0x06D1;
  12600. t['yekorean'] = 0x3156;
  12601. t['yen'] = 0x00A5;
  12602. t['yenmonospace'] = 0xFFE5;
  12603. t['yeokorean'] = 0x3155;
  12604. t['yeorinhieuhkorean'] = 0x3186;
  12605. t['yerahbenyomohebrew'] = 0x05AA;
  12606. t['yerahbenyomolefthebrew'] = 0x05AA;
  12607. t['yericyrillic'] = 0x044B;
  12608. t['yerudieresiscyrillic'] = 0x04F9;
  12609. t['yesieungkorean'] = 0x3181;
  12610. t['yesieungpansioskorean'] = 0x3183;
  12611. t['yesieungsioskorean'] = 0x3182;
  12612. t['yetivhebrew'] = 0x059A;
  12613. t['ygrave'] = 0x1EF3;
  12614. t['yhook'] = 0x01B4;
  12615. t['yhookabove'] = 0x1EF7;
  12616. t['yiarmenian'] = 0x0575;
  12617. t['yicyrillic'] = 0x0457;
  12618. t['yikorean'] = 0x3162;
  12619. t['yinyang'] = 0x262F;
  12620. t['yiwnarmenian'] = 0x0582;
  12621. t['ymonospace'] = 0xFF59;
  12622. t['yod'] = 0x05D9;
  12623. t['yoddagesh'] = 0xFB39;
  12624. t['yoddageshhebrew'] = 0xFB39;
  12625. t['yodhebrew'] = 0x05D9;
  12626. t['yodyodhebrew'] = 0x05F2;
  12627. t['yodyodpatahhebrew'] = 0xFB1F;
  12628. t['yohiragana'] = 0x3088;
  12629. t['yoikorean'] = 0x3189;
  12630. t['yokatakana'] = 0x30E8;
  12631. t['yokatakanahalfwidth'] = 0xFF96;
  12632. t['yokorean'] = 0x315B;
  12633. t['yosmallhiragana'] = 0x3087;
  12634. t['yosmallkatakana'] = 0x30E7;
  12635. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12636. t['yotgreek'] = 0x03F3;
  12637. t['yoyaekorean'] = 0x3188;
  12638. t['yoyakorean'] = 0x3187;
  12639. t['yoyakthai'] = 0x0E22;
  12640. t['yoyingthai'] = 0x0E0D;
  12641. t['yparen'] = 0x24B4;
  12642. t['ypogegrammeni'] = 0x037A;
  12643. t['ypogegrammenigreekcmb'] = 0x0345;
  12644. t['yr'] = 0x01A6;
  12645. t['yring'] = 0x1E99;
  12646. t['ysuperior'] = 0x02B8;
  12647. t['ytilde'] = 0x1EF9;
  12648. t['yturned'] = 0x028E;
  12649. t['yuhiragana'] = 0x3086;
  12650. t['yuikorean'] = 0x318C;
  12651. t['yukatakana'] = 0x30E6;
  12652. t['yukatakanahalfwidth'] = 0xFF95;
  12653. t['yukorean'] = 0x3160;
  12654. t['yusbigcyrillic'] = 0x046B;
  12655. t['yusbigiotifiedcyrillic'] = 0x046D;
  12656. t['yuslittlecyrillic'] = 0x0467;
  12657. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12658. t['yusmallhiragana'] = 0x3085;
  12659. t['yusmallkatakana'] = 0x30E5;
  12660. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12661. t['yuyekorean'] = 0x318B;
  12662. t['yuyeokorean'] = 0x318A;
  12663. t['yyabengali'] = 0x09DF;
  12664. t['yyadeva'] = 0x095F;
  12665. t['z'] = 0x007A;
  12666. t['zaarmenian'] = 0x0566;
  12667. t['zacute'] = 0x017A;
  12668. t['zadeva'] = 0x095B;
  12669. t['zagurmukhi'] = 0x0A5B;
  12670. t['zaharabic'] = 0x0638;
  12671. t['zahfinalarabic'] = 0xFEC6;
  12672. t['zahinitialarabic'] = 0xFEC7;
  12673. t['zahiragana'] = 0x3056;
  12674. t['zahmedialarabic'] = 0xFEC8;
  12675. t['zainarabic'] = 0x0632;
  12676. t['zainfinalarabic'] = 0xFEB0;
  12677. t['zakatakana'] = 0x30B6;
  12678. t['zaqefgadolhebrew'] = 0x0595;
  12679. t['zaqefqatanhebrew'] = 0x0594;
  12680. t['zarqahebrew'] = 0x0598;
  12681. t['zayin'] = 0x05D6;
  12682. t['zayindagesh'] = 0xFB36;
  12683. t['zayindageshhebrew'] = 0xFB36;
  12684. t['zayinhebrew'] = 0x05D6;
  12685. t['zbopomofo'] = 0x3117;
  12686. t['zcaron'] = 0x017E;
  12687. t['zcircle'] = 0x24E9;
  12688. t['zcircumflex'] = 0x1E91;
  12689. t['zcurl'] = 0x0291;
  12690. t['zdot'] = 0x017C;
  12691. t['zdotaccent'] = 0x017C;
  12692. t['zdotbelow'] = 0x1E93;
  12693. t['zecyrillic'] = 0x0437;
  12694. t['zedescendercyrillic'] = 0x0499;
  12695. t['zedieresiscyrillic'] = 0x04DF;
  12696. t['zehiragana'] = 0x305C;
  12697. t['zekatakana'] = 0x30BC;
  12698. t['zero'] = 0x0030;
  12699. t['zeroarabic'] = 0x0660;
  12700. t['zerobengali'] = 0x09E6;
  12701. t['zerodeva'] = 0x0966;
  12702. t['zerogujarati'] = 0x0AE6;
  12703. t['zerogurmukhi'] = 0x0A66;
  12704. t['zerohackarabic'] = 0x0660;
  12705. t['zeroinferior'] = 0x2080;
  12706. t['zeromonospace'] = 0xFF10;
  12707. t['zerooldstyle'] = 0xF730;
  12708. t['zeropersian'] = 0x06F0;
  12709. t['zerosuperior'] = 0x2070;
  12710. t['zerothai'] = 0x0E50;
  12711. t['zerowidthjoiner'] = 0xFEFF;
  12712. t['zerowidthnonjoiner'] = 0x200C;
  12713. t['zerowidthspace'] = 0x200B;
  12714. t['zeta'] = 0x03B6;
  12715. t['zhbopomofo'] = 0x3113;
  12716. t['zhearmenian'] = 0x056A;
  12717. t['zhebrevecyrillic'] = 0x04C2;
  12718. t['zhecyrillic'] = 0x0436;
  12719. t['zhedescendercyrillic'] = 0x0497;
  12720. t['zhedieresiscyrillic'] = 0x04DD;
  12721. t['zihiragana'] = 0x3058;
  12722. t['zikatakana'] = 0x30B8;
  12723. t['zinorhebrew'] = 0x05AE;
  12724. t['zlinebelow'] = 0x1E95;
  12725. t['zmonospace'] = 0xFF5A;
  12726. t['zohiragana'] = 0x305E;
  12727. t['zokatakana'] = 0x30BE;
  12728. t['zparen'] = 0x24B5;
  12729. t['zretroflexhook'] = 0x0290;
  12730. t['zstroke'] = 0x01B6;
  12731. t['zuhiragana'] = 0x305A;
  12732. t['zukatakana'] = 0x30BA;
  12733. t['.notdef'] = 0x0000;
  12734. t['angbracketleftbig'] = 0x2329;
  12735. t['angbracketleftBig'] = 0x2329;
  12736. t['angbracketleftbigg'] = 0x2329;
  12737. t['angbracketleftBigg'] = 0x2329;
  12738. t['angbracketrightBig'] = 0x232A;
  12739. t['angbracketrightbig'] = 0x232A;
  12740. t['angbracketrightBigg'] = 0x232A;
  12741. t['angbracketrightbigg'] = 0x232A;
  12742. t['arrowhookleft'] = 0x21AA;
  12743. t['arrowhookright'] = 0x21A9;
  12744. t['arrowlefttophalf'] = 0x21BC;
  12745. t['arrowleftbothalf'] = 0x21BD;
  12746. t['arrownortheast'] = 0x2197;
  12747. t['arrownorthwest'] = 0x2196;
  12748. t['arrowrighttophalf'] = 0x21C0;
  12749. t['arrowrightbothalf'] = 0x21C1;
  12750. t['arrowsoutheast'] = 0x2198;
  12751. t['arrowsouthwest'] = 0x2199;
  12752. t['backslashbig'] = 0x2216;
  12753. t['backslashBig'] = 0x2216;
  12754. t['backslashBigg'] = 0x2216;
  12755. t['backslashbigg'] = 0x2216;
  12756. t['bardbl'] = 0x2016;
  12757. t['bracehtipdownleft'] = 0xFE37;
  12758. t['bracehtipdownright'] = 0xFE37;
  12759. t['bracehtipupleft'] = 0xFE38;
  12760. t['bracehtipupright'] = 0xFE38;
  12761. t['braceleftBig'] = 0x007B;
  12762. t['braceleftbig'] = 0x007B;
  12763. t['braceleftbigg'] = 0x007B;
  12764. t['braceleftBigg'] = 0x007B;
  12765. t['bracerightBig'] = 0x007D;
  12766. t['bracerightbig'] = 0x007D;
  12767. t['bracerightbigg'] = 0x007D;
  12768. t['bracerightBigg'] = 0x007D;
  12769. t['bracketleftbig'] = 0x005B;
  12770. t['bracketleftBig'] = 0x005B;
  12771. t['bracketleftbigg'] = 0x005B;
  12772. t['bracketleftBigg'] = 0x005B;
  12773. t['bracketrightBig'] = 0x005D;
  12774. t['bracketrightbig'] = 0x005D;
  12775. t['bracketrightbigg'] = 0x005D;
  12776. t['bracketrightBigg'] = 0x005D;
  12777. t['ceilingleftbig'] = 0x2308;
  12778. t['ceilingleftBig'] = 0x2308;
  12779. t['ceilingleftBigg'] = 0x2308;
  12780. t['ceilingleftbigg'] = 0x2308;
  12781. t['ceilingrightbig'] = 0x2309;
  12782. t['ceilingrightBig'] = 0x2309;
  12783. t['ceilingrightbigg'] = 0x2309;
  12784. t['ceilingrightBigg'] = 0x2309;
  12785. t['circledotdisplay'] = 0x2299;
  12786. t['circledottext'] = 0x2299;
  12787. t['circlemultiplydisplay'] = 0x2297;
  12788. t['circlemultiplytext'] = 0x2297;
  12789. t['circleplusdisplay'] = 0x2295;
  12790. t['circleplustext'] = 0x2295;
  12791. t['contintegraldisplay'] = 0x222E;
  12792. t['contintegraltext'] = 0x222E;
  12793. t['coproductdisplay'] = 0x2210;
  12794. t['coproducttext'] = 0x2210;
  12795. t['floorleftBig'] = 0x230A;
  12796. t['floorleftbig'] = 0x230A;
  12797. t['floorleftbigg'] = 0x230A;
  12798. t['floorleftBigg'] = 0x230A;
  12799. t['floorrightbig'] = 0x230B;
  12800. t['floorrightBig'] = 0x230B;
  12801. t['floorrightBigg'] = 0x230B;
  12802. t['floorrightbigg'] = 0x230B;
  12803. t['hatwide'] = 0x0302;
  12804. t['hatwider'] = 0x0302;
  12805. t['hatwidest'] = 0x0302;
  12806. t['intercal'] = 0x1D40;
  12807. t['integraldisplay'] = 0x222B;
  12808. t['integraltext'] = 0x222B;
  12809. t['intersectiondisplay'] = 0x22C2;
  12810. t['intersectiontext'] = 0x22C2;
  12811. t['logicalanddisplay'] = 0x2227;
  12812. t['logicalandtext'] = 0x2227;
  12813. t['logicalordisplay'] = 0x2228;
  12814. t['logicalortext'] = 0x2228;
  12815. t['parenleftBig'] = 0x0028;
  12816. t['parenleftbig'] = 0x0028;
  12817. t['parenleftBigg'] = 0x0028;
  12818. t['parenleftbigg'] = 0x0028;
  12819. t['parenrightBig'] = 0x0029;
  12820. t['parenrightbig'] = 0x0029;
  12821. t['parenrightBigg'] = 0x0029;
  12822. t['parenrightbigg'] = 0x0029;
  12823. t['prime'] = 0x2032;
  12824. t['productdisplay'] = 0x220F;
  12825. t['producttext'] = 0x220F;
  12826. t['radicalbig'] = 0x221A;
  12827. t['radicalBig'] = 0x221A;
  12828. t['radicalBigg'] = 0x221A;
  12829. t['radicalbigg'] = 0x221A;
  12830. t['radicalbt'] = 0x221A;
  12831. t['radicaltp'] = 0x221A;
  12832. t['radicalvertex'] = 0x221A;
  12833. t['slashbig'] = 0x002F;
  12834. t['slashBig'] = 0x002F;
  12835. t['slashBigg'] = 0x002F;
  12836. t['slashbigg'] = 0x002F;
  12837. t['summationdisplay'] = 0x2211;
  12838. t['summationtext'] = 0x2211;
  12839. t['tildewide'] = 0x02DC;
  12840. t['tildewider'] = 0x02DC;
  12841. t['tildewidest'] = 0x02DC;
  12842. t['uniondisplay'] = 0x22C3;
  12843. t['unionmultidisplay'] = 0x228E;
  12844. t['unionmultitext'] = 0x228E;
  12845. t['unionsqdisplay'] = 0x2294;
  12846. t['unionsqtext'] = 0x2294;
  12847. t['uniontext'] = 0x22C3;
  12848. t['vextenddouble'] = 0x2225;
  12849. t['vextendsingle'] = 0x2223;
  12850. });
  12851. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12852. t['space'] = 0x0020;
  12853. t['a1'] = 0x2701;
  12854. t['a2'] = 0x2702;
  12855. t['a202'] = 0x2703;
  12856. t['a3'] = 0x2704;
  12857. t['a4'] = 0x260E;
  12858. t['a5'] = 0x2706;
  12859. t['a119'] = 0x2707;
  12860. t['a118'] = 0x2708;
  12861. t['a117'] = 0x2709;
  12862. t['a11'] = 0x261B;
  12863. t['a12'] = 0x261E;
  12864. t['a13'] = 0x270C;
  12865. t['a14'] = 0x270D;
  12866. t['a15'] = 0x270E;
  12867. t['a16'] = 0x270F;
  12868. t['a105'] = 0x2710;
  12869. t['a17'] = 0x2711;
  12870. t['a18'] = 0x2712;
  12871. t['a19'] = 0x2713;
  12872. t['a20'] = 0x2714;
  12873. t['a21'] = 0x2715;
  12874. t['a22'] = 0x2716;
  12875. t['a23'] = 0x2717;
  12876. t['a24'] = 0x2718;
  12877. t['a25'] = 0x2719;
  12878. t['a26'] = 0x271A;
  12879. t['a27'] = 0x271B;
  12880. t['a28'] = 0x271C;
  12881. t['a6'] = 0x271D;
  12882. t['a7'] = 0x271E;
  12883. t['a8'] = 0x271F;
  12884. t['a9'] = 0x2720;
  12885. t['a10'] = 0x2721;
  12886. t['a29'] = 0x2722;
  12887. t['a30'] = 0x2723;
  12888. t['a31'] = 0x2724;
  12889. t['a32'] = 0x2725;
  12890. t['a33'] = 0x2726;
  12891. t['a34'] = 0x2727;
  12892. t['a35'] = 0x2605;
  12893. t['a36'] = 0x2729;
  12894. t['a37'] = 0x272A;
  12895. t['a38'] = 0x272B;
  12896. t['a39'] = 0x272C;
  12897. t['a40'] = 0x272D;
  12898. t['a41'] = 0x272E;
  12899. t['a42'] = 0x272F;
  12900. t['a43'] = 0x2730;
  12901. t['a44'] = 0x2731;
  12902. t['a45'] = 0x2732;
  12903. t['a46'] = 0x2733;
  12904. t['a47'] = 0x2734;
  12905. t['a48'] = 0x2735;
  12906. t['a49'] = 0x2736;
  12907. t['a50'] = 0x2737;
  12908. t['a51'] = 0x2738;
  12909. t['a52'] = 0x2739;
  12910. t['a53'] = 0x273A;
  12911. t['a54'] = 0x273B;
  12912. t['a55'] = 0x273C;
  12913. t['a56'] = 0x273D;
  12914. t['a57'] = 0x273E;
  12915. t['a58'] = 0x273F;
  12916. t['a59'] = 0x2740;
  12917. t['a60'] = 0x2741;
  12918. t['a61'] = 0x2742;
  12919. t['a62'] = 0x2743;
  12920. t['a63'] = 0x2744;
  12921. t['a64'] = 0x2745;
  12922. t['a65'] = 0x2746;
  12923. t['a66'] = 0x2747;
  12924. t['a67'] = 0x2748;
  12925. t['a68'] = 0x2749;
  12926. t['a69'] = 0x274A;
  12927. t['a70'] = 0x274B;
  12928. t['a71'] = 0x25CF;
  12929. t['a72'] = 0x274D;
  12930. t['a73'] = 0x25A0;
  12931. t['a74'] = 0x274F;
  12932. t['a203'] = 0x2750;
  12933. t['a75'] = 0x2751;
  12934. t['a204'] = 0x2752;
  12935. t['a76'] = 0x25B2;
  12936. t['a77'] = 0x25BC;
  12937. t['a78'] = 0x25C6;
  12938. t['a79'] = 0x2756;
  12939. t['a81'] = 0x25D7;
  12940. t['a82'] = 0x2758;
  12941. t['a83'] = 0x2759;
  12942. t['a84'] = 0x275A;
  12943. t['a97'] = 0x275B;
  12944. t['a98'] = 0x275C;
  12945. t['a99'] = 0x275D;
  12946. t['a100'] = 0x275E;
  12947. t['a101'] = 0x2761;
  12948. t['a102'] = 0x2762;
  12949. t['a103'] = 0x2763;
  12950. t['a104'] = 0x2764;
  12951. t['a106'] = 0x2765;
  12952. t['a107'] = 0x2766;
  12953. t['a108'] = 0x2767;
  12954. t['a112'] = 0x2663;
  12955. t['a111'] = 0x2666;
  12956. t['a110'] = 0x2665;
  12957. t['a109'] = 0x2660;
  12958. t['a120'] = 0x2460;
  12959. t['a121'] = 0x2461;
  12960. t['a122'] = 0x2462;
  12961. t['a123'] = 0x2463;
  12962. t['a124'] = 0x2464;
  12963. t['a125'] = 0x2465;
  12964. t['a126'] = 0x2466;
  12965. t['a127'] = 0x2467;
  12966. t['a128'] = 0x2468;
  12967. t['a129'] = 0x2469;
  12968. t['a130'] = 0x2776;
  12969. t['a131'] = 0x2777;
  12970. t['a132'] = 0x2778;
  12971. t['a133'] = 0x2779;
  12972. t['a134'] = 0x277A;
  12973. t['a135'] = 0x277B;
  12974. t['a136'] = 0x277C;
  12975. t['a137'] = 0x277D;
  12976. t['a138'] = 0x277E;
  12977. t['a139'] = 0x277F;
  12978. t['a140'] = 0x2780;
  12979. t['a141'] = 0x2781;
  12980. t['a142'] = 0x2782;
  12981. t['a143'] = 0x2783;
  12982. t['a144'] = 0x2784;
  12983. t['a145'] = 0x2785;
  12984. t['a146'] = 0x2786;
  12985. t['a147'] = 0x2787;
  12986. t['a148'] = 0x2788;
  12987. t['a149'] = 0x2789;
  12988. t['a150'] = 0x278A;
  12989. t['a151'] = 0x278B;
  12990. t['a152'] = 0x278C;
  12991. t['a153'] = 0x278D;
  12992. t['a154'] = 0x278E;
  12993. t['a155'] = 0x278F;
  12994. t['a156'] = 0x2790;
  12995. t['a157'] = 0x2791;
  12996. t['a158'] = 0x2792;
  12997. t['a159'] = 0x2793;
  12998. t['a160'] = 0x2794;
  12999. t['a161'] = 0x2192;
  13000. t['a163'] = 0x2194;
  13001. t['a164'] = 0x2195;
  13002. t['a196'] = 0x2798;
  13003. t['a165'] = 0x2799;
  13004. t['a192'] = 0x279A;
  13005. t['a166'] = 0x279B;
  13006. t['a167'] = 0x279C;
  13007. t['a168'] = 0x279D;
  13008. t['a169'] = 0x279E;
  13009. t['a170'] = 0x279F;
  13010. t['a171'] = 0x27A0;
  13011. t['a172'] = 0x27A1;
  13012. t['a173'] = 0x27A2;
  13013. t['a162'] = 0x27A3;
  13014. t['a174'] = 0x27A4;
  13015. t['a175'] = 0x27A5;
  13016. t['a176'] = 0x27A6;
  13017. t['a177'] = 0x27A7;
  13018. t['a178'] = 0x27A8;
  13019. t['a179'] = 0x27A9;
  13020. t['a193'] = 0x27AA;
  13021. t['a180'] = 0x27AB;
  13022. t['a199'] = 0x27AC;
  13023. t['a181'] = 0x27AD;
  13024. t['a200'] = 0x27AE;
  13025. t['a182'] = 0x27AF;
  13026. t['a201'] = 0x27B1;
  13027. t['a183'] = 0x27B2;
  13028. t['a184'] = 0x27B3;
  13029. t['a197'] = 0x27B4;
  13030. t['a185'] = 0x27B5;
  13031. t['a194'] = 0x27B6;
  13032. t['a198'] = 0x27B7;
  13033. t['a186'] = 0x27B8;
  13034. t['a195'] = 0x27B9;
  13035. t['a187'] = 0x27BA;
  13036. t['a188'] = 0x27BB;
  13037. t['a189'] = 0x27BC;
  13038. t['a190'] = 0x27BD;
  13039. t['a191'] = 0x27BE;
  13040. t['a89'] = 0x2768;
  13041. t['a90'] = 0x2769;
  13042. t['a93'] = 0x276A;
  13043. t['a94'] = 0x276B;
  13044. t['a91'] = 0x276C;
  13045. t['a92'] = 0x276D;
  13046. t['a205'] = 0x276E;
  13047. t['a85'] = 0x276F;
  13048. t['a206'] = 0x2770;
  13049. t['a86'] = 0x2771;
  13050. t['a87'] = 0x2772;
  13051. t['a88'] = 0x2773;
  13052. t['a95'] = 0x2774;
  13053. t['a96'] = 0x2775;
  13054. t['.notdef'] = 0x0000;
  13055. });
  13056. exports.getGlyphsUnicode = getGlyphsUnicode;
  13057. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  13058. }));
  13059. (function (root, factory) {
  13060. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  13061. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  13062. var error = sharedUtil.error;
  13063. var log2 = sharedUtil.log2;
  13064. var readInt8 = sharedUtil.readInt8;
  13065. var readUint16 = sharedUtil.readUint16;
  13066. var readUint32 = sharedUtil.readUint32;
  13067. var shadow = sharedUtil.shadow;
  13068. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  13069. var Jbig2Image = function Jbig2ImageClosure() {
  13070. function ContextCache() {
  13071. }
  13072. ContextCache.prototype = {
  13073. getContexts: function (id) {
  13074. if (id in this) {
  13075. return this[id];
  13076. }
  13077. return this[id] = new Int8Array(1 << 16);
  13078. }
  13079. };
  13080. function DecodingContext(data, start, end) {
  13081. this.data = data;
  13082. this.start = start;
  13083. this.end = end;
  13084. }
  13085. DecodingContext.prototype = {
  13086. get decoder() {
  13087. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  13088. return shadow(this, 'decoder', decoder);
  13089. },
  13090. get contextCache() {
  13091. var cache = new ContextCache();
  13092. return shadow(this, 'contextCache', cache);
  13093. }
  13094. };
  13095. function decodeInteger(contextCache, procedure, decoder) {
  13096. var contexts = contextCache.getContexts(procedure);
  13097. var prev = 1;
  13098. function readBits(length) {
  13099. var v = 0;
  13100. for (var i = 0; i < length; i++) {
  13101. var bit = decoder.readBit(contexts, prev);
  13102. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  13103. v = v << 1 | bit;
  13104. }
  13105. return v >>> 0;
  13106. }
  13107. var sign = readBits(1);
  13108. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  13109. return sign === 0 ? value : value > 0 ? -value : null;
  13110. }
  13111. function decodeIAID(contextCache, decoder, codeLength) {
  13112. var contexts = contextCache.getContexts('IAID');
  13113. var prev = 1;
  13114. for (var i = 0; i < codeLength; i++) {
  13115. var bit = decoder.readBit(contexts, prev);
  13116. prev = prev << 1 | bit;
  13117. }
  13118. if (codeLength < 31) {
  13119. return prev & (1 << codeLength) - 1;
  13120. }
  13121. return prev & 0x7FFFFFFF;
  13122. }
  13123. var SegmentTypes = [
  13124. 'SymbolDictionary',
  13125. null,
  13126. null,
  13127. null,
  13128. 'IntermediateTextRegion',
  13129. null,
  13130. 'ImmediateTextRegion',
  13131. 'ImmediateLosslessTextRegion',
  13132. null,
  13133. null,
  13134. null,
  13135. null,
  13136. null,
  13137. null,
  13138. null,
  13139. null,
  13140. 'patternDictionary',
  13141. null,
  13142. null,
  13143. null,
  13144. 'IntermediateHalftoneRegion',
  13145. null,
  13146. 'ImmediateHalftoneRegion',
  13147. 'ImmediateLosslessHalftoneRegion',
  13148. null,
  13149. null,
  13150. null,
  13151. null,
  13152. null,
  13153. null,
  13154. null,
  13155. null,
  13156. null,
  13157. null,
  13158. null,
  13159. null,
  13160. 'IntermediateGenericRegion',
  13161. null,
  13162. 'ImmediateGenericRegion',
  13163. 'ImmediateLosslessGenericRegion',
  13164. 'IntermediateGenericRefinementRegion',
  13165. null,
  13166. 'ImmediateGenericRefinementRegion',
  13167. 'ImmediateLosslessGenericRefinementRegion',
  13168. null,
  13169. null,
  13170. null,
  13171. null,
  13172. 'PageInformation',
  13173. 'EndOfPage',
  13174. 'EndOfStripe',
  13175. 'EndOfFile',
  13176. 'Profiles',
  13177. 'Tables',
  13178. null,
  13179. null,
  13180. null,
  13181. null,
  13182. null,
  13183. null,
  13184. null,
  13185. null,
  13186. 'Extension'
  13187. ];
  13188. var CodingTemplates = [
  13189. [
  13190. {
  13191. x: -1,
  13192. y: -2
  13193. },
  13194. {
  13195. x: 0,
  13196. y: -2
  13197. },
  13198. {
  13199. x: 1,
  13200. y: -2
  13201. },
  13202. {
  13203. x: -2,
  13204. y: -1
  13205. },
  13206. {
  13207. x: -1,
  13208. y: -1
  13209. },
  13210. {
  13211. x: 0,
  13212. y: -1
  13213. },
  13214. {
  13215. x: 1,
  13216. y: -1
  13217. },
  13218. {
  13219. x: 2,
  13220. y: -1
  13221. },
  13222. {
  13223. x: -4,
  13224. y: 0
  13225. },
  13226. {
  13227. x: -3,
  13228. y: 0
  13229. },
  13230. {
  13231. x: -2,
  13232. y: 0
  13233. },
  13234. {
  13235. x: -1,
  13236. y: 0
  13237. }
  13238. ],
  13239. [
  13240. {
  13241. x: -1,
  13242. y: -2
  13243. },
  13244. {
  13245. x: 0,
  13246. y: -2
  13247. },
  13248. {
  13249. x: 1,
  13250. y: -2
  13251. },
  13252. {
  13253. x: 2,
  13254. y: -2
  13255. },
  13256. {
  13257. x: -2,
  13258. y: -1
  13259. },
  13260. {
  13261. x: -1,
  13262. y: -1
  13263. },
  13264. {
  13265. x: 0,
  13266. y: -1
  13267. },
  13268. {
  13269. x: 1,
  13270. y: -1
  13271. },
  13272. {
  13273. x: 2,
  13274. y: -1
  13275. },
  13276. {
  13277. x: -3,
  13278. y: 0
  13279. },
  13280. {
  13281. x: -2,
  13282. y: 0
  13283. },
  13284. {
  13285. x: -1,
  13286. y: 0
  13287. }
  13288. ],
  13289. [
  13290. {
  13291. x: -1,
  13292. y: -2
  13293. },
  13294. {
  13295. x: 0,
  13296. y: -2
  13297. },
  13298. {
  13299. x: 1,
  13300. y: -2
  13301. },
  13302. {
  13303. x: -2,
  13304. y: -1
  13305. },
  13306. {
  13307. x: -1,
  13308. y: -1
  13309. },
  13310. {
  13311. x: 0,
  13312. y: -1
  13313. },
  13314. {
  13315. x: 1,
  13316. y: -1
  13317. },
  13318. {
  13319. x: -2,
  13320. y: 0
  13321. },
  13322. {
  13323. x: -1,
  13324. y: 0
  13325. }
  13326. ],
  13327. [
  13328. {
  13329. x: -3,
  13330. y: -1
  13331. },
  13332. {
  13333. x: -2,
  13334. y: -1
  13335. },
  13336. {
  13337. x: -1,
  13338. y: -1
  13339. },
  13340. {
  13341. x: 0,
  13342. y: -1
  13343. },
  13344. {
  13345. x: 1,
  13346. y: -1
  13347. },
  13348. {
  13349. x: -4,
  13350. y: 0
  13351. },
  13352. {
  13353. x: -3,
  13354. y: 0
  13355. },
  13356. {
  13357. x: -2,
  13358. y: 0
  13359. },
  13360. {
  13361. x: -1,
  13362. y: 0
  13363. }
  13364. ]
  13365. ];
  13366. var RefinementTemplates = [
  13367. {
  13368. coding: [
  13369. {
  13370. x: 0,
  13371. y: -1
  13372. },
  13373. {
  13374. x: 1,
  13375. y: -1
  13376. },
  13377. {
  13378. x: -1,
  13379. y: 0
  13380. }
  13381. ],
  13382. reference: [
  13383. {
  13384. x: 0,
  13385. y: -1
  13386. },
  13387. {
  13388. x: 1,
  13389. y: -1
  13390. },
  13391. {
  13392. x: -1,
  13393. y: 0
  13394. },
  13395. {
  13396. x: 0,
  13397. y: 0
  13398. },
  13399. {
  13400. x: 1,
  13401. y: 0
  13402. },
  13403. {
  13404. x: -1,
  13405. y: 1
  13406. },
  13407. {
  13408. x: 0,
  13409. y: 1
  13410. },
  13411. {
  13412. x: 1,
  13413. y: 1
  13414. }
  13415. ]
  13416. },
  13417. {
  13418. coding: [
  13419. {
  13420. x: -1,
  13421. y: -1
  13422. },
  13423. {
  13424. x: 0,
  13425. y: -1
  13426. },
  13427. {
  13428. x: 1,
  13429. y: -1
  13430. },
  13431. {
  13432. x: -1,
  13433. y: 0
  13434. }
  13435. ],
  13436. reference: [
  13437. {
  13438. x: 0,
  13439. y: -1
  13440. },
  13441. {
  13442. x: -1,
  13443. y: 0
  13444. },
  13445. {
  13446. x: 0,
  13447. y: 0
  13448. },
  13449. {
  13450. x: 1,
  13451. y: 0
  13452. },
  13453. {
  13454. x: 0,
  13455. y: 1
  13456. },
  13457. {
  13458. x: 1,
  13459. y: 1
  13460. }
  13461. ]
  13462. }
  13463. ];
  13464. var ReusedContexts = [
  13465. 0x9B25,
  13466. 0x0795,
  13467. 0x00E5,
  13468. 0x0195
  13469. ];
  13470. var RefinementReusedContexts = [
  13471. 0x0020,
  13472. 0x0008
  13473. ];
  13474. function decodeBitmapTemplate0(width, height, decodingContext) {
  13475. var decoder = decodingContext.decoder;
  13476. var contexts = decodingContext.contextCache.getContexts('GB');
  13477. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13478. var OLD_PIXEL_MASK = 0x7BF7;
  13479. for (i = 0; i < height; i++) {
  13480. row = bitmap[i] = new Uint8Array(width);
  13481. row1 = i < 1 ? row : bitmap[i - 1];
  13482. row2 = i < 2 ? row : bitmap[i - 2];
  13483. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13484. for (j = 0; j < width; j++) {
  13485. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13486. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13487. }
  13488. }
  13489. return bitmap;
  13490. }
  13491. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13492. if (mmr) {
  13493. error('JBIG2 error: MMR encoding is not supported');
  13494. }
  13495. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  13496. return decodeBitmapTemplate0(width, height, decodingContext);
  13497. }
  13498. var useskip = !!skip;
  13499. var template = CodingTemplates[templateIndex].concat(at);
  13500. template.sort(function (a, b) {
  13501. return a.y - b.y || a.x - b.x;
  13502. });
  13503. var templateLength = template.length;
  13504. var templateX = new Int8Array(templateLength);
  13505. var templateY = new Int8Array(templateLength);
  13506. var changingTemplateEntries = [];
  13507. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13508. var c, k;
  13509. for (k = 0; k < templateLength; k++) {
  13510. templateX[k] = template[k].x;
  13511. templateY[k] = template[k].y;
  13512. minX = Math.min(minX, template[k].x);
  13513. maxX = Math.max(maxX, template[k].x);
  13514. minY = Math.min(minY, template[k].y);
  13515. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13516. reuseMask |= 1 << templateLength - 1 - k;
  13517. } else {
  13518. changingTemplateEntries.push(k);
  13519. }
  13520. }
  13521. var changingEntriesLength = changingTemplateEntries.length;
  13522. var changingTemplateX = new Int8Array(changingEntriesLength);
  13523. var changingTemplateY = new Int8Array(changingEntriesLength);
  13524. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13525. for (c = 0; c < changingEntriesLength; c++) {
  13526. k = changingTemplateEntries[c];
  13527. changingTemplateX[c] = template[k].x;
  13528. changingTemplateY[c] = template[k].y;
  13529. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13530. }
  13531. var sbb_left = -minX;
  13532. var sbb_top = -minY;
  13533. var sbb_right = width - maxX;
  13534. var pseudoPixelContext = ReusedContexts[templateIndex];
  13535. var row = new Uint8Array(width);
  13536. var bitmap = [];
  13537. var decoder = decodingContext.decoder;
  13538. var contexts = decodingContext.contextCache.getContexts('GB');
  13539. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13540. for (var i = 0; i < height; i++) {
  13541. if (prediction) {
  13542. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13543. ltp ^= sltp;
  13544. if (ltp) {
  13545. bitmap.push(row);
  13546. continue;
  13547. }
  13548. }
  13549. row = new Uint8Array(row);
  13550. bitmap.push(row);
  13551. for (j = 0; j < width; j++) {
  13552. if (useskip && skip[i][j]) {
  13553. row[j] = 0;
  13554. continue;
  13555. }
  13556. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13557. contextLabel = contextLabel << 1 & reuseMask;
  13558. for (k = 0; k < changingEntriesLength; k++) {
  13559. i0 = i + changingTemplateY[k];
  13560. j0 = j + changingTemplateX[k];
  13561. bit = bitmap[i0][j0];
  13562. if (bit) {
  13563. bit = changingTemplateBit[k];
  13564. contextLabel |= bit;
  13565. }
  13566. }
  13567. } else {
  13568. contextLabel = 0;
  13569. shift = templateLength - 1;
  13570. for (k = 0; k < templateLength; k++, shift--) {
  13571. j0 = j + templateX[k];
  13572. if (j0 >= 0 && j0 < width) {
  13573. i0 = i + templateY[k];
  13574. if (i0 >= 0) {
  13575. bit = bitmap[i0][j0];
  13576. if (bit) {
  13577. contextLabel |= bit << shift;
  13578. }
  13579. }
  13580. }
  13581. }
  13582. }
  13583. var pixel = decoder.readBit(contexts, contextLabel);
  13584. row[j] = pixel;
  13585. }
  13586. }
  13587. return bitmap;
  13588. }
  13589. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13590. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13591. if (templateIndex === 0) {
  13592. codingTemplate = codingTemplate.concat([at[0]]);
  13593. }
  13594. var codingTemplateLength = codingTemplate.length;
  13595. var codingTemplateX = new Int32Array(codingTemplateLength);
  13596. var codingTemplateY = new Int32Array(codingTemplateLength);
  13597. var k;
  13598. for (k = 0; k < codingTemplateLength; k++) {
  13599. codingTemplateX[k] = codingTemplate[k].x;
  13600. codingTemplateY[k] = codingTemplate[k].y;
  13601. }
  13602. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13603. if (templateIndex === 0) {
  13604. referenceTemplate = referenceTemplate.concat([at[1]]);
  13605. }
  13606. var referenceTemplateLength = referenceTemplate.length;
  13607. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13608. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13609. for (k = 0; k < referenceTemplateLength; k++) {
  13610. referenceTemplateX[k] = referenceTemplate[k].x;
  13611. referenceTemplateY[k] = referenceTemplate[k].y;
  13612. }
  13613. var referenceWidth = referenceBitmap[0].length;
  13614. var referenceHeight = referenceBitmap.length;
  13615. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13616. var bitmap = [];
  13617. var decoder = decodingContext.decoder;
  13618. var contexts = decodingContext.contextCache.getContexts('GR');
  13619. var ltp = 0;
  13620. for (var i = 0; i < height; i++) {
  13621. if (prediction) {
  13622. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13623. ltp ^= sltp;
  13624. if (ltp) {
  13625. error('JBIG2 error: prediction is not supported');
  13626. }
  13627. }
  13628. var row = new Uint8Array(width);
  13629. bitmap.push(row);
  13630. for (var j = 0; j < width; j++) {
  13631. var i0, j0;
  13632. var contextLabel = 0;
  13633. for (k = 0; k < codingTemplateLength; k++) {
  13634. i0 = i + codingTemplateY[k];
  13635. j0 = j + codingTemplateX[k];
  13636. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13637. contextLabel <<= 1;
  13638. } else
  13639. {
  13640. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13641. }
  13642. }
  13643. for (k = 0; k < referenceTemplateLength; k++) {
  13644. i0 = i + referenceTemplateY[k] + offsetY;
  13645. j0 = j + referenceTemplateX[k] + offsetX;
  13646. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13647. contextLabel <<= 1;
  13648. } else
  13649. {
  13650. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13651. }
  13652. }
  13653. var pixel = decoder.readBit(contexts, contextLabel);
  13654. row[j] = pixel;
  13655. }
  13656. }
  13657. return bitmap;
  13658. }
  13659. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13660. if (huffman) {
  13661. error('JBIG2 error: huffman is not supported');
  13662. }
  13663. var newSymbols = [];
  13664. var currentHeight = 0;
  13665. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13666. var decoder = decodingContext.decoder;
  13667. var contextCache = decodingContext.contextCache;
  13668. while (newSymbols.length < numberOfNewSymbols) {
  13669. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13670. currentHeight += deltaHeight;
  13671. var currentWidth = 0;
  13672. var totalWidth = 0;
  13673. while (true) {
  13674. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13675. if (deltaWidth === null) {
  13676. break;
  13677. }
  13678. currentWidth += deltaWidth;
  13679. totalWidth += currentWidth;
  13680. var bitmap;
  13681. if (refinement) {
  13682. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13683. if (numberOfInstances > 1) {
  13684. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13685. } else {
  13686. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13687. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13688. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13689. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13690. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13691. }
  13692. } else {
  13693. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13694. }
  13695. newSymbols.push(bitmap);
  13696. }
  13697. }
  13698. var exportedSymbols = [];
  13699. var flags = [], currentFlag = false;
  13700. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13701. while (flags.length < totalSymbolsLength) {
  13702. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13703. while (runLength--) {
  13704. flags.push(currentFlag);
  13705. }
  13706. currentFlag = !currentFlag;
  13707. }
  13708. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13709. if (flags[i]) {
  13710. exportedSymbols.push(symbols[i]);
  13711. }
  13712. }
  13713. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13714. if (flags[i]) {
  13715. exportedSymbols.push(newSymbols[j]);
  13716. }
  13717. }
  13718. return exportedSymbols;
  13719. }
  13720. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13721. if (huffman) {
  13722. error('JBIG2 error: huffman is not supported');
  13723. }
  13724. var bitmap = [];
  13725. var i, row;
  13726. for (i = 0; i < height; i++) {
  13727. row = new Uint8Array(width);
  13728. if (defaultPixelValue) {
  13729. for (var j = 0; j < width; j++) {
  13730. row[j] = defaultPixelValue;
  13731. }
  13732. }
  13733. bitmap.push(row);
  13734. }
  13735. var decoder = decodingContext.decoder;
  13736. var contextCache = decodingContext.contextCache;
  13737. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13738. var firstS = 0;
  13739. i = 0;
  13740. while (i < numberOfSymbolInstances) {
  13741. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13742. stripT += deltaT;
  13743. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13744. firstS += deltaFirstS;
  13745. var currentS = firstS;
  13746. do {
  13747. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13748. var t = stripSize * stripT + currentT;
  13749. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13750. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13751. var symbolBitmap = inputSymbols[symbolId];
  13752. var symbolWidth = symbolBitmap[0].length;
  13753. var symbolHeight = symbolBitmap.length;
  13754. if (applyRefinement) {
  13755. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13756. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13757. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13758. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13759. symbolWidth += rdw;
  13760. symbolHeight += rdh;
  13761. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13762. }
  13763. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13764. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13765. var s2, t2, symbolRow;
  13766. if (transposed) {
  13767. for (s2 = 0; s2 < symbolHeight; s2++) {
  13768. row = bitmap[offsetS + s2];
  13769. if (!row) {
  13770. continue;
  13771. }
  13772. symbolRow = symbolBitmap[s2];
  13773. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13774. switch (combinationOperator) {
  13775. case 0:
  13776. for (t2 = 0; t2 < maxWidth; t2++) {
  13777. row[offsetT + t2] |= symbolRow[t2];
  13778. }
  13779. break;
  13780. case 2:
  13781. for (t2 = 0; t2 < maxWidth; t2++) {
  13782. row[offsetT + t2] ^= symbolRow[t2];
  13783. }
  13784. break;
  13785. default:
  13786. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13787. }
  13788. }
  13789. currentS += symbolHeight - 1;
  13790. } else {
  13791. for (t2 = 0; t2 < symbolHeight; t2++) {
  13792. row = bitmap[offsetT + t2];
  13793. if (!row) {
  13794. continue;
  13795. }
  13796. symbolRow = symbolBitmap[t2];
  13797. switch (combinationOperator) {
  13798. case 0:
  13799. for (s2 = 0; s2 < symbolWidth; s2++) {
  13800. row[offsetS + s2] |= symbolRow[s2];
  13801. }
  13802. break;
  13803. case 2:
  13804. for (s2 = 0; s2 < symbolWidth; s2++) {
  13805. row[offsetS + s2] ^= symbolRow[s2];
  13806. }
  13807. break;
  13808. default:
  13809. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13810. }
  13811. }
  13812. currentS += symbolWidth - 1;
  13813. }
  13814. i++;
  13815. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13816. if (deltaS === null) {
  13817. break;
  13818. }
  13819. currentS += deltaS + dsOffset;
  13820. } while (true);
  13821. }
  13822. return bitmap;
  13823. }
  13824. function readSegmentHeader(data, start) {
  13825. var segmentHeader = {};
  13826. segmentHeader.number = readUint32(data, start);
  13827. var flags = data[start + 4];
  13828. var segmentType = flags & 0x3F;
  13829. if (!SegmentTypes[segmentType]) {
  13830. error('JBIG2 error: invalid segment type: ' + segmentType);
  13831. }
  13832. segmentHeader.type = segmentType;
  13833. segmentHeader.typeName = SegmentTypes[segmentType];
  13834. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13835. var pageAssociationFieldSize = !!(flags & 0x40);
  13836. var referredFlags = data[start + 5];
  13837. var referredToCount = referredFlags >> 5 & 7;
  13838. var retainBits = [referredFlags & 31];
  13839. var position = start + 6;
  13840. if (referredFlags === 7) {
  13841. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13842. position += 3;
  13843. var bytes = referredToCount + 7 >> 3;
  13844. retainBits[0] = data[position++];
  13845. while (--bytes > 0) {
  13846. retainBits.push(data[position++]);
  13847. }
  13848. } else if (referredFlags === 5 || referredFlags === 6) {
  13849. error('JBIG2 error: invalid referred-to flags');
  13850. }
  13851. segmentHeader.retainBits = retainBits;
  13852. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13853. var referredTo = [];
  13854. var i, ii;
  13855. for (i = 0; i < referredToCount; i++) {
  13856. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13857. referredTo.push(number);
  13858. position += referredToSegmentNumberSize;
  13859. }
  13860. segmentHeader.referredTo = referredTo;
  13861. if (!pageAssociationFieldSize) {
  13862. segmentHeader.pageAssociation = data[position++];
  13863. } else {
  13864. segmentHeader.pageAssociation = readUint32(data, position);
  13865. position += 4;
  13866. }
  13867. segmentHeader.length = readUint32(data, position);
  13868. position += 4;
  13869. if (segmentHeader.length === 0xFFFFFFFF) {
  13870. if (segmentType === 38) {
  13871. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13872. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13873. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13874. var searchPatternLength = 6;
  13875. var searchPattern = new Uint8Array(searchPatternLength);
  13876. if (!genericRegionMmr) {
  13877. searchPattern[0] = 0xFF;
  13878. searchPattern[1] = 0xAC;
  13879. }
  13880. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13881. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13882. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13883. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13884. for (i = position, ii = data.length; i < ii; i++) {
  13885. var j = 0;
  13886. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13887. j++;
  13888. }
  13889. if (j === searchPatternLength) {
  13890. segmentHeader.length = i + searchPatternLength;
  13891. break;
  13892. }
  13893. }
  13894. if (segmentHeader.length === 0xFFFFFFFF) {
  13895. error('JBIG2 error: segment end was not found');
  13896. }
  13897. } else {
  13898. error('JBIG2 error: invalid unknown segment length');
  13899. }
  13900. }
  13901. segmentHeader.headerEnd = position;
  13902. return segmentHeader;
  13903. }
  13904. function readSegments(header, data, start, end) {
  13905. var segments = [];
  13906. var position = start;
  13907. while (position < end) {
  13908. var segmentHeader = readSegmentHeader(data, position);
  13909. position = segmentHeader.headerEnd;
  13910. var segment = {
  13911. header: segmentHeader,
  13912. data: data
  13913. };
  13914. if (!header.randomAccess) {
  13915. segment.start = position;
  13916. position += segmentHeader.length;
  13917. segment.end = position;
  13918. }
  13919. segments.push(segment);
  13920. if (segmentHeader.type === 51) {
  13921. break;
  13922. }
  13923. }
  13924. if (header.randomAccess) {
  13925. for (var i = 0, ii = segments.length; i < ii; i++) {
  13926. segments[i].start = position;
  13927. position += segments[i].header.length;
  13928. segments[i].end = position;
  13929. }
  13930. }
  13931. return segments;
  13932. }
  13933. function readRegionSegmentInformation(data, start) {
  13934. return {
  13935. width: readUint32(data, start),
  13936. height: readUint32(data, start + 4),
  13937. x: readUint32(data, start + 8),
  13938. y: readUint32(data, start + 12),
  13939. combinationOperator: data[start + 16] & 7
  13940. };
  13941. }
  13942. var RegionSegmentInformationFieldLength = 17;
  13943. function processSegment(segment, visitor) {
  13944. var header = segment.header;
  13945. var data = segment.data, position = segment.start, end = segment.end;
  13946. var args, at, i, atLength;
  13947. switch (header.type) {
  13948. case 0:
  13949. var dictionary = {};
  13950. var dictionaryFlags = readUint16(data, position);
  13951. dictionary.huffman = !!(dictionaryFlags & 1);
  13952. dictionary.refinement = !!(dictionaryFlags & 2);
  13953. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13954. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13955. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13956. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13957. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13958. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13959. dictionary.template = dictionaryFlags >> 10 & 3;
  13960. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13961. position += 2;
  13962. if (!dictionary.huffman) {
  13963. atLength = dictionary.template === 0 ? 4 : 1;
  13964. at = [];
  13965. for (i = 0; i < atLength; i++) {
  13966. at.push({
  13967. x: readInt8(data, position),
  13968. y: readInt8(data, position + 1)
  13969. });
  13970. position += 2;
  13971. }
  13972. dictionary.at = at;
  13973. }
  13974. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13975. at = [];
  13976. for (i = 0; i < 2; i++) {
  13977. at.push({
  13978. x: readInt8(data, position),
  13979. y: readInt8(data, position + 1)
  13980. });
  13981. position += 2;
  13982. }
  13983. dictionary.refinementAt = at;
  13984. }
  13985. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13986. position += 4;
  13987. dictionary.numberOfNewSymbols = readUint32(data, position);
  13988. position += 4;
  13989. args = [
  13990. dictionary,
  13991. header.number,
  13992. header.referredTo,
  13993. data,
  13994. position,
  13995. end
  13996. ];
  13997. break;
  13998. case 6:
  13999. case 7:
  14000. var textRegion = {};
  14001. textRegion.info = readRegionSegmentInformation(data, position);
  14002. position += RegionSegmentInformationFieldLength;
  14003. var textRegionSegmentFlags = readUint16(data, position);
  14004. position += 2;
  14005. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  14006. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  14007. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  14008. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  14009. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  14010. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  14011. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  14012. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  14013. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  14014. if (textRegion.huffman) {
  14015. var textRegionHuffmanFlags = readUint16(data, position);
  14016. position += 2;
  14017. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  14018. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  14019. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  14020. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  14021. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  14022. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  14023. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  14024. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  14025. }
  14026. if (textRegion.refinement && !textRegion.refinementTemplate) {
  14027. at = [];
  14028. for (i = 0; i < 2; i++) {
  14029. at.push({
  14030. x: readInt8(data, position),
  14031. y: readInt8(data, position + 1)
  14032. });
  14033. position += 2;
  14034. }
  14035. textRegion.refinementAt = at;
  14036. }
  14037. textRegion.numberOfSymbolInstances = readUint32(data, position);
  14038. position += 4;
  14039. if (textRegion.huffman) {
  14040. error('JBIG2 error: huffman is not supported');
  14041. }
  14042. args = [
  14043. textRegion,
  14044. header.referredTo,
  14045. data,
  14046. position,
  14047. end
  14048. ];
  14049. break;
  14050. case 38:
  14051. case 39:
  14052. var genericRegion = {};
  14053. genericRegion.info = readRegionSegmentInformation(data, position);
  14054. position += RegionSegmentInformationFieldLength;
  14055. var genericRegionSegmentFlags = data[position++];
  14056. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  14057. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  14058. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  14059. if (!genericRegion.mmr) {
  14060. atLength = genericRegion.template === 0 ? 4 : 1;
  14061. at = [];
  14062. for (i = 0; i < atLength; i++) {
  14063. at.push({
  14064. x: readInt8(data, position),
  14065. y: readInt8(data, position + 1)
  14066. });
  14067. position += 2;
  14068. }
  14069. genericRegion.at = at;
  14070. }
  14071. args = [
  14072. genericRegion,
  14073. data,
  14074. position,
  14075. end
  14076. ];
  14077. break;
  14078. case 48:
  14079. var pageInfo = {
  14080. width: readUint32(data, position),
  14081. height: readUint32(data, position + 4),
  14082. resolutionX: readUint32(data, position + 8),
  14083. resolutionY: readUint32(data, position + 12)
  14084. };
  14085. if (pageInfo.height === 0xFFFFFFFF) {
  14086. delete pageInfo.height;
  14087. }
  14088. var pageSegmentFlags = data[position + 16];
  14089. var pageStripingInformation = readUint16(data, position + 17);
  14090. pageInfo.lossless = !!(pageSegmentFlags & 1);
  14091. pageInfo.refinement = !!(pageSegmentFlags & 2);
  14092. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  14093. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  14094. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  14095. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  14096. args = [pageInfo];
  14097. break;
  14098. case 49:
  14099. break;
  14100. case 50:
  14101. break;
  14102. case 51:
  14103. break;
  14104. case 62:
  14105. break;
  14106. default:
  14107. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  14108. }
  14109. var callbackName = 'on' + header.typeName;
  14110. if (callbackName in visitor) {
  14111. visitor[callbackName].apply(visitor, args);
  14112. }
  14113. }
  14114. function processSegments(segments, visitor) {
  14115. for (var i = 0, ii = segments.length; i < ii; i++) {
  14116. processSegment(segments[i], visitor);
  14117. }
  14118. }
  14119. function parseJbig2(data, start, end) {
  14120. var position = start;
  14121. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  14122. error('JBIG2 error: invalid header');
  14123. }
  14124. var header = {};
  14125. position += 8;
  14126. var flags = data[position++];
  14127. header.randomAccess = !(flags & 1);
  14128. if (!(flags & 2)) {
  14129. header.numberOfPages = readUint32(data, position);
  14130. position += 4;
  14131. }
  14132. var segments = readSegments(header, data, position, end);
  14133. error('Not implemented');
  14134. }
  14135. function parseJbig2Chunks(chunks) {
  14136. var visitor = new SimpleSegmentVisitor();
  14137. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14138. var chunk = chunks[i];
  14139. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14140. processSegments(segments, visitor);
  14141. }
  14142. return visitor.buffer;
  14143. }
  14144. function SimpleSegmentVisitor() {
  14145. }
  14146. SimpleSegmentVisitor.prototype = {
  14147. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14148. this.currentPageInfo = info;
  14149. var rowSize = info.width + 7 >> 3;
  14150. var buffer = new Uint8Array(rowSize * info.height);
  14151. if (info.defaultPixelValue) {
  14152. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14153. buffer[i] = 0xFF;
  14154. }
  14155. }
  14156. this.buffer = buffer;
  14157. },
  14158. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14159. var pageInfo = this.currentPageInfo;
  14160. var width = regionInfo.width, height = regionInfo.height;
  14161. var rowSize = pageInfo.width + 7 >> 3;
  14162. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14163. var buffer = this.buffer;
  14164. var mask0 = 128 >> (regionInfo.x & 7);
  14165. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14166. var i, j, mask, offset;
  14167. switch (combinationOperator) {
  14168. case 0:
  14169. for (i = 0; i < height; i++) {
  14170. mask = mask0;
  14171. offset = offset0;
  14172. for (j = 0; j < width; j++) {
  14173. if (bitmap[i][j]) {
  14174. buffer[offset] |= mask;
  14175. }
  14176. mask >>= 1;
  14177. if (!mask) {
  14178. mask = 128;
  14179. offset++;
  14180. }
  14181. }
  14182. offset0 += rowSize;
  14183. }
  14184. break;
  14185. case 2:
  14186. for (i = 0; i < height; i++) {
  14187. mask = mask0;
  14188. offset = offset0;
  14189. for (j = 0; j < width; j++) {
  14190. if (bitmap[i][j]) {
  14191. buffer[offset] ^= mask;
  14192. }
  14193. mask >>= 1;
  14194. if (!mask) {
  14195. mask = 128;
  14196. offset++;
  14197. }
  14198. }
  14199. offset0 += rowSize;
  14200. }
  14201. break;
  14202. default:
  14203. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14204. }
  14205. },
  14206. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14207. var regionInfo = region.info;
  14208. var decodingContext = new DecodingContext(data, start, end);
  14209. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14210. this.drawBitmap(regionInfo, bitmap);
  14211. },
  14212. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14213. this.onImmediateGenericRegion.apply(this, arguments);
  14214. },
  14215. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14216. var huffmanTables;
  14217. if (dictionary.huffman) {
  14218. error('JBIG2 error: huffman is not supported');
  14219. }
  14220. var symbols = this.symbols;
  14221. if (!symbols) {
  14222. this.symbols = symbols = {};
  14223. }
  14224. var inputSymbols = [];
  14225. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14226. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14227. }
  14228. var decodingContext = new DecodingContext(data, start, end);
  14229. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14230. },
  14231. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14232. var regionInfo = region.info;
  14233. var huffmanTables;
  14234. var symbols = this.symbols;
  14235. var inputSymbols = [];
  14236. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14237. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14238. }
  14239. var symbolCodeLength = log2(inputSymbols.length);
  14240. var decodingContext = new DecodingContext(data, start, end);
  14241. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext);
  14242. this.drawBitmap(regionInfo, bitmap);
  14243. },
  14244. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14245. this.onImmediateTextRegion.apply(this, arguments);
  14246. }
  14247. };
  14248. function Jbig2Image() {
  14249. }
  14250. Jbig2Image.prototype = {
  14251. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14252. return parseJbig2Chunks(chunks);
  14253. }
  14254. };
  14255. return Jbig2Image;
  14256. }();
  14257. exports.Jbig2Image = Jbig2Image;
  14258. }));
  14259. (function (root, factory) {
  14260. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14261. }(this, function (exports, sharedUtil) {
  14262. var error = sharedUtil.error;
  14263. var JpegImage = function JpegImageClosure() {
  14264. var dctZigZag = new Uint8Array([
  14265. 0,
  14266. 1,
  14267. 8,
  14268. 16,
  14269. 9,
  14270. 2,
  14271. 3,
  14272. 10,
  14273. 17,
  14274. 24,
  14275. 32,
  14276. 25,
  14277. 18,
  14278. 11,
  14279. 4,
  14280. 5,
  14281. 12,
  14282. 19,
  14283. 26,
  14284. 33,
  14285. 40,
  14286. 48,
  14287. 41,
  14288. 34,
  14289. 27,
  14290. 20,
  14291. 13,
  14292. 6,
  14293. 7,
  14294. 14,
  14295. 21,
  14296. 28,
  14297. 35,
  14298. 42,
  14299. 49,
  14300. 56,
  14301. 57,
  14302. 50,
  14303. 43,
  14304. 36,
  14305. 29,
  14306. 22,
  14307. 15,
  14308. 23,
  14309. 30,
  14310. 37,
  14311. 44,
  14312. 51,
  14313. 58,
  14314. 59,
  14315. 52,
  14316. 45,
  14317. 38,
  14318. 31,
  14319. 39,
  14320. 46,
  14321. 53,
  14322. 60,
  14323. 61,
  14324. 54,
  14325. 47,
  14326. 55,
  14327. 62,
  14328. 63
  14329. ]);
  14330. var dctCos1 = 4017;
  14331. var dctSin1 = 799;
  14332. var dctCos3 = 3406;
  14333. var dctSin3 = 2276;
  14334. var dctCos6 = 1567;
  14335. var dctSin6 = 3784;
  14336. var dctSqrt2 = 5793;
  14337. var dctSqrt1d2 = 2896;
  14338. function JpegImage() {
  14339. this.decodeTransform = null;
  14340. this.colorTransform = -1;
  14341. }
  14342. function buildHuffmanTable(codeLengths, values) {
  14343. var k = 0, code = [], i, j, length = 16;
  14344. while (length > 0 && !codeLengths[length - 1]) {
  14345. length--;
  14346. }
  14347. code.push({
  14348. children: [],
  14349. index: 0
  14350. });
  14351. var p = code[0], q;
  14352. for (i = 0; i < length; i++) {
  14353. for (j = 0; j < codeLengths[i]; j++) {
  14354. p = code.pop();
  14355. p.children[p.index] = values[k];
  14356. while (p.index > 0) {
  14357. p = code.pop();
  14358. }
  14359. p.index++;
  14360. code.push(p);
  14361. while (code.length <= i) {
  14362. code.push(q = {
  14363. children: [],
  14364. index: 0
  14365. });
  14366. p.children[p.index] = q.children;
  14367. p = q;
  14368. }
  14369. k++;
  14370. }
  14371. if (i + 1 < length) {
  14372. code.push(q = {
  14373. children: [],
  14374. index: 0
  14375. });
  14376. p.children[p.index] = q.children;
  14377. p = q;
  14378. }
  14379. }
  14380. return code[0].children;
  14381. }
  14382. function getBlockBufferOffset(component, row, col) {
  14383. return 64 * ((component.blocksPerLine + 1) * row + col);
  14384. }
  14385. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14386. var mcusPerLine = frame.mcusPerLine;
  14387. var progressive = frame.progressive;
  14388. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14389. function readBit() {
  14390. if (bitsCount > 0) {
  14391. bitsCount--;
  14392. return bitsData >> bitsCount & 1;
  14393. }
  14394. bitsData = data[offset++];
  14395. if (bitsData === 0xFF) {
  14396. var nextByte = data[offset++];
  14397. if (nextByte) {
  14398. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14399. }
  14400. }
  14401. bitsCount = 7;
  14402. return bitsData >>> 7;
  14403. }
  14404. function decodeHuffman(tree) {
  14405. var node = tree;
  14406. while (true) {
  14407. node = node[readBit()];
  14408. if (typeof node === 'number') {
  14409. return node;
  14410. }
  14411. if (typeof node !== 'object') {
  14412. error('JPEG error: invalid huffman sequence');
  14413. }
  14414. }
  14415. }
  14416. function receive(length) {
  14417. var n = 0;
  14418. while (length > 0) {
  14419. n = n << 1 | readBit();
  14420. length--;
  14421. }
  14422. return n;
  14423. }
  14424. function receiveAndExtend(length) {
  14425. if (length === 1) {
  14426. return readBit() === 1 ? 1 : -1;
  14427. }
  14428. var n = receive(length);
  14429. if (n >= 1 << length - 1) {
  14430. return n;
  14431. }
  14432. return n + (-1 << length) + 1;
  14433. }
  14434. function decodeBaseline(component, offset) {
  14435. var t = decodeHuffman(component.huffmanTableDC);
  14436. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14437. component.blockData[offset] = component.pred += diff;
  14438. var k = 1;
  14439. while (k < 64) {
  14440. var rs = decodeHuffman(component.huffmanTableAC);
  14441. var s = rs & 15, r = rs >> 4;
  14442. if (s === 0) {
  14443. if (r < 15) {
  14444. break;
  14445. }
  14446. k += 16;
  14447. continue;
  14448. }
  14449. k += r;
  14450. var z = dctZigZag[k];
  14451. component.blockData[offset + z] = receiveAndExtend(s);
  14452. k++;
  14453. }
  14454. }
  14455. function decodeDCFirst(component, offset) {
  14456. var t = decodeHuffman(component.huffmanTableDC);
  14457. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14458. component.blockData[offset] = component.pred += diff;
  14459. }
  14460. function decodeDCSuccessive(component, offset) {
  14461. component.blockData[offset] |= readBit() << successive;
  14462. }
  14463. var eobrun = 0;
  14464. function decodeACFirst(component, offset) {
  14465. if (eobrun > 0) {
  14466. eobrun--;
  14467. return;
  14468. }
  14469. var k = spectralStart, e = spectralEnd;
  14470. while (k <= e) {
  14471. var rs = decodeHuffman(component.huffmanTableAC);
  14472. var s = rs & 15, r = rs >> 4;
  14473. if (s === 0) {
  14474. if (r < 15) {
  14475. eobrun = receive(r) + (1 << r) - 1;
  14476. break;
  14477. }
  14478. k += 16;
  14479. continue;
  14480. }
  14481. k += r;
  14482. var z = dctZigZag[k];
  14483. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14484. k++;
  14485. }
  14486. }
  14487. var successiveACState = 0, successiveACNextValue;
  14488. function decodeACSuccessive(component, offset) {
  14489. var k = spectralStart;
  14490. var e = spectralEnd;
  14491. var r = 0;
  14492. var s;
  14493. var rs;
  14494. while (k <= e) {
  14495. var z = dctZigZag[k];
  14496. switch (successiveACState) {
  14497. case 0:
  14498. rs = decodeHuffman(component.huffmanTableAC);
  14499. s = rs & 15;
  14500. r = rs >> 4;
  14501. if (s === 0) {
  14502. if (r < 15) {
  14503. eobrun = receive(r) + (1 << r);
  14504. successiveACState = 4;
  14505. } else {
  14506. r = 16;
  14507. successiveACState = 1;
  14508. }
  14509. } else {
  14510. if (s !== 1) {
  14511. error('JPEG error: invalid ACn encoding');
  14512. }
  14513. successiveACNextValue = receiveAndExtend(s);
  14514. successiveACState = r ? 2 : 3;
  14515. }
  14516. continue;
  14517. case 1:
  14518. case 2:
  14519. if (component.blockData[offset + z]) {
  14520. component.blockData[offset + z] += readBit() << successive;
  14521. } else {
  14522. r--;
  14523. if (r === 0) {
  14524. successiveACState = successiveACState === 2 ? 3 : 0;
  14525. }
  14526. }
  14527. break;
  14528. case 3:
  14529. if (component.blockData[offset + z]) {
  14530. component.blockData[offset + z] += readBit() << successive;
  14531. } else {
  14532. component.blockData[offset + z] = successiveACNextValue << successive;
  14533. successiveACState = 0;
  14534. }
  14535. break;
  14536. case 4:
  14537. if (component.blockData[offset + z]) {
  14538. component.blockData[offset + z] += readBit() << successive;
  14539. }
  14540. break;
  14541. }
  14542. k++;
  14543. }
  14544. if (successiveACState === 4) {
  14545. eobrun--;
  14546. if (eobrun === 0) {
  14547. successiveACState = 0;
  14548. }
  14549. }
  14550. }
  14551. function decodeMcu(component, decode, mcu, row, col) {
  14552. var mcuRow = mcu / mcusPerLine | 0;
  14553. var mcuCol = mcu % mcusPerLine;
  14554. var blockRow = mcuRow * component.v + row;
  14555. var blockCol = mcuCol * component.h + col;
  14556. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14557. decode(component, offset);
  14558. }
  14559. function decodeBlock(component, decode, mcu) {
  14560. var blockRow = mcu / component.blocksPerLine | 0;
  14561. var blockCol = mcu % component.blocksPerLine;
  14562. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14563. decode(component, offset);
  14564. }
  14565. var componentsLength = components.length;
  14566. var component, i, j, k, n;
  14567. var decodeFn;
  14568. if (progressive) {
  14569. if (spectralStart === 0) {
  14570. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14571. } else {
  14572. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14573. }
  14574. } else {
  14575. decodeFn = decodeBaseline;
  14576. }
  14577. var mcu = 0, marker;
  14578. var mcuExpected;
  14579. if (componentsLength === 1) {
  14580. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14581. } else {
  14582. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14583. }
  14584. if (!resetInterval) {
  14585. resetInterval = mcuExpected;
  14586. }
  14587. var h, v;
  14588. while (mcu < mcuExpected) {
  14589. for (i = 0; i < componentsLength; i++) {
  14590. components[i].pred = 0;
  14591. }
  14592. eobrun = 0;
  14593. if (componentsLength === 1) {
  14594. component = components[0];
  14595. for (n = 0; n < resetInterval; n++) {
  14596. decodeBlock(component, decodeFn, mcu);
  14597. mcu++;
  14598. }
  14599. } else {
  14600. for (n = 0; n < resetInterval; n++) {
  14601. for (i = 0; i < componentsLength; i++) {
  14602. component = components[i];
  14603. h = component.h;
  14604. v = component.v;
  14605. for (j = 0; j < v; j++) {
  14606. for (k = 0; k < h; k++) {
  14607. decodeMcu(component, decodeFn, mcu, j, k);
  14608. }
  14609. }
  14610. }
  14611. mcu++;
  14612. }
  14613. }
  14614. bitsCount = 0;
  14615. marker = data[offset] << 8 | data[offset + 1];
  14616. while (data[offset] === 0x00 && offset < data.length - 1) {
  14617. offset++;
  14618. marker = data[offset] << 8 | data[offset + 1];
  14619. }
  14620. if (marker <= 0xFF00) {
  14621. error('JPEG error: marker was not found');
  14622. }
  14623. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14624. offset += 2;
  14625. } else {
  14626. break;
  14627. }
  14628. }
  14629. return offset - startOffset;
  14630. }
  14631. function quantizeAndInverse(component, blockBufferOffset, p) {
  14632. var qt = component.quantizationTable, blockData = component.blockData;
  14633. var v0, v1, v2, v3, v4, v5, v6, v7;
  14634. var p0, p1, p2, p3, p4, p5, p6, p7;
  14635. var t;
  14636. if (!qt) {
  14637. error('JPEG error: missing required Quantization Table.');
  14638. }
  14639. for (var row = 0; row < 64; row += 8) {
  14640. p0 = blockData[blockBufferOffset + row];
  14641. p1 = blockData[blockBufferOffset + row + 1];
  14642. p2 = blockData[blockBufferOffset + row + 2];
  14643. p3 = blockData[blockBufferOffset + row + 3];
  14644. p4 = blockData[blockBufferOffset + row + 4];
  14645. p5 = blockData[blockBufferOffset + row + 5];
  14646. p6 = blockData[blockBufferOffset + row + 6];
  14647. p7 = blockData[blockBufferOffset + row + 7];
  14648. p0 *= qt[row];
  14649. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14650. t = dctSqrt2 * p0 + 512 >> 10;
  14651. p[row] = t;
  14652. p[row + 1] = t;
  14653. p[row + 2] = t;
  14654. p[row + 3] = t;
  14655. p[row + 4] = t;
  14656. p[row + 5] = t;
  14657. p[row + 6] = t;
  14658. p[row + 7] = t;
  14659. continue;
  14660. }
  14661. p1 *= qt[row + 1];
  14662. p2 *= qt[row + 2];
  14663. p3 *= qt[row + 3];
  14664. p4 *= qt[row + 4];
  14665. p5 *= qt[row + 5];
  14666. p6 *= qt[row + 6];
  14667. p7 *= qt[row + 7];
  14668. v0 = dctSqrt2 * p0 + 128 >> 8;
  14669. v1 = dctSqrt2 * p4 + 128 >> 8;
  14670. v2 = p2;
  14671. v3 = p6;
  14672. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14673. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14674. v5 = p3 << 4;
  14675. v6 = p5 << 4;
  14676. v0 = v0 + v1 + 1 >> 1;
  14677. v1 = v0 - v1;
  14678. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14679. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14680. v3 = t;
  14681. v4 = v4 + v6 + 1 >> 1;
  14682. v6 = v4 - v6;
  14683. v7 = v7 + v5 + 1 >> 1;
  14684. v5 = v7 - v5;
  14685. v0 = v0 + v3 + 1 >> 1;
  14686. v3 = v0 - v3;
  14687. v1 = v1 + v2 + 1 >> 1;
  14688. v2 = v1 - v2;
  14689. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14690. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14691. v7 = t;
  14692. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14693. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14694. v6 = t;
  14695. p[row] = v0 + v7;
  14696. p[row + 7] = v0 - v7;
  14697. p[row + 1] = v1 + v6;
  14698. p[row + 6] = v1 - v6;
  14699. p[row + 2] = v2 + v5;
  14700. p[row + 5] = v2 - v5;
  14701. p[row + 3] = v3 + v4;
  14702. p[row + 4] = v3 - v4;
  14703. }
  14704. for (var col = 0; col < 8; ++col) {
  14705. p0 = p[col];
  14706. p1 = p[col + 8];
  14707. p2 = p[col + 16];
  14708. p3 = p[col + 24];
  14709. p4 = p[col + 32];
  14710. p5 = p[col + 40];
  14711. p6 = p[col + 48];
  14712. p7 = p[col + 56];
  14713. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14714. t = dctSqrt2 * p0 + 8192 >> 14;
  14715. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14716. blockData[blockBufferOffset + col] = t;
  14717. blockData[blockBufferOffset + col + 8] = t;
  14718. blockData[blockBufferOffset + col + 16] = t;
  14719. blockData[blockBufferOffset + col + 24] = t;
  14720. blockData[blockBufferOffset + col + 32] = t;
  14721. blockData[blockBufferOffset + col + 40] = t;
  14722. blockData[blockBufferOffset + col + 48] = t;
  14723. blockData[blockBufferOffset + col + 56] = t;
  14724. continue;
  14725. }
  14726. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14727. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14728. v2 = p2;
  14729. v3 = p6;
  14730. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14731. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14732. v5 = p3;
  14733. v6 = p5;
  14734. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14735. v1 = v0 - v1;
  14736. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14737. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14738. v3 = t;
  14739. v4 = v4 + v6 + 1 >> 1;
  14740. v6 = v4 - v6;
  14741. v7 = v7 + v5 + 1 >> 1;
  14742. v5 = v7 - v5;
  14743. v0 = v0 + v3 + 1 >> 1;
  14744. v3 = v0 - v3;
  14745. v1 = v1 + v2 + 1 >> 1;
  14746. v2 = v1 - v2;
  14747. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14748. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14749. v7 = t;
  14750. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14751. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14752. v6 = t;
  14753. p0 = v0 + v7;
  14754. p7 = v0 - v7;
  14755. p1 = v1 + v6;
  14756. p6 = v1 - v6;
  14757. p2 = v2 + v5;
  14758. p5 = v2 - v5;
  14759. p3 = v3 + v4;
  14760. p4 = v3 - v4;
  14761. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14762. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14763. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14764. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14765. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14766. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14767. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14768. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14769. blockData[blockBufferOffset + col] = p0;
  14770. blockData[blockBufferOffset + col + 8] = p1;
  14771. blockData[blockBufferOffset + col + 16] = p2;
  14772. blockData[blockBufferOffset + col + 24] = p3;
  14773. blockData[blockBufferOffset + col + 32] = p4;
  14774. blockData[blockBufferOffset + col + 40] = p5;
  14775. blockData[blockBufferOffset + col + 48] = p6;
  14776. blockData[blockBufferOffset + col + 56] = p7;
  14777. }
  14778. }
  14779. function buildComponentData(frame, component) {
  14780. var blocksPerLine = component.blocksPerLine;
  14781. var blocksPerColumn = component.blocksPerColumn;
  14782. var computationBuffer = new Int16Array(64);
  14783. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14784. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14785. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14786. quantizeAndInverse(component, offset, computationBuffer);
  14787. }
  14788. }
  14789. return component.blockData;
  14790. }
  14791. function clamp0to255(a) {
  14792. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14793. }
  14794. JpegImage.prototype = {
  14795. parse: function parse(data) {
  14796. function readUint16() {
  14797. var value = data[offset] << 8 | data[offset + 1];
  14798. offset += 2;
  14799. return value;
  14800. }
  14801. function readDataBlock() {
  14802. var length = readUint16();
  14803. var array = data.subarray(offset, offset + length - 2);
  14804. offset += array.length;
  14805. return array;
  14806. }
  14807. function prepareComponents(frame) {
  14808. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14809. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14810. for (var i = 0; i < frame.components.length; i++) {
  14811. component = frame.components[i];
  14812. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14813. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14814. var blocksPerLineForMcu = mcusPerLine * component.h;
  14815. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14816. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14817. component.blockData = new Int16Array(blocksBufferSize);
  14818. component.blocksPerLine = blocksPerLine;
  14819. component.blocksPerColumn = blocksPerColumn;
  14820. }
  14821. frame.mcusPerLine = mcusPerLine;
  14822. frame.mcusPerColumn = mcusPerColumn;
  14823. }
  14824. var offset = 0;
  14825. var jfif = null;
  14826. var adobe = null;
  14827. var frame, resetInterval;
  14828. var quantizationTables = [];
  14829. var huffmanTablesAC = [], huffmanTablesDC = [];
  14830. var fileMarker = readUint16();
  14831. if (fileMarker !== 0xFFD8) {
  14832. error('JPEG error: SOI not found');
  14833. }
  14834. fileMarker = readUint16();
  14835. while (fileMarker !== 0xFFD9) {
  14836. var i, j, l;
  14837. switch (fileMarker) {
  14838. case 0xFFE0:
  14839. case 0xFFE1:
  14840. case 0xFFE2:
  14841. case 0xFFE3:
  14842. case 0xFFE4:
  14843. case 0xFFE5:
  14844. case 0xFFE6:
  14845. case 0xFFE7:
  14846. case 0xFFE8:
  14847. case 0xFFE9:
  14848. case 0xFFEA:
  14849. case 0xFFEB:
  14850. case 0xFFEC:
  14851. case 0xFFED:
  14852. case 0xFFEE:
  14853. case 0xFFEF:
  14854. case 0xFFFE:
  14855. var appData = readDataBlock();
  14856. if (fileMarker === 0xFFE0) {
  14857. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14858. jfif = {
  14859. version: {
  14860. major: appData[5],
  14861. minor: appData[6]
  14862. },
  14863. densityUnits: appData[7],
  14864. xDensity: appData[8] << 8 | appData[9],
  14865. yDensity: appData[10] << 8 | appData[11],
  14866. thumbWidth: appData[12],
  14867. thumbHeight: appData[13],
  14868. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14869. };
  14870. }
  14871. }
  14872. if (fileMarker === 0xFFEE) {
  14873. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14874. adobe = {
  14875. version: appData[5] << 8 | appData[6],
  14876. flags0: appData[7] << 8 | appData[8],
  14877. flags1: appData[9] << 8 | appData[10],
  14878. transformCode: appData[11]
  14879. };
  14880. }
  14881. }
  14882. break;
  14883. case 0xFFDB:
  14884. var quantizationTablesLength = readUint16();
  14885. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14886. var z;
  14887. while (offset < quantizationTablesEnd) {
  14888. var quantizationTableSpec = data[offset++];
  14889. var tableData = new Uint16Array(64);
  14890. if (quantizationTableSpec >> 4 === 0) {
  14891. for (j = 0; j < 64; j++) {
  14892. z = dctZigZag[j];
  14893. tableData[z] = data[offset++];
  14894. }
  14895. } else if (quantizationTableSpec >> 4 === 1) {
  14896. for (j = 0; j < 64; j++) {
  14897. z = dctZigZag[j];
  14898. tableData[z] = readUint16();
  14899. }
  14900. } else {
  14901. error('JPEG error: DQT - invalid table spec');
  14902. }
  14903. quantizationTables[quantizationTableSpec & 15] = tableData;
  14904. }
  14905. break;
  14906. case 0xFFC0:
  14907. case 0xFFC1:
  14908. case 0xFFC2:
  14909. if (frame) {
  14910. error('JPEG error: Only single frame JPEGs supported');
  14911. }
  14912. readUint16();
  14913. frame = {};
  14914. frame.extended = fileMarker === 0xFFC1;
  14915. frame.progressive = fileMarker === 0xFFC2;
  14916. frame.precision = data[offset++];
  14917. frame.scanLines = readUint16();
  14918. frame.samplesPerLine = readUint16();
  14919. frame.components = [];
  14920. frame.componentIds = {};
  14921. var componentsCount = data[offset++], componentId;
  14922. var maxH = 0, maxV = 0;
  14923. for (i = 0; i < componentsCount; i++) {
  14924. componentId = data[offset];
  14925. var h = data[offset + 1] >> 4;
  14926. var v = data[offset + 1] & 15;
  14927. if (maxH < h) {
  14928. maxH = h;
  14929. }
  14930. if (maxV < v) {
  14931. maxV = v;
  14932. }
  14933. var qId = data[offset + 2];
  14934. l = frame.components.push({
  14935. h: h,
  14936. v: v,
  14937. quantizationId: qId,
  14938. quantizationTable: null
  14939. });
  14940. frame.componentIds[componentId] = l - 1;
  14941. offset += 3;
  14942. }
  14943. frame.maxH = maxH;
  14944. frame.maxV = maxV;
  14945. prepareComponents(frame);
  14946. break;
  14947. case 0xFFC4:
  14948. var huffmanLength = readUint16();
  14949. for (i = 2; i < huffmanLength;) {
  14950. var huffmanTableSpec = data[offset++];
  14951. var codeLengths = new Uint8Array(16);
  14952. var codeLengthSum = 0;
  14953. for (j = 0; j < 16; j++, offset++) {
  14954. codeLengthSum += codeLengths[j] = data[offset];
  14955. }
  14956. var huffmanValues = new Uint8Array(codeLengthSum);
  14957. for (j = 0; j < codeLengthSum; j++, offset++) {
  14958. huffmanValues[j] = data[offset];
  14959. }
  14960. i += 17 + codeLengthSum;
  14961. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14962. }
  14963. break;
  14964. case 0xFFDD:
  14965. readUint16();
  14966. resetInterval = readUint16();
  14967. break;
  14968. case 0xFFDA:
  14969. var scanLength = readUint16();
  14970. var selectorsCount = data[offset++];
  14971. var components = [], component;
  14972. for (i = 0; i < selectorsCount; i++) {
  14973. var componentIndex = frame.componentIds[data[offset++]];
  14974. component = frame.components[componentIndex];
  14975. var tableSpec = data[offset++];
  14976. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14977. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14978. components.push(component);
  14979. }
  14980. var spectralStart = data[offset++];
  14981. var spectralEnd = data[offset++];
  14982. var successiveApproximation = data[offset++];
  14983. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14984. offset += processed;
  14985. break;
  14986. case 0xFFFF:
  14987. if (data[offset] !== 0xFF) {
  14988. offset--;
  14989. }
  14990. break;
  14991. default:
  14992. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14993. offset -= 3;
  14994. break;
  14995. }
  14996. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14997. }
  14998. fileMarker = readUint16();
  14999. }
  15000. this.width = frame.samplesPerLine;
  15001. this.height = frame.scanLines;
  15002. this.jfif = jfif;
  15003. this.adobe = adobe;
  15004. this.components = [];
  15005. for (i = 0; i < frame.components.length; i++) {
  15006. component = frame.components[i];
  15007. var quantizationTable = quantizationTables[component.quantizationId];
  15008. if (quantizationTable) {
  15009. component.quantizationTable = quantizationTable;
  15010. }
  15011. this.components.push({
  15012. output: buildComponentData(frame, component),
  15013. scaleX: component.h / frame.maxH,
  15014. scaleY: component.v / frame.maxV,
  15015. blocksPerLine: component.blocksPerLine,
  15016. blocksPerColumn: component.blocksPerColumn
  15017. });
  15018. }
  15019. this.numComponents = this.components.length;
  15020. },
  15021. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  15022. var scaleX = this.width / width, scaleY = this.height / height;
  15023. var component, componentScaleX, componentScaleY, blocksPerScanline;
  15024. var x, y, i, j, k;
  15025. var index;
  15026. var offset = 0;
  15027. var output;
  15028. var numComponents = this.components.length;
  15029. var dataLength = width * height * numComponents;
  15030. var data = new Uint8Array(dataLength);
  15031. var xScaleBlockOffset = new Uint32Array(width);
  15032. var mask3LSB = 0xfffffff8;
  15033. for (i = 0; i < numComponents; i++) {
  15034. component = this.components[i];
  15035. componentScaleX = component.scaleX * scaleX;
  15036. componentScaleY = component.scaleY * scaleY;
  15037. offset = i;
  15038. output = component.output;
  15039. blocksPerScanline = component.blocksPerLine + 1 << 3;
  15040. for (x = 0; x < width; x++) {
  15041. j = 0 | x * componentScaleX;
  15042. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  15043. }
  15044. for (y = 0; y < height; y++) {
  15045. j = 0 | y * componentScaleY;
  15046. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  15047. for (x = 0; x < width; x++) {
  15048. data[offset] = output[index + xScaleBlockOffset[x]];
  15049. offset += numComponents;
  15050. }
  15051. }
  15052. }
  15053. var transform = this.decodeTransform;
  15054. if (transform) {
  15055. for (i = 0; i < dataLength;) {
  15056. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  15057. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  15058. }
  15059. }
  15060. }
  15061. return data;
  15062. },
  15063. _isColorConversionNeeded: function isColorConversionNeeded() {
  15064. if (this.adobe && this.adobe.transformCode) {
  15065. return true;
  15066. } else if (this.numComponents === 3) {
  15067. if (!this.adobe && this.colorTransform === 0) {
  15068. return false;
  15069. }
  15070. return true;
  15071. }
  15072. if (!this.adobe && this.colorTransform === 1) {
  15073. return true;
  15074. }
  15075. return false;
  15076. },
  15077. _convertYccToRgb: function convertYccToRgb(data) {
  15078. var Y, Cb, Cr;
  15079. for (var i = 0, length = data.length; i < length; i += 3) {
  15080. Y = data[i];
  15081. Cb = data[i + 1];
  15082. Cr = data[i + 2];
  15083. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  15084. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  15085. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  15086. }
  15087. return data;
  15088. },
  15089. _convertYcckToRgb: function convertYcckToRgb(data) {
  15090. var Y, Cb, Cr, k;
  15091. var offset = 0;
  15092. for (var i = 0, length = data.length; i < length; i += 4) {
  15093. Y = data[i];
  15094. Cb = data[i + 1];
  15095. Cr = data[i + 2];
  15096. k = data[i + 3];
  15097. var r = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  15098. var g = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  15099. var b = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  15100. data[offset++] = clamp0to255(r);
  15101. data[offset++] = clamp0to255(g);
  15102. data[offset++] = clamp0to255(b);
  15103. }
  15104. return data;
  15105. },
  15106. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  15107. var Y, Cb, Cr;
  15108. for (var i = 0, length = data.length; i < length; i += 4) {
  15109. Y = data[i];
  15110. Cb = data[i + 1];
  15111. Cr = data[i + 2];
  15112. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  15113. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15114. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15115. }
  15116. return data;
  15117. },
  15118. _convertCmykToRgb: function convertCmykToRgb(data) {
  15119. var c, m, y, k;
  15120. var offset = 0;
  15121. var min = -255 * 255 * 255;
  15122. var scale = 1 / 255 / 255;
  15123. for (var i = 0, length = data.length; i < length; i += 4) {
  15124. c = data[i];
  15125. m = data[i + 1];
  15126. y = data[i + 2];
  15127. k = data[i + 3];
  15128. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 72734.4411664936) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 1401.7366389350734) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 4465.541406466231) - k * (21.86122147463605 * k + 48317.86113160301);
  15129. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 20220.756542821975) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 48691.05921601825) + y * (4.444339102852739 * y + 9.8632861493405 * k - 6341.191035517494) - k * (20.737325471181034 * k + 47890.15695978492);
  15130. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 3616.812083916688) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 28620.90484698408) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 49363.43385999684) - k * (22.33816807309886 * k + 45932.16563550634);
  15131. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15132. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15133. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15134. }
  15135. return data;
  15136. },
  15137. getData: function getData(width, height, forceRGBoutput) {
  15138. if (this.numComponents > 4) {
  15139. error('JPEG error: Unsupported color mode');
  15140. }
  15141. var data = this._getLinearizedBlockData(width, height);
  15142. if (this.numComponents === 1 && forceRGBoutput) {
  15143. var dataLength = data.length;
  15144. var rgbData = new Uint8Array(dataLength * 3);
  15145. var offset = 0;
  15146. for (var i = 0; i < dataLength; i++) {
  15147. var grayColor = data[i];
  15148. rgbData[offset++] = grayColor;
  15149. rgbData[offset++] = grayColor;
  15150. rgbData[offset++] = grayColor;
  15151. }
  15152. return rgbData;
  15153. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15154. return this._convertYccToRgb(data);
  15155. } else if (this.numComponents === 4) {
  15156. if (this._isColorConversionNeeded()) {
  15157. if (forceRGBoutput) {
  15158. return this._convertYcckToRgb(data);
  15159. }
  15160. return this._convertYcckToCmyk(data);
  15161. } else if (forceRGBoutput) {
  15162. return this._convertCmykToRgb(data);
  15163. }
  15164. }
  15165. return data;
  15166. }
  15167. };
  15168. return JpegImage;
  15169. }();
  15170. exports.JpegImage = JpegImage;
  15171. }));
  15172. (function (root, factory) {
  15173. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15174. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15175. var info = sharedUtil.info;
  15176. var warn = sharedUtil.warn;
  15177. var error = sharedUtil.error;
  15178. var log2 = sharedUtil.log2;
  15179. var readUint16 = sharedUtil.readUint16;
  15180. var readUint32 = sharedUtil.readUint32;
  15181. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15182. var JpxImage = function JpxImageClosure() {
  15183. var SubbandsGainLog2 = {
  15184. 'LL': 0,
  15185. 'LH': 1,
  15186. 'HL': 1,
  15187. 'HH': 2
  15188. };
  15189. function JpxImage() {
  15190. this.failOnCorruptedImage = false;
  15191. }
  15192. JpxImage.prototype = {
  15193. parse: function JpxImage_parse(data) {
  15194. var head = readUint16(data, 0);
  15195. if (head === 0xFF4F) {
  15196. this.parseCodestream(data, 0, data.length);
  15197. return;
  15198. }
  15199. var position = 0, length = data.length;
  15200. while (position < length) {
  15201. var headerSize = 8;
  15202. var lbox = readUint32(data, position);
  15203. var tbox = readUint32(data, position + 4);
  15204. position += headerSize;
  15205. if (lbox === 1) {
  15206. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15207. position += 8;
  15208. headerSize += 8;
  15209. }
  15210. if (lbox === 0) {
  15211. lbox = length - position + headerSize;
  15212. }
  15213. if (lbox < headerSize) {
  15214. error('JPX Error: Invalid box field size');
  15215. }
  15216. var dataLength = lbox - headerSize;
  15217. var jumpDataLength = true;
  15218. switch (tbox) {
  15219. case 0x6A703268:
  15220. jumpDataLength = false;
  15221. break;
  15222. case 0x636F6C72:
  15223. var method = data[position];
  15224. if (method === 1) {
  15225. var colorspace = readUint32(data, position + 3);
  15226. switch (colorspace) {
  15227. case 16:
  15228. case 17:
  15229. case 18:
  15230. break;
  15231. default:
  15232. warn('Unknown colorspace ' + colorspace);
  15233. break;
  15234. }
  15235. } else if (method === 2) {
  15236. info('ICC profile not supported');
  15237. }
  15238. break;
  15239. case 0x6A703263:
  15240. this.parseCodestream(data, position, position + dataLength);
  15241. break;
  15242. case 0x6A502020:
  15243. if (0x0d0a870a !== readUint32(data, position)) {
  15244. warn('Invalid JP2 signature');
  15245. }
  15246. break;
  15247. case 0x6A501A1A:
  15248. case 0x66747970:
  15249. case 0x72726571:
  15250. case 0x72657320:
  15251. case 0x69686472:
  15252. break;
  15253. default:
  15254. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15255. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15256. break;
  15257. }
  15258. if (jumpDataLength) {
  15259. position += dataLength;
  15260. }
  15261. }
  15262. },
  15263. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15264. var newByte = stream.getByte();
  15265. while (newByte >= 0) {
  15266. var oldByte = newByte;
  15267. newByte = stream.getByte();
  15268. var code = oldByte << 8 | newByte;
  15269. if (code === 0xFF51) {
  15270. stream.skip(4);
  15271. var Xsiz = stream.getInt32() >>> 0;
  15272. var Ysiz = stream.getInt32() >>> 0;
  15273. var XOsiz = stream.getInt32() >>> 0;
  15274. var YOsiz = stream.getInt32() >>> 0;
  15275. stream.skip(16);
  15276. var Csiz = stream.getUint16();
  15277. this.width = Xsiz - XOsiz;
  15278. this.height = Ysiz - YOsiz;
  15279. this.componentsCount = Csiz;
  15280. this.bitsPerComponent = 8;
  15281. return;
  15282. }
  15283. }
  15284. error('JPX Error: No size marker found in JPX stream');
  15285. },
  15286. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15287. var context = {};
  15288. var doNotRecover = false;
  15289. try {
  15290. var position = start;
  15291. while (position + 1 < end) {
  15292. var code = readUint16(data, position);
  15293. position += 2;
  15294. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15295. switch (code) {
  15296. case 0xFF4F:
  15297. context.mainHeader = true;
  15298. break;
  15299. case 0xFFD9:
  15300. break;
  15301. case 0xFF51:
  15302. length = readUint16(data, position);
  15303. var siz = {};
  15304. siz.Xsiz = readUint32(data, position + 4);
  15305. siz.Ysiz = readUint32(data, position + 8);
  15306. siz.XOsiz = readUint32(data, position + 12);
  15307. siz.YOsiz = readUint32(data, position + 16);
  15308. siz.XTsiz = readUint32(data, position + 20);
  15309. siz.YTsiz = readUint32(data, position + 24);
  15310. siz.XTOsiz = readUint32(data, position + 28);
  15311. siz.YTOsiz = readUint32(data, position + 32);
  15312. var componentsCount = readUint16(data, position + 36);
  15313. siz.Csiz = componentsCount;
  15314. var components = [];
  15315. j = position + 38;
  15316. for (var i = 0; i < componentsCount; i++) {
  15317. var component = {
  15318. precision: (data[j] & 0x7F) + 1,
  15319. isSigned: !!(data[j] & 0x80),
  15320. XRsiz: data[j + 1],
  15321. YRsiz: data[j + 1]
  15322. };
  15323. calculateComponentDimensions(component, siz);
  15324. components.push(component);
  15325. }
  15326. context.SIZ = siz;
  15327. context.components = components;
  15328. calculateTileGrids(context, components);
  15329. context.QCC = [];
  15330. context.COC = [];
  15331. break;
  15332. case 0xFF5C:
  15333. length = readUint16(data, position);
  15334. var qcd = {};
  15335. j = position + 2;
  15336. sqcd = data[j++];
  15337. switch (sqcd & 0x1F) {
  15338. case 0:
  15339. spqcdSize = 8;
  15340. scalarExpounded = true;
  15341. break;
  15342. case 1:
  15343. spqcdSize = 16;
  15344. scalarExpounded = false;
  15345. break;
  15346. case 2:
  15347. spqcdSize = 16;
  15348. scalarExpounded = true;
  15349. break;
  15350. default:
  15351. throw new Error('Invalid SQcd value ' + sqcd);
  15352. }
  15353. qcd.noQuantization = spqcdSize === 8;
  15354. qcd.scalarExpounded = scalarExpounded;
  15355. qcd.guardBits = sqcd >> 5;
  15356. spqcds = [];
  15357. while (j < length + position) {
  15358. var spqcd = {};
  15359. if (spqcdSize === 8) {
  15360. spqcd.epsilon = data[j++] >> 3;
  15361. spqcd.mu = 0;
  15362. } else {
  15363. spqcd.epsilon = data[j] >> 3;
  15364. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15365. j += 2;
  15366. }
  15367. spqcds.push(spqcd);
  15368. }
  15369. qcd.SPqcds = spqcds;
  15370. if (context.mainHeader) {
  15371. context.QCD = qcd;
  15372. } else {
  15373. context.currentTile.QCD = qcd;
  15374. context.currentTile.QCC = [];
  15375. }
  15376. break;
  15377. case 0xFF5D:
  15378. length = readUint16(data, position);
  15379. var qcc = {};
  15380. j = position + 2;
  15381. var cqcc;
  15382. if (context.SIZ.Csiz < 257) {
  15383. cqcc = data[j++];
  15384. } else {
  15385. cqcc = readUint16(data, j);
  15386. j += 2;
  15387. }
  15388. sqcd = data[j++];
  15389. switch (sqcd & 0x1F) {
  15390. case 0:
  15391. spqcdSize = 8;
  15392. scalarExpounded = true;
  15393. break;
  15394. case 1:
  15395. spqcdSize = 16;
  15396. scalarExpounded = false;
  15397. break;
  15398. case 2:
  15399. spqcdSize = 16;
  15400. scalarExpounded = true;
  15401. break;
  15402. default:
  15403. throw new Error('Invalid SQcd value ' + sqcd);
  15404. }
  15405. qcc.noQuantization = spqcdSize === 8;
  15406. qcc.scalarExpounded = scalarExpounded;
  15407. qcc.guardBits = sqcd >> 5;
  15408. spqcds = [];
  15409. while (j < length + position) {
  15410. spqcd = {};
  15411. if (spqcdSize === 8) {
  15412. spqcd.epsilon = data[j++] >> 3;
  15413. spqcd.mu = 0;
  15414. } else {
  15415. spqcd.epsilon = data[j] >> 3;
  15416. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15417. j += 2;
  15418. }
  15419. spqcds.push(spqcd);
  15420. }
  15421. qcc.SPqcds = spqcds;
  15422. if (context.mainHeader) {
  15423. context.QCC[cqcc] = qcc;
  15424. } else {
  15425. context.currentTile.QCC[cqcc] = qcc;
  15426. }
  15427. break;
  15428. case 0xFF52:
  15429. length = readUint16(data, position);
  15430. var cod = {};
  15431. j = position + 2;
  15432. var scod = data[j++];
  15433. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15434. cod.sopMarkerUsed = !!(scod & 2);
  15435. cod.ephMarkerUsed = !!(scod & 4);
  15436. cod.progressionOrder = data[j++];
  15437. cod.layersCount = readUint16(data, j);
  15438. j += 2;
  15439. cod.multipleComponentTransform = data[j++];
  15440. cod.decompositionLevelsCount = data[j++];
  15441. cod.xcb = (data[j++] & 0xF) + 2;
  15442. cod.ycb = (data[j++] & 0xF) + 2;
  15443. var blockStyle = data[j++];
  15444. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15445. cod.resetContextProbabilities = !!(blockStyle & 2);
  15446. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15447. cod.verticalyStripe = !!(blockStyle & 8);
  15448. cod.predictableTermination = !!(blockStyle & 16);
  15449. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15450. cod.reversibleTransformation = data[j++];
  15451. if (cod.entropyCoderWithCustomPrecincts) {
  15452. var precinctsSizes = [];
  15453. while (j < length + position) {
  15454. var precinctsSize = data[j++];
  15455. precinctsSizes.push({
  15456. PPx: precinctsSize & 0xF,
  15457. PPy: precinctsSize >> 4
  15458. });
  15459. }
  15460. cod.precinctsSizes = precinctsSizes;
  15461. }
  15462. var unsupported = [];
  15463. if (cod.selectiveArithmeticCodingBypass) {
  15464. unsupported.push('selectiveArithmeticCodingBypass');
  15465. }
  15466. if (cod.resetContextProbabilities) {
  15467. unsupported.push('resetContextProbabilities');
  15468. }
  15469. if (cod.terminationOnEachCodingPass) {
  15470. unsupported.push('terminationOnEachCodingPass');
  15471. }
  15472. if (cod.verticalyStripe) {
  15473. unsupported.push('verticalyStripe');
  15474. }
  15475. if (cod.predictableTermination) {
  15476. unsupported.push('predictableTermination');
  15477. }
  15478. if (unsupported.length > 0) {
  15479. doNotRecover = true;
  15480. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15481. }
  15482. if (context.mainHeader) {
  15483. context.COD = cod;
  15484. } else {
  15485. context.currentTile.COD = cod;
  15486. context.currentTile.COC = [];
  15487. }
  15488. break;
  15489. case 0xFF90:
  15490. length = readUint16(data, position);
  15491. tile = {};
  15492. tile.index = readUint16(data, position + 2);
  15493. tile.length = readUint32(data, position + 4);
  15494. tile.dataEnd = tile.length + position - 2;
  15495. tile.partIndex = data[position + 8];
  15496. tile.partsCount = data[position + 9];
  15497. context.mainHeader = false;
  15498. if (tile.partIndex === 0) {
  15499. tile.COD = context.COD;
  15500. tile.COC = context.COC.slice(0);
  15501. tile.QCD = context.QCD;
  15502. tile.QCC = context.QCC.slice(0);
  15503. }
  15504. context.currentTile = tile;
  15505. break;
  15506. case 0xFF93:
  15507. tile = context.currentTile;
  15508. if (tile.partIndex === 0) {
  15509. initializeTile(context, tile.index);
  15510. buildPackets(context);
  15511. }
  15512. length = tile.dataEnd - position;
  15513. parseTilePackets(context, data, position, length);
  15514. break;
  15515. case 0xFF55:
  15516. case 0xFF57:
  15517. case 0xFF58:
  15518. case 0xFF64:
  15519. length = readUint16(data, position);
  15520. break;
  15521. case 0xFF53:
  15522. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15523. default:
  15524. throw new Error('Unknown codestream code: ' + code.toString(16));
  15525. }
  15526. position += length;
  15527. }
  15528. } catch (e) {
  15529. if (doNotRecover || this.failOnCorruptedImage) {
  15530. error('JPX Error: ' + e.message);
  15531. } else {
  15532. warn('JPX: Trying to recover from: ' + e.message);
  15533. }
  15534. }
  15535. this.tiles = transformComponents(context);
  15536. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15537. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15538. this.componentsCount = context.SIZ.Csiz;
  15539. }
  15540. };
  15541. function calculateComponentDimensions(component, siz) {
  15542. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15543. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15544. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15545. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15546. component.width = component.x1 - component.x0;
  15547. component.height = component.y1 - component.y0;
  15548. }
  15549. function calculateTileGrids(context, components) {
  15550. var siz = context.SIZ;
  15551. var tile, tiles = [];
  15552. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15553. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15554. for (var q = 0; q < numYtiles; q++) {
  15555. for (var p = 0; p < numXtiles; p++) {
  15556. tile = {};
  15557. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15558. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15559. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15560. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15561. tile.width = tile.tx1 - tile.tx0;
  15562. tile.height = tile.ty1 - tile.ty0;
  15563. tile.components = [];
  15564. tiles.push(tile);
  15565. }
  15566. }
  15567. context.tiles = tiles;
  15568. var componentsCount = siz.Csiz;
  15569. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15570. var component = components[i];
  15571. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15572. var tileComponent = {};
  15573. tile = tiles[j];
  15574. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15575. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15576. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15577. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15578. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15579. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15580. tile.components[i] = tileComponent;
  15581. }
  15582. }
  15583. }
  15584. function getBlocksDimensions(context, component, r) {
  15585. var codOrCoc = component.codingStyleParameters;
  15586. var result = {};
  15587. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15588. result.PPx = 15;
  15589. result.PPy = 15;
  15590. } else {
  15591. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15592. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15593. }
  15594. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15595. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15596. return result;
  15597. }
  15598. function buildPrecincts(context, resolution, dimensions) {
  15599. var precinctWidth = 1 << dimensions.PPx;
  15600. var precinctHeight = 1 << dimensions.PPy;
  15601. var isZeroRes = resolution.resLevel === 0;
  15602. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15603. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15604. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15605. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15606. var numprecincts = numprecinctswide * numprecinctshigh;
  15607. resolution.precinctParameters = {
  15608. precinctWidth: precinctWidth,
  15609. precinctHeight: precinctHeight,
  15610. numprecinctswide: numprecinctswide,
  15611. numprecinctshigh: numprecinctshigh,
  15612. numprecincts: numprecincts,
  15613. precinctWidthInSubband: precinctWidthInSubband,
  15614. precinctHeightInSubband: precinctHeightInSubband
  15615. };
  15616. }
  15617. function buildCodeblocks(context, subband, dimensions) {
  15618. var xcb_ = dimensions.xcb_;
  15619. var ycb_ = dimensions.ycb_;
  15620. var codeblockWidth = 1 << xcb_;
  15621. var codeblockHeight = 1 << ycb_;
  15622. var cbx0 = subband.tbx0 >> xcb_;
  15623. var cby0 = subband.tby0 >> ycb_;
  15624. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15625. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15626. var precinctParameters = subband.resolution.precinctParameters;
  15627. var codeblocks = [];
  15628. var precincts = [];
  15629. var i, j, codeblock, precinctNumber;
  15630. for (j = cby0; j < cby1; j++) {
  15631. for (i = cbx0; i < cbx1; i++) {
  15632. codeblock = {
  15633. cbx: i,
  15634. cby: j,
  15635. tbx0: codeblockWidth * i,
  15636. tby0: codeblockHeight * j,
  15637. tbx1: codeblockWidth * (i + 1),
  15638. tby1: codeblockHeight * (j + 1)
  15639. };
  15640. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15641. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15642. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15643. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15644. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15645. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15646. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15647. codeblock.precinctNumber = precinctNumber;
  15648. codeblock.subbandType = subband.type;
  15649. codeblock.Lblock = 3;
  15650. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15651. continue;
  15652. }
  15653. codeblocks.push(codeblock);
  15654. var precinct = precincts[precinctNumber];
  15655. if (precinct !== undefined) {
  15656. if (i < precinct.cbxMin) {
  15657. precinct.cbxMin = i;
  15658. } else if (i > precinct.cbxMax) {
  15659. precinct.cbxMax = i;
  15660. }
  15661. if (j < precinct.cbyMin) {
  15662. precinct.cbxMin = j;
  15663. } else if (j > precinct.cbyMax) {
  15664. precinct.cbyMax = j;
  15665. }
  15666. } else {
  15667. precincts[precinctNumber] = precinct = {
  15668. cbxMin: i,
  15669. cbyMin: j,
  15670. cbxMax: i,
  15671. cbyMax: j
  15672. };
  15673. }
  15674. codeblock.precinct = precinct;
  15675. }
  15676. }
  15677. subband.codeblockParameters = {
  15678. codeblockWidth: xcb_,
  15679. codeblockHeight: ycb_,
  15680. numcodeblockwide: cbx1 - cbx0 + 1,
  15681. numcodeblockhigh: cby1 - cby0 + 1
  15682. };
  15683. subband.codeblocks = codeblocks;
  15684. subband.precincts = precincts;
  15685. }
  15686. function createPacket(resolution, precinctNumber, layerNumber) {
  15687. var precinctCodeblocks = [];
  15688. var subbands = resolution.subbands;
  15689. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15690. var subband = subbands[i];
  15691. var codeblocks = subband.codeblocks;
  15692. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15693. var codeblock = codeblocks[j];
  15694. if (codeblock.precinctNumber !== precinctNumber) {
  15695. continue;
  15696. }
  15697. precinctCodeblocks.push(codeblock);
  15698. }
  15699. }
  15700. return {
  15701. layerNumber: layerNumber,
  15702. codeblocks: precinctCodeblocks
  15703. };
  15704. }
  15705. function LayerResolutionComponentPositionIterator(context) {
  15706. var siz = context.SIZ;
  15707. var tileIndex = context.currentTile.index;
  15708. var tile = context.tiles[tileIndex];
  15709. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15710. var componentsCount = siz.Csiz;
  15711. var maxDecompositionLevelsCount = 0;
  15712. for (var q = 0; q < componentsCount; q++) {
  15713. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15714. }
  15715. var l = 0, r = 0, i = 0, k = 0;
  15716. this.nextPacket = function JpxImage_nextPacket() {
  15717. for (; l < layersCount; l++) {
  15718. for (; r <= maxDecompositionLevelsCount; r++) {
  15719. for (; i < componentsCount; i++) {
  15720. var component = tile.components[i];
  15721. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15722. continue;
  15723. }
  15724. var resolution = component.resolutions[r];
  15725. var numprecincts = resolution.precinctParameters.numprecincts;
  15726. for (; k < numprecincts;) {
  15727. var packet = createPacket(resolution, k, l);
  15728. k++;
  15729. return packet;
  15730. }
  15731. k = 0;
  15732. }
  15733. i = 0;
  15734. }
  15735. r = 0;
  15736. }
  15737. error('JPX Error: Out of packets');
  15738. };
  15739. }
  15740. function ResolutionLayerComponentPositionIterator(context) {
  15741. var siz = context.SIZ;
  15742. var tileIndex = context.currentTile.index;
  15743. var tile = context.tiles[tileIndex];
  15744. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15745. var componentsCount = siz.Csiz;
  15746. var maxDecompositionLevelsCount = 0;
  15747. for (var q = 0; q < componentsCount; q++) {
  15748. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15749. }
  15750. var r = 0, l = 0, i = 0, k = 0;
  15751. this.nextPacket = function JpxImage_nextPacket() {
  15752. for (; r <= maxDecompositionLevelsCount; r++) {
  15753. for (; l < layersCount; l++) {
  15754. for (; i < componentsCount; i++) {
  15755. var component = tile.components[i];
  15756. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15757. continue;
  15758. }
  15759. var resolution = component.resolutions[r];
  15760. var numprecincts = resolution.precinctParameters.numprecincts;
  15761. for (; k < numprecincts;) {
  15762. var packet = createPacket(resolution, k, l);
  15763. k++;
  15764. return packet;
  15765. }
  15766. k = 0;
  15767. }
  15768. i = 0;
  15769. }
  15770. l = 0;
  15771. }
  15772. error('JPX Error: Out of packets');
  15773. };
  15774. }
  15775. function ResolutionPositionComponentLayerIterator(context) {
  15776. var siz = context.SIZ;
  15777. var tileIndex = context.currentTile.index;
  15778. var tile = context.tiles[tileIndex];
  15779. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15780. var componentsCount = siz.Csiz;
  15781. var l, r, c, p;
  15782. var maxDecompositionLevelsCount = 0;
  15783. for (c = 0; c < componentsCount; c++) {
  15784. var component = tile.components[c];
  15785. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15786. }
  15787. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15788. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15789. var maxNumPrecincts = 0;
  15790. for (c = 0; c < componentsCount; ++c) {
  15791. var resolutions = tile.components[c].resolutions;
  15792. if (r < resolutions.length) {
  15793. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15794. }
  15795. }
  15796. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15797. }
  15798. l = 0;
  15799. r = 0;
  15800. c = 0;
  15801. p = 0;
  15802. this.nextPacket = function JpxImage_nextPacket() {
  15803. for (; r <= maxDecompositionLevelsCount; r++) {
  15804. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15805. for (; c < componentsCount; c++) {
  15806. var component = tile.components[c];
  15807. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15808. continue;
  15809. }
  15810. var resolution = component.resolutions[r];
  15811. var numprecincts = resolution.precinctParameters.numprecincts;
  15812. if (p >= numprecincts) {
  15813. continue;
  15814. }
  15815. for (; l < layersCount;) {
  15816. var packet = createPacket(resolution, p, l);
  15817. l++;
  15818. return packet;
  15819. }
  15820. l = 0;
  15821. }
  15822. c = 0;
  15823. }
  15824. p = 0;
  15825. }
  15826. error('JPX Error: Out of packets');
  15827. };
  15828. }
  15829. function PositionComponentResolutionLayerIterator(context) {
  15830. var siz = context.SIZ;
  15831. var tileIndex = context.currentTile.index;
  15832. var tile = context.tiles[tileIndex];
  15833. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15834. var componentsCount = siz.Csiz;
  15835. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15836. var precinctsIterationSizes = precinctsSizes;
  15837. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15838. this.nextPacket = function JpxImage_nextPacket() {
  15839. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15840. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15841. for (; c < componentsCount; c++) {
  15842. var component = tile.components[c];
  15843. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15844. for (; r <= decompositionLevelsCount; r++) {
  15845. var resolution = component.resolutions[r];
  15846. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15847. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15848. if (k === null) {
  15849. continue;
  15850. }
  15851. for (; l < layersCount;) {
  15852. var packet = createPacket(resolution, k, l);
  15853. l++;
  15854. return packet;
  15855. }
  15856. l = 0;
  15857. }
  15858. r = 0;
  15859. }
  15860. c = 0;
  15861. }
  15862. px = 0;
  15863. }
  15864. error('JPX Error: Out of packets');
  15865. };
  15866. }
  15867. function ComponentPositionResolutionLayerIterator(context) {
  15868. var siz = context.SIZ;
  15869. var tileIndex = context.currentTile.index;
  15870. var tile = context.tiles[tileIndex];
  15871. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15872. var componentsCount = siz.Csiz;
  15873. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15874. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15875. this.nextPacket = function JpxImage_nextPacket() {
  15876. for (; c < componentsCount; ++c) {
  15877. var component = tile.components[c];
  15878. var precinctsIterationSizes = precinctsSizes.components[c];
  15879. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15880. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15881. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15882. for (; r <= decompositionLevelsCount; r++) {
  15883. var resolution = component.resolutions[r];
  15884. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15885. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15886. if (k === null) {
  15887. continue;
  15888. }
  15889. for (; l < layersCount;) {
  15890. var packet = createPacket(resolution, k, l);
  15891. l++;
  15892. return packet;
  15893. }
  15894. l = 0;
  15895. }
  15896. r = 0;
  15897. }
  15898. px = 0;
  15899. }
  15900. py = 0;
  15901. }
  15902. error('JPX Error: Out of packets');
  15903. };
  15904. }
  15905. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15906. var posX = pxIndex * precinctIterationSizes.minWidth;
  15907. var posY = pyIndex * precinctIterationSizes.minHeight;
  15908. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15909. return null;
  15910. }
  15911. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15912. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15913. }
  15914. function getPrecinctSizesInImageScale(tile) {
  15915. var componentsCount = tile.components.length;
  15916. var minWidth = Number.MAX_VALUE;
  15917. var minHeight = Number.MAX_VALUE;
  15918. var maxNumWide = 0;
  15919. var maxNumHigh = 0;
  15920. var sizePerComponent = new Array(componentsCount);
  15921. for (var c = 0; c < componentsCount; c++) {
  15922. var component = tile.components[c];
  15923. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15924. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15925. var minWidthCurrentComponent = Number.MAX_VALUE;
  15926. var minHeightCurrentComponent = Number.MAX_VALUE;
  15927. var maxNumWideCurrentComponent = 0;
  15928. var maxNumHighCurrentComponent = 0;
  15929. var scale = 1;
  15930. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15931. var resolution = component.resolutions[r];
  15932. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15933. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15934. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15935. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15936. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15937. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15938. sizePerResolution[r] = {
  15939. width: widthCurrentResolution,
  15940. height: heightCurrentResolution
  15941. };
  15942. scale <<= 1;
  15943. }
  15944. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15945. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15946. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15947. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15948. sizePerComponent[c] = {
  15949. resolutions: sizePerResolution,
  15950. minWidth: minWidthCurrentComponent,
  15951. minHeight: minHeightCurrentComponent,
  15952. maxNumWide: maxNumWideCurrentComponent,
  15953. maxNumHigh: maxNumHighCurrentComponent
  15954. };
  15955. }
  15956. return {
  15957. components: sizePerComponent,
  15958. minWidth: minWidth,
  15959. minHeight: minHeight,
  15960. maxNumWide: maxNumWide,
  15961. maxNumHigh: maxNumHigh
  15962. };
  15963. }
  15964. function buildPackets(context) {
  15965. var siz = context.SIZ;
  15966. var tileIndex = context.currentTile.index;
  15967. var tile = context.tiles[tileIndex];
  15968. var componentsCount = siz.Csiz;
  15969. for (var c = 0; c < componentsCount; c++) {
  15970. var component = tile.components[c];
  15971. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15972. var resolutions = [];
  15973. var subbands = [];
  15974. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15975. var blocksDimensions = getBlocksDimensions(context, component, r);
  15976. var resolution = {};
  15977. var scale = 1 << decompositionLevelsCount - r;
  15978. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15979. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15980. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15981. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15982. resolution.resLevel = r;
  15983. buildPrecincts(context, resolution, blocksDimensions);
  15984. resolutions.push(resolution);
  15985. var subband;
  15986. if (r === 0) {
  15987. subband = {};
  15988. subband.type = 'LL';
  15989. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15990. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15991. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15992. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15993. subband.resolution = resolution;
  15994. buildCodeblocks(context, subband, blocksDimensions);
  15995. subbands.push(subband);
  15996. resolution.subbands = [subband];
  15997. } else {
  15998. var bscale = 1 << decompositionLevelsCount - r + 1;
  15999. var resolutionSubbands = [];
  16000. subband = {};
  16001. subband.type = 'HL';
  16002. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16003. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  16004. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16005. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  16006. subband.resolution = resolution;
  16007. buildCodeblocks(context, subband, blocksDimensions);
  16008. subbands.push(subband);
  16009. resolutionSubbands.push(subband);
  16010. subband = {};
  16011. subband.type = 'LH';
  16012. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  16013. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16014. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  16015. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16016. subband.resolution = resolution;
  16017. buildCodeblocks(context, subband, blocksDimensions);
  16018. subbands.push(subband);
  16019. resolutionSubbands.push(subband);
  16020. subband = {};
  16021. subband.type = 'HH';
  16022. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16023. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16024. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16025. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16026. subband.resolution = resolution;
  16027. buildCodeblocks(context, subband, blocksDimensions);
  16028. subbands.push(subband);
  16029. resolutionSubbands.push(subband);
  16030. resolution.subbands = resolutionSubbands;
  16031. }
  16032. }
  16033. component.resolutions = resolutions;
  16034. component.subbands = subbands;
  16035. }
  16036. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  16037. switch (progressionOrder) {
  16038. case 0:
  16039. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  16040. break;
  16041. case 1:
  16042. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  16043. break;
  16044. case 2:
  16045. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  16046. break;
  16047. case 3:
  16048. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  16049. break;
  16050. case 4:
  16051. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  16052. break;
  16053. default:
  16054. error('JPX Error: Unsupported progression order ' + progressionOrder);
  16055. }
  16056. }
  16057. function parseTilePackets(context, data, offset, dataLength) {
  16058. var position = 0;
  16059. var buffer, bufferSize = 0, skipNextBit = false;
  16060. function readBits(count) {
  16061. while (bufferSize < count) {
  16062. var b = data[offset + position];
  16063. position++;
  16064. if (skipNextBit) {
  16065. buffer = buffer << 7 | b;
  16066. bufferSize += 7;
  16067. skipNextBit = false;
  16068. } else {
  16069. buffer = buffer << 8 | b;
  16070. bufferSize += 8;
  16071. }
  16072. if (b === 0xFF) {
  16073. skipNextBit = true;
  16074. }
  16075. }
  16076. bufferSize -= count;
  16077. return buffer >>> bufferSize & (1 << count) - 1;
  16078. }
  16079. function skipMarkerIfEqual(value) {
  16080. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  16081. skipBytes(1);
  16082. return true;
  16083. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  16084. skipBytes(2);
  16085. return true;
  16086. }
  16087. return false;
  16088. }
  16089. function skipBytes(count) {
  16090. position += count;
  16091. }
  16092. function alignToByte() {
  16093. bufferSize = 0;
  16094. if (skipNextBit) {
  16095. position++;
  16096. skipNextBit = false;
  16097. }
  16098. }
  16099. function readCodingpasses() {
  16100. if (readBits(1) === 0) {
  16101. return 1;
  16102. }
  16103. if (readBits(1) === 0) {
  16104. return 2;
  16105. }
  16106. var value = readBits(2);
  16107. if (value < 3) {
  16108. return value + 3;
  16109. }
  16110. value = readBits(5);
  16111. if (value < 31) {
  16112. return value + 6;
  16113. }
  16114. value = readBits(7);
  16115. return value + 37;
  16116. }
  16117. var tileIndex = context.currentTile.index;
  16118. var tile = context.tiles[tileIndex];
  16119. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16120. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16121. var packetsIterator = tile.packetsIterator;
  16122. while (position < dataLength) {
  16123. alignToByte();
  16124. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16125. skipBytes(4);
  16126. }
  16127. var packet = packetsIterator.nextPacket();
  16128. if (!readBits(1)) {
  16129. continue;
  16130. }
  16131. var layerNumber = packet.layerNumber;
  16132. var queue = [], codeblock;
  16133. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16134. codeblock = packet.codeblocks[i];
  16135. var precinct = codeblock.precinct;
  16136. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16137. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16138. var codeblockIncluded = false;
  16139. var firstTimeInclusion = false;
  16140. var valueReady;
  16141. if (codeblock['included'] !== undefined) {
  16142. codeblockIncluded = !!readBits(1);
  16143. } else {
  16144. precinct = codeblock.precinct;
  16145. var inclusionTree, zeroBitPlanesTree;
  16146. if (precinct['inclusionTree'] !== undefined) {
  16147. inclusionTree = precinct.inclusionTree;
  16148. } else {
  16149. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16150. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16151. inclusionTree = new InclusionTree(width, height, layerNumber);
  16152. zeroBitPlanesTree = new TagTree(width, height);
  16153. precinct.inclusionTree = inclusionTree;
  16154. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16155. }
  16156. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16157. while (true) {
  16158. if (readBits(1)) {
  16159. valueReady = !inclusionTree.nextLevel();
  16160. if (valueReady) {
  16161. codeblock.included = true;
  16162. codeblockIncluded = firstTimeInclusion = true;
  16163. break;
  16164. }
  16165. } else {
  16166. inclusionTree.incrementValue(layerNumber);
  16167. break;
  16168. }
  16169. }
  16170. }
  16171. }
  16172. if (!codeblockIncluded) {
  16173. continue;
  16174. }
  16175. if (firstTimeInclusion) {
  16176. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16177. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16178. while (true) {
  16179. if (readBits(1)) {
  16180. valueReady = !zeroBitPlanesTree.nextLevel();
  16181. if (valueReady) {
  16182. break;
  16183. }
  16184. } else {
  16185. zeroBitPlanesTree.incrementValue();
  16186. }
  16187. }
  16188. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16189. }
  16190. var codingpasses = readCodingpasses();
  16191. while (readBits(1)) {
  16192. codeblock.Lblock++;
  16193. }
  16194. var codingpassesLog2 = log2(codingpasses);
  16195. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16196. var codedDataLength = readBits(bits);
  16197. queue.push({
  16198. codeblock: codeblock,
  16199. codingpasses: codingpasses,
  16200. dataLength: codedDataLength
  16201. });
  16202. }
  16203. alignToByte();
  16204. if (ephMarkerUsed) {
  16205. skipMarkerIfEqual(0x92);
  16206. }
  16207. while (queue.length > 0) {
  16208. var packetItem = queue.shift();
  16209. codeblock = packetItem.codeblock;
  16210. if (codeblock['data'] === undefined) {
  16211. codeblock.data = [];
  16212. }
  16213. codeblock.data.push({
  16214. data: data,
  16215. start: offset + position,
  16216. end: offset + position + packetItem.dataLength,
  16217. codingpasses: packetItem.codingpasses
  16218. });
  16219. position += packetItem.dataLength;
  16220. }
  16221. }
  16222. return position;
  16223. }
  16224. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16225. var x0 = subband.tbx0;
  16226. var y0 = subband.tby0;
  16227. var width = subband.tbx1 - subband.tbx0;
  16228. var codeblocks = subband.codeblocks;
  16229. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16230. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16231. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16232. var codeblock = codeblocks[i];
  16233. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16234. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16235. if (blockWidth === 0 || blockHeight === 0) {
  16236. continue;
  16237. }
  16238. if (codeblock['data'] === undefined) {
  16239. continue;
  16240. }
  16241. var bitModel, currentCodingpassType;
  16242. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16243. currentCodingpassType = 2;
  16244. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16245. var j, jj, dataItem;
  16246. for (j = 0, jj = data.length; j < jj; j++) {
  16247. dataItem = data[j];
  16248. totalLength += dataItem.end - dataItem.start;
  16249. codingpasses += dataItem.codingpasses;
  16250. }
  16251. var encodedData = new Uint8Array(totalLength);
  16252. var position = 0;
  16253. for (j = 0, jj = data.length; j < jj; j++) {
  16254. dataItem = data[j];
  16255. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16256. encodedData.set(chunk, position);
  16257. position += chunk.length;
  16258. }
  16259. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16260. bitModel.setDecoder(decoder);
  16261. for (j = 0; j < codingpasses; j++) {
  16262. switch (currentCodingpassType) {
  16263. case 0:
  16264. bitModel.runSignificancePropagationPass();
  16265. break;
  16266. case 1:
  16267. bitModel.runMagnitudeRefinementPass();
  16268. break;
  16269. case 2:
  16270. bitModel.runCleanupPass();
  16271. if (segmentationSymbolUsed) {
  16272. bitModel.checkSegmentationSymbol();
  16273. }
  16274. break;
  16275. }
  16276. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16277. }
  16278. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16279. var sign = bitModel.coefficentsSign;
  16280. var magnitude = bitModel.coefficentsMagnitude;
  16281. var bitsDecoded = bitModel.bitsDecoded;
  16282. var magnitudeCorrection = reversible ? 0 : 0.5;
  16283. var k, n, nb;
  16284. position = 0;
  16285. var interleave = subband.type !== 'LL';
  16286. for (j = 0; j < blockHeight; j++) {
  16287. var row = offset / width | 0;
  16288. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16289. for (k = 0; k < blockWidth; k++) {
  16290. n = magnitude[position];
  16291. if (n !== 0) {
  16292. n = (n + magnitudeCorrection) * delta;
  16293. if (sign[position] !== 0) {
  16294. n = -n;
  16295. }
  16296. nb = bitsDecoded[position];
  16297. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16298. if (reversible && nb >= mb) {
  16299. coefficients[pos] = n;
  16300. } else {
  16301. coefficients[pos] = n * (1 << mb - nb);
  16302. }
  16303. }
  16304. offset++;
  16305. position++;
  16306. }
  16307. offset += width - blockWidth;
  16308. }
  16309. }
  16310. }
  16311. function transformTile(context, tile, c) {
  16312. var component = tile.components[c];
  16313. var codingStyleParameters = component.codingStyleParameters;
  16314. var quantizationParameters = component.quantizationParameters;
  16315. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16316. var spqcds = quantizationParameters.SPqcds;
  16317. var scalarExpounded = quantizationParameters.scalarExpounded;
  16318. var guardBits = quantizationParameters.guardBits;
  16319. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16320. var precision = context.components[c].precision;
  16321. var reversible = codingStyleParameters.reversibleTransformation;
  16322. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16323. var subbandCoefficients = [];
  16324. var b = 0;
  16325. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16326. var resolution = component.resolutions[i];
  16327. var width = resolution.trx1 - resolution.trx0;
  16328. var height = resolution.try1 - resolution.try0;
  16329. var coefficients = new Float32Array(width * height);
  16330. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16331. var mu, epsilon;
  16332. if (!scalarExpounded) {
  16333. mu = spqcds[0].mu;
  16334. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16335. } else {
  16336. mu = spqcds[b].mu;
  16337. epsilon = spqcds[b].epsilon;
  16338. b++;
  16339. }
  16340. var subband = resolution.subbands[j];
  16341. var gainLog2 = SubbandsGainLog2[subband.type];
  16342. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16343. var mb = guardBits + epsilon - 1;
  16344. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16345. }
  16346. subbandCoefficients.push({
  16347. width: width,
  16348. height: height,
  16349. items: coefficients
  16350. });
  16351. }
  16352. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16353. return {
  16354. left: component.tcx0,
  16355. top: component.tcy0,
  16356. width: result.width,
  16357. height: result.height,
  16358. items: result.items
  16359. };
  16360. }
  16361. function transformComponents(context) {
  16362. var siz = context.SIZ;
  16363. var components = context.components;
  16364. var componentsCount = siz.Csiz;
  16365. var resultImages = [];
  16366. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16367. var tile = context.tiles[i];
  16368. var transformedTiles = [];
  16369. var c;
  16370. for (c = 0; c < componentsCount; c++) {
  16371. transformedTiles[c] = transformTile(context, tile, c);
  16372. }
  16373. var tile0 = transformedTiles[0];
  16374. var out = new Uint8Array(tile0.items.length * componentsCount);
  16375. var result = {
  16376. left: tile0.left,
  16377. top: tile0.top,
  16378. width: tile0.width,
  16379. height: tile0.height,
  16380. items: out
  16381. };
  16382. var shift, offset, max, min, maxK;
  16383. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16384. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16385. var fourComponents = componentsCount === 4;
  16386. var y0items = transformedTiles[0].items;
  16387. var y1items = transformedTiles[1].items;
  16388. var y2items = transformedTiles[2].items;
  16389. var y3items = fourComponents ? transformedTiles[3].items : null;
  16390. shift = components[0].precision - 8;
  16391. offset = (128 << shift) + 0.5;
  16392. max = 255 * (1 << shift);
  16393. maxK = max * 0.5;
  16394. min = -maxK;
  16395. var component0 = tile.components[0];
  16396. var alpha01 = componentsCount - 3;
  16397. jj = y0items.length;
  16398. if (!component0.codingStyleParameters.reversibleTransformation) {
  16399. for (j = 0; j < jj; j++, pos += alpha01) {
  16400. y0 = y0items[j] + offset;
  16401. y1 = y1items[j];
  16402. y2 = y2items[j];
  16403. r = y0 + 1.402 * y2;
  16404. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16405. b = y0 + 1.772 * y1;
  16406. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16407. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16408. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16409. }
  16410. } else {
  16411. for (j = 0; j < jj; j++, pos += alpha01) {
  16412. y0 = y0items[j] + offset;
  16413. y1 = y1items[j];
  16414. y2 = y2items[j];
  16415. g = y0 - (y2 + y1 >> 2);
  16416. r = g + y2;
  16417. b = g + y1;
  16418. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16419. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16420. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16421. }
  16422. }
  16423. if (fourComponents) {
  16424. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16425. k = y3items[j];
  16426. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16427. }
  16428. }
  16429. } else {
  16430. for (c = 0; c < componentsCount; c++) {
  16431. var items = transformedTiles[c].items;
  16432. shift = components[c].precision - 8;
  16433. offset = (128 << shift) + 0.5;
  16434. max = 127.5 * (1 << shift);
  16435. min = -max;
  16436. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16437. val = items[j];
  16438. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16439. pos += componentsCount;
  16440. }
  16441. }
  16442. }
  16443. resultImages.push(result);
  16444. }
  16445. return resultImages;
  16446. }
  16447. function initializeTile(context, tileIndex) {
  16448. var siz = context.SIZ;
  16449. var componentsCount = siz.Csiz;
  16450. var tile = context.tiles[tileIndex];
  16451. for (var c = 0; c < componentsCount; c++) {
  16452. var component = tile.components[c];
  16453. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16454. component.quantizationParameters = qcdOrQcc;
  16455. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16456. component.codingStyleParameters = codOrCoc;
  16457. }
  16458. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16459. }
  16460. var TagTree = function TagTreeClosure() {
  16461. function TagTree(width, height) {
  16462. var levelsLength = log2(Math.max(width, height)) + 1;
  16463. this.levels = [];
  16464. for (var i = 0; i < levelsLength; i++) {
  16465. var level = {
  16466. width: width,
  16467. height: height,
  16468. items: []
  16469. };
  16470. this.levels.push(level);
  16471. width = Math.ceil(width / 2);
  16472. height = Math.ceil(height / 2);
  16473. }
  16474. }
  16475. TagTree.prototype = {
  16476. reset: function TagTree_reset(i, j) {
  16477. var currentLevel = 0, value = 0, level;
  16478. while (currentLevel < this.levels.length) {
  16479. level = this.levels[currentLevel];
  16480. var index = i + j * level.width;
  16481. if (level.items[index] !== undefined) {
  16482. value = level.items[index];
  16483. break;
  16484. }
  16485. level.index = index;
  16486. i >>= 1;
  16487. j >>= 1;
  16488. currentLevel++;
  16489. }
  16490. currentLevel--;
  16491. level = this.levels[currentLevel];
  16492. level.items[level.index] = value;
  16493. this.currentLevel = currentLevel;
  16494. delete this.value;
  16495. },
  16496. incrementValue: function TagTree_incrementValue() {
  16497. var level = this.levels[this.currentLevel];
  16498. level.items[level.index]++;
  16499. },
  16500. nextLevel: function TagTree_nextLevel() {
  16501. var currentLevel = this.currentLevel;
  16502. var level = this.levels[currentLevel];
  16503. var value = level.items[level.index];
  16504. currentLevel--;
  16505. if (currentLevel < 0) {
  16506. this.value = value;
  16507. return false;
  16508. }
  16509. this.currentLevel = currentLevel;
  16510. level = this.levels[currentLevel];
  16511. level.items[level.index] = value;
  16512. return true;
  16513. }
  16514. };
  16515. return TagTree;
  16516. }();
  16517. var InclusionTree = function InclusionTreeClosure() {
  16518. function InclusionTree(width, height, defaultValue) {
  16519. var levelsLength = log2(Math.max(width, height)) + 1;
  16520. this.levels = [];
  16521. for (var i = 0; i < levelsLength; i++) {
  16522. var items = new Uint8Array(width * height);
  16523. for (var j = 0, jj = items.length; j < jj; j++) {
  16524. items[j] = defaultValue;
  16525. }
  16526. var level = {
  16527. width: width,
  16528. height: height,
  16529. items: items
  16530. };
  16531. this.levels.push(level);
  16532. width = Math.ceil(width / 2);
  16533. height = Math.ceil(height / 2);
  16534. }
  16535. }
  16536. InclusionTree.prototype = {
  16537. reset: function InclusionTree_reset(i, j, stopValue) {
  16538. var currentLevel = 0;
  16539. while (currentLevel < this.levels.length) {
  16540. var level = this.levels[currentLevel];
  16541. var index = i + j * level.width;
  16542. level.index = index;
  16543. var value = level.items[index];
  16544. if (value === 0xFF) {
  16545. break;
  16546. }
  16547. if (value > stopValue) {
  16548. this.currentLevel = currentLevel;
  16549. this.propagateValues();
  16550. return false;
  16551. }
  16552. i >>= 1;
  16553. j >>= 1;
  16554. currentLevel++;
  16555. }
  16556. this.currentLevel = currentLevel - 1;
  16557. return true;
  16558. },
  16559. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16560. var level = this.levels[this.currentLevel];
  16561. level.items[level.index] = stopValue + 1;
  16562. this.propagateValues();
  16563. },
  16564. propagateValues: function InclusionTree_propagateValues() {
  16565. var levelIndex = this.currentLevel;
  16566. var level = this.levels[levelIndex];
  16567. var currentValue = level.items[level.index];
  16568. while (--levelIndex >= 0) {
  16569. level = this.levels[levelIndex];
  16570. level.items[level.index] = currentValue;
  16571. }
  16572. },
  16573. nextLevel: function InclusionTree_nextLevel() {
  16574. var currentLevel = this.currentLevel;
  16575. var level = this.levels[currentLevel];
  16576. var value = level.items[level.index];
  16577. level.items[level.index] = 0xFF;
  16578. currentLevel--;
  16579. if (currentLevel < 0) {
  16580. return false;
  16581. }
  16582. this.currentLevel = currentLevel;
  16583. level = this.levels[currentLevel];
  16584. level.items[level.index] = value;
  16585. return true;
  16586. }
  16587. };
  16588. return InclusionTree;
  16589. }();
  16590. var BitModel = function BitModelClosure() {
  16591. var UNIFORM_CONTEXT = 17;
  16592. var RUNLENGTH_CONTEXT = 18;
  16593. var LLAndLHContextsLabel = new Uint8Array([
  16594. 0,
  16595. 5,
  16596. 8,
  16597. 0,
  16598. 3,
  16599. 7,
  16600. 8,
  16601. 0,
  16602. 4,
  16603. 7,
  16604. 8,
  16605. 0,
  16606. 0,
  16607. 0,
  16608. 0,
  16609. 0,
  16610. 1,
  16611. 6,
  16612. 8,
  16613. 0,
  16614. 3,
  16615. 7,
  16616. 8,
  16617. 0,
  16618. 4,
  16619. 7,
  16620. 8,
  16621. 0,
  16622. 0,
  16623. 0,
  16624. 0,
  16625. 0,
  16626. 2,
  16627. 6,
  16628. 8,
  16629. 0,
  16630. 3,
  16631. 7,
  16632. 8,
  16633. 0,
  16634. 4,
  16635. 7,
  16636. 8,
  16637. 0,
  16638. 0,
  16639. 0,
  16640. 0,
  16641. 0,
  16642. 2,
  16643. 6,
  16644. 8,
  16645. 0,
  16646. 3,
  16647. 7,
  16648. 8,
  16649. 0,
  16650. 4,
  16651. 7,
  16652. 8,
  16653. 0,
  16654. 0,
  16655. 0,
  16656. 0,
  16657. 0,
  16658. 2,
  16659. 6,
  16660. 8,
  16661. 0,
  16662. 3,
  16663. 7,
  16664. 8,
  16665. 0,
  16666. 4,
  16667. 7,
  16668. 8
  16669. ]);
  16670. var HLContextLabel = new Uint8Array([
  16671. 0,
  16672. 3,
  16673. 4,
  16674. 0,
  16675. 5,
  16676. 7,
  16677. 7,
  16678. 0,
  16679. 8,
  16680. 8,
  16681. 8,
  16682. 0,
  16683. 0,
  16684. 0,
  16685. 0,
  16686. 0,
  16687. 1,
  16688. 3,
  16689. 4,
  16690. 0,
  16691. 6,
  16692. 7,
  16693. 7,
  16694. 0,
  16695. 8,
  16696. 8,
  16697. 8,
  16698. 0,
  16699. 0,
  16700. 0,
  16701. 0,
  16702. 0,
  16703. 2,
  16704. 3,
  16705. 4,
  16706. 0,
  16707. 6,
  16708. 7,
  16709. 7,
  16710. 0,
  16711. 8,
  16712. 8,
  16713. 8,
  16714. 0,
  16715. 0,
  16716. 0,
  16717. 0,
  16718. 0,
  16719. 2,
  16720. 3,
  16721. 4,
  16722. 0,
  16723. 6,
  16724. 7,
  16725. 7,
  16726. 0,
  16727. 8,
  16728. 8,
  16729. 8,
  16730. 0,
  16731. 0,
  16732. 0,
  16733. 0,
  16734. 0,
  16735. 2,
  16736. 3,
  16737. 4,
  16738. 0,
  16739. 6,
  16740. 7,
  16741. 7,
  16742. 0,
  16743. 8,
  16744. 8,
  16745. 8
  16746. ]);
  16747. var HHContextLabel = new Uint8Array([
  16748. 0,
  16749. 1,
  16750. 2,
  16751. 0,
  16752. 1,
  16753. 2,
  16754. 2,
  16755. 0,
  16756. 2,
  16757. 2,
  16758. 2,
  16759. 0,
  16760. 0,
  16761. 0,
  16762. 0,
  16763. 0,
  16764. 3,
  16765. 4,
  16766. 5,
  16767. 0,
  16768. 4,
  16769. 5,
  16770. 5,
  16771. 0,
  16772. 5,
  16773. 5,
  16774. 5,
  16775. 0,
  16776. 0,
  16777. 0,
  16778. 0,
  16779. 0,
  16780. 6,
  16781. 7,
  16782. 7,
  16783. 0,
  16784. 7,
  16785. 7,
  16786. 7,
  16787. 0,
  16788. 7,
  16789. 7,
  16790. 7,
  16791. 0,
  16792. 0,
  16793. 0,
  16794. 0,
  16795. 0,
  16796. 8,
  16797. 8,
  16798. 8,
  16799. 0,
  16800. 8,
  16801. 8,
  16802. 8,
  16803. 0,
  16804. 8,
  16805. 8,
  16806. 8,
  16807. 0,
  16808. 0,
  16809. 0,
  16810. 0,
  16811. 0,
  16812. 8,
  16813. 8,
  16814. 8,
  16815. 0,
  16816. 8,
  16817. 8,
  16818. 8,
  16819. 0,
  16820. 8,
  16821. 8,
  16822. 8
  16823. ]);
  16824. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16825. this.width = width;
  16826. this.height = height;
  16827. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16828. var coefficientCount = width * height;
  16829. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16830. this.coefficentsSign = new Uint8Array(coefficientCount);
  16831. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16832. this.processingFlags = new Uint8Array(coefficientCount);
  16833. var bitsDecoded = new Uint8Array(coefficientCount);
  16834. if (zeroBitPlanes !== 0) {
  16835. for (var i = 0; i < coefficientCount; i++) {
  16836. bitsDecoded[i] = zeroBitPlanes;
  16837. }
  16838. }
  16839. this.bitsDecoded = bitsDecoded;
  16840. this.reset();
  16841. }
  16842. BitModel.prototype = {
  16843. setDecoder: function BitModel_setDecoder(decoder) {
  16844. this.decoder = decoder;
  16845. },
  16846. reset: function BitModel_reset() {
  16847. this.contexts = new Int8Array(19);
  16848. this.contexts[0] = 4 << 1 | 0;
  16849. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16850. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16851. },
  16852. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16853. var neighborsSignificance = this.neighborsSignificance;
  16854. var width = this.width, height = this.height;
  16855. var left = column > 0;
  16856. var right = column + 1 < width;
  16857. var i;
  16858. if (row > 0) {
  16859. i = index - width;
  16860. if (left) {
  16861. neighborsSignificance[i - 1] += 0x10;
  16862. }
  16863. if (right) {
  16864. neighborsSignificance[i + 1] += 0x10;
  16865. }
  16866. neighborsSignificance[i] += 0x04;
  16867. }
  16868. if (row + 1 < height) {
  16869. i = index + width;
  16870. if (left) {
  16871. neighborsSignificance[i - 1] += 0x10;
  16872. }
  16873. if (right) {
  16874. neighborsSignificance[i + 1] += 0x10;
  16875. }
  16876. neighborsSignificance[i] += 0x04;
  16877. }
  16878. if (left) {
  16879. neighborsSignificance[index - 1] += 0x01;
  16880. }
  16881. if (right) {
  16882. neighborsSignificance[index + 1] += 0x01;
  16883. }
  16884. neighborsSignificance[index] |= 0x80;
  16885. },
  16886. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16887. var decoder = this.decoder;
  16888. var width = this.width, height = this.height;
  16889. var coefficentsMagnitude = this.coefficentsMagnitude;
  16890. var coefficentsSign = this.coefficentsSign;
  16891. var neighborsSignificance = this.neighborsSignificance;
  16892. var processingFlags = this.processingFlags;
  16893. var contexts = this.contexts;
  16894. var labels = this.contextLabelTable;
  16895. var bitsDecoded = this.bitsDecoded;
  16896. var processedInverseMask = ~1;
  16897. var processedMask = 1;
  16898. var firstMagnitudeBitMask = 2;
  16899. for (var i0 = 0; i0 < height; i0 += 4) {
  16900. for (var j = 0; j < width; j++) {
  16901. var index = i0 * width + j;
  16902. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16903. var i = i0 + i1;
  16904. if (i >= height) {
  16905. break;
  16906. }
  16907. processingFlags[index] &= processedInverseMask;
  16908. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16909. continue;
  16910. }
  16911. var contextLabel = labels[neighborsSignificance[index]];
  16912. var decision = decoder.readBit(contexts, contextLabel);
  16913. if (decision) {
  16914. var sign = this.decodeSignBit(i, j, index);
  16915. coefficentsSign[index] = sign;
  16916. coefficentsMagnitude[index] = 1;
  16917. this.setNeighborsSignificance(i, j, index);
  16918. processingFlags[index] |= firstMagnitudeBitMask;
  16919. }
  16920. bitsDecoded[index]++;
  16921. processingFlags[index] |= processedMask;
  16922. }
  16923. }
  16924. }
  16925. },
  16926. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16927. var width = this.width, height = this.height;
  16928. var coefficentsMagnitude = this.coefficentsMagnitude;
  16929. var coefficentsSign = this.coefficentsSign;
  16930. var contribution, sign0, sign1, significance1;
  16931. var contextLabel, decoded;
  16932. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16933. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16934. sign1 = coefficentsSign[index + 1];
  16935. if (significance1) {
  16936. sign0 = coefficentsSign[index - 1];
  16937. contribution = 1 - sign1 - sign0;
  16938. } else {
  16939. contribution = 1 - sign1 - sign1;
  16940. }
  16941. } else if (significance1) {
  16942. sign0 = coefficentsSign[index - 1];
  16943. contribution = 1 - sign0 - sign0;
  16944. } else {
  16945. contribution = 0;
  16946. }
  16947. var horizontalContribution = 3 * contribution;
  16948. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16949. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16950. sign1 = coefficentsSign[index + width];
  16951. if (significance1) {
  16952. sign0 = coefficentsSign[index - width];
  16953. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16954. } else {
  16955. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16956. }
  16957. } else if (significance1) {
  16958. sign0 = coefficentsSign[index - width];
  16959. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16960. } else {
  16961. contribution = horizontalContribution;
  16962. }
  16963. if (contribution >= 0) {
  16964. contextLabel = 9 + contribution;
  16965. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16966. } else {
  16967. contextLabel = 9 - contribution;
  16968. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16969. }
  16970. return decoded;
  16971. },
  16972. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16973. var decoder = this.decoder;
  16974. var width = this.width, height = this.height;
  16975. var coefficentsMagnitude = this.coefficentsMagnitude;
  16976. var neighborsSignificance = this.neighborsSignificance;
  16977. var contexts = this.contexts;
  16978. var bitsDecoded = this.bitsDecoded;
  16979. var processingFlags = this.processingFlags;
  16980. var processedMask = 1;
  16981. var firstMagnitudeBitMask = 2;
  16982. var length = width * height;
  16983. var width4 = width * 4;
  16984. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16985. indexNext = Math.min(length, index0 + width4);
  16986. for (var j = 0; j < width; j++) {
  16987. for (var index = index0 + j; index < indexNext; index += width) {
  16988. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16989. continue;
  16990. }
  16991. var contextLabel = 16;
  16992. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16993. processingFlags[index] ^= firstMagnitudeBitMask;
  16994. var significance = neighborsSignificance[index] & 127;
  16995. contextLabel = significance === 0 ? 15 : 14;
  16996. }
  16997. var bit = decoder.readBit(contexts, contextLabel);
  16998. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16999. bitsDecoded[index]++;
  17000. processingFlags[index] |= processedMask;
  17001. }
  17002. }
  17003. }
  17004. },
  17005. runCleanupPass: function BitModel_runCleanupPass() {
  17006. var decoder = this.decoder;
  17007. var width = this.width, height = this.height;
  17008. var neighborsSignificance = this.neighborsSignificance;
  17009. var coefficentsMagnitude = this.coefficentsMagnitude;
  17010. var coefficentsSign = this.coefficentsSign;
  17011. var contexts = this.contexts;
  17012. var labels = this.contextLabelTable;
  17013. var bitsDecoded = this.bitsDecoded;
  17014. var processingFlags = this.processingFlags;
  17015. var processedMask = 1;
  17016. var firstMagnitudeBitMask = 2;
  17017. var oneRowDown = width;
  17018. var twoRowsDown = width * 2;
  17019. var threeRowsDown = width * 3;
  17020. var iNext;
  17021. for (var i0 = 0; i0 < height; i0 = iNext) {
  17022. iNext = Math.min(i0 + 4, height);
  17023. var indexBase = i0 * width;
  17024. var checkAllEmpty = i0 + 3 < height;
  17025. for (var j = 0; j < width; j++) {
  17026. var index0 = indexBase + j;
  17027. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  17028. var i1 = 0, index = index0;
  17029. var i = i0, sign;
  17030. if (allEmpty) {
  17031. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  17032. if (!hasSignificantCoefficent) {
  17033. bitsDecoded[index0]++;
  17034. bitsDecoded[index0 + oneRowDown]++;
  17035. bitsDecoded[index0 + twoRowsDown]++;
  17036. bitsDecoded[index0 + threeRowsDown]++;
  17037. continue;
  17038. }
  17039. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17040. if (i1 !== 0) {
  17041. i = i0 + i1;
  17042. index += i1 * width;
  17043. }
  17044. sign = this.decodeSignBit(i, j, index);
  17045. coefficentsSign[index] = sign;
  17046. coefficentsMagnitude[index] = 1;
  17047. this.setNeighborsSignificance(i, j, index);
  17048. processingFlags[index] |= firstMagnitudeBitMask;
  17049. index = index0;
  17050. for (var i2 = i0; i2 <= i; i2++, index += width) {
  17051. bitsDecoded[index]++;
  17052. }
  17053. i1++;
  17054. }
  17055. for (i = i0 + i1; i < iNext; i++, index += width) {
  17056. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  17057. continue;
  17058. }
  17059. var contextLabel = labels[neighborsSignificance[index]];
  17060. var decision = decoder.readBit(contexts, contextLabel);
  17061. if (decision === 1) {
  17062. sign = this.decodeSignBit(i, j, index);
  17063. coefficentsSign[index] = sign;
  17064. coefficentsMagnitude[index] = 1;
  17065. this.setNeighborsSignificance(i, j, index);
  17066. processingFlags[index] |= firstMagnitudeBitMask;
  17067. }
  17068. bitsDecoded[index]++;
  17069. }
  17070. }
  17071. }
  17072. },
  17073. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  17074. var decoder = this.decoder;
  17075. var contexts = this.contexts;
  17076. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17077. if (symbol !== 0xA) {
  17078. error('JPX Error: Invalid segmentation symbol');
  17079. }
  17080. }
  17081. };
  17082. return BitModel;
  17083. }();
  17084. var Transform = function TransformClosure() {
  17085. function Transform() {
  17086. }
  17087. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  17088. var ll = subbands[0];
  17089. for (var i = 1, ii = subbands.length; i < ii; i++) {
  17090. ll = this.iterate(ll, subbands[i], u0, v0);
  17091. }
  17092. return ll;
  17093. };
  17094. Transform.prototype.extend = function extend(buffer, offset, size) {
  17095. var i1 = offset - 1, j1 = offset + 1;
  17096. var i2 = offset + size - 2, j2 = offset + size;
  17097. buffer[i1--] = buffer[j1++];
  17098. buffer[j2++] = buffer[i2--];
  17099. buffer[i1--] = buffer[j1++];
  17100. buffer[j2++] = buffer[i2--];
  17101. buffer[i1--] = buffer[j1++];
  17102. buffer[j2++] = buffer[i2--];
  17103. buffer[i1] = buffer[j1];
  17104. buffer[j2] = buffer[i2];
  17105. };
  17106. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  17107. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  17108. var width = hl_lh_hh.width;
  17109. var height = hl_lh_hh.height;
  17110. var items = hl_lh_hh.items;
  17111. var i, j, k, l, u, v;
  17112. for (k = 0, i = 0; i < llHeight; i++) {
  17113. l = i * 2 * width;
  17114. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17115. items[l] = llItems[k];
  17116. }
  17117. }
  17118. llItems = ll.items = null;
  17119. var bufferPadding = 4;
  17120. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17121. if (width === 1) {
  17122. if ((u0 & 1) !== 0) {
  17123. for (v = 0, k = 0; v < height; v++, k += width) {
  17124. items[k] *= 0.5;
  17125. }
  17126. }
  17127. } else {
  17128. for (v = 0, k = 0; v < height; v++, k += width) {
  17129. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17130. this.extend(rowBuffer, bufferPadding, width);
  17131. this.filter(rowBuffer, bufferPadding, width);
  17132. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17133. }
  17134. }
  17135. var numBuffers = 16;
  17136. var colBuffers = [];
  17137. for (i = 0; i < numBuffers; i++) {
  17138. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17139. }
  17140. var b, currentBuffer = 0;
  17141. ll = bufferPadding + height;
  17142. if (height === 1) {
  17143. if ((v0 & 1) !== 0) {
  17144. for (u = 0; u < width; u++) {
  17145. items[u] *= 0.5;
  17146. }
  17147. }
  17148. } else {
  17149. for (u = 0; u < width; u++) {
  17150. if (currentBuffer === 0) {
  17151. numBuffers = Math.min(width - u, numBuffers);
  17152. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17153. for (b = 0; b < numBuffers; b++) {
  17154. colBuffers[b][l] = items[k + b];
  17155. }
  17156. }
  17157. currentBuffer = numBuffers;
  17158. }
  17159. currentBuffer--;
  17160. var buffer = colBuffers[currentBuffer];
  17161. this.extend(buffer, bufferPadding, height);
  17162. this.filter(buffer, bufferPadding, height);
  17163. if (currentBuffer === 0) {
  17164. k = u - numBuffers + 1;
  17165. for (l = bufferPadding; l < ll; k += width, l++) {
  17166. for (b = 0; b < numBuffers; b++) {
  17167. items[k + b] = colBuffers[b][l];
  17168. }
  17169. }
  17170. }
  17171. }
  17172. }
  17173. return {
  17174. width: width,
  17175. height: height,
  17176. items: items
  17177. };
  17178. };
  17179. return Transform;
  17180. }();
  17181. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17182. function IrreversibleTransform() {
  17183. Transform.call(this);
  17184. }
  17185. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17186. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17187. var len = length >> 1;
  17188. offset = offset | 0;
  17189. var j, n, current, next;
  17190. var alpha = -1.586134342059924;
  17191. var beta = -0.052980118572961;
  17192. var gamma = 0.882911075530934;
  17193. var delta = 0.443506852043971;
  17194. var K = 1.230174104914001;
  17195. var K_ = 1 / K;
  17196. j = offset - 3;
  17197. for (n = len + 4; n--; j += 2) {
  17198. x[j] *= K_;
  17199. }
  17200. j = offset - 2;
  17201. current = delta * x[j - 1];
  17202. for (n = len + 3; n--; j += 2) {
  17203. next = delta * x[j + 1];
  17204. x[j] = K * x[j] - current - next;
  17205. if (n--) {
  17206. j += 2;
  17207. current = delta * x[j + 1];
  17208. x[j] = K * x[j] - current - next;
  17209. } else {
  17210. break;
  17211. }
  17212. }
  17213. j = offset - 1;
  17214. current = gamma * x[j - 1];
  17215. for (n = len + 2; n--; j += 2) {
  17216. next = gamma * x[j + 1];
  17217. x[j] -= current + next;
  17218. if (n--) {
  17219. j += 2;
  17220. current = gamma * x[j + 1];
  17221. x[j] -= current + next;
  17222. } else {
  17223. break;
  17224. }
  17225. }
  17226. j = offset;
  17227. current = beta * x[j - 1];
  17228. for (n = len + 1; n--; j += 2) {
  17229. next = beta * x[j + 1];
  17230. x[j] -= current + next;
  17231. if (n--) {
  17232. j += 2;
  17233. current = beta * x[j + 1];
  17234. x[j] -= current + next;
  17235. } else {
  17236. break;
  17237. }
  17238. }
  17239. if (len !== 0) {
  17240. j = offset + 1;
  17241. current = alpha * x[j - 1];
  17242. for (n = len; n--; j += 2) {
  17243. next = alpha * x[j + 1];
  17244. x[j] -= current + next;
  17245. if (n--) {
  17246. j += 2;
  17247. current = alpha * x[j + 1];
  17248. x[j] -= current + next;
  17249. } else {
  17250. break;
  17251. }
  17252. }
  17253. }
  17254. };
  17255. return IrreversibleTransform;
  17256. }();
  17257. var ReversibleTransform = function ReversibleTransformClosure() {
  17258. function ReversibleTransform() {
  17259. Transform.call(this);
  17260. }
  17261. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17262. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17263. var len = length >> 1;
  17264. offset = offset | 0;
  17265. var j, n;
  17266. for (j = offset, n = len + 1; n--; j += 2) {
  17267. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17268. }
  17269. for (j = offset + 1, n = len; n--; j += 2) {
  17270. x[j] += x[j - 1] + x[j + 1] >> 1;
  17271. }
  17272. };
  17273. return ReversibleTransform;
  17274. }();
  17275. return JpxImage;
  17276. }();
  17277. exports.JpxImage = JpxImage;
  17278. }));
  17279. (function (root, factory) {
  17280. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17281. }(this, function (exports, sharedUtil) {
  17282. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17283. var getMetrics = getLookupTableFactory(function (t) {
  17284. t['Courier'] = 600;
  17285. t['Courier-Bold'] = 600;
  17286. t['Courier-BoldOblique'] = 600;
  17287. t['Courier-Oblique'] = 600;
  17288. t['Helvetica'] = getLookupTableFactory(function (t) {
  17289. t['space'] = 278;
  17290. t['exclam'] = 278;
  17291. t['quotedbl'] = 355;
  17292. t['numbersign'] = 556;
  17293. t['dollar'] = 556;
  17294. t['percent'] = 889;
  17295. t['ampersand'] = 667;
  17296. t['quoteright'] = 222;
  17297. t['parenleft'] = 333;
  17298. t['parenright'] = 333;
  17299. t['asterisk'] = 389;
  17300. t['plus'] = 584;
  17301. t['comma'] = 278;
  17302. t['hyphen'] = 333;
  17303. t['period'] = 278;
  17304. t['slash'] = 278;
  17305. t['zero'] = 556;
  17306. t['one'] = 556;
  17307. t['two'] = 556;
  17308. t['three'] = 556;
  17309. t['four'] = 556;
  17310. t['five'] = 556;
  17311. t['six'] = 556;
  17312. t['seven'] = 556;
  17313. t['eight'] = 556;
  17314. t['nine'] = 556;
  17315. t['colon'] = 278;
  17316. t['semicolon'] = 278;
  17317. t['less'] = 584;
  17318. t['equal'] = 584;
  17319. t['greater'] = 584;
  17320. t['question'] = 556;
  17321. t['at'] = 1015;
  17322. t['A'] = 667;
  17323. t['B'] = 667;
  17324. t['C'] = 722;
  17325. t['D'] = 722;
  17326. t['E'] = 667;
  17327. t['F'] = 611;
  17328. t['G'] = 778;
  17329. t['H'] = 722;
  17330. t['I'] = 278;
  17331. t['J'] = 500;
  17332. t['K'] = 667;
  17333. t['L'] = 556;
  17334. t['M'] = 833;
  17335. t['N'] = 722;
  17336. t['O'] = 778;
  17337. t['P'] = 667;
  17338. t['Q'] = 778;
  17339. t['R'] = 722;
  17340. t['S'] = 667;
  17341. t['T'] = 611;
  17342. t['U'] = 722;
  17343. t['V'] = 667;
  17344. t['W'] = 944;
  17345. t['X'] = 667;
  17346. t['Y'] = 667;
  17347. t['Z'] = 611;
  17348. t['bracketleft'] = 278;
  17349. t['backslash'] = 278;
  17350. t['bracketright'] = 278;
  17351. t['asciicircum'] = 469;
  17352. t['underscore'] = 556;
  17353. t['quoteleft'] = 222;
  17354. t['a'] = 556;
  17355. t['b'] = 556;
  17356. t['c'] = 500;
  17357. t['d'] = 556;
  17358. t['e'] = 556;
  17359. t['f'] = 278;
  17360. t['g'] = 556;
  17361. t['h'] = 556;
  17362. t['i'] = 222;
  17363. t['j'] = 222;
  17364. t['k'] = 500;
  17365. t['l'] = 222;
  17366. t['m'] = 833;
  17367. t['n'] = 556;
  17368. t['o'] = 556;
  17369. t['p'] = 556;
  17370. t['q'] = 556;
  17371. t['r'] = 333;
  17372. t['s'] = 500;
  17373. t['t'] = 278;
  17374. t['u'] = 556;
  17375. t['v'] = 500;
  17376. t['w'] = 722;
  17377. t['x'] = 500;
  17378. t['y'] = 500;
  17379. t['z'] = 500;
  17380. t['braceleft'] = 334;
  17381. t['bar'] = 260;
  17382. t['braceright'] = 334;
  17383. t['asciitilde'] = 584;
  17384. t['exclamdown'] = 333;
  17385. t['cent'] = 556;
  17386. t['sterling'] = 556;
  17387. t['fraction'] = 167;
  17388. t['yen'] = 556;
  17389. t['florin'] = 556;
  17390. t['section'] = 556;
  17391. t['currency'] = 556;
  17392. t['quotesingle'] = 191;
  17393. t['quotedblleft'] = 333;
  17394. t['guillemotleft'] = 556;
  17395. t['guilsinglleft'] = 333;
  17396. t['guilsinglright'] = 333;
  17397. t['fi'] = 500;
  17398. t['fl'] = 500;
  17399. t['endash'] = 556;
  17400. t['dagger'] = 556;
  17401. t['daggerdbl'] = 556;
  17402. t['periodcentered'] = 278;
  17403. t['paragraph'] = 537;
  17404. t['bullet'] = 350;
  17405. t['quotesinglbase'] = 222;
  17406. t['quotedblbase'] = 333;
  17407. t['quotedblright'] = 333;
  17408. t['guillemotright'] = 556;
  17409. t['ellipsis'] = 1000;
  17410. t['perthousand'] = 1000;
  17411. t['questiondown'] = 611;
  17412. t['grave'] = 333;
  17413. t['acute'] = 333;
  17414. t['circumflex'] = 333;
  17415. t['tilde'] = 333;
  17416. t['macron'] = 333;
  17417. t['breve'] = 333;
  17418. t['dotaccent'] = 333;
  17419. t['dieresis'] = 333;
  17420. t['ring'] = 333;
  17421. t['cedilla'] = 333;
  17422. t['hungarumlaut'] = 333;
  17423. t['ogonek'] = 333;
  17424. t['caron'] = 333;
  17425. t['emdash'] = 1000;
  17426. t['AE'] = 1000;
  17427. t['ordfeminine'] = 370;
  17428. t['Lslash'] = 556;
  17429. t['Oslash'] = 778;
  17430. t['OE'] = 1000;
  17431. t['ordmasculine'] = 365;
  17432. t['ae'] = 889;
  17433. t['dotlessi'] = 278;
  17434. t['lslash'] = 222;
  17435. t['oslash'] = 611;
  17436. t['oe'] = 944;
  17437. t['germandbls'] = 611;
  17438. t['Idieresis'] = 278;
  17439. t['eacute'] = 556;
  17440. t['abreve'] = 556;
  17441. t['uhungarumlaut'] = 556;
  17442. t['ecaron'] = 556;
  17443. t['Ydieresis'] = 667;
  17444. t['divide'] = 584;
  17445. t['Yacute'] = 667;
  17446. t['Acircumflex'] = 667;
  17447. t['aacute'] = 556;
  17448. t['Ucircumflex'] = 722;
  17449. t['yacute'] = 500;
  17450. t['scommaaccent'] = 500;
  17451. t['ecircumflex'] = 556;
  17452. t['Uring'] = 722;
  17453. t['Udieresis'] = 722;
  17454. t['aogonek'] = 556;
  17455. t['Uacute'] = 722;
  17456. t['uogonek'] = 556;
  17457. t['Edieresis'] = 667;
  17458. t['Dcroat'] = 722;
  17459. t['commaaccent'] = 250;
  17460. t['copyright'] = 737;
  17461. t['Emacron'] = 667;
  17462. t['ccaron'] = 500;
  17463. t['aring'] = 556;
  17464. t['Ncommaaccent'] = 722;
  17465. t['lacute'] = 222;
  17466. t['agrave'] = 556;
  17467. t['Tcommaaccent'] = 611;
  17468. t['Cacute'] = 722;
  17469. t['atilde'] = 556;
  17470. t['Edotaccent'] = 667;
  17471. t['scaron'] = 500;
  17472. t['scedilla'] = 500;
  17473. t['iacute'] = 278;
  17474. t['lozenge'] = 471;
  17475. t['Rcaron'] = 722;
  17476. t['Gcommaaccent'] = 778;
  17477. t['ucircumflex'] = 556;
  17478. t['acircumflex'] = 556;
  17479. t['Amacron'] = 667;
  17480. t['rcaron'] = 333;
  17481. t['ccedilla'] = 500;
  17482. t['Zdotaccent'] = 611;
  17483. t['Thorn'] = 667;
  17484. t['Omacron'] = 778;
  17485. t['Racute'] = 722;
  17486. t['Sacute'] = 667;
  17487. t['dcaron'] = 643;
  17488. t['Umacron'] = 722;
  17489. t['uring'] = 556;
  17490. t['threesuperior'] = 333;
  17491. t['Ograve'] = 778;
  17492. t['Agrave'] = 667;
  17493. t['Abreve'] = 667;
  17494. t['multiply'] = 584;
  17495. t['uacute'] = 556;
  17496. t['Tcaron'] = 611;
  17497. t['partialdiff'] = 476;
  17498. t['ydieresis'] = 500;
  17499. t['Nacute'] = 722;
  17500. t['icircumflex'] = 278;
  17501. t['Ecircumflex'] = 667;
  17502. t['adieresis'] = 556;
  17503. t['edieresis'] = 556;
  17504. t['cacute'] = 500;
  17505. t['nacute'] = 556;
  17506. t['umacron'] = 556;
  17507. t['Ncaron'] = 722;
  17508. t['Iacute'] = 278;
  17509. t['plusminus'] = 584;
  17510. t['brokenbar'] = 260;
  17511. t['registered'] = 737;
  17512. t['Gbreve'] = 778;
  17513. t['Idotaccent'] = 278;
  17514. t['summation'] = 600;
  17515. t['Egrave'] = 667;
  17516. t['racute'] = 333;
  17517. t['omacron'] = 556;
  17518. t['Zacute'] = 611;
  17519. t['Zcaron'] = 611;
  17520. t['greaterequal'] = 549;
  17521. t['Eth'] = 722;
  17522. t['Ccedilla'] = 722;
  17523. t['lcommaaccent'] = 222;
  17524. t['tcaron'] = 317;
  17525. t['eogonek'] = 556;
  17526. t['Uogonek'] = 722;
  17527. t['Aacute'] = 667;
  17528. t['Adieresis'] = 667;
  17529. t['egrave'] = 556;
  17530. t['zacute'] = 500;
  17531. t['iogonek'] = 222;
  17532. t['Oacute'] = 778;
  17533. t['oacute'] = 556;
  17534. t['amacron'] = 556;
  17535. t['sacute'] = 500;
  17536. t['idieresis'] = 278;
  17537. t['Ocircumflex'] = 778;
  17538. t['Ugrave'] = 722;
  17539. t['Delta'] = 612;
  17540. t['thorn'] = 556;
  17541. t['twosuperior'] = 333;
  17542. t['Odieresis'] = 778;
  17543. t['mu'] = 556;
  17544. t['igrave'] = 278;
  17545. t['ohungarumlaut'] = 556;
  17546. t['Eogonek'] = 667;
  17547. t['dcroat'] = 556;
  17548. t['threequarters'] = 834;
  17549. t['Scedilla'] = 667;
  17550. t['lcaron'] = 299;
  17551. t['Kcommaaccent'] = 667;
  17552. t['Lacute'] = 556;
  17553. t['trademark'] = 1000;
  17554. t['edotaccent'] = 556;
  17555. t['Igrave'] = 278;
  17556. t['Imacron'] = 278;
  17557. t['Lcaron'] = 556;
  17558. t['onehalf'] = 834;
  17559. t['lessequal'] = 549;
  17560. t['ocircumflex'] = 556;
  17561. t['ntilde'] = 556;
  17562. t['Uhungarumlaut'] = 722;
  17563. t['Eacute'] = 667;
  17564. t['emacron'] = 556;
  17565. t['gbreve'] = 556;
  17566. t['onequarter'] = 834;
  17567. t['Scaron'] = 667;
  17568. t['Scommaaccent'] = 667;
  17569. t['Ohungarumlaut'] = 778;
  17570. t['degree'] = 400;
  17571. t['ograve'] = 556;
  17572. t['Ccaron'] = 722;
  17573. t['ugrave'] = 556;
  17574. t['radical'] = 453;
  17575. t['Dcaron'] = 722;
  17576. t['rcommaaccent'] = 333;
  17577. t['Ntilde'] = 722;
  17578. t['otilde'] = 556;
  17579. t['Rcommaaccent'] = 722;
  17580. t['Lcommaaccent'] = 556;
  17581. t['Atilde'] = 667;
  17582. t['Aogonek'] = 667;
  17583. t['Aring'] = 667;
  17584. t['Otilde'] = 778;
  17585. t['zdotaccent'] = 500;
  17586. t['Ecaron'] = 667;
  17587. t['Iogonek'] = 278;
  17588. t['kcommaaccent'] = 500;
  17589. t['minus'] = 584;
  17590. t['Icircumflex'] = 278;
  17591. t['ncaron'] = 556;
  17592. t['tcommaaccent'] = 278;
  17593. t['logicalnot'] = 584;
  17594. t['odieresis'] = 556;
  17595. t['udieresis'] = 556;
  17596. t['notequal'] = 549;
  17597. t['gcommaaccent'] = 556;
  17598. t['eth'] = 556;
  17599. t['zcaron'] = 500;
  17600. t['ncommaaccent'] = 556;
  17601. t['onesuperior'] = 333;
  17602. t['imacron'] = 278;
  17603. t['Euro'] = 556;
  17604. });
  17605. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17606. t['space'] = 278;
  17607. t['exclam'] = 333;
  17608. t['quotedbl'] = 474;
  17609. t['numbersign'] = 556;
  17610. t['dollar'] = 556;
  17611. t['percent'] = 889;
  17612. t['ampersand'] = 722;
  17613. t['quoteright'] = 278;
  17614. t['parenleft'] = 333;
  17615. t['parenright'] = 333;
  17616. t['asterisk'] = 389;
  17617. t['plus'] = 584;
  17618. t['comma'] = 278;
  17619. t['hyphen'] = 333;
  17620. t['period'] = 278;
  17621. t['slash'] = 278;
  17622. t['zero'] = 556;
  17623. t['one'] = 556;
  17624. t['two'] = 556;
  17625. t['three'] = 556;
  17626. t['four'] = 556;
  17627. t['five'] = 556;
  17628. t['six'] = 556;
  17629. t['seven'] = 556;
  17630. t['eight'] = 556;
  17631. t['nine'] = 556;
  17632. t['colon'] = 333;
  17633. t['semicolon'] = 333;
  17634. t['less'] = 584;
  17635. t['equal'] = 584;
  17636. t['greater'] = 584;
  17637. t['question'] = 611;
  17638. t['at'] = 975;
  17639. t['A'] = 722;
  17640. t['B'] = 722;
  17641. t['C'] = 722;
  17642. t['D'] = 722;
  17643. t['E'] = 667;
  17644. t['F'] = 611;
  17645. t['G'] = 778;
  17646. t['H'] = 722;
  17647. t['I'] = 278;
  17648. t['J'] = 556;
  17649. t['K'] = 722;
  17650. t['L'] = 611;
  17651. t['M'] = 833;
  17652. t['N'] = 722;
  17653. t['O'] = 778;
  17654. t['P'] = 667;
  17655. t['Q'] = 778;
  17656. t['R'] = 722;
  17657. t['S'] = 667;
  17658. t['T'] = 611;
  17659. t['U'] = 722;
  17660. t['V'] = 667;
  17661. t['W'] = 944;
  17662. t['X'] = 667;
  17663. t['Y'] = 667;
  17664. t['Z'] = 611;
  17665. t['bracketleft'] = 333;
  17666. t['backslash'] = 278;
  17667. t['bracketright'] = 333;
  17668. t['asciicircum'] = 584;
  17669. t['underscore'] = 556;
  17670. t['quoteleft'] = 278;
  17671. t['a'] = 556;
  17672. t['b'] = 611;
  17673. t['c'] = 556;
  17674. t['d'] = 611;
  17675. t['e'] = 556;
  17676. t['f'] = 333;
  17677. t['g'] = 611;
  17678. t['h'] = 611;
  17679. t['i'] = 278;
  17680. t['j'] = 278;
  17681. t['k'] = 556;
  17682. t['l'] = 278;
  17683. t['m'] = 889;
  17684. t['n'] = 611;
  17685. t['o'] = 611;
  17686. t['p'] = 611;
  17687. t['q'] = 611;
  17688. t['r'] = 389;
  17689. t['s'] = 556;
  17690. t['t'] = 333;
  17691. t['u'] = 611;
  17692. t['v'] = 556;
  17693. t['w'] = 778;
  17694. t['x'] = 556;
  17695. t['y'] = 556;
  17696. t['z'] = 500;
  17697. t['braceleft'] = 389;
  17698. t['bar'] = 280;
  17699. t['braceright'] = 389;
  17700. t['asciitilde'] = 584;
  17701. t['exclamdown'] = 333;
  17702. t['cent'] = 556;
  17703. t['sterling'] = 556;
  17704. t['fraction'] = 167;
  17705. t['yen'] = 556;
  17706. t['florin'] = 556;
  17707. t['section'] = 556;
  17708. t['currency'] = 556;
  17709. t['quotesingle'] = 238;
  17710. t['quotedblleft'] = 500;
  17711. t['guillemotleft'] = 556;
  17712. t['guilsinglleft'] = 333;
  17713. t['guilsinglright'] = 333;
  17714. t['fi'] = 611;
  17715. t['fl'] = 611;
  17716. t['endash'] = 556;
  17717. t['dagger'] = 556;
  17718. t['daggerdbl'] = 556;
  17719. t['periodcentered'] = 278;
  17720. t['paragraph'] = 556;
  17721. t['bullet'] = 350;
  17722. t['quotesinglbase'] = 278;
  17723. t['quotedblbase'] = 500;
  17724. t['quotedblright'] = 500;
  17725. t['guillemotright'] = 556;
  17726. t['ellipsis'] = 1000;
  17727. t['perthousand'] = 1000;
  17728. t['questiondown'] = 611;
  17729. t['grave'] = 333;
  17730. t['acute'] = 333;
  17731. t['circumflex'] = 333;
  17732. t['tilde'] = 333;
  17733. t['macron'] = 333;
  17734. t['breve'] = 333;
  17735. t['dotaccent'] = 333;
  17736. t['dieresis'] = 333;
  17737. t['ring'] = 333;
  17738. t['cedilla'] = 333;
  17739. t['hungarumlaut'] = 333;
  17740. t['ogonek'] = 333;
  17741. t['caron'] = 333;
  17742. t['emdash'] = 1000;
  17743. t['AE'] = 1000;
  17744. t['ordfeminine'] = 370;
  17745. t['Lslash'] = 611;
  17746. t['Oslash'] = 778;
  17747. t['OE'] = 1000;
  17748. t['ordmasculine'] = 365;
  17749. t['ae'] = 889;
  17750. t['dotlessi'] = 278;
  17751. t['lslash'] = 278;
  17752. t['oslash'] = 611;
  17753. t['oe'] = 944;
  17754. t['germandbls'] = 611;
  17755. t['Idieresis'] = 278;
  17756. t['eacute'] = 556;
  17757. t['abreve'] = 556;
  17758. t['uhungarumlaut'] = 611;
  17759. t['ecaron'] = 556;
  17760. t['Ydieresis'] = 667;
  17761. t['divide'] = 584;
  17762. t['Yacute'] = 667;
  17763. t['Acircumflex'] = 722;
  17764. t['aacute'] = 556;
  17765. t['Ucircumflex'] = 722;
  17766. t['yacute'] = 556;
  17767. t['scommaaccent'] = 556;
  17768. t['ecircumflex'] = 556;
  17769. t['Uring'] = 722;
  17770. t['Udieresis'] = 722;
  17771. t['aogonek'] = 556;
  17772. t['Uacute'] = 722;
  17773. t['uogonek'] = 611;
  17774. t['Edieresis'] = 667;
  17775. t['Dcroat'] = 722;
  17776. t['commaaccent'] = 250;
  17777. t['copyright'] = 737;
  17778. t['Emacron'] = 667;
  17779. t['ccaron'] = 556;
  17780. t['aring'] = 556;
  17781. t['Ncommaaccent'] = 722;
  17782. t['lacute'] = 278;
  17783. t['agrave'] = 556;
  17784. t['Tcommaaccent'] = 611;
  17785. t['Cacute'] = 722;
  17786. t['atilde'] = 556;
  17787. t['Edotaccent'] = 667;
  17788. t['scaron'] = 556;
  17789. t['scedilla'] = 556;
  17790. t['iacute'] = 278;
  17791. t['lozenge'] = 494;
  17792. t['Rcaron'] = 722;
  17793. t['Gcommaaccent'] = 778;
  17794. t['ucircumflex'] = 611;
  17795. t['acircumflex'] = 556;
  17796. t['Amacron'] = 722;
  17797. t['rcaron'] = 389;
  17798. t['ccedilla'] = 556;
  17799. t['Zdotaccent'] = 611;
  17800. t['Thorn'] = 667;
  17801. t['Omacron'] = 778;
  17802. t['Racute'] = 722;
  17803. t['Sacute'] = 667;
  17804. t['dcaron'] = 743;
  17805. t['Umacron'] = 722;
  17806. t['uring'] = 611;
  17807. t['threesuperior'] = 333;
  17808. t['Ograve'] = 778;
  17809. t['Agrave'] = 722;
  17810. t['Abreve'] = 722;
  17811. t['multiply'] = 584;
  17812. t['uacute'] = 611;
  17813. t['Tcaron'] = 611;
  17814. t['partialdiff'] = 494;
  17815. t['ydieresis'] = 556;
  17816. t['Nacute'] = 722;
  17817. t['icircumflex'] = 278;
  17818. t['Ecircumflex'] = 667;
  17819. t['adieresis'] = 556;
  17820. t['edieresis'] = 556;
  17821. t['cacute'] = 556;
  17822. t['nacute'] = 611;
  17823. t['umacron'] = 611;
  17824. t['Ncaron'] = 722;
  17825. t['Iacute'] = 278;
  17826. t['plusminus'] = 584;
  17827. t['brokenbar'] = 280;
  17828. t['registered'] = 737;
  17829. t['Gbreve'] = 778;
  17830. t['Idotaccent'] = 278;
  17831. t['summation'] = 600;
  17832. t['Egrave'] = 667;
  17833. t['racute'] = 389;
  17834. t['omacron'] = 611;
  17835. t['Zacute'] = 611;
  17836. t['Zcaron'] = 611;
  17837. t['greaterequal'] = 549;
  17838. t['Eth'] = 722;
  17839. t['Ccedilla'] = 722;
  17840. t['lcommaaccent'] = 278;
  17841. t['tcaron'] = 389;
  17842. t['eogonek'] = 556;
  17843. t['Uogonek'] = 722;
  17844. t['Aacute'] = 722;
  17845. t['Adieresis'] = 722;
  17846. t['egrave'] = 556;
  17847. t['zacute'] = 500;
  17848. t['iogonek'] = 278;
  17849. t['Oacute'] = 778;
  17850. t['oacute'] = 611;
  17851. t['amacron'] = 556;
  17852. t['sacute'] = 556;
  17853. t['idieresis'] = 278;
  17854. t['Ocircumflex'] = 778;
  17855. t['Ugrave'] = 722;
  17856. t['Delta'] = 612;
  17857. t['thorn'] = 611;
  17858. t['twosuperior'] = 333;
  17859. t['Odieresis'] = 778;
  17860. t['mu'] = 611;
  17861. t['igrave'] = 278;
  17862. t['ohungarumlaut'] = 611;
  17863. t['Eogonek'] = 667;
  17864. t['dcroat'] = 611;
  17865. t['threequarters'] = 834;
  17866. t['Scedilla'] = 667;
  17867. t['lcaron'] = 400;
  17868. t['Kcommaaccent'] = 722;
  17869. t['Lacute'] = 611;
  17870. t['trademark'] = 1000;
  17871. t['edotaccent'] = 556;
  17872. t['Igrave'] = 278;
  17873. t['Imacron'] = 278;
  17874. t['Lcaron'] = 611;
  17875. t['onehalf'] = 834;
  17876. t['lessequal'] = 549;
  17877. t['ocircumflex'] = 611;
  17878. t['ntilde'] = 611;
  17879. t['Uhungarumlaut'] = 722;
  17880. t['Eacute'] = 667;
  17881. t['emacron'] = 556;
  17882. t['gbreve'] = 611;
  17883. t['onequarter'] = 834;
  17884. t['Scaron'] = 667;
  17885. t['Scommaaccent'] = 667;
  17886. t['Ohungarumlaut'] = 778;
  17887. t['degree'] = 400;
  17888. t['ograve'] = 611;
  17889. t['Ccaron'] = 722;
  17890. t['ugrave'] = 611;
  17891. t['radical'] = 549;
  17892. t['Dcaron'] = 722;
  17893. t['rcommaaccent'] = 389;
  17894. t['Ntilde'] = 722;
  17895. t['otilde'] = 611;
  17896. t['Rcommaaccent'] = 722;
  17897. t['Lcommaaccent'] = 611;
  17898. t['Atilde'] = 722;
  17899. t['Aogonek'] = 722;
  17900. t['Aring'] = 722;
  17901. t['Otilde'] = 778;
  17902. t['zdotaccent'] = 500;
  17903. t['Ecaron'] = 667;
  17904. t['Iogonek'] = 278;
  17905. t['kcommaaccent'] = 556;
  17906. t['minus'] = 584;
  17907. t['Icircumflex'] = 278;
  17908. t['ncaron'] = 611;
  17909. t['tcommaaccent'] = 333;
  17910. t['logicalnot'] = 584;
  17911. t['odieresis'] = 611;
  17912. t['udieresis'] = 611;
  17913. t['notequal'] = 549;
  17914. t['gcommaaccent'] = 611;
  17915. t['eth'] = 611;
  17916. t['zcaron'] = 500;
  17917. t['ncommaaccent'] = 611;
  17918. t['onesuperior'] = 333;
  17919. t['imacron'] = 278;
  17920. t['Euro'] = 556;
  17921. });
  17922. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17923. t['space'] = 278;
  17924. t['exclam'] = 333;
  17925. t['quotedbl'] = 474;
  17926. t['numbersign'] = 556;
  17927. t['dollar'] = 556;
  17928. t['percent'] = 889;
  17929. t['ampersand'] = 722;
  17930. t['quoteright'] = 278;
  17931. t['parenleft'] = 333;
  17932. t['parenright'] = 333;
  17933. t['asterisk'] = 389;
  17934. t['plus'] = 584;
  17935. t['comma'] = 278;
  17936. t['hyphen'] = 333;
  17937. t['period'] = 278;
  17938. t['slash'] = 278;
  17939. t['zero'] = 556;
  17940. t['one'] = 556;
  17941. t['two'] = 556;
  17942. t['three'] = 556;
  17943. t['four'] = 556;
  17944. t['five'] = 556;
  17945. t['six'] = 556;
  17946. t['seven'] = 556;
  17947. t['eight'] = 556;
  17948. t['nine'] = 556;
  17949. t['colon'] = 333;
  17950. t['semicolon'] = 333;
  17951. t['less'] = 584;
  17952. t['equal'] = 584;
  17953. t['greater'] = 584;
  17954. t['question'] = 611;
  17955. t['at'] = 975;
  17956. t['A'] = 722;
  17957. t['B'] = 722;
  17958. t['C'] = 722;
  17959. t['D'] = 722;
  17960. t['E'] = 667;
  17961. t['F'] = 611;
  17962. t['G'] = 778;
  17963. t['H'] = 722;
  17964. t['I'] = 278;
  17965. t['J'] = 556;
  17966. t['K'] = 722;
  17967. t['L'] = 611;
  17968. t['M'] = 833;
  17969. t['N'] = 722;
  17970. t['O'] = 778;
  17971. t['P'] = 667;
  17972. t['Q'] = 778;
  17973. t['R'] = 722;
  17974. t['S'] = 667;
  17975. t['T'] = 611;
  17976. t['U'] = 722;
  17977. t['V'] = 667;
  17978. t['W'] = 944;
  17979. t['X'] = 667;
  17980. t['Y'] = 667;
  17981. t['Z'] = 611;
  17982. t['bracketleft'] = 333;
  17983. t['backslash'] = 278;
  17984. t['bracketright'] = 333;
  17985. t['asciicircum'] = 584;
  17986. t['underscore'] = 556;
  17987. t['quoteleft'] = 278;
  17988. t['a'] = 556;
  17989. t['b'] = 611;
  17990. t['c'] = 556;
  17991. t['d'] = 611;
  17992. t['e'] = 556;
  17993. t['f'] = 333;
  17994. t['g'] = 611;
  17995. t['h'] = 611;
  17996. t['i'] = 278;
  17997. t['j'] = 278;
  17998. t['k'] = 556;
  17999. t['l'] = 278;
  18000. t['m'] = 889;
  18001. t['n'] = 611;
  18002. t['o'] = 611;
  18003. t['p'] = 611;
  18004. t['q'] = 611;
  18005. t['r'] = 389;
  18006. t['s'] = 556;
  18007. t['t'] = 333;
  18008. t['u'] = 611;
  18009. t['v'] = 556;
  18010. t['w'] = 778;
  18011. t['x'] = 556;
  18012. t['y'] = 556;
  18013. t['z'] = 500;
  18014. t['braceleft'] = 389;
  18015. t['bar'] = 280;
  18016. t['braceright'] = 389;
  18017. t['asciitilde'] = 584;
  18018. t['exclamdown'] = 333;
  18019. t['cent'] = 556;
  18020. t['sterling'] = 556;
  18021. t['fraction'] = 167;
  18022. t['yen'] = 556;
  18023. t['florin'] = 556;
  18024. t['section'] = 556;
  18025. t['currency'] = 556;
  18026. t['quotesingle'] = 238;
  18027. t['quotedblleft'] = 500;
  18028. t['guillemotleft'] = 556;
  18029. t['guilsinglleft'] = 333;
  18030. t['guilsinglright'] = 333;
  18031. t['fi'] = 611;
  18032. t['fl'] = 611;
  18033. t['endash'] = 556;
  18034. t['dagger'] = 556;
  18035. t['daggerdbl'] = 556;
  18036. t['periodcentered'] = 278;
  18037. t['paragraph'] = 556;
  18038. t['bullet'] = 350;
  18039. t['quotesinglbase'] = 278;
  18040. t['quotedblbase'] = 500;
  18041. t['quotedblright'] = 500;
  18042. t['guillemotright'] = 556;
  18043. t['ellipsis'] = 1000;
  18044. t['perthousand'] = 1000;
  18045. t['questiondown'] = 611;
  18046. t['grave'] = 333;
  18047. t['acute'] = 333;
  18048. t['circumflex'] = 333;
  18049. t['tilde'] = 333;
  18050. t['macron'] = 333;
  18051. t['breve'] = 333;
  18052. t['dotaccent'] = 333;
  18053. t['dieresis'] = 333;
  18054. t['ring'] = 333;
  18055. t['cedilla'] = 333;
  18056. t['hungarumlaut'] = 333;
  18057. t['ogonek'] = 333;
  18058. t['caron'] = 333;
  18059. t['emdash'] = 1000;
  18060. t['AE'] = 1000;
  18061. t['ordfeminine'] = 370;
  18062. t['Lslash'] = 611;
  18063. t['Oslash'] = 778;
  18064. t['OE'] = 1000;
  18065. t['ordmasculine'] = 365;
  18066. t['ae'] = 889;
  18067. t['dotlessi'] = 278;
  18068. t['lslash'] = 278;
  18069. t['oslash'] = 611;
  18070. t['oe'] = 944;
  18071. t['germandbls'] = 611;
  18072. t['Idieresis'] = 278;
  18073. t['eacute'] = 556;
  18074. t['abreve'] = 556;
  18075. t['uhungarumlaut'] = 611;
  18076. t['ecaron'] = 556;
  18077. t['Ydieresis'] = 667;
  18078. t['divide'] = 584;
  18079. t['Yacute'] = 667;
  18080. t['Acircumflex'] = 722;
  18081. t['aacute'] = 556;
  18082. t['Ucircumflex'] = 722;
  18083. t['yacute'] = 556;
  18084. t['scommaaccent'] = 556;
  18085. t['ecircumflex'] = 556;
  18086. t['Uring'] = 722;
  18087. t['Udieresis'] = 722;
  18088. t['aogonek'] = 556;
  18089. t['Uacute'] = 722;
  18090. t['uogonek'] = 611;
  18091. t['Edieresis'] = 667;
  18092. t['Dcroat'] = 722;
  18093. t['commaaccent'] = 250;
  18094. t['copyright'] = 737;
  18095. t['Emacron'] = 667;
  18096. t['ccaron'] = 556;
  18097. t['aring'] = 556;
  18098. t['Ncommaaccent'] = 722;
  18099. t['lacute'] = 278;
  18100. t['agrave'] = 556;
  18101. t['Tcommaaccent'] = 611;
  18102. t['Cacute'] = 722;
  18103. t['atilde'] = 556;
  18104. t['Edotaccent'] = 667;
  18105. t['scaron'] = 556;
  18106. t['scedilla'] = 556;
  18107. t['iacute'] = 278;
  18108. t['lozenge'] = 494;
  18109. t['Rcaron'] = 722;
  18110. t['Gcommaaccent'] = 778;
  18111. t['ucircumflex'] = 611;
  18112. t['acircumflex'] = 556;
  18113. t['Amacron'] = 722;
  18114. t['rcaron'] = 389;
  18115. t['ccedilla'] = 556;
  18116. t['Zdotaccent'] = 611;
  18117. t['Thorn'] = 667;
  18118. t['Omacron'] = 778;
  18119. t['Racute'] = 722;
  18120. t['Sacute'] = 667;
  18121. t['dcaron'] = 743;
  18122. t['Umacron'] = 722;
  18123. t['uring'] = 611;
  18124. t['threesuperior'] = 333;
  18125. t['Ograve'] = 778;
  18126. t['Agrave'] = 722;
  18127. t['Abreve'] = 722;
  18128. t['multiply'] = 584;
  18129. t['uacute'] = 611;
  18130. t['Tcaron'] = 611;
  18131. t['partialdiff'] = 494;
  18132. t['ydieresis'] = 556;
  18133. t['Nacute'] = 722;
  18134. t['icircumflex'] = 278;
  18135. t['Ecircumflex'] = 667;
  18136. t['adieresis'] = 556;
  18137. t['edieresis'] = 556;
  18138. t['cacute'] = 556;
  18139. t['nacute'] = 611;
  18140. t['umacron'] = 611;
  18141. t['Ncaron'] = 722;
  18142. t['Iacute'] = 278;
  18143. t['plusminus'] = 584;
  18144. t['brokenbar'] = 280;
  18145. t['registered'] = 737;
  18146. t['Gbreve'] = 778;
  18147. t['Idotaccent'] = 278;
  18148. t['summation'] = 600;
  18149. t['Egrave'] = 667;
  18150. t['racute'] = 389;
  18151. t['omacron'] = 611;
  18152. t['Zacute'] = 611;
  18153. t['Zcaron'] = 611;
  18154. t['greaterequal'] = 549;
  18155. t['Eth'] = 722;
  18156. t['Ccedilla'] = 722;
  18157. t['lcommaaccent'] = 278;
  18158. t['tcaron'] = 389;
  18159. t['eogonek'] = 556;
  18160. t['Uogonek'] = 722;
  18161. t['Aacute'] = 722;
  18162. t['Adieresis'] = 722;
  18163. t['egrave'] = 556;
  18164. t['zacute'] = 500;
  18165. t['iogonek'] = 278;
  18166. t['Oacute'] = 778;
  18167. t['oacute'] = 611;
  18168. t['amacron'] = 556;
  18169. t['sacute'] = 556;
  18170. t['idieresis'] = 278;
  18171. t['Ocircumflex'] = 778;
  18172. t['Ugrave'] = 722;
  18173. t['Delta'] = 612;
  18174. t['thorn'] = 611;
  18175. t['twosuperior'] = 333;
  18176. t['Odieresis'] = 778;
  18177. t['mu'] = 611;
  18178. t['igrave'] = 278;
  18179. t['ohungarumlaut'] = 611;
  18180. t['Eogonek'] = 667;
  18181. t['dcroat'] = 611;
  18182. t['threequarters'] = 834;
  18183. t['Scedilla'] = 667;
  18184. t['lcaron'] = 400;
  18185. t['Kcommaaccent'] = 722;
  18186. t['Lacute'] = 611;
  18187. t['trademark'] = 1000;
  18188. t['edotaccent'] = 556;
  18189. t['Igrave'] = 278;
  18190. t['Imacron'] = 278;
  18191. t['Lcaron'] = 611;
  18192. t['onehalf'] = 834;
  18193. t['lessequal'] = 549;
  18194. t['ocircumflex'] = 611;
  18195. t['ntilde'] = 611;
  18196. t['Uhungarumlaut'] = 722;
  18197. t['Eacute'] = 667;
  18198. t['emacron'] = 556;
  18199. t['gbreve'] = 611;
  18200. t['onequarter'] = 834;
  18201. t['Scaron'] = 667;
  18202. t['Scommaaccent'] = 667;
  18203. t['Ohungarumlaut'] = 778;
  18204. t['degree'] = 400;
  18205. t['ograve'] = 611;
  18206. t['Ccaron'] = 722;
  18207. t['ugrave'] = 611;
  18208. t['radical'] = 549;
  18209. t['Dcaron'] = 722;
  18210. t['rcommaaccent'] = 389;
  18211. t['Ntilde'] = 722;
  18212. t['otilde'] = 611;
  18213. t['Rcommaaccent'] = 722;
  18214. t['Lcommaaccent'] = 611;
  18215. t['Atilde'] = 722;
  18216. t['Aogonek'] = 722;
  18217. t['Aring'] = 722;
  18218. t['Otilde'] = 778;
  18219. t['zdotaccent'] = 500;
  18220. t['Ecaron'] = 667;
  18221. t['Iogonek'] = 278;
  18222. t['kcommaaccent'] = 556;
  18223. t['minus'] = 584;
  18224. t['Icircumflex'] = 278;
  18225. t['ncaron'] = 611;
  18226. t['tcommaaccent'] = 333;
  18227. t['logicalnot'] = 584;
  18228. t['odieresis'] = 611;
  18229. t['udieresis'] = 611;
  18230. t['notequal'] = 549;
  18231. t['gcommaaccent'] = 611;
  18232. t['eth'] = 611;
  18233. t['zcaron'] = 500;
  18234. t['ncommaaccent'] = 611;
  18235. t['onesuperior'] = 333;
  18236. t['imacron'] = 278;
  18237. t['Euro'] = 556;
  18238. });
  18239. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18240. t['space'] = 278;
  18241. t['exclam'] = 278;
  18242. t['quotedbl'] = 355;
  18243. t['numbersign'] = 556;
  18244. t['dollar'] = 556;
  18245. t['percent'] = 889;
  18246. t['ampersand'] = 667;
  18247. t['quoteright'] = 222;
  18248. t['parenleft'] = 333;
  18249. t['parenright'] = 333;
  18250. t['asterisk'] = 389;
  18251. t['plus'] = 584;
  18252. t['comma'] = 278;
  18253. t['hyphen'] = 333;
  18254. t['period'] = 278;
  18255. t['slash'] = 278;
  18256. t['zero'] = 556;
  18257. t['one'] = 556;
  18258. t['two'] = 556;
  18259. t['three'] = 556;
  18260. t['four'] = 556;
  18261. t['five'] = 556;
  18262. t['six'] = 556;
  18263. t['seven'] = 556;
  18264. t['eight'] = 556;
  18265. t['nine'] = 556;
  18266. t['colon'] = 278;
  18267. t['semicolon'] = 278;
  18268. t['less'] = 584;
  18269. t['equal'] = 584;
  18270. t['greater'] = 584;
  18271. t['question'] = 556;
  18272. t['at'] = 1015;
  18273. t['A'] = 667;
  18274. t['B'] = 667;
  18275. t['C'] = 722;
  18276. t['D'] = 722;
  18277. t['E'] = 667;
  18278. t['F'] = 611;
  18279. t['G'] = 778;
  18280. t['H'] = 722;
  18281. t['I'] = 278;
  18282. t['J'] = 500;
  18283. t['K'] = 667;
  18284. t['L'] = 556;
  18285. t['M'] = 833;
  18286. t['N'] = 722;
  18287. t['O'] = 778;
  18288. t['P'] = 667;
  18289. t['Q'] = 778;
  18290. t['R'] = 722;
  18291. t['S'] = 667;
  18292. t['T'] = 611;
  18293. t['U'] = 722;
  18294. t['V'] = 667;
  18295. t['W'] = 944;
  18296. t['X'] = 667;
  18297. t['Y'] = 667;
  18298. t['Z'] = 611;
  18299. t['bracketleft'] = 278;
  18300. t['backslash'] = 278;
  18301. t['bracketright'] = 278;
  18302. t['asciicircum'] = 469;
  18303. t['underscore'] = 556;
  18304. t['quoteleft'] = 222;
  18305. t['a'] = 556;
  18306. t['b'] = 556;
  18307. t['c'] = 500;
  18308. t['d'] = 556;
  18309. t['e'] = 556;
  18310. t['f'] = 278;
  18311. t['g'] = 556;
  18312. t['h'] = 556;
  18313. t['i'] = 222;
  18314. t['j'] = 222;
  18315. t['k'] = 500;
  18316. t['l'] = 222;
  18317. t['m'] = 833;
  18318. t['n'] = 556;
  18319. t['o'] = 556;
  18320. t['p'] = 556;
  18321. t['q'] = 556;
  18322. t['r'] = 333;
  18323. t['s'] = 500;
  18324. t['t'] = 278;
  18325. t['u'] = 556;
  18326. t['v'] = 500;
  18327. t['w'] = 722;
  18328. t['x'] = 500;
  18329. t['y'] = 500;
  18330. t['z'] = 500;
  18331. t['braceleft'] = 334;
  18332. t['bar'] = 260;
  18333. t['braceright'] = 334;
  18334. t['asciitilde'] = 584;
  18335. t['exclamdown'] = 333;
  18336. t['cent'] = 556;
  18337. t['sterling'] = 556;
  18338. t['fraction'] = 167;
  18339. t['yen'] = 556;
  18340. t['florin'] = 556;
  18341. t['section'] = 556;
  18342. t['currency'] = 556;
  18343. t['quotesingle'] = 191;
  18344. t['quotedblleft'] = 333;
  18345. t['guillemotleft'] = 556;
  18346. t['guilsinglleft'] = 333;
  18347. t['guilsinglright'] = 333;
  18348. t['fi'] = 500;
  18349. t['fl'] = 500;
  18350. t['endash'] = 556;
  18351. t['dagger'] = 556;
  18352. t['daggerdbl'] = 556;
  18353. t['periodcentered'] = 278;
  18354. t['paragraph'] = 537;
  18355. t['bullet'] = 350;
  18356. t['quotesinglbase'] = 222;
  18357. t['quotedblbase'] = 333;
  18358. t['quotedblright'] = 333;
  18359. t['guillemotright'] = 556;
  18360. t['ellipsis'] = 1000;
  18361. t['perthousand'] = 1000;
  18362. t['questiondown'] = 611;
  18363. t['grave'] = 333;
  18364. t['acute'] = 333;
  18365. t['circumflex'] = 333;
  18366. t['tilde'] = 333;
  18367. t['macron'] = 333;
  18368. t['breve'] = 333;
  18369. t['dotaccent'] = 333;
  18370. t['dieresis'] = 333;
  18371. t['ring'] = 333;
  18372. t['cedilla'] = 333;
  18373. t['hungarumlaut'] = 333;
  18374. t['ogonek'] = 333;
  18375. t['caron'] = 333;
  18376. t['emdash'] = 1000;
  18377. t['AE'] = 1000;
  18378. t['ordfeminine'] = 370;
  18379. t['Lslash'] = 556;
  18380. t['Oslash'] = 778;
  18381. t['OE'] = 1000;
  18382. t['ordmasculine'] = 365;
  18383. t['ae'] = 889;
  18384. t['dotlessi'] = 278;
  18385. t['lslash'] = 222;
  18386. t['oslash'] = 611;
  18387. t['oe'] = 944;
  18388. t['germandbls'] = 611;
  18389. t['Idieresis'] = 278;
  18390. t['eacute'] = 556;
  18391. t['abreve'] = 556;
  18392. t['uhungarumlaut'] = 556;
  18393. t['ecaron'] = 556;
  18394. t['Ydieresis'] = 667;
  18395. t['divide'] = 584;
  18396. t['Yacute'] = 667;
  18397. t['Acircumflex'] = 667;
  18398. t['aacute'] = 556;
  18399. t['Ucircumflex'] = 722;
  18400. t['yacute'] = 500;
  18401. t['scommaaccent'] = 500;
  18402. t['ecircumflex'] = 556;
  18403. t['Uring'] = 722;
  18404. t['Udieresis'] = 722;
  18405. t['aogonek'] = 556;
  18406. t['Uacute'] = 722;
  18407. t['uogonek'] = 556;
  18408. t['Edieresis'] = 667;
  18409. t['Dcroat'] = 722;
  18410. t['commaaccent'] = 250;
  18411. t['copyright'] = 737;
  18412. t['Emacron'] = 667;
  18413. t['ccaron'] = 500;
  18414. t['aring'] = 556;
  18415. t['Ncommaaccent'] = 722;
  18416. t['lacute'] = 222;
  18417. t['agrave'] = 556;
  18418. t['Tcommaaccent'] = 611;
  18419. t['Cacute'] = 722;
  18420. t['atilde'] = 556;
  18421. t['Edotaccent'] = 667;
  18422. t['scaron'] = 500;
  18423. t['scedilla'] = 500;
  18424. t['iacute'] = 278;
  18425. t['lozenge'] = 471;
  18426. t['Rcaron'] = 722;
  18427. t['Gcommaaccent'] = 778;
  18428. t['ucircumflex'] = 556;
  18429. t['acircumflex'] = 556;
  18430. t['Amacron'] = 667;
  18431. t['rcaron'] = 333;
  18432. t['ccedilla'] = 500;
  18433. t['Zdotaccent'] = 611;
  18434. t['Thorn'] = 667;
  18435. t['Omacron'] = 778;
  18436. t['Racute'] = 722;
  18437. t['Sacute'] = 667;
  18438. t['dcaron'] = 643;
  18439. t['Umacron'] = 722;
  18440. t['uring'] = 556;
  18441. t['threesuperior'] = 333;
  18442. t['Ograve'] = 778;
  18443. t['Agrave'] = 667;
  18444. t['Abreve'] = 667;
  18445. t['multiply'] = 584;
  18446. t['uacute'] = 556;
  18447. t['Tcaron'] = 611;
  18448. t['partialdiff'] = 476;
  18449. t['ydieresis'] = 500;
  18450. t['Nacute'] = 722;
  18451. t['icircumflex'] = 278;
  18452. t['Ecircumflex'] = 667;
  18453. t['adieresis'] = 556;
  18454. t['edieresis'] = 556;
  18455. t['cacute'] = 500;
  18456. t['nacute'] = 556;
  18457. t['umacron'] = 556;
  18458. t['Ncaron'] = 722;
  18459. t['Iacute'] = 278;
  18460. t['plusminus'] = 584;
  18461. t['brokenbar'] = 260;
  18462. t['registered'] = 737;
  18463. t['Gbreve'] = 778;
  18464. t['Idotaccent'] = 278;
  18465. t['summation'] = 600;
  18466. t['Egrave'] = 667;
  18467. t['racute'] = 333;
  18468. t['omacron'] = 556;
  18469. t['Zacute'] = 611;
  18470. t['Zcaron'] = 611;
  18471. t['greaterequal'] = 549;
  18472. t['Eth'] = 722;
  18473. t['Ccedilla'] = 722;
  18474. t['lcommaaccent'] = 222;
  18475. t['tcaron'] = 317;
  18476. t['eogonek'] = 556;
  18477. t['Uogonek'] = 722;
  18478. t['Aacute'] = 667;
  18479. t['Adieresis'] = 667;
  18480. t['egrave'] = 556;
  18481. t['zacute'] = 500;
  18482. t['iogonek'] = 222;
  18483. t['Oacute'] = 778;
  18484. t['oacute'] = 556;
  18485. t['amacron'] = 556;
  18486. t['sacute'] = 500;
  18487. t['idieresis'] = 278;
  18488. t['Ocircumflex'] = 778;
  18489. t['Ugrave'] = 722;
  18490. t['Delta'] = 612;
  18491. t['thorn'] = 556;
  18492. t['twosuperior'] = 333;
  18493. t['Odieresis'] = 778;
  18494. t['mu'] = 556;
  18495. t['igrave'] = 278;
  18496. t['ohungarumlaut'] = 556;
  18497. t['Eogonek'] = 667;
  18498. t['dcroat'] = 556;
  18499. t['threequarters'] = 834;
  18500. t['Scedilla'] = 667;
  18501. t['lcaron'] = 299;
  18502. t['Kcommaaccent'] = 667;
  18503. t['Lacute'] = 556;
  18504. t['trademark'] = 1000;
  18505. t['edotaccent'] = 556;
  18506. t['Igrave'] = 278;
  18507. t['Imacron'] = 278;
  18508. t['Lcaron'] = 556;
  18509. t['onehalf'] = 834;
  18510. t['lessequal'] = 549;
  18511. t['ocircumflex'] = 556;
  18512. t['ntilde'] = 556;
  18513. t['Uhungarumlaut'] = 722;
  18514. t['Eacute'] = 667;
  18515. t['emacron'] = 556;
  18516. t['gbreve'] = 556;
  18517. t['onequarter'] = 834;
  18518. t['Scaron'] = 667;
  18519. t['Scommaaccent'] = 667;
  18520. t['Ohungarumlaut'] = 778;
  18521. t['degree'] = 400;
  18522. t['ograve'] = 556;
  18523. t['Ccaron'] = 722;
  18524. t['ugrave'] = 556;
  18525. t['radical'] = 453;
  18526. t['Dcaron'] = 722;
  18527. t['rcommaaccent'] = 333;
  18528. t['Ntilde'] = 722;
  18529. t['otilde'] = 556;
  18530. t['Rcommaaccent'] = 722;
  18531. t['Lcommaaccent'] = 556;
  18532. t['Atilde'] = 667;
  18533. t['Aogonek'] = 667;
  18534. t['Aring'] = 667;
  18535. t['Otilde'] = 778;
  18536. t['zdotaccent'] = 500;
  18537. t['Ecaron'] = 667;
  18538. t['Iogonek'] = 278;
  18539. t['kcommaaccent'] = 500;
  18540. t['minus'] = 584;
  18541. t['Icircumflex'] = 278;
  18542. t['ncaron'] = 556;
  18543. t['tcommaaccent'] = 278;
  18544. t['logicalnot'] = 584;
  18545. t['odieresis'] = 556;
  18546. t['udieresis'] = 556;
  18547. t['notequal'] = 549;
  18548. t['gcommaaccent'] = 556;
  18549. t['eth'] = 556;
  18550. t['zcaron'] = 500;
  18551. t['ncommaaccent'] = 556;
  18552. t['onesuperior'] = 333;
  18553. t['imacron'] = 278;
  18554. t['Euro'] = 556;
  18555. });
  18556. t['Symbol'] = getLookupTableFactory(function (t) {
  18557. t['space'] = 250;
  18558. t['exclam'] = 333;
  18559. t['universal'] = 713;
  18560. t['numbersign'] = 500;
  18561. t['existential'] = 549;
  18562. t['percent'] = 833;
  18563. t['ampersand'] = 778;
  18564. t['suchthat'] = 439;
  18565. t['parenleft'] = 333;
  18566. t['parenright'] = 333;
  18567. t['asteriskmath'] = 500;
  18568. t['plus'] = 549;
  18569. t['comma'] = 250;
  18570. t['minus'] = 549;
  18571. t['period'] = 250;
  18572. t['slash'] = 278;
  18573. t['zero'] = 500;
  18574. t['one'] = 500;
  18575. t['two'] = 500;
  18576. t['three'] = 500;
  18577. t['four'] = 500;
  18578. t['five'] = 500;
  18579. t['six'] = 500;
  18580. t['seven'] = 500;
  18581. t['eight'] = 500;
  18582. t['nine'] = 500;
  18583. t['colon'] = 278;
  18584. t['semicolon'] = 278;
  18585. t['less'] = 549;
  18586. t['equal'] = 549;
  18587. t['greater'] = 549;
  18588. t['question'] = 444;
  18589. t['congruent'] = 549;
  18590. t['Alpha'] = 722;
  18591. t['Beta'] = 667;
  18592. t['Chi'] = 722;
  18593. t['Delta'] = 612;
  18594. t['Epsilon'] = 611;
  18595. t['Phi'] = 763;
  18596. t['Gamma'] = 603;
  18597. t['Eta'] = 722;
  18598. t['Iota'] = 333;
  18599. t['theta1'] = 631;
  18600. t['Kappa'] = 722;
  18601. t['Lambda'] = 686;
  18602. t['Mu'] = 889;
  18603. t['Nu'] = 722;
  18604. t['Omicron'] = 722;
  18605. t['Pi'] = 768;
  18606. t['Theta'] = 741;
  18607. t['Rho'] = 556;
  18608. t['Sigma'] = 592;
  18609. t['Tau'] = 611;
  18610. t['Upsilon'] = 690;
  18611. t['sigma1'] = 439;
  18612. t['Omega'] = 768;
  18613. t['Xi'] = 645;
  18614. t['Psi'] = 795;
  18615. t['Zeta'] = 611;
  18616. t['bracketleft'] = 333;
  18617. t['therefore'] = 863;
  18618. t['bracketright'] = 333;
  18619. t['perpendicular'] = 658;
  18620. t['underscore'] = 500;
  18621. t['radicalex'] = 500;
  18622. t['alpha'] = 631;
  18623. t['beta'] = 549;
  18624. t['chi'] = 549;
  18625. t['delta'] = 494;
  18626. t['epsilon'] = 439;
  18627. t['phi'] = 521;
  18628. t['gamma'] = 411;
  18629. t['eta'] = 603;
  18630. t['iota'] = 329;
  18631. t['phi1'] = 603;
  18632. t['kappa'] = 549;
  18633. t['lambda'] = 549;
  18634. t['mu'] = 576;
  18635. t['nu'] = 521;
  18636. t['omicron'] = 549;
  18637. t['pi'] = 549;
  18638. t['theta'] = 521;
  18639. t['rho'] = 549;
  18640. t['sigma'] = 603;
  18641. t['tau'] = 439;
  18642. t['upsilon'] = 576;
  18643. t['omega1'] = 713;
  18644. t['omega'] = 686;
  18645. t['xi'] = 493;
  18646. t['psi'] = 686;
  18647. t['zeta'] = 494;
  18648. t['braceleft'] = 480;
  18649. t['bar'] = 200;
  18650. t['braceright'] = 480;
  18651. t['similar'] = 549;
  18652. t['Euro'] = 750;
  18653. t['Upsilon1'] = 620;
  18654. t['minute'] = 247;
  18655. t['lessequal'] = 549;
  18656. t['fraction'] = 167;
  18657. t['infinity'] = 713;
  18658. t['florin'] = 500;
  18659. t['club'] = 753;
  18660. t['diamond'] = 753;
  18661. t['heart'] = 753;
  18662. t['spade'] = 753;
  18663. t['arrowboth'] = 1042;
  18664. t['arrowleft'] = 987;
  18665. t['arrowup'] = 603;
  18666. t['arrowright'] = 987;
  18667. t['arrowdown'] = 603;
  18668. t['degree'] = 400;
  18669. t['plusminus'] = 549;
  18670. t['second'] = 411;
  18671. t['greaterequal'] = 549;
  18672. t['multiply'] = 549;
  18673. t['proportional'] = 713;
  18674. t['partialdiff'] = 494;
  18675. t['bullet'] = 460;
  18676. t['divide'] = 549;
  18677. t['notequal'] = 549;
  18678. t['equivalence'] = 549;
  18679. t['approxequal'] = 549;
  18680. t['ellipsis'] = 1000;
  18681. t['arrowvertex'] = 603;
  18682. t['arrowhorizex'] = 1000;
  18683. t['carriagereturn'] = 658;
  18684. t['aleph'] = 823;
  18685. t['Ifraktur'] = 686;
  18686. t['Rfraktur'] = 795;
  18687. t['weierstrass'] = 987;
  18688. t['circlemultiply'] = 768;
  18689. t['circleplus'] = 768;
  18690. t['emptyset'] = 823;
  18691. t['intersection'] = 768;
  18692. t['union'] = 768;
  18693. t['propersuperset'] = 713;
  18694. t['reflexsuperset'] = 713;
  18695. t['notsubset'] = 713;
  18696. t['propersubset'] = 713;
  18697. t['reflexsubset'] = 713;
  18698. t['element'] = 713;
  18699. t['notelement'] = 713;
  18700. t['angle'] = 768;
  18701. t['gradient'] = 713;
  18702. t['registerserif'] = 790;
  18703. t['copyrightserif'] = 790;
  18704. t['trademarkserif'] = 890;
  18705. t['product'] = 823;
  18706. t['radical'] = 549;
  18707. t['dotmath'] = 250;
  18708. t['logicalnot'] = 713;
  18709. t['logicaland'] = 603;
  18710. t['logicalor'] = 603;
  18711. t['arrowdblboth'] = 1042;
  18712. t['arrowdblleft'] = 987;
  18713. t['arrowdblup'] = 603;
  18714. t['arrowdblright'] = 987;
  18715. t['arrowdbldown'] = 603;
  18716. t['lozenge'] = 494;
  18717. t['angleleft'] = 329;
  18718. t['registersans'] = 790;
  18719. t['copyrightsans'] = 790;
  18720. t['trademarksans'] = 786;
  18721. t['summation'] = 713;
  18722. t['parenlefttp'] = 384;
  18723. t['parenleftex'] = 384;
  18724. t['parenleftbt'] = 384;
  18725. t['bracketlefttp'] = 384;
  18726. t['bracketleftex'] = 384;
  18727. t['bracketleftbt'] = 384;
  18728. t['bracelefttp'] = 494;
  18729. t['braceleftmid'] = 494;
  18730. t['braceleftbt'] = 494;
  18731. t['braceex'] = 494;
  18732. t['angleright'] = 329;
  18733. t['integral'] = 274;
  18734. t['integraltp'] = 686;
  18735. t['integralex'] = 686;
  18736. t['integralbt'] = 686;
  18737. t['parenrighttp'] = 384;
  18738. t['parenrightex'] = 384;
  18739. t['parenrightbt'] = 384;
  18740. t['bracketrighttp'] = 384;
  18741. t['bracketrightex'] = 384;
  18742. t['bracketrightbt'] = 384;
  18743. t['bracerighttp'] = 494;
  18744. t['bracerightmid'] = 494;
  18745. t['bracerightbt'] = 494;
  18746. t['apple'] = 790;
  18747. });
  18748. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18749. t['space'] = 250;
  18750. t['exclam'] = 333;
  18751. t['quotedbl'] = 408;
  18752. t['numbersign'] = 500;
  18753. t['dollar'] = 500;
  18754. t['percent'] = 833;
  18755. t['ampersand'] = 778;
  18756. t['quoteright'] = 333;
  18757. t['parenleft'] = 333;
  18758. t['parenright'] = 333;
  18759. t['asterisk'] = 500;
  18760. t['plus'] = 564;
  18761. t['comma'] = 250;
  18762. t['hyphen'] = 333;
  18763. t['period'] = 250;
  18764. t['slash'] = 278;
  18765. t['zero'] = 500;
  18766. t['one'] = 500;
  18767. t['two'] = 500;
  18768. t['three'] = 500;
  18769. t['four'] = 500;
  18770. t['five'] = 500;
  18771. t['six'] = 500;
  18772. t['seven'] = 500;
  18773. t['eight'] = 500;
  18774. t['nine'] = 500;
  18775. t['colon'] = 278;
  18776. t['semicolon'] = 278;
  18777. t['less'] = 564;
  18778. t['equal'] = 564;
  18779. t['greater'] = 564;
  18780. t['question'] = 444;
  18781. t['at'] = 921;
  18782. t['A'] = 722;
  18783. t['B'] = 667;
  18784. t['C'] = 667;
  18785. t['D'] = 722;
  18786. t['E'] = 611;
  18787. t['F'] = 556;
  18788. t['G'] = 722;
  18789. t['H'] = 722;
  18790. t['I'] = 333;
  18791. t['J'] = 389;
  18792. t['K'] = 722;
  18793. t['L'] = 611;
  18794. t['M'] = 889;
  18795. t['N'] = 722;
  18796. t['O'] = 722;
  18797. t['P'] = 556;
  18798. t['Q'] = 722;
  18799. t['R'] = 667;
  18800. t['S'] = 556;
  18801. t['T'] = 611;
  18802. t['U'] = 722;
  18803. t['V'] = 722;
  18804. t['W'] = 944;
  18805. t['X'] = 722;
  18806. t['Y'] = 722;
  18807. t['Z'] = 611;
  18808. t['bracketleft'] = 333;
  18809. t['backslash'] = 278;
  18810. t['bracketright'] = 333;
  18811. t['asciicircum'] = 469;
  18812. t['underscore'] = 500;
  18813. t['quoteleft'] = 333;
  18814. t['a'] = 444;
  18815. t['b'] = 500;
  18816. t['c'] = 444;
  18817. t['d'] = 500;
  18818. t['e'] = 444;
  18819. t['f'] = 333;
  18820. t['g'] = 500;
  18821. t['h'] = 500;
  18822. t['i'] = 278;
  18823. t['j'] = 278;
  18824. t['k'] = 500;
  18825. t['l'] = 278;
  18826. t['m'] = 778;
  18827. t['n'] = 500;
  18828. t['o'] = 500;
  18829. t['p'] = 500;
  18830. t['q'] = 500;
  18831. t['r'] = 333;
  18832. t['s'] = 389;
  18833. t['t'] = 278;
  18834. t['u'] = 500;
  18835. t['v'] = 500;
  18836. t['w'] = 722;
  18837. t['x'] = 500;
  18838. t['y'] = 500;
  18839. t['z'] = 444;
  18840. t['braceleft'] = 480;
  18841. t['bar'] = 200;
  18842. t['braceright'] = 480;
  18843. t['asciitilde'] = 541;
  18844. t['exclamdown'] = 333;
  18845. t['cent'] = 500;
  18846. t['sterling'] = 500;
  18847. t['fraction'] = 167;
  18848. t['yen'] = 500;
  18849. t['florin'] = 500;
  18850. t['section'] = 500;
  18851. t['currency'] = 500;
  18852. t['quotesingle'] = 180;
  18853. t['quotedblleft'] = 444;
  18854. t['guillemotleft'] = 500;
  18855. t['guilsinglleft'] = 333;
  18856. t['guilsinglright'] = 333;
  18857. t['fi'] = 556;
  18858. t['fl'] = 556;
  18859. t['endash'] = 500;
  18860. t['dagger'] = 500;
  18861. t['daggerdbl'] = 500;
  18862. t['periodcentered'] = 250;
  18863. t['paragraph'] = 453;
  18864. t['bullet'] = 350;
  18865. t['quotesinglbase'] = 333;
  18866. t['quotedblbase'] = 444;
  18867. t['quotedblright'] = 444;
  18868. t['guillemotright'] = 500;
  18869. t['ellipsis'] = 1000;
  18870. t['perthousand'] = 1000;
  18871. t['questiondown'] = 444;
  18872. t['grave'] = 333;
  18873. t['acute'] = 333;
  18874. t['circumflex'] = 333;
  18875. t['tilde'] = 333;
  18876. t['macron'] = 333;
  18877. t['breve'] = 333;
  18878. t['dotaccent'] = 333;
  18879. t['dieresis'] = 333;
  18880. t['ring'] = 333;
  18881. t['cedilla'] = 333;
  18882. t['hungarumlaut'] = 333;
  18883. t['ogonek'] = 333;
  18884. t['caron'] = 333;
  18885. t['emdash'] = 1000;
  18886. t['AE'] = 889;
  18887. t['ordfeminine'] = 276;
  18888. t['Lslash'] = 611;
  18889. t['Oslash'] = 722;
  18890. t['OE'] = 889;
  18891. t['ordmasculine'] = 310;
  18892. t['ae'] = 667;
  18893. t['dotlessi'] = 278;
  18894. t['lslash'] = 278;
  18895. t['oslash'] = 500;
  18896. t['oe'] = 722;
  18897. t['germandbls'] = 500;
  18898. t['Idieresis'] = 333;
  18899. t['eacute'] = 444;
  18900. t['abreve'] = 444;
  18901. t['uhungarumlaut'] = 500;
  18902. t['ecaron'] = 444;
  18903. t['Ydieresis'] = 722;
  18904. t['divide'] = 564;
  18905. t['Yacute'] = 722;
  18906. t['Acircumflex'] = 722;
  18907. t['aacute'] = 444;
  18908. t['Ucircumflex'] = 722;
  18909. t['yacute'] = 500;
  18910. t['scommaaccent'] = 389;
  18911. t['ecircumflex'] = 444;
  18912. t['Uring'] = 722;
  18913. t['Udieresis'] = 722;
  18914. t['aogonek'] = 444;
  18915. t['Uacute'] = 722;
  18916. t['uogonek'] = 500;
  18917. t['Edieresis'] = 611;
  18918. t['Dcroat'] = 722;
  18919. t['commaaccent'] = 250;
  18920. t['copyright'] = 760;
  18921. t['Emacron'] = 611;
  18922. t['ccaron'] = 444;
  18923. t['aring'] = 444;
  18924. t['Ncommaaccent'] = 722;
  18925. t['lacute'] = 278;
  18926. t['agrave'] = 444;
  18927. t['Tcommaaccent'] = 611;
  18928. t['Cacute'] = 667;
  18929. t['atilde'] = 444;
  18930. t['Edotaccent'] = 611;
  18931. t['scaron'] = 389;
  18932. t['scedilla'] = 389;
  18933. t['iacute'] = 278;
  18934. t['lozenge'] = 471;
  18935. t['Rcaron'] = 667;
  18936. t['Gcommaaccent'] = 722;
  18937. t['ucircumflex'] = 500;
  18938. t['acircumflex'] = 444;
  18939. t['Amacron'] = 722;
  18940. t['rcaron'] = 333;
  18941. t['ccedilla'] = 444;
  18942. t['Zdotaccent'] = 611;
  18943. t['Thorn'] = 556;
  18944. t['Omacron'] = 722;
  18945. t['Racute'] = 667;
  18946. t['Sacute'] = 556;
  18947. t['dcaron'] = 588;
  18948. t['Umacron'] = 722;
  18949. t['uring'] = 500;
  18950. t['threesuperior'] = 300;
  18951. t['Ograve'] = 722;
  18952. t['Agrave'] = 722;
  18953. t['Abreve'] = 722;
  18954. t['multiply'] = 564;
  18955. t['uacute'] = 500;
  18956. t['Tcaron'] = 611;
  18957. t['partialdiff'] = 476;
  18958. t['ydieresis'] = 500;
  18959. t['Nacute'] = 722;
  18960. t['icircumflex'] = 278;
  18961. t['Ecircumflex'] = 611;
  18962. t['adieresis'] = 444;
  18963. t['edieresis'] = 444;
  18964. t['cacute'] = 444;
  18965. t['nacute'] = 500;
  18966. t['umacron'] = 500;
  18967. t['Ncaron'] = 722;
  18968. t['Iacute'] = 333;
  18969. t['plusminus'] = 564;
  18970. t['brokenbar'] = 200;
  18971. t['registered'] = 760;
  18972. t['Gbreve'] = 722;
  18973. t['Idotaccent'] = 333;
  18974. t['summation'] = 600;
  18975. t['Egrave'] = 611;
  18976. t['racute'] = 333;
  18977. t['omacron'] = 500;
  18978. t['Zacute'] = 611;
  18979. t['Zcaron'] = 611;
  18980. t['greaterequal'] = 549;
  18981. t['Eth'] = 722;
  18982. t['Ccedilla'] = 667;
  18983. t['lcommaaccent'] = 278;
  18984. t['tcaron'] = 326;
  18985. t['eogonek'] = 444;
  18986. t['Uogonek'] = 722;
  18987. t['Aacute'] = 722;
  18988. t['Adieresis'] = 722;
  18989. t['egrave'] = 444;
  18990. t['zacute'] = 444;
  18991. t['iogonek'] = 278;
  18992. t['Oacute'] = 722;
  18993. t['oacute'] = 500;
  18994. t['amacron'] = 444;
  18995. t['sacute'] = 389;
  18996. t['idieresis'] = 278;
  18997. t['Ocircumflex'] = 722;
  18998. t['Ugrave'] = 722;
  18999. t['Delta'] = 612;
  19000. t['thorn'] = 500;
  19001. t['twosuperior'] = 300;
  19002. t['Odieresis'] = 722;
  19003. t['mu'] = 500;
  19004. t['igrave'] = 278;
  19005. t['ohungarumlaut'] = 500;
  19006. t['Eogonek'] = 611;
  19007. t['dcroat'] = 500;
  19008. t['threequarters'] = 750;
  19009. t['Scedilla'] = 556;
  19010. t['lcaron'] = 344;
  19011. t['Kcommaaccent'] = 722;
  19012. t['Lacute'] = 611;
  19013. t['trademark'] = 980;
  19014. t['edotaccent'] = 444;
  19015. t['Igrave'] = 333;
  19016. t['Imacron'] = 333;
  19017. t['Lcaron'] = 611;
  19018. t['onehalf'] = 750;
  19019. t['lessequal'] = 549;
  19020. t['ocircumflex'] = 500;
  19021. t['ntilde'] = 500;
  19022. t['Uhungarumlaut'] = 722;
  19023. t['Eacute'] = 611;
  19024. t['emacron'] = 444;
  19025. t['gbreve'] = 500;
  19026. t['onequarter'] = 750;
  19027. t['Scaron'] = 556;
  19028. t['Scommaaccent'] = 556;
  19029. t['Ohungarumlaut'] = 722;
  19030. t['degree'] = 400;
  19031. t['ograve'] = 500;
  19032. t['Ccaron'] = 667;
  19033. t['ugrave'] = 500;
  19034. t['radical'] = 453;
  19035. t['Dcaron'] = 722;
  19036. t['rcommaaccent'] = 333;
  19037. t['Ntilde'] = 722;
  19038. t['otilde'] = 500;
  19039. t['Rcommaaccent'] = 667;
  19040. t['Lcommaaccent'] = 611;
  19041. t['Atilde'] = 722;
  19042. t['Aogonek'] = 722;
  19043. t['Aring'] = 722;
  19044. t['Otilde'] = 722;
  19045. t['zdotaccent'] = 444;
  19046. t['Ecaron'] = 611;
  19047. t['Iogonek'] = 333;
  19048. t['kcommaaccent'] = 500;
  19049. t['minus'] = 564;
  19050. t['Icircumflex'] = 333;
  19051. t['ncaron'] = 500;
  19052. t['tcommaaccent'] = 278;
  19053. t['logicalnot'] = 564;
  19054. t['odieresis'] = 500;
  19055. t['udieresis'] = 500;
  19056. t['notequal'] = 549;
  19057. t['gcommaaccent'] = 500;
  19058. t['eth'] = 500;
  19059. t['zcaron'] = 444;
  19060. t['ncommaaccent'] = 500;
  19061. t['onesuperior'] = 300;
  19062. t['imacron'] = 278;
  19063. t['Euro'] = 500;
  19064. });
  19065. t['Times-Bold'] = getLookupTableFactory(function (t) {
  19066. t['space'] = 250;
  19067. t['exclam'] = 333;
  19068. t['quotedbl'] = 555;
  19069. t['numbersign'] = 500;
  19070. t['dollar'] = 500;
  19071. t['percent'] = 1000;
  19072. t['ampersand'] = 833;
  19073. t['quoteright'] = 333;
  19074. t['parenleft'] = 333;
  19075. t['parenright'] = 333;
  19076. t['asterisk'] = 500;
  19077. t['plus'] = 570;
  19078. t['comma'] = 250;
  19079. t['hyphen'] = 333;
  19080. t['period'] = 250;
  19081. t['slash'] = 278;
  19082. t['zero'] = 500;
  19083. t['one'] = 500;
  19084. t['two'] = 500;
  19085. t['three'] = 500;
  19086. t['four'] = 500;
  19087. t['five'] = 500;
  19088. t['six'] = 500;
  19089. t['seven'] = 500;
  19090. t['eight'] = 500;
  19091. t['nine'] = 500;
  19092. t['colon'] = 333;
  19093. t['semicolon'] = 333;
  19094. t['less'] = 570;
  19095. t['equal'] = 570;
  19096. t['greater'] = 570;
  19097. t['question'] = 500;
  19098. t['at'] = 930;
  19099. t['A'] = 722;
  19100. t['B'] = 667;
  19101. t['C'] = 722;
  19102. t['D'] = 722;
  19103. t['E'] = 667;
  19104. t['F'] = 611;
  19105. t['G'] = 778;
  19106. t['H'] = 778;
  19107. t['I'] = 389;
  19108. t['J'] = 500;
  19109. t['K'] = 778;
  19110. t['L'] = 667;
  19111. t['M'] = 944;
  19112. t['N'] = 722;
  19113. t['O'] = 778;
  19114. t['P'] = 611;
  19115. t['Q'] = 778;
  19116. t['R'] = 722;
  19117. t['S'] = 556;
  19118. t['T'] = 667;
  19119. t['U'] = 722;
  19120. t['V'] = 722;
  19121. t['W'] = 1000;
  19122. t['X'] = 722;
  19123. t['Y'] = 722;
  19124. t['Z'] = 667;
  19125. t['bracketleft'] = 333;
  19126. t['backslash'] = 278;
  19127. t['bracketright'] = 333;
  19128. t['asciicircum'] = 581;
  19129. t['underscore'] = 500;
  19130. t['quoteleft'] = 333;
  19131. t['a'] = 500;
  19132. t['b'] = 556;
  19133. t['c'] = 444;
  19134. t['d'] = 556;
  19135. t['e'] = 444;
  19136. t['f'] = 333;
  19137. t['g'] = 500;
  19138. t['h'] = 556;
  19139. t['i'] = 278;
  19140. t['j'] = 333;
  19141. t['k'] = 556;
  19142. t['l'] = 278;
  19143. t['m'] = 833;
  19144. t['n'] = 556;
  19145. t['o'] = 500;
  19146. t['p'] = 556;
  19147. t['q'] = 556;
  19148. t['r'] = 444;
  19149. t['s'] = 389;
  19150. t['t'] = 333;
  19151. t['u'] = 556;
  19152. t['v'] = 500;
  19153. t['w'] = 722;
  19154. t['x'] = 500;
  19155. t['y'] = 500;
  19156. t['z'] = 444;
  19157. t['braceleft'] = 394;
  19158. t['bar'] = 220;
  19159. t['braceright'] = 394;
  19160. t['asciitilde'] = 520;
  19161. t['exclamdown'] = 333;
  19162. t['cent'] = 500;
  19163. t['sterling'] = 500;
  19164. t['fraction'] = 167;
  19165. t['yen'] = 500;
  19166. t['florin'] = 500;
  19167. t['section'] = 500;
  19168. t['currency'] = 500;
  19169. t['quotesingle'] = 278;
  19170. t['quotedblleft'] = 500;
  19171. t['guillemotleft'] = 500;
  19172. t['guilsinglleft'] = 333;
  19173. t['guilsinglright'] = 333;
  19174. t['fi'] = 556;
  19175. t['fl'] = 556;
  19176. t['endash'] = 500;
  19177. t['dagger'] = 500;
  19178. t['daggerdbl'] = 500;
  19179. t['periodcentered'] = 250;
  19180. t['paragraph'] = 540;
  19181. t['bullet'] = 350;
  19182. t['quotesinglbase'] = 333;
  19183. t['quotedblbase'] = 500;
  19184. t['quotedblright'] = 500;
  19185. t['guillemotright'] = 500;
  19186. t['ellipsis'] = 1000;
  19187. t['perthousand'] = 1000;
  19188. t['questiondown'] = 500;
  19189. t['grave'] = 333;
  19190. t['acute'] = 333;
  19191. t['circumflex'] = 333;
  19192. t['tilde'] = 333;
  19193. t['macron'] = 333;
  19194. t['breve'] = 333;
  19195. t['dotaccent'] = 333;
  19196. t['dieresis'] = 333;
  19197. t['ring'] = 333;
  19198. t['cedilla'] = 333;
  19199. t['hungarumlaut'] = 333;
  19200. t['ogonek'] = 333;
  19201. t['caron'] = 333;
  19202. t['emdash'] = 1000;
  19203. t['AE'] = 1000;
  19204. t['ordfeminine'] = 300;
  19205. t['Lslash'] = 667;
  19206. t['Oslash'] = 778;
  19207. t['OE'] = 1000;
  19208. t['ordmasculine'] = 330;
  19209. t['ae'] = 722;
  19210. t['dotlessi'] = 278;
  19211. t['lslash'] = 278;
  19212. t['oslash'] = 500;
  19213. t['oe'] = 722;
  19214. t['germandbls'] = 556;
  19215. t['Idieresis'] = 389;
  19216. t['eacute'] = 444;
  19217. t['abreve'] = 500;
  19218. t['uhungarumlaut'] = 556;
  19219. t['ecaron'] = 444;
  19220. t['Ydieresis'] = 722;
  19221. t['divide'] = 570;
  19222. t['Yacute'] = 722;
  19223. t['Acircumflex'] = 722;
  19224. t['aacute'] = 500;
  19225. t['Ucircumflex'] = 722;
  19226. t['yacute'] = 500;
  19227. t['scommaaccent'] = 389;
  19228. t['ecircumflex'] = 444;
  19229. t['Uring'] = 722;
  19230. t['Udieresis'] = 722;
  19231. t['aogonek'] = 500;
  19232. t['Uacute'] = 722;
  19233. t['uogonek'] = 556;
  19234. t['Edieresis'] = 667;
  19235. t['Dcroat'] = 722;
  19236. t['commaaccent'] = 250;
  19237. t['copyright'] = 747;
  19238. t['Emacron'] = 667;
  19239. t['ccaron'] = 444;
  19240. t['aring'] = 500;
  19241. t['Ncommaaccent'] = 722;
  19242. t['lacute'] = 278;
  19243. t['agrave'] = 500;
  19244. t['Tcommaaccent'] = 667;
  19245. t['Cacute'] = 722;
  19246. t['atilde'] = 500;
  19247. t['Edotaccent'] = 667;
  19248. t['scaron'] = 389;
  19249. t['scedilla'] = 389;
  19250. t['iacute'] = 278;
  19251. t['lozenge'] = 494;
  19252. t['Rcaron'] = 722;
  19253. t['Gcommaaccent'] = 778;
  19254. t['ucircumflex'] = 556;
  19255. t['acircumflex'] = 500;
  19256. t['Amacron'] = 722;
  19257. t['rcaron'] = 444;
  19258. t['ccedilla'] = 444;
  19259. t['Zdotaccent'] = 667;
  19260. t['Thorn'] = 611;
  19261. t['Omacron'] = 778;
  19262. t['Racute'] = 722;
  19263. t['Sacute'] = 556;
  19264. t['dcaron'] = 672;
  19265. t['Umacron'] = 722;
  19266. t['uring'] = 556;
  19267. t['threesuperior'] = 300;
  19268. t['Ograve'] = 778;
  19269. t['Agrave'] = 722;
  19270. t['Abreve'] = 722;
  19271. t['multiply'] = 570;
  19272. t['uacute'] = 556;
  19273. t['Tcaron'] = 667;
  19274. t['partialdiff'] = 494;
  19275. t['ydieresis'] = 500;
  19276. t['Nacute'] = 722;
  19277. t['icircumflex'] = 278;
  19278. t['Ecircumflex'] = 667;
  19279. t['adieresis'] = 500;
  19280. t['edieresis'] = 444;
  19281. t['cacute'] = 444;
  19282. t['nacute'] = 556;
  19283. t['umacron'] = 556;
  19284. t['Ncaron'] = 722;
  19285. t['Iacute'] = 389;
  19286. t['plusminus'] = 570;
  19287. t['brokenbar'] = 220;
  19288. t['registered'] = 747;
  19289. t['Gbreve'] = 778;
  19290. t['Idotaccent'] = 389;
  19291. t['summation'] = 600;
  19292. t['Egrave'] = 667;
  19293. t['racute'] = 444;
  19294. t['omacron'] = 500;
  19295. t['Zacute'] = 667;
  19296. t['Zcaron'] = 667;
  19297. t['greaterequal'] = 549;
  19298. t['Eth'] = 722;
  19299. t['Ccedilla'] = 722;
  19300. t['lcommaaccent'] = 278;
  19301. t['tcaron'] = 416;
  19302. t['eogonek'] = 444;
  19303. t['Uogonek'] = 722;
  19304. t['Aacute'] = 722;
  19305. t['Adieresis'] = 722;
  19306. t['egrave'] = 444;
  19307. t['zacute'] = 444;
  19308. t['iogonek'] = 278;
  19309. t['Oacute'] = 778;
  19310. t['oacute'] = 500;
  19311. t['amacron'] = 500;
  19312. t['sacute'] = 389;
  19313. t['idieresis'] = 278;
  19314. t['Ocircumflex'] = 778;
  19315. t['Ugrave'] = 722;
  19316. t['Delta'] = 612;
  19317. t['thorn'] = 556;
  19318. t['twosuperior'] = 300;
  19319. t['Odieresis'] = 778;
  19320. t['mu'] = 556;
  19321. t['igrave'] = 278;
  19322. t['ohungarumlaut'] = 500;
  19323. t['Eogonek'] = 667;
  19324. t['dcroat'] = 556;
  19325. t['threequarters'] = 750;
  19326. t['Scedilla'] = 556;
  19327. t['lcaron'] = 394;
  19328. t['Kcommaaccent'] = 778;
  19329. t['Lacute'] = 667;
  19330. t['trademark'] = 1000;
  19331. t['edotaccent'] = 444;
  19332. t['Igrave'] = 389;
  19333. t['Imacron'] = 389;
  19334. t['Lcaron'] = 667;
  19335. t['onehalf'] = 750;
  19336. t['lessequal'] = 549;
  19337. t['ocircumflex'] = 500;
  19338. t['ntilde'] = 556;
  19339. t['Uhungarumlaut'] = 722;
  19340. t['Eacute'] = 667;
  19341. t['emacron'] = 444;
  19342. t['gbreve'] = 500;
  19343. t['onequarter'] = 750;
  19344. t['Scaron'] = 556;
  19345. t['Scommaaccent'] = 556;
  19346. t['Ohungarumlaut'] = 778;
  19347. t['degree'] = 400;
  19348. t['ograve'] = 500;
  19349. t['Ccaron'] = 722;
  19350. t['ugrave'] = 556;
  19351. t['radical'] = 549;
  19352. t['Dcaron'] = 722;
  19353. t['rcommaaccent'] = 444;
  19354. t['Ntilde'] = 722;
  19355. t['otilde'] = 500;
  19356. t['Rcommaaccent'] = 722;
  19357. t['Lcommaaccent'] = 667;
  19358. t['Atilde'] = 722;
  19359. t['Aogonek'] = 722;
  19360. t['Aring'] = 722;
  19361. t['Otilde'] = 778;
  19362. t['zdotaccent'] = 444;
  19363. t['Ecaron'] = 667;
  19364. t['Iogonek'] = 389;
  19365. t['kcommaaccent'] = 556;
  19366. t['minus'] = 570;
  19367. t['Icircumflex'] = 389;
  19368. t['ncaron'] = 556;
  19369. t['tcommaaccent'] = 333;
  19370. t['logicalnot'] = 570;
  19371. t['odieresis'] = 500;
  19372. t['udieresis'] = 556;
  19373. t['notequal'] = 549;
  19374. t['gcommaaccent'] = 500;
  19375. t['eth'] = 500;
  19376. t['zcaron'] = 444;
  19377. t['ncommaaccent'] = 556;
  19378. t['onesuperior'] = 300;
  19379. t['imacron'] = 278;
  19380. t['Euro'] = 500;
  19381. });
  19382. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19383. t['space'] = 250;
  19384. t['exclam'] = 389;
  19385. t['quotedbl'] = 555;
  19386. t['numbersign'] = 500;
  19387. t['dollar'] = 500;
  19388. t['percent'] = 833;
  19389. t['ampersand'] = 778;
  19390. t['quoteright'] = 333;
  19391. t['parenleft'] = 333;
  19392. t['parenright'] = 333;
  19393. t['asterisk'] = 500;
  19394. t['plus'] = 570;
  19395. t['comma'] = 250;
  19396. t['hyphen'] = 333;
  19397. t['period'] = 250;
  19398. t['slash'] = 278;
  19399. t['zero'] = 500;
  19400. t['one'] = 500;
  19401. t['two'] = 500;
  19402. t['three'] = 500;
  19403. t['four'] = 500;
  19404. t['five'] = 500;
  19405. t['six'] = 500;
  19406. t['seven'] = 500;
  19407. t['eight'] = 500;
  19408. t['nine'] = 500;
  19409. t['colon'] = 333;
  19410. t['semicolon'] = 333;
  19411. t['less'] = 570;
  19412. t['equal'] = 570;
  19413. t['greater'] = 570;
  19414. t['question'] = 500;
  19415. t['at'] = 832;
  19416. t['A'] = 667;
  19417. t['B'] = 667;
  19418. t['C'] = 667;
  19419. t['D'] = 722;
  19420. t['E'] = 667;
  19421. t['F'] = 667;
  19422. t['G'] = 722;
  19423. t['H'] = 778;
  19424. t['I'] = 389;
  19425. t['J'] = 500;
  19426. t['K'] = 667;
  19427. t['L'] = 611;
  19428. t['M'] = 889;
  19429. t['N'] = 722;
  19430. t['O'] = 722;
  19431. t['P'] = 611;
  19432. t['Q'] = 722;
  19433. t['R'] = 667;
  19434. t['S'] = 556;
  19435. t['T'] = 611;
  19436. t['U'] = 722;
  19437. t['V'] = 667;
  19438. t['W'] = 889;
  19439. t['X'] = 667;
  19440. t['Y'] = 611;
  19441. t['Z'] = 611;
  19442. t['bracketleft'] = 333;
  19443. t['backslash'] = 278;
  19444. t['bracketright'] = 333;
  19445. t['asciicircum'] = 570;
  19446. t['underscore'] = 500;
  19447. t['quoteleft'] = 333;
  19448. t['a'] = 500;
  19449. t['b'] = 500;
  19450. t['c'] = 444;
  19451. t['d'] = 500;
  19452. t['e'] = 444;
  19453. t['f'] = 333;
  19454. t['g'] = 500;
  19455. t['h'] = 556;
  19456. t['i'] = 278;
  19457. t['j'] = 278;
  19458. t['k'] = 500;
  19459. t['l'] = 278;
  19460. t['m'] = 778;
  19461. t['n'] = 556;
  19462. t['o'] = 500;
  19463. t['p'] = 500;
  19464. t['q'] = 500;
  19465. t['r'] = 389;
  19466. t['s'] = 389;
  19467. t['t'] = 278;
  19468. t['u'] = 556;
  19469. t['v'] = 444;
  19470. t['w'] = 667;
  19471. t['x'] = 500;
  19472. t['y'] = 444;
  19473. t['z'] = 389;
  19474. t['braceleft'] = 348;
  19475. t['bar'] = 220;
  19476. t['braceright'] = 348;
  19477. t['asciitilde'] = 570;
  19478. t['exclamdown'] = 389;
  19479. t['cent'] = 500;
  19480. t['sterling'] = 500;
  19481. t['fraction'] = 167;
  19482. t['yen'] = 500;
  19483. t['florin'] = 500;
  19484. t['section'] = 500;
  19485. t['currency'] = 500;
  19486. t['quotesingle'] = 278;
  19487. t['quotedblleft'] = 500;
  19488. t['guillemotleft'] = 500;
  19489. t['guilsinglleft'] = 333;
  19490. t['guilsinglright'] = 333;
  19491. t['fi'] = 556;
  19492. t['fl'] = 556;
  19493. t['endash'] = 500;
  19494. t['dagger'] = 500;
  19495. t['daggerdbl'] = 500;
  19496. t['periodcentered'] = 250;
  19497. t['paragraph'] = 500;
  19498. t['bullet'] = 350;
  19499. t['quotesinglbase'] = 333;
  19500. t['quotedblbase'] = 500;
  19501. t['quotedblright'] = 500;
  19502. t['guillemotright'] = 500;
  19503. t['ellipsis'] = 1000;
  19504. t['perthousand'] = 1000;
  19505. t['questiondown'] = 500;
  19506. t['grave'] = 333;
  19507. t['acute'] = 333;
  19508. t['circumflex'] = 333;
  19509. t['tilde'] = 333;
  19510. t['macron'] = 333;
  19511. t['breve'] = 333;
  19512. t['dotaccent'] = 333;
  19513. t['dieresis'] = 333;
  19514. t['ring'] = 333;
  19515. t['cedilla'] = 333;
  19516. t['hungarumlaut'] = 333;
  19517. t['ogonek'] = 333;
  19518. t['caron'] = 333;
  19519. t['emdash'] = 1000;
  19520. t['AE'] = 944;
  19521. t['ordfeminine'] = 266;
  19522. t['Lslash'] = 611;
  19523. t['Oslash'] = 722;
  19524. t['OE'] = 944;
  19525. t['ordmasculine'] = 300;
  19526. t['ae'] = 722;
  19527. t['dotlessi'] = 278;
  19528. t['lslash'] = 278;
  19529. t['oslash'] = 500;
  19530. t['oe'] = 722;
  19531. t['germandbls'] = 500;
  19532. t['Idieresis'] = 389;
  19533. t['eacute'] = 444;
  19534. t['abreve'] = 500;
  19535. t['uhungarumlaut'] = 556;
  19536. t['ecaron'] = 444;
  19537. t['Ydieresis'] = 611;
  19538. t['divide'] = 570;
  19539. t['Yacute'] = 611;
  19540. t['Acircumflex'] = 667;
  19541. t['aacute'] = 500;
  19542. t['Ucircumflex'] = 722;
  19543. t['yacute'] = 444;
  19544. t['scommaaccent'] = 389;
  19545. t['ecircumflex'] = 444;
  19546. t['Uring'] = 722;
  19547. t['Udieresis'] = 722;
  19548. t['aogonek'] = 500;
  19549. t['Uacute'] = 722;
  19550. t['uogonek'] = 556;
  19551. t['Edieresis'] = 667;
  19552. t['Dcroat'] = 722;
  19553. t['commaaccent'] = 250;
  19554. t['copyright'] = 747;
  19555. t['Emacron'] = 667;
  19556. t['ccaron'] = 444;
  19557. t['aring'] = 500;
  19558. t['Ncommaaccent'] = 722;
  19559. t['lacute'] = 278;
  19560. t['agrave'] = 500;
  19561. t['Tcommaaccent'] = 611;
  19562. t['Cacute'] = 667;
  19563. t['atilde'] = 500;
  19564. t['Edotaccent'] = 667;
  19565. t['scaron'] = 389;
  19566. t['scedilla'] = 389;
  19567. t['iacute'] = 278;
  19568. t['lozenge'] = 494;
  19569. t['Rcaron'] = 667;
  19570. t['Gcommaaccent'] = 722;
  19571. t['ucircumflex'] = 556;
  19572. t['acircumflex'] = 500;
  19573. t['Amacron'] = 667;
  19574. t['rcaron'] = 389;
  19575. t['ccedilla'] = 444;
  19576. t['Zdotaccent'] = 611;
  19577. t['Thorn'] = 611;
  19578. t['Omacron'] = 722;
  19579. t['Racute'] = 667;
  19580. t['Sacute'] = 556;
  19581. t['dcaron'] = 608;
  19582. t['Umacron'] = 722;
  19583. t['uring'] = 556;
  19584. t['threesuperior'] = 300;
  19585. t['Ograve'] = 722;
  19586. t['Agrave'] = 667;
  19587. t['Abreve'] = 667;
  19588. t['multiply'] = 570;
  19589. t['uacute'] = 556;
  19590. t['Tcaron'] = 611;
  19591. t['partialdiff'] = 494;
  19592. t['ydieresis'] = 444;
  19593. t['Nacute'] = 722;
  19594. t['icircumflex'] = 278;
  19595. t['Ecircumflex'] = 667;
  19596. t['adieresis'] = 500;
  19597. t['edieresis'] = 444;
  19598. t['cacute'] = 444;
  19599. t['nacute'] = 556;
  19600. t['umacron'] = 556;
  19601. t['Ncaron'] = 722;
  19602. t['Iacute'] = 389;
  19603. t['plusminus'] = 570;
  19604. t['brokenbar'] = 220;
  19605. t['registered'] = 747;
  19606. t['Gbreve'] = 722;
  19607. t['Idotaccent'] = 389;
  19608. t['summation'] = 600;
  19609. t['Egrave'] = 667;
  19610. t['racute'] = 389;
  19611. t['omacron'] = 500;
  19612. t['Zacute'] = 611;
  19613. t['Zcaron'] = 611;
  19614. t['greaterequal'] = 549;
  19615. t['Eth'] = 722;
  19616. t['Ccedilla'] = 667;
  19617. t['lcommaaccent'] = 278;
  19618. t['tcaron'] = 366;
  19619. t['eogonek'] = 444;
  19620. t['Uogonek'] = 722;
  19621. t['Aacute'] = 667;
  19622. t['Adieresis'] = 667;
  19623. t['egrave'] = 444;
  19624. t['zacute'] = 389;
  19625. t['iogonek'] = 278;
  19626. t['Oacute'] = 722;
  19627. t['oacute'] = 500;
  19628. t['amacron'] = 500;
  19629. t['sacute'] = 389;
  19630. t['idieresis'] = 278;
  19631. t['Ocircumflex'] = 722;
  19632. t['Ugrave'] = 722;
  19633. t['Delta'] = 612;
  19634. t['thorn'] = 500;
  19635. t['twosuperior'] = 300;
  19636. t['Odieresis'] = 722;
  19637. t['mu'] = 576;
  19638. t['igrave'] = 278;
  19639. t['ohungarumlaut'] = 500;
  19640. t['Eogonek'] = 667;
  19641. t['dcroat'] = 500;
  19642. t['threequarters'] = 750;
  19643. t['Scedilla'] = 556;
  19644. t['lcaron'] = 382;
  19645. t['Kcommaaccent'] = 667;
  19646. t['Lacute'] = 611;
  19647. t['trademark'] = 1000;
  19648. t['edotaccent'] = 444;
  19649. t['Igrave'] = 389;
  19650. t['Imacron'] = 389;
  19651. t['Lcaron'] = 611;
  19652. t['onehalf'] = 750;
  19653. t['lessequal'] = 549;
  19654. t['ocircumflex'] = 500;
  19655. t['ntilde'] = 556;
  19656. t['Uhungarumlaut'] = 722;
  19657. t['Eacute'] = 667;
  19658. t['emacron'] = 444;
  19659. t['gbreve'] = 500;
  19660. t['onequarter'] = 750;
  19661. t['Scaron'] = 556;
  19662. t['Scommaaccent'] = 556;
  19663. t['Ohungarumlaut'] = 722;
  19664. t['degree'] = 400;
  19665. t['ograve'] = 500;
  19666. t['Ccaron'] = 667;
  19667. t['ugrave'] = 556;
  19668. t['radical'] = 549;
  19669. t['Dcaron'] = 722;
  19670. t['rcommaaccent'] = 389;
  19671. t['Ntilde'] = 722;
  19672. t['otilde'] = 500;
  19673. t['Rcommaaccent'] = 667;
  19674. t['Lcommaaccent'] = 611;
  19675. t['Atilde'] = 667;
  19676. t['Aogonek'] = 667;
  19677. t['Aring'] = 667;
  19678. t['Otilde'] = 722;
  19679. t['zdotaccent'] = 389;
  19680. t['Ecaron'] = 667;
  19681. t['Iogonek'] = 389;
  19682. t['kcommaaccent'] = 500;
  19683. t['minus'] = 606;
  19684. t['Icircumflex'] = 389;
  19685. t['ncaron'] = 556;
  19686. t['tcommaaccent'] = 278;
  19687. t['logicalnot'] = 606;
  19688. t['odieresis'] = 500;
  19689. t['udieresis'] = 556;
  19690. t['notequal'] = 549;
  19691. t['gcommaaccent'] = 500;
  19692. t['eth'] = 500;
  19693. t['zcaron'] = 389;
  19694. t['ncommaaccent'] = 556;
  19695. t['onesuperior'] = 300;
  19696. t['imacron'] = 278;
  19697. t['Euro'] = 500;
  19698. });
  19699. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19700. t['space'] = 250;
  19701. t['exclam'] = 333;
  19702. t['quotedbl'] = 420;
  19703. t['numbersign'] = 500;
  19704. t['dollar'] = 500;
  19705. t['percent'] = 833;
  19706. t['ampersand'] = 778;
  19707. t['quoteright'] = 333;
  19708. t['parenleft'] = 333;
  19709. t['parenright'] = 333;
  19710. t['asterisk'] = 500;
  19711. t['plus'] = 675;
  19712. t['comma'] = 250;
  19713. t['hyphen'] = 333;
  19714. t['period'] = 250;
  19715. t['slash'] = 278;
  19716. t['zero'] = 500;
  19717. t['one'] = 500;
  19718. t['two'] = 500;
  19719. t['three'] = 500;
  19720. t['four'] = 500;
  19721. t['five'] = 500;
  19722. t['six'] = 500;
  19723. t['seven'] = 500;
  19724. t['eight'] = 500;
  19725. t['nine'] = 500;
  19726. t['colon'] = 333;
  19727. t['semicolon'] = 333;
  19728. t['less'] = 675;
  19729. t['equal'] = 675;
  19730. t['greater'] = 675;
  19731. t['question'] = 500;
  19732. t['at'] = 920;
  19733. t['A'] = 611;
  19734. t['B'] = 611;
  19735. t['C'] = 667;
  19736. t['D'] = 722;
  19737. t['E'] = 611;
  19738. t['F'] = 611;
  19739. t['G'] = 722;
  19740. t['H'] = 722;
  19741. t['I'] = 333;
  19742. t['J'] = 444;
  19743. t['K'] = 667;
  19744. t['L'] = 556;
  19745. t['M'] = 833;
  19746. t['N'] = 667;
  19747. t['O'] = 722;
  19748. t['P'] = 611;
  19749. t['Q'] = 722;
  19750. t['R'] = 611;
  19751. t['S'] = 500;
  19752. t['T'] = 556;
  19753. t['U'] = 722;
  19754. t['V'] = 611;
  19755. t['W'] = 833;
  19756. t['X'] = 611;
  19757. t['Y'] = 556;
  19758. t['Z'] = 556;
  19759. t['bracketleft'] = 389;
  19760. t['backslash'] = 278;
  19761. t['bracketright'] = 389;
  19762. t['asciicircum'] = 422;
  19763. t['underscore'] = 500;
  19764. t['quoteleft'] = 333;
  19765. t['a'] = 500;
  19766. t['b'] = 500;
  19767. t['c'] = 444;
  19768. t['d'] = 500;
  19769. t['e'] = 444;
  19770. t['f'] = 278;
  19771. t['g'] = 500;
  19772. t['h'] = 500;
  19773. t['i'] = 278;
  19774. t['j'] = 278;
  19775. t['k'] = 444;
  19776. t['l'] = 278;
  19777. t['m'] = 722;
  19778. t['n'] = 500;
  19779. t['o'] = 500;
  19780. t['p'] = 500;
  19781. t['q'] = 500;
  19782. t['r'] = 389;
  19783. t['s'] = 389;
  19784. t['t'] = 278;
  19785. t['u'] = 500;
  19786. t['v'] = 444;
  19787. t['w'] = 667;
  19788. t['x'] = 444;
  19789. t['y'] = 444;
  19790. t['z'] = 389;
  19791. t['braceleft'] = 400;
  19792. t['bar'] = 275;
  19793. t['braceright'] = 400;
  19794. t['asciitilde'] = 541;
  19795. t['exclamdown'] = 389;
  19796. t['cent'] = 500;
  19797. t['sterling'] = 500;
  19798. t['fraction'] = 167;
  19799. t['yen'] = 500;
  19800. t['florin'] = 500;
  19801. t['section'] = 500;
  19802. t['currency'] = 500;
  19803. t['quotesingle'] = 214;
  19804. t['quotedblleft'] = 556;
  19805. t['guillemotleft'] = 500;
  19806. t['guilsinglleft'] = 333;
  19807. t['guilsinglright'] = 333;
  19808. t['fi'] = 500;
  19809. t['fl'] = 500;
  19810. t['endash'] = 500;
  19811. t['dagger'] = 500;
  19812. t['daggerdbl'] = 500;
  19813. t['periodcentered'] = 250;
  19814. t['paragraph'] = 523;
  19815. t['bullet'] = 350;
  19816. t['quotesinglbase'] = 333;
  19817. t['quotedblbase'] = 556;
  19818. t['quotedblright'] = 556;
  19819. t['guillemotright'] = 500;
  19820. t['ellipsis'] = 889;
  19821. t['perthousand'] = 1000;
  19822. t['questiondown'] = 500;
  19823. t['grave'] = 333;
  19824. t['acute'] = 333;
  19825. t['circumflex'] = 333;
  19826. t['tilde'] = 333;
  19827. t['macron'] = 333;
  19828. t['breve'] = 333;
  19829. t['dotaccent'] = 333;
  19830. t['dieresis'] = 333;
  19831. t['ring'] = 333;
  19832. t['cedilla'] = 333;
  19833. t['hungarumlaut'] = 333;
  19834. t['ogonek'] = 333;
  19835. t['caron'] = 333;
  19836. t['emdash'] = 889;
  19837. t['AE'] = 889;
  19838. t['ordfeminine'] = 276;
  19839. t['Lslash'] = 556;
  19840. t['Oslash'] = 722;
  19841. t['OE'] = 944;
  19842. t['ordmasculine'] = 310;
  19843. t['ae'] = 667;
  19844. t['dotlessi'] = 278;
  19845. t['lslash'] = 278;
  19846. t['oslash'] = 500;
  19847. t['oe'] = 667;
  19848. t['germandbls'] = 500;
  19849. t['Idieresis'] = 333;
  19850. t['eacute'] = 444;
  19851. t['abreve'] = 500;
  19852. t['uhungarumlaut'] = 500;
  19853. t['ecaron'] = 444;
  19854. t['Ydieresis'] = 556;
  19855. t['divide'] = 675;
  19856. t['Yacute'] = 556;
  19857. t['Acircumflex'] = 611;
  19858. t['aacute'] = 500;
  19859. t['Ucircumflex'] = 722;
  19860. t['yacute'] = 444;
  19861. t['scommaaccent'] = 389;
  19862. t['ecircumflex'] = 444;
  19863. t['Uring'] = 722;
  19864. t['Udieresis'] = 722;
  19865. t['aogonek'] = 500;
  19866. t['Uacute'] = 722;
  19867. t['uogonek'] = 500;
  19868. t['Edieresis'] = 611;
  19869. t['Dcroat'] = 722;
  19870. t['commaaccent'] = 250;
  19871. t['copyright'] = 760;
  19872. t['Emacron'] = 611;
  19873. t['ccaron'] = 444;
  19874. t['aring'] = 500;
  19875. t['Ncommaaccent'] = 667;
  19876. t['lacute'] = 278;
  19877. t['agrave'] = 500;
  19878. t['Tcommaaccent'] = 556;
  19879. t['Cacute'] = 667;
  19880. t['atilde'] = 500;
  19881. t['Edotaccent'] = 611;
  19882. t['scaron'] = 389;
  19883. t['scedilla'] = 389;
  19884. t['iacute'] = 278;
  19885. t['lozenge'] = 471;
  19886. t['Rcaron'] = 611;
  19887. t['Gcommaaccent'] = 722;
  19888. t['ucircumflex'] = 500;
  19889. t['acircumflex'] = 500;
  19890. t['Amacron'] = 611;
  19891. t['rcaron'] = 389;
  19892. t['ccedilla'] = 444;
  19893. t['Zdotaccent'] = 556;
  19894. t['Thorn'] = 611;
  19895. t['Omacron'] = 722;
  19896. t['Racute'] = 611;
  19897. t['Sacute'] = 500;
  19898. t['dcaron'] = 544;
  19899. t['Umacron'] = 722;
  19900. t['uring'] = 500;
  19901. t['threesuperior'] = 300;
  19902. t['Ograve'] = 722;
  19903. t['Agrave'] = 611;
  19904. t['Abreve'] = 611;
  19905. t['multiply'] = 675;
  19906. t['uacute'] = 500;
  19907. t['Tcaron'] = 556;
  19908. t['partialdiff'] = 476;
  19909. t['ydieresis'] = 444;
  19910. t['Nacute'] = 667;
  19911. t['icircumflex'] = 278;
  19912. t['Ecircumflex'] = 611;
  19913. t['adieresis'] = 500;
  19914. t['edieresis'] = 444;
  19915. t['cacute'] = 444;
  19916. t['nacute'] = 500;
  19917. t['umacron'] = 500;
  19918. t['Ncaron'] = 667;
  19919. t['Iacute'] = 333;
  19920. t['plusminus'] = 675;
  19921. t['brokenbar'] = 275;
  19922. t['registered'] = 760;
  19923. t['Gbreve'] = 722;
  19924. t['Idotaccent'] = 333;
  19925. t['summation'] = 600;
  19926. t['Egrave'] = 611;
  19927. t['racute'] = 389;
  19928. t['omacron'] = 500;
  19929. t['Zacute'] = 556;
  19930. t['Zcaron'] = 556;
  19931. t['greaterequal'] = 549;
  19932. t['Eth'] = 722;
  19933. t['Ccedilla'] = 667;
  19934. t['lcommaaccent'] = 278;
  19935. t['tcaron'] = 300;
  19936. t['eogonek'] = 444;
  19937. t['Uogonek'] = 722;
  19938. t['Aacute'] = 611;
  19939. t['Adieresis'] = 611;
  19940. t['egrave'] = 444;
  19941. t['zacute'] = 389;
  19942. t['iogonek'] = 278;
  19943. t['Oacute'] = 722;
  19944. t['oacute'] = 500;
  19945. t['amacron'] = 500;
  19946. t['sacute'] = 389;
  19947. t['idieresis'] = 278;
  19948. t['Ocircumflex'] = 722;
  19949. t['Ugrave'] = 722;
  19950. t['Delta'] = 612;
  19951. t['thorn'] = 500;
  19952. t['twosuperior'] = 300;
  19953. t['Odieresis'] = 722;
  19954. t['mu'] = 500;
  19955. t['igrave'] = 278;
  19956. t['ohungarumlaut'] = 500;
  19957. t['Eogonek'] = 611;
  19958. t['dcroat'] = 500;
  19959. t['threequarters'] = 750;
  19960. t['Scedilla'] = 500;
  19961. t['lcaron'] = 300;
  19962. t['Kcommaaccent'] = 667;
  19963. t['Lacute'] = 556;
  19964. t['trademark'] = 980;
  19965. t['edotaccent'] = 444;
  19966. t['Igrave'] = 333;
  19967. t['Imacron'] = 333;
  19968. t['Lcaron'] = 611;
  19969. t['onehalf'] = 750;
  19970. t['lessequal'] = 549;
  19971. t['ocircumflex'] = 500;
  19972. t['ntilde'] = 500;
  19973. t['Uhungarumlaut'] = 722;
  19974. t['Eacute'] = 611;
  19975. t['emacron'] = 444;
  19976. t['gbreve'] = 500;
  19977. t['onequarter'] = 750;
  19978. t['Scaron'] = 500;
  19979. t['Scommaaccent'] = 500;
  19980. t['Ohungarumlaut'] = 722;
  19981. t['degree'] = 400;
  19982. t['ograve'] = 500;
  19983. t['Ccaron'] = 667;
  19984. t['ugrave'] = 500;
  19985. t['radical'] = 453;
  19986. t['Dcaron'] = 722;
  19987. t['rcommaaccent'] = 389;
  19988. t['Ntilde'] = 667;
  19989. t['otilde'] = 500;
  19990. t['Rcommaaccent'] = 611;
  19991. t['Lcommaaccent'] = 556;
  19992. t['Atilde'] = 611;
  19993. t['Aogonek'] = 611;
  19994. t['Aring'] = 611;
  19995. t['Otilde'] = 722;
  19996. t['zdotaccent'] = 389;
  19997. t['Ecaron'] = 611;
  19998. t['Iogonek'] = 333;
  19999. t['kcommaaccent'] = 444;
  20000. t['minus'] = 675;
  20001. t['Icircumflex'] = 333;
  20002. t['ncaron'] = 500;
  20003. t['tcommaaccent'] = 278;
  20004. t['logicalnot'] = 675;
  20005. t['odieresis'] = 500;
  20006. t['udieresis'] = 500;
  20007. t['notequal'] = 549;
  20008. t['gcommaaccent'] = 500;
  20009. t['eth'] = 500;
  20010. t['zcaron'] = 389;
  20011. t['ncommaaccent'] = 500;
  20012. t['onesuperior'] = 300;
  20013. t['imacron'] = 278;
  20014. t['Euro'] = 500;
  20015. });
  20016. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  20017. t['space'] = 278;
  20018. t['a1'] = 974;
  20019. t['a2'] = 961;
  20020. t['a202'] = 974;
  20021. t['a3'] = 980;
  20022. t['a4'] = 719;
  20023. t['a5'] = 789;
  20024. t['a119'] = 790;
  20025. t['a118'] = 791;
  20026. t['a117'] = 690;
  20027. t['a11'] = 960;
  20028. t['a12'] = 939;
  20029. t['a13'] = 549;
  20030. t['a14'] = 855;
  20031. t['a15'] = 911;
  20032. t['a16'] = 933;
  20033. t['a105'] = 911;
  20034. t['a17'] = 945;
  20035. t['a18'] = 974;
  20036. t['a19'] = 755;
  20037. t['a20'] = 846;
  20038. t['a21'] = 762;
  20039. t['a22'] = 761;
  20040. t['a23'] = 571;
  20041. t['a24'] = 677;
  20042. t['a25'] = 763;
  20043. t['a26'] = 760;
  20044. t['a27'] = 759;
  20045. t['a28'] = 754;
  20046. t['a6'] = 494;
  20047. t['a7'] = 552;
  20048. t['a8'] = 537;
  20049. t['a9'] = 577;
  20050. t['a10'] = 692;
  20051. t['a29'] = 786;
  20052. t['a30'] = 788;
  20053. t['a31'] = 788;
  20054. t['a32'] = 790;
  20055. t['a33'] = 793;
  20056. t['a34'] = 794;
  20057. t['a35'] = 816;
  20058. t['a36'] = 823;
  20059. t['a37'] = 789;
  20060. t['a38'] = 841;
  20061. t['a39'] = 823;
  20062. t['a40'] = 833;
  20063. t['a41'] = 816;
  20064. t['a42'] = 831;
  20065. t['a43'] = 923;
  20066. t['a44'] = 744;
  20067. t['a45'] = 723;
  20068. t['a46'] = 749;
  20069. t['a47'] = 790;
  20070. t['a48'] = 792;
  20071. t['a49'] = 695;
  20072. t['a50'] = 776;
  20073. t['a51'] = 768;
  20074. t['a52'] = 792;
  20075. t['a53'] = 759;
  20076. t['a54'] = 707;
  20077. t['a55'] = 708;
  20078. t['a56'] = 682;
  20079. t['a57'] = 701;
  20080. t['a58'] = 826;
  20081. t['a59'] = 815;
  20082. t['a60'] = 789;
  20083. t['a61'] = 789;
  20084. t['a62'] = 707;
  20085. t['a63'] = 687;
  20086. t['a64'] = 696;
  20087. t['a65'] = 689;
  20088. t['a66'] = 786;
  20089. t['a67'] = 787;
  20090. t['a68'] = 713;
  20091. t['a69'] = 791;
  20092. t['a70'] = 785;
  20093. t['a71'] = 791;
  20094. t['a72'] = 873;
  20095. t['a73'] = 761;
  20096. t['a74'] = 762;
  20097. t['a203'] = 762;
  20098. t['a75'] = 759;
  20099. t['a204'] = 759;
  20100. t['a76'] = 892;
  20101. t['a77'] = 892;
  20102. t['a78'] = 788;
  20103. t['a79'] = 784;
  20104. t['a81'] = 438;
  20105. t['a82'] = 138;
  20106. t['a83'] = 277;
  20107. t['a84'] = 415;
  20108. t['a97'] = 392;
  20109. t['a98'] = 392;
  20110. t['a99'] = 668;
  20111. t['a100'] = 668;
  20112. t['a89'] = 390;
  20113. t['a90'] = 390;
  20114. t['a93'] = 317;
  20115. t['a94'] = 317;
  20116. t['a91'] = 276;
  20117. t['a92'] = 276;
  20118. t['a205'] = 509;
  20119. t['a85'] = 509;
  20120. t['a206'] = 410;
  20121. t['a86'] = 410;
  20122. t['a87'] = 234;
  20123. t['a88'] = 234;
  20124. t['a95'] = 334;
  20125. t['a96'] = 334;
  20126. t['a101'] = 732;
  20127. t['a102'] = 544;
  20128. t['a103'] = 544;
  20129. t['a104'] = 910;
  20130. t['a106'] = 667;
  20131. t['a107'] = 760;
  20132. t['a108'] = 760;
  20133. t['a112'] = 776;
  20134. t['a111'] = 595;
  20135. t['a110'] = 694;
  20136. t['a109'] = 626;
  20137. t['a120'] = 788;
  20138. t['a121'] = 788;
  20139. t['a122'] = 788;
  20140. t['a123'] = 788;
  20141. t['a124'] = 788;
  20142. t['a125'] = 788;
  20143. t['a126'] = 788;
  20144. t['a127'] = 788;
  20145. t['a128'] = 788;
  20146. t['a129'] = 788;
  20147. t['a130'] = 788;
  20148. t['a131'] = 788;
  20149. t['a132'] = 788;
  20150. t['a133'] = 788;
  20151. t['a134'] = 788;
  20152. t['a135'] = 788;
  20153. t['a136'] = 788;
  20154. t['a137'] = 788;
  20155. t['a138'] = 788;
  20156. t['a139'] = 788;
  20157. t['a140'] = 788;
  20158. t['a141'] = 788;
  20159. t['a142'] = 788;
  20160. t['a143'] = 788;
  20161. t['a144'] = 788;
  20162. t['a145'] = 788;
  20163. t['a146'] = 788;
  20164. t['a147'] = 788;
  20165. t['a148'] = 788;
  20166. t['a149'] = 788;
  20167. t['a150'] = 788;
  20168. t['a151'] = 788;
  20169. t['a152'] = 788;
  20170. t['a153'] = 788;
  20171. t['a154'] = 788;
  20172. t['a155'] = 788;
  20173. t['a156'] = 788;
  20174. t['a157'] = 788;
  20175. t['a158'] = 788;
  20176. t['a159'] = 788;
  20177. t['a160'] = 894;
  20178. t['a161'] = 838;
  20179. t['a163'] = 1016;
  20180. t['a164'] = 458;
  20181. t['a196'] = 748;
  20182. t['a165'] = 924;
  20183. t['a192'] = 748;
  20184. t['a166'] = 918;
  20185. t['a167'] = 927;
  20186. t['a168'] = 928;
  20187. t['a169'] = 928;
  20188. t['a170'] = 834;
  20189. t['a171'] = 873;
  20190. t['a172'] = 828;
  20191. t['a173'] = 924;
  20192. t['a162'] = 924;
  20193. t['a174'] = 917;
  20194. t['a175'] = 930;
  20195. t['a176'] = 931;
  20196. t['a177'] = 463;
  20197. t['a178'] = 883;
  20198. t['a179'] = 836;
  20199. t['a193'] = 836;
  20200. t['a180'] = 867;
  20201. t['a199'] = 867;
  20202. t['a181'] = 696;
  20203. t['a200'] = 696;
  20204. t['a182'] = 874;
  20205. t['a201'] = 874;
  20206. t['a183'] = 760;
  20207. t['a184'] = 946;
  20208. t['a197'] = 771;
  20209. t['a185'] = 865;
  20210. t['a194'] = 771;
  20211. t['a198'] = 888;
  20212. t['a186'] = 967;
  20213. t['a195'] = 888;
  20214. t['a187'] = 831;
  20215. t['a188'] = 873;
  20216. t['a189'] = 927;
  20217. t['a190'] = 970;
  20218. t['a191'] = 918;
  20219. });
  20220. });
  20221. exports.getMetrics = getMetrics;
  20222. }));
  20223. (function (root, factory) {
  20224. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20225. }(this, function (exports, sharedUtil) {
  20226. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20227. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20228. var MASK_HIGH = 0xffff0000;
  20229. var MASK_LOW = 0xffff;
  20230. function MurmurHash3_64(seed) {
  20231. var SEED = 0xc3d2e1f0;
  20232. this.h1 = seed ? seed & 0xffffffff : SEED;
  20233. this.h2 = seed ? seed & 0xffffffff : SEED;
  20234. }
  20235. var alwaysUseUint32ArrayView = false;
  20236. try {
  20237. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20238. } catch (e) {
  20239. alwaysUseUint32ArrayView = true;
  20240. }
  20241. MurmurHash3_64.prototype = {
  20242. update: function MurmurHash3_64_update(input) {
  20243. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20244. var i;
  20245. if (typeof input === 'string') {
  20246. var data = new Uint8Array(input.length * 2);
  20247. var length = 0;
  20248. for (i = 0; i < input.length; i++) {
  20249. var code = input.charCodeAt(i);
  20250. if (code <= 0xff) {
  20251. data[length++] = code;
  20252. } else {
  20253. data[length++] = code >>> 8;
  20254. data[length++] = code & 0xff;
  20255. }
  20256. }
  20257. } else if (input instanceof Uint8Array) {
  20258. data = input;
  20259. length = data.length;
  20260. } else if (typeof input === 'object' && 'length' in input) {
  20261. data = input;
  20262. length = data.length;
  20263. useUint32ArrayView = true;
  20264. } else {
  20265. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20266. }
  20267. var blockCounts = length >> 2;
  20268. var tailLength = length - blockCounts * 4;
  20269. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20270. var k1 = 0;
  20271. var k2 = 0;
  20272. var h1 = this.h1;
  20273. var h2 = this.h2;
  20274. var C1 = 0xcc9e2d51;
  20275. var C2 = 0x1b873593;
  20276. var C1_LOW = C1 & MASK_LOW;
  20277. var C2_LOW = C2 & MASK_LOW;
  20278. for (i = 0; i < blockCounts; i++) {
  20279. if (i & 1) {
  20280. k1 = dataUint32[i];
  20281. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20282. k1 = k1 << 15 | k1 >>> 17;
  20283. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20284. h1 ^= k1;
  20285. h1 = h1 << 13 | h1 >>> 19;
  20286. h1 = h1 * 5 + 0xe6546b64;
  20287. } else {
  20288. k2 = dataUint32[i];
  20289. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20290. k2 = k2 << 15 | k2 >>> 17;
  20291. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20292. h2 ^= k2;
  20293. h2 = h2 << 13 | h2 >>> 19;
  20294. h2 = h2 * 5 + 0xe6546b64;
  20295. }
  20296. }
  20297. k1 = 0;
  20298. switch (tailLength) {
  20299. case 3:
  20300. k1 ^= data[blockCounts * 4 + 2] << 16;
  20301. case 2:
  20302. k1 ^= data[blockCounts * 4 + 1] << 8;
  20303. case 1:
  20304. k1 ^= data[blockCounts * 4];
  20305. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20306. k1 = k1 << 15 | k1 >>> 17;
  20307. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20308. if (blockCounts & 1) {
  20309. h1 ^= k1;
  20310. } else {
  20311. h2 ^= k1;
  20312. }
  20313. }
  20314. this.h1 = h1;
  20315. this.h2 = h2;
  20316. return this;
  20317. },
  20318. hexdigest: function MurmurHash3_64_hexdigest() {
  20319. var h1 = this.h1;
  20320. var h2 = this.h2;
  20321. h1 ^= h2 >>> 1;
  20322. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20323. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20324. h1 ^= h2 >>> 1;
  20325. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20326. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20327. h1 ^= h2 >>> 1;
  20328. for (var i = 0, arr = [
  20329. h1,
  20330. h2
  20331. ], str = ''; i < arr.length; i++) {
  20332. var hex = (arr[i] >>> 0).toString(16);
  20333. while (hex.length < 8) {
  20334. hex = '0' + hex;
  20335. }
  20336. str += hex;
  20337. }
  20338. return str;
  20339. }
  20340. };
  20341. return MurmurHash3_64;
  20342. }();
  20343. exports.MurmurHash3_64 = MurmurHash3_64;
  20344. }));
  20345. (function (root, factory) {
  20346. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20347. }(this, function (exports, sharedUtil) {
  20348. var isArray = sharedUtil.isArray;
  20349. var Name = function NameClosure() {
  20350. function Name(name) {
  20351. this.name = name;
  20352. }
  20353. Name.prototype = {};
  20354. var nameCache = Object.create(null);
  20355. Name.get = function Name_get(name) {
  20356. var nameValue = nameCache[name];
  20357. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20358. };
  20359. return Name;
  20360. }();
  20361. var Cmd = function CmdClosure() {
  20362. function Cmd(cmd) {
  20363. this.cmd = cmd;
  20364. }
  20365. Cmd.prototype = {};
  20366. var cmdCache = Object.create(null);
  20367. Cmd.get = function Cmd_get(cmd) {
  20368. var cmdValue = cmdCache[cmd];
  20369. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20370. };
  20371. return Cmd;
  20372. }();
  20373. var Dict = function DictClosure() {
  20374. var nonSerializable = function nonSerializableClosure() {
  20375. return nonSerializable;
  20376. };
  20377. function Dict(xref) {
  20378. this.map = Object.create(null);
  20379. this.xref = xref;
  20380. this.objId = null;
  20381. this.suppressEncryption = false;
  20382. this.__nonSerializable__ = nonSerializable;
  20383. }
  20384. Dict.prototype = {
  20385. assignXref: function Dict_assignXref(newXref) {
  20386. this.xref = newXref;
  20387. },
  20388. get: function Dict_get(key1, key2, key3) {
  20389. var value;
  20390. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20391. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20392. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20393. }
  20394. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20395. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20396. }
  20397. value = this.map[key3] || null;
  20398. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20399. },
  20400. getAsync: function Dict_getAsync(key1, key2, key3) {
  20401. var value;
  20402. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20403. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20404. if (xref) {
  20405. return xref.fetchIfRefAsync(value, suppressEncryption);
  20406. }
  20407. return Promise.resolve(value);
  20408. }
  20409. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20410. if (xref) {
  20411. return xref.fetchIfRefAsync(value, suppressEncryption);
  20412. }
  20413. return Promise.resolve(value);
  20414. }
  20415. value = this.map[key3] || null;
  20416. if (xref) {
  20417. return xref.fetchIfRefAsync(value, suppressEncryption);
  20418. }
  20419. return Promise.resolve(value);
  20420. },
  20421. getArray: function Dict_getArray(key1, key2, key3) {
  20422. var value = this.get(key1, key2, key3);
  20423. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20424. if (!isArray(value) || !xref) {
  20425. return value;
  20426. }
  20427. value = value.slice();
  20428. for (var i = 0, ii = value.length; i < ii; i++) {
  20429. if (!isRef(value[i])) {
  20430. continue;
  20431. }
  20432. value[i] = xref.fetch(value[i], suppressEncryption);
  20433. }
  20434. return value;
  20435. },
  20436. getRaw: function Dict_getRaw(key) {
  20437. return this.map[key];
  20438. },
  20439. getKeys: function Dict_getKeys() {
  20440. return Object.keys(this.map);
  20441. },
  20442. set: function Dict_set(key, value) {
  20443. this.map[key] = value;
  20444. },
  20445. has: function Dict_has(key) {
  20446. return key in this.map;
  20447. },
  20448. forEach: function Dict_forEach(callback) {
  20449. for (var key in this.map) {
  20450. callback(key, this.get(key));
  20451. }
  20452. }
  20453. };
  20454. Dict.empty = new Dict(null);
  20455. Dict.merge = function Dict_merge(xref, dictArray) {
  20456. var mergedDict = new Dict(xref);
  20457. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20458. var dict = dictArray[i];
  20459. if (!isDict(dict)) {
  20460. continue;
  20461. }
  20462. for (var keyName in dict.map) {
  20463. if (mergedDict.map[keyName]) {
  20464. continue;
  20465. }
  20466. mergedDict.map[keyName] = dict.map[keyName];
  20467. }
  20468. }
  20469. return mergedDict;
  20470. };
  20471. return Dict;
  20472. }();
  20473. var Ref = function RefClosure() {
  20474. function Ref(num, gen) {
  20475. this.num = num;
  20476. this.gen = gen;
  20477. }
  20478. Ref.prototype = {
  20479. toString: function Ref_toString() {
  20480. var str = this.num + 'R';
  20481. if (this.gen !== 0) {
  20482. str += this.gen;
  20483. }
  20484. return str;
  20485. }
  20486. };
  20487. return Ref;
  20488. }();
  20489. var RefSet = function RefSetClosure() {
  20490. function RefSet() {
  20491. this.dict = Object.create(null);
  20492. }
  20493. RefSet.prototype = {
  20494. has: function RefSet_has(ref) {
  20495. return ref.toString() in this.dict;
  20496. },
  20497. put: function RefSet_put(ref) {
  20498. this.dict[ref.toString()] = true;
  20499. },
  20500. remove: function RefSet_remove(ref) {
  20501. delete this.dict[ref.toString()];
  20502. }
  20503. };
  20504. return RefSet;
  20505. }();
  20506. var RefSetCache = function RefSetCacheClosure() {
  20507. function RefSetCache() {
  20508. this.dict = Object.create(null);
  20509. }
  20510. RefSetCache.prototype = {
  20511. get: function RefSetCache_get(ref) {
  20512. return this.dict[ref.toString()];
  20513. },
  20514. has: function RefSetCache_has(ref) {
  20515. return ref.toString() in this.dict;
  20516. },
  20517. put: function RefSetCache_put(ref, obj) {
  20518. this.dict[ref.toString()] = obj;
  20519. },
  20520. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20521. this.dict[ref.toString()] = this.get(aliasRef);
  20522. },
  20523. forEach: function RefSetCache_forEach(fn, thisArg) {
  20524. for (var i in this.dict) {
  20525. fn.call(thisArg, this.dict[i]);
  20526. }
  20527. },
  20528. clear: function RefSetCache_clear() {
  20529. this.dict = Object.create(null);
  20530. }
  20531. };
  20532. return RefSetCache;
  20533. }();
  20534. function isName(v, name) {
  20535. return v instanceof Name && (name === undefined || v.name === name);
  20536. }
  20537. function isCmd(v, cmd) {
  20538. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20539. }
  20540. function isDict(v, type) {
  20541. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20542. }
  20543. function isRef(v) {
  20544. return v instanceof Ref;
  20545. }
  20546. function isRefsEqual(v1, v2) {
  20547. return v1.num === v2.num && v1.gen === v2.gen;
  20548. }
  20549. function isStream(v) {
  20550. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20551. }
  20552. exports.Cmd = Cmd;
  20553. exports.Dict = Dict;
  20554. exports.Name = Name;
  20555. exports.Ref = Ref;
  20556. exports.RefSet = RefSet;
  20557. exports.RefSetCache = RefSetCache;
  20558. exports.isCmd = isCmd;
  20559. exports.isDict = isDict;
  20560. exports.isName = isName;
  20561. exports.isRef = isRef;
  20562. exports.isRefsEqual = isRefsEqual;
  20563. exports.isStream = isStream;
  20564. }));
  20565. (function (root, factory) {
  20566. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20567. }(this, function (exports, sharedUtil) {
  20568. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20569. var getStdFontMap = getLookupTableFactory(function (t) {
  20570. t['ArialNarrow'] = 'Helvetica';
  20571. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20572. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20573. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20574. t['ArialBlack'] = 'Helvetica';
  20575. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20576. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20577. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20578. t['Arial-Black'] = 'Helvetica';
  20579. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20580. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20581. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20582. t['Arial'] = 'Helvetica';
  20583. t['Arial-Bold'] = 'Helvetica-Bold';
  20584. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20585. t['Arial-Italic'] = 'Helvetica-Oblique';
  20586. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20587. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20588. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20589. t['ArialMT'] = 'Helvetica';
  20590. t['Courier-Bold'] = 'Courier-Bold';
  20591. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20592. t['Courier-Italic'] = 'Courier-Oblique';
  20593. t['CourierNew'] = 'Courier';
  20594. t['CourierNew-Bold'] = 'Courier-Bold';
  20595. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20596. t['CourierNew-Italic'] = 'Courier-Oblique';
  20597. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20598. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20599. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20600. t['CourierNewPSMT'] = 'Courier';
  20601. t['Helvetica'] = 'Helvetica';
  20602. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20603. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20604. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20605. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20606. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20607. t['Symbol-Bold'] = 'Symbol';
  20608. t['Symbol-BoldItalic'] = 'Symbol';
  20609. t['Symbol-Italic'] = 'Symbol';
  20610. t['TimesNewRoman'] = 'Times-Roman';
  20611. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20612. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20613. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20614. t['TimesNewRomanPS'] = 'Times-Roman';
  20615. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20616. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20617. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20618. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20619. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20620. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20621. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20622. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20623. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20624. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20625. });
  20626. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20627. t['CenturyGothic'] = 'Helvetica';
  20628. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20629. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20630. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20631. t['ComicSansMS'] = 'Comic Sans MS';
  20632. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20633. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20634. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20635. t['LucidaConsole'] = 'Courier';
  20636. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20637. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20638. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20639. t['MS-Gothic'] = 'MS Gothic';
  20640. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20641. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20642. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20643. t['MS-Mincho'] = 'MS Mincho';
  20644. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20645. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20646. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20647. t['MS-PGothic'] = 'MS PGothic';
  20648. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20649. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20650. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20651. t['MS-PMincho'] = 'MS PMincho';
  20652. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20653. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20654. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20655. t['NuptialScript'] = 'Times-Italic';
  20656. t['Wingdings'] = 'ZapfDingbats';
  20657. });
  20658. var getSerifFonts = getLookupTableFactory(function (t) {
  20659. t['Adobe Jenson'] = true;
  20660. t['Adobe Text'] = true;
  20661. t['Albertus'] = true;
  20662. t['Aldus'] = true;
  20663. t['Alexandria'] = true;
  20664. t['Algerian'] = true;
  20665. t['American Typewriter'] = true;
  20666. t['Antiqua'] = true;
  20667. t['Apex'] = true;
  20668. t['Arno'] = true;
  20669. t['Aster'] = true;
  20670. t['Aurora'] = true;
  20671. t['Baskerville'] = true;
  20672. t['Bell'] = true;
  20673. t['Bembo'] = true;
  20674. t['Bembo Schoolbook'] = true;
  20675. t['Benguiat'] = true;
  20676. t['Berkeley Old Style'] = true;
  20677. t['Bernhard Modern'] = true;
  20678. t['Berthold City'] = true;
  20679. t['Bodoni'] = true;
  20680. t['Bauer Bodoni'] = true;
  20681. t['Book Antiqua'] = true;
  20682. t['Bookman'] = true;
  20683. t['Bordeaux Roman'] = true;
  20684. t['Californian FB'] = true;
  20685. t['Calisto'] = true;
  20686. t['Calvert'] = true;
  20687. t['Capitals'] = true;
  20688. t['Cambria'] = true;
  20689. t['Cartier'] = true;
  20690. t['Caslon'] = true;
  20691. t['Catull'] = true;
  20692. t['Centaur'] = true;
  20693. t['Century Old Style'] = true;
  20694. t['Century Schoolbook'] = true;
  20695. t['Chaparral'] = true;
  20696. t['Charis SIL'] = true;
  20697. t['Cheltenham'] = true;
  20698. t['Cholla Slab'] = true;
  20699. t['Clarendon'] = true;
  20700. t['Clearface'] = true;
  20701. t['Cochin'] = true;
  20702. t['Colonna'] = true;
  20703. t['Computer Modern'] = true;
  20704. t['Concrete Roman'] = true;
  20705. t['Constantia'] = true;
  20706. t['Cooper Black'] = true;
  20707. t['Corona'] = true;
  20708. t['Ecotype'] = true;
  20709. t['Egyptienne'] = true;
  20710. t['Elephant'] = true;
  20711. t['Excelsior'] = true;
  20712. t['Fairfield'] = true;
  20713. t['FF Scala'] = true;
  20714. t['Folkard'] = true;
  20715. t['Footlight'] = true;
  20716. t['FreeSerif'] = true;
  20717. t['Friz Quadrata'] = true;
  20718. t['Garamond'] = true;
  20719. t['Gentium'] = true;
  20720. t['Georgia'] = true;
  20721. t['Gloucester'] = true;
  20722. t['Goudy Old Style'] = true;
  20723. t['Goudy Schoolbook'] = true;
  20724. t['Goudy Pro Font'] = true;
  20725. t['Granjon'] = true;
  20726. t['Guardian Egyptian'] = true;
  20727. t['Heather'] = true;
  20728. t['Hercules'] = true;
  20729. t['High Tower Text'] = true;
  20730. t['Hiroshige'] = true;
  20731. t['Hoefler Text'] = true;
  20732. t['Humana Serif'] = true;
  20733. t['Imprint'] = true;
  20734. t['Ionic No. 5'] = true;
  20735. t['Janson'] = true;
  20736. t['Joanna'] = true;
  20737. t['Korinna'] = true;
  20738. t['Lexicon'] = true;
  20739. t['Liberation Serif'] = true;
  20740. t['Linux Libertine'] = true;
  20741. t['Literaturnaya'] = true;
  20742. t['Lucida'] = true;
  20743. t['Lucida Bright'] = true;
  20744. t['Melior'] = true;
  20745. t['Memphis'] = true;
  20746. t['Miller'] = true;
  20747. t['Minion'] = true;
  20748. t['Modern'] = true;
  20749. t['Mona Lisa'] = true;
  20750. t['Mrs Eaves'] = true;
  20751. t['MS Serif'] = true;
  20752. t['Museo Slab'] = true;
  20753. t['New York'] = true;
  20754. t['Nimbus Roman'] = true;
  20755. t['NPS Rawlinson Roadway'] = true;
  20756. t['NuptialScript'] = true;
  20757. t['Palatino'] = true;
  20758. t['Perpetua'] = true;
  20759. t['Plantin'] = true;
  20760. t['Plantin Schoolbook'] = true;
  20761. t['Playbill'] = true;
  20762. t['Poor Richard'] = true;
  20763. t['Rawlinson Roadway'] = true;
  20764. t['Renault'] = true;
  20765. t['Requiem'] = true;
  20766. t['Rockwell'] = true;
  20767. t['Roman'] = true;
  20768. t['Rotis Serif'] = true;
  20769. t['Sabon'] = true;
  20770. t['Scala'] = true;
  20771. t['Seagull'] = true;
  20772. t['Sistina'] = true;
  20773. t['Souvenir'] = true;
  20774. t['STIX'] = true;
  20775. t['Stone Informal'] = true;
  20776. t['Stone Serif'] = true;
  20777. t['Sylfaen'] = true;
  20778. t['Times'] = true;
  20779. t['Trajan'] = true;
  20780. t['Trinité'] = true;
  20781. t['Trump Mediaeval'] = true;
  20782. t['Utopia'] = true;
  20783. t['Vale Type'] = true;
  20784. t['Bitstream Vera'] = true;
  20785. t['Vera Serif'] = true;
  20786. t['Versailles'] = true;
  20787. t['Wanted'] = true;
  20788. t['Weiss'] = true;
  20789. t['Wide Latin'] = true;
  20790. t['Windsor'] = true;
  20791. t['XITS'] = true;
  20792. });
  20793. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20794. t['Dingbats'] = true;
  20795. t['Symbol'] = true;
  20796. t['ZapfDingbats'] = true;
  20797. });
  20798. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20799. t[2] = 10;
  20800. t[3] = 32;
  20801. t[4] = 33;
  20802. t[5] = 34;
  20803. t[6] = 35;
  20804. t[7] = 36;
  20805. t[8] = 37;
  20806. t[9] = 38;
  20807. t[10] = 39;
  20808. t[11] = 40;
  20809. t[12] = 41;
  20810. t[13] = 42;
  20811. t[14] = 43;
  20812. t[15] = 44;
  20813. t[16] = 45;
  20814. t[17] = 46;
  20815. t[18] = 47;
  20816. t[19] = 48;
  20817. t[20] = 49;
  20818. t[21] = 50;
  20819. t[22] = 51;
  20820. t[23] = 52;
  20821. t[24] = 53;
  20822. t[25] = 54;
  20823. t[26] = 55;
  20824. t[27] = 56;
  20825. t[28] = 57;
  20826. t[29] = 58;
  20827. t[30] = 894;
  20828. t[31] = 60;
  20829. t[32] = 61;
  20830. t[33] = 62;
  20831. t[34] = 63;
  20832. t[35] = 64;
  20833. t[36] = 65;
  20834. t[37] = 66;
  20835. t[38] = 67;
  20836. t[39] = 68;
  20837. t[40] = 69;
  20838. t[41] = 70;
  20839. t[42] = 71;
  20840. t[43] = 72;
  20841. t[44] = 73;
  20842. t[45] = 74;
  20843. t[46] = 75;
  20844. t[47] = 76;
  20845. t[48] = 77;
  20846. t[49] = 78;
  20847. t[50] = 79;
  20848. t[51] = 80;
  20849. t[52] = 81;
  20850. t[53] = 82;
  20851. t[54] = 83;
  20852. t[55] = 84;
  20853. t[56] = 85;
  20854. t[57] = 86;
  20855. t[58] = 87;
  20856. t[59] = 88;
  20857. t[60] = 89;
  20858. t[61] = 90;
  20859. t[62] = 91;
  20860. t[63] = 92;
  20861. t[64] = 93;
  20862. t[65] = 94;
  20863. t[66] = 95;
  20864. t[67] = 96;
  20865. t[68] = 97;
  20866. t[69] = 98;
  20867. t[70] = 99;
  20868. t[71] = 100;
  20869. t[72] = 101;
  20870. t[73] = 102;
  20871. t[74] = 103;
  20872. t[75] = 104;
  20873. t[76] = 105;
  20874. t[77] = 106;
  20875. t[78] = 107;
  20876. t[79] = 108;
  20877. t[80] = 109;
  20878. t[81] = 110;
  20879. t[82] = 111;
  20880. t[83] = 112;
  20881. t[84] = 113;
  20882. t[85] = 114;
  20883. t[86] = 115;
  20884. t[87] = 116;
  20885. t[88] = 117;
  20886. t[89] = 118;
  20887. t[90] = 119;
  20888. t[91] = 120;
  20889. t[92] = 121;
  20890. t[93] = 122;
  20891. t[94] = 123;
  20892. t[95] = 124;
  20893. t[96] = 125;
  20894. t[97] = 126;
  20895. t[98] = 196;
  20896. t[99] = 197;
  20897. t[100] = 199;
  20898. t[101] = 201;
  20899. t[102] = 209;
  20900. t[103] = 214;
  20901. t[104] = 220;
  20902. t[105] = 225;
  20903. t[106] = 224;
  20904. t[107] = 226;
  20905. t[108] = 228;
  20906. t[109] = 227;
  20907. t[110] = 229;
  20908. t[111] = 231;
  20909. t[112] = 233;
  20910. t[113] = 232;
  20911. t[114] = 234;
  20912. t[115] = 235;
  20913. t[116] = 237;
  20914. t[117] = 236;
  20915. t[118] = 238;
  20916. t[119] = 239;
  20917. t[120] = 241;
  20918. t[121] = 243;
  20919. t[122] = 242;
  20920. t[123] = 244;
  20921. t[124] = 246;
  20922. t[125] = 245;
  20923. t[126] = 250;
  20924. t[127] = 249;
  20925. t[128] = 251;
  20926. t[129] = 252;
  20927. t[130] = 8224;
  20928. t[131] = 176;
  20929. t[132] = 162;
  20930. t[133] = 163;
  20931. t[134] = 167;
  20932. t[135] = 8226;
  20933. t[136] = 182;
  20934. t[137] = 223;
  20935. t[138] = 174;
  20936. t[139] = 169;
  20937. t[140] = 8482;
  20938. t[141] = 180;
  20939. t[142] = 168;
  20940. t[143] = 8800;
  20941. t[144] = 198;
  20942. t[145] = 216;
  20943. t[146] = 8734;
  20944. t[147] = 177;
  20945. t[148] = 8804;
  20946. t[149] = 8805;
  20947. t[150] = 165;
  20948. t[151] = 181;
  20949. t[152] = 8706;
  20950. t[153] = 8721;
  20951. t[154] = 8719;
  20952. t[156] = 8747;
  20953. t[157] = 170;
  20954. t[158] = 186;
  20955. t[159] = 8486;
  20956. t[160] = 230;
  20957. t[161] = 248;
  20958. t[162] = 191;
  20959. t[163] = 161;
  20960. t[164] = 172;
  20961. t[165] = 8730;
  20962. t[166] = 402;
  20963. t[167] = 8776;
  20964. t[168] = 8710;
  20965. t[169] = 171;
  20966. t[170] = 187;
  20967. t[171] = 8230;
  20968. t[210] = 218;
  20969. t[223] = 711;
  20970. t[224] = 321;
  20971. t[225] = 322;
  20972. t[227] = 353;
  20973. t[229] = 382;
  20974. t[234] = 253;
  20975. t[252] = 263;
  20976. t[253] = 268;
  20977. t[254] = 269;
  20978. t[258] = 258;
  20979. t[260] = 260;
  20980. t[261] = 261;
  20981. t[265] = 280;
  20982. t[266] = 281;
  20983. t[268] = 283;
  20984. t[269] = 313;
  20985. t[275] = 323;
  20986. t[276] = 324;
  20987. t[278] = 328;
  20988. t[284] = 345;
  20989. t[285] = 346;
  20990. t[286] = 347;
  20991. t[292] = 367;
  20992. t[295] = 377;
  20993. t[296] = 378;
  20994. t[298] = 380;
  20995. t[305] = 963;
  20996. t[306] = 964;
  20997. t[307] = 966;
  20998. t[308] = 8215;
  20999. t[309] = 8252;
  21000. t[310] = 8319;
  21001. t[311] = 8359;
  21002. t[312] = 8592;
  21003. t[313] = 8593;
  21004. t[337] = 9552;
  21005. t[493] = 1039;
  21006. t[494] = 1040;
  21007. t[705] = 1524;
  21008. t[706] = 8362;
  21009. t[710] = 64288;
  21010. t[711] = 64298;
  21011. t[759] = 1617;
  21012. t[761] = 1776;
  21013. t[763] = 1778;
  21014. t[775] = 1652;
  21015. t[777] = 1764;
  21016. t[778] = 1780;
  21017. t[779] = 1781;
  21018. t[780] = 1782;
  21019. t[782] = 771;
  21020. t[783] = 64726;
  21021. t[786] = 8363;
  21022. t[788] = 8532;
  21023. t[790] = 768;
  21024. t[791] = 769;
  21025. t[792] = 768;
  21026. t[795] = 803;
  21027. t[797] = 64336;
  21028. t[798] = 64337;
  21029. t[799] = 64342;
  21030. t[800] = 64343;
  21031. t[801] = 64344;
  21032. t[802] = 64345;
  21033. t[803] = 64362;
  21034. t[804] = 64363;
  21035. t[805] = 64364;
  21036. t[2424] = 7821;
  21037. t[2425] = 7822;
  21038. t[2426] = 7823;
  21039. t[2427] = 7824;
  21040. t[2428] = 7825;
  21041. t[2429] = 7826;
  21042. t[2430] = 7827;
  21043. t[2433] = 7682;
  21044. t[2678] = 8045;
  21045. t[2679] = 8046;
  21046. t[2830] = 1552;
  21047. t[2838] = 686;
  21048. t[2840] = 751;
  21049. t[2842] = 753;
  21050. t[2843] = 754;
  21051. t[2844] = 755;
  21052. t[2846] = 757;
  21053. t[2856] = 767;
  21054. t[2857] = 848;
  21055. t[2858] = 849;
  21056. t[2862] = 853;
  21057. t[2863] = 854;
  21058. t[2864] = 855;
  21059. t[2865] = 861;
  21060. t[2866] = 862;
  21061. t[2906] = 7460;
  21062. t[2908] = 7462;
  21063. t[2909] = 7463;
  21064. t[2910] = 7464;
  21065. t[2912] = 7466;
  21066. t[2913] = 7467;
  21067. t[2914] = 7468;
  21068. t[2916] = 7470;
  21069. t[2917] = 7471;
  21070. t[2918] = 7472;
  21071. t[2920] = 7474;
  21072. t[2921] = 7475;
  21073. t[2922] = 7476;
  21074. t[2924] = 7478;
  21075. t[2925] = 7479;
  21076. t[2926] = 7480;
  21077. t[2928] = 7482;
  21078. t[2929] = 7483;
  21079. t[2930] = 7484;
  21080. t[2932] = 7486;
  21081. t[2933] = 7487;
  21082. t[2934] = 7488;
  21083. t[2936] = 7490;
  21084. t[2937] = 7491;
  21085. t[2938] = 7492;
  21086. t[2940] = 7494;
  21087. t[2941] = 7495;
  21088. t[2942] = 7496;
  21089. t[2944] = 7498;
  21090. t[2946] = 7500;
  21091. t[2948] = 7502;
  21092. t[2950] = 7504;
  21093. t[2951] = 7505;
  21094. t[2952] = 7506;
  21095. t[2954] = 7508;
  21096. t[2955] = 7509;
  21097. t[2956] = 7510;
  21098. t[2958] = 7512;
  21099. t[2959] = 7513;
  21100. t[2960] = 7514;
  21101. t[2962] = 7516;
  21102. t[2963] = 7517;
  21103. t[2964] = 7518;
  21104. t[2966] = 7520;
  21105. t[2967] = 7521;
  21106. t[2968] = 7522;
  21107. t[2970] = 7524;
  21108. t[2971] = 7525;
  21109. t[2972] = 7526;
  21110. t[2974] = 7528;
  21111. t[2975] = 7529;
  21112. t[2976] = 7530;
  21113. t[2978] = 1537;
  21114. t[2979] = 1538;
  21115. t[2980] = 1539;
  21116. t[2982] = 1549;
  21117. t[2983] = 1551;
  21118. t[2984] = 1552;
  21119. t[2986] = 1554;
  21120. t[2987] = 1555;
  21121. t[2988] = 1556;
  21122. t[2990] = 1623;
  21123. t[2991] = 1624;
  21124. t[2995] = 1775;
  21125. t[2999] = 1791;
  21126. t[3002] = 64290;
  21127. t[3003] = 64291;
  21128. t[3004] = 64292;
  21129. t[3006] = 64294;
  21130. t[3007] = 64295;
  21131. t[3008] = 64296;
  21132. t[3011] = 1900;
  21133. t[3014] = 8223;
  21134. t[3015] = 8244;
  21135. t[3017] = 7532;
  21136. t[3018] = 7533;
  21137. t[3019] = 7534;
  21138. t[3075] = 7590;
  21139. t[3076] = 7591;
  21140. t[3079] = 7594;
  21141. t[3080] = 7595;
  21142. t[3083] = 7598;
  21143. t[3084] = 7599;
  21144. t[3087] = 7602;
  21145. t[3088] = 7603;
  21146. t[3091] = 7606;
  21147. t[3092] = 7607;
  21148. t[3095] = 7610;
  21149. t[3096] = 7611;
  21150. t[3099] = 7614;
  21151. t[3100] = 7615;
  21152. t[3103] = 7618;
  21153. t[3104] = 7619;
  21154. t[3107] = 8337;
  21155. t[3108] = 8338;
  21156. t[3116] = 1884;
  21157. t[3119] = 1885;
  21158. t[3120] = 1885;
  21159. t[3123] = 1886;
  21160. t[3124] = 1886;
  21161. t[3127] = 1887;
  21162. t[3128] = 1887;
  21163. t[3131] = 1888;
  21164. t[3132] = 1888;
  21165. t[3135] = 1889;
  21166. t[3136] = 1889;
  21167. t[3139] = 1890;
  21168. t[3140] = 1890;
  21169. t[3143] = 1891;
  21170. t[3144] = 1891;
  21171. t[3147] = 1892;
  21172. t[3148] = 1892;
  21173. t[3153] = 580;
  21174. t[3154] = 581;
  21175. t[3157] = 584;
  21176. t[3158] = 585;
  21177. t[3161] = 588;
  21178. t[3162] = 589;
  21179. t[3165] = 891;
  21180. t[3166] = 892;
  21181. t[3169] = 1274;
  21182. t[3170] = 1275;
  21183. t[3173] = 1278;
  21184. t[3174] = 1279;
  21185. t[3181] = 7622;
  21186. t[3182] = 7623;
  21187. t[3282] = 11799;
  21188. t[3316] = 578;
  21189. t[3379] = 42785;
  21190. t[3393] = 1159;
  21191. t[3416] = 8377;
  21192. });
  21193. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21194. t[227] = 322;
  21195. t[264] = 261;
  21196. t[291] = 346;
  21197. });
  21198. exports.getStdFontMap = getStdFontMap;
  21199. exports.getNonStdFontMap = getNonStdFontMap;
  21200. exports.getSerifFonts = getSerifFonts;
  21201. exports.getSymbolsFonts = getSymbolsFonts;
  21202. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21203. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21204. }));
  21205. (function (root, factory) {
  21206. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21207. }(this, function (exports, sharedUtil) {
  21208. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21209. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21210. t[63721] = 0x00A9;
  21211. t[63193] = 0x00A9;
  21212. t[63720] = 0x00AE;
  21213. t[63194] = 0x00AE;
  21214. t[63722] = 0x2122;
  21215. t[63195] = 0x2122;
  21216. t[63729] = 0x23A7;
  21217. t[63730] = 0x23A8;
  21218. t[63731] = 0x23A9;
  21219. t[63740] = 0x23AB;
  21220. t[63741] = 0x23AC;
  21221. t[63742] = 0x23AD;
  21222. t[63726] = 0x23A1;
  21223. t[63727] = 0x23A2;
  21224. t[63728] = 0x23A3;
  21225. t[63737] = 0x23A4;
  21226. t[63738] = 0x23A5;
  21227. t[63739] = 0x23A6;
  21228. t[63723] = 0x239B;
  21229. t[63724] = 0x239C;
  21230. t[63725] = 0x239D;
  21231. t[63734] = 0x239E;
  21232. t[63735] = 0x239F;
  21233. t[63736] = 0x23A0;
  21234. });
  21235. function mapSpecialUnicodeValues(code) {
  21236. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21237. return 0;
  21238. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21239. return getSpecialPUASymbols()[code] || code;
  21240. }
  21241. return code;
  21242. }
  21243. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21244. var unicode = glyphsUnicodeMap[name];
  21245. if (unicode !== undefined) {
  21246. return unicode;
  21247. }
  21248. if (!name) {
  21249. return -1;
  21250. }
  21251. if (name[0] === 'u') {
  21252. var nameLen = name.length, hexStr;
  21253. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21254. hexStr = name.substr(3);
  21255. } else if (nameLen >= 5 && nameLen <= 7) {
  21256. hexStr = name.substr(1);
  21257. } else {
  21258. return -1;
  21259. }
  21260. if (hexStr === hexStr.toUpperCase()) {
  21261. unicode = parseInt(hexStr, 16);
  21262. if (unicode >= 0) {
  21263. return unicode;
  21264. }
  21265. }
  21266. }
  21267. return -1;
  21268. }
  21269. var UnicodeRanges = [
  21270. {
  21271. 'begin': 0x0000,
  21272. 'end': 0x007F
  21273. },
  21274. {
  21275. 'begin': 0x0080,
  21276. 'end': 0x00FF
  21277. },
  21278. {
  21279. 'begin': 0x0100,
  21280. 'end': 0x017F
  21281. },
  21282. {
  21283. 'begin': 0x0180,
  21284. 'end': 0x024F
  21285. },
  21286. {
  21287. 'begin': 0x0250,
  21288. 'end': 0x02AF
  21289. },
  21290. {
  21291. 'begin': 0x02B0,
  21292. 'end': 0x02FF
  21293. },
  21294. {
  21295. 'begin': 0x0300,
  21296. 'end': 0x036F
  21297. },
  21298. {
  21299. 'begin': 0x0370,
  21300. 'end': 0x03FF
  21301. },
  21302. {
  21303. 'begin': 0x2C80,
  21304. 'end': 0x2CFF
  21305. },
  21306. {
  21307. 'begin': 0x0400,
  21308. 'end': 0x04FF
  21309. },
  21310. {
  21311. 'begin': 0x0530,
  21312. 'end': 0x058F
  21313. },
  21314. {
  21315. 'begin': 0x0590,
  21316. 'end': 0x05FF
  21317. },
  21318. {
  21319. 'begin': 0xA500,
  21320. 'end': 0xA63F
  21321. },
  21322. {
  21323. 'begin': 0x0600,
  21324. 'end': 0x06FF
  21325. },
  21326. {
  21327. 'begin': 0x07C0,
  21328. 'end': 0x07FF
  21329. },
  21330. {
  21331. 'begin': 0x0900,
  21332. 'end': 0x097F
  21333. },
  21334. {
  21335. 'begin': 0x0980,
  21336. 'end': 0x09FF
  21337. },
  21338. {
  21339. 'begin': 0x0A00,
  21340. 'end': 0x0A7F
  21341. },
  21342. {
  21343. 'begin': 0x0A80,
  21344. 'end': 0x0AFF
  21345. },
  21346. {
  21347. 'begin': 0x0B00,
  21348. 'end': 0x0B7F
  21349. },
  21350. {
  21351. 'begin': 0x0B80,
  21352. 'end': 0x0BFF
  21353. },
  21354. {
  21355. 'begin': 0x0C00,
  21356. 'end': 0x0C7F
  21357. },
  21358. {
  21359. 'begin': 0x0C80,
  21360. 'end': 0x0CFF
  21361. },
  21362. {
  21363. 'begin': 0x0D00,
  21364. 'end': 0x0D7F
  21365. },
  21366. {
  21367. 'begin': 0x0E00,
  21368. 'end': 0x0E7F
  21369. },
  21370. {
  21371. 'begin': 0x0E80,
  21372. 'end': 0x0EFF
  21373. },
  21374. {
  21375. 'begin': 0x10A0,
  21376. 'end': 0x10FF
  21377. },
  21378. {
  21379. 'begin': 0x1B00,
  21380. 'end': 0x1B7F
  21381. },
  21382. {
  21383. 'begin': 0x1100,
  21384. 'end': 0x11FF
  21385. },
  21386. {
  21387. 'begin': 0x1E00,
  21388. 'end': 0x1EFF
  21389. },
  21390. {
  21391. 'begin': 0x1F00,
  21392. 'end': 0x1FFF
  21393. },
  21394. {
  21395. 'begin': 0x2000,
  21396. 'end': 0x206F
  21397. },
  21398. {
  21399. 'begin': 0x2070,
  21400. 'end': 0x209F
  21401. },
  21402. {
  21403. 'begin': 0x20A0,
  21404. 'end': 0x20CF
  21405. },
  21406. {
  21407. 'begin': 0x20D0,
  21408. 'end': 0x20FF
  21409. },
  21410. {
  21411. 'begin': 0x2100,
  21412. 'end': 0x214F
  21413. },
  21414. {
  21415. 'begin': 0x2150,
  21416. 'end': 0x218F
  21417. },
  21418. {
  21419. 'begin': 0x2190,
  21420. 'end': 0x21FF
  21421. },
  21422. {
  21423. 'begin': 0x2200,
  21424. 'end': 0x22FF
  21425. },
  21426. {
  21427. 'begin': 0x2300,
  21428. 'end': 0x23FF
  21429. },
  21430. {
  21431. 'begin': 0x2400,
  21432. 'end': 0x243F
  21433. },
  21434. {
  21435. 'begin': 0x2440,
  21436. 'end': 0x245F
  21437. },
  21438. {
  21439. 'begin': 0x2460,
  21440. 'end': 0x24FF
  21441. },
  21442. {
  21443. 'begin': 0x2500,
  21444. 'end': 0x257F
  21445. },
  21446. {
  21447. 'begin': 0x2580,
  21448. 'end': 0x259F
  21449. },
  21450. {
  21451. 'begin': 0x25A0,
  21452. 'end': 0x25FF
  21453. },
  21454. {
  21455. 'begin': 0x2600,
  21456. 'end': 0x26FF
  21457. },
  21458. {
  21459. 'begin': 0x2700,
  21460. 'end': 0x27BF
  21461. },
  21462. {
  21463. 'begin': 0x3000,
  21464. 'end': 0x303F
  21465. },
  21466. {
  21467. 'begin': 0x3040,
  21468. 'end': 0x309F
  21469. },
  21470. {
  21471. 'begin': 0x30A0,
  21472. 'end': 0x30FF
  21473. },
  21474. {
  21475. 'begin': 0x3100,
  21476. 'end': 0x312F
  21477. },
  21478. {
  21479. 'begin': 0x3130,
  21480. 'end': 0x318F
  21481. },
  21482. {
  21483. 'begin': 0xA840,
  21484. 'end': 0xA87F
  21485. },
  21486. {
  21487. 'begin': 0x3200,
  21488. 'end': 0x32FF
  21489. },
  21490. {
  21491. 'begin': 0x3300,
  21492. 'end': 0x33FF
  21493. },
  21494. {
  21495. 'begin': 0xAC00,
  21496. 'end': 0xD7AF
  21497. },
  21498. {
  21499. 'begin': 0xD800,
  21500. 'end': 0xDFFF
  21501. },
  21502. {
  21503. 'begin': 0x10900,
  21504. 'end': 0x1091F
  21505. },
  21506. {
  21507. 'begin': 0x4E00,
  21508. 'end': 0x9FFF
  21509. },
  21510. {
  21511. 'begin': 0xE000,
  21512. 'end': 0xF8FF
  21513. },
  21514. {
  21515. 'begin': 0x31C0,
  21516. 'end': 0x31EF
  21517. },
  21518. {
  21519. 'begin': 0xFB00,
  21520. 'end': 0xFB4F
  21521. },
  21522. {
  21523. 'begin': 0xFB50,
  21524. 'end': 0xFDFF
  21525. },
  21526. {
  21527. 'begin': 0xFE20,
  21528. 'end': 0xFE2F
  21529. },
  21530. {
  21531. 'begin': 0xFE10,
  21532. 'end': 0xFE1F
  21533. },
  21534. {
  21535. 'begin': 0xFE50,
  21536. 'end': 0xFE6F
  21537. },
  21538. {
  21539. 'begin': 0xFE70,
  21540. 'end': 0xFEFF
  21541. },
  21542. {
  21543. 'begin': 0xFF00,
  21544. 'end': 0xFFEF
  21545. },
  21546. {
  21547. 'begin': 0xFFF0,
  21548. 'end': 0xFFFF
  21549. },
  21550. {
  21551. 'begin': 0x0F00,
  21552. 'end': 0x0FFF
  21553. },
  21554. {
  21555. 'begin': 0x0700,
  21556. 'end': 0x074F
  21557. },
  21558. {
  21559. 'begin': 0x0780,
  21560. 'end': 0x07BF
  21561. },
  21562. {
  21563. 'begin': 0x0D80,
  21564. 'end': 0x0DFF
  21565. },
  21566. {
  21567. 'begin': 0x1000,
  21568. 'end': 0x109F
  21569. },
  21570. {
  21571. 'begin': 0x1200,
  21572. 'end': 0x137F
  21573. },
  21574. {
  21575. 'begin': 0x13A0,
  21576. 'end': 0x13FF
  21577. },
  21578. {
  21579. 'begin': 0x1400,
  21580. 'end': 0x167F
  21581. },
  21582. {
  21583. 'begin': 0x1680,
  21584. 'end': 0x169F
  21585. },
  21586. {
  21587. 'begin': 0x16A0,
  21588. 'end': 0x16FF
  21589. },
  21590. {
  21591. 'begin': 0x1780,
  21592. 'end': 0x17FF
  21593. },
  21594. {
  21595. 'begin': 0x1800,
  21596. 'end': 0x18AF
  21597. },
  21598. {
  21599. 'begin': 0x2800,
  21600. 'end': 0x28FF
  21601. },
  21602. {
  21603. 'begin': 0xA000,
  21604. 'end': 0xA48F
  21605. },
  21606. {
  21607. 'begin': 0x1700,
  21608. 'end': 0x171F
  21609. },
  21610. {
  21611. 'begin': 0x10300,
  21612. 'end': 0x1032F
  21613. },
  21614. {
  21615. 'begin': 0x10330,
  21616. 'end': 0x1034F
  21617. },
  21618. {
  21619. 'begin': 0x10400,
  21620. 'end': 0x1044F
  21621. },
  21622. {
  21623. 'begin': 0x1D000,
  21624. 'end': 0x1D0FF
  21625. },
  21626. {
  21627. 'begin': 0x1D400,
  21628. 'end': 0x1D7FF
  21629. },
  21630. {
  21631. 'begin': 0xFF000,
  21632. 'end': 0xFFFFD
  21633. },
  21634. {
  21635. 'begin': 0xFE00,
  21636. 'end': 0xFE0F
  21637. },
  21638. {
  21639. 'begin': 0xE0000,
  21640. 'end': 0xE007F
  21641. },
  21642. {
  21643. 'begin': 0x1900,
  21644. 'end': 0x194F
  21645. },
  21646. {
  21647. 'begin': 0x1950,
  21648. 'end': 0x197F
  21649. },
  21650. {
  21651. 'begin': 0x1980,
  21652. 'end': 0x19DF
  21653. },
  21654. {
  21655. 'begin': 0x1A00,
  21656. 'end': 0x1A1F
  21657. },
  21658. {
  21659. 'begin': 0x2C00,
  21660. 'end': 0x2C5F
  21661. },
  21662. {
  21663. 'begin': 0x2D30,
  21664. 'end': 0x2D7F
  21665. },
  21666. {
  21667. 'begin': 0x4DC0,
  21668. 'end': 0x4DFF
  21669. },
  21670. {
  21671. 'begin': 0xA800,
  21672. 'end': 0xA82F
  21673. },
  21674. {
  21675. 'begin': 0x10000,
  21676. 'end': 0x1007F
  21677. },
  21678. {
  21679. 'begin': 0x10140,
  21680. 'end': 0x1018F
  21681. },
  21682. {
  21683. 'begin': 0x10380,
  21684. 'end': 0x1039F
  21685. },
  21686. {
  21687. 'begin': 0x103A0,
  21688. 'end': 0x103DF
  21689. },
  21690. {
  21691. 'begin': 0x10450,
  21692. 'end': 0x1047F
  21693. },
  21694. {
  21695. 'begin': 0x10480,
  21696. 'end': 0x104AF
  21697. },
  21698. {
  21699. 'begin': 0x10800,
  21700. 'end': 0x1083F
  21701. },
  21702. {
  21703. 'begin': 0x10A00,
  21704. 'end': 0x10A5F
  21705. },
  21706. {
  21707. 'begin': 0x1D300,
  21708. 'end': 0x1D35F
  21709. },
  21710. {
  21711. 'begin': 0x12000,
  21712. 'end': 0x123FF
  21713. },
  21714. {
  21715. 'begin': 0x1D360,
  21716. 'end': 0x1D37F
  21717. },
  21718. {
  21719. 'begin': 0x1B80,
  21720. 'end': 0x1BBF
  21721. },
  21722. {
  21723. 'begin': 0x1C00,
  21724. 'end': 0x1C4F
  21725. },
  21726. {
  21727. 'begin': 0x1C50,
  21728. 'end': 0x1C7F
  21729. },
  21730. {
  21731. 'begin': 0xA880,
  21732. 'end': 0xA8DF
  21733. },
  21734. {
  21735. 'begin': 0xA900,
  21736. 'end': 0xA92F
  21737. },
  21738. {
  21739. 'begin': 0xA930,
  21740. 'end': 0xA95F
  21741. },
  21742. {
  21743. 'begin': 0xAA00,
  21744. 'end': 0xAA5F
  21745. },
  21746. {
  21747. 'begin': 0x10190,
  21748. 'end': 0x101CF
  21749. },
  21750. {
  21751. 'begin': 0x101D0,
  21752. 'end': 0x101FF
  21753. },
  21754. {
  21755. 'begin': 0x102A0,
  21756. 'end': 0x102DF
  21757. },
  21758. {
  21759. 'begin': 0x1F030,
  21760. 'end': 0x1F09F
  21761. }
  21762. ];
  21763. function getUnicodeRangeFor(value) {
  21764. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21765. var range = UnicodeRanges[i];
  21766. if (value >= range.begin && value < range.end) {
  21767. return i;
  21768. }
  21769. }
  21770. return -1;
  21771. }
  21772. function isRTLRangeFor(value) {
  21773. var range = UnicodeRanges[13];
  21774. if (value >= range.begin && value < range.end) {
  21775. return true;
  21776. }
  21777. range = UnicodeRanges[11];
  21778. if (value >= range.begin && value < range.end) {
  21779. return true;
  21780. }
  21781. return false;
  21782. }
  21783. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21784. t['\u00A8'] = '\u0020\u0308';
  21785. t['\u00AF'] = '\u0020\u0304';
  21786. t['\u00B4'] = '\u0020\u0301';
  21787. t['\u00B5'] = '\u03BC';
  21788. t['\u00B8'] = '\u0020\u0327';
  21789. t['\u0132'] = '\u0049\u004A';
  21790. t['\u0133'] = '\u0069\u006A';
  21791. t['\u013F'] = '\u004C\u00B7';
  21792. t['\u0140'] = '\u006C\u00B7';
  21793. t['\u0149'] = '\u02BC\u006E';
  21794. t['\u017F'] = '\u0073';
  21795. t['\u01C4'] = '\u0044\u017D';
  21796. t['\u01C5'] = '\u0044\u017E';
  21797. t['\u01C6'] = '\u0064\u017E';
  21798. t['\u01C7'] = '\u004C\u004A';
  21799. t['\u01C8'] = '\u004C\u006A';
  21800. t['\u01C9'] = '\u006C\u006A';
  21801. t['\u01CA'] = '\u004E\u004A';
  21802. t['\u01CB'] = '\u004E\u006A';
  21803. t['\u01CC'] = '\u006E\u006A';
  21804. t['\u01F1'] = '\u0044\u005A';
  21805. t['\u01F2'] = '\u0044\u007A';
  21806. t['\u01F3'] = '\u0064\u007A';
  21807. t['\u02D8'] = '\u0020\u0306';
  21808. t['\u02D9'] = '\u0020\u0307';
  21809. t['\u02DA'] = '\u0020\u030A';
  21810. t['\u02DB'] = '\u0020\u0328';
  21811. t['\u02DC'] = '\u0020\u0303';
  21812. t['\u02DD'] = '\u0020\u030B';
  21813. t['\u037A'] = '\u0020\u0345';
  21814. t['\u0384'] = '\u0020\u0301';
  21815. t['\u03D0'] = '\u03B2';
  21816. t['\u03D1'] = '\u03B8';
  21817. t['\u03D2'] = '\u03A5';
  21818. t['\u03D5'] = '\u03C6';
  21819. t['\u03D6'] = '\u03C0';
  21820. t['\u03F0'] = '\u03BA';
  21821. t['\u03F1'] = '\u03C1';
  21822. t['\u03F2'] = '\u03C2';
  21823. t['\u03F4'] = '\u0398';
  21824. t['\u03F5'] = '\u03B5';
  21825. t['\u03F9'] = '\u03A3';
  21826. t['\u0587'] = '\u0565\u0582';
  21827. t['\u0675'] = '\u0627\u0674';
  21828. t['\u0676'] = '\u0648\u0674';
  21829. t['\u0677'] = '\u06C7\u0674';
  21830. t['\u0678'] = '\u064A\u0674';
  21831. t['\u0E33'] = '\u0E4D\u0E32';
  21832. t['\u0EB3'] = '\u0ECD\u0EB2';
  21833. t['\u0EDC'] = '\u0EAB\u0E99';
  21834. t['\u0EDD'] = '\u0EAB\u0EA1';
  21835. t['\u0F77'] = '\u0FB2\u0F81';
  21836. t['\u0F79'] = '\u0FB3\u0F81';
  21837. t['\u1E9A'] = '\u0061\u02BE';
  21838. t['\u1FBD'] = '\u0020\u0313';
  21839. t['\u1FBF'] = '\u0020\u0313';
  21840. t['\u1FC0'] = '\u0020\u0342';
  21841. t['\u1FFE'] = '\u0020\u0314';
  21842. t['\u2002'] = '\u0020';
  21843. t['\u2003'] = '\u0020';
  21844. t['\u2004'] = '\u0020';
  21845. t['\u2005'] = '\u0020';
  21846. t['\u2006'] = '\u0020';
  21847. t['\u2008'] = '\u0020';
  21848. t['\u2009'] = '\u0020';
  21849. t['\u200A'] = '\u0020';
  21850. t['\u2017'] = '\u0020\u0333';
  21851. t['\u2024'] = '\u002E';
  21852. t['\u2025'] = '\u002E\u002E';
  21853. t['\u2026'] = '\u002E\u002E\u002E';
  21854. t['\u2033'] = '\u2032\u2032';
  21855. t['\u2034'] = '\u2032\u2032\u2032';
  21856. t['\u2036'] = '\u2035\u2035';
  21857. t['\u2037'] = '\u2035\u2035\u2035';
  21858. t['\u203C'] = '\u0021\u0021';
  21859. t['\u203E'] = '\u0020\u0305';
  21860. t['\u2047'] = '\u003F\u003F';
  21861. t['\u2048'] = '\u003F\u0021';
  21862. t['\u2049'] = '\u0021\u003F';
  21863. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21864. t['\u205F'] = '\u0020';
  21865. t['\u20A8'] = '\u0052\u0073';
  21866. t['\u2100'] = '\u0061\u002F\u0063';
  21867. t['\u2101'] = '\u0061\u002F\u0073';
  21868. t['\u2103'] = '\u00B0\u0043';
  21869. t['\u2105'] = '\u0063\u002F\u006F';
  21870. t['\u2106'] = '\u0063\u002F\u0075';
  21871. t['\u2107'] = '\u0190';
  21872. t['\u2109'] = '\u00B0\u0046';
  21873. t['\u2116'] = '\u004E\u006F';
  21874. t['\u2121'] = '\u0054\u0045\u004C';
  21875. t['\u2135'] = '\u05D0';
  21876. t['\u2136'] = '\u05D1';
  21877. t['\u2137'] = '\u05D2';
  21878. t['\u2138'] = '\u05D3';
  21879. t['\u213B'] = '\u0046\u0041\u0058';
  21880. t['\u2160'] = '\u0049';
  21881. t['\u2161'] = '\u0049\u0049';
  21882. t['\u2162'] = '\u0049\u0049\u0049';
  21883. t['\u2163'] = '\u0049\u0056';
  21884. t['\u2164'] = '\u0056';
  21885. t['\u2165'] = '\u0056\u0049';
  21886. t['\u2166'] = '\u0056\u0049\u0049';
  21887. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21888. t['\u2168'] = '\u0049\u0058';
  21889. t['\u2169'] = '\u0058';
  21890. t['\u216A'] = '\u0058\u0049';
  21891. t['\u216B'] = '\u0058\u0049\u0049';
  21892. t['\u216C'] = '\u004C';
  21893. t['\u216D'] = '\u0043';
  21894. t['\u216E'] = '\u0044';
  21895. t['\u216F'] = '\u004D';
  21896. t['\u2170'] = '\u0069';
  21897. t['\u2171'] = '\u0069\u0069';
  21898. t['\u2172'] = '\u0069\u0069\u0069';
  21899. t['\u2173'] = '\u0069\u0076';
  21900. t['\u2174'] = '\u0076';
  21901. t['\u2175'] = '\u0076\u0069';
  21902. t['\u2176'] = '\u0076\u0069\u0069';
  21903. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21904. t['\u2178'] = '\u0069\u0078';
  21905. t['\u2179'] = '\u0078';
  21906. t['\u217A'] = '\u0078\u0069';
  21907. t['\u217B'] = '\u0078\u0069\u0069';
  21908. t['\u217C'] = '\u006C';
  21909. t['\u217D'] = '\u0063';
  21910. t['\u217E'] = '\u0064';
  21911. t['\u217F'] = '\u006D';
  21912. t['\u222C'] = '\u222B\u222B';
  21913. t['\u222D'] = '\u222B\u222B\u222B';
  21914. t['\u222F'] = '\u222E\u222E';
  21915. t['\u2230'] = '\u222E\u222E\u222E';
  21916. t['\u2474'] = '\u0028\u0031\u0029';
  21917. t['\u2475'] = '\u0028\u0032\u0029';
  21918. t['\u2476'] = '\u0028\u0033\u0029';
  21919. t['\u2477'] = '\u0028\u0034\u0029';
  21920. t['\u2478'] = '\u0028\u0035\u0029';
  21921. t['\u2479'] = '\u0028\u0036\u0029';
  21922. t['\u247A'] = '\u0028\u0037\u0029';
  21923. t['\u247B'] = '\u0028\u0038\u0029';
  21924. t['\u247C'] = '\u0028\u0039\u0029';
  21925. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21926. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21927. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21928. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21929. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21930. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21931. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21932. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21933. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21934. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21935. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21936. t['\u2488'] = '\u0031\u002E';
  21937. t['\u2489'] = '\u0032\u002E';
  21938. t['\u248A'] = '\u0033\u002E';
  21939. t['\u248B'] = '\u0034\u002E';
  21940. t['\u248C'] = '\u0035\u002E';
  21941. t['\u248D'] = '\u0036\u002E';
  21942. t['\u248E'] = '\u0037\u002E';
  21943. t['\u248F'] = '\u0038\u002E';
  21944. t['\u2490'] = '\u0039\u002E';
  21945. t['\u2491'] = '\u0031\u0030\u002E';
  21946. t['\u2492'] = '\u0031\u0031\u002E';
  21947. t['\u2493'] = '\u0031\u0032\u002E';
  21948. t['\u2494'] = '\u0031\u0033\u002E';
  21949. t['\u2495'] = '\u0031\u0034\u002E';
  21950. t['\u2496'] = '\u0031\u0035\u002E';
  21951. t['\u2497'] = '\u0031\u0036\u002E';
  21952. t['\u2498'] = '\u0031\u0037\u002E';
  21953. t['\u2499'] = '\u0031\u0038\u002E';
  21954. t['\u249A'] = '\u0031\u0039\u002E';
  21955. t['\u249B'] = '\u0032\u0030\u002E';
  21956. t['\u249C'] = '\u0028\u0061\u0029';
  21957. t['\u249D'] = '\u0028\u0062\u0029';
  21958. t['\u249E'] = '\u0028\u0063\u0029';
  21959. t['\u249F'] = '\u0028\u0064\u0029';
  21960. t['\u24A0'] = '\u0028\u0065\u0029';
  21961. t['\u24A1'] = '\u0028\u0066\u0029';
  21962. t['\u24A2'] = '\u0028\u0067\u0029';
  21963. t['\u24A3'] = '\u0028\u0068\u0029';
  21964. t['\u24A4'] = '\u0028\u0069\u0029';
  21965. t['\u24A5'] = '\u0028\u006A\u0029';
  21966. t['\u24A6'] = '\u0028\u006B\u0029';
  21967. t['\u24A7'] = '\u0028\u006C\u0029';
  21968. t['\u24A8'] = '\u0028\u006D\u0029';
  21969. t['\u24A9'] = '\u0028\u006E\u0029';
  21970. t['\u24AA'] = '\u0028\u006F\u0029';
  21971. t['\u24AB'] = '\u0028\u0070\u0029';
  21972. t['\u24AC'] = '\u0028\u0071\u0029';
  21973. t['\u24AD'] = '\u0028\u0072\u0029';
  21974. t['\u24AE'] = '\u0028\u0073\u0029';
  21975. t['\u24AF'] = '\u0028\u0074\u0029';
  21976. t['\u24B0'] = '\u0028\u0075\u0029';
  21977. t['\u24B1'] = '\u0028\u0076\u0029';
  21978. t['\u24B2'] = '\u0028\u0077\u0029';
  21979. t['\u24B3'] = '\u0028\u0078\u0029';
  21980. t['\u24B4'] = '\u0028\u0079\u0029';
  21981. t['\u24B5'] = '\u0028\u007A\u0029';
  21982. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21983. t['\u2A74'] = '\u003A\u003A\u003D';
  21984. t['\u2A75'] = '\u003D\u003D';
  21985. t['\u2A76'] = '\u003D\u003D\u003D';
  21986. t['\u2E9F'] = '\u6BCD';
  21987. t['\u2EF3'] = '\u9F9F';
  21988. t['\u2F00'] = '\u4E00';
  21989. t['\u2F01'] = '\u4E28';
  21990. t['\u2F02'] = '\u4E36';
  21991. t['\u2F03'] = '\u4E3F';
  21992. t['\u2F04'] = '\u4E59';
  21993. t['\u2F05'] = '\u4E85';
  21994. t['\u2F06'] = '\u4E8C';
  21995. t['\u2F07'] = '\u4EA0';
  21996. t['\u2F08'] = '\u4EBA';
  21997. t['\u2F09'] = '\u513F';
  21998. t['\u2F0A'] = '\u5165';
  21999. t['\u2F0B'] = '\u516B';
  22000. t['\u2F0C'] = '\u5182';
  22001. t['\u2F0D'] = '\u5196';
  22002. t['\u2F0E'] = '\u51AB';
  22003. t['\u2F0F'] = '\u51E0';
  22004. t['\u2F10'] = '\u51F5';
  22005. t['\u2F11'] = '\u5200';
  22006. t['\u2F12'] = '\u529B';
  22007. t['\u2F13'] = '\u52F9';
  22008. t['\u2F14'] = '\u5315';
  22009. t['\u2F15'] = '\u531A';
  22010. t['\u2F16'] = '\u5338';
  22011. t['\u2F17'] = '\u5341';
  22012. t['\u2F18'] = '\u535C';
  22013. t['\u2F19'] = '\u5369';
  22014. t['\u2F1A'] = '\u5382';
  22015. t['\u2F1B'] = '\u53B6';
  22016. t['\u2F1C'] = '\u53C8';
  22017. t['\u2F1D'] = '\u53E3';
  22018. t['\u2F1E'] = '\u56D7';
  22019. t['\u2F1F'] = '\u571F';
  22020. t['\u2F20'] = '\u58EB';
  22021. t['\u2F21'] = '\u5902';
  22022. t['\u2F22'] = '\u590A';
  22023. t['\u2F23'] = '\u5915';
  22024. t['\u2F24'] = '\u5927';
  22025. t['\u2F25'] = '\u5973';
  22026. t['\u2F26'] = '\u5B50';
  22027. t['\u2F27'] = '\u5B80';
  22028. t['\u2F28'] = '\u5BF8';
  22029. t['\u2F29'] = '\u5C0F';
  22030. t['\u2F2A'] = '\u5C22';
  22031. t['\u2F2B'] = '\u5C38';
  22032. t['\u2F2C'] = '\u5C6E';
  22033. t['\u2F2D'] = '\u5C71';
  22034. t['\u2F2E'] = '\u5DDB';
  22035. t['\u2F2F'] = '\u5DE5';
  22036. t['\u2F30'] = '\u5DF1';
  22037. t['\u2F31'] = '\u5DFE';
  22038. t['\u2F32'] = '\u5E72';
  22039. t['\u2F33'] = '\u5E7A';
  22040. t['\u2F34'] = '\u5E7F';
  22041. t['\u2F35'] = '\u5EF4';
  22042. t['\u2F36'] = '\u5EFE';
  22043. t['\u2F37'] = '\u5F0B';
  22044. t['\u2F38'] = '\u5F13';
  22045. t['\u2F39'] = '\u5F50';
  22046. t['\u2F3A'] = '\u5F61';
  22047. t['\u2F3B'] = '\u5F73';
  22048. t['\u2F3C'] = '\u5FC3';
  22049. t['\u2F3D'] = '\u6208';
  22050. t['\u2F3E'] = '\u6236';
  22051. t['\u2F3F'] = '\u624B';
  22052. t['\u2F40'] = '\u652F';
  22053. t['\u2F41'] = '\u6534';
  22054. t['\u2F42'] = '\u6587';
  22055. t['\u2F43'] = '\u6597';
  22056. t['\u2F44'] = '\u65A4';
  22057. t['\u2F45'] = '\u65B9';
  22058. t['\u2F46'] = '\u65E0';
  22059. t['\u2F47'] = '\u65E5';
  22060. t['\u2F48'] = '\u66F0';
  22061. t['\u2F49'] = '\u6708';
  22062. t['\u2F4A'] = '\u6728';
  22063. t['\u2F4B'] = '\u6B20';
  22064. t['\u2F4C'] = '\u6B62';
  22065. t['\u2F4D'] = '\u6B79';
  22066. t['\u2F4E'] = '\u6BB3';
  22067. t['\u2F4F'] = '\u6BCB';
  22068. t['\u2F50'] = '\u6BD4';
  22069. t['\u2F51'] = '\u6BDB';
  22070. t['\u2F52'] = '\u6C0F';
  22071. t['\u2F53'] = '\u6C14';
  22072. t['\u2F54'] = '\u6C34';
  22073. t['\u2F55'] = '\u706B';
  22074. t['\u2F56'] = '\u722A';
  22075. t['\u2F57'] = '\u7236';
  22076. t['\u2F58'] = '\u723B';
  22077. t['\u2F59'] = '\u723F';
  22078. t['\u2F5A'] = '\u7247';
  22079. t['\u2F5B'] = '\u7259';
  22080. t['\u2F5C'] = '\u725B';
  22081. t['\u2F5D'] = '\u72AC';
  22082. t['\u2F5E'] = '\u7384';
  22083. t['\u2F5F'] = '\u7389';
  22084. t['\u2F60'] = '\u74DC';
  22085. t['\u2F61'] = '\u74E6';
  22086. t['\u2F62'] = '\u7518';
  22087. t['\u2F63'] = '\u751F';
  22088. t['\u2F64'] = '\u7528';
  22089. t['\u2F65'] = '\u7530';
  22090. t['\u2F66'] = '\u758B';
  22091. t['\u2F67'] = '\u7592';
  22092. t['\u2F68'] = '\u7676';
  22093. t['\u2F69'] = '\u767D';
  22094. t['\u2F6A'] = '\u76AE';
  22095. t['\u2F6B'] = '\u76BF';
  22096. t['\u2F6C'] = '\u76EE';
  22097. t['\u2F6D'] = '\u77DB';
  22098. t['\u2F6E'] = '\u77E2';
  22099. t['\u2F6F'] = '\u77F3';
  22100. t['\u2F70'] = '\u793A';
  22101. t['\u2F71'] = '\u79B8';
  22102. t['\u2F72'] = '\u79BE';
  22103. t['\u2F73'] = '\u7A74';
  22104. t['\u2F74'] = '\u7ACB';
  22105. t['\u2F75'] = '\u7AF9';
  22106. t['\u2F76'] = '\u7C73';
  22107. t['\u2F77'] = '\u7CF8';
  22108. t['\u2F78'] = '\u7F36';
  22109. t['\u2F79'] = '\u7F51';
  22110. t['\u2F7A'] = '\u7F8A';
  22111. t['\u2F7B'] = '\u7FBD';
  22112. t['\u2F7C'] = '\u8001';
  22113. t['\u2F7D'] = '\u800C';
  22114. t['\u2F7E'] = '\u8012';
  22115. t['\u2F7F'] = '\u8033';
  22116. t['\u2F80'] = '\u807F';
  22117. t['\u2F81'] = '\u8089';
  22118. t['\u2F82'] = '\u81E3';
  22119. t['\u2F83'] = '\u81EA';
  22120. t['\u2F84'] = '\u81F3';
  22121. t['\u2F85'] = '\u81FC';
  22122. t['\u2F86'] = '\u820C';
  22123. t['\u2F87'] = '\u821B';
  22124. t['\u2F88'] = '\u821F';
  22125. t['\u2F89'] = '\u826E';
  22126. t['\u2F8A'] = '\u8272';
  22127. t['\u2F8B'] = '\u8278';
  22128. t['\u2F8C'] = '\u864D';
  22129. t['\u2F8D'] = '\u866B';
  22130. t['\u2F8E'] = '\u8840';
  22131. t['\u2F8F'] = '\u884C';
  22132. t['\u2F90'] = '\u8863';
  22133. t['\u2F91'] = '\u897E';
  22134. t['\u2F92'] = '\u898B';
  22135. t['\u2F93'] = '\u89D2';
  22136. t['\u2F94'] = '\u8A00';
  22137. t['\u2F95'] = '\u8C37';
  22138. t['\u2F96'] = '\u8C46';
  22139. t['\u2F97'] = '\u8C55';
  22140. t['\u2F98'] = '\u8C78';
  22141. t['\u2F99'] = '\u8C9D';
  22142. t['\u2F9A'] = '\u8D64';
  22143. t['\u2F9B'] = '\u8D70';
  22144. t['\u2F9C'] = '\u8DB3';
  22145. t['\u2F9D'] = '\u8EAB';
  22146. t['\u2F9E'] = '\u8ECA';
  22147. t['\u2F9F'] = '\u8F9B';
  22148. t['\u2FA0'] = '\u8FB0';
  22149. t['\u2FA1'] = '\u8FB5';
  22150. t['\u2FA2'] = '\u9091';
  22151. t['\u2FA3'] = '\u9149';
  22152. t['\u2FA4'] = '\u91C6';
  22153. t['\u2FA5'] = '\u91CC';
  22154. t['\u2FA6'] = '\u91D1';
  22155. t['\u2FA7'] = '\u9577';
  22156. t['\u2FA8'] = '\u9580';
  22157. t['\u2FA9'] = '\u961C';
  22158. t['\u2FAA'] = '\u96B6';
  22159. t['\u2FAB'] = '\u96B9';
  22160. t['\u2FAC'] = '\u96E8';
  22161. t['\u2FAD'] = '\u9751';
  22162. t['\u2FAE'] = '\u975E';
  22163. t['\u2FAF'] = '\u9762';
  22164. t['\u2FB0'] = '\u9769';
  22165. t['\u2FB1'] = '\u97CB';
  22166. t['\u2FB2'] = '\u97ED';
  22167. t['\u2FB3'] = '\u97F3';
  22168. t['\u2FB4'] = '\u9801';
  22169. t['\u2FB5'] = '\u98A8';
  22170. t['\u2FB6'] = '\u98DB';
  22171. t['\u2FB7'] = '\u98DF';
  22172. t['\u2FB8'] = '\u9996';
  22173. t['\u2FB9'] = '\u9999';
  22174. t['\u2FBA'] = '\u99AC';
  22175. t['\u2FBB'] = '\u9AA8';
  22176. t['\u2FBC'] = '\u9AD8';
  22177. t['\u2FBD'] = '\u9ADF';
  22178. t['\u2FBE'] = '\u9B25';
  22179. t['\u2FBF'] = '\u9B2F';
  22180. t['\u2FC0'] = '\u9B32';
  22181. t['\u2FC1'] = '\u9B3C';
  22182. t['\u2FC2'] = '\u9B5A';
  22183. t['\u2FC3'] = '\u9CE5';
  22184. t['\u2FC4'] = '\u9E75';
  22185. t['\u2FC5'] = '\u9E7F';
  22186. t['\u2FC6'] = '\u9EA5';
  22187. t['\u2FC7'] = '\u9EBB';
  22188. t['\u2FC8'] = '\u9EC3';
  22189. t['\u2FC9'] = '\u9ECD';
  22190. t['\u2FCA'] = '\u9ED1';
  22191. t['\u2FCB'] = '\u9EF9';
  22192. t['\u2FCC'] = '\u9EFD';
  22193. t['\u2FCD'] = '\u9F0E';
  22194. t['\u2FCE'] = '\u9F13';
  22195. t['\u2FCF'] = '\u9F20';
  22196. t['\u2FD0'] = '\u9F3B';
  22197. t['\u2FD1'] = '\u9F4A';
  22198. t['\u2FD2'] = '\u9F52';
  22199. t['\u2FD3'] = '\u9F8D';
  22200. t['\u2FD4'] = '\u9F9C';
  22201. t['\u2FD5'] = '\u9FA0';
  22202. t['\u3036'] = '\u3012';
  22203. t['\u3038'] = '\u5341';
  22204. t['\u3039'] = '\u5344';
  22205. t['\u303A'] = '\u5345';
  22206. t['\u309B'] = '\u0020\u3099';
  22207. t['\u309C'] = '\u0020\u309A';
  22208. t['\u3131'] = '\u1100';
  22209. t['\u3132'] = '\u1101';
  22210. t['\u3133'] = '\u11AA';
  22211. t['\u3134'] = '\u1102';
  22212. t['\u3135'] = '\u11AC';
  22213. t['\u3136'] = '\u11AD';
  22214. t['\u3137'] = '\u1103';
  22215. t['\u3138'] = '\u1104';
  22216. t['\u3139'] = '\u1105';
  22217. t['\u313A'] = '\u11B0';
  22218. t['\u313B'] = '\u11B1';
  22219. t['\u313C'] = '\u11B2';
  22220. t['\u313D'] = '\u11B3';
  22221. t['\u313E'] = '\u11B4';
  22222. t['\u313F'] = '\u11B5';
  22223. t['\u3140'] = '\u111A';
  22224. t['\u3141'] = '\u1106';
  22225. t['\u3142'] = '\u1107';
  22226. t['\u3143'] = '\u1108';
  22227. t['\u3144'] = '\u1121';
  22228. t['\u3145'] = '\u1109';
  22229. t['\u3146'] = '\u110A';
  22230. t['\u3147'] = '\u110B';
  22231. t['\u3148'] = '\u110C';
  22232. t['\u3149'] = '\u110D';
  22233. t['\u314A'] = '\u110E';
  22234. t['\u314B'] = '\u110F';
  22235. t['\u314C'] = '\u1110';
  22236. t['\u314D'] = '\u1111';
  22237. t['\u314E'] = '\u1112';
  22238. t['\u314F'] = '\u1161';
  22239. t['\u3150'] = '\u1162';
  22240. t['\u3151'] = '\u1163';
  22241. t['\u3152'] = '\u1164';
  22242. t['\u3153'] = '\u1165';
  22243. t['\u3154'] = '\u1166';
  22244. t['\u3155'] = '\u1167';
  22245. t['\u3156'] = '\u1168';
  22246. t['\u3157'] = '\u1169';
  22247. t['\u3158'] = '\u116A';
  22248. t['\u3159'] = '\u116B';
  22249. t['\u315A'] = '\u116C';
  22250. t['\u315B'] = '\u116D';
  22251. t['\u315C'] = '\u116E';
  22252. t['\u315D'] = '\u116F';
  22253. t['\u315E'] = '\u1170';
  22254. t['\u315F'] = '\u1171';
  22255. t['\u3160'] = '\u1172';
  22256. t['\u3161'] = '\u1173';
  22257. t['\u3162'] = '\u1174';
  22258. t['\u3163'] = '\u1175';
  22259. t['\u3164'] = '\u1160';
  22260. t['\u3165'] = '\u1114';
  22261. t['\u3166'] = '\u1115';
  22262. t['\u3167'] = '\u11C7';
  22263. t['\u3168'] = '\u11C8';
  22264. t['\u3169'] = '\u11CC';
  22265. t['\u316A'] = '\u11CE';
  22266. t['\u316B'] = '\u11D3';
  22267. t['\u316C'] = '\u11D7';
  22268. t['\u316D'] = '\u11D9';
  22269. t['\u316E'] = '\u111C';
  22270. t['\u316F'] = '\u11DD';
  22271. t['\u3170'] = '\u11DF';
  22272. t['\u3171'] = '\u111D';
  22273. t['\u3172'] = '\u111E';
  22274. t['\u3173'] = '\u1120';
  22275. t['\u3174'] = '\u1122';
  22276. t['\u3175'] = '\u1123';
  22277. t['\u3176'] = '\u1127';
  22278. t['\u3177'] = '\u1129';
  22279. t['\u3178'] = '\u112B';
  22280. t['\u3179'] = '\u112C';
  22281. t['\u317A'] = '\u112D';
  22282. t['\u317B'] = '\u112E';
  22283. t['\u317C'] = '\u112F';
  22284. t['\u317D'] = '\u1132';
  22285. t['\u317E'] = '\u1136';
  22286. t['\u317F'] = '\u1140';
  22287. t['\u3180'] = '\u1147';
  22288. t['\u3181'] = '\u114C';
  22289. t['\u3182'] = '\u11F1';
  22290. t['\u3183'] = '\u11F2';
  22291. t['\u3184'] = '\u1157';
  22292. t['\u3185'] = '\u1158';
  22293. t['\u3186'] = '\u1159';
  22294. t['\u3187'] = '\u1184';
  22295. t['\u3188'] = '\u1185';
  22296. t['\u3189'] = '\u1188';
  22297. t['\u318A'] = '\u1191';
  22298. t['\u318B'] = '\u1192';
  22299. t['\u318C'] = '\u1194';
  22300. t['\u318D'] = '\u119E';
  22301. t['\u318E'] = '\u11A1';
  22302. t['\u3200'] = '\u0028\u1100\u0029';
  22303. t['\u3201'] = '\u0028\u1102\u0029';
  22304. t['\u3202'] = '\u0028\u1103\u0029';
  22305. t['\u3203'] = '\u0028\u1105\u0029';
  22306. t['\u3204'] = '\u0028\u1106\u0029';
  22307. t['\u3205'] = '\u0028\u1107\u0029';
  22308. t['\u3206'] = '\u0028\u1109\u0029';
  22309. t['\u3207'] = '\u0028\u110B\u0029';
  22310. t['\u3208'] = '\u0028\u110C\u0029';
  22311. t['\u3209'] = '\u0028\u110E\u0029';
  22312. t['\u320A'] = '\u0028\u110F\u0029';
  22313. t['\u320B'] = '\u0028\u1110\u0029';
  22314. t['\u320C'] = '\u0028\u1111\u0029';
  22315. t['\u320D'] = '\u0028\u1112\u0029';
  22316. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22317. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22318. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22319. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22320. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22321. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22322. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22323. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22324. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22325. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22326. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22327. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22328. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22329. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22330. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22331. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22332. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22333. t['\u3220'] = '\u0028\u4E00\u0029';
  22334. t['\u3221'] = '\u0028\u4E8C\u0029';
  22335. t['\u3222'] = '\u0028\u4E09\u0029';
  22336. t['\u3223'] = '\u0028\u56DB\u0029';
  22337. t['\u3224'] = '\u0028\u4E94\u0029';
  22338. t['\u3225'] = '\u0028\u516D\u0029';
  22339. t['\u3226'] = '\u0028\u4E03\u0029';
  22340. t['\u3227'] = '\u0028\u516B\u0029';
  22341. t['\u3228'] = '\u0028\u4E5D\u0029';
  22342. t['\u3229'] = '\u0028\u5341\u0029';
  22343. t['\u322A'] = '\u0028\u6708\u0029';
  22344. t['\u322B'] = '\u0028\u706B\u0029';
  22345. t['\u322C'] = '\u0028\u6C34\u0029';
  22346. t['\u322D'] = '\u0028\u6728\u0029';
  22347. t['\u322E'] = '\u0028\u91D1\u0029';
  22348. t['\u322F'] = '\u0028\u571F\u0029';
  22349. t['\u3230'] = '\u0028\u65E5\u0029';
  22350. t['\u3231'] = '\u0028\u682A\u0029';
  22351. t['\u3232'] = '\u0028\u6709\u0029';
  22352. t['\u3233'] = '\u0028\u793E\u0029';
  22353. t['\u3234'] = '\u0028\u540D\u0029';
  22354. t['\u3235'] = '\u0028\u7279\u0029';
  22355. t['\u3236'] = '\u0028\u8CA1\u0029';
  22356. t['\u3237'] = '\u0028\u795D\u0029';
  22357. t['\u3238'] = '\u0028\u52B4\u0029';
  22358. t['\u3239'] = '\u0028\u4EE3\u0029';
  22359. t['\u323A'] = '\u0028\u547C\u0029';
  22360. t['\u323B'] = '\u0028\u5B66\u0029';
  22361. t['\u323C'] = '\u0028\u76E3\u0029';
  22362. t['\u323D'] = '\u0028\u4F01\u0029';
  22363. t['\u323E'] = '\u0028\u8CC7\u0029';
  22364. t['\u323F'] = '\u0028\u5354\u0029';
  22365. t['\u3240'] = '\u0028\u796D\u0029';
  22366. t['\u3241'] = '\u0028\u4F11\u0029';
  22367. t['\u3242'] = '\u0028\u81EA\u0029';
  22368. t['\u3243'] = '\u0028\u81F3\u0029';
  22369. t['\u32C0'] = '\u0031\u6708';
  22370. t['\u32C1'] = '\u0032\u6708';
  22371. t['\u32C2'] = '\u0033\u6708';
  22372. t['\u32C3'] = '\u0034\u6708';
  22373. t['\u32C4'] = '\u0035\u6708';
  22374. t['\u32C5'] = '\u0036\u6708';
  22375. t['\u32C6'] = '\u0037\u6708';
  22376. t['\u32C7'] = '\u0038\u6708';
  22377. t['\u32C8'] = '\u0039\u6708';
  22378. t['\u32C9'] = '\u0031\u0030\u6708';
  22379. t['\u32CA'] = '\u0031\u0031\u6708';
  22380. t['\u32CB'] = '\u0031\u0032\u6708';
  22381. t['\u3358'] = '\u0030\u70B9';
  22382. t['\u3359'] = '\u0031\u70B9';
  22383. t['\u335A'] = '\u0032\u70B9';
  22384. t['\u335B'] = '\u0033\u70B9';
  22385. t['\u335C'] = '\u0034\u70B9';
  22386. t['\u335D'] = '\u0035\u70B9';
  22387. t['\u335E'] = '\u0036\u70B9';
  22388. t['\u335F'] = '\u0037\u70B9';
  22389. t['\u3360'] = '\u0038\u70B9';
  22390. t['\u3361'] = '\u0039\u70B9';
  22391. t['\u3362'] = '\u0031\u0030\u70B9';
  22392. t['\u3363'] = '\u0031\u0031\u70B9';
  22393. t['\u3364'] = '\u0031\u0032\u70B9';
  22394. t['\u3365'] = '\u0031\u0033\u70B9';
  22395. t['\u3366'] = '\u0031\u0034\u70B9';
  22396. t['\u3367'] = '\u0031\u0035\u70B9';
  22397. t['\u3368'] = '\u0031\u0036\u70B9';
  22398. t['\u3369'] = '\u0031\u0037\u70B9';
  22399. t['\u336A'] = '\u0031\u0038\u70B9';
  22400. t['\u336B'] = '\u0031\u0039\u70B9';
  22401. t['\u336C'] = '\u0032\u0030\u70B9';
  22402. t['\u336D'] = '\u0032\u0031\u70B9';
  22403. t['\u336E'] = '\u0032\u0032\u70B9';
  22404. t['\u336F'] = '\u0032\u0033\u70B9';
  22405. t['\u3370'] = '\u0032\u0034\u70B9';
  22406. t['\u33E0'] = '\u0031\u65E5';
  22407. t['\u33E1'] = '\u0032\u65E5';
  22408. t['\u33E2'] = '\u0033\u65E5';
  22409. t['\u33E3'] = '\u0034\u65E5';
  22410. t['\u33E4'] = '\u0035\u65E5';
  22411. t['\u33E5'] = '\u0036\u65E5';
  22412. t['\u33E6'] = '\u0037\u65E5';
  22413. t['\u33E7'] = '\u0038\u65E5';
  22414. t['\u33E8'] = '\u0039\u65E5';
  22415. t['\u33E9'] = '\u0031\u0030\u65E5';
  22416. t['\u33EA'] = '\u0031\u0031\u65E5';
  22417. t['\u33EB'] = '\u0031\u0032\u65E5';
  22418. t['\u33EC'] = '\u0031\u0033\u65E5';
  22419. t['\u33ED'] = '\u0031\u0034\u65E5';
  22420. t['\u33EE'] = '\u0031\u0035\u65E5';
  22421. t['\u33EF'] = '\u0031\u0036\u65E5';
  22422. t['\u33F0'] = '\u0031\u0037\u65E5';
  22423. t['\u33F1'] = '\u0031\u0038\u65E5';
  22424. t['\u33F2'] = '\u0031\u0039\u65E5';
  22425. t['\u33F3'] = '\u0032\u0030\u65E5';
  22426. t['\u33F4'] = '\u0032\u0031\u65E5';
  22427. t['\u33F5'] = '\u0032\u0032\u65E5';
  22428. t['\u33F6'] = '\u0032\u0033\u65E5';
  22429. t['\u33F7'] = '\u0032\u0034\u65E5';
  22430. t['\u33F8'] = '\u0032\u0035\u65E5';
  22431. t['\u33F9'] = '\u0032\u0036\u65E5';
  22432. t['\u33FA'] = '\u0032\u0037\u65E5';
  22433. t['\u33FB'] = '\u0032\u0038\u65E5';
  22434. t['\u33FC'] = '\u0032\u0039\u65E5';
  22435. t['\u33FD'] = '\u0033\u0030\u65E5';
  22436. t['\u33FE'] = '\u0033\u0031\u65E5';
  22437. t['\uFB00'] = '\u0066\u0066';
  22438. t['\uFB01'] = '\u0066\u0069';
  22439. t['\uFB02'] = '\u0066\u006C';
  22440. t['\uFB03'] = '\u0066\u0066\u0069';
  22441. t['\uFB04'] = '\u0066\u0066\u006C';
  22442. t['\uFB05'] = '\u017F\u0074';
  22443. t['\uFB06'] = '\u0073\u0074';
  22444. t['\uFB13'] = '\u0574\u0576';
  22445. t['\uFB14'] = '\u0574\u0565';
  22446. t['\uFB15'] = '\u0574\u056B';
  22447. t['\uFB16'] = '\u057E\u0576';
  22448. t['\uFB17'] = '\u0574\u056D';
  22449. t['\uFB4F'] = '\u05D0\u05DC';
  22450. t['\uFB50'] = '\u0671';
  22451. t['\uFB51'] = '\u0671';
  22452. t['\uFB52'] = '\u067B';
  22453. t['\uFB53'] = '\u067B';
  22454. t['\uFB54'] = '\u067B';
  22455. t['\uFB55'] = '\u067B';
  22456. t['\uFB56'] = '\u067E';
  22457. t['\uFB57'] = '\u067E';
  22458. t['\uFB58'] = '\u067E';
  22459. t['\uFB59'] = '\u067E';
  22460. t['\uFB5A'] = '\u0680';
  22461. t['\uFB5B'] = '\u0680';
  22462. t['\uFB5C'] = '\u0680';
  22463. t['\uFB5D'] = '\u0680';
  22464. t['\uFB5E'] = '\u067A';
  22465. t['\uFB5F'] = '\u067A';
  22466. t['\uFB60'] = '\u067A';
  22467. t['\uFB61'] = '\u067A';
  22468. t['\uFB62'] = '\u067F';
  22469. t['\uFB63'] = '\u067F';
  22470. t['\uFB64'] = '\u067F';
  22471. t['\uFB65'] = '\u067F';
  22472. t['\uFB66'] = '\u0679';
  22473. t['\uFB67'] = '\u0679';
  22474. t['\uFB68'] = '\u0679';
  22475. t['\uFB69'] = '\u0679';
  22476. t['\uFB6A'] = '\u06A4';
  22477. t['\uFB6B'] = '\u06A4';
  22478. t['\uFB6C'] = '\u06A4';
  22479. t['\uFB6D'] = '\u06A4';
  22480. t['\uFB6E'] = '\u06A6';
  22481. t['\uFB6F'] = '\u06A6';
  22482. t['\uFB70'] = '\u06A6';
  22483. t['\uFB71'] = '\u06A6';
  22484. t['\uFB72'] = '\u0684';
  22485. t['\uFB73'] = '\u0684';
  22486. t['\uFB74'] = '\u0684';
  22487. t['\uFB75'] = '\u0684';
  22488. t['\uFB76'] = '\u0683';
  22489. t['\uFB77'] = '\u0683';
  22490. t['\uFB78'] = '\u0683';
  22491. t['\uFB79'] = '\u0683';
  22492. t['\uFB7A'] = '\u0686';
  22493. t['\uFB7B'] = '\u0686';
  22494. t['\uFB7C'] = '\u0686';
  22495. t['\uFB7D'] = '\u0686';
  22496. t['\uFB7E'] = '\u0687';
  22497. t['\uFB7F'] = '\u0687';
  22498. t['\uFB80'] = '\u0687';
  22499. t['\uFB81'] = '\u0687';
  22500. t['\uFB82'] = '\u068D';
  22501. t['\uFB83'] = '\u068D';
  22502. t['\uFB84'] = '\u068C';
  22503. t['\uFB85'] = '\u068C';
  22504. t['\uFB86'] = '\u068E';
  22505. t['\uFB87'] = '\u068E';
  22506. t['\uFB88'] = '\u0688';
  22507. t['\uFB89'] = '\u0688';
  22508. t['\uFB8A'] = '\u0698';
  22509. t['\uFB8B'] = '\u0698';
  22510. t['\uFB8C'] = '\u0691';
  22511. t['\uFB8D'] = '\u0691';
  22512. t['\uFB8E'] = '\u06A9';
  22513. t['\uFB8F'] = '\u06A9';
  22514. t['\uFB90'] = '\u06A9';
  22515. t['\uFB91'] = '\u06A9';
  22516. t['\uFB92'] = '\u06AF';
  22517. t['\uFB93'] = '\u06AF';
  22518. t['\uFB94'] = '\u06AF';
  22519. t['\uFB95'] = '\u06AF';
  22520. t['\uFB96'] = '\u06B3';
  22521. t['\uFB97'] = '\u06B3';
  22522. t['\uFB98'] = '\u06B3';
  22523. t['\uFB99'] = '\u06B3';
  22524. t['\uFB9A'] = '\u06B1';
  22525. t['\uFB9B'] = '\u06B1';
  22526. t['\uFB9C'] = '\u06B1';
  22527. t['\uFB9D'] = '\u06B1';
  22528. t['\uFB9E'] = '\u06BA';
  22529. t['\uFB9F'] = '\u06BA';
  22530. t['\uFBA0'] = '\u06BB';
  22531. t['\uFBA1'] = '\u06BB';
  22532. t['\uFBA2'] = '\u06BB';
  22533. t['\uFBA3'] = '\u06BB';
  22534. t['\uFBA4'] = '\u06C0';
  22535. t['\uFBA5'] = '\u06C0';
  22536. t['\uFBA6'] = '\u06C1';
  22537. t['\uFBA7'] = '\u06C1';
  22538. t['\uFBA8'] = '\u06C1';
  22539. t['\uFBA9'] = '\u06C1';
  22540. t['\uFBAA'] = '\u06BE';
  22541. t['\uFBAB'] = '\u06BE';
  22542. t['\uFBAC'] = '\u06BE';
  22543. t['\uFBAD'] = '\u06BE';
  22544. t['\uFBAE'] = '\u06D2';
  22545. t['\uFBAF'] = '\u06D2';
  22546. t['\uFBB0'] = '\u06D3';
  22547. t['\uFBB1'] = '\u06D3';
  22548. t['\uFBD3'] = '\u06AD';
  22549. t['\uFBD4'] = '\u06AD';
  22550. t['\uFBD5'] = '\u06AD';
  22551. t['\uFBD6'] = '\u06AD';
  22552. t['\uFBD7'] = '\u06C7';
  22553. t['\uFBD8'] = '\u06C7';
  22554. t['\uFBD9'] = '\u06C6';
  22555. t['\uFBDA'] = '\u06C6';
  22556. t['\uFBDB'] = '\u06C8';
  22557. t['\uFBDC'] = '\u06C8';
  22558. t['\uFBDD'] = '\u0677';
  22559. t['\uFBDE'] = '\u06CB';
  22560. t['\uFBDF'] = '\u06CB';
  22561. t['\uFBE0'] = '\u06C5';
  22562. t['\uFBE1'] = '\u06C5';
  22563. t['\uFBE2'] = '\u06C9';
  22564. t['\uFBE3'] = '\u06C9';
  22565. t['\uFBE4'] = '\u06D0';
  22566. t['\uFBE5'] = '\u06D0';
  22567. t['\uFBE6'] = '\u06D0';
  22568. t['\uFBE7'] = '\u06D0';
  22569. t['\uFBE8'] = '\u0649';
  22570. t['\uFBE9'] = '\u0649';
  22571. t['\uFBEA'] = '\u0626\u0627';
  22572. t['\uFBEB'] = '\u0626\u0627';
  22573. t['\uFBEC'] = '\u0626\u06D5';
  22574. t['\uFBED'] = '\u0626\u06D5';
  22575. t['\uFBEE'] = '\u0626\u0648';
  22576. t['\uFBEF'] = '\u0626\u0648';
  22577. t['\uFBF0'] = '\u0626\u06C7';
  22578. t['\uFBF1'] = '\u0626\u06C7';
  22579. t['\uFBF2'] = '\u0626\u06C6';
  22580. t['\uFBF3'] = '\u0626\u06C6';
  22581. t['\uFBF4'] = '\u0626\u06C8';
  22582. t['\uFBF5'] = '\u0626\u06C8';
  22583. t['\uFBF6'] = '\u0626\u06D0';
  22584. t['\uFBF7'] = '\u0626\u06D0';
  22585. t['\uFBF8'] = '\u0626\u06D0';
  22586. t['\uFBF9'] = '\u0626\u0649';
  22587. t['\uFBFA'] = '\u0626\u0649';
  22588. t['\uFBFB'] = '\u0626\u0649';
  22589. t['\uFBFC'] = '\u06CC';
  22590. t['\uFBFD'] = '\u06CC';
  22591. t['\uFBFE'] = '\u06CC';
  22592. t['\uFBFF'] = '\u06CC';
  22593. t['\uFC00'] = '\u0626\u062C';
  22594. t['\uFC01'] = '\u0626\u062D';
  22595. t['\uFC02'] = '\u0626\u0645';
  22596. t['\uFC03'] = '\u0626\u0649';
  22597. t['\uFC04'] = '\u0626\u064A';
  22598. t['\uFC05'] = '\u0628\u062C';
  22599. t['\uFC06'] = '\u0628\u062D';
  22600. t['\uFC07'] = '\u0628\u062E';
  22601. t['\uFC08'] = '\u0628\u0645';
  22602. t['\uFC09'] = '\u0628\u0649';
  22603. t['\uFC0A'] = '\u0628\u064A';
  22604. t['\uFC0B'] = '\u062A\u062C';
  22605. t['\uFC0C'] = '\u062A\u062D';
  22606. t['\uFC0D'] = '\u062A\u062E';
  22607. t['\uFC0E'] = '\u062A\u0645';
  22608. t['\uFC0F'] = '\u062A\u0649';
  22609. t['\uFC10'] = '\u062A\u064A';
  22610. t['\uFC11'] = '\u062B\u062C';
  22611. t['\uFC12'] = '\u062B\u0645';
  22612. t['\uFC13'] = '\u062B\u0649';
  22613. t['\uFC14'] = '\u062B\u064A';
  22614. t['\uFC15'] = '\u062C\u062D';
  22615. t['\uFC16'] = '\u062C\u0645';
  22616. t['\uFC17'] = '\u062D\u062C';
  22617. t['\uFC18'] = '\u062D\u0645';
  22618. t['\uFC19'] = '\u062E\u062C';
  22619. t['\uFC1A'] = '\u062E\u062D';
  22620. t['\uFC1B'] = '\u062E\u0645';
  22621. t['\uFC1C'] = '\u0633\u062C';
  22622. t['\uFC1D'] = '\u0633\u062D';
  22623. t['\uFC1E'] = '\u0633\u062E';
  22624. t['\uFC1F'] = '\u0633\u0645';
  22625. t['\uFC20'] = '\u0635\u062D';
  22626. t['\uFC21'] = '\u0635\u0645';
  22627. t['\uFC22'] = '\u0636\u062C';
  22628. t['\uFC23'] = '\u0636\u062D';
  22629. t['\uFC24'] = '\u0636\u062E';
  22630. t['\uFC25'] = '\u0636\u0645';
  22631. t['\uFC26'] = '\u0637\u062D';
  22632. t['\uFC27'] = '\u0637\u0645';
  22633. t['\uFC28'] = '\u0638\u0645';
  22634. t['\uFC29'] = '\u0639\u062C';
  22635. t['\uFC2A'] = '\u0639\u0645';
  22636. t['\uFC2B'] = '\u063A\u062C';
  22637. t['\uFC2C'] = '\u063A\u0645';
  22638. t['\uFC2D'] = '\u0641\u062C';
  22639. t['\uFC2E'] = '\u0641\u062D';
  22640. t['\uFC2F'] = '\u0641\u062E';
  22641. t['\uFC30'] = '\u0641\u0645';
  22642. t['\uFC31'] = '\u0641\u0649';
  22643. t['\uFC32'] = '\u0641\u064A';
  22644. t['\uFC33'] = '\u0642\u062D';
  22645. t['\uFC34'] = '\u0642\u0645';
  22646. t['\uFC35'] = '\u0642\u0649';
  22647. t['\uFC36'] = '\u0642\u064A';
  22648. t['\uFC37'] = '\u0643\u0627';
  22649. t['\uFC38'] = '\u0643\u062C';
  22650. t['\uFC39'] = '\u0643\u062D';
  22651. t['\uFC3A'] = '\u0643\u062E';
  22652. t['\uFC3B'] = '\u0643\u0644';
  22653. t['\uFC3C'] = '\u0643\u0645';
  22654. t['\uFC3D'] = '\u0643\u0649';
  22655. t['\uFC3E'] = '\u0643\u064A';
  22656. t['\uFC3F'] = '\u0644\u062C';
  22657. t['\uFC40'] = '\u0644\u062D';
  22658. t['\uFC41'] = '\u0644\u062E';
  22659. t['\uFC42'] = '\u0644\u0645';
  22660. t['\uFC43'] = '\u0644\u0649';
  22661. t['\uFC44'] = '\u0644\u064A';
  22662. t['\uFC45'] = '\u0645\u062C';
  22663. t['\uFC46'] = '\u0645\u062D';
  22664. t['\uFC47'] = '\u0645\u062E';
  22665. t['\uFC48'] = '\u0645\u0645';
  22666. t['\uFC49'] = '\u0645\u0649';
  22667. t['\uFC4A'] = '\u0645\u064A';
  22668. t['\uFC4B'] = '\u0646\u062C';
  22669. t['\uFC4C'] = '\u0646\u062D';
  22670. t['\uFC4D'] = '\u0646\u062E';
  22671. t['\uFC4E'] = '\u0646\u0645';
  22672. t['\uFC4F'] = '\u0646\u0649';
  22673. t['\uFC50'] = '\u0646\u064A';
  22674. t['\uFC51'] = '\u0647\u062C';
  22675. t['\uFC52'] = '\u0647\u0645';
  22676. t['\uFC53'] = '\u0647\u0649';
  22677. t['\uFC54'] = '\u0647\u064A';
  22678. t['\uFC55'] = '\u064A\u062C';
  22679. t['\uFC56'] = '\u064A\u062D';
  22680. t['\uFC57'] = '\u064A\u062E';
  22681. t['\uFC58'] = '\u064A\u0645';
  22682. t['\uFC59'] = '\u064A\u0649';
  22683. t['\uFC5A'] = '\u064A\u064A';
  22684. t['\uFC5B'] = '\u0630\u0670';
  22685. t['\uFC5C'] = '\u0631\u0670';
  22686. t['\uFC5D'] = '\u0649\u0670';
  22687. t['\uFC5E'] = '\u0020\u064C\u0651';
  22688. t['\uFC5F'] = '\u0020\u064D\u0651';
  22689. t['\uFC60'] = '\u0020\u064E\u0651';
  22690. t['\uFC61'] = '\u0020\u064F\u0651';
  22691. t['\uFC62'] = '\u0020\u0650\u0651';
  22692. t['\uFC63'] = '\u0020\u0651\u0670';
  22693. t['\uFC64'] = '\u0626\u0631';
  22694. t['\uFC65'] = '\u0626\u0632';
  22695. t['\uFC66'] = '\u0626\u0645';
  22696. t['\uFC67'] = '\u0626\u0646';
  22697. t['\uFC68'] = '\u0626\u0649';
  22698. t['\uFC69'] = '\u0626\u064A';
  22699. t['\uFC6A'] = '\u0628\u0631';
  22700. t['\uFC6B'] = '\u0628\u0632';
  22701. t['\uFC6C'] = '\u0628\u0645';
  22702. t['\uFC6D'] = '\u0628\u0646';
  22703. t['\uFC6E'] = '\u0628\u0649';
  22704. t['\uFC6F'] = '\u0628\u064A';
  22705. t['\uFC70'] = '\u062A\u0631';
  22706. t['\uFC71'] = '\u062A\u0632';
  22707. t['\uFC72'] = '\u062A\u0645';
  22708. t['\uFC73'] = '\u062A\u0646';
  22709. t['\uFC74'] = '\u062A\u0649';
  22710. t['\uFC75'] = '\u062A\u064A';
  22711. t['\uFC76'] = '\u062B\u0631';
  22712. t['\uFC77'] = '\u062B\u0632';
  22713. t['\uFC78'] = '\u062B\u0645';
  22714. t['\uFC79'] = '\u062B\u0646';
  22715. t['\uFC7A'] = '\u062B\u0649';
  22716. t['\uFC7B'] = '\u062B\u064A';
  22717. t['\uFC7C'] = '\u0641\u0649';
  22718. t['\uFC7D'] = '\u0641\u064A';
  22719. t['\uFC7E'] = '\u0642\u0649';
  22720. t['\uFC7F'] = '\u0642\u064A';
  22721. t['\uFC80'] = '\u0643\u0627';
  22722. t['\uFC81'] = '\u0643\u0644';
  22723. t['\uFC82'] = '\u0643\u0645';
  22724. t['\uFC83'] = '\u0643\u0649';
  22725. t['\uFC84'] = '\u0643\u064A';
  22726. t['\uFC85'] = '\u0644\u0645';
  22727. t['\uFC86'] = '\u0644\u0649';
  22728. t['\uFC87'] = '\u0644\u064A';
  22729. t['\uFC88'] = '\u0645\u0627';
  22730. t['\uFC89'] = '\u0645\u0645';
  22731. t['\uFC8A'] = '\u0646\u0631';
  22732. t['\uFC8B'] = '\u0646\u0632';
  22733. t['\uFC8C'] = '\u0646\u0645';
  22734. t['\uFC8D'] = '\u0646\u0646';
  22735. t['\uFC8E'] = '\u0646\u0649';
  22736. t['\uFC8F'] = '\u0646\u064A';
  22737. t['\uFC90'] = '\u0649\u0670';
  22738. t['\uFC91'] = '\u064A\u0631';
  22739. t['\uFC92'] = '\u064A\u0632';
  22740. t['\uFC93'] = '\u064A\u0645';
  22741. t['\uFC94'] = '\u064A\u0646';
  22742. t['\uFC95'] = '\u064A\u0649';
  22743. t['\uFC96'] = '\u064A\u064A';
  22744. t['\uFC97'] = '\u0626\u062C';
  22745. t['\uFC98'] = '\u0626\u062D';
  22746. t['\uFC99'] = '\u0626\u062E';
  22747. t['\uFC9A'] = '\u0626\u0645';
  22748. t['\uFC9B'] = '\u0626\u0647';
  22749. t['\uFC9C'] = '\u0628\u062C';
  22750. t['\uFC9D'] = '\u0628\u062D';
  22751. t['\uFC9E'] = '\u0628\u062E';
  22752. t['\uFC9F'] = '\u0628\u0645';
  22753. t['\uFCA0'] = '\u0628\u0647';
  22754. t['\uFCA1'] = '\u062A\u062C';
  22755. t['\uFCA2'] = '\u062A\u062D';
  22756. t['\uFCA3'] = '\u062A\u062E';
  22757. t['\uFCA4'] = '\u062A\u0645';
  22758. t['\uFCA5'] = '\u062A\u0647';
  22759. t['\uFCA6'] = '\u062B\u0645';
  22760. t['\uFCA7'] = '\u062C\u062D';
  22761. t['\uFCA8'] = '\u062C\u0645';
  22762. t['\uFCA9'] = '\u062D\u062C';
  22763. t['\uFCAA'] = '\u062D\u0645';
  22764. t['\uFCAB'] = '\u062E\u062C';
  22765. t['\uFCAC'] = '\u062E\u0645';
  22766. t['\uFCAD'] = '\u0633\u062C';
  22767. t['\uFCAE'] = '\u0633\u062D';
  22768. t['\uFCAF'] = '\u0633\u062E';
  22769. t['\uFCB0'] = '\u0633\u0645';
  22770. t['\uFCB1'] = '\u0635\u062D';
  22771. t['\uFCB2'] = '\u0635\u062E';
  22772. t['\uFCB3'] = '\u0635\u0645';
  22773. t['\uFCB4'] = '\u0636\u062C';
  22774. t['\uFCB5'] = '\u0636\u062D';
  22775. t['\uFCB6'] = '\u0636\u062E';
  22776. t['\uFCB7'] = '\u0636\u0645';
  22777. t['\uFCB8'] = '\u0637\u062D';
  22778. t['\uFCB9'] = '\u0638\u0645';
  22779. t['\uFCBA'] = '\u0639\u062C';
  22780. t['\uFCBB'] = '\u0639\u0645';
  22781. t['\uFCBC'] = '\u063A\u062C';
  22782. t['\uFCBD'] = '\u063A\u0645';
  22783. t['\uFCBE'] = '\u0641\u062C';
  22784. t['\uFCBF'] = '\u0641\u062D';
  22785. t['\uFCC0'] = '\u0641\u062E';
  22786. t['\uFCC1'] = '\u0641\u0645';
  22787. t['\uFCC2'] = '\u0642\u062D';
  22788. t['\uFCC3'] = '\u0642\u0645';
  22789. t['\uFCC4'] = '\u0643\u062C';
  22790. t['\uFCC5'] = '\u0643\u062D';
  22791. t['\uFCC6'] = '\u0643\u062E';
  22792. t['\uFCC7'] = '\u0643\u0644';
  22793. t['\uFCC8'] = '\u0643\u0645';
  22794. t['\uFCC9'] = '\u0644\u062C';
  22795. t['\uFCCA'] = '\u0644\u062D';
  22796. t['\uFCCB'] = '\u0644\u062E';
  22797. t['\uFCCC'] = '\u0644\u0645';
  22798. t['\uFCCD'] = '\u0644\u0647';
  22799. t['\uFCCE'] = '\u0645\u062C';
  22800. t['\uFCCF'] = '\u0645\u062D';
  22801. t['\uFCD0'] = '\u0645\u062E';
  22802. t['\uFCD1'] = '\u0645\u0645';
  22803. t['\uFCD2'] = '\u0646\u062C';
  22804. t['\uFCD3'] = '\u0646\u062D';
  22805. t['\uFCD4'] = '\u0646\u062E';
  22806. t['\uFCD5'] = '\u0646\u0645';
  22807. t['\uFCD6'] = '\u0646\u0647';
  22808. t['\uFCD7'] = '\u0647\u062C';
  22809. t['\uFCD8'] = '\u0647\u0645';
  22810. t['\uFCD9'] = '\u0647\u0670';
  22811. t['\uFCDA'] = '\u064A\u062C';
  22812. t['\uFCDB'] = '\u064A\u062D';
  22813. t['\uFCDC'] = '\u064A\u062E';
  22814. t['\uFCDD'] = '\u064A\u0645';
  22815. t['\uFCDE'] = '\u064A\u0647';
  22816. t['\uFCDF'] = '\u0626\u0645';
  22817. t['\uFCE0'] = '\u0626\u0647';
  22818. t['\uFCE1'] = '\u0628\u0645';
  22819. t['\uFCE2'] = '\u0628\u0647';
  22820. t['\uFCE3'] = '\u062A\u0645';
  22821. t['\uFCE4'] = '\u062A\u0647';
  22822. t['\uFCE5'] = '\u062B\u0645';
  22823. t['\uFCE6'] = '\u062B\u0647';
  22824. t['\uFCE7'] = '\u0633\u0645';
  22825. t['\uFCE8'] = '\u0633\u0647';
  22826. t['\uFCE9'] = '\u0634\u0645';
  22827. t['\uFCEA'] = '\u0634\u0647';
  22828. t['\uFCEB'] = '\u0643\u0644';
  22829. t['\uFCEC'] = '\u0643\u0645';
  22830. t['\uFCED'] = '\u0644\u0645';
  22831. t['\uFCEE'] = '\u0646\u0645';
  22832. t['\uFCEF'] = '\u0646\u0647';
  22833. t['\uFCF0'] = '\u064A\u0645';
  22834. t['\uFCF1'] = '\u064A\u0647';
  22835. t['\uFCF2'] = '\u0640\u064E\u0651';
  22836. t['\uFCF3'] = '\u0640\u064F\u0651';
  22837. t['\uFCF4'] = '\u0640\u0650\u0651';
  22838. t['\uFCF5'] = '\u0637\u0649';
  22839. t['\uFCF6'] = '\u0637\u064A';
  22840. t['\uFCF7'] = '\u0639\u0649';
  22841. t['\uFCF8'] = '\u0639\u064A';
  22842. t['\uFCF9'] = '\u063A\u0649';
  22843. t['\uFCFA'] = '\u063A\u064A';
  22844. t['\uFCFB'] = '\u0633\u0649';
  22845. t['\uFCFC'] = '\u0633\u064A';
  22846. t['\uFCFD'] = '\u0634\u0649';
  22847. t['\uFCFE'] = '\u0634\u064A';
  22848. t['\uFCFF'] = '\u062D\u0649';
  22849. t['\uFD00'] = '\u062D\u064A';
  22850. t['\uFD01'] = '\u062C\u0649';
  22851. t['\uFD02'] = '\u062C\u064A';
  22852. t['\uFD03'] = '\u062E\u0649';
  22853. t['\uFD04'] = '\u062E\u064A';
  22854. t['\uFD05'] = '\u0635\u0649';
  22855. t['\uFD06'] = '\u0635\u064A';
  22856. t['\uFD07'] = '\u0636\u0649';
  22857. t['\uFD08'] = '\u0636\u064A';
  22858. t['\uFD09'] = '\u0634\u062C';
  22859. t['\uFD0A'] = '\u0634\u062D';
  22860. t['\uFD0B'] = '\u0634\u062E';
  22861. t['\uFD0C'] = '\u0634\u0645';
  22862. t['\uFD0D'] = '\u0634\u0631';
  22863. t['\uFD0E'] = '\u0633\u0631';
  22864. t['\uFD0F'] = '\u0635\u0631';
  22865. t['\uFD10'] = '\u0636\u0631';
  22866. t['\uFD11'] = '\u0637\u0649';
  22867. t['\uFD12'] = '\u0637\u064A';
  22868. t['\uFD13'] = '\u0639\u0649';
  22869. t['\uFD14'] = '\u0639\u064A';
  22870. t['\uFD15'] = '\u063A\u0649';
  22871. t['\uFD16'] = '\u063A\u064A';
  22872. t['\uFD17'] = '\u0633\u0649';
  22873. t['\uFD18'] = '\u0633\u064A';
  22874. t['\uFD19'] = '\u0634\u0649';
  22875. t['\uFD1A'] = '\u0634\u064A';
  22876. t['\uFD1B'] = '\u062D\u0649';
  22877. t['\uFD1C'] = '\u062D\u064A';
  22878. t['\uFD1D'] = '\u062C\u0649';
  22879. t['\uFD1E'] = '\u062C\u064A';
  22880. t['\uFD1F'] = '\u062E\u0649';
  22881. t['\uFD20'] = '\u062E\u064A';
  22882. t['\uFD21'] = '\u0635\u0649';
  22883. t['\uFD22'] = '\u0635\u064A';
  22884. t['\uFD23'] = '\u0636\u0649';
  22885. t['\uFD24'] = '\u0636\u064A';
  22886. t['\uFD25'] = '\u0634\u062C';
  22887. t['\uFD26'] = '\u0634\u062D';
  22888. t['\uFD27'] = '\u0634\u062E';
  22889. t['\uFD28'] = '\u0634\u0645';
  22890. t['\uFD29'] = '\u0634\u0631';
  22891. t['\uFD2A'] = '\u0633\u0631';
  22892. t['\uFD2B'] = '\u0635\u0631';
  22893. t['\uFD2C'] = '\u0636\u0631';
  22894. t['\uFD2D'] = '\u0634\u062C';
  22895. t['\uFD2E'] = '\u0634\u062D';
  22896. t['\uFD2F'] = '\u0634\u062E';
  22897. t['\uFD30'] = '\u0634\u0645';
  22898. t['\uFD31'] = '\u0633\u0647';
  22899. t['\uFD32'] = '\u0634\u0647';
  22900. t['\uFD33'] = '\u0637\u0645';
  22901. t['\uFD34'] = '\u0633\u062C';
  22902. t['\uFD35'] = '\u0633\u062D';
  22903. t['\uFD36'] = '\u0633\u062E';
  22904. t['\uFD37'] = '\u0634\u062C';
  22905. t['\uFD38'] = '\u0634\u062D';
  22906. t['\uFD39'] = '\u0634\u062E';
  22907. t['\uFD3A'] = '\u0637\u0645';
  22908. t['\uFD3B'] = '\u0638\u0645';
  22909. t['\uFD3C'] = '\u0627\u064B';
  22910. t['\uFD3D'] = '\u0627\u064B';
  22911. t['\uFD50'] = '\u062A\u062C\u0645';
  22912. t['\uFD51'] = '\u062A\u062D\u062C';
  22913. t['\uFD52'] = '\u062A\u062D\u062C';
  22914. t['\uFD53'] = '\u062A\u062D\u0645';
  22915. t['\uFD54'] = '\u062A\u062E\u0645';
  22916. t['\uFD55'] = '\u062A\u0645\u062C';
  22917. t['\uFD56'] = '\u062A\u0645\u062D';
  22918. t['\uFD57'] = '\u062A\u0645\u062E';
  22919. t['\uFD58'] = '\u062C\u0645\u062D';
  22920. t['\uFD59'] = '\u062C\u0645\u062D';
  22921. t['\uFD5A'] = '\u062D\u0645\u064A';
  22922. t['\uFD5B'] = '\u062D\u0645\u0649';
  22923. t['\uFD5C'] = '\u0633\u062D\u062C';
  22924. t['\uFD5D'] = '\u0633\u062C\u062D';
  22925. t['\uFD5E'] = '\u0633\u062C\u0649';
  22926. t['\uFD5F'] = '\u0633\u0645\u062D';
  22927. t['\uFD60'] = '\u0633\u0645\u062D';
  22928. t['\uFD61'] = '\u0633\u0645\u062C';
  22929. t['\uFD62'] = '\u0633\u0645\u0645';
  22930. t['\uFD63'] = '\u0633\u0645\u0645';
  22931. t['\uFD64'] = '\u0635\u062D\u062D';
  22932. t['\uFD65'] = '\u0635\u062D\u062D';
  22933. t['\uFD66'] = '\u0635\u0645\u0645';
  22934. t['\uFD67'] = '\u0634\u062D\u0645';
  22935. t['\uFD68'] = '\u0634\u062D\u0645';
  22936. t['\uFD69'] = '\u0634\u062C\u064A';
  22937. t['\uFD6A'] = '\u0634\u0645\u062E';
  22938. t['\uFD6B'] = '\u0634\u0645\u062E';
  22939. t['\uFD6C'] = '\u0634\u0645\u0645';
  22940. t['\uFD6D'] = '\u0634\u0645\u0645';
  22941. t['\uFD6E'] = '\u0636\u062D\u0649';
  22942. t['\uFD6F'] = '\u0636\u062E\u0645';
  22943. t['\uFD70'] = '\u0636\u062E\u0645';
  22944. t['\uFD71'] = '\u0637\u0645\u062D';
  22945. t['\uFD72'] = '\u0637\u0645\u062D';
  22946. t['\uFD73'] = '\u0637\u0645\u0645';
  22947. t['\uFD74'] = '\u0637\u0645\u064A';
  22948. t['\uFD75'] = '\u0639\u062C\u0645';
  22949. t['\uFD76'] = '\u0639\u0645\u0645';
  22950. t['\uFD77'] = '\u0639\u0645\u0645';
  22951. t['\uFD78'] = '\u0639\u0645\u0649';
  22952. t['\uFD79'] = '\u063A\u0645\u0645';
  22953. t['\uFD7A'] = '\u063A\u0645\u064A';
  22954. t['\uFD7B'] = '\u063A\u0645\u0649';
  22955. t['\uFD7C'] = '\u0641\u062E\u0645';
  22956. t['\uFD7D'] = '\u0641\u062E\u0645';
  22957. t['\uFD7E'] = '\u0642\u0645\u062D';
  22958. t['\uFD7F'] = '\u0642\u0645\u0645';
  22959. t['\uFD80'] = '\u0644\u062D\u0645';
  22960. t['\uFD81'] = '\u0644\u062D\u064A';
  22961. t['\uFD82'] = '\u0644\u062D\u0649';
  22962. t['\uFD83'] = '\u0644\u062C\u062C';
  22963. t['\uFD84'] = '\u0644\u062C\u062C';
  22964. t['\uFD85'] = '\u0644\u062E\u0645';
  22965. t['\uFD86'] = '\u0644\u062E\u0645';
  22966. t['\uFD87'] = '\u0644\u0645\u062D';
  22967. t['\uFD88'] = '\u0644\u0645\u062D';
  22968. t['\uFD89'] = '\u0645\u062D\u062C';
  22969. t['\uFD8A'] = '\u0645\u062D\u0645';
  22970. t['\uFD8B'] = '\u0645\u062D\u064A';
  22971. t['\uFD8C'] = '\u0645\u062C\u062D';
  22972. t['\uFD8D'] = '\u0645\u062C\u0645';
  22973. t['\uFD8E'] = '\u0645\u062E\u062C';
  22974. t['\uFD8F'] = '\u0645\u062E\u0645';
  22975. t['\uFD92'] = '\u0645\u062C\u062E';
  22976. t['\uFD93'] = '\u0647\u0645\u062C';
  22977. t['\uFD94'] = '\u0647\u0645\u0645';
  22978. t['\uFD95'] = '\u0646\u062D\u0645';
  22979. t['\uFD96'] = '\u0646\u062D\u0649';
  22980. t['\uFD97'] = '\u0646\u062C\u0645';
  22981. t['\uFD98'] = '\u0646\u062C\u0645';
  22982. t['\uFD99'] = '\u0646\u062C\u0649';
  22983. t['\uFD9A'] = '\u0646\u0645\u064A';
  22984. t['\uFD9B'] = '\u0646\u0645\u0649';
  22985. t['\uFD9C'] = '\u064A\u0645\u0645';
  22986. t['\uFD9D'] = '\u064A\u0645\u0645';
  22987. t['\uFD9E'] = '\u0628\u062E\u064A';
  22988. t['\uFD9F'] = '\u062A\u062C\u064A';
  22989. t['\uFDA0'] = '\u062A\u062C\u0649';
  22990. t['\uFDA1'] = '\u062A\u062E\u064A';
  22991. t['\uFDA2'] = '\u062A\u062E\u0649';
  22992. t['\uFDA3'] = '\u062A\u0645\u064A';
  22993. t['\uFDA4'] = '\u062A\u0645\u0649';
  22994. t['\uFDA5'] = '\u062C\u0645\u064A';
  22995. t['\uFDA6'] = '\u062C\u062D\u0649';
  22996. t['\uFDA7'] = '\u062C\u0645\u0649';
  22997. t['\uFDA8'] = '\u0633\u062E\u0649';
  22998. t['\uFDA9'] = '\u0635\u062D\u064A';
  22999. t['\uFDAA'] = '\u0634\u062D\u064A';
  23000. t['\uFDAB'] = '\u0636\u062D\u064A';
  23001. t['\uFDAC'] = '\u0644\u062C\u064A';
  23002. t['\uFDAD'] = '\u0644\u0645\u064A';
  23003. t['\uFDAE'] = '\u064A\u062D\u064A';
  23004. t['\uFDAF'] = '\u064A\u062C\u064A';
  23005. t['\uFDB0'] = '\u064A\u0645\u064A';
  23006. t['\uFDB1'] = '\u0645\u0645\u064A';
  23007. t['\uFDB2'] = '\u0642\u0645\u064A';
  23008. t['\uFDB3'] = '\u0646\u062D\u064A';
  23009. t['\uFDB4'] = '\u0642\u0645\u062D';
  23010. t['\uFDB5'] = '\u0644\u062D\u0645';
  23011. t['\uFDB6'] = '\u0639\u0645\u064A';
  23012. t['\uFDB7'] = '\u0643\u0645\u064A';
  23013. t['\uFDB8'] = '\u0646\u062C\u062D';
  23014. t['\uFDB9'] = '\u0645\u062E\u064A';
  23015. t['\uFDBA'] = '\u0644\u062C\u0645';
  23016. t['\uFDBB'] = '\u0643\u0645\u0645';
  23017. t['\uFDBC'] = '\u0644\u062C\u0645';
  23018. t['\uFDBD'] = '\u0646\u062C\u062D';
  23019. t['\uFDBE'] = '\u062C\u062D\u064A';
  23020. t['\uFDBF'] = '\u062D\u062C\u064A';
  23021. t['\uFDC0'] = '\u0645\u062C\u064A';
  23022. t['\uFDC1'] = '\u0641\u0645\u064A';
  23023. t['\uFDC2'] = '\u0628\u062D\u064A';
  23024. t['\uFDC3'] = '\u0643\u0645\u0645';
  23025. t['\uFDC4'] = '\u0639\u062C\u0645';
  23026. t['\uFDC5'] = '\u0635\u0645\u0645';
  23027. t['\uFDC6'] = '\u0633\u062E\u064A';
  23028. t['\uFDC7'] = '\u0646\u062C\u064A';
  23029. t['\uFE49'] = '\u203E';
  23030. t['\uFE4A'] = '\u203E';
  23031. t['\uFE4B'] = '\u203E';
  23032. t['\uFE4C'] = '\u203E';
  23033. t['\uFE4D'] = '\u005F';
  23034. t['\uFE4E'] = '\u005F';
  23035. t['\uFE4F'] = '\u005F';
  23036. t['\uFE80'] = '\u0621';
  23037. t['\uFE81'] = '\u0622';
  23038. t['\uFE82'] = '\u0622';
  23039. t['\uFE83'] = '\u0623';
  23040. t['\uFE84'] = '\u0623';
  23041. t['\uFE85'] = '\u0624';
  23042. t['\uFE86'] = '\u0624';
  23043. t['\uFE87'] = '\u0625';
  23044. t['\uFE88'] = '\u0625';
  23045. t['\uFE89'] = '\u0626';
  23046. t['\uFE8A'] = '\u0626';
  23047. t['\uFE8B'] = '\u0626';
  23048. t['\uFE8C'] = '\u0626';
  23049. t['\uFE8D'] = '\u0627';
  23050. t['\uFE8E'] = '\u0627';
  23051. t['\uFE8F'] = '\u0628';
  23052. t['\uFE90'] = '\u0628';
  23053. t['\uFE91'] = '\u0628';
  23054. t['\uFE92'] = '\u0628';
  23055. t['\uFE93'] = '\u0629';
  23056. t['\uFE94'] = '\u0629';
  23057. t['\uFE95'] = '\u062A';
  23058. t['\uFE96'] = '\u062A';
  23059. t['\uFE97'] = '\u062A';
  23060. t['\uFE98'] = '\u062A';
  23061. t['\uFE99'] = '\u062B';
  23062. t['\uFE9A'] = '\u062B';
  23063. t['\uFE9B'] = '\u062B';
  23064. t['\uFE9C'] = '\u062B';
  23065. t['\uFE9D'] = '\u062C';
  23066. t['\uFE9E'] = '\u062C';
  23067. t['\uFE9F'] = '\u062C';
  23068. t['\uFEA0'] = '\u062C';
  23069. t['\uFEA1'] = '\u062D';
  23070. t['\uFEA2'] = '\u062D';
  23071. t['\uFEA3'] = '\u062D';
  23072. t['\uFEA4'] = '\u062D';
  23073. t['\uFEA5'] = '\u062E';
  23074. t['\uFEA6'] = '\u062E';
  23075. t['\uFEA7'] = '\u062E';
  23076. t['\uFEA8'] = '\u062E';
  23077. t['\uFEA9'] = '\u062F';
  23078. t['\uFEAA'] = '\u062F';
  23079. t['\uFEAB'] = '\u0630';
  23080. t['\uFEAC'] = '\u0630';
  23081. t['\uFEAD'] = '\u0631';
  23082. t['\uFEAE'] = '\u0631';
  23083. t['\uFEAF'] = '\u0632';
  23084. t['\uFEB0'] = '\u0632';
  23085. t['\uFEB1'] = '\u0633';
  23086. t['\uFEB2'] = '\u0633';
  23087. t['\uFEB3'] = '\u0633';
  23088. t['\uFEB4'] = '\u0633';
  23089. t['\uFEB5'] = '\u0634';
  23090. t['\uFEB6'] = '\u0634';
  23091. t['\uFEB7'] = '\u0634';
  23092. t['\uFEB8'] = '\u0634';
  23093. t['\uFEB9'] = '\u0635';
  23094. t['\uFEBA'] = '\u0635';
  23095. t['\uFEBB'] = '\u0635';
  23096. t['\uFEBC'] = '\u0635';
  23097. t['\uFEBD'] = '\u0636';
  23098. t['\uFEBE'] = '\u0636';
  23099. t['\uFEBF'] = '\u0636';
  23100. t['\uFEC0'] = '\u0636';
  23101. t['\uFEC1'] = '\u0637';
  23102. t['\uFEC2'] = '\u0637';
  23103. t['\uFEC3'] = '\u0637';
  23104. t['\uFEC4'] = '\u0637';
  23105. t['\uFEC5'] = '\u0638';
  23106. t['\uFEC6'] = '\u0638';
  23107. t['\uFEC7'] = '\u0638';
  23108. t['\uFEC8'] = '\u0638';
  23109. t['\uFEC9'] = '\u0639';
  23110. t['\uFECA'] = '\u0639';
  23111. t['\uFECB'] = '\u0639';
  23112. t['\uFECC'] = '\u0639';
  23113. t['\uFECD'] = '\u063A';
  23114. t['\uFECE'] = '\u063A';
  23115. t['\uFECF'] = '\u063A';
  23116. t['\uFED0'] = '\u063A';
  23117. t['\uFED1'] = '\u0641';
  23118. t['\uFED2'] = '\u0641';
  23119. t['\uFED3'] = '\u0641';
  23120. t['\uFED4'] = '\u0641';
  23121. t['\uFED5'] = '\u0642';
  23122. t['\uFED6'] = '\u0642';
  23123. t['\uFED7'] = '\u0642';
  23124. t['\uFED8'] = '\u0642';
  23125. t['\uFED9'] = '\u0643';
  23126. t['\uFEDA'] = '\u0643';
  23127. t['\uFEDB'] = '\u0643';
  23128. t['\uFEDC'] = '\u0643';
  23129. t['\uFEDD'] = '\u0644';
  23130. t['\uFEDE'] = '\u0644';
  23131. t['\uFEDF'] = '\u0644';
  23132. t['\uFEE0'] = '\u0644';
  23133. t['\uFEE1'] = '\u0645';
  23134. t['\uFEE2'] = '\u0645';
  23135. t['\uFEE3'] = '\u0645';
  23136. t['\uFEE4'] = '\u0645';
  23137. t['\uFEE5'] = '\u0646';
  23138. t['\uFEE6'] = '\u0646';
  23139. t['\uFEE7'] = '\u0646';
  23140. t['\uFEE8'] = '\u0646';
  23141. t['\uFEE9'] = '\u0647';
  23142. t['\uFEEA'] = '\u0647';
  23143. t['\uFEEB'] = '\u0647';
  23144. t['\uFEEC'] = '\u0647';
  23145. t['\uFEED'] = '\u0648';
  23146. t['\uFEEE'] = '\u0648';
  23147. t['\uFEEF'] = '\u0649';
  23148. t['\uFEF0'] = '\u0649';
  23149. t['\uFEF1'] = '\u064A';
  23150. t['\uFEF2'] = '\u064A';
  23151. t['\uFEF3'] = '\u064A';
  23152. t['\uFEF4'] = '\u064A';
  23153. t['\uFEF5'] = '\u0644\u0622';
  23154. t['\uFEF6'] = '\u0644\u0622';
  23155. t['\uFEF7'] = '\u0644\u0623';
  23156. t['\uFEF8'] = '\u0644\u0623';
  23157. t['\uFEF9'] = '\u0644\u0625';
  23158. t['\uFEFA'] = '\u0644\u0625';
  23159. t['\uFEFB'] = '\u0644\u0627';
  23160. t['\uFEFC'] = '\u0644\u0627';
  23161. });
  23162. function reverseIfRtl(chars) {
  23163. var charsLength = chars.length;
  23164. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23165. return chars;
  23166. }
  23167. var s = '';
  23168. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23169. s += chars[ii];
  23170. }
  23171. return s;
  23172. }
  23173. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23174. exports.reverseIfRtl = reverseIfRtl;
  23175. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23176. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23177. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23178. }));
  23179. (function (root, factory) {
  23180. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23181. }(this, function (exports, sharedUtil) {
  23182. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23183. var warn = sharedUtil.warn;
  23184. var deprecated = sharedUtil.deprecated;
  23185. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23186. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  23187. var CustomStyle = function CustomStyleClosure() {
  23188. var prefixes = [
  23189. 'ms',
  23190. 'Moz',
  23191. 'Webkit',
  23192. 'O'
  23193. ];
  23194. var _cache = Object.create(null);
  23195. function CustomStyle() {
  23196. }
  23197. CustomStyle.getProp = function get(propName, element) {
  23198. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23199. return _cache[propName];
  23200. }
  23201. element = element || document.documentElement;
  23202. var style = element.style, prefixed, uPropName;
  23203. if (typeof style[propName] === 'string') {
  23204. return _cache[propName] = propName;
  23205. }
  23206. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23207. for (var i = 0, l = prefixes.length; i < l; i++) {
  23208. prefixed = prefixes[i] + uPropName;
  23209. if (typeof style[prefixed] === 'string') {
  23210. return _cache[propName] = prefixed;
  23211. }
  23212. }
  23213. return _cache[propName] = 'undefined';
  23214. };
  23215. CustomStyle.setProp = function set(propName, element, str) {
  23216. var prop = this.getProp(propName);
  23217. if (prop !== 'undefined') {
  23218. element.style[prop] = str;
  23219. }
  23220. };
  23221. return CustomStyle;
  23222. }();
  23223. var hasCanvasTypedArrays;
  23224. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23225. var canvas = document.createElement('canvas');
  23226. canvas.width = canvas.height = 1;
  23227. var ctx = canvas.getContext('2d');
  23228. var imageData = ctx.createImageData(1, 1);
  23229. return typeof imageData.data.buffer !== 'undefined';
  23230. };
  23231. var LinkTarget = {
  23232. NONE: 0,
  23233. SELF: 1,
  23234. BLANK: 2,
  23235. PARENT: 3,
  23236. TOP: 4
  23237. };
  23238. var LinkTargetStringMap = [
  23239. '',
  23240. '_self',
  23241. '_blank',
  23242. '_parent',
  23243. '_top'
  23244. ];
  23245. function addLinkAttributes(link, params) {
  23246. var url = params && params.url;
  23247. link.href = link.title = url ? removeNullCharacters(url) : '';
  23248. if (url) {
  23249. var target = params.target;
  23250. if (typeof target === 'undefined') {
  23251. target = getDefaultSetting('externalLinkTarget');
  23252. }
  23253. link.target = LinkTargetStringMap[target];
  23254. var rel = params.rel;
  23255. if (typeof rel === 'undefined') {
  23256. rel = getDefaultSetting('externalLinkRel');
  23257. }
  23258. link.rel = rel;
  23259. }
  23260. }
  23261. function getFilenameFromUrl(url) {
  23262. var anchor = url.indexOf('#');
  23263. var query = url.indexOf('?');
  23264. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23265. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23266. }
  23267. function getDefaultSetting(id) {
  23268. var globalSettings = sharedUtil.globalScope.PDFJS;
  23269. switch (id) {
  23270. case 'pdfBug':
  23271. return globalSettings ? globalSettings.pdfBug : false;
  23272. case 'disableAutoFetch':
  23273. return globalSettings ? globalSettings.disableAutoFetch : false;
  23274. case 'disableStream':
  23275. return globalSettings ? globalSettings.disableStream : false;
  23276. case 'disableRange':
  23277. return globalSettings ? globalSettings.disableRange : false;
  23278. case 'disableFontFace':
  23279. return globalSettings ? globalSettings.disableFontFace : false;
  23280. case 'disableCreateObjectURL':
  23281. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23282. case 'disableWebGL':
  23283. return globalSettings ? globalSettings.disableWebGL : true;
  23284. case 'cMapUrl':
  23285. return globalSettings ? globalSettings.cMapUrl : null;
  23286. case 'cMapPacked':
  23287. return globalSettings ? globalSettings.cMapPacked : false;
  23288. case 'postMessageTransfers':
  23289. return globalSettings ? globalSettings.postMessageTransfers : true;
  23290. case 'workerSrc':
  23291. return globalSettings ? globalSettings.workerSrc : null;
  23292. case 'disableWorker':
  23293. return globalSettings ? globalSettings.disableWorker : false;
  23294. case 'maxImageSize':
  23295. return globalSettings ? globalSettings.maxImageSize : -1;
  23296. case 'imageResourcesPath':
  23297. return globalSettings ? globalSettings.imageResourcesPath : '';
  23298. case 'isEvalSupported':
  23299. return globalSettings ? globalSettings.isEvalSupported : true;
  23300. case 'externalLinkTarget':
  23301. if (!globalSettings) {
  23302. return LinkTarget.NONE;
  23303. }
  23304. switch (globalSettings.externalLinkTarget) {
  23305. case LinkTarget.NONE:
  23306. case LinkTarget.SELF:
  23307. case LinkTarget.BLANK:
  23308. case LinkTarget.PARENT:
  23309. case LinkTarget.TOP:
  23310. return globalSettings.externalLinkTarget;
  23311. }
  23312. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23313. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23314. return LinkTarget.NONE;
  23315. case 'externalLinkRel':
  23316. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  23317. case 'enableStats':
  23318. return !!(globalSettings && globalSettings.enableStats);
  23319. default:
  23320. throw new Error('Unknown default setting: ' + id);
  23321. }
  23322. }
  23323. function isExternalLinkTargetSet() {
  23324. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23325. switch (externalLinkTarget) {
  23326. case LinkTarget.NONE:
  23327. return false;
  23328. case LinkTarget.SELF:
  23329. case LinkTarget.BLANK:
  23330. case LinkTarget.PARENT:
  23331. case LinkTarget.TOP:
  23332. return true;
  23333. }
  23334. }
  23335. function isValidUrl(url, allowRelative) {
  23336. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23337. var baseUrl = allowRelative ? 'http://example.com' : null;
  23338. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23339. }
  23340. exports.CustomStyle = CustomStyle;
  23341. exports.addLinkAttributes = addLinkAttributes;
  23342. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23343. exports.isValidUrl = isValidUrl;
  23344. exports.getFilenameFromUrl = getFilenameFromUrl;
  23345. exports.LinkTarget = LinkTarget;
  23346. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23347. exports.getDefaultSetting = getDefaultSetting;
  23348. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  23349. }));
  23350. (function (root, factory) {
  23351. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23352. }(this, function (exports, sharedUtil) {
  23353. var assert = sharedUtil.assert;
  23354. var bytesToString = sharedUtil.bytesToString;
  23355. var string32 = sharedUtil.string32;
  23356. var shadow = sharedUtil.shadow;
  23357. var warn = sharedUtil.warn;
  23358. function FontLoader(docId) {
  23359. this.docId = docId;
  23360. this.styleElement = null;
  23361. this.nativeFontFaces = [];
  23362. this.loadTestFontId = 0;
  23363. this.loadingContext = {
  23364. requests: [],
  23365. nextRequestId: 0
  23366. };
  23367. }
  23368. FontLoader.prototype = {
  23369. insertRule: function fontLoaderInsertRule(rule) {
  23370. var styleElement = this.styleElement;
  23371. if (!styleElement) {
  23372. styleElement = this.styleElement = document.createElement('style');
  23373. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23374. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23375. }
  23376. var styleSheet = styleElement.sheet;
  23377. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23378. },
  23379. clear: function fontLoaderClear() {
  23380. var styleElement = this.styleElement;
  23381. if (styleElement) {
  23382. styleElement.parentNode.removeChild(styleElement);
  23383. styleElement = this.styleElement = null;
  23384. }
  23385. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23386. document.fonts.delete(nativeFontFace);
  23387. });
  23388. this.nativeFontFaces.length = 0;
  23389. }
  23390. };
  23391. var getLoadTestFont = function () {
  23392. 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==');
  23393. };
  23394. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23395. get: function () {
  23396. return shadow(this, 'loadTestFont', getLoadTestFont());
  23397. },
  23398. configurable: true
  23399. });
  23400. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23401. this.nativeFontFaces.push(nativeFontFace);
  23402. document.fonts.add(nativeFontFace);
  23403. };
  23404. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23405. var rules = [];
  23406. var fontsToLoad = [];
  23407. var fontLoadPromises = [];
  23408. var getNativeFontPromise = function (nativeFontFace) {
  23409. return nativeFontFace.loaded.catch(function (e) {
  23410. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23411. });
  23412. };
  23413. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23414. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23415. var font = fonts[i];
  23416. if (font.attached || font.loading === false) {
  23417. continue;
  23418. }
  23419. font.attached = true;
  23420. if (isFontLoadingAPISupported) {
  23421. var nativeFontFace = font.createNativeFontFace();
  23422. if (nativeFontFace) {
  23423. this.addNativeFontFace(nativeFontFace);
  23424. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23425. }
  23426. } else {
  23427. var rule = font.createFontFaceRule();
  23428. if (rule) {
  23429. this.insertRule(rule);
  23430. rules.push(rule);
  23431. fontsToLoad.push(font);
  23432. }
  23433. }
  23434. }
  23435. var request = this.queueLoadingCallback(callback);
  23436. if (isFontLoadingAPISupported) {
  23437. Promise.all(fontLoadPromises).then(function () {
  23438. request.complete();
  23439. });
  23440. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23441. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23442. } else {
  23443. request.complete();
  23444. }
  23445. };
  23446. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23447. function LoadLoader_completeRequest() {
  23448. assert(!request.end, 'completeRequest() cannot be called twice');
  23449. request.end = Date.now();
  23450. while (context.requests.length > 0 && context.requests[0].end) {
  23451. var otherRequest = context.requests.shift();
  23452. setTimeout(otherRequest.callback, 0);
  23453. }
  23454. }
  23455. var context = this.loadingContext;
  23456. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23457. var request = {
  23458. id: requestId,
  23459. complete: LoadLoader_completeRequest,
  23460. callback: callback,
  23461. started: Date.now()
  23462. };
  23463. context.requests.push(request);
  23464. return request;
  23465. };
  23466. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23467. function int32(data, offset) {
  23468. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23469. }
  23470. function spliceString(s, offset, remove, insert) {
  23471. var chunk1 = s.substr(0, offset);
  23472. var chunk2 = s.substr(offset + remove);
  23473. return chunk1 + insert + chunk2;
  23474. }
  23475. var i, ii;
  23476. var canvas = document.createElement('canvas');
  23477. canvas.width = 1;
  23478. canvas.height = 1;
  23479. var ctx = canvas.getContext('2d');
  23480. var called = 0;
  23481. function isFontReady(name, callback) {
  23482. called++;
  23483. if (called > 30) {
  23484. warn('Load test font never loaded.');
  23485. callback();
  23486. return;
  23487. }
  23488. ctx.font = '30px ' + name;
  23489. ctx.fillText('.', 0, 20);
  23490. var imageData = ctx.getImageData(0, 0, 1, 1);
  23491. if (imageData.data[3] > 0) {
  23492. callback();
  23493. return;
  23494. }
  23495. setTimeout(isFontReady.bind(null, name, callback));
  23496. }
  23497. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23498. var data = this.loadTestFont;
  23499. var COMMENT_OFFSET = 976;
  23500. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23501. var CFF_CHECKSUM_OFFSET = 16;
  23502. var XXXX_VALUE = 0x58585858;
  23503. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23504. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23505. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23506. }
  23507. if (i < loadTestFontId.length) {
  23508. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23509. }
  23510. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23511. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23512. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23513. this.insertRule(rule);
  23514. var names = [];
  23515. for (i = 0, ii = fonts.length; i < ii; i++) {
  23516. names.push(fonts[i].loadedName);
  23517. }
  23518. names.push(loadTestFontId);
  23519. var div = document.createElement('div');
  23520. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23521. for (i = 0, ii = names.length; i < ii; ++i) {
  23522. var span = document.createElement('span');
  23523. span.textContent = 'Hi';
  23524. span.style.fontFamily = names[i];
  23525. div.appendChild(span);
  23526. }
  23527. document.body.appendChild(div);
  23528. isFontReady(loadTestFontId, function () {
  23529. document.body.removeChild(div);
  23530. request.complete();
  23531. });
  23532. };
  23533. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23534. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23535. if (typeof navigator === 'undefined') {
  23536. return true;
  23537. }
  23538. var supported = false;
  23539. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23540. if (m && m[1] >= 14) {
  23541. supported = true;
  23542. }
  23543. return supported;
  23544. };
  23545. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23546. get: function () {
  23547. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23548. },
  23549. enumerable: true,
  23550. configurable: true
  23551. });
  23552. var IsEvalSupportedCached = {
  23553. get value() {
  23554. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23555. }
  23556. };
  23557. var FontFaceObject = function FontFaceObjectClosure() {
  23558. function FontFaceObject(translatedData, options) {
  23559. this.compiledGlyphs = Object.create(null);
  23560. for (var i in translatedData) {
  23561. this[i] = translatedData[i];
  23562. }
  23563. this.options = options;
  23564. }
  23565. FontFaceObject.prototype = {
  23566. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23567. if (!this.data) {
  23568. return null;
  23569. }
  23570. if (this.options.disableFontFace) {
  23571. this.disableFontFace = true;
  23572. return null;
  23573. }
  23574. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23575. if (this.options.fontRegistry) {
  23576. this.options.fontRegistry.registerFont(this);
  23577. }
  23578. return nativeFontFace;
  23579. },
  23580. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23581. if (!this.data) {
  23582. return null;
  23583. }
  23584. if (this.options.disableFontFace) {
  23585. this.disableFontFace = true;
  23586. return null;
  23587. }
  23588. var data = bytesToString(new Uint8Array(this.data));
  23589. var fontName = this.loadedName;
  23590. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23591. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23592. if (this.options.fontRegistry) {
  23593. this.options.fontRegistry.registerFont(this, url);
  23594. }
  23595. return rule;
  23596. },
  23597. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23598. if (!(character in this.compiledGlyphs)) {
  23599. var cmds = objs.get(this.loadedName + '_path_' + character);
  23600. var current, i, len;
  23601. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23602. var args, js = '';
  23603. for (i = 0, len = cmds.length; i < len; i++) {
  23604. current = cmds[i];
  23605. if (current.args !== undefined) {
  23606. args = current.args.join(',');
  23607. } else {
  23608. args = '';
  23609. }
  23610. js += 'c.' + current.cmd + '(' + args + ');\n';
  23611. }
  23612. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23613. } else {
  23614. this.compiledGlyphs[character] = function (c, size) {
  23615. for (i = 0, len = cmds.length; i < len; i++) {
  23616. current = cmds[i];
  23617. if (current.cmd === 'scale') {
  23618. current.args = [
  23619. size,
  23620. -size
  23621. ];
  23622. }
  23623. c[current.cmd].apply(c, current.args);
  23624. }
  23625. };
  23626. }
  23627. }
  23628. return this.compiledGlyphs[character];
  23629. }
  23630. };
  23631. return FontFaceObject;
  23632. }();
  23633. exports.FontFaceObject = FontFaceObject;
  23634. exports.FontLoader = FontLoader;
  23635. }));
  23636. (function (root, factory) {
  23637. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23638. }(this, function (exports, sharedUtil) {
  23639. var error = sharedUtil.error;
  23640. function fixMetadata(meta) {
  23641. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23642. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23643. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23644. });
  23645. var chars = '';
  23646. for (var i = 0; i < bytes.length; i += 2) {
  23647. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23648. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23649. }
  23650. return '>' + chars;
  23651. });
  23652. }
  23653. function Metadata(meta) {
  23654. if (typeof meta === 'string') {
  23655. meta = fixMetadata(meta);
  23656. var parser = new DOMParser();
  23657. meta = parser.parseFromString(meta, 'application/xml');
  23658. } else if (!(meta instanceof Document)) {
  23659. error('Metadata: Invalid metadata object');
  23660. }
  23661. this.metaDocument = meta;
  23662. this.metadata = Object.create(null);
  23663. this.parse();
  23664. }
  23665. Metadata.prototype = {
  23666. parse: function Metadata_parse() {
  23667. var doc = this.metaDocument;
  23668. var rdf = doc.documentElement;
  23669. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23670. rdf = rdf.firstChild;
  23671. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23672. rdf = rdf.nextSibling;
  23673. }
  23674. }
  23675. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23676. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23677. return;
  23678. }
  23679. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23680. for (i = 0, length = children.length; i < length; i++) {
  23681. desc = children[i];
  23682. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23683. continue;
  23684. }
  23685. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23686. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23687. entry = desc.childNodes[ii];
  23688. name = entry.nodeName.toLowerCase();
  23689. this.metadata[name] = entry.textContent.trim();
  23690. }
  23691. }
  23692. }
  23693. },
  23694. get: function Metadata_get(name) {
  23695. return this.metadata[name] || null;
  23696. },
  23697. has: function Metadata_has(name) {
  23698. return typeof this.metadata[name] !== 'undefined';
  23699. }
  23700. };
  23701. exports.Metadata = Metadata;
  23702. }));
  23703. (function (root, factory) {
  23704. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23705. }(this, function (exports, sharedUtil) {
  23706. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23707. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23708. var ImageKind = sharedUtil.ImageKind;
  23709. var OPS = sharedUtil.OPS;
  23710. var Util = sharedUtil.Util;
  23711. var isNum = sharedUtil.isNum;
  23712. var isArray = sharedUtil.isArray;
  23713. var warn = sharedUtil.warn;
  23714. var createObjectURL = sharedUtil.createObjectURL;
  23715. var SVG_DEFAULTS = {
  23716. fontStyle: 'normal',
  23717. fontWeight: 'normal',
  23718. fillColor: '#000000'
  23719. };
  23720. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23721. var PNG_HEADER = new Uint8Array([
  23722. 0x89,
  23723. 0x50,
  23724. 0x4e,
  23725. 0x47,
  23726. 0x0d,
  23727. 0x0a,
  23728. 0x1a,
  23729. 0x0a
  23730. ]);
  23731. var CHUNK_WRAPPER_SIZE = 12;
  23732. var crcTable = new Int32Array(256);
  23733. for (var i = 0; i < 256; i++) {
  23734. var c = i;
  23735. for (var h = 0; h < 8; h++) {
  23736. if (c & 1) {
  23737. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23738. } else {
  23739. c = c >> 1 & 0x7fffffff;
  23740. }
  23741. }
  23742. crcTable[i] = c;
  23743. }
  23744. function crc32(data, start, end) {
  23745. var crc = -1;
  23746. for (var i = start; i < end; i++) {
  23747. var a = (crc ^ data[i]) & 0xff;
  23748. var b = crcTable[a];
  23749. crc = crc >>> 8 ^ b;
  23750. }
  23751. return crc ^ -1;
  23752. }
  23753. function writePngChunk(type, body, data, offset) {
  23754. var p = offset;
  23755. var len = body.length;
  23756. data[p] = len >> 24 & 0xff;
  23757. data[p + 1] = len >> 16 & 0xff;
  23758. data[p + 2] = len >> 8 & 0xff;
  23759. data[p + 3] = len & 0xff;
  23760. p += 4;
  23761. data[p] = type.charCodeAt(0) & 0xff;
  23762. data[p + 1] = type.charCodeAt(1) & 0xff;
  23763. data[p + 2] = type.charCodeAt(2) & 0xff;
  23764. data[p + 3] = type.charCodeAt(3) & 0xff;
  23765. p += 4;
  23766. data.set(body, p);
  23767. p += body.length;
  23768. var crc = crc32(data, offset + 4, p);
  23769. data[p] = crc >> 24 & 0xff;
  23770. data[p + 1] = crc >> 16 & 0xff;
  23771. data[p + 2] = crc >> 8 & 0xff;
  23772. data[p + 3] = crc & 0xff;
  23773. }
  23774. function adler32(data, start, end) {
  23775. var a = 1;
  23776. var b = 0;
  23777. for (var i = start; i < end; ++i) {
  23778. a = (a + (data[i] & 0xff)) % 65521;
  23779. b = (b + a) % 65521;
  23780. }
  23781. return b << 16 | a;
  23782. }
  23783. function encode(imgData, kind, forceDataSchema) {
  23784. var width = imgData.width;
  23785. var height = imgData.height;
  23786. var bitDepth, colorType, lineSize;
  23787. var bytes = imgData.data;
  23788. switch (kind) {
  23789. case ImageKind.GRAYSCALE_1BPP:
  23790. colorType = 0;
  23791. bitDepth = 1;
  23792. lineSize = width + 7 >> 3;
  23793. break;
  23794. case ImageKind.RGB_24BPP:
  23795. colorType = 2;
  23796. bitDepth = 8;
  23797. lineSize = width * 3;
  23798. break;
  23799. case ImageKind.RGBA_32BPP:
  23800. colorType = 6;
  23801. bitDepth = 8;
  23802. lineSize = width * 4;
  23803. break;
  23804. default:
  23805. throw new Error('invalid format');
  23806. }
  23807. var literals = new Uint8Array((1 + lineSize) * height);
  23808. var offsetLiterals = 0, offsetBytes = 0;
  23809. var y, i;
  23810. for (y = 0; y < height; ++y) {
  23811. literals[offsetLiterals++] = 0;
  23812. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23813. offsetBytes += lineSize;
  23814. offsetLiterals += lineSize;
  23815. }
  23816. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23817. offsetLiterals = 0;
  23818. for (y = 0; y < height; y++) {
  23819. offsetLiterals++;
  23820. for (i = 0; i < lineSize; i++) {
  23821. literals[offsetLiterals++] ^= 0xFF;
  23822. }
  23823. }
  23824. }
  23825. var ihdr = new Uint8Array([
  23826. width >> 24 & 0xff,
  23827. width >> 16 & 0xff,
  23828. width >> 8 & 0xff,
  23829. width & 0xff,
  23830. height >> 24 & 0xff,
  23831. height >> 16 & 0xff,
  23832. height >> 8 & 0xff,
  23833. height & 0xff,
  23834. bitDepth,
  23835. colorType,
  23836. 0x00,
  23837. 0x00,
  23838. 0x00
  23839. ]);
  23840. var len = literals.length;
  23841. var maxBlockLength = 0xFFFF;
  23842. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23843. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23844. var pi = 0;
  23845. idat[pi++] = 0x78;
  23846. idat[pi++] = 0x9c;
  23847. var pos = 0;
  23848. while (len > maxBlockLength) {
  23849. idat[pi++] = 0x00;
  23850. idat[pi++] = 0xff;
  23851. idat[pi++] = 0xff;
  23852. idat[pi++] = 0x00;
  23853. idat[pi++] = 0x00;
  23854. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23855. pi += maxBlockLength;
  23856. pos += maxBlockLength;
  23857. len -= maxBlockLength;
  23858. }
  23859. idat[pi++] = 0x01;
  23860. idat[pi++] = len & 0xff;
  23861. idat[pi++] = len >> 8 & 0xff;
  23862. idat[pi++] = ~len & 0xffff & 0xff;
  23863. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23864. idat.set(literals.subarray(pos), pi);
  23865. pi += literals.length - pos;
  23866. var adler = adler32(literals, 0, literals.length);
  23867. idat[pi++] = adler >> 24 & 0xff;
  23868. idat[pi++] = adler >> 16 & 0xff;
  23869. idat[pi++] = adler >> 8 & 0xff;
  23870. idat[pi++] = adler & 0xff;
  23871. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23872. var data = new Uint8Array(pngLength);
  23873. var offset = 0;
  23874. data.set(PNG_HEADER, offset);
  23875. offset += PNG_HEADER.length;
  23876. writePngChunk('IHDR', ihdr, data, offset);
  23877. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23878. writePngChunk('IDATA', idat, data, offset);
  23879. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23880. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23881. return createObjectURL(data, 'image/png', forceDataSchema);
  23882. }
  23883. return function convertImgDataToPng(imgData, forceDataSchema) {
  23884. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23885. return encode(imgData, kind, forceDataSchema);
  23886. };
  23887. }();
  23888. var SVGExtraState = function SVGExtraStateClosure() {
  23889. function SVGExtraState() {
  23890. this.fontSizeScale = 1;
  23891. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23892. this.fontSize = 0;
  23893. this.textMatrix = IDENTITY_MATRIX;
  23894. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23895. this.leading = 0;
  23896. this.x = 0;
  23897. this.y = 0;
  23898. this.lineX = 0;
  23899. this.lineY = 0;
  23900. this.charSpacing = 0;
  23901. this.wordSpacing = 0;
  23902. this.textHScale = 1;
  23903. this.textRise = 0;
  23904. this.fillColor = SVG_DEFAULTS.fillColor;
  23905. this.strokeColor = '#000000';
  23906. this.fillAlpha = 1;
  23907. this.strokeAlpha = 1;
  23908. this.lineWidth = 1;
  23909. this.lineJoin = '';
  23910. this.lineCap = '';
  23911. this.miterLimit = 0;
  23912. this.dashArray = [];
  23913. this.dashPhase = 0;
  23914. this.dependencies = [];
  23915. this.activeClipUrl = null;
  23916. this.clipGroup = null;
  23917. this.maskId = '';
  23918. }
  23919. SVGExtraState.prototype = {
  23920. clone: function SVGExtraState_clone() {
  23921. return Object.create(this);
  23922. },
  23923. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23924. this.x = x;
  23925. this.y = y;
  23926. }
  23927. };
  23928. return SVGExtraState;
  23929. }();
  23930. var SVGGraphics = function SVGGraphicsClosure() {
  23931. function opListToTree(opList) {
  23932. var opTree = [];
  23933. var tmp = [];
  23934. var opListLen = opList.length;
  23935. for (var x = 0; x < opListLen; x++) {
  23936. if (opList[x].fn === 'save') {
  23937. opTree.push({
  23938. 'fnId': 92,
  23939. 'fn': 'group',
  23940. 'items': []
  23941. });
  23942. tmp.push(opTree);
  23943. opTree = opTree[opTree.length - 1].items;
  23944. continue;
  23945. }
  23946. if (opList[x].fn === 'restore') {
  23947. opTree = tmp.pop();
  23948. } else {
  23949. opTree.push(opList[x]);
  23950. }
  23951. }
  23952. return opTree;
  23953. }
  23954. function pf(value) {
  23955. if (value === (value | 0)) {
  23956. return value.toString();
  23957. }
  23958. var s = value.toFixed(10);
  23959. var i = s.length - 1;
  23960. if (s[i] !== '0') {
  23961. return s;
  23962. }
  23963. do {
  23964. i--;
  23965. } while (s[i] === '0');
  23966. return s.substr(0, s[i] === '.' ? i : i + 1);
  23967. }
  23968. function pm(m) {
  23969. if (m[4] === 0 && m[5] === 0) {
  23970. if (m[1] === 0 && m[2] === 0) {
  23971. if (m[0] === 1 && m[3] === 1) {
  23972. return '';
  23973. }
  23974. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  23975. }
  23976. if (m[0] === m[3] && m[1] === -m[2]) {
  23977. var a = Math.acos(m[0]) * 180 / Math.PI;
  23978. return 'rotate(' + pf(a) + ')';
  23979. }
  23980. } else {
  23981. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  23982. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23983. }
  23984. }
  23985. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23986. }
  23987. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  23988. this.current = new SVGExtraState();
  23989. this.transformMatrix = IDENTITY_MATRIX;
  23990. this.transformStack = [];
  23991. this.extraStack = [];
  23992. this.commonObjs = commonObjs;
  23993. this.objs = objs;
  23994. this.pendingEOFill = false;
  23995. this.embedFonts = false;
  23996. this.embeddedFonts = Object.create(null);
  23997. this.cssStyle = null;
  23998. this.forceDataSchema = !!forceDataSchema;
  23999. }
  24000. var NS = 'http://www.w3.org/2000/svg';
  24001. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  24002. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  24003. var LINE_CAP_STYLES = [
  24004. 'butt',
  24005. 'round',
  24006. 'square'
  24007. ];
  24008. var LINE_JOIN_STYLES = [
  24009. 'miter',
  24010. 'round',
  24011. 'bevel'
  24012. ];
  24013. var clipCount = 0;
  24014. var maskCount = 0;
  24015. SVGGraphics.prototype = {
  24016. save: function SVGGraphics_save() {
  24017. this.transformStack.push(this.transformMatrix);
  24018. var old = this.current;
  24019. this.extraStack.push(old);
  24020. this.current = old.clone();
  24021. },
  24022. restore: function SVGGraphics_restore() {
  24023. this.transformMatrix = this.transformStack.pop();
  24024. this.current = this.extraStack.pop();
  24025. this.tgrp = null;
  24026. },
  24027. group: function SVGGraphics_group(items) {
  24028. this.save();
  24029. this.executeOpTree(items);
  24030. this.restore();
  24031. },
  24032. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  24033. var fnArray = operatorList.fnArray;
  24034. var fnArrayLen = fnArray.length;
  24035. var argsArray = operatorList.argsArray;
  24036. var self = this;
  24037. for (var i = 0; i < fnArrayLen; i++) {
  24038. if (OPS.dependency === fnArray[i]) {
  24039. var deps = argsArray[i];
  24040. for (var n = 0, nn = deps.length; n < nn; n++) {
  24041. var obj = deps[n];
  24042. var common = obj.substring(0, 2) === 'g_';
  24043. var promise;
  24044. if (common) {
  24045. promise = new Promise(function (resolve) {
  24046. self.commonObjs.get(obj, resolve);
  24047. });
  24048. } else {
  24049. promise = new Promise(function (resolve) {
  24050. self.objs.get(obj, resolve);
  24051. });
  24052. }
  24053. this.current.dependencies.push(promise);
  24054. }
  24055. }
  24056. }
  24057. return Promise.all(this.current.dependencies);
  24058. },
  24059. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  24060. var transformMatrix = [
  24061. a,
  24062. b,
  24063. c,
  24064. d,
  24065. e,
  24066. f
  24067. ];
  24068. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  24069. this.tgrp = null;
  24070. },
  24071. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  24072. this.viewport = viewport;
  24073. var svgElement = this._initialize(viewport);
  24074. return this.loadDependencies(operatorList).then(function () {
  24075. this.transformMatrix = IDENTITY_MATRIX;
  24076. var opTree = this.convertOpList(operatorList);
  24077. this.executeOpTree(opTree);
  24078. return svgElement;
  24079. }.bind(this));
  24080. },
  24081. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  24082. var argsArray = operatorList.argsArray;
  24083. var fnArray = operatorList.fnArray;
  24084. var fnArrayLen = fnArray.length;
  24085. var REVOPS = [];
  24086. var opList = [];
  24087. for (var op in OPS) {
  24088. REVOPS[OPS[op]] = op;
  24089. }
  24090. for (var x = 0; x < fnArrayLen; x++) {
  24091. var fnId = fnArray[x];
  24092. opList.push({
  24093. 'fnId': fnId,
  24094. 'fn': REVOPS[fnId],
  24095. 'args': argsArray[x]
  24096. });
  24097. }
  24098. return opListToTree(opList);
  24099. },
  24100. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  24101. var opTreeLen = opTree.length;
  24102. for (var x = 0; x < opTreeLen; x++) {
  24103. var fn = opTree[x].fn;
  24104. var fnId = opTree[x].fnId;
  24105. var args = opTree[x].args;
  24106. switch (fnId | 0) {
  24107. case OPS.beginText:
  24108. this.beginText();
  24109. break;
  24110. case OPS.setLeading:
  24111. this.setLeading(args);
  24112. break;
  24113. case OPS.setLeadingMoveText:
  24114. this.setLeadingMoveText(args[0], args[1]);
  24115. break;
  24116. case OPS.setFont:
  24117. this.setFont(args);
  24118. break;
  24119. case OPS.showText:
  24120. this.showText(args[0]);
  24121. break;
  24122. case OPS.showSpacedText:
  24123. this.showText(args[0]);
  24124. break;
  24125. case OPS.endText:
  24126. this.endText();
  24127. break;
  24128. case OPS.moveText:
  24129. this.moveText(args[0], args[1]);
  24130. break;
  24131. case OPS.setCharSpacing:
  24132. this.setCharSpacing(args[0]);
  24133. break;
  24134. case OPS.setWordSpacing:
  24135. this.setWordSpacing(args[0]);
  24136. break;
  24137. case OPS.setHScale:
  24138. this.setHScale(args[0]);
  24139. break;
  24140. case OPS.setTextMatrix:
  24141. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24142. break;
  24143. case OPS.setLineWidth:
  24144. this.setLineWidth(args[0]);
  24145. break;
  24146. case OPS.setLineJoin:
  24147. this.setLineJoin(args[0]);
  24148. break;
  24149. case OPS.setLineCap:
  24150. this.setLineCap(args[0]);
  24151. break;
  24152. case OPS.setMiterLimit:
  24153. this.setMiterLimit(args[0]);
  24154. break;
  24155. case OPS.setFillRGBColor:
  24156. this.setFillRGBColor(args[0], args[1], args[2]);
  24157. break;
  24158. case OPS.setStrokeRGBColor:
  24159. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24160. break;
  24161. case OPS.setDash:
  24162. this.setDash(args[0], args[1]);
  24163. break;
  24164. case OPS.setGState:
  24165. this.setGState(args[0]);
  24166. break;
  24167. case OPS.fill:
  24168. this.fill();
  24169. break;
  24170. case OPS.eoFill:
  24171. this.eoFill();
  24172. break;
  24173. case OPS.stroke:
  24174. this.stroke();
  24175. break;
  24176. case OPS.fillStroke:
  24177. this.fillStroke();
  24178. break;
  24179. case OPS.eoFillStroke:
  24180. this.eoFillStroke();
  24181. break;
  24182. case OPS.clip:
  24183. this.clip('nonzero');
  24184. break;
  24185. case OPS.eoClip:
  24186. this.clip('evenodd');
  24187. break;
  24188. case OPS.paintSolidColorImageMask:
  24189. this.paintSolidColorImageMask();
  24190. break;
  24191. case OPS.paintJpegXObject:
  24192. this.paintJpegXObject(args[0], args[1], args[2]);
  24193. break;
  24194. case OPS.paintImageXObject:
  24195. this.paintImageXObject(args[0]);
  24196. break;
  24197. case OPS.paintInlineImageXObject:
  24198. this.paintInlineImageXObject(args[0]);
  24199. break;
  24200. case OPS.paintImageMaskXObject:
  24201. this.paintImageMaskXObject(args[0]);
  24202. break;
  24203. case OPS.paintFormXObjectBegin:
  24204. this.paintFormXObjectBegin(args[0], args[1]);
  24205. break;
  24206. case OPS.paintFormXObjectEnd:
  24207. this.paintFormXObjectEnd();
  24208. break;
  24209. case OPS.closePath:
  24210. this.closePath();
  24211. break;
  24212. case OPS.closeStroke:
  24213. this.closeStroke();
  24214. break;
  24215. case OPS.closeFillStroke:
  24216. this.closeFillStroke();
  24217. break;
  24218. case OPS.nextLine:
  24219. this.nextLine();
  24220. break;
  24221. case OPS.transform:
  24222. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24223. break;
  24224. case OPS.constructPath:
  24225. this.constructPath(args[0], args[1]);
  24226. break;
  24227. case OPS.endPath:
  24228. this.endPath();
  24229. break;
  24230. case 92:
  24231. this.group(opTree[x].items);
  24232. break;
  24233. default:
  24234. warn('Unimplemented operator ' + fn);
  24235. break;
  24236. }
  24237. }
  24238. },
  24239. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24240. this.current.wordSpacing = wordSpacing;
  24241. },
  24242. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24243. this.current.charSpacing = charSpacing;
  24244. },
  24245. nextLine: function SVGGraphics_nextLine() {
  24246. this.moveText(0, this.current.leading);
  24247. },
  24248. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24249. var current = this.current;
  24250. this.current.textMatrix = this.current.lineMatrix = [
  24251. a,
  24252. b,
  24253. c,
  24254. d,
  24255. e,
  24256. f
  24257. ];
  24258. this.current.x = this.current.lineX = 0;
  24259. this.current.y = this.current.lineY = 0;
  24260. current.xcoords = [];
  24261. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24262. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24263. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24264. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24265. current.txtElement = document.createElementNS(NS, 'svg:text');
  24266. current.txtElement.appendChild(current.tspan);
  24267. },
  24268. beginText: function SVGGraphics_beginText() {
  24269. this.current.x = this.current.lineX = 0;
  24270. this.current.y = this.current.lineY = 0;
  24271. this.current.textMatrix = IDENTITY_MATRIX;
  24272. this.current.lineMatrix = IDENTITY_MATRIX;
  24273. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24274. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24275. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24276. this.current.xcoords = [];
  24277. },
  24278. moveText: function SVGGraphics_moveText(x, y) {
  24279. var current = this.current;
  24280. this.current.x = this.current.lineX += x;
  24281. this.current.y = this.current.lineY += y;
  24282. current.xcoords = [];
  24283. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24284. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24285. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24286. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24287. },
  24288. showText: function SVGGraphics_showText(glyphs) {
  24289. var current = this.current;
  24290. var font = current.font;
  24291. var fontSize = current.fontSize;
  24292. if (fontSize === 0) {
  24293. return;
  24294. }
  24295. var charSpacing = current.charSpacing;
  24296. var wordSpacing = current.wordSpacing;
  24297. var fontDirection = current.fontDirection;
  24298. var textHScale = current.textHScale * fontDirection;
  24299. var glyphsLength = glyphs.length;
  24300. var vertical = font.vertical;
  24301. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24302. var x = 0, i;
  24303. for (i = 0; i < glyphsLength; ++i) {
  24304. var glyph = glyphs[i];
  24305. if (glyph === null) {
  24306. x += fontDirection * wordSpacing;
  24307. continue;
  24308. } else if (isNum(glyph)) {
  24309. x += -glyph * fontSize * 0.001;
  24310. continue;
  24311. }
  24312. current.xcoords.push(current.x + x * textHScale);
  24313. var width = glyph.width;
  24314. var character = glyph.fontChar;
  24315. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24316. x += charWidth;
  24317. current.tspan.textContent += character;
  24318. }
  24319. if (vertical) {
  24320. current.y -= x * textHScale;
  24321. } else {
  24322. current.x += x * textHScale;
  24323. }
  24324. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24325. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24326. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24327. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24328. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24329. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24330. }
  24331. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24332. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24333. }
  24334. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24335. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24336. }
  24337. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24338. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24339. current.txtElement.appendChild(current.tspan);
  24340. current.txtgrp.appendChild(current.txtElement);
  24341. this._ensureTransformGroup().appendChild(current.txtElement);
  24342. },
  24343. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24344. this.setLeading(-y);
  24345. this.moveText(x, y);
  24346. },
  24347. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24348. if (!this.cssStyle) {
  24349. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24350. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24351. this.defs.appendChild(this.cssStyle);
  24352. }
  24353. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24354. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24355. },
  24356. setFont: function SVGGraphics_setFont(details) {
  24357. var current = this.current;
  24358. var fontObj = this.commonObjs.get(details[0]);
  24359. var size = details[1];
  24360. this.current.font = fontObj;
  24361. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24362. this.addFontStyle(fontObj);
  24363. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24364. }
  24365. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24366. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24367. var italic = fontObj.italic ? 'italic' : 'normal';
  24368. if (size < 0) {
  24369. size = -size;
  24370. current.fontDirection = -1;
  24371. } else {
  24372. current.fontDirection = 1;
  24373. }
  24374. current.fontSize = size;
  24375. current.fontFamily = fontObj.loadedName;
  24376. current.fontWeight = bold;
  24377. current.fontStyle = italic;
  24378. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24379. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24380. current.xcoords = [];
  24381. },
  24382. endText: function SVGGraphics_endText() {
  24383. },
  24384. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24385. this.current.lineWidth = width;
  24386. },
  24387. setLineCap: function SVGGraphics_setLineCap(style) {
  24388. this.current.lineCap = LINE_CAP_STYLES[style];
  24389. },
  24390. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24391. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24392. },
  24393. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24394. this.current.miterLimit = limit;
  24395. },
  24396. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24397. var color = Util.makeCssRgb(r, g, b);
  24398. this.current.strokeColor = color;
  24399. },
  24400. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24401. var color = Util.makeCssRgb(r, g, b);
  24402. this.current.fillColor = color;
  24403. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24404. this.current.xcoords = [];
  24405. },
  24406. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24407. this.current.dashArray = dashArray;
  24408. this.current.dashPhase = dashPhase;
  24409. },
  24410. constructPath: function SVGGraphics_constructPath(ops, args) {
  24411. var current = this.current;
  24412. var x = current.x, y = current.y;
  24413. current.path = document.createElementNS(NS, 'svg:path');
  24414. var d = [];
  24415. var opLength = ops.length;
  24416. for (var i = 0, j = 0; i < opLength; i++) {
  24417. switch (ops[i] | 0) {
  24418. case OPS.rectangle:
  24419. x = args[j++];
  24420. y = args[j++];
  24421. var width = args[j++];
  24422. var height = args[j++];
  24423. var xw = x + width;
  24424. var yh = y + height;
  24425. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24426. break;
  24427. case OPS.moveTo:
  24428. x = args[j++];
  24429. y = args[j++];
  24430. d.push('M', pf(x), pf(y));
  24431. break;
  24432. case OPS.lineTo:
  24433. x = args[j++];
  24434. y = args[j++];
  24435. d.push('L', pf(x), pf(y));
  24436. break;
  24437. case OPS.curveTo:
  24438. x = args[j + 4];
  24439. y = args[j + 5];
  24440. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24441. j += 6;
  24442. break;
  24443. case OPS.curveTo2:
  24444. x = args[j + 2];
  24445. y = args[j + 3];
  24446. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24447. j += 4;
  24448. break;
  24449. case OPS.curveTo3:
  24450. x = args[j + 2];
  24451. y = args[j + 3];
  24452. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24453. j += 4;
  24454. break;
  24455. case OPS.closePath:
  24456. d.push('Z');
  24457. break;
  24458. }
  24459. }
  24460. current.path.setAttributeNS(null, 'd', d.join(' '));
  24461. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24462. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24463. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24464. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24465. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24466. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24467. current.path.setAttributeNS(null, 'fill', 'none');
  24468. this._ensureTransformGroup().appendChild(current.path);
  24469. current.element = current.path;
  24470. current.setCurrentPoint(x, y);
  24471. },
  24472. endPath: function SVGGraphics_endPath() {
  24473. },
  24474. clip: function SVGGraphics_clip(type) {
  24475. var current = this.current;
  24476. var clipId = 'clippath' + clipCount;
  24477. clipCount++;
  24478. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24479. clipPath.setAttributeNS(null, 'id', clipId);
  24480. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24481. var clipElement = current.element.cloneNode();
  24482. if (type === 'evenodd') {
  24483. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24484. } else {
  24485. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24486. }
  24487. clipPath.appendChild(clipElement);
  24488. this.defs.appendChild(clipPath);
  24489. if (current.activeClipUrl) {
  24490. current.clipGroup = null;
  24491. this.extraStack.forEach(function (prev) {
  24492. prev.clipGroup = null;
  24493. });
  24494. }
  24495. current.activeClipUrl = 'url(#' + clipId + ')';
  24496. this.tgrp = null;
  24497. },
  24498. closePath: function SVGGraphics_closePath() {
  24499. var current = this.current;
  24500. var d = current.path.getAttributeNS(null, 'd');
  24501. d += 'Z';
  24502. current.path.setAttributeNS(null, 'd', d);
  24503. },
  24504. setLeading: function SVGGraphics_setLeading(leading) {
  24505. this.current.leading = -leading;
  24506. },
  24507. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24508. this.current.textRise = textRise;
  24509. },
  24510. setHScale: function SVGGraphics_setHScale(scale) {
  24511. this.current.textHScale = scale / 100;
  24512. },
  24513. setGState: function SVGGraphics_setGState(states) {
  24514. for (var i = 0, ii = states.length; i < ii; i++) {
  24515. var state = states[i];
  24516. var key = state[0];
  24517. var value = state[1];
  24518. switch (key) {
  24519. case 'LW':
  24520. this.setLineWidth(value);
  24521. break;
  24522. case 'LC':
  24523. this.setLineCap(value);
  24524. break;
  24525. case 'LJ':
  24526. this.setLineJoin(value);
  24527. break;
  24528. case 'ML':
  24529. this.setMiterLimit(value);
  24530. break;
  24531. case 'D':
  24532. this.setDash(value[0], value[1]);
  24533. break;
  24534. case 'Font':
  24535. this.setFont(value);
  24536. break;
  24537. default:
  24538. warn('Unimplemented graphic state ' + key);
  24539. break;
  24540. }
  24541. }
  24542. },
  24543. fill: function SVGGraphics_fill() {
  24544. var current = this.current;
  24545. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24546. },
  24547. stroke: function SVGGraphics_stroke() {
  24548. var current = this.current;
  24549. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24550. current.element.setAttributeNS(null, 'fill', 'none');
  24551. },
  24552. eoFill: function SVGGraphics_eoFill() {
  24553. var current = this.current;
  24554. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24555. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24556. },
  24557. fillStroke: function SVGGraphics_fillStroke() {
  24558. this.stroke();
  24559. this.fill();
  24560. },
  24561. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24562. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24563. this.fillStroke();
  24564. },
  24565. closeStroke: function SVGGraphics_closeStroke() {
  24566. this.closePath();
  24567. this.stroke();
  24568. },
  24569. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24570. this.closePath();
  24571. this.fillStroke();
  24572. },
  24573. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24574. var current = this.current;
  24575. var rect = document.createElementNS(NS, 'svg:rect');
  24576. rect.setAttributeNS(null, 'x', '0');
  24577. rect.setAttributeNS(null, 'y', '0');
  24578. rect.setAttributeNS(null, 'width', '1px');
  24579. rect.setAttributeNS(null, 'height', '1px');
  24580. rect.setAttributeNS(null, 'fill', current.fillColor);
  24581. this._ensureTransformGroup().appendChild(rect);
  24582. },
  24583. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24584. var imgObj = this.objs.get(objId);
  24585. var imgEl = document.createElementNS(NS, 'svg:image');
  24586. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24587. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24588. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24589. imgEl.setAttributeNS(null, 'x', '0');
  24590. imgEl.setAttributeNS(null, 'y', pf(-h));
  24591. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24592. this._ensureTransformGroup().appendChild(imgEl);
  24593. },
  24594. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24595. var imgData = this.objs.get(objId);
  24596. if (!imgData) {
  24597. warn('Dependent image isn\'t ready yet');
  24598. return;
  24599. }
  24600. this.paintInlineImageXObject(imgData);
  24601. },
  24602. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24603. var width = imgData.width;
  24604. var height = imgData.height;
  24605. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24606. var cliprect = document.createElementNS(NS, 'svg:rect');
  24607. cliprect.setAttributeNS(null, 'x', '0');
  24608. cliprect.setAttributeNS(null, 'y', '0');
  24609. cliprect.setAttributeNS(null, 'width', pf(width));
  24610. cliprect.setAttributeNS(null, 'height', pf(height));
  24611. this.current.element = cliprect;
  24612. this.clip('nonzero');
  24613. var imgEl = document.createElementNS(NS, 'svg:image');
  24614. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24615. imgEl.setAttributeNS(null, 'x', '0');
  24616. imgEl.setAttributeNS(null, 'y', pf(-height));
  24617. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24618. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24619. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24620. if (mask) {
  24621. mask.appendChild(imgEl);
  24622. } else {
  24623. this._ensureTransformGroup().appendChild(imgEl);
  24624. }
  24625. },
  24626. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24627. var current = this.current;
  24628. var width = imgData.width;
  24629. var height = imgData.height;
  24630. var fillColor = current.fillColor;
  24631. current.maskId = 'mask' + maskCount++;
  24632. var mask = document.createElementNS(NS, 'svg:mask');
  24633. mask.setAttributeNS(null, 'id', current.maskId);
  24634. var rect = document.createElementNS(NS, 'svg:rect');
  24635. rect.setAttributeNS(null, 'x', '0');
  24636. rect.setAttributeNS(null, 'y', '0');
  24637. rect.setAttributeNS(null, 'width', pf(width));
  24638. rect.setAttributeNS(null, 'height', pf(height));
  24639. rect.setAttributeNS(null, 'fill', fillColor);
  24640. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24641. this.defs.appendChild(mask);
  24642. this._ensureTransformGroup().appendChild(rect);
  24643. this.paintInlineImageXObject(imgData, mask);
  24644. },
  24645. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24646. if (isArray(matrix) && matrix.length === 6) {
  24647. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24648. }
  24649. if (isArray(bbox) && bbox.length === 4) {
  24650. var width = bbox[2] - bbox[0];
  24651. var height = bbox[3] - bbox[1];
  24652. var cliprect = document.createElementNS(NS, 'svg:rect');
  24653. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24654. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24655. cliprect.setAttributeNS(null, 'width', pf(width));
  24656. cliprect.setAttributeNS(null, 'height', pf(height));
  24657. this.current.element = cliprect;
  24658. this.clip('nonzero');
  24659. this.endPath();
  24660. }
  24661. },
  24662. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24663. },
  24664. _initialize: function SVGGraphics_initialize(viewport) {
  24665. var svg = document.createElementNS(NS, 'svg:svg');
  24666. svg.setAttributeNS(null, 'version', '1.1');
  24667. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24668. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24669. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24670. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24671. var definitions = document.createElementNS(NS, 'svg:defs');
  24672. svg.appendChild(definitions);
  24673. this.defs = definitions;
  24674. var rootGroup = document.createElementNS(NS, 'svg:g');
  24675. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24676. svg.appendChild(rootGroup);
  24677. this.svg = rootGroup;
  24678. return svg;
  24679. },
  24680. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24681. if (!this.current.clipGroup) {
  24682. var clipGroup = document.createElementNS(NS, 'svg:g');
  24683. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24684. this.svg.appendChild(clipGroup);
  24685. this.current.clipGroup = clipGroup;
  24686. }
  24687. return this.current.clipGroup;
  24688. },
  24689. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24690. if (!this.tgrp) {
  24691. this.tgrp = document.createElementNS(NS, 'svg:g');
  24692. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24693. if (this.current.activeClipUrl) {
  24694. this._ensureClipGroup().appendChild(this.tgrp);
  24695. } else {
  24696. this.svg.appendChild(this.tgrp);
  24697. }
  24698. }
  24699. return this.tgrp;
  24700. }
  24701. };
  24702. return SVGGraphics;
  24703. }();
  24704. exports.SVGGraphics = SVGGraphics;
  24705. }));
  24706. (function (root, factory) {
  24707. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24708. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24709. var Util = sharedUtil.Util;
  24710. var error = sharedUtil.error;
  24711. var info = sharedUtil.info;
  24712. var isInt = sharedUtil.isInt;
  24713. var isArray = sharedUtil.isArray;
  24714. var createObjectURL = sharedUtil.createObjectURL;
  24715. var shadow = sharedUtil.shadow;
  24716. var warn = sharedUtil.warn;
  24717. var isSpace = sharedUtil.isSpace;
  24718. var Dict = corePrimitives.Dict;
  24719. var isDict = corePrimitives.isDict;
  24720. var isStream = corePrimitives.isStream;
  24721. var Jbig2Image = coreJbig2.Jbig2Image;
  24722. var JpegImage = coreJpg.JpegImage;
  24723. var JpxImage = coreJpx.JpxImage;
  24724. var Stream = function StreamClosure() {
  24725. function Stream(arrayBuffer, start, length, dict) {
  24726. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24727. this.start = start || 0;
  24728. this.pos = this.start;
  24729. this.end = start + length || this.bytes.length;
  24730. this.dict = dict;
  24731. }
  24732. Stream.prototype = {
  24733. get length() {
  24734. return this.end - this.start;
  24735. },
  24736. get isEmpty() {
  24737. return this.length === 0;
  24738. },
  24739. getByte: function Stream_getByte() {
  24740. if (this.pos >= this.end) {
  24741. return -1;
  24742. }
  24743. return this.bytes[this.pos++];
  24744. },
  24745. getUint16: function Stream_getUint16() {
  24746. var b0 = this.getByte();
  24747. var b1 = this.getByte();
  24748. if (b0 === -1 || b1 === -1) {
  24749. return -1;
  24750. }
  24751. return (b0 << 8) + b1;
  24752. },
  24753. getInt32: function Stream_getInt32() {
  24754. var b0 = this.getByte();
  24755. var b1 = this.getByte();
  24756. var b2 = this.getByte();
  24757. var b3 = this.getByte();
  24758. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24759. },
  24760. getBytes: function Stream_getBytes(length) {
  24761. var bytes = this.bytes;
  24762. var pos = this.pos;
  24763. var strEnd = this.end;
  24764. if (!length) {
  24765. return bytes.subarray(pos, strEnd);
  24766. }
  24767. var end = pos + length;
  24768. if (end > strEnd) {
  24769. end = strEnd;
  24770. }
  24771. this.pos = end;
  24772. return bytes.subarray(pos, end);
  24773. },
  24774. peekByte: function Stream_peekByte() {
  24775. var peekedByte = this.getByte();
  24776. this.pos--;
  24777. return peekedByte;
  24778. },
  24779. peekBytes: function Stream_peekBytes(length) {
  24780. var bytes = this.getBytes(length);
  24781. this.pos -= bytes.length;
  24782. return bytes;
  24783. },
  24784. skip: function Stream_skip(n) {
  24785. if (!n) {
  24786. n = 1;
  24787. }
  24788. this.pos += n;
  24789. },
  24790. reset: function Stream_reset() {
  24791. this.pos = this.start;
  24792. },
  24793. moveStart: function Stream_moveStart() {
  24794. this.start = this.pos;
  24795. },
  24796. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24797. return new Stream(this.bytes.buffer, start, length, dict);
  24798. },
  24799. isStream: true
  24800. };
  24801. return Stream;
  24802. }();
  24803. var StringStream = function StringStreamClosure() {
  24804. function StringStream(str) {
  24805. var length = str.length;
  24806. var bytes = new Uint8Array(length);
  24807. for (var n = 0; n < length; ++n) {
  24808. bytes[n] = str.charCodeAt(n);
  24809. }
  24810. Stream.call(this, bytes);
  24811. }
  24812. StringStream.prototype = Stream.prototype;
  24813. return StringStream;
  24814. }();
  24815. var DecodeStream = function DecodeStreamClosure() {
  24816. var emptyBuffer = new Uint8Array(0);
  24817. function DecodeStream(maybeMinBufferLength) {
  24818. this.pos = 0;
  24819. this.bufferLength = 0;
  24820. this.eof = false;
  24821. this.buffer = emptyBuffer;
  24822. this.minBufferLength = 512;
  24823. if (maybeMinBufferLength) {
  24824. while (this.minBufferLength < maybeMinBufferLength) {
  24825. this.minBufferLength *= 2;
  24826. }
  24827. }
  24828. }
  24829. DecodeStream.prototype = {
  24830. get isEmpty() {
  24831. while (!this.eof && this.bufferLength === 0) {
  24832. this.readBlock();
  24833. }
  24834. return this.bufferLength === 0;
  24835. },
  24836. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24837. var buffer = this.buffer;
  24838. if (requested <= buffer.byteLength) {
  24839. return buffer;
  24840. }
  24841. var size = this.minBufferLength;
  24842. while (size < requested) {
  24843. size *= 2;
  24844. }
  24845. var buffer2 = new Uint8Array(size);
  24846. buffer2.set(buffer);
  24847. return this.buffer = buffer2;
  24848. },
  24849. getByte: function DecodeStream_getByte() {
  24850. var pos = this.pos;
  24851. while (this.bufferLength <= pos) {
  24852. if (this.eof) {
  24853. return -1;
  24854. }
  24855. this.readBlock();
  24856. }
  24857. return this.buffer[this.pos++];
  24858. },
  24859. getUint16: function DecodeStream_getUint16() {
  24860. var b0 = this.getByte();
  24861. var b1 = this.getByte();
  24862. if (b0 === -1 || b1 === -1) {
  24863. return -1;
  24864. }
  24865. return (b0 << 8) + b1;
  24866. },
  24867. getInt32: function DecodeStream_getInt32() {
  24868. var b0 = this.getByte();
  24869. var b1 = this.getByte();
  24870. var b2 = this.getByte();
  24871. var b3 = this.getByte();
  24872. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24873. },
  24874. getBytes: function DecodeStream_getBytes(length) {
  24875. var end, pos = this.pos;
  24876. if (length) {
  24877. this.ensureBuffer(pos + length);
  24878. end = pos + length;
  24879. while (!this.eof && this.bufferLength < end) {
  24880. this.readBlock();
  24881. }
  24882. var bufEnd = this.bufferLength;
  24883. if (end > bufEnd) {
  24884. end = bufEnd;
  24885. }
  24886. } else {
  24887. while (!this.eof) {
  24888. this.readBlock();
  24889. }
  24890. end = this.bufferLength;
  24891. }
  24892. this.pos = end;
  24893. return this.buffer.subarray(pos, end);
  24894. },
  24895. peekByte: function DecodeStream_peekByte() {
  24896. var peekedByte = this.getByte();
  24897. this.pos--;
  24898. return peekedByte;
  24899. },
  24900. peekBytes: function DecodeStream_peekBytes(length) {
  24901. var bytes = this.getBytes(length);
  24902. this.pos -= bytes.length;
  24903. return bytes;
  24904. },
  24905. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24906. var end = start + length;
  24907. while (this.bufferLength <= end && !this.eof) {
  24908. this.readBlock();
  24909. }
  24910. return new Stream(this.buffer, start, length, dict);
  24911. },
  24912. skip: function DecodeStream_skip(n) {
  24913. if (!n) {
  24914. n = 1;
  24915. }
  24916. this.pos += n;
  24917. },
  24918. reset: function DecodeStream_reset() {
  24919. this.pos = 0;
  24920. },
  24921. getBaseStreams: function DecodeStream_getBaseStreams() {
  24922. if (this.str && this.str.getBaseStreams) {
  24923. return this.str.getBaseStreams();
  24924. }
  24925. return [];
  24926. }
  24927. };
  24928. return DecodeStream;
  24929. }();
  24930. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24931. function StreamsSequenceStream(streams) {
  24932. this.streams = streams;
  24933. DecodeStream.call(this, null);
  24934. }
  24935. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24936. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24937. var streams = this.streams;
  24938. if (streams.length === 0) {
  24939. this.eof = true;
  24940. return;
  24941. }
  24942. var stream = streams.shift();
  24943. var chunk = stream.getBytes();
  24944. var bufferLength = this.bufferLength;
  24945. var newLength = bufferLength + chunk.length;
  24946. var buffer = this.ensureBuffer(newLength);
  24947. buffer.set(chunk, bufferLength);
  24948. this.bufferLength = newLength;
  24949. };
  24950. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24951. var baseStreams = [];
  24952. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24953. var stream = this.streams[i];
  24954. if (stream.getBaseStreams) {
  24955. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24956. }
  24957. }
  24958. return baseStreams;
  24959. };
  24960. return StreamsSequenceStream;
  24961. }();
  24962. var FlateStream = function FlateStreamClosure() {
  24963. var codeLenCodeMap = new Int32Array([
  24964. 16,
  24965. 17,
  24966. 18,
  24967. 0,
  24968. 8,
  24969. 7,
  24970. 9,
  24971. 6,
  24972. 10,
  24973. 5,
  24974. 11,
  24975. 4,
  24976. 12,
  24977. 3,
  24978. 13,
  24979. 2,
  24980. 14,
  24981. 1,
  24982. 15
  24983. ]);
  24984. var lengthDecode = new Int32Array([
  24985. 0x00003,
  24986. 0x00004,
  24987. 0x00005,
  24988. 0x00006,
  24989. 0x00007,
  24990. 0x00008,
  24991. 0x00009,
  24992. 0x0000a,
  24993. 0x1000b,
  24994. 0x1000d,
  24995. 0x1000f,
  24996. 0x10011,
  24997. 0x20013,
  24998. 0x20017,
  24999. 0x2001b,
  25000. 0x2001f,
  25001. 0x30023,
  25002. 0x3002b,
  25003. 0x30033,
  25004. 0x3003b,
  25005. 0x40043,
  25006. 0x40053,
  25007. 0x40063,
  25008. 0x40073,
  25009. 0x50083,
  25010. 0x500a3,
  25011. 0x500c3,
  25012. 0x500e3,
  25013. 0x00102,
  25014. 0x00102,
  25015. 0x00102
  25016. ]);
  25017. var distDecode = new Int32Array([
  25018. 0x00001,
  25019. 0x00002,
  25020. 0x00003,
  25021. 0x00004,
  25022. 0x10005,
  25023. 0x10007,
  25024. 0x20009,
  25025. 0x2000d,
  25026. 0x30011,
  25027. 0x30019,
  25028. 0x40021,
  25029. 0x40031,
  25030. 0x50041,
  25031. 0x50061,
  25032. 0x60081,
  25033. 0x600c1,
  25034. 0x70101,
  25035. 0x70181,
  25036. 0x80201,
  25037. 0x80301,
  25038. 0x90401,
  25039. 0x90601,
  25040. 0xa0801,
  25041. 0xa0c01,
  25042. 0xb1001,
  25043. 0xb1801,
  25044. 0xc2001,
  25045. 0xc3001,
  25046. 0xd4001,
  25047. 0xd6001
  25048. ]);
  25049. var fixedLitCodeTab = [
  25050. new Int32Array([
  25051. 0x70100,
  25052. 0x80050,
  25053. 0x80010,
  25054. 0x80118,
  25055. 0x70110,
  25056. 0x80070,
  25057. 0x80030,
  25058. 0x900c0,
  25059. 0x70108,
  25060. 0x80060,
  25061. 0x80020,
  25062. 0x900a0,
  25063. 0x80000,
  25064. 0x80080,
  25065. 0x80040,
  25066. 0x900e0,
  25067. 0x70104,
  25068. 0x80058,
  25069. 0x80018,
  25070. 0x90090,
  25071. 0x70114,
  25072. 0x80078,
  25073. 0x80038,
  25074. 0x900d0,
  25075. 0x7010c,
  25076. 0x80068,
  25077. 0x80028,
  25078. 0x900b0,
  25079. 0x80008,
  25080. 0x80088,
  25081. 0x80048,
  25082. 0x900f0,
  25083. 0x70102,
  25084. 0x80054,
  25085. 0x80014,
  25086. 0x8011c,
  25087. 0x70112,
  25088. 0x80074,
  25089. 0x80034,
  25090. 0x900c8,
  25091. 0x7010a,
  25092. 0x80064,
  25093. 0x80024,
  25094. 0x900a8,
  25095. 0x80004,
  25096. 0x80084,
  25097. 0x80044,
  25098. 0x900e8,
  25099. 0x70106,
  25100. 0x8005c,
  25101. 0x8001c,
  25102. 0x90098,
  25103. 0x70116,
  25104. 0x8007c,
  25105. 0x8003c,
  25106. 0x900d8,
  25107. 0x7010e,
  25108. 0x8006c,
  25109. 0x8002c,
  25110. 0x900b8,
  25111. 0x8000c,
  25112. 0x8008c,
  25113. 0x8004c,
  25114. 0x900f8,
  25115. 0x70101,
  25116. 0x80052,
  25117. 0x80012,
  25118. 0x8011a,
  25119. 0x70111,
  25120. 0x80072,
  25121. 0x80032,
  25122. 0x900c4,
  25123. 0x70109,
  25124. 0x80062,
  25125. 0x80022,
  25126. 0x900a4,
  25127. 0x80002,
  25128. 0x80082,
  25129. 0x80042,
  25130. 0x900e4,
  25131. 0x70105,
  25132. 0x8005a,
  25133. 0x8001a,
  25134. 0x90094,
  25135. 0x70115,
  25136. 0x8007a,
  25137. 0x8003a,
  25138. 0x900d4,
  25139. 0x7010d,
  25140. 0x8006a,
  25141. 0x8002a,
  25142. 0x900b4,
  25143. 0x8000a,
  25144. 0x8008a,
  25145. 0x8004a,
  25146. 0x900f4,
  25147. 0x70103,
  25148. 0x80056,
  25149. 0x80016,
  25150. 0x8011e,
  25151. 0x70113,
  25152. 0x80076,
  25153. 0x80036,
  25154. 0x900cc,
  25155. 0x7010b,
  25156. 0x80066,
  25157. 0x80026,
  25158. 0x900ac,
  25159. 0x80006,
  25160. 0x80086,
  25161. 0x80046,
  25162. 0x900ec,
  25163. 0x70107,
  25164. 0x8005e,
  25165. 0x8001e,
  25166. 0x9009c,
  25167. 0x70117,
  25168. 0x8007e,
  25169. 0x8003e,
  25170. 0x900dc,
  25171. 0x7010f,
  25172. 0x8006e,
  25173. 0x8002e,
  25174. 0x900bc,
  25175. 0x8000e,
  25176. 0x8008e,
  25177. 0x8004e,
  25178. 0x900fc,
  25179. 0x70100,
  25180. 0x80051,
  25181. 0x80011,
  25182. 0x80119,
  25183. 0x70110,
  25184. 0x80071,
  25185. 0x80031,
  25186. 0x900c2,
  25187. 0x70108,
  25188. 0x80061,
  25189. 0x80021,
  25190. 0x900a2,
  25191. 0x80001,
  25192. 0x80081,
  25193. 0x80041,
  25194. 0x900e2,
  25195. 0x70104,
  25196. 0x80059,
  25197. 0x80019,
  25198. 0x90092,
  25199. 0x70114,
  25200. 0x80079,
  25201. 0x80039,
  25202. 0x900d2,
  25203. 0x7010c,
  25204. 0x80069,
  25205. 0x80029,
  25206. 0x900b2,
  25207. 0x80009,
  25208. 0x80089,
  25209. 0x80049,
  25210. 0x900f2,
  25211. 0x70102,
  25212. 0x80055,
  25213. 0x80015,
  25214. 0x8011d,
  25215. 0x70112,
  25216. 0x80075,
  25217. 0x80035,
  25218. 0x900ca,
  25219. 0x7010a,
  25220. 0x80065,
  25221. 0x80025,
  25222. 0x900aa,
  25223. 0x80005,
  25224. 0x80085,
  25225. 0x80045,
  25226. 0x900ea,
  25227. 0x70106,
  25228. 0x8005d,
  25229. 0x8001d,
  25230. 0x9009a,
  25231. 0x70116,
  25232. 0x8007d,
  25233. 0x8003d,
  25234. 0x900da,
  25235. 0x7010e,
  25236. 0x8006d,
  25237. 0x8002d,
  25238. 0x900ba,
  25239. 0x8000d,
  25240. 0x8008d,
  25241. 0x8004d,
  25242. 0x900fa,
  25243. 0x70101,
  25244. 0x80053,
  25245. 0x80013,
  25246. 0x8011b,
  25247. 0x70111,
  25248. 0x80073,
  25249. 0x80033,
  25250. 0x900c6,
  25251. 0x70109,
  25252. 0x80063,
  25253. 0x80023,
  25254. 0x900a6,
  25255. 0x80003,
  25256. 0x80083,
  25257. 0x80043,
  25258. 0x900e6,
  25259. 0x70105,
  25260. 0x8005b,
  25261. 0x8001b,
  25262. 0x90096,
  25263. 0x70115,
  25264. 0x8007b,
  25265. 0x8003b,
  25266. 0x900d6,
  25267. 0x7010d,
  25268. 0x8006b,
  25269. 0x8002b,
  25270. 0x900b6,
  25271. 0x8000b,
  25272. 0x8008b,
  25273. 0x8004b,
  25274. 0x900f6,
  25275. 0x70103,
  25276. 0x80057,
  25277. 0x80017,
  25278. 0x8011f,
  25279. 0x70113,
  25280. 0x80077,
  25281. 0x80037,
  25282. 0x900ce,
  25283. 0x7010b,
  25284. 0x80067,
  25285. 0x80027,
  25286. 0x900ae,
  25287. 0x80007,
  25288. 0x80087,
  25289. 0x80047,
  25290. 0x900ee,
  25291. 0x70107,
  25292. 0x8005f,
  25293. 0x8001f,
  25294. 0x9009e,
  25295. 0x70117,
  25296. 0x8007f,
  25297. 0x8003f,
  25298. 0x900de,
  25299. 0x7010f,
  25300. 0x8006f,
  25301. 0x8002f,
  25302. 0x900be,
  25303. 0x8000f,
  25304. 0x8008f,
  25305. 0x8004f,
  25306. 0x900fe,
  25307. 0x70100,
  25308. 0x80050,
  25309. 0x80010,
  25310. 0x80118,
  25311. 0x70110,
  25312. 0x80070,
  25313. 0x80030,
  25314. 0x900c1,
  25315. 0x70108,
  25316. 0x80060,
  25317. 0x80020,
  25318. 0x900a1,
  25319. 0x80000,
  25320. 0x80080,
  25321. 0x80040,
  25322. 0x900e1,
  25323. 0x70104,
  25324. 0x80058,
  25325. 0x80018,
  25326. 0x90091,
  25327. 0x70114,
  25328. 0x80078,
  25329. 0x80038,
  25330. 0x900d1,
  25331. 0x7010c,
  25332. 0x80068,
  25333. 0x80028,
  25334. 0x900b1,
  25335. 0x80008,
  25336. 0x80088,
  25337. 0x80048,
  25338. 0x900f1,
  25339. 0x70102,
  25340. 0x80054,
  25341. 0x80014,
  25342. 0x8011c,
  25343. 0x70112,
  25344. 0x80074,
  25345. 0x80034,
  25346. 0x900c9,
  25347. 0x7010a,
  25348. 0x80064,
  25349. 0x80024,
  25350. 0x900a9,
  25351. 0x80004,
  25352. 0x80084,
  25353. 0x80044,
  25354. 0x900e9,
  25355. 0x70106,
  25356. 0x8005c,
  25357. 0x8001c,
  25358. 0x90099,
  25359. 0x70116,
  25360. 0x8007c,
  25361. 0x8003c,
  25362. 0x900d9,
  25363. 0x7010e,
  25364. 0x8006c,
  25365. 0x8002c,
  25366. 0x900b9,
  25367. 0x8000c,
  25368. 0x8008c,
  25369. 0x8004c,
  25370. 0x900f9,
  25371. 0x70101,
  25372. 0x80052,
  25373. 0x80012,
  25374. 0x8011a,
  25375. 0x70111,
  25376. 0x80072,
  25377. 0x80032,
  25378. 0x900c5,
  25379. 0x70109,
  25380. 0x80062,
  25381. 0x80022,
  25382. 0x900a5,
  25383. 0x80002,
  25384. 0x80082,
  25385. 0x80042,
  25386. 0x900e5,
  25387. 0x70105,
  25388. 0x8005a,
  25389. 0x8001a,
  25390. 0x90095,
  25391. 0x70115,
  25392. 0x8007a,
  25393. 0x8003a,
  25394. 0x900d5,
  25395. 0x7010d,
  25396. 0x8006a,
  25397. 0x8002a,
  25398. 0x900b5,
  25399. 0x8000a,
  25400. 0x8008a,
  25401. 0x8004a,
  25402. 0x900f5,
  25403. 0x70103,
  25404. 0x80056,
  25405. 0x80016,
  25406. 0x8011e,
  25407. 0x70113,
  25408. 0x80076,
  25409. 0x80036,
  25410. 0x900cd,
  25411. 0x7010b,
  25412. 0x80066,
  25413. 0x80026,
  25414. 0x900ad,
  25415. 0x80006,
  25416. 0x80086,
  25417. 0x80046,
  25418. 0x900ed,
  25419. 0x70107,
  25420. 0x8005e,
  25421. 0x8001e,
  25422. 0x9009d,
  25423. 0x70117,
  25424. 0x8007e,
  25425. 0x8003e,
  25426. 0x900dd,
  25427. 0x7010f,
  25428. 0x8006e,
  25429. 0x8002e,
  25430. 0x900bd,
  25431. 0x8000e,
  25432. 0x8008e,
  25433. 0x8004e,
  25434. 0x900fd,
  25435. 0x70100,
  25436. 0x80051,
  25437. 0x80011,
  25438. 0x80119,
  25439. 0x70110,
  25440. 0x80071,
  25441. 0x80031,
  25442. 0x900c3,
  25443. 0x70108,
  25444. 0x80061,
  25445. 0x80021,
  25446. 0x900a3,
  25447. 0x80001,
  25448. 0x80081,
  25449. 0x80041,
  25450. 0x900e3,
  25451. 0x70104,
  25452. 0x80059,
  25453. 0x80019,
  25454. 0x90093,
  25455. 0x70114,
  25456. 0x80079,
  25457. 0x80039,
  25458. 0x900d3,
  25459. 0x7010c,
  25460. 0x80069,
  25461. 0x80029,
  25462. 0x900b3,
  25463. 0x80009,
  25464. 0x80089,
  25465. 0x80049,
  25466. 0x900f3,
  25467. 0x70102,
  25468. 0x80055,
  25469. 0x80015,
  25470. 0x8011d,
  25471. 0x70112,
  25472. 0x80075,
  25473. 0x80035,
  25474. 0x900cb,
  25475. 0x7010a,
  25476. 0x80065,
  25477. 0x80025,
  25478. 0x900ab,
  25479. 0x80005,
  25480. 0x80085,
  25481. 0x80045,
  25482. 0x900eb,
  25483. 0x70106,
  25484. 0x8005d,
  25485. 0x8001d,
  25486. 0x9009b,
  25487. 0x70116,
  25488. 0x8007d,
  25489. 0x8003d,
  25490. 0x900db,
  25491. 0x7010e,
  25492. 0x8006d,
  25493. 0x8002d,
  25494. 0x900bb,
  25495. 0x8000d,
  25496. 0x8008d,
  25497. 0x8004d,
  25498. 0x900fb,
  25499. 0x70101,
  25500. 0x80053,
  25501. 0x80013,
  25502. 0x8011b,
  25503. 0x70111,
  25504. 0x80073,
  25505. 0x80033,
  25506. 0x900c7,
  25507. 0x70109,
  25508. 0x80063,
  25509. 0x80023,
  25510. 0x900a7,
  25511. 0x80003,
  25512. 0x80083,
  25513. 0x80043,
  25514. 0x900e7,
  25515. 0x70105,
  25516. 0x8005b,
  25517. 0x8001b,
  25518. 0x90097,
  25519. 0x70115,
  25520. 0x8007b,
  25521. 0x8003b,
  25522. 0x900d7,
  25523. 0x7010d,
  25524. 0x8006b,
  25525. 0x8002b,
  25526. 0x900b7,
  25527. 0x8000b,
  25528. 0x8008b,
  25529. 0x8004b,
  25530. 0x900f7,
  25531. 0x70103,
  25532. 0x80057,
  25533. 0x80017,
  25534. 0x8011f,
  25535. 0x70113,
  25536. 0x80077,
  25537. 0x80037,
  25538. 0x900cf,
  25539. 0x7010b,
  25540. 0x80067,
  25541. 0x80027,
  25542. 0x900af,
  25543. 0x80007,
  25544. 0x80087,
  25545. 0x80047,
  25546. 0x900ef,
  25547. 0x70107,
  25548. 0x8005f,
  25549. 0x8001f,
  25550. 0x9009f,
  25551. 0x70117,
  25552. 0x8007f,
  25553. 0x8003f,
  25554. 0x900df,
  25555. 0x7010f,
  25556. 0x8006f,
  25557. 0x8002f,
  25558. 0x900bf,
  25559. 0x8000f,
  25560. 0x8008f,
  25561. 0x8004f,
  25562. 0x900ff
  25563. ]),
  25564. 9
  25565. ];
  25566. var fixedDistCodeTab = [
  25567. new Int32Array([
  25568. 0x50000,
  25569. 0x50010,
  25570. 0x50008,
  25571. 0x50018,
  25572. 0x50004,
  25573. 0x50014,
  25574. 0x5000c,
  25575. 0x5001c,
  25576. 0x50002,
  25577. 0x50012,
  25578. 0x5000a,
  25579. 0x5001a,
  25580. 0x50006,
  25581. 0x50016,
  25582. 0x5000e,
  25583. 0x00000,
  25584. 0x50001,
  25585. 0x50011,
  25586. 0x50009,
  25587. 0x50019,
  25588. 0x50005,
  25589. 0x50015,
  25590. 0x5000d,
  25591. 0x5001d,
  25592. 0x50003,
  25593. 0x50013,
  25594. 0x5000b,
  25595. 0x5001b,
  25596. 0x50007,
  25597. 0x50017,
  25598. 0x5000f,
  25599. 0x00000
  25600. ]),
  25601. 5
  25602. ];
  25603. function FlateStream(str, maybeLength) {
  25604. this.str = str;
  25605. this.dict = str.dict;
  25606. var cmf = str.getByte();
  25607. var flg = str.getByte();
  25608. if (cmf === -1 || flg === -1) {
  25609. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25610. }
  25611. if ((cmf & 0x0f) !== 0x08) {
  25612. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25613. }
  25614. if (((cmf << 8) + flg) % 31 !== 0) {
  25615. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25616. }
  25617. if (flg & 0x20) {
  25618. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25619. }
  25620. this.codeSize = 0;
  25621. this.codeBuf = 0;
  25622. DecodeStream.call(this, maybeLength);
  25623. }
  25624. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25625. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25626. var str = this.str;
  25627. var codeSize = this.codeSize;
  25628. var codeBuf = this.codeBuf;
  25629. var b;
  25630. while (codeSize < bits) {
  25631. if ((b = str.getByte()) === -1) {
  25632. error('Bad encoding in flate stream');
  25633. }
  25634. codeBuf |= b << codeSize;
  25635. codeSize += 8;
  25636. }
  25637. b = codeBuf & (1 << bits) - 1;
  25638. this.codeBuf = codeBuf >> bits;
  25639. this.codeSize = codeSize -= bits;
  25640. return b;
  25641. };
  25642. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25643. var str = this.str;
  25644. var codes = table[0];
  25645. var maxLen = table[1];
  25646. var codeSize = this.codeSize;
  25647. var codeBuf = this.codeBuf;
  25648. var b;
  25649. while (codeSize < maxLen) {
  25650. if ((b = str.getByte()) === -1) {
  25651. break;
  25652. }
  25653. codeBuf |= b << codeSize;
  25654. codeSize += 8;
  25655. }
  25656. var code = codes[codeBuf & (1 << maxLen) - 1];
  25657. var codeLen = code >> 16;
  25658. var codeVal = code & 0xffff;
  25659. if (codeLen < 1 || codeSize < codeLen) {
  25660. error('Bad encoding in flate stream');
  25661. }
  25662. this.codeBuf = codeBuf >> codeLen;
  25663. this.codeSize = codeSize - codeLen;
  25664. return codeVal;
  25665. };
  25666. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25667. var n = lengths.length;
  25668. var maxLen = 0;
  25669. var i;
  25670. for (i = 0; i < n; ++i) {
  25671. if (lengths[i] > maxLen) {
  25672. maxLen = lengths[i];
  25673. }
  25674. }
  25675. var size = 1 << maxLen;
  25676. var codes = new Int32Array(size);
  25677. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25678. for (var val = 0; val < n; ++val) {
  25679. if (lengths[val] === len) {
  25680. var code2 = 0;
  25681. var t = code;
  25682. for (i = 0; i < len; ++i) {
  25683. code2 = code2 << 1 | t & 1;
  25684. t >>= 1;
  25685. }
  25686. for (i = code2; i < size; i += skip) {
  25687. codes[i] = len << 16 | val;
  25688. }
  25689. ++code;
  25690. }
  25691. }
  25692. }
  25693. return [
  25694. codes,
  25695. maxLen
  25696. ];
  25697. };
  25698. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25699. var buffer, len;
  25700. var str = this.str;
  25701. var hdr = this.getBits(3);
  25702. if (hdr & 1) {
  25703. this.eof = true;
  25704. }
  25705. hdr >>= 1;
  25706. if (hdr === 0) {
  25707. var b;
  25708. if ((b = str.getByte()) === -1) {
  25709. error('Bad block header in flate stream');
  25710. }
  25711. var blockLen = b;
  25712. if ((b = str.getByte()) === -1) {
  25713. error('Bad block header in flate stream');
  25714. }
  25715. blockLen |= b << 8;
  25716. if ((b = str.getByte()) === -1) {
  25717. error('Bad block header in flate stream');
  25718. }
  25719. var check = b;
  25720. if ((b = str.getByte()) === -1) {
  25721. error('Bad block header in flate stream');
  25722. }
  25723. check |= b << 8;
  25724. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25725. error('Bad uncompressed block length in flate stream');
  25726. }
  25727. this.codeBuf = 0;
  25728. this.codeSize = 0;
  25729. var bufferLength = this.bufferLength;
  25730. buffer = this.ensureBuffer(bufferLength + blockLen);
  25731. var end = bufferLength + blockLen;
  25732. this.bufferLength = end;
  25733. if (blockLen === 0) {
  25734. if (str.peekByte() === -1) {
  25735. this.eof = true;
  25736. }
  25737. } else {
  25738. for (var n = bufferLength; n < end; ++n) {
  25739. if ((b = str.getByte()) === -1) {
  25740. this.eof = true;
  25741. break;
  25742. }
  25743. buffer[n] = b;
  25744. }
  25745. }
  25746. return;
  25747. }
  25748. var litCodeTable;
  25749. var distCodeTable;
  25750. if (hdr === 1) {
  25751. litCodeTable = fixedLitCodeTab;
  25752. distCodeTable = fixedDistCodeTab;
  25753. } else if (hdr === 2) {
  25754. var numLitCodes = this.getBits(5) + 257;
  25755. var numDistCodes = this.getBits(5) + 1;
  25756. var numCodeLenCodes = this.getBits(4) + 4;
  25757. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25758. var i;
  25759. for (i = 0; i < numCodeLenCodes; ++i) {
  25760. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25761. }
  25762. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25763. len = 0;
  25764. i = 0;
  25765. var codes = numLitCodes + numDistCodes;
  25766. var codeLengths = new Uint8Array(codes);
  25767. var bitsLength, bitsOffset, what;
  25768. while (i < codes) {
  25769. var code = this.getCode(codeLenCodeTab);
  25770. if (code === 16) {
  25771. bitsLength = 2;
  25772. bitsOffset = 3;
  25773. what = len;
  25774. } else if (code === 17) {
  25775. bitsLength = 3;
  25776. bitsOffset = 3;
  25777. what = len = 0;
  25778. } else if (code === 18) {
  25779. bitsLength = 7;
  25780. bitsOffset = 11;
  25781. what = len = 0;
  25782. } else {
  25783. codeLengths[i++] = len = code;
  25784. continue;
  25785. }
  25786. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25787. while (repeatLength-- > 0) {
  25788. codeLengths[i++] = what;
  25789. }
  25790. }
  25791. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25792. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25793. } else {
  25794. error('Unknown block type in flate stream');
  25795. }
  25796. buffer = this.buffer;
  25797. var limit = buffer ? buffer.length : 0;
  25798. var pos = this.bufferLength;
  25799. while (true) {
  25800. var code1 = this.getCode(litCodeTable);
  25801. if (code1 < 256) {
  25802. if (pos + 1 >= limit) {
  25803. buffer = this.ensureBuffer(pos + 1);
  25804. limit = buffer.length;
  25805. }
  25806. buffer[pos++] = code1;
  25807. continue;
  25808. }
  25809. if (code1 === 256) {
  25810. this.bufferLength = pos;
  25811. return;
  25812. }
  25813. code1 -= 257;
  25814. code1 = lengthDecode[code1];
  25815. var code2 = code1 >> 16;
  25816. if (code2 > 0) {
  25817. code2 = this.getBits(code2);
  25818. }
  25819. len = (code1 & 0xffff) + code2;
  25820. code1 = this.getCode(distCodeTable);
  25821. code1 = distDecode[code1];
  25822. code2 = code1 >> 16;
  25823. if (code2 > 0) {
  25824. code2 = this.getBits(code2);
  25825. }
  25826. var dist = (code1 & 0xffff) + code2;
  25827. if (pos + len >= limit) {
  25828. buffer = this.ensureBuffer(pos + len);
  25829. limit = buffer.length;
  25830. }
  25831. for (var k = 0; k < len; ++k, ++pos) {
  25832. buffer[pos] = buffer[pos - dist];
  25833. }
  25834. }
  25835. };
  25836. return FlateStream;
  25837. }();
  25838. var PredictorStream = function PredictorStreamClosure() {
  25839. function PredictorStream(str, maybeLength, params) {
  25840. if (!isDict(params)) {
  25841. return str;
  25842. }
  25843. var predictor = this.predictor = params.get('Predictor') || 1;
  25844. if (predictor <= 1) {
  25845. return str;
  25846. }
  25847. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25848. error('Unsupported predictor: ' + predictor);
  25849. }
  25850. if (predictor === 2) {
  25851. this.readBlock = this.readBlockTiff;
  25852. } else {
  25853. this.readBlock = this.readBlockPng;
  25854. }
  25855. this.str = str;
  25856. this.dict = str.dict;
  25857. var colors = this.colors = params.get('Colors') || 1;
  25858. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25859. var columns = this.columns = params.get('Columns') || 1;
  25860. this.pixBytes = colors * bits + 7 >> 3;
  25861. this.rowBytes = columns * colors * bits + 7 >> 3;
  25862. DecodeStream.call(this, maybeLength);
  25863. return this;
  25864. }
  25865. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25866. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25867. var rowBytes = this.rowBytes;
  25868. var bufferLength = this.bufferLength;
  25869. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25870. var bits = this.bits;
  25871. var colors = this.colors;
  25872. var rawBytes = this.str.getBytes(rowBytes);
  25873. this.eof = !rawBytes.length;
  25874. if (this.eof) {
  25875. return;
  25876. }
  25877. var inbuf = 0, outbuf = 0;
  25878. var inbits = 0, outbits = 0;
  25879. var pos = bufferLength;
  25880. var i;
  25881. if (bits === 1 && colors === 1) {
  25882. for (i = 0; i < rowBytes; ++i) {
  25883. var c = rawBytes[i] ^ inbuf;
  25884. c ^= c >> 1;
  25885. c ^= c >> 2;
  25886. c ^= c >> 4;
  25887. inbuf = (c & 1) << 7;
  25888. buffer[pos++] = c;
  25889. }
  25890. } else if (bits === 8) {
  25891. for (i = 0; i < colors; ++i) {
  25892. buffer[pos++] = rawBytes[i];
  25893. }
  25894. for (; i < rowBytes; ++i) {
  25895. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  25896. pos++;
  25897. }
  25898. } else {
  25899. var compArray = new Uint8Array(colors + 1);
  25900. var bitMask = (1 << bits) - 1;
  25901. var j = 0, k = bufferLength;
  25902. var columns = this.columns;
  25903. for (i = 0; i < columns; ++i) {
  25904. for (var kk = 0; kk < colors; ++kk) {
  25905. if (inbits < bits) {
  25906. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  25907. inbits += 8;
  25908. }
  25909. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  25910. inbits -= bits;
  25911. outbuf = outbuf << bits | compArray[kk];
  25912. outbits += bits;
  25913. if (outbits >= 8) {
  25914. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  25915. outbits -= 8;
  25916. }
  25917. }
  25918. }
  25919. if (outbits > 0) {
  25920. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  25921. }
  25922. }
  25923. this.bufferLength += rowBytes;
  25924. };
  25925. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  25926. var rowBytes = this.rowBytes;
  25927. var pixBytes = this.pixBytes;
  25928. var predictor = this.str.getByte();
  25929. var rawBytes = this.str.getBytes(rowBytes);
  25930. this.eof = !rawBytes.length;
  25931. if (this.eof) {
  25932. return;
  25933. }
  25934. var bufferLength = this.bufferLength;
  25935. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25936. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  25937. if (prevRow.length === 0) {
  25938. prevRow = new Uint8Array(rowBytes);
  25939. }
  25940. var i, j = bufferLength, up, c;
  25941. switch (predictor) {
  25942. case 0:
  25943. for (i = 0; i < rowBytes; ++i) {
  25944. buffer[j++] = rawBytes[i];
  25945. }
  25946. break;
  25947. case 1:
  25948. for (i = 0; i < pixBytes; ++i) {
  25949. buffer[j++] = rawBytes[i];
  25950. }
  25951. for (; i < rowBytes; ++i) {
  25952. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  25953. j++;
  25954. }
  25955. break;
  25956. case 2:
  25957. for (i = 0; i < rowBytes; ++i) {
  25958. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  25959. }
  25960. break;
  25961. case 3:
  25962. for (i = 0; i < pixBytes; ++i) {
  25963. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  25964. }
  25965. for (; i < rowBytes; ++i) {
  25966. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  25967. j++;
  25968. }
  25969. break;
  25970. case 4:
  25971. for (i = 0; i < pixBytes; ++i) {
  25972. up = prevRow[i];
  25973. c = rawBytes[i];
  25974. buffer[j++] = up + c;
  25975. }
  25976. for (; i < rowBytes; ++i) {
  25977. up = prevRow[i];
  25978. var upLeft = prevRow[i - pixBytes];
  25979. var left = buffer[j - pixBytes];
  25980. var p = left + up - upLeft;
  25981. var pa = p - left;
  25982. if (pa < 0) {
  25983. pa = -pa;
  25984. }
  25985. var pb = p - up;
  25986. if (pb < 0) {
  25987. pb = -pb;
  25988. }
  25989. var pc = p - upLeft;
  25990. if (pc < 0) {
  25991. pc = -pc;
  25992. }
  25993. c = rawBytes[i];
  25994. if (pa <= pb && pa <= pc) {
  25995. buffer[j++] = left + c;
  25996. } else if (pb <= pc) {
  25997. buffer[j++] = up + c;
  25998. } else {
  25999. buffer[j++] = upLeft + c;
  26000. }
  26001. }
  26002. break;
  26003. default:
  26004. error('Unsupported predictor: ' + predictor);
  26005. }
  26006. this.bufferLength += rowBytes;
  26007. };
  26008. return PredictorStream;
  26009. }();
  26010. var JpegStream = function JpegStreamClosure() {
  26011. function JpegStream(stream, maybeLength, dict, params) {
  26012. var ch;
  26013. while ((ch = stream.getByte()) !== -1) {
  26014. if (ch === 0xFF) {
  26015. stream.skip(-1);
  26016. break;
  26017. }
  26018. }
  26019. this.stream = stream;
  26020. this.maybeLength = maybeLength;
  26021. this.dict = dict;
  26022. this.params = params;
  26023. DecodeStream.call(this, maybeLength);
  26024. }
  26025. JpegStream.prototype = Object.create(DecodeStream.prototype);
  26026. Object.defineProperty(JpegStream.prototype, 'bytes', {
  26027. get: function JpegStream_bytes() {
  26028. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26029. },
  26030. configurable: true
  26031. });
  26032. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  26033. if (this.bufferLength) {
  26034. return;
  26035. }
  26036. var jpegImage = new JpegImage();
  26037. var decodeArr = this.dict.getArray('Decode', 'D');
  26038. if (this.forceRGB && isArray(decodeArr)) {
  26039. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  26040. var decodeArrLength = decodeArr.length;
  26041. var transform = new Int32Array(decodeArrLength);
  26042. var transformNeeded = false;
  26043. var maxValue = (1 << bitsPerComponent) - 1;
  26044. for (var i = 0; i < decodeArrLength; i += 2) {
  26045. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  26046. transform[i + 1] = decodeArr[i] * maxValue | 0;
  26047. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  26048. transformNeeded = true;
  26049. }
  26050. }
  26051. if (transformNeeded) {
  26052. jpegImage.decodeTransform = transform;
  26053. }
  26054. }
  26055. if (isDict(this.params)) {
  26056. var colorTransform = this.params.get('ColorTransform');
  26057. if (isInt(colorTransform)) {
  26058. jpegImage.colorTransform = colorTransform;
  26059. }
  26060. }
  26061. jpegImage.parse(this.bytes);
  26062. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  26063. this.buffer = data;
  26064. this.bufferLength = data.length;
  26065. this.eof = true;
  26066. };
  26067. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  26068. this.ensureBuffer();
  26069. return this.buffer;
  26070. };
  26071. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  26072. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  26073. };
  26074. return JpegStream;
  26075. }();
  26076. var JpxStream = function JpxStreamClosure() {
  26077. function JpxStream(stream, maybeLength, dict, params) {
  26078. this.stream = stream;
  26079. this.maybeLength = maybeLength;
  26080. this.dict = dict;
  26081. this.params = params;
  26082. DecodeStream.call(this, maybeLength);
  26083. }
  26084. JpxStream.prototype = Object.create(DecodeStream.prototype);
  26085. Object.defineProperty(JpxStream.prototype, 'bytes', {
  26086. get: function JpxStream_bytes() {
  26087. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26088. },
  26089. configurable: true
  26090. });
  26091. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  26092. if (this.bufferLength) {
  26093. return;
  26094. }
  26095. var jpxImage = new JpxImage();
  26096. jpxImage.parse(this.bytes);
  26097. var width = jpxImage.width;
  26098. var height = jpxImage.height;
  26099. var componentsCount = jpxImage.componentsCount;
  26100. var tileCount = jpxImage.tiles.length;
  26101. if (tileCount === 1) {
  26102. this.buffer = jpxImage.tiles[0].items;
  26103. } else {
  26104. var data = new Uint8Array(width * height * componentsCount);
  26105. for (var k = 0; k < tileCount; k++) {
  26106. var tileComponents = jpxImage.tiles[k];
  26107. var tileWidth = tileComponents.width;
  26108. var tileHeight = tileComponents.height;
  26109. var tileLeft = tileComponents.left;
  26110. var tileTop = tileComponents.top;
  26111. var src = tileComponents.items;
  26112. var srcPosition = 0;
  26113. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  26114. var imgRowSize = width * componentsCount;
  26115. var tileRowSize = tileWidth * componentsCount;
  26116. for (var j = 0; j < tileHeight; j++) {
  26117. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  26118. data.set(rowBytes, dataPosition);
  26119. srcPosition += tileRowSize;
  26120. dataPosition += imgRowSize;
  26121. }
  26122. }
  26123. this.buffer = data;
  26124. }
  26125. this.bufferLength = this.buffer.length;
  26126. this.eof = true;
  26127. };
  26128. return JpxStream;
  26129. }();
  26130. var Jbig2Stream = function Jbig2StreamClosure() {
  26131. function Jbig2Stream(stream, maybeLength, dict, params) {
  26132. this.stream = stream;
  26133. this.maybeLength = maybeLength;
  26134. this.dict = dict;
  26135. this.params = params;
  26136. DecodeStream.call(this, maybeLength);
  26137. }
  26138. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26139. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26140. get: function Jbig2Stream_bytes() {
  26141. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26142. },
  26143. configurable: true
  26144. });
  26145. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26146. if (this.bufferLength) {
  26147. return;
  26148. }
  26149. var jbig2Image = new Jbig2Image();
  26150. var chunks = [];
  26151. if (isDict(this.params)) {
  26152. var globalsStream = this.params.get('JBIG2Globals');
  26153. if (isStream(globalsStream)) {
  26154. var globals = globalsStream.getBytes();
  26155. chunks.push({
  26156. data: globals,
  26157. start: 0,
  26158. end: globals.length
  26159. });
  26160. }
  26161. }
  26162. chunks.push({
  26163. data: this.bytes,
  26164. start: 0,
  26165. end: this.bytes.length
  26166. });
  26167. var data = jbig2Image.parseChunks(chunks);
  26168. var dataLength = data.length;
  26169. for (var i = 0; i < dataLength; i++) {
  26170. data[i] ^= 0xFF;
  26171. }
  26172. this.buffer = data;
  26173. this.bufferLength = dataLength;
  26174. this.eof = true;
  26175. };
  26176. return Jbig2Stream;
  26177. }();
  26178. var DecryptStream = function DecryptStreamClosure() {
  26179. function DecryptStream(str, maybeLength, decrypt) {
  26180. this.str = str;
  26181. this.dict = str.dict;
  26182. this.decrypt = decrypt;
  26183. this.nextChunk = null;
  26184. this.initialized = false;
  26185. DecodeStream.call(this, maybeLength);
  26186. }
  26187. var chunkSize = 512;
  26188. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26189. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26190. var chunk;
  26191. if (this.initialized) {
  26192. chunk = this.nextChunk;
  26193. } else {
  26194. chunk = this.str.getBytes(chunkSize);
  26195. this.initialized = true;
  26196. }
  26197. if (!chunk || chunk.length === 0) {
  26198. this.eof = true;
  26199. return;
  26200. }
  26201. this.nextChunk = this.str.getBytes(chunkSize);
  26202. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26203. var decrypt = this.decrypt;
  26204. chunk = decrypt(chunk, !hasMoreData);
  26205. var bufferLength = this.bufferLength;
  26206. var i, n = chunk.length;
  26207. var buffer = this.ensureBuffer(bufferLength + n);
  26208. for (i = 0; i < n; i++) {
  26209. buffer[bufferLength++] = chunk[i];
  26210. }
  26211. this.bufferLength = bufferLength;
  26212. };
  26213. return DecryptStream;
  26214. }();
  26215. var Ascii85Stream = function Ascii85StreamClosure() {
  26216. function Ascii85Stream(str, maybeLength) {
  26217. this.str = str;
  26218. this.dict = str.dict;
  26219. this.input = new Uint8Array(5);
  26220. if (maybeLength) {
  26221. maybeLength = 0.8 * maybeLength;
  26222. }
  26223. DecodeStream.call(this, maybeLength);
  26224. }
  26225. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26226. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26227. var TILDA_CHAR = 0x7E;
  26228. var Z_LOWER_CHAR = 0x7A;
  26229. var EOF = -1;
  26230. var str = this.str;
  26231. var c = str.getByte();
  26232. while (isSpace(c)) {
  26233. c = str.getByte();
  26234. }
  26235. if (c === EOF || c === TILDA_CHAR) {
  26236. this.eof = true;
  26237. return;
  26238. }
  26239. var bufferLength = this.bufferLength, buffer;
  26240. var i;
  26241. if (c === Z_LOWER_CHAR) {
  26242. buffer = this.ensureBuffer(bufferLength + 4);
  26243. for (i = 0; i < 4; ++i) {
  26244. buffer[bufferLength + i] = 0;
  26245. }
  26246. this.bufferLength += 4;
  26247. } else {
  26248. var input = this.input;
  26249. input[0] = c;
  26250. for (i = 1; i < 5; ++i) {
  26251. c = str.getByte();
  26252. while (isSpace(c)) {
  26253. c = str.getByte();
  26254. }
  26255. input[i] = c;
  26256. if (c === EOF || c === TILDA_CHAR) {
  26257. break;
  26258. }
  26259. }
  26260. buffer = this.ensureBuffer(bufferLength + i - 1);
  26261. this.bufferLength += i - 1;
  26262. if (i < 5) {
  26263. for (; i < 5; ++i) {
  26264. input[i] = 0x21 + 84;
  26265. }
  26266. this.eof = true;
  26267. }
  26268. var t = 0;
  26269. for (i = 0; i < 5; ++i) {
  26270. t = t * 85 + (input[i] - 0x21);
  26271. }
  26272. for (i = 3; i >= 0; --i) {
  26273. buffer[bufferLength + i] = t & 0xFF;
  26274. t >>= 8;
  26275. }
  26276. }
  26277. };
  26278. return Ascii85Stream;
  26279. }();
  26280. var AsciiHexStream = function AsciiHexStreamClosure() {
  26281. function AsciiHexStream(str, maybeLength) {
  26282. this.str = str;
  26283. this.dict = str.dict;
  26284. this.firstDigit = -1;
  26285. if (maybeLength) {
  26286. maybeLength = 0.5 * maybeLength;
  26287. }
  26288. DecodeStream.call(this, maybeLength);
  26289. }
  26290. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26291. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26292. var UPSTREAM_BLOCK_SIZE = 8000;
  26293. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26294. if (!bytes.length) {
  26295. this.eof = true;
  26296. return;
  26297. }
  26298. var maxDecodeLength = bytes.length + 1 >> 1;
  26299. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26300. var bufferLength = this.bufferLength;
  26301. var firstDigit = this.firstDigit;
  26302. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26303. var ch = bytes[i], digit;
  26304. if (ch >= 0x30 && ch <= 0x39) {
  26305. digit = ch & 0x0F;
  26306. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26307. digit = (ch & 0x0F) + 9;
  26308. } else if (ch === 0x3E) {
  26309. this.eof = true;
  26310. break;
  26311. } else {
  26312. continue;
  26313. }
  26314. if (firstDigit < 0) {
  26315. firstDigit = digit;
  26316. } else {
  26317. buffer[bufferLength++] = firstDigit << 4 | digit;
  26318. firstDigit = -1;
  26319. }
  26320. }
  26321. if (firstDigit >= 0 && this.eof) {
  26322. buffer[bufferLength++] = firstDigit << 4;
  26323. firstDigit = -1;
  26324. }
  26325. this.firstDigit = firstDigit;
  26326. this.bufferLength = bufferLength;
  26327. };
  26328. return AsciiHexStream;
  26329. }();
  26330. var RunLengthStream = function RunLengthStreamClosure() {
  26331. function RunLengthStream(str, maybeLength) {
  26332. this.str = str;
  26333. this.dict = str.dict;
  26334. DecodeStream.call(this, maybeLength);
  26335. }
  26336. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26337. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26338. var repeatHeader = this.str.getBytes(2);
  26339. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26340. this.eof = true;
  26341. return;
  26342. }
  26343. var buffer;
  26344. var bufferLength = this.bufferLength;
  26345. var n = repeatHeader[0];
  26346. if (n < 128) {
  26347. buffer = this.ensureBuffer(bufferLength + n + 1);
  26348. buffer[bufferLength++] = repeatHeader[1];
  26349. if (n > 0) {
  26350. var source = this.str.getBytes(n);
  26351. buffer.set(source, bufferLength);
  26352. bufferLength += n;
  26353. }
  26354. } else {
  26355. n = 257 - n;
  26356. var b = repeatHeader[1];
  26357. buffer = this.ensureBuffer(bufferLength + n + 1);
  26358. for (var i = 0; i < n; i++) {
  26359. buffer[bufferLength++] = b;
  26360. }
  26361. }
  26362. this.bufferLength = bufferLength;
  26363. };
  26364. return RunLengthStream;
  26365. }();
  26366. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26367. var ccittEOL = -2;
  26368. var ccittEOF = -1;
  26369. var twoDimPass = 0;
  26370. var twoDimHoriz = 1;
  26371. var twoDimVert0 = 2;
  26372. var twoDimVertR1 = 3;
  26373. var twoDimVertL1 = 4;
  26374. var twoDimVertR2 = 5;
  26375. var twoDimVertL2 = 6;
  26376. var twoDimVertR3 = 7;
  26377. var twoDimVertL3 = 8;
  26378. var twoDimTable = [
  26379. [
  26380. -1,
  26381. -1
  26382. ],
  26383. [
  26384. -1,
  26385. -1
  26386. ],
  26387. [
  26388. 7,
  26389. twoDimVertL3
  26390. ],
  26391. [
  26392. 7,
  26393. twoDimVertR3
  26394. ],
  26395. [
  26396. 6,
  26397. twoDimVertL2
  26398. ],
  26399. [
  26400. 6,
  26401. twoDimVertL2
  26402. ],
  26403. [
  26404. 6,
  26405. twoDimVertR2
  26406. ],
  26407. [
  26408. 6,
  26409. twoDimVertR2
  26410. ],
  26411. [
  26412. 4,
  26413. twoDimPass
  26414. ],
  26415. [
  26416. 4,
  26417. twoDimPass
  26418. ],
  26419. [
  26420. 4,
  26421. twoDimPass
  26422. ],
  26423. [
  26424. 4,
  26425. twoDimPass
  26426. ],
  26427. [
  26428. 4,
  26429. twoDimPass
  26430. ],
  26431. [
  26432. 4,
  26433. twoDimPass
  26434. ],
  26435. [
  26436. 4,
  26437. twoDimPass
  26438. ],
  26439. [
  26440. 4,
  26441. twoDimPass
  26442. ],
  26443. [
  26444. 3,
  26445. twoDimHoriz
  26446. ],
  26447. [
  26448. 3,
  26449. twoDimHoriz
  26450. ],
  26451. [
  26452. 3,
  26453. twoDimHoriz
  26454. ],
  26455. [
  26456. 3,
  26457. twoDimHoriz
  26458. ],
  26459. [
  26460. 3,
  26461. twoDimHoriz
  26462. ],
  26463. [
  26464. 3,
  26465. twoDimHoriz
  26466. ],
  26467. [
  26468. 3,
  26469. twoDimHoriz
  26470. ],
  26471. [
  26472. 3,
  26473. twoDimHoriz
  26474. ],
  26475. [
  26476. 3,
  26477. twoDimHoriz
  26478. ],
  26479. [
  26480. 3,
  26481. twoDimHoriz
  26482. ],
  26483. [
  26484. 3,
  26485. twoDimHoriz
  26486. ],
  26487. [
  26488. 3,
  26489. twoDimHoriz
  26490. ],
  26491. [
  26492. 3,
  26493. twoDimHoriz
  26494. ],
  26495. [
  26496. 3,
  26497. twoDimHoriz
  26498. ],
  26499. [
  26500. 3,
  26501. twoDimHoriz
  26502. ],
  26503. [
  26504. 3,
  26505. twoDimHoriz
  26506. ],
  26507. [
  26508. 3,
  26509. twoDimVertL1
  26510. ],
  26511. [
  26512. 3,
  26513. twoDimVertL1
  26514. ],
  26515. [
  26516. 3,
  26517. twoDimVertL1
  26518. ],
  26519. [
  26520. 3,
  26521. twoDimVertL1
  26522. ],
  26523. [
  26524. 3,
  26525. twoDimVertL1
  26526. ],
  26527. [
  26528. 3,
  26529. twoDimVertL1
  26530. ],
  26531. [
  26532. 3,
  26533. twoDimVertL1
  26534. ],
  26535. [
  26536. 3,
  26537. twoDimVertL1
  26538. ],
  26539. [
  26540. 3,
  26541. twoDimVertL1
  26542. ],
  26543. [
  26544. 3,
  26545. twoDimVertL1
  26546. ],
  26547. [
  26548. 3,
  26549. twoDimVertL1
  26550. ],
  26551. [
  26552. 3,
  26553. twoDimVertL1
  26554. ],
  26555. [
  26556. 3,
  26557. twoDimVertL1
  26558. ],
  26559. [
  26560. 3,
  26561. twoDimVertL1
  26562. ],
  26563. [
  26564. 3,
  26565. twoDimVertL1
  26566. ],
  26567. [
  26568. 3,
  26569. twoDimVertL1
  26570. ],
  26571. [
  26572. 3,
  26573. twoDimVertR1
  26574. ],
  26575. [
  26576. 3,
  26577. twoDimVertR1
  26578. ],
  26579. [
  26580. 3,
  26581. twoDimVertR1
  26582. ],
  26583. [
  26584. 3,
  26585. twoDimVertR1
  26586. ],
  26587. [
  26588. 3,
  26589. twoDimVertR1
  26590. ],
  26591. [
  26592. 3,
  26593. twoDimVertR1
  26594. ],
  26595. [
  26596. 3,
  26597. twoDimVertR1
  26598. ],
  26599. [
  26600. 3,
  26601. twoDimVertR1
  26602. ],
  26603. [
  26604. 3,
  26605. twoDimVertR1
  26606. ],
  26607. [
  26608. 3,
  26609. twoDimVertR1
  26610. ],
  26611. [
  26612. 3,
  26613. twoDimVertR1
  26614. ],
  26615. [
  26616. 3,
  26617. twoDimVertR1
  26618. ],
  26619. [
  26620. 3,
  26621. twoDimVertR1
  26622. ],
  26623. [
  26624. 3,
  26625. twoDimVertR1
  26626. ],
  26627. [
  26628. 3,
  26629. twoDimVertR1
  26630. ],
  26631. [
  26632. 3,
  26633. twoDimVertR1
  26634. ],
  26635. [
  26636. 1,
  26637. twoDimVert0
  26638. ],
  26639. [
  26640. 1,
  26641. twoDimVert0
  26642. ],
  26643. [
  26644. 1,
  26645. twoDimVert0
  26646. ],
  26647. [
  26648. 1,
  26649. twoDimVert0
  26650. ],
  26651. [
  26652. 1,
  26653. twoDimVert0
  26654. ],
  26655. [
  26656. 1,
  26657. twoDimVert0
  26658. ],
  26659. [
  26660. 1,
  26661. twoDimVert0
  26662. ],
  26663. [
  26664. 1,
  26665. twoDimVert0
  26666. ],
  26667. [
  26668. 1,
  26669. twoDimVert0
  26670. ],
  26671. [
  26672. 1,
  26673. twoDimVert0
  26674. ],
  26675. [
  26676. 1,
  26677. twoDimVert0
  26678. ],
  26679. [
  26680. 1,
  26681. twoDimVert0
  26682. ],
  26683. [
  26684. 1,
  26685. twoDimVert0
  26686. ],
  26687. [
  26688. 1,
  26689. twoDimVert0
  26690. ],
  26691. [
  26692. 1,
  26693. twoDimVert0
  26694. ],
  26695. [
  26696. 1,
  26697. twoDimVert0
  26698. ],
  26699. [
  26700. 1,
  26701. twoDimVert0
  26702. ],
  26703. [
  26704. 1,
  26705. twoDimVert0
  26706. ],
  26707. [
  26708. 1,
  26709. twoDimVert0
  26710. ],
  26711. [
  26712. 1,
  26713. twoDimVert0
  26714. ],
  26715. [
  26716. 1,
  26717. twoDimVert0
  26718. ],
  26719. [
  26720. 1,
  26721. twoDimVert0
  26722. ],
  26723. [
  26724. 1,
  26725. twoDimVert0
  26726. ],
  26727. [
  26728. 1,
  26729. twoDimVert0
  26730. ],
  26731. [
  26732. 1,
  26733. twoDimVert0
  26734. ],
  26735. [
  26736. 1,
  26737. twoDimVert0
  26738. ],
  26739. [
  26740. 1,
  26741. twoDimVert0
  26742. ],
  26743. [
  26744. 1,
  26745. twoDimVert0
  26746. ],
  26747. [
  26748. 1,
  26749. twoDimVert0
  26750. ],
  26751. [
  26752. 1,
  26753. twoDimVert0
  26754. ],
  26755. [
  26756. 1,
  26757. twoDimVert0
  26758. ],
  26759. [
  26760. 1,
  26761. twoDimVert0
  26762. ],
  26763. [
  26764. 1,
  26765. twoDimVert0
  26766. ],
  26767. [
  26768. 1,
  26769. twoDimVert0
  26770. ],
  26771. [
  26772. 1,
  26773. twoDimVert0
  26774. ],
  26775. [
  26776. 1,
  26777. twoDimVert0
  26778. ],
  26779. [
  26780. 1,
  26781. twoDimVert0
  26782. ],
  26783. [
  26784. 1,
  26785. twoDimVert0
  26786. ],
  26787. [
  26788. 1,
  26789. twoDimVert0
  26790. ],
  26791. [
  26792. 1,
  26793. twoDimVert0
  26794. ],
  26795. [
  26796. 1,
  26797. twoDimVert0
  26798. ],
  26799. [
  26800. 1,
  26801. twoDimVert0
  26802. ],
  26803. [
  26804. 1,
  26805. twoDimVert0
  26806. ],
  26807. [
  26808. 1,
  26809. twoDimVert0
  26810. ],
  26811. [
  26812. 1,
  26813. twoDimVert0
  26814. ],
  26815. [
  26816. 1,
  26817. twoDimVert0
  26818. ],
  26819. [
  26820. 1,
  26821. twoDimVert0
  26822. ],
  26823. [
  26824. 1,
  26825. twoDimVert0
  26826. ],
  26827. [
  26828. 1,
  26829. twoDimVert0
  26830. ],
  26831. [
  26832. 1,
  26833. twoDimVert0
  26834. ],
  26835. [
  26836. 1,
  26837. twoDimVert0
  26838. ],
  26839. [
  26840. 1,
  26841. twoDimVert0
  26842. ],
  26843. [
  26844. 1,
  26845. twoDimVert0
  26846. ],
  26847. [
  26848. 1,
  26849. twoDimVert0
  26850. ],
  26851. [
  26852. 1,
  26853. twoDimVert0
  26854. ],
  26855. [
  26856. 1,
  26857. twoDimVert0
  26858. ],
  26859. [
  26860. 1,
  26861. twoDimVert0
  26862. ],
  26863. [
  26864. 1,
  26865. twoDimVert0
  26866. ],
  26867. [
  26868. 1,
  26869. twoDimVert0
  26870. ],
  26871. [
  26872. 1,
  26873. twoDimVert0
  26874. ],
  26875. [
  26876. 1,
  26877. twoDimVert0
  26878. ],
  26879. [
  26880. 1,
  26881. twoDimVert0
  26882. ],
  26883. [
  26884. 1,
  26885. twoDimVert0
  26886. ],
  26887. [
  26888. 1,
  26889. twoDimVert0
  26890. ]
  26891. ];
  26892. var whiteTable1 = [
  26893. [
  26894. -1,
  26895. -1
  26896. ],
  26897. [
  26898. 12,
  26899. ccittEOL
  26900. ],
  26901. [
  26902. -1,
  26903. -1
  26904. ],
  26905. [
  26906. -1,
  26907. -1
  26908. ],
  26909. [
  26910. -1,
  26911. -1
  26912. ],
  26913. [
  26914. -1,
  26915. -1
  26916. ],
  26917. [
  26918. -1,
  26919. -1
  26920. ],
  26921. [
  26922. -1,
  26923. -1
  26924. ],
  26925. [
  26926. -1,
  26927. -1
  26928. ],
  26929. [
  26930. -1,
  26931. -1
  26932. ],
  26933. [
  26934. -1,
  26935. -1
  26936. ],
  26937. [
  26938. -1,
  26939. -1
  26940. ],
  26941. [
  26942. -1,
  26943. -1
  26944. ],
  26945. [
  26946. -1,
  26947. -1
  26948. ],
  26949. [
  26950. -1,
  26951. -1
  26952. ],
  26953. [
  26954. -1,
  26955. -1
  26956. ],
  26957. [
  26958. 11,
  26959. 1792
  26960. ],
  26961. [
  26962. 11,
  26963. 1792
  26964. ],
  26965. [
  26966. 12,
  26967. 1984
  26968. ],
  26969. [
  26970. 12,
  26971. 2048
  26972. ],
  26973. [
  26974. 12,
  26975. 2112
  26976. ],
  26977. [
  26978. 12,
  26979. 2176
  26980. ],
  26981. [
  26982. 12,
  26983. 2240
  26984. ],
  26985. [
  26986. 12,
  26987. 2304
  26988. ],
  26989. [
  26990. 11,
  26991. 1856
  26992. ],
  26993. [
  26994. 11,
  26995. 1856
  26996. ],
  26997. [
  26998. 11,
  26999. 1920
  27000. ],
  27001. [
  27002. 11,
  27003. 1920
  27004. ],
  27005. [
  27006. 12,
  27007. 2368
  27008. ],
  27009. [
  27010. 12,
  27011. 2432
  27012. ],
  27013. [
  27014. 12,
  27015. 2496
  27016. ],
  27017. [
  27018. 12,
  27019. 2560
  27020. ]
  27021. ];
  27022. var whiteTable2 = [
  27023. [
  27024. -1,
  27025. -1
  27026. ],
  27027. [
  27028. -1,
  27029. -1
  27030. ],
  27031. [
  27032. -1,
  27033. -1
  27034. ],
  27035. [
  27036. -1,
  27037. -1
  27038. ],
  27039. [
  27040. 8,
  27041. 29
  27042. ],
  27043. [
  27044. 8,
  27045. 29
  27046. ],
  27047. [
  27048. 8,
  27049. 30
  27050. ],
  27051. [
  27052. 8,
  27053. 30
  27054. ],
  27055. [
  27056. 8,
  27057. 45
  27058. ],
  27059. [
  27060. 8,
  27061. 45
  27062. ],
  27063. [
  27064. 8,
  27065. 46
  27066. ],
  27067. [
  27068. 8,
  27069. 46
  27070. ],
  27071. [
  27072. 7,
  27073. 22
  27074. ],
  27075. [
  27076. 7,
  27077. 22
  27078. ],
  27079. [
  27080. 7,
  27081. 22
  27082. ],
  27083. [
  27084. 7,
  27085. 22
  27086. ],
  27087. [
  27088. 7,
  27089. 23
  27090. ],
  27091. [
  27092. 7,
  27093. 23
  27094. ],
  27095. [
  27096. 7,
  27097. 23
  27098. ],
  27099. [
  27100. 7,
  27101. 23
  27102. ],
  27103. [
  27104. 8,
  27105. 47
  27106. ],
  27107. [
  27108. 8,
  27109. 47
  27110. ],
  27111. [
  27112. 8,
  27113. 48
  27114. ],
  27115. [
  27116. 8,
  27117. 48
  27118. ],
  27119. [
  27120. 6,
  27121. 13
  27122. ],
  27123. [
  27124. 6,
  27125. 13
  27126. ],
  27127. [
  27128. 6,
  27129. 13
  27130. ],
  27131. [
  27132. 6,
  27133. 13
  27134. ],
  27135. [
  27136. 6,
  27137. 13
  27138. ],
  27139. [
  27140. 6,
  27141. 13
  27142. ],
  27143. [
  27144. 6,
  27145. 13
  27146. ],
  27147. [
  27148. 6,
  27149. 13
  27150. ],
  27151. [
  27152. 7,
  27153. 20
  27154. ],
  27155. [
  27156. 7,
  27157. 20
  27158. ],
  27159. [
  27160. 7,
  27161. 20
  27162. ],
  27163. [
  27164. 7,
  27165. 20
  27166. ],
  27167. [
  27168. 8,
  27169. 33
  27170. ],
  27171. [
  27172. 8,
  27173. 33
  27174. ],
  27175. [
  27176. 8,
  27177. 34
  27178. ],
  27179. [
  27180. 8,
  27181. 34
  27182. ],
  27183. [
  27184. 8,
  27185. 35
  27186. ],
  27187. [
  27188. 8,
  27189. 35
  27190. ],
  27191. [
  27192. 8,
  27193. 36
  27194. ],
  27195. [
  27196. 8,
  27197. 36
  27198. ],
  27199. [
  27200. 8,
  27201. 37
  27202. ],
  27203. [
  27204. 8,
  27205. 37
  27206. ],
  27207. [
  27208. 8,
  27209. 38
  27210. ],
  27211. [
  27212. 8,
  27213. 38
  27214. ],
  27215. [
  27216. 7,
  27217. 19
  27218. ],
  27219. [
  27220. 7,
  27221. 19
  27222. ],
  27223. [
  27224. 7,
  27225. 19
  27226. ],
  27227. [
  27228. 7,
  27229. 19
  27230. ],
  27231. [
  27232. 8,
  27233. 31
  27234. ],
  27235. [
  27236. 8,
  27237. 31
  27238. ],
  27239. [
  27240. 8,
  27241. 32
  27242. ],
  27243. [
  27244. 8,
  27245. 32
  27246. ],
  27247. [
  27248. 6,
  27249. 1
  27250. ],
  27251. [
  27252. 6,
  27253. 1
  27254. ],
  27255. [
  27256. 6,
  27257. 1
  27258. ],
  27259. [
  27260. 6,
  27261. 1
  27262. ],
  27263. [
  27264. 6,
  27265. 1
  27266. ],
  27267. [
  27268. 6,
  27269. 1
  27270. ],
  27271. [
  27272. 6,
  27273. 1
  27274. ],
  27275. [
  27276. 6,
  27277. 1
  27278. ],
  27279. [
  27280. 6,
  27281. 12
  27282. ],
  27283. [
  27284. 6,
  27285. 12
  27286. ],
  27287. [
  27288. 6,
  27289. 12
  27290. ],
  27291. [
  27292. 6,
  27293. 12
  27294. ],
  27295. [
  27296. 6,
  27297. 12
  27298. ],
  27299. [
  27300. 6,
  27301. 12
  27302. ],
  27303. [
  27304. 6,
  27305. 12
  27306. ],
  27307. [
  27308. 6,
  27309. 12
  27310. ],
  27311. [
  27312. 8,
  27313. 53
  27314. ],
  27315. [
  27316. 8,
  27317. 53
  27318. ],
  27319. [
  27320. 8,
  27321. 54
  27322. ],
  27323. [
  27324. 8,
  27325. 54
  27326. ],
  27327. [
  27328. 7,
  27329. 26
  27330. ],
  27331. [
  27332. 7,
  27333. 26
  27334. ],
  27335. [
  27336. 7,
  27337. 26
  27338. ],
  27339. [
  27340. 7,
  27341. 26
  27342. ],
  27343. [
  27344. 8,
  27345. 39
  27346. ],
  27347. [
  27348. 8,
  27349. 39
  27350. ],
  27351. [
  27352. 8,
  27353. 40
  27354. ],
  27355. [
  27356. 8,
  27357. 40
  27358. ],
  27359. [
  27360. 8,
  27361. 41
  27362. ],
  27363. [
  27364. 8,
  27365. 41
  27366. ],
  27367. [
  27368. 8,
  27369. 42
  27370. ],
  27371. [
  27372. 8,
  27373. 42
  27374. ],
  27375. [
  27376. 8,
  27377. 43
  27378. ],
  27379. [
  27380. 8,
  27381. 43
  27382. ],
  27383. [
  27384. 8,
  27385. 44
  27386. ],
  27387. [
  27388. 8,
  27389. 44
  27390. ],
  27391. [
  27392. 7,
  27393. 21
  27394. ],
  27395. [
  27396. 7,
  27397. 21
  27398. ],
  27399. [
  27400. 7,
  27401. 21
  27402. ],
  27403. [
  27404. 7,
  27405. 21
  27406. ],
  27407. [
  27408. 7,
  27409. 28
  27410. ],
  27411. [
  27412. 7,
  27413. 28
  27414. ],
  27415. [
  27416. 7,
  27417. 28
  27418. ],
  27419. [
  27420. 7,
  27421. 28
  27422. ],
  27423. [
  27424. 8,
  27425. 61
  27426. ],
  27427. [
  27428. 8,
  27429. 61
  27430. ],
  27431. [
  27432. 8,
  27433. 62
  27434. ],
  27435. [
  27436. 8,
  27437. 62
  27438. ],
  27439. [
  27440. 8,
  27441. 63
  27442. ],
  27443. [
  27444. 8,
  27445. 63
  27446. ],
  27447. [
  27448. 8,
  27449. 0
  27450. ],
  27451. [
  27452. 8,
  27453. 0
  27454. ],
  27455. [
  27456. 8,
  27457. 320
  27458. ],
  27459. [
  27460. 8,
  27461. 320
  27462. ],
  27463. [
  27464. 8,
  27465. 384
  27466. ],
  27467. [
  27468. 8,
  27469. 384
  27470. ],
  27471. [
  27472. 5,
  27473. 10
  27474. ],
  27475. [
  27476. 5,
  27477. 10
  27478. ],
  27479. [
  27480. 5,
  27481. 10
  27482. ],
  27483. [
  27484. 5,
  27485. 10
  27486. ],
  27487. [
  27488. 5,
  27489. 10
  27490. ],
  27491. [
  27492. 5,
  27493. 10
  27494. ],
  27495. [
  27496. 5,
  27497. 10
  27498. ],
  27499. [
  27500. 5,
  27501. 10
  27502. ],
  27503. [
  27504. 5,
  27505. 10
  27506. ],
  27507. [
  27508. 5,
  27509. 10
  27510. ],
  27511. [
  27512. 5,
  27513. 10
  27514. ],
  27515. [
  27516. 5,
  27517. 10
  27518. ],
  27519. [
  27520. 5,
  27521. 10
  27522. ],
  27523. [
  27524. 5,
  27525. 10
  27526. ],
  27527. [
  27528. 5,
  27529. 10
  27530. ],
  27531. [
  27532. 5,
  27533. 10
  27534. ],
  27535. [
  27536. 5,
  27537. 11
  27538. ],
  27539. [
  27540. 5,
  27541. 11
  27542. ],
  27543. [
  27544. 5,
  27545. 11
  27546. ],
  27547. [
  27548. 5,
  27549. 11
  27550. ],
  27551. [
  27552. 5,
  27553. 11
  27554. ],
  27555. [
  27556. 5,
  27557. 11
  27558. ],
  27559. [
  27560. 5,
  27561. 11
  27562. ],
  27563. [
  27564. 5,
  27565. 11
  27566. ],
  27567. [
  27568. 5,
  27569. 11
  27570. ],
  27571. [
  27572. 5,
  27573. 11
  27574. ],
  27575. [
  27576. 5,
  27577. 11
  27578. ],
  27579. [
  27580. 5,
  27581. 11
  27582. ],
  27583. [
  27584. 5,
  27585. 11
  27586. ],
  27587. [
  27588. 5,
  27589. 11
  27590. ],
  27591. [
  27592. 5,
  27593. 11
  27594. ],
  27595. [
  27596. 5,
  27597. 11
  27598. ],
  27599. [
  27600. 7,
  27601. 27
  27602. ],
  27603. [
  27604. 7,
  27605. 27
  27606. ],
  27607. [
  27608. 7,
  27609. 27
  27610. ],
  27611. [
  27612. 7,
  27613. 27
  27614. ],
  27615. [
  27616. 8,
  27617. 59
  27618. ],
  27619. [
  27620. 8,
  27621. 59
  27622. ],
  27623. [
  27624. 8,
  27625. 60
  27626. ],
  27627. [
  27628. 8,
  27629. 60
  27630. ],
  27631. [
  27632. 9,
  27633. 1472
  27634. ],
  27635. [
  27636. 9,
  27637. 1536
  27638. ],
  27639. [
  27640. 9,
  27641. 1600
  27642. ],
  27643. [
  27644. 9,
  27645. 1728
  27646. ],
  27647. [
  27648. 7,
  27649. 18
  27650. ],
  27651. [
  27652. 7,
  27653. 18
  27654. ],
  27655. [
  27656. 7,
  27657. 18
  27658. ],
  27659. [
  27660. 7,
  27661. 18
  27662. ],
  27663. [
  27664. 7,
  27665. 24
  27666. ],
  27667. [
  27668. 7,
  27669. 24
  27670. ],
  27671. [
  27672. 7,
  27673. 24
  27674. ],
  27675. [
  27676. 7,
  27677. 24
  27678. ],
  27679. [
  27680. 8,
  27681. 49
  27682. ],
  27683. [
  27684. 8,
  27685. 49
  27686. ],
  27687. [
  27688. 8,
  27689. 50
  27690. ],
  27691. [
  27692. 8,
  27693. 50
  27694. ],
  27695. [
  27696. 8,
  27697. 51
  27698. ],
  27699. [
  27700. 8,
  27701. 51
  27702. ],
  27703. [
  27704. 8,
  27705. 52
  27706. ],
  27707. [
  27708. 8,
  27709. 52
  27710. ],
  27711. [
  27712. 7,
  27713. 25
  27714. ],
  27715. [
  27716. 7,
  27717. 25
  27718. ],
  27719. [
  27720. 7,
  27721. 25
  27722. ],
  27723. [
  27724. 7,
  27725. 25
  27726. ],
  27727. [
  27728. 8,
  27729. 55
  27730. ],
  27731. [
  27732. 8,
  27733. 55
  27734. ],
  27735. [
  27736. 8,
  27737. 56
  27738. ],
  27739. [
  27740. 8,
  27741. 56
  27742. ],
  27743. [
  27744. 8,
  27745. 57
  27746. ],
  27747. [
  27748. 8,
  27749. 57
  27750. ],
  27751. [
  27752. 8,
  27753. 58
  27754. ],
  27755. [
  27756. 8,
  27757. 58
  27758. ],
  27759. [
  27760. 6,
  27761. 192
  27762. ],
  27763. [
  27764. 6,
  27765. 192
  27766. ],
  27767. [
  27768. 6,
  27769. 192
  27770. ],
  27771. [
  27772. 6,
  27773. 192
  27774. ],
  27775. [
  27776. 6,
  27777. 192
  27778. ],
  27779. [
  27780. 6,
  27781. 192
  27782. ],
  27783. [
  27784. 6,
  27785. 192
  27786. ],
  27787. [
  27788. 6,
  27789. 192
  27790. ],
  27791. [
  27792. 6,
  27793. 1664
  27794. ],
  27795. [
  27796. 6,
  27797. 1664
  27798. ],
  27799. [
  27800. 6,
  27801. 1664
  27802. ],
  27803. [
  27804. 6,
  27805. 1664
  27806. ],
  27807. [
  27808. 6,
  27809. 1664
  27810. ],
  27811. [
  27812. 6,
  27813. 1664
  27814. ],
  27815. [
  27816. 6,
  27817. 1664
  27818. ],
  27819. [
  27820. 6,
  27821. 1664
  27822. ],
  27823. [
  27824. 8,
  27825. 448
  27826. ],
  27827. [
  27828. 8,
  27829. 448
  27830. ],
  27831. [
  27832. 8,
  27833. 512
  27834. ],
  27835. [
  27836. 8,
  27837. 512
  27838. ],
  27839. [
  27840. 9,
  27841. 704
  27842. ],
  27843. [
  27844. 9,
  27845. 768
  27846. ],
  27847. [
  27848. 8,
  27849. 640
  27850. ],
  27851. [
  27852. 8,
  27853. 640
  27854. ],
  27855. [
  27856. 8,
  27857. 576
  27858. ],
  27859. [
  27860. 8,
  27861. 576
  27862. ],
  27863. [
  27864. 9,
  27865. 832
  27866. ],
  27867. [
  27868. 9,
  27869. 896
  27870. ],
  27871. [
  27872. 9,
  27873. 960
  27874. ],
  27875. [
  27876. 9,
  27877. 1024
  27878. ],
  27879. [
  27880. 9,
  27881. 1088
  27882. ],
  27883. [
  27884. 9,
  27885. 1152
  27886. ],
  27887. [
  27888. 9,
  27889. 1216
  27890. ],
  27891. [
  27892. 9,
  27893. 1280
  27894. ],
  27895. [
  27896. 9,
  27897. 1344
  27898. ],
  27899. [
  27900. 9,
  27901. 1408
  27902. ],
  27903. [
  27904. 7,
  27905. 256
  27906. ],
  27907. [
  27908. 7,
  27909. 256
  27910. ],
  27911. [
  27912. 7,
  27913. 256
  27914. ],
  27915. [
  27916. 7,
  27917. 256
  27918. ],
  27919. [
  27920. 4,
  27921. 2
  27922. ],
  27923. [
  27924. 4,
  27925. 2
  27926. ],
  27927. [
  27928. 4,
  27929. 2
  27930. ],
  27931. [
  27932. 4,
  27933. 2
  27934. ],
  27935. [
  27936. 4,
  27937. 2
  27938. ],
  27939. [
  27940. 4,
  27941. 2
  27942. ],
  27943. [
  27944. 4,
  27945. 2
  27946. ],
  27947. [
  27948. 4,
  27949. 2
  27950. ],
  27951. [
  27952. 4,
  27953. 2
  27954. ],
  27955. [
  27956. 4,
  27957. 2
  27958. ],
  27959. [
  27960. 4,
  27961. 2
  27962. ],
  27963. [
  27964. 4,
  27965. 2
  27966. ],
  27967. [
  27968. 4,
  27969. 2
  27970. ],
  27971. [
  27972. 4,
  27973. 2
  27974. ],
  27975. [
  27976. 4,
  27977. 2
  27978. ],
  27979. [
  27980. 4,
  27981. 2
  27982. ],
  27983. [
  27984. 4,
  27985. 2
  27986. ],
  27987. [
  27988. 4,
  27989. 2
  27990. ],
  27991. [
  27992. 4,
  27993. 2
  27994. ],
  27995. [
  27996. 4,
  27997. 2
  27998. ],
  27999. [
  28000. 4,
  28001. 2
  28002. ],
  28003. [
  28004. 4,
  28005. 2
  28006. ],
  28007. [
  28008. 4,
  28009. 2
  28010. ],
  28011. [
  28012. 4,
  28013. 2
  28014. ],
  28015. [
  28016. 4,
  28017. 2
  28018. ],
  28019. [
  28020. 4,
  28021. 2
  28022. ],
  28023. [
  28024. 4,
  28025. 2
  28026. ],
  28027. [
  28028. 4,
  28029. 2
  28030. ],
  28031. [
  28032. 4,
  28033. 2
  28034. ],
  28035. [
  28036. 4,
  28037. 2
  28038. ],
  28039. [
  28040. 4,
  28041. 2
  28042. ],
  28043. [
  28044. 4,
  28045. 2
  28046. ],
  28047. [
  28048. 4,
  28049. 3
  28050. ],
  28051. [
  28052. 4,
  28053. 3
  28054. ],
  28055. [
  28056. 4,
  28057. 3
  28058. ],
  28059. [
  28060. 4,
  28061. 3
  28062. ],
  28063. [
  28064. 4,
  28065. 3
  28066. ],
  28067. [
  28068. 4,
  28069. 3
  28070. ],
  28071. [
  28072. 4,
  28073. 3
  28074. ],
  28075. [
  28076. 4,
  28077. 3
  28078. ],
  28079. [
  28080. 4,
  28081. 3
  28082. ],
  28083. [
  28084. 4,
  28085. 3
  28086. ],
  28087. [
  28088. 4,
  28089. 3
  28090. ],
  28091. [
  28092. 4,
  28093. 3
  28094. ],
  28095. [
  28096. 4,
  28097. 3
  28098. ],
  28099. [
  28100. 4,
  28101. 3
  28102. ],
  28103. [
  28104. 4,
  28105. 3
  28106. ],
  28107. [
  28108. 4,
  28109. 3
  28110. ],
  28111. [
  28112. 4,
  28113. 3
  28114. ],
  28115. [
  28116. 4,
  28117. 3
  28118. ],
  28119. [
  28120. 4,
  28121. 3
  28122. ],
  28123. [
  28124. 4,
  28125. 3
  28126. ],
  28127. [
  28128. 4,
  28129. 3
  28130. ],
  28131. [
  28132. 4,
  28133. 3
  28134. ],
  28135. [
  28136. 4,
  28137. 3
  28138. ],
  28139. [
  28140. 4,
  28141. 3
  28142. ],
  28143. [
  28144. 4,
  28145. 3
  28146. ],
  28147. [
  28148. 4,
  28149. 3
  28150. ],
  28151. [
  28152. 4,
  28153. 3
  28154. ],
  28155. [
  28156. 4,
  28157. 3
  28158. ],
  28159. [
  28160. 4,
  28161. 3
  28162. ],
  28163. [
  28164. 4,
  28165. 3
  28166. ],
  28167. [
  28168. 4,
  28169. 3
  28170. ],
  28171. [
  28172. 4,
  28173. 3
  28174. ],
  28175. [
  28176. 5,
  28177. 128
  28178. ],
  28179. [
  28180. 5,
  28181. 128
  28182. ],
  28183. [
  28184. 5,
  28185. 128
  28186. ],
  28187. [
  28188. 5,
  28189. 128
  28190. ],
  28191. [
  28192. 5,
  28193. 128
  28194. ],
  28195. [
  28196. 5,
  28197. 128
  28198. ],
  28199. [
  28200. 5,
  28201. 128
  28202. ],
  28203. [
  28204. 5,
  28205. 128
  28206. ],
  28207. [
  28208. 5,
  28209. 128
  28210. ],
  28211. [
  28212. 5,
  28213. 128
  28214. ],
  28215. [
  28216. 5,
  28217. 128
  28218. ],
  28219. [
  28220. 5,
  28221. 128
  28222. ],
  28223. [
  28224. 5,
  28225. 128
  28226. ],
  28227. [
  28228. 5,
  28229. 128
  28230. ],
  28231. [
  28232. 5,
  28233. 128
  28234. ],
  28235. [
  28236. 5,
  28237. 128
  28238. ],
  28239. [
  28240. 5,
  28241. 8
  28242. ],
  28243. [
  28244. 5,
  28245. 8
  28246. ],
  28247. [
  28248. 5,
  28249. 8
  28250. ],
  28251. [
  28252. 5,
  28253. 8
  28254. ],
  28255. [
  28256. 5,
  28257. 8
  28258. ],
  28259. [
  28260. 5,
  28261. 8
  28262. ],
  28263. [
  28264. 5,
  28265. 8
  28266. ],
  28267. [
  28268. 5,
  28269. 8
  28270. ],
  28271. [
  28272. 5,
  28273. 8
  28274. ],
  28275. [
  28276. 5,
  28277. 8
  28278. ],
  28279. [
  28280. 5,
  28281. 8
  28282. ],
  28283. [
  28284. 5,
  28285. 8
  28286. ],
  28287. [
  28288. 5,
  28289. 8
  28290. ],
  28291. [
  28292. 5,
  28293. 8
  28294. ],
  28295. [
  28296. 5,
  28297. 8
  28298. ],
  28299. [
  28300. 5,
  28301. 8
  28302. ],
  28303. [
  28304. 5,
  28305. 9
  28306. ],
  28307. [
  28308. 5,
  28309. 9
  28310. ],
  28311. [
  28312. 5,
  28313. 9
  28314. ],
  28315. [
  28316. 5,
  28317. 9
  28318. ],
  28319. [
  28320. 5,
  28321. 9
  28322. ],
  28323. [
  28324. 5,
  28325. 9
  28326. ],
  28327. [
  28328. 5,
  28329. 9
  28330. ],
  28331. [
  28332. 5,
  28333. 9
  28334. ],
  28335. [
  28336. 5,
  28337. 9
  28338. ],
  28339. [
  28340. 5,
  28341. 9
  28342. ],
  28343. [
  28344. 5,
  28345. 9
  28346. ],
  28347. [
  28348. 5,
  28349. 9
  28350. ],
  28351. [
  28352. 5,
  28353. 9
  28354. ],
  28355. [
  28356. 5,
  28357. 9
  28358. ],
  28359. [
  28360. 5,
  28361. 9
  28362. ],
  28363. [
  28364. 5,
  28365. 9
  28366. ],
  28367. [
  28368. 6,
  28369. 16
  28370. ],
  28371. [
  28372. 6,
  28373. 16
  28374. ],
  28375. [
  28376. 6,
  28377. 16
  28378. ],
  28379. [
  28380. 6,
  28381. 16
  28382. ],
  28383. [
  28384. 6,
  28385. 16
  28386. ],
  28387. [
  28388. 6,
  28389. 16
  28390. ],
  28391. [
  28392. 6,
  28393. 16
  28394. ],
  28395. [
  28396. 6,
  28397. 16
  28398. ],
  28399. [
  28400. 6,
  28401. 17
  28402. ],
  28403. [
  28404. 6,
  28405. 17
  28406. ],
  28407. [
  28408. 6,
  28409. 17
  28410. ],
  28411. [
  28412. 6,
  28413. 17
  28414. ],
  28415. [
  28416. 6,
  28417. 17
  28418. ],
  28419. [
  28420. 6,
  28421. 17
  28422. ],
  28423. [
  28424. 6,
  28425. 17
  28426. ],
  28427. [
  28428. 6,
  28429. 17
  28430. ],
  28431. [
  28432. 4,
  28433. 4
  28434. ],
  28435. [
  28436. 4,
  28437. 4
  28438. ],
  28439. [
  28440. 4,
  28441. 4
  28442. ],
  28443. [
  28444. 4,
  28445. 4
  28446. ],
  28447. [
  28448. 4,
  28449. 4
  28450. ],
  28451. [
  28452. 4,
  28453. 4
  28454. ],
  28455. [
  28456. 4,
  28457. 4
  28458. ],
  28459. [
  28460. 4,
  28461. 4
  28462. ],
  28463. [
  28464. 4,
  28465. 4
  28466. ],
  28467. [
  28468. 4,
  28469. 4
  28470. ],
  28471. [
  28472. 4,
  28473. 4
  28474. ],
  28475. [
  28476. 4,
  28477. 4
  28478. ],
  28479. [
  28480. 4,
  28481. 4
  28482. ],
  28483. [
  28484. 4,
  28485. 4
  28486. ],
  28487. [
  28488. 4,
  28489. 4
  28490. ],
  28491. [
  28492. 4,
  28493. 4
  28494. ],
  28495. [
  28496. 4,
  28497. 4
  28498. ],
  28499. [
  28500. 4,
  28501. 4
  28502. ],
  28503. [
  28504. 4,
  28505. 4
  28506. ],
  28507. [
  28508. 4,
  28509. 4
  28510. ],
  28511. [
  28512. 4,
  28513. 4
  28514. ],
  28515. [
  28516. 4,
  28517. 4
  28518. ],
  28519. [
  28520. 4,
  28521. 4
  28522. ],
  28523. [
  28524. 4,
  28525. 4
  28526. ],
  28527. [
  28528. 4,
  28529. 4
  28530. ],
  28531. [
  28532. 4,
  28533. 4
  28534. ],
  28535. [
  28536. 4,
  28537. 4
  28538. ],
  28539. [
  28540. 4,
  28541. 4
  28542. ],
  28543. [
  28544. 4,
  28545. 4
  28546. ],
  28547. [
  28548. 4,
  28549. 4
  28550. ],
  28551. [
  28552. 4,
  28553. 4
  28554. ],
  28555. [
  28556. 4,
  28557. 4
  28558. ],
  28559. [
  28560. 4,
  28561. 5
  28562. ],
  28563. [
  28564. 4,
  28565. 5
  28566. ],
  28567. [
  28568. 4,
  28569. 5
  28570. ],
  28571. [
  28572. 4,
  28573. 5
  28574. ],
  28575. [
  28576. 4,
  28577. 5
  28578. ],
  28579. [
  28580. 4,
  28581. 5
  28582. ],
  28583. [
  28584. 4,
  28585. 5
  28586. ],
  28587. [
  28588. 4,
  28589. 5
  28590. ],
  28591. [
  28592. 4,
  28593. 5
  28594. ],
  28595. [
  28596. 4,
  28597. 5
  28598. ],
  28599. [
  28600. 4,
  28601. 5
  28602. ],
  28603. [
  28604. 4,
  28605. 5
  28606. ],
  28607. [
  28608. 4,
  28609. 5
  28610. ],
  28611. [
  28612. 4,
  28613. 5
  28614. ],
  28615. [
  28616. 4,
  28617. 5
  28618. ],
  28619. [
  28620. 4,
  28621. 5
  28622. ],
  28623. [
  28624. 4,
  28625. 5
  28626. ],
  28627. [
  28628. 4,
  28629. 5
  28630. ],
  28631. [
  28632. 4,
  28633. 5
  28634. ],
  28635. [
  28636. 4,
  28637. 5
  28638. ],
  28639. [
  28640. 4,
  28641. 5
  28642. ],
  28643. [
  28644. 4,
  28645. 5
  28646. ],
  28647. [
  28648. 4,
  28649. 5
  28650. ],
  28651. [
  28652. 4,
  28653. 5
  28654. ],
  28655. [
  28656. 4,
  28657. 5
  28658. ],
  28659. [
  28660. 4,
  28661. 5
  28662. ],
  28663. [
  28664. 4,
  28665. 5
  28666. ],
  28667. [
  28668. 4,
  28669. 5
  28670. ],
  28671. [
  28672. 4,
  28673. 5
  28674. ],
  28675. [
  28676. 4,
  28677. 5
  28678. ],
  28679. [
  28680. 4,
  28681. 5
  28682. ],
  28683. [
  28684. 4,
  28685. 5
  28686. ],
  28687. [
  28688. 6,
  28689. 14
  28690. ],
  28691. [
  28692. 6,
  28693. 14
  28694. ],
  28695. [
  28696. 6,
  28697. 14
  28698. ],
  28699. [
  28700. 6,
  28701. 14
  28702. ],
  28703. [
  28704. 6,
  28705. 14
  28706. ],
  28707. [
  28708. 6,
  28709. 14
  28710. ],
  28711. [
  28712. 6,
  28713. 14
  28714. ],
  28715. [
  28716. 6,
  28717. 14
  28718. ],
  28719. [
  28720. 6,
  28721. 15
  28722. ],
  28723. [
  28724. 6,
  28725. 15
  28726. ],
  28727. [
  28728. 6,
  28729. 15
  28730. ],
  28731. [
  28732. 6,
  28733. 15
  28734. ],
  28735. [
  28736. 6,
  28737. 15
  28738. ],
  28739. [
  28740. 6,
  28741. 15
  28742. ],
  28743. [
  28744. 6,
  28745. 15
  28746. ],
  28747. [
  28748. 6,
  28749. 15
  28750. ],
  28751. [
  28752. 5,
  28753. 64
  28754. ],
  28755. [
  28756. 5,
  28757. 64
  28758. ],
  28759. [
  28760. 5,
  28761. 64
  28762. ],
  28763. [
  28764. 5,
  28765. 64
  28766. ],
  28767. [
  28768. 5,
  28769. 64
  28770. ],
  28771. [
  28772. 5,
  28773. 64
  28774. ],
  28775. [
  28776. 5,
  28777. 64
  28778. ],
  28779. [
  28780. 5,
  28781. 64
  28782. ],
  28783. [
  28784. 5,
  28785. 64
  28786. ],
  28787. [
  28788. 5,
  28789. 64
  28790. ],
  28791. [
  28792. 5,
  28793. 64
  28794. ],
  28795. [
  28796. 5,
  28797. 64
  28798. ],
  28799. [
  28800. 5,
  28801. 64
  28802. ],
  28803. [
  28804. 5,
  28805. 64
  28806. ],
  28807. [
  28808. 5,
  28809. 64
  28810. ],
  28811. [
  28812. 5,
  28813. 64
  28814. ],
  28815. [
  28816. 4,
  28817. 6
  28818. ],
  28819. [
  28820. 4,
  28821. 6
  28822. ],
  28823. [
  28824. 4,
  28825. 6
  28826. ],
  28827. [
  28828. 4,
  28829. 6
  28830. ],
  28831. [
  28832. 4,
  28833. 6
  28834. ],
  28835. [
  28836. 4,
  28837. 6
  28838. ],
  28839. [
  28840. 4,
  28841. 6
  28842. ],
  28843. [
  28844. 4,
  28845. 6
  28846. ],
  28847. [
  28848. 4,
  28849. 6
  28850. ],
  28851. [
  28852. 4,
  28853. 6
  28854. ],
  28855. [
  28856. 4,
  28857. 6
  28858. ],
  28859. [
  28860. 4,
  28861. 6
  28862. ],
  28863. [
  28864. 4,
  28865. 6
  28866. ],
  28867. [
  28868. 4,
  28869. 6
  28870. ],
  28871. [
  28872. 4,
  28873. 6
  28874. ],
  28875. [
  28876. 4,
  28877. 6
  28878. ],
  28879. [
  28880. 4,
  28881. 6
  28882. ],
  28883. [
  28884. 4,
  28885. 6
  28886. ],
  28887. [
  28888. 4,
  28889. 6
  28890. ],
  28891. [
  28892. 4,
  28893. 6
  28894. ],
  28895. [
  28896. 4,
  28897. 6
  28898. ],
  28899. [
  28900. 4,
  28901. 6
  28902. ],
  28903. [
  28904. 4,
  28905. 6
  28906. ],
  28907. [
  28908. 4,
  28909. 6
  28910. ],
  28911. [
  28912. 4,
  28913. 6
  28914. ],
  28915. [
  28916. 4,
  28917. 6
  28918. ],
  28919. [
  28920. 4,
  28921. 6
  28922. ],
  28923. [
  28924. 4,
  28925. 6
  28926. ],
  28927. [
  28928. 4,
  28929. 6
  28930. ],
  28931. [
  28932. 4,
  28933. 6
  28934. ],
  28935. [
  28936. 4,
  28937. 6
  28938. ],
  28939. [
  28940. 4,
  28941. 6
  28942. ],
  28943. [
  28944. 4,
  28945. 7
  28946. ],
  28947. [
  28948. 4,
  28949. 7
  28950. ],
  28951. [
  28952. 4,
  28953. 7
  28954. ],
  28955. [
  28956. 4,
  28957. 7
  28958. ],
  28959. [
  28960. 4,
  28961. 7
  28962. ],
  28963. [
  28964. 4,
  28965. 7
  28966. ],
  28967. [
  28968. 4,
  28969. 7
  28970. ],
  28971. [
  28972. 4,
  28973. 7
  28974. ],
  28975. [
  28976. 4,
  28977. 7
  28978. ],
  28979. [
  28980. 4,
  28981. 7
  28982. ],
  28983. [
  28984. 4,
  28985. 7
  28986. ],
  28987. [
  28988. 4,
  28989. 7
  28990. ],
  28991. [
  28992. 4,
  28993. 7
  28994. ],
  28995. [
  28996. 4,
  28997. 7
  28998. ],
  28999. [
  29000. 4,
  29001. 7
  29002. ],
  29003. [
  29004. 4,
  29005. 7
  29006. ],
  29007. [
  29008. 4,
  29009. 7
  29010. ],
  29011. [
  29012. 4,
  29013. 7
  29014. ],
  29015. [
  29016. 4,
  29017. 7
  29018. ],
  29019. [
  29020. 4,
  29021. 7
  29022. ],
  29023. [
  29024. 4,
  29025. 7
  29026. ],
  29027. [
  29028. 4,
  29029. 7
  29030. ],
  29031. [
  29032. 4,
  29033. 7
  29034. ],
  29035. [
  29036. 4,
  29037. 7
  29038. ],
  29039. [
  29040. 4,
  29041. 7
  29042. ],
  29043. [
  29044. 4,
  29045. 7
  29046. ],
  29047. [
  29048. 4,
  29049. 7
  29050. ],
  29051. [
  29052. 4,
  29053. 7
  29054. ],
  29055. [
  29056. 4,
  29057. 7
  29058. ],
  29059. [
  29060. 4,
  29061. 7
  29062. ],
  29063. [
  29064. 4,
  29065. 7
  29066. ],
  29067. [
  29068. 4,
  29069. 7
  29070. ]
  29071. ];
  29072. var blackTable1 = [
  29073. [
  29074. -1,
  29075. -1
  29076. ],
  29077. [
  29078. -1,
  29079. -1
  29080. ],
  29081. [
  29082. 12,
  29083. ccittEOL
  29084. ],
  29085. [
  29086. 12,
  29087. ccittEOL
  29088. ],
  29089. [
  29090. -1,
  29091. -1
  29092. ],
  29093. [
  29094. -1,
  29095. -1
  29096. ],
  29097. [
  29098. -1,
  29099. -1
  29100. ],
  29101. [
  29102. -1,
  29103. -1
  29104. ],
  29105. [
  29106. -1,
  29107. -1
  29108. ],
  29109. [
  29110. -1,
  29111. -1
  29112. ],
  29113. [
  29114. -1,
  29115. -1
  29116. ],
  29117. [
  29118. -1,
  29119. -1
  29120. ],
  29121. [
  29122. -1,
  29123. -1
  29124. ],
  29125. [
  29126. -1,
  29127. -1
  29128. ],
  29129. [
  29130. -1,
  29131. -1
  29132. ],
  29133. [
  29134. -1,
  29135. -1
  29136. ],
  29137. [
  29138. -1,
  29139. -1
  29140. ],
  29141. [
  29142. -1,
  29143. -1
  29144. ],
  29145. [
  29146. -1,
  29147. -1
  29148. ],
  29149. [
  29150. -1,
  29151. -1
  29152. ],
  29153. [
  29154. -1,
  29155. -1
  29156. ],
  29157. [
  29158. -1,
  29159. -1
  29160. ],
  29161. [
  29162. -1,
  29163. -1
  29164. ],
  29165. [
  29166. -1,
  29167. -1
  29168. ],
  29169. [
  29170. -1,
  29171. -1
  29172. ],
  29173. [
  29174. -1,
  29175. -1
  29176. ],
  29177. [
  29178. -1,
  29179. -1
  29180. ],
  29181. [
  29182. -1,
  29183. -1
  29184. ],
  29185. [
  29186. -1,
  29187. -1
  29188. ],
  29189. [
  29190. -1,
  29191. -1
  29192. ],
  29193. [
  29194. -1,
  29195. -1
  29196. ],
  29197. [
  29198. -1,
  29199. -1
  29200. ],
  29201. [
  29202. 11,
  29203. 1792
  29204. ],
  29205. [
  29206. 11,
  29207. 1792
  29208. ],
  29209. [
  29210. 11,
  29211. 1792
  29212. ],
  29213. [
  29214. 11,
  29215. 1792
  29216. ],
  29217. [
  29218. 12,
  29219. 1984
  29220. ],
  29221. [
  29222. 12,
  29223. 1984
  29224. ],
  29225. [
  29226. 12,
  29227. 2048
  29228. ],
  29229. [
  29230. 12,
  29231. 2048
  29232. ],
  29233. [
  29234. 12,
  29235. 2112
  29236. ],
  29237. [
  29238. 12,
  29239. 2112
  29240. ],
  29241. [
  29242. 12,
  29243. 2176
  29244. ],
  29245. [
  29246. 12,
  29247. 2176
  29248. ],
  29249. [
  29250. 12,
  29251. 2240
  29252. ],
  29253. [
  29254. 12,
  29255. 2240
  29256. ],
  29257. [
  29258. 12,
  29259. 2304
  29260. ],
  29261. [
  29262. 12,
  29263. 2304
  29264. ],
  29265. [
  29266. 11,
  29267. 1856
  29268. ],
  29269. [
  29270. 11,
  29271. 1856
  29272. ],
  29273. [
  29274. 11,
  29275. 1856
  29276. ],
  29277. [
  29278. 11,
  29279. 1856
  29280. ],
  29281. [
  29282. 11,
  29283. 1920
  29284. ],
  29285. [
  29286. 11,
  29287. 1920
  29288. ],
  29289. [
  29290. 11,
  29291. 1920
  29292. ],
  29293. [
  29294. 11,
  29295. 1920
  29296. ],
  29297. [
  29298. 12,
  29299. 2368
  29300. ],
  29301. [
  29302. 12,
  29303. 2368
  29304. ],
  29305. [
  29306. 12,
  29307. 2432
  29308. ],
  29309. [
  29310. 12,
  29311. 2432
  29312. ],
  29313. [
  29314. 12,
  29315. 2496
  29316. ],
  29317. [
  29318. 12,
  29319. 2496
  29320. ],
  29321. [
  29322. 12,
  29323. 2560
  29324. ],
  29325. [
  29326. 12,
  29327. 2560
  29328. ],
  29329. [
  29330. 10,
  29331. 18
  29332. ],
  29333. [
  29334. 10,
  29335. 18
  29336. ],
  29337. [
  29338. 10,
  29339. 18
  29340. ],
  29341. [
  29342. 10,
  29343. 18
  29344. ],
  29345. [
  29346. 10,
  29347. 18
  29348. ],
  29349. [
  29350. 10,
  29351. 18
  29352. ],
  29353. [
  29354. 10,
  29355. 18
  29356. ],
  29357. [
  29358. 10,
  29359. 18
  29360. ],
  29361. [
  29362. 12,
  29363. 52
  29364. ],
  29365. [
  29366. 12,
  29367. 52
  29368. ],
  29369. [
  29370. 13,
  29371. 640
  29372. ],
  29373. [
  29374. 13,
  29375. 704
  29376. ],
  29377. [
  29378. 13,
  29379. 768
  29380. ],
  29381. [
  29382. 13,
  29383. 832
  29384. ],
  29385. [
  29386. 12,
  29387. 55
  29388. ],
  29389. [
  29390. 12,
  29391. 55
  29392. ],
  29393. [
  29394. 12,
  29395. 56
  29396. ],
  29397. [
  29398. 12,
  29399. 56
  29400. ],
  29401. [
  29402. 13,
  29403. 1280
  29404. ],
  29405. [
  29406. 13,
  29407. 1344
  29408. ],
  29409. [
  29410. 13,
  29411. 1408
  29412. ],
  29413. [
  29414. 13,
  29415. 1472
  29416. ],
  29417. [
  29418. 12,
  29419. 59
  29420. ],
  29421. [
  29422. 12,
  29423. 59
  29424. ],
  29425. [
  29426. 12,
  29427. 60
  29428. ],
  29429. [
  29430. 12,
  29431. 60
  29432. ],
  29433. [
  29434. 13,
  29435. 1536
  29436. ],
  29437. [
  29438. 13,
  29439. 1600
  29440. ],
  29441. [
  29442. 11,
  29443. 24
  29444. ],
  29445. [
  29446. 11,
  29447. 24
  29448. ],
  29449. [
  29450. 11,
  29451. 24
  29452. ],
  29453. [
  29454. 11,
  29455. 24
  29456. ],
  29457. [
  29458. 11,
  29459. 25
  29460. ],
  29461. [
  29462. 11,
  29463. 25
  29464. ],
  29465. [
  29466. 11,
  29467. 25
  29468. ],
  29469. [
  29470. 11,
  29471. 25
  29472. ],
  29473. [
  29474. 13,
  29475. 1664
  29476. ],
  29477. [
  29478. 13,
  29479. 1728
  29480. ],
  29481. [
  29482. 12,
  29483. 320
  29484. ],
  29485. [
  29486. 12,
  29487. 320
  29488. ],
  29489. [
  29490. 12,
  29491. 384
  29492. ],
  29493. [
  29494. 12,
  29495. 384
  29496. ],
  29497. [
  29498. 12,
  29499. 448
  29500. ],
  29501. [
  29502. 12,
  29503. 448
  29504. ],
  29505. [
  29506. 13,
  29507. 512
  29508. ],
  29509. [
  29510. 13,
  29511. 576
  29512. ],
  29513. [
  29514. 12,
  29515. 53
  29516. ],
  29517. [
  29518. 12,
  29519. 53
  29520. ],
  29521. [
  29522. 12,
  29523. 54
  29524. ],
  29525. [
  29526. 12,
  29527. 54
  29528. ],
  29529. [
  29530. 13,
  29531. 896
  29532. ],
  29533. [
  29534. 13,
  29535. 960
  29536. ],
  29537. [
  29538. 13,
  29539. 1024
  29540. ],
  29541. [
  29542. 13,
  29543. 1088
  29544. ],
  29545. [
  29546. 13,
  29547. 1152
  29548. ],
  29549. [
  29550. 13,
  29551. 1216
  29552. ],
  29553. [
  29554. 10,
  29555. 64
  29556. ],
  29557. [
  29558. 10,
  29559. 64
  29560. ],
  29561. [
  29562. 10,
  29563. 64
  29564. ],
  29565. [
  29566. 10,
  29567. 64
  29568. ],
  29569. [
  29570. 10,
  29571. 64
  29572. ],
  29573. [
  29574. 10,
  29575. 64
  29576. ],
  29577. [
  29578. 10,
  29579. 64
  29580. ],
  29581. [
  29582. 10,
  29583. 64
  29584. ]
  29585. ];
  29586. var blackTable2 = [
  29587. [
  29588. 8,
  29589. 13
  29590. ],
  29591. [
  29592. 8,
  29593. 13
  29594. ],
  29595. [
  29596. 8,
  29597. 13
  29598. ],
  29599. [
  29600. 8,
  29601. 13
  29602. ],
  29603. [
  29604. 8,
  29605. 13
  29606. ],
  29607. [
  29608. 8,
  29609. 13
  29610. ],
  29611. [
  29612. 8,
  29613. 13
  29614. ],
  29615. [
  29616. 8,
  29617. 13
  29618. ],
  29619. [
  29620. 8,
  29621. 13
  29622. ],
  29623. [
  29624. 8,
  29625. 13
  29626. ],
  29627. [
  29628. 8,
  29629. 13
  29630. ],
  29631. [
  29632. 8,
  29633. 13
  29634. ],
  29635. [
  29636. 8,
  29637. 13
  29638. ],
  29639. [
  29640. 8,
  29641. 13
  29642. ],
  29643. [
  29644. 8,
  29645. 13
  29646. ],
  29647. [
  29648. 8,
  29649. 13
  29650. ],
  29651. [
  29652. 11,
  29653. 23
  29654. ],
  29655. [
  29656. 11,
  29657. 23
  29658. ],
  29659. [
  29660. 12,
  29661. 50
  29662. ],
  29663. [
  29664. 12,
  29665. 51
  29666. ],
  29667. [
  29668. 12,
  29669. 44
  29670. ],
  29671. [
  29672. 12,
  29673. 45
  29674. ],
  29675. [
  29676. 12,
  29677. 46
  29678. ],
  29679. [
  29680. 12,
  29681. 47
  29682. ],
  29683. [
  29684. 12,
  29685. 57
  29686. ],
  29687. [
  29688. 12,
  29689. 58
  29690. ],
  29691. [
  29692. 12,
  29693. 61
  29694. ],
  29695. [
  29696. 12,
  29697. 256
  29698. ],
  29699. [
  29700. 10,
  29701. 16
  29702. ],
  29703. [
  29704. 10,
  29705. 16
  29706. ],
  29707. [
  29708. 10,
  29709. 16
  29710. ],
  29711. [
  29712. 10,
  29713. 16
  29714. ],
  29715. [
  29716. 10,
  29717. 17
  29718. ],
  29719. [
  29720. 10,
  29721. 17
  29722. ],
  29723. [
  29724. 10,
  29725. 17
  29726. ],
  29727. [
  29728. 10,
  29729. 17
  29730. ],
  29731. [
  29732. 12,
  29733. 48
  29734. ],
  29735. [
  29736. 12,
  29737. 49
  29738. ],
  29739. [
  29740. 12,
  29741. 62
  29742. ],
  29743. [
  29744. 12,
  29745. 63
  29746. ],
  29747. [
  29748. 12,
  29749. 30
  29750. ],
  29751. [
  29752. 12,
  29753. 31
  29754. ],
  29755. [
  29756. 12,
  29757. 32
  29758. ],
  29759. [
  29760. 12,
  29761. 33
  29762. ],
  29763. [
  29764. 12,
  29765. 40
  29766. ],
  29767. [
  29768. 12,
  29769. 41
  29770. ],
  29771. [
  29772. 11,
  29773. 22
  29774. ],
  29775. [
  29776. 11,
  29777. 22
  29778. ],
  29779. [
  29780. 8,
  29781. 14
  29782. ],
  29783. [
  29784. 8,
  29785. 14
  29786. ],
  29787. [
  29788. 8,
  29789. 14
  29790. ],
  29791. [
  29792. 8,
  29793. 14
  29794. ],
  29795. [
  29796. 8,
  29797. 14
  29798. ],
  29799. [
  29800. 8,
  29801. 14
  29802. ],
  29803. [
  29804. 8,
  29805. 14
  29806. ],
  29807. [
  29808. 8,
  29809. 14
  29810. ],
  29811. [
  29812. 8,
  29813. 14
  29814. ],
  29815. [
  29816. 8,
  29817. 14
  29818. ],
  29819. [
  29820. 8,
  29821. 14
  29822. ],
  29823. [
  29824. 8,
  29825. 14
  29826. ],
  29827. [
  29828. 8,
  29829. 14
  29830. ],
  29831. [
  29832. 8,
  29833. 14
  29834. ],
  29835. [
  29836. 8,
  29837. 14
  29838. ],
  29839. [
  29840. 8,
  29841. 14
  29842. ],
  29843. [
  29844. 7,
  29845. 10
  29846. ],
  29847. [
  29848. 7,
  29849. 10
  29850. ],
  29851. [
  29852. 7,
  29853. 10
  29854. ],
  29855. [
  29856. 7,
  29857. 10
  29858. ],
  29859. [
  29860. 7,
  29861. 10
  29862. ],
  29863. [
  29864. 7,
  29865. 10
  29866. ],
  29867. [
  29868. 7,
  29869. 10
  29870. ],
  29871. [
  29872. 7,
  29873. 10
  29874. ],
  29875. [
  29876. 7,
  29877. 10
  29878. ],
  29879. [
  29880. 7,
  29881. 10
  29882. ],
  29883. [
  29884. 7,
  29885. 10
  29886. ],
  29887. [
  29888. 7,
  29889. 10
  29890. ],
  29891. [
  29892. 7,
  29893. 10
  29894. ],
  29895. [
  29896. 7,
  29897. 10
  29898. ],
  29899. [
  29900. 7,
  29901. 10
  29902. ],
  29903. [
  29904. 7,
  29905. 10
  29906. ],
  29907. [
  29908. 7,
  29909. 10
  29910. ],
  29911. [
  29912. 7,
  29913. 10
  29914. ],
  29915. [
  29916. 7,
  29917. 10
  29918. ],
  29919. [
  29920. 7,
  29921. 10
  29922. ],
  29923. [
  29924. 7,
  29925. 10
  29926. ],
  29927. [
  29928. 7,
  29929. 10
  29930. ],
  29931. [
  29932. 7,
  29933. 10
  29934. ],
  29935. [
  29936. 7,
  29937. 10
  29938. ],
  29939. [
  29940. 7,
  29941. 10
  29942. ],
  29943. [
  29944. 7,
  29945. 10
  29946. ],
  29947. [
  29948. 7,
  29949. 10
  29950. ],
  29951. [
  29952. 7,
  29953. 10
  29954. ],
  29955. [
  29956. 7,
  29957. 10
  29958. ],
  29959. [
  29960. 7,
  29961. 10
  29962. ],
  29963. [
  29964. 7,
  29965. 10
  29966. ],
  29967. [
  29968. 7,
  29969. 10
  29970. ],
  29971. [
  29972. 7,
  29973. 11
  29974. ],
  29975. [
  29976. 7,
  29977. 11
  29978. ],
  29979. [
  29980. 7,
  29981. 11
  29982. ],
  29983. [
  29984. 7,
  29985. 11
  29986. ],
  29987. [
  29988. 7,
  29989. 11
  29990. ],
  29991. [
  29992. 7,
  29993. 11
  29994. ],
  29995. [
  29996. 7,
  29997. 11
  29998. ],
  29999. [
  30000. 7,
  30001. 11
  30002. ],
  30003. [
  30004. 7,
  30005. 11
  30006. ],
  30007. [
  30008. 7,
  30009. 11
  30010. ],
  30011. [
  30012. 7,
  30013. 11
  30014. ],
  30015. [
  30016. 7,
  30017. 11
  30018. ],
  30019. [
  30020. 7,
  30021. 11
  30022. ],
  30023. [
  30024. 7,
  30025. 11
  30026. ],
  30027. [
  30028. 7,
  30029. 11
  30030. ],
  30031. [
  30032. 7,
  30033. 11
  30034. ],
  30035. [
  30036. 7,
  30037. 11
  30038. ],
  30039. [
  30040. 7,
  30041. 11
  30042. ],
  30043. [
  30044. 7,
  30045. 11
  30046. ],
  30047. [
  30048. 7,
  30049. 11
  30050. ],
  30051. [
  30052. 7,
  30053. 11
  30054. ],
  30055. [
  30056. 7,
  30057. 11
  30058. ],
  30059. [
  30060. 7,
  30061. 11
  30062. ],
  30063. [
  30064. 7,
  30065. 11
  30066. ],
  30067. [
  30068. 7,
  30069. 11
  30070. ],
  30071. [
  30072. 7,
  30073. 11
  30074. ],
  30075. [
  30076. 7,
  30077. 11
  30078. ],
  30079. [
  30080. 7,
  30081. 11
  30082. ],
  30083. [
  30084. 7,
  30085. 11
  30086. ],
  30087. [
  30088. 7,
  30089. 11
  30090. ],
  30091. [
  30092. 7,
  30093. 11
  30094. ],
  30095. [
  30096. 7,
  30097. 11
  30098. ],
  30099. [
  30100. 9,
  30101. 15
  30102. ],
  30103. [
  30104. 9,
  30105. 15
  30106. ],
  30107. [
  30108. 9,
  30109. 15
  30110. ],
  30111. [
  30112. 9,
  30113. 15
  30114. ],
  30115. [
  30116. 9,
  30117. 15
  30118. ],
  30119. [
  30120. 9,
  30121. 15
  30122. ],
  30123. [
  30124. 9,
  30125. 15
  30126. ],
  30127. [
  30128. 9,
  30129. 15
  30130. ],
  30131. [
  30132. 12,
  30133. 128
  30134. ],
  30135. [
  30136. 12,
  30137. 192
  30138. ],
  30139. [
  30140. 12,
  30141. 26
  30142. ],
  30143. [
  30144. 12,
  30145. 27
  30146. ],
  30147. [
  30148. 12,
  30149. 28
  30150. ],
  30151. [
  30152. 12,
  30153. 29
  30154. ],
  30155. [
  30156. 11,
  30157. 19
  30158. ],
  30159. [
  30160. 11,
  30161. 19
  30162. ],
  30163. [
  30164. 11,
  30165. 20
  30166. ],
  30167. [
  30168. 11,
  30169. 20
  30170. ],
  30171. [
  30172. 12,
  30173. 34
  30174. ],
  30175. [
  30176. 12,
  30177. 35
  30178. ],
  30179. [
  30180. 12,
  30181. 36
  30182. ],
  30183. [
  30184. 12,
  30185. 37
  30186. ],
  30187. [
  30188. 12,
  30189. 38
  30190. ],
  30191. [
  30192. 12,
  30193. 39
  30194. ],
  30195. [
  30196. 11,
  30197. 21
  30198. ],
  30199. [
  30200. 11,
  30201. 21
  30202. ],
  30203. [
  30204. 12,
  30205. 42
  30206. ],
  30207. [
  30208. 12,
  30209. 43
  30210. ],
  30211. [
  30212. 10,
  30213. 0
  30214. ],
  30215. [
  30216. 10,
  30217. 0
  30218. ],
  30219. [
  30220. 10,
  30221. 0
  30222. ],
  30223. [
  30224. 10,
  30225. 0
  30226. ],
  30227. [
  30228. 7,
  30229. 12
  30230. ],
  30231. [
  30232. 7,
  30233. 12
  30234. ],
  30235. [
  30236. 7,
  30237. 12
  30238. ],
  30239. [
  30240. 7,
  30241. 12
  30242. ],
  30243. [
  30244. 7,
  30245. 12
  30246. ],
  30247. [
  30248. 7,
  30249. 12
  30250. ],
  30251. [
  30252. 7,
  30253. 12
  30254. ],
  30255. [
  30256. 7,
  30257. 12
  30258. ],
  30259. [
  30260. 7,
  30261. 12
  30262. ],
  30263. [
  30264. 7,
  30265. 12
  30266. ],
  30267. [
  30268. 7,
  30269. 12
  30270. ],
  30271. [
  30272. 7,
  30273. 12
  30274. ],
  30275. [
  30276. 7,
  30277. 12
  30278. ],
  30279. [
  30280. 7,
  30281. 12
  30282. ],
  30283. [
  30284. 7,
  30285. 12
  30286. ],
  30287. [
  30288. 7,
  30289. 12
  30290. ],
  30291. [
  30292. 7,
  30293. 12
  30294. ],
  30295. [
  30296. 7,
  30297. 12
  30298. ],
  30299. [
  30300. 7,
  30301. 12
  30302. ],
  30303. [
  30304. 7,
  30305. 12
  30306. ],
  30307. [
  30308. 7,
  30309. 12
  30310. ],
  30311. [
  30312. 7,
  30313. 12
  30314. ],
  30315. [
  30316. 7,
  30317. 12
  30318. ],
  30319. [
  30320. 7,
  30321. 12
  30322. ],
  30323. [
  30324. 7,
  30325. 12
  30326. ],
  30327. [
  30328. 7,
  30329. 12
  30330. ],
  30331. [
  30332. 7,
  30333. 12
  30334. ],
  30335. [
  30336. 7,
  30337. 12
  30338. ],
  30339. [
  30340. 7,
  30341. 12
  30342. ],
  30343. [
  30344. 7,
  30345. 12
  30346. ],
  30347. [
  30348. 7,
  30349. 12
  30350. ],
  30351. [
  30352. 7,
  30353. 12
  30354. ]
  30355. ];
  30356. var blackTable3 = [
  30357. [
  30358. -1,
  30359. -1
  30360. ],
  30361. [
  30362. -1,
  30363. -1
  30364. ],
  30365. [
  30366. -1,
  30367. -1
  30368. ],
  30369. [
  30370. -1,
  30371. -1
  30372. ],
  30373. [
  30374. 6,
  30375. 9
  30376. ],
  30377. [
  30378. 6,
  30379. 8
  30380. ],
  30381. [
  30382. 5,
  30383. 7
  30384. ],
  30385. [
  30386. 5,
  30387. 7
  30388. ],
  30389. [
  30390. 4,
  30391. 6
  30392. ],
  30393. [
  30394. 4,
  30395. 6
  30396. ],
  30397. [
  30398. 4,
  30399. 6
  30400. ],
  30401. [
  30402. 4,
  30403. 6
  30404. ],
  30405. [
  30406. 4,
  30407. 5
  30408. ],
  30409. [
  30410. 4,
  30411. 5
  30412. ],
  30413. [
  30414. 4,
  30415. 5
  30416. ],
  30417. [
  30418. 4,
  30419. 5
  30420. ],
  30421. [
  30422. 3,
  30423. 1
  30424. ],
  30425. [
  30426. 3,
  30427. 1
  30428. ],
  30429. [
  30430. 3,
  30431. 1
  30432. ],
  30433. [
  30434. 3,
  30435. 1
  30436. ],
  30437. [
  30438. 3,
  30439. 1
  30440. ],
  30441. [
  30442. 3,
  30443. 1
  30444. ],
  30445. [
  30446. 3,
  30447. 1
  30448. ],
  30449. [
  30450. 3,
  30451. 1
  30452. ],
  30453. [
  30454. 3,
  30455. 4
  30456. ],
  30457. [
  30458. 3,
  30459. 4
  30460. ],
  30461. [
  30462. 3,
  30463. 4
  30464. ],
  30465. [
  30466. 3,
  30467. 4
  30468. ],
  30469. [
  30470. 3,
  30471. 4
  30472. ],
  30473. [
  30474. 3,
  30475. 4
  30476. ],
  30477. [
  30478. 3,
  30479. 4
  30480. ],
  30481. [
  30482. 3,
  30483. 4
  30484. ],
  30485. [
  30486. 2,
  30487. 3
  30488. ],
  30489. [
  30490. 2,
  30491. 3
  30492. ],
  30493. [
  30494. 2,
  30495. 3
  30496. ],
  30497. [
  30498. 2,
  30499. 3
  30500. ],
  30501. [
  30502. 2,
  30503. 3
  30504. ],
  30505. [
  30506. 2,
  30507. 3
  30508. ],
  30509. [
  30510. 2,
  30511. 3
  30512. ],
  30513. [
  30514. 2,
  30515. 3
  30516. ],
  30517. [
  30518. 2,
  30519. 3
  30520. ],
  30521. [
  30522. 2,
  30523. 3
  30524. ],
  30525. [
  30526. 2,
  30527. 3
  30528. ],
  30529. [
  30530. 2,
  30531. 3
  30532. ],
  30533. [
  30534. 2,
  30535. 3
  30536. ],
  30537. [
  30538. 2,
  30539. 3
  30540. ],
  30541. [
  30542. 2,
  30543. 3
  30544. ],
  30545. [
  30546. 2,
  30547. 3
  30548. ],
  30549. [
  30550. 2,
  30551. 2
  30552. ],
  30553. [
  30554. 2,
  30555. 2
  30556. ],
  30557. [
  30558. 2,
  30559. 2
  30560. ],
  30561. [
  30562. 2,
  30563. 2
  30564. ],
  30565. [
  30566. 2,
  30567. 2
  30568. ],
  30569. [
  30570. 2,
  30571. 2
  30572. ],
  30573. [
  30574. 2,
  30575. 2
  30576. ],
  30577. [
  30578. 2,
  30579. 2
  30580. ],
  30581. [
  30582. 2,
  30583. 2
  30584. ],
  30585. [
  30586. 2,
  30587. 2
  30588. ],
  30589. [
  30590. 2,
  30591. 2
  30592. ],
  30593. [
  30594. 2,
  30595. 2
  30596. ],
  30597. [
  30598. 2,
  30599. 2
  30600. ],
  30601. [
  30602. 2,
  30603. 2
  30604. ],
  30605. [
  30606. 2,
  30607. 2
  30608. ],
  30609. [
  30610. 2,
  30611. 2
  30612. ]
  30613. ];
  30614. function CCITTFaxStream(str, maybeLength, params) {
  30615. this.str = str;
  30616. this.dict = str.dict;
  30617. params = params || Dict.empty;
  30618. this.encoding = params.get('K') || 0;
  30619. this.eoline = params.get('EndOfLine') || false;
  30620. this.byteAlign = params.get('EncodedByteAlign') || false;
  30621. this.columns = params.get('Columns') || 1728;
  30622. this.rows = params.get('Rows') || 0;
  30623. var eoblock = params.get('EndOfBlock');
  30624. if (eoblock === null || eoblock === undefined) {
  30625. eoblock = true;
  30626. }
  30627. this.eoblock = eoblock;
  30628. this.black = params.get('BlackIs1') || false;
  30629. this.codingLine = new Uint32Array(this.columns + 1);
  30630. this.refLine = new Uint32Array(this.columns + 2);
  30631. this.codingLine[0] = this.columns;
  30632. this.codingPos = 0;
  30633. this.row = 0;
  30634. this.nextLine2D = this.encoding < 0;
  30635. this.inputBits = 0;
  30636. this.inputBuf = 0;
  30637. this.outputBits = 0;
  30638. var code1;
  30639. while ((code1 = this.lookBits(12)) === 0) {
  30640. this.eatBits(1);
  30641. }
  30642. if (code1 === 1) {
  30643. this.eatBits(12);
  30644. }
  30645. if (this.encoding > 0) {
  30646. this.nextLine2D = !this.lookBits(1);
  30647. this.eatBits(1);
  30648. }
  30649. DecodeStream.call(this, maybeLength);
  30650. }
  30651. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30652. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30653. while (!this.eof) {
  30654. var c = this.lookChar();
  30655. this.ensureBuffer(this.bufferLength + 1);
  30656. this.buffer[this.bufferLength++] = c;
  30657. }
  30658. };
  30659. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30660. var codingLine = this.codingLine;
  30661. var codingPos = this.codingPos;
  30662. if (a1 > codingLine[codingPos]) {
  30663. if (a1 > this.columns) {
  30664. info('row is wrong length');
  30665. this.err = true;
  30666. a1 = this.columns;
  30667. }
  30668. if (codingPos & 1 ^ blackPixels) {
  30669. ++codingPos;
  30670. }
  30671. codingLine[codingPos] = a1;
  30672. }
  30673. this.codingPos = codingPos;
  30674. };
  30675. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30676. var codingLine = this.codingLine;
  30677. var codingPos = this.codingPos;
  30678. if (a1 > codingLine[codingPos]) {
  30679. if (a1 > this.columns) {
  30680. info('row is wrong length');
  30681. this.err = true;
  30682. a1 = this.columns;
  30683. }
  30684. if (codingPos & 1 ^ blackPixels) {
  30685. ++codingPos;
  30686. }
  30687. codingLine[codingPos] = a1;
  30688. } else if (a1 < codingLine[codingPos]) {
  30689. if (a1 < 0) {
  30690. info('invalid code');
  30691. this.err = true;
  30692. a1 = 0;
  30693. }
  30694. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30695. --codingPos;
  30696. }
  30697. codingLine[codingPos] = a1;
  30698. }
  30699. this.codingPos = codingPos;
  30700. };
  30701. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30702. var refLine = this.refLine;
  30703. var codingLine = this.codingLine;
  30704. var columns = this.columns;
  30705. var refPos, blackPixels, bits, i;
  30706. if (this.outputBits === 0) {
  30707. if (this.eof) {
  30708. return null;
  30709. }
  30710. this.err = false;
  30711. var code1, code2, code3;
  30712. if (this.nextLine2D) {
  30713. for (i = 0; codingLine[i] < columns; ++i) {
  30714. refLine[i] = codingLine[i];
  30715. }
  30716. refLine[i++] = columns;
  30717. refLine[i] = columns;
  30718. codingLine[0] = 0;
  30719. this.codingPos = 0;
  30720. refPos = 0;
  30721. blackPixels = 0;
  30722. while (codingLine[this.codingPos] < columns) {
  30723. code1 = this.getTwoDimCode();
  30724. switch (code1) {
  30725. case twoDimPass:
  30726. this.addPixels(refLine[refPos + 1], blackPixels);
  30727. if (refLine[refPos + 1] < columns) {
  30728. refPos += 2;
  30729. }
  30730. break;
  30731. case twoDimHoriz:
  30732. code1 = code2 = 0;
  30733. if (blackPixels) {
  30734. do {
  30735. code1 += code3 = this.getBlackCode();
  30736. } while (code3 >= 64);
  30737. do {
  30738. code2 += code3 = this.getWhiteCode();
  30739. } while (code3 >= 64);
  30740. } else {
  30741. do {
  30742. code1 += code3 = this.getWhiteCode();
  30743. } while (code3 >= 64);
  30744. do {
  30745. code2 += code3 = this.getBlackCode();
  30746. } while (code3 >= 64);
  30747. }
  30748. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30749. if (codingLine[this.codingPos] < columns) {
  30750. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30751. }
  30752. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30753. refPos += 2;
  30754. }
  30755. break;
  30756. case twoDimVertR3:
  30757. this.addPixels(refLine[refPos] + 3, blackPixels);
  30758. blackPixels ^= 1;
  30759. if (codingLine[this.codingPos] < columns) {
  30760. ++refPos;
  30761. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30762. refPos += 2;
  30763. }
  30764. }
  30765. break;
  30766. case twoDimVertR2:
  30767. this.addPixels(refLine[refPos] + 2, blackPixels);
  30768. blackPixels ^= 1;
  30769. if (codingLine[this.codingPos] < columns) {
  30770. ++refPos;
  30771. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30772. refPos += 2;
  30773. }
  30774. }
  30775. break;
  30776. case twoDimVertR1:
  30777. this.addPixels(refLine[refPos] + 1, blackPixels);
  30778. blackPixels ^= 1;
  30779. if (codingLine[this.codingPos] < columns) {
  30780. ++refPos;
  30781. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30782. refPos += 2;
  30783. }
  30784. }
  30785. break;
  30786. case twoDimVert0:
  30787. this.addPixels(refLine[refPos], blackPixels);
  30788. blackPixels ^= 1;
  30789. if (codingLine[this.codingPos] < columns) {
  30790. ++refPos;
  30791. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30792. refPos += 2;
  30793. }
  30794. }
  30795. break;
  30796. case twoDimVertL3:
  30797. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  30798. blackPixels ^= 1;
  30799. if (codingLine[this.codingPos] < columns) {
  30800. if (refPos > 0) {
  30801. --refPos;
  30802. } else {
  30803. ++refPos;
  30804. }
  30805. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30806. refPos += 2;
  30807. }
  30808. }
  30809. break;
  30810. case twoDimVertL2:
  30811. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  30812. blackPixels ^= 1;
  30813. if (codingLine[this.codingPos] < columns) {
  30814. if (refPos > 0) {
  30815. --refPos;
  30816. } else {
  30817. ++refPos;
  30818. }
  30819. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30820. refPos += 2;
  30821. }
  30822. }
  30823. break;
  30824. case twoDimVertL1:
  30825. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  30826. blackPixels ^= 1;
  30827. if (codingLine[this.codingPos] < columns) {
  30828. if (refPos > 0) {
  30829. --refPos;
  30830. } else {
  30831. ++refPos;
  30832. }
  30833. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30834. refPos += 2;
  30835. }
  30836. }
  30837. break;
  30838. case ccittEOF:
  30839. this.addPixels(columns, 0);
  30840. this.eof = true;
  30841. break;
  30842. default:
  30843. info('bad 2d code');
  30844. this.addPixels(columns, 0);
  30845. this.err = true;
  30846. }
  30847. }
  30848. } else {
  30849. codingLine[0] = 0;
  30850. this.codingPos = 0;
  30851. blackPixels = 0;
  30852. while (codingLine[this.codingPos] < columns) {
  30853. code1 = 0;
  30854. if (blackPixels) {
  30855. do {
  30856. code1 += code3 = this.getBlackCode();
  30857. } while (code3 >= 64);
  30858. } else {
  30859. do {
  30860. code1 += code3 = this.getWhiteCode();
  30861. } while (code3 >= 64);
  30862. }
  30863. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30864. blackPixels ^= 1;
  30865. }
  30866. }
  30867. var gotEOL = false;
  30868. if (this.byteAlign) {
  30869. this.inputBits &= ~7;
  30870. }
  30871. if (!this.eoblock && this.row === this.rows - 1) {
  30872. this.eof = true;
  30873. } else {
  30874. code1 = this.lookBits(12);
  30875. if (this.eoline) {
  30876. while (code1 !== ccittEOF && code1 !== 1) {
  30877. this.eatBits(1);
  30878. code1 = this.lookBits(12);
  30879. }
  30880. } else {
  30881. while (code1 === 0) {
  30882. this.eatBits(1);
  30883. code1 = this.lookBits(12);
  30884. }
  30885. }
  30886. if (code1 === 1) {
  30887. this.eatBits(12);
  30888. gotEOL = true;
  30889. } else if (code1 === ccittEOF) {
  30890. this.eof = true;
  30891. }
  30892. }
  30893. if (!this.eof && this.encoding > 0) {
  30894. this.nextLine2D = !this.lookBits(1);
  30895. this.eatBits(1);
  30896. }
  30897. if (this.eoblock && gotEOL && this.byteAlign) {
  30898. code1 = this.lookBits(12);
  30899. if (code1 === 1) {
  30900. this.eatBits(12);
  30901. if (this.encoding > 0) {
  30902. this.lookBits(1);
  30903. this.eatBits(1);
  30904. }
  30905. if (this.encoding >= 0) {
  30906. for (i = 0; i < 4; ++i) {
  30907. code1 = this.lookBits(12);
  30908. if (code1 !== 1) {
  30909. info('bad rtc code: ' + code1);
  30910. }
  30911. this.eatBits(12);
  30912. if (this.encoding > 0) {
  30913. this.lookBits(1);
  30914. this.eatBits(1);
  30915. }
  30916. }
  30917. }
  30918. this.eof = true;
  30919. }
  30920. } else if (this.err && this.eoline) {
  30921. while (true) {
  30922. code1 = this.lookBits(13);
  30923. if (code1 === ccittEOF) {
  30924. this.eof = true;
  30925. return null;
  30926. }
  30927. if (code1 >> 1 === 1) {
  30928. break;
  30929. }
  30930. this.eatBits(1);
  30931. }
  30932. this.eatBits(12);
  30933. if (this.encoding > 0) {
  30934. this.eatBits(1);
  30935. this.nextLine2D = !(code1 & 1);
  30936. }
  30937. }
  30938. if (codingLine[0] > 0) {
  30939. this.outputBits = codingLine[this.codingPos = 0];
  30940. } else {
  30941. this.outputBits = codingLine[this.codingPos = 1];
  30942. }
  30943. this.row++;
  30944. }
  30945. var c;
  30946. if (this.outputBits >= 8) {
  30947. c = this.codingPos & 1 ? 0 : 0xFF;
  30948. this.outputBits -= 8;
  30949. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  30950. this.codingPos++;
  30951. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30952. }
  30953. } else {
  30954. bits = 8;
  30955. c = 0;
  30956. do {
  30957. if (this.outputBits > bits) {
  30958. c <<= bits;
  30959. if (!(this.codingPos & 1)) {
  30960. c |= 0xFF >> 8 - bits;
  30961. }
  30962. this.outputBits -= bits;
  30963. bits = 0;
  30964. } else {
  30965. c <<= this.outputBits;
  30966. if (!(this.codingPos & 1)) {
  30967. c |= 0xFF >> 8 - this.outputBits;
  30968. }
  30969. bits -= this.outputBits;
  30970. this.outputBits = 0;
  30971. if (codingLine[this.codingPos] < columns) {
  30972. this.codingPos++;
  30973. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30974. } else if (bits > 0) {
  30975. c <<= bits;
  30976. bits = 0;
  30977. }
  30978. }
  30979. } while (bits);
  30980. }
  30981. if (this.black) {
  30982. c ^= 0xFF;
  30983. }
  30984. return c;
  30985. };
  30986. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  30987. var limitValue = limit || 0;
  30988. for (var i = start; i <= end; ++i) {
  30989. var code = this.lookBits(i);
  30990. if (code === ccittEOF) {
  30991. return [
  30992. true,
  30993. 1,
  30994. false
  30995. ];
  30996. }
  30997. if (i < end) {
  30998. code <<= end - i;
  30999. }
  31000. if (!limitValue || code >= limitValue) {
  31001. var p = table[code - limitValue];
  31002. if (p[0] === i) {
  31003. this.eatBits(i);
  31004. return [
  31005. true,
  31006. p[1],
  31007. true
  31008. ];
  31009. }
  31010. }
  31011. }
  31012. return [
  31013. false,
  31014. 0,
  31015. false
  31016. ];
  31017. };
  31018. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  31019. var code = 0;
  31020. var p;
  31021. if (this.eoblock) {
  31022. code = this.lookBits(7);
  31023. p = twoDimTable[code];
  31024. if (p && p[0] > 0) {
  31025. this.eatBits(p[0]);
  31026. return p[1];
  31027. }
  31028. } else {
  31029. var result = this.findTableCode(1, 7, twoDimTable);
  31030. if (result[0] && result[2]) {
  31031. return result[1];
  31032. }
  31033. }
  31034. info('Bad two dim code');
  31035. return ccittEOF;
  31036. };
  31037. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  31038. var code = 0;
  31039. var p;
  31040. if (this.eoblock) {
  31041. code = this.lookBits(12);
  31042. if (code === ccittEOF) {
  31043. return 1;
  31044. }
  31045. if (code >> 5 === 0) {
  31046. p = whiteTable1[code];
  31047. } else {
  31048. p = whiteTable2[code >> 3];
  31049. }
  31050. if (p[0] > 0) {
  31051. this.eatBits(p[0]);
  31052. return p[1];
  31053. }
  31054. } else {
  31055. var result = this.findTableCode(1, 9, whiteTable2);
  31056. if (result[0]) {
  31057. return result[1];
  31058. }
  31059. result = this.findTableCode(11, 12, whiteTable1);
  31060. if (result[0]) {
  31061. return result[1];
  31062. }
  31063. }
  31064. info('bad white code');
  31065. this.eatBits(1);
  31066. return 1;
  31067. };
  31068. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  31069. var code, p;
  31070. if (this.eoblock) {
  31071. code = this.lookBits(13);
  31072. if (code === ccittEOF) {
  31073. return 1;
  31074. }
  31075. if (code >> 7 === 0) {
  31076. p = blackTable1[code];
  31077. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  31078. p = blackTable2[(code >> 1) - 64];
  31079. } else {
  31080. p = blackTable3[code >> 7];
  31081. }
  31082. if (p[0] > 0) {
  31083. this.eatBits(p[0]);
  31084. return p[1];
  31085. }
  31086. } else {
  31087. var result = this.findTableCode(2, 6, blackTable3);
  31088. if (result[0]) {
  31089. return result[1];
  31090. }
  31091. result = this.findTableCode(7, 12, blackTable2, 64);
  31092. if (result[0]) {
  31093. return result[1];
  31094. }
  31095. result = this.findTableCode(10, 13, blackTable1);
  31096. if (result[0]) {
  31097. return result[1];
  31098. }
  31099. }
  31100. info('bad black code');
  31101. this.eatBits(1);
  31102. return 1;
  31103. };
  31104. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  31105. var c;
  31106. while (this.inputBits < n) {
  31107. if ((c = this.str.getByte()) === -1) {
  31108. if (this.inputBits === 0) {
  31109. return ccittEOF;
  31110. }
  31111. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  31112. }
  31113. this.inputBuf = this.inputBuf << 8 | c;
  31114. this.inputBits += 8;
  31115. }
  31116. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  31117. };
  31118. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  31119. if ((this.inputBits -= n) < 0) {
  31120. this.inputBits = 0;
  31121. }
  31122. };
  31123. return CCITTFaxStream;
  31124. }();
  31125. var LZWStream = function LZWStreamClosure() {
  31126. function LZWStream(str, maybeLength, earlyChange) {
  31127. this.str = str;
  31128. this.dict = str.dict;
  31129. this.cachedData = 0;
  31130. this.bitsCached = 0;
  31131. var maxLzwDictionarySize = 4096;
  31132. var lzwState = {
  31133. earlyChange: earlyChange,
  31134. codeLength: 9,
  31135. nextCode: 258,
  31136. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31137. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31138. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31139. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31140. currentSequenceLength: 0
  31141. };
  31142. for (var i = 0; i < 256; ++i) {
  31143. lzwState.dictionaryValues[i] = i;
  31144. lzwState.dictionaryLengths[i] = 1;
  31145. }
  31146. this.lzwState = lzwState;
  31147. DecodeStream.call(this, maybeLength);
  31148. }
  31149. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31150. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31151. var bitsCached = this.bitsCached;
  31152. var cachedData = this.cachedData;
  31153. while (bitsCached < n) {
  31154. var c = this.str.getByte();
  31155. if (c === -1) {
  31156. this.eof = true;
  31157. return null;
  31158. }
  31159. cachedData = cachedData << 8 | c;
  31160. bitsCached += 8;
  31161. }
  31162. this.bitsCached = bitsCached -= n;
  31163. this.cachedData = cachedData;
  31164. this.lastCode = null;
  31165. return cachedData >>> bitsCached & (1 << n) - 1;
  31166. };
  31167. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31168. var blockSize = 512;
  31169. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31170. var i, j, q;
  31171. var lzwState = this.lzwState;
  31172. if (!lzwState) {
  31173. return;
  31174. }
  31175. var earlyChange = lzwState.earlyChange;
  31176. var nextCode = lzwState.nextCode;
  31177. var dictionaryValues = lzwState.dictionaryValues;
  31178. var dictionaryLengths = lzwState.dictionaryLengths;
  31179. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31180. var codeLength = lzwState.codeLength;
  31181. var prevCode = lzwState.prevCode;
  31182. var currentSequence = lzwState.currentSequence;
  31183. var currentSequenceLength = lzwState.currentSequenceLength;
  31184. var decodedLength = 0;
  31185. var currentBufferLength = this.bufferLength;
  31186. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31187. for (i = 0; i < blockSize; i++) {
  31188. var code = this.readBits(codeLength);
  31189. var hasPrev = currentSequenceLength > 0;
  31190. if (code < 256) {
  31191. currentSequence[0] = code;
  31192. currentSequenceLength = 1;
  31193. } else if (code >= 258) {
  31194. if (code < nextCode) {
  31195. currentSequenceLength = dictionaryLengths[code];
  31196. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31197. currentSequence[j] = dictionaryValues[q];
  31198. q = dictionaryPrevCodes[q];
  31199. }
  31200. } else {
  31201. currentSequence[currentSequenceLength++] = currentSequence[0];
  31202. }
  31203. } else if (code === 256) {
  31204. codeLength = 9;
  31205. nextCode = 258;
  31206. currentSequenceLength = 0;
  31207. continue;
  31208. } else {
  31209. this.eof = true;
  31210. delete this.lzwState;
  31211. break;
  31212. }
  31213. if (hasPrev) {
  31214. dictionaryPrevCodes[nextCode] = prevCode;
  31215. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31216. dictionaryValues[nextCode] = currentSequence[0];
  31217. nextCode++;
  31218. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31219. }
  31220. prevCode = code;
  31221. decodedLength += currentSequenceLength;
  31222. if (estimatedDecodedSize < decodedLength) {
  31223. do {
  31224. estimatedDecodedSize += decodedSizeDelta;
  31225. } while (estimatedDecodedSize < decodedLength);
  31226. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31227. }
  31228. for (j = 0; j < currentSequenceLength; j++) {
  31229. buffer[currentBufferLength++] = currentSequence[j];
  31230. }
  31231. }
  31232. lzwState.nextCode = nextCode;
  31233. lzwState.codeLength = codeLength;
  31234. lzwState.prevCode = prevCode;
  31235. lzwState.currentSequenceLength = currentSequenceLength;
  31236. this.bufferLength = currentBufferLength;
  31237. };
  31238. return LZWStream;
  31239. }();
  31240. var NullStream = function NullStreamClosure() {
  31241. function NullStream() {
  31242. Stream.call(this, new Uint8Array(0));
  31243. }
  31244. NullStream.prototype = Stream.prototype;
  31245. return NullStream;
  31246. }();
  31247. exports.Ascii85Stream = Ascii85Stream;
  31248. exports.AsciiHexStream = AsciiHexStream;
  31249. exports.CCITTFaxStream = CCITTFaxStream;
  31250. exports.DecryptStream = DecryptStream;
  31251. exports.DecodeStream = DecodeStream;
  31252. exports.FlateStream = FlateStream;
  31253. exports.Jbig2Stream = Jbig2Stream;
  31254. exports.JpegStream = JpegStream;
  31255. exports.JpxStream = JpxStream;
  31256. exports.NullStream = NullStream;
  31257. exports.PredictorStream = PredictorStream;
  31258. exports.RunLengthStream = RunLengthStream;
  31259. exports.Stream = Stream;
  31260. exports.StreamsSequenceStream = StreamsSequenceStream;
  31261. exports.StringStream = StringStream;
  31262. exports.LZWStream = LZWStream;
  31263. }));
  31264. (function (root, factory) {
  31265. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31266. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31267. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31268. var AnnotationType = sharedUtil.AnnotationType;
  31269. var Util = sharedUtil.Util;
  31270. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31271. var LinkTarget = displayDOMUtils.LinkTarget;
  31272. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31273. var warn = sharedUtil.warn;
  31274. var CustomStyle = displayDOMUtils.CustomStyle;
  31275. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31276. function AnnotationElementFactory() {
  31277. }
  31278. AnnotationElementFactory.prototype = {
  31279. create: function AnnotationElementFactory_create(parameters) {
  31280. var subtype = parameters.data.annotationType;
  31281. switch (subtype) {
  31282. case AnnotationType.LINK:
  31283. return new LinkAnnotationElement(parameters);
  31284. case AnnotationType.TEXT:
  31285. return new TextAnnotationElement(parameters);
  31286. case AnnotationType.WIDGET:
  31287. var fieldType = parameters.data.fieldType;
  31288. switch (fieldType) {
  31289. case 'Tx':
  31290. return new TextWidgetAnnotationElement(parameters);
  31291. case 'Btn':
  31292. if (parameters.data.radioButton) {
  31293. return new RadioButtonWidgetAnnotationElement(parameters);
  31294. } else if (parameters.data.checkBox) {
  31295. return new CheckboxWidgetAnnotationElement(parameters);
  31296. }
  31297. warn('Unimplemented button widget annotation: pushbutton');
  31298. break;
  31299. case 'Ch':
  31300. return new ChoiceWidgetAnnotationElement(parameters);
  31301. }
  31302. return new WidgetAnnotationElement(parameters);
  31303. case AnnotationType.POPUP:
  31304. return new PopupAnnotationElement(parameters);
  31305. case AnnotationType.HIGHLIGHT:
  31306. return new HighlightAnnotationElement(parameters);
  31307. case AnnotationType.UNDERLINE:
  31308. return new UnderlineAnnotationElement(parameters);
  31309. case AnnotationType.SQUIGGLY:
  31310. return new SquigglyAnnotationElement(parameters);
  31311. case AnnotationType.STRIKEOUT:
  31312. return new StrikeOutAnnotationElement(parameters);
  31313. case AnnotationType.FILEATTACHMENT:
  31314. return new FileAttachmentAnnotationElement(parameters);
  31315. default:
  31316. return new AnnotationElement(parameters);
  31317. }
  31318. }
  31319. };
  31320. var AnnotationElement = function AnnotationElementClosure() {
  31321. function AnnotationElement(parameters, isRenderable) {
  31322. this.isRenderable = isRenderable || false;
  31323. this.data = parameters.data;
  31324. this.layer = parameters.layer;
  31325. this.page = parameters.page;
  31326. this.viewport = parameters.viewport;
  31327. this.linkService = parameters.linkService;
  31328. this.downloadManager = parameters.downloadManager;
  31329. this.imageResourcesPath = parameters.imageResourcesPath;
  31330. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31331. if (isRenderable) {
  31332. this.container = this._createContainer();
  31333. }
  31334. }
  31335. AnnotationElement.prototype = {
  31336. _createContainer: function AnnotationElement_createContainer() {
  31337. var data = this.data, page = this.page, viewport = this.viewport;
  31338. var container = document.createElement('section');
  31339. var width = data.rect[2] - data.rect[0];
  31340. var height = data.rect[3] - data.rect[1];
  31341. container.setAttribute('data-annotation-id', data.id);
  31342. var rect = Util.normalizeRect([
  31343. data.rect[0],
  31344. page.view[3] - data.rect[1] + page.view[1],
  31345. data.rect[2],
  31346. page.view[3] - data.rect[3] + page.view[1]
  31347. ]);
  31348. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31349. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31350. if (data.borderStyle.width > 0) {
  31351. container.style.borderWidth = data.borderStyle.width + 'px';
  31352. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31353. width = width - 2 * data.borderStyle.width;
  31354. height = height - 2 * data.borderStyle.width;
  31355. }
  31356. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31357. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31358. if (horizontalRadius > 0 || verticalRadius > 0) {
  31359. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31360. CustomStyle.setProp('borderRadius', container, radius);
  31361. }
  31362. switch (data.borderStyle.style) {
  31363. case AnnotationBorderStyleType.SOLID:
  31364. container.style.borderStyle = 'solid';
  31365. break;
  31366. case AnnotationBorderStyleType.DASHED:
  31367. container.style.borderStyle = 'dashed';
  31368. break;
  31369. case AnnotationBorderStyleType.BEVELED:
  31370. warn('Unimplemented border style: beveled');
  31371. break;
  31372. case AnnotationBorderStyleType.INSET:
  31373. warn('Unimplemented border style: inset');
  31374. break;
  31375. case AnnotationBorderStyleType.UNDERLINE:
  31376. container.style.borderBottomStyle = 'solid';
  31377. break;
  31378. default:
  31379. break;
  31380. }
  31381. if (data.color) {
  31382. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31383. } else {
  31384. container.style.borderWidth = 0;
  31385. }
  31386. }
  31387. container.style.left = rect[0] + 'px';
  31388. container.style.top = rect[1] + 'px';
  31389. container.style.width = width + 'px';
  31390. container.style.height = height + 'px';
  31391. return container;
  31392. },
  31393. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31394. if (!trigger) {
  31395. trigger = document.createElement('div');
  31396. trigger.style.height = container.style.height;
  31397. trigger.style.width = container.style.width;
  31398. container.appendChild(trigger);
  31399. }
  31400. var popupElement = new PopupElement({
  31401. container: container,
  31402. trigger: trigger,
  31403. color: data.color,
  31404. title: data.title,
  31405. contents: data.contents,
  31406. hideWrapper: true
  31407. });
  31408. var popup = popupElement.render();
  31409. popup.style.left = container.style.width;
  31410. container.appendChild(popup);
  31411. },
  31412. render: function AnnotationElement_render() {
  31413. throw new Error('Abstract method AnnotationElement.render called');
  31414. }
  31415. };
  31416. return AnnotationElement;
  31417. }();
  31418. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31419. function LinkAnnotationElement(parameters) {
  31420. AnnotationElement.call(this, parameters, true);
  31421. }
  31422. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31423. render: function LinkAnnotationElement_render() {
  31424. this.container.className = 'linkAnnotation';
  31425. var link = document.createElement('a');
  31426. addLinkAttributes(link, {
  31427. url: this.data.url,
  31428. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31429. });
  31430. if (!this.data.url) {
  31431. if (this.data.action) {
  31432. this._bindNamedAction(link, this.data.action);
  31433. } else {
  31434. this._bindLink(link, this.data.dest);
  31435. }
  31436. }
  31437. this.container.appendChild(link);
  31438. return this.container;
  31439. },
  31440. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31441. var self = this;
  31442. link.href = this.linkService.getDestinationHash(destination);
  31443. link.onclick = function () {
  31444. if (destination) {
  31445. self.linkService.navigateTo(destination);
  31446. }
  31447. return false;
  31448. };
  31449. if (destination) {
  31450. link.className = 'internalLink';
  31451. }
  31452. },
  31453. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31454. var self = this;
  31455. link.href = this.linkService.getAnchorUrl('');
  31456. link.onclick = function () {
  31457. self.linkService.executeNamedAction(action);
  31458. return false;
  31459. };
  31460. link.className = 'internalLink';
  31461. }
  31462. });
  31463. return LinkAnnotationElement;
  31464. }();
  31465. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31466. function TextAnnotationElement(parameters) {
  31467. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31468. AnnotationElement.call(this, parameters, isRenderable);
  31469. }
  31470. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31471. render: function TextAnnotationElement_render() {
  31472. this.container.className = 'textAnnotation';
  31473. var image = document.createElement('img');
  31474. image.style.height = this.container.style.height;
  31475. image.style.width = this.container.style.width;
  31476. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31477. image.alt = '[{{type}} Annotation]';
  31478. image.dataset.l10nId = 'text_annotation_type';
  31479. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31480. if (!this.data.hasPopup) {
  31481. this._createPopup(this.container, image, this.data);
  31482. }
  31483. this.container.appendChild(image);
  31484. return this.container;
  31485. }
  31486. });
  31487. return TextAnnotationElement;
  31488. }();
  31489. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31490. function WidgetAnnotationElement(parameters, isRenderable) {
  31491. AnnotationElement.call(this, parameters, isRenderable);
  31492. }
  31493. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31494. render: function WidgetAnnotationElement_render() {
  31495. return this.container;
  31496. }
  31497. });
  31498. return WidgetAnnotationElement;
  31499. }();
  31500. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31501. var TEXT_ALIGNMENT = [
  31502. 'left',
  31503. 'center',
  31504. 'right'
  31505. ];
  31506. function TextWidgetAnnotationElement(parameters) {
  31507. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31508. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31509. }
  31510. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31511. render: function TextWidgetAnnotationElement_render() {
  31512. this.container.className = 'textWidgetAnnotation';
  31513. var element = null;
  31514. if (this.renderInteractiveForms) {
  31515. if (this.data.multiLine) {
  31516. element = document.createElement('textarea');
  31517. element.textContent = this.data.fieldValue;
  31518. } else {
  31519. element = document.createElement('input');
  31520. element.type = 'text';
  31521. element.setAttribute('value', this.data.fieldValue);
  31522. }
  31523. element.disabled = this.data.readOnly;
  31524. if (this.data.maxLen !== null) {
  31525. element.maxLength = this.data.maxLen;
  31526. }
  31527. if (this.data.comb) {
  31528. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31529. var combWidth = fieldWidth / this.data.maxLen;
  31530. element.classList.add('comb');
  31531. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31532. }
  31533. } else {
  31534. element = document.createElement('div');
  31535. element.textContent = this.data.fieldValue;
  31536. element.style.verticalAlign = 'middle';
  31537. element.style.display = 'table-cell';
  31538. var font = null;
  31539. if (this.data.fontRefName) {
  31540. font = this.page.commonObjs.getData(this.data.fontRefName);
  31541. }
  31542. this._setTextStyle(element, font);
  31543. }
  31544. if (this.data.textAlignment !== null) {
  31545. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31546. }
  31547. this.container.appendChild(element);
  31548. return this.container;
  31549. },
  31550. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31551. var style = element.style;
  31552. style.fontSize = this.data.fontSize + 'px';
  31553. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31554. if (!font) {
  31555. return;
  31556. }
  31557. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31558. style.fontStyle = font.italic ? 'italic' : 'normal';
  31559. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31560. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31561. style.fontFamily = fontFamily + fallbackName;
  31562. }
  31563. });
  31564. return TextWidgetAnnotationElement;
  31565. }();
  31566. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  31567. function CheckboxWidgetAnnotationElement(parameters) {
  31568. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31569. }
  31570. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  31571. render: function CheckboxWidgetAnnotationElement_render() {
  31572. this.container.className = 'buttonWidgetAnnotation checkBox';
  31573. var element = document.createElement('input');
  31574. element.disabled = this.data.readOnly;
  31575. element.type = 'checkbox';
  31576. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  31577. element.setAttribute('checked', true);
  31578. }
  31579. this.container.appendChild(element);
  31580. return this.container;
  31581. }
  31582. });
  31583. return CheckboxWidgetAnnotationElement;
  31584. }();
  31585. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  31586. function RadioButtonWidgetAnnotationElement(parameters) {
  31587. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31588. }
  31589. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  31590. render: function RadioButtonWidgetAnnotationElement_render() {
  31591. this.container.className = 'buttonWidgetAnnotation radioButton';
  31592. var element = document.createElement('input');
  31593. element.disabled = this.data.readOnly;
  31594. element.type = 'radio';
  31595. element.name = this.data.fieldName;
  31596. if (this.data.fieldValue === this.data.buttonValue) {
  31597. element.setAttribute('checked', true);
  31598. }
  31599. this.container.appendChild(element);
  31600. return this.container;
  31601. }
  31602. });
  31603. return RadioButtonWidgetAnnotationElement;
  31604. }();
  31605. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31606. function ChoiceWidgetAnnotationElement(parameters) {
  31607. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31608. }
  31609. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31610. render: function ChoiceWidgetAnnotationElement_render() {
  31611. this.container.className = 'choiceWidgetAnnotation';
  31612. var selectElement = document.createElement('select');
  31613. selectElement.disabled = this.data.readOnly;
  31614. if (!this.data.combo) {
  31615. selectElement.size = this.data.options.length;
  31616. if (this.data.multiSelect) {
  31617. selectElement.multiple = true;
  31618. }
  31619. }
  31620. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31621. var option = this.data.options[i];
  31622. var optionElement = document.createElement('option');
  31623. optionElement.textContent = option.displayValue;
  31624. optionElement.value = option.exportValue;
  31625. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31626. optionElement.setAttribute('selected', true);
  31627. }
  31628. selectElement.appendChild(optionElement);
  31629. }
  31630. this.container.appendChild(selectElement);
  31631. return this.container;
  31632. }
  31633. });
  31634. return ChoiceWidgetAnnotationElement;
  31635. }();
  31636. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31637. function PopupAnnotationElement(parameters) {
  31638. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31639. AnnotationElement.call(this, parameters, isRenderable);
  31640. }
  31641. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31642. render: function PopupAnnotationElement_render() {
  31643. this.container.className = 'popupAnnotation';
  31644. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31645. var parentElement = this.layer.querySelector(selector);
  31646. if (!parentElement) {
  31647. return this.container;
  31648. }
  31649. var popup = new PopupElement({
  31650. container: this.container,
  31651. trigger: parentElement,
  31652. color: this.data.color,
  31653. title: this.data.title,
  31654. contents: this.data.contents
  31655. });
  31656. var parentLeft = parseFloat(parentElement.style.left);
  31657. var parentWidth = parseFloat(parentElement.style.width);
  31658. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31659. this.container.style.left = parentLeft + parentWidth + 'px';
  31660. this.container.appendChild(popup.render());
  31661. return this.container;
  31662. }
  31663. });
  31664. return PopupAnnotationElement;
  31665. }();
  31666. var PopupElement = function PopupElementClosure() {
  31667. var BACKGROUND_ENLIGHT = 0.7;
  31668. function PopupElement(parameters) {
  31669. this.container = parameters.container;
  31670. this.trigger = parameters.trigger;
  31671. this.color = parameters.color;
  31672. this.title = parameters.title;
  31673. this.contents = parameters.contents;
  31674. this.hideWrapper = parameters.hideWrapper || false;
  31675. this.pinned = false;
  31676. }
  31677. PopupElement.prototype = {
  31678. render: function PopupElement_render() {
  31679. var wrapper = document.createElement('div');
  31680. wrapper.className = 'popupWrapper';
  31681. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31682. this.hideElement.setAttribute('hidden', true);
  31683. var popup = document.createElement('div');
  31684. popup.className = 'popup';
  31685. var color = this.color;
  31686. if (color) {
  31687. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31688. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31689. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31690. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31691. }
  31692. var contents = this._formatContents(this.contents);
  31693. var title = document.createElement('h1');
  31694. title.textContent = this.title;
  31695. this.trigger.addEventListener('click', this._toggle.bind(this));
  31696. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31697. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31698. popup.addEventListener('click', this._hide.bind(this, true));
  31699. popup.appendChild(title);
  31700. popup.appendChild(contents);
  31701. wrapper.appendChild(popup);
  31702. return wrapper;
  31703. },
  31704. _formatContents: function PopupElement_formatContents(contents) {
  31705. var p = document.createElement('p');
  31706. var lines = contents.split(/(?:\r\n?|\n)/);
  31707. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31708. var line = lines[i];
  31709. p.appendChild(document.createTextNode(line));
  31710. if (i < ii - 1) {
  31711. p.appendChild(document.createElement('br'));
  31712. }
  31713. }
  31714. return p;
  31715. },
  31716. _toggle: function PopupElement_toggle() {
  31717. if (this.pinned) {
  31718. this._hide(true);
  31719. } else {
  31720. this._show(true);
  31721. }
  31722. },
  31723. _show: function PopupElement_show(pin) {
  31724. if (pin) {
  31725. this.pinned = true;
  31726. }
  31727. if (this.hideElement.hasAttribute('hidden')) {
  31728. this.hideElement.removeAttribute('hidden');
  31729. this.container.style.zIndex += 1;
  31730. }
  31731. },
  31732. _hide: function PopupElement_hide(unpin) {
  31733. if (unpin) {
  31734. this.pinned = false;
  31735. }
  31736. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31737. this.hideElement.setAttribute('hidden', true);
  31738. this.container.style.zIndex -= 1;
  31739. }
  31740. }
  31741. };
  31742. return PopupElement;
  31743. }();
  31744. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31745. function HighlightAnnotationElement(parameters) {
  31746. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31747. AnnotationElement.call(this, parameters, isRenderable);
  31748. }
  31749. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31750. render: function HighlightAnnotationElement_render() {
  31751. this.container.className = 'highlightAnnotation';
  31752. if (!this.data.hasPopup) {
  31753. this._createPopup(this.container, null, this.data);
  31754. }
  31755. return this.container;
  31756. }
  31757. });
  31758. return HighlightAnnotationElement;
  31759. }();
  31760. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31761. function UnderlineAnnotationElement(parameters) {
  31762. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31763. AnnotationElement.call(this, parameters, isRenderable);
  31764. }
  31765. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31766. render: function UnderlineAnnotationElement_render() {
  31767. this.container.className = 'underlineAnnotation';
  31768. if (!this.data.hasPopup) {
  31769. this._createPopup(this.container, null, this.data);
  31770. }
  31771. return this.container;
  31772. }
  31773. });
  31774. return UnderlineAnnotationElement;
  31775. }();
  31776. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31777. function SquigglyAnnotationElement(parameters) {
  31778. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31779. AnnotationElement.call(this, parameters, isRenderable);
  31780. }
  31781. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31782. render: function SquigglyAnnotationElement_render() {
  31783. this.container.className = 'squigglyAnnotation';
  31784. if (!this.data.hasPopup) {
  31785. this._createPopup(this.container, null, this.data);
  31786. }
  31787. return this.container;
  31788. }
  31789. });
  31790. return SquigglyAnnotationElement;
  31791. }();
  31792. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31793. function StrikeOutAnnotationElement(parameters) {
  31794. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31795. AnnotationElement.call(this, parameters, isRenderable);
  31796. }
  31797. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31798. render: function StrikeOutAnnotationElement_render() {
  31799. this.container.className = 'strikeoutAnnotation';
  31800. if (!this.data.hasPopup) {
  31801. this._createPopup(this.container, null, this.data);
  31802. }
  31803. return this.container;
  31804. }
  31805. });
  31806. return StrikeOutAnnotationElement;
  31807. }();
  31808. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31809. function FileAttachmentAnnotationElement(parameters) {
  31810. AnnotationElement.call(this, parameters, true);
  31811. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31812. this.content = parameters.data.file.content;
  31813. }
  31814. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31815. render: function FileAttachmentAnnotationElement_render() {
  31816. this.container.className = 'fileAttachmentAnnotation';
  31817. var trigger = document.createElement('div');
  31818. trigger.style.height = this.container.style.height;
  31819. trigger.style.width = this.container.style.width;
  31820. trigger.addEventListener('dblclick', this._download.bind(this));
  31821. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31822. this._createPopup(this.container, trigger, this.data);
  31823. }
  31824. this.container.appendChild(trigger);
  31825. return this.container;
  31826. },
  31827. _download: function FileAttachmentAnnotationElement_download() {
  31828. if (!this.downloadManager) {
  31829. warn('Download cannot be started due to unavailable download manager');
  31830. return;
  31831. }
  31832. this.downloadManager.downloadData(this.content, this.filename, '');
  31833. }
  31834. });
  31835. return FileAttachmentAnnotationElement;
  31836. }();
  31837. var AnnotationLayer = function AnnotationLayerClosure() {
  31838. return {
  31839. render: function AnnotationLayer_render(parameters) {
  31840. var annotationElementFactory = new AnnotationElementFactory();
  31841. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31842. var data = parameters.annotations[i];
  31843. if (!data) {
  31844. continue;
  31845. }
  31846. var properties = {
  31847. data: data,
  31848. layer: parameters.div,
  31849. page: parameters.page,
  31850. viewport: parameters.viewport,
  31851. linkService: parameters.linkService,
  31852. downloadManager: parameters.downloadManager,
  31853. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31854. renderInteractiveForms: parameters.renderInteractiveForms || false
  31855. };
  31856. var element = annotationElementFactory.create(properties);
  31857. if (element.isRenderable) {
  31858. parameters.div.appendChild(element.render());
  31859. }
  31860. }
  31861. },
  31862. update: function AnnotationLayer_update(parameters) {
  31863. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31864. var data = parameters.annotations[i];
  31865. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31866. if (element) {
  31867. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31868. }
  31869. }
  31870. parameters.div.removeAttribute('hidden');
  31871. }
  31872. };
  31873. }();
  31874. exports.AnnotationLayer = AnnotationLayer;
  31875. }));
  31876. (function (root, factory) {
  31877. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31878. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31879. var Util = sharedUtil.Util;
  31880. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31881. var CustomStyle = displayDOMUtils.CustomStyle;
  31882. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31883. var renderTextLayer = function renderTextLayerClosure() {
  31884. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31885. var NonWhitespaceRegexp = /\S/;
  31886. function isAllWhitespace(str) {
  31887. return !NonWhitespaceRegexp.test(str);
  31888. }
  31889. var styleBuf = [
  31890. 'left: ',
  31891. 0,
  31892. 'px; top: ',
  31893. 0,
  31894. 'px; font-size: ',
  31895. 0,
  31896. 'px; font-family: ',
  31897. '',
  31898. ';'
  31899. ];
  31900. function appendText(task, geom, styles) {
  31901. var textDiv = document.createElement('div');
  31902. var textDivProperties = {
  31903. style: null,
  31904. angle: 0,
  31905. canvasWidth: 0,
  31906. isWhitespace: false,
  31907. originalTransform: null,
  31908. paddingBottom: 0,
  31909. paddingLeft: 0,
  31910. paddingRight: 0,
  31911. paddingTop: 0,
  31912. scale: 1
  31913. };
  31914. task._textDivs.push(textDiv);
  31915. if (isAllWhitespace(geom.str)) {
  31916. textDivProperties.isWhitespace = true;
  31917. task._textDivProperties.set(textDiv, textDivProperties);
  31918. return;
  31919. }
  31920. var tx = Util.transform(task._viewport.transform, geom.transform);
  31921. var angle = Math.atan2(tx[1], tx[0]);
  31922. var style = styles[geom.fontName];
  31923. if (style.vertical) {
  31924. angle += Math.PI / 2;
  31925. }
  31926. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31927. var fontAscent = fontHeight;
  31928. if (style.ascent) {
  31929. fontAscent = style.ascent * fontAscent;
  31930. } else if (style.descent) {
  31931. fontAscent = (1 + style.descent) * fontAscent;
  31932. }
  31933. var left;
  31934. var top;
  31935. if (angle === 0) {
  31936. left = tx[4];
  31937. top = tx[5] - fontAscent;
  31938. } else {
  31939. left = tx[4] + fontAscent * Math.sin(angle);
  31940. top = tx[5] - fontAscent * Math.cos(angle);
  31941. }
  31942. styleBuf[1] = left;
  31943. styleBuf[3] = top;
  31944. styleBuf[5] = fontHeight;
  31945. styleBuf[7] = style.fontFamily;
  31946. textDivProperties.style = styleBuf.join('');
  31947. textDiv.setAttribute('style', textDivProperties.style);
  31948. textDiv.textContent = geom.str;
  31949. if (getDefaultSetting('pdfBug')) {
  31950. textDiv.dataset.fontName = geom.fontName;
  31951. }
  31952. if (angle !== 0) {
  31953. textDivProperties.angle = angle * (180 / Math.PI);
  31954. }
  31955. if (geom.str.length > 1) {
  31956. if (style.vertical) {
  31957. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31958. } else {
  31959. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31960. }
  31961. }
  31962. task._textDivProperties.set(textDiv, textDivProperties);
  31963. if (task._enhanceTextSelection) {
  31964. var angleCos = 1, angleSin = 0;
  31965. if (angle !== 0) {
  31966. angleCos = Math.cos(angle);
  31967. angleSin = Math.sin(angle);
  31968. }
  31969. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31970. var divHeight = fontHeight;
  31971. var m, b;
  31972. if (angle !== 0) {
  31973. m = [
  31974. angleCos,
  31975. angleSin,
  31976. -angleSin,
  31977. angleCos,
  31978. left,
  31979. top
  31980. ];
  31981. b = Util.getAxialAlignedBoundingBox([
  31982. 0,
  31983. 0,
  31984. divWidth,
  31985. divHeight
  31986. ], m);
  31987. } else {
  31988. b = [
  31989. left,
  31990. top,
  31991. left + divWidth,
  31992. top + divHeight
  31993. ];
  31994. }
  31995. task._bounds.push({
  31996. left: b[0],
  31997. top: b[1],
  31998. right: b[2],
  31999. bottom: b[3],
  32000. div: textDiv,
  32001. size: [
  32002. divWidth,
  32003. divHeight
  32004. ],
  32005. m: m
  32006. });
  32007. }
  32008. }
  32009. function render(task) {
  32010. if (task._canceled) {
  32011. return;
  32012. }
  32013. var textLayerFrag = task._container;
  32014. var textDivs = task._textDivs;
  32015. var capability = task._capability;
  32016. var textDivsLength = textDivs.length;
  32017. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  32018. task._renderingDone = true;
  32019. capability.resolve();
  32020. return;
  32021. }
  32022. var canvas = document.createElement('canvas');
  32023. var ctx = canvas.getContext('2d', { alpha: false });
  32024. var lastFontSize;
  32025. var lastFontFamily;
  32026. for (var i = 0; i < textDivsLength; i++) {
  32027. var textDiv = textDivs[i];
  32028. var textDivProperties = task._textDivProperties.get(textDiv);
  32029. if (textDivProperties.isWhitespace) {
  32030. continue;
  32031. }
  32032. var fontSize = textDiv.style.fontSize;
  32033. var fontFamily = textDiv.style.fontFamily;
  32034. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  32035. ctx.font = fontSize + ' ' + fontFamily;
  32036. lastFontSize = fontSize;
  32037. lastFontFamily = fontFamily;
  32038. }
  32039. var width = ctx.measureText(textDiv.textContent).width;
  32040. textLayerFrag.appendChild(textDiv);
  32041. var transform = '';
  32042. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  32043. textDivProperties.scale = textDivProperties.canvasWidth / width;
  32044. transform = 'scaleX(' + textDivProperties.scale + ')';
  32045. }
  32046. if (textDivProperties.angle !== 0) {
  32047. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  32048. }
  32049. if (transform !== '') {
  32050. textDivProperties.originalTransform = transform;
  32051. CustomStyle.setProp('transform', textDiv, transform);
  32052. }
  32053. task._textDivProperties.set(textDiv, textDivProperties);
  32054. }
  32055. task._renderingDone = true;
  32056. capability.resolve();
  32057. }
  32058. function expand(task) {
  32059. var bounds = task._bounds;
  32060. var viewport = task._viewport;
  32061. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  32062. for (var i = 0; i < expanded.length; i++) {
  32063. var div = bounds[i].div;
  32064. var divProperties = task._textDivProperties.get(div);
  32065. if (divProperties.angle === 0) {
  32066. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  32067. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  32068. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  32069. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  32070. task._textDivProperties.set(div, divProperties);
  32071. continue;
  32072. }
  32073. var e = expanded[i], b = bounds[i];
  32074. var m = b.m, c = m[0], s = m[1];
  32075. var points = [
  32076. [
  32077. 0,
  32078. 0
  32079. ],
  32080. [
  32081. 0,
  32082. b.size[1]
  32083. ],
  32084. [
  32085. b.size[0],
  32086. 0
  32087. ],
  32088. b.size
  32089. ];
  32090. var ts = new Float64Array(64);
  32091. points.forEach(function (p, i) {
  32092. var t = Util.applyTransform(p, m);
  32093. ts[i + 0] = c && (e.left - t[0]) / c;
  32094. ts[i + 4] = s && (e.top - t[1]) / s;
  32095. ts[i + 8] = c && (e.right - t[0]) / c;
  32096. ts[i + 12] = s && (e.bottom - t[1]) / s;
  32097. ts[i + 16] = s && (e.left - t[0]) / -s;
  32098. ts[i + 20] = c && (e.top - t[1]) / c;
  32099. ts[i + 24] = s && (e.right - t[0]) / -s;
  32100. ts[i + 28] = c && (e.bottom - t[1]) / c;
  32101. ts[i + 32] = c && (e.left - t[0]) / -c;
  32102. ts[i + 36] = s && (e.top - t[1]) / -s;
  32103. ts[i + 40] = c && (e.right - t[0]) / -c;
  32104. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  32105. ts[i + 48] = s && (e.left - t[0]) / s;
  32106. ts[i + 52] = c && (e.top - t[1]) / -c;
  32107. ts[i + 56] = s && (e.right - t[0]) / s;
  32108. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  32109. });
  32110. var findPositiveMin = function (ts, offset, count) {
  32111. var result = 0;
  32112. for (var i = 0; i < count; i++) {
  32113. var t = ts[offset++];
  32114. if (t > 0) {
  32115. result = result ? Math.min(t, result) : t;
  32116. }
  32117. }
  32118. return result;
  32119. };
  32120. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  32121. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  32122. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  32123. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  32124. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  32125. task._textDivProperties.set(div, divProperties);
  32126. }
  32127. }
  32128. function expandBounds(width, height, boxes) {
  32129. var bounds = boxes.map(function (box, i) {
  32130. return {
  32131. x1: box.left,
  32132. y1: box.top,
  32133. x2: box.right,
  32134. y2: box.bottom,
  32135. index: i,
  32136. x1New: undefined,
  32137. x2New: undefined
  32138. };
  32139. });
  32140. expandBoundsLTR(width, bounds);
  32141. var expanded = new Array(boxes.length);
  32142. bounds.forEach(function (b) {
  32143. var i = b.index;
  32144. expanded[i] = {
  32145. left: b.x1New,
  32146. top: 0,
  32147. right: b.x2New,
  32148. bottom: 0
  32149. };
  32150. });
  32151. boxes.map(function (box, i) {
  32152. var e = expanded[i], b = bounds[i];
  32153. b.x1 = box.top;
  32154. b.y1 = width - e.right;
  32155. b.x2 = box.bottom;
  32156. b.y2 = width - e.left;
  32157. b.index = i;
  32158. b.x1New = undefined;
  32159. b.x2New = undefined;
  32160. });
  32161. expandBoundsLTR(height, bounds);
  32162. bounds.forEach(function (b) {
  32163. var i = b.index;
  32164. expanded[i].top = b.x1New;
  32165. expanded[i].bottom = b.x2New;
  32166. });
  32167. return expanded;
  32168. }
  32169. function expandBoundsLTR(width, bounds) {
  32170. bounds.sort(function (a, b) {
  32171. return a.x1 - b.x1 || a.index - b.index;
  32172. });
  32173. var fakeBoundary = {
  32174. x1: -Infinity,
  32175. y1: -Infinity,
  32176. x2: 0,
  32177. y2: Infinity,
  32178. index: -1,
  32179. x1New: 0,
  32180. x2New: 0
  32181. };
  32182. var horizon = [{
  32183. start: -Infinity,
  32184. end: Infinity,
  32185. boundary: fakeBoundary
  32186. }];
  32187. bounds.forEach(function (boundary) {
  32188. var i = 0;
  32189. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32190. i++;
  32191. }
  32192. var j = horizon.length - 1;
  32193. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32194. j--;
  32195. }
  32196. var horizonPart, affectedBoundary;
  32197. var q, k, maxXNew = -Infinity;
  32198. for (q = i; q <= j; q++) {
  32199. horizonPart = horizon[q];
  32200. affectedBoundary = horizonPart.boundary;
  32201. var xNew;
  32202. if (affectedBoundary.x2 > boundary.x1) {
  32203. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32204. } else if (affectedBoundary.x2New === undefined) {
  32205. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32206. } else {
  32207. xNew = affectedBoundary.x2New;
  32208. }
  32209. if (xNew > maxXNew) {
  32210. maxXNew = xNew;
  32211. }
  32212. }
  32213. boundary.x1New = maxXNew;
  32214. for (q = i; q <= j; q++) {
  32215. horizonPart = horizon[q];
  32216. affectedBoundary = horizonPart.boundary;
  32217. if (affectedBoundary.x2New === undefined) {
  32218. if (affectedBoundary.x2 > boundary.x1) {
  32219. if (affectedBoundary.index > boundary.index) {
  32220. affectedBoundary.x2New = affectedBoundary.x2;
  32221. }
  32222. } else {
  32223. affectedBoundary.x2New = maxXNew;
  32224. }
  32225. } else if (affectedBoundary.x2New > maxXNew) {
  32226. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32227. }
  32228. }
  32229. var changedHorizon = [], lastBoundary = null;
  32230. for (q = i; q <= j; q++) {
  32231. horizonPart = horizon[q];
  32232. affectedBoundary = horizonPart.boundary;
  32233. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32234. if (lastBoundary === useBoundary) {
  32235. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32236. } else {
  32237. changedHorizon.push({
  32238. start: horizonPart.start,
  32239. end: horizonPart.end,
  32240. boundary: useBoundary
  32241. });
  32242. lastBoundary = useBoundary;
  32243. }
  32244. }
  32245. if (horizon[i].start < boundary.y1) {
  32246. changedHorizon[0].start = boundary.y1;
  32247. changedHorizon.unshift({
  32248. start: horizon[i].start,
  32249. end: boundary.y1,
  32250. boundary: horizon[i].boundary
  32251. });
  32252. }
  32253. if (boundary.y2 < horizon[j].end) {
  32254. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32255. changedHorizon.push({
  32256. start: boundary.y2,
  32257. end: horizon[j].end,
  32258. boundary: horizon[j].boundary
  32259. });
  32260. }
  32261. for (q = i; q <= j; q++) {
  32262. horizonPart = horizon[q];
  32263. affectedBoundary = horizonPart.boundary;
  32264. if (affectedBoundary.x2New !== undefined) {
  32265. continue;
  32266. }
  32267. var used = false;
  32268. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32269. used = horizon[k].boundary === affectedBoundary;
  32270. }
  32271. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32272. used = horizon[k].boundary === affectedBoundary;
  32273. }
  32274. for (k = 0; !used && k < changedHorizon.length; k++) {
  32275. used = changedHorizon[k].boundary === affectedBoundary;
  32276. }
  32277. if (!used) {
  32278. affectedBoundary.x2New = maxXNew;
  32279. }
  32280. }
  32281. Array.prototype.splice.apply(horizon, [
  32282. i,
  32283. j - i + 1
  32284. ].concat(changedHorizon));
  32285. });
  32286. horizon.forEach(function (horizonPart) {
  32287. var affectedBoundary = horizonPart.boundary;
  32288. if (affectedBoundary.x2New === undefined) {
  32289. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32290. }
  32291. });
  32292. }
  32293. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32294. this._textContent = textContent;
  32295. this._container = container;
  32296. this._viewport = viewport;
  32297. this._textDivs = textDivs || [];
  32298. this._textDivProperties = new WeakMap();
  32299. this._renderingDone = false;
  32300. this._canceled = false;
  32301. this._capability = createPromiseCapability();
  32302. this._renderTimer = null;
  32303. this._bounds = [];
  32304. this._enhanceTextSelection = !!enhanceTextSelection;
  32305. }
  32306. TextLayerRenderTask.prototype = {
  32307. get promise() {
  32308. return this._capability.promise;
  32309. },
  32310. cancel: function TextLayer_cancel() {
  32311. this._canceled = true;
  32312. if (this._renderTimer !== null) {
  32313. clearTimeout(this._renderTimer);
  32314. this._renderTimer = null;
  32315. }
  32316. this._capability.reject('canceled');
  32317. },
  32318. _render: function TextLayer_render(timeout) {
  32319. var textItems = this._textContent.items;
  32320. var textStyles = this._textContent.styles;
  32321. for (var i = 0, len = textItems.length; i < len; i++) {
  32322. appendText(this, textItems[i], textStyles);
  32323. }
  32324. if (!timeout) {
  32325. render(this);
  32326. } else {
  32327. var self = this;
  32328. this._renderTimer = setTimeout(function () {
  32329. render(self);
  32330. self._renderTimer = null;
  32331. }, timeout);
  32332. }
  32333. },
  32334. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32335. if (!this._enhanceTextSelection || !this._renderingDone) {
  32336. return;
  32337. }
  32338. if (this._bounds !== null) {
  32339. expand(this);
  32340. this._bounds = null;
  32341. }
  32342. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32343. var div = this._textDivs[i];
  32344. var divProperties = this._textDivProperties.get(div);
  32345. if (divProperties.isWhitespace) {
  32346. continue;
  32347. }
  32348. if (expandDivs) {
  32349. var transform = '', padding = '';
  32350. if (divProperties.scale !== 1) {
  32351. transform = 'scaleX(' + divProperties.scale + ')';
  32352. }
  32353. if (divProperties.angle !== 0) {
  32354. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32355. }
  32356. if (divProperties.paddingLeft !== 0) {
  32357. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32358. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32359. }
  32360. if (divProperties.paddingTop !== 0) {
  32361. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32362. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32363. }
  32364. if (divProperties.paddingRight !== 0) {
  32365. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32366. }
  32367. if (divProperties.paddingBottom !== 0) {
  32368. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32369. }
  32370. if (padding !== '') {
  32371. div.setAttribute('style', divProperties.style + padding);
  32372. }
  32373. if (transform !== '') {
  32374. CustomStyle.setProp('transform', div, transform);
  32375. }
  32376. } else {
  32377. div.style.padding = 0;
  32378. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32379. }
  32380. }
  32381. }
  32382. };
  32383. function renderTextLayer(renderParameters) {
  32384. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32385. task._render(renderParameters.timeout);
  32386. return task;
  32387. }
  32388. return renderTextLayer;
  32389. }();
  32390. exports.renderTextLayer = renderTextLayer;
  32391. }));
  32392. (function (root, factory) {
  32393. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32394. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32395. var shadow = sharedUtil.shadow;
  32396. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32397. var WebGLUtils = function WebGLUtilsClosure() {
  32398. function loadShader(gl, code, shaderType) {
  32399. var shader = gl.createShader(shaderType);
  32400. gl.shaderSource(shader, code);
  32401. gl.compileShader(shader);
  32402. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32403. if (!compiled) {
  32404. var errorMsg = gl.getShaderInfoLog(shader);
  32405. throw new Error('Error during shader compilation: ' + errorMsg);
  32406. }
  32407. return shader;
  32408. }
  32409. function createVertexShader(gl, code) {
  32410. return loadShader(gl, code, gl.VERTEX_SHADER);
  32411. }
  32412. function createFragmentShader(gl, code) {
  32413. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32414. }
  32415. function createProgram(gl, shaders) {
  32416. var program = gl.createProgram();
  32417. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32418. gl.attachShader(program, shaders[i]);
  32419. }
  32420. gl.linkProgram(program);
  32421. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32422. if (!linked) {
  32423. var errorMsg = gl.getProgramInfoLog(program);
  32424. throw new Error('Error during program linking: ' + errorMsg);
  32425. }
  32426. return program;
  32427. }
  32428. function createTexture(gl, image, textureId) {
  32429. gl.activeTexture(textureId);
  32430. var texture = gl.createTexture();
  32431. gl.bindTexture(gl.TEXTURE_2D, texture);
  32432. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32433. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32434. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32435. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32436. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32437. return texture;
  32438. }
  32439. var currentGL, currentCanvas;
  32440. function generateGL() {
  32441. if (currentGL) {
  32442. return;
  32443. }
  32444. currentCanvas = document.createElement('canvas');
  32445. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32446. }
  32447. var smaskVertexShaderCode = '\
  32448. attribute vec2 a_position; \
  32449. attribute vec2 a_texCoord; \
  32450. \
  32451. uniform vec2 u_resolution; \
  32452. \
  32453. varying vec2 v_texCoord; \
  32454. \
  32455. void main() { \
  32456. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32457. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32458. \
  32459. v_texCoord = a_texCoord; \
  32460. } ';
  32461. var smaskFragmentShaderCode = '\
  32462. precision mediump float; \
  32463. \
  32464. uniform vec4 u_backdrop; \
  32465. uniform int u_subtype; \
  32466. uniform sampler2D u_image; \
  32467. uniform sampler2D u_mask; \
  32468. \
  32469. varying vec2 v_texCoord; \
  32470. \
  32471. void main() { \
  32472. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32473. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32474. if (u_backdrop.a > 0.0) { \
  32475. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32476. u_backdrop.rgb * (1.0 - maskColor.a); \
  32477. } \
  32478. float lum; \
  32479. if (u_subtype == 0) { \
  32480. lum = maskColor.a; \
  32481. } else { \
  32482. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32483. maskColor.b * 0.11; \
  32484. } \
  32485. imageColor.a *= lum; \
  32486. imageColor.rgb *= imageColor.a; \
  32487. gl_FragColor = imageColor; \
  32488. } ';
  32489. var smaskCache = null;
  32490. function initSmaskGL() {
  32491. var canvas, gl;
  32492. generateGL();
  32493. canvas = currentCanvas;
  32494. currentCanvas = null;
  32495. gl = currentGL;
  32496. currentGL = null;
  32497. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32498. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32499. var program = createProgram(gl, [
  32500. vertexShader,
  32501. fragmentShader
  32502. ]);
  32503. gl.useProgram(program);
  32504. var cache = {};
  32505. cache.gl = gl;
  32506. cache.canvas = canvas;
  32507. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32508. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32509. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32510. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32511. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32512. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32513. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32514. var texCoordBuffer = gl.createBuffer();
  32515. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32516. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32517. 0.0,
  32518. 0.0,
  32519. 1.0,
  32520. 0.0,
  32521. 0.0,
  32522. 1.0,
  32523. 0.0,
  32524. 1.0,
  32525. 1.0,
  32526. 0.0,
  32527. 1.0,
  32528. 1.0
  32529. ]), gl.STATIC_DRAW);
  32530. gl.enableVertexAttribArray(texCoordLocation);
  32531. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32532. gl.uniform1i(texLayerLocation, 0);
  32533. gl.uniform1i(texMaskLocation, 1);
  32534. smaskCache = cache;
  32535. }
  32536. function composeSMask(layer, mask, properties) {
  32537. var width = layer.width, height = layer.height;
  32538. if (!smaskCache) {
  32539. initSmaskGL();
  32540. }
  32541. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32542. canvas.width = width;
  32543. canvas.height = height;
  32544. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32545. gl.uniform2f(cache.resolutionLocation, width, height);
  32546. if (properties.backdrop) {
  32547. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32548. } else {
  32549. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32550. }
  32551. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32552. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32553. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32554. var buffer = gl.createBuffer();
  32555. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32556. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32557. 0,
  32558. 0,
  32559. width,
  32560. 0,
  32561. 0,
  32562. height,
  32563. 0,
  32564. height,
  32565. width,
  32566. 0,
  32567. width,
  32568. height
  32569. ]), gl.STATIC_DRAW);
  32570. gl.enableVertexAttribArray(cache.positionLocation);
  32571. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32572. gl.clearColor(0, 0, 0, 0);
  32573. gl.enable(gl.BLEND);
  32574. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32575. gl.clear(gl.COLOR_BUFFER_BIT);
  32576. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32577. gl.flush();
  32578. gl.deleteTexture(texture);
  32579. gl.deleteTexture(maskTexture);
  32580. gl.deleteBuffer(buffer);
  32581. return canvas;
  32582. }
  32583. var figuresVertexShaderCode = '\
  32584. attribute vec2 a_position; \
  32585. attribute vec3 a_color; \
  32586. \
  32587. uniform vec2 u_resolution; \
  32588. uniform vec2 u_scale; \
  32589. uniform vec2 u_offset; \
  32590. \
  32591. varying vec4 v_color; \
  32592. \
  32593. void main() { \
  32594. vec2 position = (a_position + u_offset) * u_scale; \
  32595. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32596. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32597. \
  32598. v_color = vec4(a_color / 255.0, 1.0); \
  32599. } ';
  32600. var figuresFragmentShaderCode = '\
  32601. precision mediump float; \
  32602. \
  32603. varying vec4 v_color; \
  32604. \
  32605. void main() { \
  32606. gl_FragColor = v_color; \
  32607. } ';
  32608. var figuresCache = null;
  32609. function initFiguresGL() {
  32610. var canvas, gl;
  32611. generateGL();
  32612. canvas = currentCanvas;
  32613. currentCanvas = null;
  32614. gl = currentGL;
  32615. currentGL = null;
  32616. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32617. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32618. var program = createProgram(gl, [
  32619. vertexShader,
  32620. fragmentShader
  32621. ]);
  32622. gl.useProgram(program);
  32623. var cache = {};
  32624. cache.gl = gl;
  32625. cache.canvas = canvas;
  32626. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32627. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32628. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32629. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32630. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32631. figuresCache = cache;
  32632. }
  32633. function drawFigures(width, height, backgroundColor, figures, context) {
  32634. if (!figuresCache) {
  32635. initFiguresGL();
  32636. }
  32637. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32638. canvas.width = width;
  32639. canvas.height = height;
  32640. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32641. gl.uniform2f(cache.resolutionLocation, width, height);
  32642. var count = 0;
  32643. var i, ii, rows;
  32644. for (i = 0, ii = figures.length; i < ii; i++) {
  32645. switch (figures[i].type) {
  32646. case 'lattice':
  32647. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32648. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32649. break;
  32650. case 'triangles':
  32651. count += figures[i].coords.length;
  32652. break;
  32653. }
  32654. }
  32655. var coords = new Float32Array(count * 2);
  32656. var colors = new Uint8Array(count * 3);
  32657. var coordsMap = context.coords, colorsMap = context.colors;
  32658. var pIndex = 0, cIndex = 0;
  32659. for (i = 0, ii = figures.length; i < ii; i++) {
  32660. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32661. switch (figure.type) {
  32662. case 'lattice':
  32663. var cols = figure.verticesPerRow;
  32664. rows = ps.length / cols | 0;
  32665. for (var row = 1; row < rows; row++) {
  32666. var offset = row * cols + 1;
  32667. for (var col = 1; col < cols; col++, offset++) {
  32668. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32669. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32670. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32671. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32672. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32673. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32674. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32675. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32676. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32677. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32678. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32679. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32680. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32681. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32682. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32683. coords[pIndex + 6] = coords[pIndex + 2];
  32684. coords[pIndex + 7] = coords[pIndex + 3];
  32685. coords[pIndex + 8] = coords[pIndex + 4];
  32686. coords[pIndex + 9] = coords[pIndex + 5];
  32687. coords[pIndex + 10] = coordsMap[ps[offset]];
  32688. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32689. colors[cIndex + 9] = colors[cIndex + 3];
  32690. colors[cIndex + 10] = colors[cIndex + 4];
  32691. colors[cIndex + 11] = colors[cIndex + 5];
  32692. colors[cIndex + 12] = colors[cIndex + 6];
  32693. colors[cIndex + 13] = colors[cIndex + 7];
  32694. colors[cIndex + 14] = colors[cIndex + 8];
  32695. colors[cIndex + 15] = colorsMap[cs[offset]];
  32696. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32697. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32698. pIndex += 12;
  32699. cIndex += 18;
  32700. }
  32701. }
  32702. break;
  32703. case 'triangles':
  32704. for (var j = 0, jj = ps.length; j < jj; j++) {
  32705. coords[pIndex] = coordsMap[ps[j]];
  32706. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32707. colors[cIndex] = colorsMap[cs[j]];
  32708. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32709. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32710. pIndex += 2;
  32711. cIndex += 3;
  32712. }
  32713. break;
  32714. }
  32715. }
  32716. if (backgroundColor) {
  32717. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32718. } else {
  32719. gl.clearColor(0, 0, 0, 0);
  32720. }
  32721. gl.clear(gl.COLOR_BUFFER_BIT);
  32722. var coordsBuffer = gl.createBuffer();
  32723. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32724. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32725. gl.enableVertexAttribArray(cache.positionLocation);
  32726. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32727. var colorsBuffer = gl.createBuffer();
  32728. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32729. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32730. gl.enableVertexAttribArray(cache.colorLocation);
  32731. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32732. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32733. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32734. gl.drawArrays(gl.TRIANGLES, 0, count);
  32735. gl.flush();
  32736. gl.deleteBuffer(coordsBuffer);
  32737. gl.deleteBuffer(colorsBuffer);
  32738. return canvas;
  32739. }
  32740. function cleanup() {
  32741. if (smaskCache && smaskCache.canvas) {
  32742. smaskCache.canvas.width = 0;
  32743. smaskCache.canvas.height = 0;
  32744. }
  32745. if (figuresCache && figuresCache.canvas) {
  32746. figuresCache.canvas.width = 0;
  32747. figuresCache.canvas.height = 0;
  32748. }
  32749. smaskCache = null;
  32750. figuresCache = null;
  32751. }
  32752. return {
  32753. get isEnabled() {
  32754. if (getDefaultSetting('disableWebGL')) {
  32755. return false;
  32756. }
  32757. var enabled = false;
  32758. try {
  32759. generateGL();
  32760. enabled = !!currentGL;
  32761. } catch (e) {
  32762. }
  32763. return shadow(this, 'isEnabled', enabled);
  32764. },
  32765. composeSMask: composeSMask,
  32766. drawFigures: drawFigures,
  32767. clear: cleanup
  32768. };
  32769. }();
  32770. exports.WebGLUtils = WebGLUtils;
  32771. }));
  32772. (function (root, factory) {
  32773. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32774. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32775. var PasswordException = sharedUtil.PasswordException;
  32776. var PasswordResponses = sharedUtil.PasswordResponses;
  32777. var bytesToString = sharedUtil.bytesToString;
  32778. var warn = sharedUtil.warn;
  32779. var error = sharedUtil.error;
  32780. var assert = sharedUtil.assert;
  32781. var isInt = sharedUtil.isInt;
  32782. var stringToBytes = sharedUtil.stringToBytes;
  32783. var utf8StringToString = sharedUtil.utf8StringToString;
  32784. var Name = corePrimitives.Name;
  32785. var isName = corePrimitives.isName;
  32786. var isDict = corePrimitives.isDict;
  32787. var DecryptStream = coreStream.DecryptStream;
  32788. var ARCFourCipher = function ARCFourCipherClosure() {
  32789. function ARCFourCipher(key) {
  32790. this.a = 0;
  32791. this.b = 0;
  32792. var s = new Uint8Array(256);
  32793. var i, j = 0, tmp, keyLength = key.length;
  32794. for (i = 0; i < 256; ++i) {
  32795. s[i] = i;
  32796. }
  32797. for (i = 0; i < 256; ++i) {
  32798. tmp = s[i];
  32799. j = j + tmp + key[i % keyLength] & 0xFF;
  32800. s[i] = s[j];
  32801. s[j] = tmp;
  32802. }
  32803. this.s = s;
  32804. }
  32805. ARCFourCipher.prototype = {
  32806. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32807. var i, n = data.length, tmp, tmp2;
  32808. var a = this.a, b = this.b, s = this.s;
  32809. var output = new Uint8Array(n);
  32810. for (i = 0; i < n; ++i) {
  32811. a = a + 1 & 0xFF;
  32812. tmp = s[a];
  32813. b = b + tmp & 0xFF;
  32814. tmp2 = s[b];
  32815. s[a] = tmp2;
  32816. s[b] = tmp;
  32817. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32818. }
  32819. this.a = a;
  32820. this.b = b;
  32821. return output;
  32822. }
  32823. };
  32824. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32825. return ARCFourCipher;
  32826. }();
  32827. var calculateMD5 = function calculateMD5Closure() {
  32828. var r = new Uint8Array([
  32829. 7,
  32830. 12,
  32831. 17,
  32832. 22,
  32833. 7,
  32834. 12,
  32835. 17,
  32836. 22,
  32837. 7,
  32838. 12,
  32839. 17,
  32840. 22,
  32841. 7,
  32842. 12,
  32843. 17,
  32844. 22,
  32845. 5,
  32846. 9,
  32847. 14,
  32848. 20,
  32849. 5,
  32850. 9,
  32851. 14,
  32852. 20,
  32853. 5,
  32854. 9,
  32855. 14,
  32856. 20,
  32857. 5,
  32858. 9,
  32859. 14,
  32860. 20,
  32861. 4,
  32862. 11,
  32863. 16,
  32864. 23,
  32865. 4,
  32866. 11,
  32867. 16,
  32868. 23,
  32869. 4,
  32870. 11,
  32871. 16,
  32872. 23,
  32873. 4,
  32874. 11,
  32875. 16,
  32876. 23,
  32877. 6,
  32878. 10,
  32879. 15,
  32880. 21,
  32881. 6,
  32882. 10,
  32883. 15,
  32884. 21,
  32885. 6,
  32886. 10,
  32887. 15,
  32888. 21,
  32889. 6,
  32890. 10,
  32891. 15,
  32892. 21
  32893. ]);
  32894. var k = new Int32Array([
  32895. -680876936,
  32896. -389564586,
  32897. 606105819,
  32898. -1044525330,
  32899. -176418897,
  32900. 1200080426,
  32901. -1473231341,
  32902. -45705983,
  32903. 1770035416,
  32904. -1958414417,
  32905. -42063,
  32906. -1990404162,
  32907. 1804603682,
  32908. -40341101,
  32909. -1502002290,
  32910. 1236535329,
  32911. -165796510,
  32912. -1069501632,
  32913. 643717713,
  32914. -373897302,
  32915. -701558691,
  32916. 38016083,
  32917. -660478335,
  32918. -405537848,
  32919. 568446438,
  32920. -1019803690,
  32921. -187363961,
  32922. 1163531501,
  32923. -1444681467,
  32924. -51403784,
  32925. 1735328473,
  32926. -1926607734,
  32927. -378558,
  32928. -2022574463,
  32929. 1839030562,
  32930. -35309556,
  32931. -1530992060,
  32932. 1272893353,
  32933. -155497632,
  32934. -1094730640,
  32935. 681279174,
  32936. -358537222,
  32937. -722521979,
  32938. 76029189,
  32939. -640364487,
  32940. -421815835,
  32941. 530742520,
  32942. -995338651,
  32943. -198630844,
  32944. 1126891415,
  32945. -1416354905,
  32946. -57434055,
  32947. 1700485571,
  32948. -1894986606,
  32949. -1051523,
  32950. -2054922799,
  32951. 1873313359,
  32952. -30611744,
  32953. -1560198380,
  32954. 1309151649,
  32955. -145523070,
  32956. -1120210379,
  32957. 718787259,
  32958. -343485551
  32959. ]);
  32960. function hash(data, offset, length) {
  32961. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32962. var paddedLength = length + 72 & ~63;
  32963. var padded = new Uint8Array(paddedLength);
  32964. var i, j, n;
  32965. for (i = 0; i < length; ++i) {
  32966. padded[i] = data[offset++];
  32967. }
  32968. padded[i++] = 0x80;
  32969. n = paddedLength - 8;
  32970. while (i < n) {
  32971. padded[i++] = 0;
  32972. }
  32973. padded[i++] = length << 3 & 0xFF;
  32974. padded[i++] = length >> 5 & 0xFF;
  32975. padded[i++] = length >> 13 & 0xFF;
  32976. padded[i++] = length >> 21 & 0xFF;
  32977. padded[i++] = length >>> 29 & 0xFF;
  32978. padded[i++] = 0;
  32979. padded[i++] = 0;
  32980. padded[i++] = 0;
  32981. var w = new Int32Array(16);
  32982. for (i = 0; i < paddedLength;) {
  32983. for (j = 0; j < 16; ++j, i += 4) {
  32984. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32985. }
  32986. var a = h0, b = h1, c = h2, d = h3, f, g;
  32987. for (j = 0; j < 64; ++j) {
  32988. if (j < 16) {
  32989. f = b & c | ~b & d;
  32990. g = j;
  32991. } else if (j < 32) {
  32992. f = d & b | ~d & c;
  32993. g = 5 * j + 1 & 15;
  32994. } else if (j < 48) {
  32995. f = b ^ c ^ d;
  32996. g = 3 * j + 5 & 15;
  32997. } else {
  32998. f = c ^ (b | ~d);
  32999. g = 7 * j & 15;
  33000. }
  33001. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  33002. d = c;
  33003. c = b;
  33004. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  33005. a = tmp;
  33006. }
  33007. h0 = h0 + a | 0;
  33008. h1 = h1 + b | 0;
  33009. h2 = h2 + c | 0;
  33010. h3 = h3 + d | 0;
  33011. }
  33012. return new Uint8Array([
  33013. h0 & 0xFF,
  33014. h0 >> 8 & 0xFF,
  33015. h0 >> 16 & 0xFF,
  33016. h0 >>> 24 & 0xFF,
  33017. h1 & 0xFF,
  33018. h1 >> 8 & 0xFF,
  33019. h1 >> 16 & 0xFF,
  33020. h1 >>> 24 & 0xFF,
  33021. h2 & 0xFF,
  33022. h2 >> 8 & 0xFF,
  33023. h2 >> 16 & 0xFF,
  33024. h2 >>> 24 & 0xFF,
  33025. h3 & 0xFF,
  33026. h3 >> 8 & 0xFF,
  33027. h3 >> 16 & 0xFF,
  33028. h3 >>> 24 & 0xFF
  33029. ]);
  33030. }
  33031. return hash;
  33032. }();
  33033. var Word64 = function Word64Closure() {
  33034. function Word64(highInteger, lowInteger) {
  33035. this.high = highInteger | 0;
  33036. this.low = lowInteger | 0;
  33037. }
  33038. Word64.prototype = {
  33039. and: function Word64_and(word) {
  33040. this.high &= word.high;
  33041. this.low &= word.low;
  33042. },
  33043. xor: function Word64_xor(word) {
  33044. this.high ^= word.high;
  33045. this.low ^= word.low;
  33046. },
  33047. or: function Word64_or(word) {
  33048. this.high |= word.high;
  33049. this.low |= word.low;
  33050. },
  33051. shiftRight: function Word64_shiftRight(places) {
  33052. if (places >= 32) {
  33053. this.low = this.high >>> places - 32 | 0;
  33054. this.high = 0;
  33055. } else {
  33056. this.low = this.low >>> places | this.high << 32 - places;
  33057. this.high = this.high >>> places | 0;
  33058. }
  33059. },
  33060. shiftLeft: function Word64_shiftLeft(places) {
  33061. if (places >= 32) {
  33062. this.high = this.low << places - 32;
  33063. this.low = 0;
  33064. } else {
  33065. this.high = this.high << places | this.low >>> 32 - places;
  33066. this.low = this.low << places;
  33067. }
  33068. },
  33069. rotateRight: function Word64_rotateRight(places) {
  33070. var low, high;
  33071. if (places & 32) {
  33072. high = this.low;
  33073. low = this.high;
  33074. } else {
  33075. low = this.low;
  33076. high = this.high;
  33077. }
  33078. places &= 31;
  33079. this.low = low >>> places | high << 32 - places;
  33080. this.high = high >>> places | low << 32 - places;
  33081. },
  33082. not: function Word64_not() {
  33083. this.high = ~this.high;
  33084. this.low = ~this.low;
  33085. },
  33086. add: function Word64_add(word) {
  33087. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  33088. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  33089. if (lowAdd > 0xFFFFFFFF) {
  33090. highAdd += 1;
  33091. }
  33092. this.low = lowAdd | 0;
  33093. this.high = highAdd | 0;
  33094. },
  33095. copyTo: function Word64_copyTo(bytes, offset) {
  33096. bytes[offset] = this.high >>> 24 & 0xFF;
  33097. bytes[offset + 1] = this.high >> 16 & 0xFF;
  33098. bytes[offset + 2] = this.high >> 8 & 0xFF;
  33099. bytes[offset + 3] = this.high & 0xFF;
  33100. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  33101. bytes[offset + 5] = this.low >> 16 & 0xFF;
  33102. bytes[offset + 6] = this.low >> 8 & 0xFF;
  33103. bytes[offset + 7] = this.low & 0xFF;
  33104. },
  33105. assign: function Word64_assign(word) {
  33106. this.high = word.high;
  33107. this.low = word.low;
  33108. }
  33109. };
  33110. return Word64;
  33111. }();
  33112. var calculateSHA256 = function calculateSHA256Closure() {
  33113. function rotr(x, n) {
  33114. return x >>> n | x << 32 - n;
  33115. }
  33116. function ch(x, y, z) {
  33117. return x & y ^ ~x & z;
  33118. }
  33119. function maj(x, y, z) {
  33120. return x & y ^ x & z ^ y & z;
  33121. }
  33122. function sigma(x) {
  33123. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  33124. }
  33125. function sigmaPrime(x) {
  33126. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  33127. }
  33128. function littleSigma(x) {
  33129. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  33130. }
  33131. function littleSigmaPrime(x) {
  33132. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  33133. }
  33134. var k = [
  33135. 0x428a2f98,
  33136. 0x71374491,
  33137. 0xb5c0fbcf,
  33138. 0xe9b5dba5,
  33139. 0x3956c25b,
  33140. 0x59f111f1,
  33141. 0x923f82a4,
  33142. 0xab1c5ed5,
  33143. 0xd807aa98,
  33144. 0x12835b01,
  33145. 0x243185be,
  33146. 0x550c7dc3,
  33147. 0x72be5d74,
  33148. 0x80deb1fe,
  33149. 0x9bdc06a7,
  33150. 0xc19bf174,
  33151. 0xe49b69c1,
  33152. 0xefbe4786,
  33153. 0x0fc19dc6,
  33154. 0x240ca1cc,
  33155. 0x2de92c6f,
  33156. 0x4a7484aa,
  33157. 0x5cb0a9dc,
  33158. 0x76f988da,
  33159. 0x983e5152,
  33160. 0xa831c66d,
  33161. 0xb00327c8,
  33162. 0xbf597fc7,
  33163. 0xc6e00bf3,
  33164. 0xd5a79147,
  33165. 0x06ca6351,
  33166. 0x14292967,
  33167. 0x27b70a85,
  33168. 0x2e1b2138,
  33169. 0x4d2c6dfc,
  33170. 0x53380d13,
  33171. 0x650a7354,
  33172. 0x766a0abb,
  33173. 0x81c2c92e,
  33174. 0x92722c85,
  33175. 0xa2bfe8a1,
  33176. 0xa81a664b,
  33177. 0xc24b8b70,
  33178. 0xc76c51a3,
  33179. 0xd192e819,
  33180. 0xd6990624,
  33181. 0xf40e3585,
  33182. 0x106aa070,
  33183. 0x19a4c116,
  33184. 0x1e376c08,
  33185. 0x2748774c,
  33186. 0x34b0bcb5,
  33187. 0x391c0cb3,
  33188. 0x4ed8aa4a,
  33189. 0x5b9cca4f,
  33190. 0x682e6ff3,
  33191. 0x748f82ee,
  33192. 0x78a5636f,
  33193. 0x84c87814,
  33194. 0x8cc70208,
  33195. 0x90befffa,
  33196. 0xa4506ceb,
  33197. 0xbef9a3f7,
  33198. 0xc67178f2
  33199. ];
  33200. function hash(data, offset, length) {
  33201. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33202. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33203. var padded = new Uint8Array(paddedLength);
  33204. var i, j, n;
  33205. for (i = 0; i < length; ++i) {
  33206. padded[i] = data[offset++];
  33207. }
  33208. padded[i++] = 0x80;
  33209. n = paddedLength - 8;
  33210. while (i < n) {
  33211. padded[i++] = 0;
  33212. }
  33213. padded[i++] = 0;
  33214. padded[i++] = 0;
  33215. padded[i++] = 0;
  33216. padded[i++] = length >>> 29 & 0xFF;
  33217. padded[i++] = length >> 21 & 0xFF;
  33218. padded[i++] = length >> 13 & 0xFF;
  33219. padded[i++] = length >> 5 & 0xFF;
  33220. padded[i++] = length << 3 & 0xFF;
  33221. var w = new Uint32Array(64);
  33222. for (i = 0; i < paddedLength;) {
  33223. for (j = 0; j < 16; ++j) {
  33224. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33225. i += 4;
  33226. }
  33227. for (j = 16; j < 64; ++j) {
  33228. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33229. }
  33230. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33231. for (j = 0; j < 64; ++j) {
  33232. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33233. t2 = sigma(a) + maj(a, b, c);
  33234. h = g;
  33235. g = f;
  33236. f = e;
  33237. e = d + t1 | 0;
  33238. d = c;
  33239. c = b;
  33240. b = a;
  33241. a = t1 + t2 | 0;
  33242. }
  33243. h0 = h0 + a | 0;
  33244. h1 = h1 + b | 0;
  33245. h2 = h2 + c | 0;
  33246. h3 = h3 + d | 0;
  33247. h4 = h4 + e | 0;
  33248. h5 = h5 + f | 0;
  33249. h6 = h6 + g | 0;
  33250. h7 = h7 + h | 0;
  33251. }
  33252. return new Uint8Array([
  33253. h0 >> 24 & 0xFF,
  33254. h0 >> 16 & 0xFF,
  33255. h0 >> 8 & 0xFF,
  33256. h0 & 0xFF,
  33257. h1 >> 24 & 0xFF,
  33258. h1 >> 16 & 0xFF,
  33259. h1 >> 8 & 0xFF,
  33260. h1 & 0xFF,
  33261. h2 >> 24 & 0xFF,
  33262. h2 >> 16 & 0xFF,
  33263. h2 >> 8 & 0xFF,
  33264. h2 & 0xFF,
  33265. h3 >> 24 & 0xFF,
  33266. h3 >> 16 & 0xFF,
  33267. h3 >> 8 & 0xFF,
  33268. h3 & 0xFF,
  33269. h4 >> 24 & 0xFF,
  33270. h4 >> 16 & 0xFF,
  33271. h4 >> 8 & 0xFF,
  33272. h4 & 0xFF,
  33273. h5 >> 24 & 0xFF,
  33274. h5 >> 16 & 0xFF,
  33275. h5 >> 8 & 0xFF,
  33276. h5 & 0xFF,
  33277. h6 >> 24 & 0xFF,
  33278. h6 >> 16 & 0xFF,
  33279. h6 >> 8 & 0xFF,
  33280. h6 & 0xFF,
  33281. h7 >> 24 & 0xFF,
  33282. h7 >> 16 & 0xFF,
  33283. h7 >> 8 & 0xFF,
  33284. h7 & 0xFF
  33285. ]);
  33286. }
  33287. return hash;
  33288. }();
  33289. var calculateSHA512 = function calculateSHA512Closure() {
  33290. function ch(result, x, y, z, tmp) {
  33291. result.assign(x);
  33292. result.and(y);
  33293. tmp.assign(x);
  33294. tmp.not();
  33295. tmp.and(z);
  33296. result.xor(tmp);
  33297. }
  33298. function maj(result, x, y, z, tmp) {
  33299. result.assign(x);
  33300. result.and(y);
  33301. tmp.assign(x);
  33302. tmp.and(z);
  33303. result.xor(tmp);
  33304. tmp.assign(y);
  33305. tmp.and(z);
  33306. result.xor(tmp);
  33307. }
  33308. function sigma(result, x, tmp) {
  33309. result.assign(x);
  33310. result.rotateRight(28);
  33311. tmp.assign(x);
  33312. tmp.rotateRight(34);
  33313. result.xor(tmp);
  33314. tmp.assign(x);
  33315. tmp.rotateRight(39);
  33316. result.xor(tmp);
  33317. }
  33318. function sigmaPrime(result, x, tmp) {
  33319. result.assign(x);
  33320. result.rotateRight(14);
  33321. tmp.assign(x);
  33322. tmp.rotateRight(18);
  33323. result.xor(tmp);
  33324. tmp.assign(x);
  33325. tmp.rotateRight(41);
  33326. result.xor(tmp);
  33327. }
  33328. function littleSigma(result, x, tmp) {
  33329. result.assign(x);
  33330. result.rotateRight(1);
  33331. tmp.assign(x);
  33332. tmp.rotateRight(8);
  33333. result.xor(tmp);
  33334. tmp.assign(x);
  33335. tmp.shiftRight(7);
  33336. result.xor(tmp);
  33337. }
  33338. function littleSigmaPrime(result, x, tmp) {
  33339. result.assign(x);
  33340. result.rotateRight(19);
  33341. tmp.assign(x);
  33342. tmp.rotateRight(61);
  33343. result.xor(tmp);
  33344. tmp.assign(x);
  33345. tmp.shiftRight(6);
  33346. result.xor(tmp);
  33347. }
  33348. var k = [
  33349. new Word64(0x428a2f98, 0xd728ae22),
  33350. new Word64(0x71374491, 0x23ef65cd),
  33351. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33352. new Word64(0xe9b5dba5, 0x8189dbbc),
  33353. new Word64(0x3956c25b, 0xf348b538),
  33354. new Word64(0x59f111f1, 0xb605d019),
  33355. new Word64(0x923f82a4, 0xaf194f9b),
  33356. new Word64(0xab1c5ed5, 0xda6d8118),
  33357. new Word64(0xd807aa98, 0xa3030242),
  33358. new Word64(0x12835b01, 0x45706fbe),
  33359. new Word64(0x243185be, 0x4ee4b28c),
  33360. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33361. new Word64(0x72be5d74, 0xf27b896f),
  33362. new Word64(0x80deb1fe, 0x3b1696b1),
  33363. new Word64(0x9bdc06a7, 0x25c71235),
  33364. new Word64(0xc19bf174, 0xcf692694),
  33365. new Word64(0xe49b69c1, 0x9ef14ad2),
  33366. new Word64(0xefbe4786, 0x384f25e3),
  33367. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33368. new Word64(0x240ca1cc, 0x77ac9c65),
  33369. new Word64(0x2de92c6f, 0x592b0275),
  33370. new Word64(0x4a7484aa, 0x6ea6e483),
  33371. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33372. new Word64(0x76f988da, 0x831153b5),
  33373. new Word64(0x983e5152, 0xee66dfab),
  33374. new Word64(0xa831c66d, 0x2db43210),
  33375. new Word64(0xb00327c8, 0x98fb213f),
  33376. new Word64(0xbf597fc7, 0xbeef0ee4),
  33377. new Word64(0xc6e00bf3, 0x3da88fc2),
  33378. new Word64(0xd5a79147, 0x930aa725),
  33379. new Word64(0x06ca6351, 0xe003826f),
  33380. new Word64(0x14292967, 0x0a0e6e70),
  33381. new Word64(0x27b70a85, 0x46d22ffc),
  33382. new Word64(0x2e1b2138, 0x5c26c926),
  33383. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33384. new Word64(0x53380d13, 0x9d95b3df),
  33385. new Word64(0x650a7354, 0x8baf63de),
  33386. new Word64(0x766a0abb, 0x3c77b2a8),
  33387. new Word64(0x81c2c92e, 0x47edaee6),
  33388. new Word64(0x92722c85, 0x1482353b),
  33389. new Word64(0xa2bfe8a1, 0x4cf10364),
  33390. new Word64(0xa81a664b, 0xbc423001),
  33391. new Word64(0xc24b8b70, 0xd0f89791),
  33392. new Word64(0xc76c51a3, 0x0654be30),
  33393. new Word64(0xd192e819, 0xd6ef5218),
  33394. new Word64(0xd6990624, 0x5565a910),
  33395. new Word64(0xf40e3585, 0x5771202a),
  33396. new Word64(0x106aa070, 0x32bbd1b8),
  33397. new Word64(0x19a4c116, 0xb8d2d0c8),
  33398. new Word64(0x1e376c08, 0x5141ab53),
  33399. new Word64(0x2748774c, 0xdf8eeb99),
  33400. new Word64(0x34b0bcb5, 0xe19b48a8),
  33401. new Word64(0x391c0cb3, 0xc5c95a63),
  33402. new Word64(0x4ed8aa4a, 0xe3418acb),
  33403. new Word64(0x5b9cca4f, 0x7763e373),
  33404. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33405. new Word64(0x748f82ee, 0x5defb2fc),
  33406. new Word64(0x78a5636f, 0x43172f60),
  33407. new Word64(0x84c87814, 0xa1f0ab72),
  33408. new Word64(0x8cc70208, 0x1a6439ec),
  33409. new Word64(0x90befffa, 0x23631e28),
  33410. new Word64(0xa4506ceb, 0xde82bde9),
  33411. new Word64(0xbef9a3f7, 0xb2c67915),
  33412. new Word64(0xc67178f2, 0xe372532b),
  33413. new Word64(0xca273ece, 0xea26619c),
  33414. new Word64(0xd186b8c7, 0x21c0c207),
  33415. new Word64(0xeada7dd6, 0xcde0eb1e),
  33416. new Word64(0xf57d4f7f, 0xee6ed178),
  33417. new Word64(0x06f067aa, 0x72176fba),
  33418. new Word64(0x0a637dc5, 0xa2c898a6),
  33419. new Word64(0x113f9804, 0xbef90dae),
  33420. new Word64(0x1b710b35, 0x131c471b),
  33421. new Word64(0x28db77f5, 0x23047d84),
  33422. new Word64(0x32caab7b, 0x40c72493),
  33423. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33424. new Word64(0x431d67c4, 0x9c100d4c),
  33425. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33426. new Word64(0x597f299c, 0xfc657e2a),
  33427. new Word64(0x5fcb6fab, 0x3ad6faec),
  33428. new Word64(0x6c44198c, 0x4a475817)
  33429. ];
  33430. function hash(data, offset, length, mode384) {
  33431. mode384 = !!mode384;
  33432. var h0, h1, h2, h3, h4, h5, h6, h7;
  33433. if (!mode384) {
  33434. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33435. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33436. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33437. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33438. h4 = new Word64(0x510e527f, 0xade682d1);
  33439. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33440. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33441. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33442. } else {
  33443. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33444. h1 = new Word64(0x629a292a, 0x367cd507);
  33445. h2 = new Word64(0x9159015a, 0x3070dd17);
  33446. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33447. h4 = new Word64(0x67332667, 0xffc00b31);
  33448. h5 = new Word64(0x8eb44a87, 0x68581511);
  33449. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33450. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33451. }
  33452. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33453. var padded = new Uint8Array(paddedLength);
  33454. var i, j, n;
  33455. for (i = 0; i < length; ++i) {
  33456. padded[i] = data[offset++];
  33457. }
  33458. padded[i++] = 0x80;
  33459. n = paddedLength - 16;
  33460. while (i < n) {
  33461. padded[i++] = 0;
  33462. }
  33463. padded[i++] = 0;
  33464. padded[i++] = 0;
  33465. padded[i++] = 0;
  33466. padded[i++] = 0;
  33467. padded[i++] = 0;
  33468. padded[i++] = 0;
  33469. padded[i++] = 0;
  33470. padded[i++] = 0;
  33471. padded[i++] = 0;
  33472. padded[i++] = 0;
  33473. padded[i++] = 0;
  33474. padded[i++] = length >>> 29 & 0xFF;
  33475. padded[i++] = length >> 21 & 0xFF;
  33476. padded[i++] = length >> 13 & 0xFF;
  33477. padded[i++] = length >> 5 & 0xFF;
  33478. padded[i++] = length << 3 & 0xFF;
  33479. var w = new Array(80);
  33480. for (i = 0; i < 80; i++) {
  33481. w[i] = new Word64(0, 0);
  33482. }
  33483. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33484. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33485. var g = new Word64(0, 0), h = new Word64(0, 0);
  33486. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33487. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33488. for (i = 0; i < paddedLength;) {
  33489. for (j = 0; j < 16; ++j) {
  33490. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33491. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33492. i += 8;
  33493. }
  33494. for (j = 16; j < 80; ++j) {
  33495. tmp3 = w[j];
  33496. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33497. tmp3.add(w[j - 7]);
  33498. littleSigma(tmp1, w[j - 15], tmp2);
  33499. tmp3.add(tmp1);
  33500. tmp3.add(w[j - 16]);
  33501. }
  33502. a.assign(h0);
  33503. b.assign(h1);
  33504. c.assign(h2);
  33505. d.assign(h3);
  33506. e.assign(h4);
  33507. f.assign(h5);
  33508. g.assign(h6);
  33509. h.assign(h7);
  33510. for (j = 0; j < 80; ++j) {
  33511. t1.assign(h);
  33512. sigmaPrime(tmp1, e, tmp2);
  33513. t1.add(tmp1);
  33514. ch(tmp1, e, f, g, tmp2);
  33515. t1.add(tmp1);
  33516. t1.add(k[j]);
  33517. t1.add(w[j]);
  33518. sigma(t2, a, tmp2);
  33519. maj(tmp1, a, b, c, tmp2);
  33520. t2.add(tmp1);
  33521. tmp3 = h;
  33522. h = g;
  33523. g = f;
  33524. f = e;
  33525. d.add(t1);
  33526. e = d;
  33527. d = c;
  33528. c = b;
  33529. b = a;
  33530. tmp3.assign(t1);
  33531. tmp3.add(t2);
  33532. a = tmp3;
  33533. }
  33534. h0.add(a);
  33535. h1.add(b);
  33536. h2.add(c);
  33537. h3.add(d);
  33538. h4.add(e);
  33539. h5.add(f);
  33540. h6.add(g);
  33541. h7.add(h);
  33542. }
  33543. var result;
  33544. if (!mode384) {
  33545. result = new Uint8Array(64);
  33546. h0.copyTo(result, 0);
  33547. h1.copyTo(result, 8);
  33548. h2.copyTo(result, 16);
  33549. h3.copyTo(result, 24);
  33550. h4.copyTo(result, 32);
  33551. h5.copyTo(result, 40);
  33552. h6.copyTo(result, 48);
  33553. h7.copyTo(result, 56);
  33554. } else {
  33555. result = new Uint8Array(48);
  33556. h0.copyTo(result, 0);
  33557. h1.copyTo(result, 8);
  33558. h2.copyTo(result, 16);
  33559. h3.copyTo(result, 24);
  33560. h4.copyTo(result, 32);
  33561. h5.copyTo(result, 40);
  33562. }
  33563. return result;
  33564. }
  33565. return hash;
  33566. }();
  33567. var calculateSHA384 = function calculateSHA384Closure() {
  33568. function hash(data, offset, length) {
  33569. return calculateSHA512(data, offset, length, true);
  33570. }
  33571. return hash;
  33572. }();
  33573. var NullCipher = function NullCipherClosure() {
  33574. function NullCipher() {
  33575. }
  33576. NullCipher.prototype = {
  33577. decryptBlock: function NullCipher_decryptBlock(data) {
  33578. return data;
  33579. }
  33580. };
  33581. return NullCipher;
  33582. }();
  33583. var AES128Cipher = function AES128CipherClosure() {
  33584. var rcon = new Uint8Array([
  33585. 0x8d,
  33586. 0x01,
  33587. 0x02,
  33588. 0x04,
  33589. 0x08,
  33590. 0x10,
  33591. 0x20,
  33592. 0x40,
  33593. 0x80,
  33594. 0x1b,
  33595. 0x36,
  33596. 0x6c,
  33597. 0xd8,
  33598. 0xab,
  33599. 0x4d,
  33600. 0x9a,
  33601. 0x2f,
  33602. 0x5e,
  33603. 0xbc,
  33604. 0x63,
  33605. 0xc6,
  33606. 0x97,
  33607. 0x35,
  33608. 0x6a,
  33609. 0xd4,
  33610. 0xb3,
  33611. 0x7d,
  33612. 0xfa,
  33613. 0xef,
  33614. 0xc5,
  33615. 0x91,
  33616. 0x39,
  33617. 0x72,
  33618. 0xe4,
  33619. 0xd3,
  33620. 0xbd,
  33621. 0x61,
  33622. 0xc2,
  33623. 0x9f,
  33624. 0x25,
  33625. 0x4a,
  33626. 0x94,
  33627. 0x33,
  33628. 0x66,
  33629. 0xcc,
  33630. 0x83,
  33631. 0x1d,
  33632. 0x3a,
  33633. 0x74,
  33634. 0xe8,
  33635. 0xcb,
  33636. 0x8d,
  33637. 0x01,
  33638. 0x02,
  33639. 0x04,
  33640. 0x08,
  33641. 0x10,
  33642. 0x20,
  33643. 0x40,
  33644. 0x80,
  33645. 0x1b,
  33646. 0x36,
  33647. 0x6c,
  33648. 0xd8,
  33649. 0xab,
  33650. 0x4d,
  33651. 0x9a,
  33652. 0x2f,
  33653. 0x5e,
  33654. 0xbc,
  33655. 0x63,
  33656. 0xc6,
  33657. 0x97,
  33658. 0x35,
  33659. 0x6a,
  33660. 0xd4,
  33661. 0xb3,
  33662. 0x7d,
  33663. 0xfa,
  33664. 0xef,
  33665. 0xc5,
  33666. 0x91,
  33667. 0x39,
  33668. 0x72,
  33669. 0xe4,
  33670. 0xd3,
  33671. 0xbd,
  33672. 0x61,
  33673. 0xc2,
  33674. 0x9f,
  33675. 0x25,
  33676. 0x4a,
  33677. 0x94,
  33678. 0x33,
  33679. 0x66,
  33680. 0xcc,
  33681. 0x83,
  33682. 0x1d,
  33683. 0x3a,
  33684. 0x74,
  33685. 0xe8,
  33686. 0xcb,
  33687. 0x8d,
  33688. 0x01,
  33689. 0x02,
  33690. 0x04,
  33691. 0x08,
  33692. 0x10,
  33693. 0x20,
  33694. 0x40,
  33695. 0x80,
  33696. 0x1b,
  33697. 0x36,
  33698. 0x6c,
  33699. 0xd8,
  33700. 0xab,
  33701. 0x4d,
  33702. 0x9a,
  33703. 0x2f,
  33704. 0x5e,
  33705. 0xbc,
  33706. 0x63,
  33707. 0xc6,
  33708. 0x97,
  33709. 0x35,
  33710. 0x6a,
  33711. 0xd4,
  33712. 0xb3,
  33713. 0x7d,
  33714. 0xfa,
  33715. 0xef,
  33716. 0xc5,
  33717. 0x91,
  33718. 0x39,
  33719. 0x72,
  33720. 0xe4,
  33721. 0xd3,
  33722. 0xbd,
  33723. 0x61,
  33724. 0xc2,
  33725. 0x9f,
  33726. 0x25,
  33727. 0x4a,
  33728. 0x94,
  33729. 0x33,
  33730. 0x66,
  33731. 0xcc,
  33732. 0x83,
  33733. 0x1d,
  33734. 0x3a,
  33735. 0x74,
  33736. 0xe8,
  33737. 0xcb,
  33738. 0x8d,
  33739. 0x01,
  33740. 0x02,
  33741. 0x04,
  33742. 0x08,
  33743. 0x10,
  33744. 0x20,
  33745. 0x40,
  33746. 0x80,
  33747. 0x1b,
  33748. 0x36,
  33749. 0x6c,
  33750. 0xd8,
  33751. 0xab,
  33752. 0x4d,
  33753. 0x9a,
  33754. 0x2f,
  33755. 0x5e,
  33756. 0xbc,
  33757. 0x63,
  33758. 0xc6,
  33759. 0x97,
  33760. 0x35,
  33761. 0x6a,
  33762. 0xd4,
  33763. 0xb3,
  33764. 0x7d,
  33765. 0xfa,
  33766. 0xef,
  33767. 0xc5,
  33768. 0x91,
  33769. 0x39,
  33770. 0x72,
  33771. 0xe4,
  33772. 0xd3,
  33773. 0xbd,
  33774. 0x61,
  33775. 0xc2,
  33776. 0x9f,
  33777. 0x25,
  33778. 0x4a,
  33779. 0x94,
  33780. 0x33,
  33781. 0x66,
  33782. 0xcc,
  33783. 0x83,
  33784. 0x1d,
  33785. 0x3a,
  33786. 0x74,
  33787. 0xe8,
  33788. 0xcb,
  33789. 0x8d,
  33790. 0x01,
  33791. 0x02,
  33792. 0x04,
  33793. 0x08,
  33794. 0x10,
  33795. 0x20,
  33796. 0x40,
  33797. 0x80,
  33798. 0x1b,
  33799. 0x36,
  33800. 0x6c,
  33801. 0xd8,
  33802. 0xab,
  33803. 0x4d,
  33804. 0x9a,
  33805. 0x2f,
  33806. 0x5e,
  33807. 0xbc,
  33808. 0x63,
  33809. 0xc6,
  33810. 0x97,
  33811. 0x35,
  33812. 0x6a,
  33813. 0xd4,
  33814. 0xb3,
  33815. 0x7d,
  33816. 0xfa,
  33817. 0xef,
  33818. 0xc5,
  33819. 0x91,
  33820. 0x39,
  33821. 0x72,
  33822. 0xe4,
  33823. 0xd3,
  33824. 0xbd,
  33825. 0x61,
  33826. 0xc2,
  33827. 0x9f,
  33828. 0x25,
  33829. 0x4a,
  33830. 0x94,
  33831. 0x33,
  33832. 0x66,
  33833. 0xcc,
  33834. 0x83,
  33835. 0x1d,
  33836. 0x3a,
  33837. 0x74,
  33838. 0xe8,
  33839. 0xcb,
  33840. 0x8d
  33841. ]);
  33842. var s = new Uint8Array([
  33843. 0x63,
  33844. 0x7c,
  33845. 0x77,
  33846. 0x7b,
  33847. 0xf2,
  33848. 0x6b,
  33849. 0x6f,
  33850. 0xc5,
  33851. 0x30,
  33852. 0x01,
  33853. 0x67,
  33854. 0x2b,
  33855. 0xfe,
  33856. 0xd7,
  33857. 0xab,
  33858. 0x76,
  33859. 0xca,
  33860. 0x82,
  33861. 0xc9,
  33862. 0x7d,
  33863. 0xfa,
  33864. 0x59,
  33865. 0x47,
  33866. 0xf0,
  33867. 0xad,
  33868. 0xd4,
  33869. 0xa2,
  33870. 0xaf,
  33871. 0x9c,
  33872. 0xa4,
  33873. 0x72,
  33874. 0xc0,
  33875. 0xb7,
  33876. 0xfd,
  33877. 0x93,
  33878. 0x26,
  33879. 0x36,
  33880. 0x3f,
  33881. 0xf7,
  33882. 0xcc,
  33883. 0x34,
  33884. 0xa5,
  33885. 0xe5,
  33886. 0xf1,
  33887. 0x71,
  33888. 0xd8,
  33889. 0x31,
  33890. 0x15,
  33891. 0x04,
  33892. 0xc7,
  33893. 0x23,
  33894. 0xc3,
  33895. 0x18,
  33896. 0x96,
  33897. 0x05,
  33898. 0x9a,
  33899. 0x07,
  33900. 0x12,
  33901. 0x80,
  33902. 0xe2,
  33903. 0xeb,
  33904. 0x27,
  33905. 0xb2,
  33906. 0x75,
  33907. 0x09,
  33908. 0x83,
  33909. 0x2c,
  33910. 0x1a,
  33911. 0x1b,
  33912. 0x6e,
  33913. 0x5a,
  33914. 0xa0,
  33915. 0x52,
  33916. 0x3b,
  33917. 0xd6,
  33918. 0xb3,
  33919. 0x29,
  33920. 0xe3,
  33921. 0x2f,
  33922. 0x84,
  33923. 0x53,
  33924. 0xd1,
  33925. 0x00,
  33926. 0xed,
  33927. 0x20,
  33928. 0xfc,
  33929. 0xb1,
  33930. 0x5b,
  33931. 0x6a,
  33932. 0xcb,
  33933. 0xbe,
  33934. 0x39,
  33935. 0x4a,
  33936. 0x4c,
  33937. 0x58,
  33938. 0xcf,
  33939. 0xd0,
  33940. 0xef,
  33941. 0xaa,
  33942. 0xfb,
  33943. 0x43,
  33944. 0x4d,
  33945. 0x33,
  33946. 0x85,
  33947. 0x45,
  33948. 0xf9,
  33949. 0x02,
  33950. 0x7f,
  33951. 0x50,
  33952. 0x3c,
  33953. 0x9f,
  33954. 0xa8,
  33955. 0x51,
  33956. 0xa3,
  33957. 0x40,
  33958. 0x8f,
  33959. 0x92,
  33960. 0x9d,
  33961. 0x38,
  33962. 0xf5,
  33963. 0xbc,
  33964. 0xb6,
  33965. 0xda,
  33966. 0x21,
  33967. 0x10,
  33968. 0xff,
  33969. 0xf3,
  33970. 0xd2,
  33971. 0xcd,
  33972. 0x0c,
  33973. 0x13,
  33974. 0xec,
  33975. 0x5f,
  33976. 0x97,
  33977. 0x44,
  33978. 0x17,
  33979. 0xc4,
  33980. 0xa7,
  33981. 0x7e,
  33982. 0x3d,
  33983. 0x64,
  33984. 0x5d,
  33985. 0x19,
  33986. 0x73,
  33987. 0x60,
  33988. 0x81,
  33989. 0x4f,
  33990. 0xdc,
  33991. 0x22,
  33992. 0x2a,
  33993. 0x90,
  33994. 0x88,
  33995. 0x46,
  33996. 0xee,
  33997. 0xb8,
  33998. 0x14,
  33999. 0xde,
  34000. 0x5e,
  34001. 0x0b,
  34002. 0xdb,
  34003. 0xe0,
  34004. 0x32,
  34005. 0x3a,
  34006. 0x0a,
  34007. 0x49,
  34008. 0x06,
  34009. 0x24,
  34010. 0x5c,
  34011. 0xc2,
  34012. 0xd3,
  34013. 0xac,
  34014. 0x62,
  34015. 0x91,
  34016. 0x95,
  34017. 0xe4,
  34018. 0x79,
  34019. 0xe7,
  34020. 0xc8,
  34021. 0x37,
  34022. 0x6d,
  34023. 0x8d,
  34024. 0xd5,
  34025. 0x4e,
  34026. 0xa9,
  34027. 0x6c,
  34028. 0x56,
  34029. 0xf4,
  34030. 0xea,
  34031. 0x65,
  34032. 0x7a,
  34033. 0xae,
  34034. 0x08,
  34035. 0xba,
  34036. 0x78,
  34037. 0x25,
  34038. 0x2e,
  34039. 0x1c,
  34040. 0xa6,
  34041. 0xb4,
  34042. 0xc6,
  34043. 0xe8,
  34044. 0xdd,
  34045. 0x74,
  34046. 0x1f,
  34047. 0x4b,
  34048. 0xbd,
  34049. 0x8b,
  34050. 0x8a,
  34051. 0x70,
  34052. 0x3e,
  34053. 0xb5,
  34054. 0x66,
  34055. 0x48,
  34056. 0x03,
  34057. 0xf6,
  34058. 0x0e,
  34059. 0x61,
  34060. 0x35,
  34061. 0x57,
  34062. 0xb9,
  34063. 0x86,
  34064. 0xc1,
  34065. 0x1d,
  34066. 0x9e,
  34067. 0xe1,
  34068. 0xf8,
  34069. 0x98,
  34070. 0x11,
  34071. 0x69,
  34072. 0xd9,
  34073. 0x8e,
  34074. 0x94,
  34075. 0x9b,
  34076. 0x1e,
  34077. 0x87,
  34078. 0xe9,
  34079. 0xce,
  34080. 0x55,
  34081. 0x28,
  34082. 0xdf,
  34083. 0x8c,
  34084. 0xa1,
  34085. 0x89,
  34086. 0x0d,
  34087. 0xbf,
  34088. 0xe6,
  34089. 0x42,
  34090. 0x68,
  34091. 0x41,
  34092. 0x99,
  34093. 0x2d,
  34094. 0x0f,
  34095. 0xb0,
  34096. 0x54,
  34097. 0xbb,
  34098. 0x16
  34099. ]);
  34100. var inv_s = new Uint8Array([
  34101. 0x52,
  34102. 0x09,
  34103. 0x6a,
  34104. 0xd5,
  34105. 0x30,
  34106. 0x36,
  34107. 0xa5,
  34108. 0x38,
  34109. 0xbf,
  34110. 0x40,
  34111. 0xa3,
  34112. 0x9e,
  34113. 0x81,
  34114. 0xf3,
  34115. 0xd7,
  34116. 0xfb,
  34117. 0x7c,
  34118. 0xe3,
  34119. 0x39,
  34120. 0x82,
  34121. 0x9b,
  34122. 0x2f,
  34123. 0xff,
  34124. 0x87,
  34125. 0x34,
  34126. 0x8e,
  34127. 0x43,
  34128. 0x44,
  34129. 0xc4,
  34130. 0xde,
  34131. 0xe9,
  34132. 0xcb,
  34133. 0x54,
  34134. 0x7b,
  34135. 0x94,
  34136. 0x32,
  34137. 0xa6,
  34138. 0xc2,
  34139. 0x23,
  34140. 0x3d,
  34141. 0xee,
  34142. 0x4c,
  34143. 0x95,
  34144. 0x0b,
  34145. 0x42,
  34146. 0xfa,
  34147. 0xc3,
  34148. 0x4e,
  34149. 0x08,
  34150. 0x2e,
  34151. 0xa1,
  34152. 0x66,
  34153. 0x28,
  34154. 0xd9,
  34155. 0x24,
  34156. 0xb2,
  34157. 0x76,
  34158. 0x5b,
  34159. 0xa2,
  34160. 0x49,
  34161. 0x6d,
  34162. 0x8b,
  34163. 0xd1,
  34164. 0x25,
  34165. 0x72,
  34166. 0xf8,
  34167. 0xf6,
  34168. 0x64,
  34169. 0x86,
  34170. 0x68,
  34171. 0x98,
  34172. 0x16,
  34173. 0xd4,
  34174. 0xa4,
  34175. 0x5c,
  34176. 0xcc,
  34177. 0x5d,
  34178. 0x65,
  34179. 0xb6,
  34180. 0x92,
  34181. 0x6c,
  34182. 0x70,
  34183. 0x48,
  34184. 0x50,
  34185. 0xfd,
  34186. 0xed,
  34187. 0xb9,
  34188. 0xda,
  34189. 0x5e,
  34190. 0x15,
  34191. 0x46,
  34192. 0x57,
  34193. 0xa7,
  34194. 0x8d,
  34195. 0x9d,
  34196. 0x84,
  34197. 0x90,
  34198. 0xd8,
  34199. 0xab,
  34200. 0x00,
  34201. 0x8c,
  34202. 0xbc,
  34203. 0xd3,
  34204. 0x0a,
  34205. 0xf7,
  34206. 0xe4,
  34207. 0x58,
  34208. 0x05,
  34209. 0xb8,
  34210. 0xb3,
  34211. 0x45,
  34212. 0x06,
  34213. 0xd0,
  34214. 0x2c,
  34215. 0x1e,
  34216. 0x8f,
  34217. 0xca,
  34218. 0x3f,
  34219. 0x0f,
  34220. 0x02,
  34221. 0xc1,
  34222. 0xaf,
  34223. 0xbd,
  34224. 0x03,
  34225. 0x01,
  34226. 0x13,
  34227. 0x8a,
  34228. 0x6b,
  34229. 0x3a,
  34230. 0x91,
  34231. 0x11,
  34232. 0x41,
  34233. 0x4f,
  34234. 0x67,
  34235. 0xdc,
  34236. 0xea,
  34237. 0x97,
  34238. 0xf2,
  34239. 0xcf,
  34240. 0xce,
  34241. 0xf0,
  34242. 0xb4,
  34243. 0xe6,
  34244. 0x73,
  34245. 0x96,
  34246. 0xac,
  34247. 0x74,
  34248. 0x22,
  34249. 0xe7,
  34250. 0xad,
  34251. 0x35,
  34252. 0x85,
  34253. 0xe2,
  34254. 0xf9,
  34255. 0x37,
  34256. 0xe8,
  34257. 0x1c,
  34258. 0x75,
  34259. 0xdf,
  34260. 0x6e,
  34261. 0x47,
  34262. 0xf1,
  34263. 0x1a,
  34264. 0x71,
  34265. 0x1d,
  34266. 0x29,
  34267. 0xc5,
  34268. 0x89,
  34269. 0x6f,
  34270. 0xb7,
  34271. 0x62,
  34272. 0x0e,
  34273. 0xaa,
  34274. 0x18,
  34275. 0xbe,
  34276. 0x1b,
  34277. 0xfc,
  34278. 0x56,
  34279. 0x3e,
  34280. 0x4b,
  34281. 0xc6,
  34282. 0xd2,
  34283. 0x79,
  34284. 0x20,
  34285. 0x9a,
  34286. 0xdb,
  34287. 0xc0,
  34288. 0xfe,
  34289. 0x78,
  34290. 0xcd,
  34291. 0x5a,
  34292. 0xf4,
  34293. 0x1f,
  34294. 0xdd,
  34295. 0xa8,
  34296. 0x33,
  34297. 0x88,
  34298. 0x07,
  34299. 0xc7,
  34300. 0x31,
  34301. 0xb1,
  34302. 0x12,
  34303. 0x10,
  34304. 0x59,
  34305. 0x27,
  34306. 0x80,
  34307. 0xec,
  34308. 0x5f,
  34309. 0x60,
  34310. 0x51,
  34311. 0x7f,
  34312. 0xa9,
  34313. 0x19,
  34314. 0xb5,
  34315. 0x4a,
  34316. 0x0d,
  34317. 0x2d,
  34318. 0xe5,
  34319. 0x7a,
  34320. 0x9f,
  34321. 0x93,
  34322. 0xc9,
  34323. 0x9c,
  34324. 0xef,
  34325. 0xa0,
  34326. 0xe0,
  34327. 0x3b,
  34328. 0x4d,
  34329. 0xae,
  34330. 0x2a,
  34331. 0xf5,
  34332. 0xb0,
  34333. 0xc8,
  34334. 0xeb,
  34335. 0xbb,
  34336. 0x3c,
  34337. 0x83,
  34338. 0x53,
  34339. 0x99,
  34340. 0x61,
  34341. 0x17,
  34342. 0x2b,
  34343. 0x04,
  34344. 0x7e,
  34345. 0xba,
  34346. 0x77,
  34347. 0xd6,
  34348. 0x26,
  34349. 0xe1,
  34350. 0x69,
  34351. 0x14,
  34352. 0x63,
  34353. 0x55,
  34354. 0x21,
  34355. 0x0c,
  34356. 0x7d
  34357. ]);
  34358. var mixCol = new Uint8Array(256);
  34359. for (var i = 0; i < 256; i++) {
  34360. if (i < 128) {
  34361. mixCol[i] = i << 1;
  34362. } else {
  34363. mixCol[i] = i << 1 ^ 0x1b;
  34364. }
  34365. }
  34366. var mix = new Uint32Array([
  34367. 0x00000000,
  34368. 0x0e090d0b,
  34369. 0x1c121a16,
  34370. 0x121b171d,
  34371. 0x3824342c,
  34372. 0x362d3927,
  34373. 0x24362e3a,
  34374. 0x2a3f2331,
  34375. 0x70486858,
  34376. 0x7e416553,
  34377. 0x6c5a724e,
  34378. 0x62537f45,
  34379. 0x486c5c74,
  34380. 0x4665517f,
  34381. 0x547e4662,
  34382. 0x5a774b69,
  34383. 0xe090d0b0,
  34384. 0xee99ddbb,
  34385. 0xfc82caa6,
  34386. 0xf28bc7ad,
  34387. 0xd8b4e49c,
  34388. 0xd6bde997,
  34389. 0xc4a6fe8a,
  34390. 0xcaaff381,
  34391. 0x90d8b8e8,
  34392. 0x9ed1b5e3,
  34393. 0x8ccaa2fe,
  34394. 0x82c3aff5,
  34395. 0xa8fc8cc4,
  34396. 0xa6f581cf,
  34397. 0xb4ee96d2,
  34398. 0xbae79bd9,
  34399. 0xdb3bbb7b,
  34400. 0xd532b670,
  34401. 0xc729a16d,
  34402. 0xc920ac66,
  34403. 0xe31f8f57,
  34404. 0xed16825c,
  34405. 0xff0d9541,
  34406. 0xf104984a,
  34407. 0xab73d323,
  34408. 0xa57ade28,
  34409. 0xb761c935,
  34410. 0xb968c43e,
  34411. 0x9357e70f,
  34412. 0x9d5eea04,
  34413. 0x8f45fd19,
  34414. 0x814cf012,
  34415. 0x3bab6bcb,
  34416. 0x35a266c0,
  34417. 0x27b971dd,
  34418. 0x29b07cd6,
  34419. 0x038f5fe7,
  34420. 0x0d8652ec,
  34421. 0x1f9d45f1,
  34422. 0x119448fa,
  34423. 0x4be30393,
  34424. 0x45ea0e98,
  34425. 0x57f11985,
  34426. 0x59f8148e,
  34427. 0x73c737bf,
  34428. 0x7dce3ab4,
  34429. 0x6fd52da9,
  34430. 0x61dc20a2,
  34431. 0xad766df6,
  34432. 0xa37f60fd,
  34433. 0xb16477e0,
  34434. 0xbf6d7aeb,
  34435. 0x955259da,
  34436. 0x9b5b54d1,
  34437. 0x894043cc,
  34438. 0x87494ec7,
  34439. 0xdd3e05ae,
  34440. 0xd33708a5,
  34441. 0xc12c1fb8,
  34442. 0xcf2512b3,
  34443. 0xe51a3182,
  34444. 0xeb133c89,
  34445. 0xf9082b94,
  34446. 0xf701269f,
  34447. 0x4de6bd46,
  34448. 0x43efb04d,
  34449. 0x51f4a750,
  34450. 0x5ffdaa5b,
  34451. 0x75c2896a,
  34452. 0x7bcb8461,
  34453. 0x69d0937c,
  34454. 0x67d99e77,
  34455. 0x3daed51e,
  34456. 0x33a7d815,
  34457. 0x21bccf08,
  34458. 0x2fb5c203,
  34459. 0x058ae132,
  34460. 0x0b83ec39,
  34461. 0x1998fb24,
  34462. 0x1791f62f,
  34463. 0x764dd68d,
  34464. 0x7844db86,
  34465. 0x6a5fcc9b,
  34466. 0x6456c190,
  34467. 0x4e69e2a1,
  34468. 0x4060efaa,
  34469. 0x527bf8b7,
  34470. 0x5c72f5bc,
  34471. 0x0605bed5,
  34472. 0x080cb3de,
  34473. 0x1a17a4c3,
  34474. 0x141ea9c8,
  34475. 0x3e218af9,
  34476. 0x302887f2,
  34477. 0x223390ef,
  34478. 0x2c3a9de4,
  34479. 0x96dd063d,
  34480. 0x98d40b36,
  34481. 0x8acf1c2b,
  34482. 0x84c61120,
  34483. 0xaef93211,
  34484. 0xa0f03f1a,
  34485. 0xb2eb2807,
  34486. 0xbce2250c,
  34487. 0xe6956e65,
  34488. 0xe89c636e,
  34489. 0xfa877473,
  34490. 0xf48e7978,
  34491. 0xdeb15a49,
  34492. 0xd0b85742,
  34493. 0xc2a3405f,
  34494. 0xccaa4d54,
  34495. 0x41ecdaf7,
  34496. 0x4fe5d7fc,
  34497. 0x5dfec0e1,
  34498. 0x53f7cdea,
  34499. 0x79c8eedb,
  34500. 0x77c1e3d0,
  34501. 0x65daf4cd,
  34502. 0x6bd3f9c6,
  34503. 0x31a4b2af,
  34504. 0x3fadbfa4,
  34505. 0x2db6a8b9,
  34506. 0x23bfa5b2,
  34507. 0x09808683,
  34508. 0x07898b88,
  34509. 0x15929c95,
  34510. 0x1b9b919e,
  34511. 0xa17c0a47,
  34512. 0xaf75074c,
  34513. 0xbd6e1051,
  34514. 0xb3671d5a,
  34515. 0x99583e6b,
  34516. 0x97513360,
  34517. 0x854a247d,
  34518. 0x8b432976,
  34519. 0xd134621f,
  34520. 0xdf3d6f14,
  34521. 0xcd267809,
  34522. 0xc32f7502,
  34523. 0xe9105633,
  34524. 0xe7195b38,
  34525. 0xf5024c25,
  34526. 0xfb0b412e,
  34527. 0x9ad7618c,
  34528. 0x94de6c87,
  34529. 0x86c57b9a,
  34530. 0x88cc7691,
  34531. 0xa2f355a0,
  34532. 0xacfa58ab,
  34533. 0xbee14fb6,
  34534. 0xb0e842bd,
  34535. 0xea9f09d4,
  34536. 0xe49604df,
  34537. 0xf68d13c2,
  34538. 0xf8841ec9,
  34539. 0xd2bb3df8,
  34540. 0xdcb230f3,
  34541. 0xcea927ee,
  34542. 0xc0a02ae5,
  34543. 0x7a47b13c,
  34544. 0x744ebc37,
  34545. 0x6655ab2a,
  34546. 0x685ca621,
  34547. 0x42638510,
  34548. 0x4c6a881b,
  34549. 0x5e719f06,
  34550. 0x5078920d,
  34551. 0x0a0fd964,
  34552. 0x0406d46f,
  34553. 0x161dc372,
  34554. 0x1814ce79,
  34555. 0x322bed48,
  34556. 0x3c22e043,
  34557. 0x2e39f75e,
  34558. 0x2030fa55,
  34559. 0xec9ab701,
  34560. 0xe293ba0a,
  34561. 0xf088ad17,
  34562. 0xfe81a01c,
  34563. 0xd4be832d,
  34564. 0xdab78e26,
  34565. 0xc8ac993b,
  34566. 0xc6a59430,
  34567. 0x9cd2df59,
  34568. 0x92dbd252,
  34569. 0x80c0c54f,
  34570. 0x8ec9c844,
  34571. 0xa4f6eb75,
  34572. 0xaaffe67e,
  34573. 0xb8e4f163,
  34574. 0xb6edfc68,
  34575. 0x0c0a67b1,
  34576. 0x02036aba,
  34577. 0x10187da7,
  34578. 0x1e1170ac,
  34579. 0x342e539d,
  34580. 0x3a275e96,
  34581. 0x283c498b,
  34582. 0x26354480,
  34583. 0x7c420fe9,
  34584. 0x724b02e2,
  34585. 0x605015ff,
  34586. 0x6e5918f4,
  34587. 0x44663bc5,
  34588. 0x4a6f36ce,
  34589. 0x587421d3,
  34590. 0x567d2cd8,
  34591. 0x37a10c7a,
  34592. 0x39a80171,
  34593. 0x2bb3166c,
  34594. 0x25ba1b67,
  34595. 0x0f853856,
  34596. 0x018c355d,
  34597. 0x13972240,
  34598. 0x1d9e2f4b,
  34599. 0x47e96422,
  34600. 0x49e06929,
  34601. 0x5bfb7e34,
  34602. 0x55f2733f,
  34603. 0x7fcd500e,
  34604. 0x71c45d05,
  34605. 0x63df4a18,
  34606. 0x6dd64713,
  34607. 0xd731dcca,
  34608. 0xd938d1c1,
  34609. 0xcb23c6dc,
  34610. 0xc52acbd7,
  34611. 0xef15e8e6,
  34612. 0xe11ce5ed,
  34613. 0xf307f2f0,
  34614. 0xfd0efffb,
  34615. 0xa779b492,
  34616. 0xa970b999,
  34617. 0xbb6bae84,
  34618. 0xb562a38f,
  34619. 0x9f5d80be,
  34620. 0x91548db5,
  34621. 0x834f9aa8,
  34622. 0x8d4697a3
  34623. ]);
  34624. function expandKey128(cipherKey) {
  34625. var b = 176, result = new Uint8Array(b);
  34626. result.set(cipherKey);
  34627. for (var j = 16, i = 1; j < b; ++i) {
  34628. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34629. t1 = s[t1];
  34630. t2 = s[t2];
  34631. t3 = s[t3];
  34632. t4 = s[t4];
  34633. t1 = t1 ^ rcon[i];
  34634. for (var n = 0; n < 4; ++n) {
  34635. result[j] = t1 ^= result[j - 16];
  34636. j++;
  34637. result[j] = t2 ^= result[j - 16];
  34638. j++;
  34639. result[j] = t3 ^= result[j - 16];
  34640. j++;
  34641. result[j] = t4 ^= result[j - 16];
  34642. j++;
  34643. }
  34644. }
  34645. return result;
  34646. }
  34647. function decrypt128(input, key) {
  34648. var state = new Uint8Array(16);
  34649. state.set(input);
  34650. var i, j, k;
  34651. var t, u, v;
  34652. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34653. state[j] ^= key[k];
  34654. }
  34655. for (i = 9; i >= 1; --i) {
  34656. t = state[13];
  34657. state[13] = state[9];
  34658. state[9] = state[5];
  34659. state[5] = state[1];
  34660. state[1] = t;
  34661. t = state[14];
  34662. u = state[10];
  34663. state[14] = state[6];
  34664. state[10] = state[2];
  34665. state[6] = t;
  34666. state[2] = u;
  34667. t = state[15];
  34668. u = state[11];
  34669. v = state[7];
  34670. state[15] = state[3];
  34671. state[11] = t;
  34672. state[7] = u;
  34673. state[3] = v;
  34674. for (j = 0; j < 16; ++j) {
  34675. state[j] = inv_s[state[j]];
  34676. }
  34677. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34678. state[j] ^= key[k];
  34679. }
  34680. for (j = 0; j < 16; j += 4) {
  34681. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34682. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34683. state[j] = t >>> 24 & 0xFF;
  34684. state[j + 1] = t >> 16 & 0xFF;
  34685. state[j + 2] = t >> 8 & 0xFF;
  34686. state[j + 3] = t & 0xFF;
  34687. }
  34688. }
  34689. t = state[13];
  34690. state[13] = state[9];
  34691. state[9] = state[5];
  34692. state[5] = state[1];
  34693. state[1] = t;
  34694. t = state[14];
  34695. u = state[10];
  34696. state[14] = state[6];
  34697. state[10] = state[2];
  34698. state[6] = t;
  34699. state[2] = u;
  34700. t = state[15];
  34701. u = state[11];
  34702. v = state[7];
  34703. state[15] = state[3];
  34704. state[11] = t;
  34705. state[7] = u;
  34706. state[3] = v;
  34707. for (j = 0; j < 16; ++j) {
  34708. state[j] = inv_s[state[j]];
  34709. state[j] ^= key[j];
  34710. }
  34711. return state;
  34712. }
  34713. function encrypt128(input, key) {
  34714. var t, u, v, k;
  34715. var state = new Uint8Array(16);
  34716. state.set(input);
  34717. for (j = 0; j < 16; ++j) {
  34718. state[j] ^= key[j];
  34719. }
  34720. for (i = 1; i < 10; i++) {
  34721. for (j = 0; j < 16; ++j) {
  34722. state[j] = s[state[j]];
  34723. }
  34724. v = state[1];
  34725. state[1] = state[5];
  34726. state[5] = state[9];
  34727. state[9] = state[13];
  34728. state[13] = v;
  34729. v = state[2];
  34730. u = state[6];
  34731. state[2] = state[10];
  34732. state[6] = state[14];
  34733. state[10] = v;
  34734. state[14] = u;
  34735. v = state[3];
  34736. u = state[7];
  34737. t = state[11];
  34738. state[3] = state[15];
  34739. state[7] = v;
  34740. state[11] = u;
  34741. state[15] = t;
  34742. for (var j = 0; j < 16; j += 4) {
  34743. var s0 = state[j + 0], s1 = state[j + 1];
  34744. var s2 = state[j + 2], s3 = state[j + 3];
  34745. t = s0 ^ s1 ^ s2 ^ s3;
  34746. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34747. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34748. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34749. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34750. }
  34751. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34752. state[j] ^= key[k];
  34753. }
  34754. }
  34755. for (j = 0; j < 16; ++j) {
  34756. state[j] = s[state[j]];
  34757. }
  34758. v = state[1];
  34759. state[1] = state[5];
  34760. state[5] = state[9];
  34761. state[9] = state[13];
  34762. state[13] = v;
  34763. v = state[2];
  34764. u = state[6];
  34765. state[2] = state[10];
  34766. state[6] = state[14];
  34767. state[10] = v;
  34768. state[14] = u;
  34769. v = state[3];
  34770. u = state[7];
  34771. t = state[11];
  34772. state[3] = state[15];
  34773. state[7] = v;
  34774. state[11] = u;
  34775. state[15] = t;
  34776. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34777. state[j] ^= key[k];
  34778. }
  34779. return state;
  34780. }
  34781. function AES128Cipher(key) {
  34782. this.key = expandKey128(key);
  34783. this.buffer = new Uint8Array(16);
  34784. this.bufferPosition = 0;
  34785. }
  34786. function decryptBlock2(data, finalize) {
  34787. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34788. for (i = 0; i < sourceLength; ++i) {
  34789. buffer[bufferLength] = data[i];
  34790. ++bufferLength;
  34791. if (bufferLength < 16) {
  34792. continue;
  34793. }
  34794. var plain = decrypt128(buffer, this.key);
  34795. for (j = 0; j < 16; ++j) {
  34796. plain[j] ^= iv[j];
  34797. }
  34798. iv = buffer;
  34799. result.push(plain);
  34800. buffer = new Uint8Array(16);
  34801. bufferLength = 0;
  34802. }
  34803. this.buffer = buffer;
  34804. this.bufferLength = bufferLength;
  34805. this.iv = iv;
  34806. if (result.length === 0) {
  34807. return new Uint8Array([]);
  34808. }
  34809. var outputLength = 16 * result.length;
  34810. if (finalize) {
  34811. var lastBlock = result[result.length - 1];
  34812. var psLen = lastBlock[15];
  34813. if (psLen <= 16) {
  34814. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34815. if (lastBlock[i] !== psLen) {
  34816. psLen = 0;
  34817. break;
  34818. }
  34819. }
  34820. outputLength -= psLen;
  34821. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34822. }
  34823. }
  34824. var output = new Uint8Array(outputLength);
  34825. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34826. output.set(result[i], j);
  34827. }
  34828. return output;
  34829. }
  34830. AES128Cipher.prototype = {
  34831. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34832. var i, sourceLength = data.length;
  34833. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34834. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34835. buffer[bufferLength] = data[i];
  34836. }
  34837. if (bufferLength < 16) {
  34838. this.bufferLength = bufferLength;
  34839. return new Uint8Array([]);
  34840. }
  34841. this.iv = buffer;
  34842. this.buffer = new Uint8Array(16);
  34843. this.bufferLength = 0;
  34844. this.decryptBlock = decryptBlock2;
  34845. return this.decryptBlock(data.subarray(16), finalize);
  34846. },
  34847. encrypt: function AES128Cipher_encrypt(data, iv) {
  34848. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34849. if (!iv) {
  34850. iv = new Uint8Array(16);
  34851. }
  34852. for (i = 0; i < sourceLength; ++i) {
  34853. buffer[bufferLength] = data[i];
  34854. ++bufferLength;
  34855. if (bufferLength < 16) {
  34856. continue;
  34857. }
  34858. for (j = 0; j < 16; ++j) {
  34859. buffer[j] ^= iv[j];
  34860. }
  34861. var cipher = encrypt128(buffer, this.key);
  34862. iv = cipher;
  34863. result.push(cipher);
  34864. buffer = new Uint8Array(16);
  34865. bufferLength = 0;
  34866. }
  34867. this.buffer = buffer;
  34868. this.bufferLength = bufferLength;
  34869. this.iv = iv;
  34870. if (result.length === 0) {
  34871. return new Uint8Array([]);
  34872. }
  34873. var outputLength = 16 * result.length;
  34874. var output = new Uint8Array(outputLength);
  34875. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34876. output.set(result[i], j);
  34877. }
  34878. return output;
  34879. }
  34880. };
  34881. return AES128Cipher;
  34882. }();
  34883. var AES256Cipher = function AES256CipherClosure() {
  34884. var rcon = new Uint8Array([
  34885. 0x8d,
  34886. 0x01,
  34887. 0x02,
  34888. 0x04,
  34889. 0x08,
  34890. 0x10,
  34891. 0x20,
  34892. 0x40,
  34893. 0x80,
  34894. 0x1b,
  34895. 0x36,
  34896. 0x6c,
  34897. 0xd8,
  34898. 0xab,
  34899. 0x4d,
  34900. 0x9a,
  34901. 0x2f,
  34902. 0x5e,
  34903. 0xbc,
  34904. 0x63,
  34905. 0xc6,
  34906. 0x97,
  34907. 0x35,
  34908. 0x6a,
  34909. 0xd4,
  34910. 0xb3,
  34911. 0x7d,
  34912. 0xfa,
  34913. 0xef,
  34914. 0xc5,
  34915. 0x91,
  34916. 0x39,
  34917. 0x72,
  34918. 0xe4,
  34919. 0xd3,
  34920. 0xbd,
  34921. 0x61,
  34922. 0xc2,
  34923. 0x9f,
  34924. 0x25,
  34925. 0x4a,
  34926. 0x94,
  34927. 0x33,
  34928. 0x66,
  34929. 0xcc,
  34930. 0x83,
  34931. 0x1d,
  34932. 0x3a,
  34933. 0x74,
  34934. 0xe8,
  34935. 0xcb,
  34936. 0x8d,
  34937. 0x01,
  34938. 0x02,
  34939. 0x04,
  34940. 0x08,
  34941. 0x10,
  34942. 0x20,
  34943. 0x40,
  34944. 0x80,
  34945. 0x1b,
  34946. 0x36,
  34947. 0x6c,
  34948. 0xd8,
  34949. 0xab,
  34950. 0x4d,
  34951. 0x9a,
  34952. 0x2f,
  34953. 0x5e,
  34954. 0xbc,
  34955. 0x63,
  34956. 0xc6,
  34957. 0x97,
  34958. 0x35,
  34959. 0x6a,
  34960. 0xd4,
  34961. 0xb3,
  34962. 0x7d,
  34963. 0xfa,
  34964. 0xef,
  34965. 0xc5,
  34966. 0x91,
  34967. 0x39,
  34968. 0x72,
  34969. 0xe4,
  34970. 0xd3,
  34971. 0xbd,
  34972. 0x61,
  34973. 0xc2,
  34974. 0x9f,
  34975. 0x25,
  34976. 0x4a,
  34977. 0x94,
  34978. 0x33,
  34979. 0x66,
  34980. 0xcc,
  34981. 0x83,
  34982. 0x1d,
  34983. 0x3a,
  34984. 0x74,
  34985. 0xe8,
  34986. 0xcb,
  34987. 0x8d,
  34988. 0x01,
  34989. 0x02,
  34990. 0x04,
  34991. 0x08,
  34992. 0x10,
  34993. 0x20,
  34994. 0x40,
  34995. 0x80,
  34996. 0x1b,
  34997. 0x36,
  34998. 0x6c,
  34999. 0xd8,
  35000. 0xab,
  35001. 0x4d,
  35002. 0x9a,
  35003. 0x2f,
  35004. 0x5e,
  35005. 0xbc,
  35006. 0x63,
  35007. 0xc6,
  35008. 0x97,
  35009. 0x35,
  35010. 0x6a,
  35011. 0xd4,
  35012. 0xb3,
  35013. 0x7d,
  35014. 0xfa,
  35015. 0xef,
  35016. 0xc5,
  35017. 0x91,
  35018. 0x39,
  35019. 0x72,
  35020. 0xe4,
  35021. 0xd3,
  35022. 0xbd,
  35023. 0x61,
  35024. 0xc2,
  35025. 0x9f,
  35026. 0x25,
  35027. 0x4a,
  35028. 0x94,
  35029. 0x33,
  35030. 0x66,
  35031. 0xcc,
  35032. 0x83,
  35033. 0x1d,
  35034. 0x3a,
  35035. 0x74,
  35036. 0xe8,
  35037. 0xcb,
  35038. 0x8d,
  35039. 0x01,
  35040. 0x02,
  35041. 0x04,
  35042. 0x08,
  35043. 0x10,
  35044. 0x20,
  35045. 0x40,
  35046. 0x80,
  35047. 0x1b,
  35048. 0x36,
  35049. 0x6c,
  35050. 0xd8,
  35051. 0xab,
  35052. 0x4d,
  35053. 0x9a,
  35054. 0x2f,
  35055. 0x5e,
  35056. 0xbc,
  35057. 0x63,
  35058. 0xc6,
  35059. 0x97,
  35060. 0x35,
  35061. 0x6a,
  35062. 0xd4,
  35063. 0xb3,
  35064. 0x7d,
  35065. 0xfa,
  35066. 0xef,
  35067. 0xc5,
  35068. 0x91,
  35069. 0x39,
  35070. 0x72,
  35071. 0xe4,
  35072. 0xd3,
  35073. 0xbd,
  35074. 0x61,
  35075. 0xc2,
  35076. 0x9f,
  35077. 0x25,
  35078. 0x4a,
  35079. 0x94,
  35080. 0x33,
  35081. 0x66,
  35082. 0xcc,
  35083. 0x83,
  35084. 0x1d,
  35085. 0x3a,
  35086. 0x74,
  35087. 0xe8,
  35088. 0xcb,
  35089. 0x8d,
  35090. 0x01,
  35091. 0x02,
  35092. 0x04,
  35093. 0x08,
  35094. 0x10,
  35095. 0x20,
  35096. 0x40,
  35097. 0x80,
  35098. 0x1b,
  35099. 0x36,
  35100. 0x6c,
  35101. 0xd8,
  35102. 0xab,
  35103. 0x4d,
  35104. 0x9a,
  35105. 0x2f,
  35106. 0x5e,
  35107. 0xbc,
  35108. 0x63,
  35109. 0xc6,
  35110. 0x97,
  35111. 0x35,
  35112. 0x6a,
  35113. 0xd4,
  35114. 0xb3,
  35115. 0x7d,
  35116. 0xfa,
  35117. 0xef,
  35118. 0xc5,
  35119. 0x91,
  35120. 0x39,
  35121. 0x72,
  35122. 0xe4,
  35123. 0xd3,
  35124. 0xbd,
  35125. 0x61,
  35126. 0xc2,
  35127. 0x9f,
  35128. 0x25,
  35129. 0x4a,
  35130. 0x94,
  35131. 0x33,
  35132. 0x66,
  35133. 0xcc,
  35134. 0x83,
  35135. 0x1d,
  35136. 0x3a,
  35137. 0x74,
  35138. 0xe8,
  35139. 0xcb,
  35140. 0x8d
  35141. ]);
  35142. var s = new Uint8Array([
  35143. 0x63,
  35144. 0x7c,
  35145. 0x77,
  35146. 0x7b,
  35147. 0xf2,
  35148. 0x6b,
  35149. 0x6f,
  35150. 0xc5,
  35151. 0x30,
  35152. 0x01,
  35153. 0x67,
  35154. 0x2b,
  35155. 0xfe,
  35156. 0xd7,
  35157. 0xab,
  35158. 0x76,
  35159. 0xca,
  35160. 0x82,
  35161. 0xc9,
  35162. 0x7d,
  35163. 0xfa,
  35164. 0x59,
  35165. 0x47,
  35166. 0xf0,
  35167. 0xad,
  35168. 0xd4,
  35169. 0xa2,
  35170. 0xaf,
  35171. 0x9c,
  35172. 0xa4,
  35173. 0x72,
  35174. 0xc0,
  35175. 0xb7,
  35176. 0xfd,
  35177. 0x93,
  35178. 0x26,
  35179. 0x36,
  35180. 0x3f,
  35181. 0xf7,
  35182. 0xcc,
  35183. 0x34,
  35184. 0xa5,
  35185. 0xe5,
  35186. 0xf1,
  35187. 0x71,
  35188. 0xd8,
  35189. 0x31,
  35190. 0x15,
  35191. 0x04,
  35192. 0xc7,
  35193. 0x23,
  35194. 0xc3,
  35195. 0x18,
  35196. 0x96,
  35197. 0x05,
  35198. 0x9a,
  35199. 0x07,
  35200. 0x12,
  35201. 0x80,
  35202. 0xe2,
  35203. 0xeb,
  35204. 0x27,
  35205. 0xb2,
  35206. 0x75,
  35207. 0x09,
  35208. 0x83,
  35209. 0x2c,
  35210. 0x1a,
  35211. 0x1b,
  35212. 0x6e,
  35213. 0x5a,
  35214. 0xa0,
  35215. 0x52,
  35216. 0x3b,
  35217. 0xd6,
  35218. 0xb3,
  35219. 0x29,
  35220. 0xe3,
  35221. 0x2f,
  35222. 0x84,
  35223. 0x53,
  35224. 0xd1,
  35225. 0x00,
  35226. 0xed,
  35227. 0x20,
  35228. 0xfc,
  35229. 0xb1,
  35230. 0x5b,
  35231. 0x6a,
  35232. 0xcb,
  35233. 0xbe,
  35234. 0x39,
  35235. 0x4a,
  35236. 0x4c,
  35237. 0x58,
  35238. 0xcf,
  35239. 0xd0,
  35240. 0xef,
  35241. 0xaa,
  35242. 0xfb,
  35243. 0x43,
  35244. 0x4d,
  35245. 0x33,
  35246. 0x85,
  35247. 0x45,
  35248. 0xf9,
  35249. 0x02,
  35250. 0x7f,
  35251. 0x50,
  35252. 0x3c,
  35253. 0x9f,
  35254. 0xa8,
  35255. 0x51,
  35256. 0xa3,
  35257. 0x40,
  35258. 0x8f,
  35259. 0x92,
  35260. 0x9d,
  35261. 0x38,
  35262. 0xf5,
  35263. 0xbc,
  35264. 0xb6,
  35265. 0xda,
  35266. 0x21,
  35267. 0x10,
  35268. 0xff,
  35269. 0xf3,
  35270. 0xd2,
  35271. 0xcd,
  35272. 0x0c,
  35273. 0x13,
  35274. 0xec,
  35275. 0x5f,
  35276. 0x97,
  35277. 0x44,
  35278. 0x17,
  35279. 0xc4,
  35280. 0xa7,
  35281. 0x7e,
  35282. 0x3d,
  35283. 0x64,
  35284. 0x5d,
  35285. 0x19,
  35286. 0x73,
  35287. 0x60,
  35288. 0x81,
  35289. 0x4f,
  35290. 0xdc,
  35291. 0x22,
  35292. 0x2a,
  35293. 0x90,
  35294. 0x88,
  35295. 0x46,
  35296. 0xee,
  35297. 0xb8,
  35298. 0x14,
  35299. 0xde,
  35300. 0x5e,
  35301. 0x0b,
  35302. 0xdb,
  35303. 0xe0,
  35304. 0x32,
  35305. 0x3a,
  35306. 0x0a,
  35307. 0x49,
  35308. 0x06,
  35309. 0x24,
  35310. 0x5c,
  35311. 0xc2,
  35312. 0xd3,
  35313. 0xac,
  35314. 0x62,
  35315. 0x91,
  35316. 0x95,
  35317. 0xe4,
  35318. 0x79,
  35319. 0xe7,
  35320. 0xc8,
  35321. 0x37,
  35322. 0x6d,
  35323. 0x8d,
  35324. 0xd5,
  35325. 0x4e,
  35326. 0xa9,
  35327. 0x6c,
  35328. 0x56,
  35329. 0xf4,
  35330. 0xea,
  35331. 0x65,
  35332. 0x7a,
  35333. 0xae,
  35334. 0x08,
  35335. 0xba,
  35336. 0x78,
  35337. 0x25,
  35338. 0x2e,
  35339. 0x1c,
  35340. 0xa6,
  35341. 0xb4,
  35342. 0xc6,
  35343. 0xe8,
  35344. 0xdd,
  35345. 0x74,
  35346. 0x1f,
  35347. 0x4b,
  35348. 0xbd,
  35349. 0x8b,
  35350. 0x8a,
  35351. 0x70,
  35352. 0x3e,
  35353. 0xb5,
  35354. 0x66,
  35355. 0x48,
  35356. 0x03,
  35357. 0xf6,
  35358. 0x0e,
  35359. 0x61,
  35360. 0x35,
  35361. 0x57,
  35362. 0xb9,
  35363. 0x86,
  35364. 0xc1,
  35365. 0x1d,
  35366. 0x9e,
  35367. 0xe1,
  35368. 0xf8,
  35369. 0x98,
  35370. 0x11,
  35371. 0x69,
  35372. 0xd9,
  35373. 0x8e,
  35374. 0x94,
  35375. 0x9b,
  35376. 0x1e,
  35377. 0x87,
  35378. 0xe9,
  35379. 0xce,
  35380. 0x55,
  35381. 0x28,
  35382. 0xdf,
  35383. 0x8c,
  35384. 0xa1,
  35385. 0x89,
  35386. 0x0d,
  35387. 0xbf,
  35388. 0xe6,
  35389. 0x42,
  35390. 0x68,
  35391. 0x41,
  35392. 0x99,
  35393. 0x2d,
  35394. 0x0f,
  35395. 0xb0,
  35396. 0x54,
  35397. 0xbb,
  35398. 0x16
  35399. ]);
  35400. var inv_s = new Uint8Array([
  35401. 0x52,
  35402. 0x09,
  35403. 0x6a,
  35404. 0xd5,
  35405. 0x30,
  35406. 0x36,
  35407. 0xa5,
  35408. 0x38,
  35409. 0xbf,
  35410. 0x40,
  35411. 0xa3,
  35412. 0x9e,
  35413. 0x81,
  35414. 0xf3,
  35415. 0xd7,
  35416. 0xfb,
  35417. 0x7c,
  35418. 0xe3,
  35419. 0x39,
  35420. 0x82,
  35421. 0x9b,
  35422. 0x2f,
  35423. 0xff,
  35424. 0x87,
  35425. 0x34,
  35426. 0x8e,
  35427. 0x43,
  35428. 0x44,
  35429. 0xc4,
  35430. 0xde,
  35431. 0xe9,
  35432. 0xcb,
  35433. 0x54,
  35434. 0x7b,
  35435. 0x94,
  35436. 0x32,
  35437. 0xa6,
  35438. 0xc2,
  35439. 0x23,
  35440. 0x3d,
  35441. 0xee,
  35442. 0x4c,
  35443. 0x95,
  35444. 0x0b,
  35445. 0x42,
  35446. 0xfa,
  35447. 0xc3,
  35448. 0x4e,
  35449. 0x08,
  35450. 0x2e,
  35451. 0xa1,
  35452. 0x66,
  35453. 0x28,
  35454. 0xd9,
  35455. 0x24,
  35456. 0xb2,
  35457. 0x76,
  35458. 0x5b,
  35459. 0xa2,
  35460. 0x49,
  35461. 0x6d,
  35462. 0x8b,
  35463. 0xd1,
  35464. 0x25,
  35465. 0x72,
  35466. 0xf8,
  35467. 0xf6,
  35468. 0x64,
  35469. 0x86,
  35470. 0x68,
  35471. 0x98,
  35472. 0x16,
  35473. 0xd4,
  35474. 0xa4,
  35475. 0x5c,
  35476. 0xcc,
  35477. 0x5d,
  35478. 0x65,
  35479. 0xb6,
  35480. 0x92,
  35481. 0x6c,
  35482. 0x70,
  35483. 0x48,
  35484. 0x50,
  35485. 0xfd,
  35486. 0xed,
  35487. 0xb9,
  35488. 0xda,
  35489. 0x5e,
  35490. 0x15,
  35491. 0x46,
  35492. 0x57,
  35493. 0xa7,
  35494. 0x8d,
  35495. 0x9d,
  35496. 0x84,
  35497. 0x90,
  35498. 0xd8,
  35499. 0xab,
  35500. 0x00,
  35501. 0x8c,
  35502. 0xbc,
  35503. 0xd3,
  35504. 0x0a,
  35505. 0xf7,
  35506. 0xe4,
  35507. 0x58,
  35508. 0x05,
  35509. 0xb8,
  35510. 0xb3,
  35511. 0x45,
  35512. 0x06,
  35513. 0xd0,
  35514. 0x2c,
  35515. 0x1e,
  35516. 0x8f,
  35517. 0xca,
  35518. 0x3f,
  35519. 0x0f,
  35520. 0x02,
  35521. 0xc1,
  35522. 0xaf,
  35523. 0xbd,
  35524. 0x03,
  35525. 0x01,
  35526. 0x13,
  35527. 0x8a,
  35528. 0x6b,
  35529. 0x3a,
  35530. 0x91,
  35531. 0x11,
  35532. 0x41,
  35533. 0x4f,
  35534. 0x67,
  35535. 0xdc,
  35536. 0xea,
  35537. 0x97,
  35538. 0xf2,
  35539. 0xcf,
  35540. 0xce,
  35541. 0xf0,
  35542. 0xb4,
  35543. 0xe6,
  35544. 0x73,
  35545. 0x96,
  35546. 0xac,
  35547. 0x74,
  35548. 0x22,
  35549. 0xe7,
  35550. 0xad,
  35551. 0x35,
  35552. 0x85,
  35553. 0xe2,
  35554. 0xf9,
  35555. 0x37,
  35556. 0xe8,
  35557. 0x1c,
  35558. 0x75,
  35559. 0xdf,
  35560. 0x6e,
  35561. 0x47,
  35562. 0xf1,
  35563. 0x1a,
  35564. 0x71,
  35565. 0x1d,
  35566. 0x29,
  35567. 0xc5,
  35568. 0x89,
  35569. 0x6f,
  35570. 0xb7,
  35571. 0x62,
  35572. 0x0e,
  35573. 0xaa,
  35574. 0x18,
  35575. 0xbe,
  35576. 0x1b,
  35577. 0xfc,
  35578. 0x56,
  35579. 0x3e,
  35580. 0x4b,
  35581. 0xc6,
  35582. 0xd2,
  35583. 0x79,
  35584. 0x20,
  35585. 0x9a,
  35586. 0xdb,
  35587. 0xc0,
  35588. 0xfe,
  35589. 0x78,
  35590. 0xcd,
  35591. 0x5a,
  35592. 0xf4,
  35593. 0x1f,
  35594. 0xdd,
  35595. 0xa8,
  35596. 0x33,
  35597. 0x88,
  35598. 0x07,
  35599. 0xc7,
  35600. 0x31,
  35601. 0xb1,
  35602. 0x12,
  35603. 0x10,
  35604. 0x59,
  35605. 0x27,
  35606. 0x80,
  35607. 0xec,
  35608. 0x5f,
  35609. 0x60,
  35610. 0x51,
  35611. 0x7f,
  35612. 0xa9,
  35613. 0x19,
  35614. 0xb5,
  35615. 0x4a,
  35616. 0x0d,
  35617. 0x2d,
  35618. 0xe5,
  35619. 0x7a,
  35620. 0x9f,
  35621. 0x93,
  35622. 0xc9,
  35623. 0x9c,
  35624. 0xef,
  35625. 0xa0,
  35626. 0xe0,
  35627. 0x3b,
  35628. 0x4d,
  35629. 0xae,
  35630. 0x2a,
  35631. 0xf5,
  35632. 0xb0,
  35633. 0xc8,
  35634. 0xeb,
  35635. 0xbb,
  35636. 0x3c,
  35637. 0x83,
  35638. 0x53,
  35639. 0x99,
  35640. 0x61,
  35641. 0x17,
  35642. 0x2b,
  35643. 0x04,
  35644. 0x7e,
  35645. 0xba,
  35646. 0x77,
  35647. 0xd6,
  35648. 0x26,
  35649. 0xe1,
  35650. 0x69,
  35651. 0x14,
  35652. 0x63,
  35653. 0x55,
  35654. 0x21,
  35655. 0x0c,
  35656. 0x7d
  35657. ]);
  35658. var mixCol = new Uint8Array(256);
  35659. for (var i = 0; i < 256; i++) {
  35660. if (i < 128) {
  35661. mixCol[i] = i << 1;
  35662. } else {
  35663. mixCol[i] = i << 1 ^ 0x1b;
  35664. }
  35665. }
  35666. var mix = new Uint32Array([
  35667. 0x00000000,
  35668. 0x0e090d0b,
  35669. 0x1c121a16,
  35670. 0x121b171d,
  35671. 0x3824342c,
  35672. 0x362d3927,
  35673. 0x24362e3a,
  35674. 0x2a3f2331,
  35675. 0x70486858,
  35676. 0x7e416553,
  35677. 0x6c5a724e,
  35678. 0x62537f45,
  35679. 0x486c5c74,
  35680. 0x4665517f,
  35681. 0x547e4662,
  35682. 0x5a774b69,
  35683. 0xe090d0b0,
  35684. 0xee99ddbb,
  35685. 0xfc82caa6,
  35686. 0xf28bc7ad,
  35687. 0xd8b4e49c,
  35688. 0xd6bde997,
  35689. 0xc4a6fe8a,
  35690. 0xcaaff381,
  35691. 0x90d8b8e8,
  35692. 0x9ed1b5e3,
  35693. 0x8ccaa2fe,
  35694. 0x82c3aff5,
  35695. 0xa8fc8cc4,
  35696. 0xa6f581cf,
  35697. 0xb4ee96d2,
  35698. 0xbae79bd9,
  35699. 0xdb3bbb7b,
  35700. 0xd532b670,
  35701. 0xc729a16d,
  35702. 0xc920ac66,
  35703. 0xe31f8f57,
  35704. 0xed16825c,
  35705. 0xff0d9541,
  35706. 0xf104984a,
  35707. 0xab73d323,
  35708. 0xa57ade28,
  35709. 0xb761c935,
  35710. 0xb968c43e,
  35711. 0x9357e70f,
  35712. 0x9d5eea04,
  35713. 0x8f45fd19,
  35714. 0x814cf012,
  35715. 0x3bab6bcb,
  35716. 0x35a266c0,
  35717. 0x27b971dd,
  35718. 0x29b07cd6,
  35719. 0x038f5fe7,
  35720. 0x0d8652ec,
  35721. 0x1f9d45f1,
  35722. 0x119448fa,
  35723. 0x4be30393,
  35724. 0x45ea0e98,
  35725. 0x57f11985,
  35726. 0x59f8148e,
  35727. 0x73c737bf,
  35728. 0x7dce3ab4,
  35729. 0x6fd52da9,
  35730. 0x61dc20a2,
  35731. 0xad766df6,
  35732. 0xa37f60fd,
  35733. 0xb16477e0,
  35734. 0xbf6d7aeb,
  35735. 0x955259da,
  35736. 0x9b5b54d1,
  35737. 0x894043cc,
  35738. 0x87494ec7,
  35739. 0xdd3e05ae,
  35740. 0xd33708a5,
  35741. 0xc12c1fb8,
  35742. 0xcf2512b3,
  35743. 0xe51a3182,
  35744. 0xeb133c89,
  35745. 0xf9082b94,
  35746. 0xf701269f,
  35747. 0x4de6bd46,
  35748. 0x43efb04d,
  35749. 0x51f4a750,
  35750. 0x5ffdaa5b,
  35751. 0x75c2896a,
  35752. 0x7bcb8461,
  35753. 0x69d0937c,
  35754. 0x67d99e77,
  35755. 0x3daed51e,
  35756. 0x33a7d815,
  35757. 0x21bccf08,
  35758. 0x2fb5c203,
  35759. 0x058ae132,
  35760. 0x0b83ec39,
  35761. 0x1998fb24,
  35762. 0x1791f62f,
  35763. 0x764dd68d,
  35764. 0x7844db86,
  35765. 0x6a5fcc9b,
  35766. 0x6456c190,
  35767. 0x4e69e2a1,
  35768. 0x4060efaa,
  35769. 0x527bf8b7,
  35770. 0x5c72f5bc,
  35771. 0x0605bed5,
  35772. 0x080cb3de,
  35773. 0x1a17a4c3,
  35774. 0x141ea9c8,
  35775. 0x3e218af9,
  35776. 0x302887f2,
  35777. 0x223390ef,
  35778. 0x2c3a9de4,
  35779. 0x96dd063d,
  35780. 0x98d40b36,
  35781. 0x8acf1c2b,
  35782. 0x84c61120,
  35783. 0xaef93211,
  35784. 0xa0f03f1a,
  35785. 0xb2eb2807,
  35786. 0xbce2250c,
  35787. 0xe6956e65,
  35788. 0xe89c636e,
  35789. 0xfa877473,
  35790. 0xf48e7978,
  35791. 0xdeb15a49,
  35792. 0xd0b85742,
  35793. 0xc2a3405f,
  35794. 0xccaa4d54,
  35795. 0x41ecdaf7,
  35796. 0x4fe5d7fc,
  35797. 0x5dfec0e1,
  35798. 0x53f7cdea,
  35799. 0x79c8eedb,
  35800. 0x77c1e3d0,
  35801. 0x65daf4cd,
  35802. 0x6bd3f9c6,
  35803. 0x31a4b2af,
  35804. 0x3fadbfa4,
  35805. 0x2db6a8b9,
  35806. 0x23bfa5b2,
  35807. 0x09808683,
  35808. 0x07898b88,
  35809. 0x15929c95,
  35810. 0x1b9b919e,
  35811. 0xa17c0a47,
  35812. 0xaf75074c,
  35813. 0xbd6e1051,
  35814. 0xb3671d5a,
  35815. 0x99583e6b,
  35816. 0x97513360,
  35817. 0x854a247d,
  35818. 0x8b432976,
  35819. 0xd134621f,
  35820. 0xdf3d6f14,
  35821. 0xcd267809,
  35822. 0xc32f7502,
  35823. 0xe9105633,
  35824. 0xe7195b38,
  35825. 0xf5024c25,
  35826. 0xfb0b412e,
  35827. 0x9ad7618c,
  35828. 0x94de6c87,
  35829. 0x86c57b9a,
  35830. 0x88cc7691,
  35831. 0xa2f355a0,
  35832. 0xacfa58ab,
  35833. 0xbee14fb6,
  35834. 0xb0e842bd,
  35835. 0xea9f09d4,
  35836. 0xe49604df,
  35837. 0xf68d13c2,
  35838. 0xf8841ec9,
  35839. 0xd2bb3df8,
  35840. 0xdcb230f3,
  35841. 0xcea927ee,
  35842. 0xc0a02ae5,
  35843. 0x7a47b13c,
  35844. 0x744ebc37,
  35845. 0x6655ab2a,
  35846. 0x685ca621,
  35847. 0x42638510,
  35848. 0x4c6a881b,
  35849. 0x5e719f06,
  35850. 0x5078920d,
  35851. 0x0a0fd964,
  35852. 0x0406d46f,
  35853. 0x161dc372,
  35854. 0x1814ce79,
  35855. 0x322bed48,
  35856. 0x3c22e043,
  35857. 0x2e39f75e,
  35858. 0x2030fa55,
  35859. 0xec9ab701,
  35860. 0xe293ba0a,
  35861. 0xf088ad17,
  35862. 0xfe81a01c,
  35863. 0xd4be832d,
  35864. 0xdab78e26,
  35865. 0xc8ac993b,
  35866. 0xc6a59430,
  35867. 0x9cd2df59,
  35868. 0x92dbd252,
  35869. 0x80c0c54f,
  35870. 0x8ec9c844,
  35871. 0xa4f6eb75,
  35872. 0xaaffe67e,
  35873. 0xb8e4f163,
  35874. 0xb6edfc68,
  35875. 0x0c0a67b1,
  35876. 0x02036aba,
  35877. 0x10187da7,
  35878. 0x1e1170ac,
  35879. 0x342e539d,
  35880. 0x3a275e96,
  35881. 0x283c498b,
  35882. 0x26354480,
  35883. 0x7c420fe9,
  35884. 0x724b02e2,
  35885. 0x605015ff,
  35886. 0x6e5918f4,
  35887. 0x44663bc5,
  35888. 0x4a6f36ce,
  35889. 0x587421d3,
  35890. 0x567d2cd8,
  35891. 0x37a10c7a,
  35892. 0x39a80171,
  35893. 0x2bb3166c,
  35894. 0x25ba1b67,
  35895. 0x0f853856,
  35896. 0x018c355d,
  35897. 0x13972240,
  35898. 0x1d9e2f4b,
  35899. 0x47e96422,
  35900. 0x49e06929,
  35901. 0x5bfb7e34,
  35902. 0x55f2733f,
  35903. 0x7fcd500e,
  35904. 0x71c45d05,
  35905. 0x63df4a18,
  35906. 0x6dd64713,
  35907. 0xd731dcca,
  35908. 0xd938d1c1,
  35909. 0xcb23c6dc,
  35910. 0xc52acbd7,
  35911. 0xef15e8e6,
  35912. 0xe11ce5ed,
  35913. 0xf307f2f0,
  35914. 0xfd0efffb,
  35915. 0xa779b492,
  35916. 0xa970b999,
  35917. 0xbb6bae84,
  35918. 0xb562a38f,
  35919. 0x9f5d80be,
  35920. 0x91548db5,
  35921. 0x834f9aa8,
  35922. 0x8d4697a3
  35923. ]);
  35924. function expandKey256(cipherKey) {
  35925. var b = 240, result = new Uint8Array(b);
  35926. var r = 1;
  35927. result.set(cipherKey);
  35928. for (var j = 32, i = 1; j < b; ++i) {
  35929. if (j % 32 === 16) {
  35930. t1 = s[t1];
  35931. t2 = s[t2];
  35932. t3 = s[t3];
  35933. t4 = s[t4];
  35934. } else if (j % 32 === 0) {
  35935. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35936. t1 = s[t1];
  35937. t2 = s[t2];
  35938. t3 = s[t3];
  35939. t4 = s[t4];
  35940. t1 = t1 ^ r;
  35941. if ((r <<= 1) >= 256) {
  35942. r = (r ^ 0x1b) & 0xFF;
  35943. }
  35944. }
  35945. for (var n = 0; n < 4; ++n) {
  35946. result[j] = t1 ^= result[j - 32];
  35947. j++;
  35948. result[j] = t2 ^= result[j - 32];
  35949. j++;
  35950. result[j] = t3 ^= result[j - 32];
  35951. j++;
  35952. result[j] = t4 ^= result[j - 32];
  35953. j++;
  35954. }
  35955. }
  35956. return result;
  35957. }
  35958. function decrypt256(input, key) {
  35959. var state = new Uint8Array(16);
  35960. state.set(input);
  35961. var i, j, k;
  35962. var t, u, v;
  35963. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35964. state[j] ^= key[k];
  35965. }
  35966. for (i = 13; i >= 1; --i) {
  35967. t = state[13];
  35968. state[13] = state[9];
  35969. state[9] = state[5];
  35970. state[5] = state[1];
  35971. state[1] = t;
  35972. t = state[14];
  35973. u = state[10];
  35974. state[14] = state[6];
  35975. state[10] = state[2];
  35976. state[6] = t;
  35977. state[2] = u;
  35978. t = state[15];
  35979. u = state[11];
  35980. v = state[7];
  35981. state[15] = state[3];
  35982. state[11] = t;
  35983. state[7] = u;
  35984. state[3] = v;
  35985. for (j = 0; j < 16; ++j) {
  35986. state[j] = inv_s[state[j]];
  35987. }
  35988. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35989. state[j] ^= key[k];
  35990. }
  35991. for (j = 0; j < 16; j += 4) {
  35992. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35993. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35994. state[j] = t >>> 24 & 0xFF;
  35995. state[j + 1] = t >> 16 & 0xFF;
  35996. state[j + 2] = t >> 8 & 0xFF;
  35997. state[j + 3] = t & 0xFF;
  35998. }
  35999. }
  36000. t = state[13];
  36001. state[13] = state[9];
  36002. state[9] = state[5];
  36003. state[5] = state[1];
  36004. state[1] = t;
  36005. t = state[14];
  36006. u = state[10];
  36007. state[14] = state[6];
  36008. state[10] = state[2];
  36009. state[6] = t;
  36010. state[2] = u;
  36011. t = state[15];
  36012. u = state[11];
  36013. v = state[7];
  36014. state[15] = state[3];
  36015. state[11] = t;
  36016. state[7] = u;
  36017. state[3] = v;
  36018. for (j = 0; j < 16; ++j) {
  36019. state[j] = inv_s[state[j]];
  36020. state[j] ^= key[j];
  36021. }
  36022. return state;
  36023. }
  36024. function encrypt256(input, key) {
  36025. var t, u, v, k;
  36026. var state = new Uint8Array(16);
  36027. state.set(input);
  36028. for (j = 0; j < 16; ++j) {
  36029. state[j] ^= key[j];
  36030. }
  36031. for (i = 1; i < 14; i++) {
  36032. for (j = 0; j < 16; ++j) {
  36033. state[j] = s[state[j]];
  36034. }
  36035. v = state[1];
  36036. state[1] = state[5];
  36037. state[5] = state[9];
  36038. state[9] = state[13];
  36039. state[13] = v;
  36040. v = state[2];
  36041. u = state[6];
  36042. state[2] = state[10];
  36043. state[6] = state[14];
  36044. state[10] = v;
  36045. state[14] = u;
  36046. v = state[3];
  36047. u = state[7];
  36048. t = state[11];
  36049. state[3] = state[15];
  36050. state[7] = v;
  36051. state[11] = u;
  36052. state[15] = t;
  36053. for (var j = 0; j < 16; j += 4) {
  36054. var s0 = state[j + 0], s1 = state[j + 1];
  36055. var s2 = state[j + 2], s3 = state[j + 3];
  36056. t = s0 ^ s1 ^ s2 ^ s3;
  36057. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  36058. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  36059. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  36060. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  36061. }
  36062. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  36063. state[j] ^= key[k];
  36064. }
  36065. }
  36066. for (j = 0; j < 16; ++j) {
  36067. state[j] = s[state[j]];
  36068. }
  36069. v = state[1];
  36070. state[1] = state[5];
  36071. state[5] = state[9];
  36072. state[9] = state[13];
  36073. state[13] = v;
  36074. v = state[2];
  36075. u = state[6];
  36076. state[2] = state[10];
  36077. state[6] = state[14];
  36078. state[10] = v;
  36079. state[14] = u;
  36080. v = state[3];
  36081. u = state[7];
  36082. t = state[11];
  36083. state[3] = state[15];
  36084. state[7] = v;
  36085. state[11] = u;
  36086. state[15] = t;
  36087. for (j = 0, k = 224; j < 16; ++j, ++k) {
  36088. state[j] ^= key[k];
  36089. }
  36090. return state;
  36091. }
  36092. function AES256Cipher(key) {
  36093. this.key = expandKey256(key);
  36094. this.buffer = new Uint8Array(16);
  36095. this.bufferPosition = 0;
  36096. }
  36097. function decryptBlock2(data, finalize) {
  36098. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  36099. for (i = 0; i < sourceLength; ++i) {
  36100. buffer[bufferLength] = data[i];
  36101. ++bufferLength;
  36102. if (bufferLength < 16) {
  36103. continue;
  36104. }
  36105. var plain = decrypt256(buffer, this.key);
  36106. for (j = 0; j < 16; ++j) {
  36107. plain[j] ^= iv[j];
  36108. }
  36109. iv = buffer;
  36110. result.push(plain);
  36111. buffer = new Uint8Array(16);
  36112. bufferLength = 0;
  36113. }
  36114. this.buffer = buffer;
  36115. this.bufferLength = bufferLength;
  36116. this.iv = iv;
  36117. if (result.length === 0) {
  36118. return new Uint8Array([]);
  36119. }
  36120. var outputLength = 16 * result.length;
  36121. if (finalize) {
  36122. var lastBlock = result[result.length - 1];
  36123. var psLen = lastBlock[15];
  36124. if (psLen <= 16) {
  36125. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  36126. if (lastBlock[i] !== psLen) {
  36127. psLen = 0;
  36128. break;
  36129. }
  36130. }
  36131. outputLength -= psLen;
  36132. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  36133. }
  36134. }
  36135. var output = new Uint8Array(outputLength);
  36136. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36137. output.set(result[i], j);
  36138. }
  36139. return output;
  36140. }
  36141. AES256Cipher.prototype = {
  36142. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  36143. var i, sourceLength = data.length;
  36144. var buffer = this.buffer, bufferLength = this.bufferPosition;
  36145. if (iv) {
  36146. this.iv = iv;
  36147. } else {
  36148. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  36149. buffer[bufferLength] = data[i];
  36150. }
  36151. if (bufferLength < 16) {
  36152. this.bufferLength = bufferLength;
  36153. return new Uint8Array([]);
  36154. }
  36155. this.iv = buffer;
  36156. data = data.subarray(16);
  36157. }
  36158. this.buffer = new Uint8Array(16);
  36159. this.bufferLength = 0;
  36160. this.decryptBlock = decryptBlock2;
  36161. return this.decryptBlock(data, finalize);
  36162. },
  36163. encrypt: function AES256Cipher_encrypt(data, iv) {
  36164. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  36165. if (!iv) {
  36166. iv = new Uint8Array(16);
  36167. }
  36168. for (i = 0; i < sourceLength; ++i) {
  36169. buffer[bufferLength] = data[i];
  36170. ++bufferLength;
  36171. if (bufferLength < 16) {
  36172. continue;
  36173. }
  36174. for (j = 0; j < 16; ++j) {
  36175. buffer[j] ^= iv[j];
  36176. }
  36177. var cipher = encrypt256(buffer, this.key);
  36178. this.iv = cipher;
  36179. result.push(cipher);
  36180. buffer = new Uint8Array(16);
  36181. bufferLength = 0;
  36182. }
  36183. this.buffer = buffer;
  36184. this.bufferLength = bufferLength;
  36185. this.iv = iv;
  36186. if (result.length === 0) {
  36187. return new Uint8Array([]);
  36188. }
  36189. var outputLength = 16 * result.length;
  36190. var output = new Uint8Array(outputLength);
  36191. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36192. output.set(result[i], j);
  36193. }
  36194. return output;
  36195. }
  36196. };
  36197. return AES256Cipher;
  36198. }();
  36199. var PDF17 = function PDF17Closure() {
  36200. function compareByteArrays(array1, array2) {
  36201. if (array1.length !== array2.length) {
  36202. return false;
  36203. }
  36204. for (var i = 0; i < array1.length; i++) {
  36205. if (array1[i] !== array2[i]) {
  36206. return false;
  36207. }
  36208. }
  36209. return true;
  36210. }
  36211. function PDF17() {
  36212. }
  36213. PDF17.prototype = {
  36214. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36215. var hashData = new Uint8Array(password.length + 56);
  36216. hashData.set(password, 0);
  36217. hashData.set(ownerValidationSalt, password.length);
  36218. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36219. var result = calculateSHA256(hashData, 0, hashData.length);
  36220. return compareByteArrays(result, ownerPassword);
  36221. },
  36222. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36223. var hashData = new Uint8Array(password.length + 8);
  36224. hashData.set(password, 0);
  36225. hashData.set(userValidationSalt, password.length);
  36226. var result = calculateSHA256(hashData, 0, hashData.length);
  36227. return compareByteArrays(result, userPassword);
  36228. },
  36229. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36230. var hashData = new Uint8Array(password.length + 56);
  36231. hashData.set(password, 0);
  36232. hashData.set(ownerKeySalt, password.length);
  36233. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36234. var key = calculateSHA256(hashData, 0, hashData.length);
  36235. var cipher = new AES256Cipher(key);
  36236. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36237. },
  36238. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36239. var hashData = new Uint8Array(password.length + 8);
  36240. hashData.set(password, 0);
  36241. hashData.set(userKeySalt, password.length);
  36242. var key = calculateSHA256(hashData, 0, hashData.length);
  36243. var cipher = new AES256Cipher(key);
  36244. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36245. }
  36246. };
  36247. return PDF17;
  36248. }();
  36249. var PDF20 = function PDF20Closure() {
  36250. function concatArrays(array1, array2) {
  36251. var t = new Uint8Array(array1.length + array2.length);
  36252. t.set(array1, 0);
  36253. t.set(array2, array1.length);
  36254. return t;
  36255. }
  36256. function calculatePDF20Hash(password, input, userBytes) {
  36257. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36258. var e = [0];
  36259. var i = 0;
  36260. while (i < 64 || e[e.length - 1] > i - 32) {
  36261. var arrayLength = password.length + k.length + userBytes.length;
  36262. var k1 = new Uint8Array(arrayLength * 64);
  36263. var array = concatArrays(password, k);
  36264. array = concatArrays(array, userBytes);
  36265. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36266. k1.set(array, pos);
  36267. }
  36268. var cipher = new AES128Cipher(k.subarray(0, 16));
  36269. e = cipher.encrypt(k1, k.subarray(16, 32));
  36270. var remainder = 0;
  36271. for (var z = 0; z < 16; z++) {
  36272. remainder *= 256 % 3;
  36273. remainder %= 3;
  36274. remainder += (e[z] >>> 0) % 3;
  36275. remainder %= 3;
  36276. }
  36277. if (remainder === 0) {
  36278. k = calculateSHA256(e, 0, e.length);
  36279. } else if (remainder === 1) {
  36280. k = calculateSHA384(e, 0, e.length);
  36281. } else if (remainder === 2) {
  36282. k = calculateSHA512(e, 0, e.length);
  36283. }
  36284. i++;
  36285. }
  36286. return k.subarray(0, 32);
  36287. }
  36288. function PDF20() {
  36289. }
  36290. function compareByteArrays(array1, array2) {
  36291. if (array1.length !== array2.length) {
  36292. return false;
  36293. }
  36294. for (var i = 0; i < array1.length; i++) {
  36295. if (array1[i] !== array2[i]) {
  36296. return false;
  36297. }
  36298. }
  36299. return true;
  36300. }
  36301. PDF20.prototype = {
  36302. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36303. return calculatePDF20Hash(password, concatBytes, userBytes);
  36304. },
  36305. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36306. var hashData = new Uint8Array(password.length + 56);
  36307. hashData.set(password, 0);
  36308. hashData.set(ownerValidationSalt, password.length);
  36309. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36310. var result = calculatePDF20Hash(password, hashData, userBytes);
  36311. return compareByteArrays(result, ownerPassword);
  36312. },
  36313. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36314. var hashData = new Uint8Array(password.length + 8);
  36315. hashData.set(password, 0);
  36316. hashData.set(userValidationSalt, password.length);
  36317. var result = calculatePDF20Hash(password, hashData, []);
  36318. return compareByteArrays(result, userPassword);
  36319. },
  36320. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36321. var hashData = new Uint8Array(password.length + 56);
  36322. hashData.set(password, 0);
  36323. hashData.set(ownerKeySalt, password.length);
  36324. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36325. var key = calculatePDF20Hash(password, hashData, userBytes);
  36326. var cipher = new AES256Cipher(key);
  36327. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36328. },
  36329. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36330. var hashData = new Uint8Array(password.length + 8);
  36331. hashData.set(password, 0);
  36332. hashData.set(userKeySalt, password.length);
  36333. var key = calculatePDF20Hash(password, hashData, []);
  36334. var cipher = new AES256Cipher(key);
  36335. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36336. }
  36337. };
  36338. return PDF20;
  36339. }();
  36340. var CipherTransform = function CipherTransformClosure() {
  36341. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36342. this.StringCipherConstructor = stringCipherConstructor;
  36343. this.StreamCipherConstructor = streamCipherConstructor;
  36344. }
  36345. CipherTransform.prototype = {
  36346. createStream: function CipherTransform_createStream(stream, length) {
  36347. var cipher = new this.StreamCipherConstructor();
  36348. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36349. return cipher.decryptBlock(data, finalize);
  36350. });
  36351. },
  36352. decryptString: function CipherTransform_decryptString(s) {
  36353. var cipher = new this.StringCipherConstructor();
  36354. var data = stringToBytes(s);
  36355. data = cipher.decryptBlock(data, true);
  36356. return bytesToString(data);
  36357. }
  36358. };
  36359. return CipherTransform;
  36360. }();
  36361. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36362. var defaultPasswordBytes = new Uint8Array([
  36363. 0x28,
  36364. 0xBF,
  36365. 0x4E,
  36366. 0x5E,
  36367. 0x4E,
  36368. 0x75,
  36369. 0x8A,
  36370. 0x41,
  36371. 0x64,
  36372. 0x00,
  36373. 0x4E,
  36374. 0x56,
  36375. 0xFF,
  36376. 0xFA,
  36377. 0x01,
  36378. 0x08,
  36379. 0x2E,
  36380. 0x2E,
  36381. 0x00,
  36382. 0xB6,
  36383. 0xD0,
  36384. 0x68,
  36385. 0x3E,
  36386. 0x80,
  36387. 0x2F,
  36388. 0x0C,
  36389. 0xA9,
  36390. 0xFE,
  36391. 0x64,
  36392. 0x53,
  36393. 0x69,
  36394. 0x7A
  36395. ]);
  36396. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36397. if (password) {
  36398. var passwordLength = Math.min(127, password.length);
  36399. password = password.subarray(0, passwordLength);
  36400. } else {
  36401. password = [];
  36402. }
  36403. var pdfAlgorithm;
  36404. if (revision === 6) {
  36405. pdfAlgorithm = new PDF20();
  36406. } else {
  36407. pdfAlgorithm = new PDF17();
  36408. }
  36409. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36410. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36411. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36412. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36413. }
  36414. return null;
  36415. }
  36416. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36417. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36418. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36419. if (password) {
  36420. n = Math.min(32, password.length);
  36421. for (; i < n; ++i) {
  36422. hashData[i] = password[i];
  36423. }
  36424. }
  36425. j = 0;
  36426. while (i < 32) {
  36427. hashData[i++] = defaultPasswordBytes[j++];
  36428. }
  36429. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36430. hashData[i++] = ownerPassword[j];
  36431. }
  36432. hashData[i++] = flags & 0xFF;
  36433. hashData[i++] = flags >> 8 & 0xFF;
  36434. hashData[i++] = flags >> 16 & 0xFF;
  36435. hashData[i++] = flags >>> 24 & 0xFF;
  36436. for (j = 0, n = fileId.length; j < n; ++j) {
  36437. hashData[i++] = fileId[j];
  36438. }
  36439. if (revision >= 4 && !encryptMetadata) {
  36440. hashData[i++] = 0xFF;
  36441. hashData[i++] = 0xFF;
  36442. hashData[i++] = 0xFF;
  36443. hashData[i++] = 0xFF;
  36444. }
  36445. var hash = calculateMD5(hashData, 0, i);
  36446. var keyLengthInBytes = keyLength >> 3;
  36447. if (revision >= 3) {
  36448. for (j = 0; j < 50; ++j) {
  36449. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36450. }
  36451. }
  36452. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36453. var cipher, checkData;
  36454. if (revision >= 3) {
  36455. for (i = 0; i < 32; ++i) {
  36456. hashData[i] = defaultPasswordBytes[i];
  36457. }
  36458. for (j = 0, n = fileId.length; j < n; ++j) {
  36459. hashData[i++] = fileId[j];
  36460. }
  36461. cipher = new ARCFourCipher(encryptionKey);
  36462. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36463. n = encryptionKey.length;
  36464. var derivedKey = new Uint8Array(n), k;
  36465. for (j = 1; j <= 19; ++j) {
  36466. for (k = 0; k < n; ++k) {
  36467. derivedKey[k] = encryptionKey[k] ^ j;
  36468. }
  36469. cipher = new ARCFourCipher(derivedKey);
  36470. checkData = cipher.encryptBlock(checkData);
  36471. }
  36472. for (j = 0, n = checkData.length; j < n; ++j) {
  36473. if (userPassword[j] !== checkData[j]) {
  36474. return null;
  36475. }
  36476. }
  36477. } else {
  36478. cipher = new ARCFourCipher(encryptionKey);
  36479. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36480. for (j = 0, n = checkData.length; j < n; ++j) {
  36481. if (userPassword[j] !== checkData[j]) {
  36482. return null;
  36483. }
  36484. }
  36485. }
  36486. return encryptionKey;
  36487. }
  36488. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36489. var hashData = new Uint8Array(32), i = 0, j, n;
  36490. n = Math.min(32, password.length);
  36491. for (; i < n; ++i) {
  36492. hashData[i] = password[i];
  36493. }
  36494. j = 0;
  36495. while (i < 32) {
  36496. hashData[i++] = defaultPasswordBytes[j++];
  36497. }
  36498. var hash = calculateMD5(hashData, 0, i);
  36499. var keyLengthInBytes = keyLength >> 3;
  36500. if (revision >= 3) {
  36501. for (j = 0; j < 50; ++j) {
  36502. hash = calculateMD5(hash, 0, hash.length);
  36503. }
  36504. }
  36505. var cipher, userPassword;
  36506. if (revision >= 3) {
  36507. userPassword = ownerPassword;
  36508. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36509. for (j = 19; j >= 0; j--) {
  36510. for (k = 0; k < keyLengthInBytes; ++k) {
  36511. derivedKey[k] = hash[k] ^ j;
  36512. }
  36513. cipher = new ARCFourCipher(derivedKey);
  36514. userPassword = cipher.encryptBlock(userPassword);
  36515. }
  36516. } else {
  36517. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36518. userPassword = cipher.encryptBlock(ownerPassword);
  36519. }
  36520. return userPassword;
  36521. }
  36522. var identityName = Name.get('Identity');
  36523. function CipherTransformFactory(dict, fileId, password) {
  36524. var filter = dict.get('Filter');
  36525. if (!isName(filter, 'Standard')) {
  36526. error('unknown encryption method');
  36527. }
  36528. this.dict = dict;
  36529. var algorithm = dict.get('V');
  36530. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36531. error('unsupported encryption algorithm');
  36532. }
  36533. this.algorithm = algorithm;
  36534. var keyLength = dict.get('Length');
  36535. if (!keyLength) {
  36536. if (algorithm <= 3) {
  36537. keyLength = 40;
  36538. } else {
  36539. var cfDict = dict.get('CF');
  36540. var streamCryptoName = dict.get('StmF');
  36541. if (isDict(cfDict) && isName(streamCryptoName)) {
  36542. cfDict.suppressEncryption = true;
  36543. var handlerDict = cfDict.get(streamCryptoName.name);
  36544. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36545. if (keyLength < 40) {
  36546. keyLength <<= 3;
  36547. }
  36548. }
  36549. }
  36550. }
  36551. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36552. error('invalid key length');
  36553. }
  36554. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36555. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36556. var flags = dict.get('P');
  36557. var revision = dict.get('R');
  36558. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36559. this.encryptMetadata = encryptMetadata;
  36560. var fileIdBytes = stringToBytes(fileId);
  36561. var passwordBytes;
  36562. if (password) {
  36563. if (revision === 6) {
  36564. try {
  36565. password = utf8StringToString(password);
  36566. } catch (ex) {
  36567. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36568. }
  36569. }
  36570. passwordBytes = stringToBytes(password);
  36571. }
  36572. var encryptionKey;
  36573. if (algorithm !== 5) {
  36574. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36575. } else {
  36576. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36577. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36578. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36579. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36580. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36581. var ownerEncryption = stringToBytes(dict.get('OE'));
  36582. var userEncryption = stringToBytes(dict.get('UE'));
  36583. var perms = stringToBytes(dict.get('Perms'));
  36584. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36585. }
  36586. if (!encryptionKey && !password) {
  36587. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36588. } else if (!encryptionKey && password) {
  36589. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36590. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36591. }
  36592. if (!encryptionKey) {
  36593. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36594. }
  36595. this.encryptionKey = encryptionKey;
  36596. if (algorithm >= 4) {
  36597. var cf = dict.get('CF');
  36598. if (isDict(cf)) {
  36599. cf.suppressEncryption = true;
  36600. }
  36601. this.cf = cf;
  36602. this.stmf = dict.get('StmF') || identityName;
  36603. this.strf = dict.get('StrF') || identityName;
  36604. this.eff = dict.get('EFF') || this.stmf;
  36605. }
  36606. }
  36607. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36608. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36609. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36610. key[i] = encryptionKey[i];
  36611. }
  36612. key[i++] = num & 0xFF;
  36613. key[i++] = num >> 8 & 0xFF;
  36614. key[i++] = num >> 16 & 0xFF;
  36615. key[i++] = gen & 0xFF;
  36616. key[i++] = gen >> 8 & 0xFF;
  36617. if (isAes) {
  36618. key[i++] = 0x73;
  36619. key[i++] = 0x41;
  36620. key[i++] = 0x6C;
  36621. key[i++] = 0x54;
  36622. }
  36623. var hash = calculateMD5(key, 0, i);
  36624. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36625. }
  36626. function buildCipherConstructor(cf, name, num, gen, key) {
  36627. assert(isName(name), 'Invalid crypt filter name.');
  36628. var cryptFilter = cf.get(name.name);
  36629. var cfm;
  36630. if (cryptFilter !== null && cryptFilter !== undefined) {
  36631. cfm = cryptFilter.get('CFM');
  36632. }
  36633. if (!cfm || cfm.name === 'None') {
  36634. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36635. return new NullCipher();
  36636. };
  36637. }
  36638. if (cfm.name === 'V2') {
  36639. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36640. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36641. };
  36642. }
  36643. if (cfm.name === 'AESV2') {
  36644. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36645. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36646. };
  36647. }
  36648. if (cfm.name === 'AESV3') {
  36649. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36650. return new AES256Cipher(key);
  36651. };
  36652. }
  36653. error('Unknown crypto method');
  36654. }
  36655. CipherTransformFactory.prototype = {
  36656. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36657. if (this.algorithm === 4 || this.algorithm === 5) {
  36658. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36659. }
  36660. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36661. var cipherConstructor = function buildCipherCipherConstructor() {
  36662. return new ARCFourCipher(key);
  36663. };
  36664. return new CipherTransform(cipherConstructor, cipherConstructor);
  36665. }
  36666. };
  36667. return CipherTransformFactory;
  36668. }();
  36669. exports.AES128Cipher = AES128Cipher;
  36670. exports.AES256Cipher = AES256Cipher;
  36671. exports.ARCFourCipher = ARCFourCipher;
  36672. exports.CipherTransformFactory = CipherTransformFactory;
  36673. exports.PDF17 = PDF17;
  36674. exports.PDF20 = PDF20;
  36675. exports.calculateMD5 = calculateMD5;
  36676. exports.calculateSHA256 = calculateSHA256;
  36677. exports.calculateSHA384 = calculateSHA384;
  36678. exports.calculateSHA512 = calculateSHA512;
  36679. }));
  36680. (function (root, factory) {
  36681. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36682. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36683. var Util = sharedUtil.Util;
  36684. var bytesToString = sharedUtil.bytesToString;
  36685. var error = sharedUtil.error;
  36686. var Stream = coreStream.Stream;
  36687. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36688. var StandardEncoding = coreEncodings.StandardEncoding;
  36689. var CFFParser = coreCFFParser.CFFParser;
  36690. var FontRendererFactory = function FontRendererFactoryClosure() {
  36691. function getLong(data, offset) {
  36692. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36693. }
  36694. function getUshort(data, offset) {
  36695. return data[offset] << 8 | data[offset + 1];
  36696. }
  36697. function parseCmap(data, start, end) {
  36698. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36699. var format = getUshort(data, start + offset);
  36700. var length, ranges, p, i;
  36701. if (format === 4) {
  36702. length = getUshort(data, start + offset + 2);
  36703. var segCount = getUshort(data, start + offset + 6) >> 1;
  36704. p = start + offset + 14;
  36705. ranges = [];
  36706. for (i = 0; i < segCount; i++, p += 2) {
  36707. ranges[i] = { end: getUshort(data, p) };
  36708. }
  36709. p += 2;
  36710. for (i = 0; i < segCount; i++, p += 2) {
  36711. ranges[i].start = getUshort(data, p);
  36712. }
  36713. for (i = 0; i < segCount; i++, p += 2) {
  36714. ranges[i].idDelta = getUshort(data, p);
  36715. }
  36716. for (i = 0; i < segCount; i++, p += 2) {
  36717. var idOffset = getUshort(data, p);
  36718. if (idOffset === 0) {
  36719. continue;
  36720. }
  36721. ranges[i].ids = [];
  36722. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36723. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36724. idOffset += 2;
  36725. }
  36726. }
  36727. return ranges;
  36728. } else if (format === 12) {
  36729. length = getLong(data, start + offset + 4);
  36730. var groups = getLong(data, start + offset + 12);
  36731. p = start + offset + 16;
  36732. ranges = [];
  36733. for (i = 0; i < groups; i++) {
  36734. ranges.push({
  36735. start: getLong(data, p),
  36736. end: getLong(data, p + 4),
  36737. idDelta: getLong(data, p + 8) - getLong(data, p)
  36738. });
  36739. p += 12;
  36740. }
  36741. return ranges;
  36742. }
  36743. error('not supported cmap: ' + format);
  36744. }
  36745. function parseCff(data, start, end, seacAnalysisEnabled) {
  36746. var properties = {};
  36747. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36748. var cff = parser.parse();
  36749. return {
  36750. glyphs: cff.charStrings.objects,
  36751. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36752. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36753. };
  36754. }
  36755. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36756. var itemSize, itemDecode;
  36757. if (isGlyphLocationsLong) {
  36758. itemSize = 4;
  36759. itemDecode = function fontItemDecodeLong(data, offset) {
  36760. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36761. };
  36762. } else {
  36763. itemSize = 2;
  36764. itemDecode = function fontItemDecode(data, offset) {
  36765. return data[offset] << 9 | data[offset + 1] << 1;
  36766. };
  36767. }
  36768. var glyphs = [];
  36769. var startOffset = itemDecode(loca, 0);
  36770. for (var j = itemSize; j < loca.length; j += itemSize) {
  36771. var endOffset = itemDecode(loca, j);
  36772. glyphs.push(glyf.subarray(startOffset, endOffset));
  36773. startOffset = endOffset;
  36774. }
  36775. return glyphs;
  36776. }
  36777. function lookupCmap(ranges, unicode) {
  36778. var code = unicode.charCodeAt(0), gid = 0;
  36779. var l = 0, r = ranges.length - 1;
  36780. while (l < r) {
  36781. var c = l + r + 1 >> 1;
  36782. if (code < ranges[c].start) {
  36783. r = c - 1;
  36784. } else {
  36785. l = c;
  36786. }
  36787. }
  36788. if (ranges[l].start <= code && code <= ranges[l].end) {
  36789. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36790. }
  36791. return {
  36792. charCode: code,
  36793. glyphId: gid
  36794. };
  36795. }
  36796. function compileGlyf(code, cmds, font) {
  36797. function moveTo(x, y) {
  36798. cmds.push({
  36799. cmd: 'moveTo',
  36800. args: [
  36801. x,
  36802. y
  36803. ]
  36804. });
  36805. }
  36806. function lineTo(x, y) {
  36807. cmds.push({
  36808. cmd: 'lineTo',
  36809. args: [
  36810. x,
  36811. y
  36812. ]
  36813. });
  36814. }
  36815. function quadraticCurveTo(xa, ya, x, y) {
  36816. cmds.push({
  36817. cmd: 'quadraticCurveTo',
  36818. args: [
  36819. xa,
  36820. ya,
  36821. x,
  36822. y
  36823. ]
  36824. });
  36825. }
  36826. var i = 0;
  36827. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36828. var flags;
  36829. var x = 0, y = 0;
  36830. i += 10;
  36831. if (numberOfContours < 0) {
  36832. do {
  36833. flags = code[i] << 8 | code[i + 1];
  36834. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36835. i += 4;
  36836. var arg1, arg2;
  36837. if (flags & 0x01) {
  36838. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36839. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36840. i += 4;
  36841. } else {
  36842. arg1 = code[i++];
  36843. arg2 = code[i++];
  36844. }
  36845. if (flags & 0x02) {
  36846. x = arg1;
  36847. y = arg2;
  36848. } else {
  36849. x = 0;
  36850. y = 0;
  36851. }
  36852. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36853. if (flags & 0x08) {
  36854. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36855. i += 2;
  36856. } else if (flags & 0x40) {
  36857. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36858. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36859. i += 4;
  36860. } else if (flags & 0x80) {
  36861. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36862. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36863. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36864. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36865. i += 8;
  36866. }
  36867. var subglyph = font.glyphs[glyphIndex];
  36868. if (subglyph) {
  36869. cmds.push({ cmd: 'save' });
  36870. cmds.push({
  36871. cmd: 'transform',
  36872. args: [
  36873. scaleX,
  36874. scale01,
  36875. scale10,
  36876. scaleY,
  36877. x,
  36878. y
  36879. ]
  36880. });
  36881. compileGlyf(subglyph, cmds, font);
  36882. cmds.push({ cmd: 'restore' });
  36883. }
  36884. } while (flags & 0x20);
  36885. } else {
  36886. var endPtsOfContours = [];
  36887. var j, jj;
  36888. for (j = 0; j < numberOfContours; j++) {
  36889. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36890. i += 2;
  36891. }
  36892. var instructionLength = code[i] << 8 | code[i + 1];
  36893. i += 2 + instructionLength;
  36894. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36895. var points = [];
  36896. while (points.length < numberOfPoints) {
  36897. flags = code[i++];
  36898. var repeat = 1;
  36899. if (flags & 0x08) {
  36900. repeat += code[i++];
  36901. }
  36902. while (repeat-- > 0) {
  36903. points.push({ flags: flags });
  36904. }
  36905. }
  36906. for (j = 0; j < numberOfPoints; j++) {
  36907. switch (points[j].flags & 0x12) {
  36908. case 0x00:
  36909. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36910. i += 2;
  36911. break;
  36912. case 0x02:
  36913. x -= code[i++];
  36914. break;
  36915. case 0x12:
  36916. x += code[i++];
  36917. break;
  36918. }
  36919. points[j].x = x;
  36920. }
  36921. for (j = 0; j < numberOfPoints; j++) {
  36922. switch (points[j].flags & 0x24) {
  36923. case 0x00:
  36924. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36925. i += 2;
  36926. break;
  36927. case 0x04:
  36928. y -= code[i++];
  36929. break;
  36930. case 0x24:
  36931. y += code[i++];
  36932. break;
  36933. }
  36934. points[j].y = y;
  36935. }
  36936. var startPoint = 0;
  36937. for (i = 0; i < numberOfContours; i++) {
  36938. var endPoint = endPtsOfContours[i];
  36939. var contour = points.slice(startPoint, endPoint + 1);
  36940. if (contour[0].flags & 1) {
  36941. contour.push(contour[0]);
  36942. } else if (contour[contour.length - 1].flags & 1) {
  36943. contour.unshift(contour[contour.length - 1]);
  36944. } else {
  36945. var p = {
  36946. flags: 1,
  36947. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36948. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36949. };
  36950. contour.unshift(p);
  36951. contour.push(p);
  36952. }
  36953. moveTo(contour[0].x, contour[0].y);
  36954. for (j = 1, jj = contour.length; j < jj; j++) {
  36955. if (contour[j].flags & 1) {
  36956. lineTo(contour[j].x, contour[j].y);
  36957. } else if (contour[j + 1].flags & 1) {
  36958. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36959. j++;
  36960. } else {
  36961. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36962. }
  36963. }
  36964. startPoint = endPoint + 1;
  36965. }
  36966. }
  36967. }
  36968. function compileCharString(code, cmds, font) {
  36969. var stack = [];
  36970. var x = 0, y = 0;
  36971. var stems = 0;
  36972. function moveTo(x, y) {
  36973. cmds.push({
  36974. cmd: 'moveTo',
  36975. args: [
  36976. x,
  36977. y
  36978. ]
  36979. });
  36980. }
  36981. function lineTo(x, y) {
  36982. cmds.push({
  36983. cmd: 'lineTo',
  36984. args: [
  36985. x,
  36986. y
  36987. ]
  36988. });
  36989. }
  36990. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36991. cmds.push({
  36992. cmd: 'bezierCurveTo',
  36993. args: [
  36994. x1,
  36995. y1,
  36996. x2,
  36997. y2,
  36998. x,
  36999. y
  37000. ]
  37001. });
  37002. }
  37003. function parse(code) {
  37004. var i = 0;
  37005. while (i < code.length) {
  37006. var stackClean = false;
  37007. var v = code[i++];
  37008. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  37009. switch (v) {
  37010. case 1:
  37011. stems += stack.length >> 1;
  37012. stackClean = true;
  37013. break;
  37014. case 3:
  37015. stems += stack.length >> 1;
  37016. stackClean = true;
  37017. break;
  37018. case 4:
  37019. y += stack.pop();
  37020. moveTo(x, y);
  37021. stackClean = true;
  37022. break;
  37023. case 5:
  37024. while (stack.length > 0) {
  37025. x += stack.shift();
  37026. y += stack.shift();
  37027. lineTo(x, y);
  37028. }
  37029. break;
  37030. case 6:
  37031. while (stack.length > 0) {
  37032. x += stack.shift();
  37033. lineTo(x, y);
  37034. if (stack.length === 0) {
  37035. break;
  37036. }
  37037. y += stack.shift();
  37038. lineTo(x, y);
  37039. }
  37040. break;
  37041. case 7:
  37042. while (stack.length > 0) {
  37043. y += stack.shift();
  37044. lineTo(x, y);
  37045. if (stack.length === 0) {
  37046. break;
  37047. }
  37048. x += stack.shift();
  37049. lineTo(x, y);
  37050. }
  37051. break;
  37052. case 8:
  37053. while (stack.length > 0) {
  37054. xa = x + stack.shift();
  37055. ya = y + stack.shift();
  37056. xb = xa + stack.shift();
  37057. yb = ya + stack.shift();
  37058. x = xb + stack.shift();
  37059. y = yb + stack.shift();
  37060. bezierCurveTo(xa, ya, xb, yb, x, y);
  37061. }
  37062. break;
  37063. case 10:
  37064. n = stack.pop() + font.subrsBias;
  37065. subrCode = font.subrs[n];
  37066. if (subrCode) {
  37067. parse(subrCode);
  37068. }
  37069. break;
  37070. case 11:
  37071. return;
  37072. case 12:
  37073. v = code[i++];
  37074. switch (v) {
  37075. case 34:
  37076. xa = x + stack.shift();
  37077. xb = xa + stack.shift();
  37078. y1 = y + stack.shift();
  37079. x = xb + stack.shift();
  37080. bezierCurveTo(xa, y, xb, y1, x, y1);
  37081. xa = x + stack.shift();
  37082. xb = xa + stack.shift();
  37083. x = xb + stack.shift();
  37084. bezierCurveTo(xa, y1, xb, y, x, y);
  37085. break;
  37086. case 35:
  37087. xa = x + stack.shift();
  37088. ya = y + stack.shift();
  37089. xb = xa + stack.shift();
  37090. yb = ya + stack.shift();
  37091. x = xb + stack.shift();
  37092. y = yb + stack.shift();
  37093. bezierCurveTo(xa, ya, xb, yb, x, y);
  37094. xa = x + stack.shift();
  37095. ya = y + stack.shift();
  37096. xb = xa + stack.shift();
  37097. yb = ya + stack.shift();
  37098. x = xb + stack.shift();
  37099. y = yb + stack.shift();
  37100. bezierCurveTo(xa, ya, xb, yb, x, y);
  37101. stack.pop();
  37102. break;
  37103. case 36:
  37104. xa = x + stack.shift();
  37105. y1 = y + stack.shift();
  37106. xb = xa + stack.shift();
  37107. y2 = y1 + stack.shift();
  37108. x = xb + stack.shift();
  37109. bezierCurveTo(xa, y1, xb, y2, x, y2);
  37110. xa = x + stack.shift();
  37111. xb = xa + stack.shift();
  37112. y3 = y2 + stack.shift();
  37113. x = xb + stack.shift();
  37114. bezierCurveTo(xa, y2, xb, y3, x, y);
  37115. break;
  37116. case 37:
  37117. var x0 = x, y0 = y;
  37118. xa = x + stack.shift();
  37119. ya = y + stack.shift();
  37120. xb = xa + stack.shift();
  37121. yb = ya + stack.shift();
  37122. x = xb + stack.shift();
  37123. y = yb + stack.shift();
  37124. bezierCurveTo(xa, ya, xb, yb, x, y);
  37125. xa = x + stack.shift();
  37126. ya = y + stack.shift();
  37127. xb = xa + stack.shift();
  37128. yb = ya + stack.shift();
  37129. x = xb;
  37130. y = yb;
  37131. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  37132. x += stack.shift();
  37133. } else {
  37134. y += stack.shift();
  37135. }
  37136. bezierCurveTo(xa, ya, xb, yb, x, y);
  37137. break;
  37138. default:
  37139. error('unknown operator: 12 ' + v);
  37140. }
  37141. break;
  37142. case 14:
  37143. if (stack.length >= 4) {
  37144. var achar = stack.pop();
  37145. var bchar = stack.pop();
  37146. y = stack.pop();
  37147. x = stack.pop();
  37148. cmds.push({ cmd: 'save' });
  37149. cmds.push({
  37150. cmd: 'translate',
  37151. args: [
  37152. x,
  37153. y
  37154. ]
  37155. });
  37156. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  37157. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  37158. cmds.push({ cmd: 'restore' });
  37159. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  37160. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  37161. }
  37162. return;
  37163. case 18:
  37164. stems += stack.length >> 1;
  37165. stackClean = true;
  37166. break;
  37167. case 19:
  37168. stems += stack.length >> 1;
  37169. i += stems + 7 >> 3;
  37170. stackClean = true;
  37171. break;
  37172. case 20:
  37173. stems += stack.length >> 1;
  37174. i += stems + 7 >> 3;
  37175. stackClean = true;
  37176. break;
  37177. case 21:
  37178. y += stack.pop();
  37179. x += stack.pop();
  37180. moveTo(x, y);
  37181. stackClean = true;
  37182. break;
  37183. case 22:
  37184. x += stack.pop();
  37185. moveTo(x, y);
  37186. stackClean = true;
  37187. break;
  37188. case 23:
  37189. stems += stack.length >> 1;
  37190. stackClean = true;
  37191. break;
  37192. case 24:
  37193. while (stack.length > 2) {
  37194. xa = x + stack.shift();
  37195. ya = y + stack.shift();
  37196. xb = xa + stack.shift();
  37197. yb = ya + stack.shift();
  37198. x = xb + stack.shift();
  37199. y = yb + stack.shift();
  37200. bezierCurveTo(xa, ya, xb, yb, x, y);
  37201. }
  37202. x += stack.shift();
  37203. y += stack.shift();
  37204. lineTo(x, y);
  37205. break;
  37206. case 25:
  37207. while (stack.length > 6) {
  37208. x += stack.shift();
  37209. y += stack.shift();
  37210. lineTo(x, y);
  37211. }
  37212. xa = x + stack.shift();
  37213. ya = y + stack.shift();
  37214. xb = xa + stack.shift();
  37215. yb = ya + stack.shift();
  37216. x = xb + stack.shift();
  37217. y = yb + stack.shift();
  37218. bezierCurveTo(xa, ya, xb, yb, x, y);
  37219. break;
  37220. case 26:
  37221. if (stack.length % 2) {
  37222. x += stack.shift();
  37223. }
  37224. while (stack.length > 0) {
  37225. xa = x;
  37226. ya = y + stack.shift();
  37227. xb = xa + stack.shift();
  37228. yb = ya + stack.shift();
  37229. x = xb;
  37230. y = yb + stack.shift();
  37231. bezierCurveTo(xa, ya, xb, yb, x, y);
  37232. }
  37233. break;
  37234. case 27:
  37235. if (stack.length % 2) {
  37236. y += stack.shift();
  37237. }
  37238. while (stack.length > 0) {
  37239. xa = x + stack.shift();
  37240. ya = y;
  37241. xb = xa + stack.shift();
  37242. yb = ya + stack.shift();
  37243. x = xb + stack.shift();
  37244. y = yb;
  37245. bezierCurveTo(xa, ya, xb, yb, x, y);
  37246. }
  37247. break;
  37248. case 28:
  37249. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37250. i += 2;
  37251. break;
  37252. case 29:
  37253. n = stack.pop() + font.gsubrsBias;
  37254. subrCode = font.gsubrs[n];
  37255. if (subrCode) {
  37256. parse(subrCode);
  37257. }
  37258. break;
  37259. case 30:
  37260. while (stack.length > 0) {
  37261. xa = x;
  37262. ya = y + stack.shift();
  37263. xb = xa + stack.shift();
  37264. yb = ya + stack.shift();
  37265. x = xb + stack.shift();
  37266. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37267. bezierCurveTo(xa, ya, xb, yb, x, y);
  37268. if (stack.length === 0) {
  37269. break;
  37270. }
  37271. xa = x + stack.shift();
  37272. ya = y;
  37273. xb = xa + stack.shift();
  37274. yb = ya + stack.shift();
  37275. y = yb + stack.shift();
  37276. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37277. bezierCurveTo(xa, ya, xb, yb, x, y);
  37278. }
  37279. break;
  37280. case 31:
  37281. while (stack.length > 0) {
  37282. xa = x + stack.shift();
  37283. ya = y;
  37284. xb = xa + stack.shift();
  37285. yb = ya + stack.shift();
  37286. y = yb + stack.shift();
  37287. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37288. bezierCurveTo(xa, ya, xb, yb, x, y);
  37289. if (stack.length === 0) {
  37290. break;
  37291. }
  37292. xa = x;
  37293. ya = y + stack.shift();
  37294. xb = xa + stack.shift();
  37295. yb = ya + stack.shift();
  37296. x = xb + stack.shift();
  37297. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37298. bezierCurveTo(xa, ya, xb, yb, x, y);
  37299. }
  37300. break;
  37301. default:
  37302. if (v < 32) {
  37303. error('unknown operator: ' + v);
  37304. }
  37305. if (v < 247) {
  37306. stack.push(v - 139);
  37307. } else if (v < 251) {
  37308. stack.push((v - 247) * 256 + code[i++] + 108);
  37309. } else if (v < 255) {
  37310. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37311. } else {
  37312. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37313. i += 4;
  37314. }
  37315. break;
  37316. }
  37317. if (stackClean) {
  37318. stack.length = 0;
  37319. }
  37320. }
  37321. }
  37322. parse(code);
  37323. }
  37324. var noop = '';
  37325. function CompiledFont(fontMatrix) {
  37326. this.compiledGlyphs = Object.create(null);
  37327. this.compiledCharCodeToGlyphId = Object.create(null);
  37328. this.fontMatrix = fontMatrix;
  37329. }
  37330. CompiledFont.prototype = {
  37331. getPathJs: function (unicode) {
  37332. var cmap = lookupCmap(this.cmap, unicode);
  37333. var fn = this.compiledGlyphs[cmap.glyphId];
  37334. if (!fn) {
  37335. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37336. this.compiledGlyphs[cmap.glyphId] = fn;
  37337. }
  37338. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37339. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37340. }
  37341. return fn;
  37342. },
  37343. compileGlyph: function (code) {
  37344. if (!code || code.length === 0 || code[0] === 14) {
  37345. return noop;
  37346. }
  37347. var cmds = [];
  37348. cmds.push({ cmd: 'save' });
  37349. cmds.push({
  37350. cmd: 'transform',
  37351. args: this.fontMatrix.slice()
  37352. });
  37353. cmds.push({
  37354. cmd: 'scale',
  37355. args: [
  37356. 'size',
  37357. '-size'
  37358. ]
  37359. });
  37360. this.compileGlyphImpl(code, cmds);
  37361. cmds.push({ cmd: 'restore' });
  37362. return cmds;
  37363. },
  37364. compileGlyphImpl: function () {
  37365. error('Children classes should implement this.');
  37366. },
  37367. hasBuiltPath: function (unicode) {
  37368. var cmap = lookupCmap(this.cmap, unicode);
  37369. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37370. }
  37371. };
  37372. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37373. fontMatrix = fontMatrix || [
  37374. 0.000488,
  37375. 0,
  37376. 0,
  37377. 0.000488,
  37378. 0,
  37379. 0
  37380. ];
  37381. CompiledFont.call(this, fontMatrix);
  37382. this.glyphs = glyphs;
  37383. this.cmap = cmap;
  37384. }
  37385. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37386. compileGlyphImpl: function (code, cmds) {
  37387. compileGlyf(code, cmds, this);
  37388. }
  37389. });
  37390. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37391. fontMatrix = fontMatrix || [
  37392. 0.001,
  37393. 0,
  37394. 0,
  37395. 0.001,
  37396. 0,
  37397. 0
  37398. ];
  37399. CompiledFont.call(this, fontMatrix);
  37400. this.glyphs = cffInfo.glyphs;
  37401. this.gsubrs = cffInfo.gsubrs || [];
  37402. this.subrs = cffInfo.subrs || [];
  37403. this.cmap = cmap;
  37404. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37405. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37406. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37407. }
  37408. Util.inherit(Type2Compiled, CompiledFont, {
  37409. compileGlyphImpl: function (code, cmds) {
  37410. compileCharString(code, cmds, this);
  37411. }
  37412. });
  37413. return {
  37414. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37415. var data = new Uint8Array(font.data);
  37416. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37417. var numTables = getUshort(data, 4);
  37418. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37419. var tag = bytesToString(data.subarray(p, p + 4));
  37420. var offset = getLong(data, p + 8);
  37421. var length = getLong(data, p + 12);
  37422. switch (tag) {
  37423. case 'cmap':
  37424. cmap = parseCmap(data, offset, offset + length);
  37425. break;
  37426. case 'glyf':
  37427. glyf = data.subarray(offset, offset + length);
  37428. break;
  37429. case 'loca':
  37430. loca = data.subarray(offset, offset + length);
  37431. break;
  37432. case 'head':
  37433. unitsPerEm = getUshort(data, offset + 18);
  37434. indexToLocFormat = getUshort(data, offset + 50);
  37435. break;
  37436. case 'CFF ':
  37437. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37438. break;
  37439. }
  37440. }
  37441. if (glyf) {
  37442. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37443. 1 / unitsPerEm,
  37444. 0,
  37445. 0,
  37446. 1 / unitsPerEm,
  37447. 0,
  37448. 0
  37449. ];
  37450. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37451. }
  37452. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37453. }
  37454. };
  37455. }();
  37456. exports.FontRendererFactory = FontRendererFactory;
  37457. }));
  37458. (function (root, factory) {
  37459. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37460. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37461. var MissingDataException = sharedUtil.MissingDataException;
  37462. var StreamType = sharedUtil.StreamType;
  37463. var assert = sharedUtil.assert;
  37464. var error = sharedUtil.error;
  37465. var info = sharedUtil.info;
  37466. var isArray = sharedUtil.isArray;
  37467. var isInt = sharedUtil.isInt;
  37468. var isNum = sharedUtil.isNum;
  37469. var isString = sharedUtil.isString;
  37470. var warn = sharedUtil.warn;
  37471. var Cmd = corePrimitives.Cmd;
  37472. var Dict = corePrimitives.Dict;
  37473. var Name = corePrimitives.Name;
  37474. var Ref = corePrimitives.Ref;
  37475. var isCmd = corePrimitives.isCmd;
  37476. var isDict = corePrimitives.isDict;
  37477. var isName = corePrimitives.isName;
  37478. var Ascii85Stream = coreStream.Ascii85Stream;
  37479. var AsciiHexStream = coreStream.AsciiHexStream;
  37480. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37481. var FlateStream = coreStream.FlateStream;
  37482. var Jbig2Stream = coreStream.Jbig2Stream;
  37483. var JpegStream = coreStream.JpegStream;
  37484. var JpxStream = coreStream.JpxStream;
  37485. var LZWStream = coreStream.LZWStream;
  37486. var NullStream = coreStream.NullStream;
  37487. var PredictorStream = coreStream.PredictorStream;
  37488. var RunLengthStream = coreStream.RunLengthStream;
  37489. var EOF = {};
  37490. function isEOF(v) {
  37491. return v === EOF;
  37492. }
  37493. var MAX_LENGTH_TO_CACHE = 1000;
  37494. var Parser = function ParserClosure() {
  37495. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37496. this.lexer = lexer;
  37497. this.allowStreams = allowStreams;
  37498. this.xref = xref;
  37499. this.recoveryMode = recoveryMode || false;
  37500. this.imageCache = Object.create(null);
  37501. this.refill();
  37502. }
  37503. Parser.prototype = {
  37504. refill: function Parser_refill() {
  37505. this.buf1 = this.lexer.getObj();
  37506. this.buf2 = this.lexer.getObj();
  37507. },
  37508. shift: function Parser_shift() {
  37509. if (isCmd(this.buf2, 'ID')) {
  37510. this.buf1 = this.buf2;
  37511. this.buf2 = null;
  37512. } else {
  37513. this.buf1 = this.buf2;
  37514. this.buf2 = this.lexer.getObj();
  37515. }
  37516. },
  37517. tryShift: function Parser_tryShift() {
  37518. try {
  37519. this.shift();
  37520. return true;
  37521. } catch (e) {
  37522. if (e instanceof MissingDataException) {
  37523. throw e;
  37524. }
  37525. return false;
  37526. }
  37527. },
  37528. getObj: function Parser_getObj(cipherTransform) {
  37529. var buf1 = this.buf1;
  37530. this.shift();
  37531. if (buf1 instanceof Cmd) {
  37532. switch (buf1.cmd) {
  37533. case 'BI':
  37534. return this.makeInlineImage(cipherTransform);
  37535. case '[':
  37536. var array = [];
  37537. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37538. array.push(this.getObj(cipherTransform));
  37539. }
  37540. if (isEOF(this.buf1)) {
  37541. if (!this.recoveryMode) {
  37542. error('End of file inside array');
  37543. }
  37544. return array;
  37545. }
  37546. this.shift();
  37547. return array;
  37548. case '<<':
  37549. var dict = new Dict(this.xref);
  37550. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37551. if (!isName(this.buf1)) {
  37552. info('Malformed dictionary: key must be a name object');
  37553. this.shift();
  37554. continue;
  37555. }
  37556. var key = this.buf1.name;
  37557. this.shift();
  37558. if (isEOF(this.buf1)) {
  37559. break;
  37560. }
  37561. dict.set(key, this.getObj(cipherTransform));
  37562. }
  37563. if (isEOF(this.buf1)) {
  37564. if (!this.recoveryMode) {
  37565. error('End of file inside dictionary');
  37566. }
  37567. return dict;
  37568. }
  37569. if (isCmd(this.buf2, 'stream')) {
  37570. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37571. }
  37572. this.shift();
  37573. return dict;
  37574. default:
  37575. return buf1;
  37576. }
  37577. }
  37578. if (isInt(buf1)) {
  37579. var num = buf1;
  37580. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37581. var ref = new Ref(num, this.buf1);
  37582. this.shift();
  37583. this.shift();
  37584. return ref;
  37585. }
  37586. return num;
  37587. }
  37588. if (isString(buf1)) {
  37589. var str = buf1;
  37590. if (cipherTransform) {
  37591. str = cipherTransform.decryptString(str);
  37592. }
  37593. return str;
  37594. }
  37595. return buf1;
  37596. },
  37597. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37598. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37599. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37600. while ((ch = stream.getByte()) !== -1) {
  37601. if (state === 0) {
  37602. state = ch === E ? 1 : 0;
  37603. } else if (state === 1) {
  37604. state = ch === I ? 2 : 0;
  37605. } else {
  37606. assert(state === 2);
  37607. if (ch === SPACE || ch === LF || ch === CR) {
  37608. n = 5;
  37609. followingBytes = stream.peekBytes(n);
  37610. for (i = 0; i < n; i++) {
  37611. ch = followingBytes[i];
  37612. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37613. state = 0;
  37614. break;
  37615. }
  37616. }
  37617. if (state === 2) {
  37618. break;
  37619. }
  37620. } else
  37621. {
  37622. state = 0;
  37623. }
  37624. }
  37625. }
  37626. return stream.pos - 4 - startPos;
  37627. },
  37628. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37629. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37630. while ((b = stream.getByte()) !== -1) {
  37631. if (b !== 0xFF) {
  37632. continue;
  37633. }
  37634. switch (stream.getByte()) {
  37635. case 0x00:
  37636. break;
  37637. case 0xFF:
  37638. stream.skip(-1);
  37639. break;
  37640. case 0xD9:
  37641. foundEOI = true;
  37642. break;
  37643. case 0xC0:
  37644. case 0xC1:
  37645. case 0xC2:
  37646. case 0xC3:
  37647. case 0xC5:
  37648. case 0xC6:
  37649. case 0xC7:
  37650. case 0xC9:
  37651. case 0xCA:
  37652. case 0xCB:
  37653. case 0xCD:
  37654. case 0xCE:
  37655. case 0xCF:
  37656. case 0xC4:
  37657. case 0xCC:
  37658. case 0xDA:
  37659. case 0xDB:
  37660. case 0xDC:
  37661. case 0xDD:
  37662. case 0xDE:
  37663. case 0xDF:
  37664. case 0xE0:
  37665. case 0xE1:
  37666. case 0xE2:
  37667. case 0xE3:
  37668. case 0xE4:
  37669. case 0xE5:
  37670. case 0xE6:
  37671. case 0xE7:
  37672. case 0xE8:
  37673. case 0xE9:
  37674. case 0xEA:
  37675. case 0xEB:
  37676. case 0xEC:
  37677. case 0xED:
  37678. case 0xEE:
  37679. case 0xEF:
  37680. case 0xFE:
  37681. markerLength = stream.getUint16();
  37682. if (markerLength > 2) {
  37683. stream.skip(markerLength - 2);
  37684. } else
  37685. {
  37686. stream.skip(-2);
  37687. }
  37688. break;
  37689. }
  37690. if (foundEOI) {
  37691. break;
  37692. }
  37693. }
  37694. length = stream.pos - startPos;
  37695. if (b === -1) {
  37696. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37697. stream.skip(-length);
  37698. return this.findDefaultInlineStreamEnd(stream);
  37699. }
  37700. this.inlineStreamSkipEI(stream);
  37701. return length;
  37702. },
  37703. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37704. var TILDE = 0x7E, GT = 0x3E;
  37705. var startPos = stream.pos, ch, length;
  37706. while ((ch = stream.getByte()) !== -1) {
  37707. if (ch === TILDE && stream.peekByte() === GT) {
  37708. stream.skip();
  37709. break;
  37710. }
  37711. }
  37712. length = stream.pos - startPos;
  37713. if (ch === -1) {
  37714. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37715. stream.skip(-length);
  37716. return this.findDefaultInlineStreamEnd(stream);
  37717. }
  37718. this.inlineStreamSkipEI(stream);
  37719. return length;
  37720. },
  37721. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37722. var GT = 0x3E;
  37723. var startPos = stream.pos, ch, length;
  37724. while ((ch = stream.getByte()) !== -1) {
  37725. if (ch === GT) {
  37726. break;
  37727. }
  37728. }
  37729. length = stream.pos - startPos;
  37730. if (ch === -1) {
  37731. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37732. stream.skip(-length);
  37733. return this.findDefaultInlineStreamEnd(stream);
  37734. }
  37735. this.inlineStreamSkipEI(stream);
  37736. return length;
  37737. },
  37738. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37739. var E = 0x45, I = 0x49;
  37740. var state = 0, ch;
  37741. while ((ch = stream.getByte()) !== -1) {
  37742. if (state === 0) {
  37743. state = ch === E ? 1 : 0;
  37744. } else if (state === 1) {
  37745. state = ch === I ? 2 : 0;
  37746. } else if (state === 2) {
  37747. break;
  37748. }
  37749. }
  37750. },
  37751. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37752. var lexer = this.lexer;
  37753. var stream = lexer.stream;
  37754. var dict = new Dict(this.xref);
  37755. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37756. if (!isName(this.buf1)) {
  37757. error('Dictionary key must be a name object');
  37758. }
  37759. var key = this.buf1.name;
  37760. this.shift();
  37761. if (isEOF(this.buf1)) {
  37762. break;
  37763. }
  37764. dict.set(key, this.getObj(cipherTransform));
  37765. }
  37766. var filter = dict.get('Filter', 'F'), filterName;
  37767. if (isName(filter)) {
  37768. filterName = filter.name;
  37769. } else if (isArray(filter)) {
  37770. var filterZero = this.xref.fetchIfRef(filter[0]);
  37771. if (isName(filterZero)) {
  37772. filterName = filterZero.name;
  37773. }
  37774. }
  37775. var startPos = stream.pos, length, i, ii;
  37776. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37777. length = this.findDCTDecodeInlineStreamEnd(stream);
  37778. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37779. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37780. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37781. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37782. } else {
  37783. length = this.findDefaultInlineStreamEnd(stream);
  37784. }
  37785. var imageStream = stream.makeSubStream(startPos, length, dict);
  37786. var adler32;
  37787. if (length < MAX_LENGTH_TO_CACHE) {
  37788. var imageBytes = imageStream.getBytes();
  37789. imageStream.reset();
  37790. var a = 1;
  37791. var b = 0;
  37792. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37793. a += imageBytes[i] & 0xff;
  37794. b += a;
  37795. }
  37796. adler32 = b % 65521 << 16 | a % 65521;
  37797. if (this.imageCache.adler32 === adler32) {
  37798. this.buf2 = Cmd.get('EI');
  37799. this.shift();
  37800. this.imageCache[adler32].reset();
  37801. return this.imageCache[adler32];
  37802. }
  37803. }
  37804. if (cipherTransform) {
  37805. imageStream = cipherTransform.createStream(imageStream, length);
  37806. }
  37807. imageStream = this.filter(imageStream, dict, length);
  37808. imageStream.dict = dict;
  37809. if (adler32 !== undefined) {
  37810. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37811. this.imageCache[adler32] = imageStream;
  37812. }
  37813. this.buf2 = Cmd.get('EI');
  37814. this.shift();
  37815. return imageStream;
  37816. },
  37817. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37818. var lexer = this.lexer;
  37819. var stream = lexer.stream;
  37820. lexer.skipToNextLine();
  37821. var pos = stream.pos - 1;
  37822. var length = dict.get('Length');
  37823. if (!isInt(length)) {
  37824. info('Bad ' + length + ' attribute in stream');
  37825. length = 0;
  37826. }
  37827. stream.pos = pos + length;
  37828. lexer.nextChar();
  37829. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37830. this.shift();
  37831. } else
  37832. {
  37833. stream.pos = pos;
  37834. var SCAN_BLOCK_SIZE = 2048;
  37835. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37836. var ENDSTREAM_SIGNATURE = [
  37837. 0x65,
  37838. 0x6E,
  37839. 0x64,
  37840. 0x73,
  37841. 0x74,
  37842. 0x72,
  37843. 0x65,
  37844. 0x61,
  37845. 0x6D
  37846. ];
  37847. var skipped = 0, found = false, i, j;
  37848. while (stream.pos < stream.end) {
  37849. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37850. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37851. if (scanLength <= 0) {
  37852. break;
  37853. }
  37854. found = false;
  37855. i = 0;
  37856. while (i < scanLength) {
  37857. j = 0;
  37858. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37859. j++;
  37860. }
  37861. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37862. found = true;
  37863. break;
  37864. }
  37865. i++;
  37866. }
  37867. if (found) {
  37868. skipped += i;
  37869. stream.pos += i;
  37870. break;
  37871. }
  37872. skipped += scanLength;
  37873. stream.pos += scanLength;
  37874. }
  37875. if (!found) {
  37876. error('Missing endstream');
  37877. }
  37878. length = skipped;
  37879. lexer.nextChar();
  37880. this.shift();
  37881. this.shift();
  37882. }
  37883. this.shift();
  37884. stream = stream.makeSubStream(pos, length, dict);
  37885. if (cipherTransform) {
  37886. stream = cipherTransform.createStream(stream, length);
  37887. }
  37888. stream = this.filter(stream, dict, length);
  37889. stream.dict = dict;
  37890. return stream;
  37891. },
  37892. filter: function Parser_filter(stream, dict, length) {
  37893. var filter = dict.get('Filter', 'F');
  37894. var params = dict.get('DecodeParms', 'DP');
  37895. if (isName(filter)) {
  37896. if (isArray(params)) {
  37897. params = this.xref.fetchIfRef(params[0]);
  37898. }
  37899. return this.makeFilter(stream, filter.name, length, params);
  37900. }
  37901. var maybeLength = length;
  37902. if (isArray(filter)) {
  37903. var filterArray = filter;
  37904. var paramsArray = params;
  37905. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37906. filter = this.xref.fetchIfRef(filterArray[i]);
  37907. if (!isName(filter)) {
  37908. error('Bad filter name: ' + filter);
  37909. }
  37910. params = null;
  37911. if (isArray(paramsArray) && i in paramsArray) {
  37912. params = this.xref.fetchIfRef(paramsArray[i]);
  37913. }
  37914. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37915. maybeLength = null;
  37916. }
  37917. }
  37918. return stream;
  37919. },
  37920. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37921. if (maybeLength === 0) {
  37922. warn('Empty "' + name + '" stream.');
  37923. return new NullStream(stream);
  37924. }
  37925. try {
  37926. var xrefStreamStats = this.xref.stats.streamTypes;
  37927. if (name === 'FlateDecode' || name === 'Fl') {
  37928. xrefStreamStats[StreamType.FLATE] = true;
  37929. if (params) {
  37930. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37931. }
  37932. return new FlateStream(stream, maybeLength);
  37933. }
  37934. if (name === 'LZWDecode' || name === 'LZW') {
  37935. xrefStreamStats[StreamType.LZW] = true;
  37936. var earlyChange = 1;
  37937. if (params) {
  37938. if (params.has('EarlyChange')) {
  37939. earlyChange = params.get('EarlyChange');
  37940. }
  37941. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37942. }
  37943. return new LZWStream(stream, maybeLength, earlyChange);
  37944. }
  37945. if (name === 'DCTDecode' || name === 'DCT') {
  37946. xrefStreamStats[StreamType.DCT] = true;
  37947. return new JpegStream(stream, maybeLength, stream.dict, params);
  37948. }
  37949. if (name === 'JPXDecode' || name === 'JPX') {
  37950. xrefStreamStats[StreamType.JPX] = true;
  37951. return new JpxStream(stream, maybeLength, stream.dict, params);
  37952. }
  37953. if (name === 'ASCII85Decode' || name === 'A85') {
  37954. xrefStreamStats[StreamType.A85] = true;
  37955. return new Ascii85Stream(stream, maybeLength);
  37956. }
  37957. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37958. xrefStreamStats[StreamType.AHX] = true;
  37959. return new AsciiHexStream(stream, maybeLength);
  37960. }
  37961. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37962. xrefStreamStats[StreamType.CCF] = true;
  37963. return new CCITTFaxStream(stream, maybeLength, params);
  37964. }
  37965. if (name === 'RunLengthDecode' || name === 'RL') {
  37966. xrefStreamStats[StreamType.RL] = true;
  37967. return new RunLengthStream(stream, maybeLength);
  37968. }
  37969. if (name === 'JBIG2Decode') {
  37970. xrefStreamStats[StreamType.JBIG] = true;
  37971. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37972. }
  37973. warn('filter "' + name + '" not supported yet');
  37974. return stream;
  37975. } catch (ex) {
  37976. if (ex instanceof MissingDataException) {
  37977. throw ex;
  37978. }
  37979. warn('Invalid stream: \"' + ex + '\"');
  37980. return new NullStream(stream);
  37981. }
  37982. }
  37983. };
  37984. return Parser;
  37985. }();
  37986. var Lexer = function LexerClosure() {
  37987. function Lexer(stream, knownCommands) {
  37988. this.stream = stream;
  37989. this.nextChar();
  37990. this.strBuf = [];
  37991. this.knownCommands = knownCommands;
  37992. }
  37993. var specialChars = [
  37994. 1,
  37995. 0,
  37996. 0,
  37997. 0,
  37998. 0,
  37999. 0,
  38000. 0,
  38001. 0,
  38002. 0,
  38003. 1,
  38004. 1,
  38005. 0,
  38006. 1,
  38007. 1,
  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. 1,
  38027. 0,
  38028. 0,
  38029. 0,
  38030. 0,
  38031. 2,
  38032. 0,
  38033. 0,
  38034. 2,
  38035. 2,
  38036. 0,
  38037. 0,
  38038. 0,
  38039. 0,
  38040. 0,
  38041. 2,
  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. 2,
  38055. 0,
  38056. 2,
  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. 2,
  38086. 0,
  38087. 2,
  38088. 0,
  38089. 0,
  38090. 0,
  38091. 0,
  38092. 0,
  38093. 0,
  38094. 0,
  38095. 0,
  38096. 0,
  38097. 0,
  38098. 0,
  38099. 0,
  38100. 0,
  38101. 0,
  38102. 0,
  38103. 0,
  38104. 0,
  38105. 0,
  38106. 0,
  38107. 0,
  38108. 0,
  38109. 0,
  38110. 0,
  38111. 0,
  38112. 0,
  38113. 0,
  38114. 0,
  38115. 0,
  38116. 0,
  38117. 2,
  38118. 0,
  38119. 2,
  38120. 0,
  38121. 0,
  38122. 0,
  38123. 0,
  38124. 0,
  38125. 0,
  38126. 0,
  38127. 0,
  38128. 0,
  38129. 0,
  38130. 0,
  38131. 0,
  38132. 0,
  38133. 0,
  38134. 0,
  38135. 0,
  38136. 0,
  38137. 0,
  38138. 0,
  38139. 0,
  38140. 0,
  38141. 0,
  38142. 0,
  38143. 0,
  38144. 0,
  38145. 0,
  38146. 0,
  38147. 0,
  38148. 0,
  38149. 0,
  38150. 0,
  38151. 0,
  38152. 0,
  38153. 0,
  38154. 0,
  38155. 0,
  38156. 0,
  38157. 0,
  38158. 0,
  38159. 0,
  38160. 0,
  38161. 0,
  38162. 0,
  38163. 0,
  38164. 0,
  38165. 0,
  38166. 0,
  38167. 0,
  38168. 0,
  38169. 0,
  38170. 0,
  38171. 0,
  38172. 0,
  38173. 0,
  38174. 0,
  38175. 0,
  38176. 0,
  38177. 0,
  38178. 0,
  38179. 0,
  38180. 0,
  38181. 0,
  38182. 0,
  38183. 0,
  38184. 0,
  38185. 0,
  38186. 0,
  38187. 0,
  38188. 0,
  38189. 0,
  38190. 0,
  38191. 0,
  38192. 0,
  38193. 0,
  38194. 0,
  38195. 0,
  38196. 0,
  38197. 0,
  38198. 0,
  38199. 0,
  38200. 0,
  38201. 0,
  38202. 0,
  38203. 0,
  38204. 0,
  38205. 0,
  38206. 0,
  38207. 0,
  38208. 0,
  38209. 0,
  38210. 0,
  38211. 0,
  38212. 0,
  38213. 0,
  38214. 0,
  38215. 0,
  38216. 0,
  38217. 0,
  38218. 0,
  38219. 0,
  38220. 0,
  38221. 0,
  38222. 0,
  38223. 0,
  38224. 0,
  38225. 0,
  38226. 0,
  38227. 0,
  38228. 0,
  38229. 0,
  38230. 0,
  38231. 0,
  38232. 0,
  38233. 0,
  38234. 0,
  38235. 0,
  38236. 0,
  38237. 0,
  38238. 0,
  38239. 0,
  38240. 0,
  38241. 0,
  38242. 0,
  38243. 0,
  38244. 0,
  38245. 0,
  38246. 0,
  38247. 0,
  38248. 0,
  38249. 0
  38250. ];
  38251. function toHexDigit(ch) {
  38252. if (ch >= 0x30 && ch <= 0x39) {
  38253. return ch & 0x0F;
  38254. }
  38255. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38256. return (ch & 0x0F) + 9;
  38257. }
  38258. return -1;
  38259. }
  38260. Lexer.prototype = {
  38261. nextChar: function Lexer_nextChar() {
  38262. return this.currentChar = this.stream.getByte();
  38263. },
  38264. peekChar: function Lexer_peekChar() {
  38265. return this.stream.peekByte();
  38266. },
  38267. getNumber: function Lexer_getNumber() {
  38268. var ch = this.currentChar;
  38269. var eNotation = false;
  38270. var divideBy = 0;
  38271. var sign = 1;
  38272. if (ch === 0x2D) {
  38273. sign = -1;
  38274. ch = this.nextChar();
  38275. if (ch === 0x2D) {
  38276. ch = this.nextChar();
  38277. }
  38278. } else if (ch === 0x2B) {
  38279. ch = this.nextChar();
  38280. }
  38281. if (ch === 0x2E) {
  38282. divideBy = 10;
  38283. ch = this.nextChar();
  38284. }
  38285. if (ch < 0x30 || ch > 0x39) {
  38286. error('Invalid number: ' + String.fromCharCode(ch));
  38287. return 0;
  38288. }
  38289. var baseValue = ch - 0x30;
  38290. var powerValue = 0;
  38291. var powerValueSign = 1;
  38292. while ((ch = this.nextChar()) >= 0) {
  38293. if (0x30 <= ch && ch <= 0x39) {
  38294. var currentDigit = ch - 0x30;
  38295. if (eNotation) {
  38296. powerValue = powerValue * 10 + currentDigit;
  38297. } else {
  38298. if (divideBy !== 0) {
  38299. divideBy *= 10;
  38300. }
  38301. baseValue = baseValue * 10 + currentDigit;
  38302. }
  38303. } else if (ch === 0x2E) {
  38304. if (divideBy === 0) {
  38305. divideBy = 1;
  38306. } else {
  38307. break;
  38308. }
  38309. } else if (ch === 0x2D) {
  38310. warn('Badly formatted number');
  38311. } else if (ch === 0x45 || ch === 0x65) {
  38312. ch = this.peekChar();
  38313. if (ch === 0x2B || ch === 0x2D) {
  38314. powerValueSign = ch === 0x2D ? -1 : 1;
  38315. this.nextChar();
  38316. } else if (ch < 0x30 || ch > 0x39) {
  38317. break;
  38318. }
  38319. eNotation = true;
  38320. } else {
  38321. break;
  38322. }
  38323. }
  38324. if (divideBy !== 0) {
  38325. baseValue /= divideBy;
  38326. }
  38327. if (eNotation) {
  38328. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38329. }
  38330. return sign * baseValue;
  38331. },
  38332. getString: function Lexer_getString() {
  38333. var numParen = 1;
  38334. var done = false;
  38335. var strBuf = this.strBuf;
  38336. strBuf.length = 0;
  38337. var ch = this.nextChar();
  38338. while (true) {
  38339. var charBuffered = false;
  38340. switch (ch | 0) {
  38341. case -1:
  38342. warn('Unterminated string');
  38343. done = true;
  38344. break;
  38345. case 0x28:
  38346. ++numParen;
  38347. strBuf.push('(');
  38348. break;
  38349. case 0x29:
  38350. if (--numParen === 0) {
  38351. this.nextChar();
  38352. done = true;
  38353. } else {
  38354. strBuf.push(')');
  38355. }
  38356. break;
  38357. case 0x5C:
  38358. ch = this.nextChar();
  38359. switch (ch) {
  38360. case -1:
  38361. warn('Unterminated string');
  38362. done = true;
  38363. break;
  38364. case 0x6E:
  38365. strBuf.push('\n');
  38366. break;
  38367. case 0x72:
  38368. strBuf.push('\r');
  38369. break;
  38370. case 0x74:
  38371. strBuf.push('\t');
  38372. break;
  38373. case 0x62:
  38374. strBuf.push('\b');
  38375. break;
  38376. case 0x66:
  38377. strBuf.push('\f');
  38378. break;
  38379. case 0x5C:
  38380. case 0x28:
  38381. case 0x29:
  38382. strBuf.push(String.fromCharCode(ch));
  38383. break;
  38384. case 0x30:
  38385. case 0x31:
  38386. case 0x32:
  38387. case 0x33:
  38388. case 0x34:
  38389. case 0x35:
  38390. case 0x36:
  38391. case 0x37:
  38392. var x = ch & 0x0F;
  38393. ch = this.nextChar();
  38394. charBuffered = true;
  38395. if (ch >= 0x30 && ch <= 0x37) {
  38396. x = (x << 3) + (ch & 0x0F);
  38397. ch = this.nextChar();
  38398. if (ch >= 0x30 && ch <= 0x37) {
  38399. charBuffered = false;
  38400. x = (x << 3) + (ch & 0x0F);
  38401. }
  38402. }
  38403. strBuf.push(String.fromCharCode(x));
  38404. break;
  38405. case 0x0D:
  38406. if (this.peekChar() === 0x0A) {
  38407. this.nextChar();
  38408. }
  38409. break;
  38410. case 0x0A:
  38411. break;
  38412. default:
  38413. strBuf.push(String.fromCharCode(ch));
  38414. break;
  38415. }
  38416. break;
  38417. default:
  38418. strBuf.push(String.fromCharCode(ch));
  38419. break;
  38420. }
  38421. if (done) {
  38422. break;
  38423. }
  38424. if (!charBuffered) {
  38425. ch = this.nextChar();
  38426. }
  38427. }
  38428. return strBuf.join('');
  38429. },
  38430. getName: function Lexer_getName() {
  38431. var ch, previousCh;
  38432. var strBuf = this.strBuf;
  38433. strBuf.length = 0;
  38434. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38435. if (ch === 0x23) {
  38436. ch = this.nextChar();
  38437. if (specialChars[ch]) {
  38438. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38439. strBuf.push('#');
  38440. break;
  38441. }
  38442. var x = toHexDigit(ch);
  38443. if (x !== -1) {
  38444. previousCh = ch;
  38445. ch = this.nextChar();
  38446. var x2 = toHexDigit(ch);
  38447. if (x2 === -1) {
  38448. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38449. strBuf.push('#', String.fromCharCode(previousCh));
  38450. if (specialChars[ch]) {
  38451. break;
  38452. }
  38453. strBuf.push(String.fromCharCode(ch));
  38454. continue;
  38455. }
  38456. strBuf.push(String.fromCharCode(x << 4 | x2));
  38457. } else {
  38458. strBuf.push('#', String.fromCharCode(ch));
  38459. }
  38460. } else {
  38461. strBuf.push(String.fromCharCode(ch));
  38462. }
  38463. }
  38464. if (strBuf.length > 127) {
  38465. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38466. }
  38467. return Name.get(strBuf.join(''));
  38468. },
  38469. getHexString: function Lexer_getHexString() {
  38470. var strBuf = this.strBuf;
  38471. strBuf.length = 0;
  38472. var ch = this.currentChar;
  38473. var isFirstHex = true;
  38474. var firstDigit;
  38475. var secondDigit;
  38476. while (true) {
  38477. if (ch < 0) {
  38478. warn('Unterminated hex string');
  38479. break;
  38480. } else if (ch === 0x3E) {
  38481. this.nextChar();
  38482. break;
  38483. } else if (specialChars[ch] === 1) {
  38484. ch = this.nextChar();
  38485. continue;
  38486. } else {
  38487. if (isFirstHex) {
  38488. firstDigit = toHexDigit(ch);
  38489. if (firstDigit === -1) {
  38490. warn('Ignoring invalid character "' + ch + '" in hex string');
  38491. ch = this.nextChar();
  38492. continue;
  38493. }
  38494. } else {
  38495. secondDigit = toHexDigit(ch);
  38496. if (secondDigit === -1) {
  38497. warn('Ignoring invalid character "' + ch + '" in hex string');
  38498. ch = this.nextChar();
  38499. continue;
  38500. }
  38501. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38502. }
  38503. isFirstHex = !isFirstHex;
  38504. ch = this.nextChar();
  38505. }
  38506. }
  38507. return strBuf.join('');
  38508. },
  38509. getObj: function Lexer_getObj() {
  38510. var comment = false;
  38511. var ch = this.currentChar;
  38512. while (true) {
  38513. if (ch < 0) {
  38514. return EOF;
  38515. }
  38516. if (comment) {
  38517. if (ch === 0x0A || ch === 0x0D) {
  38518. comment = false;
  38519. }
  38520. } else if (ch === 0x25) {
  38521. comment = true;
  38522. } else if (specialChars[ch] !== 1) {
  38523. break;
  38524. }
  38525. ch = this.nextChar();
  38526. }
  38527. switch (ch | 0) {
  38528. case 0x30:
  38529. case 0x31:
  38530. case 0x32:
  38531. case 0x33:
  38532. case 0x34:
  38533. case 0x35:
  38534. case 0x36:
  38535. case 0x37:
  38536. case 0x38:
  38537. case 0x39:
  38538. case 0x2B:
  38539. case 0x2D:
  38540. case 0x2E:
  38541. return this.getNumber();
  38542. case 0x28:
  38543. return this.getString();
  38544. case 0x2F:
  38545. return this.getName();
  38546. case 0x5B:
  38547. this.nextChar();
  38548. return Cmd.get('[');
  38549. case 0x5D:
  38550. this.nextChar();
  38551. return Cmd.get(']');
  38552. case 0x3C:
  38553. ch = this.nextChar();
  38554. if (ch === 0x3C) {
  38555. this.nextChar();
  38556. return Cmd.get('<<');
  38557. }
  38558. return this.getHexString();
  38559. case 0x3E:
  38560. ch = this.nextChar();
  38561. if (ch === 0x3E) {
  38562. this.nextChar();
  38563. return Cmd.get('>>');
  38564. }
  38565. return Cmd.get('>');
  38566. case 0x7B:
  38567. this.nextChar();
  38568. return Cmd.get('{');
  38569. case 0x7D:
  38570. this.nextChar();
  38571. return Cmd.get('}');
  38572. case 0x29:
  38573. error('Illegal character: ' + ch);
  38574. break;
  38575. }
  38576. var str = String.fromCharCode(ch);
  38577. var knownCommands = this.knownCommands;
  38578. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38579. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38580. var possibleCommand = str + String.fromCharCode(ch);
  38581. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38582. break;
  38583. }
  38584. if (str.length === 128) {
  38585. error('Command token too long: ' + str.length);
  38586. }
  38587. str = possibleCommand;
  38588. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38589. }
  38590. if (str === 'true') {
  38591. return true;
  38592. }
  38593. if (str === 'false') {
  38594. return false;
  38595. }
  38596. if (str === 'null') {
  38597. return null;
  38598. }
  38599. return Cmd.get(str);
  38600. },
  38601. skipToNextLine: function Lexer_skipToNextLine() {
  38602. var ch = this.currentChar;
  38603. while (ch >= 0) {
  38604. if (ch === 0x0D) {
  38605. ch = this.nextChar();
  38606. if (ch === 0x0A) {
  38607. this.nextChar();
  38608. }
  38609. break;
  38610. } else if (ch === 0x0A) {
  38611. this.nextChar();
  38612. break;
  38613. }
  38614. ch = this.nextChar();
  38615. }
  38616. }
  38617. };
  38618. return Lexer;
  38619. }();
  38620. var Linearization = {
  38621. create: function LinearizationCreate(stream) {
  38622. function getInt(name, allowZeroValue) {
  38623. var obj = linDict.get(name);
  38624. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38625. return obj;
  38626. }
  38627. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38628. }
  38629. function getHints() {
  38630. var hints = linDict.get('H'), hintsLength, item;
  38631. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38632. for (var index = 0; index < hintsLength; index++) {
  38633. if (!(isInt(item = hints[index]) && item > 0)) {
  38634. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38635. }
  38636. }
  38637. return hints;
  38638. }
  38639. throw new Error('Hint array in the linearization dictionary is invalid.');
  38640. }
  38641. var parser = new Parser(new Lexer(stream), false, null);
  38642. var obj1 = parser.getObj();
  38643. var obj2 = parser.getObj();
  38644. var obj3 = parser.getObj();
  38645. var linDict = parser.getObj();
  38646. var obj, length;
  38647. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38648. return null;
  38649. } else if ((length = getInt('L')) !== stream.length) {
  38650. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38651. }
  38652. return {
  38653. length: length,
  38654. hints: getHints(),
  38655. objectNumberFirst: getInt('O'),
  38656. endFirst: getInt('E'),
  38657. numPages: getInt('N'),
  38658. mainXRefEntriesOffset: getInt('T'),
  38659. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38660. };
  38661. }
  38662. };
  38663. exports.EOF = EOF;
  38664. exports.Lexer = Lexer;
  38665. exports.Linearization = Linearization;
  38666. exports.Parser = Parser;
  38667. exports.isEOF = isEOF;
  38668. }));
  38669. (function (root, factory) {
  38670. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38671. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38672. var warn = sharedUtil.warn;
  38673. var isSpace = sharedUtil.isSpace;
  38674. var Stream = coreStream.Stream;
  38675. var getEncoding = coreEncodings.getEncoding;
  38676. var HINTING_ENABLED = false;
  38677. var Type1CharString = function Type1CharStringClosure() {
  38678. var COMMAND_MAP = {
  38679. 'hstem': [1],
  38680. 'vstem': [3],
  38681. 'vmoveto': [4],
  38682. 'rlineto': [5],
  38683. 'hlineto': [6],
  38684. 'vlineto': [7],
  38685. 'rrcurveto': [8],
  38686. 'callsubr': [10],
  38687. 'flex': [
  38688. 12,
  38689. 35
  38690. ],
  38691. 'drop': [
  38692. 12,
  38693. 18
  38694. ],
  38695. 'endchar': [14],
  38696. 'rmoveto': [21],
  38697. 'hmoveto': [22],
  38698. 'vhcurveto': [30],
  38699. 'hvcurveto': [31]
  38700. };
  38701. function Type1CharString() {
  38702. this.width = 0;
  38703. this.lsb = 0;
  38704. this.flexing = false;
  38705. this.output = [];
  38706. this.stack = [];
  38707. }
  38708. Type1CharString.prototype = {
  38709. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38710. var count = encoded.length;
  38711. var error = false;
  38712. var wx, sbx, subrNumber;
  38713. for (var i = 0; i < count; i++) {
  38714. var value = encoded[i];
  38715. if (value < 32) {
  38716. if (value === 12) {
  38717. value = (value << 8) + encoded[++i];
  38718. }
  38719. switch (value) {
  38720. case 1:
  38721. if (!HINTING_ENABLED) {
  38722. this.stack = [];
  38723. break;
  38724. }
  38725. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38726. break;
  38727. case 3:
  38728. if (!HINTING_ENABLED) {
  38729. this.stack = [];
  38730. break;
  38731. }
  38732. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38733. break;
  38734. case 4:
  38735. if (this.flexing) {
  38736. if (this.stack.length < 1) {
  38737. error = true;
  38738. break;
  38739. }
  38740. var dy = this.stack.pop();
  38741. this.stack.push(0, dy);
  38742. break;
  38743. }
  38744. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38745. break;
  38746. case 5:
  38747. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38748. break;
  38749. case 6:
  38750. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38751. break;
  38752. case 7:
  38753. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38754. break;
  38755. case 8:
  38756. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38757. break;
  38758. case 9:
  38759. this.stack = [];
  38760. break;
  38761. case 10:
  38762. if (this.stack.length < 1) {
  38763. error = true;
  38764. break;
  38765. }
  38766. subrNumber = this.stack.pop();
  38767. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38768. break;
  38769. case 11:
  38770. return error;
  38771. case 13:
  38772. if (this.stack.length < 2) {
  38773. error = true;
  38774. break;
  38775. }
  38776. wx = this.stack.pop();
  38777. sbx = this.stack.pop();
  38778. this.lsb = sbx;
  38779. this.width = wx;
  38780. this.stack.push(wx, sbx);
  38781. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38782. break;
  38783. case 14:
  38784. this.output.push(COMMAND_MAP.endchar[0]);
  38785. break;
  38786. case 21:
  38787. if (this.flexing) {
  38788. break;
  38789. }
  38790. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38791. break;
  38792. case 22:
  38793. if (this.flexing) {
  38794. this.stack.push(0);
  38795. break;
  38796. }
  38797. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38798. break;
  38799. case 30:
  38800. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38801. break;
  38802. case 31:
  38803. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38804. break;
  38805. case (12 << 8) + 0:
  38806. this.stack = [];
  38807. break;
  38808. case (12 << 8) + 1:
  38809. if (!HINTING_ENABLED) {
  38810. this.stack = [];
  38811. break;
  38812. }
  38813. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38814. break;
  38815. case (12 << 8) + 2:
  38816. if (!HINTING_ENABLED) {
  38817. this.stack = [];
  38818. break;
  38819. }
  38820. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38821. break;
  38822. case (12 << 8) + 6:
  38823. if (seacAnalysisEnabled) {
  38824. this.seac = this.stack.splice(-4, 4);
  38825. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38826. } else {
  38827. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38828. }
  38829. break;
  38830. case (12 << 8) + 7:
  38831. if (this.stack.length < 4) {
  38832. error = true;
  38833. break;
  38834. }
  38835. var wy = this.stack.pop();
  38836. wx = this.stack.pop();
  38837. var sby = this.stack.pop();
  38838. sbx = this.stack.pop();
  38839. this.lsb = sbx;
  38840. this.width = wx;
  38841. this.stack.push(wx, sbx, sby);
  38842. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38843. break;
  38844. case (12 << 8) + 12:
  38845. if (this.stack.length < 2) {
  38846. error = true;
  38847. break;
  38848. }
  38849. var num2 = this.stack.pop();
  38850. var num1 = this.stack.pop();
  38851. this.stack.push(num1 / num2);
  38852. break;
  38853. case (12 << 8) + 16:
  38854. if (this.stack.length < 2) {
  38855. error = true;
  38856. break;
  38857. }
  38858. subrNumber = this.stack.pop();
  38859. var numArgs = this.stack.pop();
  38860. if (subrNumber === 0 && numArgs === 3) {
  38861. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38862. 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]);
  38863. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38864. this.flexing = false;
  38865. this.stack.push(flexArgs[15], flexArgs[16]);
  38866. } else if (subrNumber === 1 && numArgs === 0) {
  38867. this.flexing = true;
  38868. }
  38869. break;
  38870. case (12 << 8) + 17:
  38871. break;
  38872. case (12 << 8) + 33:
  38873. this.stack = [];
  38874. break;
  38875. default:
  38876. warn('Unknown type 1 charstring command of "' + value + '"');
  38877. break;
  38878. }
  38879. if (error) {
  38880. break;
  38881. }
  38882. continue;
  38883. } else if (value <= 246) {
  38884. value = value - 139;
  38885. } else if (value <= 250) {
  38886. value = (value - 247) * 256 + encoded[++i] + 108;
  38887. } else if (value <= 254) {
  38888. value = -((value - 251) * 256) - encoded[++i] - 108;
  38889. } else {
  38890. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38891. }
  38892. this.stack.push(value);
  38893. }
  38894. return error;
  38895. },
  38896. executeCommand: function (howManyArgs, command, keepStack) {
  38897. var stackLength = this.stack.length;
  38898. if (howManyArgs > stackLength) {
  38899. return true;
  38900. }
  38901. var start = stackLength - howManyArgs;
  38902. for (var i = start; i < stackLength; i++) {
  38903. var value = this.stack[i];
  38904. if (value === (value | 0)) {
  38905. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38906. } else {
  38907. value = 65536 * value | 0;
  38908. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38909. }
  38910. }
  38911. this.output.push.apply(this.output, command);
  38912. if (keepStack) {
  38913. this.stack.splice(start, howManyArgs);
  38914. } else {
  38915. this.stack.length = 0;
  38916. }
  38917. return false;
  38918. }
  38919. };
  38920. return Type1CharString;
  38921. }();
  38922. var Type1Parser = function Type1ParserClosure() {
  38923. var EEXEC_ENCRYPT_KEY = 55665;
  38924. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38925. function isHexDigit(code) {
  38926. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38927. }
  38928. function decrypt(data, key, discardNumber) {
  38929. if (discardNumber >= data.length) {
  38930. return new Uint8Array(0);
  38931. }
  38932. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38933. for (i = 0; i < discardNumber; i++) {
  38934. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38935. }
  38936. var count = data.length - discardNumber;
  38937. var decrypted = new Uint8Array(count);
  38938. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38939. var value = data[i];
  38940. decrypted[j] = value ^ r >> 8;
  38941. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38942. }
  38943. return decrypted;
  38944. }
  38945. function decryptAscii(data, key, discardNumber) {
  38946. var r = key | 0, c1 = 52845, c2 = 22719;
  38947. var count = data.length, maybeLength = count >>> 1;
  38948. var decrypted = new Uint8Array(maybeLength);
  38949. var i, j;
  38950. for (i = 0, j = 0; i < count; i++) {
  38951. var digit1 = data[i];
  38952. if (!isHexDigit(digit1)) {
  38953. continue;
  38954. }
  38955. i++;
  38956. var digit2;
  38957. while (i < count && !isHexDigit(digit2 = data[i])) {
  38958. i++;
  38959. }
  38960. if (i < count) {
  38961. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38962. decrypted[j++] = value ^ r >> 8;
  38963. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38964. }
  38965. }
  38966. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38967. }
  38968. function isSpecial(c) {
  38969. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38970. }
  38971. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38972. if (encrypted) {
  38973. var data = stream.getBytes();
  38974. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38975. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38976. }
  38977. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38978. this.stream = stream;
  38979. this.nextChar();
  38980. }
  38981. Type1Parser.prototype = {
  38982. readNumberArray: function Type1Parser_readNumberArray() {
  38983. this.getToken();
  38984. var array = [];
  38985. while (true) {
  38986. var token = this.getToken();
  38987. if (token === null || token === ']' || token === '}') {
  38988. break;
  38989. }
  38990. array.push(parseFloat(token || 0));
  38991. }
  38992. return array;
  38993. },
  38994. readNumber: function Type1Parser_readNumber() {
  38995. var token = this.getToken();
  38996. return parseFloat(token || 0);
  38997. },
  38998. readInt: function Type1Parser_readInt() {
  38999. var token = this.getToken();
  39000. return parseInt(token || 0, 10) | 0;
  39001. },
  39002. readBoolean: function Type1Parser_readBoolean() {
  39003. var token = this.getToken();
  39004. return token === 'true' ? 1 : 0;
  39005. },
  39006. nextChar: function Type1_nextChar() {
  39007. return this.currentChar = this.stream.getByte();
  39008. },
  39009. getToken: function Type1Parser_getToken() {
  39010. var comment = false;
  39011. var ch = this.currentChar;
  39012. while (true) {
  39013. if (ch === -1) {
  39014. return null;
  39015. }
  39016. if (comment) {
  39017. if (ch === 0x0A || ch === 0x0D) {
  39018. comment = false;
  39019. }
  39020. } else if (ch === 0x25) {
  39021. comment = true;
  39022. } else if (!isSpace(ch)) {
  39023. break;
  39024. }
  39025. ch = this.nextChar();
  39026. }
  39027. if (isSpecial(ch)) {
  39028. this.nextChar();
  39029. return String.fromCharCode(ch);
  39030. }
  39031. var token = '';
  39032. do {
  39033. token += String.fromCharCode(ch);
  39034. ch = this.nextChar();
  39035. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  39036. return token;
  39037. },
  39038. extractFontProgram: function Type1Parser_extractFontProgram() {
  39039. var stream = this.stream;
  39040. var subrs = [], charstrings = [];
  39041. var privateData = Object.create(null);
  39042. privateData['lenIV'] = 4;
  39043. var program = {
  39044. subrs: [],
  39045. charstrings: [],
  39046. properties: { 'privateData': privateData }
  39047. };
  39048. var token, length, data, lenIV, encoded;
  39049. while ((token = this.getToken()) !== null) {
  39050. if (token !== '/') {
  39051. continue;
  39052. }
  39053. token = this.getToken();
  39054. switch (token) {
  39055. case 'CharStrings':
  39056. this.getToken();
  39057. this.getToken();
  39058. this.getToken();
  39059. this.getToken();
  39060. while (true) {
  39061. token = this.getToken();
  39062. if (token === null || token === 'end') {
  39063. break;
  39064. }
  39065. if (token !== '/') {
  39066. continue;
  39067. }
  39068. var glyph = this.getToken();
  39069. length = this.readInt();
  39070. this.getToken();
  39071. data = stream.makeSubStream(stream.pos, length);
  39072. lenIV = program.properties.privateData['lenIV'];
  39073. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  39074. stream.skip(length);
  39075. this.nextChar();
  39076. token = this.getToken();
  39077. if (token === 'noaccess') {
  39078. this.getToken();
  39079. }
  39080. charstrings.push({
  39081. glyph: glyph,
  39082. encoded: encoded
  39083. });
  39084. }
  39085. break;
  39086. case 'Subrs':
  39087. var num = this.readInt();
  39088. this.getToken();
  39089. while ((token = this.getToken()) === 'dup') {
  39090. var index = this.readInt();
  39091. length = this.readInt();
  39092. this.getToken();
  39093. data = stream.makeSubStream(stream.pos, length);
  39094. lenIV = program.properties.privateData['lenIV'];
  39095. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  39096. stream.skip(length);
  39097. this.nextChar();
  39098. token = this.getToken();
  39099. if (token === 'noaccess') {
  39100. this.getToken();
  39101. }
  39102. subrs[index] = encoded;
  39103. }
  39104. break;
  39105. case 'BlueValues':
  39106. case 'OtherBlues':
  39107. case 'FamilyBlues':
  39108. case 'FamilyOtherBlues':
  39109. var blueArray = this.readNumberArray();
  39110. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  39111. program.properties.privateData[token] = blueArray;
  39112. }
  39113. break;
  39114. case 'StemSnapH':
  39115. case 'StemSnapV':
  39116. program.properties.privateData[token] = this.readNumberArray();
  39117. break;
  39118. case 'StdHW':
  39119. case 'StdVW':
  39120. program.properties.privateData[token] = this.readNumberArray()[0];
  39121. break;
  39122. case 'BlueShift':
  39123. case 'lenIV':
  39124. case 'BlueFuzz':
  39125. case 'BlueScale':
  39126. case 'LanguageGroup':
  39127. case 'ExpansionFactor':
  39128. program.properties.privateData[token] = this.readNumber();
  39129. break;
  39130. case 'ForceBold':
  39131. program.properties.privateData[token] = this.readBoolean();
  39132. break;
  39133. }
  39134. }
  39135. for (var i = 0; i < charstrings.length; i++) {
  39136. glyph = charstrings[i].glyph;
  39137. encoded = charstrings[i].encoded;
  39138. var charString = new Type1CharString();
  39139. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  39140. var output = charString.output;
  39141. if (error) {
  39142. output = [14];
  39143. }
  39144. program.charstrings.push({
  39145. glyphName: glyph,
  39146. charstring: output,
  39147. width: charString.width,
  39148. lsb: charString.lsb,
  39149. seac: charString.seac
  39150. });
  39151. }
  39152. return program;
  39153. },
  39154. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  39155. var token;
  39156. while ((token = this.getToken()) !== null) {
  39157. if (token !== '/') {
  39158. continue;
  39159. }
  39160. token = this.getToken();
  39161. switch (token) {
  39162. case 'FontMatrix':
  39163. var matrix = this.readNumberArray();
  39164. properties.fontMatrix = matrix;
  39165. break;
  39166. case 'Encoding':
  39167. var encodingArg = this.getToken();
  39168. var encoding;
  39169. if (!/^\d+$/.test(encodingArg)) {
  39170. encoding = getEncoding(encodingArg);
  39171. } else {
  39172. encoding = [];
  39173. var size = parseInt(encodingArg, 10) | 0;
  39174. this.getToken();
  39175. for (var j = 0; j < size; j++) {
  39176. token = this.getToken();
  39177. while (token !== 'dup' && token !== 'def') {
  39178. token = this.getToken();
  39179. if (token === null) {
  39180. return;
  39181. }
  39182. }
  39183. if (token === 'def') {
  39184. break;
  39185. }
  39186. var index = this.readInt();
  39187. this.getToken();
  39188. var glyph = this.getToken();
  39189. encoding[index] = glyph;
  39190. this.getToken();
  39191. }
  39192. }
  39193. properties.builtInEncoding = encoding;
  39194. break;
  39195. case 'FontBBox':
  39196. var fontBBox = this.readNumberArray();
  39197. properties.ascent = fontBBox[3];
  39198. properties.descent = fontBBox[1];
  39199. properties.ascentScaled = true;
  39200. break;
  39201. }
  39202. }
  39203. }
  39204. };
  39205. return Type1Parser;
  39206. }();
  39207. exports.Type1Parser = Type1Parser;
  39208. }));
  39209. (function (root, factory) {
  39210. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39211. }(this, function (exports, sharedUtil, displayWebGL) {
  39212. var Util = sharedUtil.Util;
  39213. var info = sharedUtil.info;
  39214. var isArray = sharedUtil.isArray;
  39215. var error = sharedUtil.error;
  39216. var WebGLUtils = displayWebGL.WebGLUtils;
  39217. var ShadingIRs = {};
  39218. ShadingIRs.RadialAxial = {
  39219. fromIR: function RadialAxial_fromIR(raw) {
  39220. var type = raw[1];
  39221. var colorStops = raw[2];
  39222. var p0 = raw[3];
  39223. var p1 = raw[4];
  39224. var r0 = raw[5];
  39225. var r1 = raw[6];
  39226. return {
  39227. type: 'Pattern',
  39228. getPattern: function RadialAxial_getPattern(ctx) {
  39229. var grad;
  39230. if (type === 'axial') {
  39231. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39232. } else if (type === 'radial') {
  39233. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39234. }
  39235. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39236. var c = colorStops[i];
  39237. grad.addColorStop(c[0], c[1]);
  39238. }
  39239. return grad;
  39240. }
  39241. };
  39242. }
  39243. };
  39244. var createMeshCanvas = function createMeshCanvasClosure() {
  39245. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39246. var coords = context.coords, colors = context.colors;
  39247. var bytes = data.data, rowSize = data.width * 4;
  39248. var tmp;
  39249. if (coords[p1 + 1] > coords[p2 + 1]) {
  39250. tmp = p1;
  39251. p1 = p2;
  39252. p2 = tmp;
  39253. tmp = c1;
  39254. c1 = c2;
  39255. c2 = tmp;
  39256. }
  39257. if (coords[p2 + 1] > coords[p3 + 1]) {
  39258. tmp = p2;
  39259. p2 = p3;
  39260. p3 = tmp;
  39261. tmp = c2;
  39262. c2 = c3;
  39263. c3 = tmp;
  39264. }
  39265. if (coords[p1 + 1] > coords[p2 + 1]) {
  39266. tmp = p1;
  39267. p1 = p2;
  39268. p2 = tmp;
  39269. tmp = c1;
  39270. c1 = c2;
  39271. c2 = tmp;
  39272. }
  39273. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39274. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39275. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39276. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39277. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39278. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39279. if (y1 >= y3) {
  39280. return;
  39281. }
  39282. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39283. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39284. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39285. var minY = Math.round(y1), maxY = Math.round(y3);
  39286. var xa, car, cag, cab;
  39287. var xb, cbr, cbg, cbb;
  39288. var k;
  39289. for (var y = minY; y <= maxY; y++) {
  39290. if (y < y2) {
  39291. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39292. xa = x1 - (x1 - x2) * k;
  39293. car = c1r - (c1r - c2r) * k;
  39294. cag = c1g - (c1g - c2g) * k;
  39295. cab = c1b - (c1b - c2b) * k;
  39296. } else {
  39297. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39298. xa = x2 - (x2 - x3) * k;
  39299. car = c2r - (c2r - c3r) * k;
  39300. cag = c2g - (c2g - c3g) * k;
  39301. cab = c2b - (c2b - c3b) * k;
  39302. }
  39303. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39304. xb = x1 - (x1 - x3) * k;
  39305. cbr = c1r - (c1r - c3r) * k;
  39306. cbg = c1g - (c1g - c3g) * k;
  39307. cbb = c1b - (c1b - c3b) * k;
  39308. var x1_ = Math.round(Math.min(xa, xb));
  39309. var x2_ = Math.round(Math.max(xa, xb));
  39310. var j = rowSize * y + x1_ * 4;
  39311. for (var x = x1_; x <= x2_; x++) {
  39312. k = (xa - x) / (xa - xb);
  39313. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39314. bytes[j++] = car - (car - cbr) * k | 0;
  39315. bytes[j++] = cag - (cag - cbg) * k | 0;
  39316. bytes[j++] = cab - (cab - cbb) * k | 0;
  39317. bytes[j++] = 255;
  39318. }
  39319. }
  39320. }
  39321. function drawFigure(data, figure, context) {
  39322. var ps = figure.coords;
  39323. var cs = figure.colors;
  39324. var i, ii;
  39325. switch (figure.type) {
  39326. case 'lattice':
  39327. var verticesPerRow = figure.verticesPerRow;
  39328. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39329. var cols = verticesPerRow - 1;
  39330. for (i = 0; i < rows; i++) {
  39331. var q = i * verticesPerRow;
  39332. for (var j = 0; j < cols; j++, q++) {
  39333. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39334. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39335. }
  39336. }
  39337. break;
  39338. case 'triangles':
  39339. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39340. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39341. }
  39342. break;
  39343. default:
  39344. error('illigal figure');
  39345. break;
  39346. }
  39347. }
  39348. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39349. var EXPECTED_SCALE = 1.1;
  39350. var MAX_PATTERN_SIZE = 3000;
  39351. var BORDER_SIZE = 2;
  39352. var offsetX = Math.floor(bounds[0]);
  39353. var offsetY = Math.floor(bounds[1]);
  39354. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39355. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39356. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39357. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39358. var scaleX = boundsWidth / width;
  39359. var scaleY = boundsHeight / height;
  39360. var context = {
  39361. coords: coords,
  39362. colors: colors,
  39363. offsetX: -offsetX,
  39364. offsetY: -offsetY,
  39365. scaleX: 1 / scaleX,
  39366. scaleY: 1 / scaleY
  39367. };
  39368. var paddedWidth = width + BORDER_SIZE * 2;
  39369. var paddedHeight = height + BORDER_SIZE * 2;
  39370. var canvas, tmpCanvas, i, ii;
  39371. if (WebGLUtils.isEnabled) {
  39372. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39373. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39374. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39375. canvas = tmpCanvas.canvas;
  39376. } else {
  39377. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39378. var tmpCtx = tmpCanvas.context;
  39379. var data = tmpCtx.createImageData(width, height);
  39380. if (backgroundColor) {
  39381. var bytes = data.data;
  39382. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39383. bytes[i] = backgroundColor[0];
  39384. bytes[i + 1] = backgroundColor[1];
  39385. bytes[i + 2] = backgroundColor[2];
  39386. bytes[i + 3] = 255;
  39387. }
  39388. }
  39389. for (i = 0; i < figures.length; i++) {
  39390. drawFigure(data, figures[i], context);
  39391. }
  39392. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39393. canvas = tmpCanvas.canvas;
  39394. }
  39395. return {
  39396. canvas: canvas,
  39397. offsetX: offsetX - BORDER_SIZE * scaleX,
  39398. offsetY: offsetY - BORDER_SIZE * scaleY,
  39399. scaleX: scaleX,
  39400. scaleY: scaleY
  39401. };
  39402. }
  39403. return createMeshCanvas;
  39404. }();
  39405. ShadingIRs.Mesh = {
  39406. fromIR: function Mesh_fromIR(raw) {
  39407. var coords = raw[2];
  39408. var colors = raw[3];
  39409. var figures = raw[4];
  39410. var bounds = raw[5];
  39411. var matrix = raw[6];
  39412. var background = raw[8];
  39413. return {
  39414. type: 'Pattern',
  39415. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39416. var scale;
  39417. if (shadingFill) {
  39418. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39419. } else {
  39420. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39421. if (matrix) {
  39422. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39423. scale = [
  39424. scale[0] * matrixScale[0],
  39425. scale[1] * matrixScale[1]
  39426. ];
  39427. }
  39428. }
  39429. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39430. if (!shadingFill) {
  39431. ctx.setTransform.apply(ctx, owner.baseTransform);
  39432. if (matrix) {
  39433. ctx.transform.apply(ctx, matrix);
  39434. }
  39435. }
  39436. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39437. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39438. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39439. }
  39440. };
  39441. }
  39442. };
  39443. ShadingIRs.Dummy = {
  39444. fromIR: function Dummy_fromIR() {
  39445. return {
  39446. type: 'Pattern',
  39447. getPattern: function Dummy_fromIR_getPattern() {
  39448. return 'hotpink';
  39449. }
  39450. };
  39451. }
  39452. };
  39453. function getShadingPatternFromIR(raw) {
  39454. var shadingIR = ShadingIRs[raw[0]];
  39455. if (!shadingIR) {
  39456. error('Unknown IR type: ' + raw[0]);
  39457. }
  39458. return shadingIR.fromIR(raw);
  39459. }
  39460. var TilingPattern = function TilingPatternClosure() {
  39461. var PaintType = {
  39462. COLORED: 1,
  39463. UNCOLORED: 2
  39464. };
  39465. var MAX_PATTERN_SIZE = 3000;
  39466. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39467. this.operatorList = IR[2];
  39468. this.matrix = IR[3] || [
  39469. 1,
  39470. 0,
  39471. 0,
  39472. 1,
  39473. 0,
  39474. 0
  39475. ];
  39476. this.bbox = IR[4];
  39477. this.xstep = IR[5];
  39478. this.ystep = IR[6];
  39479. this.paintType = IR[7];
  39480. this.tilingType = IR[8];
  39481. this.color = color;
  39482. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39483. this.baseTransform = baseTransform;
  39484. this.type = 'Pattern';
  39485. this.ctx = ctx;
  39486. }
  39487. TilingPattern.prototype = {
  39488. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39489. var operatorList = this.operatorList;
  39490. var bbox = this.bbox;
  39491. var xstep = this.xstep;
  39492. var ystep = this.ystep;
  39493. var paintType = this.paintType;
  39494. var tilingType = this.tilingType;
  39495. var color = this.color;
  39496. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39497. info('TilingType: ' + tilingType);
  39498. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39499. var topLeft = [
  39500. x0,
  39501. y0
  39502. ];
  39503. var botRight = [
  39504. x0 + xstep,
  39505. y0 + ystep
  39506. ];
  39507. var width = botRight[0] - topLeft[0];
  39508. var height = botRight[1] - topLeft[1];
  39509. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39510. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39511. var combinedScale = [
  39512. matrixScale[0] * curMatrixScale[0],
  39513. matrixScale[1] * curMatrixScale[1]
  39514. ];
  39515. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39516. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39517. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39518. var tmpCtx = tmpCanvas.context;
  39519. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39520. graphics.groupLevel = owner.groupLevel;
  39521. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39522. this.setScale(width, height, xstep, ystep);
  39523. this.transformToScale(graphics);
  39524. var tmpTranslate = [
  39525. 1,
  39526. 0,
  39527. 0,
  39528. 1,
  39529. -topLeft[0],
  39530. -topLeft[1]
  39531. ];
  39532. graphics.transform.apply(graphics, tmpTranslate);
  39533. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39534. graphics.executeOperatorList(operatorList);
  39535. return tmpCanvas.canvas;
  39536. },
  39537. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39538. this.scale = [
  39539. width / xstep,
  39540. height / ystep
  39541. ];
  39542. },
  39543. transformToScale: function TilingPattern_transformToScale(graphics) {
  39544. var scale = this.scale;
  39545. var tmpScale = [
  39546. scale[0],
  39547. 0,
  39548. 0,
  39549. scale[1],
  39550. 0,
  39551. 0
  39552. ];
  39553. graphics.transform.apply(graphics, tmpScale);
  39554. },
  39555. scaleToContext: function TilingPattern_scaleToContext() {
  39556. var scale = this.scale;
  39557. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39558. },
  39559. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39560. if (bbox && isArray(bbox) && bbox.length === 4) {
  39561. var bboxWidth = x1 - x0;
  39562. var bboxHeight = y1 - y0;
  39563. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39564. graphics.clip();
  39565. graphics.endPath();
  39566. }
  39567. },
  39568. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39569. switch (paintType) {
  39570. case PaintType.COLORED:
  39571. var ctx = this.ctx;
  39572. context.fillStyle = ctx.fillStyle;
  39573. context.strokeStyle = ctx.strokeStyle;
  39574. break;
  39575. case PaintType.UNCOLORED:
  39576. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39577. context.fillStyle = cssColor;
  39578. context.strokeStyle = cssColor;
  39579. break;
  39580. default:
  39581. error('Unsupported paint type: ' + paintType);
  39582. }
  39583. },
  39584. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39585. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39586. ctx = this.ctx;
  39587. ctx.setTransform.apply(ctx, this.baseTransform);
  39588. ctx.transform.apply(ctx, this.matrix);
  39589. this.scaleToContext();
  39590. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39591. }
  39592. };
  39593. return TilingPattern;
  39594. }();
  39595. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39596. exports.TilingPattern = TilingPattern;
  39597. }));
  39598. (function (root, factory) {
  39599. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39600. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39601. var Util = sharedUtil.Util;
  39602. var assert = sharedUtil.assert;
  39603. var warn = sharedUtil.warn;
  39604. var error = sharedUtil.error;
  39605. var isInt = sharedUtil.isInt;
  39606. var isString = sharedUtil.isString;
  39607. var MissingDataException = sharedUtil.MissingDataException;
  39608. var isName = corePrimitives.isName;
  39609. var isCmd = corePrimitives.isCmd;
  39610. var isStream = corePrimitives.isStream;
  39611. var StringStream = coreStream.StringStream;
  39612. var Lexer = coreParser.Lexer;
  39613. var isEOF = coreParser.isEOF;
  39614. var BUILT_IN_CMAPS = [
  39615. 'Adobe-GB1-UCS2',
  39616. 'Adobe-CNS1-UCS2',
  39617. 'Adobe-Japan1-UCS2',
  39618. 'Adobe-Korea1-UCS2',
  39619. '78-EUC-H',
  39620. '78-EUC-V',
  39621. '78-H',
  39622. '78-RKSJ-H',
  39623. '78-RKSJ-V',
  39624. '78-V',
  39625. '78ms-RKSJ-H',
  39626. '78ms-RKSJ-V',
  39627. '83pv-RKSJ-H',
  39628. '90ms-RKSJ-H',
  39629. '90ms-RKSJ-V',
  39630. '90msp-RKSJ-H',
  39631. '90msp-RKSJ-V',
  39632. '90pv-RKSJ-H',
  39633. '90pv-RKSJ-V',
  39634. 'Add-H',
  39635. 'Add-RKSJ-H',
  39636. 'Add-RKSJ-V',
  39637. 'Add-V',
  39638. 'Adobe-CNS1-0',
  39639. 'Adobe-CNS1-1',
  39640. 'Adobe-CNS1-2',
  39641. 'Adobe-CNS1-3',
  39642. 'Adobe-CNS1-4',
  39643. 'Adobe-CNS1-5',
  39644. 'Adobe-CNS1-6',
  39645. 'Adobe-GB1-0',
  39646. 'Adobe-GB1-1',
  39647. 'Adobe-GB1-2',
  39648. 'Adobe-GB1-3',
  39649. 'Adobe-GB1-4',
  39650. 'Adobe-GB1-5',
  39651. 'Adobe-Japan1-0',
  39652. 'Adobe-Japan1-1',
  39653. 'Adobe-Japan1-2',
  39654. 'Adobe-Japan1-3',
  39655. 'Adobe-Japan1-4',
  39656. 'Adobe-Japan1-5',
  39657. 'Adobe-Japan1-6',
  39658. 'Adobe-Korea1-0',
  39659. 'Adobe-Korea1-1',
  39660. 'Adobe-Korea1-2',
  39661. 'B5-H',
  39662. 'B5-V',
  39663. 'B5pc-H',
  39664. 'B5pc-V',
  39665. 'CNS-EUC-H',
  39666. 'CNS-EUC-V',
  39667. 'CNS1-H',
  39668. 'CNS1-V',
  39669. 'CNS2-H',
  39670. 'CNS2-V',
  39671. 'ETHK-B5-H',
  39672. 'ETHK-B5-V',
  39673. 'ETen-B5-H',
  39674. 'ETen-B5-V',
  39675. 'ETenms-B5-H',
  39676. 'ETenms-B5-V',
  39677. 'EUC-H',
  39678. 'EUC-V',
  39679. 'Ext-H',
  39680. 'Ext-RKSJ-H',
  39681. 'Ext-RKSJ-V',
  39682. 'Ext-V',
  39683. 'GB-EUC-H',
  39684. 'GB-EUC-V',
  39685. 'GB-H',
  39686. 'GB-V',
  39687. 'GBK-EUC-H',
  39688. 'GBK-EUC-V',
  39689. 'GBK2K-H',
  39690. 'GBK2K-V',
  39691. 'GBKp-EUC-H',
  39692. 'GBKp-EUC-V',
  39693. 'GBT-EUC-H',
  39694. 'GBT-EUC-V',
  39695. 'GBT-H',
  39696. 'GBT-V',
  39697. 'GBTpc-EUC-H',
  39698. 'GBTpc-EUC-V',
  39699. 'GBpc-EUC-H',
  39700. 'GBpc-EUC-V',
  39701. 'H',
  39702. 'HKdla-B5-H',
  39703. 'HKdla-B5-V',
  39704. 'HKdlb-B5-H',
  39705. 'HKdlb-B5-V',
  39706. 'HKgccs-B5-H',
  39707. 'HKgccs-B5-V',
  39708. 'HKm314-B5-H',
  39709. 'HKm314-B5-V',
  39710. 'HKm471-B5-H',
  39711. 'HKm471-B5-V',
  39712. 'HKscs-B5-H',
  39713. 'HKscs-B5-V',
  39714. 'Hankaku',
  39715. 'Hiragana',
  39716. 'KSC-EUC-H',
  39717. 'KSC-EUC-V',
  39718. 'KSC-H',
  39719. 'KSC-Johab-H',
  39720. 'KSC-Johab-V',
  39721. 'KSC-V',
  39722. 'KSCms-UHC-H',
  39723. 'KSCms-UHC-HW-H',
  39724. 'KSCms-UHC-HW-V',
  39725. 'KSCms-UHC-V',
  39726. 'KSCpc-EUC-H',
  39727. 'KSCpc-EUC-V',
  39728. 'Katakana',
  39729. 'NWP-H',
  39730. 'NWP-V',
  39731. 'RKSJ-H',
  39732. 'RKSJ-V',
  39733. 'Roman',
  39734. 'UniCNS-UCS2-H',
  39735. 'UniCNS-UCS2-V',
  39736. 'UniCNS-UTF16-H',
  39737. 'UniCNS-UTF16-V',
  39738. 'UniCNS-UTF32-H',
  39739. 'UniCNS-UTF32-V',
  39740. 'UniCNS-UTF8-H',
  39741. 'UniCNS-UTF8-V',
  39742. 'UniGB-UCS2-H',
  39743. 'UniGB-UCS2-V',
  39744. 'UniGB-UTF16-H',
  39745. 'UniGB-UTF16-V',
  39746. 'UniGB-UTF32-H',
  39747. 'UniGB-UTF32-V',
  39748. 'UniGB-UTF8-H',
  39749. 'UniGB-UTF8-V',
  39750. 'UniJIS-UCS2-H',
  39751. 'UniJIS-UCS2-HW-H',
  39752. 'UniJIS-UCS2-HW-V',
  39753. 'UniJIS-UCS2-V',
  39754. 'UniJIS-UTF16-H',
  39755. 'UniJIS-UTF16-V',
  39756. 'UniJIS-UTF32-H',
  39757. 'UniJIS-UTF32-V',
  39758. 'UniJIS-UTF8-H',
  39759. 'UniJIS-UTF8-V',
  39760. 'UniJIS2004-UTF16-H',
  39761. 'UniJIS2004-UTF16-V',
  39762. 'UniJIS2004-UTF32-H',
  39763. 'UniJIS2004-UTF32-V',
  39764. 'UniJIS2004-UTF8-H',
  39765. 'UniJIS2004-UTF8-V',
  39766. 'UniJISPro-UCS2-HW-V',
  39767. 'UniJISPro-UCS2-V',
  39768. 'UniJISPro-UTF8-V',
  39769. 'UniJISX0213-UTF32-H',
  39770. 'UniJISX0213-UTF32-V',
  39771. 'UniJISX02132004-UTF32-H',
  39772. 'UniJISX02132004-UTF32-V',
  39773. 'UniKS-UCS2-H',
  39774. 'UniKS-UCS2-V',
  39775. 'UniKS-UTF16-H',
  39776. 'UniKS-UTF16-V',
  39777. 'UniKS-UTF32-H',
  39778. 'UniKS-UTF32-V',
  39779. 'UniKS-UTF8-H',
  39780. 'UniKS-UTF8-V',
  39781. 'V',
  39782. 'WP-Symbol'
  39783. ];
  39784. var CMap = function CMapClosure() {
  39785. function CMap(builtInCMap) {
  39786. this.codespaceRanges = [
  39787. [],
  39788. [],
  39789. [],
  39790. []
  39791. ];
  39792. this.numCodespaceRanges = 0;
  39793. this._map = [];
  39794. this.name = '';
  39795. this.vertical = false;
  39796. this.useCMap = null;
  39797. this.builtInCMap = builtInCMap;
  39798. }
  39799. CMap.prototype = {
  39800. addCodespaceRange: function (n, low, high) {
  39801. this.codespaceRanges[n - 1].push(low, high);
  39802. this.numCodespaceRanges++;
  39803. },
  39804. mapCidRange: function (low, high, dstLow) {
  39805. while (low <= high) {
  39806. this._map[low++] = dstLow++;
  39807. }
  39808. },
  39809. mapBfRange: function (low, high, dstLow) {
  39810. var lastByte = dstLow.length - 1;
  39811. while (low <= high) {
  39812. this._map[low++] = dstLow;
  39813. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39814. }
  39815. },
  39816. mapBfRangeToArray: function (low, high, array) {
  39817. var i = 0, ii = array.length;
  39818. while (low <= high && i < ii) {
  39819. this._map[low] = array[i++];
  39820. ++low;
  39821. }
  39822. },
  39823. mapOne: function (src, dst) {
  39824. this._map[src] = dst;
  39825. },
  39826. lookup: function (code) {
  39827. return this._map[code];
  39828. },
  39829. contains: function (code) {
  39830. return this._map[code] !== undefined;
  39831. },
  39832. forEach: function (callback) {
  39833. var map = this._map;
  39834. var length = map.length;
  39835. var i;
  39836. if (length <= 0x10000) {
  39837. for (i = 0; i < length; i++) {
  39838. if (map[i] !== undefined) {
  39839. callback(i, map[i]);
  39840. }
  39841. }
  39842. } else {
  39843. for (i in this._map) {
  39844. callback(i, map[i]);
  39845. }
  39846. }
  39847. },
  39848. charCodeOf: function (value) {
  39849. return this._map.indexOf(value);
  39850. },
  39851. getMap: function () {
  39852. return this._map;
  39853. },
  39854. readCharCode: function (str, offset, out) {
  39855. var c = 0;
  39856. var codespaceRanges = this.codespaceRanges;
  39857. var codespaceRangesLen = this.codespaceRanges.length;
  39858. for (var n = 0; n < codespaceRangesLen; n++) {
  39859. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39860. var codespaceRange = codespaceRanges[n];
  39861. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39862. var low = codespaceRange[k++];
  39863. var high = codespaceRange[k++];
  39864. if (c >= low && c <= high) {
  39865. out.charcode = c;
  39866. out.length = n + 1;
  39867. return;
  39868. }
  39869. }
  39870. }
  39871. out.charcode = 0;
  39872. out.length = 1;
  39873. },
  39874. get length() {
  39875. return this._map.length;
  39876. },
  39877. get isIdentityCMap() {
  39878. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39879. return false;
  39880. }
  39881. if (this._map.length !== 0x10000) {
  39882. return false;
  39883. }
  39884. for (var i = 0; i < 0x10000; i++) {
  39885. if (this._map[i] !== i) {
  39886. return false;
  39887. }
  39888. }
  39889. return true;
  39890. }
  39891. };
  39892. return CMap;
  39893. }();
  39894. var IdentityCMap = function IdentityCMapClosure() {
  39895. function IdentityCMap(vertical, n) {
  39896. CMap.call(this);
  39897. this.vertical = vertical;
  39898. this.addCodespaceRange(n, 0, 0xffff);
  39899. }
  39900. Util.inherit(IdentityCMap, CMap, {});
  39901. IdentityCMap.prototype = {
  39902. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39903. mapCidRange: function (low, high, dstLow) {
  39904. error('should not call mapCidRange');
  39905. },
  39906. mapBfRange: function (low, high, dstLow) {
  39907. error('should not call mapBfRange');
  39908. },
  39909. mapBfRangeToArray: function (low, high, array) {
  39910. error('should not call mapBfRangeToArray');
  39911. },
  39912. mapOne: function (src, dst) {
  39913. error('should not call mapCidOne');
  39914. },
  39915. lookup: function (code) {
  39916. return isInt(code) && code <= 0xffff ? code : undefined;
  39917. },
  39918. contains: function (code) {
  39919. return isInt(code) && code <= 0xffff;
  39920. },
  39921. forEach: function (callback) {
  39922. for (var i = 0; i <= 0xffff; i++) {
  39923. callback(i, i);
  39924. }
  39925. },
  39926. charCodeOf: function (value) {
  39927. return isInt(value) && value <= 0xffff ? value : -1;
  39928. },
  39929. getMap: function () {
  39930. var map = new Array(0x10000);
  39931. for (var i = 0; i <= 0xffff; i++) {
  39932. map[i] = i;
  39933. }
  39934. return map;
  39935. },
  39936. readCharCode: CMap.prototype.readCharCode,
  39937. get length() {
  39938. return 0x10000;
  39939. },
  39940. get isIdentityCMap() {
  39941. error('should not access .isIdentityCMap');
  39942. }
  39943. };
  39944. return IdentityCMap;
  39945. }();
  39946. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39947. function fetchBinaryData(url) {
  39948. return new Promise(function (resolve, reject) {
  39949. var request = new XMLHttpRequest();
  39950. request.open('GET', url, true);
  39951. request.responseType = 'arraybuffer';
  39952. request.onreadystatechange = function () {
  39953. if (request.readyState === XMLHttpRequest.DONE) {
  39954. if (!request.response || request.status !== 200 && request.status !== 0) {
  39955. reject(new Error('Unable to get binary cMap at: ' + url));
  39956. } else {
  39957. resolve(new Uint8Array(request.response));
  39958. }
  39959. }
  39960. };
  39961. request.send(null);
  39962. });
  39963. }
  39964. function hexToInt(a, size) {
  39965. var n = 0;
  39966. for (var i = 0; i <= size; i++) {
  39967. n = n << 8 | a[i];
  39968. }
  39969. return n >>> 0;
  39970. }
  39971. function hexToStr(a, size) {
  39972. if (size === 1) {
  39973. return String.fromCharCode(a[0], a[1]);
  39974. }
  39975. if (size === 3) {
  39976. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39977. }
  39978. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39979. }
  39980. function addHex(a, b, size) {
  39981. var c = 0;
  39982. for (var i = size; i >= 0; i--) {
  39983. c += a[i] + b[i];
  39984. a[i] = c & 255;
  39985. c >>= 8;
  39986. }
  39987. }
  39988. function incHex(a, size) {
  39989. var c = 1;
  39990. for (var i = size; i >= 0 && c > 0; i--) {
  39991. c += a[i];
  39992. a[i] = c & 255;
  39993. c >>= 8;
  39994. }
  39995. }
  39996. var MAX_NUM_SIZE = 16;
  39997. var MAX_ENCODED_NUM_SIZE = 19;
  39998. function BinaryCMapStream(data) {
  39999. this.buffer = data;
  40000. this.pos = 0;
  40001. this.end = data.length;
  40002. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  40003. }
  40004. BinaryCMapStream.prototype = {
  40005. readByte: function () {
  40006. if (this.pos >= this.end) {
  40007. return -1;
  40008. }
  40009. return this.buffer[this.pos++];
  40010. },
  40011. readNumber: function () {
  40012. var n = 0;
  40013. var last;
  40014. do {
  40015. var b = this.readByte();
  40016. if (b < 0) {
  40017. error('unexpected EOF in bcmap');
  40018. }
  40019. last = !(b & 0x80);
  40020. n = n << 7 | b & 0x7F;
  40021. } while (!last);
  40022. return n;
  40023. },
  40024. readSigned: function () {
  40025. var n = this.readNumber();
  40026. return n & 1 ? ~(n >>> 1) : n >>> 1;
  40027. },
  40028. readHex: function (num, size) {
  40029. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  40030. this.pos += size + 1;
  40031. },
  40032. readHexNumber: function (num, size) {
  40033. var last;
  40034. var stack = this.tmpBuf, sp = 0;
  40035. do {
  40036. var b = this.readByte();
  40037. if (b < 0) {
  40038. error('unexpected EOF in bcmap');
  40039. }
  40040. last = !(b & 0x80);
  40041. stack[sp++] = b & 0x7F;
  40042. } while (!last);
  40043. var i = size, buffer = 0, bufferSize = 0;
  40044. while (i >= 0) {
  40045. while (bufferSize < 8 && stack.length > 0) {
  40046. buffer = stack[--sp] << bufferSize | buffer;
  40047. bufferSize += 7;
  40048. }
  40049. num[i] = buffer & 255;
  40050. i--;
  40051. buffer >>= 8;
  40052. bufferSize -= 8;
  40053. }
  40054. },
  40055. readHexSigned: function (num, size) {
  40056. this.readHexNumber(num, size);
  40057. var sign = num[size] & 1 ? 255 : 0;
  40058. var c = 0;
  40059. for (var i = 0; i <= size; i++) {
  40060. c = (c & 1) << 8 | num[i];
  40061. num[i] = c >> 1 ^ sign;
  40062. }
  40063. },
  40064. readString: function () {
  40065. var len = this.readNumber();
  40066. var s = '';
  40067. for (var i = 0; i < len; i++) {
  40068. s += String.fromCharCode(this.readNumber());
  40069. }
  40070. return s;
  40071. }
  40072. };
  40073. function processBinaryCMap(url, cMap, extend) {
  40074. return fetchBinaryData(url).then(function (data) {
  40075. var stream = new BinaryCMapStream(data);
  40076. var header = stream.readByte();
  40077. cMap.vertical = !!(header & 1);
  40078. var useCMap = null;
  40079. var start = new Uint8Array(MAX_NUM_SIZE);
  40080. var end = new Uint8Array(MAX_NUM_SIZE);
  40081. var char = new Uint8Array(MAX_NUM_SIZE);
  40082. var charCode = new Uint8Array(MAX_NUM_SIZE);
  40083. var tmp = new Uint8Array(MAX_NUM_SIZE);
  40084. var code;
  40085. var b;
  40086. while ((b = stream.readByte()) >= 0) {
  40087. var type = b >> 5;
  40088. if (type === 7) {
  40089. switch (b & 0x1F) {
  40090. case 0:
  40091. stream.readString();
  40092. break;
  40093. case 1:
  40094. useCMap = stream.readString();
  40095. break;
  40096. }
  40097. continue;
  40098. }
  40099. var sequence = !!(b & 0x10);
  40100. var dataSize = b & 15;
  40101. assert(dataSize + 1 <= MAX_NUM_SIZE);
  40102. var ucs2DataSize = 1;
  40103. var subitemsCount = stream.readNumber();
  40104. var i;
  40105. switch (type) {
  40106. case 0:
  40107. stream.readHex(start, dataSize);
  40108. stream.readHexNumber(end, dataSize);
  40109. addHex(end, start, dataSize);
  40110. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  40111. for (i = 1; i < subitemsCount; i++) {
  40112. incHex(end, dataSize);
  40113. stream.readHexNumber(start, dataSize);
  40114. addHex(start, end, dataSize);
  40115. stream.readHexNumber(end, dataSize);
  40116. addHex(end, start, dataSize);
  40117. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  40118. }
  40119. break;
  40120. case 1:
  40121. stream.readHex(start, dataSize);
  40122. stream.readHexNumber(end, dataSize);
  40123. addHex(end, start, dataSize);
  40124. code = stream.readNumber();
  40125. for (i = 1; i < subitemsCount; i++) {
  40126. incHex(end, dataSize);
  40127. stream.readHexNumber(start, dataSize);
  40128. addHex(start, end, dataSize);
  40129. stream.readHexNumber(end, dataSize);
  40130. addHex(end, start, dataSize);
  40131. code = stream.readNumber();
  40132. }
  40133. break;
  40134. case 2:
  40135. stream.readHex(char, dataSize);
  40136. code = stream.readNumber();
  40137. cMap.mapOne(hexToInt(char, dataSize), code);
  40138. for (i = 1; i < subitemsCount; i++) {
  40139. incHex(char, dataSize);
  40140. if (!sequence) {
  40141. stream.readHexNumber(tmp, dataSize);
  40142. addHex(char, tmp, dataSize);
  40143. }
  40144. code = stream.readSigned() + (code + 1);
  40145. cMap.mapOne(hexToInt(char, dataSize), code);
  40146. }
  40147. break;
  40148. case 3:
  40149. stream.readHex(start, dataSize);
  40150. stream.readHexNumber(end, dataSize);
  40151. addHex(end, start, dataSize);
  40152. code = stream.readNumber();
  40153. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  40154. for (i = 1; i < subitemsCount; i++) {
  40155. incHex(end, dataSize);
  40156. if (!sequence) {
  40157. stream.readHexNumber(start, dataSize);
  40158. addHex(start, end, dataSize);
  40159. } else {
  40160. start.set(end);
  40161. }
  40162. stream.readHexNumber(end, dataSize);
  40163. addHex(end, start, dataSize);
  40164. code = stream.readNumber();
  40165. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  40166. }
  40167. break;
  40168. case 4:
  40169. stream.readHex(char, ucs2DataSize);
  40170. stream.readHex(charCode, dataSize);
  40171. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40172. for (i = 1; i < subitemsCount; i++) {
  40173. incHex(char, ucs2DataSize);
  40174. if (!sequence) {
  40175. stream.readHexNumber(tmp, ucs2DataSize);
  40176. addHex(char, tmp, ucs2DataSize);
  40177. }
  40178. incHex(charCode, dataSize);
  40179. stream.readHexSigned(tmp, dataSize);
  40180. addHex(charCode, tmp, dataSize);
  40181. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40182. }
  40183. break;
  40184. case 5:
  40185. stream.readHex(start, ucs2DataSize);
  40186. stream.readHexNumber(end, ucs2DataSize);
  40187. addHex(end, start, ucs2DataSize);
  40188. stream.readHex(charCode, dataSize);
  40189. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40190. for (i = 1; i < subitemsCount; i++) {
  40191. incHex(end, ucs2DataSize);
  40192. if (!sequence) {
  40193. stream.readHexNumber(start, ucs2DataSize);
  40194. addHex(start, end, ucs2DataSize);
  40195. } else {
  40196. start.set(end);
  40197. }
  40198. stream.readHexNumber(end, ucs2DataSize);
  40199. addHex(end, start, ucs2DataSize);
  40200. stream.readHex(charCode, dataSize);
  40201. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40202. }
  40203. break;
  40204. default:
  40205. error('Unknown type: ' + type);
  40206. break;
  40207. }
  40208. }
  40209. if (useCMap) {
  40210. return extend(useCMap);
  40211. }
  40212. return cMap;
  40213. });
  40214. }
  40215. function BinaryCMapReader() {
  40216. }
  40217. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40218. return BinaryCMapReader;
  40219. }();
  40220. var CMapFactory = function CMapFactoryClosure() {
  40221. function strToInt(str) {
  40222. var a = 0;
  40223. for (var i = 0; i < str.length; i++) {
  40224. a = a << 8 | str.charCodeAt(i);
  40225. }
  40226. return a >>> 0;
  40227. }
  40228. function expectString(obj) {
  40229. if (!isString(obj)) {
  40230. error('Malformed CMap: expected string.');
  40231. }
  40232. }
  40233. function expectInt(obj) {
  40234. if (!isInt(obj)) {
  40235. error('Malformed CMap: expected int.');
  40236. }
  40237. }
  40238. function parseBfChar(cMap, lexer) {
  40239. while (true) {
  40240. var obj = lexer.getObj();
  40241. if (isEOF(obj)) {
  40242. break;
  40243. }
  40244. if (isCmd(obj, 'endbfchar')) {
  40245. return;
  40246. }
  40247. expectString(obj);
  40248. var src = strToInt(obj);
  40249. obj = lexer.getObj();
  40250. expectString(obj);
  40251. var dst = obj;
  40252. cMap.mapOne(src, dst);
  40253. }
  40254. }
  40255. function parseBfRange(cMap, lexer) {
  40256. while (true) {
  40257. var obj = lexer.getObj();
  40258. if (isEOF(obj)) {
  40259. break;
  40260. }
  40261. if (isCmd(obj, 'endbfrange')) {
  40262. return;
  40263. }
  40264. expectString(obj);
  40265. var low = strToInt(obj);
  40266. obj = lexer.getObj();
  40267. expectString(obj);
  40268. var high = strToInt(obj);
  40269. obj = lexer.getObj();
  40270. if (isInt(obj) || isString(obj)) {
  40271. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40272. cMap.mapBfRange(low, high, dstLow);
  40273. } else if (isCmd(obj, '[')) {
  40274. obj = lexer.getObj();
  40275. var array = [];
  40276. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40277. array.push(obj);
  40278. obj = lexer.getObj();
  40279. }
  40280. cMap.mapBfRangeToArray(low, high, array);
  40281. } else {
  40282. break;
  40283. }
  40284. }
  40285. error('Invalid bf range.');
  40286. }
  40287. function parseCidChar(cMap, lexer) {
  40288. while (true) {
  40289. var obj = lexer.getObj();
  40290. if (isEOF(obj)) {
  40291. break;
  40292. }
  40293. if (isCmd(obj, 'endcidchar')) {
  40294. return;
  40295. }
  40296. expectString(obj);
  40297. var src = strToInt(obj);
  40298. obj = lexer.getObj();
  40299. expectInt(obj);
  40300. var dst = obj;
  40301. cMap.mapOne(src, dst);
  40302. }
  40303. }
  40304. function parseCidRange(cMap, lexer) {
  40305. while (true) {
  40306. var obj = lexer.getObj();
  40307. if (isEOF(obj)) {
  40308. break;
  40309. }
  40310. if (isCmd(obj, 'endcidrange')) {
  40311. return;
  40312. }
  40313. expectString(obj);
  40314. var low = strToInt(obj);
  40315. obj = lexer.getObj();
  40316. expectString(obj);
  40317. var high = strToInt(obj);
  40318. obj = lexer.getObj();
  40319. expectInt(obj);
  40320. var dstLow = obj;
  40321. cMap.mapCidRange(low, high, dstLow);
  40322. }
  40323. }
  40324. function parseCodespaceRange(cMap, lexer) {
  40325. while (true) {
  40326. var obj = lexer.getObj();
  40327. if (isEOF(obj)) {
  40328. break;
  40329. }
  40330. if (isCmd(obj, 'endcodespacerange')) {
  40331. return;
  40332. }
  40333. if (!isString(obj)) {
  40334. break;
  40335. }
  40336. var low = strToInt(obj);
  40337. obj = lexer.getObj();
  40338. if (!isString(obj)) {
  40339. break;
  40340. }
  40341. var high = strToInt(obj);
  40342. cMap.addCodespaceRange(obj.length, low, high);
  40343. }
  40344. error('Invalid codespace range.');
  40345. }
  40346. function parseWMode(cMap, lexer) {
  40347. var obj = lexer.getObj();
  40348. if (isInt(obj)) {
  40349. cMap.vertical = !!obj;
  40350. }
  40351. }
  40352. function parseCMapName(cMap, lexer) {
  40353. var obj = lexer.getObj();
  40354. if (isName(obj) && isString(obj.name)) {
  40355. cMap.name = obj.name;
  40356. }
  40357. }
  40358. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40359. var previous;
  40360. var embededUseCMap;
  40361. objLoop:
  40362. while (true) {
  40363. try {
  40364. var obj = lexer.getObj();
  40365. if (isEOF(obj)) {
  40366. break;
  40367. } else if (isName(obj)) {
  40368. if (obj.name === 'WMode') {
  40369. parseWMode(cMap, lexer);
  40370. } else if (obj.name === 'CMapName') {
  40371. parseCMapName(cMap, lexer);
  40372. }
  40373. previous = obj;
  40374. } else if (isCmd(obj)) {
  40375. switch (obj.cmd) {
  40376. case 'endcmap':
  40377. break objLoop;
  40378. case 'usecmap':
  40379. if (isName(previous)) {
  40380. embededUseCMap = previous.name;
  40381. }
  40382. break;
  40383. case 'begincodespacerange':
  40384. parseCodespaceRange(cMap, lexer);
  40385. break;
  40386. case 'beginbfchar':
  40387. parseBfChar(cMap, lexer);
  40388. break;
  40389. case 'begincidchar':
  40390. parseCidChar(cMap, lexer);
  40391. break;
  40392. case 'beginbfrange':
  40393. parseBfRange(cMap, lexer);
  40394. break;
  40395. case 'begincidrange':
  40396. parseCidRange(cMap, lexer);
  40397. break;
  40398. }
  40399. }
  40400. } catch (ex) {
  40401. if (ex instanceof MissingDataException) {
  40402. throw ex;
  40403. }
  40404. warn('Invalid cMap data: ' + ex);
  40405. continue;
  40406. }
  40407. }
  40408. if (!useCMap && embededUseCMap) {
  40409. useCMap = embededUseCMap;
  40410. }
  40411. if (useCMap) {
  40412. return extendCMap(cMap, builtInCMapParams, useCMap);
  40413. }
  40414. return Promise.resolve(cMap);
  40415. }
  40416. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40417. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40418. cMap.useCMap = newCMap;
  40419. if (cMap.numCodespaceRanges === 0) {
  40420. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40421. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40422. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40423. }
  40424. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40425. }
  40426. cMap.useCMap.forEach(function (key, value) {
  40427. if (!cMap.contains(key)) {
  40428. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40429. }
  40430. });
  40431. return cMap;
  40432. });
  40433. }
  40434. function parseBinaryCMap(name, builtInCMapParams) {
  40435. var url = builtInCMapParams.url + name + '.bcmap';
  40436. var cMap = new CMap(true);
  40437. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40438. return extendCMap(cMap, builtInCMapParams, useCMap);
  40439. });
  40440. }
  40441. function createBuiltInCMap(name, builtInCMapParams) {
  40442. if (name === 'Identity-H') {
  40443. return Promise.resolve(new IdentityCMap(false, 2));
  40444. } else if (name === 'Identity-V') {
  40445. return Promise.resolve(new IdentityCMap(true, 2));
  40446. }
  40447. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40448. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40449. }
  40450. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40451. if (builtInCMapParams.packed) {
  40452. return parseBinaryCMap(name, builtInCMapParams);
  40453. }
  40454. return new Promise(function (resolve, reject) {
  40455. var url = builtInCMapParams.url + name;
  40456. var request = new XMLHttpRequest();
  40457. request.onreadystatechange = function () {
  40458. if (request.readyState === XMLHttpRequest.DONE) {
  40459. if (request.status === 200 || request.status === 0) {
  40460. var cMap = new CMap(true);
  40461. var lexer = new Lexer(new StringStream(request.responseText));
  40462. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40463. resolve(parsedCMap);
  40464. });
  40465. } else {
  40466. reject(new Error('Unable to get cMap at: ' + url));
  40467. }
  40468. }
  40469. };
  40470. request.open('GET', url, true);
  40471. request.send(null);
  40472. });
  40473. }
  40474. return {
  40475. create: function (encoding, builtInCMapParams, useCMap) {
  40476. if (isName(encoding)) {
  40477. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40478. } else if (isStream(encoding)) {
  40479. var cMap = new CMap();
  40480. var lexer = new Lexer(encoding);
  40481. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40482. if (parsedCMap.isIdentityCMap) {
  40483. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40484. }
  40485. return parsedCMap;
  40486. });
  40487. }
  40488. return Promise.reject(new Error('Encoding required.'));
  40489. }
  40490. };
  40491. }();
  40492. exports.CMap = CMap;
  40493. exports.CMapFactory = CMapFactory;
  40494. exports.IdentityCMap = IdentityCMap;
  40495. }));
  40496. (function (root, factory) {
  40497. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40498. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40499. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40500. var FontType = sharedUtil.FontType;
  40501. var assert = sharedUtil.assert;
  40502. var bytesToString = sharedUtil.bytesToString;
  40503. var error = sharedUtil.error;
  40504. var info = sharedUtil.info;
  40505. var isArray = sharedUtil.isArray;
  40506. var isInt = sharedUtil.isInt;
  40507. var isNum = sharedUtil.isNum;
  40508. var readUint32 = sharedUtil.readUint32;
  40509. var shadow = sharedUtil.shadow;
  40510. var string32 = sharedUtil.string32;
  40511. var warn = sharedUtil.warn;
  40512. var MissingDataException = sharedUtil.MissingDataException;
  40513. var isSpace = sharedUtil.isSpace;
  40514. var Stream = coreStream.Stream;
  40515. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40516. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40517. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40518. var StandardEncoding = coreEncodings.StandardEncoding;
  40519. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40520. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40521. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40522. var getEncoding = coreEncodings.getEncoding;
  40523. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40524. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40525. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40526. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40527. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40528. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40529. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40530. var Type1Parser = coreType1Parser.Type1Parser;
  40531. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40532. var CFFParser = coreCFFParser.CFFParser;
  40533. var CFFCompiler = coreCFFParser.CFFCompiler;
  40534. var CFF = coreCFFParser.CFF;
  40535. var CFFHeader = coreCFFParser.CFFHeader;
  40536. var CFFTopDict = coreCFFParser.CFFTopDict;
  40537. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40538. var CFFStrings = coreCFFParser.CFFStrings;
  40539. var CFFIndex = coreCFFParser.CFFIndex;
  40540. var CFFCharset = coreCFFParser.CFFCharset;
  40541. var PRIVATE_USE_OFFSET_START = 0xE000;
  40542. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40543. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40544. var PDF_GLYPH_SPACE_UNITS = 1000;
  40545. var SEAC_ANALYSIS_ENABLED = false;
  40546. var FontFlags = {
  40547. FixedPitch: 1,
  40548. Serif: 2,
  40549. Symbolic: 4,
  40550. Script: 8,
  40551. Nonsymbolic: 32,
  40552. Italic: 64,
  40553. AllCap: 65536,
  40554. SmallCap: 131072,
  40555. ForceBold: 262144
  40556. };
  40557. var MacStandardGlyphOrdering = [
  40558. '.notdef',
  40559. '.null',
  40560. 'nonmarkingreturn',
  40561. 'space',
  40562. 'exclam',
  40563. 'quotedbl',
  40564. 'numbersign',
  40565. 'dollar',
  40566. 'percent',
  40567. 'ampersand',
  40568. 'quotesingle',
  40569. 'parenleft',
  40570. 'parenright',
  40571. 'asterisk',
  40572. 'plus',
  40573. 'comma',
  40574. 'hyphen',
  40575. 'period',
  40576. 'slash',
  40577. 'zero',
  40578. 'one',
  40579. 'two',
  40580. 'three',
  40581. 'four',
  40582. 'five',
  40583. 'six',
  40584. 'seven',
  40585. 'eight',
  40586. 'nine',
  40587. 'colon',
  40588. 'semicolon',
  40589. 'less',
  40590. 'equal',
  40591. 'greater',
  40592. 'question',
  40593. 'at',
  40594. 'A',
  40595. 'B',
  40596. 'C',
  40597. 'D',
  40598. 'E',
  40599. 'F',
  40600. 'G',
  40601. 'H',
  40602. 'I',
  40603. 'J',
  40604. 'K',
  40605. 'L',
  40606. 'M',
  40607. 'N',
  40608. 'O',
  40609. 'P',
  40610. 'Q',
  40611. 'R',
  40612. 'S',
  40613. 'T',
  40614. 'U',
  40615. 'V',
  40616. 'W',
  40617. 'X',
  40618. 'Y',
  40619. 'Z',
  40620. 'bracketleft',
  40621. 'backslash',
  40622. 'bracketright',
  40623. 'asciicircum',
  40624. 'underscore',
  40625. 'grave',
  40626. 'a',
  40627. 'b',
  40628. 'c',
  40629. 'd',
  40630. 'e',
  40631. 'f',
  40632. 'g',
  40633. 'h',
  40634. 'i',
  40635. 'j',
  40636. 'k',
  40637. 'l',
  40638. 'm',
  40639. 'n',
  40640. 'o',
  40641. 'p',
  40642. 'q',
  40643. 'r',
  40644. 's',
  40645. 't',
  40646. 'u',
  40647. 'v',
  40648. 'w',
  40649. 'x',
  40650. 'y',
  40651. 'z',
  40652. 'braceleft',
  40653. 'bar',
  40654. 'braceright',
  40655. 'asciitilde',
  40656. 'Adieresis',
  40657. 'Aring',
  40658. 'Ccedilla',
  40659. 'Eacute',
  40660. 'Ntilde',
  40661. 'Odieresis',
  40662. 'Udieresis',
  40663. 'aacute',
  40664. 'agrave',
  40665. 'acircumflex',
  40666. 'adieresis',
  40667. 'atilde',
  40668. 'aring',
  40669. 'ccedilla',
  40670. 'eacute',
  40671. 'egrave',
  40672. 'ecircumflex',
  40673. 'edieresis',
  40674. 'iacute',
  40675. 'igrave',
  40676. 'icircumflex',
  40677. 'idieresis',
  40678. 'ntilde',
  40679. 'oacute',
  40680. 'ograve',
  40681. 'ocircumflex',
  40682. 'odieresis',
  40683. 'otilde',
  40684. 'uacute',
  40685. 'ugrave',
  40686. 'ucircumflex',
  40687. 'udieresis',
  40688. 'dagger',
  40689. 'degree',
  40690. 'cent',
  40691. 'sterling',
  40692. 'section',
  40693. 'bullet',
  40694. 'paragraph',
  40695. 'germandbls',
  40696. 'registered',
  40697. 'copyright',
  40698. 'trademark',
  40699. 'acute',
  40700. 'dieresis',
  40701. 'notequal',
  40702. 'AE',
  40703. 'Oslash',
  40704. 'infinity',
  40705. 'plusminus',
  40706. 'lessequal',
  40707. 'greaterequal',
  40708. 'yen',
  40709. 'mu',
  40710. 'partialdiff',
  40711. 'summation',
  40712. 'product',
  40713. 'pi',
  40714. 'integral',
  40715. 'ordfeminine',
  40716. 'ordmasculine',
  40717. 'Omega',
  40718. 'ae',
  40719. 'oslash',
  40720. 'questiondown',
  40721. 'exclamdown',
  40722. 'logicalnot',
  40723. 'radical',
  40724. 'florin',
  40725. 'approxequal',
  40726. 'Delta',
  40727. 'guillemotleft',
  40728. 'guillemotright',
  40729. 'ellipsis',
  40730. 'nonbreakingspace',
  40731. 'Agrave',
  40732. 'Atilde',
  40733. 'Otilde',
  40734. 'OE',
  40735. 'oe',
  40736. 'endash',
  40737. 'emdash',
  40738. 'quotedblleft',
  40739. 'quotedblright',
  40740. 'quoteleft',
  40741. 'quoteright',
  40742. 'divide',
  40743. 'lozenge',
  40744. 'ydieresis',
  40745. 'Ydieresis',
  40746. 'fraction',
  40747. 'currency',
  40748. 'guilsinglleft',
  40749. 'guilsinglright',
  40750. 'fi',
  40751. 'fl',
  40752. 'daggerdbl',
  40753. 'periodcentered',
  40754. 'quotesinglbase',
  40755. 'quotedblbase',
  40756. 'perthousand',
  40757. 'Acircumflex',
  40758. 'Ecircumflex',
  40759. 'Aacute',
  40760. 'Edieresis',
  40761. 'Egrave',
  40762. 'Iacute',
  40763. 'Icircumflex',
  40764. 'Idieresis',
  40765. 'Igrave',
  40766. 'Oacute',
  40767. 'Ocircumflex',
  40768. 'apple',
  40769. 'Ograve',
  40770. 'Uacute',
  40771. 'Ucircumflex',
  40772. 'Ugrave',
  40773. 'dotlessi',
  40774. 'circumflex',
  40775. 'tilde',
  40776. 'macron',
  40777. 'breve',
  40778. 'dotaccent',
  40779. 'ring',
  40780. 'cedilla',
  40781. 'hungarumlaut',
  40782. 'ogonek',
  40783. 'caron',
  40784. 'Lslash',
  40785. 'lslash',
  40786. 'Scaron',
  40787. 'scaron',
  40788. 'Zcaron',
  40789. 'zcaron',
  40790. 'brokenbar',
  40791. 'Eth',
  40792. 'eth',
  40793. 'Yacute',
  40794. 'yacute',
  40795. 'Thorn',
  40796. 'thorn',
  40797. 'minus',
  40798. 'multiply',
  40799. 'onesuperior',
  40800. 'twosuperior',
  40801. 'threesuperior',
  40802. 'onehalf',
  40803. 'onequarter',
  40804. 'threequarters',
  40805. 'franc',
  40806. 'Gbreve',
  40807. 'gbreve',
  40808. 'Idotaccent',
  40809. 'Scedilla',
  40810. 'scedilla',
  40811. 'Cacute',
  40812. 'cacute',
  40813. 'Ccaron',
  40814. 'ccaron',
  40815. 'dcroat'
  40816. ];
  40817. function adjustWidths(properties) {
  40818. if (!properties.fontMatrix) {
  40819. return;
  40820. }
  40821. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40822. return;
  40823. }
  40824. var scale = 0.001 / properties.fontMatrix[0];
  40825. var glyphsWidths = properties.widths;
  40826. for (var glyph in glyphsWidths) {
  40827. glyphsWidths[glyph] *= scale;
  40828. }
  40829. properties.defaultWidth *= scale;
  40830. }
  40831. function adjustToUnicode(properties, builtInEncoding) {
  40832. if (properties.hasIncludedToUnicodeMap) {
  40833. return;
  40834. }
  40835. if (properties.hasEncoding) {
  40836. return;
  40837. }
  40838. if (builtInEncoding === properties.defaultEncoding) {
  40839. return;
  40840. }
  40841. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40842. return;
  40843. }
  40844. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40845. for (var charCode in builtInEncoding) {
  40846. var glyphName = builtInEncoding[charCode];
  40847. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40848. if (unicode !== -1) {
  40849. toUnicode[charCode] = String.fromCharCode(unicode);
  40850. }
  40851. }
  40852. properties.toUnicode.amend(toUnicode);
  40853. }
  40854. function getFontType(type, subtype) {
  40855. switch (type) {
  40856. case 'Type1':
  40857. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40858. case 'CIDFontType0':
  40859. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40860. case 'OpenType':
  40861. return FontType.OPENTYPE;
  40862. case 'TrueType':
  40863. return FontType.TRUETYPE;
  40864. case 'CIDFontType2':
  40865. return FontType.CIDFONTTYPE2;
  40866. case 'MMType1':
  40867. return FontType.MMTYPE1;
  40868. case 'Type0':
  40869. return FontType.TYPE0;
  40870. default:
  40871. return FontType.UNKNOWN;
  40872. }
  40873. }
  40874. function recoverGlyphName(name, glyphsUnicodeMap) {
  40875. if (glyphsUnicodeMap[name] !== undefined) {
  40876. return name;
  40877. }
  40878. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40879. if (unicode !== -1) {
  40880. for (var key in glyphsUnicodeMap) {
  40881. if (glyphsUnicodeMap[key] === unicode) {
  40882. return key;
  40883. }
  40884. }
  40885. }
  40886. info('Unable to recover a standard glyph name for: ' + name);
  40887. return name;
  40888. }
  40889. var Glyph = function GlyphClosure() {
  40890. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40891. this.fontChar = fontChar;
  40892. this.unicode = unicode;
  40893. this.accent = accent;
  40894. this.width = width;
  40895. this.vmetric = vmetric;
  40896. this.operatorListId = operatorListId;
  40897. this.isSpace = isSpace;
  40898. this.isInFont = isInFont;
  40899. }
  40900. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40901. 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;
  40902. };
  40903. return Glyph;
  40904. }();
  40905. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40906. function ToUnicodeMap(cmap) {
  40907. this._map = cmap;
  40908. }
  40909. ToUnicodeMap.prototype = {
  40910. get length() {
  40911. return this._map.length;
  40912. },
  40913. forEach: function (callback) {
  40914. for (var charCode in this._map) {
  40915. callback(charCode, this._map[charCode].charCodeAt(0));
  40916. }
  40917. },
  40918. has: function (i) {
  40919. return this._map[i] !== undefined;
  40920. },
  40921. get: function (i) {
  40922. return this._map[i];
  40923. },
  40924. charCodeOf: function (v) {
  40925. return this._map.indexOf(v);
  40926. },
  40927. amend: function (map) {
  40928. for (var charCode in map) {
  40929. this._map[charCode] = map[charCode];
  40930. }
  40931. }
  40932. };
  40933. return ToUnicodeMap;
  40934. }();
  40935. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40936. function IdentityToUnicodeMap(firstChar, lastChar) {
  40937. this.firstChar = firstChar;
  40938. this.lastChar = lastChar;
  40939. }
  40940. IdentityToUnicodeMap.prototype = {
  40941. get length() {
  40942. return this.lastChar + 1 - this.firstChar;
  40943. },
  40944. forEach: function (callback) {
  40945. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40946. callback(i, i);
  40947. }
  40948. },
  40949. has: function (i) {
  40950. return this.firstChar <= i && i <= this.lastChar;
  40951. },
  40952. get: function (i) {
  40953. if (this.firstChar <= i && i <= this.lastChar) {
  40954. return String.fromCharCode(i);
  40955. }
  40956. return undefined;
  40957. },
  40958. charCodeOf: function (v) {
  40959. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40960. },
  40961. amend: function (map) {
  40962. error('Should not call amend()');
  40963. }
  40964. };
  40965. return IdentityToUnicodeMap;
  40966. }();
  40967. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40968. function writeInt16(dest, offset, num) {
  40969. dest[offset] = num >> 8 & 0xFF;
  40970. dest[offset + 1] = num & 0xFF;
  40971. }
  40972. function writeInt32(dest, offset, num) {
  40973. dest[offset] = num >> 24 & 0xFF;
  40974. dest[offset + 1] = num >> 16 & 0xFF;
  40975. dest[offset + 2] = num >> 8 & 0xFF;
  40976. dest[offset + 3] = num & 0xFF;
  40977. }
  40978. function writeData(dest, offset, data) {
  40979. var i, ii;
  40980. if (data instanceof Uint8Array) {
  40981. dest.set(data, offset);
  40982. } else if (typeof data === 'string') {
  40983. for (i = 0, ii = data.length; i < ii; i++) {
  40984. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40985. }
  40986. } else {
  40987. for (i = 0, ii = data.length; i < ii; i++) {
  40988. dest[offset++] = data[i] & 0xFF;
  40989. }
  40990. }
  40991. }
  40992. function OpenTypeFileBuilder(sfnt) {
  40993. this.sfnt = sfnt;
  40994. this.tables = Object.create(null);
  40995. }
  40996. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40997. var maxPower2 = 1, log2 = 0;
  40998. while ((maxPower2 ^ entriesCount) > maxPower2) {
  40999. maxPower2 <<= 1;
  41000. log2++;
  41001. }
  41002. var searchRange = maxPower2 * entrySize;
  41003. return {
  41004. range: searchRange,
  41005. entry: log2,
  41006. rangeShift: entrySize * entriesCount - searchRange
  41007. };
  41008. };
  41009. var OTF_HEADER_SIZE = 12;
  41010. var OTF_TABLE_ENTRY_SIZE = 16;
  41011. OpenTypeFileBuilder.prototype = {
  41012. toArray: function OpenTypeFileBuilder_toArray() {
  41013. var sfnt = this.sfnt;
  41014. var tables = this.tables;
  41015. var tablesNames = Object.keys(tables);
  41016. tablesNames.sort();
  41017. var numTables = tablesNames.length;
  41018. var i, j, jj, table, tableName;
  41019. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  41020. var tableOffsets = [offset];
  41021. for (i = 0; i < numTables; i++) {
  41022. table = tables[tablesNames[i]];
  41023. var paddedLength = (table.length + 3 & ~3) >>> 0;
  41024. offset += paddedLength;
  41025. tableOffsets.push(offset);
  41026. }
  41027. var file = new Uint8Array(offset);
  41028. for (i = 0; i < numTables; i++) {
  41029. table = tables[tablesNames[i]];
  41030. writeData(file, tableOffsets[i], table);
  41031. }
  41032. if (sfnt === 'true') {
  41033. sfnt = string32(0x00010000);
  41034. }
  41035. file[0] = sfnt.charCodeAt(0) & 0xFF;
  41036. file[1] = sfnt.charCodeAt(1) & 0xFF;
  41037. file[2] = sfnt.charCodeAt(2) & 0xFF;
  41038. file[3] = sfnt.charCodeAt(3) & 0xFF;
  41039. writeInt16(file, 4, numTables);
  41040. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  41041. writeInt16(file, 6, searchParams.range);
  41042. writeInt16(file, 8, searchParams.entry);
  41043. writeInt16(file, 10, searchParams.rangeShift);
  41044. offset = OTF_HEADER_SIZE;
  41045. for (i = 0; i < numTables; i++) {
  41046. tableName = tablesNames[i];
  41047. file[offset] = tableName.charCodeAt(0) & 0xFF;
  41048. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  41049. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  41050. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  41051. var checksum = 0;
  41052. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  41053. var quad = readUint32(file, j);
  41054. checksum = checksum + quad >>> 0;
  41055. }
  41056. writeInt32(file, offset + 4, checksum);
  41057. writeInt32(file, offset + 8, tableOffsets[i]);
  41058. writeInt32(file, offset + 12, tables[tableName].length);
  41059. offset += OTF_TABLE_ENTRY_SIZE;
  41060. }
  41061. return file;
  41062. },
  41063. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  41064. if (tag in this.tables) {
  41065. throw new Error('Table ' + tag + ' already exists');
  41066. }
  41067. this.tables[tag] = data;
  41068. }
  41069. };
  41070. return OpenTypeFileBuilder;
  41071. }();
  41072. var ProblematicCharRanges = new Int32Array([
  41073. 0x0000,
  41074. 0x0020,
  41075. 0x007F,
  41076. 0x00A1,
  41077. 0x00AD,
  41078. 0x00AE,
  41079. 0x0600,
  41080. 0x0780,
  41081. 0x08A0,
  41082. 0x10A0,
  41083. 0x1780,
  41084. 0x1800,
  41085. 0x1C00,
  41086. 0x1C50,
  41087. 0x2000,
  41088. 0x2010,
  41089. 0x2011,
  41090. 0x2012,
  41091. 0x2028,
  41092. 0x2030,
  41093. 0x205F,
  41094. 0x2070,
  41095. 0x25CC,
  41096. 0x25CD,
  41097. 0x3000,
  41098. 0x3001,
  41099. 0xAA60,
  41100. 0xAA80,
  41101. 0xFFF0,
  41102. 0x10000
  41103. ]);
  41104. var Font = function FontClosure() {
  41105. function Font(name, file, properties) {
  41106. var charCode, glyphName, unicode;
  41107. this.name = name;
  41108. this.loadedName = properties.loadedName;
  41109. this.isType3Font = properties.isType3Font;
  41110. this.sizes = [];
  41111. this.missingFile = false;
  41112. this.glyphCache = Object.create(null);
  41113. var names = name.split('+');
  41114. names = names.length > 1 ? names[1] : names[0];
  41115. names = names.split(/[-,_]/g)[0];
  41116. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  41117. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  41118. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  41119. var type = properties.type;
  41120. var subtype = properties.subtype;
  41121. this.type = type;
  41122. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  41123. this.differences = properties.differences;
  41124. this.widths = properties.widths;
  41125. this.defaultWidth = properties.defaultWidth;
  41126. this.composite = properties.composite;
  41127. this.wideChars = properties.wideChars;
  41128. this.cMap = properties.cMap;
  41129. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  41130. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  41131. this.fontMatrix = properties.fontMatrix;
  41132. this.bbox = properties.bbox;
  41133. this.toUnicode = properties.toUnicode;
  41134. this.toFontChar = [];
  41135. if (properties.type === 'Type3') {
  41136. for (charCode = 0; charCode < 256; charCode++) {
  41137. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  41138. }
  41139. this.fontType = FontType.TYPE3;
  41140. return;
  41141. }
  41142. this.cidEncoding = properties.cidEncoding;
  41143. this.vertical = properties.vertical;
  41144. if (this.vertical) {
  41145. this.vmetrics = properties.vmetrics;
  41146. this.defaultVMetrics = properties.defaultVMetrics;
  41147. }
  41148. var glyphsUnicodeMap;
  41149. if (!file || file.isEmpty) {
  41150. if (file) {
  41151. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  41152. }
  41153. this.missingFile = true;
  41154. var fontName = name.replace(/[,_]/g, '-');
  41155. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  41156. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  41157. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  41158. this.bold = fontName.search(/bold/gi) !== -1;
  41159. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  41160. this.black = name.search(/Black/g) !== -1;
  41161. this.remeasure = Object.keys(this.widths).length > 0;
  41162. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  41163. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  41164. var map = [];
  41165. for (charCode in GlyphMapForStandardFonts) {
  41166. map[+charCode] = GlyphMapForStandardFonts[charCode];
  41167. }
  41168. if (/Arial-?Black/i.test(name)) {
  41169. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  41170. for (charCode in SupplementalGlyphMapForArialBlack) {
  41171. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  41172. }
  41173. }
  41174. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41175. if (!isIdentityUnicode) {
  41176. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41177. map[+charCode] = unicodeCharCode;
  41178. });
  41179. }
  41180. this.toFontChar = map;
  41181. this.toUnicode = new ToUnicodeMap(map);
  41182. } else if (/Symbol/i.test(fontName)) {
  41183. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41184. } else if (/Dingbats/i.test(fontName)) {
  41185. if (/Wingdings/i.test(name)) {
  41186. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41187. }
  41188. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41189. } else if (isStandardFont) {
  41190. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41191. } else {
  41192. glyphsUnicodeMap = getGlyphsUnicode();
  41193. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41194. if (!this.composite) {
  41195. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41196. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41197. if (unicode !== -1) {
  41198. unicodeCharCode = unicode;
  41199. }
  41200. }
  41201. this.toFontChar[charCode] = unicodeCharCode;
  41202. }.bind(this));
  41203. }
  41204. this.loadedName = fontName.split('-')[0];
  41205. this.loading = false;
  41206. this.fontType = getFontType(type, subtype);
  41207. return;
  41208. }
  41209. if (subtype === 'Type1C') {
  41210. if (type !== 'Type1' && type !== 'MMType1') {
  41211. if (isTrueTypeFile(file)) {
  41212. subtype = 'TrueType';
  41213. } else {
  41214. type = 'Type1';
  41215. }
  41216. } else if (isOpenTypeFile(file)) {
  41217. type = subtype = 'OpenType';
  41218. }
  41219. }
  41220. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41221. type = 'CIDFontType0';
  41222. }
  41223. if (subtype === 'OpenType') {
  41224. type = 'OpenType';
  41225. }
  41226. if (type === 'CIDFontType0') {
  41227. if (isType1File(file)) {
  41228. subtype = 'CIDFontType0';
  41229. } else if (isOpenTypeFile(file)) {
  41230. type = subtype = 'OpenType';
  41231. } else {
  41232. subtype = 'CIDFontType0C';
  41233. }
  41234. }
  41235. var data;
  41236. switch (type) {
  41237. case 'MMType1':
  41238. info('MMType1 font (' + name + '), falling back to Type1.');
  41239. case 'Type1':
  41240. case 'CIDFontType0':
  41241. this.mimetype = 'font/opentype';
  41242. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41243. adjustWidths(properties);
  41244. data = this.convert(name, cff, properties);
  41245. break;
  41246. case 'OpenType':
  41247. case 'TrueType':
  41248. case 'CIDFontType2':
  41249. this.mimetype = 'font/opentype';
  41250. data = this.checkAndRepair(name, file, properties);
  41251. if (this.isOpenType) {
  41252. adjustWidths(properties);
  41253. type = 'OpenType';
  41254. }
  41255. break;
  41256. default:
  41257. error('Font ' + type + ' is not supported');
  41258. break;
  41259. }
  41260. this.data = data;
  41261. this.fontType = getFontType(type, subtype);
  41262. this.fontMatrix = properties.fontMatrix;
  41263. this.widths = properties.widths;
  41264. this.defaultWidth = properties.defaultWidth;
  41265. this.toUnicode = properties.toUnicode;
  41266. this.encoding = properties.baseEncoding;
  41267. this.seacMap = properties.seacMap;
  41268. this.loading = true;
  41269. }
  41270. Font.getFontID = function () {
  41271. var ID = 1;
  41272. return function Font_getFontID() {
  41273. return String(ID++);
  41274. };
  41275. }();
  41276. function int16(b0, b1) {
  41277. return (b0 << 8) + b1;
  41278. }
  41279. function signedInt16(b0, b1) {
  41280. var value = (b0 << 8) + b1;
  41281. return value & 1 << 15 ? value - 0x10000 : value;
  41282. }
  41283. function int32(b0, b1, b2, b3) {
  41284. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41285. }
  41286. function string16(value) {
  41287. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41288. }
  41289. function safeString16(value) {
  41290. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41291. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41292. }
  41293. function isTrueTypeFile(file) {
  41294. var header = file.peekBytes(4);
  41295. return readUint32(header, 0) === 0x00010000;
  41296. }
  41297. function isOpenTypeFile(file) {
  41298. var header = file.peekBytes(4);
  41299. return bytesToString(header) === 'OTTO';
  41300. }
  41301. function isType1File(file) {
  41302. var header = file.peekBytes(2);
  41303. if (header[0] === 0x25 && header[1] === 0x21) {
  41304. return true;
  41305. }
  41306. if (header[0] === 0x80 && header[1] === 0x01) {
  41307. return true;
  41308. }
  41309. return false;
  41310. }
  41311. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41312. var toFontChar = [], unicode;
  41313. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41314. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41315. if (unicode !== -1) {
  41316. toFontChar[i] = unicode;
  41317. }
  41318. }
  41319. for (var charCode in differences) {
  41320. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41321. if (unicode !== -1) {
  41322. toFontChar[+charCode] = unicode;
  41323. }
  41324. }
  41325. return toFontChar;
  41326. }
  41327. function isProblematicUnicodeLocation(code) {
  41328. var i = 0, j = ProblematicCharRanges.length - 1;
  41329. while (i < j) {
  41330. var c = i + j + 1 >> 1;
  41331. if (code < ProblematicCharRanges[c]) {
  41332. j = c - 1;
  41333. } else {
  41334. i = c;
  41335. }
  41336. }
  41337. return !(i & 1);
  41338. }
  41339. function adjustMapping(charCodeToGlyphId, properties) {
  41340. var toUnicode = properties.toUnicode;
  41341. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41342. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41343. var newMap = Object.create(null);
  41344. var toFontChar = [];
  41345. var usedFontCharCodes = [];
  41346. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41347. for (var originalCharCode in charCodeToGlyphId) {
  41348. originalCharCode |= 0;
  41349. var glyphId = charCodeToGlyphId[originalCharCode];
  41350. var fontCharCode = originalCharCode;
  41351. var hasUnicodeValue = false;
  41352. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41353. hasUnicodeValue = true;
  41354. var unicode = toUnicode.get(fontCharCode);
  41355. if (unicode.length === 1) {
  41356. fontCharCode = unicode.charCodeAt(0);
  41357. }
  41358. }
  41359. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41360. do {
  41361. fontCharCode = nextAvailableFontCharCode++;
  41362. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41363. fontCharCode = 0xF020;
  41364. nextAvailableFontCharCode = fontCharCode + 1;
  41365. }
  41366. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41367. }
  41368. newMap[fontCharCode] = glyphId;
  41369. toFontChar[originalCharCode] = fontCharCode;
  41370. usedFontCharCodes[fontCharCode] = true;
  41371. }
  41372. return {
  41373. toFontChar: toFontChar,
  41374. charCodeToGlyphId: newMap,
  41375. nextAvailableFontCharCode: nextAvailableFontCharCode
  41376. };
  41377. }
  41378. function getRanges(glyphs, numGlyphs) {
  41379. var codes = [];
  41380. for (var charCode in glyphs) {
  41381. if (glyphs[charCode] >= numGlyphs) {
  41382. continue;
  41383. }
  41384. codes.push({
  41385. fontCharCode: charCode | 0,
  41386. glyphId: glyphs[charCode]
  41387. });
  41388. }
  41389. codes.sort(function fontGetRangesSort(a, b) {
  41390. return a.fontCharCode - b.fontCharCode;
  41391. });
  41392. var ranges = [];
  41393. var length = codes.length;
  41394. for (var n = 0; n < length;) {
  41395. var start = codes[n].fontCharCode;
  41396. var codeIndices = [codes[n].glyphId];
  41397. ++n;
  41398. var end = start;
  41399. while (n < length && end + 1 === codes[n].fontCharCode) {
  41400. codeIndices.push(codes[n].glyphId);
  41401. ++end;
  41402. ++n;
  41403. if (end === 0xFFFF) {
  41404. break;
  41405. }
  41406. }
  41407. ranges.push([
  41408. start,
  41409. end,
  41410. codeIndices
  41411. ]);
  41412. }
  41413. return ranges;
  41414. }
  41415. function createCmapTable(glyphs, numGlyphs) {
  41416. var ranges = getRanges(glyphs, numGlyphs);
  41417. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41418. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41419. var i, ii, j, jj;
  41420. for (i = ranges.length - 1; i >= 0; --i) {
  41421. if (ranges[i][0] <= 0xFFFF) {
  41422. break;
  41423. }
  41424. }
  41425. var bmpLength = i + 1;
  41426. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41427. ranges[i][1] = 0xFFFE;
  41428. }
  41429. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41430. var segCount = bmpLength + trailingRangesCount;
  41431. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41432. var startCount = '';
  41433. var endCount = '';
  41434. var idDeltas = '';
  41435. var idRangeOffsets = '';
  41436. var glyphsIds = '';
  41437. var bias = 0;
  41438. var range, start, end, codes;
  41439. for (i = 0, ii = bmpLength; i < ii; i++) {
  41440. range = ranges[i];
  41441. start = range[0];
  41442. end = range[1];
  41443. startCount += string16(start);
  41444. endCount += string16(end);
  41445. codes = range[2];
  41446. var contiguous = true;
  41447. for (j = 1, jj = codes.length; j < jj; ++j) {
  41448. if (codes[j] !== codes[j - 1] + 1) {
  41449. contiguous = false;
  41450. break;
  41451. }
  41452. }
  41453. if (!contiguous) {
  41454. var offset = (segCount - i) * 2 + bias * 2;
  41455. bias += end - start + 1;
  41456. idDeltas += string16(0);
  41457. idRangeOffsets += string16(offset);
  41458. for (j = 0, jj = codes.length; j < jj; ++j) {
  41459. glyphsIds += string16(codes[j]);
  41460. }
  41461. } else {
  41462. var startCode = codes[0];
  41463. idDeltas += string16(startCode - start & 0xFFFF);
  41464. idRangeOffsets += string16(0);
  41465. }
  41466. }
  41467. if (trailingRangesCount > 0) {
  41468. endCount += '\xFF\xFF';
  41469. startCount += '\xFF\xFF';
  41470. idDeltas += '\x00\x01';
  41471. idRangeOffsets += '\x00\x00';
  41472. }
  41473. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41474. var format31012 = '';
  41475. var header31012 = '';
  41476. if (numTables > 1) {
  41477. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41478. format31012 = '';
  41479. for (i = 0, ii = ranges.length; i < ii; i++) {
  41480. range = ranges[i];
  41481. start = range[0];
  41482. codes = range[2];
  41483. var code = codes[0];
  41484. for (j = 1, jj = codes.length; j < jj; ++j) {
  41485. if (codes[j] !== codes[j - 1] + 1) {
  41486. end = range[0] + j - 1;
  41487. format31012 += string32(start) + string32(end) + string32(code);
  41488. start = end + 1;
  41489. code = codes[j];
  41490. }
  41491. }
  41492. format31012 += string32(start) + string32(range[1]) + string32(code);
  41493. }
  41494. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41495. }
  41496. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41497. }
  41498. function validateOS2Table(os2) {
  41499. var stream = new Stream(os2.data);
  41500. var version = stream.getUint16();
  41501. stream.getBytes(60);
  41502. var selection = stream.getUint16();
  41503. if (version < 4 && selection & 0x0300) {
  41504. return false;
  41505. }
  41506. var firstChar = stream.getUint16();
  41507. var lastChar = stream.getUint16();
  41508. if (firstChar > lastChar) {
  41509. return false;
  41510. }
  41511. stream.getBytes(6);
  41512. var usWinAscent = stream.getUint16();
  41513. if (usWinAscent === 0) {
  41514. return false;
  41515. }
  41516. os2.data[8] = os2.data[9] = 0;
  41517. return true;
  41518. }
  41519. function createOS2Table(properties, charstrings, override) {
  41520. override = override || {
  41521. unitsPerEm: 0,
  41522. yMax: 0,
  41523. yMin: 0,
  41524. ascent: 0,
  41525. descent: 0
  41526. };
  41527. var ulUnicodeRange1 = 0;
  41528. var ulUnicodeRange2 = 0;
  41529. var ulUnicodeRange3 = 0;
  41530. var ulUnicodeRange4 = 0;
  41531. var firstCharIndex = null;
  41532. var lastCharIndex = 0;
  41533. if (charstrings) {
  41534. for (var code in charstrings) {
  41535. code |= 0;
  41536. if (firstCharIndex > code || !firstCharIndex) {
  41537. firstCharIndex = code;
  41538. }
  41539. if (lastCharIndex < code) {
  41540. lastCharIndex = code;
  41541. }
  41542. var position = getUnicodeRangeFor(code);
  41543. if (position < 32) {
  41544. ulUnicodeRange1 |= 1 << position;
  41545. } else if (position < 64) {
  41546. ulUnicodeRange2 |= 1 << position - 32;
  41547. } else if (position < 96) {
  41548. ulUnicodeRange3 |= 1 << position - 64;
  41549. } else if (position < 123) {
  41550. ulUnicodeRange4 |= 1 << position - 96;
  41551. } else {
  41552. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41553. }
  41554. }
  41555. } else {
  41556. firstCharIndex = 0;
  41557. lastCharIndex = 255;
  41558. }
  41559. var bbox = properties.bbox || [
  41560. 0,
  41561. 0,
  41562. 0,
  41563. 0
  41564. ];
  41565. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41566. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41567. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41568. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41569. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41570. typoDescent = -typoDescent;
  41571. }
  41572. var winAscent = override.yMax || typoAscent;
  41573. var winDescent = -override.yMin || -typoDescent;
  41574. 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';
  41575. }
  41576. function createPostTable(properties) {
  41577. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41578. 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';
  41579. }
  41580. function createNameTable(name, proto) {
  41581. if (!proto) {
  41582. proto = [
  41583. [],
  41584. []
  41585. ];
  41586. }
  41587. var strings = [
  41588. proto[0][0] || 'Original licence',
  41589. proto[0][1] || name,
  41590. proto[0][2] || 'Unknown',
  41591. proto[0][3] || 'uniqueID',
  41592. proto[0][4] || name,
  41593. proto[0][5] || 'Version 0.11',
  41594. proto[0][6] || '',
  41595. proto[0][7] || 'Unknown',
  41596. proto[0][8] || 'Unknown',
  41597. proto[0][9] || 'Unknown'
  41598. ];
  41599. var stringsUnicode = [];
  41600. var i, ii, j, jj, str;
  41601. for (i = 0, ii = strings.length; i < ii; i++) {
  41602. str = proto[1][i] || strings[i];
  41603. var strBufUnicode = [];
  41604. for (j = 0, jj = str.length; j < jj; j++) {
  41605. strBufUnicode.push(string16(str.charCodeAt(j)));
  41606. }
  41607. stringsUnicode.push(strBufUnicode.join(''));
  41608. }
  41609. var names = [
  41610. strings,
  41611. stringsUnicode
  41612. ];
  41613. var platforms = [
  41614. '\x00\x01',
  41615. '\x00\x03'
  41616. ];
  41617. var encodings = [
  41618. '\x00\x00',
  41619. '\x00\x01'
  41620. ];
  41621. var languages = [
  41622. '\x00\x00',
  41623. '\x04\x09'
  41624. ];
  41625. var namesRecordCount = strings.length * platforms.length;
  41626. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41627. var strOffset = 0;
  41628. for (i = 0, ii = platforms.length; i < ii; i++) {
  41629. var strs = names[i];
  41630. for (j = 0, jj = strs.length; j < jj; j++) {
  41631. str = strs[j];
  41632. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41633. nameTable += nameRecord;
  41634. strOffset += str.length;
  41635. }
  41636. }
  41637. nameTable += strings.join('') + stringsUnicode.join('');
  41638. return nameTable;
  41639. }
  41640. Font.prototype = {
  41641. name: null,
  41642. font: null,
  41643. mimetype: null,
  41644. encoding: null,
  41645. get renderer() {
  41646. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41647. return shadow(this, 'renderer', renderer);
  41648. },
  41649. exportData: function Font_exportData() {
  41650. var data = {};
  41651. for (var i in this) {
  41652. if (this.hasOwnProperty(i)) {
  41653. data[i] = this[i];
  41654. }
  41655. }
  41656. return data;
  41657. },
  41658. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41659. function readTableEntry(file) {
  41660. var tag = bytesToString(file.getBytes(4));
  41661. var checksum = file.getInt32() >>> 0;
  41662. var offset = file.getInt32() >>> 0;
  41663. var length = file.getInt32() >>> 0;
  41664. var previousPosition = file.pos;
  41665. file.pos = file.start ? file.start : 0;
  41666. file.skip(offset);
  41667. var data = file.getBytes(length);
  41668. file.pos = previousPosition;
  41669. if (tag === 'head') {
  41670. data[8] = data[9] = data[10] = data[11] = 0;
  41671. data[17] |= 0x20;
  41672. }
  41673. return {
  41674. tag: tag,
  41675. checksum: checksum,
  41676. length: length,
  41677. offset: offset,
  41678. data: data
  41679. };
  41680. }
  41681. function readOpenTypeHeader(ttf) {
  41682. return {
  41683. version: bytesToString(ttf.getBytes(4)),
  41684. numTables: ttf.getUint16(),
  41685. searchRange: ttf.getUint16(),
  41686. entrySelector: ttf.getUint16(),
  41687. rangeShift: ttf.getUint16()
  41688. };
  41689. }
  41690. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41691. if (!cmap) {
  41692. warn('No cmap table available.');
  41693. return {
  41694. platformId: -1,
  41695. encodingId: -1,
  41696. mappings: [],
  41697. hasShortCmap: false
  41698. };
  41699. }
  41700. var segment;
  41701. var start = (font.start ? font.start : 0) + cmap.offset;
  41702. font.pos = start;
  41703. var version = font.getUint16();
  41704. var numTables = font.getUint16();
  41705. var potentialTable;
  41706. var canBreak = false;
  41707. for (var i = 0; i < numTables; i++) {
  41708. var platformId = font.getUint16();
  41709. var encodingId = font.getUint16();
  41710. var offset = font.getInt32() >>> 0;
  41711. var useTable = false;
  41712. if (platformId === 0 && encodingId === 0) {
  41713. useTable = true;
  41714. } else if (platformId === 1 && encodingId === 0) {
  41715. useTable = true;
  41716. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41717. useTable = true;
  41718. if (!isSymbolicFont) {
  41719. canBreak = true;
  41720. }
  41721. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41722. useTable = true;
  41723. canBreak = true;
  41724. }
  41725. if (useTable) {
  41726. potentialTable = {
  41727. platformId: platformId,
  41728. encodingId: encodingId,
  41729. offset: offset
  41730. };
  41731. }
  41732. if (canBreak) {
  41733. break;
  41734. }
  41735. }
  41736. if (potentialTable) {
  41737. font.pos = start + potentialTable.offset;
  41738. }
  41739. if (!potentialTable || font.peekByte() === -1) {
  41740. warn('Could not find a preferred cmap table.');
  41741. return {
  41742. platformId: -1,
  41743. encodingId: -1,
  41744. mappings: [],
  41745. hasShortCmap: false
  41746. };
  41747. }
  41748. var format = font.getUint16();
  41749. var length = font.getUint16();
  41750. var language = font.getUint16();
  41751. var hasShortCmap = false;
  41752. var mappings = [];
  41753. var j, glyphId;
  41754. if (format === 0) {
  41755. for (j = 0; j < 256; j++) {
  41756. var index = font.getByte();
  41757. if (!index) {
  41758. continue;
  41759. }
  41760. mappings.push({
  41761. charCode: j,
  41762. glyphId: index
  41763. });
  41764. }
  41765. hasShortCmap = true;
  41766. } else if (format === 4) {
  41767. var segCount = font.getUint16() >> 1;
  41768. font.getBytes(6);
  41769. var segIndex, segments = [];
  41770. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41771. segments.push({ end: font.getUint16() });
  41772. }
  41773. font.getUint16();
  41774. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41775. segments[segIndex].start = font.getUint16();
  41776. }
  41777. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41778. segments[segIndex].delta = font.getUint16();
  41779. }
  41780. var offsetsCount = 0;
  41781. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41782. segment = segments[segIndex];
  41783. var rangeOffset = font.getUint16();
  41784. if (!rangeOffset) {
  41785. segment.offsetIndex = -1;
  41786. continue;
  41787. }
  41788. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41789. segment.offsetIndex = offsetIndex;
  41790. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41791. }
  41792. var offsets = [];
  41793. for (j = 0; j < offsetsCount; j++) {
  41794. offsets.push(font.getUint16());
  41795. }
  41796. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41797. segment = segments[segIndex];
  41798. start = segment.start;
  41799. var end = segment.end;
  41800. var delta = segment.delta;
  41801. offsetIndex = segment.offsetIndex;
  41802. for (j = start; j <= end; j++) {
  41803. if (j === 0xFFFF) {
  41804. continue;
  41805. }
  41806. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41807. glyphId = glyphId + delta & 0xFFFF;
  41808. if (glyphId === 0) {
  41809. continue;
  41810. }
  41811. mappings.push({
  41812. charCode: j,
  41813. glyphId: glyphId
  41814. });
  41815. }
  41816. }
  41817. } else if (format === 6) {
  41818. var firstCode = font.getUint16();
  41819. var entryCount = font.getUint16();
  41820. for (j = 0; j < entryCount; j++) {
  41821. glyphId = font.getUint16();
  41822. var charCode = firstCode + j;
  41823. mappings.push({
  41824. charCode: charCode,
  41825. glyphId: glyphId
  41826. });
  41827. }
  41828. } else {
  41829. warn('cmap table has unsupported format: ' + format);
  41830. return {
  41831. platformId: -1,
  41832. encodingId: -1,
  41833. mappings: [],
  41834. hasShortCmap: false
  41835. };
  41836. }
  41837. mappings.sort(function (a, b) {
  41838. return a.charCode - b.charCode;
  41839. });
  41840. for (i = 1; i < mappings.length; i++) {
  41841. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41842. mappings.splice(i, 1);
  41843. i--;
  41844. }
  41845. }
  41846. return {
  41847. platformId: potentialTable.platformId,
  41848. encodingId: potentialTable.encodingId,
  41849. mappings: mappings,
  41850. hasShortCmap: hasShortCmap
  41851. };
  41852. }
  41853. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41854. if (!header) {
  41855. if (metrics) {
  41856. metrics.data = null;
  41857. }
  41858. return;
  41859. }
  41860. font.pos = (font.start ? font.start : 0) + header.offset;
  41861. font.pos += header.length - 2;
  41862. var numOfMetrics = font.getUint16();
  41863. if (numOfMetrics > numGlyphs) {
  41864. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41865. numOfMetrics = numGlyphs;
  41866. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41867. header.data[35] = numOfMetrics & 0x00ff;
  41868. }
  41869. var numOfSidebearings = numGlyphs - numOfMetrics;
  41870. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41871. if (numMissing > 0) {
  41872. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41873. entries.set(metrics.data);
  41874. metrics.data = entries;
  41875. }
  41876. }
  41877. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41878. if (sourceEnd - sourceStart <= 12) {
  41879. return 0;
  41880. }
  41881. var glyf = source.subarray(sourceStart, sourceEnd);
  41882. var contoursCount = glyf[0] << 8 | glyf[1];
  41883. if (contoursCount & 0x8000) {
  41884. dest.set(glyf, destStart);
  41885. return glyf.length;
  41886. }
  41887. var i, j = 10, flagsCount = 0;
  41888. for (i = 0; i < contoursCount; i++) {
  41889. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41890. flagsCount = endPoint + 1;
  41891. j += 2;
  41892. }
  41893. var instructionsStart = j;
  41894. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41895. j += 2 + instructionsLength;
  41896. var instructionsEnd = j;
  41897. var coordinatesLength = 0;
  41898. for (i = 0; i < flagsCount; i++) {
  41899. var flag = glyf[j++];
  41900. if (flag & 0xC0) {
  41901. glyf[j - 1] = flag & 0x3F;
  41902. }
  41903. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41904. coordinatesLength += xyLength;
  41905. if (flag & 8) {
  41906. var repeat = glyf[j++];
  41907. i += repeat;
  41908. coordinatesLength += repeat * xyLength;
  41909. }
  41910. }
  41911. if (coordinatesLength === 0) {
  41912. return 0;
  41913. }
  41914. var glyphDataLength = j + coordinatesLength;
  41915. if (glyphDataLength > glyf.length) {
  41916. return 0;
  41917. }
  41918. if (!hintsValid && instructionsLength > 0) {
  41919. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41920. dest.set([
  41921. 0,
  41922. 0
  41923. ], destStart + instructionsStart);
  41924. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41925. glyphDataLength -= instructionsLength;
  41926. if (glyf.length - glyphDataLength > 3) {
  41927. glyphDataLength = glyphDataLength + 3 & ~3;
  41928. }
  41929. return glyphDataLength;
  41930. }
  41931. if (glyf.length - glyphDataLength > 3) {
  41932. glyphDataLength = glyphDataLength + 3 & ~3;
  41933. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41934. return glyphDataLength;
  41935. }
  41936. dest.set(glyf, destStart);
  41937. return glyf.length;
  41938. }
  41939. function sanitizeHead(head, numGlyphs, locaLength) {
  41940. var data = head.data;
  41941. var version = int32(data[0], data[1], data[2], data[3]);
  41942. if (version >> 16 !== 1) {
  41943. info('Attempting to fix invalid version in head table: ' + version);
  41944. data[0] = 0;
  41945. data[1] = 1;
  41946. data[2] = 0;
  41947. data[3] = 0;
  41948. }
  41949. var indexToLocFormat = int16(data[50], data[51]);
  41950. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41951. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41952. var numGlyphsPlusOne = numGlyphs + 1;
  41953. if (locaLength === numGlyphsPlusOne << 1) {
  41954. data[50] = 0;
  41955. data[51] = 0;
  41956. } else if (locaLength === numGlyphsPlusOne << 2) {
  41957. data[50] = 0;
  41958. data[51] = 1;
  41959. } else {
  41960. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41961. }
  41962. }
  41963. }
  41964. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41965. var itemSize, itemDecode, itemEncode;
  41966. if (isGlyphLocationsLong) {
  41967. itemSize = 4;
  41968. itemDecode = function fontItemDecodeLong(data, offset) {
  41969. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41970. };
  41971. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41972. data[offset] = value >>> 24 & 0xFF;
  41973. data[offset + 1] = value >> 16 & 0xFF;
  41974. data[offset + 2] = value >> 8 & 0xFF;
  41975. data[offset + 3] = value & 0xFF;
  41976. };
  41977. } else {
  41978. itemSize = 2;
  41979. itemDecode = function fontItemDecode(data, offset) {
  41980. return data[offset] << 9 | data[offset + 1] << 1;
  41981. };
  41982. itemEncode = function fontItemEncode(data, offset, value) {
  41983. data[offset] = value >> 9 & 0xFF;
  41984. data[offset + 1] = value >> 1 & 0xFF;
  41985. };
  41986. }
  41987. var locaData = loca.data;
  41988. var locaDataSize = itemSize * (1 + numGlyphs);
  41989. if (locaData.length !== locaDataSize) {
  41990. locaData = new Uint8Array(locaDataSize);
  41991. locaData.set(loca.data.subarray(0, locaDataSize));
  41992. loca.data = locaData;
  41993. }
  41994. var oldGlyfData = glyf.data;
  41995. var oldGlyfDataLength = oldGlyfData.length;
  41996. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41997. var startOffset = itemDecode(locaData, 0);
  41998. var writeOffset = 0;
  41999. var missingGlyphData = Object.create(null);
  42000. itemEncode(locaData, 0, writeOffset);
  42001. var i, j;
  42002. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  42003. var endOffset = itemDecode(locaData, j);
  42004. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  42005. endOffset = oldGlyfDataLength;
  42006. }
  42007. if (endOffset > oldGlyfDataLength) {
  42008. itemEncode(locaData, j, writeOffset);
  42009. startOffset = endOffset;
  42010. continue;
  42011. }
  42012. if (startOffset === endOffset) {
  42013. missingGlyphData[i] = true;
  42014. }
  42015. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  42016. writeOffset += newLength;
  42017. itemEncode(locaData, j, writeOffset);
  42018. startOffset = endOffset;
  42019. }
  42020. if (writeOffset === 0) {
  42021. var simpleGlyph = new Uint8Array([
  42022. 0,
  42023. 1,
  42024. 0,
  42025. 0,
  42026. 0,
  42027. 0,
  42028. 0,
  42029. 0,
  42030. 0,
  42031. 0,
  42032. 0,
  42033. 0,
  42034. 0,
  42035. 0,
  42036. 49,
  42037. 0
  42038. ]);
  42039. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  42040. itemEncode(locaData, j, simpleGlyph.length);
  42041. }
  42042. glyf.data = simpleGlyph;
  42043. return missingGlyphData;
  42044. }
  42045. if (dupFirstEntry) {
  42046. var firstEntryLength = itemDecode(locaData, itemSize);
  42047. if (newGlyfData.length > firstEntryLength + writeOffset) {
  42048. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  42049. } else {
  42050. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  42051. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  42052. }
  42053. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  42054. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  42055. } else {
  42056. glyf.data = newGlyfData.subarray(0, writeOffset);
  42057. }
  42058. return missingGlyphData;
  42059. }
  42060. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  42061. var start = (font.start ? font.start : 0) + post.offset;
  42062. font.pos = start;
  42063. var length = post.length, end = start + length;
  42064. var version = font.getInt32();
  42065. font.getBytes(28);
  42066. var glyphNames;
  42067. var valid = true;
  42068. var i;
  42069. switch (version) {
  42070. case 0x00010000:
  42071. glyphNames = MacStandardGlyphOrdering;
  42072. break;
  42073. case 0x00020000:
  42074. var numGlyphs = font.getUint16();
  42075. if (numGlyphs !== maxpNumGlyphs) {
  42076. valid = false;
  42077. break;
  42078. }
  42079. var glyphNameIndexes = [];
  42080. for (i = 0; i < numGlyphs; ++i) {
  42081. var index = font.getUint16();
  42082. if (index >= 32768) {
  42083. valid = false;
  42084. break;
  42085. }
  42086. glyphNameIndexes.push(index);
  42087. }
  42088. if (!valid) {
  42089. break;
  42090. }
  42091. var customNames = [];
  42092. var strBuf = [];
  42093. while (font.pos < end) {
  42094. var stringLength = font.getByte();
  42095. strBuf.length = stringLength;
  42096. for (i = 0; i < stringLength; ++i) {
  42097. strBuf[i] = String.fromCharCode(font.getByte());
  42098. }
  42099. customNames.push(strBuf.join(''));
  42100. }
  42101. glyphNames = [];
  42102. for (i = 0; i < numGlyphs; ++i) {
  42103. var j = glyphNameIndexes[i];
  42104. if (j < 258) {
  42105. glyphNames.push(MacStandardGlyphOrdering[j]);
  42106. continue;
  42107. }
  42108. glyphNames.push(customNames[j - 258]);
  42109. }
  42110. break;
  42111. case 0x00030000:
  42112. break;
  42113. default:
  42114. warn('Unknown/unsupported post table version ' + version);
  42115. valid = false;
  42116. if (properties.defaultEncoding) {
  42117. glyphNames = properties.defaultEncoding;
  42118. }
  42119. break;
  42120. }
  42121. properties.glyphNames = glyphNames;
  42122. return valid;
  42123. }
  42124. function readNameTable(nameTable) {
  42125. var start = (font.start ? font.start : 0) + nameTable.offset;
  42126. font.pos = start;
  42127. var names = [
  42128. [],
  42129. []
  42130. ];
  42131. var length = nameTable.length, end = start + length;
  42132. var format = font.getUint16();
  42133. var FORMAT_0_HEADER_LENGTH = 6;
  42134. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  42135. return names;
  42136. }
  42137. var numRecords = font.getUint16();
  42138. var stringsStart = font.getUint16();
  42139. var records = [];
  42140. var NAME_RECORD_LENGTH = 12;
  42141. var i, ii;
  42142. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  42143. var r = {
  42144. platform: font.getUint16(),
  42145. encoding: font.getUint16(),
  42146. language: font.getUint16(),
  42147. name: font.getUint16(),
  42148. length: font.getUint16(),
  42149. offset: font.getUint16()
  42150. };
  42151. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  42152. records.push(r);
  42153. }
  42154. }
  42155. for (i = 0, ii = records.length; i < ii; i++) {
  42156. var record = records[i];
  42157. if (record.length <= 0) {
  42158. continue;
  42159. }
  42160. var pos = start + stringsStart + record.offset;
  42161. if (pos + record.length > end) {
  42162. continue;
  42163. }
  42164. font.pos = pos;
  42165. var nameIndex = record.name;
  42166. if (record.encoding) {
  42167. var str = '';
  42168. for (var j = 0, jj = record.length; j < jj; j += 2) {
  42169. str += String.fromCharCode(font.getUint16());
  42170. }
  42171. names[1][nameIndex] = str;
  42172. } else {
  42173. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  42174. }
  42175. }
  42176. return names;
  42177. }
  42178. var TTOpsStackDeltas = [
  42179. 0,
  42180. 0,
  42181. 0,
  42182. 0,
  42183. 0,
  42184. 0,
  42185. 0,
  42186. 0,
  42187. -2,
  42188. -2,
  42189. -2,
  42190. -2,
  42191. 0,
  42192. 0,
  42193. -2,
  42194. -5,
  42195. -1,
  42196. -1,
  42197. -1,
  42198. -1,
  42199. -1,
  42200. -1,
  42201. -1,
  42202. -1,
  42203. 0,
  42204. 0,
  42205. -1,
  42206. 0,
  42207. -1,
  42208. -1,
  42209. -1,
  42210. -1,
  42211. 1,
  42212. -1,
  42213. -999,
  42214. 0,
  42215. 1,
  42216. 0,
  42217. -1,
  42218. -2,
  42219. 0,
  42220. -1,
  42221. -2,
  42222. -1,
  42223. -1,
  42224. 0,
  42225. -1,
  42226. -1,
  42227. 0,
  42228. 0,
  42229. -999,
  42230. -999,
  42231. -1,
  42232. -1,
  42233. -1,
  42234. -1,
  42235. -2,
  42236. -999,
  42237. -2,
  42238. -2,
  42239. -999,
  42240. 0,
  42241. -2,
  42242. -2,
  42243. 0,
  42244. 0,
  42245. -2,
  42246. 0,
  42247. -2,
  42248. 0,
  42249. 0,
  42250. 0,
  42251. -2,
  42252. -1,
  42253. -1,
  42254. 1,
  42255. 1,
  42256. 0,
  42257. 0,
  42258. -1,
  42259. -1,
  42260. -1,
  42261. -1,
  42262. -1,
  42263. -1,
  42264. -1,
  42265. 0,
  42266. 0,
  42267. -1,
  42268. 0,
  42269. -1,
  42270. -1,
  42271. 0,
  42272. -999,
  42273. -1,
  42274. -1,
  42275. -1,
  42276. -1,
  42277. -1,
  42278. -1,
  42279. 0,
  42280. 0,
  42281. 0,
  42282. 0,
  42283. 0,
  42284. 0,
  42285. 0,
  42286. 0,
  42287. 0,
  42288. 0,
  42289. 0,
  42290. 0,
  42291. -2,
  42292. -999,
  42293. -999,
  42294. -999,
  42295. -999,
  42296. -999,
  42297. -1,
  42298. -1,
  42299. -2,
  42300. -2,
  42301. 0,
  42302. 0,
  42303. 0,
  42304. 0,
  42305. -1,
  42306. -1,
  42307. -999,
  42308. -2,
  42309. -2,
  42310. 0,
  42311. 0,
  42312. -1,
  42313. -2,
  42314. -2,
  42315. 0,
  42316. 0,
  42317. 0,
  42318. -1,
  42319. -1,
  42320. -1,
  42321. -2
  42322. ];
  42323. function sanitizeTTProgram(table, ttContext) {
  42324. var data = table.data;
  42325. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42326. var stack = [];
  42327. var callstack = [];
  42328. var functionsCalled = [];
  42329. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42330. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42331. for (var ii = data.length; i < ii;) {
  42332. var op = data[i++];
  42333. if (op === 0x40) {
  42334. n = data[i++];
  42335. if (inFDEF || inELSE) {
  42336. i += n;
  42337. } else {
  42338. for (j = 0; j < n; j++) {
  42339. stack.push(data[i++]);
  42340. }
  42341. }
  42342. } else if (op === 0x41) {
  42343. n = data[i++];
  42344. if (inFDEF || inELSE) {
  42345. i += n * 2;
  42346. } else {
  42347. for (j = 0; j < n; j++) {
  42348. b = data[i++];
  42349. stack.push(b << 8 | data[i++]);
  42350. }
  42351. }
  42352. } else if ((op & 0xF8) === 0xB0) {
  42353. n = op - 0xB0 + 1;
  42354. if (inFDEF || inELSE) {
  42355. i += n;
  42356. } else {
  42357. for (j = 0; j < n; j++) {
  42358. stack.push(data[i++]);
  42359. }
  42360. }
  42361. } else if ((op & 0xF8) === 0xB8) {
  42362. n = op - 0xB8 + 1;
  42363. if (inFDEF || inELSE) {
  42364. i += n * 2;
  42365. } else {
  42366. for (j = 0; j < n; j++) {
  42367. b = data[i++];
  42368. stack.push(b << 8 | data[i++]);
  42369. }
  42370. }
  42371. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42372. if (!inFDEF && !inELSE) {
  42373. funcId = stack[stack.length - 1];
  42374. ttContext.functionsUsed[funcId] = true;
  42375. if (funcId in ttContext.functionsStackDeltas) {
  42376. stack.length += ttContext.functionsStackDeltas[funcId];
  42377. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42378. callstack.push({
  42379. data: data,
  42380. i: i,
  42381. stackTop: stack.length - 1
  42382. });
  42383. functionsCalled.push(funcId);
  42384. pc = ttContext.functionsDefined[funcId];
  42385. if (!pc) {
  42386. warn('TT: CALL non-existent function');
  42387. ttContext.hintsValid = false;
  42388. return;
  42389. }
  42390. data = pc.data;
  42391. i = pc.i;
  42392. }
  42393. }
  42394. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42395. if (inFDEF || inELSE) {
  42396. warn('TT: nested FDEFs not allowed');
  42397. tooComplexToFollowFunctions = true;
  42398. }
  42399. inFDEF = true;
  42400. lastDeff = i;
  42401. funcId = stack.pop();
  42402. ttContext.functionsDefined[funcId] = {
  42403. data: data,
  42404. i: i
  42405. };
  42406. } else if (op === 0x2D) {
  42407. if (inFDEF) {
  42408. inFDEF = false;
  42409. lastEndf = i;
  42410. } else {
  42411. pc = callstack.pop();
  42412. if (!pc) {
  42413. warn('TT: ENDF bad stack');
  42414. ttContext.hintsValid = false;
  42415. return;
  42416. }
  42417. funcId = functionsCalled.pop();
  42418. data = pc.data;
  42419. i = pc.i;
  42420. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42421. }
  42422. } else if (op === 0x89) {
  42423. if (inFDEF || inELSE) {
  42424. warn('TT: nested IDEFs not allowed');
  42425. tooComplexToFollowFunctions = true;
  42426. }
  42427. inFDEF = true;
  42428. lastDeff = i;
  42429. } else if (op === 0x58) {
  42430. ++ifLevel;
  42431. } else if (op === 0x1B) {
  42432. inELSE = ifLevel;
  42433. } else if (op === 0x59) {
  42434. if (inELSE === ifLevel) {
  42435. inELSE = 0;
  42436. }
  42437. --ifLevel;
  42438. } else if (op === 0x1C) {
  42439. if (!inFDEF && !inELSE) {
  42440. var offset = stack[stack.length - 1];
  42441. if (offset > 0) {
  42442. i += offset - 1;
  42443. }
  42444. }
  42445. }
  42446. if (!inFDEF && !inELSE) {
  42447. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42448. if (op >= 0x71 && op <= 0x75) {
  42449. n = stack.pop();
  42450. if (!isNaN(n)) {
  42451. stackDelta = -n * 2;
  42452. }
  42453. }
  42454. while (stackDelta < 0 && stack.length > 0) {
  42455. stack.pop();
  42456. stackDelta++;
  42457. }
  42458. while (stackDelta > 0) {
  42459. stack.push(NaN);
  42460. stackDelta--;
  42461. }
  42462. }
  42463. }
  42464. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42465. var content = [data];
  42466. if (i > data.length) {
  42467. content.push(new Uint8Array(i - data.length));
  42468. }
  42469. if (lastDeff > lastEndf) {
  42470. warn('TT: complementing a missing function tail');
  42471. content.push(new Uint8Array([
  42472. 0x22,
  42473. 0x2D
  42474. ]));
  42475. }
  42476. foldTTTable(table, content);
  42477. }
  42478. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42479. if (ttContext.tooComplexToFollowFunctions) {
  42480. return;
  42481. }
  42482. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42483. warn('TT: more functions defined than expected');
  42484. ttContext.hintsValid = false;
  42485. return;
  42486. }
  42487. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42488. if (j > maxFunctionDefs) {
  42489. warn('TT: invalid function id: ' + j);
  42490. ttContext.hintsValid = false;
  42491. return;
  42492. }
  42493. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42494. warn('TT: undefined function: ' + j);
  42495. ttContext.hintsValid = false;
  42496. return;
  42497. }
  42498. }
  42499. }
  42500. function foldTTTable(table, content) {
  42501. if (content.length > 1) {
  42502. var newLength = 0;
  42503. var j, jj;
  42504. for (j = 0, jj = content.length; j < jj; j++) {
  42505. newLength += content[j].length;
  42506. }
  42507. newLength = newLength + 3 & ~3;
  42508. var result = new Uint8Array(newLength);
  42509. var pos = 0;
  42510. for (j = 0, jj = content.length; j < jj; j++) {
  42511. result.set(content[j], pos);
  42512. pos += content[j].length;
  42513. }
  42514. table.data = result;
  42515. table.length = newLength;
  42516. }
  42517. }
  42518. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42519. var ttContext = {
  42520. functionsDefined: [],
  42521. functionsUsed: [],
  42522. functionsStackDeltas: [],
  42523. tooComplexToFollowFunctions: false,
  42524. hintsValid: true
  42525. };
  42526. if (fpgm) {
  42527. sanitizeTTProgram(fpgm, ttContext);
  42528. }
  42529. if (prep) {
  42530. sanitizeTTProgram(prep, ttContext);
  42531. }
  42532. if (fpgm) {
  42533. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42534. }
  42535. if (cvt && cvt.length & 1) {
  42536. var cvtData = new Uint8Array(cvt.length + 1);
  42537. cvtData.set(cvt.data);
  42538. cvt.data = cvtData;
  42539. }
  42540. return ttContext.hintsValid;
  42541. }
  42542. font = new Stream(new Uint8Array(font.getBytes()));
  42543. var VALID_TABLES = [
  42544. 'OS/2',
  42545. 'cmap',
  42546. 'head',
  42547. 'hhea',
  42548. 'hmtx',
  42549. 'maxp',
  42550. 'name',
  42551. 'post',
  42552. 'loca',
  42553. 'glyf',
  42554. 'fpgm',
  42555. 'prep',
  42556. 'cvt ',
  42557. 'CFF '
  42558. ];
  42559. var header = readOpenTypeHeader(font);
  42560. var numTables = header.numTables;
  42561. var cff, cffFile;
  42562. var tables = Object.create(null);
  42563. tables['OS/2'] = null;
  42564. tables['cmap'] = null;
  42565. tables['head'] = null;
  42566. tables['hhea'] = null;
  42567. tables['hmtx'] = null;
  42568. tables['maxp'] = null;
  42569. tables['name'] = null;
  42570. tables['post'] = null;
  42571. var table;
  42572. for (var i = 0; i < numTables; i++) {
  42573. table = readTableEntry(font);
  42574. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42575. continue;
  42576. }
  42577. if (table.length === 0) {
  42578. continue;
  42579. }
  42580. tables[table.tag] = table;
  42581. }
  42582. var isTrueType = !tables['CFF '];
  42583. if (!isTrueType) {
  42584. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42585. cffFile = new Stream(tables['CFF '].data);
  42586. cff = new CFFFont(cffFile, properties);
  42587. adjustWidths(properties);
  42588. return this.convert(name, cff, properties);
  42589. }
  42590. delete tables['glyf'];
  42591. delete tables['loca'];
  42592. delete tables['fpgm'];
  42593. delete tables['prep'];
  42594. delete tables['cvt '];
  42595. this.isOpenType = true;
  42596. } else {
  42597. if (!tables['loca']) {
  42598. error('Required "loca" table is not found');
  42599. }
  42600. if (!tables['glyf']) {
  42601. warn('Required "glyf" table is not found -- trying to recover.');
  42602. tables['glyf'] = {
  42603. tag: 'glyf',
  42604. data: new Uint8Array(0)
  42605. };
  42606. }
  42607. this.isOpenType = false;
  42608. }
  42609. if (!tables['maxp']) {
  42610. error('Required "maxp" table is not found');
  42611. }
  42612. font.pos = (font.start || 0) + tables['maxp'].offset;
  42613. var version = font.getInt32();
  42614. var numGlyphs = font.getUint16();
  42615. var maxFunctionDefs = 0;
  42616. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42617. font.pos += 8;
  42618. var maxZones = font.getUint16();
  42619. if (maxZones > 2) {
  42620. tables['maxp'].data[14] = 0;
  42621. tables['maxp'].data[15] = 2;
  42622. }
  42623. font.pos += 4;
  42624. maxFunctionDefs = font.getUint16();
  42625. }
  42626. var dupFirstEntry = false;
  42627. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42628. dupFirstEntry = true;
  42629. numGlyphs++;
  42630. tables['maxp'].data[4] = numGlyphs >> 8;
  42631. tables['maxp'].data[5] = numGlyphs & 255;
  42632. }
  42633. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42634. if (!hintsValid) {
  42635. delete tables['fpgm'];
  42636. delete tables['prep'];
  42637. delete tables['cvt '];
  42638. }
  42639. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42640. if (!tables['head']) {
  42641. error('Required "head" table is not found');
  42642. }
  42643. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42644. var missingGlyphs = Object.create(null);
  42645. if (isTrueType) {
  42646. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42647. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42648. }
  42649. if (!tables['hhea']) {
  42650. error('Required "hhea" table is not found');
  42651. }
  42652. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42653. tables['hhea'].data[10] = 0xFF;
  42654. tables['hhea'].data[11] = 0xFF;
  42655. }
  42656. var metricsOverride = {
  42657. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42658. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42659. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42660. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42661. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42662. };
  42663. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42664. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42665. if (tables['post']) {
  42666. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42667. if (!valid) {
  42668. tables['post'] = null;
  42669. }
  42670. }
  42671. var charCodeToGlyphId = [], charCode;
  42672. var toUnicode = properties.toUnicode, widths = properties.widths;
  42673. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42674. function hasGlyph(glyphId, charCode, widthCode) {
  42675. if (!missingGlyphs[glyphId]) {
  42676. return true;
  42677. }
  42678. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42679. return true;
  42680. }
  42681. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42682. return true;
  42683. }
  42684. return false;
  42685. }
  42686. if (properties.composite) {
  42687. var cidToGidMap = properties.cidToGidMap || [];
  42688. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42689. properties.cMap.forEach(function (charCode, cid) {
  42690. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42691. var glyphId = -1;
  42692. if (isCidToGidMapEmpty) {
  42693. glyphId = cid;
  42694. } else if (cidToGidMap[cid] !== undefined) {
  42695. glyphId = cidToGidMap[cid];
  42696. }
  42697. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42698. charCodeToGlyphId[charCode] = glyphId;
  42699. }
  42700. });
  42701. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42702. charCodeToGlyphId[0] = numGlyphs - 1;
  42703. }
  42704. } else {
  42705. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42706. var cmapPlatformId = cmapTable.platformId;
  42707. var cmapEncodingId = cmapTable.encodingId;
  42708. var cmapMappings = cmapTable.mappings;
  42709. var cmapMappingsLength = cmapMappings.length;
  42710. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42711. var baseEncoding = [];
  42712. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42713. baseEncoding = getEncoding(properties.baseEncodingName);
  42714. }
  42715. var glyphsUnicodeMap = getGlyphsUnicode();
  42716. for (charCode = 0; charCode < 256; charCode++) {
  42717. var glyphName, standardGlyphName;
  42718. if (this.differences && charCode in this.differences) {
  42719. glyphName = this.differences[charCode];
  42720. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42721. glyphName = baseEncoding[charCode];
  42722. } else {
  42723. glyphName = StandardEncoding[charCode];
  42724. }
  42725. if (!glyphName) {
  42726. continue;
  42727. }
  42728. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42729. var unicodeOrCharCode, isUnicode = false;
  42730. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42731. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42732. isUnicode = true;
  42733. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42734. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42735. }
  42736. var found = false;
  42737. for (i = 0; i < cmapMappingsLength; ++i) {
  42738. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42739. continue;
  42740. }
  42741. var code = isUnicode ? charCode : unicodeOrCharCode;
  42742. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42743. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42744. found = true;
  42745. break;
  42746. }
  42747. }
  42748. if (!found && properties.glyphNames) {
  42749. var glyphId = properties.glyphNames.indexOf(glyphName);
  42750. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42751. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42752. }
  42753. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42754. charCodeToGlyphId[charCode] = glyphId;
  42755. found = true;
  42756. }
  42757. }
  42758. if (!found) {
  42759. charCodeToGlyphId[charCode] = 0;
  42760. }
  42761. }
  42762. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42763. for (i = 0; i < cmapMappingsLength; ++i) {
  42764. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42765. }
  42766. } else {
  42767. for (i = 0; i < cmapMappingsLength; ++i) {
  42768. charCode = cmapMappings[i].charCode & 0xFF;
  42769. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42770. }
  42771. }
  42772. }
  42773. if (charCodeToGlyphId.length === 0) {
  42774. charCodeToGlyphId[0] = 0;
  42775. }
  42776. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42777. this.toFontChar = newMapping.toFontChar;
  42778. tables['cmap'] = {
  42779. tag: 'cmap',
  42780. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42781. };
  42782. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42783. tables['OS/2'] = {
  42784. tag: 'OS/2',
  42785. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42786. };
  42787. }
  42788. if (!tables['post']) {
  42789. tables['post'] = {
  42790. tag: 'post',
  42791. data: createPostTable(properties)
  42792. };
  42793. }
  42794. if (!isTrueType) {
  42795. try {
  42796. cffFile = new Stream(tables['CFF '].data);
  42797. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42798. cff = parser.parse();
  42799. var compiler = new CFFCompiler(cff);
  42800. tables['CFF '].data = compiler.compile();
  42801. } catch (e) {
  42802. warn('Failed to compile font ' + properties.loadedName);
  42803. }
  42804. }
  42805. if (!tables['name']) {
  42806. tables['name'] = {
  42807. tag: 'name',
  42808. data: createNameTable(this.name)
  42809. };
  42810. } else {
  42811. var namePrototype = readNameTable(tables['name']);
  42812. tables['name'].data = createNameTable(name, namePrototype);
  42813. }
  42814. var builder = new OpenTypeFileBuilder(header.version);
  42815. for (var tableTag in tables) {
  42816. builder.addTable(tableTag, tables[tableTag].data);
  42817. }
  42818. return builder.toArray();
  42819. },
  42820. convert: function Font_convert(fontName, font, properties) {
  42821. properties.fixedPitch = false;
  42822. if (properties.builtInEncoding) {
  42823. adjustToUnicode(properties, properties.builtInEncoding);
  42824. }
  42825. var mapping = font.getGlyphMapping(properties);
  42826. var newMapping = adjustMapping(mapping, properties);
  42827. this.toFontChar = newMapping.toFontChar;
  42828. var numGlyphs = font.numGlyphs;
  42829. function getCharCodes(charCodeToGlyphId, glyphId) {
  42830. var charCodes = null;
  42831. for (var charCode in charCodeToGlyphId) {
  42832. if (glyphId === charCodeToGlyphId[charCode]) {
  42833. if (!charCodes) {
  42834. charCodes = [];
  42835. }
  42836. charCodes.push(charCode | 0);
  42837. }
  42838. }
  42839. return charCodes;
  42840. }
  42841. function createCharCode(charCodeToGlyphId, glyphId) {
  42842. for (var charCode in charCodeToGlyphId) {
  42843. if (glyphId === charCodeToGlyphId[charCode]) {
  42844. return charCode | 0;
  42845. }
  42846. }
  42847. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42848. return newMapping.nextAvailableFontCharCode++;
  42849. }
  42850. var seacs = font.seacs;
  42851. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42852. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42853. var charset = font.getCharset();
  42854. var seacMap = Object.create(null);
  42855. for (var glyphId in seacs) {
  42856. glyphId |= 0;
  42857. var seac = seacs[glyphId];
  42858. var baseGlyphName = StandardEncoding[seac[2]];
  42859. var accentGlyphName = StandardEncoding[seac[3]];
  42860. var baseGlyphId = charset.indexOf(baseGlyphName);
  42861. var accentGlyphId = charset.indexOf(accentGlyphName);
  42862. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42863. continue;
  42864. }
  42865. var accentOffset = {
  42866. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42867. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42868. };
  42869. var charCodes = getCharCodes(mapping, glyphId);
  42870. if (!charCodes) {
  42871. continue;
  42872. }
  42873. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42874. var charCode = charCodes[i];
  42875. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42876. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42877. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42878. seacMap[charCode] = {
  42879. baseFontCharCode: baseFontCharCode,
  42880. accentFontCharCode: accentFontCharCode,
  42881. accentOffset: accentOffset
  42882. };
  42883. }
  42884. }
  42885. properties.seacMap = seacMap;
  42886. }
  42887. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42888. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42889. builder.addTable('CFF ', font.data);
  42890. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42891. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42892. 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');
  42893. 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));
  42894. builder.addTable('hmtx', function fontFieldsHmtx() {
  42895. var charstrings = font.charstrings;
  42896. var cffWidths = font.cff ? font.cff.widths : null;
  42897. var hmtx = '\x00\x00\x00\x00';
  42898. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42899. var width = 0;
  42900. if (charstrings) {
  42901. var charstring = charstrings[i - 1];
  42902. width = 'width' in charstring ? charstring.width : 0;
  42903. } else if (cffWidths) {
  42904. width = Math.ceil(cffWidths[i] || 0);
  42905. }
  42906. hmtx += string16(width) + string16(0);
  42907. }
  42908. return hmtx;
  42909. }());
  42910. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42911. builder.addTable('name', createNameTable(fontName));
  42912. builder.addTable('post', createPostTable(properties));
  42913. return builder.toArray();
  42914. },
  42915. get spaceWidth() {
  42916. if ('_shadowWidth' in this) {
  42917. return this._shadowWidth;
  42918. }
  42919. var possibleSpaceReplacements = [
  42920. 'space',
  42921. 'minus',
  42922. 'one',
  42923. 'i',
  42924. 'I'
  42925. ];
  42926. var width;
  42927. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42928. var glyphName = possibleSpaceReplacements[i];
  42929. if (glyphName in this.widths) {
  42930. width = this.widths[glyphName];
  42931. break;
  42932. }
  42933. var glyphsUnicodeMap = getGlyphsUnicode();
  42934. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42935. var charcode = 0;
  42936. if (this.composite) {
  42937. if (this.cMap.contains(glyphUnicode)) {
  42938. charcode = this.cMap.lookup(glyphUnicode);
  42939. }
  42940. }
  42941. if (!charcode && this.toUnicode) {
  42942. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42943. }
  42944. if (charcode <= 0) {
  42945. charcode = glyphUnicode;
  42946. }
  42947. width = this.widths[charcode];
  42948. if (width) {
  42949. break;
  42950. }
  42951. }
  42952. width = width || this.defaultWidth;
  42953. this._shadowWidth = width;
  42954. return width;
  42955. },
  42956. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42957. var fontCharCode, width, operatorListId;
  42958. var widthCode = charcode;
  42959. if (this.cMap && this.cMap.contains(charcode)) {
  42960. widthCode = this.cMap.lookup(charcode);
  42961. }
  42962. width = this.widths[widthCode];
  42963. width = isNum(width) ? width : this.defaultWidth;
  42964. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42965. var unicode = this.toUnicode.get(charcode) || charcode;
  42966. if (typeof unicode === 'number') {
  42967. unicode = String.fromCharCode(unicode);
  42968. }
  42969. var isInFont = charcode in this.toFontChar;
  42970. fontCharCode = this.toFontChar[charcode] || charcode;
  42971. if (this.missingFile) {
  42972. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42973. }
  42974. if (this.isType3Font) {
  42975. operatorListId = fontCharCode;
  42976. }
  42977. var accent = null;
  42978. if (this.seacMap && this.seacMap[charcode]) {
  42979. isInFont = true;
  42980. var seac = this.seacMap[charcode];
  42981. fontCharCode = seac.baseFontCharCode;
  42982. accent = {
  42983. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42984. offset: seac.accentOffset
  42985. };
  42986. }
  42987. var fontChar = String.fromCharCode(fontCharCode);
  42988. var glyph = this.glyphCache[charcode];
  42989. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42990. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42991. this.glyphCache[charcode] = glyph;
  42992. }
  42993. return glyph;
  42994. },
  42995. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42996. var charsCache = this.charsCache;
  42997. var glyphs, glyph, charcode;
  42998. if (charsCache) {
  42999. glyphs = charsCache[chars];
  43000. if (glyphs) {
  43001. return glyphs;
  43002. }
  43003. }
  43004. if (!charsCache) {
  43005. charsCache = this.charsCache = Object.create(null);
  43006. }
  43007. glyphs = [];
  43008. var charsCacheKey = chars;
  43009. var i = 0, ii;
  43010. if (this.cMap) {
  43011. var c = Object.create(null);
  43012. while (i < chars.length) {
  43013. this.cMap.readCharCode(chars, i, c);
  43014. charcode = c.charcode;
  43015. var length = c.length;
  43016. i += length;
  43017. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  43018. glyph = this.charToGlyph(charcode, isSpace);
  43019. glyphs.push(glyph);
  43020. }
  43021. } else {
  43022. for (i = 0, ii = chars.length; i < ii; ++i) {
  43023. charcode = chars.charCodeAt(i);
  43024. glyph = this.charToGlyph(charcode, charcode === 0x20);
  43025. glyphs.push(glyph);
  43026. }
  43027. }
  43028. return charsCache[charsCacheKey] = glyphs;
  43029. }
  43030. };
  43031. return Font;
  43032. }();
  43033. var ErrorFont = function ErrorFontClosure() {
  43034. function ErrorFont(error) {
  43035. this.error = error;
  43036. this.loadedName = 'g_font_error';
  43037. this.loading = false;
  43038. }
  43039. ErrorFont.prototype = {
  43040. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  43041. return [];
  43042. },
  43043. exportData: function ErrorFont_exportData() {
  43044. return { error: this.error };
  43045. }
  43046. };
  43047. return ErrorFont;
  43048. }();
  43049. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  43050. var charCodeToGlyphId = Object.create(null);
  43051. var glyphId, charCode, baseEncoding;
  43052. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43053. if (properties.baseEncodingName) {
  43054. baseEncoding = getEncoding(properties.baseEncodingName);
  43055. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  43056. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  43057. if (glyphId >= 0) {
  43058. charCodeToGlyphId[charCode] = glyphId;
  43059. } else {
  43060. charCodeToGlyphId[charCode] = 0;
  43061. }
  43062. }
  43063. } else if (isSymbolicFont) {
  43064. for (charCode in builtInEncoding) {
  43065. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  43066. }
  43067. } else {
  43068. baseEncoding = StandardEncoding;
  43069. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  43070. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  43071. if (glyphId >= 0) {
  43072. charCodeToGlyphId[charCode] = glyphId;
  43073. } else {
  43074. charCodeToGlyphId[charCode] = 0;
  43075. }
  43076. }
  43077. }
  43078. var differences = properties.differences, glyphsUnicodeMap;
  43079. if (differences) {
  43080. for (charCode in differences) {
  43081. var glyphName = differences[charCode];
  43082. glyphId = glyphNames.indexOf(glyphName);
  43083. if (glyphId === -1) {
  43084. if (!glyphsUnicodeMap) {
  43085. glyphsUnicodeMap = getGlyphsUnicode();
  43086. }
  43087. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  43088. if (standardGlyphName !== glyphName) {
  43089. glyphId = glyphNames.indexOf(standardGlyphName);
  43090. }
  43091. }
  43092. if (glyphId >= 0) {
  43093. charCodeToGlyphId[charCode] = glyphId;
  43094. } else {
  43095. charCodeToGlyphId[charCode] = 0;
  43096. }
  43097. }
  43098. }
  43099. return charCodeToGlyphId;
  43100. }
  43101. var Type1Font = function Type1FontClosure() {
  43102. function findBlock(streamBytes, signature, startIndex) {
  43103. var streamBytesLength = streamBytes.length;
  43104. var signatureLength = signature.length;
  43105. var scanLength = streamBytesLength - signatureLength;
  43106. var i = startIndex, j, found = false;
  43107. while (i < scanLength) {
  43108. j = 0;
  43109. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  43110. j++;
  43111. }
  43112. if (j >= signatureLength) {
  43113. i += j;
  43114. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  43115. i++;
  43116. }
  43117. found = true;
  43118. break;
  43119. }
  43120. i++;
  43121. }
  43122. return {
  43123. found: found,
  43124. length: i
  43125. };
  43126. }
  43127. function getHeaderBlock(stream, suggestedLength) {
  43128. var EEXEC_SIGNATURE = [
  43129. 0x65,
  43130. 0x65,
  43131. 0x78,
  43132. 0x65,
  43133. 0x63
  43134. ];
  43135. var streamStartPos = stream.pos;
  43136. var headerBytes, headerBytesLength, block;
  43137. try {
  43138. headerBytes = stream.getBytes(suggestedLength);
  43139. headerBytesLength = headerBytes.length;
  43140. } catch (ex) {
  43141. if (ex instanceof MissingDataException) {
  43142. throw ex;
  43143. }
  43144. }
  43145. if (headerBytesLength === suggestedLength) {
  43146. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  43147. if (block.found && block.length === suggestedLength) {
  43148. return {
  43149. stream: new Stream(headerBytes),
  43150. length: suggestedLength
  43151. };
  43152. }
  43153. }
  43154. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  43155. stream.pos = streamStartPos;
  43156. var SCAN_BLOCK_LENGTH = 2048;
  43157. var actualLength;
  43158. while (true) {
  43159. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  43160. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  43161. if (block.length === 0) {
  43162. break;
  43163. }
  43164. stream.pos += block.length;
  43165. if (block.found) {
  43166. actualLength = stream.pos - streamStartPos;
  43167. break;
  43168. }
  43169. }
  43170. stream.pos = streamStartPos;
  43171. if (actualLength) {
  43172. return {
  43173. stream: new Stream(stream.getBytes(actualLength)),
  43174. length: actualLength
  43175. };
  43176. }
  43177. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43178. return {
  43179. stream: new Stream(stream.getBytes(suggestedLength)),
  43180. length: suggestedLength
  43181. };
  43182. }
  43183. function getEexecBlock(stream, suggestedLength) {
  43184. var eexecBytes = stream.getBytes();
  43185. return {
  43186. stream: new Stream(eexecBytes),
  43187. length: eexecBytes.length
  43188. };
  43189. }
  43190. function Type1Font(name, file, properties) {
  43191. var PFB_HEADER_SIZE = 6;
  43192. var headerBlockLength = properties.length1;
  43193. var eexecBlockLength = properties.length2;
  43194. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43195. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43196. if (pfbHeaderPresent) {
  43197. file.skip(PFB_HEADER_SIZE);
  43198. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43199. }
  43200. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43201. headerBlockLength = headerBlock.length;
  43202. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43203. headerBlockParser.extractFontHeader(properties);
  43204. if (pfbHeaderPresent) {
  43205. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43206. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43207. }
  43208. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43209. eexecBlockLength = eexecBlock.length;
  43210. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43211. var data = eexecBlockParser.extractFontProgram();
  43212. for (var info in data.properties) {
  43213. properties[info] = data.properties[info];
  43214. }
  43215. var charstrings = data.charstrings;
  43216. var type2Charstrings = this.getType2Charstrings(charstrings);
  43217. var subrs = this.getType2Subrs(data.subrs);
  43218. this.charstrings = charstrings;
  43219. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43220. this.seacs = this.getSeacs(data.charstrings);
  43221. }
  43222. Type1Font.prototype = {
  43223. get numGlyphs() {
  43224. return this.charstrings.length + 1;
  43225. },
  43226. getCharset: function Type1Font_getCharset() {
  43227. var charset = ['.notdef'];
  43228. var charstrings = this.charstrings;
  43229. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43230. charset.push(charstrings[glyphId].glyphName);
  43231. }
  43232. return charset;
  43233. },
  43234. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43235. var charstrings = this.charstrings;
  43236. var glyphNames = ['.notdef'], glyphId;
  43237. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43238. glyphNames.push(charstrings[glyphId].glyphName);
  43239. }
  43240. var encoding = properties.builtInEncoding;
  43241. if (encoding) {
  43242. var builtInEncoding = Object.create(null);
  43243. for (var charCode in encoding) {
  43244. glyphId = glyphNames.indexOf(encoding[charCode]);
  43245. if (glyphId >= 0) {
  43246. builtInEncoding[charCode] = glyphId;
  43247. }
  43248. }
  43249. }
  43250. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43251. },
  43252. getSeacs: function Type1Font_getSeacs(charstrings) {
  43253. var i, ii;
  43254. var seacMap = [];
  43255. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43256. var charstring = charstrings[i];
  43257. if (charstring.seac) {
  43258. seacMap[i + 1] = charstring.seac;
  43259. }
  43260. }
  43261. return seacMap;
  43262. },
  43263. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43264. var type2Charstrings = [];
  43265. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43266. type2Charstrings.push(type1Charstrings[i].charstring);
  43267. }
  43268. return type2Charstrings;
  43269. },
  43270. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43271. var bias = 0;
  43272. var count = type1Subrs.length;
  43273. if (count < 1133) {
  43274. bias = 107;
  43275. } else if (count < 33769) {
  43276. bias = 1131;
  43277. } else {
  43278. bias = 32768;
  43279. }
  43280. var type2Subrs = [];
  43281. var i;
  43282. for (i = 0; i < bias; i++) {
  43283. type2Subrs.push([0x0B]);
  43284. }
  43285. for (i = 0; i < count; i++) {
  43286. type2Subrs.push(type1Subrs[i]);
  43287. }
  43288. return type2Subrs;
  43289. },
  43290. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43291. var cff = new CFF();
  43292. cff.header = new CFFHeader(1, 0, 4, 4);
  43293. cff.names = [name];
  43294. var topDict = new CFFTopDict();
  43295. topDict.setByName('version', 391);
  43296. topDict.setByName('Notice', 392);
  43297. topDict.setByName('FullName', 393);
  43298. topDict.setByName('FamilyName', 394);
  43299. topDict.setByName('Weight', 395);
  43300. topDict.setByName('Encoding', null);
  43301. topDict.setByName('FontMatrix', properties.fontMatrix);
  43302. topDict.setByName('FontBBox', properties.bbox);
  43303. topDict.setByName('charset', null);
  43304. topDict.setByName('CharStrings', null);
  43305. topDict.setByName('Private', null);
  43306. cff.topDict = topDict;
  43307. var strings = new CFFStrings();
  43308. strings.add('Version 0.11');
  43309. strings.add('See original notice');
  43310. strings.add(name);
  43311. strings.add(name);
  43312. strings.add('Medium');
  43313. cff.strings = strings;
  43314. cff.globalSubrIndex = new CFFIndex();
  43315. var count = glyphs.length;
  43316. var charsetArray = [0];
  43317. var i, ii;
  43318. for (i = 0; i < count; i++) {
  43319. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43320. if (index === -1) {
  43321. index = 0;
  43322. }
  43323. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43324. }
  43325. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43326. var charStringsIndex = new CFFIndex();
  43327. charStringsIndex.add([
  43328. 0x8B,
  43329. 0x0E
  43330. ]);
  43331. for (i = 0; i < count; i++) {
  43332. var glyph = glyphs[i];
  43333. if (glyph.length === 0) {
  43334. charStringsIndex.add([
  43335. 0x8B,
  43336. 0x0E
  43337. ]);
  43338. continue;
  43339. }
  43340. charStringsIndex.add(glyph);
  43341. }
  43342. cff.charStrings = charStringsIndex;
  43343. var privateDict = new CFFPrivateDict();
  43344. privateDict.setByName('Subrs', null);
  43345. var fields = [
  43346. 'BlueValues',
  43347. 'OtherBlues',
  43348. 'FamilyBlues',
  43349. 'FamilyOtherBlues',
  43350. 'StemSnapH',
  43351. 'StemSnapV',
  43352. 'BlueShift',
  43353. 'BlueFuzz',
  43354. 'BlueScale',
  43355. 'LanguageGroup',
  43356. 'ExpansionFactor',
  43357. 'ForceBold',
  43358. 'StdHW',
  43359. 'StdVW'
  43360. ];
  43361. for (i = 0, ii = fields.length; i < ii; i++) {
  43362. var field = fields[i];
  43363. if (!(field in properties.privateData)) {
  43364. continue;
  43365. }
  43366. var value = properties.privateData[field];
  43367. if (isArray(value)) {
  43368. for (var j = value.length - 1; j > 0; j--) {
  43369. value[j] -= value[j - 1];
  43370. }
  43371. }
  43372. privateDict.setByName(field, value);
  43373. }
  43374. cff.topDict.privateDict = privateDict;
  43375. var subrIndex = new CFFIndex();
  43376. for (i = 0, ii = subrs.length; i < ii; i++) {
  43377. subrIndex.add(subrs[i]);
  43378. }
  43379. privateDict.subrsIndex = subrIndex;
  43380. var compiler = new CFFCompiler(cff);
  43381. return compiler.compile();
  43382. }
  43383. };
  43384. return Type1Font;
  43385. }();
  43386. var CFFFont = function CFFFontClosure() {
  43387. function CFFFont(file, properties) {
  43388. this.properties = properties;
  43389. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43390. this.cff = parser.parse();
  43391. var compiler = new CFFCompiler(this.cff);
  43392. this.seacs = this.cff.seacs;
  43393. try {
  43394. this.data = compiler.compile();
  43395. } catch (e) {
  43396. warn('Failed to compile font ' + properties.loadedName);
  43397. this.data = file;
  43398. }
  43399. }
  43400. CFFFont.prototype = {
  43401. get numGlyphs() {
  43402. return this.cff.charStrings.count;
  43403. },
  43404. getCharset: function CFFFont_getCharset() {
  43405. return this.cff.charset.charset;
  43406. },
  43407. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43408. var cff = this.cff;
  43409. var properties = this.properties;
  43410. var charsets = cff.charset.charset;
  43411. var charCodeToGlyphId;
  43412. var glyphId;
  43413. if (properties.composite) {
  43414. charCodeToGlyphId = Object.create(null);
  43415. if (cff.isCIDFont) {
  43416. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43417. var cid = charsets[glyphId];
  43418. var charCode = properties.cMap.charCodeOf(cid);
  43419. charCodeToGlyphId[charCode] = glyphId;
  43420. }
  43421. } else {
  43422. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43423. charCodeToGlyphId[glyphId] = glyphId;
  43424. }
  43425. }
  43426. return charCodeToGlyphId;
  43427. }
  43428. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43429. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43430. return charCodeToGlyphId;
  43431. }
  43432. };
  43433. return CFFFont;
  43434. }();
  43435. (function checkSeacSupport() {
  43436. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43437. SEAC_ANALYSIS_ENABLED = true;
  43438. }
  43439. }());
  43440. (function checkChromeWindows() {
  43441. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43442. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43443. }
  43444. }());
  43445. exports.ErrorFont = ErrorFont;
  43446. exports.Font = Font;
  43447. exports.FontFlags = FontFlags;
  43448. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43449. exports.ToUnicodeMap = ToUnicodeMap;
  43450. exports.getFontType = getFontType;
  43451. }));
  43452. (function (root, factory) {
  43453. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43454. }(this, function (exports, sharedUtil, coreParser) {
  43455. var error = sharedUtil.error;
  43456. var isSpace = sharedUtil.isSpace;
  43457. var EOF = coreParser.EOF;
  43458. var PostScriptParser = function PostScriptParserClosure() {
  43459. function PostScriptParser(lexer) {
  43460. this.lexer = lexer;
  43461. this.operators = [];
  43462. this.token = null;
  43463. this.prev = null;
  43464. }
  43465. PostScriptParser.prototype = {
  43466. nextToken: function PostScriptParser_nextToken() {
  43467. this.prev = this.token;
  43468. this.token = this.lexer.getToken();
  43469. },
  43470. accept: function PostScriptParser_accept(type) {
  43471. if (this.token.type === type) {
  43472. this.nextToken();
  43473. return true;
  43474. }
  43475. return false;
  43476. },
  43477. expect: function PostScriptParser_expect(type) {
  43478. if (this.accept(type)) {
  43479. return true;
  43480. }
  43481. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43482. },
  43483. parse: function PostScriptParser_parse() {
  43484. this.nextToken();
  43485. this.expect(PostScriptTokenTypes.LBRACE);
  43486. this.parseBlock();
  43487. this.expect(PostScriptTokenTypes.RBRACE);
  43488. return this.operators;
  43489. },
  43490. parseBlock: function PostScriptParser_parseBlock() {
  43491. while (true) {
  43492. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43493. this.operators.push(this.prev.value);
  43494. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43495. this.operators.push(this.prev.value);
  43496. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43497. this.parseCondition();
  43498. } else {
  43499. return;
  43500. }
  43501. }
  43502. },
  43503. parseCondition: function PostScriptParser_parseCondition() {
  43504. var conditionLocation = this.operators.length;
  43505. this.operators.push(null, null);
  43506. this.parseBlock();
  43507. this.expect(PostScriptTokenTypes.RBRACE);
  43508. if (this.accept(PostScriptTokenTypes.IF)) {
  43509. this.operators[conditionLocation] = this.operators.length;
  43510. this.operators[conditionLocation + 1] = 'jz';
  43511. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43512. var jumpLocation = this.operators.length;
  43513. this.operators.push(null, null);
  43514. var endOfTrue = this.operators.length;
  43515. this.parseBlock();
  43516. this.expect(PostScriptTokenTypes.RBRACE);
  43517. this.expect(PostScriptTokenTypes.IFELSE);
  43518. this.operators[jumpLocation] = this.operators.length;
  43519. this.operators[jumpLocation + 1] = 'j';
  43520. this.operators[conditionLocation] = endOfTrue;
  43521. this.operators[conditionLocation + 1] = 'jz';
  43522. } else {
  43523. error('PS Function: error parsing conditional.');
  43524. }
  43525. }
  43526. };
  43527. return PostScriptParser;
  43528. }();
  43529. var PostScriptTokenTypes = {
  43530. LBRACE: 0,
  43531. RBRACE: 1,
  43532. NUMBER: 2,
  43533. OPERATOR: 3,
  43534. IF: 4,
  43535. IFELSE: 5
  43536. };
  43537. var PostScriptToken = function PostScriptTokenClosure() {
  43538. function PostScriptToken(type, value) {
  43539. this.type = type;
  43540. this.value = value;
  43541. }
  43542. var opCache = Object.create(null);
  43543. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43544. var opValue = opCache[op];
  43545. if (opValue) {
  43546. return opValue;
  43547. }
  43548. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43549. };
  43550. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43551. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43552. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43553. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43554. return PostScriptToken;
  43555. }();
  43556. var PostScriptLexer = function PostScriptLexerClosure() {
  43557. function PostScriptLexer(stream) {
  43558. this.stream = stream;
  43559. this.nextChar();
  43560. this.strBuf = [];
  43561. }
  43562. PostScriptLexer.prototype = {
  43563. nextChar: function PostScriptLexer_nextChar() {
  43564. return this.currentChar = this.stream.getByte();
  43565. },
  43566. getToken: function PostScriptLexer_getToken() {
  43567. var comment = false;
  43568. var ch = this.currentChar;
  43569. while (true) {
  43570. if (ch < 0) {
  43571. return EOF;
  43572. }
  43573. if (comment) {
  43574. if (ch === 0x0A || ch === 0x0D) {
  43575. comment = false;
  43576. }
  43577. } else if (ch === 0x25) {
  43578. comment = true;
  43579. } else if (!isSpace(ch)) {
  43580. break;
  43581. }
  43582. ch = this.nextChar();
  43583. }
  43584. switch (ch | 0) {
  43585. case 0x30:
  43586. case 0x31:
  43587. case 0x32:
  43588. case 0x33:
  43589. case 0x34:
  43590. case 0x35:
  43591. case 0x36:
  43592. case 0x37:
  43593. case 0x38:
  43594. case 0x39:
  43595. case 0x2B:
  43596. case 0x2D:
  43597. case 0x2E:
  43598. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43599. case 0x7B:
  43600. this.nextChar();
  43601. return PostScriptToken.LBRACE;
  43602. case 0x7D:
  43603. this.nextChar();
  43604. return PostScriptToken.RBRACE;
  43605. }
  43606. var strBuf = this.strBuf;
  43607. strBuf.length = 0;
  43608. strBuf[0] = String.fromCharCode(ch);
  43609. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43610. strBuf.push(String.fromCharCode(ch));
  43611. }
  43612. var str = strBuf.join('');
  43613. switch (str.toLowerCase()) {
  43614. case 'if':
  43615. return PostScriptToken.IF;
  43616. case 'ifelse':
  43617. return PostScriptToken.IFELSE;
  43618. default:
  43619. return PostScriptToken.getOperator(str);
  43620. }
  43621. },
  43622. getNumber: function PostScriptLexer_getNumber() {
  43623. var ch = this.currentChar;
  43624. var strBuf = this.strBuf;
  43625. strBuf.length = 0;
  43626. strBuf[0] = String.fromCharCode(ch);
  43627. while ((ch = this.nextChar()) >= 0) {
  43628. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43629. strBuf.push(String.fromCharCode(ch));
  43630. } else {
  43631. break;
  43632. }
  43633. }
  43634. var value = parseFloat(strBuf.join(''));
  43635. if (isNaN(value)) {
  43636. error('Invalid floating point number: ' + value);
  43637. }
  43638. return value;
  43639. }
  43640. };
  43641. return PostScriptLexer;
  43642. }();
  43643. exports.PostScriptLexer = PostScriptLexer;
  43644. exports.PostScriptParser = PostScriptParser;
  43645. }));
  43646. (function (root, factory) {
  43647. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43648. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43649. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43650. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43651. var ImageKind = sharedUtil.ImageKind;
  43652. var OPS = sharedUtil.OPS;
  43653. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43654. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43655. var Util = sharedUtil.Util;
  43656. var assert = sharedUtil.assert;
  43657. var info = sharedUtil.info;
  43658. var isNum = sharedUtil.isNum;
  43659. var isArray = sharedUtil.isArray;
  43660. var isLittleEndian = sharedUtil.isLittleEndian;
  43661. var error = sharedUtil.error;
  43662. var shadow = sharedUtil.shadow;
  43663. var warn = sharedUtil.warn;
  43664. var TilingPattern = displayPatternHelper.TilingPattern;
  43665. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43666. var WebGLUtils = displayWebGL.WebGLUtils;
  43667. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43668. var MIN_FONT_SIZE = 16;
  43669. var MAX_FONT_SIZE = 100;
  43670. var MAX_GROUP_SIZE = 4096;
  43671. var MIN_WIDTH_FACTOR = 0.65;
  43672. var COMPILE_TYPE3_GLYPHS = true;
  43673. var MAX_SIZE_TO_COMPILE = 1000;
  43674. var FULL_CHUNK_HEIGHT = 16;
  43675. var HasCanvasTypedArraysCached = {
  43676. get value() {
  43677. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43678. }
  43679. };
  43680. var IsLittleEndianCached = {
  43681. get value() {
  43682. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43683. }
  43684. };
  43685. function createScratchCanvas(width, height) {
  43686. var canvas = document.createElement('canvas');
  43687. canvas.width = width;
  43688. canvas.height = height;
  43689. return canvas;
  43690. }
  43691. function addContextCurrentTransform(ctx) {
  43692. if (!ctx.mozCurrentTransform) {
  43693. ctx._originalSave = ctx.save;
  43694. ctx._originalRestore = ctx.restore;
  43695. ctx._originalRotate = ctx.rotate;
  43696. ctx._originalScale = ctx.scale;
  43697. ctx._originalTranslate = ctx.translate;
  43698. ctx._originalTransform = ctx.transform;
  43699. ctx._originalSetTransform = ctx.setTransform;
  43700. ctx._transformMatrix = ctx._transformMatrix || [
  43701. 1,
  43702. 0,
  43703. 0,
  43704. 1,
  43705. 0,
  43706. 0
  43707. ];
  43708. ctx._transformStack = [];
  43709. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43710. get: function getCurrentTransform() {
  43711. return this._transformMatrix;
  43712. }
  43713. });
  43714. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43715. get: function getCurrentTransformInverse() {
  43716. var m = this._transformMatrix;
  43717. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43718. var ad_bc = a * d - b * c;
  43719. var bc_ad = b * c - a * d;
  43720. return [
  43721. d / ad_bc,
  43722. b / bc_ad,
  43723. c / bc_ad,
  43724. a / ad_bc,
  43725. (d * e - c * f) / bc_ad,
  43726. (b * e - a * f) / ad_bc
  43727. ];
  43728. }
  43729. });
  43730. ctx.save = function ctxSave() {
  43731. var old = this._transformMatrix;
  43732. this._transformStack.push(old);
  43733. this._transformMatrix = old.slice(0, 6);
  43734. this._originalSave();
  43735. };
  43736. ctx.restore = function ctxRestore() {
  43737. var prev = this._transformStack.pop();
  43738. if (prev) {
  43739. this._transformMatrix = prev;
  43740. this._originalRestore();
  43741. }
  43742. };
  43743. ctx.translate = function ctxTranslate(x, y) {
  43744. var m = this._transformMatrix;
  43745. m[4] = m[0] * x + m[2] * y + m[4];
  43746. m[5] = m[1] * x + m[3] * y + m[5];
  43747. this._originalTranslate(x, y);
  43748. };
  43749. ctx.scale = function ctxScale(x, y) {
  43750. var m = this._transformMatrix;
  43751. m[0] = m[0] * x;
  43752. m[1] = m[1] * x;
  43753. m[2] = m[2] * y;
  43754. m[3] = m[3] * y;
  43755. this._originalScale(x, y);
  43756. };
  43757. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43758. var m = this._transformMatrix;
  43759. this._transformMatrix = [
  43760. m[0] * a + m[2] * b,
  43761. m[1] * a + m[3] * b,
  43762. m[0] * c + m[2] * d,
  43763. m[1] * c + m[3] * d,
  43764. m[0] * e + m[2] * f + m[4],
  43765. m[1] * e + m[3] * f + m[5]
  43766. ];
  43767. ctx._originalTransform(a, b, c, d, e, f);
  43768. };
  43769. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43770. this._transformMatrix = [
  43771. a,
  43772. b,
  43773. c,
  43774. d,
  43775. e,
  43776. f
  43777. ];
  43778. ctx._originalSetTransform(a, b, c, d, e, f);
  43779. };
  43780. ctx.rotate = function ctxRotate(angle) {
  43781. var cosValue = Math.cos(angle);
  43782. var sinValue = Math.sin(angle);
  43783. var m = this._transformMatrix;
  43784. this._transformMatrix = [
  43785. m[0] * cosValue + m[2] * sinValue,
  43786. m[1] * cosValue + m[3] * sinValue,
  43787. m[0] * -sinValue + m[2] * cosValue,
  43788. m[1] * -sinValue + m[3] * cosValue,
  43789. m[4],
  43790. m[5]
  43791. ];
  43792. this._originalRotate(angle);
  43793. };
  43794. }
  43795. }
  43796. var CachedCanvases = function CachedCanvasesClosure() {
  43797. function CachedCanvases() {
  43798. this.cache = Object.create(null);
  43799. }
  43800. CachedCanvases.prototype = {
  43801. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43802. var canvasEntry;
  43803. if (this.cache[id] !== undefined) {
  43804. canvasEntry = this.cache[id];
  43805. canvasEntry.canvas.width = width;
  43806. canvasEntry.canvas.height = height;
  43807. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43808. } else {
  43809. var canvas = createScratchCanvas(width, height);
  43810. var ctx = canvas.getContext('2d');
  43811. if (trackTransform) {
  43812. addContextCurrentTransform(ctx);
  43813. }
  43814. this.cache[id] = canvasEntry = {
  43815. canvas: canvas,
  43816. context: ctx
  43817. };
  43818. }
  43819. return canvasEntry;
  43820. },
  43821. clear: function () {
  43822. for (var id in this.cache) {
  43823. var canvasEntry = this.cache[id];
  43824. canvasEntry.canvas.width = 0;
  43825. canvasEntry.canvas.height = 0;
  43826. delete this.cache[id];
  43827. }
  43828. }
  43829. };
  43830. return CachedCanvases;
  43831. }();
  43832. function compileType3Glyph(imgData) {
  43833. var POINT_TO_PROCESS_LIMIT = 1000;
  43834. var width = imgData.width, height = imgData.height;
  43835. var i, j, j0, width1 = width + 1;
  43836. var points = new Uint8Array(width1 * (height + 1));
  43837. var POINT_TYPES = new Uint8Array([
  43838. 0,
  43839. 2,
  43840. 4,
  43841. 0,
  43842. 1,
  43843. 0,
  43844. 5,
  43845. 4,
  43846. 8,
  43847. 10,
  43848. 0,
  43849. 8,
  43850. 0,
  43851. 2,
  43852. 1,
  43853. 0
  43854. ]);
  43855. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43856. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43857. for (i = 0, ii = data0.length; i < ii; i++) {
  43858. var mask = 128, elem = data0[i];
  43859. while (mask > 0) {
  43860. data[pos++] = elem & mask ? 0 : 255;
  43861. mask >>= 1;
  43862. }
  43863. }
  43864. var count = 0;
  43865. pos = 0;
  43866. if (data[pos] !== 0) {
  43867. points[0] = 1;
  43868. ++count;
  43869. }
  43870. for (j = 1; j < width; j++) {
  43871. if (data[pos] !== data[pos + 1]) {
  43872. points[j] = data[pos] ? 2 : 1;
  43873. ++count;
  43874. }
  43875. pos++;
  43876. }
  43877. if (data[pos] !== 0) {
  43878. points[j] = 2;
  43879. ++count;
  43880. }
  43881. for (i = 1; i < height; i++) {
  43882. pos = i * lineSize;
  43883. j0 = i * width1;
  43884. if (data[pos - lineSize] !== data[pos]) {
  43885. points[j0] = data[pos] ? 1 : 8;
  43886. ++count;
  43887. }
  43888. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43889. for (j = 1; j < width; j++) {
  43890. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43891. if (POINT_TYPES[sum]) {
  43892. points[j0 + j] = POINT_TYPES[sum];
  43893. ++count;
  43894. }
  43895. pos++;
  43896. }
  43897. if (data[pos - lineSize] !== data[pos]) {
  43898. points[j0 + j] = data[pos] ? 2 : 4;
  43899. ++count;
  43900. }
  43901. if (count > POINT_TO_PROCESS_LIMIT) {
  43902. return null;
  43903. }
  43904. }
  43905. pos = lineSize * (height - 1);
  43906. j0 = i * width1;
  43907. if (data[pos] !== 0) {
  43908. points[j0] = 8;
  43909. ++count;
  43910. }
  43911. for (j = 1; j < width; j++) {
  43912. if (data[pos] !== data[pos + 1]) {
  43913. points[j0 + j] = data[pos] ? 4 : 8;
  43914. ++count;
  43915. }
  43916. pos++;
  43917. }
  43918. if (data[pos] !== 0) {
  43919. points[j0 + j] = 4;
  43920. ++count;
  43921. }
  43922. if (count > POINT_TO_PROCESS_LIMIT) {
  43923. return null;
  43924. }
  43925. var steps = new Int32Array([
  43926. 0,
  43927. width1,
  43928. -1,
  43929. 0,
  43930. -width1,
  43931. 0,
  43932. 0,
  43933. 0,
  43934. 1
  43935. ]);
  43936. var outlines = [];
  43937. for (i = 0; count && i <= height; i++) {
  43938. var p = i * width1;
  43939. var end = p + width;
  43940. while (p < end && !points[p]) {
  43941. p++;
  43942. }
  43943. if (p === end) {
  43944. continue;
  43945. }
  43946. var coords = [
  43947. p % width1,
  43948. i
  43949. ];
  43950. var type = points[p], p0 = p, pp;
  43951. do {
  43952. var step = steps[type];
  43953. do {
  43954. p += step;
  43955. } while (!points[p]);
  43956. pp = points[p];
  43957. if (pp !== 5 && pp !== 10) {
  43958. type = pp;
  43959. points[p] = 0;
  43960. } else {
  43961. type = pp & 0x33 * type >> 4;
  43962. points[p] &= type >> 2 | type << 2;
  43963. }
  43964. coords.push(p % width1);
  43965. coords.push(p / width1 | 0);
  43966. --count;
  43967. } while (p0 !== p);
  43968. outlines.push(coords);
  43969. --i;
  43970. }
  43971. var drawOutline = function (c) {
  43972. c.save();
  43973. c.scale(1 / width, -1 / height);
  43974. c.translate(0, -height);
  43975. c.beginPath();
  43976. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43977. var o = outlines[i];
  43978. c.moveTo(o[0], o[1]);
  43979. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43980. c.lineTo(o[j], o[j + 1]);
  43981. }
  43982. }
  43983. c.fill();
  43984. c.beginPath();
  43985. c.restore();
  43986. };
  43987. return drawOutline;
  43988. }
  43989. var CanvasExtraState = function CanvasExtraStateClosure() {
  43990. function CanvasExtraState(old) {
  43991. this.alphaIsShape = false;
  43992. this.fontSize = 0;
  43993. this.fontSizeScale = 1;
  43994. this.textMatrix = IDENTITY_MATRIX;
  43995. this.textMatrixScale = 1;
  43996. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43997. this.leading = 0;
  43998. this.x = 0;
  43999. this.y = 0;
  44000. this.lineX = 0;
  44001. this.lineY = 0;
  44002. this.charSpacing = 0;
  44003. this.wordSpacing = 0;
  44004. this.textHScale = 1;
  44005. this.textRenderingMode = TextRenderingMode.FILL;
  44006. this.textRise = 0;
  44007. this.fillColor = '#000000';
  44008. this.strokeColor = '#000000';
  44009. this.patternFill = false;
  44010. this.fillAlpha = 1;
  44011. this.strokeAlpha = 1;
  44012. this.lineWidth = 1;
  44013. this.activeSMask = null;
  44014. this.resumeSMaskCtx = null;
  44015. this.old = old;
  44016. }
  44017. CanvasExtraState.prototype = {
  44018. clone: function CanvasExtraState_clone() {
  44019. return Object.create(this);
  44020. },
  44021. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  44022. this.x = x;
  44023. this.y = y;
  44024. }
  44025. };
  44026. return CanvasExtraState;
  44027. }();
  44028. var CanvasGraphics = function CanvasGraphicsClosure() {
  44029. var EXECUTION_TIME = 15;
  44030. var EXECUTION_STEPS = 10;
  44031. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  44032. this.ctx = canvasCtx;
  44033. this.current = new CanvasExtraState();
  44034. this.stateStack = [];
  44035. this.pendingClip = null;
  44036. this.pendingEOFill = false;
  44037. this.res = null;
  44038. this.xobjs = null;
  44039. this.commonObjs = commonObjs;
  44040. this.objs = objs;
  44041. this.imageLayer = imageLayer;
  44042. this.groupStack = [];
  44043. this.processingType3 = null;
  44044. this.baseTransform = null;
  44045. this.baseTransformStack = [];
  44046. this.groupLevel = 0;
  44047. this.smaskStack = [];
  44048. this.smaskCounter = 0;
  44049. this.tempSMask = null;
  44050. this.cachedCanvases = new CachedCanvases();
  44051. if (canvasCtx) {
  44052. addContextCurrentTransform(canvasCtx);
  44053. }
  44054. this.cachedGetSinglePixelWidth = null;
  44055. }
  44056. function putBinaryImageData(ctx, imgData) {
  44057. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  44058. ctx.putImageData(imgData, 0, 0);
  44059. return;
  44060. }
  44061. var height = imgData.height, width = imgData.width;
  44062. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  44063. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  44064. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  44065. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  44066. var srcPos = 0, destPos;
  44067. var src = imgData.data;
  44068. var dest = chunkImgData.data;
  44069. var i, j, thisChunkHeight, elemsInThisChunk;
  44070. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  44071. var srcLength = src.byteLength;
  44072. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  44073. var dest32DataLength = dest32.length;
  44074. var fullSrcDiff = width + 7 >> 3;
  44075. var white = 0xFFFFFFFF;
  44076. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  44077. for (i = 0; i < totalChunks; i++) {
  44078. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  44079. destPos = 0;
  44080. for (j = 0; j < thisChunkHeight; j++) {
  44081. var srcDiff = srcLength - srcPos;
  44082. var k = 0;
  44083. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  44084. var kEndUnrolled = kEnd & ~7;
  44085. var mask = 0;
  44086. var srcByte = 0;
  44087. for (; k < kEndUnrolled; k += 8) {
  44088. srcByte = src[srcPos++];
  44089. dest32[destPos++] = srcByte & 128 ? white : black;
  44090. dest32[destPos++] = srcByte & 64 ? white : black;
  44091. dest32[destPos++] = srcByte & 32 ? white : black;
  44092. dest32[destPos++] = srcByte & 16 ? white : black;
  44093. dest32[destPos++] = srcByte & 8 ? white : black;
  44094. dest32[destPos++] = srcByte & 4 ? white : black;
  44095. dest32[destPos++] = srcByte & 2 ? white : black;
  44096. dest32[destPos++] = srcByte & 1 ? white : black;
  44097. }
  44098. for (; k < kEnd; k++) {
  44099. if (mask === 0) {
  44100. srcByte = src[srcPos++];
  44101. mask = 128;
  44102. }
  44103. dest32[destPos++] = srcByte & mask ? white : black;
  44104. mask >>= 1;
  44105. }
  44106. }
  44107. while (destPos < dest32DataLength) {
  44108. dest32[destPos++] = 0;
  44109. }
  44110. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44111. }
  44112. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  44113. j = 0;
  44114. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  44115. for (i = 0; i < fullChunks; i++) {
  44116. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  44117. srcPos += elemsInThisChunk;
  44118. ctx.putImageData(chunkImgData, 0, j);
  44119. j += FULL_CHUNK_HEIGHT;
  44120. }
  44121. if (i < totalChunks) {
  44122. elemsInThisChunk = width * partialChunkHeight * 4;
  44123. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  44124. ctx.putImageData(chunkImgData, 0, j);
  44125. }
  44126. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  44127. thisChunkHeight = FULL_CHUNK_HEIGHT;
  44128. elemsInThisChunk = width * thisChunkHeight;
  44129. for (i = 0; i < totalChunks; i++) {
  44130. if (i >= fullChunks) {
  44131. thisChunkHeight = partialChunkHeight;
  44132. elemsInThisChunk = width * thisChunkHeight;
  44133. }
  44134. destPos = 0;
  44135. for (j = elemsInThisChunk; j--;) {
  44136. dest[destPos++] = src[srcPos++];
  44137. dest[destPos++] = src[srcPos++];
  44138. dest[destPos++] = src[srcPos++];
  44139. dest[destPos++] = 255;
  44140. }
  44141. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44142. }
  44143. } else {
  44144. error('bad image kind: ' + imgData.kind);
  44145. }
  44146. }
  44147. function putBinaryImageMask(ctx, imgData) {
  44148. var height = imgData.height, width = imgData.width;
  44149. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  44150. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  44151. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  44152. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  44153. var srcPos = 0;
  44154. var src = imgData.data;
  44155. var dest = chunkImgData.data;
  44156. for (var i = 0; i < totalChunks; i++) {
  44157. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  44158. var destPos = 3;
  44159. for (var j = 0; j < thisChunkHeight; j++) {
  44160. var mask = 0;
  44161. for (var k = 0; k < width; k++) {
  44162. if (!mask) {
  44163. var elem = src[srcPos++];
  44164. mask = 128;
  44165. }
  44166. dest[destPos] = elem & mask ? 0 : 255;
  44167. destPos += 4;
  44168. mask >>= 1;
  44169. }
  44170. }
  44171. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44172. }
  44173. }
  44174. function copyCtxState(sourceCtx, destCtx) {
  44175. var properties = [
  44176. 'strokeStyle',
  44177. 'fillStyle',
  44178. 'fillRule',
  44179. 'globalAlpha',
  44180. 'lineWidth',
  44181. 'lineCap',
  44182. 'lineJoin',
  44183. 'miterLimit',
  44184. 'globalCompositeOperation',
  44185. 'font'
  44186. ];
  44187. for (var i = 0, ii = properties.length; i < ii; i++) {
  44188. var property = properties[i];
  44189. if (sourceCtx[property] !== undefined) {
  44190. destCtx[property] = sourceCtx[property];
  44191. }
  44192. }
  44193. if (sourceCtx.setLineDash !== undefined) {
  44194. destCtx.setLineDash(sourceCtx.getLineDash());
  44195. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44196. }
  44197. }
  44198. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44199. var length = bytes.length;
  44200. for (var i = 3; i < length; i += 4) {
  44201. var alpha = bytes[i];
  44202. if (alpha === 0) {
  44203. bytes[i - 3] = r0;
  44204. bytes[i - 2] = g0;
  44205. bytes[i - 1] = b0;
  44206. } else if (alpha < 255) {
  44207. var alpha_ = 255 - alpha;
  44208. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44209. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44210. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44211. }
  44212. }
  44213. }
  44214. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44215. var length = maskData.length;
  44216. var scale = 1 / 255;
  44217. for (var i = 3; i < length; i += 4) {
  44218. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44219. layerData[i] = layerData[i] * alpha * scale | 0;
  44220. }
  44221. }
  44222. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44223. var length = maskData.length;
  44224. for (var i = 3; i < length; i += 4) {
  44225. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44226. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44227. }
  44228. }
  44229. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44230. var hasBackdrop = !!backdrop;
  44231. var r0 = hasBackdrop ? backdrop[0] : 0;
  44232. var g0 = hasBackdrop ? backdrop[1] : 0;
  44233. var b0 = hasBackdrop ? backdrop[2] : 0;
  44234. var composeFn;
  44235. if (subtype === 'Luminosity') {
  44236. composeFn = composeSMaskLuminosity;
  44237. } else {
  44238. composeFn = composeSMaskAlpha;
  44239. }
  44240. var PIXELS_TO_PROCESS = 1048576;
  44241. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44242. for (var row = 0; row < height; row += chunkSize) {
  44243. var chunkHeight = Math.min(chunkSize, height - row);
  44244. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44245. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44246. if (hasBackdrop) {
  44247. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44248. }
  44249. composeFn(maskData.data, layerData.data, transferMap);
  44250. maskCtx.putImageData(layerData, 0, row);
  44251. }
  44252. }
  44253. function composeSMask(ctx, smask, layerCtx) {
  44254. var mask = smask.canvas;
  44255. var maskCtx = smask.context;
  44256. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44257. var backdrop = smask.backdrop || null;
  44258. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44259. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44260. subtype: smask.subtype,
  44261. backdrop: backdrop
  44262. });
  44263. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44264. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44265. return;
  44266. }
  44267. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44268. ctx.drawImage(mask, 0, 0);
  44269. }
  44270. var LINE_CAP_STYLES = [
  44271. 'butt',
  44272. 'round',
  44273. 'square'
  44274. ];
  44275. var LINE_JOIN_STYLES = [
  44276. 'miter',
  44277. 'round',
  44278. 'bevel'
  44279. ];
  44280. var NORMAL_CLIP = {};
  44281. var EO_CLIP = {};
  44282. CanvasGraphics.prototype = {
  44283. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44284. var width = this.ctx.canvas.width;
  44285. var height = this.ctx.canvas.height;
  44286. this.ctx.save();
  44287. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44288. this.ctx.fillRect(0, 0, width, height);
  44289. this.ctx.restore();
  44290. if (transparency) {
  44291. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44292. this.compositeCtx = this.ctx;
  44293. this.transparentCanvas = transparentCanvas.canvas;
  44294. this.ctx = transparentCanvas.context;
  44295. this.ctx.save();
  44296. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44297. }
  44298. this.ctx.save();
  44299. if (transform) {
  44300. this.ctx.transform.apply(this.ctx, transform);
  44301. }
  44302. this.ctx.transform.apply(this.ctx, viewport.transform);
  44303. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44304. if (this.imageLayer) {
  44305. this.imageLayer.beginLayout();
  44306. }
  44307. },
  44308. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44309. var argsArray = operatorList.argsArray;
  44310. var fnArray = operatorList.fnArray;
  44311. var i = executionStartIdx || 0;
  44312. var argsArrayLen = argsArray.length;
  44313. if (argsArrayLen === i) {
  44314. return i;
  44315. }
  44316. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44317. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44318. var steps = 0;
  44319. var commonObjs = this.commonObjs;
  44320. var objs = this.objs;
  44321. var fnId;
  44322. while (true) {
  44323. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44324. stepper.breakIt(i, continueCallback);
  44325. return i;
  44326. }
  44327. fnId = fnArray[i];
  44328. if (fnId !== OPS.dependency) {
  44329. this[fnId].apply(this, argsArray[i]);
  44330. } else {
  44331. var deps = argsArray[i];
  44332. for (var n = 0, nn = deps.length; n < nn; n++) {
  44333. var depObjId = deps[n];
  44334. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44335. var objsPool = common ? commonObjs : objs;
  44336. if (!objsPool.isResolved(depObjId)) {
  44337. objsPool.get(depObjId, continueCallback);
  44338. return i;
  44339. }
  44340. }
  44341. }
  44342. i++;
  44343. if (i === argsArrayLen) {
  44344. return i;
  44345. }
  44346. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44347. if (Date.now() > endTime) {
  44348. continueCallback();
  44349. return i;
  44350. }
  44351. steps = 0;
  44352. }
  44353. }
  44354. },
  44355. endDrawing: function CanvasGraphics_endDrawing() {
  44356. if (this.current.activeSMask !== null) {
  44357. this.endSMaskGroup();
  44358. }
  44359. this.ctx.restore();
  44360. if (this.transparentCanvas) {
  44361. this.ctx = this.compositeCtx;
  44362. this.ctx.save();
  44363. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44364. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44365. this.ctx.restore();
  44366. this.transparentCanvas = null;
  44367. }
  44368. this.cachedCanvases.clear();
  44369. WebGLUtils.clear();
  44370. if (this.imageLayer) {
  44371. this.imageLayer.endLayout();
  44372. }
  44373. },
  44374. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44375. this.current.lineWidth = width;
  44376. this.ctx.lineWidth = width;
  44377. },
  44378. setLineCap: function CanvasGraphics_setLineCap(style) {
  44379. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44380. },
  44381. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44382. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44383. },
  44384. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44385. this.ctx.miterLimit = limit;
  44386. },
  44387. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44388. var ctx = this.ctx;
  44389. if (ctx.setLineDash !== undefined) {
  44390. ctx.setLineDash(dashArray);
  44391. ctx.lineDashOffset = dashPhase;
  44392. }
  44393. },
  44394. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44395. },
  44396. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44397. },
  44398. setGState: function CanvasGraphics_setGState(states) {
  44399. for (var i = 0, ii = states.length; i < ii; i++) {
  44400. var state = states[i];
  44401. var key = state[0];
  44402. var value = state[1];
  44403. switch (key) {
  44404. case 'LW':
  44405. this.setLineWidth(value);
  44406. break;
  44407. case 'LC':
  44408. this.setLineCap(value);
  44409. break;
  44410. case 'LJ':
  44411. this.setLineJoin(value);
  44412. break;
  44413. case 'ML':
  44414. this.setMiterLimit(value);
  44415. break;
  44416. case 'D':
  44417. this.setDash(value[0], value[1]);
  44418. break;
  44419. case 'RI':
  44420. this.setRenderingIntent(value);
  44421. break;
  44422. case 'FL':
  44423. this.setFlatness(value);
  44424. break;
  44425. case 'Font':
  44426. this.setFont(value[0], value[1]);
  44427. break;
  44428. case 'CA':
  44429. this.current.strokeAlpha = state[1];
  44430. break;
  44431. case 'ca':
  44432. this.current.fillAlpha = state[1];
  44433. this.ctx.globalAlpha = state[1];
  44434. break;
  44435. case 'BM':
  44436. if (value && value.name && value.name !== 'Normal') {
  44437. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44438. return '-' + c.toLowerCase();
  44439. }).substring(1);
  44440. this.ctx.globalCompositeOperation = mode;
  44441. if (this.ctx.globalCompositeOperation !== mode) {
  44442. warn('globalCompositeOperation "' + mode + '" is not supported');
  44443. }
  44444. } else {
  44445. this.ctx.globalCompositeOperation = 'source-over';
  44446. }
  44447. break;
  44448. case 'SMask':
  44449. if (this.current.activeSMask) {
  44450. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44451. this.suspendSMaskGroup();
  44452. } else {
  44453. this.endSMaskGroup();
  44454. }
  44455. }
  44456. this.current.activeSMask = value ? this.tempSMask : null;
  44457. if (this.current.activeSMask) {
  44458. this.beginSMaskGroup();
  44459. }
  44460. this.tempSMask = null;
  44461. break;
  44462. }
  44463. }
  44464. },
  44465. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44466. var activeSMask = this.current.activeSMask;
  44467. var drawnWidth = activeSMask.canvas.width;
  44468. var drawnHeight = activeSMask.canvas.height;
  44469. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44470. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44471. var currentCtx = this.ctx;
  44472. var currentTransform = currentCtx.mozCurrentTransform;
  44473. this.ctx.save();
  44474. var groupCtx = scratchCanvas.context;
  44475. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44476. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44477. groupCtx.transform.apply(groupCtx, currentTransform);
  44478. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44479. copyCtxState(currentCtx, groupCtx);
  44480. this.ctx = groupCtx;
  44481. this.setGState([
  44482. [
  44483. 'BM',
  44484. 'Normal'
  44485. ],
  44486. [
  44487. 'ca',
  44488. 1
  44489. ],
  44490. [
  44491. 'CA',
  44492. 1
  44493. ]
  44494. ]);
  44495. this.groupStack.push(currentCtx);
  44496. this.groupLevel++;
  44497. },
  44498. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44499. var groupCtx = this.ctx;
  44500. this.groupLevel--;
  44501. this.ctx = this.groupStack.pop();
  44502. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44503. this.ctx.restore();
  44504. this.ctx.save();
  44505. copyCtxState(groupCtx, this.ctx);
  44506. this.current.resumeSMaskCtx = groupCtx;
  44507. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44508. this.ctx.transform.apply(this.ctx, deltaTransform);
  44509. groupCtx.save();
  44510. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44511. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44512. groupCtx.restore();
  44513. },
  44514. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44515. var groupCtx = this.current.resumeSMaskCtx;
  44516. var currentCtx = this.ctx;
  44517. this.ctx = groupCtx;
  44518. this.groupStack.push(currentCtx);
  44519. this.groupLevel++;
  44520. },
  44521. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44522. var groupCtx = this.ctx;
  44523. this.groupLevel--;
  44524. this.ctx = this.groupStack.pop();
  44525. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44526. this.ctx.restore();
  44527. copyCtxState(groupCtx, this.ctx);
  44528. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44529. this.ctx.transform.apply(this.ctx, deltaTransform);
  44530. },
  44531. save: function CanvasGraphics_save() {
  44532. this.ctx.save();
  44533. var old = this.current;
  44534. this.stateStack.push(old);
  44535. this.current = old.clone();
  44536. this.current.resumeSMaskCtx = null;
  44537. },
  44538. restore: function CanvasGraphics_restore() {
  44539. if (this.current.resumeSMaskCtx) {
  44540. this.resumeSMaskGroup();
  44541. }
  44542. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44543. this.endSMaskGroup();
  44544. }
  44545. if (this.stateStack.length !== 0) {
  44546. this.current = this.stateStack.pop();
  44547. this.ctx.restore();
  44548. this.pendingClip = null;
  44549. this.cachedGetSinglePixelWidth = null;
  44550. }
  44551. },
  44552. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44553. this.ctx.transform(a, b, c, d, e, f);
  44554. this.cachedGetSinglePixelWidth = null;
  44555. },
  44556. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44557. var ctx = this.ctx;
  44558. var current = this.current;
  44559. var x = current.x, y = current.y;
  44560. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44561. switch (ops[i] | 0) {
  44562. case OPS.rectangle:
  44563. x = args[j++];
  44564. y = args[j++];
  44565. var width = args[j++];
  44566. var height = args[j++];
  44567. if (width === 0) {
  44568. width = this.getSinglePixelWidth();
  44569. }
  44570. if (height === 0) {
  44571. height = this.getSinglePixelWidth();
  44572. }
  44573. var xw = x + width;
  44574. var yh = y + height;
  44575. this.ctx.moveTo(x, y);
  44576. this.ctx.lineTo(xw, y);
  44577. this.ctx.lineTo(xw, yh);
  44578. this.ctx.lineTo(x, yh);
  44579. this.ctx.lineTo(x, y);
  44580. this.ctx.closePath();
  44581. break;
  44582. case OPS.moveTo:
  44583. x = args[j++];
  44584. y = args[j++];
  44585. ctx.moveTo(x, y);
  44586. break;
  44587. case OPS.lineTo:
  44588. x = args[j++];
  44589. y = args[j++];
  44590. ctx.lineTo(x, y);
  44591. break;
  44592. case OPS.curveTo:
  44593. x = args[j + 4];
  44594. y = args[j + 5];
  44595. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44596. j += 6;
  44597. break;
  44598. case OPS.curveTo2:
  44599. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44600. x = args[j + 2];
  44601. y = args[j + 3];
  44602. j += 4;
  44603. break;
  44604. case OPS.curveTo3:
  44605. x = args[j + 2];
  44606. y = args[j + 3];
  44607. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44608. j += 4;
  44609. break;
  44610. case OPS.closePath:
  44611. ctx.closePath();
  44612. break;
  44613. }
  44614. }
  44615. current.setCurrentPoint(x, y);
  44616. },
  44617. closePath: function CanvasGraphics_closePath() {
  44618. this.ctx.closePath();
  44619. },
  44620. stroke: function CanvasGraphics_stroke(consumePath) {
  44621. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44622. var ctx = this.ctx;
  44623. var strokeColor = this.current.strokeColor;
  44624. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44625. ctx.globalAlpha = this.current.strokeAlpha;
  44626. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44627. ctx.save();
  44628. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44629. ctx.stroke();
  44630. ctx.restore();
  44631. } else {
  44632. ctx.stroke();
  44633. }
  44634. if (consumePath) {
  44635. this.consumePath();
  44636. }
  44637. ctx.globalAlpha = this.current.fillAlpha;
  44638. },
  44639. closeStroke: function CanvasGraphics_closeStroke() {
  44640. this.closePath();
  44641. this.stroke();
  44642. },
  44643. fill: function CanvasGraphics_fill(consumePath) {
  44644. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44645. var ctx = this.ctx;
  44646. var fillColor = this.current.fillColor;
  44647. var isPatternFill = this.current.patternFill;
  44648. var needRestore = false;
  44649. if (isPatternFill) {
  44650. ctx.save();
  44651. if (this.baseTransform) {
  44652. ctx.setTransform.apply(ctx, this.baseTransform);
  44653. }
  44654. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44655. needRestore = true;
  44656. }
  44657. if (this.pendingEOFill) {
  44658. if (ctx.mozFillRule !== undefined) {
  44659. ctx.mozFillRule = 'evenodd';
  44660. ctx.fill();
  44661. ctx.mozFillRule = 'nonzero';
  44662. } else {
  44663. ctx.fill('evenodd');
  44664. }
  44665. this.pendingEOFill = false;
  44666. } else {
  44667. ctx.fill();
  44668. }
  44669. if (needRestore) {
  44670. ctx.restore();
  44671. }
  44672. if (consumePath) {
  44673. this.consumePath();
  44674. }
  44675. },
  44676. eoFill: function CanvasGraphics_eoFill() {
  44677. this.pendingEOFill = true;
  44678. this.fill();
  44679. },
  44680. fillStroke: function CanvasGraphics_fillStroke() {
  44681. this.fill(false);
  44682. this.stroke(false);
  44683. this.consumePath();
  44684. },
  44685. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44686. this.pendingEOFill = true;
  44687. this.fillStroke();
  44688. },
  44689. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44690. this.closePath();
  44691. this.fillStroke();
  44692. },
  44693. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44694. this.pendingEOFill = true;
  44695. this.closePath();
  44696. this.fillStroke();
  44697. },
  44698. endPath: function CanvasGraphics_endPath() {
  44699. this.consumePath();
  44700. },
  44701. clip: function CanvasGraphics_clip() {
  44702. this.pendingClip = NORMAL_CLIP;
  44703. },
  44704. eoClip: function CanvasGraphics_eoClip() {
  44705. this.pendingClip = EO_CLIP;
  44706. },
  44707. beginText: function CanvasGraphics_beginText() {
  44708. this.current.textMatrix = IDENTITY_MATRIX;
  44709. this.current.textMatrixScale = 1;
  44710. this.current.x = this.current.lineX = 0;
  44711. this.current.y = this.current.lineY = 0;
  44712. },
  44713. endText: function CanvasGraphics_endText() {
  44714. var paths = this.pendingTextPaths;
  44715. var ctx = this.ctx;
  44716. if (paths === undefined) {
  44717. ctx.beginPath();
  44718. return;
  44719. }
  44720. ctx.save();
  44721. ctx.beginPath();
  44722. for (var i = 0; i < paths.length; i++) {
  44723. var path = paths[i];
  44724. ctx.setTransform.apply(ctx, path.transform);
  44725. ctx.translate(path.x, path.y);
  44726. path.addToPath(ctx, path.fontSize);
  44727. }
  44728. ctx.restore();
  44729. ctx.clip();
  44730. ctx.beginPath();
  44731. delete this.pendingTextPaths;
  44732. },
  44733. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44734. this.current.charSpacing = spacing;
  44735. },
  44736. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44737. this.current.wordSpacing = spacing;
  44738. },
  44739. setHScale: function CanvasGraphics_setHScale(scale) {
  44740. this.current.textHScale = scale / 100;
  44741. },
  44742. setLeading: function CanvasGraphics_setLeading(leading) {
  44743. this.current.leading = -leading;
  44744. },
  44745. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44746. var fontObj = this.commonObjs.get(fontRefName);
  44747. var current = this.current;
  44748. if (!fontObj) {
  44749. error('Can\'t find font for ' + fontRefName);
  44750. }
  44751. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44752. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44753. warn('Invalid font matrix for font ' + fontRefName);
  44754. }
  44755. if (size < 0) {
  44756. size = -size;
  44757. current.fontDirection = -1;
  44758. } else {
  44759. current.fontDirection = 1;
  44760. }
  44761. this.current.font = fontObj;
  44762. this.current.fontSize = size;
  44763. if (fontObj.isType3Font) {
  44764. return;
  44765. }
  44766. var name = fontObj.loadedName || 'sans-serif';
  44767. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  44768. var italic = fontObj.italic ? 'italic' : 'normal';
  44769. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44770. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44771. this.current.fontSizeScale = size / browserFontSize;
  44772. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44773. this.ctx.font = rule;
  44774. },
  44775. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44776. this.current.textRenderingMode = mode;
  44777. },
  44778. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44779. this.current.textRise = rise;
  44780. },
  44781. moveText: function CanvasGraphics_moveText(x, y) {
  44782. this.current.x = this.current.lineX += x;
  44783. this.current.y = this.current.lineY += y;
  44784. },
  44785. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44786. this.setLeading(-y);
  44787. this.moveText(x, y);
  44788. },
  44789. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44790. this.current.textMatrix = [
  44791. a,
  44792. b,
  44793. c,
  44794. d,
  44795. e,
  44796. f
  44797. ];
  44798. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44799. this.current.x = this.current.lineX = 0;
  44800. this.current.y = this.current.lineY = 0;
  44801. },
  44802. nextLine: function CanvasGraphics_nextLine() {
  44803. this.moveText(0, this.current.leading);
  44804. },
  44805. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44806. var ctx = this.ctx;
  44807. var current = this.current;
  44808. var font = current.font;
  44809. var textRenderingMode = current.textRenderingMode;
  44810. var fontSize = current.fontSize / current.fontSizeScale;
  44811. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44812. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44813. var addToPath;
  44814. if (font.disableFontFace || isAddToPathSet) {
  44815. addToPath = font.getPathGenerator(this.commonObjs, character);
  44816. }
  44817. if (font.disableFontFace) {
  44818. ctx.save();
  44819. ctx.translate(x, y);
  44820. ctx.beginPath();
  44821. addToPath(ctx, fontSize);
  44822. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44823. ctx.fill();
  44824. }
  44825. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44826. ctx.stroke();
  44827. }
  44828. ctx.restore();
  44829. } else {
  44830. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44831. ctx.fillText(character, x, y);
  44832. }
  44833. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44834. ctx.strokeText(character, x, y);
  44835. }
  44836. }
  44837. if (isAddToPathSet) {
  44838. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44839. paths.push({
  44840. transform: ctx.mozCurrentTransform,
  44841. x: x,
  44842. y: y,
  44843. fontSize: fontSize,
  44844. addToPath: addToPath
  44845. });
  44846. }
  44847. },
  44848. get isFontSubpixelAAEnabled() {
  44849. var ctx = document.createElement('canvas').getContext('2d');
  44850. ctx.scale(1.5, 1);
  44851. ctx.fillText('I', 0, 10);
  44852. var data = ctx.getImageData(0, 0, 10, 10).data;
  44853. var enabled = false;
  44854. for (var i = 3; i < data.length; i += 4) {
  44855. if (data[i] > 0 && data[i] < 255) {
  44856. enabled = true;
  44857. break;
  44858. }
  44859. }
  44860. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44861. },
  44862. showText: function CanvasGraphics_showText(glyphs) {
  44863. var current = this.current;
  44864. var font = current.font;
  44865. if (font.isType3Font) {
  44866. return this.showType3Text(glyphs);
  44867. }
  44868. var fontSize = current.fontSize;
  44869. if (fontSize === 0) {
  44870. return;
  44871. }
  44872. var ctx = this.ctx;
  44873. var fontSizeScale = current.fontSizeScale;
  44874. var charSpacing = current.charSpacing;
  44875. var wordSpacing = current.wordSpacing;
  44876. var fontDirection = current.fontDirection;
  44877. var textHScale = current.textHScale * fontDirection;
  44878. var glyphsLength = glyphs.length;
  44879. var vertical = font.vertical;
  44880. var spacingDir = vertical ? 1 : -1;
  44881. var defaultVMetrics = font.defaultVMetrics;
  44882. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44883. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44884. ctx.save();
  44885. ctx.transform.apply(ctx, current.textMatrix);
  44886. ctx.translate(current.x, current.y + current.textRise);
  44887. if (current.patternFill) {
  44888. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44889. }
  44890. if (fontDirection > 0) {
  44891. ctx.scale(textHScale, -1);
  44892. } else {
  44893. ctx.scale(textHScale, 1);
  44894. }
  44895. var lineWidth = current.lineWidth;
  44896. var scale = current.textMatrixScale;
  44897. if (scale === 0 || lineWidth === 0) {
  44898. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44899. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44900. this.cachedGetSinglePixelWidth = null;
  44901. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44902. }
  44903. } else {
  44904. lineWidth /= scale;
  44905. }
  44906. if (fontSizeScale !== 1.0) {
  44907. ctx.scale(fontSizeScale, fontSizeScale);
  44908. lineWidth /= fontSizeScale;
  44909. }
  44910. ctx.lineWidth = lineWidth;
  44911. var x = 0, i;
  44912. for (i = 0; i < glyphsLength; ++i) {
  44913. var glyph = glyphs[i];
  44914. if (isNum(glyph)) {
  44915. x += spacingDir * glyph * fontSize / 1000;
  44916. continue;
  44917. }
  44918. var restoreNeeded = false;
  44919. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44920. var character = glyph.fontChar;
  44921. var accent = glyph.accent;
  44922. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44923. var width = glyph.width;
  44924. if (vertical) {
  44925. var vmetric, vx, vy;
  44926. vmetric = glyph.vmetric || defaultVMetrics;
  44927. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44928. vx = -vx * widthAdvanceScale;
  44929. vy = vmetric[2] * widthAdvanceScale;
  44930. width = vmetric ? -vmetric[0] : width;
  44931. scaledX = vx / fontSizeScale;
  44932. scaledY = (x + vy) / fontSizeScale;
  44933. } else {
  44934. scaledX = x / fontSizeScale;
  44935. scaledY = 0;
  44936. }
  44937. if (font.remeasure && width > 0) {
  44938. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44939. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44940. var characterScaleX = width / measuredWidth;
  44941. restoreNeeded = true;
  44942. ctx.save();
  44943. ctx.scale(characterScaleX, 1);
  44944. scaledX /= characterScaleX;
  44945. } else if (width !== measuredWidth) {
  44946. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44947. }
  44948. }
  44949. if (glyph.isInFont || font.missingFile) {
  44950. if (simpleFillText && !accent) {
  44951. ctx.fillText(character, scaledX, scaledY);
  44952. } else {
  44953. this.paintChar(character, scaledX, scaledY);
  44954. if (accent) {
  44955. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44956. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44957. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44958. }
  44959. }
  44960. }
  44961. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44962. x += charWidth;
  44963. if (restoreNeeded) {
  44964. ctx.restore();
  44965. }
  44966. }
  44967. if (vertical) {
  44968. current.y -= x * textHScale;
  44969. } else {
  44970. current.x += x * textHScale;
  44971. }
  44972. ctx.restore();
  44973. },
  44974. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44975. var ctx = this.ctx;
  44976. var current = this.current;
  44977. var font = current.font;
  44978. var fontSize = current.fontSize;
  44979. var fontDirection = current.fontDirection;
  44980. var spacingDir = font.vertical ? 1 : -1;
  44981. var charSpacing = current.charSpacing;
  44982. var wordSpacing = current.wordSpacing;
  44983. var textHScale = current.textHScale * fontDirection;
  44984. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44985. var glyphsLength = glyphs.length;
  44986. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44987. var i, glyph, width, spacingLength;
  44988. if (isTextInvisible || fontSize === 0) {
  44989. return;
  44990. }
  44991. this.cachedGetSinglePixelWidth = null;
  44992. ctx.save();
  44993. ctx.transform.apply(ctx, current.textMatrix);
  44994. ctx.translate(current.x, current.y);
  44995. ctx.scale(textHScale, fontDirection);
  44996. for (i = 0; i < glyphsLength; ++i) {
  44997. glyph = glyphs[i];
  44998. if (isNum(glyph)) {
  44999. spacingLength = spacingDir * glyph * fontSize / 1000;
  45000. this.ctx.translate(spacingLength, 0);
  45001. current.x += spacingLength * textHScale;
  45002. continue;
  45003. }
  45004. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  45005. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  45006. if (!operatorList) {
  45007. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  45008. continue;
  45009. }
  45010. this.processingType3 = glyph;
  45011. this.save();
  45012. ctx.scale(fontSize, fontSize);
  45013. ctx.transform.apply(ctx, fontMatrix);
  45014. this.executeOperatorList(operatorList);
  45015. this.restore();
  45016. var transformed = Util.applyTransform([
  45017. glyph.width,
  45018. 0
  45019. ], fontMatrix);
  45020. width = transformed[0] * fontSize + spacing;
  45021. ctx.translate(width, 0);
  45022. current.x += width * textHScale;
  45023. }
  45024. ctx.restore();
  45025. this.processingType3 = null;
  45026. },
  45027. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  45028. },
  45029. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  45030. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  45031. this.clip();
  45032. this.endPath();
  45033. },
  45034. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  45035. var pattern;
  45036. if (IR[0] === 'TilingPattern') {
  45037. var color = IR[1];
  45038. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  45039. var self = this;
  45040. var canvasGraphicsFactory = {
  45041. createCanvasGraphics: function (ctx) {
  45042. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  45043. }
  45044. };
  45045. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  45046. } else {
  45047. pattern = getShadingPatternFromIR(IR);
  45048. }
  45049. return pattern;
  45050. },
  45051. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  45052. this.current.strokeColor = this.getColorN_Pattern(arguments);
  45053. },
  45054. setFillColorN: function CanvasGraphics_setFillColorN() {
  45055. this.current.fillColor = this.getColorN_Pattern(arguments);
  45056. this.current.patternFill = true;
  45057. },
  45058. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  45059. var color = Util.makeCssRgb(r, g, b);
  45060. this.ctx.strokeStyle = color;
  45061. this.current.strokeColor = color;
  45062. },
  45063. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  45064. var color = Util.makeCssRgb(r, g, b);
  45065. this.ctx.fillStyle = color;
  45066. this.current.fillColor = color;
  45067. this.current.patternFill = false;
  45068. },
  45069. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  45070. var ctx = this.ctx;
  45071. this.save();
  45072. var pattern = getShadingPatternFromIR(patternIR);
  45073. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  45074. var inv = ctx.mozCurrentTransformInverse;
  45075. if (inv) {
  45076. var canvas = ctx.canvas;
  45077. var width = canvas.width;
  45078. var height = canvas.height;
  45079. var bl = Util.applyTransform([
  45080. 0,
  45081. 0
  45082. ], inv);
  45083. var br = Util.applyTransform([
  45084. 0,
  45085. height
  45086. ], inv);
  45087. var ul = Util.applyTransform([
  45088. width,
  45089. 0
  45090. ], inv);
  45091. var ur = Util.applyTransform([
  45092. width,
  45093. height
  45094. ], inv);
  45095. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  45096. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  45097. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  45098. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  45099. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  45100. } else {
  45101. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  45102. }
  45103. this.restore();
  45104. },
  45105. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  45106. error('Should not call beginInlineImage');
  45107. },
  45108. beginImageData: function CanvasGraphics_beginImageData() {
  45109. error('Should not call beginImageData');
  45110. },
  45111. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  45112. this.save();
  45113. this.baseTransformStack.push(this.baseTransform);
  45114. if (isArray(matrix) && matrix.length === 6) {
  45115. this.transform.apply(this, matrix);
  45116. }
  45117. this.baseTransform = this.ctx.mozCurrentTransform;
  45118. if (isArray(bbox) && bbox.length === 4) {
  45119. var width = bbox[2] - bbox[0];
  45120. var height = bbox[3] - bbox[1];
  45121. this.ctx.rect(bbox[0], bbox[1], width, height);
  45122. this.clip();
  45123. this.endPath();
  45124. }
  45125. },
  45126. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  45127. this.restore();
  45128. this.baseTransform = this.baseTransformStack.pop();
  45129. },
  45130. beginGroup: function CanvasGraphics_beginGroup(group) {
  45131. this.save();
  45132. var currentCtx = this.ctx;
  45133. if (!group.isolated) {
  45134. info('TODO: Support non-isolated groups.');
  45135. }
  45136. if (group.knockout) {
  45137. warn('Knockout groups not supported.');
  45138. }
  45139. var currentTransform = currentCtx.mozCurrentTransform;
  45140. if (group.matrix) {
  45141. currentCtx.transform.apply(currentCtx, group.matrix);
  45142. }
  45143. assert(group.bbox, 'Bounding box is required.');
  45144. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  45145. var canvasBounds = [
  45146. 0,
  45147. 0,
  45148. currentCtx.canvas.width,
  45149. currentCtx.canvas.height
  45150. ];
  45151. bounds = Util.intersect(bounds, canvasBounds) || [
  45152. 0,
  45153. 0,
  45154. 0,
  45155. 0
  45156. ];
  45157. var offsetX = Math.floor(bounds[0]);
  45158. var offsetY = Math.floor(bounds[1]);
  45159. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  45160. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  45161. var scaleX = 1, scaleY = 1;
  45162. if (drawnWidth > MAX_GROUP_SIZE) {
  45163. scaleX = drawnWidth / MAX_GROUP_SIZE;
  45164. drawnWidth = MAX_GROUP_SIZE;
  45165. }
  45166. if (drawnHeight > MAX_GROUP_SIZE) {
  45167. scaleY = drawnHeight / MAX_GROUP_SIZE;
  45168. drawnHeight = MAX_GROUP_SIZE;
  45169. }
  45170. var cacheId = 'groupAt' + this.groupLevel;
  45171. if (group.smask) {
  45172. cacheId += '_smask_' + this.smaskCounter++ % 2;
  45173. }
  45174. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45175. var groupCtx = scratchCanvas.context;
  45176. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45177. groupCtx.translate(-offsetX, -offsetY);
  45178. groupCtx.transform.apply(groupCtx, currentTransform);
  45179. if (group.smask) {
  45180. this.smaskStack.push({
  45181. canvas: scratchCanvas.canvas,
  45182. context: groupCtx,
  45183. offsetX: offsetX,
  45184. offsetY: offsetY,
  45185. scaleX: scaleX,
  45186. scaleY: scaleY,
  45187. subtype: group.smask.subtype,
  45188. backdrop: group.smask.backdrop,
  45189. transferMap: group.smask.transferMap || null,
  45190. startTransformInverse: null
  45191. });
  45192. } else
  45193. {
  45194. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45195. currentCtx.translate(offsetX, offsetY);
  45196. currentCtx.scale(scaleX, scaleY);
  45197. }
  45198. copyCtxState(currentCtx, groupCtx);
  45199. this.ctx = groupCtx;
  45200. this.setGState([
  45201. [
  45202. 'BM',
  45203. 'Normal'
  45204. ],
  45205. [
  45206. 'ca',
  45207. 1
  45208. ],
  45209. [
  45210. 'CA',
  45211. 1
  45212. ]
  45213. ]);
  45214. this.groupStack.push(currentCtx);
  45215. this.groupLevel++;
  45216. this.current.activeSMask = null;
  45217. },
  45218. endGroup: function CanvasGraphics_endGroup(group) {
  45219. this.groupLevel--;
  45220. var groupCtx = this.ctx;
  45221. this.ctx = this.groupStack.pop();
  45222. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45223. this.ctx.imageSmoothingEnabled = false;
  45224. } else {
  45225. this.ctx.mozImageSmoothingEnabled = false;
  45226. }
  45227. if (group.smask) {
  45228. this.tempSMask = this.smaskStack.pop();
  45229. } else {
  45230. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45231. }
  45232. this.restore();
  45233. },
  45234. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45235. this.save();
  45236. this.current = new CanvasExtraState();
  45237. if (this.baseTransform) {
  45238. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45239. }
  45240. },
  45241. endAnnotations: function CanvasGraphics_endAnnotations() {
  45242. this.restore();
  45243. },
  45244. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45245. this.save();
  45246. if (isArray(rect) && rect.length === 4) {
  45247. var width = rect[2] - rect[0];
  45248. var height = rect[3] - rect[1];
  45249. this.ctx.rect(rect[0], rect[1], width, height);
  45250. this.clip();
  45251. this.endPath();
  45252. }
  45253. this.transform.apply(this, transform);
  45254. this.transform.apply(this, matrix);
  45255. },
  45256. endAnnotation: function CanvasGraphics_endAnnotation() {
  45257. this.restore();
  45258. },
  45259. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45260. var domImage = this.objs.get(objId);
  45261. if (!domImage) {
  45262. warn('Dependent image isn\'t ready yet');
  45263. return;
  45264. }
  45265. this.save();
  45266. var ctx = this.ctx;
  45267. ctx.scale(1 / w, -1 / h);
  45268. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45269. if (this.imageLayer) {
  45270. var currentTransform = ctx.mozCurrentTransformInverse;
  45271. var position = this.getCanvasPosition(0, 0);
  45272. this.imageLayer.appendImage({
  45273. objId: objId,
  45274. left: position[0],
  45275. top: position[1],
  45276. width: w / currentTransform[0],
  45277. height: h / currentTransform[3]
  45278. });
  45279. }
  45280. this.restore();
  45281. },
  45282. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45283. var ctx = this.ctx;
  45284. var width = img.width, height = img.height;
  45285. var fillColor = this.current.fillColor;
  45286. var isPatternFill = this.current.patternFill;
  45287. var glyph = this.processingType3;
  45288. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45289. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45290. glyph.compiled = compileType3Glyph({
  45291. data: img.data,
  45292. width: width,
  45293. height: height
  45294. });
  45295. } else {
  45296. glyph.compiled = null;
  45297. }
  45298. }
  45299. if (glyph && glyph.compiled) {
  45300. glyph.compiled(ctx);
  45301. return;
  45302. }
  45303. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45304. var maskCtx = maskCanvas.context;
  45305. maskCtx.save();
  45306. putBinaryImageMask(maskCtx, img);
  45307. maskCtx.globalCompositeOperation = 'source-in';
  45308. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45309. maskCtx.fillRect(0, 0, width, height);
  45310. maskCtx.restore();
  45311. this.paintInlineImageXObject(maskCanvas.canvas);
  45312. },
  45313. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45314. var width = imgData.width;
  45315. var height = imgData.height;
  45316. var fillColor = this.current.fillColor;
  45317. var isPatternFill = this.current.patternFill;
  45318. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45319. var maskCtx = maskCanvas.context;
  45320. maskCtx.save();
  45321. putBinaryImageMask(maskCtx, imgData);
  45322. maskCtx.globalCompositeOperation = 'source-in';
  45323. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45324. maskCtx.fillRect(0, 0, width, height);
  45325. maskCtx.restore();
  45326. var ctx = this.ctx;
  45327. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45328. ctx.save();
  45329. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45330. ctx.scale(1, -1);
  45331. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45332. ctx.restore();
  45333. }
  45334. },
  45335. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45336. var ctx = this.ctx;
  45337. var fillColor = this.current.fillColor;
  45338. var isPatternFill = this.current.patternFill;
  45339. for (var i = 0, ii = images.length; i < ii; i++) {
  45340. var image = images[i];
  45341. var width = image.width, height = image.height;
  45342. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45343. var maskCtx = maskCanvas.context;
  45344. maskCtx.save();
  45345. putBinaryImageMask(maskCtx, image);
  45346. maskCtx.globalCompositeOperation = 'source-in';
  45347. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45348. maskCtx.fillRect(0, 0, width, height);
  45349. maskCtx.restore();
  45350. ctx.save();
  45351. ctx.transform.apply(ctx, image.transform);
  45352. ctx.scale(1, -1);
  45353. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45354. ctx.restore();
  45355. }
  45356. },
  45357. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45358. var imgData = this.objs.get(objId);
  45359. if (!imgData) {
  45360. warn('Dependent image isn\'t ready yet');
  45361. return;
  45362. }
  45363. this.paintInlineImageXObject(imgData);
  45364. },
  45365. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45366. var imgData = this.objs.get(objId);
  45367. if (!imgData) {
  45368. warn('Dependent image isn\'t ready yet');
  45369. return;
  45370. }
  45371. var width = imgData.width;
  45372. var height = imgData.height;
  45373. var map = [];
  45374. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45375. map.push({
  45376. transform: [
  45377. scaleX,
  45378. 0,
  45379. 0,
  45380. scaleY,
  45381. positions[i],
  45382. positions[i + 1]
  45383. ],
  45384. x: 0,
  45385. y: 0,
  45386. w: width,
  45387. h: height
  45388. });
  45389. }
  45390. this.paintInlineImageXObjectGroup(imgData, map);
  45391. },
  45392. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45393. var width = imgData.width;
  45394. var height = imgData.height;
  45395. var ctx = this.ctx;
  45396. this.save();
  45397. ctx.scale(1 / width, -1 / height);
  45398. var currentTransform = ctx.mozCurrentTransformInverse;
  45399. var a = currentTransform[0], b = currentTransform[1];
  45400. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45401. var c = currentTransform[2], d = currentTransform[3];
  45402. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45403. var imgToPaint, tmpCanvas;
  45404. if (imgData instanceof HTMLElement || !imgData.data) {
  45405. imgToPaint = imgData;
  45406. } else {
  45407. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45408. var tmpCtx = tmpCanvas.context;
  45409. putBinaryImageData(tmpCtx, imgData);
  45410. imgToPaint = tmpCanvas.canvas;
  45411. }
  45412. var paintWidth = width, paintHeight = height;
  45413. var tmpCanvasId = 'prescale1';
  45414. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45415. var newWidth = paintWidth, newHeight = paintHeight;
  45416. if (widthScale > 2 && paintWidth > 1) {
  45417. newWidth = Math.ceil(paintWidth / 2);
  45418. widthScale /= paintWidth / newWidth;
  45419. }
  45420. if (heightScale > 2 && paintHeight > 1) {
  45421. newHeight = Math.ceil(paintHeight / 2);
  45422. heightScale /= paintHeight / newHeight;
  45423. }
  45424. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45425. tmpCtx = tmpCanvas.context;
  45426. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45427. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45428. imgToPaint = tmpCanvas.canvas;
  45429. paintWidth = newWidth;
  45430. paintHeight = newHeight;
  45431. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45432. }
  45433. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45434. if (this.imageLayer) {
  45435. var position = this.getCanvasPosition(0, -height);
  45436. this.imageLayer.appendImage({
  45437. imgData: imgData,
  45438. left: position[0],
  45439. top: position[1],
  45440. width: width / currentTransform[0],
  45441. height: height / currentTransform[3]
  45442. });
  45443. }
  45444. this.restore();
  45445. },
  45446. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45447. var ctx = this.ctx;
  45448. var w = imgData.width;
  45449. var h = imgData.height;
  45450. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45451. var tmpCtx = tmpCanvas.context;
  45452. putBinaryImageData(tmpCtx, imgData);
  45453. for (var i = 0, ii = map.length; i < ii; i++) {
  45454. var entry = map[i];
  45455. ctx.save();
  45456. ctx.transform.apply(ctx, entry.transform);
  45457. ctx.scale(1, -1);
  45458. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45459. if (this.imageLayer) {
  45460. var position = this.getCanvasPosition(entry.x, entry.y);
  45461. this.imageLayer.appendImage({
  45462. imgData: imgData,
  45463. left: position[0],
  45464. top: position[1],
  45465. width: w,
  45466. height: h
  45467. });
  45468. }
  45469. ctx.restore();
  45470. }
  45471. },
  45472. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45473. this.ctx.fillRect(0, 0, 1, 1);
  45474. },
  45475. paintXObject: function CanvasGraphics_paintXObject() {
  45476. warn('Unsupported \'paintXObject\' command.');
  45477. },
  45478. markPoint: function CanvasGraphics_markPoint(tag) {
  45479. },
  45480. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45481. },
  45482. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45483. },
  45484. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45485. },
  45486. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45487. },
  45488. beginCompat: function CanvasGraphics_beginCompat() {
  45489. },
  45490. endCompat: function CanvasGraphics_endCompat() {
  45491. },
  45492. consumePath: function CanvasGraphics_consumePath() {
  45493. var ctx = this.ctx;
  45494. if (this.pendingClip) {
  45495. if (this.pendingClip === EO_CLIP) {
  45496. if (ctx.mozFillRule !== undefined) {
  45497. ctx.mozFillRule = 'evenodd';
  45498. ctx.clip();
  45499. ctx.mozFillRule = 'nonzero';
  45500. } else {
  45501. ctx.clip('evenodd');
  45502. }
  45503. } else {
  45504. ctx.clip();
  45505. }
  45506. this.pendingClip = null;
  45507. }
  45508. ctx.beginPath();
  45509. },
  45510. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45511. if (this.cachedGetSinglePixelWidth === null) {
  45512. this.ctx.save();
  45513. var inverse = this.ctx.mozCurrentTransformInverse;
  45514. this.ctx.restore();
  45515. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45516. }
  45517. return this.cachedGetSinglePixelWidth;
  45518. },
  45519. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45520. var transform = this.ctx.mozCurrentTransform;
  45521. return [
  45522. transform[0] * x + transform[2] * y + transform[4],
  45523. transform[1] * x + transform[3] * y + transform[5]
  45524. ];
  45525. }
  45526. };
  45527. for (var op in OPS) {
  45528. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45529. }
  45530. return CanvasGraphics;
  45531. }();
  45532. exports.CanvasGraphics = CanvasGraphics;
  45533. exports.createScratchCanvas = createScratchCanvas;
  45534. }));
  45535. (function (root, factory) {
  45536. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45537. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45538. var error = sharedUtil.error;
  45539. var info = sharedUtil.info;
  45540. var isArray = sharedUtil.isArray;
  45541. var isBool = sharedUtil.isBool;
  45542. var isDict = corePrimitives.isDict;
  45543. var isStream = corePrimitives.isStream;
  45544. var PostScriptLexer = corePsParser.PostScriptLexer;
  45545. var PostScriptParser = corePsParser.PostScriptParser;
  45546. var PDFFunction = function PDFFunctionClosure() {
  45547. var CONSTRUCT_SAMPLED = 0;
  45548. var CONSTRUCT_INTERPOLATED = 2;
  45549. var CONSTRUCT_STICHED = 3;
  45550. var CONSTRUCT_POSTSCRIPT = 4;
  45551. return {
  45552. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45553. var i, ii;
  45554. var length = 1;
  45555. for (i = 0, ii = size.length; i < ii; i++) {
  45556. length *= size[i];
  45557. }
  45558. length *= outputSize;
  45559. var array = new Array(length);
  45560. var codeSize = 0;
  45561. var codeBuf = 0;
  45562. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45563. var strBytes = str.getBytes((length * bps + 7) / 8);
  45564. var strIdx = 0;
  45565. for (i = 0; i < length; i++) {
  45566. while (codeSize < bps) {
  45567. codeBuf <<= 8;
  45568. codeBuf |= strBytes[strIdx++];
  45569. codeSize += 8;
  45570. }
  45571. codeSize -= bps;
  45572. array[i] = (codeBuf >> codeSize) * sampleMul;
  45573. codeBuf &= (1 << codeSize) - 1;
  45574. }
  45575. return array;
  45576. },
  45577. getIR: function PDFFunction_getIR(xref, fn) {
  45578. var dict = fn.dict;
  45579. if (!dict) {
  45580. dict = fn;
  45581. }
  45582. var types = [
  45583. this.constructSampled,
  45584. null,
  45585. this.constructInterpolated,
  45586. this.constructStiched,
  45587. this.constructPostScript
  45588. ];
  45589. var typeNum = dict.get('FunctionType');
  45590. var typeFn = types[typeNum];
  45591. if (!typeFn) {
  45592. error('Unknown type of function');
  45593. }
  45594. return typeFn.call(this, fn, dict, xref);
  45595. },
  45596. fromIR: function PDFFunction_fromIR(IR) {
  45597. var type = IR[0];
  45598. switch (type) {
  45599. case CONSTRUCT_SAMPLED:
  45600. return this.constructSampledFromIR(IR);
  45601. case CONSTRUCT_INTERPOLATED:
  45602. return this.constructInterpolatedFromIR(IR);
  45603. case CONSTRUCT_STICHED:
  45604. return this.constructStichedFromIR(IR);
  45605. default:
  45606. return this.constructPostScriptFromIR(IR);
  45607. }
  45608. },
  45609. parse: function PDFFunction_parse(xref, fn) {
  45610. var IR = this.getIR(xref, fn);
  45611. return this.fromIR(IR);
  45612. },
  45613. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45614. if (!isArray(fnObj)) {
  45615. return this.parse(xref, fnObj);
  45616. }
  45617. var fnArray = [];
  45618. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45619. var obj = xref.fetchIfRef(fnObj[j]);
  45620. fnArray.push(PDFFunction.parse(xref, obj));
  45621. }
  45622. return function (src, srcOffset, dest, destOffset) {
  45623. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45624. fnArray[i](src, srcOffset, dest, destOffset + i);
  45625. }
  45626. };
  45627. },
  45628. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45629. function toMultiArray(arr) {
  45630. var inputLength = arr.length;
  45631. var out = [];
  45632. var index = 0;
  45633. for (var i = 0; i < inputLength; i += 2) {
  45634. out[index] = [
  45635. arr[i],
  45636. arr[i + 1]
  45637. ];
  45638. ++index;
  45639. }
  45640. return out;
  45641. }
  45642. var domain = dict.getArray('Domain');
  45643. var range = dict.getArray('Range');
  45644. if (!domain || !range) {
  45645. error('No domain or range');
  45646. }
  45647. var inputSize = domain.length / 2;
  45648. var outputSize = range.length / 2;
  45649. domain = toMultiArray(domain);
  45650. range = toMultiArray(range);
  45651. var size = dict.get('Size');
  45652. var bps = dict.get('BitsPerSample');
  45653. var order = dict.get('Order') || 1;
  45654. if (order !== 1) {
  45655. info('No support for cubic spline interpolation: ' + order);
  45656. }
  45657. var encode = dict.getArray('Encode');
  45658. if (!encode) {
  45659. encode = [];
  45660. for (var i = 0; i < inputSize; ++i) {
  45661. encode.push(0);
  45662. encode.push(size[i] - 1);
  45663. }
  45664. }
  45665. encode = toMultiArray(encode);
  45666. var decode = dict.getArray('Decode');
  45667. if (!decode) {
  45668. decode = range;
  45669. } else {
  45670. decode = toMultiArray(decode);
  45671. }
  45672. var samples = this.getSampleArray(size, outputSize, bps, str);
  45673. return [
  45674. CONSTRUCT_SAMPLED,
  45675. inputSize,
  45676. domain,
  45677. encode,
  45678. decode,
  45679. samples,
  45680. size,
  45681. outputSize,
  45682. Math.pow(2, bps) - 1,
  45683. range
  45684. ];
  45685. },
  45686. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45687. function interpolate(x, xmin, xmax, ymin, ymax) {
  45688. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45689. }
  45690. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45691. var m = IR[1];
  45692. var domain = IR[2];
  45693. var encode = IR[3];
  45694. var decode = IR[4];
  45695. var samples = IR[5];
  45696. var size = IR[6];
  45697. var n = IR[7];
  45698. var range = IR[9];
  45699. var cubeVertices = 1 << m;
  45700. var cubeN = new Float64Array(cubeVertices);
  45701. var cubeVertex = new Uint32Array(cubeVertices);
  45702. var i, j;
  45703. for (j = 0; j < cubeVertices; j++) {
  45704. cubeN[j] = 1;
  45705. }
  45706. var k = n, pos = 1;
  45707. for (i = 0; i < m; ++i) {
  45708. var domain_2i = domain[i][0];
  45709. var domain_2i_1 = domain[i][1];
  45710. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45711. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45712. var size_i = size[i];
  45713. e = Math.min(Math.max(e, 0), size_i - 1);
  45714. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45715. var n0 = e0 + 1 - e;
  45716. var n1 = e - e0;
  45717. var offset0 = e0 * k;
  45718. var offset1 = offset0 + k;
  45719. for (j = 0; j < cubeVertices; j++) {
  45720. if (j & pos) {
  45721. cubeN[j] *= n1;
  45722. cubeVertex[j] += offset1;
  45723. } else {
  45724. cubeN[j] *= n0;
  45725. cubeVertex[j] += offset0;
  45726. }
  45727. }
  45728. k *= size_i;
  45729. pos <<= 1;
  45730. }
  45731. for (j = 0; j < n; ++j) {
  45732. var rj = 0;
  45733. for (i = 0; i < cubeVertices; i++) {
  45734. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45735. }
  45736. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45737. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45738. }
  45739. };
  45740. },
  45741. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45742. var c0 = dict.getArray('C0') || [0];
  45743. var c1 = dict.getArray('C1') || [1];
  45744. var n = dict.get('N');
  45745. if (!isArray(c0) || !isArray(c1)) {
  45746. error('Illegal dictionary for interpolated function');
  45747. }
  45748. var length = c0.length;
  45749. var diff = [];
  45750. for (var i = 0; i < length; ++i) {
  45751. diff.push(c1[i] - c0[i]);
  45752. }
  45753. return [
  45754. CONSTRUCT_INTERPOLATED,
  45755. c0,
  45756. diff,
  45757. n
  45758. ];
  45759. },
  45760. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45761. var c0 = IR[1];
  45762. var diff = IR[2];
  45763. var n = IR[3];
  45764. var length = diff.length;
  45765. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45766. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45767. for (var j = 0; j < length; ++j) {
  45768. dest[destOffset + j] = c0[j] + x * diff[j];
  45769. }
  45770. };
  45771. },
  45772. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45773. var domain = dict.getArray('Domain');
  45774. if (!domain) {
  45775. error('No domain');
  45776. }
  45777. var inputSize = domain.length / 2;
  45778. if (inputSize !== 1) {
  45779. error('Bad domain for stiched function');
  45780. }
  45781. var fnRefs = dict.get('Functions');
  45782. var fns = [];
  45783. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45784. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45785. }
  45786. var bounds = dict.getArray('Bounds');
  45787. var encode = dict.getArray('Encode');
  45788. return [
  45789. CONSTRUCT_STICHED,
  45790. domain,
  45791. bounds,
  45792. encode,
  45793. fns
  45794. ];
  45795. },
  45796. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45797. var domain = IR[1];
  45798. var bounds = IR[2];
  45799. var encode = IR[3];
  45800. var fnsIR = IR[4];
  45801. var fns = [];
  45802. var tmpBuf = new Float32Array(1);
  45803. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45804. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45805. }
  45806. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45807. var clip = function constructStichedFromIRClip(v, min, max) {
  45808. if (v > max) {
  45809. v = max;
  45810. } else if (v < min) {
  45811. v = min;
  45812. }
  45813. return v;
  45814. };
  45815. var v = clip(src[srcOffset], domain[0], domain[1]);
  45816. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45817. if (v < bounds[i]) {
  45818. break;
  45819. }
  45820. }
  45821. var dmin = domain[0];
  45822. if (i > 0) {
  45823. dmin = bounds[i - 1];
  45824. }
  45825. var dmax = domain[1];
  45826. if (i < bounds.length) {
  45827. dmax = bounds[i];
  45828. }
  45829. var rmin = encode[2 * i];
  45830. var rmax = encode[2 * i + 1];
  45831. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45832. fns[i](tmpBuf, 0, dest, destOffset);
  45833. };
  45834. },
  45835. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45836. var domain = dict.getArray('Domain');
  45837. var range = dict.getArray('Range');
  45838. if (!domain) {
  45839. error('No domain.');
  45840. }
  45841. if (!range) {
  45842. error('No range.');
  45843. }
  45844. var lexer = new PostScriptLexer(fn);
  45845. var parser = new PostScriptParser(lexer);
  45846. var code = parser.parse();
  45847. return [
  45848. CONSTRUCT_POSTSCRIPT,
  45849. domain,
  45850. range,
  45851. code
  45852. ];
  45853. },
  45854. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45855. var domain = IR[1];
  45856. var range = IR[2];
  45857. var code = IR[3];
  45858. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45859. if (compiled) {
  45860. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45861. }
  45862. info('Unable to compile PS function');
  45863. var numOutputs = range.length >> 1;
  45864. var numInputs = domain.length >> 1;
  45865. var evaluator = new PostScriptEvaluator(code);
  45866. var cache = Object.create(null);
  45867. var MAX_CACHE_SIZE = 2048 * 4;
  45868. var cache_available = MAX_CACHE_SIZE;
  45869. var tmpBuf = new Float32Array(numInputs);
  45870. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45871. var i, value;
  45872. var key = '';
  45873. var input = tmpBuf;
  45874. for (i = 0; i < numInputs; i++) {
  45875. value = src[srcOffset + i];
  45876. input[i] = value;
  45877. key += value + '_';
  45878. }
  45879. var cachedValue = cache[key];
  45880. if (cachedValue !== undefined) {
  45881. dest.set(cachedValue, destOffset);
  45882. return;
  45883. }
  45884. var output = new Float32Array(numOutputs);
  45885. var stack = evaluator.execute(input);
  45886. var stackIndex = stack.length - numOutputs;
  45887. for (i = 0; i < numOutputs; i++) {
  45888. value = stack[stackIndex + i];
  45889. var bound = range[i * 2];
  45890. if (value < bound) {
  45891. value = bound;
  45892. } else {
  45893. bound = range[i * 2 + 1];
  45894. if (value > bound) {
  45895. value = bound;
  45896. }
  45897. }
  45898. output[i] = value;
  45899. }
  45900. if (cache_available > 0) {
  45901. cache_available--;
  45902. cache[key] = output;
  45903. }
  45904. dest.set(output, destOffset);
  45905. };
  45906. }
  45907. };
  45908. }();
  45909. function isPDFFunction(v) {
  45910. var fnDict;
  45911. if (typeof v !== 'object') {
  45912. return false;
  45913. } else if (isDict(v)) {
  45914. fnDict = v;
  45915. } else if (isStream(v)) {
  45916. fnDict = v.dict;
  45917. } else {
  45918. return false;
  45919. }
  45920. return fnDict.has('FunctionType');
  45921. }
  45922. var PostScriptStack = function PostScriptStackClosure() {
  45923. var MAX_STACK_SIZE = 100;
  45924. function PostScriptStack(initialStack) {
  45925. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45926. }
  45927. PostScriptStack.prototype = {
  45928. push: function PostScriptStack_push(value) {
  45929. if (this.stack.length >= MAX_STACK_SIZE) {
  45930. error('PostScript function stack overflow.');
  45931. }
  45932. this.stack.push(value);
  45933. },
  45934. pop: function PostScriptStack_pop() {
  45935. if (this.stack.length <= 0) {
  45936. error('PostScript function stack underflow.');
  45937. }
  45938. return this.stack.pop();
  45939. },
  45940. copy: function PostScriptStack_copy(n) {
  45941. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45942. error('PostScript function stack overflow.');
  45943. }
  45944. var stack = this.stack;
  45945. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45946. stack.push(stack[i]);
  45947. }
  45948. },
  45949. index: function PostScriptStack_index(n) {
  45950. this.push(this.stack[this.stack.length - n - 1]);
  45951. },
  45952. roll: function PostScriptStack_roll(n, p) {
  45953. var stack = this.stack;
  45954. var l = stack.length - n;
  45955. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45956. for (i = l, j = r; i < j; i++, j--) {
  45957. t = stack[i];
  45958. stack[i] = stack[j];
  45959. stack[j] = t;
  45960. }
  45961. for (i = l, j = c - 1; i < j; i++, j--) {
  45962. t = stack[i];
  45963. stack[i] = stack[j];
  45964. stack[j] = t;
  45965. }
  45966. for (i = c, j = r; i < j; i++, j--) {
  45967. t = stack[i];
  45968. stack[i] = stack[j];
  45969. stack[j] = t;
  45970. }
  45971. }
  45972. };
  45973. return PostScriptStack;
  45974. }();
  45975. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45976. function PostScriptEvaluator(operators) {
  45977. this.operators = operators;
  45978. }
  45979. PostScriptEvaluator.prototype = {
  45980. execute: function PostScriptEvaluator_execute(initialStack) {
  45981. var stack = new PostScriptStack(initialStack);
  45982. var counter = 0;
  45983. var operators = this.operators;
  45984. var length = operators.length;
  45985. var operator, a, b;
  45986. while (counter < length) {
  45987. operator = operators[counter++];
  45988. if (typeof operator === 'number') {
  45989. stack.push(operator);
  45990. continue;
  45991. }
  45992. switch (operator) {
  45993. case 'jz':
  45994. b = stack.pop();
  45995. a = stack.pop();
  45996. if (!a) {
  45997. counter = b;
  45998. }
  45999. break;
  46000. case 'j':
  46001. a = stack.pop();
  46002. counter = a;
  46003. break;
  46004. case 'abs':
  46005. a = stack.pop();
  46006. stack.push(Math.abs(a));
  46007. break;
  46008. case 'add':
  46009. b = stack.pop();
  46010. a = stack.pop();
  46011. stack.push(a + b);
  46012. break;
  46013. case 'and':
  46014. b = stack.pop();
  46015. a = stack.pop();
  46016. if (isBool(a) && isBool(b)) {
  46017. stack.push(a && b);
  46018. } else {
  46019. stack.push(a & b);
  46020. }
  46021. break;
  46022. case 'atan':
  46023. a = stack.pop();
  46024. stack.push(Math.atan(a));
  46025. break;
  46026. case 'bitshift':
  46027. b = stack.pop();
  46028. a = stack.pop();
  46029. if (a > 0) {
  46030. stack.push(a << b);
  46031. } else {
  46032. stack.push(a >> b);
  46033. }
  46034. break;
  46035. case 'ceiling':
  46036. a = stack.pop();
  46037. stack.push(Math.ceil(a));
  46038. break;
  46039. case 'copy':
  46040. a = stack.pop();
  46041. stack.copy(a);
  46042. break;
  46043. case 'cos':
  46044. a = stack.pop();
  46045. stack.push(Math.cos(a));
  46046. break;
  46047. case 'cvi':
  46048. a = stack.pop() | 0;
  46049. stack.push(a);
  46050. break;
  46051. case 'cvr':
  46052. break;
  46053. case 'div':
  46054. b = stack.pop();
  46055. a = stack.pop();
  46056. stack.push(a / b);
  46057. break;
  46058. case 'dup':
  46059. stack.copy(1);
  46060. break;
  46061. case 'eq':
  46062. b = stack.pop();
  46063. a = stack.pop();
  46064. stack.push(a === b);
  46065. break;
  46066. case 'exch':
  46067. stack.roll(2, 1);
  46068. break;
  46069. case 'exp':
  46070. b = stack.pop();
  46071. a = stack.pop();
  46072. stack.push(Math.pow(a, b));
  46073. break;
  46074. case 'false':
  46075. stack.push(false);
  46076. break;
  46077. case 'floor':
  46078. a = stack.pop();
  46079. stack.push(Math.floor(a));
  46080. break;
  46081. case 'ge':
  46082. b = stack.pop();
  46083. a = stack.pop();
  46084. stack.push(a >= b);
  46085. break;
  46086. case 'gt':
  46087. b = stack.pop();
  46088. a = stack.pop();
  46089. stack.push(a > b);
  46090. break;
  46091. case 'idiv':
  46092. b = stack.pop();
  46093. a = stack.pop();
  46094. stack.push(a / b | 0);
  46095. break;
  46096. case 'index':
  46097. a = stack.pop();
  46098. stack.index(a);
  46099. break;
  46100. case 'le':
  46101. b = stack.pop();
  46102. a = stack.pop();
  46103. stack.push(a <= b);
  46104. break;
  46105. case 'ln':
  46106. a = stack.pop();
  46107. stack.push(Math.log(a));
  46108. break;
  46109. case 'log':
  46110. a = stack.pop();
  46111. stack.push(Math.log(a) / Math.LN10);
  46112. break;
  46113. case 'lt':
  46114. b = stack.pop();
  46115. a = stack.pop();
  46116. stack.push(a < b);
  46117. break;
  46118. case 'mod':
  46119. b = stack.pop();
  46120. a = stack.pop();
  46121. stack.push(a % b);
  46122. break;
  46123. case 'mul':
  46124. b = stack.pop();
  46125. a = stack.pop();
  46126. stack.push(a * b);
  46127. break;
  46128. case 'ne':
  46129. b = stack.pop();
  46130. a = stack.pop();
  46131. stack.push(a !== b);
  46132. break;
  46133. case 'neg':
  46134. a = stack.pop();
  46135. stack.push(-a);
  46136. break;
  46137. case 'not':
  46138. a = stack.pop();
  46139. if (isBool(a)) {
  46140. stack.push(!a);
  46141. } else {
  46142. stack.push(~a);
  46143. }
  46144. break;
  46145. case 'or':
  46146. b = stack.pop();
  46147. a = stack.pop();
  46148. if (isBool(a) && isBool(b)) {
  46149. stack.push(a || b);
  46150. } else {
  46151. stack.push(a | b);
  46152. }
  46153. break;
  46154. case 'pop':
  46155. stack.pop();
  46156. break;
  46157. case 'roll':
  46158. b = stack.pop();
  46159. a = stack.pop();
  46160. stack.roll(a, b);
  46161. break;
  46162. case 'round':
  46163. a = stack.pop();
  46164. stack.push(Math.round(a));
  46165. break;
  46166. case 'sin':
  46167. a = stack.pop();
  46168. stack.push(Math.sin(a));
  46169. break;
  46170. case 'sqrt':
  46171. a = stack.pop();
  46172. stack.push(Math.sqrt(a));
  46173. break;
  46174. case 'sub':
  46175. b = stack.pop();
  46176. a = stack.pop();
  46177. stack.push(a - b);
  46178. break;
  46179. case 'true':
  46180. stack.push(true);
  46181. break;
  46182. case 'truncate':
  46183. a = stack.pop();
  46184. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46185. stack.push(a);
  46186. break;
  46187. case 'xor':
  46188. b = stack.pop();
  46189. a = stack.pop();
  46190. if (isBool(a) && isBool(b)) {
  46191. stack.push(a !== b);
  46192. } else {
  46193. stack.push(a ^ b);
  46194. }
  46195. break;
  46196. default:
  46197. error('Unknown operator ' + operator);
  46198. break;
  46199. }
  46200. }
  46201. return stack.stack;
  46202. }
  46203. };
  46204. return PostScriptEvaluator;
  46205. }();
  46206. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46207. function AstNode(type) {
  46208. this.type = type;
  46209. }
  46210. AstNode.prototype.visit = function (visitor) {
  46211. throw new Error('abstract method');
  46212. };
  46213. function AstArgument(index, min, max) {
  46214. AstNode.call(this, 'args');
  46215. this.index = index;
  46216. this.min = min;
  46217. this.max = max;
  46218. }
  46219. AstArgument.prototype = Object.create(AstNode.prototype);
  46220. AstArgument.prototype.visit = function (visitor) {
  46221. visitor.visitArgument(this);
  46222. };
  46223. function AstLiteral(number) {
  46224. AstNode.call(this, 'literal');
  46225. this.number = number;
  46226. this.min = number;
  46227. this.max = number;
  46228. }
  46229. AstLiteral.prototype = Object.create(AstNode.prototype);
  46230. AstLiteral.prototype.visit = function (visitor) {
  46231. visitor.visitLiteral(this);
  46232. };
  46233. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46234. AstNode.call(this, 'binary');
  46235. this.op = op;
  46236. this.arg1 = arg1;
  46237. this.arg2 = arg2;
  46238. this.min = min;
  46239. this.max = max;
  46240. }
  46241. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46242. AstBinaryOperation.prototype.visit = function (visitor) {
  46243. visitor.visitBinaryOperation(this);
  46244. };
  46245. function AstMin(arg, max) {
  46246. AstNode.call(this, 'max');
  46247. this.arg = arg;
  46248. this.min = arg.min;
  46249. this.max = max;
  46250. }
  46251. AstMin.prototype = Object.create(AstNode.prototype);
  46252. AstMin.prototype.visit = function (visitor) {
  46253. visitor.visitMin(this);
  46254. };
  46255. function AstVariable(index, min, max) {
  46256. AstNode.call(this, 'var');
  46257. this.index = index;
  46258. this.min = min;
  46259. this.max = max;
  46260. }
  46261. AstVariable.prototype = Object.create(AstNode.prototype);
  46262. AstVariable.prototype.visit = function (visitor) {
  46263. visitor.visitVariable(this);
  46264. };
  46265. function AstVariableDefinition(variable, arg) {
  46266. AstNode.call(this, 'definition');
  46267. this.variable = variable;
  46268. this.arg = arg;
  46269. }
  46270. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46271. AstVariableDefinition.prototype.visit = function (visitor) {
  46272. visitor.visitVariableDefinition(this);
  46273. };
  46274. function ExpressionBuilderVisitor() {
  46275. this.parts = [];
  46276. }
  46277. ExpressionBuilderVisitor.prototype = {
  46278. visitArgument: function (arg) {
  46279. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46280. },
  46281. visitVariable: function (variable) {
  46282. this.parts.push('v', variable.index);
  46283. },
  46284. visitLiteral: function (literal) {
  46285. this.parts.push(literal.number);
  46286. },
  46287. visitBinaryOperation: function (operation) {
  46288. this.parts.push('(');
  46289. operation.arg1.visit(this);
  46290. this.parts.push(' ', operation.op, ' ');
  46291. operation.arg2.visit(this);
  46292. this.parts.push(')');
  46293. },
  46294. visitVariableDefinition: function (definition) {
  46295. this.parts.push('var ');
  46296. definition.variable.visit(this);
  46297. this.parts.push(' = ');
  46298. definition.arg.visit(this);
  46299. this.parts.push(';');
  46300. },
  46301. visitMin: function (max) {
  46302. this.parts.push('Math.min(');
  46303. max.arg.visit(this);
  46304. this.parts.push(', ', max.max, ')');
  46305. },
  46306. toString: function () {
  46307. return this.parts.join('');
  46308. }
  46309. };
  46310. function buildAddOperation(num1, num2) {
  46311. if (num2.type === 'literal' && num2.number === 0) {
  46312. return num1;
  46313. }
  46314. if (num1.type === 'literal' && num1.number === 0) {
  46315. return num2;
  46316. }
  46317. if (num2.type === 'literal' && num1.type === 'literal') {
  46318. return new AstLiteral(num1.number + num2.number);
  46319. }
  46320. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46321. }
  46322. function buildMulOperation(num1, num2) {
  46323. if (num2.type === 'literal') {
  46324. if (num2.number === 0) {
  46325. return new AstLiteral(0);
  46326. } else if (num2.number === 1) {
  46327. return num1;
  46328. } else if (num1.type === 'literal') {
  46329. return new AstLiteral(num1.number * num2.number);
  46330. }
  46331. }
  46332. if (num1.type === 'literal') {
  46333. if (num1.number === 0) {
  46334. return new AstLiteral(0);
  46335. } else if (num1.number === 1) {
  46336. return num2;
  46337. }
  46338. }
  46339. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46340. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46341. return new AstBinaryOperation('*', num1, num2, min, max);
  46342. }
  46343. function buildSubOperation(num1, num2) {
  46344. if (num2.type === 'literal') {
  46345. if (num2.number === 0) {
  46346. return num1;
  46347. } else if (num1.type === 'literal') {
  46348. return new AstLiteral(num1.number - num2.number);
  46349. }
  46350. }
  46351. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46352. return num2.arg2;
  46353. }
  46354. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46355. }
  46356. function buildMinOperation(num1, max) {
  46357. if (num1.min >= max) {
  46358. return new AstLiteral(max);
  46359. } else if (num1.max <= max) {
  46360. return num1;
  46361. }
  46362. return new AstMin(num1, max);
  46363. }
  46364. function PostScriptCompiler() {
  46365. }
  46366. PostScriptCompiler.prototype = {
  46367. compile: function PostScriptCompiler_compile(code, domain, range) {
  46368. var stack = [];
  46369. var i, ii;
  46370. var instructions = [];
  46371. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46372. var lastRegister = 0;
  46373. var n, j;
  46374. var num1, num2, ast1, ast2, tmpVar, item;
  46375. for (i = 0; i < inputSize; i++) {
  46376. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46377. }
  46378. for (i = 0, ii = code.length; i < ii; i++) {
  46379. item = code[i];
  46380. if (typeof item === 'number') {
  46381. stack.push(new AstLiteral(item));
  46382. continue;
  46383. }
  46384. switch (item) {
  46385. case 'add':
  46386. if (stack.length < 2) {
  46387. return null;
  46388. }
  46389. num2 = stack.pop();
  46390. num1 = stack.pop();
  46391. stack.push(buildAddOperation(num1, num2));
  46392. break;
  46393. case 'cvr':
  46394. if (stack.length < 1) {
  46395. return null;
  46396. }
  46397. break;
  46398. case 'mul':
  46399. if (stack.length < 2) {
  46400. return null;
  46401. }
  46402. num2 = stack.pop();
  46403. num1 = stack.pop();
  46404. stack.push(buildMulOperation(num1, num2));
  46405. break;
  46406. case 'sub':
  46407. if (stack.length < 2) {
  46408. return null;
  46409. }
  46410. num2 = stack.pop();
  46411. num1 = stack.pop();
  46412. stack.push(buildSubOperation(num1, num2));
  46413. break;
  46414. case 'exch':
  46415. if (stack.length < 2) {
  46416. return null;
  46417. }
  46418. ast1 = stack.pop();
  46419. ast2 = stack.pop();
  46420. stack.push(ast1, ast2);
  46421. break;
  46422. case 'pop':
  46423. if (stack.length < 1) {
  46424. return null;
  46425. }
  46426. stack.pop();
  46427. break;
  46428. case 'index':
  46429. if (stack.length < 1) {
  46430. return null;
  46431. }
  46432. num1 = stack.pop();
  46433. if (num1.type !== 'literal') {
  46434. return null;
  46435. }
  46436. n = num1.number;
  46437. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46438. return null;
  46439. }
  46440. ast1 = stack[stack.length - n - 1];
  46441. if (ast1.type === 'literal' || ast1.type === 'var') {
  46442. stack.push(ast1);
  46443. break;
  46444. }
  46445. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46446. stack[stack.length - n - 1] = tmpVar;
  46447. stack.push(tmpVar);
  46448. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46449. break;
  46450. case 'dup':
  46451. if (stack.length < 1) {
  46452. return null;
  46453. }
  46454. 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]) {
  46455. num1 = stack.pop();
  46456. stack.push(buildMinOperation(num1, code[i + 1]));
  46457. i += 6;
  46458. break;
  46459. }
  46460. ast1 = stack[stack.length - 1];
  46461. if (ast1.type === 'literal' || ast1.type === 'var') {
  46462. stack.push(ast1);
  46463. break;
  46464. }
  46465. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46466. stack[stack.length - 1] = tmpVar;
  46467. stack.push(tmpVar);
  46468. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46469. break;
  46470. case 'roll':
  46471. if (stack.length < 2) {
  46472. return null;
  46473. }
  46474. num2 = stack.pop();
  46475. num1 = stack.pop();
  46476. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46477. return null;
  46478. }
  46479. j = num2.number;
  46480. n = num1.number;
  46481. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46482. return null;
  46483. }
  46484. j = (j % n + n) % n;
  46485. if (j === 0) {
  46486. break;
  46487. }
  46488. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46489. break;
  46490. default:
  46491. return null;
  46492. }
  46493. }
  46494. if (stack.length !== outputSize) {
  46495. return null;
  46496. }
  46497. var result = [];
  46498. instructions.forEach(function (instruction) {
  46499. var statementBuilder = new ExpressionBuilderVisitor();
  46500. instruction.visit(statementBuilder);
  46501. result.push(statementBuilder.toString());
  46502. });
  46503. stack.forEach(function (expr, i) {
  46504. var statementBuilder = new ExpressionBuilderVisitor();
  46505. expr.visit(statementBuilder);
  46506. var min = range[i * 2], max = range[i * 2 + 1];
  46507. var out = [statementBuilder.toString()];
  46508. if (min > expr.min) {
  46509. out.unshift('Math.max(', min, ', ');
  46510. out.push(')');
  46511. }
  46512. if (max < expr.max) {
  46513. out.unshift('Math.min(', max, ', ');
  46514. out.push(')');
  46515. }
  46516. out.unshift('dest[destOffset + ', i, '] = ');
  46517. out.push(';');
  46518. result.push(out.join(''));
  46519. });
  46520. return result.join('\n');
  46521. }
  46522. };
  46523. return PostScriptCompiler;
  46524. }();
  46525. exports.isPDFFunction = isPDFFunction;
  46526. exports.PDFFunction = PDFFunction;
  46527. exports.PostScriptEvaluator = PostScriptEvaluator;
  46528. exports.PostScriptCompiler = PostScriptCompiler;
  46529. }));
  46530. (function (root, factory) {
  46531. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46532. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46533. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46534. var MessageHandler = sharedUtil.MessageHandler;
  46535. var MissingPDFException = sharedUtil.MissingPDFException;
  46536. var PageViewport = sharedUtil.PageViewport;
  46537. var PasswordResponses = sharedUtil.PasswordResponses;
  46538. var PasswordException = sharedUtil.PasswordException;
  46539. var StatTimer = sharedUtil.StatTimer;
  46540. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46541. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46542. var Util = sharedUtil.Util;
  46543. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46544. var error = sharedUtil.error;
  46545. var deprecated = sharedUtil.deprecated;
  46546. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46547. var info = sharedUtil.info;
  46548. var isInt = sharedUtil.isInt;
  46549. var isArray = sharedUtil.isArray;
  46550. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46551. var isSameOrigin = sharedUtil.isSameOrigin;
  46552. var loadJpegStream = sharedUtil.loadJpegStream;
  46553. var stringToBytes = sharedUtil.stringToBytes;
  46554. var globalScope = sharedUtil.globalScope;
  46555. var warn = sharedUtil.warn;
  46556. var FontFaceObject = displayFontLoader.FontFaceObject;
  46557. var FontLoader = displayFontLoader.FontLoader;
  46558. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46559. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46560. var Metadata = displayMetadata.Metadata;
  46561. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46562. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46563. var isWorkerDisabled = false;
  46564. var workerSrc;
  46565. var isPostMessageTransfersDisabled = false;
  46566. var fakeWorkerFilesLoader = null;
  46567. var useRequireEnsure = false;
  46568. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46569. var task = new PDFDocumentLoadingTask();
  46570. if (arguments.length > 1) {
  46571. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46572. }
  46573. if (pdfDataRangeTransport) {
  46574. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46575. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46576. pdfDataRangeTransport.length = src.length;
  46577. pdfDataRangeTransport.initialData = src.initialData;
  46578. if (!pdfDataRangeTransport.abort) {
  46579. pdfDataRangeTransport.abort = function () {
  46580. };
  46581. }
  46582. }
  46583. src = Object.create(src);
  46584. src.range = pdfDataRangeTransport;
  46585. }
  46586. task.onPassword = passwordCallback || null;
  46587. task.onProgress = progressCallback || null;
  46588. var source;
  46589. if (typeof src === 'string') {
  46590. source = { url: src };
  46591. } else if (isArrayBuffer(src)) {
  46592. source = { data: src };
  46593. } else if (src instanceof PDFDataRangeTransport) {
  46594. source = { range: src };
  46595. } else {
  46596. if (typeof src !== 'object') {
  46597. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46598. }
  46599. if (!src.url && !src.data && !src.range) {
  46600. error('Invalid parameter object: need either .data, .range or .url');
  46601. }
  46602. source = src;
  46603. }
  46604. var params = {};
  46605. var rangeTransport = null;
  46606. var worker = null;
  46607. for (var key in source) {
  46608. if (key === 'url' && typeof window !== 'undefined') {
  46609. params[key] = new URL(source[key], window.location).href;
  46610. continue;
  46611. } else if (key === 'range') {
  46612. rangeTransport = source[key];
  46613. continue;
  46614. } else if (key === 'worker') {
  46615. worker = source[key];
  46616. continue;
  46617. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46618. var pdfBytes = source[key];
  46619. if (typeof pdfBytes === 'string') {
  46620. params[key] = stringToBytes(pdfBytes);
  46621. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46622. params[key] = new Uint8Array(pdfBytes);
  46623. } else if (isArrayBuffer(pdfBytes)) {
  46624. params[key] = new Uint8Array(pdfBytes);
  46625. } else {
  46626. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46627. }
  46628. continue;
  46629. }
  46630. params[key] = source[key];
  46631. }
  46632. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46633. if (!worker) {
  46634. worker = new PDFWorker();
  46635. task._worker = worker;
  46636. }
  46637. var docId = task.docId;
  46638. worker.promise.then(function () {
  46639. if (task.destroyed) {
  46640. throw new Error('Loading aborted');
  46641. }
  46642. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46643. if (task.destroyed) {
  46644. throw new Error('Loading aborted');
  46645. }
  46646. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46647. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46648. task._transport = transport;
  46649. messageHandler.send('Ready', null);
  46650. });
  46651. }).catch(task._capability.reject);
  46652. return task;
  46653. }
  46654. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46655. if (worker.destroyed) {
  46656. return Promise.reject(new Error('Worker was destroyed'));
  46657. }
  46658. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46659. source.disableStream = getDefaultSetting('disableStream');
  46660. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46661. if (pdfDataRangeTransport) {
  46662. source.length = pdfDataRangeTransport.length;
  46663. source.initialData = pdfDataRangeTransport.initialData;
  46664. }
  46665. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46666. docId: docId,
  46667. source: source,
  46668. disableRange: getDefaultSetting('disableRange'),
  46669. maxImageSize: getDefaultSetting('maxImageSize'),
  46670. cMapUrl: getDefaultSetting('cMapUrl'),
  46671. cMapPacked: getDefaultSetting('cMapPacked'),
  46672. disableFontFace: getDefaultSetting('disableFontFace'),
  46673. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46674. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46675. docBaseUrl: source.docBaseUrl
  46676. }).then(function (workerId) {
  46677. if (worker.destroyed) {
  46678. throw new Error('Worker was destroyed');
  46679. }
  46680. return workerId;
  46681. });
  46682. }
  46683. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46684. var nextDocumentId = 0;
  46685. function PDFDocumentLoadingTask() {
  46686. this._capability = createPromiseCapability();
  46687. this._transport = null;
  46688. this._worker = null;
  46689. this.docId = 'd' + nextDocumentId++;
  46690. this.destroyed = false;
  46691. this.onPassword = null;
  46692. this.onProgress = null;
  46693. this.onUnsupportedFeature = null;
  46694. }
  46695. PDFDocumentLoadingTask.prototype = {
  46696. get promise() {
  46697. return this._capability.promise;
  46698. },
  46699. destroy: function () {
  46700. this.destroyed = true;
  46701. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46702. return transportDestroyed.then(function () {
  46703. this._transport = null;
  46704. if (this._worker) {
  46705. this._worker.destroy();
  46706. this._worker = null;
  46707. }
  46708. }.bind(this));
  46709. },
  46710. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46711. return this.promise.then.apply(this.promise, arguments);
  46712. }
  46713. };
  46714. return PDFDocumentLoadingTask;
  46715. }();
  46716. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46717. function PDFDataRangeTransport(length, initialData) {
  46718. this.length = length;
  46719. this.initialData = initialData;
  46720. this._rangeListeners = [];
  46721. this._progressListeners = [];
  46722. this._progressiveReadListeners = [];
  46723. this._readyCapability = createPromiseCapability();
  46724. }
  46725. PDFDataRangeTransport.prototype = {
  46726. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46727. this._rangeListeners.push(listener);
  46728. },
  46729. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46730. this._progressListeners.push(listener);
  46731. },
  46732. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46733. this._progressiveReadListeners.push(listener);
  46734. },
  46735. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46736. var listeners = this._rangeListeners;
  46737. for (var i = 0, n = listeners.length; i < n; ++i) {
  46738. listeners[i](begin, chunk);
  46739. }
  46740. },
  46741. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46742. this._readyCapability.promise.then(function () {
  46743. var listeners = this._progressListeners;
  46744. for (var i = 0, n = listeners.length; i < n; ++i) {
  46745. listeners[i](loaded);
  46746. }
  46747. }.bind(this));
  46748. },
  46749. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46750. this._readyCapability.promise.then(function () {
  46751. var listeners = this._progressiveReadListeners;
  46752. for (var i = 0, n = listeners.length; i < n; ++i) {
  46753. listeners[i](chunk);
  46754. }
  46755. }.bind(this));
  46756. },
  46757. transportReady: function PDFDataRangeTransport_transportReady() {
  46758. this._readyCapability.resolve();
  46759. },
  46760. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46761. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46762. },
  46763. abort: function PDFDataRangeTransport_abort() {
  46764. }
  46765. };
  46766. return PDFDataRangeTransport;
  46767. }();
  46768. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46769. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46770. this.pdfInfo = pdfInfo;
  46771. this.transport = transport;
  46772. this.loadingTask = loadingTask;
  46773. }
  46774. PDFDocumentProxy.prototype = {
  46775. get numPages() {
  46776. return this.pdfInfo.numPages;
  46777. },
  46778. get fingerprint() {
  46779. return this.pdfInfo.fingerprint;
  46780. },
  46781. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46782. return this.transport.getPage(pageNumber);
  46783. },
  46784. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46785. return this.transport.getPageIndex(ref);
  46786. },
  46787. getDestinations: function PDFDocumentProxy_getDestinations() {
  46788. return this.transport.getDestinations();
  46789. },
  46790. getDestination: function PDFDocumentProxy_getDestination(id) {
  46791. return this.transport.getDestination(id);
  46792. },
  46793. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46794. return this.transport.getPageLabels();
  46795. },
  46796. getAttachments: function PDFDocumentProxy_getAttachments() {
  46797. return this.transport.getAttachments();
  46798. },
  46799. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46800. return this.transport.getJavaScript();
  46801. },
  46802. getOutline: function PDFDocumentProxy_getOutline() {
  46803. return this.transport.getOutline();
  46804. },
  46805. getMetadata: function PDFDocumentProxy_getMetadata() {
  46806. return this.transport.getMetadata();
  46807. },
  46808. getData: function PDFDocumentProxy_getData() {
  46809. return this.transport.getData();
  46810. },
  46811. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46812. return this.transport.downloadInfoCapability.promise;
  46813. },
  46814. getStats: function PDFDocumentProxy_getStats() {
  46815. return this.transport.getStats();
  46816. },
  46817. cleanup: function PDFDocumentProxy_cleanup() {
  46818. this.transport.startCleanup();
  46819. },
  46820. destroy: function PDFDocumentProxy_destroy() {
  46821. return this.loadingTask.destroy();
  46822. }
  46823. };
  46824. return PDFDocumentProxy;
  46825. }();
  46826. var PDFPageProxy = function PDFPageProxyClosure() {
  46827. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46828. this.pageIndex = pageIndex;
  46829. this.pageInfo = pageInfo;
  46830. this.transport = transport;
  46831. this.stats = new StatTimer();
  46832. this.stats.enabled = getDefaultSetting('enableStats');
  46833. this.commonObjs = transport.commonObjs;
  46834. this.objs = new PDFObjects();
  46835. this.cleanupAfterRender = false;
  46836. this.pendingCleanup = false;
  46837. this.intentStates = Object.create(null);
  46838. this.destroyed = false;
  46839. }
  46840. PDFPageProxy.prototype = {
  46841. get pageNumber() {
  46842. return this.pageIndex + 1;
  46843. },
  46844. get rotate() {
  46845. return this.pageInfo.rotate;
  46846. },
  46847. get ref() {
  46848. return this.pageInfo.ref;
  46849. },
  46850. get userUnit() {
  46851. return this.pageInfo.userUnit;
  46852. },
  46853. get view() {
  46854. return this.pageInfo.view;
  46855. },
  46856. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46857. if (arguments.length < 2) {
  46858. rotate = this.rotate;
  46859. }
  46860. return new PageViewport(this.view, scale, rotate, 0, 0);
  46861. },
  46862. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46863. var intent = params && params.intent || null;
  46864. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46865. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46866. this.annotationsIntent = intent;
  46867. }
  46868. return this.annotationsPromise;
  46869. },
  46870. render: function PDFPageProxy_render(params) {
  46871. var stats = this.stats;
  46872. stats.time('Overall');
  46873. this.pendingCleanup = false;
  46874. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46875. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46876. if (!this.intentStates[renderingIntent]) {
  46877. this.intentStates[renderingIntent] = Object.create(null);
  46878. }
  46879. var intentState = this.intentStates[renderingIntent];
  46880. if (!intentState.displayReadyCapability) {
  46881. intentState.receivingOperatorList = true;
  46882. intentState.displayReadyCapability = createPromiseCapability();
  46883. intentState.operatorList = {
  46884. fnArray: [],
  46885. argsArray: [],
  46886. lastChunk: false
  46887. };
  46888. this.stats.time('Page Request');
  46889. this.transport.messageHandler.send('RenderPageRequest', {
  46890. pageIndex: this.pageNumber - 1,
  46891. intent: renderingIntent,
  46892. renderInteractiveForms: renderInteractiveForms
  46893. });
  46894. }
  46895. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46896. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46897. if (!intentState.renderTasks) {
  46898. intentState.renderTasks = [];
  46899. }
  46900. intentState.renderTasks.push(internalRenderTask);
  46901. var renderTask = internalRenderTask.task;
  46902. if (params.continueCallback) {
  46903. deprecated('render is used with continueCallback parameter');
  46904. renderTask.onContinue = params.continueCallback;
  46905. }
  46906. var self = this;
  46907. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46908. if (self.pendingCleanup) {
  46909. complete();
  46910. return;
  46911. }
  46912. stats.time('Rendering');
  46913. internalRenderTask.initializeGraphics(transparency);
  46914. internalRenderTask.operatorListChanged();
  46915. }, function pageDisplayReadPromiseError(reason) {
  46916. complete(reason);
  46917. });
  46918. function complete(error) {
  46919. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46920. if (i >= 0) {
  46921. intentState.renderTasks.splice(i, 1);
  46922. }
  46923. if (self.cleanupAfterRender) {
  46924. self.pendingCleanup = true;
  46925. }
  46926. self._tryCleanup();
  46927. if (error) {
  46928. internalRenderTask.capability.reject(error);
  46929. } else {
  46930. internalRenderTask.capability.resolve();
  46931. }
  46932. stats.timeEnd('Rendering');
  46933. stats.timeEnd('Overall');
  46934. }
  46935. return renderTask;
  46936. },
  46937. getOperatorList: function PDFPageProxy_getOperatorList() {
  46938. function operatorListChanged() {
  46939. if (intentState.operatorList.lastChunk) {
  46940. intentState.opListReadCapability.resolve(intentState.operatorList);
  46941. var i = intentState.renderTasks.indexOf(opListTask);
  46942. if (i >= 0) {
  46943. intentState.renderTasks.splice(i, 1);
  46944. }
  46945. }
  46946. }
  46947. var renderingIntent = 'oplist';
  46948. if (!this.intentStates[renderingIntent]) {
  46949. this.intentStates[renderingIntent] = Object.create(null);
  46950. }
  46951. var intentState = this.intentStates[renderingIntent];
  46952. var opListTask;
  46953. if (!intentState.opListReadCapability) {
  46954. opListTask = {};
  46955. opListTask.operatorListChanged = operatorListChanged;
  46956. intentState.receivingOperatorList = true;
  46957. intentState.opListReadCapability = createPromiseCapability();
  46958. intentState.renderTasks = [];
  46959. intentState.renderTasks.push(opListTask);
  46960. intentState.operatorList = {
  46961. fnArray: [],
  46962. argsArray: [],
  46963. lastChunk: false
  46964. };
  46965. this.transport.messageHandler.send('RenderPageRequest', {
  46966. pageIndex: this.pageIndex,
  46967. intent: renderingIntent
  46968. });
  46969. }
  46970. return intentState.opListReadCapability.promise;
  46971. },
  46972. getTextContent: function PDFPageProxy_getTextContent(params) {
  46973. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46974. pageIndex: this.pageNumber - 1,
  46975. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46976. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46977. });
  46978. },
  46979. _destroy: function PDFPageProxy_destroy() {
  46980. this.destroyed = true;
  46981. this.transport.pageCache[this.pageIndex] = null;
  46982. var waitOn = [];
  46983. Object.keys(this.intentStates).forEach(function (intent) {
  46984. if (intent === 'oplist') {
  46985. return;
  46986. }
  46987. var intentState = this.intentStates[intent];
  46988. intentState.renderTasks.forEach(function (renderTask) {
  46989. var renderCompleted = renderTask.capability.promise.catch(function () {
  46990. });
  46991. waitOn.push(renderCompleted);
  46992. renderTask.cancel();
  46993. });
  46994. }, this);
  46995. this.objs.clear();
  46996. this.annotationsPromise = null;
  46997. this.pendingCleanup = false;
  46998. return Promise.all(waitOn);
  46999. },
  47000. destroy: function () {
  47001. deprecated('page destroy method, use cleanup() instead');
  47002. this.cleanup();
  47003. },
  47004. cleanup: function PDFPageProxy_cleanup() {
  47005. this.pendingCleanup = true;
  47006. this._tryCleanup();
  47007. },
  47008. _tryCleanup: function PDFPageProxy_tryCleanup() {
  47009. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  47010. var intentState = this.intentStates[intent];
  47011. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  47012. }, this)) {
  47013. return;
  47014. }
  47015. Object.keys(this.intentStates).forEach(function (intent) {
  47016. delete this.intentStates[intent];
  47017. }, this);
  47018. this.objs.clear();
  47019. this.annotationsPromise = null;
  47020. this.pendingCleanup = false;
  47021. },
  47022. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  47023. var intentState = this.intentStates[intent];
  47024. if (intentState.displayReadyCapability) {
  47025. intentState.displayReadyCapability.resolve(transparency);
  47026. }
  47027. },
  47028. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  47029. var intentState = this.intentStates[intent];
  47030. var i, ii;
  47031. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  47032. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  47033. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  47034. }
  47035. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  47036. for (i = 0; i < intentState.renderTasks.length; i++) {
  47037. intentState.renderTasks[i].operatorListChanged();
  47038. }
  47039. if (operatorListChunk.lastChunk) {
  47040. intentState.receivingOperatorList = false;
  47041. this._tryCleanup();
  47042. }
  47043. }
  47044. };
  47045. return PDFPageProxy;
  47046. }();
  47047. var PDFWorker = function PDFWorkerClosure() {
  47048. var nextFakeWorkerId = 0;
  47049. function getWorkerSrc() {
  47050. if (typeof workerSrc !== 'undefined') {
  47051. return workerSrc;
  47052. }
  47053. if (getDefaultSetting('workerSrc')) {
  47054. return getDefaultSetting('workerSrc');
  47055. }
  47056. if (pdfjsFilePath) {
  47057. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  47058. }
  47059. error('No PDFJS.workerSrc specified');
  47060. }
  47061. var fakeWorkerFilesLoadedCapability;
  47062. function setupFakeWorkerGlobal() {
  47063. var WorkerMessageHandler;
  47064. if (fakeWorkerFilesLoadedCapability) {
  47065. return fakeWorkerFilesLoadedCapability.promise;
  47066. }
  47067. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  47068. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  47069. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  47070. return fakeWorkerFilesLoadedCapability.promise;
  47071. }
  47072. function FakeWorkerPort(defer) {
  47073. this._listeners = [];
  47074. this._defer = defer;
  47075. this._deferred = Promise.resolve(undefined);
  47076. }
  47077. FakeWorkerPort.prototype = {
  47078. postMessage: function (obj, transfers) {
  47079. function cloneValue(value) {
  47080. if (typeof value !== 'object' || value === null) {
  47081. return value;
  47082. }
  47083. if (cloned.has(value)) {
  47084. return cloned.get(value);
  47085. }
  47086. var result;
  47087. var buffer;
  47088. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  47089. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  47090. if (value === buffer) {
  47091. result = value;
  47092. } else if (transferable) {
  47093. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  47094. } else {
  47095. result = new value.constructor(value);
  47096. }
  47097. cloned.set(value, result);
  47098. return result;
  47099. }
  47100. result = isArray(value) ? [] : {};
  47101. cloned.set(value, result);
  47102. for (var i in value) {
  47103. var desc, p = value;
  47104. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  47105. p = Object.getPrototypeOf(p);
  47106. }
  47107. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  47108. continue;
  47109. }
  47110. result[i] = cloneValue(desc.value);
  47111. }
  47112. return result;
  47113. }
  47114. if (!this._defer) {
  47115. this._listeners.forEach(function (listener) {
  47116. listener.call(this, { data: obj });
  47117. }, this);
  47118. return;
  47119. }
  47120. var cloned = new WeakMap();
  47121. var e = { data: cloneValue(obj) };
  47122. this._deferred.then(function () {
  47123. this._listeners.forEach(function (listener) {
  47124. listener.call(this, e);
  47125. }, this);
  47126. }.bind(this));
  47127. },
  47128. addEventListener: function (name, listener) {
  47129. this._listeners.push(listener);
  47130. },
  47131. removeEventListener: function (name, listener) {
  47132. var i = this._listeners.indexOf(listener);
  47133. this._listeners.splice(i, 1);
  47134. },
  47135. terminate: function () {
  47136. this._listeners = [];
  47137. }
  47138. };
  47139. function createCDNWrapper(url) {
  47140. var wrapper = 'importScripts(\'' + url + '\');';
  47141. return URL.createObjectURL(new Blob([wrapper]));
  47142. }
  47143. function PDFWorker(name) {
  47144. this.name = name;
  47145. this.destroyed = false;
  47146. this._readyCapability = createPromiseCapability();
  47147. this._port = null;
  47148. this._webWorker = null;
  47149. this._messageHandler = null;
  47150. this._initialize();
  47151. }
  47152. PDFWorker.prototype = {
  47153. get promise() {
  47154. return this._readyCapability.promise;
  47155. },
  47156. get port() {
  47157. return this._port;
  47158. },
  47159. get messageHandler() {
  47160. return this._messageHandler;
  47161. },
  47162. _initialize: function PDFWorker_initialize() {
  47163. this._setupFakeWorker();
  47164. },
  47165. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  47166. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  47167. warn('Setting up fake worker.');
  47168. isWorkerDisabled = true;
  47169. }
  47170. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  47171. if (this.destroyed) {
  47172. this._readyCapability.reject(new Error('Worker was destroyed'));
  47173. return;
  47174. }
  47175. var isTypedArraysPresent = Uint8Array !== Float32Array;
  47176. var port = new FakeWorkerPort(isTypedArraysPresent);
  47177. this._port = port;
  47178. var id = 'fake' + nextFakeWorkerId++;
  47179. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47180. WorkerMessageHandler.setup(workerHandler, port);
  47181. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47182. this._messageHandler = messageHandler;
  47183. this._readyCapability.resolve();
  47184. }.bind(this));
  47185. },
  47186. destroy: function PDFWorker_destroy() {
  47187. this.destroyed = true;
  47188. if (this._webWorker) {
  47189. this._webWorker.terminate();
  47190. this._webWorker = null;
  47191. }
  47192. this._port = null;
  47193. if (this._messageHandler) {
  47194. this._messageHandler.destroy();
  47195. this._messageHandler = null;
  47196. }
  47197. }
  47198. };
  47199. return PDFWorker;
  47200. }();
  47201. var WorkerTransport = function WorkerTransportClosure() {
  47202. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47203. this.messageHandler = messageHandler;
  47204. this.loadingTask = loadingTask;
  47205. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47206. this.commonObjs = new PDFObjects();
  47207. this.fontLoader = new FontLoader(loadingTask.docId);
  47208. this.destroyed = false;
  47209. this.destroyCapability = null;
  47210. this._passwordCapability = null;
  47211. this.pageCache = [];
  47212. this.pagePromises = [];
  47213. this.downloadInfoCapability = createPromiseCapability();
  47214. this.setupMessageHandler();
  47215. }
  47216. WorkerTransport.prototype = {
  47217. destroy: function WorkerTransport_destroy() {
  47218. if (this.destroyCapability) {
  47219. return this.destroyCapability.promise;
  47220. }
  47221. this.destroyed = true;
  47222. this.destroyCapability = createPromiseCapability();
  47223. if (this._passwordCapability) {
  47224. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  47225. }
  47226. var waitOn = [];
  47227. this.pageCache.forEach(function (page) {
  47228. if (page) {
  47229. waitOn.push(page._destroy());
  47230. }
  47231. });
  47232. this.pageCache = [];
  47233. this.pagePromises = [];
  47234. var self = this;
  47235. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  47236. waitOn.push(terminated);
  47237. Promise.all(waitOn).then(function () {
  47238. self.fontLoader.clear();
  47239. if (self.pdfDataRangeTransport) {
  47240. self.pdfDataRangeTransport.abort();
  47241. self.pdfDataRangeTransport = null;
  47242. }
  47243. if (self.messageHandler) {
  47244. self.messageHandler.destroy();
  47245. self.messageHandler = null;
  47246. }
  47247. self.destroyCapability.resolve();
  47248. }, this.destroyCapability.reject);
  47249. return this.destroyCapability.promise;
  47250. },
  47251. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  47252. var messageHandler = this.messageHandler;
  47253. var loadingTask = this.loadingTask;
  47254. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47255. if (pdfDataRangeTransport) {
  47256. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47257. messageHandler.send('OnDataRange', {
  47258. begin: begin,
  47259. chunk: chunk
  47260. });
  47261. });
  47262. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47263. messageHandler.send('OnDataProgress', { loaded: loaded });
  47264. });
  47265. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47266. messageHandler.send('OnDataRange', { chunk: chunk });
  47267. });
  47268. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47269. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47270. }, this);
  47271. }
  47272. messageHandler.on('GetDoc', function transportDoc(data) {
  47273. var pdfInfo = data.pdfInfo;
  47274. this.numPages = data.pdfInfo.numPages;
  47275. var loadingTask = this.loadingTask;
  47276. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47277. this.pdfDocument = pdfDocument;
  47278. loadingTask._capability.resolve(pdfDocument);
  47279. }, this);
  47280. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  47281. this._passwordCapability = createPromiseCapability();
  47282. if (loadingTask.onPassword) {
  47283. var updatePassword = function (password) {
  47284. this._passwordCapability.resolve({ password: password });
  47285. }.bind(this);
  47286. loadingTask.onPassword(updatePassword, exception.code);
  47287. } else {
  47288. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  47289. }
  47290. return this._passwordCapability.promise;
  47291. }, this);
  47292. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  47293. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47294. }, this);
  47295. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47296. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47297. }, this);
  47298. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47299. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47300. }, this);
  47301. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47302. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47303. }, this);
  47304. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47305. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47306. }, this);
  47307. messageHandler.on('DataLoaded', function transportPage(data) {
  47308. this.downloadInfoCapability.resolve(data);
  47309. }, this);
  47310. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47311. if (this.pdfDataRangeTransport) {
  47312. this.pdfDataRangeTransport.transportReady();
  47313. }
  47314. }, this);
  47315. messageHandler.on('StartRenderPage', function transportRender(data) {
  47316. if (this.destroyed) {
  47317. return;
  47318. }
  47319. var page = this.pageCache[data.pageIndex];
  47320. page.stats.timeEnd('Page Request');
  47321. page._startRenderPage(data.transparency, data.intent);
  47322. }, this);
  47323. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47324. if (this.destroyed) {
  47325. return;
  47326. }
  47327. var page = this.pageCache[data.pageIndex];
  47328. page._renderPageChunk(data.operatorList, data.intent);
  47329. }, this);
  47330. messageHandler.on('commonobj', function transportObj(data) {
  47331. if (this.destroyed) {
  47332. return;
  47333. }
  47334. var id = data[0];
  47335. var type = data[1];
  47336. if (this.commonObjs.hasData(id)) {
  47337. return;
  47338. }
  47339. switch (type) {
  47340. case 'Font':
  47341. var exportedData = data[2];
  47342. if ('error' in exportedData) {
  47343. var exportedError = exportedData.error;
  47344. warn('Error during font loading: ' + exportedError);
  47345. this.commonObjs.resolve(id, exportedError);
  47346. break;
  47347. }
  47348. var fontRegistry = null;
  47349. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47350. fontRegistry = {
  47351. registerFont: function (font, url) {
  47352. globalScope['FontInspector'].fontAdded(font, url);
  47353. }
  47354. };
  47355. }
  47356. var font = new FontFaceObject(exportedData, {
  47357. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47358. disableFontFace: getDefaultSetting('disableFontFace'),
  47359. fontRegistry: fontRegistry
  47360. });
  47361. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47362. this.commonObjs.resolve(id, font);
  47363. }.bind(this));
  47364. break;
  47365. case 'FontPath':
  47366. this.commonObjs.resolve(id, data[2]);
  47367. break;
  47368. default:
  47369. error('Got unknown common object type ' + type);
  47370. }
  47371. }, this);
  47372. messageHandler.on('obj', function transportObj(data) {
  47373. if (this.destroyed) {
  47374. return;
  47375. }
  47376. var id = data[0];
  47377. var pageIndex = data[1];
  47378. var type = data[2];
  47379. var pageProxy = this.pageCache[pageIndex];
  47380. var imageData;
  47381. if (pageProxy.objs.hasData(id)) {
  47382. return;
  47383. }
  47384. switch (type) {
  47385. case 'JpegStream':
  47386. imageData = data[3];
  47387. loadJpegStream(id, imageData, pageProxy.objs);
  47388. break;
  47389. case 'Image':
  47390. imageData = data[3];
  47391. pageProxy.objs.resolve(id, imageData);
  47392. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47393. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47394. pageProxy.cleanupAfterRender = true;
  47395. }
  47396. break;
  47397. default:
  47398. error('Got unknown object type ' + type);
  47399. }
  47400. }, this);
  47401. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47402. if (this.destroyed) {
  47403. return;
  47404. }
  47405. var loadingTask = this.loadingTask;
  47406. if (loadingTask.onProgress) {
  47407. loadingTask.onProgress({
  47408. loaded: data.loaded,
  47409. total: data.total
  47410. });
  47411. }
  47412. }, this);
  47413. messageHandler.on('PageError', function transportError(data) {
  47414. if (this.destroyed) {
  47415. return;
  47416. }
  47417. var page = this.pageCache[data.pageNum - 1];
  47418. var intentState = page.intentStates[data.intent];
  47419. if (intentState.displayReadyCapability) {
  47420. intentState.displayReadyCapability.reject(data.error);
  47421. } else {
  47422. error(data.error);
  47423. }
  47424. if (intentState.operatorList) {
  47425. intentState.operatorList.lastChunk = true;
  47426. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47427. intentState.renderTasks[i].operatorListChanged();
  47428. }
  47429. }
  47430. }, this);
  47431. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47432. if (this.destroyed) {
  47433. return;
  47434. }
  47435. var featureId = data.featureId;
  47436. var loadingTask = this.loadingTask;
  47437. if (loadingTask.onUnsupportedFeature) {
  47438. loadingTask.onUnsupportedFeature(featureId);
  47439. }
  47440. _UnsupportedManager.notify(featureId);
  47441. }, this);
  47442. messageHandler.on('JpegDecode', function (data) {
  47443. if (this.destroyed) {
  47444. return Promise.reject(new Error('Worker was destroyed'));
  47445. }
  47446. var imageUrl = data[0];
  47447. var components = data[1];
  47448. if (components !== 3 && components !== 1) {
  47449. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47450. }
  47451. return new Promise(function (resolve, reject) {
  47452. var img = new Image();
  47453. img.onload = function () {
  47454. var width = img.width;
  47455. var height = img.height;
  47456. var size = width * height;
  47457. var rgbaLength = size * 4;
  47458. var buf = new Uint8Array(size * components);
  47459. var tmpCanvas = createScratchCanvas(width, height);
  47460. var tmpCtx = tmpCanvas.getContext('2d');
  47461. tmpCtx.drawImage(img, 0, 0);
  47462. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47463. var i, j;
  47464. if (components === 3) {
  47465. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47466. buf[j] = data[i];
  47467. buf[j + 1] = data[i + 1];
  47468. buf[j + 2] = data[i + 2];
  47469. }
  47470. } else if (components === 1) {
  47471. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47472. buf[j] = data[i];
  47473. }
  47474. }
  47475. resolve({
  47476. data: buf,
  47477. width: width,
  47478. height: height
  47479. });
  47480. };
  47481. img.onerror = function () {
  47482. reject(new Error('JpegDecode failed to load image'));
  47483. };
  47484. img.src = imageUrl;
  47485. });
  47486. }, this);
  47487. },
  47488. getData: function WorkerTransport_getData() {
  47489. return this.messageHandler.sendWithPromise('GetData', null);
  47490. },
  47491. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47492. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47493. return Promise.reject(new Error('Invalid page request'));
  47494. }
  47495. var pageIndex = pageNumber - 1;
  47496. if (pageIndex in this.pagePromises) {
  47497. return this.pagePromises[pageIndex];
  47498. }
  47499. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47500. if (this.destroyed) {
  47501. throw new Error('Transport destroyed');
  47502. }
  47503. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47504. this.pageCache[pageIndex] = page;
  47505. return page;
  47506. }.bind(this));
  47507. this.pagePromises[pageIndex] = promise;
  47508. return promise;
  47509. },
  47510. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47511. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47512. return Promise.reject(new Error(reason));
  47513. });
  47514. },
  47515. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47516. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47517. pageIndex: pageIndex,
  47518. intent: intent
  47519. });
  47520. },
  47521. getDestinations: function WorkerTransport_getDestinations() {
  47522. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47523. },
  47524. getDestination: function WorkerTransport_getDestination(id) {
  47525. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47526. },
  47527. getPageLabels: function WorkerTransport_getPageLabels() {
  47528. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47529. },
  47530. getAttachments: function WorkerTransport_getAttachments() {
  47531. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47532. },
  47533. getJavaScript: function WorkerTransport_getJavaScript() {
  47534. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47535. },
  47536. getOutline: function WorkerTransport_getOutline() {
  47537. return this.messageHandler.sendWithPromise('GetOutline', null);
  47538. },
  47539. getMetadata: function WorkerTransport_getMetadata() {
  47540. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47541. return {
  47542. info: results[0],
  47543. metadata: results[1] ? new Metadata(results[1]) : null
  47544. };
  47545. });
  47546. },
  47547. getStats: function WorkerTransport_getStats() {
  47548. return this.messageHandler.sendWithPromise('GetStats', null);
  47549. },
  47550. startCleanup: function WorkerTransport_startCleanup() {
  47551. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47552. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47553. var page = this.pageCache[i];
  47554. if (page) {
  47555. page.cleanup();
  47556. }
  47557. }
  47558. this.commonObjs.clear();
  47559. this.fontLoader.clear();
  47560. }.bind(this));
  47561. }
  47562. };
  47563. return WorkerTransport;
  47564. }();
  47565. var PDFObjects = function PDFObjectsClosure() {
  47566. function PDFObjects() {
  47567. this.objs = Object.create(null);
  47568. }
  47569. PDFObjects.prototype = {
  47570. ensureObj: function PDFObjects_ensureObj(objId) {
  47571. if (this.objs[objId]) {
  47572. return this.objs[objId];
  47573. }
  47574. var obj = {
  47575. capability: createPromiseCapability(),
  47576. data: null,
  47577. resolved: false
  47578. };
  47579. this.objs[objId] = obj;
  47580. return obj;
  47581. },
  47582. get: function PDFObjects_get(objId, callback) {
  47583. if (callback) {
  47584. this.ensureObj(objId).capability.promise.then(callback);
  47585. return null;
  47586. }
  47587. var obj = this.objs[objId];
  47588. if (!obj || !obj.resolved) {
  47589. error('Requesting object that isn\'t resolved yet ' + objId);
  47590. }
  47591. return obj.data;
  47592. },
  47593. resolve: function PDFObjects_resolve(objId, data) {
  47594. var obj = this.ensureObj(objId);
  47595. obj.resolved = true;
  47596. obj.data = data;
  47597. obj.capability.resolve(data);
  47598. },
  47599. isResolved: function PDFObjects_isResolved(objId) {
  47600. var objs = this.objs;
  47601. if (!objs[objId]) {
  47602. return false;
  47603. }
  47604. return objs[objId].resolved;
  47605. },
  47606. hasData: function PDFObjects_hasData(objId) {
  47607. return this.isResolved(objId);
  47608. },
  47609. getData: function PDFObjects_getData(objId) {
  47610. var objs = this.objs;
  47611. if (!objs[objId] || !objs[objId].resolved) {
  47612. return null;
  47613. }
  47614. return objs[objId].data;
  47615. },
  47616. clear: function PDFObjects_clear() {
  47617. this.objs = Object.create(null);
  47618. }
  47619. };
  47620. return PDFObjects;
  47621. }();
  47622. var RenderTask = function RenderTaskClosure() {
  47623. function RenderTask(internalRenderTask) {
  47624. this._internalRenderTask = internalRenderTask;
  47625. this.onContinue = null;
  47626. }
  47627. RenderTask.prototype = {
  47628. get promise() {
  47629. return this._internalRenderTask.capability.promise;
  47630. },
  47631. cancel: function RenderTask_cancel() {
  47632. this._internalRenderTask.cancel();
  47633. },
  47634. then: function RenderTask_then(onFulfilled, onRejected) {
  47635. return this.promise.then.apply(this.promise, arguments);
  47636. }
  47637. };
  47638. return RenderTask;
  47639. }();
  47640. var InternalRenderTask = function InternalRenderTaskClosure() {
  47641. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47642. this.callback = callback;
  47643. this.params = params;
  47644. this.objs = objs;
  47645. this.commonObjs = commonObjs;
  47646. this.operatorListIdx = null;
  47647. this.operatorList = operatorList;
  47648. this.pageNumber = pageNumber;
  47649. this.running = false;
  47650. this.graphicsReadyCallback = null;
  47651. this.graphicsReady = false;
  47652. this.useRequestAnimationFrame = false;
  47653. this.cancelled = false;
  47654. this.capability = createPromiseCapability();
  47655. this.task = new RenderTask(this);
  47656. this._continueBound = this._continue.bind(this);
  47657. this._scheduleNextBound = this._scheduleNext.bind(this);
  47658. this._nextBound = this._next.bind(this);
  47659. }
  47660. InternalRenderTask.prototype = {
  47661. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47662. if (this.cancelled) {
  47663. return;
  47664. }
  47665. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47666. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47667. this.stepper.init(this.operatorList);
  47668. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47669. }
  47670. var params = this.params;
  47671. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47672. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47673. this.operatorListIdx = 0;
  47674. this.graphicsReady = true;
  47675. if (this.graphicsReadyCallback) {
  47676. this.graphicsReadyCallback();
  47677. }
  47678. },
  47679. cancel: function InternalRenderTask_cancel() {
  47680. this.running = false;
  47681. this.cancelled = true;
  47682. this.callback('cancelled');
  47683. },
  47684. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47685. if (!this.graphicsReady) {
  47686. if (!this.graphicsReadyCallback) {
  47687. this.graphicsReadyCallback = this._continueBound;
  47688. }
  47689. return;
  47690. }
  47691. if (this.stepper) {
  47692. this.stepper.updateOperatorList(this.operatorList);
  47693. }
  47694. if (this.running) {
  47695. return;
  47696. }
  47697. this._continue();
  47698. },
  47699. _continue: function InternalRenderTask__continue() {
  47700. this.running = true;
  47701. if (this.cancelled) {
  47702. return;
  47703. }
  47704. if (this.task.onContinue) {
  47705. this.task.onContinue(this._scheduleNextBound);
  47706. } else {
  47707. this._scheduleNext();
  47708. }
  47709. },
  47710. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47711. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47712. window.requestAnimationFrame(this._nextBound);
  47713. } else {
  47714. Promise.resolve(undefined).then(this._nextBound);
  47715. }
  47716. },
  47717. _next: function InternalRenderTask__next() {
  47718. if (this.cancelled) {
  47719. return;
  47720. }
  47721. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47722. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47723. this.running = false;
  47724. if (this.operatorList.lastChunk) {
  47725. this.gfx.endDrawing();
  47726. this.callback();
  47727. }
  47728. }
  47729. }
  47730. };
  47731. return InternalRenderTask;
  47732. }();
  47733. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47734. var listeners = [];
  47735. return {
  47736. listen: function (cb) {
  47737. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47738. listeners.push(cb);
  47739. },
  47740. notify: function (featureId) {
  47741. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47742. listeners[i](featureId);
  47743. }
  47744. }
  47745. };
  47746. }();
  47747. if (typeof pdfjsVersion !== 'undefined') {
  47748. exports.version = pdfjsVersion;
  47749. }
  47750. if (typeof pdfjsBuild !== 'undefined') {
  47751. exports.build = pdfjsBuild;
  47752. }
  47753. exports.getDocument = getDocument;
  47754. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47755. exports.PDFWorker = PDFWorker;
  47756. exports.PDFDocumentProxy = PDFDocumentProxy;
  47757. exports.PDFPageProxy = PDFPageProxy;
  47758. exports._UnsupportedManager = _UnsupportedManager;
  47759. }));
  47760. (function (root, factory) {
  47761. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47762. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47763. var error = sharedUtil.error;
  47764. var info = sharedUtil.info;
  47765. var isArray = sharedUtil.isArray;
  47766. var isString = sharedUtil.isString;
  47767. var shadow = sharedUtil.shadow;
  47768. var warn = sharedUtil.warn;
  47769. var isDict = corePrimitives.isDict;
  47770. var isName = corePrimitives.isName;
  47771. var isStream = corePrimitives.isStream;
  47772. var PDFFunction = coreFunction.PDFFunction;
  47773. var ColorSpace = function ColorSpaceClosure() {
  47774. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47775. var COMPONENTS = 3;
  47776. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47777. var xRatio = w1 / w2;
  47778. var yRatio = h1 / h2;
  47779. var i, j, py, newIndex = 0, oldIndex;
  47780. var xScaled = new Uint16Array(w2);
  47781. var w1Scanline = w1 * COMPONENTS;
  47782. for (i = 0; i < w2; i++) {
  47783. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47784. }
  47785. for (i = 0; i < h2; i++) {
  47786. py = Math.floor(i * yRatio) * w1Scanline;
  47787. for (j = 0; j < w2; j++) {
  47788. oldIndex = py + xScaled[j];
  47789. dest[newIndex++] = src[oldIndex++];
  47790. dest[newIndex++] = src[oldIndex++];
  47791. dest[newIndex++] = src[oldIndex++];
  47792. newIndex += alpha01;
  47793. }
  47794. }
  47795. }
  47796. function ColorSpace() {
  47797. error('should not call ColorSpace constructor');
  47798. }
  47799. ColorSpace.prototype = {
  47800. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47801. var rgb = new Uint8Array(3);
  47802. this.getRgbItem(src, srcOffset, rgb, 0);
  47803. return rgb;
  47804. },
  47805. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47806. error('Should not call ColorSpace.getRgbItem');
  47807. },
  47808. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47809. error('Should not call ColorSpace.getRgbBuffer');
  47810. },
  47811. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47812. error('Should not call ColorSpace.getOutputLength');
  47813. },
  47814. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47815. return false;
  47816. },
  47817. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47818. var count = originalWidth * originalHeight;
  47819. var rgbBuf = null;
  47820. var numComponentColors = 1 << bpc;
  47821. var needsResizing = originalHeight !== height || originalWidth !== width;
  47822. var i, ii;
  47823. if (this.isPassthrough(bpc)) {
  47824. rgbBuf = comps;
  47825. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47826. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47827. var key;
  47828. for (i = 0; i < numComponentColors; i++) {
  47829. allColors[i] = i;
  47830. }
  47831. var colorMap = new Uint8Array(numComponentColors * 3);
  47832. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47833. var destPos, rgbPos;
  47834. if (!needsResizing) {
  47835. destPos = 0;
  47836. for (i = 0; i < count; ++i) {
  47837. key = comps[i] * 3;
  47838. dest[destPos++] = colorMap[key];
  47839. dest[destPos++] = colorMap[key + 1];
  47840. dest[destPos++] = colorMap[key + 2];
  47841. destPos += alpha01;
  47842. }
  47843. } else {
  47844. rgbBuf = new Uint8Array(count * 3);
  47845. rgbPos = 0;
  47846. for (i = 0; i < count; ++i) {
  47847. key = comps[i] * 3;
  47848. rgbBuf[rgbPos++] = colorMap[key];
  47849. rgbBuf[rgbPos++] = colorMap[key + 1];
  47850. rgbBuf[rgbPos++] = colorMap[key + 2];
  47851. }
  47852. }
  47853. } else {
  47854. if (!needsResizing) {
  47855. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47856. } else {
  47857. rgbBuf = new Uint8Array(count * 3);
  47858. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47859. }
  47860. }
  47861. if (rgbBuf) {
  47862. if (needsResizing) {
  47863. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47864. } else {
  47865. rgbPos = 0;
  47866. destPos = 0;
  47867. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47868. dest[destPos++] = rgbBuf[rgbPos++];
  47869. dest[destPos++] = rgbBuf[rgbPos++];
  47870. dest[destPos++] = rgbBuf[rgbPos++];
  47871. destPos += alpha01;
  47872. }
  47873. }
  47874. }
  47875. },
  47876. usesZeroToOneRange: true
  47877. };
  47878. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47879. var IR = ColorSpace.parseToIR(cs, xref, res);
  47880. if (IR instanceof AlternateCS) {
  47881. return IR;
  47882. }
  47883. return ColorSpace.fromIR(IR);
  47884. };
  47885. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47886. var name = isArray(IR) ? IR[0] : IR;
  47887. var whitePoint, blackPoint, gamma;
  47888. switch (name) {
  47889. case 'DeviceGrayCS':
  47890. return this.singletons.gray;
  47891. case 'DeviceRgbCS':
  47892. return this.singletons.rgb;
  47893. case 'DeviceCmykCS':
  47894. return this.singletons.cmyk;
  47895. case 'CalGrayCS':
  47896. whitePoint = IR[1];
  47897. blackPoint = IR[2];
  47898. gamma = IR[3];
  47899. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47900. case 'CalRGBCS':
  47901. whitePoint = IR[1];
  47902. blackPoint = IR[2];
  47903. gamma = IR[3];
  47904. var matrix = IR[4];
  47905. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47906. case 'PatternCS':
  47907. var basePatternCS = IR[1];
  47908. if (basePatternCS) {
  47909. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47910. }
  47911. return new PatternCS(basePatternCS);
  47912. case 'IndexedCS':
  47913. var baseIndexedCS = IR[1];
  47914. var hiVal = IR[2];
  47915. var lookup = IR[3];
  47916. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47917. case 'AlternateCS':
  47918. var numComps = IR[1];
  47919. var alt = IR[2];
  47920. var tintFnIR = IR[3];
  47921. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47922. case 'LabCS':
  47923. whitePoint = IR[1];
  47924. blackPoint = IR[2];
  47925. var range = IR[3];
  47926. return new LabCS(whitePoint, blackPoint, range);
  47927. default:
  47928. error('Unknown name ' + name);
  47929. }
  47930. return null;
  47931. };
  47932. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47933. if (isName(cs)) {
  47934. var colorSpaces = res.get('ColorSpace');
  47935. if (isDict(colorSpaces)) {
  47936. var refcs = colorSpaces.get(cs.name);
  47937. if (refcs) {
  47938. cs = refcs;
  47939. }
  47940. }
  47941. }
  47942. cs = xref.fetchIfRef(cs);
  47943. if (isName(cs)) {
  47944. switch (cs.name) {
  47945. case 'DeviceGray':
  47946. case 'G':
  47947. return 'DeviceGrayCS';
  47948. case 'DeviceRGB':
  47949. case 'RGB':
  47950. return 'DeviceRgbCS';
  47951. case 'DeviceCMYK':
  47952. case 'CMYK':
  47953. return 'DeviceCmykCS';
  47954. case 'Pattern':
  47955. return [
  47956. 'PatternCS',
  47957. null
  47958. ];
  47959. default:
  47960. error('unrecognized colorspace ' + cs.name);
  47961. }
  47962. } else if (isArray(cs)) {
  47963. var mode = xref.fetchIfRef(cs[0]).name;
  47964. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47965. switch (mode) {
  47966. case 'DeviceGray':
  47967. case 'G':
  47968. return 'DeviceGrayCS';
  47969. case 'DeviceRGB':
  47970. case 'RGB':
  47971. return 'DeviceRgbCS';
  47972. case 'DeviceCMYK':
  47973. case 'CMYK':
  47974. return 'DeviceCmykCS';
  47975. case 'CalGray':
  47976. params = xref.fetchIfRef(cs[1]);
  47977. whitePoint = params.getArray('WhitePoint');
  47978. blackPoint = params.getArray('BlackPoint');
  47979. gamma = params.get('Gamma');
  47980. return [
  47981. 'CalGrayCS',
  47982. whitePoint,
  47983. blackPoint,
  47984. gamma
  47985. ];
  47986. case 'CalRGB':
  47987. params = xref.fetchIfRef(cs[1]);
  47988. whitePoint = params.getArray('WhitePoint');
  47989. blackPoint = params.getArray('BlackPoint');
  47990. gamma = params.getArray('Gamma');
  47991. var matrix = params.getArray('Matrix');
  47992. return [
  47993. 'CalRGBCS',
  47994. whitePoint,
  47995. blackPoint,
  47996. gamma,
  47997. matrix
  47998. ];
  47999. case 'ICCBased':
  48000. var stream = xref.fetchIfRef(cs[1]);
  48001. var dict = stream.dict;
  48002. numComps = dict.get('N');
  48003. alt = dict.get('Alternate');
  48004. if (alt) {
  48005. var altIR = ColorSpace.parseToIR(alt, xref, res);
  48006. var altCS = ColorSpace.fromIR(altIR);
  48007. if (altCS.numComps === numComps) {
  48008. return altIR;
  48009. }
  48010. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  48011. }
  48012. if (numComps === 1) {
  48013. return 'DeviceGrayCS';
  48014. } else if (numComps === 3) {
  48015. return 'DeviceRgbCS';
  48016. } else if (numComps === 4) {
  48017. return 'DeviceCmykCS';
  48018. }
  48019. break;
  48020. case 'Pattern':
  48021. var basePatternCS = cs[1] || null;
  48022. if (basePatternCS) {
  48023. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  48024. }
  48025. return [
  48026. 'PatternCS',
  48027. basePatternCS
  48028. ];
  48029. case 'Indexed':
  48030. case 'I':
  48031. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  48032. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  48033. var lookup = xref.fetchIfRef(cs[3]);
  48034. if (isStream(lookup)) {
  48035. lookup = lookup.getBytes();
  48036. }
  48037. return [
  48038. 'IndexedCS',
  48039. baseIndexedCS,
  48040. hiVal,
  48041. lookup
  48042. ];
  48043. case 'Separation':
  48044. case 'DeviceN':
  48045. var name = xref.fetchIfRef(cs[1]);
  48046. numComps = isArray(name) ? name.length : 1;
  48047. alt = ColorSpace.parseToIR(cs[2], xref, res);
  48048. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  48049. return [
  48050. 'AlternateCS',
  48051. numComps,
  48052. alt,
  48053. tintFnIR
  48054. ];
  48055. case 'Lab':
  48056. params = xref.fetchIfRef(cs[1]);
  48057. whitePoint = params.getArray('WhitePoint');
  48058. blackPoint = params.getArray('BlackPoint');
  48059. var range = params.getArray('Range');
  48060. return [
  48061. 'LabCS',
  48062. whitePoint,
  48063. blackPoint,
  48064. range
  48065. ];
  48066. default:
  48067. error('unimplemented color space object "' + mode + '"');
  48068. }
  48069. } else {
  48070. error('unrecognized color space object: "' + cs + '"');
  48071. }
  48072. return null;
  48073. };
  48074. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  48075. if (!isArray(decode)) {
  48076. return true;
  48077. }
  48078. if (n * 2 !== decode.length) {
  48079. warn('The decode map is not the correct length');
  48080. return true;
  48081. }
  48082. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  48083. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  48084. return false;
  48085. }
  48086. }
  48087. return true;
  48088. };
  48089. ColorSpace.singletons = {
  48090. get gray() {
  48091. return shadow(this, 'gray', new DeviceGrayCS());
  48092. },
  48093. get rgb() {
  48094. return shadow(this, 'rgb', new DeviceRgbCS());
  48095. },
  48096. get cmyk() {
  48097. return shadow(this, 'cmyk', new DeviceCmykCS());
  48098. }
  48099. };
  48100. return ColorSpace;
  48101. }();
  48102. var AlternateCS = function AlternateCSClosure() {
  48103. function AlternateCS(numComps, base, tintFn) {
  48104. this.name = 'Alternate';
  48105. this.numComps = numComps;
  48106. this.defaultColor = new Float32Array(numComps);
  48107. for (var i = 0; i < numComps; ++i) {
  48108. this.defaultColor[i] = 1;
  48109. }
  48110. this.base = base;
  48111. this.tintFn = tintFn;
  48112. this.tmpBuf = new Float32Array(base.numComps);
  48113. }
  48114. AlternateCS.prototype = {
  48115. getRgb: ColorSpace.prototype.getRgb,
  48116. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48117. var tmpBuf = this.tmpBuf;
  48118. this.tintFn(src, srcOffset, tmpBuf, 0);
  48119. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  48120. },
  48121. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48122. var tintFn = this.tintFn;
  48123. var base = this.base;
  48124. var scale = 1 / ((1 << bits) - 1);
  48125. var baseNumComps = base.numComps;
  48126. var usesZeroToOneRange = base.usesZeroToOneRange;
  48127. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  48128. var pos = isPassthrough ? destOffset : 0;
  48129. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  48130. var numComps = this.numComps;
  48131. var scaled = new Float32Array(numComps);
  48132. var tinted = new Float32Array(baseNumComps);
  48133. var i, j;
  48134. for (i = 0; i < count; i++) {
  48135. for (j = 0; j < numComps; j++) {
  48136. scaled[j] = src[srcOffset++] * scale;
  48137. }
  48138. tintFn(scaled, 0, tinted, 0);
  48139. if (usesZeroToOneRange) {
  48140. for (j = 0; j < baseNumComps; j++) {
  48141. baseBuf[pos++] = tinted[j] * 255;
  48142. }
  48143. } else {
  48144. base.getRgbItem(tinted, 0, baseBuf, pos);
  48145. pos += baseNumComps;
  48146. }
  48147. }
  48148. if (!isPassthrough) {
  48149. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  48150. }
  48151. },
  48152. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  48153. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  48154. },
  48155. isPassthrough: ColorSpace.prototype.isPassthrough,
  48156. fillRgb: ColorSpace.prototype.fillRgb,
  48157. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  48158. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48159. },
  48160. usesZeroToOneRange: true
  48161. };
  48162. return AlternateCS;
  48163. }();
  48164. var PatternCS = function PatternCSClosure() {
  48165. function PatternCS(baseCS) {
  48166. this.name = 'Pattern';
  48167. this.base = baseCS;
  48168. }
  48169. PatternCS.prototype = {};
  48170. return PatternCS;
  48171. }();
  48172. var IndexedCS = function IndexedCSClosure() {
  48173. function IndexedCS(base, highVal, lookup) {
  48174. this.name = 'Indexed';
  48175. this.numComps = 1;
  48176. this.defaultColor = new Uint8Array(this.numComps);
  48177. this.base = base;
  48178. this.highVal = highVal;
  48179. var baseNumComps = base.numComps;
  48180. var length = baseNumComps * highVal;
  48181. if (isStream(lookup)) {
  48182. this.lookup = new Uint8Array(length);
  48183. var bytes = lookup.getBytes(length);
  48184. this.lookup.set(bytes);
  48185. } else if (isString(lookup)) {
  48186. this.lookup = new Uint8Array(length);
  48187. for (var i = 0; i < length; ++i) {
  48188. this.lookup[i] = lookup.charCodeAt(i);
  48189. }
  48190. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48191. this.lookup = lookup;
  48192. } else {
  48193. error('Unrecognized lookup table: ' + lookup);
  48194. }
  48195. }
  48196. IndexedCS.prototype = {
  48197. getRgb: ColorSpace.prototype.getRgb,
  48198. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48199. var numComps = this.base.numComps;
  48200. var start = src[srcOffset] * numComps;
  48201. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48202. },
  48203. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48204. var base = this.base;
  48205. var numComps = base.numComps;
  48206. var outputDelta = base.getOutputLength(numComps, alpha01);
  48207. var lookup = this.lookup;
  48208. for (var i = 0; i < count; ++i) {
  48209. var lookupPos = src[srcOffset++] * numComps;
  48210. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48211. destOffset += outputDelta;
  48212. }
  48213. },
  48214. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48215. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48216. },
  48217. isPassthrough: ColorSpace.prototype.isPassthrough,
  48218. fillRgb: ColorSpace.prototype.fillRgb,
  48219. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48220. return true;
  48221. },
  48222. usesZeroToOneRange: true
  48223. };
  48224. return IndexedCS;
  48225. }();
  48226. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48227. function DeviceGrayCS() {
  48228. this.name = 'DeviceGray';
  48229. this.numComps = 1;
  48230. this.defaultColor = new Float32Array(this.numComps);
  48231. }
  48232. DeviceGrayCS.prototype = {
  48233. getRgb: ColorSpace.prototype.getRgb,
  48234. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48235. var c = src[srcOffset] * 255 | 0;
  48236. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48237. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48238. },
  48239. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48240. var scale = 255 / ((1 << bits) - 1);
  48241. var j = srcOffset, q = destOffset;
  48242. for (var i = 0; i < count; ++i) {
  48243. var c = scale * src[j++] | 0;
  48244. dest[q++] = c;
  48245. dest[q++] = c;
  48246. dest[q++] = c;
  48247. q += alpha01;
  48248. }
  48249. },
  48250. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48251. return inputLength * (3 + alpha01);
  48252. },
  48253. isPassthrough: ColorSpace.prototype.isPassthrough,
  48254. fillRgb: ColorSpace.prototype.fillRgb,
  48255. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48256. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48257. },
  48258. usesZeroToOneRange: true
  48259. };
  48260. return DeviceGrayCS;
  48261. }();
  48262. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48263. function DeviceRgbCS() {
  48264. this.name = 'DeviceRGB';
  48265. this.numComps = 3;
  48266. this.defaultColor = new Float32Array(this.numComps);
  48267. }
  48268. DeviceRgbCS.prototype = {
  48269. getRgb: ColorSpace.prototype.getRgb,
  48270. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48271. var r = src[srcOffset] * 255 | 0;
  48272. var g = src[srcOffset + 1] * 255 | 0;
  48273. var b = src[srcOffset + 2] * 255 | 0;
  48274. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48275. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48276. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48277. },
  48278. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48279. if (bits === 8 && alpha01 === 0) {
  48280. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48281. return;
  48282. }
  48283. var scale = 255 / ((1 << bits) - 1);
  48284. var j = srcOffset, q = destOffset;
  48285. for (var i = 0; i < count; ++i) {
  48286. dest[q++] = scale * src[j++] | 0;
  48287. dest[q++] = scale * src[j++] | 0;
  48288. dest[q++] = scale * src[j++] | 0;
  48289. q += alpha01;
  48290. }
  48291. },
  48292. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48293. return inputLength * (3 + alpha01) / 3 | 0;
  48294. },
  48295. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48296. return bits === 8;
  48297. },
  48298. fillRgb: ColorSpace.prototype.fillRgb,
  48299. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48300. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48301. },
  48302. usesZeroToOneRange: true
  48303. };
  48304. return DeviceRgbCS;
  48305. }();
  48306. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48307. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48308. var c = src[srcOffset + 0] * srcScale;
  48309. var m = src[srcOffset + 1] * srcScale;
  48310. var y = src[srcOffset + 2] * srcScale;
  48311. var k = src[srcOffset + 3] * srcScale;
  48312. 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;
  48313. 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;
  48314. 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;
  48315. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48316. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48317. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48318. }
  48319. function DeviceCmykCS() {
  48320. this.name = 'DeviceCMYK';
  48321. this.numComps = 4;
  48322. this.defaultColor = new Float32Array(this.numComps);
  48323. this.defaultColor[3] = 1;
  48324. }
  48325. DeviceCmykCS.prototype = {
  48326. getRgb: ColorSpace.prototype.getRgb,
  48327. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48328. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48329. },
  48330. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48331. var scale = 1 / ((1 << bits) - 1);
  48332. for (var i = 0; i < count; i++) {
  48333. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48334. srcOffset += 4;
  48335. destOffset += 3 + alpha01;
  48336. }
  48337. },
  48338. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48339. return inputLength / 4 * (3 + alpha01) | 0;
  48340. },
  48341. isPassthrough: ColorSpace.prototype.isPassthrough,
  48342. fillRgb: ColorSpace.prototype.fillRgb,
  48343. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48344. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48345. },
  48346. usesZeroToOneRange: true
  48347. };
  48348. return DeviceCmykCS;
  48349. }();
  48350. var CalGrayCS = function CalGrayCSClosure() {
  48351. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48352. this.name = 'CalGray';
  48353. this.numComps = 1;
  48354. this.defaultColor = new Float32Array(this.numComps);
  48355. if (!whitePoint) {
  48356. error('WhitePoint missing - required for color space CalGray');
  48357. }
  48358. blackPoint = blackPoint || [
  48359. 0,
  48360. 0,
  48361. 0
  48362. ];
  48363. gamma = gamma || 1;
  48364. this.XW = whitePoint[0];
  48365. this.YW = whitePoint[1];
  48366. this.ZW = whitePoint[2];
  48367. this.XB = blackPoint[0];
  48368. this.YB = blackPoint[1];
  48369. this.ZB = blackPoint[2];
  48370. this.G = gamma;
  48371. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48372. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48373. }
  48374. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48375. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48376. this.XB = this.YB = this.ZB = 0;
  48377. }
  48378. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48379. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48380. }
  48381. if (this.G < 1) {
  48382. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48383. this.G = 1;
  48384. }
  48385. }
  48386. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48387. var A = src[srcOffset] * scale;
  48388. var AG = Math.pow(A, cs.G);
  48389. var L = cs.YW * AG;
  48390. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48391. dest[destOffset] = val;
  48392. dest[destOffset + 1] = val;
  48393. dest[destOffset + 2] = val;
  48394. }
  48395. CalGrayCS.prototype = {
  48396. getRgb: ColorSpace.prototype.getRgb,
  48397. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48398. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48399. },
  48400. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48401. var scale = 1 / ((1 << bits) - 1);
  48402. for (var i = 0; i < count; ++i) {
  48403. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48404. srcOffset += 1;
  48405. destOffset += 3 + alpha01;
  48406. }
  48407. },
  48408. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48409. return inputLength * (3 + alpha01);
  48410. },
  48411. isPassthrough: ColorSpace.prototype.isPassthrough,
  48412. fillRgb: ColorSpace.prototype.fillRgb,
  48413. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48414. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48415. },
  48416. usesZeroToOneRange: true
  48417. };
  48418. return CalGrayCS;
  48419. }();
  48420. var CalRGBCS = function CalRGBCSClosure() {
  48421. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48422. 0.8951,
  48423. 0.2664,
  48424. -0.1614,
  48425. -0.7502,
  48426. 1.7135,
  48427. 0.0367,
  48428. 0.0389,
  48429. -0.0685,
  48430. 1.0296
  48431. ]);
  48432. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48433. 0.9869929,
  48434. -0.1470543,
  48435. 0.1599627,
  48436. 0.4323053,
  48437. 0.5183603,
  48438. 0.0492912,
  48439. -0.0085287,
  48440. 0.0400428,
  48441. 0.9684867
  48442. ]);
  48443. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48444. 3.2404542,
  48445. -1.5371385,
  48446. -0.4985314,
  48447. -0.9692660,
  48448. 1.8760108,
  48449. 0.0415560,
  48450. 0.0556434,
  48451. -0.2040259,
  48452. 1.0572252
  48453. ]);
  48454. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48455. 1,
  48456. 1,
  48457. 1
  48458. ]);
  48459. var tempNormalizeMatrix = new Float32Array(3);
  48460. var tempConvertMatrix1 = new Float32Array(3);
  48461. var tempConvertMatrix2 = new Float32Array(3);
  48462. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48463. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48464. this.name = 'CalRGB';
  48465. this.numComps = 3;
  48466. this.defaultColor = new Float32Array(this.numComps);
  48467. if (!whitePoint) {
  48468. error('WhitePoint missing - required for color space CalRGB');
  48469. }
  48470. blackPoint = blackPoint || new Float32Array(3);
  48471. gamma = gamma || new Float32Array([
  48472. 1,
  48473. 1,
  48474. 1
  48475. ]);
  48476. matrix = matrix || new Float32Array([
  48477. 1,
  48478. 0,
  48479. 0,
  48480. 0,
  48481. 1,
  48482. 0,
  48483. 0,
  48484. 0,
  48485. 1
  48486. ]);
  48487. var XW = whitePoint[0];
  48488. var YW = whitePoint[1];
  48489. var ZW = whitePoint[2];
  48490. this.whitePoint = whitePoint;
  48491. var XB = blackPoint[0];
  48492. var YB = blackPoint[1];
  48493. var ZB = blackPoint[2];
  48494. this.blackPoint = blackPoint;
  48495. this.GR = gamma[0];
  48496. this.GG = gamma[1];
  48497. this.GB = gamma[2];
  48498. this.MXA = matrix[0];
  48499. this.MYA = matrix[1];
  48500. this.MZA = matrix[2];
  48501. this.MXB = matrix[3];
  48502. this.MYB = matrix[4];
  48503. this.MZB = matrix[5];
  48504. this.MXC = matrix[6];
  48505. this.MYC = matrix[7];
  48506. this.MZC = matrix[8];
  48507. if (XW < 0 || ZW < 0 || YW !== 1) {
  48508. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48509. }
  48510. if (XB < 0 || YB < 0 || ZB < 0) {
  48511. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48512. this.blackPoint = new Float32Array(3);
  48513. }
  48514. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48515. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48516. this.GR = this.GG = this.GB = 1;
  48517. }
  48518. 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) {
  48519. 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');
  48520. this.MXA = this.MYB = this.MZC = 1;
  48521. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48522. }
  48523. }
  48524. function matrixProduct(a, b, result) {
  48525. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48526. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48527. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48528. }
  48529. function convertToFlat(sourceWhitePoint, LMS, result) {
  48530. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48531. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48532. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48533. }
  48534. function convertToD65(sourceWhitePoint, LMS, result) {
  48535. var D65X = 0.95047;
  48536. var D65Y = 1;
  48537. var D65Z = 1.08883;
  48538. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48539. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48540. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48541. }
  48542. function sRGBTransferFunction(color) {
  48543. if (color <= 0.0031308) {
  48544. return adjustToRange(0, 1, 12.92 * color);
  48545. }
  48546. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48547. }
  48548. function adjustToRange(min, max, value) {
  48549. return Math.max(min, Math.min(max, value));
  48550. }
  48551. function decodeL(L) {
  48552. if (L < 0) {
  48553. return -decodeL(-L);
  48554. }
  48555. if (L > 8.0) {
  48556. return Math.pow((L + 16) / 116, 3);
  48557. }
  48558. return L * DECODE_L_CONSTANT;
  48559. }
  48560. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48561. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48562. result[0] = XYZ_Flat[0];
  48563. result[1] = XYZ_Flat[1];
  48564. result[2] = XYZ_Flat[2];
  48565. return;
  48566. }
  48567. var zeroDecodeL = decodeL(0);
  48568. var X_DST = zeroDecodeL;
  48569. var X_SRC = decodeL(sourceBlackPoint[0]);
  48570. var Y_DST = zeroDecodeL;
  48571. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48572. var Z_DST = zeroDecodeL;
  48573. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48574. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48575. var X_Offset = 1 - X_Scale;
  48576. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48577. var Y_Offset = 1 - Y_Scale;
  48578. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48579. var Z_Offset = 1 - Z_Scale;
  48580. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48581. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48582. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48583. }
  48584. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48585. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48586. result[0] = XYZ_In[0];
  48587. result[1] = XYZ_In[1];
  48588. result[2] = XYZ_In[2];
  48589. return;
  48590. }
  48591. var LMS = result;
  48592. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48593. var LMS_Flat = tempNormalizeMatrix;
  48594. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48595. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48596. }
  48597. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48598. var LMS = result;
  48599. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48600. var LMS_D65 = tempNormalizeMatrix;
  48601. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48602. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48603. }
  48604. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48605. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48606. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48607. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48608. var AGR = Math.pow(A, cs.GR);
  48609. var BGG = Math.pow(B, cs.GG);
  48610. var CGB = Math.pow(C, cs.GB);
  48611. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48612. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48613. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48614. var XYZ = tempConvertMatrix1;
  48615. XYZ[0] = X;
  48616. XYZ[1] = Y;
  48617. XYZ[2] = Z;
  48618. var XYZ_Flat = tempConvertMatrix2;
  48619. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48620. var XYZ_Black = tempConvertMatrix1;
  48621. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48622. var XYZ_D65 = tempConvertMatrix2;
  48623. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48624. var SRGB = tempConvertMatrix1;
  48625. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48626. var sR = sRGBTransferFunction(SRGB[0]);
  48627. var sG = sRGBTransferFunction(SRGB[1]);
  48628. var sB = sRGBTransferFunction(SRGB[2]);
  48629. dest[destOffset] = Math.round(sR * 255);
  48630. dest[destOffset + 1] = Math.round(sG * 255);
  48631. dest[destOffset + 2] = Math.round(sB * 255);
  48632. }
  48633. CalRGBCS.prototype = {
  48634. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48635. var rgb = new Uint8Array(3);
  48636. this.getRgbItem(src, srcOffset, rgb, 0);
  48637. return rgb;
  48638. },
  48639. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48640. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48641. },
  48642. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48643. var scale = 1 / ((1 << bits) - 1);
  48644. for (var i = 0; i < count; ++i) {
  48645. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48646. srcOffset += 3;
  48647. destOffset += 3 + alpha01;
  48648. }
  48649. },
  48650. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48651. return inputLength * (3 + alpha01) / 3 | 0;
  48652. },
  48653. isPassthrough: ColorSpace.prototype.isPassthrough,
  48654. fillRgb: ColorSpace.prototype.fillRgb,
  48655. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48656. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48657. },
  48658. usesZeroToOneRange: true
  48659. };
  48660. return CalRGBCS;
  48661. }();
  48662. var LabCS = function LabCSClosure() {
  48663. function LabCS(whitePoint, blackPoint, range) {
  48664. this.name = 'Lab';
  48665. this.numComps = 3;
  48666. this.defaultColor = new Float32Array(this.numComps);
  48667. if (!whitePoint) {
  48668. error('WhitePoint missing - required for color space Lab');
  48669. }
  48670. blackPoint = blackPoint || [
  48671. 0,
  48672. 0,
  48673. 0
  48674. ];
  48675. range = range || [
  48676. -100,
  48677. 100,
  48678. -100,
  48679. 100
  48680. ];
  48681. this.XW = whitePoint[0];
  48682. this.YW = whitePoint[1];
  48683. this.ZW = whitePoint[2];
  48684. this.amin = range[0];
  48685. this.amax = range[1];
  48686. this.bmin = range[2];
  48687. this.bmax = range[3];
  48688. this.XB = blackPoint[0];
  48689. this.YB = blackPoint[1];
  48690. this.ZB = blackPoint[2];
  48691. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48692. error('Invalid WhitePoint components, no fallback available');
  48693. }
  48694. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48695. info('Invalid BlackPoint, falling back to default');
  48696. this.XB = this.YB = this.ZB = 0;
  48697. }
  48698. if (this.amin > this.amax || this.bmin > this.bmax) {
  48699. info('Invalid Range, falling back to defaults');
  48700. this.amin = -100;
  48701. this.amax = 100;
  48702. this.bmin = -100;
  48703. this.bmax = 100;
  48704. }
  48705. }
  48706. function fn_g(x) {
  48707. var result;
  48708. if (x >= 6 / 29) {
  48709. result = x * x * x;
  48710. } else {
  48711. result = 108 / 841 * (x - 4 / 29);
  48712. }
  48713. return result;
  48714. }
  48715. function decode(value, high1, low2, high2) {
  48716. return low2 + value * (high2 - low2) / high1;
  48717. }
  48718. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48719. var Ls = src[srcOffset];
  48720. var as = src[srcOffset + 1];
  48721. var bs = src[srcOffset + 2];
  48722. if (maxVal !== false) {
  48723. Ls = decode(Ls, maxVal, 0, 100);
  48724. as = decode(as, maxVal, cs.amin, cs.amax);
  48725. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48726. }
  48727. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48728. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48729. var M = (Ls + 16) / 116;
  48730. var L = M + as / 500;
  48731. var N = M - bs / 200;
  48732. var X = cs.XW * fn_g(L);
  48733. var Y = cs.YW * fn_g(M);
  48734. var Z = cs.ZW * fn_g(N);
  48735. var r, g, b;
  48736. if (cs.ZW < 1) {
  48737. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48738. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48739. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48740. } else {
  48741. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48742. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48743. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48744. }
  48745. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48746. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48747. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48748. }
  48749. LabCS.prototype = {
  48750. getRgb: ColorSpace.prototype.getRgb,
  48751. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48752. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48753. },
  48754. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48755. var maxVal = (1 << bits) - 1;
  48756. for (var i = 0; i < count; i++) {
  48757. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48758. srcOffset += 3;
  48759. destOffset += 3 + alpha01;
  48760. }
  48761. },
  48762. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48763. return inputLength * (3 + alpha01) / 3 | 0;
  48764. },
  48765. isPassthrough: ColorSpace.prototype.isPassthrough,
  48766. fillRgb: ColorSpace.prototype.fillRgb,
  48767. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48768. return true;
  48769. },
  48770. usesZeroToOneRange: false
  48771. };
  48772. return LabCS;
  48773. }();
  48774. exports.ColorSpace = ColorSpace;
  48775. }));
  48776. (function (root, factory) {
  48777. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48778. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48779. var globalScope = sharedUtil.globalScope;
  48780. var deprecated = sharedUtil.deprecated;
  48781. var warn = sharedUtil.warn;
  48782. var LinkTarget = displayDOMUtils.LinkTarget;
  48783. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  48784. var isWorker = typeof window === 'undefined';
  48785. if (!globalScope.PDFJS) {
  48786. globalScope.PDFJS = {};
  48787. }
  48788. var PDFJS = globalScope.PDFJS;
  48789. if (typeof pdfjsVersion !== 'undefined') {
  48790. PDFJS.version = pdfjsVersion;
  48791. }
  48792. if (typeof pdfjsBuild !== 'undefined') {
  48793. PDFJS.build = pdfjsBuild;
  48794. }
  48795. PDFJS.pdfBug = false;
  48796. if (PDFJS.verbosity !== undefined) {
  48797. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  48798. }
  48799. delete PDFJS.verbosity;
  48800. Object.defineProperty(PDFJS, 'verbosity', {
  48801. get: function () {
  48802. return sharedUtil.getVerbosityLevel();
  48803. },
  48804. set: function (level) {
  48805. sharedUtil.setVerbosityLevel(level);
  48806. },
  48807. enumerable: true,
  48808. configurable: true
  48809. });
  48810. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  48811. PDFJS.OPS = sharedUtil.OPS;
  48812. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  48813. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  48814. PDFJS.shadow = sharedUtil.shadow;
  48815. PDFJS.createBlob = sharedUtil.createBlob;
  48816. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  48817. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  48818. };
  48819. Object.defineProperty(PDFJS, 'isLittleEndian', {
  48820. configurable: true,
  48821. get: function PDFJS_isLittleEndian() {
  48822. var value = sharedUtil.isLittleEndian();
  48823. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  48824. }
  48825. });
  48826. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  48827. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  48828. PDFJS.PasswordException = sharedUtil.PasswordException;
  48829. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  48830. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  48831. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  48832. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  48833. PDFJS.Util = sharedUtil.Util;
  48834. PDFJS.PageViewport = sharedUtil.PageViewport;
  48835. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  48836. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  48837. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  48838. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  48839. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  48840. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  48841. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  48842. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  48843. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  48844. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  48845. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  48846. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  48847. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  48848. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  48849. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  48850. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  48851. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  48852. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  48853. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  48854. delete PDFJS.openExternalLinksInNewWindow;
  48855. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  48856. get: function () {
  48857. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  48858. },
  48859. set: function (value) {
  48860. if (value) {
  48861. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  48862. }
  48863. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  48864. warn('PDFJS.externalLinkTarget is already initialized');
  48865. return;
  48866. }
  48867. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  48868. },
  48869. enumerable: true,
  48870. configurable: true
  48871. });
  48872. if (savedOpenExternalLinksInNewWindow) {
  48873. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  48874. }
  48875. PDFJS.getDocument = displayAPI.getDocument;
  48876. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  48877. PDFJS.PDFWorker = displayAPI.PDFWorker;
  48878. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  48879. configurable: true,
  48880. get: function PDFJS_hasCanvasTypedArrays() {
  48881. var value = displayDOMUtils.hasCanvasTypedArrays();
  48882. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  48883. }
  48884. });
  48885. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  48886. PDFJS.LinkTarget = LinkTarget;
  48887. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  48888. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  48889. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  48890. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  48891. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  48892. PDFJS.Metadata = displayMetadata.Metadata;
  48893. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  48894. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  48895. exports.globalScope = globalScope;
  48896. exports.isWorker = isWorker;
  48897. exports.PDFJS = globalScope.PDFJS;
  48898. }));
  48899. (function (root, factory) {
  48900. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  48901. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  48902. var ImageKind = sharedUtil.ImageKind;
  48903. var assert = sharedUtil.assert;
  48904. var error = sharedUtil.error;
  48905. var info = sharedUtil.info;
  48906. var isArray = sharedUtil.isArray;
  48907. var warn = sharedUtil.warn;
  48908. var Name = corePrimitives.Name;
  48909. var isStream = corePrimitives.isStream;
  48910. var ColorSpace = coreColorSpace.ColorSpace;
  48911. var DecodeStream = coreStream.DecodeStream;
  48912. var JpegStream = coreStream.JpegStream;
  48913. var JpxImage = coreJpx.JpxImage;
  48914. var PDFImage = function PDFImageClosure() {
  48915. function handleImageData(image, nativeDecoder) {
  48916. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  48917. return nativeDecoder.decode(image);
  48918. }
  48919. return Promise.resolve(image);
  48920. }
  48921. function decodeAndClamp(value, addend, coefficient, max) {
  48922. value = addend + value * coefficient;
  48923. return value < 0 ? 0 : value > max ? max : value;
  48924. }
  48925. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48926. var length = w2 * h2;
  48927. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48928. var xRatio = w1 / w2;
  48929. var yRatio = h1 / h2;
  48930. var i, j, py, newIndex = 0, oldIndex;
  48931. var xScaled = new Uint16Array(w2);
  48932. var w1Scanline = w1;
  48933. for (i = 0; i < w2; i++) {
  48934. xScaled[i] = Math.floor(i * xRatio);
  48935. }
  48936. for (i = 0; i < h2; i++) {
  48937. py = Math.floor(i * yRatio) * w1Scanline;
  48938. for (j = 0; j < w2; j++) {
  48939. oldIndex = py + xScaled[j];
  48940. dest[newIndex++] = src[oldIndex];
  48941. }
  48942. }
  48943. return dest;
  48944. }
  48945. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48946. this.image = image;
  48947. var dict = image.dict;
  48948. if (dict.has('Filter')) {
  48949. var filter = dict.get('Filter').name;
  48950. if (filter === 'JPXDecode') {
  48951. var jpxImage = new JpxImage();
  48952. jpxImage.parseImageProperties(image.stream);
  48953. image.stream.reset();
  48954. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48955. image.numComps = jpxImage.componentsCount;
  48956. } else if (filter === 'JBIG2Decode') {
  48957. image.bitsPerComponent = 1;
  48958. image.numComps = 1;
  48959. }
  48960. }
  48961. this.width = dict.get('Width', 'W');
  48962. this.height = dict.get('Height', 'H');
  48963. if (this.width < 1 || this.height < 1) {
  48964. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48965. }
  48966. this.interpolate = dict.get('Interpolate', 'I') || false;
  48967. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48968. this.matte = dict.get('Matte') || false;
  48969. var bitsPerComponent = image.bitsPerComponent;
  48970. if (!bitsPerComponent) {
  48971. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48972. if (!bitsPerComponent) {
  48973. if (this.imageMask) {
  48974. bitsPerComponent = 1;
  48975. } else {
  48976. error('Bits per component missing in image: ' + this.imageMask);
  48977. }
  48978. }
  48979. }
  48980. this.bpc = bitsPerComponent;
  48981. if (!this.imageMask) {
  48982. var colorSpace = dict.get('ColorSpace', 'CS');
  48983. if (!colorSpace) {
  48984. info('JPX images (which do not require color spaces)');
  48985. switch (image.numComps) {
  48986. case 1:
  48987. colorSpace = Name.get('DeviceGray');
  48988. break;
  48989. case 3:
  48990. colorSpace = Name.get('DeviceRGB');
  48991. break;
  48992. case 4:
  48993. colorSpace = Name.get('DeviceCMYK');
  48994. break;
  48995. default:
  48996. error('JPX images with ' + this.numComps + ' color components not supported.');
  48997. }
  48998. }
  48999. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  49000. this.numComps = this.colorSpace.numComps;
  49001. }
  49002. this.decode = dict.getArray('Decode', 'D');
  49003. this.needsDecode = false;
  49004. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  49005. this.needsDecode = true;
  49006. var max = (1 << bitsPerComponent) - 1;
  49007. this.decodeCoefficients = [];
  49008. this.decodeAddends = [];
  49009. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  49010. var dmin = this.decode[i];
  49011. var dmax = this.decode[i + 1];
  49012. this.decodeCoefficients[j] = dmax - dmin;
  49013. this.decodeAddends[j] = max * dmin;
  49014. }
  49015. }
  49016. if (smask) {
  49017. this.smask = new PDFImage(xref, res, smask, false);
  49018. } else if (mask) {
  49019. if (isStream(mask)) {
  49020. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  49021. if (!imageMask) {
  49022. warn('Ignoring /Mask in image without /ImageMask.');
  49023. } else {
  49024. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  49025. }
  49026. } else {
  49027. this.mask = mask;
  49028. }
  49029. }
  49030. }
  49031. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  49032. var imagePromise = handleImageData(image, nativeDecoder);
  49033. var smaskPromise;
  49034. var maskPromise;
  49035. var smask = image.dict.get('SMask');
  49036. var mask = image.dict.get('Mask');
  49037. if (smask) {
  49038. smaskPromise = handleImageData(smask, nativeDecoder);
  49039. maskPromise = Promise.resolve(null);
  49040. } else {
  49041. smaskPromise = Promise.resolve(null);
  49042. if (mask) {
  49043. if (isStream(mask)) {
  49044. maskPromise = handleImageData(mask, nativeDecoder);
  49045. } else if (isArray(mask)) {
  49046. maskPromise = Promise.resolve(mask);
  49047. } else {
  49048. warn('Unsupported mask format.');
  49049. maskPromise = Promise.resolve(null);
  49050. }
  49051. } else {
  49052. maskPromise = Promise.resolve(null);
  49053. }
  49054. }
  49055. return Promise.all([
  49056. imagePromise,
  49057. smaskPromise,
  49058. maskPromise
  49059. ]).then(function (results) {
  49060. var imageData = results[0];
  49061. var smaskData = results[1];
  49062. var maskData = results[2];
  49063. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  49064. });
  49065. };
  49066. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  49067. var computedLength = (width + 7 >> 3) * height;
  49068. var actualLength = imgArray.byteLength;
  49069. var haveFullData = computedLength === actualLength;
  49070. var data, i;
  49071. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  49072. data = imgArray;
  49073. } else if (!inverseDecode) {
  49074. data = new Uint8Array(actualLength);
  49075. data.set(imgArray);
  49076. } else {
  49077. data = new Uint8Array(computedLength);
  49078. data.set(imgArray);
  49079. for (i = actualLength; i < computedLength; i++) {
  49080. data[i] = 0xff;
  49081. }
  49082. }
  49083. if (inverseDecode) {
  49084. for (i = 0; i < actualLength; i++) {
  49085. data[i] = ~data[i];
  49086. }
  49087. }
  49088. return {
  49089. data: data,
  49090. width: width,
  49091. height: height
  49092. };
  49093. };
  49094. PDFImage.prototype = {
  49095. get drawWidth() {
  49096. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  49097. },
  49098. get drawHeight() {
  49099. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  49100. },
  49101. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  49102. var bpc = this.bpc;
  49103. var numComps = this.numComps;
  49104. var decodeAddends = this.decodeAddends;
  49105. var decodeCoefficients = this.decodeCoefficients;
  49106. var max = (1 << bpc) - 1;
  49107. var i, ii;
  49108. if (bpc === 1) {
  49109. for (i = 0, ii = buffer.length; i < ii; i++) {
  49110. buffer[i] = +!buffer[i];
  49111. }
  49112. return;
  49113. }
  49114. var index = 0;
  49115. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  49116. for (var j = 0; j < numComps; j++) {
  49117. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  49118. index++;
  49119. }
  49120. }
  49121. },
  49122. getComponents: function PDFImage_getComponents(buffer) {
  49123. var bpc = this.bpc;
  49124. if (bpc === 8) {
  49125. return buffer;
  49126. }
  49127. var width = this.width;
  49128. var height = this.height;
  49129. var numComps = this.numComps;
  49130. var length = width * height * numComps;
  49131. var bufferPos = 0;
  49132. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  49133. var rowComps = width * numComps;
  49134. var max = (1 << bpc) - 1;
  49135. var i = 0, ii, buf;
  49136. if (bpc === 1) {
  49137. var mask, loop1End, loop2End;
  49138. for (var j = 0; j < height; j++) {
  49139. loop1End = i + (rowComps & ~7);
  49140. loop2End = i + rowComps;
  49141. while (i < loop1End) {
  49142. buf = buffer[bufferPos++];
  49143. output[i] = buf >> 7 & 1;
  49144. output[i + 1] = buf >> 6 & 1;
  49145. output[i + 2] = buf >> 5 & 1;
  49146. output[i + 3] = buf >> 4 & 1;
  49147. output[i + 4] = buf >> 3 & 1;
  49148. output[i + 5] = buf >> 2 & 1;
  49149. output[i + 6] = buf >> 1 & 1;
  49150. output[i + 7] = buf & 1;
  49151. i += 8;
  49152. }
  49153. if (i < loop2End) {
  49154. buf = buffer[bufferPos++];
  49155. mask = 128;
  49156. while (i < loop2End) {
  49157. output[i++] = +!!(buf & mask);
  49158. mask >>= 1;
  49159. }
  49160. }
  49161. }
  49162. } else {
  49163. var bits = 0;
  49164. buf = 0;
  49165. for (i = 0, ii = length; i < ii; ++i) {
  49166. if (i % rowComps === 0) {
  49167. buf = 0;
  49168. bits = 0;
  49169. }
  49170. while (bits < bpc) {
  49171. buf = buf << 8 | buffer[bufferPos++];
  49172. bits += 8;
  49173. }
  49174. var remainingBits = bits - bpc;
  49175. var value = buf >> remainingBits;
  49176. output[i] = value < 0 ? 0 : value > max ? max : value;
  49177. buf = buf & (1 << remainingBits) - 1;
  49178. bits = remainingBits;
  49179. }
  49180. }
  49181. return output;
  49182. },
  49183. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49184. var smask = this.smask;
  49185. var mask = this.mask;
  49186. var alphaBuf, sw, sh, i, ii, j;
  49187. if (smask) {
  49188. sw = smask.width;
  49189. sh = smask.height;
  49190. alphaBuf = new Uint8Array(sw * sh);
  49191. smask.fillGrayBuffer(alphaBuf);
  49192. if (sw !== width || sh !== height) {
  49193. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49194. }
  49195. } else if (mask) {
  49196. if (mask instanceof PDFImage) {
  49197. sw = mask.width;
  49198. sh = mask.height;
  49199. alphaBuf = new Uint8Array(sw * sh);
  49200. mask.numComps = 1;
  49201. mask.fillGrayBuffer(alphaBuf);
  49202. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49203. alphaBuf[i] = 255 - alphaBuf[i];
  49204. }
  49205. if (sw !== width || sh !== height) {
  49206. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49207. }
  49208. } else if (isArray(mask)) {
  49209. alphaBuf = new Uint8Array(width * height);
  49210. var numComps = this.numComps;
  49211. for (i = 0, ii = width * height; i < ii; ++i) {
  49212. var opacity = 0;
  49213. var imageOffset = i * numComps;
  49214. for (j = 0; j < numComps; ++j) {
  49215. var color = image[imageOffset + j];
  49216. var maskOffset = j * 2;
  49217. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49218. opacity = 255;
  49219. break;
  49220. }
  49221. }
  49222. alphaBuf[i] = opacity;
  49223. }
  49224. } else {
  49225. error('Unknown mask format.');
  49226. }
  49227. }
  49228. if (alphaBuf) {
  49229. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49230. rgbaBuf[j] = alphaBuf[i];
  49231. }
  49232. } else {
  49233. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49234. rgbaBuf[j] = 255;
  49235. }
  49236. }
  49237. },
  49238. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49239. var matte = this.smask && this.smask.matte;
  49240. if (!matte) {
  49241. return;
  49242. }
  49243. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49244. var matteR = matteRgb[0];
  49245. var matteG = matteRgb[1];
  49246. var matteB = matteRgb[2];
  49247. var length = width * height * 4;
  49248. var r, g, b;
  49249. for (var i = 0; i < length; i += 4) {
  49250. var alpha = buffer[i + 3];
  49251. if (alpha === 0) {
  49252. buffer[i] = 255;
  49253. buffer[i + 1] = 255;
  49254. buffer[i + 2] = 255;
  49255. continue;
  49256. }
  49257. var k = 255 / alpha;
  49258. r = (buffer[i] - matteR) * k + matteR;
  49259. g = (buffer[i + 1] - matteG) * k + matteG;
  49260. b = (buffer[i + 2] - matteB) * k + matteB;
  49261. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49262. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49263. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49264. }
  49265. },
  49266. createImageData: function PDFImage_createImageData(forceRGBA) {
  49267. var drawWidth = this.drawWidth;
  49268. var drawHeight = this.drawHeight;
  49269. var imgData = {
  49270. width: drawWidth,
  49271. height: drawHeight
  49272. };
  49273. var numComps = this.numComps;
  49274. var originalWidth = this.width;
  49275. var originalHeight = this.height;
  49276. var bpc = this.bpc;
  49277. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49278. var imgArray;
  49279. if (!forceRGBA) {
  49280. var kind;
  49281. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49282. kind = ImageKind.GRAYSCALE_1BPP;
  49283. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49284. kind = ImageKind.RGB_24BPP;
  49285. }
  49286. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49287. imgData.kind = kind;
  49288. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49289. if (this.image instanceof DecodeStream) {
  49290. imgData.data = imgArray;
  49291. } else {
  49292. var newArray = new Uint8Array(imgArray.length);
  49293. newArray.set(imgArray);
  49294. imgData.data = newArray;
  49295. }
  49296. if (this.needsDecode) {
  49297. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49298. var buffer = imgData.data;
  49299. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49300. buffer[i] ^= 0xff;
  49301. }
  49302. }
  49303. return imgData;
  49304. }
  49305. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49306. imgData.kind = ImageKind.RGB_24BPP;
  49307. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49308. return imgData;
  49309. }
  49310. }
  49311. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49312. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49313. var comps = this.getComponents(imgArray);
  49314. var alpha01, maybeUndoPreblend;
  49315. if (!forceRGBA && !this.smask && !this.mask) {
  49316. imgData.kind = ImageKind.RGB_24BPP;
  49317. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49318. alpha01 = 0;
  49319. maybeUndoPreblend = false;
  49320. } else {
  49321. imgData.kind = ImageKind.RGBA_32BPP;
  49322. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49323. alpha01 = 1;
  49324. maybeUndoPreblend = true;
  49325. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49326. }
  49327. if (this.needsDecode) {
  49328. this.decodeBuffer(comps);
  49329. }
  49330. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49331. if (maybeUndoPreblend) {
  49332. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49333. }
  49334. return imgData;
  49335. },
  49336. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49337. var numComps = this.numComps;
  49338. if (numComps !== 1) {
  49339. error('Reading gray scale from a color image: ' + numComps);
  49340. }
  49341. var width = this.width;
  49342. var height = this.height;
  49343. var bpc = this.bpc;
  49344. var rowBytes = width * numComps * bpc + 7 >> 3;
  49345. var imgArray = this.getImageBytes(height * rowBytes);
  49346. var comps = this.getComponents(imgArray);
  49347. var i, length;
  49348. if (bpc === 1) {
  49349. length = width * height;
  49350. if (this.needsDecode) {
  49351. for (i = 0; i < length; ++i) {
  49352. buffer[i] = comps[i] - 1 & 255;
  49353. }
  49354. } else {
  49355. for (i = 0; i < length; ++i) {
  49356. buffer[i] = -comps[i] & 255;
  49357. }
  49358. }
  49359. return;
  49360. }
  49361. if (this.needsDecode) {
  49362. this.decodeBuffer(comps);
  49363. }
  49364. length = width * height;
  49365. var scale = 255 / ((1 << bpc) - 1);
  49366. for (i = 0; i < length; ++i) {
  49367. buffer[i] = scale * comps[i] | 0;
  49368. }
  49369. },
  49370. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49371. this.image.reset();
  49372. this.image.drawWidth = drawWidth || this.width;
  49373. this.image.drawHeight = drawHeight || this.height;
  49374. this.image.forceRGB = !!forceRGB;
  49375. return this.image.getBytes(length);
  49376. }
  49377. };
  49378. return PDFImage;
  49379. }();
  49380. exports.PDFImage = PDFImage;
  49381. }));
  49382. (function (root, factory) {
  49383. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49384. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49385. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49386. var MissingDataException = sharedUtil.MissingDataException;
  49387. var XRefParseException = sharedUtil.XRefParseException;
  49388. var assert = sharedUtil.assert;
  49389. var bytesToString = sharedUtil.bytesToString;
  49390. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49391. var error = sharedUtil.error;
  49392. var info = sharedUtil.info;
  49393. var isArray = sharedUtil.isArray;
  49394. var isBool = sharedUtil.isBool;
  49395. var isInt = sharedUtil.isInt;
  49396. var isString = sharedUtil.isString;
  49397. var shadow = sharedUtil.shadow;
  49398. var stringToPDFString = sharedUtil.stringToPDFString;
  49399. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49400. var warn = sharedUtil.warn;
  49401. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49402. var Util = sharedUtil.Util;
  49403. var Ref = corePrimitives.Ref;
  49404. var RefSet = corePrimitives.RefSet;
  49405. var RefSetCache = corePrimitives.RefSetCache;
  49406. var isName = corePrimitives.isName;
  49407. var isCmd = corePrimitives.isCmd;
  49408. var isDict = corePrimitives.isDict;
  49409. var isRef = corePrimitives.isRef;
  49410. var isRefsEqual = corePrimitives.isRefsEqual;
  49411. var isStream = corePrimitives.isStream;
  49412. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49413. var Lexer = coreParser.Lexer;
  49414. var Parser = coreParser.Parser;
  49415. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49416. var ColorSpace = coreColorSpace.ColorSpace;
  49417. var Catalog = function CatalogClosure() {
  49418. function Catalog(pdfManager, xref, pageFactory) {
  49419. this.pdfManager = pdfManager;
  49420. this.xref = xref;
  49421. this.catDict = xref.getCatalogObj();
  49422. this.fontCache = new RefSetCache();
  49423. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49424. this.pageFactory = pageFactory;
  49425. this.pagePromises = [];
  49426. }
  49427. Catalog.prototype = {
  49428. get metadata() {
  49429. var streamRef = this.catDict.getRaw('Metadata');
  49430. if (!isRef(streamRef)) {
  49431. return shadow(this, 'metadata', null);
  49432. }
  49433. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49434. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49435. var metadata;
  49436. if (stream && isDict(stream.dict)) {
  49437. var type = stream.dict.get('Type');
  49438. var subtype = stream.dict.get('Subtype');
  49439. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49440. try {
  49441. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49442. } catch (e) {
  49443. info('Skipping invalid metadata.');
  49444. }
  49445. }
  49446. }
  49447. return shadow(this, 'metadata', metadata);
  49448. },
  49449. get toplevelPagesDict() {
  49450. var pagesObj = this.catDict.get('Pages');
  49451. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49452. return shadow(this, 'toplevelPagesDict', pagesObj);
  49453. },
  49454. get documentOutline() {
  49455. var obj = null;
  49456. try {
  49457. obj = this.readDocumentOutline();
  49458. } catch (ex) {
  49459. if (ex instanceof MissingDataException) {
  49460. throw ex;
  49461. }
  49462. warn('Unable to read document outline');
  49463. }
  49464. return shadow(this, 'documentOutline', obj);
  49465. },
  49466. readDocumentOutline: function Catalog_readDocumentOutline() {
  49467. var obj = this.catDict.get('Outlines');
  49468. if (!isDict(obj)) {
  49469. return null;
  49470. }
  49471. obj = obj.getRaw('First');
  49472. if (!isRef(obj)) {
  49473. return null;
  49474. }
  49475. var root = { items: [] };
  49476. var queue = [{
  49477. obj: obj,
  49478. parent: root
  49479. }];
  49480. var processed = new RefSet();
  49481. processed.put(obj);
  49482. var xref = this.xref, blackColor = new Uint8Array(3);
  49483. while (queue.length > 0) {
  49484. var i = queue.shift();
  49485. var outlineDict = xref.fetchIfRef(i.obj);
  49486. if (outlineDict === null) {
  49487. continue;
  49488. }
  49489. assert(outlineDict.has('Title'), 'Invalid outline item');
  49490. var data = {
  49491. url: null,
  49492. dest: null
  49493. };
  49494. Catalog.parseDestDictionary({
  49495. destDict: outlineDict,
  49496. resultObj: data,
  49497. docBaseUrl: this.pdfManager.docBaseUrl
  49498. });
  49499. var title = outlineDict.get('Title');
  49500. var flags = outlineDict.get('F') || 0;
  49501. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49502. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49503. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49504. }
  49505. var outlineItem = {
  49506. dest: data.dest,
  49507. url: data.url,
  49508. unsafeUrl: data.unsafeUrl,
  49509. newWindow: data.newWindow,
  49510. title: stringToPDFString(title),
  49511. color: rgbColor,
  49512. count: outlineDict.get('Count'),
  49513. bold: !!(flags & 2),
  49514. italic: !!(flags & 1),
  49515. items: []
  49516. };
  49517. i.parent.items.push(outlineItem);
  49518. obj = outlineDict.getRaw('First');
  49519. if (isRef(obj) && !processed.has(obj)) {
  49520. queue.push({
  49521. obj: obj,
  49522. parent: outlineItem
  49523. });
  49524. processed.put(obj);
  49525. }
  49526. obj = outlineDict.getRaw('Next');
  49527. if (isRef(obj) && !processed.has(obj)) {
  49528. queue.push({
  49529. obj: obj,
  49530. parent: i.parent
  49531. });
  49532. processed.put(obj);
  49533. }
  49534. }
  49535. return root.items.length > 0 ? root.items : null;
  49536. },
  49537. get numPages() {
  49538. var obj = this.toplevelPagesDict.get('Count');
  49539. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49540. return shadow(this, 'num', obj);
  49541. },
  49542. get destinations() {
  49543. function fetchDestination(dest) {
  49544. return isDict(dest) ? dest.get('D') : dest;
  49545. }
  49546. var xref = this.xref;
  49547. var dests = {}, nameTreeRef, nameDictionaryRef;
  49548. var obj = this.catDict.get('Names');
  49549. if (obj && obj.has('Dests')) {
  49550. nameTreeRef = obj.getRaw('Dests');
  49551. } else if (this.catDict.has('Dests')) {
  49552. nameDictionaryRef = this.catDict.get('Dests');
  49553. }
  49554. if (nameDictionaryRef) {
  49555. obj = nameDictionaryRef;
  49556. obj.forEach(function catalogForEach(key, value) {
  49557. if (!value) {
  49558. return;
  49559. }
  49560. dests[key] = fetchDestination(value);
  49561. });
  49562. }
  49563. if (nameTreeRef) {
  49564. var nameTree = new NameTree(nameTreeRef, xref);
  49565. var names = nameTree.getAll();
  49566. for (var name in names) {
  49567. dests[name] = fetchDestination(names[name]);
  49568. }
  49569. }
  49570. return shadow(this, 'destinations', dests);
  49571. },
  49572. getDestination: function Catalog_getDestination(destinationId) {
  49573. function fetchDestination(dest) {
  49574. return isDict(dest) ? dest.get('D') : dest;
  49575. }
  49576. var xref = this.xref;
  49577. var dest = null, nameTreeRef, nameDictionaryRef;
  49578. var obj = this.catDict.get('Names');
  49579. if (obj && obj.has('Dests')) {
  49580. nameTreeRef = obj.getRaw('Dests');
  49581. } else if (this.catDict.has('Dests')) {
  49582. nameDictionaryRef = this.catDict.get('Dests');
  49583. }
  49584. if (nameDictionaryRef) {
  49585. var value = nameDictionaryRef.get(destinationId);
  49586. if (value) {
  49587. dest = fetchDestination(value);
  49588. }
  49589. }
  49590. if (nameTreeRef) {
  49591. var nameTree = new NameTree(nameTreeRef, xref);
  49592. dest = fetchDestination(nameTree.get(destinationId));
  49593. }
  49594. return dest;
  49595. },
  49596. get pageLabels() {
  49597. var obj = null;
  49598. try {
  49599. obj = this.readPageLabels();
  49600. } catch (ex) {
  49601. if (ex instanceof MissingDataException) {
  49602. throw ex;
  49603. }
  49604. warn('Unable to read page labels.');
  49605. }
  49606. return shadow(this, 'pageLabels', obj);
  49607. },
  49608. readPageLabels: function Catalog_readPageLabels() {
  49609. var obj = this.catDict.getRaw('PageLabels');
  49610. if (!obj) {
  49611. return null;
  49612. }
  49613. var pageLabels = new Array(this.numPages);
  49614. var style = null;
  49615. var prefix = '';
  49616. var numberTree = new NumberTree(obj, this.xref);
  49617. var nums = numberTree.getAll();
  49618. var currentLabel = '', currentIndex = 1;
  49619. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49620. if (i in nums) {
  49621. var labelDict = nums[i];
  49622. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49623. var type = labelDict.get('Type');
  49624. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49625. var s = labelDict.get('S');
  49626. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49627. style = s ? s.name : null;
  49628. var p = labelDict.get('P');
  49629. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49630. prefix = p ? stringToPDFString(p) : '';
  49631. var st = labelDict.get('St');
  49632. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49633. currentIndex = st || 1;
  49634. }
  49635. switch (style) {
  49636. case 'D':
  49637. currentLabel = currentIndex;
  49638. break;
  49639. case 'R':
  49640. case 'r':
  49641. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49642. break;
  49643. case 'A':
  49644. case 'a':
  49645. var LIMIT = 26;
  49646. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49647. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49648. var letterIndex = currentIndex - 1;
  49649. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49650. var charBuf = [];
  49651. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49652. charBuf.push(character);
  49653. }
  49654. currentLabel = charBuf.join('');
  49655. break;
  49656. default:
  49657. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49658. }
  49659. pageLabels[i] = prefix + currentLabel;
  49660. currentLabel = '';
  49661. currentIndex++;
  49662. }
  49663. return pageLabels;
  49664. },
  49665. get attachments() {
  49666. var xref = this.xref;
  49667. var attachments = null, nameTreeRef;
  49668. var obj = this.catDict.get('Names');
  49669. if (obj) {
  49670. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49671. }
  49672. if (nameTreeRef) {
  49673. var nameTree = new NameTree(nameTreeRef, xref);
  49674. var names = nameTree.getAll();
  49675. for (var name in names) {
  49676. var fs = new FileSpec(names[name], xref);
  49677. if (!attachments) {
  49678. attachments = Object.create(null);
  49679. }
  49680. attachments[stringToPDFString(name)] = fs.serializable;
  49681. }
  49682. }
  49683. return shadow(this, 'attachments', attachments);
  49684. },
  49685. get javaScript() {
  49686. var xref = this.xref;
  49687. var obj = this.catDict.get('Names');
  49688. var javaScript = [];
  49689. function appendIfJavaScriptDict(jsDict) {
  49690. var type = jsDict.get('S');
  49691. if (!isName(type, 'JavaScript')) {
  49692. return;
  49693. }
  49694. var js = jsDict.get('JS');
  49695. if (isStream(js)) {
  49696. js = bytesToString(js.getBytes());
  49697. } else if (!isString(js)) {
  49698. return;
  49699. }
  49700. javaScript.push(stringToPDFString(js));
  49701. }
  49702. if (obj && obj.has('JavaScript')) {
  49703. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49704. var names = nameTree.getAll();
  49705. for (var name in names) {
  49706. var jsDict = names[name];
  49707. if (isDict(jsDict)) {
  49708. appendIfJavaScriptDict(jsDict);
  49709. }
  49710. }
  49711. }
  49712. var openactionDict = this.catDict.get('OpenAction');
  49713. if (isDict(openactionDict, 'Action')) {
  49714. var actionType = openactionDict.get('S');
  49715. if (isName(actionType, 'Named')) {
  49716. var action = openactionDict.get('N');
  49717. if (isName(action, 'Print')) {
  49718. javaScript.push('print({});');
  49719. }
  49720. } else {
  49721. appendIfJavaScriptDict(openactionDict);
  49722. }
  49723. }
  49724. return shadow(this, 'javaScript', javaScript);
  49725. },
  49726. cleanup: function Catalog_cleanup() {
  49727. var promises = [];
  49728. this.fontCache.forEach(function (promise) {
  49729. promises.push(promise);
  49730. });
  49731. return Promise.all(promises).then(function (translatedFonts) {
  49732. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49733. var font = translatedFonts[i].dict;
  49734. delete font.translated;
  49735. }
  49736. this.fontCache.clear();
  49737. }.bind(this));
  49738. },
  49739. getPage: function Catalog_getPage(pageIndex) {
  49740. if (!(pageIndex in this.pagePromises)) {
  49741. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49742. var dict = a[0];
  49743. var ref = a[1];
  49744. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49745. }.bind(this));
  49746. }
  49747. return this.pagePromises[pageIndex];
  49748. },
  49749. getPageDict: function Catalog_getPageDict(pageIndex) {
  49750. var capability = createPromiseCapability();
  49751. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49752. var currentPageIndex = 0;
  49753. var xref = this.xref;
  49754. var checkAllKids = false;
  49755. function next() {
  49756. while (nodesToVisit.length) {
  49757. var currentNode = nodesToVisit.pop();
  49758. if (isRef(currentNode)) {
  49759. xref.fetchAsync(currentNode).then(function (obj) {
  49760. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49761. if (pageIndex === currentPageIndex) {
  49762. capability.resolve([
  49763. obj,
  49764. currentNode
  49765. ]);
  49766. } else {
  49767. currentPageIndex++;
  49768. next();
  49769. }
  49770. return;
  49771. }
  49772. nodesToVisit.push(obj);
  49773. next();
  49774. }, capability.reject);
  49775. return;
  49776. }
  49777. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49778. var count = currentNode.get('Count');
  49779. if (count === 0) {
  49780. checkAllKids = true;
  49781. }
  49782. if (currentPageIndex + count <= pageIndex) {
  49783. currentPageIndex += count;
  49784. continue;
  49785. }
  49786. var kids = currentNode.get('Kids');
  49787. assert(isArray(kids), 'page dictionary kids object is not an array');
  49788. if (!checkAllKids && count === kids.length) {
  49789. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49790. currentPageIndex = pageIndex;
  49791. continue;
  49792. } else {
  49793. for (var last = kids.length - 1; last >= 0; last--) {
  49794. nodesToVisit.push(kids[last]);
  49795. }
  49796. }
  49797. }
  49798. capability.reject('Page index ' + pageIndex + ' not found.');
  49799. }
  49800. next();
  49801. return capability.promise;
  49802. },
  49803. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49804. var xref = this.xref;
  49805. function pagesBeforeRef(kidRef) {
  49806. var total = 0;
  49807. var parentRef;
  49808. return xref.fetchAsync(kidRef).then(function (node) {
  49809. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49810. throw new Error('The reference does not point to a /Page Dict.');
  49811. }
  49812. if (!node) {
  49813. return null;
  49814. }
  49815. assert(isDict(node), 'node must be a Dict.');
  49816. parentRef = node.getRaw('Parent');
  49817. return node.getAsync('Parent');
  49818. }).then(function (parent) {
  49819. if (!parent) {
  49820. return null;
  49821. }
  49822. assert(isDict(parent), 'parent must be a Dict.');
  49823. return parent.getAsync('Kids');
  49824. }).then(function (kids) {
  49825. if (!kids) {
  49826. return null;
  49827. }
  49828. var kidPromises = [];
  49829. var found = false;
  49830. for (var i = 0; i < kids.length; i++) {
  49831. var kid = kids[i];
  49832. assert(isRef(kid), 'kid must be a Ref.');
  49833. if (kid.num === kidRef.num) {
  49834. found = true;
  49835. break;
  49836. }
  49837. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49838. if (kid.has('Count')) {
  49839. var count = kid.get('Count');
  49840. total += count;
  49841. } else {
  49842. total++;
  49843. }
  49844. }));
  49845. }
  49846. if (!found) {
  49847. error('kid ref not found in parents kids');
  49848. }
  49849. return Promise.all(kidPromises).then(function () {
  49850. return [
  49851. total,
  49852. parentRef
  49853. ];
  49854. });
  49855. });
  49856. }
  49857. var total = 0;
  49858. function next(ref) {
  49859. return pagesBeforeRef(ref).then(function (args) {
  49860. if (!args) {
  49861. return total;
  49862. }
  49863. var count = args[0];
  49864. var parentRef = args[1];
  49865. total += count;
  49866. return next(parentRef);
  49867. });
  49868. }
  49869. return next(pageRef);
  49870. }
  49871. };
  49872. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49873. function addDefaultProtocolToUrl(url) {
  49874. if (url.indexOf('www.') === 0) {
  49875. return 'http://' + url;
  49876. }
  49877. return url;
  49878. }
  49879. function tryConvertUrlEncoding(url) {
  49880. try {
  49881. return stringToUTF8String(url);
  49882. } catch (e) {
  49883. return url;
  49884. }
  49885. }
  49886. var destDict = params.destDict;
  49887. if (!isDict(destDict)) {
  49888. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49889. return;
  49890. }
  49891. var resultObj = params.resultObj;
  49892. if (typeof resultObj !== 'object') {
  49893. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49894. return;
  49895. }
  49896. var docBaseUrl = params.docBaseUrl || null;
  49897. var action = destDict.get('A'), url, dest;
  49898. if (isDict(action)) {
  49899. var linkType = action.get('S').name;
  49900. switch (linkType) {
  49901. case 'URI':
  49902. url = action.get('URI');
  49903. if (isName(url)) {
  49904. url = '/' + url.name;
  49905. } else if (isString(url)) {
  49906. url = addDefaultProtocolToUrl(url);
  49907. }
  49908. break;
  49909. case 'GoTo':
  49910. dest = action.get('D');
  49911. break;
  49912. case 'Launch':
  49913. case 'GoToR':
  49914. var urlDict = action.get('F');
  49915. if (isDict(urlDict)) {
  49916. url = urlDict.get('F') || null;
  49917. } else if (isString(urlDict)) {
  49918. url = urlDict;
  49919. }
  49920. var remoteDest = action.get('D');
  49921. if (remoteDest) {
  49922. if (isName(remoteDest)) {
  49923. remoteDest = remoteDest.name;
  49924. }
  49925. if (isString(url)) {
  49926. var baseUrl = url.split('#')[0];
  49927. if (isString(remoteDest)) {
  49928. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49929. } else if (isArray(remoteDest)) {
  49930. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49931. }
  49932. }
  49933. }
  49934. var newWindow = action.get('NewWindow');
  49935. if (isBool(newWindow)) {
  49936. resultObj.newWindow = newWindow;
  49937. }
  49938. break;
  49939. case 'Named':
  49940. var namedAction = action.get('N');
  49941. if (isName(namedAction)) {
  49942. resultObj.action = namedAction.name;
  49943. }
  49944. break;
  49945. case 'JavaScript':
  49946. var jsAction = action.get('JS'), js;
  49947. if (isStream(jsAction)) {
  49948. js = bytesToString(jsAction.getBytes());
  49949. } else if (isString(jsAction)) {
  49950. js = jsAction;
  49951. }
  49952. if (js) {
  49953. var URL_OPEN_METHODS = [
  49954. 'app.launchURL',
  49955. 'window.open'
  49956. ];
  49957. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49958. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49959. if (jsUrl && jsUrl[1]) {
  49960. url = jsUrl[1];
  49961. break;
  49962. }
  49963. }
  49964. default:
  49965. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49966. break;
  49967. }
  49968. } else if (destDict.has('Dest')) {
  49969. dest = destDict.get('Dest');
  49970. }
  49971. if (isString(url)) {
  49972. url = tryConvertUrlEncoding(url);
  49973. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49974. if (absoluteUrl) {
  49975. resultObj.url = absoluteUrl.href;
  49976. }
  49977. resultObj.unsafeUrl = url;
  49978. }
  49979. if (dest) {
  49980. if (isName(dest)) {
  49981. dest = dest.name;
  49982. }
  49983. if (isString(dest) || isArray(dest)) {
  49984. resultObj.dest = dest;
  49985. }
  49986. }
  49987. };
  49988. return Catalog;
  49989. }();
  49990. var XRef = function XRefClosure() {
  49991. function XRef(stream, pdfManager) {
  49992. this.stream = stream;
  49993. this.pdfManager = pdfManager;
  49994. this.entries = [];
  49995. this.xrefstms = Object.create(null);
  49996. this.cache = [];
  49997. this.stats = {
  49998. streamTypes: [],
  49999. fontTypes: []
  50000. };
  50001. }
  50002. XRef.prototype = {
  50003. setStartXRef: function XRef_setStartXRef(startXRef) {
  50004. this.startXRefQueue = [startXRef];
  50005. },
  50006. parse: function XRef_parse(recoveryMode) {
  50007. var trailerDict;
  50008. if (!recoveryMode) {
  50009. trailerDict = this.readXRef();
  50010. } else {
  50011. warn('Indexing all PDF objects');
  50012. trailerDict = this.indexObjects();
  50013. }
  50014. trailerDict.assignXref(this);
  50015. this.trailer = trailerDict;
  50016. var encrypt = trailerDict.get('Encrypt');
  50017. if (isDict(encrypt)) {
  50018. var ids = trailerDict.get('ID');
  50019. var fileId = ids && ids.length ? ids[0] : '';
  50020. encrypt.suppressEncryption = true;
  50021. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  50022. }
  50023. if (!(this.root = trailerDict.get('Root'))) {
  50024. error('Invalid root reference');
  50025. }
  50026. },
  50027. processXRefTable: function XRef_processXRefTable(parser) {
  50028. if (!('tableState' in this)) {
  50029. this.tableState = {
  50030. entryNum: 0,
  50031. streamPos: parser.lexer.stream.pos,
  50032. parserBuf1: parser.buf1,
  50033. parserBuf2: parser.buf2
  50034. };
  50035. }
  50036. var obj = this.readXRefTable(parser);
  50037. if (!isCmd(obj, 'trailer')) {
  50038. error('Invalid XRef table: could not find trailer dictionary');
  50039. }
  50040. var dict = parser.getObj();
  50041. if (!isDict(dict) && dict.dict) {
  50042. dict = dict.dict;
  50043. }
  50044. if (!isDict(dict)) {
  50045. error('Invalid XRef table: could not parse trailer dictionary');
  50046. }
  50047. delete this.tableState;
  50048. return dict;
  50049. },
  50050. readXRefTable: function XRef_readXRefTable(parser) {
  50051. var stream = parser.lexer.stream;
  50052. var tableState = this.tableState;
  50053. stream.pos = tableState.streamPos;
  50054. parser.buf1 = tableState.parserBuf1;
  50055. parser.buf2 = tableState.parserBuf2;
  50056. var obj;
  50057. while (true) {
  50058. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  50059. if (isCmd(obj = parser.getObj(), 'trailer')) {
  50060. break;
  50061. }
  50062. tableState.firstEntryNum = obj;
  50063. tableState.entryCount = parser.getObj();
  50064. }
  50065. var first = tableState.firstEntryNum;
  50066. var count = tableState.entryCount;
  50067. if (!isInt(first) || !isInt(count)) {
  50068. error('Invalid XRef table: wrong types in subsection header');
  50069. }
  50070. for (var i = tableState.entryNum; i < count; i++) {
  50071. tableState.streamPos = stream.pos;
  50072. tableState.entryNum = i;
  50073. tableState.parserBuf1 = parser.buf1;
  50074. tableState.parserBuf2 = parser.buf2;
  50075. var entry = {};
  50076. entry.offset = parser.getObj();
  50077. entry.gen = parser.getObj();
  50078. var type = parser.getObj();
  50079. if (isCmd(type, 'f')) {
  50080. entry.free = true;
  50081. } else if (isCmd(type, 'n')) {
  50082. entry.uncompressed = true;
  50083. }
  50084. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  50085. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  50086. }
  50087. if (i === 0 && entry.free && first === 1) {
  50088. first = 0;
  50089. }
  50090. if (!this.entries[i + first]) {
  50091. this.entries[i + first] = entry;
  50092. }
  50093. }
  50094. tableState.entryNum = 0;
  50095. tableState.streamPos = stream.pos;
  50096. tableState.parserBuf1 = parser.buf1;
  50097. tableState.parserBuf2 = parser.buf2;
  50098. delete tableState.firstEntryNum;
  50099. delete tableState.entryCount;
  50100. }
  50101. if (this.entries[0] && !this.entries[0].free) {
  50102. error('Invalid XRef table: unexpected first object');
  50103. }
  50104. return obj;
  50105. },
  50106. processXRefStream: function XRef_processXRefStream(stream) {
  50107. if (!('streamState' in this)) {
  50108. var streamParameters = stream.dict;
  50109. var byteWidths = streamParameters.get('W');
  50110. var range = streamParameters.get('Index');
  50111. if (!range) {
  50112. range = [
  50113. 0,
  50114. streamParameters.get('Size')
  50115. ];
  50116. }
  50117. this.streamState = {
  50118. entryRanges: range,
  50119. byteWidths: byteWidths,
  50120. entryNum: 0,
  50121. streamPos: stream.pos
  50122. };
  50123. }
  50124. this.readXRefStream(stream);
  50125. delete this.streamState;
  50126. return stream.dict;
  50127. },
  50128. readXRefStream: function XRef_readXRefStream(stream) {
  50129. var i, j;
  50130. var streamState = this.streamState;
  50131. stream.pos = streamState.streamPos;
  50132. var byteWidths = streamState.byteWidths;
  50133. var typeFieldWidth = byteWidths[0];
  50134. var offsetFieldWidth = byteWidths[1];
  50135. var generationFieldWidth = byteWidths[2];
  50136. var entryRanges = streamState.entryRanges;
  50137. while (entryRanges.length > 0) {
  50138. var first = entryRanges[0];
  50139. var n = entryRanges[1];
  50140. if (!isInt(first) || !isInt(n)) {
  50141. error('Invalid XRef range fields: ' + first + ', ' + n);
  50142. }
  50143. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  50144. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  50145. }
  50146. for (i = streamState.entryNum; i < n; ++i) {
  50147. streamState.entryNum = i;
  50148. streamState.streamPos = stream.pos;
  50149. var type = 0, offset = 0, generation = 0;
  50150. for (j = 0; j < typeFieldWidth; ++j) {
  50151. type = type << 8 | stream.getByte();
  50152. }
  50153. if (typeFieldWidth === 0) {
  50154. type = 1;
  50155. }
  50156. for (j = 0; j < offsetFieldWidth; ++j) {
  50157. offset = offset << 8 | stream.getByte();
  50158. }
  50159. for (j = 0; j < generationFieldWidth; ++j) {
  50160. generation = generation << 8 | stream.getByte();
  50161. }
  50162. var entry = {};
  50163. entry.offset = offset;
  50164. entry.gen = generation;
  50165. switch (type) {
  50166. case 0:
  50167. entry.free = true;
  50168. break;
  50169. case 1:
  50170. entry.uncompressed = true;
  50171. break;
  50172. case 2:
  50173. break;
  50174. default:
  50175. error('Invalid XRef entry type: ' + type);
  50176. }
  50177. if (!this.entries[first + i]) {
  50178. this.entries[first + i] = entry;
  50179. }
  50180. }
  50181. streamState.entryNum = 0;
  50182. streamState.streamPos = stream.pos;
  50183. entryRanges.splice(0, 2);
  50184. }
  50185. },
  50186. indexObjects: function XRef_indexObjects() {
  50187. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50188. var PERCENT = 0x25, LT = 0x3C;
  50189. function readToken(data, offset) {
  50190. var token = '', ch = data[offset];
  50191. while (ch !== LF && ch !== CR && ch !== LT) {
  50192. if (++offset >= data.length) {
  50193. break;
  50194. }
  50195. token += String.fromCharCode(ch);
  50196. ch = data[offset];
  50197. }
  50198. return token;
  50199. }
  50200. function skipUntil(data, offset, what) {
  50201. var length = what.length, dataLength = data.length;
  50202. var skipped = 0;
  50203. while (offset < dataLength) {
  50204. var i = 0;
  50205. while (i < length && data[offset + i] === what[i]) {
  50206. ++i;
  50207. }
  50208. if (i >= length) {
  50209. break;
  50210. }
  50211. offset++;
  50212. skipped++;
  50213. }
  50214. return skipped;
  50215. }
  50216. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50217. var trailerBytes = new Uint8Array([
  50218. 116,
  50219. 114,
  50220. 97,
  50221. 105,
  50222. 108,
  50223. 101,
  50224. 114
  50225. ]);
  50226. var startxrefBytes = new Uint8Array([
  50227. 115,
  50228. 116,
  50229. 97,
  50230. 114,
  50231. 116,
  50232. 120,
  50233. 114,
  50234. 101,
  50235. 102
  50236. ]);
  50237. var endobjBytes = new Uint8Array([
  50238. 101,
  50239. 110,
  50240. 100,
  50241. 111,
  50242. 98,
  50243. 106
  50244. ]);
  50245. var xrefBytes = new Uint8Array([
  50246. 47,
  50247. 88,
  50248. 82,
  50249. 101,
  50250. 102
  50251. ]);
  50252. this.entries.length = 0;
  50253. var stream = this.stream;
  50254. stream.pos = 0;
  50255. var buffer = stream.getBytes();
  50256. var position = stream.start, length = buffer.length;
  50257. var trailers = [], xrefStms = [];
  50258. while (position < length) {
  50259. var ch = buffer[position];
  50260. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50261. ++position;
  50262. continue;
  50263. }
  50264. if (ch === PERCENT) {
  50265. do {
  50266. ++position;
  50267. if (position >= length) {
  50268. break;
  50269. }
  50270. ch = buffer[position];
  50271. } while (ch !== LF && ch !== CR);
  50272. continue;
  50273. }
  50274. var token = readToken(buffer, position);
  50275. var m;
  50276. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50277. position += skipUntil(buffer, position, trailerBytes);
  50278. trailers.push(position);
  50279. position += skipUntil(buffer, position, startxrefBytes);
  50280. } else if (m = objRegExp.exec(token)) {
  50281. if (typeof this.entries[m[1]] === 'undefined') {
  50282. this.entries[m[1]] = {
  50283. offset: position - stream.start,
  50284. gen: m[2] | 0,
  50285. uncompressed: true
  50286. };
  50287. }
  50288. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50289. var content = buffer.subarray(position, position + contentLength);
  50290. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50291. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50292. xrefStms.push(position - stream.start);
  50293. this.xrefstms[position - stream.start] = 1;
  50294. }
  50295. position += contentLength;
  50296. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50297. trailers.push(position);
  50298. position += skipUntil(buffer, position, startxrefBytes);
  50299. } else {
  50300. position += token.length + 1;
  50301. }
  50302. }
  50303. var i, ii;
  50304. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50305. this.startXRefQueue.push(xrefStms[i]);
  50306. this.readXRef(true);
  50307. }
  50308. var dict;
  50309. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50310. stream.pos = trailers[i];
  50311. var parser = new Parser(new Lexer(stream), true, this, true);
  50312. var obj = parser.getObj();
  50313. if (!isCmd(obj, 'trailer')) {
  50314. continue;
  50315. }
  50316. dict = parser.getObj();
  50317. if (!isDict(dict)) {
  50318. continue;
  50319. }
  50320. if (dict.has('ID')) {
  50321. return dict;
  50322. }
  50323. }
  50324. if (dict) {
  50325. return dict;
  50326. }
  50327. throw new InvalidPDFException('Invalid PDF structure');
  50328. },
  50329. readXRef: function XRef_readXRef(recoveryMode) {
  50330. var stream = this.stream;
  50331. try {
  50332. while (this.startXRefQueue.length) {
  50333. var startXRef = this.startXRefQueue[0];
  50334. stream.pos = startXRef + stream.start;
  50335. var parser = new Parser(new Lexer(stream), true, this);
  50336. var obj = parser.getObj();
  50337. var dict;
  50338. if (isCmd(obj, 'xref')) {
  50339. dict = this.processXRefTable(parser);
  50340. if (!this.topDict) {
  50341. this.topDict = dict;
  50342. }
  50343. obj = dict.get('XRefStm');
  50344. if (isInt(obj)) {
  50345. var pos = obj;
  50346. if (!(pos in this.xrefstms)) {
  50347. this.xrefstms[pos] = 1;
  50348. this.startXRefQueue.push(pos);
  50349. }
  50350. }
  50351. } else if (isInt(obj)) {
  50352. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50353. error('Invalid XRef stream');
  50354. }
  50355. dict = this.processXRefStream(obj);
  50356. if (!this.topDict) {
  50357. this.topDict = dict;
  50358. }
  50359. if (!dict) {
  50360. error('Failed to read XRef stream');
  50361. }
  50362. } else {
  50363. error('Invalid XRef stream header');
  50364. }
  50365. obj = dict.get('Prev');
  50366. if (isInt(obj)) {
  50367. this.startXRefQueue.push(obj);
  50368. } else if (isRef(obj)) {
  50369. this.startXRefQueue.push(obj.num);
  50370. }
  50371. this.startXRefQueue.shift();
  50372. }
  50373. return this.topDict;
  50374. } catch (e) {
  50375. if (e instanceof MissingDataException) {
  50376. throw e;
  50377. }
  50378. info('(while reading XRef): ' + e);
  50379. }
  50380. if (recoveryMode) {
  50381. return;
  50382. }
  50383. throw new XRefParseException();
  50384. },
  50385. getEntry: function XRef_getEntry(i) {
  50386. var xrefEntry = this.entries[i];
  50387. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50388. return xrefEntry;
  50389. }
  50390. return null;
  50391. },
  50392. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50393. if (!isRef(obj)) {
  50394. return obj;
  50395. }
  50396. return this.fetch(obj, suppressEncryption);
  50397. },
  50398. fetch: function XRef_fetch(ref, suppressEncryption) {
  50399. assert(isRef(ref), 'ref object is not a reference');
  50400. var num = ref.num;
  50401. if (num in this.cache) {
  50402. var cacheEntry = this.cache[num];
  50403. return cacheEntry;
  50404. }
  50405. var xrefEntry = this.getEntry(num);
  50406. if (xrefEntry === null) {
  50407. return this.cache[num] = null;
  50408. }
  50409. if (xrefEntry.uncompressed) {
  50410. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50411. } else {
  50412. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50413. }
  50414. if (isDict(xrefEntry)) {
  50415. xrefEntry.objId = ref.toString();
  50416. } else if (isStream(xrefEntry)) {
  50417. xrefEntry.dict.objId = ref.toString();
  50418. }
  50419. return xrefEntry;
  50420. },
  50421. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50422. var gen = ref.gen;
  50423. var num = ref.num;
  50424. if (xrefEntry.gen !== gen) {
  50425. error('inconsistent generation in XRef');
  50426. }
  50427. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50428. var parser = new Parser(new Lexer(stream), true, this);
  50429. var obj1 = parser.getObj();
  50430. var obj2 = parser.getObj();
  50431. var obj3 = parser.getObj();
  50432. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50433. error('bad XRef entry');
  50434. }
  50435. if (!isCmd(obj3, 'obj')) {
  50436. if (obj3.cmd.indexOf('obj') === 0) {
  50437. num = parseInt(obj3.cmd.substring(3), 10);
  50438. if (!isNaN(num)) {
  50439. return num;
  50440. }
  50441. }
  50442. error('bad XRef entry');
  50443. }
  50444. if (this.encrypt && !suppressEncryption) {
  50445. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50446. } else {
  50447. xrefEntry = parser.getObj();
  50448. }
  50449. if (!isStream(xrefEntry)) {
  50450. this.cache[num] = xrefEntry;
  50451. }
  50452. return xrefEntry;
  50453. },
  50454. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50455. var tableOffset = xrefEntry.offset;
  50456. var stream = this.fetch(new Ref(tableOffset, 0));
  50457. if (!isStream(stream)) {
  50458. error('bad ObjStm stream');
  50459. }
  50460. var first = stream.dict.get('First');
  50461. var n = stream.dict.get('N');
  50462. if (!isInt(first) || !isInt(n)) {
  50463. error('invalid first and n parameters for ObjStm stream');
  50464. }
  50465. var parser = new Parser(new Lexer(stream), false, this);
  50466. parser.allowStreams = true;
  50467. var i, entries = [], num, nums = [];
  50468. for (i = 0; i < n; ++i) {
  50469. num = parser.getObj();
  50470. if (!isInt(num)) {
  50471. error('invalid object number in the ObjStm stream: ' + num);
  50472. }
  50473. nums.push(num);
  50474. var offset = parser.getObj();
  50475. if (!isInt(offset)) {
  50476. error('invalid object offset in the ObjStm stream: ' + offset);
  50477. }
  50478. }
  50479. for (i = 0; i < n; ++i) {
  50480. entries.push(parser.getObj());
  50481. if (isCmd(parser.buf1, 'endobj')) {
  50482. parser.shift();
  50483. }
  50484. num = nums[i];
  50485. var entry = this.entries[num];
  50486. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50487. this.cache[num] = entries[i];
  50488. }
  50489. }
  50490. xrefEntry = entries[xrefEntry.gen];
  50491. if (xrefEntry === undefined) {
  50492. error('bad XRef entry for compressed object');
  50493. }
  50494. return xrefEntry;
  50495. },
  50496. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50497. if (!isRef(obj)) {
  50498. return Promise.resolve(obj);
  50499. }
  50500. return this.fetchAsync(obj, suppressEncryption);
  50501. },
  50502. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50503. var streamManager = this.stream.manager;
  50504. var xref = this;
  50505. return new Promise(function tryFetch(resolve, reject) {
  50506. try {
  50507. resolve(xref.fetch(ref, suppressEncryption));
  50508. } catch (e) {
  50509. if (e instanceof MissingDataException) {
  50510. streamManager.requestRange(e.begin, e.end).then(function () {
  50511. tryFetch(resolve, reject);
  50512. }, reject);
  50513. return;
  50514. }
  50515. reject(e);
  50516. }
  50517. });
  50518. },
  50519. getCatalogObj: function XRef_getCatalogObj() {
  50520. return this.root;
  50521. }
  50522. };
  50523. return XRef;
  50524. }();
  50525. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50526. function NameOrNumberTree(root, xref) {
  50527. throw new Error('Cannot initialize NameOrNumberTree.');
  50528. }
  50529. NameOrNumberTree.prototype = {
  50530. getAll: function NameOrNumberTree_getAll() {
  50531. var dict = Object.create(null);
  50532. if (!this.root) {
  50533. return dict;
  50534. }
  50535. var xref = this.xref;
  50536. var processed = new RefSet();
  50537. processed.put(this.root);
  50538. var queue = [this.root];
  50539. while (queue.length > 0) {
  50540. var i, n;
  50541. var obj = xref.fetchIfRef(queue.shift());
  50542. if (!isDict(obj)) {
  50543. continue;
  50544. }
  50545. if (obj.has('Kids')) {
  50546. var kids = obj.get('Kids');
  50547. for (i = 0, n = kids.length; i < n; i++) {
  50548. var kid = kids[i];
  50549. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50550. queue.push(kid);
  50551. processed.put(kid);
  50552. }
  50553. continue;
  50554. }
  50555. var entries = obj.get(this._type);
  50556. if (isArray(entries)) {
  50557. for (i = 0, n = entries.length; i < n; i += 2) {
  50558. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50559. }
  50560. }
  50561. }
  50562. return dict;
  50563. },
  50564. get: function NameOrNumberTree_get(key) {
  50565. if (!this.root) {
  50566. return null;
  50567. }
  50568. var xref = this.xref;
  50569. var kidsOrEntries = xref.fetchIfRef(this.root);
  50570. var loopCount = 0;
  50571. var MAX_LEVELS = 10;
  50572. var l, r, m;
  50573. while (kidsOrEntries.has('Kids')) {
  50574. if (++loopCount > MAX_LEVELS) {
  50575. warn('Search depth limit reached for "' + this._type + '" tree.');
  50576. return null;
  50577. }
  50578. var kids = kidsOrEntries.get('Kids');
  50579. if (!isArray(kids)) {
  50580. return null;
  50581. }
  50582. l = 0;
  50583. r = kids.length - 1;
  50584. while (l <= r) {
  50585. m = l + r >> 1;
  50586. var kid = xref.fetchIfRef(kids[m]);
  50587. var limits = kid.get('Limits');
  50588. if (key < xref.fetchIfRef(limits[0])) {
  50589. r = m - 1;
  50590. } else if (key > xref.fetchIfRef(limits[1])) {
  50591. l = m + 1;
  50592. } else {
  50593. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50594. break;
  50595. }
  50596. }
  50597. if (l > r) {
  50598. return null;
  50599. }
  50600. }
  50601. var entries = kidsOrEntries.get(this._type);
  50602. if (isArray(entries)) {
  50603. l = 0;
  50604. r = entries.length - 2;
  50605. while (l <= r) {
  50606. m = l + r & ~1;
  50607. var currentKey = xref.fetchIfRef(entries[m]);
  50608. if (key < currentKey) {
  50609. r = m - 2;
  50610. } else if (key > currentKey) {
  50611. l = m + 2;
  50612. } else {
  50613. return xref.fetchIfRef(entries[m + 1]);
  50614. }
  50615. }
  50616. }
  50617. return null;
  50618. }
  50619. };
  50620. return NameOrNumberTree;
  50621. }();
  50622. var NameTree = function NameTreeClosure() {
  50623. function NameTree(root, xref) {
  50624. this.root = root;
  50625. this.xref = xref;
  50626. this._type = 'Names';
  50627. }
  50628. Util.inherit(NameTree, NameOrNumberTree, {});
  50629. return NameTree;
  50630. }();
  50631. var NumberTree = function NumberTreeClosure() {
  50632. function NumberTree(root, xref) {
  50633. this.root = root;
  50634. this.xref = xref;
  50635. this._type = 'Nums';
  50636. }
  50637. Util.inherit(NumberTree, NameOrNumberTree, {});
  50638. return NumberTree;
  50639. }();
  50640. var FileSpec = function FileSpecClosure() {
  50641. function FileSpec(root, xref) {
  50642. if (!root || !isDict(root)) {
  50643. return;
  50644. }
  50645. this.xref = xref;
  50646. this.root = root;
  50647. if (root.has('FS')) {
  50648. this.fs = root.get('FS');
  50649. }
  50650. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50651. if (root.has('RF')) {
  50652. warn('Related file specifications are not supported');
  50653. }
  50654. this.contentAvailable = true;
  50655. if (!root.has('EF')) {
  50656. this.contentAvailable = false;
  50657. warn('Non-embedded file specifications are not supported');
  50658. }
  50659. }
  50660. function pickPlatformItem(dict) {
  50661. if (dict.has('UF')) {
  50662. return dict.get('UF');
  50663. } else if (dict.has('F')) {
  50664. return dict.get('F');
  50665. } else if (dict.has('Unix')) {
  50666. return dict.get('Unix');
  50667. } else if (dict.has('Mac')) {
  50668. return dict.get('Mac');
  50669. } else if (dict.has('DOS')) {
  50670. return dict.get('DOS');
  50671. }
  50672. return null;
  50673. }
  50674. FileSpec.prototype = {
  50675. get filename() {
  50676. if (!this._filename && this.root) {
  50677. var filename = pickPlatformItem(this.root) || 'unnamed';
  50678. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50679. }
  50680. return this._filename;
  50681. },
  50682. get content() {
  50683. if (!this.contentAvailable) {
  50684. return null;
  50685. }
  50686. if (!this.contentRef && this.root) {
  50687. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50688. }
  50689. var content = null;
  50690. if (this.contentRef) {
  50691. var xref = this.xref;
  50692. var fileObj = xref.fetchIfRef(this.contentRef);
  50693. if (fileObj && isStream(fileObj)) {
  50694. content = fileObj.getBytes();
  50695. } else {
  50696. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50697. }
  50698. } else {
  50699. warn('Embedded file specification does not have a content');
  50700. }
  50701. return content;
  50702. },
  50703. get serializable() {
  50704. return {
  50705. filename: this.filename,
  50706. content: this.content
  50707. };
  50708. }
  50709. };
  50710. return FileSpec;
  50711. }();
  50712. var ObjectLoader = function () {
  50713. function mayHaveChildren(value) {
  50714. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50715. }
  50716. function addChildren(node, nodesToVisit) {
  50717. var value;
  50718. if (isDict(node) || isStream(node)) {
  50719. var map;
  50720. if (isDict(node)) {
  50721. map = node.map;
  50722. } else {
  50723. map = node.dict.map;
  50724. }
  50725. for (var key in map) {
  50726. value = map[key];
  50727. if (mayHaveChildren(value)) {
  50728. nodesToVisit.push(value);
  50729. }
  50730. }
  50731. } else if (isArray(node)) {
  50732. for (var i = 0, ii = node.length; i < ii; i++) {
  50733. value = node[i];
  50734. if (mayHaveChildren(value)) {
  50735. nodesToVisit.push(value);
  50736. }
  50737. }
  50738. }
  50739. }
  50740. function ObjectLoader(obj, keys, xref) {
  50741. this.obj = obj;
  50742. this.keys = keys;
  50743. this.xref = xref;
  50744. this.refSet = null;
  50745. this.capability = null;
  50746. }
  50747. ObjectLoader.prototype = {
  50748. load: function ObjectLoader_load() {
  50749. var keys = this.keys;
  50750. this.capability = createPromiseCapability();
  50751. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50752. this.capability.resolve();
  50753. return this.capability.promise;
  50754. }
  50755. this.refSet = new RefSet();
  50756. var nodesToVisit = [];
  50757. for (var i = 0; i < keys.length; i++) {
  50758. nodesToVisit.push(this.obj[keys[i]]);
  50759. }
  50760. this._walk(nodesToVisit);
  50761. return this.capability.promise;
  50762. },
  50763. _walk: function ObjectLoader_walk(nodesToVisit) {
  50764. var nodesToRevisit = [];
  50765. var pendingRequests = [];
  50766. while (nodesToVisit.length) {
  50767. var currentNode = nodesToVisit.pop();
  50768. if (isRef(currentNode)) {
  50769. if (this.refSet.has(currentNode)) {
  50770. continue;
  50771. }
  50772. try {
  50773. var ref = currentNode;
  50774. this.refSet.put(ref);
  50775. currentNode = this.xref.fetch(currentNode);
  50776. } catch (e) {
  50777. if (!(e instanceof MissingDataException)) {
  50778. throw e;
  50779. }
  50780. nodesToRevisit.push(currentNode);
  50781. pendingRequests.push({
  50782. begin: e.begin,
  50783. end: e.end
  50784. });
  50785. }
  50786. }
  50787. if (currentNode && currentNode.getBaseStreams) {
  50788. var baseStreams = currentNode.getBaseStreams();
  50789. var foundMissingData = false;
  50790. for (var i = 0; i < baseStreams.length; i++) {
  50791. var stream = baseStreams[i];
  50792. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50793. foundMissingData = true;
  50794. pendingRequests.push({
  50795. begin: stream.start,
  50796. end: stream.end
  50797. });
  50798. }
  50799. }
  50800. if (foundMissingData) {
  50801. nodesToRevisit.push(currentNode);
  50802. }
  50803. }
  50804. addChildren(currentNode, nodesToVisit);
  50805. }
  50806. if (pendingRequests.length) {
  50807. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50808. nodesToVisit = nodesToRevisit;
  50809. for (var i = 0; i < nodesToRevisit.length; i++) {
  50810. var node = nodesToRevisit[i];
  50811. if (isRef(node)) {
  50812. this.refSet.remove(node);
  50813. }
  50814. }
  50815. this._walk(nodesToVisit);
  50816. }.bind(this), this.capability.reject);
  50817. return;
  50818. }
  50819. this.refSet = null;
  50820. this.capability.resolve();
  50821. }
  50822. };
  50823. return ObjectLoader;
  50824. }();
  50825. exports.Catalog = Catalog;
  50826. exports.ObjectLoader = ObjectLoader;
  50827. exports.XRef = XRef;
  50828. exports.FileSpec = FileSpec;
  50829. }));
  50830. (function (root, factory) {
  50831. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50832. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50833. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50834. var MissingDataException = sharedUtil.MissingDataException;
  50835. var Util = sharedUtil.Util;
  50836. var assert = sharedUtil.assert;
  50837. var error = sharedUtil.error;
  50838. var info = sharedUtil.info;
  50839. var warn = sharedUtil.warn;
  50840. var isStream = corePrimitives.isStream;
  50841. var PDFFunction = coreFunction.PDFFunction;
  50842. var ColorSpace = coreColorSpace.ColorSpace;
  50843. var ShadingType = {
  50844. FUNCTION_BASED: 1,
  50845. AXIAL: 2,
  50846. RADIAL: 3,
  50847. FREE_FORM_MESH: 4,
  50848. LATTICE_FORM_MESH: 5,
  50849. COONS_PATCH_MESH: 6,
  50850. TENSOR_PATCH_MESH: 7
  50851. };
  50852. var Pattern = function PatternClosure() {
  50853. function Pattern() {
  50854. error('should not call Pattern constructor');
  50855. }
  50856. Pattern.prototype = {
  50857. getPattern: function Pattern_getPattern(ctx) {
  50858. error('Should not call Pattern.getStyle: ' + ctx);
  50859. }
  50860. };
  50861. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50862. var dict = isStream(shading) ? shading.dict : shading;
  50863. var type = dict.get('ShadingType');
  50864. try {
  50865. switch (type) {
  50866. case ShadingType.AXIAL:
  50867. case ShadingType.RADIAL:
  50868. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50869. case ShadingType.FREE_FORM_MESH:
  50870. case ShadingType.LATTICE_FORM_MESH:
  50871. case ShadingType.COONS_PATCH_MESH:
  50872. case ShadingType.TENSOR_PATCH_MESH:
  50873. return new Shadings.Mesh(shading, matrix, xref, res);
  50874. default:
  50875. throw new Error('Unsupported ShadingType: ' + type);
  50876. }
  50877. } catch (ex) {
  50878. if (ex instanceof MissingDataException) {
  50879. throw ex;
  50880. }
  50881. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50882. warn(ex);
  50883. return new Shadings.Dummy();
  50884. }
  50885. };
  50886. return Pattern;
  50887. }();
  50888. var Shadings = {};
  50889. Shadings.SMALL_NUMBER = 1e-6;
  50890. Shadings.RadialAxial = function RadialAxialClosure() {
  50891. function RadialAxial(dict, matrix, xref, res) {
  50892. this.matrix = matrix;
  50893. this.coordsArr = dict.getArray('Coords');
  50894. this.shadingType = dict.get('ShadingType');
  50895. this.type = 'Pattern';
  50896. var cs = dict.get('ColorSpace', 'CS');
  50897. cs = ColorSpace.parse(cs, xref, res);
  50898. this.cs = cs;
  50899. var t0 = 0.0, t1 = 1.0;
  50900. if (dict.has('Domain')) {
  50901. var domainArr = dict.getArray('Domain');
  50902. t0 = domainArr[0];
  50903. t1 = domainArr[1];
  50904. }
  50905. var extendStart = false, extendEnd = false;
  50906. if (dict.has('Extend')) {
  50907. var extendArr = dict.getArray('Extend');
  50908. extendStart = extendArr[0];
  50909. extendEnd = extendArr[1];
  50910. }
  50911. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50912. var x1 = this.coordsArr[0];
  50913. var y1 = this.coordsArr[1];
  50914. var r1 = this.coordsArr[2];
  50915. var x2 = this.coordsArr[3];
  50916. var y2 = this.coordsArr[4];
  50917. var r2 = this.coordsArr[5];
  50918. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50919. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50920. warn('Unsupported radial gradient.');
  50921. }
  50922. }
  50923. this.extendStart = extendStart;
  50924. this.extendEnd = extendEnd;
  50925. var fnObj = dict.get('Function');
  50926. var fn = PDFFunction.parseArray(xref, fnObj);
  50927. var diff = t1 - t0;
  50928. var step = diff / 10;
  50929. var colorStops = this.colorStops = [];
  50930. if (t0 >= t1 || step <= 0) {
  50931. info('Bad shading domain.');
  50932. return;
  50933. }
  50934. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50935. var rgbColor;
  50936. for (var i = t0; i <= t1; i += step) {
  50937. ratio[0] = i;
  50938. fn(ratio, 0, color, 0);
  50939. rgbColor = cs.getRgb(color, 0);
  50940. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50941. colorStops.push([
  50942. (i - t0) / diff,
  50943. cssColor
  50944. ]);
  50945. }
  50946. var background = 'transparent';
  50947. if (dict.has('Background')) {
  50948. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50949. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50950. }
  50951. if (!extendStart) {
  50952. colorStops.unshift([
  50953. 0,
  50954. background
  50955. ]);
  50956. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50957. }
  50958. if (!extendEnd) {
  50959. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50960. colorStops.push([
  50961. 1,
  50962. background
  50963. ]);
  50964. }
  50965. this.colorStops = colorStops;
  50966. }
  50967. RadialAxial.prototype = {
  50968. getIR: function RadialAxial_getIR() {
  50969. var coordsArr = this.coordsArr;
  50970. var shadingType = this.shadingType;
  50971. var type, p0, p1, r0, r1;
  50972. if (shadingType === ShadingType.AXIAL) {
  50973. p0 = [
  50974. coordsArr[0],
  50975. coordsArr[1]
  50976. ];
  50977. p1 = [
  50978. coordsArr[2],
  50979. coordsArr[3]
  50980. ];
  50981. r0 = null;
  50982. r1 = null;
  50983. type = 'axial';
  50984. } else if (shadingType === ShadingType.RADIAL) {
  50985. p0 = [
  50986. coordsArr[0],
  50987. coordsArr[1]
  50988. ];
  50989. p1 = [
  50990. coordsArr[3],
  50991. coordsArr[4]
  50992. ];
  50993. r0 = coordsArr[2];
  50994. r1 = coordsArr[5];
  50995. type = 'radial';
  50996. } else {
  50997. error('getPattern type unknown: ' + shadingType);
  50998. }
  50999. var matrix = this.matrix;
  51000. if (matrix) {
  51001. p0 = Util.applyTransform(p0, matrix);
  51002. p1 = Util.applyTransform(p1, matrix);
  51003. if (shadingType === ShadingType.RADIAL) {
  51004. var scale = Util.singularValueDecompose2dScale(matrix);
  51005. r0 *= scale[0];
  51006. r1 *= scale[1];
  51007. }
  51008. }
  51009. return [
  51010. 'RadialAxial',
  51011. type,
  51012. this.colorStops,
  51013. p0,
  51014. p1,
  51015. r0,
  51016. r1
  51017. ];
  51018. }
  51019. };
  51020. return RadialAxial;
  51021. }();
  51022. Shadings.Mesh = function MeshClosure() {
  51023. function MeshStreamReader(stream, context) {
  51024. this.stream = stream;
  51025. this.context = context;
  51026. this.buffer = 0;
  51027. this.bufferLength = 0;
  51028. var numComps = context.numComps;
  51029. this.tmpCompsBuf = new Float32Array(numComps);
  51030. var csNumComps = context.colorSpace.numComps;
  51031. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  51032. }
  51033. MeshStreamReader.prototype = {
  51034. get hasData() {
  51035. if (this.stream.end) {
  51036. return this.stream.pos < this.stream.end;
  51037. }
  51038. if (this.bufferLength > 0) {
  51039. return true;
  51040. }
  51041. var nextByte = this.stream.getByte();
  51042. if (nextByte < 0) {
  51043. return false;
  51044. }
  51045. this.buffer = nextByte;
  51046. this.bufferLength = 8;
  51047. return true;
  51048. },
  51049. readBits: function MeshStreamReader_readBits(n) {
  51050. var buffer = this.buffer;
  51051. var bufferLength = this.bufferLength;
  51052. if (n === 32) {
  51053. if (bufferLength === 0) {
  51054. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  51055. }
  51056. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  51057. var nextByte = this.stream.getByte();
  51058. this.buffer = nextByte & (1 << bufferLength) - 1;
  51059. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  51060. }
  51061. if (n === 8 && bufferLength === 0) {
  51062. return this.stream.getByte();
  51063. }
  51064. while (bufferLength < n) {
  51065. buffer = buffer << 8 | this.stream.getByte();
  51066. bufferLength += 8;
  51067. }
  51068. bufferLength -= n;
  51069. this.bufferLength = bufferLength;
  51070. this.buffer = buffer & (1 << bufferLength) - 1;
  51071. return buffer >> bufferLength;
  51072. },
  51073. align: function MeshStreamReader_align() {
  51074. this.buffer = 0;
  51075. this.bufferLength = 0;
  51076. },
  51077. readFlag: function MeshStreamReader_readFlag() {
  51078. return this.readBits(this.context.bitsPerFlag);
  51079. },
  51080. readCoordinate: function MeshStreamReader_readCoordinate() {
  51081. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  51082. var xi = this.readBits(bitsPerCoordinate);
  51083. var yi = this.readBits(bitsPerCoordinate);
  51084. var decode = this.context.decode;
  51085. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  51086. return [
  51087. xi * scale * (decode[1] - decode[0]) + decode[0],
  51088. yi * scale * (decode[3] - decode[2]) + decode[2]
  51089. ];
  51090. },
  51091. readComponents: function MeshStreamReader_readComponents() {
  51092. var numComps = this.context.numComps;
  51093. var bitsPerComponent = this.context.bitsPerComponent;
  51094. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  51095. var decode = this.context.decode;
  51096. var components = this.tmpCompsBuf;
  51097. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  51098. var ci = this.readBits(bitsPerComponent);
  51099. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  51100. }
  51101. var color = this.tmpCsCompsBuf;
  51102. if (this.context.colorFn) {
  51103. this.context.colorFn(components, 0, color, 0);
  51104. }
  51105. return this.context.colorSpace.getRgb(color, 0);
  51106. }
  51107. };
  51108. function decodeType4Shading(mesh, reader) {
  51109. var coords = mesh.coords;
  51110. var colors = mesh.colors;
  51111. var operators = [];
  51112. var ps = [];
  51113. var verticesLeft = 0;
  51114. while (reader.hasData) {
  51115. var f = reader.readFlag();
  51116. var coord = reader.readCoordinate();
  51117. var color = reader.readComponents();
  51118. if (verticesLeft === 0) {
  51119. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  51120. switch (f) {
  51121. case 0:
  51122. verticesLeft = 3;
  51123. break;
  51124. case 1:
  51125. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  51126. verticesLeft = 1;
  51127. break;
  51128. case 2:
  51129. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  51130. verticesLeft = 1;
  51131. break;
  51132. }
  51133. operators.push(f);
  51134. }
  51135. ps.push(coords.length);
  51136. coords.push(coord);
  51137. colors.push(color);
  51138. verticesLeft--;
  51139. reader.align();
  51140. }
  51141. mesh.figures.push({
  51142. type: 'triangles',
  51143. coords: new Int32Array(ps),
  51144. colors: new Int32Array(ps)
  51145. });
  51146. }
  51147. function decodeType5Shading(mesh, reader, verticesPerRow) {
  51148. var coords = mesh.coords;
  51149. var colors = mesh.colors;
  51150. var ps = [];
  51151. while (reader.hasData) {
  51152. var coord = reader.readCoordinate();
  51153. var color = reader.readComponents();
  51154. ps.push(coords.length);
  51155. coords.push(coord);
  51156. colors.push(color);
  51157. }
  51158. mesh.figures.push({
  51159. type: 'lattice',
  51160. coords: new Int32Array(ps),
  51161. colors: new Int32Array(ps),
  51162. verticesPerRow: verticesPerRow
  51163. });
  51164. }
  51165. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51166. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51167. var TRIANGLE_DENSITY = 20;
  51168. var getB = function getBClosure() {
  51169. function buildB(count) {
  51170. var lut = [];
  51171. for (var i = 0; i <= count; i++) {
  51172. var t = i / count, t_ = 1 - t;
  51173. lut.push(new Float32Array([
  51174. t_ * t_ * t_,
  51175. 3 * t * t_ * t_,
  51176. 3 * t * t * t_,
  51177. t * t * t
  51178. ]));
  51179. }
  51180. return lut;
  51181. }
  51182. var cache = [];
  51183. return function getB(count) {
  51184. if (!cache[count]) {
  51185. cache[count] = buildB(count);
  51186. }
  51187. return cache[count];
  51188. };
  51189. }();
  51190. function buildFigureFromPatch(mesh, index) {
  51191. var figure = mesh.figures[index];
  51192. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51193. var coords = mesh.coords, colors = mesh.colors;
  51194. var pi = figure.coords;
  51195. var ci = figure.colors;
  51196. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51197. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51198. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51199. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51200. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51201. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51202. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51203. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51204. var verticesPerRow = splitXBy + 1;
  51205. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51206. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51207. var k = 0;
  51208. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51209. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51210. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51211. for (var row = 0; row <= splitYBy; row++) {
  51212. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51213. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51214. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51215. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51216. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51217. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51218. for (var col = 0; col <= splitXBy; col++, k++) {
  51219. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51220. continue;
  51221. }
  51222. var x = 0, y = 0;
  51223. var q = 0;
  51224. for (var i = 0; i <= 3; i++) {
  51225. for (var j = 0; j <= 3; j++, q++) {
  51226. var m = bRow[row][i] * bCol[col][j];
  51227. x += coords[pi[q]][0] * m;
  51228. y += coords[pi[q]][1] * m;
  51229. }
  51230. }
  51231. figureCoords[k] = coords.length;
  51232. coords.push([
  51233. x,
  51234. y
  51235. ]);
  51236. figureColors[k] = colors.length;
  51237. var newColor = new Uint8Array(3);
  51238. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51239. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51240. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51241. colors.push(newColor);
  51242. }
  51243. }
  51244. figureCoords[0] = pi[0];
  51245. figureColors[0] = ci[0];
  51246. figureCoords[splitXBy] = pi[3];
  51247. figureColors[splitXBy] = ci[1];
  51248. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51249. figureColors[verticesPerRow * splitYBy] = ci[2];
  51250. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51251. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51252. mesh.figures[index] = {
  51253. type: 'lattice',
  51254. coords: figureCoords,
  51255. colors: figureColors,
  51256. verticesPerRow: verticesPerRow
  51257. };
  51258. }
  51259. function decodeType6Shading(mesh, reader) {
  51260. var coords = mesh.coords;
  51261. var colors = mesh.colors;
  51262. var ps = new Int32Array(16);
  51263. var cs = new Int32Array(4);
  51264. while (reader.hasData) {
  51265. var f = reader.readFlag();
  51266. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51267. var i, ii;
  51268. var pi = coords.length;
  51269. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51270. coords.push(reader.readCoordinate());
  51271. }
  51272. var ci = colors.length;
  51273. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51274. colors.push(reader.readComponents());
  51275. }
  51276. var tmp1, tmp2, tmp3, tmp4;
  51277. switch (f) {
  51278. case 0:
  51279. ps[12] = pi + 3;
  51280. ps[13] = pi + 4;
  51281. ps[14] = pi + 5;
  51282. ps[15] = pi + 6;
  51283. ps[8] = pi + 2;
  51284. ps[11] = pi + 7;
  51285. ps[4] = pi + 1;
  51286. ps[7] = pi + 8;
  51287. ps[0] = pi;
  51288. ps[1] = pi + 11;
  51289. ps[2] = pi + 10;
  51290. ps[3] = pi + 9;
  51291. cs[2] = ci + 1;
  51292. cs[3] = ci + 2;
  51293. cs[0] = ci;
  51294. cs[1] = ci + 3;
  51295. break;
  51296. case 1:
  51297. tmp1 = ps[12];
  51298. tmp2 = ps[13];
  51299. tmp3 = ps[14];
  51300. tmp4 = ps[15];
  51301. ps[12] = tmp4;
  51302. ps[13] = pi + 0;
  51303. ps[14] = pi + 1;
  51304. ps[15] = pi + 2;
  51305. ps[8] = tmp3;
  51306. ps[11] = pi + 3;
  51307. ps[4] = tmp2;
  51308. ps[7] = pi + 4;
  51309. ps[0] = tmp1;
  51310. ps[1] = pi + 7;
  51311. ps[2] = pi + 6;
  51312. ps[3] = pi + 5;
  51313. tmp1 = cs[2];
  51314. tmp2 = cs[3];
  51315. cs[2] = tmp2;
  51316. cs[3] = ci;
  51317. cs[0] = tmp1;
  51318. cs[1] = ci + 1;
  51319. break;
  51320. case 2:
  51321. tmp1 = ps[15];
  51322. tmp2 = ps[11];
  51323. ps[12] = ps[3];
  51324. ps[13] = pi + 0;
  51325. ps[14] = pi + 1;
  51326. ps[15] = pi + 2;
  51327. ps[8] = ps[7];
  51328. ps[11] = pi + 3;
  51329. ps[4] = tmp2;
  51330. ps[7] = pi + 4;
  51331. ps[0] = tmp1;
  51332. ps[1] = pi + 7;
  51333. ps[2] = pi + 6;
  51334. ps[3] = pi + 5;
  51335. tmp1 = cs[3];
  51336. cs[2] = cs[1];
  51337. cs[3] = ci;
  51338. cs[0] = tmp1;
  51339. cs[1] = ci + 1;
  51340. break;
  51341. case 3:
  51342. ps[12] = ps[0];
  51343. ps[13] = pi + 0;
  51344. ps[14] = pi + 1;
  51345. ps[15] = pi + 2;
  51346. ps[8] = ps[1];
  51347. ps[11] = pi + 3;
  51348. ps[4] = ps[2];
  51349. ps[7] = pi + 4;
  51350. ps[0] = ps[3];
  51351. ps[1] = pi + 7;
  51352. ps[2] = pi + 6;
  51353. ps[3] = pi + 5;
  51354. cs[2] = cs[0];
  51355. cs[3] = ci;
  51356. cs[0] = cs[1];
  51357. cs[1] = ci + 1;
  51358. break;
  51359. }
  51360. ps[5] = coords.length;
  51361. coords.push([
  51362. (-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,
  51363. (-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
  51364. ]);
  51365. ps[6] = coords.length;
  51366. coords.push([
  51367. (-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,
  51368. (-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
  51369. ]);
  51370. ps[9] = coords.length;
  51371. coords.push([
  51372. (-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,
  51373. (-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
  51374. ]);
  51375. ps[10] = coords.length;
  51376. coords.push([
  51377. (-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,
  51378. (-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
  51379. ]);
  51380. mesh.figures.push({
  51381. type: 'patch',
  51382. coords: new Int32Array(ps),
  51383. colors: new Int32Array(cs)
  51384. });
  51385. }
  51386. }
  51387. function decodeType7Shading(mesh, reader) {
  51388. var coords = mesh.coords;
  51389. var colors = mesh.colors;
  51390. var ps = new Int32Array(16);
  51391. var cs = new Int32Array(4);
  51392. while (reader.hasData) {
  51393. var f = reader.readFlag();
  51394. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51395. var i, ii;
  51396. var pi = coords.length;
  51397. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51398. coords.push(reader.readCoordinate());
  51399. }
  51400. var ci = colors.length;
  51401. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51402. colors.push(reader.readComponents());
  51403. }
  51404. var tmp1, tmp2, tmp3, tmp4;
  51405. switch (f) {
  51406. case 0:
  51407. ps[12] = pi + 3;
  51408. ps[13] = pi + 4;
  51409. ps[14] = pi + 5;
  51410. ps[15] = pi + 6;
  51411. ps[8] = pi + 2;
  51412. ps[9] = pi + 13;
  51413. ps[10] = pi + 14;
  51414. ps[11] = pi + 7;
  51415. ps[4] = pi + 1;
  51416. ps[5] = pi + 12;
  51417. ps[6] = pi + 15;
  51418. ps[7] = pi + 8;
  51419. ps[0] = pi;
  51420. ps[1] = pi + 11;
  51421. ps[2] = pi + 10;
  51422. ps[3] = pi + 9;
  51423. cs[2] = ci + 1;
  51424. cs[3] = ci + 2;
  51425. cs[0] = ci;
  51426. cs[1] = ci + 3;
  51427. break;
  51428. case 1:
  51429. tmp1 = ps[12];
  51430. tmp2 = ps[13];
  51431. tmp3 = ps[14];
  51432. tmp4 = ps[15];
  51433. ps[12] = tmp4;
  51434. ps[13] = pi + 0;
  51435. ps[14] = pi + 1;
  51436. ps[15] = pi + 2;
  51437. ps[8] = tmp3;
  51438. ps[9] = pi + 9;
  51439. ps[10] = pi + 10;
  51440. ps[11] = pi + 3;
  51441. ps[4] = tmp2;
  51442. ps[5] = pi + 8;
  51443. ps[6] = pi + 11;
  51444. ps[7] = pi + 4;
  51445. ps[0] = tmp1;
  51446. ps[1] = pi + 7;
  51447. ps[2] = pi + 6;
  51448. ps[3] = pi + 5;
  51449. tmp1 = cs[2];
  51450. tmp2 = cs[3];
  51451. cs[2] = tmp2;
  51452. cs[3] = ci;
  51453. cs[0] = tmp1;
  51454. cs[1] = ci + 1;
  51455. break;
  51456. case 2:
  51457. tmp1 = ps[15];
  51458. tmp2 = ps[11];
  51459. ps[12] = ps[3];
  51460. ps[13] = pi + 0;
  51461. ps[14] = pi + 1;
  51462. ps[15] = pi + 2;
  51463. ps[8] = ps[7];
  51464. ps[9] = pi + 9;
  51465. ps[10] = pi + 10;
  51466. ps[11] = pi + 3;
  51467. ps[4] = tmp2;
  51468. ps[5] = pi + 8;
  51469. ps[6] = pi + 11;
  51470. ps[7] = pi + 4;
  51471. ps[0] = tmp1;
  51472. ps[1] = pi + 7;
  51473. ps[2] = pi + 6;
  51474. ps[3] = pi + 5;
  51475. tmp1 = cs[3];
  51476. cs[2] = cs[1];
  51477. cs[3] = ci;
  51478. cs[0] = tmp1;
  51479. cs[1] = ci + 1;
  51480. break;
  51481. case 3:
  51482. ps[12] = ps[0];
  51483. ps[13] = pi + 0;
  51484. ps[14] = pi + 1;
  51485. ps[15] = pi + 2;
  51486. ps[8] = ps[1];
  51487. ps[9] = pi + 9;
  51488. ps[10] = pi + 10;
  51489. ps[11] = pi + 3;
  51490. ps[4] = ps[2];
  51491. ps[5] = pi + 8;
  51492. ps[6] = pi + 11;
  51493. ps[7] = pi + 4;
  51494. ps[0] = ps[3];
  51495. ps[1] = pi + 7;
  51496. ps[2] = pi + 6;
  51497. ps[3] = pi + 5;
  51498. cs[2] = cs[0];
  51499. cs[3] = ci;
  51500. cs[0] = cs[1];
  51501. cs[1] = ci + 1;
  51502. break;
  51503. }
  51504. mesh.figures.push({
  51505. type: 'patch',
  51506. coords: new Int32Array(ps),
  51507. colors: new Int32Array(cs)
  51508. });
  51509. }
  51510. }
  51511. function updateBounds(mesh) {
  51512. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51513. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51514. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51515. minX = minX > x ? x : minX;
  51516. minY = minY > y ? y : minY;
  51517. maxX = maxX < x ? x : maxX;
  51518. maxY = maxY < y ? y : maxY;
  51519. }
  51520. mesh.bounds = [
  51521. minX,
  51522. minY,
  51523. maxX,
  51524. maxY
  51525. ];
  51526. }
  51527. function packData(mesh) {
  51528. var i, ii, j, jj;
  51529. var coords = mesh.coords;
  51530. var coordsPacked = new Float32Array(coords.length * 2);
  51531. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51532. var xy = coords[i];
  51533. coordsPacked[j++] = xy[0];
  51534. coordsPacked[j++] = xy[1];
  51535. }
  51536. mesh.coords = coordsPacked;
  51537. var colors = mesh.colors;
  51538. var colorsPacked = new Uint8Array(colors.length * 3);
  51539. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51540. var c = colors[i];
  51541. colorsPacked[j++] = c[0];
  51542. colorsPacked[j++] = c[1];
  51543. colorsPacked[j++] = c[2];
  51544. }
  51545. mesh.colors = colorsPacked;
  51546. var figures = mesh.figures;
  51547. for (i = 0, ii = figures.length; i < ii; i++) {
  51548. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51549. for (j = 0, jj = ps.length; j < jj; j++) {
  51550. ps[j] *= 2;
  51551. cs[j] *= 3;
  51552. }
  51553. }
  51554. }
  51555. function Mesh(stream, matrix, xref, res) {
  51556. assert(isStream(stream), 'Mesh data is not a stream');
  51557. var dict = stream.dict;
  51558. this.matrix = matrix;
  51559. this.shadingType = dict.get('ShadingType');
  51560. this.type = 'Pattern';
  51561. this.bbox = dict.getArray('BBox');
  51562. var cs = dict.get('ColorSpace', 'CS');
  51563. cs = ColorSpace.parse(cs, xref, res);
  51564. this.cs = cs;
  51565. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51566. var fnObj = dict.get('Function');
  51567. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51568. this.coords = [];
  51569. this.colors = [];
  51570. this.figures = [];
  51571. var decodeContext = {
  51572. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51573. bitsPerComponent: dict.get('BitsPerComponent'),
  51574. bitsPerFlag: dict.get('BitsPerFlag'),
  51575. decode: dict.getArray('Decode'),
  51576. colorFn: fn,
  51577. colorSpace: cs,
  51578. numComps: fn ? 1 : cs.numComps
  51579. };
  51580. var reader = new MeshStreamReader(stream, decodeContext);
  51581. var patchMesh = false;
  51582. switch (this.shadingType) {
  51583. case ShadingType.FREE_FORM_MESH:
  51584. decodeType4Shading(this, reader);
  51585. break;
  51586. case ShadingType.LATTICE_FORM_MESH:
  51587. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51588. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51589. decodeType5Shading(this, reader, verticesPerRow);
  51590. break;
  51591. case ShadingType.COONS_PATCH_MESH:
  51592. decodeType6Shading(this, reader);
  51593. patchMesh = true;
  51594. break;
  51595. case ShadingType.TENSOR_PATCH_MESH:
  51596. decodeType7Shading(this, reader);
  51597. patchMesh = true;
  51598. break;
  51599. default:
  51600. error('Unsupported mesh type.');
  51601. break;
  51602. }
  51603. if (patchMesh) {
  51604. updateBounds(this);
  51605. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51606. buildFigureFromPatch(this, i);
  51607. }
  51608. }
  51609. updateBounds(this);
  51610. packData(this);
  51611. }
  51612. Mesh.prototype = {
  51613. getIR: function Mesh_getIR() {
  51614. return [
  51615. 'Mesh',
  51616. this.shadingType,
  51617. this.coords,
  51618. this.colors,
  51619. this.figures,
  51620. this.bounds,
  51621. this.matrix,
  51622. this.bbox,
  51623. this.background
  51624. ];
  51625. }
  51626. };
  51627. return Mesh;
  51628. }();
  51629. Shadings.Dummy = function DummyClosure() {
  51630. function Dummy() {
  51631. this.type = 'Pattern';
  51632. }
  51633. Dummy.prototype = {
  51634. getIR: function Dummy_getIR() {
  51635. return ['Dummy'];
  51636. }
  51637. };
  51638. return Dummy;
  51639. }();
  51640. function getTilingPatternIR(operatorList, dict, args) {
  51641. var matrix = dict.getArray('Matrix');
  51642. var bbox = dict.getArray('BBox');
  51643. var xstep = dict.get('XStep');
  51644. var ystep = dict.get('YStep');
  51645. var paintType = dict.get('PaintType');
  51646. var tilingType = dict.get('TilingType');
  51647. return [
  51648. 'TilingPattern',
  51649. args,
  51650. operatorList,
  51651. matrix,
  51652. bbox,
  51653. xstep,
  51654. ystep,
  51655. paintType,
  51656. tilingType
  51657. ];
  51658. }
  51659. exports.Pattern = Pattern;
  51660. exports.getTilingPatternIR = getTilingPatternIR;
  51661. }));
  51662. (function (root, factory) {
  51663. 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);
  51664. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51665. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51666. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51667. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51668. var ImageKind = sharedUtil.ImageKind;
  51669. var OPS = sharedUtil.OPS;
  51670. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51671. var Util = sharedUtil.Util;
  51672. var assert = sharedUtil.assert;
  51673. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51674. var error = sharedUtil.error;
  51675. var info = sharedUtil.info;
  51676. var isArray = sharedUtil.isArray;
  51677. var isNum = sharedUtil.isNum;
  51678. var isString = sharedUtil.isString;
  51679. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51680. var warn = sharedUtil.warn;
  51681. var Dict = corePrimitives.Dict;
  51682. var Name = corePrimitives.Name;
  51683. var isCmd = corePrimitives.isCmd;
  51684. var isDict = corePrimitives.isDict;
  51685. var isName = corePrimitives.isName;
  51686. var isRef = corePrimitives.isRef;
  51687. var isStream = corePrimitives.isStream;
  51688. var DecodeStream = coreStream.DecodeStream;
  51689. var JpegStream = coreStream.JpegStream;
  51690. var Stream = coreStream.Stream;
  51691. var Lexer = coreParser.Lexer;
  51692. var Parser = coreParser.Parser;
  51693. var isEOF = coreParser.isEOF;
  51694. var PDFImage = coreImage.PDFImage;
  51695. var ColorSpace = coreColorSpace.ColorSpace;
  51696. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51697. var ErrorFont = coreFonts.ErrorFont;
  51698. var FontFlags = coreFonts.FontFlags;
  51699. var Font = coreFonts.Font;
  51700. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51701. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51702. var getFontType = coreFonts.getFontType;
  51703. var isPDFFunction = coreFunction.isPDFFunction;
  51704. var PDFFunction = coreFunction.PDFFunction;
  51705. var Pattern = corePattern.Pattern;
  51706. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51707. var CMapFactory = coreCMap.CMapFactory;
  51708. var IdentityCMap = coreCMap.IdentityCMap;
  51709. var getMetrics = coreMetrics.getMetrics;
  51710. var bidi = coreBidi.bidi;
  51711. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51712. var StandardEncoding = coreEncodings.StandardEncoding;
  51713. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51714. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51715. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51716. var getEncoding = coreEncodings.getEncoding;
  51717. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51718. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51719. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51720. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51721. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51722. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51723. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51724. var PartialEvaluator = function PartialEvaluatorClosure() {
  51725. var DefaultPartialEvaluatorOptions = {
  51726. forceDataSchema: false,
  51727. maxImageSize: -1,
  51728. disableFontFace: false,
  51729. cMapOptions: {
  51730. url: null,
  51731. packed: false
  51732. }
  51733. };
  51734. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51735. this.xref = xref;
  51736. this.resources = resources;
  51737. this.handler = handler;
  51738. this.forceDataSchema = forceDataSchema;
  51739. }
  51740. NativeImageDecoder.prototype = {
  51741. canDecode: function (image) {
  51742. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51743. },
  51744. decode: function (image) {
  51745. var dict = image.dict;
  51746. var colorSpace = dict.get('ColorSpace', 'CS');
  51747. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51748. var numComps = colorSpace.numComps;
  51749. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51750. image.getIR(this.forceDataSchema),
  51751. numComps
  51752. ]);
  51753. return decodePromise.then(function (message) {
  51754. var data = message.data;
  51755. return new Stream(data, 0, data.length, image.dict);
  51756. });
  51757. }
  51758. };
  51759. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51760. var dict = image.dict;
  51761. if (dict.has('DecodeParms') || dict.has('DP')) {
  51762. return false;
  51763. }
  51764. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51765. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51766. };
  51767. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51768. var dict = image.dict;
  51769. if (dict.has('DecodeParms') || dict.has('DP')) {
  51770. return false;
  51771. }
  51772. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51773. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51774. };
  51775. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  51776. this.pdfManager = pdfManager;
  51777. this.xref = xref;
  51778. this.handler = handler;
  51779. this.pageIndex = pageIndex;
  51780. this.idFactory = idFactory;
  51781. this.fontCache = fontCache;
  51782. this.options = options || DefaultPartialEvaluatorOptions;
  51783. }
  51784. var TIME_SLOT_DURATION_MS = 20;
  51785. var CHECK_TIME_EVERY = 100;
  51786. function TimeSlotManager() {
  51787. this.reset();
  51788. }
  51789. TimeSlotManager.prototype = {
  51790. check: function TimeSlotManager_check() {
  51791. if (++this.checked < CHECK_TIME_EVERY) {
  51792. return false;
  51793. }
  51794. this.checked = 0;
  51795. return this.endTime <= Date.now();
  51796. },
  51797. reset: function TimeSlotManager_reset() {
  51798. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51799. this.checked = 0;
  51800. }
  51801. };
  51802. var deferred = Promise.resolve();
  51803. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51804. PartialEvaluator.prototype = {
  51805. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51806. if (!isDict(resources)) {
  51807. return false;
  51808. }
  51809. var processed = Object.create(null);
  51810. if (resources.objId) {
  51811. processed[resources.objId] = true;
  51812. }
  51813. var nodes = [resources], xref = this.xref;
  51814. while (nodes.length) {
  51815. var key, i, ii;
  51816. var node = nodes.shift();
  51817. var graphicStates = node.get('ExtGState');
  51818. if (isDict(graphicStates)) {
  51819. var graphicStatesKeys = graphicStates.getKeys();
  51820. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51821. key = graphicStatesKeys[i];
  51822. var graphicState = graphicStates.get(key);
  51823. var bm = graphicState.get('BM');
  51824. if (isName(bm) && bm.name !== 'Normal') {
  51825. return true;
  51826. }
  51827. }
  51828. }
  51829. var xObjects = node.get('XObject');
  51830. if (!isDict(xObjects)) {
  51831. continue;
  51832. }
  51833. var xObjectsKeys = xObjects.getKeys();
  51834. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51835. key = xObjectsKeys[i];
  51836. var xObject = xObjects.getRaw(key);
  51837. if (isRef(xObject)) {
  51838. if (processed[xObject.toString()]) {
  51839. continue;
  51840. }
  51841. xObject = xref.fetch(xObject);
  51842. }
  51843. if (!isStream(xObject)) {
  51844. continue;
  51845. }
  51846. if (xObject.dict.objId) {
  51847. if (processed[xObject.dict.objId]) {
  51848. continue;
  51849. }
  51850. processed[xObject.dict.objId] = true;
  51851. }
  51852. var xResources = xObject.dict.get('Resources');
  51853. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51854. nodes.push(xResources);
  51855. if (xResources.objId) {
  51856. processed[xResources.objId] = true;
  51857. }
  51858. }
  51859. }
  51860. }
  51861. return false;
  51862. },
  51863. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51864. var matrix = xobj.dict.getArray('Matrix');
  51865. var bbox = xobj.dict.getArray('BBox');
  51866. var group = xobj.dict.get('Group');
  51867. if (group) {
  51868. var groupOptions = {
  51869. matrix: matrix,
  51870. bbox: bbox,
  51871. smask: smask,
  51872. isolated: false,
  51873. knockout: false
  51874. };
  51875. var groupSubtype = group.get('S');
  51876. var colorSpace;
  51877. if (isName(groupSubtype, 'Transparency')) {
  51878. groupOptions.isolated = group.get('I') || false;
  51879. groupOptions.knockout = group.get('K') || false;
  51880. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51881. }
  51882. if (smask && smask.backdrop) {
  51883. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51884. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51885. }
  51886. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51887. }
  51888. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51889. matrix,
  51890. bbox
  51891. ]);
  51892. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51893. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51894. if (group) {
  51895. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51896. }
  51897. });
  51898. },
  51899. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51900. var self = this;
  51901. var dict = image.dict;
  51902. var w = dict.get('Width', 'W');
  51903. var h = dict.get('Height', 'H');
  51904. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51905. warn('Image dimensions are missing, or not numbers.');
  51906. return;
  51907. }
  51908. var maxImageSize = this.options.maxImageSize;
  51909. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51910. warn('Image exceeded maximum allowed size and was removed.');
  51911. return;
  51912. }
  51913. var imageMask = dict.get('ImageMask', 'IM') || false;
  51914. var imgData, args;
  51915. if (imageMask) {
  51916. var width = dict.get('Width', 'W');
  51917. var height = dict.get('Height', 'H');
  51918. var bitStrideLength = width + 7 >> 3;
  51919. var imgArray = image.getBytes(bitStrideLength * height);
  51920. var decode = dict.getArray('Decode', 'D');
  51921. var inverseDecode = !!decode && decode[0] > 0;
  51922. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51923. imgData.cached = true;
  51924. args = [imgData];
  51925. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51926. if (cacheKey) {
  51927. imageCache[cacheKey] = {
  51928. fn: OPS.paintImageMaskXObject,
  51929. args: args
  51930. };
  51931. }
  51932. return;
  51933. }
  51934. var softMask = dict.get('SMask', 'SM') || false;
  51935. var mask = dict.get('Mask') || false;
  51936. var SMALL_IMAGE_DIMENSIONS = 200;
  51937. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51938. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51939. imgData = imageObj.createImageData(true);
  51940. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51941. return;
  51942. }
  51943. var objId = 'img_' + this.idFactory.createObjId();
  51944. operatorList.addDependency(objId);
  51945. args = [
  51946. objId,
  51947. w,
  51948. h
  51949. ];
  51950. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51951. operatorList.addOp(OPS.paintJpegXObject, args);
  51952. this.handler.send('obj', [
  51953. objId,
  51954. this.pageIndex,
  51955. 'JpegStream',
  51956. image.getIR(this.options.forceDataSchema)
  51957. ]);
  51958. return;
  51959. }
  51960. var nativeImageDecoder = null;
  51961. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51962. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51963. }
  51964. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51965. var imgData = imageObj.createImageData(false);
  51966. self.handler.send('obj', [
  51967. objId,
  51968. self.pageIndex,
  51969. 'Image',
  51970. imgData
  51971. ], [imgData.data.buffer]);
  51972. }).then(undefined, function (reason) {
  51973. warn('Unable to decode image: ' + reason);
  51974. self.handler.send('obj', [
  51975. objId,
  51976. self.pageIndex,
  51977. 'Image',
  51978. null
  51979. ]);
  51980. });
  51981. operatorList.addOp(OPS.paintImageXObject, args);
  51982. if (cacheKey) {
  51983. imageCache[cacheKey] = {
  51984. fn: OPS.paintImageXObject,
  51985. args: args
  51986. };
  51987. }
  51988. },
  51989. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51990. var smaskContent = smask.get('G');
  51991. var smaskOptions = {
  51992. subtype: smask.get('S').name,
  51993. backdrop: smask.get('BC')
  51994. };
  51995. var transferObj = smask.get('TR');
  51996. if (isPDFFunction(transferObj)) {
  51997. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51998. var transferMap = new Uint8Array(256);
  51999. var tmp = new Float32Array(1);
  52000. for (var i = 0; i < 256; i++) {
  52001. tmp[0] = i / 255;
  52002. transferFn(tmp, 0, tmp, 0);
  52003. transferMap[i] = tmp[0] * 255 | 0;
  52004. }
  52005. smaskOptions.transferMap = transferMap;
  52006. }
  52007. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  52008. },
  52009. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  52010. var tilingOpList = new OperatorList();
  52011. var resourcesArray = [
  52012. patternDict.get('Resources'),
  52013. resources
  52014. ];
  52015. var patternResources = Dict.merge(this.xref, resourcesArray);
  52016. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  52017. operatorList.addDependencies(tilingOpList.dependencies);
  52018. operatorList.addOp(fn, getTilingPatternIR({
  52019. fnArray: tilingOpList.fnArray,
  52020. argsArray: tilingOpList.argsArray
  52021. }, patternDict, args));
  52022. });
  52023. },
  52024. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  52025. var fontName;
  52026. if (fontArgs) {
  52027. fontArgs = fontArgs.slice();
  52028. fontName = fontArgs[0].name;
  52029. }
  52030. var self = this;
  52031. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  52032. if (!translated.font.isType3Font) {
  52033. return translated;
  52034. }
  52035. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  52036. return translated;
  52037. }, function (reason) {
  52038. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52039. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  52040. });
  52041. }).then(function (translated) {
  52042. state.font = translated.font;
  52043. translated.send(self.handler);
  52044. return translated.loadedName;
  52045. });
  52046. },
  52047. handleText: function PartialEvaluator_handleText(chars, state) {
  52048. var font = state.font;
  52049. var glyphs = font.charsToGlyphs(chars);
  52050. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  52051. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  52052. var buildPath = function (fontChar) {
  52053. if (!font.renderer.hasBuiltPath(fontChar)) {
  52054. var path = font.renderer.getPathJs(fontChar);
  52055. this.handler.send('commonobj', [
  52056. font.loadedName + '_path_' + fontChar,
  52057. 'FontPath',
  52058. path
  52059. ]);
  52060. }
  52061. }.bind(this);
  52062. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  52063. var glyph = glyphs[i];
  52064. buildPath(glyph.fontChar);
  52065. var accent = glyph.accent;
  52066. if (accent && accent.fontChar) {
  52067. buildPath(accent.fontChar);
  52068. }
  52069. }
  52070. }
  52071. return glyphs;
  52072. },
  52073. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  52074. var gStateObj = [];
  52075. var gStateKeys = gState.getKeys();
  52076. var self = this;
  52077. var promise = Promise.resolve();
  52078. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  52079. var key = gStateKeys[i];
  52080. var value = gState.get(key);
  52081. switch (key) {
  52082. case 'Type':
  52083. break;
  52084. case 'LW':
  52085. case 'LC':
  52086. case 'LJ':
  52087. case 'ML':
  52088. case 'D':
  52089. case 'RI':
  52090. case 'FL':
  52091. case 'CA':
  52092. case 'ca':
  52093. gStateObj.push([
  52094. key,
  52095. value
  52096. ]);
  52097. break;
  52098. case 'Font':
  52099. promise = promise.then(function () {
  52100. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  52101. operatorList.addDependency(loadedName);
  52102. gStateObj.push([
  52103. key,
  52104. [
  52105. loadedName,
  52106. value[1]
  52107. ]
  52108. ]);
  52109. });
  52110. });
  52111. break;
  52112. case 'BM':
  52113. gStateObj.push([
  52114. key,
  52115. value
  52116. ]);
  52117. break;
  52118. case 'SMask':
  52119. if (isName(value, 'None')) {
  52120. gStateObj.push([
  52121. key,
  52122. false
  52123. ]);
  52124. break;
  52125. }
  52126. if (isDict(value)) {
  52127. promise = promise.then(function (dict) {
  52128. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  52129. }.bind(this, value));
  52130. gStateObj.push([
  52131. key,
  52132. true
  52133. ]);
  52134. } else {
  52135. warn('Unsupported SMask type');
  52136. }
  52137. break;
  52138. case 'OP':
  52139. case 'op':
  52140. case 'OPM':
  52141. case 'BG':
  52142. case 'BG2':
  52143. case 'UCR':
  52144. case 'UCR2':
  52145. case 'TR':
  52146. case 'TR2':
  52147. case 'HT':
  52148. case 'SM':
  52149. case 'SA':
  52150. case 'AIS':
  52151. case 'TK':
  52152. info('graphic state operator ' + key);
  52153. break;
  52154. default:
  52155. info('Unknown graphic state operator ' + key);
  52156. break;
  52157. }
  52158. }
  52159. return promise.then(function () {
  52160. if (gStateObj.length > 0) {
  52161. operatorList.addOp(OPS.setGState, [gStateObj]);
  52162. }
  52163. });
  52164. },
  52165. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52166. function errorFont() {
  52167. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52168. }
  52169. var fontRef;
  52170. if (font) {
  52171. assert(isRef(font));
  52172. fontRef = font;
  52173. } else {
  52174. var fontRes = resources.get('Font');
  52175. if (fontRes) {
  52176. fontRef = fontRes.getRaw(fontName);
  52177. } else {
  52178. warn('fontRes not available');
  52179. return errorFont();
  52180. }
  52181. }
  52182. if (!fontRef) {
  52183. warn('fontRef not available');
  52184. return errorFont();
  52185. }
  52186. if (this.fontCache.has(fontRef)) {
  52187. return this.fontCache.get(fontRef);
  52188. }
  52189. font = xref.fetchIfRef(fontRef);
  52190. if (!isDict(font)) {
  52191. return errorFont();
  52192. }
  52193. if (font.translated) {
  52194. return font.translated;
  52195. }
  52196. var fontCapability = createPromiseCapability();
  52197. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52198. var descriptor = preEvaluatedFont.descriptor;
  52199. var fontRefIsRef = isRef(fontRef), fontID;
  52200. if (fontRefIsRef) {
  52201. fontID = fontRef.toString();
  52202. }
  52203. if (isDict(descriptor)) {
  52204. if (!descriptor.fontAliases) {
  52205. descriptor.fontAliases = Object.create(null);
  52206. }
  52207. var fontAliases = descriptor.fontAliases;
  52208. var hash = preEvaluatedFont.hash;
  52209. if (fontAliases[hash]) {
  52210. var aliasFontRef = fontAliases[hash].aliasRef;
  52211. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52212. this.fontCache.putAlias(fontRef, aliasFontRef);
  52213. return this.fontCache.get(fontRef);
  52214. }
  52215. } else {
  52216. fontAliases[hash] = { fontID: Font.getFontID() };
  52217. }
  52218. if (fontRefIsRef) {
  52219. fontAliases[hash].aliasRef = fontRef;
  52220. }
  52221. fontID = fontAliases[hash].fontID;
  52222. }
  52223. if (fontRefIsRef) {
  52224. this.fontCache.put(fontRef, fontCapability.promise);
  52225. } else {
  52226. if (!fontID) {
  52227. fontID = this.idFactory.createObjId();
  52228. }
  52229. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52230. }
  52231. assert(fontID, 'The "fontID" must be defined.');
  52232. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52233. font.translated = fontCapability.promise;
  52234. var translatedPromise;
  52235. try {
  52236. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52237. } catch (e) {
  52238. translatedPromise = Promise.reject(e);
  52239. }
  52240. var self = this;
  52241. translatedPromise.then(function (translatedFont) {
  52242. if (translatedFont.fontType !== undefined) {
  52243. var xrefFontStats = xref.stats.fontTypes;
  52244. xrefFontStats[translatedFont.fontType] = true;
  52245. }
  52246. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52247. }, function (reason) {
  52248. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52249. try {
  52250. var descriptor = preEvaluatedFont.descriptor;
  52251. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52252. var subtype = fontFile3 && fontFile3.get('Subtype');
  52253. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52254. var xrefFontStats = xref.stats.fontTypes;
  52255. xrefFontStats[fontType] = true;
  52256. } catch (ex) {
  52257. }
  52258. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52259. });
  52260. return fontCapability.promise;
  52261. },
  52262. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52263. var lastIndex = operatorList.length - 1;
  52264. if (!args) {
  52265. args = [];
  52266. }
  52267. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52268. operatorList.addOp(OPS.constructPath, [
  52269. [fn],
  52270. args
  52271. ]);
  52272. } else {
  52273. var opArgs = operatorList.argsArray[lastIndex];
  52274. opArgs[0].push(fn);
  52275. Array.prototype.push.apply(opArgs[1], args);
  52276. }
  52277. },
  52278. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52279. var patternName = args[args.length - 1];
  52280. var pattern;
  52281. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52282. var dict = isStream(pattern) ? pattern.dict : pattern;
  52283. var typeNum = dict.get('PatternType');
  52284. if (typeNum === TILING_PATTERN) {
  52285. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52286. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52287. } else if (typeNum === SHADING_PATTERN) {
  52288. var shading = dict.get('Shading');
  52289. var matrix = dict.getArray('Matrix');
  52290. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52291. operatorList.addOp(fn, pattern.getIR());
  52292. return Promise.resolve();
  52293. }
  52294. return Promise.reject('Unknown PatternType: ' + typeNum);
  52295. }
  52296. operatorList.addOp(fn, args);
  52297. return Promise.resolve();
  52298. },
  52299. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52300. var self = this;
  52301. var xref = this.xref;
  52302. var imageCache = Object.create(null);
  52303. assert(operatorList);
  52304. resources = resources || Dict.empty;
  52305. var xobjs = resources.get('XObject') || Dict.empty;
  52306. var patterns = resources.get('Pattern') || Dict.empty;
  52307. var stateManager = new StateManager(initialState || new EvalState());
  52308. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52309. var timeSlotManager = new TimeSlotManager();
  52310. return new Promise(function promiseBody(resolve, reject) {
  52311. var next = function (promise) {
  52312. promise.then(function () {
  52313. try {
  52314. promiseBody(resolve, reject);
  52315. } catch (ex) {
  52316. reject(ex);
  52317. }
  52318. }, reject);
  52319. };
  52320. task.ensureNotTerminated();
  52321. timeSlotManager.reset();
  52322. var stop, operation = {}, i, ii, cs;
  52323. while (!(stop = timeSlotManager.check())) {
  52324. operation.args = null;
  52325. if (!preprocessor.read(operation)) {
  52326. break;
  52327. }
  52328. var args = operation.args;
  52329. var fn = operation.fn;
  52330. switch (fn | 0) {
  52331. case OPS.paintXObject:
  52332. if (args[0].code) {
  52333. break;
  52334. }
  52335. var name = args[0].name;
  52336. if (!name) {
  52337. warn('XObject must be referred to by name.');
  52338. continue;
  52339. }
  52340. if (imageCache[name] !== undefined) {
  52341. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52342. args = null;
  52343. continue;
  52344. }
  52345. var xobj = xobjs.get(name);
  52346. if (xobj) {
  52347. assert(isStream(xobj), 'XObject should be a stream');
  52348. var type = xobj.dict.get('Subtype');
  52349. assert(isName(type), 'XObject should have a Name subtype');
  52350. if (type.name === 'Form') {
  52351. stateManager.save();
  52352. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52353. stateManager.restore();
  52354. }));
  52355. return;
  52356. } else if (type.name === 'Image') {
  52357. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52358. args = null;
  52359. continue;
  52360. } else if (type.name === 'PS') {
  52361. info('Ignored XObject subtype PS');
  52362. continue;
  52363. } else {
  52364. error('Unhandled XObject subtype ' + type.name);
  52365. }
  52366. }
  52367. break;
  52368. case OPS.setFont:
  52369. var fontSize = args[1];
  52370. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52371. operatorList.addDependency(loadedName);
  52372. operatorList.addOp(OPS.setFont, [
  52373. loadedName,
  52374. fontSize
  52375. ]);
  52376. }));
  52377. return;
  52378. case OPS.endInlineImage:
  52379. var cacheKey = args[0].cacheKey;
  52380. if (cacheKey) {
  52381. var cacheEntry = imageCache[cacheKey];
  52382. if (cacheEntry !== undefined) {
  52383. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52384. args = null;
  52385. continue;
  52386. }
  52387. }
  52388. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52389. args = null;
  52390. continue;
  52391. case OPS.showText:
  52392. args[0] = self.handleText(args[0], stateManager.state);
  52393. break;
  52394. case OPS.showSpacedText:
  52395. var arr = args[0];
  52396. var combinedGlyphs = [];
  52397. var arrLength = arr.length;
  52398. var state = stateManager.state;
  52399. for (i = 0; i < arrLength; ++i) {
  52400. var arrItem = arr[i];
  52401. if (isString(arrItem)) {
  52402. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52403. } else if (isNum(arrItem)) {
  52404. combinedGlyphs.push(arrItem);
  52405. }
  52406. }
  52407. args[0] = combinedGlyphs;
  52408. fn = OPS.showText;
  52409. break;
  52410. case OPS.nextLineShowText:
  52411. operatorList.addOp(OPS.nextLine);
  52412. args[0] = self.handleText(args[0], stateManager.state);
  52413. fn = OPS.showText;
  52414. break;
  52415. case OPS.nextLineSetSpacingShowText:
  52416. operatorList.addOp(OPS.nextLine);
  52417. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52418. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52419. args[0] = self.handleText(args[0], stateManager.state);
  52420. fn = OPS.showText;
  52421. break;
  52422. case OPS.setTextRenderingMode:
  52423. stateManager.state.textRenderingMode = args[0];
  52424. break;
  52425. case OPS.setFillColorSpace:
  52426. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52427. continue;
  52428. case OPS.setStrokeColorSpace:
  52429. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52430. continue;
  52431. case OPS.setFillColor:
  52432. cs = stateManager.state.fillColorSpace;
  52433. args = cs.getRgb(args, 0);
  52434. fn = OPS.setFillRGBColor;
  52435. break;
  52436. case OPS.setStrokeColor:
  52437. cs = stateManager.state.strokeColorSpace;
  52438. args = cs.getRgb(args, 0);
  52439. fn = OPS.setStrokeRGBColor;
  52440. break;
  52441. case OPS.setFillGray:
  52442. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52443. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52444. fn = OPS.setFillRGBColor;
  52445. break;
  52446. case OPS.setStrokeGray:
  52447. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52448. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52449. fn = OPS.setStrokeRGBColor;
  52450. break;
  52451. case OPS.setFillCMYKColor:
  52452. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52453. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52454. fn = OPS.setFillRGBColor;
  52455. break;
  52456. case OPS.setStrokeCMYKColor:
  52457. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52458. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52459. fn = OPS.setStrokeRGBColor;
  52460. break;
  52461. case OPS.setFillRGBColor:
  52462. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52463. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52464. break;
  52465. case OPS.setStrokeRGBColor:
  52466. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52467. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52468. break;
  52469. case OPS.setFillColorN:
  52470. cs = stateManager.state.fillColorSpace;
  52471. if (cs.name === 'Pattern') {
  52472. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52473. return;
  52474. }
  52475. args = cs.getRgb(args, 0);
  52476. fn = OPS.setFillRGBColor;
  52477. break;
  52478. case OPS.setStrokeColorN:
  52479. cs = stateManager.state.strokeColorSpace;
  52480. if (cs.name === 'Pattern') {
  52481. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52482. return;
  52483. }
  52484. args = cs.getRgb(args, 0);
  52485. fn = OPS.setStrokeRGBColor;
  52486. break;
  52487. case OPS.shadingFill:
  52488. var shadingRes = resources.get('Shading');
  52489. if (!shadingRes) {
  52490. error('No shading resource found');
  52491. }
  52492. var shading = shadingRes.get(args[0].name);
  52493. if (!shading) {
  52494. error('No shading object found');
  52495. }
  52496. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52497. var patternIR = shadingFill.getIR();
  52498. args = [patternIR];
  52499. fn = OPS.shadingFill;
  52500. break;
  52501. case OPS.setGState:
  52502. var dictName = args[0];
  52503. var extGState = resources.get('ExtGState');
  52504. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52505. break;
  52506. }
  52507. var gState = extGState.get(dictName.name);
  52508. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52509. return;
  52510. case OPS.moveTo:
  52511. case OPS.lineTo:
  52512. case OPS.curveTo:
  52513. case OPS.curveTo2:
  52514. case OPS.curveTo3:
  52515. case OPS.closePath:
  52516. self.buildPath(operatorList, fn, args);
  52517. continue;
  52518. case OPS.rectangle:
  52519. self.buildPath(operatorList, fn, args);
  52520. continue;
  52521. case OPS.markPoint:
  52522. case OPS.markPointProps:
  52523. case OPS.beginMarkedContent:
  52524. case OPS.beginMarkedContentProps:
  52525. case OPS.endMarkedContent:
  52526. case OPS.beginCompat:
  52527. case OPS.endCompat:
  52528. continue;
  52529. default:
  52530. if (args !== null) {
  52531. for (i = 0, ii = args.length; i < ii; i++) {
  52532. if (args[i] instanceof Dict) {
  52533. break;
  52534. }
  52535. }
  52536. if (i < ii) {
  52537. warn('getOperatorList - ignoring operator: ' + fn);
  52538. continue;
  52539. }
  52540. }
  52541. }
  52542. operatorList.addOp(fn, args);
  52543. }
  52544. if (stop) {
  52545. next(deferred);
  52546. return;
  52547. }
  52548. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52549. operatorList.addOp(OPS.restore, []);
  52550. }
  52551. resolve();
  52552. });
  52553. },
  52554. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52555. stateManager = stateManager || new StateManager(new TextState());
  52556. var WhitespaceRegexp = /\s/g;
  52557. var textContent = {
  52558. items: [],
  52559. styles: Object.create(null)
  52560. };
  52561. var textContentItem = {
  52562. initialized: false,
  52563. str: [],
  52564. width: 0,
  52565. height: 0,
  52566. vertical: false,
  52567. lastAdvanceWidth: 0,
  52568. lastAdvanceHeight: 0,
  52569. textAdvanceScale: 0,
  52570. spaceWidth: 0,
  52571. fakeSpaceMin: Infinity,
  52572. fakeMultiSpaceMin: Infinity,
  52573. fakeMultiSpaceMax: -0,
  52574. textRunBreakAllowed: false,
  52575. transform: null,
  52576. fontName: null
  52577. };
  52578. var SPACE_FACTOR = 0.3;
  52579. var MULTI_SPACE_FACTOR = 1.5;
  52580. var MULTI_SPACE_FACTOR_MAX = 4;
  52581. var self = this;
  52582. var xref = this.xref;
  52583. resources = xref.fetchIfRef(resources) || Dict.empty;
  52584. var xobjs = null;
  52585. var xobjsCache = Object.create(null);
  52586. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52587. var textState;
  52588. function ensureTextContentItem() {
  52589. if (textContentItem.initialized) {
  52590. return textContentItem;
  52591. }
  52592. var font = textState.font;
  52593. if (!(font.loadedName in textContent.styles)) {
  52594. textContent.styles[font.loadedName] = {
  52595. fontFamily: font.fallbackName,
  52596. ascent: font.ascent,
  52597. descent: font.descent,
  52598. vertical: font.vertical
  52599. };
  52600. }
  52601. textContentItem.fontName = font.loadedName;
  52602. var tsm = [
  52603. textState.fontSize * textState.textHScale,
  52604. 0,
  52605. 0,
  52606. textState.fontSize,
  52607. 0,
  52608. textState.textRise
  52609. ];
  52610. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52611. var glyphHeight = font.bbox[3] - font.bbox[1];
  52612. if (glyphHeight > 0) {
  52613. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52614. tsm[3] *= glyphHeight;
  52615. }
  52616. }
  52617. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52618. textContentItem.transform = trm;
  52619. if (!font.vertical) {
  52620. textContentItem.width = 0;
  52621. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52622. textContentItem.vertical = false;
  52623. } else {
  52624. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52625. textContentItem.height = 0;
  52626. textContentItem.vertical = true;
  52627. }
  52628. var a = textState.textLineMatrix[0];
  52629. var b = textState.textLineMatrix[1];
  52630. var scaleLineX = Math.sqrt(a * a + b * b);
  52631. a = textState.ctm[0];
  52632. b = textState.ctm[1];
  52633. var scaleCtmX = Math.sqrt(a * a + b * b);
  52634. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52635. textContentItem.lastAdvanceWidth = 0;
  52636. textContentItem.lastAdvanceHeight = 0;
  52637. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52638. if (spaceWidth) {
  52639. textContentItem.spaceWidth = spaceWidth;
  52640. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52641. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52642. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52643. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52644. } else {
  52645. textContentItem.spaceWidth = 0;
  52646. textContentItem.fakeSpaceMin = Infinity;
  52647. textContentItem.fakeMultiSpaceMin = Infinity;
  52648. textContentItem.fakeMultiSpaceMax = 0;
  52649. textContentItem.textRunBreakAllowed = false;
  52650. }
  52651. textContentItem.initialized = true;
  52652. return textContentItem;
  52653. }
  52654. function replaceWhitespace(str) {
  52655. var i = 0, ii = str.length, code;
  52656. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52657. i++;
  52658. }
  52659. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52660. }
  52661. function runBidiTransform(textChunk) {
  52662. var str = textChunk.str.join('');
  52663. var bidiResult = bidi(str, -1, textChunk.vertical);
  52664. return {
  52665. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52666. dir: bidiResult.dir,
  52667. width: textChunk.width,
  52668. height: textChunk.height,
  52669. transform: textChunk.transform,
  52670. fontName: textChunk.fontName
  52671. };
  52672. }
  52673. function handleSetFont(fontName, fontRef) {
  52674. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52675. textState.font = translated.font;
  52676. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52677. });
  52678. }
  52679. function buildTextContentItem(chars) {
  52680. var font = textState.font;
  52681. var textChunk = ensureTextContentItem();
  52682. var width = 0;
  52683. var height = 0;
  52684. var glyphs = font.charsToGlyphs(chars);
  52685. var defaultVMetrics = font.defaultVMetrics;
  52686. for (var i = 0; i < glyphs.length; i++) {
  52687. var glyph = glyphs[i];
  52688. var vMetricX = null;
  52689. var vMetricY = null;
  52690. var glyphWidth = null;
  52691. if (font.vertical) {
  52692. if (glyph.vmetric) {
  52693. glyphWidth = glyph.vmetric[0];
  52694. vMetricX = glyph.vmetric[1];
  52695. vMetricY = glyph.vmetric[2];
  52696. } else {
  52697. glyphWidth = glyph.width;
  52698. vMetricX = glyph.width * 0.5;
  52699. vMetricY = defaultVMetrics[2];
  52700. }
  52701. } else {
  52702. glyphWidth = glyph.width;
  52703. }
  52704. var glyphUnicode = glyph.unicode;
  52705. var NormalizedUnicodes = getNormalizedUnicodes();
  52706. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52707. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52708. }
  52709. glyphUnicode = reverseIfRtl(glyphUnicode);
  52710. var charSpacing = textState.charSpacing;
  52711. if (glyph.isSpace) {
  52712. var wordSpacing = textState.wordSpacing;
  52713. charSpacing += wordSpacing;
  52714. if (wordSpacing > 0) {
  52715. addFakeSpaces(wordSpacing, textChunk.str);
  52716. }
  52717. }
  52718. var tx = 0;
  52719. var ty = 0;
  52720. if (!font.vertical) {
  52721. var w0 = glyphWidth * textState.fontMatrix[0];
  52722. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52723. width += tx;
  52724. } else {
  52725. var w1 = glyphWidth * textState.fontMatrix[0];
  52726. ty = w1 * textState.fontSize + charSpacing;
  52727. height += ty;
  52728. }
  52729. textState.translateTextMatrix(tx, ty);
  52730. textChunk.str.push(glyphUnicode);
  52731. }
  52732. if (!font.vertical) {
  52733. textChunk.lastAdvanceWidth = width;
  52734. textChunk.width += width;
  52735. } else {
  52736. textChunk.lastAdvanceHeight = height;
  52737. textChunk.height += Math.abs(height);
  52738. }
  52739. return textChunk;
  52740. }
  52741. function addFakeSpaces(width, strBuf) {
  52742. if (width < textContentItem.fakeSpaceMin) {
  52743. return;
  52744. }
  52745. if (width < textContentItem.fakeMultiSpaceMin) {
  52746. strBuf.push(' ');
  52747. return;
  52748. }
  52749. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52750. while (fakeSpaces-- > 0) {
  52751. strBuf.push(' ');
  52752. }
  52753. }
  52754. function flushTextContentItem() {
  52755. if (!textContentItem.initialized) {
  52756. return;
  52757. }
  52758. textContentItem.width *= textContentItem.textAdvanceScale;
  52759. textContentItem.height *= textContentItem.textAdvanceScale;
  52760. textContent.items.push(runBidiTransform(textContentItem));
  52761. textContentItem.initialized = false;
  52762. textContentItem.str.length = 0;
  52763. }
  52764. var timeSlotManager = new TimeSlotManager();
  52765. return new Promise(function promiseBody(resolve, reject) {
  52766. var next = function (promise) {
  52767. promise.then(function () {
  52768. try {
  52769. promiseBody(resolve, reject);
  52770. } catch (ex) {
  52771. reject(ex);
  52772. }
  52773. }, reject);
  52774. };
  52775. task.ensureNotTerminated();
  52776. timeSlotManager.reset();
  52777. var stop, operation = {}, args = [];
  52778. while (!(stop = timeSlotManager.check())) {
  52779. args.length = 0;
  52780. operation.args = args;
  52781. if (!preprocessor.read(operation)) {
  52782. break;
  52783. }
  52784. textState = stateManager.state;
  52785. var fn = operation.fn;
  52786. args = operation.args;
  52787. var advance, diff;
  52788. switch (fn | 0) {
  52789. case OPS.setFont:
  52790. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52791. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52792. break;
  52793. }
  52794. flushTextContentItem();
  52795. textState.fontName = fontNameArg;
  52796. textState.fontSize = fontSizeArg;
  52797. next(handleSetFont(fontNameArg, null));
  52798. return;
  52799. case OPS.setTextRise:
  52800. flushTextContentItem();
  52801. textState.textRise = args[0];
  52802. break;
  52803. case OPS.setHScale:
  52804. flushTextContentItem();
  52805. textState.textHScale = args[0] / 100;
  52806. break;
  52807. case OPS.setLeading:
  52808. flushTextContentItem();
  52809. textState.leading = args[0];
  52810. break;
  52811. case OPS.moveText:
  52812. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52813. advance = args[0] - args[1];
  52814. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52815. textState.translateTextLineMatrix(args[0], args[1]);
  52816. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52817. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52818. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52819. addFakeSpaces(diff, textContentItem.str);
  52820. break;
  52821. }
  52822. flushTextContentItem();
  52823. textState.translateTextLineMatrix(args[0], args[1]);
  52824. textState.textMatrix = textState.textLineMatrix.slice();
  52825. break;
  52826. case OPS.setLeadingMoveText:
  52827. flushTextContentItem();
  52828. textState.leading = -args[1];
  52829. textState.translateTextLineMatrix(args[0], args[1]);
  52830. textState.textMatrix = textState.textLineMatrix.slice();
  52831. break;
  52832. case OPS.nextLine:
  52833. flushTextContentItem();
  52834. textState.carriageReturn();
  52835. break;
  52836. case OPS.setTextMatrix:
  52837. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52838. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52839. textState.translateTextLineMatrix(advance.width, advance.height);
  52840. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52841. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52842. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52843. addFakeSpaces(diff, textContentItem.str);
  52844. break;
  52845. }
  52846. flushTextContentItem();
  52847. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52848. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52849. break;
  52850. case OPS.setCharSpacing:
  52851. textState.charSpacing = args[0];
  52852. break;
  52853. case OPS.setWordSpacing:
  52854. textState.wordSpacing = args[0];
  52855. break;
  52856. case OPS.beginText:
  52857. flushTextContentItem();
  52858. textState.textMatrix = IDENTITY_MATRIX.slice();
  52859. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52860. break;
  52861. case OPS.showSpacedText:
  52862. var items = args[0];
  52863. var offset;
  52864. for (var j = 0, jj = items.length; j < jj; j++) {
  52865. if (typeof items[j] === 'string') {
  52866. buildTextContentItem(items[j]);
  52867. } else if (isNum(items[j])) {
  52868. ensureTextContentItem();
  52869. advance = items[j] * textState.fontSize / 1000;
  52870. var breakTextRun = false;
  52871. if (textState.font.vertical) {
  52872. offset = advance;
  52873. textState.translateTextMatrix(0, offset);
  52874. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52875. if (!breakTextRun) {
  52876. textContentItem.height += offset;
  52877. }
  52878. } else {
  52879. advance = -advance;
  52880. offset = advance * textState.textHScale;
  52881. textState.translateTextMatrix(offset, 0);
  52882. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52883. if (!breakTextRun) {
  52884. textContentItem.width += offset;
  52885. }
  52886. }
  52887. if (breakTextRun) {
  52888. flushTextContentItem();
  52889. } else if (advance > 0) {
  52890. addFakeSpaces(advance, textContentItem.str);
  52891. }
  52892. }
  52893. }
  52894. break;
  52895. case OPS.showText:
  52896. buildTextContentItem(args[0]);
  52897. break;
  52898. case OPS.nextLineShowText:
  52899. flushTextContentItem();
  52900. textState.carriageReturn();
  52901. buildTextContentItem(args[0]);
  52902. break;
  52903. case OPS.nextLineSetSpacingShowText:
  52904. flushTextContentItem();
  52905. textState.wordSpacing = args[0];
  52906. textState.charSpacing = args[1];
  52907. textState.carriageReturn();
  52908. buildTextContentItem(args[2]);
  52909. break;
  52910. case OPS.paintXObject:
  52911. flushTextContentItem();
  52912. if (args[0].code) {
  52913. break;
  52914. }
  52915. if (!xobjs) {
  52916. xobjs = resources.get('XObject') || Dict.empty;
  52917. }
  52918. var name = args[0].name;
  52919. if (xobjsCache.key === name) {
  52920. if (xobjsCache.texts) {
  52921. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52922. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52923. }
  52924. break;
  52925. }
  52926. var xobj = xobjs.get(name);
  52927. if (!xobj) {
  52928. break;
  52929. }
  52930. assert(isStream(xobj), 'XObject should be a stream');
  52931. var type = xobj.dict.get('Subtype');
  52932. assert(isName(type), 'XObject should have a Name subtype');
  52933. if ('Form' !== type.name) {
  52934. xobjsCache.key = name;
  52935. xobjsCache.texts = null;
  52936. break;
  52937. }
  52938. stateManager.save();
  52939. var matrix = xobj.dict.getArray('Matrix');
  52940. if (isArray(matrix) && matrix.length === 6) {
  52941. stateManager.transform(matrix);
  52942. }
  52943. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52944. Util.appendToArray(textContent.items, formTextContent.items);
  52945. Util.extendObj(textContent.styles, formTextContent.styles);
  52946. stateManager.restore();
  52947. xobjsCache.key = name;
  52948. xobjsCache.texts = formTextContent;
  52949. }));
  52950. return;
  52951. case OPS.setGState:
  52952. flushTextContentItem();
  52953. var dictName = args[0];
  52954. var extGState = resources.get('ExtGState');
  52955. if (!isDict(extGState) || !isName(dictName)) {
  52956. break;
  52957. }
  52958. var gState = extGState.get(dictName.name);
  52959. if (!isDict(gState)) {
  52960. break;
  52961. }
  52962. var gStateFont = gState.get('Font');
  52963. if (gStateFont) {
  52964. textState.fontName = null;
  52965. textState.fontSize = gStateFont[1];
  52966. next(handleSetFont(null, gStateFont[0]));
  52967. return;
  52968. }
  52969. break;
  52970. }
  52971. }
  52972. if (stop) {
  52973. next(deferred);
  52974. return;
  52975. }
  52976. flushTextContentItem();
  52977. resolve(textContent);
  52978. });
  52979. },
  52980. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52981. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52982. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52983. if (properties.composite) {
  52984. var cidSystemInfo = dict.get('CIDSystemInfo');
  52985. if (isDict(cidSystemInfo)) {
  52986. properties.cidSystemInfo = {
  52987. registry: cidSystemInfo.get('Registry'),
  52988. ordering: cidSystemInfo.get('Ordering'),
  52989. supplement: cidSystemInfo.get('Supplement')
  52990. };
  52991. }
  52992. var cidToGidMap = dict.get('CIDToGIDMap');
  52993. if (isStream(cidToGidMap)) {
  52994. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52995. }
  52996. }
  52997. var differences = [];
  52998. var baseEncodingName = null;
  52999. var encoding;
  53000. if (dict.has('Encoding')) {
  53001. encoding = dict.get('Encoding');
  53002. if (isDict(encoding)) {
  53003. baseEncodingName = encoding.get('BaseEncoding');
  53004. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  53005. if (encoding.has('Differences')) {
  53006. var diffEncoding = encoding.get('Differences');
  53007. var index = 0;
  53008. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  53009. var data = xref.fetchIfRef(diffEncoding[j]);
  53010. if (isNum(data)) {
  53011. index = data;
  53012. } else if (isName(data)) {
  53013. differences[index++] = data.name;
  53014. } else {
  53015. error('Invalid entry in \'Differences\' array: ' + data);
  53016. }
  53017. }
  53018. }
  53019. } else if (isName(encoding)) {
  53020. baseEncodingName = encoding.name;
  53021. } else {
  53022. error('Encoding is not a Name nor a Dict');
  53023. }
  53024. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  53025. baseEncodingName = null;
  53026. }
  53027. }
  53028. if (baseEncodingName) {
  53029. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  53030. } else {
  53031. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  53032. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  53033. encoding = StandardEncoding;
  53034. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  53035. encoding = WinAnsiEncoding;
  53036. }
  53037. if (isSymbolicFont) {
  53038. encoding = MacRomanEncoding;
  53039. if (!properties.file) {
  53040. if (/Symbol/i.test(properties.name)) {
  53041. encoding = SymbolSetEncoding;
  53042. } else if (/Dingbats/i.test(properties.name)) {
  53043. encoding = ZapfDingbatsEncoding;
  53044. }
  53045. }
  53046. }
  53047. properties.defaultEncoding = encoding;
  53048. }
  53049. properties.differences = differences;
  53050. properties.baseEncodingName = baseEncodingName;
  53051. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  53052. properties.dict = dict;
  53053. return toUnicodePromise.then(function (toUnicode) {
  53054. properties.toUnicode = toUnicode;
  53055. return this.buildToUnicode(properties);
  53056. }.bind(this)).then(function (toUnicode) {
  53057. properties.toUnicode = toUnicode;
  53058. return properties;
  53059. });
  53060. },
  53061. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  53062. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  53063. if (properties.hasIncludedToUnicodeMap) {
  53064. return Promise.resolve(properties.toUnicode);
  53065. }
  53066. var toUnicode, charcode, glyphName;
  53067. if (!properties.composite)
  53068. {
  53069. toUnicode = [];
  53070. var encoding = properties.defaultEncoding.slice();
  53071. var baseEncodingName = properties.baseEncodingName;
  53072. var differences = properties.differences;
  53073. for (charcode in differences) {
  53074. glyphName = differences[charcode];
  53075. if (glyphName === '.notdef') {
  53076. continue;
  53077. }
  53078. encoding[charcode] = glyphName;
  53079. }
  53080. var glyphsUnicodeMap = getGlyphsUnicode();
  53081. for (charcode in encoding) {
  53082. glyphName = encoding[charcode];
  53083. if (glyphName === '') {
  53084. continue;
  53085. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  53086. var code = 0;
  53087. switch (glyphName[0]) {
  53088. case 'G':
  53089. if (glyphName.length === 3) {
  53090. code = parseInt(glyphName.substr(1), 16);
  53091. }
  53092. break;
  53093. case 'g':
  53094. if (glyphName.length === 5) {
  53095. code = parseInt(glyphName.substr(1), 16);
  53096. }
  53097. break;
  53098. case 'C':
  53099. case 'c':
  53100. if (glyphName.length >= 3) {
  53101. code = +glyphName.substr(1);
  53102. }
  53103. break;
  53104. default:
  53105. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  53106. if (unicode !== -1) {
  53107. code = unicode;
  53108. }
  53109. }
  53110. if (code) {
  53111. if (baseEncodingName && code === +charcode) {
  53112. var baseEncoding = getEncoding(baseEncodingName);
  53113. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  53114. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  53115. continue;
  53116. }
  53117. }
  53118. toUnicode[charcode] = String.fromCharCode(code);
  53119. }
  53120. continue;
  53121. }
  53122. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  53123. }
  53124. return Promise.resolve(new ToUnicodeMap(toUnicode));
  53125. }
  53126. 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'))) {
  53127. var registry = properties.cidSystemInfo.registry;
  53128. var ordering = properties.cidSystemInfo.ordering;
  53129. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  53130. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  53131. var cMap = properties.cMap;
  53132. toUnicode = [];
  53133. cMap.forEach(function (charcode, cid) {
  53134. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  53135. var ucs2 = ucs2CMap.lookup(cid);
  53136. if (ucs2) {
  53137. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  53138. }
  53139. });
  53140. return new ToUnicodeMap(toUnicode);
  53141. });
  53142. }
  53143. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  53144. },
  53145. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  53146. var cmapObj = toUnicode;
  53147. if (isName(cmapObj)) {
  53148. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53149. if (cmap instanceof IdentityCMap) {
  53150. return new IdentityToUnicodeMap(0, 0xFFFF);
  53151. }
  53152. return new ToUnicodeMap(cmap.getMap());
  53153. });
  53154. } else if (isStream(cmapObj)) {
  53155. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53156. if (cmap instanceof IdentityCMap) {
  53157. return new IdentityToUnicodeMap(0, 0xFFFF);
  53158. }
  53159. var map = new Array(cmap.length);
  53160. cmap.forEach(function (charCode, token) {
  53161. var str = [];
  53162. for (var k = 0; k < token.length; k += 2) {
  53163. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53164. if ((w1 & 0xF800) !== 0xD800) {
  53165. str.push(w1);
  53166. continue;
  53167. }
  53168. k += 2;
  53169. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53170. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53171. }
  53172. map[charCode] = String.fromCharCode.apply(String, str);
  53173. });
  53174. return new ToUnicodeMap(map);
  53175. });
  53176. }
  53177. return Promise.resolve(null);
  53178. },
  53179. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53180. var glyphsData = cidToGidStream.getBytes();
  53181. var result = [];
  53182. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53183. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53184. if (glyphID === 0) {
  53185. continue;
  53186. }
  53187. var code = j >> 1;
  53188. result[code] = glyphID;
  53189. }
  53190. return result;
  53191. },
  53192. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53193. var glyphsWidths = [];
  53194. var defaultWidth = 0;
  53195. var glyphsVMetrics = [];
  53196. var defaultVMetrics;
  53197. var i, ii, j, jj, start, code, widths;
  53198. if (properties.composite) {
  53199. defaultWidth = dict.get('DW') || 1000;
  53200. widths = dict.get('W');
  53201. if (widths) {
  53202. for (i = 0, ii = widths.length; i < ii; i++) {
  53203. start = xref.fetchIfRef(widths[i++]);
  53204. code = xref.fetchIfRef(widths[i]);
  53205. if (isArray(code)) {
  53206. for (j = 0, jj = code.length; j < jj; j++) {
  53207. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  53208. }
  53209. } else {
  53210. var width = xref.fetchIfRef(widths[++i]);
  53211. for (j = start; j <= code; j++) {
  53212. glyphsWidths[j] = width;
  53213. }
  53214. }
  53215. }
  53216. }
  53217. if (properties.vertical) {
  53218. var vmetrics = dict.getArray('DW2') || [
  53219. 880,
  53220. -1000
  53221. ];
  53222. defaultVMetrics = [
  53223. vmetrics[1],
  53224. defaultWidth * 0.5,
  53225. vmetrics[0]
  53226. ];
  53227. vmetrics = dict.get('W2');
  53228. if (vmetrics) {
  53229. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53230. start = xref.fetchIfRef(vmetrics[i++]);
  53231. code = xref.fetchIfRef(vmetrics[i]);
  53232. if (isArray(code)) {
  53233. for (j = 0, jj = code.length; j < jj; j++) {
  53234. glyphsVMetrics[start++] = [
  53235. xref.fetchIfRef(code[j++]),
  53236. xref.fetchIfRef(code[j++]),
  53237. xref.fetchIfRef(code[j])
  53238. ];
  53239. }
  53240. } else {
  53241. var vmetric = [
  53242. xref.fetchIfRef(vmetrics[++i]),
  53243. xref.fetchIfRef(vmetrics[++i]),
  53244. xref.fetchIfRef(vmetrics[++i])
  53245. ];
  53246. for (j = start; j <= code; j++) {
  53247. glyphsVMetrics[j] = vmetric;
  53248. }
  53249. }
  53250. }
  53251. }
  53252. }
  53253. } else {
  53254. var firstChar = properties.firstChar;
  53255. widths = dict.get('Widths');
  53256. if (widths) {
  53257. j = firstChar;
  53258. for (i = 0, ii = widths.length; i < ii; i++) {
  53259. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  53260. }
  53261. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53262. } else {
  53263. var baseFontName = dict.get('BaseFont');
  53264. if (isName(baseFontName)) {
  53265. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53266. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53267. defaultWidth = metrics.defaultWidth;
  53268. }
  53269. }
  53270. }
  53271. var isMonospace = true;
  53272. var firstWidth = defaultWidth;
  53273. for (var glyph in glyphsWidths) {
  53274. var glyphWidth = glyphsWidths[glyph];
  53275. if (!glyphWidth) {
  53276. continue;
  53277. }
  53278. if (!firstWidth) {
  53279. firstWidth = glyphWidth;
  53280. continue;
  53281. }
  53282. if (firstWidth !== glyphWidth) {
  53283. isMonospace = false;
  53284. break;
  53285. }
  53286. }
  53287. if (isMonospace) {
  53288. properties.flags |= FontFlags.FixedPitch;
  53289. }
  53290. properties.defaultWidth = defaultWidth;
  53291. properties.widths = glyphsWidths;
  53292. properties.defaultVMetrics = defaultVMetrics;
  53293. properties.vmetrics = glyphsVMetrics;
  53294. },
  53295. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53296. var fontNameWoStyle = baseFontName.split('-')[0];
  53297. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53298. },
  53299. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53300. var defaultWidth = 0;
  53301. var widths = [];
  53302. var monospace = false;
  53303. var stdFontMap = getStdFontMap();
  53304. var lookupName = stdFontMap[name] || name;
  53305. var Metrics = getMetrics();
  53306. if (!(lookupName in Metrics)) {
  53307. if (this.isSerifFont(name)) {
  53308. lookupName = 'Times-Roman';
  53309. } else {
  53310. lookupName = 'Helvetica';
  53311. }
  53312. }
  53313. var glyphWidths = Metrics[lookupName];
  53314. if (isNum(glyphWidths)) {
  53315. defaultWidth = glyphWidths;
  53316. monospace = true;
  53317. } else {
  53318. widths = glyphWidths();
  53319. }
  53320. return {
  53321. defaultWidth: defaultWidth,
  53322. monospace: monospace,
  53323. widths: widths
  53324. };
  53325. },
  53326. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53327. var widths = Object.create(null);
  53328. var differences = properties.differences;
  53329. var encoding = properties.defaultEncoding;
  53330. for (var charCode = 0; charCode < 256; charCode++) {
  53331. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53332. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53333. continue;
  53334. }
  53335. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53336. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53337. continue;
  53338. }
  53339. }
  53340. return widths;
  53341. },
  53342. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53343. var baseDict = dict;
  53344. var type = dict.get('Subtype');
  53345. assert(isName(type), 'invalid font Subtype');
  53346. var composite = false;
  53347. var uint8array;
  53348. if (type.name === 'Type0') {
  53349. var df = dict.get('DescendantFonts');
  53350. if (!df) {
  53351. error('Descendant fonts are not specified');
  53352. }
  53353. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53354. type = dict.get('Subtype');
  53355. assert(isName(type), 'invalid font Subtype');
  53356. composite = true;
  53357. }
  53358. var descriptor = dict.get('FontDescriptor');
  53359. if (descriptor) {
  53360. var hash = new MurmurHash3_64();
  53361. var encoding = baseDict.getRaw('Encoding');
  53362. if (isName(encoding)) {
  53363. hash.update(encoding.name);
  53364. } else if (isRef(encoding)) {
  53365. hash.update(encoding.toString());
  53366. } else if (isDict(encoding)) {
  53367. var keys = encoding.getKeys();
  53368. for (var i = 0, ii = keys.length; i < ii; i++) {
  53369. var entry = encoding.getRaw(keys[i]);
  53370. if (isName(entry)) {
  53371. hash.update(entry.name);
  53372. } else if (isRef(entry)) {
  53373. hash.update(entry.toString());
  53374. } else if (isArray(entry)) {
  53375. var diffLength = entry.length, diffBuf = new Array(diffLength);
  53376. for (var j = 0; j < diffLength; j++) {
  53377. var diffEntry = entry[j];
  53378. if (isName(diffEntry)) {
  53379. diffBuf[j] = diffEntry.name;
  53380. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  53381. diffBuf[j] = diffEntry.toString();
  53382. }
  53383. }
  53384. hash.update(diffBuf.join());
  53385. }
  53386. }
  53387. }
  53388. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53389. if (isStream(toUnicode)) {
  53390. var stream = toUnicode.str || toUnicode;
  53391. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53392. hash.update(uint8array);
  53393. } else if (isName(toUnicode)) {
  53394. hash.update(toUnicode.name);
  53395. }
  53396. var widths = dict.get('Widths') || baseDict.get('Widths');
  53397. if (widths) {
  53398. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53399. hash.update(uint8array);
  53400. }
  53401. }
  53402. return {
  53403. descriptor: descriptor,
  53404. dict: dict,
  53405. baseDict: baseDict,
  53406. composite: composite,
  53407. type: type.name,
  53408. hash: hash ? hash.hexdigest() : ''
  53409. };
  53410. },
  53411. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53412. var baseDict = preEvaluatedFont.baseDict;
  53413. var dict = preEvaluatedFont.dict;
  53414. var composite = preEvaluatedFont.composite;
  53415. var descriptor = preEvaluatedFont.descriptor;
  53416. var type = preEvaluatedFont.type;
  53417. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53418. var cMapOptions = this.options.cMapOptions;
  53419. var properties;
  53420. if (!descriptor) {
  53421. if (type === 'Type3') {
  53422. descriptor = new Dict(null);
  53423. descriptor.set('FontName', Name.get(type));
  53424. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53425. } else {
  53426. var baseFontName = dict.get('BaseFont');
  53427. if (!isName(baseFontName)) {
  53428. error('Base font is not specified');
  53429. }
  53430. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53431. var metrics = this.getBaseFontMetrics(baseFontName);
  53432. var fontNameWoStyle = baseFontName.split('-')[0];
  53433. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53434. properties = {
  53435. type: type,
  53436. name: baseFontName,
  53437. widths: metrics.widths,
  53438. defaultWidth: metrics.defaultWidth,
  53439. flags: flags,
  53440. firstChar: 0,
  53441. lastChar: maxCharIndex
  53442. };
  53443. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53444. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53445. return new Font(baseFontName, null, properties);
  53446. }.bind(this));
  53447. }
  53448. }
  53449. var firstChar = dict.get('FirstChar') || 0;
  53450. var lastChar = dict.get('LastChar') || maxCharIndex;
  53451. var fontName = descriptor.get('FontName');
  53452. var baseFont = dict.get('BaseFont');
  53453. if (isString(fontName)) {
  53454. fontName = Name.get(fontName);
  53455. }
  53456. if (isString(baseFont)) {
  53457. baseFont = Name.get(baseFont);
  53458. }
  53459. if (type !== 'Type3') {
  53460. var fontNameStr = fontName && fontName.name;
  53461. var baseFontStr = baseFont && baseFont.name;
  53462. if (fontNameStr !== baseFontStr) {
  53463. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53464. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53465. fontName = baseFont;
  53466. }
  53467. }
  53468. }
  53469. fontName = fontName || baseFont;
  53470. assert(isName(fontName), 'invalid font name');
  53471. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53472. if (fontFile) {
  53473. if (fontFile.dict) {
  53474. var subtype = fontFile.dict.get('Subtype');
  53475. if (subtype) {
  53476. subtype = subtype.name;
  53477. }
  53478. var length1 = fontFile.dict.get('Length1');
  53479. var length2 = fontFile.dict.get('Length2');
  53480. var length3 = fontFile.dict.get('Length3');
  53481. }
  53482. }
  53483. properties = {
  53484. type: type,
  53485. name: fontName.name,
  53486. subtype: subtype,
  53487. file: fontFile,
  53488. length1: length1,
  53489. length2: length2,
  53490. length3: length3,
  53491. loadedName: baseDict.loadedName,
  53492. composite: composite,
  53493. wideChars: composite,
  53494. fixedPitch: false,
  53495. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53496. firstChar: firstChar || 0,
  53497. lastChar: lastChar || maxCharIndex,
  53498. bbox: descriptor.getArray('FontBBox'),
  53499. ascent: descriptor.get('Ascent'),
  53500. descent: descriptor.get('Descent'),
  53501. xHeight: descriptor.get('XHeight'),
  53502. capHeight: descriptor.get('CapHeight'),
  53503. flags: descriptor.get('Flags'),
  53504. italicAngle: descriptor.get('ItalicAngle'),
  53505. coded: false
  53506. };
  53507. var cMapPromise;
  53508. if (composite) {
  53509. var cidEncoding = baseDict.get('Encoding');
  53510. if (isName(cidEncoding)) {
  53511. properties.cidEncoding = cidEncoding.name;
  53512. }
  53513. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53514. properties.cMap = cMap;
  53515. properties.vertical = properties.cMap.vertical;
  53516. });
  53517. } else {
  53518. cMapPromise = Promise.resolve(undefined);
  53519. }
  53520. return cMapPromise.then(function () {
  53521. return this.extractDataStructures(dict, baseDict, xref, properties);
  53522. }.bind(this)).then(function (properties) {
  53523. this.extractWidths(dict, xref, descriptor, properties);
  53524. if (type === 'Type3') {
  53525. properties.isType3Font = true;
  53526. }
  53527. return new Font(fontName.name, fontFile, properties);
  53528. }.bind(this));
  53529. }
  53530. };
  53531. return PartialEvaluator;
  53532. }();
  53533. var TranslatedFont = function TranslatedFontClosure() {
  53534. function TranslatedFont(loadedName, font, dict) {
  53535. this.loadedName = loadedName;
  53536. this.font = font;
  53537. this.dict = dict;
  53538. this.type3Loaded = null;
  53539. this.sent = false;
  53540. }
  53541. TranslatedFont.prototype = {
  53542. send: function (handler) {
  53543. if (this.sent) {
  53544. return;
  53545. }
  53546. var fontData = this.font.exportData();
  53547. handler.send('commonobj', [
  53548. this.loadedName,
  53549. 'Font',
  53550. fontData
  53551. ]);
  53552. this.sent = true;
  53553. },
  53554. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53555. assert(this.font.isType3Font);
  53556. if (this.type3Loaded) {
  53557. return this.type3Loaded;
  53558. }
  53559. var translatedFont = this.font;
  53560. var loadCharProcsPromise = Promise.resolve();
  53561. var charProcs = this.dict.get('CharProcs');
  53562. var fontResources = this.dict.get('Resources') || resources;
  53563. var charProcKeys = charProcs.getKeys();
  53564. var charProcOperatorList = Object.create(null);
  53565. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53566. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53567. var glyphStream = charProcs.get(key);
  53568. var operatorList = new OperatorList();
  53569. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53570. charProcOperatorList[key] = operatorList.getIR();
  53571. parentOperatorList.addDependencies(operatorList.dependencies);
  53572. }, function (reason) {
  53573. warn('Type3 font resource \"' + key + '\" is not available');
  53574. var operatorList = new OperatorList();
  53575. charProcOperatorList[key] = operatorList.getIR();
  53576. });
  53577. }.bind(this, charProcKeys[i]));
  53578. }
  53579. this.type3Loaded = loadCharProcsPromise.then(function () {
  53580. translatedFont.charProcOperatorList = charProcOperatorList;
  53581. });
  53582. return this.type3Loaded;
  53583. }
  53584. };
  53585. return TranslatedFont;
  53586. }();
  53587. var OperatorList = function OperatorListClosure() {
  53588. var CHUNK_SIZE = 1000;
  53589. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53590. function getTransfers(queue) {
  53591. var transfers = [];
  53592. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53593. for (var i = 0, ii = queue.length; i < ii; i++) {
  53594. switch (fnArray[i]) {
  53595. case OPS.paintInlineImageXObject:
  53596. case OPS.paintInlineImageXObjectGroup:
  53597. case OPS.paintImageMaskXObject:
  53598. var arg = argsArray[i][0];
  53599. if (!arg.cached) {
  53600. transfers.push(arg.data.buffer);
  53601. }
  53602. break;
  53603. }
  53604. }
  53605. return transfers;
  53606. }
  53607. function OperatorList(intent, messageHandler, pageIndex) {
  53608. this.messageHandler = messageHandler;
  53609. this.fnArray = [];
  53610. this.argsArray = [];
  53611. this.dependencies = Object.create(null);
  53612. this._totalLength = 0;
  53613. this.pageIndex = pageIndex;
  53614. this.intent = intent;
  53615. }
  53616. OperatorList.prototype = {
  53617. get length() {
  53618. return this.argsArray.length;
  53619. },
  53620. get totalLength() {
  53621. return this._totalLength + this.length;
  53622. },
  53623. addOp: function (fn, args) {
  53624. this.fnArray.push(fn);
  53625. this.argsArray.push(args);
  53626. if (this.messageHandler) {
  53627. if (this.fnArray.length >= CHUNK_SIZE) {
  53628. this.flush();
  53629. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53630. this.flush();
  53631. }
  53632. }
  53633. },
  53634. addDependency: function (dependency) {
  53635. if (dependency in this.dependencies) {
  53636. return;
  53637. }
  53638. this.dependencies[dependency] = true;
  53639. this.addOp(OPS.dependency, [dependency]);
  53640. },
  53641. addDependencies: function (dependencies) {
  53642. for (var key in dependencies) {
  53643. this.addDependency(key);
  53644. }
  53645. },
  53646. addOpList: function (opList) {
  53647. Util.extendObj(this.dependencies, opList.dependencies);
  53648. for (var i = 0, ii = opList.length; i < ii; i++) {
  53649. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53650. }
  53651. },
  53652. getIR: function () {
  53653. return {
  53654. fnArray: this.fnArray,
  53655. argsArray: this.argsArray,
  53656. length: this.length
  53657. };
  53658. },
  53659. flush: function (lastChunk) {
  53660. if (this.intent !== 'oplist') {
  53661. new QueueOptimizer().optimize(this);
  53662. }
  53663. var transfers = getTransfers(this);
  53664. var length = this.length;
  53665. this._totalLength += length;
  53666. this.messageHandler.send('RenderPageChunk', {
  53667. operatorList: {
  53668. fnArray: this.fnArray,
  53669. argsArray: this.argsArray,
  53670. lastChunk: lastChunk,
  53671. length: length
  53672. },
  53673. pageIndex: this.pageIndex,
  53674. intent: this.intent
  53675. }, transfers);
  53676. this.dependencies = Object.create(null);
  53677. this.fnArray.length = 0;
  53678. this.argsArray.length = 0;
  53679. }
  53680. };
  53681. return OperatorList;
  53682. }();
  53683. var StateManager = function StateManagerClosure() {
  53684. function StateManager(initialState) {
  53685. this.state = initialState;
  53686. this.stateStack = [];
  53687. }
  53688. StateManager.prototype = {
  53689. save: function () {
  53690. var old = this.state;
  53691. this.stateStack.push(this.state);
  53692. this.state = old.clone();
  53693. },
  53694. restore: function () {
  53695. var prev = this.stateStack.pop();
  53696. if (prev) {
  53697. this.state = prev;
  53698. }
  53699. },
  53700. transform: function (args) {
  53701. this.state.ctm = Util.transform(this.state.ctm, args);
  53702. }
  53703. };
  53704. return StateManager;
  53705. }();
  53706. var TextState = function TextStateClosure() {
  53707. function TextState() {
  53708. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53709. this.fontName = null;
  53710. this.fontSize = 0;
  53711. this.font = null;
  53712. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53713. this.textMatrix = IDENTITY_MATRIX.slice();
  53714. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53715. this.charSpacing = 0;
  53716. this.wordSpacing = 0;
  53717. this.leading = 0;
  53718. this.textHScale = 1;
  53719. this.textRise = 0;
  53720. }
  53721. TextState.prototype = {
  53722. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53723. var m = this.textMatrix;
  53724. m[0] = a;
  53725. m[1] = b;
  53726. m[2] = c;
  53727. m[3] = d;
  53728. m[4] = e;
  53729. m[5] = f;
  53730. },
  53731. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53732. var m = this.textLineMatrix;
  53733. m[0] = a;
  53734. m[1] = b;
  53735. m[2] = c;
  53736. m[3] = d;
  53737. m[4] = e;
  53738. m[5] = f;
  53739. },
  53740. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53741. var m = this.textMatrix;
  53742. m[4] = m[0] * x + m[2] * y + m[4];
  53743. m[5] = m[1] * x + m[3] * y + m[5];
  53744. },
  53745. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53746. var m = this.textLineMatrix;
  53747. m[4] = m[0] * x + m[2] * y + m[4];
  53748. m[5] = m[1] * x + m[3] * y + m[5];
  53749. },
  53750. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53751. var font = this.font;
  53752. if (!font) {
  53753. return null;
  53754. }
  53755. var m = this.textLineMatrix;
  53756. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53757. return null;
  53758. }
  53759. var txDiff = e - m[4], tyDiff = f - m[5];
  53760. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53761. return null;
  53762. }
  53763. var tx, ty, denominator = a * d - b * c;
  53764. if (font.vertical) {
  53765. tx = -tyDiff * c / denominator;
  53766. ty = tyDiff * a / denominator;
  53767. } else {
  53768. tx = txDiff * d / denominator;
  53769. ty = -txDiff * b / denominator;
  53770. }
  53771. return {
  53772. width: tx,
  53773. height: ty,
  53774. value: font.vertical ? ty : tx
  53775. };
  53776. },
  53777. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53778. var tsm = [
  53779. this.fontSize * this.textHScale,
  53780. 0,
  53781. 0,
  53782. this.fontSize,
  53783. 0,
  53784. this.textRise
  53785. ];
  53786. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53787. },
  53788. carriageReturn: function TextState_carriageReturn() {
  53789. this.translateTextLineMatrix(0, -this.leading);
  53790. this.textMatrix = this.textLineMatrix.slice();
  53791. },
  53792. clone: function TextState_clone() {
  53793. var clone = Object.create(this);
  53794. clone.textMatrix = this.textMatrix.slice();
  53795. clone.textLineMatrix = this.textLineMatrix.slice();
  53796. clone.fontMatrix = this.fontMatrix.slice();
  53797. return clone;
  53798. }
  53799. };
  53800. return TextState;
  53801. }();
  53802. var EvalState = function EvalStateClosure() {
  53803. function EvalState() {
  53804. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53805. this.font = null;
  53806. this.textRenderingMode = TextRenderingMode.FILL;
  53807. this.fillColorSpace = ColorSpace.singletons.gray;
  53808. this.strokeColorSpace = ColorSpace.singletons.gray;
  53809. }
  53810. EvalState.prototype = {
  53811. clone: function CanvasExtraState_clone() {
  53812. return Object.create(this);
  53813. }
  53814. };
  53815. return EvalState;
  53816. }();
  53817. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53818. var getOPMap = getLookupTableFactory(function (t) {
  53819. t['w'] = {
  53820. id: OPS.setLineWidth,
  53821. numArgs: 1,
  53822. variableArgs: false
  53823. };
  53824. t['J'] = {
  53825. id: OPS.setLineCap,
  53826. numArgs: 1,
  53827. variableArgs: false
  53828. };
  53829. t['j'] = {
  53830. id: OPS.setLineJoin,
  53831. numArgs: 1,
  53832. variableArgs: false
  53833. };
  53834. t['M'] = {
  53835. id: OPS.setMiterLimit,
  53836. numArgs: 1,
  53837. variableArgs: false
  53838. };
  53839. t['d'] = {
  53840. id: OPS.setDash,
  53841. numArgs: 2,
  53842. variableArgs: false
  53843. };
  53844. t['ri'] = {
  53845. id: OPS.setRenderingIntent,
  53846. numArgs: 1,
  53847. variableArgs: false
  53848. };
  53849. t['i'] = {
  53850. id: OPS.setFlatness,
  53851. numArgs: 1,
  53852. variableArgs: false
  53853. };
  53854. t['gs'] = {
  53855. id: OPS.setGState,
  53856. numArgs: 1,
  53857. variableArgs: false
  53858. };
  53859. t['q'] = {
  53860. id: OPS.save,
  53861. numArgs: 0,
  53862. variableArgs: false
  53863. };
  53864. t['Q'] = {
  53865. id: OPS.restore,
  53866. numArgs: 0,
  53867. variableArgs: false
  53868. };
  53869. t['cm'] = {
  53870. id: OPS.transform,
  53871. numArgs: 6,
  53872. variableArgs: false
  53873. };
  53874. t['m'] = {
  53875. id: OPS.moveTo,
  53876. numArgs: 2,
  53877. variableArgs: false
  53878. };
  53879. t['l'] = {
  53880. id: OPS.lineTo,
  53881. numArgs: 2,
  53882. variableArgs: false
  53883. };
  53884. t['c'] = {
  53885. id: OPS.curveTo,
  53886. numArgs: 6,
  53887. variableArgs: false
  53888. };
  53889. t['v'] = {
  53890. id: OPS.curveTo2,
  53891. numArgs: 4,
  53892. variableArgs: false
  53893. };
  53894. t['y'] = {
  53895. id: OPS.curveTo3,
  53896. numArgs: 4,
  53897. variableArgs: false
  53898. };
  53899. t['h'] = {
  53900. id: OPS.closePath,
  53901. numArgs: 0,
  53902. variableArgs: false
  53903. };
  53904. t['re'] = {
  53905. id: OPS.rectangle,
  53906. numArgs: 4,
  53907. variableArgs: false
  53908. };
  53909. t['S'] = {
  53910. id: OPS.stroke,
  53911. numArgs: 0,
  53912. variableArgs: false
  53913. };
  53914. t['s'] = {
  53915. id: OPS.closeStroke,
  53916. numArgs: 0,
  53917. variableArgs: false
  53918. };
  53919. t['f'] = {
  53920. id: OPS.fill,
  53921. numArgs: 0,
  53922. variableArgs: false
  53923. };
  53924. t['F'] = {
  53925. id: OPS.fill,
  53926. numArgs: 0,
  53927. variableArgs: false
  53928. };
  53929. t['f*'] = {
  53930. id: OPS.eoFill,
  53931. numArgs: 0,
  53932. variableArgs: false
  53933. };
  53934. t['B'] = {
  53935. id: OPS.fillStroke,
  53936. numArgs: 0,
  53937. variableArgs: false
  53938. };
  53939. t['B*'] = {
  53940. id: OPS.eoFillStroke,
  53941. numArgs: 0,
  53942. variableArgs: false
  53943. };
  53944. t['b'] = {
  53945. id: OPS.closeFillStroke,
  53946. numArgs: 0,
  53947. variableArgs: false
  53948. };
  53949. t['b*'] = {
  53950. id: OPS.closeEOFillStroke,
  53951. numArgs: 0,
  53952. variableArgs: false
  53953. };
  53954. t['n'] = {
  53955. id: OPS.endPath,
  53956. numArgs: 0,
  53957. variableArgs: false
  53958. };
  53959. t['W'] = {
  53960. id: OPS.clip,
  53961. numArgs: 0,
  53962. variableArgs: false
  53963. };
  53964. t['W*'] = {
  53965. id: OPS.eoClip,
  53966. numArgs: 0,
  53967. variableArgs: false
  53968. };
  53969. t['BT'] = {
  53970. id: OPS.beginText,
  53971. numArgs: 0,
  53972. variableArgs: false
  53973. };
  53974. t['ET'] = {
  53975. id: OPS.endText,
  53976. numArgs: 0,
  53977. variableArgs: false
  53978. };
  53979. t['Tc'] = {
  53980. id: OPS.setCharSpacing,
  53981. numArgs: 1,
  53982. variableArgs: false
  53983. };
  53984. t['Tw'] = {
  53985. id: OPS.setWordSpacing,
  53986. numArgs: 1,
  53987. variableArgs: false
  53988. };
  53989. t['Tz'] = {
  53990. id: OPS.setHScale,
  53991. numArgs: 1,
  53992. variableArgs: false
  53993. };
  53994. t['TL'] = {
  53995. id: OPS.setLeading,
  53996. numArgs: 1,
  53997. variableArgs: false
  53998. };
  53999. t['Tf'] = {
  54000. id: OPS.setFont,
  54001. numArgs: 2,
  54002. variableArgs: false
  54003. };
  54004. t['Tr'] = {
  54005. id: OPS.setTextRenderingMode,
  54006. numArgs: 1,
  54007. variableArgs: false
  54008. };
  54009. t['Ts'] = {
  54010. id: OPS.setTextRise,
  54011. numArgs: 1,
  54012. variableArgs: false
  54013. };
  54014. t['Td'] = {
  54015. id: OPS.moveText,
  54016. numArgs: 2,
  54017. variableArgs: false
  54018. };
  54019. t['TD'] = {
  54020. id: OPS.setLeadingMoveText,
  54021. numArgs: 2,
  54022. variableArgs: false
  54023. };
  54024. t['Tm'] = {
  54025. id: OPS.setTextMatrix,
  54026. numArgs: 6,
  54027. variableArgs: false
  54028. };
  54029. t['T*'] = {
  54030. id: OPS.nextLine,
  54031. numArgs: 0,
  54032. variableArgs: false
  54033. };
  54034. t['Tj'] = {
  54035. id: OPS.showText,
  54036. numArgs: 1,
  54037. variableArgs: false
  54038. };
  54039. t['TJ'] = {
  54040. id: OPS.showSpacedText,
  54041. numArgs: 1,
  54042. variableArgs: false
  54043. };
  54044. t['\''] = {
  54045. id: OPS.nextLineShowText,
  54046. numArgs: 1,
  54047. variableArgs: false
  54048. };
  54049. t['"'] = {
  54050. id: OPS.nextLineSetSpacingShowText,
  54051. numArgs: 3,
  54052. variableArgs: false
  54053. };
  54054. t['d0'] = {
  54055. id: OPS.setCharWidth,
  54056. numArgs: 2,
  54057. variableArgs: false
  54058. };
  54059. t['d1'] = {
  54060. id: OPS.setCharWidthAndBounds,
  54061. numArgs: 6,
  54062. variableArgs: false
  54063. };
  54064. t['CS'] = {
  54065. id: OPS.setStrokeColorSpace,
  54066. numArgs: 1,
  54067. variableArgs: false
  54068. };
  54069. t['cs'] = {
  54070. id: OPS.setFillColorSpace,
  54071. numArgs: 1,
  54072. variableArgs: false
  54073. };
  54074. t['SC'] = {
  54075. id: OPS.setStrokeColor,
  54076. numArgs: 4,
  54077. variableArgs: true
  54078. };
  54079. t['SCN'] = {
  54080. id: OPS.setStrokeColorN,
  54081. numArgs: 33,
  54082. variableArgs: true
  54083. };
  54084. t['sc'] = {
  54085. id: OPS.setFillColor,
  54086. numArgs: 4,
  54087. variableArgs: true
  54088. };
  54089. t['scn'] = {
  54090. id: OPS.setFillColorN,
  54091. numArgs: 33,
  54092. variableArgs: true
  54093. };
  54094. t['G'] = {
  54095. id: OPS.setStrokeGray,
  54096. numArgs: 1,
  54097. variableArgs: false
  54098. };
  54099. t['g'] = {
  54100. id: OPS.setFillGray,
  54101. numArgs: 1,
  54102. variableArgs: false
  54103. };
  54104. t['RG'] = {
  54105. id: OPS.setStrokeRGBColor,
  54106. numArgs: 3,
  54107. variableArgs: false
  54108. };
  54109. t['rg'] = {
  54110. id: OPS.setFillRGBColor,
  54111. numArgs: 3,
  54112. variableArgs: false
  54113. };
  54114. t['K'] = {
  54115. id: OPS.setStrokeCMYKColor,
  54116. numArgs: 4,
  54117. variableArgs: false
  54118. };
  54119. t['k'] = {
  54120. id: OPS.setFillCMYKColor,
  54121. numArgs: 4,
  54122. variableArgs: false
  54123. };
  54124. t['sh'] = {
  54125. id: OPS.shadingFill,
  54126. numArgs: 1,
  54127. variableArgs: false
  54128. };
  54129. t['BI'] = {
  54130. id: OPS.beginInlineImage,
  54131. numArgs: 0,
  54132. variableArgs: false
  54133. };
  54134. t['ID'] = {
  54135. id: OPS.beginImageData,
  54136. numArgs: 0,
  54137. variableArgs: false
  54138. };
  54139. t['EI'] = {
  54140. id: OPS.endInlineImage,
  54141. numArgs: 1,
  54142. variableArgs: false
  54143. };
  54144. t['Do'] = {
  54145. id: OPS.paintXObject,
  54146. numArgs: 1,
  54147. variableArgs: false
  54148. };
  54149. t['MP'] = {
  54150. id: OPS.markPoint,
  54151. numArgs: 1,
  54152. variableArgs: false
  54153. };
  54154. t['DP'] = {
  54155. id: OPS.markPointProps,
  54156. numArgs: 2,
  54157. variableArgs: false
  54158. };
  54159. t['BMC'] = {
  54160. id: OPS.beginMarkedContent,
  54161. numArgs: 1,
  54162. variableArgs: false
  54163. };
  54164. t['BDC'] = {
  54165. id: OPS.beginMarkedContentProps,
  54166. numArgs: 2,
  54167. variableArgs: false
  54168. };
  54169. t['EMC'] = {
  54170. id: OPS.endMarkedContent,
  54171. numArgs: 0,
  54172. variableArgs: false
  54173. };
  54174. t['BX'] = {
  54175. id: OPS.beginCompat,
  54176. numArgs: 0,
  54177. variableArgs: false
  54178. };
  54179. t['EX'] = {
  54180. id: OPS.endCompat,
  54181. numArgs: 0,
  54182. variableArgs: false
  54183. };
  54184. t['BM'] = null;
  54185. t['BD'] = null;
  54186. t['true'] = null;
  54187. t['fa'] = null;
  54188. t['fal'] = null;
  54189. t['fals'] = null;
  54190. t['false'] = null;
  54191. t['nu'] = null;
  54192. t['nul'] = null;
  54193. t['null'] = null;
  54194. });
  54195. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54196. this.opMap = getOPMap();
  54197. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54198. this.stateManager = stateManager;
  54199. this.nonProcessedArgs = [];
  54200. }
  54201. EvaluatorPreprocessor.prototype = {
  54202. get savedStatesDepth() {
  54203. return this.stateManager.stateStack.length;
  54204. },
  54205. read: function EvaluatorPreprocessor_read(operation) {
  54206. var args = operation.args;
  54207. while (true) {
  54208. var obj = this.parser.getObj();
  54209. if (isCmd(obj)) {
  54210. var cmd = obj.cmd;
  54211. var opSpec = this.opMap[cmd];
  54212. if (!opSpec) {
  54213. warn('Unknown command "' + cmd + '"');
  54214. continue;
  54215. }
  54216. var fn = opSpec.id;
  54217. var numArgs = opSpec.numArgs;
  54218. var argsLength = args !== null ? args.length : 0;
  54219. if (!opSpec.variableArgs) {
  54220. if (argsLength !== numArgs) {
  54221. var nonProcessedArgs = this.nonProcessedArgs;
  54222. while (argsLength > numArgs) {
  54223. nonProcessedArgs.push(args.shift());
  54224. argsLength--;
  54225. }
  54226. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54227. if (args === null) {
  54228. args = [];
  54229. }
  54230. args.unshift(nonProcessedArgs.pop());
  54231. argsLength++;
  54232. }
  54233. }
  54234. if (argsLength < numArgs) {
  54235. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54236. if (args !== null) {
  54237. args.length = 0;
  54238. }
  54239. continue;
  54240. }
  54241. } else if (argsLength > numArgs) {
  54242. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54243. }
  54244. this.preprocessCommand(fn, args);
  54245. operation.fn = fn;
  54246. operation.args = args;
  54247. return true;
  54248. }
  54249. if (isEOF(obj)) {
  54250. return false;
  54251. }
  54252. if (obj !== null) {
  54253. if (args === null) {
  54254. args = [];
  54255. }
  54256. args.push(obj);
  54257. assert(args.length <= 33, 'Too many arguments');
  54258. }
  54259. }
  54260. },
  54261. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54262. switch (fn | 0) {
  54263. case OPS.save:
  54264. this.stateManager.save();
  54265. break;
  54266. case OPS.restore:
  54267. this.stateManager.restore();
  54268. break;
  54269. case OPS.transform:
  54270. this.stateManager.transform(args);
  54271. break;
  54272. }
  54273. }
  54274. };
  54275. return EvaluatorPreprocessor;
  54276. }();
  54277. var QueueOptimizer = function QueueOptimizerClosure() {
  54278. function addState(parentState, pattern, fn) {
  54279. var state = parentState;
  54280. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54281. var item = pattern[i];
  54282. state = state[item] || (state[item] = []);
  54283. }
  54284. state[pattern[pattern.length - 1]] = fn;
  54285. }
  54286. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54287. var iFirstPIMXO = iFirstSave + 2;
  54288. for (var i = 0; i < count; i++) {
  54289. var arg = argsArray[iFirstPIMXO + 4 * i];
  54290. var imageMask = arg.length === 1 && arg[0];
  54291. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54292. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54293. continue;
  54294. }
  54295. break;
  54296. }
  54297. return count - i;
  54298. }
  54299. var InitialState = [];
  54300. addState(InitialState, [
  54301. OPS.save,
  54302. OPS.transform,
  54303. OPS.paintInlineImageXObject,
  54304. OPS.restore
  54305. ], function foundInlineImageGroup(context) {
  54306. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54307. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54308. var MAX_WIDTH = 1000;
  54309. var IMAGE_PADDING = 1;
  54310. var fnArray = context.fnArray, argsArray = context.argsArray;
  54311. var curr = context.iCurr;
  54312. var iFirstSave = curr - 3;
  54313. var iFirstTransform = curr - 2;
  54314. var iFirstPIIXO = curr - 1;
  54315. var i = iFirstSave + 4;
  54316. var ii = fnArray.length;
  54317. while (i + 3 < ii) {
  54318. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54319. break;
  54320. }
  54321. i += 4;
  54322. }
  54323. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54324. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54325. return i;
  54326. }
  54327. var maxX = 0;
  54328. var map = [], maxLineHeight = 0;
  54329. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54330. var q;
  54331. for (q = 0; q < count; q++) {
  54332. var transform = argsArray[iFirstTransform + (q << 2)];
  54333. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54334. if (currentX + img.width > MAX_WIDTH) {
  54335. maxX = Math.max(maxX, currentX);
  54336. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54337. currentX = 0;
  54338. maxLineHeight = 0;
  54339. }
  54340. map.push({
  54341. transform: transform,
  54342. x: currentX,
  54343. y: currentY,
  54344. w: img.width,
  54345. h: img.height
  54346. });
  54347. currentX += img.width + 2 * IMAGE_PADDING;
  54348. maxLineHeight = Math.max(maxLineHeight, img.height);
  54349. }
  54350. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54351. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54352. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54353. var imgRowSize = imgWidth << 2;
  54354. for (q = 0; q < count; q++) {
  54355. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54356. var rowSize = map[q].w << 2;
  54357. var dataOffset = 0;
  54358. var offset = map[q].x + map[q].y * imgWidth << 2;
  54359. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54360. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54361. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54362. dataOffset += rowSize;
  54363. offset += imgRowSize;
  54364. }
  54365. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54366. while (offset >= 0) {
  54367. data[offset - 4] = data[offset];
  54368. data[offset - 3] = data[offset + 1];
  54369. data[offset - 2] = data[offset + 2];
  54370. data[offset - 1] = data[offset + 3];
  54371. data[offset + rowSize] = data[offset + rowSize - 4];
  54372. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54373. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54374. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54375. offset -= imgRowSize;
  54376. }
  54377. }
  54378. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54379. argsArray.splice(iFirstSave, count * 4, [
  54380. {
  54381. width: imgWidth,
  54382. height: imgHeight,
  54383. kind: ImageKind.RGBA_32BPP,
  54384. data: imgData
  54385. },
  54386. map
  54387. ]);
  54388. return iFirstSave + 1;
  54389. });
  54390. addState(InitialState, [
  54391. OPS.save,
  54392. OPS.transform,
  54393. OPS.paintImageMaskXObject,
  54394. OPS.restore
  54395. ], function foundImageMaskGroup(context) {
  54396. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54397. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54398. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54399. var fnArray = context.fnArray, argsArray = context.argsArray;
  54400. var curr = context.iCurr;
  54401. var iFirstSave = curr - 3;
  54402. var iFirstTransform = curr - 2;
  54403. var iFirstPIMXO = curr - 1;
  54404. var i = iFirstSave + 4;
  54405. var ii = fnArray.length;
  54406. while (i + 3 < ii) {
  54407. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54408. break;
  54409. }
  54410. i += 4;
  54411. }
  54412. var count = (i - iFirstSave) / 4;
  54413. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54414. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54415. return i;
  54416. }
  54417. var q;
  54418. var isSameImage = false;
  54419. var iTransform, transformArgs;
  54420. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54421. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54422. isSameImage = true;
  54423. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54424. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54425. iTransform = iFirstTransform + 4;
  54426. var iPIMXO = iFirstPIMXO + 4;
  54427. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54428. transformArgs = argsArray[iTransform];
  54429. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54430. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54431. isSameImage = false;
  54432. } else {
  54433. count = q;
  54434. }
  54435. break;
  54436. }
  54437. }
  54438. }
  54439. if (isSameImage) {
  54440. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54441. var positions = new Float32Array(count * 2);
  54442. iTransform = iFirstTransform;
  54443. for (q = 0; q < count; q++, iTransform += 4) {
  54444. transformArgs = argsArray[iTransform];
  54445. positions[q << 1] = transformArgs[4];
  54446. positions[(q << 1) + 1] = transformArgs[5];
  54447. }
  54448. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54449. argsArray.splice(iFirstSave, count * 4, [
  54450. firstPIMXOArg0,
  54451. firstTransformArg0,
  54452. firstTransformArg3,
  54453. positions
  54454. ]);
  54455. } else {
  54456. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54457. var images = [];
  54458. for (q = 0; q < count; q++) {
  54459. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54460. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54461. images.push({
  54462. data: maskParams.data,
  54463. width: maskParams.width,
  54464. height: maskParams.height,
  54465. transform: transformArgs
  54466. });
  54467. }
  54468. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54469. argsArray.splice(iFirstSave, count * 4, [images]);
  54470. }
  54471. return iFirstSave + 1;
  54472. });
  54473. addState(InitialState, [
  54474. OPS.save,
  54475. OPS.transform,
  54476. OPS.paintImageXObject,
  54477. OPS.restore
  54478. ], function (context) {
  54479. var MIN_IMAGES_IN_BLOCK = 3;
  54480. var MAX_IMAGES_IN_BLOCK = 1000;
  54481. var fnArray = context.fnArray, argsArray = context.argsArray;
  54482. var curr = context.iCurr;
  54483. var iFirstSave = curr - 3;
  54484. var iFirstTransform = curr - 2;
  54485. var iFirstPIXO = curr - 1;
  54486. var iFirstRestore = curr;
  54487. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54488. return iFirstRestore + 1;
  54489. }
  54490. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54491. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54492. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54493. var i = iFirstSave + 4;
  54494. var ii = fnArray.length;
  54495. while (i + 3 < ii) {
  54496. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54497. break;
  54498. }
  54499. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54500. break;
  54501. }
  54502. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54503. break;
  54504. }
  54505. i += 4;
  54506. }
  54507. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54508. if (count < MIN_IMAGES_IN_BLOCK) {
  54509. return i;
  54510. }
  54511. var positions = new Float32Array(count * 2);
  54512. var iTransform = iFirstTransform;
  54513. for (var q = 0; q < count; q++, iTransform += 4) {
  54514. var transformArgs = argsArray[iTransform];
  54515. positions[q << 1] = transformArgs[4];
  54516. positions[(q << 1) + 1] = transformArgs[5];
  54517. }
  54518. var args = [
  54519. firstPIXOArg0,
  54520. firstTransformArg0,
  54521. firstTransformArg3,
  54522. positions
  54523. ];
  54524. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54525. argsArray.splice(iFirstSave, count * 4, args);
  54526. return iFirstSave + 1;
  54527. });
  54528. addState(InitialState, [
  54529. OPS.beginText,
  54530. OPS.setFont,
  54531. OPS.setTextMatrix,
  54532. OPS.showText,
  54533. OPS.endText
  54534. ], function (context) {
  54535. var MIN_CHARS_IN_BLOCK = 3;
  54536. var MAX_CHARS_IN_BLOCK = 1000;
  54537. var fnArray = context.fnArray, argsArray = context.argsArray;
  54538. var curr = context.iCurr;
  54539. var iFirstBeginText = curr - 4;
  54540. var iFirstSetFont = curr - 3;
  54541. var iFirstSetTextMatrix = curr - 2;
  54542. var iFirstShowText = curr - 1;
  54543. var iFirstEndText = curr;
  54544. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54545. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54546. var i = iFirstBeginText + 5;
  54547. var ii = fnArray.length;
  54548. while (i + 4 < ii) {
  54549. 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) {
  54550. break;
  54551. }
  54552. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54553. break;
  54554. }
  54555. i += 5;
  54556. }
  54557. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54558. if (count < MIN_CHARS_IN_BLOCK) {
  54559. return i;
  54560. }
  54561. var iFirst = iFirstBeginText;
  54562. 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) {
  54563. count++;
  54564. iFirst -= 5;
  54565. }
  54566. var iEndText = iFirst + 4;
  54567. for (var q = 1; q < count; q++) {
  54568. fnArray.splice(iEndText, 3);
  54569. argsArray.splice(iEndText, 3);
  54570. iEndText += 2;
  54571. }
  54572. return iEndText + 1;
  54573. });
  54574. function QueueOptimizer() {
  54575. }
  54576. QueueOptimizer.prototype = {
  54577. optimize: function QueueOptimizer_optimize(queue) {
  54578. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54579. var context = {
  54580. iCurr: 0,
  54581. fnArray: fnArray,
  54582. argsArray: argsArray
  54583. };
  54584. var state;
  54585. var i = 0, ii = fnArray.length;
  54586. while (i < ii) {
  54587. state = (state || InitialState)[fnArray[i]];
  54588. if (typeof state === 'function') {
  54589. context.iCurr = i;
  54590. i = state(context);
  54591. state = undefined;
  54592. ii = context.fnArray.length;
  54593. } else {
  54594. i++;
  54595. }
  54596. }
  54597. }
  54598. };
  54599. return QueueOptimizer;
  54600. }();
  54601. exports.OperatorList = OperatorList;
  54602. exports.PartialEvaluator = PartialEvaluator;
  54603. }));
  54604. (function (root, factory) {
  54605. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54606. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54607. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54608. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54609. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54610. var AnnotationType = sharedUtil.AnnotationType;
  54611. var OPS = sharedUtil.OPS;
  54612. var Util = sharedUtil.Util;
  54613. var isString = sharedUtil.isString;
  54614. var isArray = sharedUtil.isArray;
  54615. var isInt = sharedUtil.isInt;
  54616. var stringToBytes = sharedUtil.stringToBytes;
  54617. var stringToPDFString = sharedUtil.stringToPDFString;
  54618. var warn = sharedUtil.warn;
  54619. var Dict = corePrimitives.Dict;
  54620. var isDict = corePrimitives.isDict;
  54621. var isName = corePrimitives.isName;
  54622. var isRef = corePrimitives.isRef;
  54623. var Stream = coreStream.Stream;
  54624. var ColorSpace = coreColorSpace.ColorSpace;
  54625. var Catalog = coreObj.Catalog;
  54626. var ObjectLoader = coreObj.ObjectLoader;
  54627. var FileSpec = coreObj.FileSpec;
  54628. var OperatorList = coreEvaluator.OperatorList;
  54629. function AnnotationFactory() {
  54630. }
  54631. AnnotationFactory.prototype = {
  54632. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  54633. var dict = xref.fetchIfRef(ref);
  54634. if (!isDict(dict)) {
  54635. return;
  54636. }
  54637. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  54638. var subtype = dict.get('Subtype');
  54639. subtype = isName(subtype) ? subtype.name : null;
  54640. var parameters = {
  54641. xref: xref,
  54642. dict: dict,
  54643. ref: isRef(ref) ? ref : null,
  54644. subtype: subtype,
  54645. id: id,
  54646. pdfManager: pdfManager
  54647. };
  54648. switch (subtype) {
  54649. case 'Link':
  54650. return new LinkAnnotation(parameters);
  54651. case 'Text':
  54652. return new TextAnnotation(parameters);
  54653. case 'Widget':
  54654. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54655. fieldType = isName(fieldType) ? fieldType.name : null;
  54656. switch (fieldType) {
  54657. case 'Tx':
  54658. return new TextWidgetAnnotation(parameters);
  54659. case 'Btn':
  54660. return new ButtonWidgetAnnotation(parameters);
  54661. case 'Ch':
  54662. return new ChoiceWidgetAnnotation(parameters);
  54663. }
  54664. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54665. return new WidgetAnnotation(parameters);
  54666. case 'Popup':
  54667. return new PopupAnnotation(parameters);
  54668. case 'Highlight':
  54669. return new HighlightAnnotation(parameters);
  54670. case 'Underline':
  54671. return new UnderlineAnnotation(parameters);
  54672. case 'Squiggly':
  54673. return new SquigglyAnnotation(parameters);
  54674. case 'StrikeOut':
  54675. return new StrikeOutAnnotation(parameters);
  54676. case 'FileAttachment':
  54677. return new FileAttachmentAnnotation(parameters);
  54678. default:
  54679. if (!subtype) {
  54680. warn('Annotation is missing the required /Subtype.');
  54681. } else {
  54682. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54683. }
  54684. return new Annotation(parameters);
  54685. }
  54686. }
  54687. };
  54688. var Annotation = function AnnotationClosure() {
  54689. function getTransformMatrix(rect, bbox, matrix) {
  54690. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54691. var minX = bounds[0];
  54692. var minY = bounds[1];
  54693. var maxX = bounds[2];
  54694. var maxY = bounds[3];
  54695. if (minX === maxX || minY === maxY) {
  54696. return [
  54697. 1,
  54698. 0,
  54699. 0,
  54700. 1,
  54701. rect[0],
  54702. rect[1]
  54703. ];
  54704. }
  54705. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54706. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54707. return [
  54708. xRatio,
  54709. 0,
  54710. 0,
  54711. yRatio,
  54712. rect[0] - minX * xRatio,
  54713. rect[1] - minY * yRatio
  54714. ];
  54715. }
  54716. function getDefaultAppearance(dict) {
  54717. var appearanceState = dict.get('AP');
  54718. if (!isDict(appearanceState)) {
  54719. return;
  54720. }
  54721. var appearance;
  54722. var appearances = appearanceState.get('N');
  54723. if (isDict(appearances)) {
  54724. var as = dict.get('AS');
  54725. if (as && appearances.has(as.name)) {
  54726. appearance = appearances.get(as.name);
  54727. }
  54728. } else {
  54729. appearance = appearances;
  54730. }
  54731. return appearance;
  54732. }
  54733. function Annotation(params) {
  54734. var dict = params.dict;
  54735. this.setFlags(dict.get('F'));
  54736. this.setRectangle(dict.getArray('Rect'));
  54737. this.setColor(dict.getArray('C'));
  54738. this.setBorderStyle(dict);
  54739. this.appearance = getDefaultAppearance(dict);
  54740. this.data = {};
  54741. this.data.id = params.id;
  54742. this.data.subtype = params.subtype;
  54743. this.data.annotationFlags = this.flags;
  54744. this.data.rect = this.rectangle;
  54745. this.data.color = this.color;
  54746. this.data.borderStyle = this.borderStyle;
  54747. this.data.hasAppearance = !!this.appearance;
  54748. }
  54749. Annotation.prototype = {
  54750. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54751. return !!(flags & flag);
  54752. },
  54753. _isViewable: function Annotation_isViewable(flags) {
  54754. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54755. },
  54756. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54757. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54758. },
  54759. get viewable() {
  54760. if (this.flags === 0) {
  54761. return true;
  54762. }
  54763. return this._isViewable(this.flags);
  54764. },
  54765. get printable() {
  54766. if (this.flags === 0) {
  54767. return false;
  54768. }
  54769. return this._isPrintable(this.flags);
  54770. },
  54771. setFlags: function Annotation_setFlags(flags) {
  54772. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54773. },
  54774. hasFlag: function Annotation_hasFlag(flag) {
  54775. return this._hasFlag(this.flags, flag);
  54776. },
  54777. setRectangle: function Annotation_setRectangle(rectangle) {
  54778. if (isArray(rectangle) && rectangle.length === 4) {
  54779. this.rectangle = Util.normalizeRect(rectangle);
  54780. } else {
  54781. this.rectangle = [
  54782. 0,
  54783. 0,
  54784. 0,
  54785. 0
  54786. ];
  54787. }
  54788. },
  54789. setColor: function Annotation_setColor(color) {
  54790. var rgbColor = new Uint8Array(3);
  54791. if (!isArray(color)) {
  54792. this.color = rgbColor;
  54793. return;
  54794. }
  54795. switch (color.length) {
  54796. case 0:
  54797. this.color = null;
  54798. break;
  54799. case 1:
  54800. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54801. this.color = rgbColor;
  54802. break;
  54803. case 3:
  54804. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54805. this.color = rgbColor;
  54806. break;
  54807. case 4:
  54808. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54809. this.color = rgbColor;
  54810. break;
  54811. default:
  54812. this.color = rgbColor;
  54813. break;
  54814. }
  54815. },
  54816. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54817. this.borderStyle = new AnnotationBorderStyle();
  54818. if (!isDict(borderStyle)) {
  54819. return;
  54820. }
  54821. if (borderStyle.has('BS')) {
  54822. var dict = borderStyle.get('BS');
  54823. var dictType = dict.get('Type');
  54824. if (!dictType || isName(dictType, 'Border')) {
  54825. this.borderStyle.setWidth(dict.get('W'));
  54826. this.borderStyle.setStyle(dict.get('S'));
  54827. this.borderStyle.setDashArray(dict.getArray('D'));
  54828. }
  54829. } else if (borderStyle.has('Border')) {
  54830. var array = borderStyle.getArray('Border');
  54831. if (isArray(array) && array.length >= 3) {
  54832. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54833. this.borderStyle.setVerticalCornerRadius(array[1]);
  54834. this.borderStyle.setWidth(array[2]);
  54835. if (array.length === 4) {
  54836. this.borderStyle.setDashArray(array[3]);
  54837. }
  54838. }
  54839. } else {
  54840. this.borderStyle.setWidth(0);
  54841. }
  54842. },
  54843. _preparePopup: function Annotation_preparePopup(dict) {
  54844. if (!dict.has('C')) {
  54845. this.data.color = null;
  54846. }
  54847. this.data.hasPopup = dict.has('Popup');
  54848. this.data.title = stringToPDFString(dict.get('T') || '');
  54849. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54850. },
  54851. loadResources: function Annotation_loadResources(keys) {
  54852. return new Promise(function (resolve, reject) {
  54853. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54854. if (!resources) {
  54855. resolve();
  54856. return;
  54857. }
  54858. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54859. objectLoader.load().then(function () {
  54860. resolve(resources);
  54861. }, reject);
  54862. }, reject);
  54863. }.bind(this));
  54864. },
  54865. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54866. if (!this.appearance) {
  54867. return Promise.resolve(new OperatorList());
  54868. }
  54869. var data = this.data;
  54870. var appearanceDict = this.appearance.dict;
  54871. var resourcesPromise = this.loadResources([
  54872. 'ExtGState',
  54873. 'ColorSpace',
  54874. 'Pattern',
  54875. 'Shading',
  54876. 'XObject',
  54877. 'Font'
  54878. ]);
  54879. var bbox = appearanceDict.getArray('BBox') || [
  54880. 0,
  54881. 0,
  54882. 1,
  54883. 1
  54884. ];
  54885. var matrix = appearanceDict.getArray('Matrix') || [
  54886. 1,
  54887. 0,
  54888. 0,
  54889. 1,
  54890. 0,
  54891. 0
  54892. ];
  54893. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54894. var self = this;
  54895. return resourcesPromise.then(function (resources) {
  54896. var opList = new OperatorList();
  54897. opList.addOp(OPS.beginAnnotation, [
  54898. data.rect,
  54899. transform,
  54900. matrix
  54901. ]);
  54902. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54903. opList.addOp(OPS.endAnnotation, []);
  54904. self.appearance.reset();
  54905. return opList;
  54906. });
  54907. });
  54908. }
  54909. };
  54910. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54911. var annotationPromises = [];
  54912. for (var i = 0, n = annotations.length; i < n; ++i) {
  54913. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54914. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54915. }
  54916. }
  54917. return Promise.all(annotationPromises).then(function (operatorLists) {
  54918. opList.addOp(OPS.beginAnnotations, []);
  54919. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54920. opList.addOpList(operatorLists[i]);
  54921. }
  54922. opList.addOp(OPS.endAnnotations, []);
  54923. });
  54924. };
  54925. return Annotation;
  54926. }();
  54927. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54928. function AnnotationBorderStyle() {
  54929. this.width = 1;
  54930. this.style = AnnotationBorderStyleType.SOLID;
  54931. this.dashArray = [3];
  54932. this.horizontalCornerRadius = 0;
  54933. this.verticalCornerRadius = 0;
  54934. }
  54935. AnnotationBorderStyle.prototype = {
  54936. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54937. if (width === (width | 0)) {
  54938. this.width = width;
  54939. }
  54940. },
  54941. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54942. if (!style) {
  54943. return;
  54944. }
  54945. switch (style.name) {
  54946. case 'S':
  54947. this.style = AnnotationBorderStyleType.SOLID;
  54948. break;
  54949. case 'D':
  54950. this.style = AnnotationBorderStyleType.DASHED;
  54951. break;
  54952. case 'B':
  54953. this.style = AnnotationBorderStyleType.BEVELED;
  54954. break;
  54955. case 'I':
  54956. this.style = AnnotationBorderStyleType.INSET;
  54957. break;
  54958. case 'U':
  54959. this.style = AnnotationBorderStyleType.UNDERLINE;
  54960. break;
  54961. default:
  54962. break;
  54963. }
  54964. },
  54965. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54966. if (isArray(dashArray) && dashArray.length > 0) {
  54967. var isValid = true;
  54968. var allZeros = true;
  54969. for (var i = 0, len = dashArray.length; i < len; i++) {
  54970. var element = dashArray[i];
  54971. var validNumber = +element >= 0;
  54972. if (!validNumber) {
  54973. isValid = false;
  54974. break;
  54975. } else if (element > 0) {
  54976. allZeros = false;
  54977. }
  54978. }
  54979. if (isValid && !allZeros) {
  54980. this.dashArray = dashArray;
  54981. } else {
  54982. this.width = 0;
  54983. }
  54984. } else if (dashArray) {
  54985. this.width = 0;
  54986. }
  54987. },
  54988. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54989. if (radius === (radius | 0)) {
  54990. this.horizontalCornerRadius = radius;
  54991. }
  54992. },
  54993. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54994. if (radius === (radius | 0)) {
  54995. this.verticalCornerRadius = radius;
  54996. }
  54997. }
  54998. };
  54999. return AnnotationBorderStyle;
  55000. }();
  55001. var WidgetAnnotation = function WidgetAnnotationClosure() {
  55002. function WidgetAnnotation(params) {
  55003. Annotation.call(this, params);
  55004. var dict = params.dict;
  55005. var data = this.data;
  55006. data.annotationType = AnnotationType.WIDGET;
  55007. data.fieldName = this._constructFieldName(dict);
  55008. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  55009. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  55010. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  55011. var fieldType = Util.getInheritableProperty(dict, 'FT');
  55012. data.fieldType = isName(fieldType) ? fieldType.name : null;
  55013. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  55014. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  55015. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  55016. data.fieldFlags = 0;
  55017. }
  55018. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  55019. if (data.fieldType === 'Sig') {
  55020. this.setFlags(AnnotationFlag.HIDDEN);
  55021. }
  55022. }
  55023. Util.inherit(WidgetAnnotation, Annotation, {
  55024. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  55025. if (!dict.has('T') && !dict.has('Parent')) {
  55026. warn('Unknown field name, falling back to empty field name.');
  55027. return '';
  55028. }
  55029. if (!dict.has('Parent')) {
  55030. return stringToPDFString(dict.get('T'));
  55031. }
  55032. var fieldName = [];
  55033. if (dict.has('T')) {
  55034. fieldName.unshift(stringToPDFString(dict.get('T')));
  55035. }
  55036. var loopDict = dict;
  55037. while (loopDict.has('Parent')) {
  55038. loopDict = loopDict.get('Parent');
  55039. if (loopDict.has('T')) {
  55040. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  55041. }
  55042. }
  55043. return fieldName.join('.');
  55044. },
  55045. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  55046. return !!(this.data.fieldFlags & flag);
  55047. }
  55048. });
  55049. return WidgetAnnotation;
  55050. }();
  55051. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  55052. function TextWidgetAnnotation(params) {
  55053. WidgetAnnotation.call(this, params);
  55054. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  55055. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  55056. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  55057. alignment = null;
  55058. }
  55059. this.data.textAlignment = alignment;
  55060. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  55061. if (!isInt(maximumLength) || maximumLength < 0) {
  55062. maximumLength = null;
  55063. }
  55064. this.data.maxLen = maximumLength;
  55065. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  55066. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  55067. }
  55068. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  55069. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  55070. var operatorList = new OperatorList();
  55071. if (renderForms) {
  55072. return Promise.resolve(operatorList);
  55073. }
  55074. if (this.appearance) {
  55075. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  55076. }
  55077. if (!this.data.defaultAppearance) {
  55078. return Promise.resolve(operatorList);
  55079. }
  55080. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  55081. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  55082. return operatorList;
  55083. });
  55084. }
  55085. });
  55086. return TextWidgetAnnotation;
  55087. }();
  55088. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  55089. function ButtonWidgetAnnotation(params) {
  55090. WidgetAnnotation.call(this, params);
  55091. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  55092. if (this.data.checkBox) {
  55093. if (!isName(this.data.fieldValue)) {
  55094. return;
  55095. }
  55096. this.data.fieldValue = this.data.fieldValue.name;
  55097. }
  55098. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  55099. if (this.data.radioButton) {
  55100. this.data.fieldValue = this.data.buttonValue = null;
  55101. var fieldParent = params.dict.get('Parent');
  55102. if (!isDict(fieldParent) || !fieldParent.has('V')) {
  55103. return;
  55104. }
  55105. var fieldParentValue = fieldParent.get('V');
  55106. if (!isName(fieldParentValue)) {
  55107. return;
  55108. }
  55109. this.data.fieldValue = fieldParentValue.name;
  55110. var appearanceStates = params.dict.get('AP');
  55111. if (!isDict(appearanceStates)) {
  55112. return;
  55113. }
  55114. var normalAppearanceState = appearanceStates.get('N');
  55115. if (!isDict(normalAppearanceState)) {
  55116. return;
  55117. }
  55118. var keys = normalAppearanceState.getKeys();
  55119. for (var i = 0, ii = keys.length; i < ii; i++) {
  55120. if (keys[i] !== 'Off') {
  55121. this.data.buttonValue = keys[i];
  55122. break;
  55123. }
  55124. }
  55125. }
  55126. }
  55127. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  55128. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  55129. var operatorList = new OperatorList();
  55130. if (renderForms) {
  55131. return Promise.resolve(operatorList);
  55132. }
  55133. if (this.appearance) {
  55134. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  55135. }
  55136. return Promise.resolve(operatorList);
  55137. }
  55138. });
  55139. return ButtonWidgetAnnotation;
  55140. }();
  55141. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  55142. function ChoiceWidgetAnnotation(params) {
  55143. WidgetAnnotation.call(this, params);
  55144. this.data.options = [];
  55145. var options = params.dict.get('Opt');
  55146. if (isArray(options)) {
  55147. var xref = params.xref;
  55148. for (var i = 0, ii = options.length; i < ii; i++) {
  55149. var option = xref.fetchIfRef(options[i]);
  55150. var isOptionArray = isArray(option);
  55151. this.data.options[i] = {
  55152. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  55153. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  55154. };
  55155. }
  55156. }
  55157. if (!isArray(this.data.fieldValue)) {
  55158. this.data.fieldValue = [this.data.fieldValue];
  55159. }
  55160. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  55161. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  55162. }
  55163. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  55164. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  55165. var operatorList = new OperatorList();
  55166. if (renderForms) {
  55167. return Promise.resolve(operatorList);
  55168. }
  55169. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  55170. }
  55171. });
  55172. return ChoiceWidgetAnnotation;
  55173. }();
  55174. var TextAnnotation = function TextAnnotationClosure() {
  55175. var DEFAULT_ICON_SIZE = 22;
  55176. function TextAnnotation(parameters) {
  55177. Annotation.call(this, parameters);
  55178. this.data.annotationType = AnnotationType.TEXT;
  55179. if (this.data.hasAppearance) {
  55180. this.data.name = 'NoIcon';
  55181. } else {
  55182. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  55183. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  55184. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  55185. }
  55186. this._preparePopup(parameters.dict);
  55187. }
  55188. Util.inherit(TextAnnotation, Annotation, {});
  55189. return TextAnnotation;
  55190. }();
  55191. var LinkAnnotation = function LinkAnnotationClosure() {
  55192. function LinkAnnotation(params) {
  55193. Annotation.call(this, params);
  55194. var data = this.data;
  55195. data.annotationType = AnnotationType.LINK;
  55196. Catalog.parseDestDictionary({
  55197. destDict: params.dict,
  55198. resultObj: data,
  55199. docBaseUrl: params.pdfManager.docBaseUrl
  55200. });
  55201. }
  55202. Util.inherit(LinkAnnotation, Annotation, {});
  55203. return LinkAnnotation;
  55204. }();
  55205. var PopupAnnotation = function PopupAnnotationClosure() {
  55206. function PopupAnnotation(parameters) {
  55207. Annotation.call(this, parameters);
  55208. this.data.annotationType = AnnotationType.POPUP;
  55209. var dict = parameters.dict;
  55210. var parentItem = dict.get('Parent');
  55211. if (!parentItem) {
  55212. warn('Popup annotation has a missing or invalid parent annotation.');
  55213. return;
  55214. }
  55215. this.data.parentId = dict.getRaw('Parent').toString();
  55216. this.data.title = stringToPDFString(parentItem.get('T') || '');
  55217. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  55218. if (!parentItem.has('C')) {
  55219. this.data.color = null;
  55220. } else {
  55221. this.setColor(parentItem.getArray('C'));
  55222. this.data.color = this.color;
  55223. }
  55224. if (!this.viewable) {
  55225. var parentFlags = parentItem.get('F');
  55226. if (this._isViewable(parentFlags)) {
  55227. this.setFlags(parentFlags);
  55228. }
  55229. }
  55230. }
  55231. Util.inherit(PopupAnnotation, Annotation, {});
  55232. return PopupAnnotation;
  55233. }();
  55234. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55235. function HighlightAnnotation(parameters) {
  55236. Annotation.call(this, parameters);
  55237. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55238. this._preparePopup(parameters.dict);
  55239. this.data.borderStyle.setWidth(0);
  55240. }
  55241. Util.inherit(HighlightAnnotation, Annotation, {});
  55242. return HighlightAnnotation;
  55243. }();
  55244. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55245. function UnderlineAnnotation(parameters) {
  55246. Annotation.call(this, parameters);
  55247. this.data.annotationType = AnnotationType.UNDERLINE;
  55248. this._preparePopup(parameters.dict);
  55249. this.data.borderStyle.setWidth(0);
  55250. }
  55251. Util.inherit(UnderlineAnnotation, Annotation, {});
  55252. return UnderlineAnnotation;
  55253. }();
  55254. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55255. function SquigglyAnnotation(parameters) {
  55256. Annotation.call(this, parameters);
  55257. this.data.annotationType = AnnotationType.SQUIGGLY;
  55258. this._preparePopup(parameters.dict);
  55259. this.data.borderStyle.setWidth(0);
  55260. }
  55261. Util.inherit(SquigglyAnnotation, Annotation, {});
  55262. return SquigglyAnnotation;
  55263. }();
  55264. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55265. function StrikeOutAnnotation(parameters) {
  55266. Annotation.call(this, parameters);
  55267. this.data.annotationType = AnnotationType.STRIKEOUT;
  55268. this._preparePopup(parameters.dict);
  55269. this.data.borderStyle.setWidth(0);
  55270. }
  55271. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55272. return StrikeOutAnnotation;
  55273. }();
  55274. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55275. function FileAttachmentAnnotation(parameters) {
  55276. Annotation.call(this, parameters);
  55277. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55278. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55279. this.data.file = file.serializable;
  55280. this._preparePopup(parameters.dict);
  55281. }
  55282. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55283. return FileAttachmentAnnotation;
  55284. }();
  55285. exports.Annotation = Annotation;
  55286. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55287. exports.AnnotationFactory = AnnotationFactory;
  55288. }));
  55289. (function (root, factory) {
  55290. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55291. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55292. var MissingDataException = sharedUtil.MissingDataException;
  55293. var Util = sharedUtil.Util;
  55294. var assert = sharedUtil.assert;
  55295. var error = sharedUtil.error;
  55296. var info = sharedUtil.info;
  55297. var isArray = sharedUtil.isArray;
  55298. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55299. var isNum = sharedUtil.isNum;
  55300. var isString = sharedUtil.isString;
  55301. var shadow = sharedUtil.shadow;
  55302. var stringToBytes = sharedUtil.stringToBytes;
  55303. var stringToPDFString = sharedUtil.stringToPDFString;
  55304. var warn = sharedUtil.warn;
  55305. var isSpace = sharedUtil.isSpace;
  55306. var Dict = corePrimitives.Dict;
  55307. var isDict = corePrimitives.isDict;
  55308. var isName = corePrimitives.isName;
  55309. var isStream = corePrimitives.isStream;
  55310. var NullStream = coreStream.NullStream;
  55311. var Stream = coreStream.Stream;
  55312. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55313. var Catalog = coreObj.Catalog;
  55314. var ObjectLoader = coreObj.ObjectLoader;
  55315. var XRef = coreObj.XRef;
  55316. var Linearization = coreParser.Linearization;
  55317. var calculateMD5 = coreCrypto.calculateMD5;
  55318. var OperatorList = coreEvaluator.OperatorList;
  55319. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55320. var Annotation = coreAnnotation.Annotation;
  55321. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55322. var Page = function PageClosure() {
  55323. var DEFAULT_USER_UNIT = 1.0;
  55324. var LETTER_SIZE_MEDIABOX = [
  55325. 0,
  55326. 0,
  55327. 612,
  55328. 792
  55329. ];
  55330. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55331. this.pdfManager = pdfManager;
  55332. this.pageIndex = pageIndex;
  55333. this.pageDict = pageDict;
  55334. this.xref = xref;
  55335. this.ref = ref;
  55336. this.fontCache = fontCache;
  55337. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55338. this.resourcesPromise = null;
  55339. var uniquePrefix = 'p' + this.pageIndex + '_';
  55340. var idCounters = { obj: 0 };
  55341. this.idFactory = {
  55342. createObjId: function () {
  55343. return uniquePrefix + ++idCounters.obj;
  55344. }
  55345. };
  55346. }
  55347. Page.prototype = {
  55348. getPageProp: function Page_getPageProp(key) {
  55349. return this.pageDict.get(key);
  55350. },
  55351. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  55352. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55353. var MAX_LOOP_COUNT = 100;
  55354. getArray = getArray || false;
  55355. while (dict) {
  55356. var value = getArray ? dict.getArray(key) : dict.get(key);
  55357. if (value) {
  55358. if (!valueArray) {
  55359. valueArray = [];
  55360. }
  55361. valueArray.push(value);
  55362. }
  55363. if (++loopCount > MAX_LOOP_COUNT) {
  55364. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55365. break;
  55366. }
  55367. dict = dict.get('Parent');
  55368. }
  55369. if (!valueArray) {
  55370. return Dict.empty;
  55371. }
  55372. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55373. return valueArray[0];
  55374. }
  55375. return Dict.merge(this.xref, valueArray);
  55376. },
  55377. get content() {
  55378. return this.getPageProp('Contents');
  55379. },
  55380. get resources() {
  55381. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55382. },
  55383. get mediaBox() {
  55384. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  55385. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  55386. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  55387. }
  55388. return shadow(this, 'mediaBox', mediaBox);
  55389. },
  55390. get cropBox() {
  55391. var cropBox = this.getInheritedPageProp('CropBox', true);
  55392. if (!isArray(cropBox) || cropBox.length !== 4) {
  55393. return shadow(this, 'cropBox', this.mediaBox);
  55394. }
  55395. return shadow(this, 'cropBox', cropBox);
  55396. },
  55397. get userUnit() {
  55398. var obj = this.getPageProp('UserUnit');
  55399. if (!isNum(obj) || obj <= 0) {
  55400. obj = DEFAULT_USER_UNIT;
  55401. }
  55402. return shadow(this, 'userUnit', obj);
  55403. },
  55404. get view() {
  55405. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  55406. if (mediaBox === cropBox) {
  55407. return shadow(this, 'view', mediaBox);
  55408. }
  55409. var intersection = Util.intersect(cropBox, mediaBox);
  55410. return shadow(this, 'view', intersection || mediaBox);
  55411. },
  55412. get rotate() {
  55413. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55414. if (rotate % 90 !== 0) {
  55415. rotate = 0;
  55416. } else if (rotate >= 360) {
  55417. rotate = rotate % 360;
  55418. } else if (rotate < 0) {
  55419. rotate = (rotate % 360 + 360) % 360;
  55420. }
  55421. return shadow(this, 'rotate', rotate);
  55422. },
  55423. getContentStream: function Page_getContentStream() {
  55424. var content = this.content;
  55425. var stream;
  55426. if (isArray(content)) {
  55427. var xref = this.xref;
  55428. var i, n = content.length;
  55429. var streams = [];
  55430. for (i = 0; i < n; ++i) {
  55431. streams.push(xref.fetchIfRef(content[i]));
  55432. }
  55433. stream = new StreamsSequenceStream(streams);
  55434. } else if (isStream(content)) {
  55435. stream = content;
  55436. } else {
  55437. stream = new NullStream();
  55438. }
  55439. return stream;
  55440. },
  55441. loadResources: function Page_loadResources(keys) {
  55442. if (!this.resourcesPromise) {
  55443. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55444. }
  55445. return this.resourcesPromise.then(function resourceSuccess() {
  55446. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55447. return objectLoader.load();
  55448. }.bind(this));
  55449. },
  55450. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55451. var self = this;
  55452. var pdfManager = this.pdfManager;
  55453. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55454. var resourcesPromise = this.loadResources([
  55455. 'ExtGState',
  55456. 'ColorSpace',
  55457. 'Pattern',
  55458. 'Shading',
  55459. 'XObject',
  55460. 'Font'
  55461. ]);
  55462. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  55463. var dataPromises = Promise.all([
  55464. contentStreamPromise,
  55465. resourcesPromise
  55466. ]);
  55467. var pageListPromise = dataPromises.then(function (data) {
  55468. var contentStream = data[0];
  55469. var opList = new OperatorList(intent, handler, self.pageIndex);
  55470. handler.send('StartRenderPage', {
  55471. transparency: partialEvaluator.hasBlendModes(self.resources),
  55472. pageIndex: self.pageIndex,
  55473. intent: intent
  55474. });
  55475. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55476. return opList;
  55477. });
  55478. });
  55479. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55480. return Promise.all([
  55481. pageListPromise,
  55482. annotationsPromise
  55483. ]).then(function (datas) {
  55484. var pageOpList = datas[0];
  55485. var annotations = datas[1];
  55486. if (annotations.length === 0) {
  55487. pageOpList.flush(true);
  55488. return pageOpList;
  55489. }
  55490. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55491. return annotationsReadyPromise.then(function () {
  55492. pageOpList.flush(true);
  55493. return pageOpList;
  55494. });
  55495. });
  55496. },
  55497. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55498. var handler = {
  55499. on: function nullHandlerOn() {
  55500. },
  55501. send: function nullHandlerSend() {
  55502. }
  55503. };
  55504. var self = this;
  55505. var pdfManager = this.pdfManager;
  55506. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55507. var resourcesPromise = this.loadResources([
  55508. 'ExtGState',
  55509. 'XObject',
  55510. 'Font'
  55511. ]);
  55512. var dataPromises = Promise.all([
  55513. contentStreamPromise,
  55514. resourcesPromise
  55515. ]);
  55516. return dataPromises.then(function (data) {
  55517. var contentStream = data[0];
  55518. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  55519. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55520. });
  55521. },
  55522. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55523. var annotations = this.annotations;
  55524. var annotationsData = [];
  55525. for (var i = 0, n = annotations.length; i < n; ++i) {
  55526. if (intent) {
  55527. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55528. continue;
  55529. }
  55530. }
  55531. annotationsData.push(annotations[i].data);
  55532. }
  55533. return annotationsData;
  55534. },
  55535. get annotations() {
  55536. var annotations = [];
  55537. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55538. var annotationFactory = new AnnotationFactory();
  55539. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55540. var annotationRef = annotationRefs[i];
  55541. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  55542. if (annotation) {
  55543. annotations.push(annotation);
  55544. }
  55545. }
  55546. return shadow(this, 'annotations', annotations);
  55547. }
  55548. };
  55549. return Page;
  55550. }();
  55551. var PDFDocument = function PDFDocumentClosure() {
  55552. var FINGERPRINT_FIRST_BYTES = 1024;
  55553. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55554. function PDFDocument(pdfManager, arg) {
  55555. var stream;
  55556. if (isStream(arg)) {
  55557. stream = arg;
  55558. } else if (isArrayBuffer(arg)) {
  55559. stream = new Stream(arg);
  55560. } else {
  55561. error('PDFDocument: Unknown argument type');
  55562. }
  55563. assert(stream.length > 0, 'stream must have data');
  55564. this.pdfManager = pdfManager;
  55565. this.stream = stream;
  55566. this.xref = new XRef(stream, pdfManager);
  55567. }
  55568. function find(stream, needle, limit, backwards) {
  55569. var pos = stream.pos;
  55570. var end = stream.end;
  55571. var strBuf = [];
  55572. if (pos + limit > end) {
  55573. limit = end - pos;
  55574. }
  55575. for (var n = 0; n < limit; ++n) {
  55576. strBuf.push(String.fromCharCode(stream.getByte()));
  55577. }
  55578. var str = strBuf.join('');
  55579. stream.pos = pos;
  55580. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55581. if (index === -1) {
  55582. return false;
  55583. }
  55584. stream.pos += index;
  55585. return true;
  55586. }
  55587. var DocumentInfoValidators = {
  55588. get entries() {
  55589. return shadow(this, 'entries', {
  55590. Title: isString,
  55591. Author: isString,
  55592. Subject: isString,
  55593. Keywords: isString,
  55594. Creator: isString,
  55595. Producer: isString,
  55596. CreationDate: isString,
  55597. ModDate: isString,
  55598. Trapped: isName
  55599. });
  55600. }
  55601. };
  55602. PDFDocument.prototype = {
  55603. parse: function PDFDocument_parse(recoveryMode) {
  55604. this.setup(recoveryMode);
  55605. var version = this.catalog.catDict.get('Version');
  55606. if (isName(version)) {
  55607. this.pdfFormatVersion = version.name;
  55608. }
  55609. try {
  55610. this.acroForm = this.catalog.catDict.get('AcroForm');
  55611. if (this.acroForm) {
  55612. this.xfa = this.acroForm.get('XFA');
  55613. var fields = this.acroForm.get('Fields');
  55614. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55615. this.acroForm = null;
  55616. }
  55617. }
  55618. } catch (ex) {
  55619. info('Something wrong with AcroForm entry');
  55620. this.acroForm = null;
  55621. }
  55622. },
  55623. get linearization() {
  55624. var linearization = null;
  55625. if (this.stream.length) {
  55626. try {
  55627. linearization = Linearization.create(this.stream);
  55628. } catch (err) {
  55629. if (err instanceof MissingDataException) {
  55630. throw err;
  55631. }
  55632. info(err);
  55633. }
  55634. }
  55635. return shadow(this, 'linearization', linearization);
  55636. },
  55637. get startXRef() {
  55638. var stream = this.stream;
  55639. var startXRef = 0;
  55640. var linearization = this.linearization;
  55641. if (linearization) {
  55642. stream.reset();
  55643. if (find(stream, 'endobj', 1024)) {
  55644. startXRef = stream.pos + 6;
  55645. }
  55646. } else {
  55647. var step = 1024;
  55648. var found = false, pos = stream.end;
  55649. while (!found && pos > 0) {
  55650. pos -= step - 'startxref'.length;
  55651. if (pos < 0) {
  55652. pos = 0;
  55653. }
  55654. stream.pos = pos;
  55655. found = find(stream, 'startxref', step, true);
  55656. }
  55657. if (found) {
  55658. stream.skip(9);
  55659. var ch;
  55660. do {
  55661. ch = stream.getByte();
  55662. } while (isSpace(ch));
  55663. var str = '';
  55664. while (ch >= 0x20 && ch <= 0x39) {
  55665. str += String.fromCharCode(ch);
  55666. ch = stream.getByte();
  55667. }
  55668. startXRef = parseInt(str, 10);
  55669. if (isNaN(startXRef)) {
  55670. startXRef = 0;
  55671. }
  55672. }
  55673. }
  55674. return shadow(this, 'startXRef', startXRef);
  55675. },
  55676. get mainXRefEntriesOffset() {
  55677. var mainXRefEntriesOffset = 0;
  55678. var linearization = this.linearization;
  55679. if (linearization) {
  55680. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55681. }
  55682. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55683. },
  55684. checkHeader: function PDFDocument_checkHeader() {
  55685. var stream = this.stream;
  55686. stream.reset();
  55687. if (find(stream, '%PDF-', 1024)) {
  55688. stream.moveStart();
  55689. var MAX_VERSION_LENGTH = 12;
  55690. var version = '', ch;
  55691. while ((ch = stream.getByte()) > 0x20) {
  55692. if (version.length >= MAX_VERSION_LENGTH) {
  55693. break;
  55694. }
  55695. version += String.fromCharCode(ch);
  55696. }
  55697. if (!this.pdfFormatVersion) {
  55698. this.pdfFormatVersion = version.substring(5);
  55699. }
  55700. return;
  55701. }
  55702. },
  55703. parseStartXRef: function PDFDocument_parseStartXRef() {
  55704. var startXRef = this.startXRef;
  55705. this.xref.setStartXRef(startXRef);
  55706. },
  55707. setup: function PDFDocument_setup(recoveryMode) {
  55708. this.xref.parse(recoveryMode);
  55709. var self = this;
  55710. var pageFactory = {
  55711. createPage: function (pageIndex, dict, ref, fontCache) {
  55712. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55713. }
  55714. };
  55715. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55716. },
  55717. get numPages() {
  55718. var linearization = this.linearization;
  55719. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55720. return shadow(this, 'numPages', num);
  55721. },
  55722. get documentInfo() {
  55723. var docInfo = {
  55724. PDFFormatVersion: this.pdfFormatVersion,
  55725. IsAcroFormPresent: !!this.acroForm,
  55726. IsXFAPresent: !!this.xfa
  55727. };
  55728. var infoDict;
  55729. try {
  55730. infoDict = this.xref.trailer.get('Info');
  55731. } catch (err) {
  55732. info('The document information dictionary is invalid.');
  55733. }
  55734. if (infoDict) {
  55735. var validEntries = DocumentInfoValidators.entries;
  55736. for (var key in validEntries) {
  55737. if (infoDict.has(key)) {
  55738. var value = infoDict.get(key);
  55739. if (validEntries[key](value)) {
  55740. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55741. } else {
  55742. info('Bad value in document info for "' + key + '"');
  55743. }
  55744. }
  55745. }
  55746. }
  55747. return shadow(this, 'documentInfo', docInfo);
  55748. },
  55749. get fingerprint() {
  55750. var xref = this.xref, hash, fileID = '';
  55751. var idArray = xref.trailer.get('ID');
  55752. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55753. hash = stringToBytes(idArray[0]);
  55754. } else {
  55755. if (this.stream.ensureRange) {
  55756. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55757. }
  55758. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55759. }
  55760. for (var i = 0, n = hash.length; i < n; i++) {
  55761. var hex = hash[i].toString(16);
  55762. fileID += hex.length === 1 ? '0' + hex : hex;
  55763. }
  55764. return shadow(this, 'fingerprint', fileID);
  55765. },
  55766. getPage: function PDFDocument_getPage(pageIndex) {
  55767. return this.catalog.getPage(pageIndex);
  55768. },
  55769. cleanup: function PDFDocument_cleanup() {
  55770. return this.catalog.cleanup();
  55771. }
  55772. };
  55773. return PDFDocument;
  55774. }();
  55775. exports.Page = Page;
  55776. exports.PDFDocument = PDFDocument;
  55777. }));
  55778. (function (root, factory) {
  55779. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55780. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55781. var warn = sharedUtil.warn;
  55782. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55783. var shadow = sharedUtil.shadow;
  55784. var NotImplementedException = sharedUtil.NotImplementedException;
  55785. var MissingDataException = sharedUtil.MissingDataException;
  55786. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55787. var Util = sharedUtil.Util;
  55788. var Stream = coreStream.Stream;
  55789. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55790. var PDFDocument = coreDocument.PDFDocument;
  55791. var BasePdfManager = function BasePdfManagerClosure() {
  55792. function BasePdfManager() {
  55793. throw new Error('Cannot initialize BaseManagerManager');
  55794. }
  55795. BasePdfManager.prototype = {
  55796. get docId() {
  55797. return this._docId;
  55798. },
  55799. get password() {
  55800. return this._password;
  55801. },
  55802. get docBaseUrl() {
  55803. var docBaseUrl = null;
  55804. if (this._docBaseUrl) {
  55805. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55806. if (absoluteUrl) {
  55807. docBaseUrl = absoluteUrl.href;
  55808. } else {
  55809. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55810. }
  55811. }
  55812. return shadow(this, 'docBaseUrl', docBaseUrl);
  55813. },
  55814. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55815. throw new NotImplementedException();
  55816. },
  55817. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55818. return this.ensure(this.pdfDocument, prop, args);
  55819. },
  55820. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55821. return this.ensure(this.pdfDocument.xref, prop, args);
  55822. },
  55823. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55824. return this.ensure(this.pdfDocument.catalog, prop, args);
  55825. },
  55826. getPage: function BasePdfManager_getPage(pageIndex) {
  55827. return this.pdfDocument.getPage(pageIndex);
  55828. },
  55829. cleanup: function BasePdfManager_cleanup() {
  55830. return this.pdfDocument.cleanup();
  55831. },
  55832. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55833. return new NotImplementedException();
  55834. },
  55835. requestRange: function BasePdfManager_requestRange(begin, end) {
  55836. return new NotImplementedException();
  55837. },
  55838. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55839. return new NotImplementedException();
  55840. },
  55841. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55842. return new NotImplementedException();
  55843. },
  55844. updatePassword: function BasePdfManager_updatePassword(password) {
  55845. this._password = password;
  55846. },
  55847. terminate: function BasePdfManager_terminate() {
  55848. return new NotImplementedException();
  55849. }
  55850. };
  55851. return BasePdfManager;
  55852. }();
  55853. var LocalPdfManager = function LocalPdfManagerClosure() {
  55854. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55855. this._docId = docId;
  55856. this._password = password;
  55857. this._docBaseUrl = docBaseUrl;
  55858. this.evaluatorOptions = evaluatorOptions;
  55859. var stream = new Stream(data);
  55860. this.pdfDocument = new PDFDocument(this, stream);
  55861. this._loadedStreamCapability = createPromiseCapability();
  55862. this._loadedStreamCapability.resolve(stream);
  55863. }
  55864. Util.inherit(LocalPdfManager, BasePdfManager, {
  55865. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55866. return new Promise(function (resolve, reject) {
  55867. try {
  55868. var value = obj[prop];
  55869. var result;
  55870. if (typeof value === 'function') {
  55871. result = value.apply(obj, args);
  55872. } else {
  55873. result = value;
  55874. }
  55875. resolve(result);
  55876. } catch (e) {
  55877. reject(e);
  55878. }
  55879. });
  55880. },
  55881. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55882. return Promise.resolve();
  55883. },
  55884. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55885. },
  55886. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55887. return this._loadedStreamCapability.promise;
  55888. },
  55889. terminate: function LocalPdfManager_terminate() {
  55890. }
  55891. });
  55892. return LocalPdfManager;
  55893. }();
  55894. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55895. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55896. this._docId = docId;
  55897. this._password = args.password;
  55898. this._docBaseUrl = docBaseUrl;
  55899. this.msgHandler = args.msgHandler;
  55900. this.evaluatorOptions = evaluatorOptions;
  55901. var params = {
  55902. msgHandler: args.msgHandler,
  55903. url: args.url,
  55904. length: args.length,
  55905. disableAutoFetch: args.disableAutoFetch,
  55906. rangeChunkSize: args.rangeChunkSize
  55907. };
  55908. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55909. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  55910. }
  55911. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55912. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55913. var pdfManager = this;
  55914. return new Promise(function (resolve, reject) {
  55915. function ensureHelper() {
  55916. try {
  55917. var result;
  55918. var value = obj[prop];
  55919. if (typeof value === 'function') {
  55920. result = value.apply(obj, args);
  55921. } else {
  55922. result = value;
  55923. }
  55924. resolve(result);
  55925. } catch (e) {
  55926. if (!(e instanceof MissingDataException)) {
  55927. reject(e);
  55928. return;
  55929. }
  55930. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55931. }
  55932. }
  55933. ensureHelper();
  55934. });
  55935. },
  55936. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55937. return this.streamManager.requestRange(begin, end);
  55938. },
  55939. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55940. this.streamManager.requestAllChunks();
  55941. },
  55942. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55943. this.streamManager.onReceiveData({ chunk: chunk });
  55944. },
  55945. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55946. return this.streamManager.onLoadedStream();
  55947. },
  55948. terminate: function NetworkPdfManager_terminate() {
  55949. this.streamManager.abort();
  55950. }
  55951. });
  55952. return NetworkPdfManager;
  55953. }();
  55954. exports.LocalPdfManager = LocalPdfManager;
  55955. exports.NetworkPdfManager = NetworkPdfManager;
  55956. }));
  55957. (function (root, factory) {
  55958. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55959. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55960. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55961. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55962. var MessageHandler = sharedUtil.MessageHandler;
  55963. var MissingPDFException = sharedUtil.MissingPDFException;
  55964. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55965. var PasswordException = sharedUtil.PasswordException;
  55966. var PasswordResponses = sharedUtil.PasswordResponses;
  55967. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55968. var XRefParseException = sharedUtil.XRefParseException;
  55969. var arrayByteLength = sharedUtil.arrayByteLength;
  55970. var arraysToBytes = sharedUtil.arraysToBytes;
  55971. var assert = sharedUtil.assert;
  55972. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55973. var error = sharedUtil.error;
  55974. var info = sharedUtil.info;
  55975. var warn = sharedUtil.warn;
  55976. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55977. var Ref = corePrimitives.Ref;
  55978. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55979. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55980. var globalScope = sharedUtil.globalScope;
  55981. var WorkerTask = function WorkerTaskClosure() {
  55982. function WorkerTask(name) {
  55983. this.name = name;
  55984. this.terminated = false;
  55985. this._capability = createPromiseCapability();
  55986. }
  55987. WorkerTask.prototype = {
  55988. get finished() {
  55989. return this._capability.promise;
  55990. },
  55991. finish: function () {
  55992. this._capability.resolve();
  55993. },
  55994. terminate: function () {
  55995. this.terminated = true;
  55996. },
  55997. ensureNotTerminated: function () {
  55998. if (this.terminated) {
  55999. throw new Error('Worker task was terminated');
  56000. }
  56001. }
  56002. };
  56003. return WorkerTask;
  56004. }();
  56005. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  56006. function PDFWorkerStream(params, msgHandler) {
  56007. this._queuedChunks = [];
  56008. var initialData = params.initialData;
  56009. if (initialData && initialData.length > 0) {
  56010. this._queuedChunks.push(initialData);
  56011. }
  56012. this._msgHandler = msgHandler;
  56013. this._isRangeSupported = !params.disableRange;
  56014. this._isStreamingSupported = !params.disableStream;
  56015. this._contentLength = params.length;
  56016. this._fullRequestReader = null;
  56017. this._rangeReaders = [];
  56018. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  56019. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  56020. }
  56021. PDFWorkerStream.prototype = {
  56022. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  56023. if (args.begin === undefined) {
  56024. if (this._fullRequestReader) {
  56025. this._fullRequestReader._enqueue(args.chunk);
  56026. } else {
  56027. this._queuedChunks.push(args.chunk);
  56028. }
  56029. } else {
  56030. var found = this._rangeReaders.some(function (rangeReader) {
  56031. if (rangeReader._begin !== args.begin) {
  56032. return false;
  56033. }
  56034. rangeReader._enqueue(args.chunk);
  56035. return true;
  56036. });
  56037. assert(found);
  56038. }
  56039. },
  56040. _onProgress: function PDFWorkerStream_onProgress(evt) {
  56041. if (this._rangeReaders.length > 0) {
  56042. var firstReader = this._rangeReaders[0];
  56043. if (firstReader.onProgress) {
  56044. firstReader.onProgress({ loaded: evt.loaded });
  56045. }
  56046. }
  56047. },
  56048. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  56049. var i = this._rangeReaders.indexOf(reader);
  56050. if (i >= 0) {
  56051. this._rangeReaders.splice(i, 1);
  56052. }
  56053. },
  56054. getFullReader: function PDFWorkerStream_getFullReader() {
  56055. assert(!this._fullRequestReader);
  56056. var queuedChunks = this._queuedChunks;
  56057. this._queuedChunks = null;
  56058. return new PDFWorkerStreamReader(this, queuedChunks);
  56059. },
  56060. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  56061. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  56062. this._msgHandler.send('RequestDataRange', {
  56063. begin: begin,
  56064. end: end
  56065. });
  56066. this._rangeReaders.push(reader);
  56067. return reader;
  56068. },
  56069. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  56070. if (this._fullRequestReader) {
  56071. this._fullRequestReader.cancel(reason);
  56072. }
  56073. var readers = this._rangeReaders.slice(0);
  56074. readers.forEach(function (rangeReader) {
  56075. rangeReader.cancel(reason);
  56076. });
  56077. }
  56078. };
  56079. function PDFWorkerStreamReader(stream, queuedChunks) {
  56080. this._stream = stream;
  56081. this._done = false;
  56082. this._queuedChunks = queuedChunks || [];
  56083. this._requests = [];
  56084. this._headersReady = Promise.resolve();
  56085. stream._fullRequestReader = this;
  56086. this.onProgress = null;
  56087. }
  56088. PDFWorkerStreamReader.prototype = {
  56089. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  56090. if (this._done) {
  56091. return;
  56092. }
  56093. if (this._requests.length > 0) {
  56094. var requestCapability = this._requests.shift();
  56095. requestCapability.resolve({
  56096. value: chunk,
  56097. done: false
  56098. });
  56099. return;
  56100. }
  56101. this._queuedChunks.push(chunk);
  56102. },
  56103. get headersReady() {
  56104. return this._headersReady;
  56105. },
  56106. get isRangeSupported() {
  56107. return this._stream._isRangeSupported;
  56108. },
  56109. get isStreamingSupported() {
  56110. return this._stream._isStreamingSupported;
  56111. },
  56112. get contentLength() {
  56113. return this._stream._contentLength;
  56114. },
  56115. read: function PDFWorkerStreamReader_read() {
  56116. if (this._queuedChunks.length > 0) {
  56117. var chunk = this._queuedChunks.shift();
  56118. return Promise.resolve({
  56119. value: chunk,
  56120. done: false
  56121. });
  56122. }
  56123. if (this._done) {
  56124. return Promise.resolve({
  56125. value: undefined,
  56126. done: true
  56127. });
  56128. }
  56129. var requestCapability = createPromiseCapability();
  56130. this._requests.push(requestCapability);
  56131. return requestCapability.promise;
  56132. },
  56133. cancel: function PDFWorkerStreamReader_cancel(reason) {
  56134. this._done = true;
  56135. this._requests.forEach(function (requestCapability) {
  56136. requestCapability.resolve({
  56137. value: undefined,
  56138. done: true
  56139. });
  56140. });
  56141. this._requests = [];
  56142. }
  56143. };
  56144. function PDFWorkerStreamRangeReader(stream, begin, end) {
  56145. this._stream = stream;
  56146. this._begin = begin;
  56147. this._end = end;
  56148. this._queuedChunk = null;
  56149. this._requests = [];
  56150. this._done = false;
  56151. this.onProgress = null;
  56152. }
  56153. PDFWorkerStreamRangeReader.prototype = {
  56154. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  56155. if (this._done) {
  56156. return;
  56157. }
  56158. if (this._requests.length === 0) {
  56159. this._queuedChunk = chunk;
  56160. } else {
  56161. var requestsCapability = this._requests.shift();
  56162. requestsCapability.resolve({
  56163. value: chunk,
  56164. done: false
  56165. });
  56166. this._requests.forEach(function (requestCapability) {
  56167. requestCapability.resolve({
  56168. value: undefined,
  56169. done: true
  56170. });
  56171. });
  56172. this._requests = [];
  56173. }
  56174. this._done = true;
  56175. this._stream._removeRangeReader(this);
  56176. },
  56177. get isStreamingSupported() {
  56178. return false;
  56179. },
  56180. read: function PDFWorkerStreamRangeReader_read() {
  56181. if (this._queuedChunk) {
  56182. return Promise.resolve({
  56183. value: this._queuedChunk,
  56184. done: false
  56185. });
  56186. }
  56187. if (this._done) {
  56188. return Promise.resolve({
  56189. value: undefined,
  56190. done: true
  56191. });
  56192. }
  56193. var requestCapability = createPromiseCapability();
  56194. this._requests.push(requestCapability);
  56195. return requestCapability.promise;
  56196. },
  56197. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  56198. this._done = true;
  56199. this._requests.forEach(function (requestCapability) {
  56200. requestCapability.resolve({
  56201. value: undefined,
  56202. done: true
  56203. });
  56204. });
  56205. this._requests = [];
  56206. this._stream._removeRangeReader(this);
  56207. }
  56208. };
  56209. return PDFWorkerStream;
  56210. }();
  56211. var PDFNetworkStream;
  56212. function setPDFNetworkStreamClass(cls) {
  56213. PDFNetworkStream = cls;
  56214. }
  56215. var WorkerMessageHandler = {
  56216. setup: function wphSetup(handler, port) {
  56217. var testMessageProcessed = false;
  56218. handler.on('test', function wphSetupTest(data) {
  56219. if (testMessageProcessed) {
  56220. return;
  56221. }
  56222. testMessageProcessed = true;
  56223. if (!(data instanceof Uint8Array)) {
  56224. handler.send('test', 'main', false);
  56225. return;
  56226. }
  56227. var supportTransfers = data[0] === 255;
  56228. handler.postMessageTransfers = supportTransfers;
  56229. var xhr = new XMLHttpRequest();
  56230. var responseExists = 'response' in xhr;
  56231. try {
  56232. var dummy = xhr.responseType;
  56233. } catch (e) {
  56234. responseExists = false;
  56235. }
  56236. if (!responseExists) {
  56237. handler.send('test', false);
  56238. return;
  56239. }
  56240. handler.send('test', {
  56241. supportTypedArray: true,
  56242. supportTransfers: supportTransfers
  56243. });
  56244. });
  56245. handler.on('configure', function wphConfigure(data) {
  56246. setVerbosityLevel(data.verbosity);
  56247. });
  56248. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56249. return WorkerMessageHandler.createDocumentHandler(data, port);
  56250. });
  56251. },
  56252. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56253. var pdfManager;
  56254. var terminated = false;
  56255. var cancelXHRs = null;
  56256. var WorkerTasks = [];
  56257. var docId = docParams.docId;
  56258. var docBaseUrl = docParams.docBaseUrl;
  56259. var workerHandlerName = docParams.docId + '_worker';
  56260. var handler = new MessageHandler(workerHandlerName, docId, port);
  56261. handler.postMessageTransfers = docParams.postMessageTransfers;
  56262. function ensureNotTerminated() {
  56263. if (terminated) {
  56264. throw new Error('Worker was terminated');
  56265. }
  56266. }
  56267. function startWorkerTask(task) {
  56268. WorkerTasks.push(task);
  56269. }
  56270. function finishWorkerTask(task) {
  56271. task.finish();
  56272. var i = WorkerTasks.indexOf(task);
  56273. WorkerTasks.splice(i, 1);
  56274. }
  56275. function loadDocument(recoveryMode) {
  56276. var loadDocumentCapability = createPromiseCapability();
  56277. var parseSuccess = function parseSuccess() {
  56278. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56279. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56280. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56281. Promise.all([
  56282. numPagesPromise,
  56283. fingerprintPromise,
  56284. encryptedPromise
  56285. ]).then(function onDocReady(results) {
  56286. var doc = {
  56287. numPages: results[0],
  56288. fingerprint: results[1],
  56289. encrypted: !!results[2]
  56290. };
  56291. loadDocumentCapability.resolve(doc);
  56292. }, parseFailure);
  56293. };
  56294. var parseFailure = function parseFailure(e) {
  56295. loadDocumentCapability.reject(e);
  56296. };
  56297. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56298. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56299. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56300. }, parseFailure);
  56301. }, parseFailure);
  56302. return loadDocumentCapability.promise;
  56303. }
  56304. function getPdfManager(data, evaluatorOptions) {
  56305. var pdfManagerCapability = createPromiseCapability();
  56306. var pdfManager;
  56307. var source = data.source;
  56308. if (source.data) {
  56309. try {
  56310. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56311. pdfManagerCapability.resolve(pdfManager);
  56312. } catch (ex) {
  56313. pdfManagerCapability.reject(ex);
  56314. }
  56315. return pdfManagerCapability.promise;
  56316. }
  56317. var pdfStream;
  56318. try {
  56319. if (source.chunkedViewerLoading) {
  56320. pdfStream = new PDFWorkerStream(source, handler);
  56321. } else {
  56322. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56323. pdfStream = new PDFNetworkStream(data);
  56324. }
  56325. } catch (ex) {
  56326. pdfManagerCapability.reject(ex);
  56327. return pdfManagerCapability.promise;
  56328. }
  56329. var fullRequest = pdfStream.getFullReader();
  56330. fullRequest.headersReady.then(function () {
  56331. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56332. fullRequest.onProgress = function (evt) {
  56333. handler.send('DocProgress', {
  56334. loaded: evt.loaded,
  56335. total: evt.total
  56336. });
  56337. };
  56338. }
  56339. if (!fullRequest.isRangeSupported) {
  56340. return;
  56341. }
  56342. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56343. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56344. msgHandler: handler,
  56345. url: source.url,
  56346. password: source.password,
  56347. length: fullRequest.contentLength,
  56348. disableAutoFetch: disableAutoFetch,
  56349. rangeChunkSize: source.rangeChunkSize
  56350. }, evaluatorOptions, docBaseUrl);
  56351. pdfManagerCapability.resolve(pdfManager);
  56352. cancelXHRs = null;
  56353. }).catch(function (reason) {
  56354. pdfManagerCapability.reject(reason);
  56355. cancelXHRs = null;
  56356. });
  56357. var cachedChunks = [], loaded = 0;
  56358. var flushChunks = function () {
  56359. var pdfFile = arraysToBytes(cachedChunks);
  56360. if (source.length && pdfFile.length !== source.length) {
  56361. warn('reported HTTP length is different from actual');
  56362. }
  56363. try {
  56364. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56365. pdfManagerCapability.resolve(pdfManager);
  56366. } catch (ex) {
  56367. pdfManagerCapability.reject(ex);
  56368. }
  56369. cachedChunks = [];
  56370. };
  56371. var readPromise = new Promise(function (resolve, reject) {
  56372. var readChunk = function (chunk) {
  56373. try {
  56374. ensureNotTerminated();
  56375. if (chunk.done) {
  56376. if (!pdfManager) {
  56377. flushChunks();
  56378. }
  56379. cancelXHRs = null;
  56380. return;
  56381. }
  56382. var data = chunk.value;
  56383. loaded += arrayByteLength(data);
  56384. if (!fullRequest.isStreamingSupported) {
  56385. handler.send('DocProgress', {
  56386. loaded: loaded,
  56387. total: Math.max(loaded, fullRequest.contentLength || 0)
  56388. });
  56389. }
  56390. if (pdfManager) {
  56391. pdfManager.sendProgressiveData(data);
  56392. } else {
  56393. cachedChunks.push(data);
  56394. }
  56395. fullRequest.read().then(readChunk, reject);
  56396. } catch (e) {
  56397. reject(e);
  56398. }
  56399. };
  56400. fullRequest.read().then(readChunk, reject);
  56401. });
  56402. readPromise.catch(function (e) {
  56403. pdfManagerCapability.reject(e);
  56404. cancelXHRs = null;
  56405. });
  56406. cancelXHRs = function () {
  56407. pdfStream.cancelAllRequests('abort');
  56408. };
  56409. return pdfManagerCapability.promise;
  56410. }
  56411. function setupDoc(data) {
  56412. function onSuccess(doc) {
  56413. ensureNotTerminated();
  56414. handler.send('GetDoc', { pdfInfo: doc });
  56415. }
  56416. function onFailure(e) {
  56417. if (e instanceof PasswordException) {
  56418. var task = new WorkerTask('PasswordException: response ' + e.code);
  56419. startWorkerTask(task);
  56420. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  56421. finishWorkerTask(task);
  56422. pdfManager.updatePassword(data.password);
  56423. pdfManagerReady();
  56424. }).catch(function (ex) {
  56425. finishWorkerTask(task);
  56426. handler.send('PasswordException', ex);
  56427. }.bind(null, e));
  56428. } else if (e instanceof InvalidPDFException) {
  56429. handler.send('InvalidPDF', e);
  56430. } else if (e instanceof MissingPDFException) {
  56431. handler.send('MissingPDF', e);
  56432. } else if (e instanceof UnexpectedResponseException) {
  56433. handler.send('UnexpectedResponse', e);
  56434. } else {
  56435. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56436. }
  56437. }
  56438. function pdfManagerReady() {
  56439. ensureNotTerminated();
  56440. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56441. ensureNotTerminated();
  56442. if (!(ex instanceof XRefParseException)) {
  56443. onFailure(ex);
  56444. return;
  56445. }
  56446. pdfManager.requestLoadedStream();
  56447. pdfManager.onLoadedStream().then(function () {
  56448. ensureNotTerminated();
  56449. loadDocument(true).then(onSuccess, onFailure);
  56450. });
  56451. }, onFailure);
  56452. }
  56453. ensureNotTerminated();
  56454. var cMapOptions = {
  56455. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56456. packed: data.cMapPacked === true
  56457. };
  56458. var evaluatorOptions = {
  56459. forceDataSchema: data.disableCreateObjectURL,
  56460. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56461. disableFontFace: data.disableFontFace,
  56462. cMapOptions: cMapOptions
  56463. };
  56464. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56465. if (terminated) {
  56466. newPdfManager.terminate();
  56467. throw new Error('Worker was terminated');
  56468. }
  56469. pdfManager = newPdfManager;
  56470. handler.send('PDFManagerReady', null);
  56471. pdfManager.onLoadedStream().then(function (stream) {
  56472. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56473. });
  56474. }).then(pdfManagerReady, onFailure);
  56475. }
  56476. handler.on('GetPage', function wphSetupGetPage(data) {
  56477. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56478. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56479. var refPromise = pdfManager.ensure(page, 'ref');
  56480. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  56481. var viewPromise = pdfManager.ensure(page, 'view');
  56482. return Promise.all([
  56483. rotatePromise,
  56484. refPromise,
  56485. userUnitPromise,
  56486. viewPromise
  56487. ]).then(function (results) {
  56488. return {
  56489. rotate: results[0],
  56490. ref: results[1],
  56491. userUnit: results[2],
  56492. view: results[3]
  56493. };
  56494. });
  56495. });
  56496. });
  56497. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56498. var ref = new Ref(data.ref.num, data.ref.gen);
  56499. var catalog = pdfManager.pdfDocument.catalog;
  56500. return catalog.getPageIndex(ref);
  56501. });
  56502. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56503. return pdfManager.ensureCatalog('destinations');
  56504. });
  56505. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56506. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56507. });
  56508. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56509. return pdfManager.ensureCatalog('pageLabels');
  56510. });
  56511. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56512. return pdfManager.ensureCatalog('attachments');
  56513. });
  56514. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56515. return pdfManager.ensureCatalog('javaScript');
  56516. });
  56517. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56518. return pdfManager.ensureCatalog('documentOutline');
  56519. });
  56520. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56521. return Promise.all([
  56522. pdfManager.ensureDoc('documentInfo'),
  56523. pdfManager.ensureCatalog('metadata')
  56524. ]);
  56525. });
  56526. handler.on('GetData', function wphSetupGetData(data) {
  56527. pdfManager.requestLoadedStream();
  56528. return pdfManager.onLoadedStream().then(function (stream) {
  56529. return stream.bytes;
  56530. });
  56531. });
  56532. handler.on('GetStats', function wphSetupGetStats(data) {
  56533. return pdfManager.pdfDocument.xref.stats;
  56534. });
  56535. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56536. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56537. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56538. });
  56539. });
  56540. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56541. var pageIndex = data.pageIndex;
  56542. pdfManager.getPage(pageIndex).then(function (page) {
  56543. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56544. startWorkerTask(task);
  56545. var pageNum = pageIndex + 1;
  56546. var start = Date.now();
  56547. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56548. finishWorkerTask(task);
  56549. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56550. }, function (e) {
  56551. finishWorkerTask(task);
  56552. if (task.terminated) {
  56553. return;
  56554. }
  56555. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56556. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56557. var wrappedException;
  56558. if (typeof e === 'string') {
  56559. wrappedException = {
  56560. message: e,
  56561. stack: minimumStackMessage
  56562. };
  56563. } else if (typeof e === 'object') {
  56564. wrappedException = {
  56565. message: e.message || e.toString(),
  56566. stack: e.stack || minimumStackMessage
  56567. };
  56568. } else {
  56569. wrappedException = {
  56570. message: 'Unknown exception type: ' + typeof e,
  56571. stack: minimumStackMessage
  56572. };
  56573. }
  56574. handler.send('PageError', {
  56575. pageNum: pageNum,
  56576. error: wrappedException,
  56577. intent: data.intent
  56578. });
  56579. });
  56580. });
  56581. }, this);
  56582. handler.on('GetTextContent', function wphExtractText(data) {
  56583. var pageIndex = data.pageIndex;
  56584. var normalizeWhitespace = data.normalizeWhitespace;
  56585. var combineTextItems = data.combineTextItems;
  56586. return pdfManager.getPage(pageIndex).then(function (page) {
  56587. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56588. startWorkerTask(task);
  56589. var pageNum = pageIndex + 1;
  56590. var start = Date.now();
  56591. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56592. finishWorkerTask(task);
  56593. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56594. return textContent;
  56595. }, function (reason) {
  56596. finishWorkerTask(task);
  56597. if (task.terminated) {
  56598. return;
  56599. }
  56600. throw reason;
  56601. });
  56602. });
  56603. });
  56604. handler.on('Cleanup', function wphCleanup(data) {
  56605. return pdfManager.cleanup();
  56606. });
  56607. handler.on('Terminate', function wphTerminate(data) {
  56608. terminated = true;
  56609. if (pdfManager) {
  56610. pdfManager.terminate();
  56611. pdfManager = null;
  56612. }
  56613. if (cancelXHRs) {
  56614. cancelXHRs();
  56615. }
  56616. var waitOn = [];
  56617. WorkerTasks.forEach(function (task) {
  56618. waitOn.push(task.finished);
  56619. task.terminate();
  56620. });
  56621. return Promise.all(waitOn).then(function () {
  56622. handler.destroy();
  56623. handler = null;
  56624. });
  56625. });
  56626. handler.on('Ready', function wphReady(data) {
  56627. setupDoc(docParams);
  56628. docParams = null;
  56629. });
  56630. return workerHandlerName;
  56631. }
  56632. };
  56633. function initializeWorker() {
  56634. if (!('console' in globalScope)) {
  56635. var consoleTimer = {};
  56636. var workerConsole = {
  56637. log: function log() {
  56638. var args = Array.prototype.slice.call(arguments);
  56639. globalScope.postMessage({
  56640. targetName: 'main',
  56641. action: 'console_log',
  56642. data: args
  56643. });
  56644. },
  56645. error: function error() {
  56646. var args = Array.prototype.slice.call(arguments);
  56647. globalScope.postMessage({
  56648. targetName: 'main',
  56649. action: 'console_error',
  56650. data: args
  56651. });
  56652. throw 'pdf.js execution error';
  56653. },
  56654. time: function time(name) {
  56655. consoleTimer[name] = Date.now();
  56656. },
  56657. timeEnd: function timeEnd(name) {
  56658. var time = consoleTimer[name];
  56659. if (!time) {
  56660. error('Unknown timer name ' + name);
  56661. }
  56662. this.log('Timer:', name, Date.now() - time);
  56663. }
  56664. };
  56665. globalScope.console = workerConsole;
  56666. }
  56667. var handler = new MessageHandler('worker', 'main', self);
  56668. WorkerMessageHandler.setup(handler, self);
  56669. handler.send('ready', null);
  56670. }
  56671. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56672. initializeWorker();
  56673. }
  56674. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56675. exports.WorkerTask = WorkerTask;
  56676. exports.WorkerMessageHandler = WorkerMessageHandler;
  56677. }));
  56678. (function (root, factory) {
  56679. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56680. }(this, function (exports, sharedUtil, coreWorker) {
  56681. var OK_RESPONSE = 200;
  56682. var PARTIAL_CONTENT_RESPONSE = 206;
  56683. function NetworkManager(url, args) {
  56684. this.url = url;
  56685. args = args || {};
  56686. this.isHttp = /^https?:/i.test(url);
  56687. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56688. this.withCredentials = args.withCredentials || false;
  56689. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56690. return new XMLHttpRequest();
  56691. };
  56692. this.currXhrId = 0;
  56693. this.pendingRequests = Object.create(null);
  56694. this.loadedRequests = Object.create(null);
  56695. }
  56696. function getArrayBuffer(xhr) {
  56697. var data = xhr.response;
  56698. if (typeof data !== 'string') {
  56699. return data;
  56700. }
  56701. var length = data.length;
  56702. var array = new Uint8Array(length);
  56703. for (var i = 0; i < length; i++) {
  56704. array[i] = data.charCodeAt(i) & 0xFF;
  56705. }
  56706. return array.buffer;
  56707. }
  56708. var supportsMozChunked = function supportsMozChunkedClosure() {
  56709. try {
  56710. var x = new XMLHttpRequest();
  56711. x.open('GET', 'https://example.com');
  56712. x.responseType = 'moz-chunked-arraybuffer';
  56713. return x.responseType === 'moz-chunked-arraybuffer';
  56714. } catch (e) {
  56715. return false;
  56716. }
  56717. }();
  56718. NetworkManager.prototype = {
  56719. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56720. var args = {
  56721. begin: begin,
  56722. end: end
  56723. };
  56724. for (var prop in listeners) {
  56725. args[prop] = listeners[prop];
  56726. }
  56727. return this.request(args);
  56728. },
  56729. requestFull: function NetworkManager_requestFull(listeners) {
  56730. return this.request(listeners);
  56731. },
  56732. request: function NetworkManager_request(args) {
  56733. var xhr = this.getXhr();
  56734. var xhrId = this.currXhrId++;
  56735. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56736. xhr.open('GET', this.url);
  56737. xhr.withCredentials = this.withCredentials;
  56738. for (var property in this.httpHeaders) {
  56739. var value = this.httpHeaders[property];
  56740. if (typeof value === 'undefined') {
  56741. continue;
  56742. }
  56743. xhr.setRequestHeader(property, value);
  56744. }
  56745. if (this.isHttp && 'begin' in args && 'end' in args) {
  56746. var rangeStr = args.begin + '-' + (args.end - 1);
  56747. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56748. pendingRequest.expectedStatus = 206;
  56749. } else {
  56750. pendingRequest.expectedStatus = 200;
  56751. }
  56752. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56753. if (useMozChunkedLoading) {
  56754. xhr.responseType = 'moz-chunked-arraybuffer';
  56755. pendingRequest.onProgressiveData = args.onProgressiveData;
  56756. pendingRequest.mozChunked = true;
  56757. } else {
  56758. xhr.responseType = 'arraybuffer';
  56759. }
  56760. if (args.onError) {
  56761. xhr.onerror = function (evt) {
  56762. args.onError(xhr.status);
  56763. };
  56764. }
  56765. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56766. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56767. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56768. pendingRequest.onDone = args.onDone;
  56769. pendingRequest.onError = args.onError;
  56770. pendingRequest.onProgress = args.onProgress;
  56771. xhr.send(null);
  56772. return xhrId;
  56773. },
  56774. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56775. var pendingRequest = this.pendingRequests[xhrId];
  56776. if (!pendingRequest) {
  56777. return;
  56778. }
  56779. if (pendingRequest.mozChunked) {
  56780. var chunk = getArrayBuffer(pendingRequest.xhr);
  56781. pendingRequest.onProgressiveData(chunk);
  56782. }
  56783. var onProgress = pendingRequest.onProgress;
  56784. if (onProgress) {
  56785. onProgress(evt);
  56786. }
  56787. },
  56788. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56789. var pendingRequest = this.pendingRequests[xhrId];
  56790. if (!pendingRequest) {
  56791. return;
  56792. }
  56793. var xhr = pendingRequest.xhr;
  56794. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56795. pendingRequest.onHeadersReceived();
  56796. delete pendingRequest.onHeadersReceived;
  56797. }
  56798. if (xhr.readyState !== 4) {
  56799. return;
  56800. }
  56801. if (!(xhrId in this.pendingRequests)) {
  56802. return;
  56803. }
  56804. delete this.pendingRequests[xhrId];
  56805. if (xhr.status === 0 && this.isHttp) {
  56806. if (pendingRequest.onError) {
  56807. pendingRequest.onError(xhr.status);
  56808. }
  56809. return;
  56810. }
  56811. var xhrStatus = xhr.status || OK_RESPONSE;
  56812. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56813. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56814. if (pendingRequest.onError) {
  56815. pendingRequest.onError(xhr.status);
  56816. }
  56817. return;
  56818. }
  56819. this.loadedRequests[xhrId] = true;
  56820. var chunk = getArrayBuffer(xhr);
  56821. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56822. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56823. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56824. var begin = parseInt(matches[1], 10);
  56825. pendingRequest.onDone({
  56826. begin: begin,
  56827. chunk: chunk
  56828. });
  56829. } else if (pendingRequest.onProgressiveData) {
  56830. pendingRequest.onDone(null);
  56831. } else if (chunk) {
  56832. pendingRequest.onDone({
  56833. begin: 0,
  56834. chunk: chunk
  56835. });
  56836. } else if (pendingRequest.onError) {
  56837. pendingRequest.onError(xhr.status);
  56838. }
  56839. },
  56840. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56841. for (var xhrId in this.pendingRequests) {
  56842. return true;
  56843. }
  56844. return false;
  56845. },
  56846. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56847. return this.pendingRequests[xhrId].xhr;
  56848. },
  56849. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56850. return !!this.pendingRequests[xhrId].onProgressiveData;
  56851. },
  56852. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56853. return xhrId in this.pendingRequests;
  56854. },
  56855. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56856. return xhrId in this.loadedRequests;
  56857. },
  56858. abortAllRequests: function NetworkManager_abortAllRequests() {
  56859. for (var xhrId in this.pendingRequests) {
  56860. this.abortRequest(xhrId | 0);
  56861. }
  56862. },
  56863. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56864. var xhr = this.pendingRequests[xhrId].xhr;
  56865. delete this.pendingRequests[xhrId];
  56866. xhr.abort();
  56867. }
  56868. };
  56869. var assert = sharedUtil.assert;
  56870. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56871. var isInt = sharedUtil.isInt;
  56872. var MissingPDFException = sharedUtil.MissingPDFException;
  56873. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56874. function PDFNetworkStream(options) {
  56875. this._options = options;
  56876. var source = options.source;
  56877. this._manager = new NetworkManager(source.url, {
  56878. httpHeaders: source.httpHeaders,
  56879. withCredentials: source.withCredentials
  56880. });
  56881. this._rangeChunkSize = source.rangeChunkSize;
  56882. this._fullRequestReader = null;
  56883. this._rangeRequestReaders = [];
  56884. }
  56885. PDFNetworkStream.prototype = {
  56886. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56887. var i = this._rangeRequestReaders.indexOf(reader);
  56888. if (i >= 0) {
  56889. this._rangeRequestReaders.splice(i, 1);
  56890. }
  56891. },
  56892. getFullReader: function PDFNetworkStream_getFullReader() {
  56893. assert(!this._fullRequestReader);
  56894. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56895. return this._fullRequestReader;
  56896. },
  56897. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56898. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56899. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56900. this._rangeRequestReaders.push(reader);
  56901. return reader;
  56902. },
  56903. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56904. if (this._fullRequestReader) {
  56905. this._fullRequestReader.cancel(reason);
  56906. }
  56907. var readers = this._rangeRequestReaders.slice(0);
  56908. readers.forEach(function (reader) {
  56909. reader.cancel(reason);
  56910. });
  56911. }
  56912. };
  56913. function PDFNetworkStreamFullRequestReader(manager, options) {
  56914. this._manager = manager;
  56915. var source = options.source;
  56916. var args = {
  56917. onHeadersReceived: this._onHeadersReceived.bind(this),
  56918. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56919. onDone: this._onDone.bind(this),
  56920. onError: this._onError.bind(this),
  56921. onProgress: this._onProgress.bind(this)
  56922. };
  56923. this._url = source.url;
  56924. this._fullRequestId = manager.requestFull(args);
  56925. this._headersReceivedCapability = createPromiseCapability();
  56926. this._disableRange = options.disableRange || false;
  56927. this._contentLength = source.length;
  56928. this._rangeChunkSize = source.rangeChunkSize;
  56929. if (!this._rangeChunkSize && !this._disableRange) {
  56930. this._disableRange = true;
  56931. }
  56932. this._isStreamingSupported = false;
  56933. this._isRangeSupported = false;
  56934. this._cachedChunks = [];
  56935. this._requests = [];
  56936. this._done = false;
  56937. this._storedError = undefined;
  56938. this.onProgress = null;
  56939. }
  56940. PDFNetworkStreamFullRequestReader.prototype = {
  56941. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56942. if (this._disableRange) {
  56943. return false;
  56944. }
  56945. var networkManager = this._manager;
  56946. if (!networkManager.isHttp) {
  56947. return false;
  56948. }
  56949. var fullRequestXhrId = this._fullRequestId;
  56950. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56951. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56952. return false;
  56953. }
  56954. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56955. if (contentEncoding !== 'identity') {
  56956. return false;
  56957. }
  56958. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56959. length = parseInt(length, 10);
  56960. if (!isInt(length)) {
  56961. return false;
  56962. }
  56963. this._contentLength = length;
  56964. if (length <= 2 * this._rangeChunkSize) {
  56965. return false;
  56966. }
  56967. return true;
  56968. },
  56969. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56970. if (this._validateRangeRequestCapabilities()) {
  56971. this._isRangeSupported = true;
  56972. }
  56973. var networkManager = this._manager;
  56974. var fullRequestXhrId = this._fullRequestId;
  56975. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56976. this._isStreamingSupported = true;
  56977. } else if (this._isRangeSupported) {
  56978. networkManager.abortRequest(fullRequestXhrId);
  56979. }
  56980. this._headersReceivedCapability.resolve();
  56981. },
  56982. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56983. if (this._requests.length > 0) {
  56984. var requestCapability = this._requests.shift();
  56985. requestCapability.resolve({
  56986. value: chunk,
  56987. done: false
  56988. });
  56989. } else {
  56990. this._cachedChunks.push(chunk);
  56991. }
  56992. },
  56993. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56994. if (args) {
  56995. this._onProgressiveData(args.chunk);
  56996. }
  56997. this._done = true;
  56998. if (this._cachedChunks.length > 0) {
  56999. return;
  57000. }
  57001. this._requests.forEach(function (requestCapability) {
  57002. requestCapability.resolve({
  57003. value: undefined,
  57004. done: true
  57005. });
  57006. });
  57007. this._requests = [];
  57008. },
  57009. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  57010. var url = this._url;
  57011. var exception;
  57012. if (status === 404 || status === 0 && /^file:/.test(url)) {
  57013. exception = new MissingPDFException('Missing PDF "' + url + '".');
  57014. } else {
  57015. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  57016. }
  57017. this._storedError = exception;
  57018. this._headersReceivedCapability.reject(exception);
  57019. this._requests.forEach(function (requestCapability) {
  57020. requestCapability.reject(exception);
  57021. });
  57022. this._requests = [];
  57023. this._cachedChunks = [];
  57024. },
  57025. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  57026. if (this.onProgress) {
  57027. this.onProgress({
  57028. loaded: data.loaded,
  57029. total: data.lengthComputable ? data.total : this._contentLength
  57030. });
  57031. }
  57032. },
  57033. get isRangeSupported() {
  57034. return this._isRangeSupported;
  57035. },
  57036. get isStreamingSupported() {
  57037. return this._isStreamingSupported;
  57038. },
  57039. get contentLength() {
  57040. return this._contentLength;
  57041. },
  57042. get headersReady() {
  57043. return this._headersReceivedCapability.promise;
  57044. },
  57045. read: function PDFNetworkStreamFullRequestReader_read() {
  57046. if (this._storedError) {
  57047. return Promise.reject(this._storedError);
  57048. }
  57049. if (this._cachedChunks.length > 0) {
  57050. var chunk = this._cachedChunks.shift();
  57051. return Promise.resolve(chunk);
  57052. }
  57053. if (this._done) {
  57054. return Promise.resolve({
  57055. value: undefined,
  57056. done: true
  57057. });
  57058. }
  57059. var requestCapability = createPromiseCapability();
  57060. this._requests.push(requestCapability);
  57061. return requestCapability.promise;
  57062. },
  57063. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  57064. this._done = true;
  57065. this._headersReceivedCapability.reject(reason);
  57066. this._requests.forEach(function (requestCapability) {
  57067. requestCapability.resolve({
  57068. value: undefined,
  57069. done: true
  57070. });
  57071. });
  57072. this._requests = [];
  57073. if (this._manager.isPendingRequest(this._fullRequestId)) {
  57074. this._manager.abortRequest(this._fullRequestId);
  57075. }
  57076. this._fullRequestReader = null;
  57077. }
  57078. };
  57079. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  57080. this._manager = manager;
  57081. var args = {
  57082. onDone: this._onDone.bind(this),
  57083. onProgress: this._onProgress.bind(this)
  57084. };
  57085. this._requestId = manager.requestRange(begin, end, args);
  57086. this._requests = [];
  57087. this._queuedChunk = null;
  57088. this._done = false;
  57089. this.onProgress = null;
  57090. this.onClosed = null;
  57091. }
  57092. PDFNetworkStreamRangeRequestReader.prototype = {
  57093. _close: function PDFNetworkStreamRangeRequestReader_close() {
  57094. if (this.onClosed) {
  57095. this.onClosed(this);
  57096. }
  57097. },
  57098. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  57099. var chunk = data.chunk;
  57100. if (this._requests.length > 0) {
  57101. var requestCapability = this._requests.shift();
  57102. requestCapability.resolve({
  57103. value: chunk,
  57104. done: false
  57105. });
  57106. } else {
  57107. this._queuedChunk = chunk;
  57108. }
  57109. this._done = true;
  57110. this._requests.forEach(function (requestCapability) {
  57111. requestCapability.resolve({
  57112. value: undefined,
  57113. done: true
  57114. });
  57115. });
  57116. this._requests = [];
  57117. this._close();
  57118. },
  57119. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  57120. if (!this.isStreamingSupported && this.onProgress) {
  57121. this.onProgress({ loaded: evt.loaded });
  57122. }
  57123. },
  57124. get isStreamingSupported() {
  57125. return false;
  57126. },
  57127. read: function PDFNetworkStreamRangeRequestReader_read() {
  57128. if (this._queuedChunk !== null) {
  57129. var chunk = this._queuedChunk;
  57130. this._queuedChunk = null;
  57131. return Promise.resolve({
  57132. value: chunk,
  57133. done: false
  57134. });
  57135. }
  57136. if (this._done) {
  57137. return Promise.resolve({
  57138. value: undefined,
  57139. done: true
  57140. });
  57141. }
  57142. var requestCapability = createPromiseCapability();
  57143. this._requests.push(requestCapability);
  57144. return requestCapability.promise;
  57145. },
  57146. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  57147. this._done = true;
  57148. this._requests.forEach(function (requestCapability) {
  57149. requestCapability.resolve({
  57150. value: undefined,
  57151. done: true
  57152. });
  57153. });
  57154. this._requests = [];
  57155. if (this._manager.isPendingRequest(this._requestId)) {
  57156. this._manager.abortRequest(this._requestId);
  57157. }
  57158. this._close();
  57159. }
  57160. };
  57161. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  57162. exports.PDFNetworkStream = PDFNetworkStream;
  57163. exports.NetworkManager = NetworkManager;
  57164. }));
  57165. }.call(pdfjsLibs));
  57166. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  57167. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  57168. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  57169. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  57170. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  57171. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  57172. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  57173. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57174. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  57175. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  57176. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  57177. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  57178. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  57179. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  57180. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  57181. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57182. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  57183. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  57184. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  57185. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  57186. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  57187. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  57188. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57189. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  57190. }));