2
0

pdf.combined.js 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186
  1. /* Copyright 2012 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function (root, factory) {
  16. 'use strict';
  17. if (typeof define === 'function' && define.amd) {
  18. define('pdfjs-dist/build/pdf.combined', ['exports'], factory);
  19. } else if (typeof exports !== 'undefined') {
  20. factory(exports);
  21. } else {
  22. factory(root['pdfjsDistBuildPdfCombined'] = {});
  23. }
  24. }(this, function (exports) {
  25. 'use strict';
  26. var pdfjsVersion = '1.6.411';
  27. var pdfjsBuild = '017e9b9';
  28. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  29. var pdfjsLibs = {};
  30. (function pdfjsWrapper() {
  31. (function (root, factory) {
  32. factory(root.pdfjsCoreArithmeticDecoder = {});
  33. }(this, function (exports) {
  34. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  35. var QeTable = [
  36. {
  37. qe: 0x5601,
  38. nmps: 1,
  39. nlps: 1,
  40. switchFlag: 1
  41. },
  42. {
  43. qe: 0x3401,
  44. nmps: 2,
  45. nlps: 6,
  46. switchFlag: 0
  47. },
  48. {
  49. qe: 0x1801,
  50. nmps: 3,
  51. nlps: 9,
  52. switchFlag: 0
  53. },
  54. {
  55. qe: 0x0AC1,
  56. nmps: 4,
  57. nlps: 12,
  58. switchFlag: 0
  59. },
  60. {
  61. qe: 0x0521,
  62. nmps: 5,
  63. nlps: 29,
  64. switchFlag: 0
  65. },
  66. {
  67. qe: 0x0221,
  68. nmps: 38,
  69. nlps: 33,
  70. switchFlag: 0
  71. },
  72. {
  73. qe: 0x5601,
  74. nmps: 7,
  75. nlps: 6,
  76. switchFlag: 1
  77. },
  78. {
  79. qe: 0x5401,
  80. nmps: 8,
  81. nlps: 14,
  82. switchFlag: 0
  83. },
  84. {
  85. qe: 0x4801,
  86. nmps: 9,
  87. nlps: 14,
  88. switchFlag: 0
  89. },
  90. {
  91. qe: 0x3801,
  92. nmps: 10,
  93. nlps: 14,
  94. switchFlag: 0
  95. },
  96. {
  97. qe: 0x3001,
  98. nmps: 11,
  99. nlps: 17,
  100. switchFlag: 0
  101. },
  102. {
  103. qe: 0x2401,
  104. nmps: 12,
  105. nlps: 18,
  106. switchFlag: 0
  107. },
  108. {
  109. qe: 0x1C01,
  110. nmps: 13,
  111. nlps: 20,
  112. switchFlag: 0
  113. },
  114. {
  115. qe: 0x1601,
  116. nmps: 29,
  117. nlps: 21,
  118. switchFlag: 0
  119. },
  120. {
  121. qe: 0x5601,
  122. nmps: 15,
  123. nlps: 14,
  124. switchFlag: 1
  125. },
  126. {
  127. qe: 0x5401,
  128. nmps: 16,
  129. nlps: 14,
  130. switchFlag: 0
  131. },
  132. {
  133. qe: 0x5101,
  134. nmps: 17,
  135. nlps: 15,
  136. switchFlag: 0
  137. },
  138. {
  139. qe: 0x4801,
  140. nmps: 18,
  141. nlps: 16,
  142. switchFlag: 0
  143. },
  144. {
  145. qe: 0x3801,
  146. nmps: 19,
  147. nlps: 17,
  148. switchFlag: 0
  149. },
  150. {
  151. qe: 0x3401,
  152. nmps: 20,
  153. nlps: 18,
  154. switchFlag: 0
  155. },
  156. {
  157. qe: 0x3001,
  158. nmps: 21,
  159. nlps: 19,
  160. switchFlag: 0
  161. },
  162. {
  163. qe: 0x2801,
  164. nmps: 22,
  165. nlps: 19,
  166. switchFlag: 0
  167. },
  168. {
  169. qe: 0x2401,
  170. nmps: 23,
  171. nlps: 20,
  172. switchFlag: 0
  173. },
  174. {
  175. qe: 0x2201,
  176. nmps: 24,
  177. nlps: 21,
  178. switchFlag: 0
  179. },
  180. {
  181. qe: 0x1C01,
  182. nmps: 25,
  183. nlps: 22,
  184. switchFlag: 0
  185. },
  186. {
  187. qe: 0x1801,
  188. nmps: 26,
  189. nlps: 23,
  190. switchFlag: 0
  191. },
  192. {
  193. qe: 0x1601,
  194. nmps: 27,
  195. nlps: 24,
  196. switchFlag: 0
  197. },
  198. {
  199. qe: 0x1401,
  200. nmps: 28,
  201. nlps: 25,
  202. switchFlag: 0
  203. },
  204. {
  205. qe: 0x1201,
  206. nmps: 29,
  207. nlps: 26,
  208. switchFlag: 0
  209. },
  210. {
  211. qe: 0x1101,
  212. nmps: 30,
  213. nlps: 27,
  214. switchFlag: 0
  215. },
  216. {
  217. qe: 0x0AC1,
  218. nmps: 31,
  219. nlps: 28,
  220. switchFlag: 0
  221. },
  222. {
  223. qe: 0x09C1,
  224. nmps: 32,
  225. nlps: 29,
  226. switchFlag: 0
  227. },
  228. {
  229. qe: 0x08A1,
  230. nmps: 33,
  231. nlps: 30,
  232. switchFlag: 0
  233. },
  234. {
  235. qe: 0x0521,
  236. nmps: 34,
  237. nlps: 31,
  238. switchFlag: 0
  239. },
  240. {
  241. qe: 0x0441,
  242. nmps: 35,
  243. nlps: 32,
  244. switchFlag: 0
  245. },
  246. {
  247. qe: 0x02A1,
  248. nmps: 36,
  249. nlps: 33,
  250. switchFlag: 0
  251. },
  252. {
  253. qe: 0x0221,
  254. nmps: 37,
  255. nlps: 34,
  256. switchFlag: 0
  257. },
  258. {
  259. qe: 0x0141,
  260. nmps: 38,
  261. nlps: 35,
  262. switchFlag: 0
  263. },
  264. {
  265. qe: 0x0111,
  266. nmps: 39,
  267. nlps: 36,
  268. switchFlag: 0
  269. },
  270. {
  271. qe: 0x0085,
  272. nmps: 40,
  273. nlps: 37,
  274. switchFlag: 0
  275. },
  276. {
  277. qe: 0x0049,
  278. nmps: 41,
  279. nlps: 38,
  280. switchFlag: 0
  281. },
  282. {
  283. qe: 0x0025,
  284. nmps: 42,
  285. nlps: 39,
  286. switchFlag: 0
  287. },
  288. {
  289. qe: 0x0015,
  290. nmps: 43,
  291. nlps: 40,
  292. switchFlag: 0
  293. },
  294. {
  295. qe: 0x0009,
  296. nmps: 44,
  297. nlps: 41,
  298. switchFlag: 0
  299. },
  300. {
  301. qe: 0x0005,
  302. nmps: 45,
  303. nlps: 42,
  304. switchFlag: 0
  305. },
  306. {
  307. qe: 0x0001,
  308. nmps: 45,
  309. nlps: 43,
  310. switchFlag: 0
  311. },
  312. {
  313. qe: 0x5601,
  314. nmps: 46,
  315. nlps: 46,
  316. switchFlag: 0
  317. }
  318. ];
  319. function ArithmeticDecoder(data, start, end) {
  320. this.data = data;
  321. this.bp = start;
  322. this.dataEnd = end;
  323. this.chigh = data[start];
  324. this.clow = 0;
  325. this.byteIn();
  326. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  327. this.clow = this.clow << 7 & 0xFFFF;
  328. this.ct -= 7;
  329. this.a = 0x8000;
  330. }
  331. ArithmeticDecoder.prototype = {
  332. byteIn: function ArithmeticDecoder_byteIn() {
  333. var data = this.data;
  334. var bp = this.bp;
  335. if (data[bp] === 0xFF) {
  336. var b1 = data[bp + 1];
  337. if (b1 > 0x8F) {
  338. this.clow += 0xFF00;
  339. this.ct = 8;
  340. } else {
  341. bp++;
  342. this.clow += data[bp] << 9;
  343. this.ct = 7;
  344. this.bp = bp;
  345. }
  346. } else {
  347. bp++;
  348. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  349. this.ct = 8;
  350. this.bp = bp;
  351. }
  352. if (this.clow > 0xFFFF) {
  353. this.chigh += this.clow >> 16;
  354. this.clow &= 0xFFFF;
  355. }
  356. },
  357. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  358. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  359. var qeTableIcx = QeTable[cx_index];
  360. var qeIcx = qeTableIcx.qe;
  361. var d;
  362. var a = this.a - qeIcx;
  363. if (this.chigh < qeIcx) {
  364. if (a < qeIcx) {
  365. a = qeIcx;
  366. d = cx_mps;
  367. cx_index = qeTableIcx.nmps;
  368. } else {
  369. a = qeIcx;
  370. d = 1 ^ cx_mps;
  371. if (qeTableIcx.switchFlag === 1) {
  372. cx_mps = d;
  373. }
  374. cx_index = qeTableIcx.nlps;
  375. }
  376. } else {
  377. this.chigh -= qeIcx;
  378. if ((a & 0x8000) !== 0) {
  379. this.a = a;
  380. return cx_mps;
  381. }
  382. if (a < qeIcx) {
  383. d = 1 ^ cx_mps;
  384. if (qeTableIcx.switchFlag === 1) {
  385. cx_mps = d;
  386. }
  387. cx_index = qeTableIcx.nlps;
  388. } else {
  389. d = cx_mps;
  390. cx_index = qeTableIcx.nmps;
  391. }
  392. }
  393. do {
  394. if (this.ct === 0) {
  395. this.byteIn();
  396. }
  397. a <<= 1;
  398. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  399. this.clow = this.clow << 1 & 0xFFFF;
  400. this.ct--;
  401. } while ((a & 0x8000) === 0);
  402. this.a = a;
  403. contexts[pos] = cx_index << 1 | cx_mps;
  404. return d;
  405. }
  406. };
  407. return ArithmeticDecoder;
  408. }();
  409. exports.ArithmeticDecoder = ArithmeticDecoder;
  410. }));
  411. (function (root, factory) {
  412. factory(root.pdfjsCoreCharsets = {});
  413. }(this, function (exports) {
  414. var ISOAdobeCharset = [
  415. '.notdef',
  416. 'space',
  417. 'exclam',
  418. 'quotedbl',
  419. 'numbersign',
  420. 'dollar',
  421. 'percent',
  422. 'ampersand',
  423. 'quoteright',
  424. 'parenleft',
  425. 'parenright',
  426. 'asterisk',
  427. 'plus',
  428. 'comma',
  429. 'hyphen',
  430. 'period',
  431. 'slash',
  432. 'zero',
  433. 'one',
  434. 'two',
  435. 'three',
  436. 'four',
  437. 'five',
  438. 'six',
  439. 'seven',
  440. 'eight',
  441. 'nine',
  442. 'colon',
  443. 'semicolon',
  444. 'less',
  445. 'equal',
  446. 'greater',
  447. 'question',
  448. 'at',
  449. 'A',
  450. 'B',
  451. 'C',
  452. 'D',
  453. 'E',
  454. 'F',
  455. 'G',
  456. 'H',
  457. 'I',
  458. 'J',
  459. 'K',
  460. 'L',
  461. 'M',
  462. 'N',
  463. 'O',
  464. 'P',
  465. 'Q',
  466. 'R',
  467. 'S',
  468. 'T',
  469. 'U',
  470. 'V',
  471. 'W',
  472. 'X',
  473. 'Y',
  474. 'Z',
  475. 'bracketleft',
  476. 'backslash',
  477. 'bracketright',
  478. 'asciicircum',
  479. 'underscore',
  480. 'quoteleft',
  481. 'a',
  482. 'b',
  483. 'c',
  484. 'd',
  485. 'e',
  486. 'f',
  487. 'g',
  488. 'h',
  489. 'i',
  490. 'j',
  491. 'k',
  492. 'l',
  493. 'm',
  494. 'n',
  495. 'o',
  496. 'p',
  497. 'q',
  498. 'r',
  499. 's',
  500. 't',
  501. 'u',
  502. 'v',
  503. 'w',
  504. 'x',
  505. 'y',
  506. 'z',
  507. 'braceleft',
  508. 'bar',
  509. 'braceright',
  510. 'asciitilde',
  511. 'exclamdown',
  512. 'cent',
  513. 'sterling',
  514. 'fraction',
  515. 'yen',
  516. 'florin',
  517. 'section',
  518. 'currency',
  519. 'quotesingle',
  520. 'quotedblleft',
  521. 'guillemotleft',
  522. 'guilsinglleft',
  523. 'guilsinglright',
  524. 'fi',
  525. 'fl',
  526. 'endash',
  527. 'dagger',
  528. 'daggerdbl',
  529. 'periodcentered',
  530. 'paragraph',
  531. 'bullet',
  532. 'quotesinglbase',
  533. 'quotedblbase',
  534. 'quotedblright',
  535. 'guillemotright',
  536. 'ellipsis',
  537. 'perthousand',
  538. 'questiondown',
  539. 'grave',
  540. 'acute',
  541. 'circumflex',
  542. 'tilde',
  543. 'macron',
  544. 'breve',
  545. 'dotaccent',
  546. 'dieresis',
  547. 'ring',
  548. 'cedilla',
  549. 'hungarumlaut',
  550. 'ogonek',
  551. 'caron',
  552. 'emdash',
  553. 'AE',
  554. 'ordfeminine',
  555. 'Lslash',
  556. 'Oslash',
  557. 'OE',
  558. 'ordmasculine',
  559. 'ae',
  560. 'dotlessi',
  561. 'lslash',
  562. 'oslash',
  563. 'oe',
  564. 'germandbls',
  565. 'onesuperior',
  566. 'logicalnot',
  567. 'mu',
  568. 'trademark',
  569. 'Eth',
  570. 'onehalf',
  571. 'plusminus',
  572. 'Thorn',
  573. 'onequarter',
  574. 'divide',
  575. 'brokenbar',
  576. 'degree',
  577. 'thorn',
  578. 'threequarters',
  579. 'twosuperior',
  580. 'registered',
  581. 'minus',
  582. 'eth',
  583. 'multiply',
  584. 'threesuperior',
  585. 'copyright',
  586. 'Aacute',
  587. 'Acircumflex',
  588. 'Adieresis',
  589. 'Agrave',
  590. 'Aring',
  591. 'Atilde',
  592. 'Ccedilla',
  593. 'Eacute',
  594. 'Ecircumflex',
  595. 'Edieresis',
  596. 'Egrave',
  597. 'Iacute',
  598. 'Icircumflex',
  599. 'Idieresis',
  600. 'Igrave',
  601. 'Ntilde',
  602. 'Oacute',
  603. 'Ocircumflex',
  604. 'Odieresis',
  605. 'Ograve',
  606. 'Otilde',
  607. 'Scaron',
  608. 'Uacute',
  609. 'Ucircumflex',
  610. 'Udieresis',
  611. 'Ugrave',
  612. 'Yacute',
  613. 'Ydieresis',
  614. 'Zcaron',
  615. 'aacute',
  616. 'acircumflex',
  617. 'adieresis',
  618. 'agrave',
  619. 'aring',
  620. 'atilde',
  621. 'ccedilla',
  622. 'eacute',
  623. 'ecircumflex',
  624. 'edieresis',
  625. 'egrave',
  626. 'iacute',
  627. 'icircumflex',
  628. 'idieresis',
  629. 'igrave',
  630. 'ntilde',
  631. 'oacute',
  632. 'ocircumflex',
  633. 'odieresis',
  634. 'ograve',
  635. 'otilde',
  636. 'scaron',
  637. 'uacute',
  638. 'ucircumflex',
  639. 'udieresis',
  640. 'ugrave',
  641. 'yacute',
  642. 'ydieresis',
  643. 'zcaron'
  644. ];
  645. var ExpertCharset = [
  646. '.notdef',
  647. 'space',
  648. 'exclamsmall',
  649. 'Hungarumlautsmall',
  650. 'dollaroldstyle',
  651. 'dollarsuperior',
  652. 'ampersandsmall',
  653. 'Acutesmall',
  654. 'parenleftsuperior',
  655. 'parenrightsuperior',
  656. 'twodotenleader',
  657. 'onedotenleader',
  658. 'comma',
  659. 'hyphen',
  660. 'period',
  661. 'fraction',
  662. 'zerooldstyle',
  663. 'oneoldstyle',
  664. 'twooldstyle',
  665. 'threeoldstyle',
  666. 'fouroldstyle',
  667. 'fiveoldstyle',
  668. 'sixoldstyle',
  669. 'sevenoldstyle',
  670. 'eightoldstyle',
  671. 'nineoldstyle',
  672. 'colon',
  673. 'semicolon',
  674. 'commasuperior',
  675. 'threequartersemdash',
  676. 'periodsuperior',
  677. 'questionsmall',
  678. 'asuperior',
  679. 'bsuperior',
  680. 'centsuperior',
  681. 'dsuperior',
  682. 'esuperior',
  683. 'isuperior',
  684. 'lsuperior',
  685. 'msuperior',
  686. 'nsuperior',
  687. 'osuperior',
  688. 'rsuperior',
  689. 'ssuperior',
  690. 'tsuperior',
  691. 'ff',
  692. 'fi',
  693. 'fl',
  694. 'ffi',
  695. 'ffl',
  696. 'parenleftinferior',
  697. 'parenrightinferior',
  698. 'Circumflexsmall',
  699. 'hyphensuperior',
  700. 'Gravesmall',
  701. 'Asmall',
  702. 'Bsmall',
  703. 'Csmall',
  704. 'Dsmall',
  705. 'Esmall',
  706. 'Fsmall',
  707. 'Gsmall',
  708. 'Hsmall',
  709. 'Ismall',
  710. 'Jsmall',
  711. 'Ksmall',
  712. 'Lsmall',
  713. 'Msmall',
  714. 'Nsmall',
  715. 'Osmall',
  716. 'Psmall',
  717. 'Qsmall',
  718. 'Rsmall',
  719. 'Ssmall',
  720. 'Tsmall',
  721. 'Usmall',
  722. 'Vsmall',
  723. 'Wsmall',
  724. 'Xsmall',
  725. 'Ysmall',
  726. 'Zsmall',
  727. 'colonmonetary',
  728. 'onefitted',
  729. 'rupiah',
  730. 'Tildesmall',
  731. 'exclamdownsmall',
  732. 'centoldstyle',
  733. 'Lslashsmall',
  734. 'Scaronsmall',
  735. 'Zcaronsmall',
  736. 'Dieresissmall',
  737. 'Brevesmall',
  738. 'Caronsmall',
  739. 'Dotaccentsmall',
  740. 'Macronsmall',
  741. 'figuredash',
  742. 'hypheninferior',
  743. 'Ogoneksmall',
  744. 'Ringsmall',
  745. 'Cedillasmall',
  746. 'onequarter',
  747. 'onehalf',
  748. 'threequarters',
  749. 'questiondownsmall',
  750. 'oneeighth',
  751. 'threeeighths',
  752. 'fiveeighths',
  753. 'seveneighths',
  754. 'onethird',
  755. 'twothirds',
  756. 'zerosuperior',
  757. 'onesuperior',
  758. 'twosuperior',
  759. 'threesuperior',
  760. 'foursuperior',
  761. 'fivesuperior',
  762. 'sixsuperior',
  763. 'sevensuperior',
  764. 'eightsuperior',
  765. 'ninesuperior',
  766. 'zeroinferior',
  767. 'oneinferior',
  768. 'twoinferior',
  769. 'threeinferior',
  770. 'fourinferior',
  771. 'fiveinferior',
  772. 'sixinferior',
  773. 'seveninferior',
  774. 'eightinferior',
  775. 'nineinferior',
  776. 'centinferior',
  777. 'dollarinferior',
  778. 'periodinferior',
  779. 'commainferior',
  780. 'Agravesmall',
  781. 'Aacutesmall',
  782. 'Acircumflexsmall',
  783. 'Atildesmall',
  784. 'Adieresissmall',
  785. 'Aringsmall',
  786. 'AEsmall',
  787. 'Ccedillasmall',
  788. 'Egravesmall',
  789. 'Eacutesmall',
  790. 'Ecircumflexsmall',
  791. 'Edieresissmall',
  792. 'Igravesmall',
  793. 'Iacutesmall',
  794. 'Icircumflexsmall',
  795. 'Idieresissmall',
  796. 'Ethsmall',
  797. 'Ntildesmall',
  798. 'Ogravesmall',
  799. 'Oacutesmall',
  800. 'Ocircumflexsmall',
  801. 'Otildesmall',
  802. 'Odieresissmall',
  803. 'OEsmall',
  804. 'Oslashsmall',
  805. 'Ugravesmall',
  806. 'Uacutesmall',
  807. 'Ucircumflexsmall',
  808. 'Udieresissmall',
  809. 'Yacutesmall',
  810. 'Thornsmall',
  811. 'Ydieresissmall'
  812. ];
  813. var ExpertSubsetCharset = [
  814. '.notdef',
  815. 'space',
  816. 'dollaroldstyle',
  817. 'dollarsuperior',
  818. 'parenleftsuperior',
  819. 'parenrightsuperior',
  820. 'twodotenleader',
  821. 'onedotenleader',
  822. 'comma',
  823. 'hyphen',
  824. 'period',
  825. 'fraction',
  826. 'zerooldstyle',
  827. 'oneoldstyle',
  828. 'twooldstyle',
  829. 'threeoldstyle',
  830. 'fouroldstyle',
  831. 'fiveoldstyle',
  832. 'sixoldstyle',
  833. 'sevenoldstyle',
  834. 'eightoldstyle',
  835. 'nineoldstyle',
  836. 'colon',
  837. 'semicolon',
  838. 'commasuperior',
  839. 'threequartersemdash',
  840. 'periodsuperior',
  841. 'asuperior',
  842. 'bsuperior',
  843. 'centsuperior',
  844. 'dsuperior',
  845. 'esuperior',
  846. 'isuperior',
  847. 'lsuperior',
  848. 'msuperior',
  849. 'nsuperior',
  850. 'osuperior',
  851. 'rsuperior',
  852. 'ssuperior',
  853. 'tsuperior',
  854. 'ff',
  855. 'fi',
  856. 'fl',
  857. 'ffi',
  858. 'ffl',
  859. 'parenleftinferior',
  860. 'parenrightinferior',
  861. 'hyphensuperior',
  862. 'colonmonetary',
  863. 'onefitted',
  864. 'rupiah',
  865. 'centoldstyle',
  866. 'figuredash',
  867. 'hypheninferior',
  868. 'onequarter',
  869. 'onehalf',
  870. 'threequarters',
  871. 'oneeighth',
  872. 'threeeighths',
  873. 'fiveeighths',
  874. 'seveneighths',
  875. 'onethird',
  876. 'twothirds',
  877. 'zerosuperior',
  878. 'onesuperior',
  879. 'twosuperior',
  880. 'threesuperior',
  881. 'foursuperior',
  882. 'fivesuperior',
  883. 'sixsuperior',
  884. 'sevensuperior',
  885. 'eightsuperior',
  886. 'ninesuperior',
  887. 'zeroinferior',
  888. 'oneinferior',
  889. 'twoinferior',
  890. 'threeinferior',
  891. 'fourinferior',
  892. 'fiveinferior',
  893. 'sixinferior',
  894. 'seveninferior',
  895. 'eightinferior',
  896. 'nineinferior',
  897. 'centinferior',
  898. 'dollarinferior',
  899. 'periodinferior',
  900. 'commainferior'
  901. ];
  902. exports.ISOAdobeCharset = ISOAdobeCharset;
  903. exports.ExpertCharset = ExpertCharset;
  904. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  905. }));
  906. (function (root, factory) {
  907. factory(root.pdfjsCoreEncodings = {});
  908. }(this, function (exports) {
  909. var ExpertEncoding = [
  910. '',
  911. '',
  912. '',
  913. '',
  914. '',
  915. '',
  916. '',
  917. '',
  918. '',
  919. '',
  920. '',
  921. '',
  922. '',
  923. '',
  924. '',
  925. '',
  926. '',
  927. '',
  928. '',
  929. '',
  930. '',
  931. '',
  932. '',
  933. '',
  934. '',
  935. '',
  936. '',
  937. '',
  938. '',
  939. '',
  940. '',
  941. '',
  942. 'space',
  943. 'exclamsmall',
  944. 'Hungarumlautsmall',
  945. '',
  946. 'dollaroldstyle',
  947. 'dollarsuperior',
  948. 'ampersandsmall',
  949. 'Acutesmall',
  950. 'parenleftsuperior',
  951. 'parenrightsuperior',
  952. 'twodotenleader',
  953. 'onedotenleader',
  954. 'comma',
  955. 'hyphen',
  956. 'period',
  957. 'fraction',
  958. 'zerooldstyle',
  959. 'oneoldstyle',
  960. 'twooldstyle',
  961. 'threeoldstyle',
  962. 'fouroldstyle',
  963. 'fiveoldstyle',
  964. 'sixoldstyle',
  965. 'sevenoldstyle',
  966. 'eightoldstyle',
  967. 'nineoldstyle',
  968. 'colon',
  969. 'semicolon',
  970. 'commasuperior',
  971. 'threequartersemdash',
  972. 'periodsuperior',
  973. 'questionsmall',
  974. '',
  975. 'asuperior',
  976. 'bsuperior',
  977. 'centsuperior',
  978. 'dsuperior',
  979. 'esuperior',
  980. '',
  981. '',
  982. 'isuperior',
  983. '',
  984. '',
  985. 'lsuperior',
  986. 'msuperior',
  987. 'nsuperior',
  988. 'osuperior',
  989. '',
  990. '',
  991. 'rsuperior',
  992. 'ssuperior',
  993. 'tsuperior',
  994. '',
  995. 'ff',
  996. 'fi',
  997. 'fl',
  998. 'ffi',
  999. 'ffl',
  1000. 'parenleftinferior',
  1001. '',
  1002. 'parenrightinferior',
  1003. 'Circumflexsmall',
  1004. 'hyphensuperior',
  1005. 'Gravesmall',
  1006. 'Asmall',
  1007. 'Bsmall',
  1008. 'Csmall',
  1009. 'Dsmall',
  1010. 'Esmall',
  1011. 'Fsmall',
  1012. 'Gsmall',
  1013. 'Hsmall',
  1014. 'Ismall',
  1015. 'Jsmall',
  1016. 'Ksmall',
  1017. 'Lsmall',
  1018. 'Msmall',
  1019. 'Nsmall',
  1020. 'Osmall',
  1021. 'Psmall',
  1022. 'Qsmall',
  1023. 'Rsmall',
  1024. 'Ssmall',
  1025. 'Tsmall',
  1026. 'Usmall',
  1027. 'Vsmall',
  1028. 'Wsmall',
  1029. 'Xsmall',
  1030. 'Ysmall',
  1031. 'Zsmall',
  1032. 'colonmonetary',
  1033. 'onefitted',
  1034. 'rupiah',
  1035. 'Tildesmall',
  1036. '',
  1037. '',
  1038. '',
  1039. '',
  1040. '',
  1041. '',
  1042. '',
  1043. '',
  1044. '',
  1045. '',
  1046. '',
  1047. '',
  1048. '',
  1049. '',
  1050. '',
  1051. '',
  1052. '',
  1053. '',
  1054. '',
  1055. '',
  1056. '',
  1057. '',
  1058. '',
  1059. '',
  1060. '',
  1061. '',
  1062. '',
  1063. '',
  1064. '',
  1065. '',
  1066. '',
  1067. '',
  1068. '',
  1069. '',
  1070. 'exclamdownsmall',
  1071. 'centoldstyle',
  1072. 'Lslashsmall',
  1073. '',
  1074. '',
  1075. 'Scaronsmall',
  1076. 'Zcaronsmall',
  1077. 'Dieresissmall',
  1078. 'Brevesmall',
  1079. 'Caronsmall',
  1080. '',
  1081. 'Dotaccentsmall',
  1082. '',
  1083. '',
  1084. 'Macronsmall',
  1085. '',
  1086. '',
  1087. 'figuredash',
  1088. 'hypheninferior',
  1089. '',
  1090. '',
  1091. 'Ogoneksmall',
  1092. 'Ringsmall',
  1093. 'Cedillasmall',
  1094. '',
  1095. '',
  1096. '',
  1097. 'onequarter',
  1098. 'onehalf',
  1099. 'threequarters',
  1100. 'questiondownsmall',
  1101. 'oneeighth',
  1102. 'threeeighths',
  1103. 'fiveeighths',
  1104. 'seveneighths',
  1105. 'onethird',
  1106. 'twothirds',
  1107. '',
  1108. '',
  1109. 'zerosuperior',
  1110. 'onesuperior',
  1111. 'twosuperior',
  1112. 'threesuperior',
  1113. 'foursuperior',
  1114. 'fivesuperior',
  1115. 'sixsuperior',
  1116. 'sevensuperior',
  1117. 'eightsuperior',
  1118. 'ninesuperior',
  1119. 'zeroinferior',
  1120. 'oneinferior',
  1121. 'twoinferior',
  1122. 'threeinferior',
  1123. 'fourinferior',
  1124. 'fiveinferior',
  1125. 'sixinferior',
  1126. 'seveninferior',
  1127. 'eightinferior',
  1128. 'nineinferior',
  1129. 'centinferior',
  1130. 'dollarinferior',
  1131. 'periodinferior',
  1132. 'commainferior',
  1133. 'Agravesmall',
  1134. 'Aacutesmall',
  1135. 'Acircumflexsmall',
  1136. 'Atildesmall',
  1137. 'Adieresissmall',
  1138. 'Aringsmall',
  1139. 'AEsmall',
  1140. 'Ccedillasmall',
  1141. 'Egravesmall',
  1142. 'Eacutesmall',
  1143. 'Ecircumflexsmall',
  1144. 'Edieresissmall',
  1145. 'Igravesmall',
  1146. 'Iacutesmall',
  1147. 'Icircumflexsmall',
  1148. 'Idieresissmall',
  1149. 'Ethsmall',
  1150. 'Ntildesmall',
  1151. 'Ogravesmall',
  1152. 'Oacutesmall',
  1153. 'Ocircumflexsmall',
  1154. 'Otildesmall',
  1155. 'Odieresissmall',
  1156. 'OEsmall',
  1157. 'Oslashsmall',
  1158. 'Ugravesmall',
  1159. 'Uacutesmall',
  1160. 'Ucircumflexsmall',
  1161. 'Udieresissmall',
  1162. 'Yacutesmall',
  1163. 'Thornsmall',
  1164. 'Ydieresissmall'
  1165. ];
  1166. var MacExpertEncoding = [
  1167. '',
  1168. '',
  1169. '',
  1170. '',
  1171. '',
  1172. '',
  1173. '',
  1174. '',
  1175. '',
  1176. '',
  1177. '',
  1178. '',
  1179. '',
  1180. '',
  1181. '',
  1182. '',
  1183. '',
  1184. '',
  1185. '',
  1186. '',
  1187. '',
  1188. '',
  1189. '',
  1190. '',
  1191. '',
  1192. '',
  1193. '',
  1194. '',
  1195. '',
  1196. '',
  1197. '',
  1198. '',
  1199. 'space',
  1200. 'exclamsmall',
  1201. 'Hungarumlautsmall',
  1202. 'centoldstyle',
  1203. 'dollaroldstyle',
  1204. 'dollarsuperior',
  1205. 'ampersandsmall',
  1206. 'Acutesmall',
  1207. 'parenleftsuperior',
  1208. 'parenrightsuperior',
  1209. 'twodotenleader',
  1210. 'onedotenleader',
  1211. 'comma',
  1212. 'hyphen',
  1213. 'period',
  1214. 'fraction',
  1215. 'zerooldstyle',
  1216. 'oneoldstyle',
  1217. 'twooldstyle',
  1218. 'threeoldstyle',
  1219. 'fouroldstyle',
  1220. 'fiveoldstyle',
  1221. 'sixoldstyle',
  1222. 'sevenoldstyle',
  1223. 'eightoldstyle',
  1224. 'nineoldstyle',
  1225. 'colon',
  1226. 'semicolon',
  1227. '',
  1228. 'threequartersemdash',
  1229. '',
  1230. 'questionsmall',
  1231. '',
  1232. '',
  1233. '',
  1234. '',
  1235. 'Ethsmall',
  1236. '',
  1237. '',
  1238. 'onequarter',
  1239. 'onehalf',
  1240. 'threequarters',
  1241. 'oneeighth',
  1242. 'threeeighths',
  1243. 'fiveeighths',
  1244. 'seveneighths',
  1245. 'onethird',
  1246. 'twothirds',
  1247. '',
  1248. '',
  1249. '',
  1250. '',
  1251. '',
  1252. '',
  1253. 'ff',
  1254. 'fi',
  1255. 'fl',
  1256. 'ffi',
  1257. 'ffl',
  1258. 'parenleftinferior',
  1259. '',
  1260. 'parenrightinferior',
  1261. 'Circumflexsmall',
  1262. 'hypheninferior',
  1263. 'Gravesmall',
  1264. 'Asmall',
  1265. 'Bsmall',
  1266. 'Csmall',
  1267. 'Dsmall',
  1268. 'Esmall',
  1269. 'Fsmall',
  1270. 'Gsmall',
  1271. 'Hsmall',
  1272. 'Ismall',
  1273. 'Jsmall',
  1274. 'Ksmall',
  1275. 'Lsmall',
  1276. 'Msmall',
  1277. 'Nsmall',
  1278. 'Osmall',
  1279. 'Psmall',
  1280. 'Qsmall',
  1281. 'Rsmall',
  1282. 'Ssmall',
  1283. 'Tsmall',
  1284. 'Usmall',
  1285. 'Vsmall',
  1286. 'Wsmall',
  1287. 'Xsmall',
  1288. 'Ysmall',
  1289. 'Zsmall',
  1290. 'colonmonetary',
  1291. 'onefitted',
  1292. 'rupiah',
  1293. 'Tildesmall',
  1294. '',
  1295. '',
  1296. 'asuperior',
  1297. 'centsuperior',
  1298. '',
  1299. '',
  1300. '',
  1301. '',
  1302. 'Aacutesmall',
  1303. 'Agravesmall',
  1304. 'Acircumflexsmall',
  1305. 'Adieresissmall',
  1306. 'Atildesmall',
  1307. 'Aringsmall',
  1308. 'Ccedillasmall',
  1309. 'Eacutesmall',
  1310. 'Egravesmall',
  1311. 'Ecircumflexsmall',
  1312. 'Edieresissmall',
  1313. 'Iacutesmall',
  1314. 'Igravesmall',
  1315. 'Icircumflexsmall',
  1316. 'Idieresissmall',
  1317. 'Ntildesmall',
  1318. 'Oacutesmall',
  1319. 'Ogravesmall',
  1320. 'Ocircumflexsmall',
  1321. 'Odieresissmall',
  1322. 'Otildesmall',
  1323. 'Uacutesmall',
  1324. 'Ugravesmall',
  1325. 'Ucircumflexsmall',
  1326. 'Udieresissmall',
  1327. '',
  1328. 'eightsuperior',
  1329. 'fourinferior',
  1330. 'threeinferior',
  1331. 'sixinferior',
  1332. 'eightinferior',
  1333. 'seveninferior',
  1334. 'Scaronsmall',
  1335. '',
  1336. 'centinferior',
  1337. 'twoinferior',
  1338. '',
  1339. 'Dieresissmall',
  1340. '',
  1341. 'Caronsmall',
  1342. 'osuperior',
  1343. 'fiveinferior',
  1344. '',
  1345. 'commainferior',
  1346. 'periodinferior',
  1347. 'Yacutesmall',
  1348. '',
  1349. 'dollarinferior',
  1350. '',
  1351. 'Thornsmall',
  1352. '',
  1353. 'nineinferior',
  1354. 'zeroinferior',
  1355. 'Zcaronsmall',
  1356. 'AEsmall',
  1357. 'Oslashsmall',
  1358. 'questiondownsmall',
  1359. 'oneinferior',
  1360. 'Lslashsmall',
  1361. '',
  1362. '',
  1363. '',
  1364. '',
  1365. '',
  1366. '',
  1367. 'Cedillasmall',
  1368. '',
  1369. '',
  1370. '',
  1371. '',
  1372. '',
  1373. 'OEsmall',
  1374. 'figuredash',
  1375. 'hyphensuperior',
  1376. '',
  1377. '',
  1378. '',
  1379. '',
  1380. 'exclamdownsmall',
  1381. '',
  1382. 'Ydieresissmall',
  1383. '',
  1384. 'onesuperior',
  1385. 'twosuperior',
  1386. 'threesuperior',
  1387. 'foursuperior',
  1388. 'fivesuperior',
  1389. 'sixsuperior',
  1390. 'sevensuperior',
  1391. 'ninesuperior',
  1392. 'zerosuperior',
  1393. '',
  1394. 'esuperior',
  1395. 'rsuperior',
  1396. 'tsuperior',
  1397. '',
  1398. '',
  1399. 'isuperior',
  1400. 'ssuperior',
  1401. 'dsuperior',
  1402. '',
  1403. '',
  1404. '',
  1405. '',
  1406. '',
  1407. 'lsuperior',
  1408. 'Ogoneksmall',
  1409. 'Brevesmall',
  1410. 'Macronsmall',
  1411. 'bsuperior',
  1412. 'nsuperior',
  1413. 'msuperior',
  1414. 'commasuperior',
  1415. 'periodsuperior',
  1416. 'Dotaccentsmall',
  1417. 'Ringsmall'
  1418. ];
  1419. var MacRomanEncoding = [
  1420. '',
  1421. '',
  1422. '',
  1423. '',
  1424. '',
  1425. '',
  1426. '',
  1427. '',
  1428. '',
  1429. '',
  1430. '',
  1431. '',
  1432. '',
  1433. '',
  1434. '',
  1435. '',
  1436. '',
  1437. '',
  1438. '',
  1439. '',
  1440. '',
  1441. '',
  1442. '',
  1443. '',
  1444. '',
  1445. '',
  1446. '',
  1447. '',
  1448. '',
  1449. '',
  1450. '',
  1451. '',
  1452. 'space',
  1453. 'exclam',
  1454. 'quotedbl',
  1455. 'numbersign',
  1456. 'dollar',
  1457. 'percent',
  1458. 'ampersand',
  1459. 'quotesingle',
  1460. 'parenleft',
  1461. 'parenright',
  1462. 'asterisk',
  1463. 'plus',
  1464. 'comma',
  1465. 'hyphen',
  1466. 'period',
  1467. 'slash',
  1468. 'zero',
  1469. 'one',
  1470. 'two',
  1471. 'three',
  1472. 'four',
  1473. 'five',
  1474. 'six',
  1475. 'seven',
  1476. 'eight',
  1477. 'nine',
  1478. 'colon',
  1479. 'semicolon',
  1480. 'less',
  1481. 'equal',
  1482. 'greater',
  1483. 'question',
  1484. 'at',
  1485. 'A',
  1486. 'B',
  1487. 'C',
  1488. 'D',
  1489. 'E',
  1490. 'F',
  1491. 'G',
  1492. 'H',
  1493. 'I',
  1494. 'J',
  1495. 'K',
  1496. 'L',
  1497. 'M',
  1498. 'N',
  1499. 'O',
  1500. 'P',
  1501. 'Q',
  1502. 'R',
  1503. 'S',
  1504. 'T',
  1505. 'U',
  1506. 'V',
  1507. 'W',
  1508. 'X',
  1509. 'Y',
  1510. 'Z',
  1511. 'bracketleft',
  1512. 'backslash',
  1513. 'bracketright',
  1514. 'asciicircum',
  1515. 'underscore',
  1516. 'grave',
  1517. 'a',
  1518. 'b',
  1519. 'c',
  1520. 'd',
  1521. 'e',
  1522. 'f',
  1523. 'g',
  1524. 'h',
  1525. 'i',
  1526. 'j',
  1527. 'k',
  1528. 'l',
  1529. 'm',
  1530. 'n',
  1531. 'o',
  1532. 'p',
  1533. 'q',
  1534. 'r',
  1535. 's',
  1536. 't',
  1537. 'u',
  1538. 'v',
  1539. 'w',
  1540. 'x',
  1541. 'y',
  1542. 'z',
  1543. 'braceleft',
  1544. 'bar',
  1545. 'braceright',
  1546. 'asciitilde',
  1547. '',
  1548. 'Adieresis',
  1549. 'Aring',
  1550. 'Ccedilla',
  1551. 'Eacute',
  1552. 'Ntilde',
  1553. 'Odieresis',
  1554. 'Udieresis',
  1555. 'aacute',
  1556. 'agrave',
  1557. 'acircumflex',
  1558. 'adieresis',
  1559. 'atilde',
  1560. 'aring',
  1561. 'ccedilla',
  1562. 'eacute',
  1563. 'egrave',
  1564. 'ecircumflex',
  1565. 'edieresis',
  1566. 'iacute',
  1567. 'igrave',
  1568. 'icircumflex',
  1569. 'idieresis',
  1570. 'ntilde',
  1571. 'oacute',
  1572. 'ograve',
  1573. 'ocircumflex',
  1574. 'odieresis',
  1575. 'otilde',
  1576. 'uacute',
  1577. 'ugrave',
  1578. 'ucircumflex',
  1579. 'udieresis',
  1580. 'dagger',
  1581. 'degree',
  1582. 'cent',
  1583. 'sterling',
  1584. 'section',
  1585. 'bullet',
  1586. 'paragraph',
  1587. 'germandbls',
  1588. 'registered',
  1589. 'copyright',
  1590. 'trademark',
  1591. 'acute',
  1592. 'dieresis',
  1593. 'notequal',
  1594. 'AE',
  1595. 'Oslash',
  1596. 'infinity',
  1597. 'plusminus',
  1598. 'lessequal',
  1599. 'greaterequal',
  1600. 'yen',
  1601. 'mu',
  1602. 'partialdiff',
  1603. 'summation',
  1604. 'product',
  1605. 'pi',
  1606. 'integral',
  1607. 'ordfeminine',
  1608. 'ordmasculine',
  1609. 'Omega',
  1610. 'ae',
  1611. 'oslash',
  1612. 'questiondown',
  1613. 'exclamdown',
  1614. 'logicalnot',
  1615. 'radical',
  1616. 'florin',
  1617. 'approxequal',
  1618. 'Delta',
  1619. 'guillemotleft',
  1620. 'guillemotright',
  1621. 'ellipsis',
  1622. 'space',
  1623. 'Agrave',
  1624. 'Atilde',
  1625. 'Otilde',
  1626. 'OE',
  1627. 'oe',
  1628. 'endash',
  1629. 'emdash',
  1630. 'quotedblleft',
  1631. 'quotedblright',
  1632. 'quoteleft',
  1633. 'quoteright',
  1634. 'divide',
  1635. 'lozenge',
  1636. 'ydieresis',
  1637. 'Ydieresis',
  1638. 'fraction',
  1639. 'currency',
  1640. 'guilsinglleft',
  1641. 'guilsinglright',
  1642. 'fi',
  1643. 'fl',
  1644. 'daggerdbl',
  1645. 'periodcentered',
  1646. 'quotesinglbase',
  1647. 'quotedblbase',
  1648. 'perthousand',
  1649. 'Acircumflex',
  1650. 'Ecircumflex',
  1651. 'Aacute',
  1652. 'Edieresis',
  1653. 'Egrave',
  1654. 'Iacute',
  1655. 'Icircumflex',
  1656. 'Idieresis',
  1657. 'Igrave',
  1658. 'Oacute',
  1659. 'Ocircumflex',
  1660. 'apple',
  1661. 'Ograve',
  1662. 'Uacute',
  1663. 'Ucircumflex',
  1664. 'Ugrave',
  1665. 'dotlessi',
  1666. 'circumflex',
  1667. 'tilde',
  1668. 'macron',
  1669. 'breve',
  1670. 'dotaccent',
  1671. 'ring',
  1672. 'cedilla',
  1673. 'hungarumlaut',
  1674. 'ogonek',
  1675. 'caron'
  1676. ];
  1677. var StandardEncoding = [
  1678. '',
  1679. '',
  1680. '',
  1681. '',
  1682. '',
  1683. '',
  1684. '',
  1685. '',
  1686. '',
  1687. '',
  1688. '',
  1689. '',
  1690. '',
  1691. '',
  1692. '',
  1693. '',
  1694. '',
  1695. '',
  1696. '',
  1697. '',
  1698. '',
  1699. '',
  1700. '',
  1701. '',
  1702. '',
  1703. '',
  1704. '',
  1705. '',
  1706. '',
  1707. '',
  1708. '',
  1709. '',
  1710. 'space',
  1711. 'exclam',
  1712. 'quotedbl',
  1713. 'numbersign',
  1714. 'dollar',
  1715. 'percent',
  1716. 'ampersand',
  1717. 'quoteright',
  1718. 'parenleft',
  1719. 'parenright',
  1720. 'asterisk',
  1721. 'plus',
  1722. 'comma',
  1723. 'hyphen',
  1724. 'period',
  1725. 'slash',
  1726. 'zero',
  1727. 'one',
  1728. 'two',
  1729. 'three',
  1730. 'four',
  1731. 'five',
  1732. 'six',
  1733. 'seven',
  1734. 'eight',
  1735. 'nine',
  1736. 'colon',
  1737. 'semicolon',
  1738. 'less',
  1739. 'equal',
  1740. 'greater',
  1741. 'question',
  1742. 'at',
  1743. 'A',
  1744. 'B',
  1745. 'C',
  1746. 'D',
  1747. 'E',
  1748. 'F',
  1749. 'G',
  1750. 'H',
  1751. 'I',
  1752. 'J',
  1753. 'K',
  1754. 'L',
  1755. 'M',
  1756. 'N',
  1757. 'O',
  1758. 'P',
  1759. 'Q',
  1760. 'R',
  1761. 'S',
  1762. 'T',
  1763. 'U',
  1764. 'V',
  1765. 'W',
  1766. 'X',
  1767. 'Y',
  1768. 'Z',
  1769. 'bracketleft',
  1770. 'backslash',
  1771. 'bracketright',
  1772. 'asciicircum',
  1773. 'underscore',
  1774. 'quoteleft',
  1775. 'a',
  1776. 'b',
  1777. 'c',
  1778. 'd',
  1779. 'e',
  1780. 'f',
  1781. 'g',
  1782. 'h',
  1783. 'i',
  1784. 'j',
  1785. 'k',
  1786. 'l',
  1787. 'm',
  1788. 'n',
  1789. 'o',
  1790. 'p',
  1791. 'q',
  1792. 'r',
  1793. 's',
  1794. 't',
  1795. 'u',
  1796. 'v',
  1797. 'w',
  1798. 'x',
  1799. 'y',
  1800. 'z',
  1801. 'braceleft',
  1802. 'bar',
  1803. 'braceright',
  1804. 'asciitilde',
  1805. '',
  1806. '',
  1807. '',
  1808. '',
  1809. '',
  1810. '',
  1811. '',
  1812. '',
  1813. '',
  1814. '',
  1815. '',
  1816. '',
  1817. '',
  1818. '',
  1819. '',
  1820. '',
  1821. '',
  1822. '',
  1823. '',
  1824. '',
  1825. '',
  1826. '',
  1827. '',
  1828. '',
  1829. '',
  1830. '',
  1831. '',
  1832. '',
  1833. '',
  1834. '',
  1835. '',
  1836. '',
  1837. '',
  1838. '',
  1839. 'exclamdown',
  1840. 'cent',
  1841. 'sterling',
  1842. 'fraction',
  1843. 'yen',
  1844. 'florin',
  1845. 'section',
  1846. 'currency',
  1847. 'quotesingle',
  1848. 'quotedblleft',
  1849. 'guillemotleft',
  1850. 'guilsinglleft',
  1851. 'guilsinglright',
  1852. 'fi',
  1853. 'fl',
  1854. '',
  1855. 'endash',
  1856. 'dagger',
  1857. 'daggerdbl',
  1858. 'periodcentered',
  1859. '',
  1860. 'paragraph',
  1861. 'bullet',
  1862. 'quotesinglbase',
  1863. 'quotedblbase',
  1864. 'quotedblright',
  1865. 'guillemotright',
  1866. 'ellipsis',
  1867. 'perthousand',
  1868. '',
  1869. 'questiondown',
  1870. '',
  1871. 'grave',
  1872. 'acute',
  1873. 'circumflex',
  1874. 'tilde',
  1875. 'macron',
  1876. 'breve',
  1877. 'dotaccent',
  1878. 'dieresis',
  1879. '',
  1880. 'ring',
  1881. 'cedilla',
  1882. '',
  1883. 'hungarumlaut',
  1884. 'ogonek',
  1885. 'caron',
  1886. 'emdash',
  1887. '',
  1888. '',
  1889. '',
  1890. '',
  1891. '',
  1892. '',
  1893. '',
  1894. '',
  1895. '',
  1896. '',
  1897. '',
  1898. '',
  1899. '',
  1900. '',
  1901. '',
  1902. '',
  1903. 'AE',
  1904. '',
  1905. 'ordfeminine',
  1906. '',
  1907. '',
  1908. '',
  1909. '',
  1910. 'Lslash',
  1911. 'Oslash',
  1912. 'OE',
  1913. 'ordmasculine',
  1914. '',
  1915. '',
  1916. '',
  1917. '',
  1918. '',
  1919. 'ae',
  1920. '',
  1921. '',
  1922. '',
  1923. 'dotlessi',
  1924. '',
  1925. '',
  1926. 'lslash',
  1927. 'oslash',
  1928. 'oe',
  1929. 'germandbls'
  1930. ];
  1931. var WinAnsiEncoding = [
  1932. '',
  1933. '',
  1934. '',
  1935. '',
  1936. '',
  1937. '',
  1938. '',
  1939. '',
  1940. '',
  1941. '',
  1942. '',
  1943. '',
  1944. '',
  1945. '',
  1946. '',
  1947. '',
  1948. '',
  1949. '',
  1950. '',
  1951. '',
  1952. '',
  1953. '',
  1954. '',
  1955. '',
  1956. '',
  1957. '',
  1958. '',
  1959. '',
  1960. '',
  1961. '',
  1962. '',
  1963. '',
  1964. 'space',
  1965. 'exclam',
  1966. 'quotedbl',
  1967. 'numbersign',
  1968. 'dollar',
  1969. 'percent',
  1970. 'ampersand',
  1971. 'quotesingle',
  1972. 'parenleft',
  1973. 'parenright',
  1974. 'asterisk',
  1975. 'plus',
  1976. 'comma',
  1977. 'hyphen',
  1978. 'period',
  1979. 'slash',
  1980. 'zero',
  1981. 'one',
  1982. 'two',
  1983. 'three',
  1984. 'four',
  1985. 'five',
  1986. 'six',
  1987. 'seven',
  1988. 'eight',
  1989. 'nine',
  1990. 'colon',
  1991. 'semicolon',
  1992. 'less',
  1993. 'equal',
  1994. 'greater',
  1995. 'question',
  1996. 'at',
  1997. 'A',
  1998. 'B',
  1999. 'C',
  2000. 'D',
  2001. 'E',
  2002. 'F',
  2003. 'G',
  2004. 'H',
  2005. 'I',
  2006. 'J',
  2007. 'K',
  2008. 'L',
  2009. 'M',
  2010. 'N',
  2011. 'O',
  2012. 'P',
  2013. 'Q',
  2014. 'R',
  2015. 'S',
  2016. 'T',
  2017. 'U',
  2018. 'V',
  2019. 'W',
  2020. 'X',
  2021. 'Y',
  2022. 'Z',
  2023. 'bracketleft',
  2024. 'backslash',
  2025. 'bracketright',
  2026. 'asciicircum',
  2027. 'underscore',
  2028. 'grave',
  2029. 'a',
  2030. 'b',
  2031. 'c',
  2032. 'd',
  2033. 'e',
  2034. 'f',
  2035. 'g',
  2036. 'h',
  2037. 'i',
  2038. 'j',
  2039. 'k',
  2040. 'l',
  2041. 'm',
  2042. 'n',
  2043. 'o',
  2044. 'p',
  2045. 'q',
  2046. 'r',
  2047. 's',
  2048. 't',
  2049. 'u',
  2050. 'v',
  2051. 'w',
  2052. 'x',
  2053. 'y',
  2054. 'z',
  2055. 'braceleft',
  2056. 'bar',
  2057. 'braceright',
  2058. 'asciitilde',
  2059. 'bullet',
  2060. 'Euro',
  2061. 'bullet',
  2062. 'quotesinglbase',
  2063. 'florin',
  2064. 'quotedblbase',
  2065. 'ellipsis',
  2066. 'dagger',
  2067. 'daggerdbl',
  2068. 'circumflex',
  2069. 'perthousand',
  2070. 'Scaron',
  2071. 'guilsinglleft',
  2072. 'OE',
  2073. 'bullet',
  2074. 'Zcaron',
  2075. 'bullet',
  2076. 'bullet',
  2077. 'quoteleft',
  2078. 'quoteright',
  2079. 'quotedblleft',
  2080. 'quotedblright',
  2081. 'bullet',
  2082. 'endash',
  2083. 'emdash',
  2084. 'tilde',
  2085. 'trademark',
  2086. 'scaron',
  2087. 'guilsinglright',
  2088. 'oe',
  2089. 'bullet',
  2090. 'zcaron',
  2091. 'Ydieresis',
  2092. 'space',
  2093. 'exclamdown',
  2094. 'cent',
  2095. 'sterling',
  2096. 'currency',
  2097. 'yen',
  2098. 'brokenbar',
  2099. 'section',
  2100. 'dieresis',
  2101. 'copyright',
  2102. 'ordfeminine',
  2103. 'guillemotleft',
  2104. 'logicalnot',
  2105. 'hyphen',
  2106. 'registered',
  2107. 'macron',
  2108. 'degree',
  2109. 'plusminus',
  2110. 'twosuperior',
  2111. 'threesuperior',
  2112. 'acute',
  2113. 'mu',
  2114. 'paragraph',
  2115. 'periodcentered',
  2116. 'cedilla',
  2117. 'onesuperior',
  2118. 'ordmasculine',
  2119. 'guillemotright',
  2120. 'onequarter',
  2121. 'onehalf',
  2122. 'threequarters',
  2123. 'questiondown',
  2124. 'Agrave',
  2125. 'Aacute',
  2126. 'Acircumflex',
  2127. 'Atilde',
  2128. 'Adieresis',
  2129. 'Aring',
  2130. 'AE',
  2131. 'Ccedilla',
  2132. 'Egrave',
  2133. 'Eacute',
  2134. 'Ecircumflex',
  2135. 'Edieresis',
  2136. 'Igrave',
  2137. 'Iacute',
  2138. 'Icircumflex',
  2139. 'Idieresis',
  2140. 'Eth',
  2141. 'Ntilde',
  2142. 'Ograve',
  2143. 'Oacute',
  2144. 'Ocircumflex',
  2145. 'Otilde',
  2146. 'Odieresis',
  2147. 'multiply',
  2148. 'Oslash',
  2149. 'Ugrave',
  2150. 'Uacute',
  2151. 'Ucircumflex',
  2152. 'Udieresis',
  2153. 'Yacute',
  2154. 'Thorn',
  2155. 'germandbls',
  2156. 'agrave',
  2157. 'aacute',
  2158. 'acircumflex',
  2159. 'atilde',
  2160. 'adieresis',
  2161. 'aring',
  2162. 'ae',
  2163. 'ccedilla',
  2164. 'egrave',
  2165. 'eacute',
  2166. 'ecircumflex',
  2167. 'edieresis',
  2168. 'igrave',
  2169. 'iacute',
  2170. 'icircumflex',
  2171. 'idieresis',
  2172. 'eth',
  2173. 'ntilde',
  2174. 'ograve',
  2175. 'oacute',
  2176. 'ocircumflex',
  2177. 'otilde',
  2178. 'odieresis',
  2179. 'divide',
  2180. 'oslash',
  2181. 'ugrave',
  2182. 'uacute',
  2183. 'ucircumflex',
  2184. 'udieresis',
  2185. 'yacute',
  2186. 'thorn',
  2187. 'ydieresis'
  2188. ];
  2189. var SymbolSetEncoding = [
  2190. '',
  2191. '',
  2192. '',
  2193. '',
  2194. '',
  2195. '',
  2196. '',
  2197. '',
  2198. '',
  2199. '',
  2200. '',
  2201. '',
  2202. '',
  2203. '',
  2204. '',
  2205. '',
  2206. '',
  2207. '',
  2208. '',
  2209. '',
  2210. '',
  2211. '',
  2212. '',
  2213. '',
  2214. '',
  2215. '',
  2216. '',
  2217. '',
  2218. '',
  2219. '',
  2220. '',
  2221. '',
  2222. 'space',
  2223. 'exclam',
  2224. 'universal',
  2225. 'numbersign',
  2226. 'existential',
  2227. 'percent',
  2228. 'ampersand',
  2229. 'suchthat',
  2230. 'parenleft',
  2231. 'parenright',
  2232. 'asteriskmath',
  2233. 'plus',
  2234. 'comma',
  2235. 'minus',
  2236. 'period',
  2237. 'slash',
  2238. 'zero',
  2239. 'one',
  2240. 'two',
  2241. 'three',
  2242. 'four',
  2243. 'five',
  2244. 'six',
  2245. 'seven',
  2246. 'eight',
  2247. 'nine',
  2248. 'colon',
  2249. 'semicolon',
  2250. 'less',
  2251. 'equal',
  2252. 'greater',
  2253. 'question',
  2254. 'congruent',
  2255. 'Alpha',
  2256. 'Beta',
  2257. 'Chi',
  2258. 'Delta',
  2259. 'Epsilon',
  2260. 'Phi',
  2261. 'Gamma',
  2262. 'Eta',
  2263. 'Iota',
  2264. 'theta1',
  2265. 'Kappa',
  2266. 'Lambda',
  2267. 'Mu',
  2268. 'Nu',
  2269. 'Omicron',
  2270. 'Pi',
  2271. 'Theta',
  2272. 'Rho',
  2273. 'Sigma',
  2274. 'Tau',
  2275. 'Upsilon',
  2276. 'sigma1',
  2277. 'Omega',
  2278. 'Xi',
  2279. 'Psi',
  2280. 'Zeta',
  2281. 'bracketleft',
  2282. 'therefore',
  2283. 'bracketright',
  2284. 'perpendicular',
  2285. 'underscore',
  2286. 'radicalex',
  2287. 'alpha',
  2288. 'beta',
  2289. 'chi',
  2290. 'delta',
  2291. 'epsilon',
  2292. 'phi',
  2293. 'gamma',
  2294. 'eta',
  2295. 'iota',
  2296. 'phi1',
  2297. 'kappa',
  2298. 'lambda',
  2299. 'mu',
  2300. 'nu',
  2301. 'omicron',
  2302. 'pi',
  2303. 'theta',
  2304. 'rho',
  2305. 'sigma',
  2306. 'tau',
  2307. 'upsilon',
  2308. 'omega1',
  2309. 'omega',
  2310. 'xi',
  2311. 'psi',
  2312. 'zeta',
  2313. 'braceleft',
  2314. 'bar',
  2315. 'braceright',
  2316. 'similar',
  2317. '',
  2318. '',
  2319. '',
  2320. '',
  2321. '',
  2322. '',
  2323. '',
  2324. '',
  2325. '',
  2326. '',
  2327. '',
  2328. '',
  2329. '',
  2330. '',
  2331. '',
  2332. '',
  2333. '',
  2334. '',
  2335. '',
  2336. '',
  2337. '',
  2338. '',
  2339. '',
  2340. '',
  2341. '',
  2342. '',
  2343. '',
  2344. '',
  2345. '',
  2346. '',
  2347. '',
  2348. '',
  2349. '',
  2350. 'Euro',
  2351. 'Upsilon1',
  2352. 'minute',
  2353. 'lessequal',
  2354. 'fraction',
  2355. 'infinity',
  2356. 'florin',
  2357. 'club',
  2358. 'diamond',
  2359. 'heart',
  2360. 'spade',
  2361. 'arrowboth',
  2362. 'arrowleft',
  2363. 'arrowup',
  2364. 'arrowright',
  2365. 'arrowdown',
  2366. 'degree',
  2367. 'plusminus',
  2368. 'second',
  2369. 'greaterequal',
  2370. 'multiply',
  2371. 'proportional',
  2372. 'partialdiff',
  2373. 'bullet',
  2374. 'divide',
  2375. 'notequal',
  2376. 'equivalence',
  2377. 'approxequal',
  2378. 'ellipsis',
  2379. 'arrowvertex',
  2380. 'arrowhorizex',
  2381. 'carriagereturn',
  2382. 'aleph',
  2383. 'Ifraktur',
  2384. 'Rfraktur',
  2385. 'weierstrass',
  2386. 'circlemultiply',
  2387. 'circleplus',
  2388. 'emptyset',
  2389. 'intersection',
  2390. 'union',
  2391. 'propersuperset',
  2392. 'reflexsuperset',
  2393. 'notsubset',
  2394. 'propersubset',
  2395. 'reflexsubset',
  2396. 'element',
  2397. 'notelement',
  2398. 'angle',
  2399. 'gradient',
  2400. 'registerserif',
  2401. 'copyrightserif',
  2402. 'trademarkserif',
  2403. 'product',
  2404. 'radical',
  2405. 'dotmath',
  2406. 'logicalnot',
  2407. 'logicaland',
  2408. 'logicalor',
  2409. 'arrowdblboth',
  2410. 'arrowdblleft',
  2411. 'arrowdblup',
  2412. 'arrowdblright',
  2413. 'arrowdbldown',
  2414. 'lozenge',
  2415. 'angleleft',
  2416. 'registersans',
  2417. 'copyrightsans',
  2418. 'trademarksans',
  2419. 'summation',
  2420. 'parenlefttp',
  2421. 'parenleftex',
  2422. 'parenleftbt',
  2423. 'bracketlefttp',
  2424. 'bracketleftex',
  2425. 'bracketleftbt',
  2426. 'bracelefttp',
  2427. 'braceleftmid',
  2428. 'braceleftbt',
  2429. 'braceex',
  2430. '',
  2431. 'angleright',
  2432. 'integral',
  2433. 'integraltp',
  2434. 'integralex',
  2435. 'integralbt',
  2436. 'parenrighttp',
  2437. 'parenrightex',
  2438. 'parenrightbt',
  2439. 'bracketrighttp',
  2440. 'bracketrightex',
  2441. 'bracketrightbt',
  2442. 'bracerighttp',
  2443. 'bracerightmid',
  2444. 'bracerightbt'
  2445. ];
  2446. var ZapfDingbatsEncoding = [
  2447. '',
  2448. '',
  2449. '',
  2450. '',
  2451. '',
  2452. '',
  2453. '',
  2454. '',
  2455. '',
  2456. '',
  2457. '',
  2458. '',
  2459. '',
  2460. '',
  2461. '',
  2462. '',
  2463. '',
  2464. '',
  2465. '',
  2466. '',
  2467. '',
  2468. '',
  2469. '',
  2470. '',
  2471. '',
  2472. '',
  2473. '',
  2474. '',
  2475. '',
  2476. '',
  2477. '',
  2478. '',
  2479. 'space',
  2480. 'a1',
  2481. 'a2',
  2482. 'a202',
  2483. 'a3',
  2484. 'a4',
  2485. 'a5',
  2486. 'a119',
  2487. 'a118',
  2488. 'a117',
  2489. 'a11',
  2490. 'a12',
  2491. 'a13',
  2492. 'a14',
  2493. 'a15',
  2494. 'a16',
  2495. 'a105',
  2496. 'a17',
  2497. 'a18',
  2498. 'a19',
  2499. 'a20',
  2500. 'a21',
  2501. 'a22',
  2502. 'a23',
  2503. 'a24',
  2504. 'a25',
  2505. 'a26',
  2506. 'a27',
  2507. 'a28',
  2508. 'a6',
  2509. 'a7',
  2510. 'a8',
  2511. 'a9',
  2512. 'a10',
  2513. 'a29',
  2514. 'a30',
  2515. 'a31',
  2516. 'a32',
  2517. 'a33',
  2518. 'a34',
  2519. 'a35',
  2520. 'a36',
  2521. 'a37',
  2522. 'a38',
  2523. 'a39',
  2524. 'a40',
  2525. 'a41',
  2526. 'a42',
  2527. 'a43',
  2528. 'a44',
  2529. 'a45',
  2530. 'a46',
  2531. 'a47',
  2532. 'a48',
  2533. 'a49',
  2534. 'a50',
  2535. 'a51',
  2536. 'a52',
  2537. 'a53',
  2538. 'a54',
  2539. 'a55',
  2540. 'a56',
  2541. 'a57',
  2542. 'a58',
  2543. 'a59',
  2544. 'a60',
  2545. 'a61',
  2546. 'a62',
  2547. 'a63',
  2548. 'a64',
  2549. 'a65',
  2550. 'a66',
  2551. 'a67',
  2552. 'a68',
  2553. 'a69',
  2554. 'a70',
  2555. 'a71',
  2556. 'a72',
  2557. 'a73',
  2558. 'a74',
  2559. 'a203',
  2560. 'a75',
  2561. 'a204',
  2562. 'a76',
  2563. 'a77',
  2564. 'a78',
  2565. 'a79',
  2566. 'a81',
  2567. 'a82',
  2568. 'a83',
  2569. 'a84',
  2570. 'a97',
  2571. 'a98',
  2572. 'a99',
  2573. 'a100',
  2574. '',
  2575. 'a89',
  2576. 'a90',
  2577. 'a93',
  2578. 'a94',
  2579. 'a91',
  2580. 'a92',
  2581. 'a205',
  2582. 'a85',
  2583. 'a206',
  2584. 'a86',
  2585. 'a87',
  2586. 'a88',
  2587. 'a95',
  2588. 'a96',
  2589. '',
  2590. '',
  2591. '',
  2592. '',
  2593. '',
  2594. '',
  2595. '',
  2596. '',
  2597. '',
  2598. '',
  2599. '',
  2600. '',
  2601. '',
  2602. '',
  2603. '',
  2604. '',
  2605. '',
  2606. '',
  2607. '',
  2608. 'a101',
  2609. 'a102',
  2610. 'a103',
  2611. 'a104',
  2612. 'a106',
  2613. 'a107',
  2614. 'a108',
  2615. 'a112',
  2616. 'a111',
  2617. 'a110',
  2618. 'a109',
  2619. 'a120',
  2620. 'a121',
  2621. 'a122',
  2622. 'a123',
  2623. 'a124',
  2624. 'a125',
  2625. 'a126',
  2626. 'a127',
  2627. 'a128',
  2628. 'a129',
  2629. 'a130',
  2630. 'a131',
  2631. 'a132',
  2632. 'a133',
  2633. 'a134',
  2634. 'a135',
  2635. 'a136',
  2636. 'a137',
  2637. 'a138',
  2638. 'a139',
  2639. 'a140',
  2640. 'a141',
  2641. 'a142',
  2642. 'a143',
  2643. 'a144',
  2644. 'a145',
  2645. 'a146',
  2646. 'a147',
  2647. 'a148',
  2648. 'a149',
  2649. 'a150',
  2650. 'a151',
  2651. 'a152',
  2652. 'a153',
  2653. 'a154',
  2654. 'a155',
  2655. 'a156',
  2656. 'a157',
  2657. 'a158',
  2658. 'a159',
  2659. 'a160',
  2660. 'a161',
  2661. 'a163',
  2662. 'a164',
  2663. 'a196',
  2664. 'a165',
  2665. 'a192',
  2666. 'a166',
  2667. 'a167',
  2668. 'a168',
  2669. 'a169',
  2670. 'a170',
  2671. 'a171',
  2672. 'a172',
  2673. 'a173',
  2674. 'a162',
  2675. 'a174',
  2676. 'a175',
  2677. 'a176',
  2678. 'a177',
  2679. 'a178',
  2680. 'a179',
  2681. 'a193',
  2682. 'a180',
  2683. 'a199',
  2684. 'a181',
  2685. 'a200',
  2686. 'a182',
  2687. '',
  2688. 'a201',
  2689. 'a183',
  2690. 'a184',
  2691. 'a197',
  2692. 'a185',
  2693. 'a194',
  2694. 'a198',
  2695. 'a186',
  2696. 'a195',
  2697. 'a187',
  2698. 'a188',
  2699. 'a189',
  2700. 'a190',
  2701. 'a191'
  2702. ];
  2703. function getEncoding(encodingName) {
  2704. switch (encodingName) {
  2705. case 'WinAnsiEncoding':
  2706. return WinAnsiEncoding;
  2707. case 'StandardEncoding':
  2708. return StandardEncoding;
  2709. case 'MacRomanEncoding':
  2710. return MacRomanEncoding;
  2711. case 'SymbolSetEncoding':
  2712. return SymbolSetEncoding;
  2713. case 'ZapfDingbatsEncoding':
  2714. return ZapfDingbatsEncoding;
  2715. case 'ExpertEncoding':
  2716. return ExpertEncoding;
  2717. case 'MacExpertEncoding':
  2718. return MacExpertEncoding;
  2719. default:
  2720. return null;
  2721. }
  2722. }
  2723. exports.WinAnsiEncoding = WinAnsiEncoding;
  2724. exports.StandardEncoding = StandardEncoding;
  2725. exports.MacRomanEncoding = MacRomanEncoding;
  2726. exports.SymbolSetEncoding = SymbolSetEncoding;
  2727. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  2728. exports.ExpertEncoding = ExpertEncoding;
  2729. exports.getEncoding = getEncoding;
  2730. }));
  2731. (function (root, factory) {
  2732. factory(root.pdfjsSharedUtil = {});
  2733. }(this, function (exports) {
  2734. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  2735. var FONT_IDENTITY_MATRIX = [
  2736. 0.001,
  2737. 0,
  2738. 0,
  2739. 0.001,
  2740. 0,
  2741. 0
  2742. ];
  2743. var TextRenderingMode = {
  2744. FILL: 0,
  2745. STROKE: 1,
  2746. FILL_STROKE: 2,
  2747. INVISIBLE: 3,
  2748. FILL_ADD_TO_PATH: 4,
  2749. STROKE_ADD_TO_PATH: 5,
  2750. FILL_STROKE_ADD_TO_PATH: 6,
  2751. ADD_TO_PATH: 7,
  2752. FILL_STROKE_MASK: 3,
  2753. ADD_TO_PATH_FLAG: 4
  2754. };
  2755. var ImageKind = {
  2756. GRAYSCALE_1BPP: 1,
  2757. RGB_24BPP: 2,
  2758. RGBA_32BPP: 3
  2759. };
  2760. var AnnotationType = {
  2761. TEXT: 1,
  2762. LINK: 2,
  2763. FREETEXT: 3,
  2764. LINE: 4,
  2765. SQUARE: 5,
  2766. CIRCLE: 6,
  2767. POLYGON: 7,
  2768. POLYLINE: 8,
  2769. HIGHLIGHT: 9,
  2770. UNDERLINE: 10,
  2771. SQUIGGLY: 11,
  2772. STRIKEOUT: 12,
  2773. STAMP: 13,
  2774. CARET: 14,
  2775. INK: 15,
  2776. POPUP: 16,
  2777. FILEATTACHMENT: 17,
  2778. SOUND: 18,
  2779. MOVIE: 19,
  2780. WIDGET: 20,
  2781. SCREEN: 21,
  2782. PRINTERMARK: 22,
  2783. TRAPNET: 23,
  2784. WATERMARK: 24,
  2785. THREED: 25,
  2786. REDACT: 26
  2787. };
  2788. var AnnotationFlag = {
  2789. INVISIBLE: 0x01,
  2790. HIDDEN: 0x02,
  2791. PRINT: 0x04,
  2792. NOZOOM: 0x08,
  2793. NOROTATE: 0x10,
  2794. NOVIEW: 0x20,
  2795. READONLY: 0x40,
  2796. LOCKED: 0x80,
  2797. TOGGLENOVIEW: 0x100,
  2798. LOCKEDCONTENTS: 0x200
  2799. };
  2800. var AnnotationFieldFlag = {
  2801. READONLY: 0x0000001,
  2802. REQUIRED: 0x0000002,
  2803. NOEXPORT: 0x0000004,
  2804. MULTILINE: 0x0001000,
  2805. PASSWORD: 0x0002000,
  2806. NOTOGGLETOOFF: 0x0004000,
  2807. RADIO: 0x0008000,
  2808. PUSHBUTTON: 0x0010000,
  2809. COMBO: 0x0020000,
  2810. EDIT: 0x0040000,
  2811. SORT: 0x0080000,
  2812. FILESELECT: 0x0100000,
  2813. MULTISELECT: 0x0200000,
  2814. DONOTSPELLCHECK: 0x0400000,
  2815. DONOTSCROLL: 0x0800000,
  2816. COMB: 0x1000000,
  2817. RICHTEXT: 0x2000000,
  2818. RADIOSINUNISON: 0x2000000,
  2819. COMMITONSELCHANGE: 0x4000000
  2820. };
  2821. var AnnotationBorderStyleType = {
  2822. SOLID: 1,
  2823. DASHED: 2,
  2824. BEVELED: 3,
  2825. INSET: 4,
  2826. UNDERLINE: 5
  2827. };
  2828. var StreamType = {
  2829. UNKNOWN: 0,
  2830. FLATE: 1,
  2831. LZW: 2,
  2832. DCT: 3,
  2833. JPX: 4,
  2834. JBIG: 5,
  2835. A85: 6,
  2836. AHX: 7,
  2837. CCF: 8,
  2838. RL: 9
  2839. };
  2840. var FontType = {
  2841. UNKNOWN: 0,
  2842. TYPE1: 1,
  2843. TYPE1C: 2,
  2844. CIDFONTTYPE0: 3,
  2845. CIDFONTTYPE0C: 4,
  2846. TRUETYPE: 5,
  2847. CIDFONTTYPE2: 6,
  2848. TYPE3: 7,
  2849. OPENTYPE: 8,
  2850. TYPE0: 9,
  2851. MMTYPE1: 10
  2852. };
  2853. var VERBOSITY_LEVELS = {
  2854. errors: 0,
  2855. warnings: 1,
  2856. infos: 5
  2857. };
  2858. var OPS = {
  2859. dependency: 1,
  2860. setLineWidth: 2,
  2861. setLineCap: 3,
  2862. setLineJoin: 4,
  2863. setMiterLimit: 5,
  2864. setDash: 6,
  2865. setRenderingIntent: 7,
  2866. setFlatness: 8,
  2867. setGState: 9,
  2868. save: 10,
  2869. restore: 11,
  2870. transform: 12,
  2871. moveTo: 13,
  2872. lineTo: 14,
  2873. curveTo: 15,
  2874. curveTo2: 16,
  2875. curveTo3: 17,
  2876. closePath: 18,
  2877. rectangle: 19,
  2878. stroke: 20,
  2879. closeStroke: 21,
  2880. fill: 22,
  2881. eoFill: 23,
  2882. fillStroke: 24,
  2883. eoFillStroke: 25,
  2884. closeFillStroke: 26,
  2885. closeEOFillStroke: 27,
  2886. endPath: 28,
  2887. clip: 29,
  2888. eoClip: 30,
  2889. beginText: 31,
  2890. endText: 32,
  2891. setCharSpacing: 33,
  2892. setWordSpacing: 34,
  2893. setHScale: 35,
  2894. setLeading: 36,
  2895. setFont: 37,
  2896. setTextRenderingMode: 38,
  2897. setTextRise: 39,
  2898. moveText: 40,
  2899. setLeadingMoveText: 41,
  2900. setTextMatrix: 42,
  2901. nextLine: 43,
  2902. showText: 44,
  2903. showSpacedText: 45,
  2904. nextLineShowText: 46,
  2905. nextLineSetSpacingShowText: 47,
  2906. setCharWidth: 48,
  2907. setCharWidthAndBounds: 49,
  2908. setStrokeColorSpace: 50,
  2909. setFillColorSpace: 51,
  2910. setStrokeColor: 52,
  2911. setStrokeColorN: 53,
  2912. setFillColor: 54,
  2913. setFillColorN: 55,
  2914. setStrokeGray: 56,
  2915. setFillGray: 57,
  2916. setStrokeRGBColor: 58,
  2917. setFillRGBColor: 59,
  2918. setStrokeCMYKColor: 60,
  2919. setFillCMYKColor: 61,
  2920. shadingFill: 62,
  2921. beginInlineImage: 63,
  2922. beginImageData: 64,
  2923. endInlineImage: 65,
  2924. paintXObject: 66,
  2925. markPoint: 67,
  2926. markPointProps: 68,
  2927. beginMarkedContent: 69,
  2928. beginMarkedContentProps: 70,
  2929. endMarkedContent: 71,
  2930. beginCompat: 72,
  2931. endCompat: 73,
  2932. paintFormXObjectBegin: 74,
  2933. paintFormXObjectEnd: 75,
  2934. beginGroup: 76,
  2935. endGroup: 77,
  2936. beginAnnotations: 78,
  2937. endAnnotations: 79,
  2938. beginAnnotation: 80,
  2939. endAnnotation: 81,
  2940. paintJpegXObject: 82,
  2941. paintImageMaskXObject: 83,
  2942. paintImageMaskXObjectGroup: 84,
  2943. paintImageXObject: 85,
  2944. paintInlineImageXObject: 86,
  2945. paintInlineImageXObjectGroup: 87,
  2946. paintImageXObjectRepeat: 88,
  2947. paintImageMaskXObjectRepeat: 89,
  2948. paintSolidColorImageMask: 90,
  2949. constructPath: 91
  2950. };
  2951. var verbosity = VERBOSITY_LEVELS.warnings;
  2952. function setVerbosityLevel(level) {
  2953. verbosity = level;
  2954. }
  2955. function getVerbosityLevel() {
  2956. return verbosity;
  2957. }
  2958. function info(msg) {
  2959. if (verbosity >= VERBOSITY_LEVELS.infos) {
  2960. console.log('Info: ' + msg);
  2961. }
  2962. }
  2963. function warn(msg) {
  2964. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  2965. console.log('Warning: ' + msg);
  2966. }
  2967. }
  2968. function deprecated(details) {
  2969. console.log('Deprecated API usage: ' + details);
  2970. }
  2971. function error(msg) {
  2972. if (verbosity >= VERBOSITY_LEVELS.errors) {
  2973. console.log('Error: ' + msg);
  2974. console.log(backtrace());
  2975. }
  2976. throw new Error(msg);
  2977. }
  2978. function backtrace() {
  2979. try {
  2980. throw new Error();
  2981. } catch (e) {
  2982. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  2983. }
  2984. }
  2985. function assert(cond, msg) {
  2986. if (!cond) {
  2987. error(msg);
  2988. }
  2989. }
  2990. var UNSUPPORTED_FEATURES = {
  2991. unknown: 'unknown',
  2992. forms: 'forms',
  2993. javaScript: 'javaScript',
  2994. smask: 'smask',
  2995. shadingPattern: 'shadingPattern',
  2996. font: 'font'
  2997. };
  2998. function isSameOrigin(baseUrl, otherUrl) {
  2999. try {
  3000. var base = new URL(baseUrl);
  3001. if (!base.origin || base.origin === 'null') {
  3002. return false;
  3003. }
  3004. } catch (e) {
  3005. return false;
  3006. }
  3007. var other = new URL(otherUrl, base);
  3008. return base.origin === other.origin;
  3009. }
  3010. function isValidProtocol(url) {
  3011. if (!url) {
  3012. return false;
  3013. }
  3014. switch (url.protocol) {
  3015. case 'http:':
  3016. case 'https:':
  3017. case 'ftp:':
  3018. case 'mailto:':
  3019. case 'tel:':
  3020. return true;
  3021. default:
  3022. return false;
  3023. }
  3024. }
  3025. function createValidAbsoluteUrl(url, baseUrl) {
  3026. if (!url) {
  3027. return null;
  3028. }
  3029. try {
  3030. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3031. if (isValidProtocol(absoluteUrl)) {
  3032. return absoluteUrl;
  3033. }
  3034. } catch (ex) {
  3035. }
  3036. return null;
  3037. }
  3038. function shadow(obj, prop, value) {
  3039. Object.defineProperty(obj, prop, {
  3040. value: value,
  3041. enumerable: true,
  3042. configurable: true,
  3043. writable: false
  3044. });
  3045. return value;
  3046. }
  3047. function getLookupTableFactory(initializer) {
  3048. var lookup;
  3049. return function () {
  3050. if (initializer) {
  3051. lookup = Object.create(null);
  3052. initializer(lookup);
  3053. initializer = null;
  3054. }
  3055. return lookup;
  3056. };
  3057. }
  3058. var PasswordResponses = {
  3059. NEED_PASSWORD: 1,
  3060. INCORRECT_PASSWORD: 2
  3061. };
  3062. var PasswordException = function PasswordExceptionClosure() {
  3063. function PasswordException(msg, code) {
  3064. this.name = 'PasswordException';
  3065. this.message = msg;
  3066. this.code = code;
  3067. }
  3068. PasswordException.prototype = new Error();
  3069. PasswordException.constructor = PasswordException;
  3070. return PasswordException;
  3071. }();
  3072. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  3073. function UnknownErrorException(msg, details) {
  3074. this.name = 'UnknownErrorException';
  3075. this.message = msg;
  3076. this.details = details;
  3077. }
  3078. UnknownErrorException.prototype = new Error();
  3079. UnknownErrorException.constructor = UnknownErrorException;
  3080. return UnknownErrorException;
  3081. }();
  3082. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  3083. function InvalidPDFException(msg) {
  3084. this.name = 'InvalidPDFException';
  3085. this.message = msg;
  3086. }
  3087. InvalidPDFException.prototype = new Error();
  3088. InvalidPDFException.constructor = InvalidPDFException;
  3089. return InvalidPDFException;
  3090. }();
  3091. var MissingPDFException = function MissingPDFExceptionClosure() {
  3092. function MissingPDFException(msg) {
  3093. this.name = 'MissingPDFException';
  3094. this.message = msg;
  3095. }
  3096. MissingPDFException.prototype = new Error();
  3097. MissingPDFException.constructor = MissingPDFException;
  3098. return MissingPDFException;
  3099. }();
  3100. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  3101. function UnexpectedResponseException(msg, status) {
  3102. this.name = 'UnexpectedResponseException';
  3103. this.message = msg;
  3104. this.status = status;
  3105. }
  3106. UnexpectedResponseException.prototype = new Error();
  3107. UnexpectedResponseException.constructor = UnexpectedResponseException;
  3108. return UnexpectedResponseException;
  3109. }();
  3110. var NotImplementedException = function NotImplementedExceptionClosure() {
  3111. function NotImplementedException(msg) {
  3112. this.message = msg;
  3113. }
  3114. NotImplementedException.prototype = new Error();
  3115. NotImplementedException.prototype.name = 'NotImplementedException';
  3116. NotImplementedException.constructor = NotImplementedException;
  3117. return NotImplementedException;
  3118. }();
  3119. var MissingDataException = function MissingDataExceptionClosure() {
  3120. function MissingDataException(begin, end) {
  3121. this.begin = begin;
  3122. this.end = end;
  3123. this.message = 'Missing data [' + begin + ', ' + end + ')';
  3124. }
  3125. MissingDataException.prototype = new Error();
  3126. MissingDataException.prototype.name = 'MissingDataException';
  3127. MissingDataException.constructor = MissingDataException;
  3128. return MissingDataException;
  3129. }();
  3130. var XRefParseException = function XRefParseExceptionClosure() {
  3131. function XRefParseException(msg) {
  3132. this.message = msg;
  3133. }
  3134. XRefParseException.prototype = new Error();
  3135. XRefParseException.prototype.name = 'XRefParseException';
  3136. XRefParseException.constructor = XRefParseException;
  3137. return XRefParseException;
  3138. }();
  3139. var NullCharactersRegExp = /\x00/g;
  3140. function removeNullCharacters(str) {
  3141. if (typeof str !== 'string') {
  3142. warn('The argument for removeNullCharacters must be a string.');
  3143. return str;
  3144. }
  3145. return str.replace(NullCharactersRegExp, '');
  3146. }
  3147. function bytesToString(bytes) {
  3148. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  3149. var length = bytes.length;
  3150. var MAX_ARGUMENT_COUNT = 8192;
  3151. if (length < MAX_ARGUMENT_COUNT) {
  3152. return String.fromCharCode.apply(null, bytes);
  3153. }
  3154. var strBuf = [];
  3155. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3156. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3157. var chunk = bytes.subarray(i, chunkEnd);
  3158. strBuf.push(String.fromCharCode.apply(null, chunk));
  3159. }
  3160. return strBuf.join('');
  3161. }
  3162. function stringToBytes(str) {
  3163. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  3164. var length = str.length;
  3165. var bytes = new Uint8Array(length);
  3166. for (var i = 0; i < length; ++i) {
  3167. bytes[i] = str.charCodeAt(i) & 0xFF;
  3168. }
  3169. return bytes;
  3170. }
  3171. function arrayByteLength(arr) {
  3172. if (arr.length !== undefined) {
  3173. return arr.length;
  3174. }
  3175. assert(arr.byteLength !== undefined);
  3176. return arr.byteLength;
  3177. }
  3178. function arraysToBytes(arr) {
  3179. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  3180. return arr[0];
  3181. }
  3182. var resultLength = 0;
  3183. var i, ii = arr.length;
  3184. var item, itemLength;
  3185. for (i = 0; i < ii; i++) {
  3186. item = arr[i];
  3187. itemLength = arrayByteLength(item);
  3188. resultLength += itemLength;
  3189. }
  3190. var pos = 0;
  3191. var data = new Uint8Array(resultLength);
  3192. for (i = 0; i < ii; i++) {
  3193. item = arr[i];
  3194. if (!(item instanceof Uint8Array)) {
  3195. if (typeof item === 'string') {
  3196. item = stringToBytes(item);
  3197. } else {
  3198. item = new Uint8Array(item);
  3199. }
  3200. }
  3201. itemLength = item.byteLength;
  3202. data.set(item, pos);
  3203. pos += itemLength;
  3204. }
  3205. return data;
  3206. }
  3207. function string32(value) {
  3208. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3209. }
  3210. function log2(x) {
  3211. var n = 1, i = 0;
  3212. while (x > n) {
  3213. n <<= 1;
  3214. i++;
  3215. }
  3216. return i;
  3217. }
  3218. function readInt8(data, start) {
  3219. return data[start] << 24 >> 24;
  3220. }
  3221. function readUint16(data, offset) {
  3222. return data[offset] << 8 | data[offset + 1];
  3223. }
  3224. function readUint32(data, offset) {
  3225. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  3226. }
  3227. function isLittleEndian() {
  3228. var buffer8 = new Uint8Array(2);
  3229. buffer8[0] = 1;
  3230. var buffer16 = new Uint16Array(buffer8.buffer);
  3231. return buffer16[0] === 1;
  3232. }
  3233. function isEvalSupported() {
  3234. try {
  3235. new Function('');
  3236. return true;
  3237. } catch (e) {
  3238. return false;
  3239. }
  3240. }
  3241. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  3242. function Uint32ArrayView(buffer, length) {
  3243. this.buffer = buffer;
  3244. this.byteLength = buffer.length;
  3245. this.length = length === undefined ? this.byteLength >> 2 : length;
  3246. ensureUint32ArrayViewProps(this.length);
  3247. }
  3248. Uint32ArrayView.prototype = Object.create(null);
  3249. var uint32ArrayViewSetters = 0;
  3250. function createUint32ArrayProp(index) {
  3251. return {
  3252. get: function () {
  3253. var buffer = this.buffer, offset = index << 2;
  3254. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  3255. },
  3256. set: function (value) {
  3257. var buffer = this.buffer, offset = index << 2;
  3258. buffer[offset] = value & 255;
  3259. buffer[offset + 1] = value >> 8 & 255;
  3260. buffer[offset + 2] = value >> 16 & 255;
  3261. buffer[offset + 3] = value >>> 24 & 255;
  3262. }
  3263. };
  3264. }
  3265. function ensureUint32ArrayViewProps(length) {
  3266. while (uint32ArrayViewSetters < length) {
  3267. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  3268. uint32ArrayViewSetters++;
  3269. }
  3270. }
  3271. return Uint32ArrayView;
  3272. }();
  3273. exports.Uint32ArrayView = Uint32ArrayView;
  3274. var IDENTITY_MATRIX = [
  3275. 1,
  3276. 0,
  3277. 0,
  3278. 1,
  3279. 0,
  3280. 0
  3281. ];
  3282. var Util = function UtilClosure() {
  3283. function Util() {
  3284. }
  3285. var rgbBuf = [
  3286. 'rgb(',
  3287. 0,
  3288. ',',
  3289. 0,
  3290. ',',
  3291. 0,
  3292. ')'
  3293. ];
  3294. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  3295. rgbBuf[1] = r;
  3296. rgbBuf[3] = g;
  3297. rgbBuf[5] = b;
  3298. return rgbBuf.join('');
  3299. };
  3300. Util.transform = function Util_transform(m1, m2) {
  3301. return [
  3302. m1[0] * m2[0] + m1[2] * m2[1],
  3303. m1[1] * m2[0] + m1[3] * m2[1],
  3304. m1[0] * m2[2] + m1[2] * m2[3],
  3305. m1[1] * m2[2] + m1[3] * m2[3],
  3306. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  3307. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  3308. ];
  3309. };
  3310. Util.applyTransform = function Util_applyTransform(p, m) {
  3311. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  3312. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  3313. return [
  3314. xt,
  3315. yt
  3316. ];
  3317. };
  3318. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  3319. var d = m[0] * m[3] - m[1] * m[2];
  3320. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  3321. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  3322. return [
  3323. xt,
  3324. yt
  3325. ];
  3326. };
  3327. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  3328. var p1 = Util.applyTransform(r, m);
  3329. var p2 = Util.applyTransform(r.slice(2, 4), m);
  3330. var p3 = Util.applyTransform([
  3331. r[0],
  3332. r[3]
  3333. ], m);
  3334. var p4 = Util.applyTransform([
  3335. r[2],
  3336. r[1]
  3337. ], m);
  3338. return [
  3339. Math.min(p1[0], p2[0], p3[0], p4[0]),
  3340. Math.min(p1[1], p2[1], p3[1], p4[1]),
  3341. Math.max(p1[0], p2[0], p3[0], p4[0]),
  3342. Math.max(p1[1], p2[1], p3[1], p4[1])
  3343. ];
  3344. };
  3345. Util.inverseTransform = function Util_inverseTransform(m) {
  3346. var d = m[0] * m[3] - m[1] * m[2];
  3347. return [
  3348. m[3] / d,
  3349. -m[1] / d,
  3350. -m[2] / d,
  3351. m[0] / d,
  3352. (m[2] * m[5] - m[4] * m[3]) / d,
  3353. (m[4] * m[1] - m[5] * m[0]) / d
  3354. ];
  3355. };
  3356. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  3357. return [
  3358. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  3359. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  3360. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  3361. ];
  3362. };
  3363. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  3364. var transpose = [
  3365. m[0],
  3366. m[2],
  3367. m[1],
  3368. m[3]
  3369. ];
  3370. var a = m[0] * transpose[0] + m[1] * transpose[2];
  3371. var b = m[0] * transpose[1] + m[1] * transpose[3];
  3372. var c = m[2] * transpose[0] + m[3] * transpose[2];
  3373. var d = m[2] * transpose[1] + m[3] * transpose[3];
  3374. var first = (a + d) / 2;
  3375. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  3376. var sx = first + second || 1;
  3377. var sy = first - second || 1;
  3378. return [
  3379. Math.sqrt(sx),
  3380. Math.sqrt(sy)
  3381. ];
  3382. };
  3383. Util.normalizeRect = function Util_normalizeRect(rect) {
  3384. var r = rect.slice(0);
  3385. if (rect[0] > rect[2]) {
  3386. r[0] = rect[2];
  3387. r[2] = rect[0];
  3388. }
  3389. if (rect[1] > rect[3]) {
  3390. r[1] = rect[3];
  3391. r[3] = rect[1];
  3392. }
  3393. return r;
  3394. };
  3395. Util.intersect = function Util_intersect(rect1, rect2) {
  3396. function compare(a, b) {
  3397. return a - b;
  3398. }
  3399. var orderedX = [
  3400. rect1[0],
  3401. rect1[2],
  3402. rect2[0],
  3403. rect2[2]
  3404. ].sort(compare), orderedY = [
  3405. rect1[1],
  3406. rect1[3],
  3407. rect2[1],
  3408. rect2[3]
  3409. ].sort(compare), result = [];
  3410. rect1 = Util.normalizeRect(rect1);
  3411. rect2 = Util.normalizeRect(rect2);
  3412. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  3413. result[0] = orderedX[1];
  3414. result[2] = orderedX[2];
  3415. } else {
  3416. return false;
  3417. }
  3418. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  3419. result[1] = orderedY[1];
  3420. result[3] = orderedY[2];
  3421. } else {
  3422. return false;
  3423. }
  3424. return result;
  3425. };
  3426. Util.sign = function Util_sign(num) {
  3427. return num < 0 ? -1 : 1;
  3428. };
  3429. var ROMAN_NUMBER_MAP = [
  3430. '',
  3431. 'C',
  3432. 'CC',
  3433. 'CCC',
  3434. 'CD',
  3435. 'D',
  3436. 'DC',
  3437. 'DCC',
  3438. 'DCCC',
  3439. 'CM',
  3440. '',
  3441. 'X',
  3442. 'XX',
  3443. 'XXX',
  3444. 'XL',
  3445. 'L',
  3446. 'LX',
  3447. 'LXX',
  3448. 'LXXX',
  3449. 'XC',
  3450. '',
  3451. 'I',
  3452. 'II',
  3453. 'III',
  3454. 'IV',
  3455. 'V',
  3456. 'VI',
  3457. 'VII',
  3458. 'VIII',
  3459. 'IX'
  3460. ];
  3461. Util.toRoman = function Util_toRoman(number, lowerCase) {
  3462. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  3463. var pos, romanBuf = [];
  3464. while (number >= 1000) {
  3465. number -= 1000;
  3466. romanBuf.push('M');
  3467. }
  3468. pos = number / 100 | 0;
  3469. number %= 100;
  3470. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  3471. pos = number / 10 | 0;
  3472. number %= 10;
  3473. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  3474. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  3475. var romanStr = romanBuf.join('');
  3476. return lowerCase ? romanStr.toLowerCase() : romanStr;
  3477. };
  3478. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  3479. Array.prototype.push.apply(arr1, arr2);
  3480. };
  3481. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  3482. Array.prototype.unshift.apply(arr1, arr2);
  3483. };
  3484. Util.extendObj = function extendObj(obj1, obj2) {
  3485. for (var key in obj2) {
  3486. obj1[key] = obj2[key];
  3487. }
  3488. };
  3489. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  3490. while (dict && !dict.has(name)) {
  3491. dict = dict.get('Parent');
  3492. }
  3493. if (!dict) {
  3494. return null;
  3495. }
  3496. return getArray ? dict.getArray(name) : dict.get(name);
  3497. };
  3498. Util.inherit = function Util_inherit(sub, base, prototype) {
  3499. sub.prototype = Object.create(base.prototype);
  3500. sub.prototype.constructor = sub;
  3501. for (var prop in prototype) {
  3502. sub.prototype[prop] = prototype[prop];
  3503. }
  3504. };
  3505. Util.loadScript = function Util_loadScript(src, callback) {
  3506. var script = document.createElement('script');
  3507. var loaded = false;
  3508. script.setAttribute('src', src);
  3509. if (callback) {
  3510. script.onload = function () {
  3511. if (!loaded) {
  3512. callback();
  3513. }
  3514. loaded = true;
  3515. };
  3516. }
  3517. document.getElementsByTagName('head')[0].appendChild(script);
  3518. };
  3519. return Util;
  3520. }();
  3521. var PageViewport = function PageViewportClosure() {
  3522. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  3523. this.viewBox = viewBox;
  3524. this.scale = scale;
  3525. this.rotation = rotation;
  3526. this.offsetX = offsetX;
  3527. this.offsetY = offsetY;
  3528. var centerX = (viewBox[2] + viewBox[0]) / 2;
  3529. var centerY = (viewBox[3] + viewBox[1]) / 2;
  3530. var rotateA, rotateB, rotateC, rotateD;
  3531. rotation = rotation % 360;
  3532. rotation = rotation < 0 ? rotation + 360 : rotation;
  3533. switch (rotation) {
  3534. case 180:
  3535. rotateA = -1;
  3536. rotateB = 0;
  3537. rotateC = 0;
  3538. rotateD = 1;
  3539. break;
  3540. case 90:
  3541. rotateA = 0;
  3542. rotateB = 1;
  3543. rotateC = 1;
  3544. rotateD = 0;
  3545. break;
  3546. case 270:
  3547. rotateA = 0;
  3548. rotateB = -1;
  3549. rotateC = -1;
  3550. rotateD = 0;
  3551. break;
  3552. default:
  3553. rotateA = 1;
  3554. rotateB = 0;
  3555. rotateC = 0;
  3556. rotateD = -1;
  3557. break;
  3558. }
  3559. if (dontFlip) {
  3560. rotateC = -rotateC;
  3561. rotateD = -rotateD;
  3562. }
  3563. var offsetCanvasX, offsetCanvasY;
  3564. var width, height;
  3565. if (rotateA === 0) {
  3566. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  3567. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  3568. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3569. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3570. } else {
  3571. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  3572. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  3573. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3574. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3575. }
  3576. this.transform = [
  3577. rotateA * scale,
  3578. rotateB * scale,
  3579. rotateC * scale,
  3580. rotateD * scale,
  3581. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  3582. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  3583. ];
  3584. this.width = width;
  3585. this.height = height;
  3586. this.fontScale = scale;
  3587. }
  3588. PageViewport.prototype = {
  3589. clone: function PageViewPort_clone(args) {
  3590. args = args || {};
  3591. var scale = 'scale' in args ? args.scale : this.scale;
  3592. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  3593. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  3594. },
  3595. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  3596. return Util.applyTransform([
  3597. x,
  3598. y
  3599. ], this.transform);
  3600. },
  3601. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  3602. var tl = Util.applyTransform([
  3603. rect[0],
  3604. rect[1]
  3605. ], this.transform);
  3606. var br = Util.applyTransform([
  3607. rect[2],
  3608. rect[3]
  3609. ], this.transform);
  3610. return [
  3611. tl[0],
  3612. tl[1],
  3613. br[0],
  3614. br[1]
  3615. ];
  3616. },
  3617. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  3618. return Util.applyInverseTransform([
  3619. x,
  3620. y
  3621. ], this.transform);
  3622. }
  3623. };
  3624. return PageViewport;
  3625. }();
  3626. var PDFStringTranslateTable = [
  3627. 0,
  3628. 0,
  3629. 0,
  3630. 0,
  3631. 0,
  3632. 0,
  3633. 0,
  3634. 0,
  3635. 0,
  3636. 0,
  3637. 0,
  3638. 0,
  3639. 0,
  3640. 0,
  3641. 0,
  3642. 0,
  3643. 0,
  3644. 0,
  3645. 0,
  3646. 0,
  3647. 0,
  3648. 0,
  3649. 0,
  3650. 0,
  3651. 0x2D8,
  3652. 0x2C7,
  3653. 0x2C6,
  3654. 0x2D9,
  3655. 0x2DD,
  3656. 0x2DB,
  3657. 0x2DA,
  3658. 0x2DC,
  3659. 0,
  3660. 0,
  3661. 0,
  3662. 0,
  3663. 0,
  3664. 0,
  3665. 0,
  3666. 0,
  3667. 0,
  3668. 0,
  3669. 0,
  3670. 0,
  3671. 0,
  3672. 0,
  3673. 0,
  3674. 0,
  3675. 0,
  3676. 0,
  3677. 0,
  3678. 0,
  3679. 0,
  3680. 0,
  3681. 0,
  3682. 0,
  3683. 0,
  3684. 0,
  3685. 0,
  3686. 0,
  3687. 0,
  3688. 0,
  3689. 0,
  3690. 0,
  3691. 0,
  3692. 0,
  3693. 0,
  3694. 0,
  3695. 0,
  3696. 0,
  3697. 0,
  3698. 0,
  3699. 0,
  3700. 0,
  3701. 0,
  3702. 0,
  3703. 0,
  3704. 0,
  3705. 0,
  3706. 0,
  3707. 0,
  3708. 0,
  3709. 0,
  3710. 0,
  3711. 0,
  3712. 0,
  3713. 0,
  3714. 0,
  3715. 0,
  3716. 0,
  3717. 0,
  3718. 0,
  3719. 0,
  3720. 0,
  3721. 0,
  3722. 0,
  3723. 0,
  3724. 0,
  3725. 0,
  3726. 0,
  3727. 0,
  3728. 0,
  3729. 0,
  3730. 0,
  3731. 0,
  3732. 0,
  3733. 0,
  3734. 0,
  3735. 0,
  3736. 0,
  3737. 0,
  3738. 0,
  3739. 0,
  3740. 0,
  3741. 0,
  3742. 0,
  3743. 0,
  3744. 0,
  3745. 0,
  3746. 0,
  3747. 0,
  3748. 0,
  3749. 0,
  3750. 0,
  3751. 0,
  3752. 0,
  3753. 0,
  3754. 0,
  3755. 0x2022,
  3756. 0x2020,
  3757. 0x2021,
  3758. 0x2026,
  3759. 0x2014,
  3760. 0x2013,
  3761. 0x192,
  3762. 0x2044,
  3763. 0x2039,
  3764. 0x203A,
  3765. 0x2212,
  3766. 0x2030,
  3767. 0x201E,
  3768. 0x201C,
  3769. 0x201D,
  3770. 0x2018,
  3771. 0x2019,
  3772. 0x201A,
  3773. 0x2122,
  3774. 0xFB01,
  3775. 0xFB02,
  3776. 0x141,
  3777. 0x152,
  3778. 0x160,
  3779. 0x178,
  3780. 0x17D,
  3781. 0x131,
  3782. 0x142,
  3783. 0x153,
  3784. 0x161,
  3785. 0x17E,
  3786. 0,
  3787. 0x20AC
  3788. ];
  3789. function stringToPDFString(str) {
  3790. var i, n = str.length, strBuf = [];
  3791. if (str[0] === '\xFE' && str[1] === '\xFF') {
  3792. for (i = 2; i < n; i += 2) {
  3793. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  3794. }
  3795. } else {
  3796. for (i = 0; i < n; ++i) {
  3797. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  3798. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  3799. }
  3800. }
  3801. return strBuf.join('');
  3802. }
  3803. function stringToUTF8String(str) {
  3804. return decodeURIComponent(escape(str));
  3805. }
  3806. function utf8StringToString(str) {
  3807. return unescape(encodeURIComponent(str));
  3808. }
  3809. function isEmptyObj(obj) {
  3810. for (var key in obj) {
  3811. return false;
  3812. }
  3813. return true;
  3814. }
  3815. function isBool(v) {
  3816. return typeof v === 'boolean';
  3817. }
  3818. function isInt(v) {
  3819. return typeof v === 'number' && (v | 0) === v;
  3820. }
  3821. function isNum(v) {
  3822. return typeof v === 'number';
  3823. }
  3824. function isString(v) {
  3825. return typeof v === 'string';
  3826. }
  3827. function isArray(v) {
  3828. return v instanceof Array;
  3829. }
  3830. function isArrayBuffer(v) {
  3831. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  3832. }
  3833. function isSpace(ch) {
  3834. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  3835. }
  3836. function createPromiseCapability() {
  3837. var capability = {};
  3838. capability.promise = new Promise(function (resolve, reject) {
  3839. capability.resolve = resolve;
  3840. capability.reject = reject;
  3841. });
  3842. return capability;
  3843. }
  3844. (function PromiseClosure() {
  3845. if (globalScope.Promise) {
  3846. if (typeof globalScope.Promise.all !== 'function') {
  3847. globalScope.Promise.all = function (iterable) {
  3848. var count = 0, results = [], resolve, reject;
  3849. var promise = new globalScope.Promise(function (resolve_, reject_) {
  3850. resolve = resolve_;
  3851. reject = reject_;
  3852. });
  3853. iterable.forEach(function (p, i) {
  3854. count++;
  3855. p.then(function (result) {
  3856. results[i] = result;
  3857. count--;
  3858. if (count === 0) {
  3859. resolve(results);
  3860. }
  3861. }, reject);
  3862. });
  3863. if (count === 0) {
  3864. resolve(results);
  3865. }
  3866. return promise;
  3867. };
  3868. }
  3869. if (typeof globalScope.Promise.resolve !== 'function') {
  3870. globalScope.Promise.resolve = function (value) {
  3871. return new globalScope.Promise(function (resolve) {
  3872. resolve(value);
  3873. });
  3874. };
  3875. }
  3876. if (typeof globalScope.Promise.reject !== 'function') {
  3877. globalScope.Promise.reject = function (reason) {
  3878. return new globalScope.Promise(function (resolve, reject) {
  3879. reject(reason);
  3880. });
  3881. };
  3882. }
  3883. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  3884. globalScope.Promise.prototype.catch = function (onReject) {
  3885. return globalScope.Promise.prototype.then(undefined, onReject);
  3886. };
  3887. }
  3888. return;
  3889. }
  3890. var STATUS_PENDING = 0;
  3891. var STATUS_RESOLVED = 1;
  3892. var STATUS_REJECTED = 2;
  3893. var REJECTION_TIMEOUT = 500;
  3894. var HandlerManager = {
  3895. handlers: [],
  3896. running: false,
  3897. unhandledRejections: [],
  3898. pendingRejectionCheck: false,
  3899. scheduleHandlers: function scheduleHandlers(promise) {
  3900. if (promise._status === STATUS_PENDING) {
  3901. return;
  3902. }
  3903. this.handlers = this.handlers.concat(promise._handlers);
  3904. promise._handlers = [];
  3905. if (this.running) {
  3906. return;
  3907. }
  3908. this.running = true;
  3909. setTimeout(this.runHandlers.bind(this), 0);
  3910. },
  3911. runHandlers: function runHandlers() {
  3912. var RUN_TIMEOUT = 1;
  3913. var timeoutAt = Date.now() + RUN_TIMEOUT;
  3914. while (this.handlers.length > 0) {
  3915. var handler = this.handlers.shift();
  3916. var nextStatus = handler.thisPromise._status;
  3917. var nextValue = handler.thisPromise._value;
  3918. try {
  3919. if (nextStatus === STATUS_RESOLVED) {
  3920. if (typeof handler.onResolve === 'function') {
  3921. nextValue = handler.onResolve(nextValue);
  3922. }
  3923. } else if (typeof handler.onReject === 'function') {
  3924. nextValue = handler.onReject(nextValue);
  3925. nextStatus = STATUS_RESOLVED;
  3926. if (handler.thisPromise._unhandledRejection) {
  3927. this.removeUnhandeledRejection(handler.thisPromise);
  3928. }
  3929. }
  3930. } catch (ex) {
  3931. nextStatus = STATUS_REJECTED;
  3932. nextValue = ex;
  3933. }
  3934. handler.nextPromise._updateStatus(nextStatus, nextValue);
  3935. if (Date.now() >= timeoutAt) {
  3936. break;
  3937. }
  3938. }
  3939. if (this.handlers.length > 0) {
  3940. setTimeout(this.runHandlers.bind(this), 0);
  3941. return;
  3942. }
  3943. this.running = false;
  3944. },
  3945. addUnhandledRejection: function addUnhandledRejection(promise) {
  3946. this.unhandledRejections.push({
  3947. promise: promise,
  3948. time: Date.now()
  3949. });
  3950. this.scheduleRejectionCheck();
  3951. },
  3952. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  3953. promise._unhandledRejection = false;
  3954. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3955. if (this.unhandledRejections[i].promise === promise) {
  3956. this.unhandledRejections.splice(i);
  3957. i--;
  3958. }
  3959. }
  3960. },
  3961. scheduleRejectionCheck: function scheduleRejectionCheck() {
  3962. if (this.pendingRejectionCheck) {
  3963. return;
  3964. }
  3965. this.pendingRejectionCheck = true;
  3966. setTimeout(function rejectionCheck() {
  3967. this.pendingRejectionCheck = false;
  3968. var now = Date.now();
  3969. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3970. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  3971. var unhandled = this.unhandledRejections[i].promise._value;
  3972. var msg = 'Unhandled rejection: ' + unhandled;
  3973. if (unhandled.stack) {
  3974. msg += '\n' + unhandled.stack;
  3975. }
  3976. warn(msg);
  3977. this.unhandledRejections.splice(i);
  3978. i--;
  3979. }
  3980. }
  3981. if (this.unhandledRejections.length) {
  3982. this.scheduleRejectionCheck();
  3983. }
  3984. }.bind(this), REJECTION_TIMEOUT);
  3985. }
  3986. };
  3987. var Promise = function Promise(resolver) {
  3988. this._status = STATUS_PENDING;
  3989. this._handlers = [];
  3990. try {
  3991. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  3992. } catch (e) {
  3993. this._reject(e);
  3994. }
  3995. };
  3996. Promise.all = function Promise_all(promises) {
  3997. var resolveAll, rejectAll;
  3998. var deferred = new Promise(function (resolve, reject) {
  3999. resolveAll = resolve;
  4000. rejectAll = reject;
  4001. });
  4002. var unresolved = promises.length;
  4003. var results = [];
  4004. if (unresolved === 0) {
  4005. resolveAll(results);
  4006. return deferred;
  4007. }
  4008. function reject(reason) {
  4009. if (deferred._status === STATUS_REJECTED) {
  4010. return;
  4011. }
  4012. results = [];
  4013. rejectAll(reason);
  4014. }
  4015. for (var i = 0, ii = promises.length; i < ii; ++i) {
  4016. var promise = promises[i];
  4017. var resolve = function (i) {
  4018. return function (value) {
  4019. if (deferred._status === STATUS_REJECTED) {
  4020. return;
  4021. }
  4022. results[i] = value;
  4023. unresolved--;
  4024. if (unresolved === 0) {
  4025. resolveAll(results);
  4026. }
  4027. };
  4028. }(i);
  4029. if (Promise.isPromise(promise)) {
  4030. promise.then(resolve, reject);
  4031. } else {
  4032. resolve(promise);
  4033. }
  4034. }
  4035. return deferred;
  4036. };
  4037. Promise.isPromise = function Promise_isPromise(value) {
  4038. return value && typeof value.then === 'function';
  4039. };
  4040. Promise.resolve = function Promise_resolve(value) {
  4041. return new Promise(function (resolve) {
  4042. resolve(value);
  4043. });
  4044. };
  4045. Promise.reject = function Promise_reject(reason) {
  4046. return new Promise(function (resolve, reject) {
  4047. reject(reason);
  4048. });
  4049. };
  4050. Promise.prototype = {
  4051. _status: null,
  4052. _value: null,
  4053. _handlers: null,
  4054. _unhandledRejection: null,
  4055. _updateStatus: function Promise__updateStatus(status, value) {
  4056. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  4057. return;
  4058. }
  4059. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  4060. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  4061. return;
  4062. }
  4063. this._status = status;
  4064. this._value = value;
  4065. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  4066. this._unhandledRejection = true;
  4067. HandlerManager.addUnhandledRejection(this);
  4068. }
  4069. HandlerManager.scheduleHandlers(this);
  4070. },
  4071. _resolve: function Promise_resolve(value) {
  4072. this._updateStatus(STATUS_RESOLVED, value);
  4073. },
  4074. _reject: function Promise_reject(reason) {
  4075. this._updateStatus(STATUS_REJECTED, reason);
  4076. },
  4077. then: function Promise_then(onResolve, onReject) {
  4078. var nextPromise = new Promise(function (resolve, reject) {
  4079. this.resolve = resolve;
  4080. this.reject = reject;
  4081. });
  4082. this._handlers.push({
  4083. thisPromise: this,
  4084. onResolve: onResolve,
  4085. onReject: onReject,
  4086. nextPromise: nextPromise
  4087. });
  4088. HandlerManager.scheduleHandlers(this);
  4089. return nextPromise;
  4090. },
  4091. catch: function Promise_catch(onReject) {
  4092. return this.then(undefined, onReject);
  4093. }
  4094. };
  4095. globalScope.Promise = Promise;
  4096. }());
  4097. (function WeakMapClosure() {
  4098. if (globalScope.WeakMap) {
  4099. return;
  4100. }
  4101. var id = 0;
  4102. function WeakMap() {
  4103. this.id = '$weakmap' + id++;
  4104. }
  4105. WeakMap.prototype = {
  4106. has: function (obj) {
  4107. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  4108. },
  4109. get: function (obj, defaultValue) {
  4110. return this.has(obj) ? obj[this.id] : defaultValue;
  4111. },
  4112. set: function (obj, value) {
  4113. Object.defineProperty(obj, this.id, {
  4114. value: value,
  4115. enumerable: false,
  4116. configurable: true
  4117. });
  4118. },
  4119. delete: function (obj) {
  4120. delete obj[this.id];
  4121. }
  4122. };
  4123. globalScope.WeakMap = WeakMap;
  4124. }());
  4125. var StatTimer = function StatTimerClosure() {
  4126. function rpad(str, pad, length) {
  4127. while (str.length < length) {
  4128. str += pad;
  4129. }
  4130. return str;
  4131. }
  4132. function StatTimer() {
  4133. this.started = Object.create(null);
  4134. this.times = [];
  4135. this.enabled = true;
  4136. }
  4137. StatTimer.prototype = {
  4138. time: function StatTimer_time(name) {
  4139. if (!this.enabled) {
  4140. return;
  4141. }
  4142. if (name in this.started) {
  4143. warn('Timer is already running for ' + name);
  4144. }
  4145. this.started[name] = Date.now();
  4146. },
  4147. timeEnd: function StatTimer_timeEnd(name) {
  4148. if (!this.enabled) {
  4149. return;
  4150. }
  4151. if (!(name in this.started)) {
  4152. warn('Timer has not been started for ' + name);
  4153. }
  4154. this.times.push({
  4155. 'name': name,
  4156. 'start': this.started[name],
  4157. 'end': Date.now()
  4158. });
  4159. delete this.started[name];
  4160. },
  4161. toString: function StatTimer_toString() {
  4162. var i, ii;
  4163. var times = this.times;
  4164. var out = '';
  4165. var longest = 0;
  4166. for (i = 0, ii = times.length; i < ii; ++i) {
  4167. var name = times[i]['name'];
  4168. if (name.length > longest) {
  4169. longest = name.length;
  4170. }
  4171. }
  4172. for (i = 0, ii = times.length; i < ii; ++i) {
  4173. var span = times[i];
  4174. var duration = span.end - span.start;
  4175. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  4176. }
  4177. return out;
  4178. }
  4179. };
  4180. return StatTimer;
  4181. }();
  4182. var createBlob = function createBlob(data, contentType) {
  4183. if (typeof Blob !== 'undefined') {
  4184. return new Blob([data], { type: contentType });
  4185. }
  4186. warn('The "Blob" constructor is not supported.');
  4187. };
  4188. var createObjectURL = function createObjectURLClosure() {
  4189. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  4190. return function createObjectURL(data, contentType, forceDataSchema) {
  4191. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  4192. var blob = createBlob(data, contentType);
  4193. return URL.createObjectURL(blob);
  4194. }
  4195. var buffer = 'data:' + contentType + ';base64,';
  4196. for (var i = 0, ii = data.length; i < ii; i += 3) {
  4197. var b1 = data[i] & 0xFF;
  4198. var b2 = data[i + 1] & 0xFF;
  4199. var b3 = data[i + 2] & 0xFF;
  4200. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  4201. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  4202. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  4203. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  4204. }
  4205. return buffer;
  4206. };
  4207. }();
  4208. function MessageHandler(sourceName, targetName, comObj) {
  4209. this.sourceName = sourceName;
  4210. this.targetName = targetName;
  4211. this.comObj = comObj;
  4212. this.callbackIndex = 1;
  4213. this.postMessageTransfers = true;
  4214. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  4215. var ah = this.actionHandler = Object.create(null);
  4216. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  4217. var data = event.data;
  4218. if (data.targetName !== this.sourceName) {
  4219. return;
  4220. }
  4221. if (data.isReply) {
  4222. var callbackId = data.callbackId;
  4223. if (data.callbackId in callbacksCapabilities) {
  4224. var callback = callbacksCapabilities[callbackId];
  4225. delete callbacksCapabilities[callbackId];
  4226. if ('error' in data) {
  4227. callback.reject(data.error);
  4228. } else {
  4229. callback.resolve(data.data);
  4230. }
  4231. } else {
  4232. error('Cannot resolve callback ' + callbackId);
  4233. }
  4234. } else if (data.action in ah) {
  4235. var action = ah[data.action];
  4236. if (data.callbackId) {
  4237. var sourceName = this.sourceName;
  4238. var targetName = data.sourceName;
  4239. Promise.resolve().then(function () {
  4240. return action[0].call(action[1], data.data);
  4241. }).then(function (result) {
  4242. comObj.postMessage({
  4243. sourceName: sourceName,
  4244. targetName: targetName,
  4245. isReply: true,
  4246. callbackId: data.callbackId,
  4247. data: result
  4248. });
  4249. }, function (reason) {
  4250. if (reason instanceof Error) {
  4251. reason = reason + '';
  4252. }
  4253. comObj.postMessage({
  4254. sourceName: sourceName,
  4255. targetName: targetName,
  4256. isReply: true,
  4257. callbackId: data.callbackId,
  4258. error: reason
  4259. });
  4260. });
  4261. } else {
  4262. action[0].call(action[1], data.data);
  4263. }
  4264. } else {
  4265. error('Unknown action from worker: ' + data.action);
  4266. }
  4267. }.bind(this);
  4268. comObj.addEventListener('message', this._onComObjOnMessage);
  4269. }
  4270. MessageHandler.prototype = {
  4271. on: function messageHandlerOn(actionName, handler, scope) {
  4272. var ah = this.actionHandler;
  4273. if (ah[actionName]) {
  4274. error('There is already an actionName called "' + actionName + '"');
  4275. }
  4276. ah[actionName] = [
  4277. handler,
  4278. scope
  4279. ];
  4280. },
  4281. send: function messageHandlerSend(actionName, data, transfers) {
  4282. var message = {
  4283. sourceName: this.sourceName,
  4284. targetName: this.targetName,
  4285. action: actionName,
  4286. data: data
  4287. };
  4288. this.postMessage(message, transfers);
  4289. },
  4290. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  4291. var callbackId = this.callbackIndex++;
  4292. var message = {
  4293. sourceName: this.sourceName,
  4294. targetName: this.targetName,
  4295. action: actionName,
  4296. data: data,
  4297. callbackId: callbackId
  4298. };
  4299. var capability = createPromiseCapability();
  4300. this.callbacksCapabilities[callbackId] = capability;
  4301. try {
  4302. this.postMessage(message, transfers);
  4303. } catch (e) {
  4304. capability.reject(e);
  4305. }
  4306. return capability.promise;
  4307. },
  4308. postMessage: function (message, transfers) {
  4309. if (transfers && this.postMessageTransfers) {
  4310. this.comObj.postMessage(message, transfers);
  4311. } else {
  4312. this.comObj.postMessage(message);
  4313. }
  4314. },
  4315. destroy: function () {
  4316. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  4317. }
  4318. };
  4319. function loadJpegStream(id, imageUrl, objs) {
  4320. var img = new Image();
  4321. img.onload = function loadJpegStream_onloadClosure() {
  4322. objs.resolve(id, img);
  4323. };
  4324. img.onerror = function loadJpegStream_onerrorClosure() {
  4325. objs.resolve(id, null);
  4326. warn('Error during JPEG image loading');
  4327. };
  4328. img.src = imageUrl;
  4329. }
  4330. /* Any copyright is dedicated to the Public Domain.
  4331. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4332. (function checkURLConstructor(scope) {
  4333. var hasWorkingUrl = false;
  4334. try {
  4335. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  4336. var u = new URL('b', 'http://a');
  4337. u.pathname = 'c%20d';
  4338. hasWorkingUrl = u.href === 'http://a/c%20d';
  4339. }
  4340. } catch (e) {
  4341. }
  4342. if (hasWorkingUrl) {
  4343. return;
  4344. }
  4345. var relative = Object.create(null);
  4346. relative['ftp'] = 21;
  4347. relative['file'] = 0;
  4348. relative['gopher'] = 70;
  4349. relative['http'] = 80;
  4350. relative['https'] = 443;
  4351. relative['ws'] = 80;
  4352. relative['wss'] = 443;
  4353. var relativePathDotMapping = Object.create(null);
  4354. relativePathDotMapping['%2e'] = '.';
  4355. relativePathDotMapping['.%2e'] = '..';
  4356. relativePathDotMapping['%2e.'] = '..';
  4357. relativePathDotMapping['%2e%2e'] = '..';
  4358. function isRelativeScheme(scheme) {
  4359. return relative[scheme] !== undefined;
  4360. }
  4361. function invalid() {
  4362. clear.call(this);
  4363. this._isInvalid = true;
  4364. }
  4365. function IDNAToASCII(h) {
  4366. if ('' === h) {
  4367. invalid.call(this);
  4368. }
  4369. return h.toLowerCase();
  4370. }
  4371. function percentEscape(c) {
  4372. var unicode = c.charCodeAt(0);
  4373. if (unicode > 0x20 && unicode < 0x7F && [
  4374. 0x22,
  4375. 0x23,
  4376. 0x3C,
  4377. 0x3E,
  4378. 0x3F,
  4379. 0x60
  4380. ].indexOf(unicode) === -1) {
  4381. return c;
  4382. }
  4383. return encodeURIComponent(c);
  4384. }
  4385. function percentEscapeQuery(c) {
  4386. var unicode = c.charCodeAt(0);
  4387. if (unicode > 0x20 && unicode < 0x7F && [
  4388. 0x22,
  4389. 0x23,
  4390. 0x3C,
  4391. 0x3E,
  4392. 0x60
  4393. ].indexOf(unicode) === -1) {
  4394. return c;
  4395. }
  4396. return encodeURIComponent(c);
  4397. }
  4398. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  4399. function parse(input, stateOverride, base) {
  4400. function err(message) {
  4401. errors.push(message);
  4402. }
  4403. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  4404. loop:
  4405. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  4406. var c = input[cursor];
  4407. switch (state) {
  4408. case 'scheme start':
  4409. if (c && ALPHA.test(c)) {
  4410. buffer += c.toLowerCase();
  4411. state = 'scheme';
  4412. } else if (!stateOverride) {
  4413. buffer = '';
  4414. state = 'no scheme';
  4415. continue;
  4416. } else {
  4417. err('Invalid scheme.');
  4418. break loop;
  4419. }
  4420. break;
  4421. case 'scheme':
  4422. if (c && ALPHANUMERIC.test(c)) {
  4423. buffer += c.toLowerCase();
  4424. } else if (':' === c) {
  4425. this._scheme = buffer;
  4426. buffer = '';
  4427. if (stateOverride) {
  4428. break loop;
  4429. }
  4430. if (isRelativeScheme(this._scheme)) {
  4431. this._isRelative = true;
  4432. }
  4433. if ('file' === this._scheme) {
  4434. state = 'relative';
  4435. } else if (this._isRelative && base && base._scheme === this._scheme) {
  4436. state = 'relative or authority';
  4437. } else if (this._isRelative) {
  4438. state = 'authority first slash';
  4439. } else {
  4440. state = 'scheme data';
  4441. }
  4442. } else if (!stateOverride) {
  4443. buffer = '';
  4444. cursor = 0;
  4445. state = 'no scheme';
  4446. continue;
  4447. } else if (EOF === c) {
  4448. break loop;
  4449. } else {
  4450. err('Code point not allowed in scheme: ' + c);
  4451. break loop;
  4452. }
  4453. break;
  4454. case 'scheme data':
  4455. if ('?' === c) {
  4456. this._query = '?';
  4457. state = 'query';
  4458. } else if ('#' === c) {
  4459. this._fragment = '#';
  4460. state = 'fragment';
  4461. } else {
  4462. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4463. this._schemeData += percentEscape(c);
  4464. }
  4465. }
  4466. break;
  4467. case 'no scheme':
  4468. if (!base || !isRelativeScheme(base._scheme)) {
  4469. err('Missing scheme.');
  4470. invalid.call(this);
  4471. } else {
  4472. state = 'relative';
  4473. continue;
  4474. }
  4475. break;
  4476. case 'relative or authority':
  4477. if ('/' === c && '/' === input[cursor + 1]) {
  4478. state = 'authority ignore slashes';
  4479. } else {
  4480. err('Expected /, got: ' + c);
  4481. state = 'relative';
  4482. continue;
  4483. }
  4484. break;
  4485. case 'relative':
  4486. this._isRelative = true;
  4487. if ('file' !== this._scheme) {
  4488. this._scheme = base._scheme;
  4489. }
  4490. if (EOF === c) {
  4491. this._host = base._host;
  4492. this._port = base._port;
  4493. this._path = base._path.slice();
  4494. this._query = base._query;
  4495. this._username = base._username;
  4496. this._password = base._password;
  4497. break loop;
  4498. } else if ('/' === c || '\\' === c) {
  4499. if ('\\' === c) {
  4500. err('\\ is an invalid code point.');
  4501. }
  4502. state = 'relative slash';
  4503. } else if ('?' === c) {
  4504. this._host = base._host;
  4505. this._port = base._port;
  4506. this._path = base._path.slice();
  4507. this._query = '?';
  4508. this._username = base._username;
  4509. this._password = base._password;
  4510. state = 'query';
  4511. } else if ('#' === c) {
  4512. this._host = base._host;
  4513. this._port = base._port;
  4514. this._path = base._path.slice();
  4515. this._query = base._query;
  4516. this._fragment = '#';
  4517. this._username = base._username;
  4518. this._password = base._password;
  4519. state = 'fragment';
  4520. } else {
  4521. var nextC = input[cursor + 1];
  4522. var nextNextC = input[cursor + 2];
  4523. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  4524. this._host = base._host;
  4525. this._port = base._port;
  4526. this._username = base._username;
  4527. this._password = base._password;
  4528. this._path = base._path.slice();
  4529. this._path.pop();
  4530. }
  4531. state = 'relative path';
  4532. continue;
  4533. }
  4534. break;
  4535. case 'relative slash':
  4536. if ('/' === c || '\\' === c) {
  4537. if ('\\' === c) {
  4538. err('\\ is an invalid code point.');
  4539. }
  4540. if ('file' === this._scheme) {
  4541. state = 'file host';
  4542. } else {
  4543. state = 'authority ignore slashes';
  4544. }
  4545. } else {
  4546. if ('file' !== this._scheme) {
  4547. this._host = base._host;
  4548. this._port = base._port;
  4549. this._username = base._username;
  4550. this._password = base._password;
  4551. }
  4552. state = 'relative path';
  4553. continue;
  4554. }
  4555. break;
  4556. case 'authority first slash':
  4557. if ('/' === c) {
  4558. state = 'authority second slash';
  4559. } else {
  4560. err('Expected \'/\', got: ' + c);
  4561. state = 'authority ignore slashes';
  4562. continue;
  4563. }
  4564. break;
  4565. case 'authority second slash':
  4566. state = 'authority ignore slashes';
  4567. if ('/' !== c) {
  4568. err('Expected \'/\', got: ' + c);
  4569. continue;
  4570. }
  4571. break;
  4572. case 'authority ignore slashes':
  4573. if ('/' !== c && '\\' !== c) {
  4574. state = 'authority';
  4575. continue;
  4576. } else {
  4577. err('Expected authority, got: ' + c);
  4578. }
  4579. break;
  4580. case 'authority':
  4581. if ('@' === c) {
  4582. if (seenAt) {
  4583. err('@ already seen.');
  4584. buffer += '%40';
  4585. }
  4586. seenAt = true;
  4587. for (var i = 0; i < buffer.length; i++) {
  4588. var cp = buffer[i];
  4589. if ('\t' === cp || '\n' === cp || '\r' === cp) {
  4590. err('Invalid whitespace in authority.');
  4591. continue;
  4592. }
  4593. if (':' === cp && null === this._password) {
  4594. this._password = '';
  4595. continue;
  4596. }
  4597. var tempC = percentEscape(cp);
  4598. if (null !== this._password) {
  4599. this._password += tempC;
  4600. } else {
  4601. this._username += tempC;
  4602. }
  4603. }
  4604. buffer = '';
  4605. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4606. cursor -= buffer.length;
  4607. buffer = '';
  4608. state = 'host';
  4609. continue;
  4610. } else {
  4611. buffer += c;
  4612. }
  4613. break;
  4614. case 'file host':
  4615. if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4616. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  4617. state = 'relative path';
  4618. } else if (buffer.length === 0) {
  4619. state = 'relative path start';
  4620. } else {
  4621. this._host = IDNAToASCII.call(this, buffer);
  4622. buffer = '';
  4623. state = 'relative path start';
  4624. }
  4625. continue;
  4626. } else if ('\t' === c || '\n' === c || '\r' === c) {
  4627. err('Invalid whitespace in file host.');
  4628. } else {
  4629. buffer += c;
  4630. }
  4631. break;
  4632. case 'host':
  4633. case 'hostname':
  4634. if (':' === c && !seenBracket) {
  4635. this._host = IDNAToASCII.call(this, buffer);
  4636. buffer = '';
  4637. state = 'port';
  4638. if ('hostname' === stateOverride) {
  4639. break loop;
  4640. }
  4641. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4642. this._host = IDNAToASCII.call(this, buffer);
  4643. buffer = '';
  4644. state = 'relative path start';
  4645. if (stateOverride) {
  4646. break loop;
  4647. }
  4648. continue;
  4649. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4650. if ('[' === c) {
  4651. seenBracket = true;
  4652. } else if (']' === c) {
  4653. seenBracket = false;
  4654. }
  4655. buffer += c;
  4656. } else {
  4657. err('Invalid code point in host/hostname: ' + c);
  4658. }
  4659. break;
  4660. case 'port':
  4661. if (/[0-9]/.test(c)) {
  4662. buffer += c;
  4663. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c || stateOverride) {
  4664. if ('' !== buffer) {
  4665. var temp = parseInt(buffer, 10);
  4666. if (temp !== relative[this._scheme]) {
  4667. this._port = temp + '';
  4668. }
  4669. buffer = '';
  4670. }
  4671. if (stateOverride) {
  4672. break loop;
  4673. }
  4674. state = 'relative path start';
  4675. continue;
  4676. } else if ('\t' === c || '\n' === c || '\r' === c) {
  4677. err('Invalid code point in port: ' + c);
  4678. } else {
  4679. invalid.call(this);
  4680. }
  4681. break;
  4682. case 'relative path start':
  4683. if ('\\' === c) {
  4684. err('\'\\\' not allowed in path.');
  4685. }
  4686. state = 'relative path';
  4687. if ('/' !== c && '\\' !== c) {
  4688. continue;
  4689. }
  4690. break;
  4691. case 'relative path':
  4692. if (EOF === c || '/' === c || '\\' === c || !stateOverride && ('?' === c || '#' === c)) {
  4693. if ('\\' === c) {
  4694. err('\\ not allowed in relative path.');
  4695. }
  4696. var tmp;
  4697. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  4698. buffer = tmp;
  4699. }
  4700. if ('..' === buffer) {
  4701. this._path.pop();
  4702. if ('/' !== c && '\\' !== c) {
  4703. this._path.push('');
  4704. }
  4705. } else if ('.' === buffer && '/' !== c && '\\' !== c) {
  4706. this._path.push('');
  4707. } else if ('.' !== buffer) {
  4708. if ('file' === this._scheme && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  4709. buffer = buffer[0] + ':';
  4710. }
  4711. this._path.push(buffer);
  4712. }
  4713. buffer = '';
  4714. if ('?' === c) {
  4715. this._query = '?';
  4716. state = 'query';
  4717. } else if ('#' === c) {
  4718. this._fragment = '#';
  4719. state = 'fragment';
  4720. }
  4721. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4722. buffer += percentEscape(c);
  4723. }
  4724. break;
  4725. case 'query':
  4726. if (!stateOverride && '#' === c) {
  4727. this._fragment = '#';
  4728. state = 'fragment';
  4729. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4730. this._query += percentEscapeQuery(c);
  4731. }
  4732. break;
  4733. case 'fragment':
  4734. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4735. this._fragment += c;
  4736. }
  4737. break;
  4738. }
  4739. cursor++;
  4740. }
  4741. }
  4742. function clear() {
  4743. this._scheme = '';
  4744. this._schemeData = '';
  4745. this._username = '';
  4746. this._password = null;
  4747. this._host = '';
  4748. this._port = '';
  4749. this._path = [];
  4750. this._query = '';
  4751. this._fragment = '';
  4752. this._isInvalid = false;
  4753. this._isRelative = false;
  4754. }
  4755. function JURL(url, base)
  4756. {
  4757. if (base !== undefined && !(base instanceof JURL)) {
  4758. base = new JURL(String(base));
  4759. }
  4760. this._url = url;
  4761. clear.call(this);
  4762. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  4763. parse.call(this, input, null, base);
  4764. }
  4765. JURL.prototype = {
  4766. toString: function () {
  4767. return this.href;
  4768. },
  4769. get href() {
  4770. if (this._isInvalid) {
  4771. return this._url;
  4772. }
  4773. var authority = '';
  4774. if ('' !== this._username || null !== this._password) {
  4775. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  4776. }
  4777. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  4778. },
  4779. set href(href) {
  4780. clear.call(this);
  4781. parse.call(this, href);
  4782. },
  4783. get protocol() {
  4784. return this._scheme + ':';
  4785. },
  4786. set protocol(protocol) {
  4787. if (this._isInvalid) {
  4788. return;
  4789. }
  4790. parse.call(this, protocol + ':', 'scheme start');
  4791. },
  4792. get host() {
  4793. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  4794. },
  4795. set host(host) {
  4796. if (this._isInvalid || !this._isRelative) {
  4797. return;
  4798. }
  4799. parse.call(this, host, 'host');
  4800. },
  4801. get hostname() {
  4802. return this._host;
  4803. },
  4804. set hostname(hostname) {
  4805. if (this._isInvalid || !this._isRelative) {
  4806. return;
  4807. }
  4808. parse.call(this, hostname, 'hostname');
  4809. },
  4810. get port() {
  4811. return this._port;
  4812. },
  4813. set port(port) {
  4814. if (this._isInvalid || !this._isRelative) {
  4815. return;
  4816. }
  4817. parse.call(this, port, 'port');
  4818. },
  4819. get pathname() {
  4820. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  4821. },
  4822. set pathname(pathname) {
  4823. if (this._isInvalid || !this._isRelative) {
  4824. return;
  4825. }
  4826. this._path = [];
  4827. parse.call(this, pathname, 'relative path start');
  4828. },
  4829. get search() {
  4830. return this._isInvalid || !this._query || '?' === this._query ? '' : this._query;
  4831. },
  4832. set search(search) {
  4833. if (this._isInvalid || !this._isRelative) {
  4834. return;
  4835. }
  4836. this._query = '?';
  4837. if ('?' === search[0]) {
  4838. search = search.slice(1);
  4839. }
  4840. parse.call(this, search, 'query');
  4841. },
  4842. get hash() {
  4843. return this._isInvalid || !this._fragment || '#' === this._fragment ? '' : this._fragment;
  4844. },
  4845. set hash(hash) {
  4846. if (this._isInvalid) {
  4847. return;
  4848. }
  4849. this._fragment = '#';
  4850. if ('#' === hash[0]) {
  4851. hash = hash.slice(1);
  4852. }
  4853. parse.call(this, hash, 'fragment');
  4854. },
  4855. get origin() {
  4856. var host;
  4857. if (this._isInvalid || !this._scheme) {
  4858. return '';
  4859. }
  4860. switch (this._scheme) {
  4861. case 'data':
  4862. case 'file':
  4863. case 'javascript':
  4864. case 'mailto':
  4865. return 'null';
  4866. }
  4867. host = this.host;
  4868. if (!host) {
  4869. return '';
  4870. }
  4871. return this._scheme + '://' + host;
  4872. }
  4873. };
  4874. var OriginalURL = scope.URL;
  4875. if (OriginalURL) {
  4876. JURL.createObjectURL = function (blob) {
  4877. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  4878. };
  4879. JURL.revokeObjectURL = function (url) {
  4880. OriginalURL.revokeObjectURL(url);
  4881. };
  4882. }
  4883. scope.URL = JURL;
  4884. }(globalScope));
  4885. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  4886. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  4887. exports.OPS = OPS;
  4888. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  4889. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  4890. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  4891. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  4892. exports.AnnotationFlag = AnnotationFlag;
  4893. exports.AnnotationType = AnnotationType;
  4894. exports.FontType = FontType;
  4895. exports.ImageKind = ImageKind;
  4896. exports.InvalidPDFException = InvalidPDFException;
  4897. exports.MessageHandler = MessageHandler;
  4898. exports.MissingDataException = MissingDataException;
  4899. exports.MissingPDFException = MissingPDFException;
  4900. exports.NotImplementedException = NotImplementedException;
  4901. exports.PageViewport = PageViewport;
  4902. exports.PasswordException = PasswordException;
  4903. exports.PasswordResponses = PasswordResponses;
  4904. exports.StatTimer = StatTimer;
  4905. exports.StreamType = StreamType;
  4906. exports.TextRenderingMode = TextRenderingMode;
  4907. exports.UnexpectedResponseException = UnexpectedResponseException;
  4908. exports.UnknownErrorException = UnknownErrorException;
  4909. exports.Util = Util;
  4910. exports.XRefParseException = XRefParseException;
  4911. exports.arrayByteLength = arrayByteLength;
  4912. exports.arraysToBytes = arraysToBytes;
  4913. exports.assert = assert;
  4914. exports.bytesToString = bytesToString;
  4915. exports.createBlob = createBlob;
  4916. exports.createPromiseCapability = createPromiseCapability;
  4917. exports.createObjectURL = createObjectURL;
  4918. exports.deprecated = deprecated;
  4919. exports.error = error;
  4920. exports.getLookupTableFactory = getLookupTableFactory;
  4921. exports.getVerbosityLevel = getVerbosityLevel;
  4922. exports.globalScope = globalScope;
  4923. exports.info = info;
  4924. exports.isArray = isArray;
  4925. exports.isArrayBuffer = isArrayBuffer;
  4926. exports.isBool = isBool;
  4927. exports.isEmptyObj = isEmptyObj;
  4928. exports.isInt = isInt;
  4929. exports.isNum = isNum;
  4930. exports.isString = isString;
  4931. exports.isSpace = isSpace;
  4932. exports.isSameOrigin = isSameOrigin;
  4933. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  4934. exports.isLittleEndian = isLittleEndian;
  4935. exports.isEvalSupported = isEvalSupported;
  4936. exports.loadJpegStream = loadJpegStream;
  4937. exports.log2 = log2;
  4938. exports.readInt8 = readInt8;
  4939. exports.readUint16 = readUint16;
  4940. exports.readUint32 = readUint32;
  4941. exports.removeNullCharacters = removeNullCharacters;
  4942. exports.setVerbosityLevel = setVerbosityLevel;
  4943. exports.shadow = shadow;
  4944. exports.string32 = string32;
  4945. exports.stringToBytes = stringToBytes;
  4946. exports.stringToPDFString = stringToPDFString;
  4947. exports.stringToUTF8String = stringToUTF8String;
  4948. exports.utf8StringToString = utf8StringToString;
  4949. exports.warn = warn;
  4950. }));
  4951. (function (root, factory) {
  4952. factory(root.pdfjsCoreBidi = {}, root.pdfjsSharedUtil);
  4953. }(this, function (exports, sharedUtil) {
  4954. var warn = sharedUtil.warn;
  4955. var baseTypes = [
  4956. 'BN',
  4957. 'BN',
  4958. 'BN',
  4959. 'BN',
  4960. 'BN',
  4961. 'BN',
  4962. 'BN',
  4963. 'BN',
  4964. 'BN',
  4965. 'S',
  4966. 'B',
  4967. 'S',
  4968. 'WS',
  4969. 'B',
  4970. 'BN',
  4971. 'BN',
  4972. 'BN',
  4973. 'BN',
  4974. 'BN',
  4975. 'BN',
  4976. 'BN',
  4977. 'BN',
  4978. 'BN',
  4979. 'BN',
  4980. 'BN',
  4981. 'BN',
  4982. 'BN',
  4983. 'BN',
  4984. 'B',
  4985. 'B',
  4986. 'B',
  4987. 'S',
  4988. 'WS',
  4989. 'ON',
  4990. 'ON',
  4991. 'ET',
  4992. 'ET',
  4993. 'ET',
  4994. 'ON',
  4995. 'ON',
  4996. 'ON',
  4997. 'ON',
  4998. 'ON',
  4999. 'ES',
  5000. 'CS',
  5001. 'ES',
  5002. 'CS',
  5003. 'CS',
  5004. 'EN',
  5005. 'EN',
  5006. 'EN',
  5007. 'EN',
  5008. 'EN',
  5009. 'EN',
  5010. 'EN',
  5011. 'EN',
  5012. 'EN',
  5013. 'EN',
  5014. 'CS',
  5015. 'ON',
  5016. 'ON',
  5017. 'ON',
  5018. 'ON',
  5019. 'ON',
  5020. 'ON',
  5021. 'L',
  5022. 'L',
  5023. 'L',
  5024. 'L',
  5025. 'L',
  5026. 'L',
  5027. 'L',
  5028. 'L',
  5029. 'L',
  5030. 'L',
  5031. 'L',
  5032. 'L',
  5033. 'L',
  5034. 'L',
  5035. 'L',
  5036. 'L',
  5037. 'L',
  5038. 'L',
  5039. 'L',
  5040. 'L',
  5041. 'L',
  5042. 'L',
  5043. 'L',
  5044. 'L',
  5045. 'L',
  5046. 'L',
  5047. 'ON',
  5048. 'ON',
  5049. 'ON',
  5050. 'ON',
  5051. 'ON',
  5052. 'ON',
  5053. 'L',
  5054. 'L',
  5055. 'L',
  5056. 'L',
  5057. 'L',
  5058. 'L',
  5059. 'L',
  5060. 'L',
  5061. 'L',
  5062. 'L',
  5063. 'L',
  5064. 'L',
  5065. 'L',
  5066. 'L',
  5067. 'L',
  5068. 'L',
  5069. 'L',
  5070. 'L',
  5071. 'L',
  5072. 'L',
  5073. 'L',
  5074. 'L',
  5075. 'L',
  5076. 'L',
  5077. 'L',
  5078. 'L',
  5079. 'ON',
  5080. 'ON',
  5081. 'ON',
  5082. 'ON',
  5083. 'BN',
  5084. 'BN',
  5085. 'BN',
  5086. 'BN',
  5087. 'BN',
  5088. 'BN',
  5089. 'B',
  5090. 'BN',
  5091. 'BN',
  5092. 'BN',
  5093. 'BN',
  5094. 'BN',
  5095. 'BN',
  5096. 'BN',
  5097. 'BN',
  5098. 'BN',
  5099. 'BN',
  5100. 'BN',
  5101. 'BN',
  5102. 'BN',
  5103. 'BN',
  5104. 'BN',
  5105. 'BN',
  5106. 'BN',
  5107. 'BN',
  5108. 'BN',
  5109. 'BN',
  5110. 'BN',
  5111. 'BN',
  5112. 'BN',
  5113. 'BN',
  5114. 'BN',
  5115. 'BN',
  5116. 'CS',
  5117. 'ON',
  5118. 'ET',
  5119. 'ET',
  5120. 'ET',
  5121. 'ET',
  5122. 'ON',
  5123. 'ON',
  5124. 'ON',
  5125. 'ON',
  5126. 'L',
  5127. 'ON',
  5128. 'ON',
  5129. 'BN',
  5130. 'ON',
  5131. 'ON',
  5132. 'ET',
  5133. 'ET',
  5134. 'EN',
  5135. 'EN',
  5136. 'ON',
  5137. 'L',
  5138. 'ON',
  5139. 'ON',
  5140. 'ON',
  5141. 'EN',
  5142. 'L',
  5143. 'ON',
  5144. 'ON',
  5145. 'ON',
  5146. 'ON',
  5147. 'ON',
  5148. 'L',
  5149. 'L',
  5150. 'L',
  5151. 'L',
  5152. 'L',
  5153. 'L',
  5154. 'L',
  5155. 'L',
  5156. 'L',
  5157. 'L',
  5158. 'L',
  5159. 'L',
  5160. 'L',
  5161. 'L',
  5162. 'L',
  5163. 'L',
  5164. 'L',
  5165. 'L',
  5166. 'L',
  5167. 'L',
  5168. 'L',
  5169. 'L',
  5170. 'L',
  5171. 'ON',
  5172. 'L',
  5173. 'L',
  5174. 'L',
  5175. 'L',
  5176. 'L',
  5177. 'L',
  5178. 'L',
  5179. 'L',
  5180. 'L',
  5181. 'L',
  5182. 'L',
  5183. 'L',
  5184. 'L',
  5185. 'L',
  5186. 'L',
  5187. 'L',
  5188. 'L',
  5189. 'L',
  5190. 'L',
  5191. 'L',
  5192. 'L',
  5193. 'L',
  5194. 'L',
  5195. 'L',
  5196. 'L',
  5197. 'L',
  5198. 'L',
  5199. 'L',
  5200. 'L',
  5201. 'L',
  5202. 'L',
  5203. 'ON',
  5204. 'L',
  5205. 'L',
  5206. 'L',
  5207. 'L',
  5208. 'L',
  5209. 'L',
  5210. 'L',
  5211. 'L'
  5212. ];
  5213. var arabicTypes = [
  5214. 'AN',
  5215. 'AN',
  5216. 'AN',
  5217. 'AN',
  5218. 'AN',
  5219. 'AN',
  5220. 'ON',
  5221. 'ON',
  5222. 'AL',
  5223. 'ET',
  5224. 'ET',
  5225. 'AL',
  5226. 'CS',
  5227. 'AL',
  5228. 'ON',
  5229. 'ON',
  5230. 'NSM',
  5231. 'NSM',
  5232. 'NSM',
  5233. 'NSM',
  5234. 'NSM',
  5235. 'NSM',
  5236. 'NSM',
  5237. 'NSM',
  5238. 'NSM',
  5239. 'NSM',
  5240. 'NSM',
  5241. 'AL',
  5242. 'AL',
  5243. '',
  5244. 'AL',
  5245. 'AL',
  5246. 'AL',
  5247. 'AL',
  5248. 'AL',
  5249. 'AL',
  5250. 'AL',
  5251. 'AL',
  5252. 'AL',
  5253. 'AL',
  5254. 'AL',
  5255. 'AL',
  5256. 'AL',
  5257. 'AL',
  5258. 'AL',
  5259. 'AL',
  5260. 'AL',
  5261. 'AL',
  5262. 'AL',
  5263. 'AL',
  5264. 'AL',
  5265. 'AL',
  5266. 'AL',
  5267. 'AL',
  5268. 'AL',
  5269. 'AL',
  5270. 'AL',
  5271. 'AL',
  5272. 'AL',
  5273. 'AL',
  5274. 'AL',
  5275. 'AL',
  5276. 'AL',
  5277. 'AL',
  5278. 'AL',
  5279. 'AL',
  5280. 'AL',
  5281. 'AL',
  5282. 'AL',
  5283. 'AL',
  5284. 'AL',
  5285. 'AL',
  5286. 'AL',
  5287. 'AL',
  5288. 'AL',
  5289. 'NSM',
  5290. 'NSM',
  5291. 'NSM',
  5292. 'NSM',
  5293. 'NSM',
  5294. 'NSM',
  5295. 'NSM',
  5296. 'NSM',
  5297. 'NSM',
  5298. 'NSM',
  5299. 'NSM',
  5300. 'NSM',
  5301. 'NSM',
  5302. 'NSM',
  5303. 'NSM',
  5304. 'NSM',
  5305. 'NSM',
  5306. 'NSM',
  5307. 'NSM',
  5308. 'NSM',
  5309. 'NSM',
  5310. 'AN',
  5311. 'AN',
  5312. 'AN',
  5313. 'AN',
  5314. 'AN',
  5315. 'AN',
  5316. 'AN',
  5317. 'AN',
  5318. 'AN',
  5319. 'AN',
  5320. 'ET',
  5321. 'AN',
  5322. 'AN',
  5323. 'AL',
  5324. 'AL',
  5325. 'AL',
  5326. 'NSM',
  5327. 'AL',
  5328. 'AL',
  5329. 'AL',
  5330. 'AL',
  5331. 'AL',
  5332. 'AL',
  5333. 'AL',
  5334. 'AL',
  5335. 'AL',
  5336. 'AL',
  5337. 'AL',
  5338. 'AL',
  5339. 'AL',
  5340. 'AL',
  5341. 'AL',
  5342. 'AL',
  5343. 'AL',
  5344. 'AL',
  5345. 'AL',
  5346. 'AL',
  5347. 'AL',
  5348. 'AL',
  5349. 'AL',
  5350. 'AL',
  5351. 'AL',
  5352. 'AL',
  5353. 'AL',
  5354. 'AL',
  5355. 'AL',
  5356. 'AL',
  5357. 'AL',
  5358. 'AL',
  5359. 'AL',
  5360. 'AL',
  5361. 'AL',
  5362. 'AL',
  5363. 'AL',
  5364. 'AL',
  5365. 'AL',
  5366. 'AL',
  5367. 'AL',
  5368. 'AL',
  5369. 'AL',
  5370. 'AL',
  5371. 'AL',
  5372. 'AL',
  5373. 'AL',
  5374. 'AL',
  5375. 'AL',
  5376. 'AL',
  5377. 'AL',
  5378. 'AL',
  5379. 'AL',
  5380. 'AL',
  5381. 'AL',
  5382. 'AL',
  5383. 'AL',
  5384. 'AL',
  5385. 'AL',
  5386. 'AL',
  5387. 'AL',
  5388. 'AL',
  5389. 'AL',
  5390. 'AL',
  5391. 'AL',
  5392. 'AL',
  5393. 'AL',
  5394. 'AL',
  5395. 'AL',
  5396. 'AL',
  5397. 'AL',
  5398. 'AL',
  5399. 'AL',
  5400. 'AL',
  5401. 'AL',
  5402. 'AL',
  5403. 'AL',
  5404. 'AL',
  5405. 'AL',
  5406. 'AL',
  5407. 'AL',
  5408. 'AL',
  5409. 'AL',
  5410. 'AL',
  5411. 'AL',
  5412. 'AL',
  5413. 'AL',
  5414. 'AL',
  5415. 'AL',
  5416. 'AL',
  5417. 'AL',
  5418. 'AL',
  5419. 'AL',
  5420. 'AL',
  5421. 'AL',
  5422. 'AL',
  5423. 'AL',
  5424. 'AL',
  5425. 'AL',
  5426. 'AL',
  5427. 'AL',
  5428. 'NSM',
  5429. 'NSM',
  5430. 'NSM',
  5431. 'NSM',
  5432. 'NSM',
  5433. 'NSM',
  5434. 'NSM',
  5435. 'AN',
  5436. 'ON',
  5437. 'NSM',
  5438. 'NSM',
  5439. 'NSM',
  5440. 'NSM',
  5441. 'NSM',
  5442. 'NSM',
  5443. 'AL',
  5444. 'AL',
  5445. 'NSM',
  5446. 'NSM',
  5447. 'ON',
  5448. 'NSM',
  5449. 'NSM',
  5450. 'NSM',
  5451. 'NSM',
  5452. 'AL',
  5453. 'AL',
  5454. 'EN',
  5455. 'EN',
  5456. 'EN',
  5457. 'EN',
  5458. 'EN',
  5459. 'EN',
  5460. 'EN',
  5461. 'EN',
  5462. 'EN',
  5463. 'EN',
  5464. 'AL',
  5465. 'AL',
  5466. 'AL',
  5467. 'AL',
  5468. 'AL',
  5469. 'AL'
  5470. ];
  5471. function isOdd(i) {
  5472. return (i & 1) !== 0;
  5473. }
  5474. function isEven(i) {
  5475. return (i & 1) === 0;
  5476. }
  5477. function findUnequal(arr, start, value) {
  5478. for (var j = start, jj = arr.length; j < jj; ++j) {
  5479. if (arr[j] !== value) {
  5480. return j;
  5481. }
  5482. }
  5483. return j;
  5484. }
  5485. function setValues(arr, start, end, value) {
  5486. for (var j = start; j < end; ++j) {
  5487. arr[j] = value;
  5488. }
  5489. }
  5490. function reverseValues(arr, start, end) {
  5491. for (var i = start, j = end - 1; i < j; ++i, --j) {
  5492. var temp = arr[i];
  5493. arr[i] = arr[j];
  5494. arr[j] = temp;
  5495. }
  5496. }
  5497. function createBidiText(str, isLTR, vertical) {
  5498. return {
  5499. str: str,
  5500. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  5501. };
  5502. }
  5503. var chars = [];
  5504. var types = [];
  5505. function bidi(str, startLevel, vertical) {
  5506. var isLTR = true;
  5507. var strLength = str.length;
  5508. if (strLength === 0 || vertical) {
  5509. return createBidiText(str, isLTR, vertical);
  5510. }
  5511. chars.length = strLength;
  5512. types.length = strLength;
  5513. var numBidi = 0;
  5514. var i, ii;
  5515. for (i = 0; i < strLength; ++i) {
  5516. chars[i] = str.charAt(i);
  5517. var charCode = str.charCodeAt(i);
  5518. var charType = 'L';
  5519. if (charCode <= 0x00ff) {
  5520. charType = baseTypes[charCode];
  5521. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  5522. charType = 'R';
  5523. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  5524. charType = arabicTypes[charCode & 0xff];
  5525. if (!charType) {
  5526. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  5527. }
  5528. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  5529. charType = 'AL';
  5530. }
  5531. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  5532. numBidi++;
  5533. }
  5534. types[i] = charType;
  5535. }
  5536. if (numBidi === 0) {
  5537. isLTR = true;
  5538. return createBidiText(str, isLTR);
  5539. }
  5540. if (startLevel === -1) {
  5541. if (strLength / numBidi < 0.3) {
  5542. isLTR = true;
  5543. startLevel = 0;
  5544. } else {
  5545. isLTR = false;
  5546. startLevel = 1;
  5547. }
  5548. }
  5549. var levels = [];
  5550. for (i = 0; i < strLength; ++i) {
  5551. levels[i] = startLevel;
  5552. }
  5553. var e = isOdd(startLevel) ? 'R' : 'L';
  5554. var sor = e;
  5555. var eor = sor;
  5556. var lastType = sor;
  5557. for (i = 0; i < strLength; ++i) {
  5558. if (types[i] === 'NSM') {
  5559. types[i] = lastType;
  5560. } else {
  5561. lastType = types[i];
  5562. }
  5563. }
  5564. lastType = sor;
  5565. var t;
  5566. for (i = 0; i < strLength; ++i) {
  5567. t = types[i];
  5568. if (t === 'EN') {
  5569. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  5570. } else if (t === 'R' || t === 'L' || t === 'AL') {
  5571. lastType = t;
  5572. }
  5573. }
  5574. for (i = 0; i < strLength; ++i) {
  5575. t = types[i];
  5576. if (t === 'AL') {
  5577. types[i] = 'R';
  5578. }
  5579. }
  5580. for (i = 1; i < strLength - 1; ++i) {
  5581. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  5582. types[i] = 'EN';
  5583. }
  5584. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  5585. types[i] = types[i - 1];
  5586. }
  5587. }
  5588. for (i = 0; i < strLength; ++i) {
  5589. if (types[i] === 'EN') {
  5590. var j;
  5591. for (j = i - 1; j >= 0; --j) {
  5592. if (types[j] !== 'ET') {
  5593. break;
  5594. }
  5595. types[j] = 'EN';
  5596. }
  5597. for (j = i + 1; j < strLength; ++j) {
  5598. if (types[j] !== 'ET') {
  5599. break;
  5600. }
  5601. types[j] = 'EN';
  5602. }
  5603. }
  5604. }
  5605. for (i = 0; i < strLength; ++i) {
  5606. t = types[i];
  5607. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  5608. types[i] = 'ON';
  5609. }
  5610. }
  5611. lastType = sor;
  5612. for (i = 0; i < strLength; ++i) {
  5613. t = types[i];
  5614. if (t === 'EN') {
  5615. types[i] = lastType === 'L' ? 'L' : 'EN';
  5616. } else if (t === 'R' || t === 'L') {
  5617. lastType = t;
  5618. }
  5619. }
  5620. for (i = 0; i < strLength; ++i) {
  5621. if (types[i] === 'ON') {
  5622. var end = findUnequal(types, i + 1, 'ON');
  5623. var before = sor;
  5624. if (i > 0) {
  5625. before = types[i - 1];
  5626. }
  5627. var after = eor;
  5628. if (end + 1 < strLength) {
  5629. after = types[end + 1];
  5630. }
  5631. if (before !== 'L') {
  5632. before = 'R';
  5633. }
  5634. if (after !== 'L') {
  5635. after = 'R';
  5636. }
  5637. if (before === after) {
  5638. setValues(types, i, end, before);
  5639. }
  5640. i = end - 1;
  5641. }
  5642. }
  5643. for (i = 0; i < strLength; ++i) {
  5644. if (types[i] === 'ON') {
  5645. types[i] = e;
  5646. }
  5647. }
  5648. for (i = 0; i < strLength; ++i) {
  5649. t = types[i];
  5650. if (isEven(levels[i])) {
  5651. if (t === 'R') {
  5652. levels[i] += 1;
  5653. } else if (t === 'AN' || t === 'EN') {
  5654. levels[i] += 2;
  5655. }
  5656. } else {
  5657. if (t === 'L' || t === 'AN' || t === 'EN') {
  5658. levels[i] += 1;
  5659. }
  5660. }
  5661. }
  5662. var highestLevel = -1;
  5663. var lowestOddLevel = 99;
  5664. var level;
  5665. for (i = 0, ii = levels.length; i < ii; ++i) {
  5666. level = levels[i];
  5667. if (highestLevel < level) {
  5668. highestLevel = level;
  5669. }
  5670. if (lowestOddLevel > level && isOdd(level)) {
  5671. lowestOddLevel = level;
  5672. }
  5673. }
  5674. for (level = highestLevel; level >= lowestOddLevel; --level) {
  5675. var start = -1;
  5676. for (i = 0, ii = levels.length; i < ii; ++i) {
  5677. if (levels[i] < level) {
  5678. if (start >= 0) {
  5679. reverseValues(chars, start, i);
  5680. start = -1;
  5681. }
  5682. } else if (start < 0) {
  5683. start = i;
  5684. }
  5685. }
  5686. if (start >= 0) {
  5687. reverseValues(chars, start, levels.length);
  5688. }
  5689. }
  5690. for (i = 0, ii = chars.length; i < ii; ++i) {
  5691. var ch = chars[i];
  5692. if (ch === '<' || ch === '>') {
  5693. chars[i] = '';
  5694. }
  5695. }
  5696. return createBidiText(chars.join(''), isLTR);
  5697. }
  5698. exports.bidi = bidi;
  5699. }));
  5700. (function (root, factory) {
  5701. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5702. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5703. var error = sharedUtil.error;
  5704. var info = sharedUtil.info;
  5705. var bytesToString = sharedUtil.bytesToString;
  5706. var warn = sharedUtil.warn;
  5707. var isArray = sharedUtil.isArray;
  5708. var Util = sharedUtil.Util;
  5709. var stringToBytes = sharedUtil.stringToBytes;
  5710. var assert = sharedUtil.assert;
  5711. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5712. var ExpertCharset = coreCharsets.ExpertCharset;
  5713. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5714. var StandardEncoding = coreEncodings.StandardEncoding;
  5715. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5716. var MAX_SUBR_NESTING = 10;
  5717. var CFFStandardStrings = [
  5718. '.notdef',
  5719. 'space',
  5720. 'exclam',
  5721. 'quotedbl',
  5722. 'numbersign',
  5723. 'dollar',
  5724. 'percent',
  5725. 'ampersand',
  5726. 'quoteright',
  5727. 'parenleft',
  5728. 'parenright',
  5729. 'asterisk',
  5730. 'plus',
  5731. 'comma',
  5732. 'hyphen',
  5733. 'period',
  5734. 'slash',
  5735. 'zero',
  5736. 'one',
  5737. 'two',
  5738. 'three',
  5739. 'four',
  5740. 'five',
  5741. 'six',
  5742. 'seven',
  5743. 'eight',
  5744. 'nine',
  5745. 'colon',
  5746. 'semicolon',
  5747. 'less',
  5748. 'equal',
  5749. 'greater',
  5750. 'question',
  5751. 'at',
  5752. 'A',
  5753. 'B',
  5754. 'C',
  5755. 'D',
  5756. 'E',
  5757. 'F',
  5758. 'G',
  5759. 'H',
  5760. 'I',
  5761. 'J',
  5762. 'K',
  5763. 'L',
  5764. 'M',
  5765. 'N',
  5766. 'O',
  5767. 'P',
  5768. 'Q',
  5769. 'R',
  5770. 'S',
  5771. 'T',
  5772. 'U',
  5773. 'V',
  5774. 'W',
  5775. 'X',
  5776. 'Y',
  5777. 'Z',
  5778. 'bracketleft',
  5779. 'backslash',
  5780. 'bracketright',
  5781. 'asciicircum',
  5782. 'underscore',
  5783. 'quoteleft',
  5784. 'a',
  5785. 'b',
  5786. 'c',
  5787. 'd',
  5788. 'e',
  5789. 'f',
  5790. 'g',
  5791. 'h',
  5792. 'i',
  5793. 'j',
  5794. 'k',
  5795. 'l',
  5796. 'm',
  5797. 'n',
  5798. 'o',
  5799. 'p',
  5800. 'q',
  5801. 'r',
  5802. 's',
  5803. 't',
  5804. 'u',
  5805. 'v',
  5806. 'w',
  5807. 'x',
  5808. 'y',
  5809. 'z',
  5810. 'braceleft',
  5811. 'bar',
  5812. 'braceright',
  5813. 'asciitilde',
  5814. 'exclamdown',
  5815. 'cent',
  5816. 'sterling',
  5817. 'fraction',
  5818. 'yen',
  5819. 'florin',
  5820. 'section',
  5821. 'currency',
  5822. 'quotesingle',
  5823. 'quotedblleft',
  5824. 'guillemotleft',
  5825. 'guilsinglleft',
  5826. 'guilsinglright',
  5827. 'fi',
  5828. 'fl',
  5829. 'endash',
  5830. 'dagger',
  5831. 'daggerdbl',
  5832. 'periodcentered',
  5833. 'paragraph',
  5834. 'bullet',
  5835. 'quotesinglbase',
  5836. 'quotedblbase',
  5837. 'quotedblright',
  5838. 'guillemotright',
  5839. 'ellipsis',
  5840. 'perthousand',
  5841. 'questiondown',
  5842. 'grave',
  5843. 'acute',
  5844. 'circumflex',
  5845. 'tilde',
  5846. 'macron',
  5847. 'breve',
  5848. 'dotaccent',
  5849. 'dieresis',
  5850. 'ring',
  5851. 'cedilla',
  5852. 'hungarumlaut',
  5853. 'ogonek',
  5854. 'caron',
  5855. 'emdash',
  5856. 'AE',
  5857. 'ordfeminine',
  5858. 'Lslash',
  5859. 'Oslash',
  5860. 'OE',
  5861. 'ordmasculine',
  5862. 'ae',
  5863. 'dotlessi',
  5864. 'lslash',
  5865. 'oslash',
  5866. 'oe',
  5867. 'germandbls',
  5868. 'onesuperior',
  5869. 'logicalnot',
  5870. 'mu',
  5871. 'trademark',
  5872. 'Eth',
  5873. 'onehalf',
  5874. 'plusminus',
  5875. 'Thorn',
  5876. 'onequarter',
  5877. 'divide',
  5878. 'brokenbar',
  5879. 'degree',
  5880. 'thorn',
  5881. 'threequarters',
  5882. 'twosuperior',
  5883. 'registered',
  5884. 'minus',
  5885. 'eth',
  5886. 'multiply',
  5887. 'threesuperior',
  5888. 'copyright',
  5889. 'Aacute',
  5890. 'Acircumflex',
  5891. 'Adieresis',
  5892. 'Agrave',
  5893. 'Aring',
  5894. 'Atilde',
  5895. 'Ccedilla',
  5896. 'Eacute',
  5897. 'Ecircumflex',
  5898. 'Edieresis',
  5899. 'Egrave',
  5900. 'Iacute',
  5901. 'Icircumflex',
  5902. 'Idieresis',
  5903. 'Igrave',
  5904. 'Ntilde',
  5905. 'Oacute',
  5906. 'Ocircumflex',
  5907. 'Odieresis',
  5908. 'Ograve',
  5909. 'Otilde',
  5910. 'Scaron',
  5911. 'Uacute',
  5912. 'Ucircumflex',
  5913. 'Udieresis',
  5914. 'Ugrave',
  5915. 'Yacute',
  5916. 'Ydieresis',
  5917. 'Zcaron',
  5918. 'aacute',
  5919. 'acircumflex',
  5920. 'adieresis',
  5921. 'agrave',
  5922. 'aring',
  5923. 'atilde',
  5924. 'ccedilla',
  5925. 'eacute',
  5926. 'ecircumflex',
  5927. 'edieresis',
  5928. 'egrave',
  5929. 'iacute',
  5930. 'icircumflex',
  5931. 'idieresis',
  5932. 'igrave',
  5933. 'ntilde',
  5934. 'oacute',
  5935. 'ocircumflex',
  5936. 'odieresis',
  5937. 'ograve',
  5938. 'otilde',
  5939. 'scaron',
  5940. 'uacute',
  5941. 'ucircumflex',
  5942. 'udieresis',
  5943. 'ugrave',
  5944. 'yacute',
  5945. 'ydieresis',
  5946. 'zcaron',
  5947. 'exclamsmall',
  5948. 'Hungarumlautsmall',
  5949. 'dollaroldstyle',
  5950. 'dollarsuperior',
  5951. 'ampersandsmall',
  5952. 'Acutesmall',
  5953. 'parenleftsuperior',
  5954. 'parenrightsuperior',
  5955. 'twodotenleader',
  5956. 'onedotenleader',
  5957. 'zerooldstyle',
  5958. 'oneoldstyle',
  5959. 'twooldstyle',
  5960. 'threeoldstyle',
  5961. 'fouroldstyle',
  5962. 'fiveoldstyle',
  5963. 'sixoldstyle',
  5964. 'sevenoldstyle',
  5965. 'eightoldstyle',
  5966. 'nineoldstyle',
  5967. 'commasuperior',
  5968. 'threequartersemdash',
  5969. 'periodsuperior',
  5970. 'questionsmall',
  5971. 'asuperior',
  5972. 'bsuperior',
  5973. 'centsuperior',
  5974. 'dsuperior',
  5975. 'esuperior',
  5976. 'isuperior',
  5977. 'lsuperior',
  5978. 'msuperior',
  5979. 'nsuperior',
  5980. 'osuperior',
  5981. 'rsuperior',
  5982. 'ssuperior',
  5983. 'tsuperior',
  5984. 'ff',
  5985. 'ffi',
  5986. 'ffl',
  5987. 'parenleftinferior',
  5988. 'parenrightinferior',
  5989. 'Circumflexsmall',
  5990. 'hyphensuperior',
  5991. 'Gravesmall',
  5992. 'Asmall',
  5993. 'Bsmall',
  5994. 'Csmall',
  5995. 'Dsmall',
  5996. 'Esmall',
  5997. 'Fsmall',
  5998. 'Gsmall',
  5999. 'Hsmall',
  6000. 'Ismall',
  6001. 'Jsmall',
  6002. 'Ksmall',
  6003. 'Lsmall',
  6004. 'Msmall',
  6005. 'Nsmall',
  6006. 'Osmall',
  6007. 'Psmall',
  6008. 'Qsmall',
  6009. 'Rsmall',
  6010. 'Ssmall',
  6011. 'Tsmall',
  6012. 'Usmall',
  6013. 'Vsmall',
  6014. 'Wsmall',
  6015. 'Xsmall',
  6016. 'Ysmall',
  6017. 'Zsmall',
  6018. 'colonmonetary',
  6019. 'onefitted',
  6020. 'rupiah',
  6021. 'Tildesmall',
  6022. 'exclamdownsmall',
  6023. 'centoldstyle',
  6024. 'Lslashsmall',
  6025. 'Scaronsmall',
  6026. 'Zcaronsmall',
  6027. 'Dieresissmall',
  6028. 'Brevesmall',
  6029. 'Caronsmall',
  6030. 'Dotaccentsmall',
  6031. 'Macronsmall',
  6032. 'figuredash',
  6033. 'hypheninferior',
  6034. 'Ogoneksmall',
  6035. 'Ringsmall',
  6036. 'Cedillasmall',
  6037. 'questiondownsmall',
  6038. 'oneeighth',
  6039. 'threeeighths',
  6040. 'fiveeighths',
  6041. 'seveneighths',
  6042. 'onethird',
  6043. 'twothirds',
  6044. 'zerosuperior',
  6045. 'foursuperior',
  6046. 'fivesuperior',
  6047. 'sixsuperior',
  6048. 'sevensuperior',
  6049. 'eightsuperior',
  6050. 'ninesuperior',
  6051. 'zeroinferior',
  6052. 'oneinferior',
  6053. 'twoinferior',
  6054. 'threeinferior',
  6055. 'fourinferior',
  6056. 'fiveinferior',
  6057. 'sixinferior',
  6058. 'seveninferior',
  6059. 'eightinferior',
  6060. 'nineinferior',
  6061. 'centinferior',
  6062. 'dollarinferior',
  6063. 'periodinferior',
  6064. 'commainferior',
  6065. 'Agravesmall',
  6066. 'Aacutesmall',
  6067. 'Acircumflexsmall',
  6068. 'Atildesmall',
  6069. 'Adieresissmall',
  6070. 'Aringsmall',
  6071. 'AEsmall',
  6072. 'Ccedillasmall',
  6073. 'Egravesmall',
  6074. 'Eacutesmall',
  6075. 'Ecircumflexsmall',
  6076. 'Edieresissmall',
  6077. 'Igravesmall',
  6078. 'Iacutesmall',
  6079. 'Icircumflexsmall',
  6080. 'Idieresissmall',
  6081. 'Ethsmall',
  6082. 'Ntildesmall',
  6083. 'Ogravesmall',
  6084. 'Oacutesmall',
  6085. 'Ocircumflexsmall',
  6086. 'Otildesmall',
  6087. 'Odieresissmall',
  6088. 'OEsmall',
  6089. 'Oslashsmall',
  6090. 'Ugravesmall',
  6091. 'Uacutesmall',
  6092. 'Ucircumflexsmall',
  6093. 'Udieresissmall',
  6094. 'Yacutesmall',
  6095. 'Thornsmall',
  6096. 'Ydieresissmall',
  6097. '001.000',
  6098. '001.001',
  6099. '001.002',
  6100. '001.003',
  6101. 'Black',
  6102. 'Bold',
  6103. 'Book',
  6104. 'Light',
  6105. 'Medium',
  6106. 'Regular',
  6107. 'Roman',
  6108. 'Semibold'
  6109. ];
  6110. var CFFParser = function CFFParserClosure() {
  6111. var CharstringValidationData = [
  6112. null,
  6113. {
  6114. id: 'hstem',
  6115. min: 2,
  6116. stackClearing: true,
  6117. stem: true
  6118. },
  6119. null,
  6120. {
  6121. id: 'vstem',
  6122. min: 2,
  6123. stackClearing: true,
  6124. stem: true
  6125. },
  6126. {
  6127. id: 'vmoveto',
  6128. min: 1,
  6129. stackClearing: true
  6130. },
  6131. {
  6132. id: 'rlineto',
  6133. min: 2,
  6134. resetStack: true
  6135. },
  6136. {
  6137. id: 'hlineto',
  6138. min: 1,
  6139. resetStack: true
  6140. },
  6141. {
  6142. id: 'vlineto',
  6143. min: 1,
  6144. resetStack: true
  6145. },
  6146. {
  6147. id: 'rrcurveto',
  6148. min: 6,
  6149. resetStack: true
  6150. },
  6151. null,
  6152. {
  6153. id: 'callsubr',
  6154. min: 1,
  6155. undefStack: true
  6156. },
  6157. {
  6158. id: 'return',
  6159. min: 0,
  6160. undefStack: true
  6161. },
  6162. null,
  6163. null,
  6164. {
  6165. id: 'endchar',
  6166. min: 0,
  6167. stackClearing: true
  6168. },
  6169. null,
  6170. null,
  6171. null,
  6172. {
  6173. id: 'hstemhm',
  6174. min: 2,
  6175. stackClearing: true,
  6176. stem: true
  6177. },
  6178. {
  6179. id: 'hintmask',
  6180. min: 0,
  6181. stackClearing: true
  6182. },
  6183. {
  6184. id: 'cntrmask',
  6185. min: 0,
  6186. stackClearing: true
  6187. },
  6188. {
  6189. id: 'rmoveto',
  6190. min: 2,
  6191. stackClearing: true
  6192. },
  6193. {
  6194. id: 'hmoveto',
  6195. min: 1,
  6196. stackClearing: true
  6197. },
  6198. {
  6199. id: 'vstemhm',
  6200. min: 2,
  6201. stackClearing: true,
  6202. stem: true
  6203. },
  6204. {
  6205. id: 'rcurveline',
  6206. min: 8,
  6207. resetStack: true
  6208. },
  6209. {
  6210. id: 'rlinecurve',
  6211. min: 8,
  6212. resetStack: true
  6213. },
  6214. {
  6215. id: 'vvcurveto',
  6216. min: 4,
  6217. resetStack: true
  6218. },
  6219. {
  6220. id: 'hhcurveto',
  6221. min: 4,
  6222. resetStack: true
  6223. },
  6224. null,
  6225. {
  6226. id: 'callgsubr',
  6227. min: 1,
  6228. undefStack: true
  6229. },
  6230. {
  6231. id: 'vhcurveto',
  6232. min: 4,
  6233. resetStack: true
  6234. },
  6235. {
  6236. id: 'hvcurveto',
  6237. min: 4,
  6238. resetStack: true
  6239. }
  6240. ];
  6241. var CharstringValidationData12 = [
  6242. null,
  6243. null,
  6244. null,
  6245. {
  6246. id: 'and',
  6247. min: 2,
  6248. stackDelta: -1
  6249. },
  6250. {
  6251. id: 'or',
  6252. min: 2,
  6253. stackDelta: -1
  6254. },
  6255. {
  6256. id: 'not',
  6257. min: 1,
  6258. stackDelta: 0
  6259. },
  6260. null,
  6261. null,
  6262. null,
  6263. {
  6264. id: 'abs',
  6265. min: 1,
  6266. stackDelta: 0
  6267. },
  6268. {
  6269. id: 'add',
  6270. min: 2,
  6271. stackDelta: -1,
  6272. stackFn: function stack_div(stack, index) {
  6273. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6274. }
  6275. },
  6276. {
  6277. id: 'sub',
  6278. min: 2,
  6279. stackDelta: -1,
  6280. stackFn: function stack_div(stack, index) {
  6281. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6282. }
  6283. },
  6284. {
  6285. id: 'div',
  6286. min: 2,
  6287. stackDelta: -1,
  6288. stackFn: function stack_div(stack, index) {
  6289. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6290. }
  6291. },
  6292. null,
  6293. {
  6294. id: 'neg',
  6295. min: 1,
  6296. stackDelta: 0,
  6297. stackFn: function stack_div(stack, index) {
  6298. stack[index - 1] = -stack[index - 1];
  6299. }
  6300. },
  6301. {
  6302. id: 'eq',
  6303. min: 2,
  6304. stackDelta: -1
  6305. },
  6306. null,
  6307. null,
  6308. {
  6309. id: 'drop',
  6310. min: 1,
  6311. stackDelta: -1
  6312. },
  6313. null,
  6314. {
  6315. id: 'put',
  6316. min: 2,
  6317. stackDelta: -2
  6318. },
  6319. {
  6320. id: 'get',
  6321. min: 1,
  6322. stackDelta: 0
  6323. },
  6324. {
  6325. id: 'ifelse',
  6326. min: 4,
  6327. stackDelta: -3
  6328. },
  6329. {
  6330. id: 'random',
  6331. min: 0,
  6332. stackDelta: 1
  6333. },
  6334. {
  6335. id: 'mul',
  6336. min: 2,
  6337. stackDelta: -1,
  6338. stackFn: function stack_div(stack, index) {
  6339. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6340. }
  6341. },
  6342. null,
  6343. {
  6344. id: 'sqrt',
  6345. min: 1,
  6346. stackDelta: 0
  6347. },
  6348. {
  6349. id: 'dup',
  6350. min: 1,
  6351. stackDelta: 1
  6352. },
  6353. {
  6354. id: 'exch',
  6355. min: 2,
  6356. stackDelta: 0
  6357. },
  6358. {
  6359. id: 'index',
  6360. min: 2,
  6361. stackDelta: 0
  6362. },
  6363. {
  6364. id: 'roll',
  6365. min: 3,
  6366. stackDelta: -2
  6367. },
  6368. null,
  6369. null,
  6370. null,
  6371. {
  6372. id: 'hflex',
  6373. min: 7,
  6374. resetStack: true
  6375. },
  6376. {
  6377. id: 'flex',
  6378. min: 13,
  6379. resetStack: true
  6380. },
  6381. {
  6382. id: 'hflex1',
  6383. min: 9,
  6384. resetStack: true
  6385. },
  6386. {
  6387. id: 'flex1',
  6388. min: 11,
  6389. resetStack: true
  6390. }
  6391. ];
  6392. function CFFParser(file, properties, seacAnalysisEnabled) {
  6393. this.bytes = file.getBytes();
  6394. this.properties = properties;
  6395. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6396. }
  6397. CFFParser.prototype = {
  6398. parse: function CFFParser_parse() {
  6399. var properties = this.properties;
  6400. var cff = new CFF();
  6401. this.cff = cff;
  6402. var header = this.parseHeader();
  6403. var nameIndex = this.parseIndex(header.endPos);
  6404. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6405. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6406. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6407. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6408. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6409. cff.header = header.obj;
  6410. cff.names = this.parseNameIndex(nameIndex.obj);
  6411. cff.strings = this.parseStringIndex(stringIndex.obj);
  6412. cff.topDict = topDict;
  6413. cff.globalSubrIndex = globalSubrIndex.obj;
  6414. this.parsePrivateDict(cff.topDict);
  6415. cff.isCIDFont = topDict.hasName('ROS');
  6416. var charStringOffset = topDict.getByName('CharStrings');
  6417. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6418. var fontMatrix = topDict.getByName('FontMatrix');
  6419. if (fontMatrix) {
  6420. properties.fontMatrix = fontMatrix;
  6421. }
  6422. var fontBBox = topDict.getByName('FontBBox');
  6423. if (fontBBox) {
  6424. properties.ascent = fontBBox[3];
  6425. properties.descent = fontBBox[1];
  6426. properties.ascentScaled = true;
  6427. }
  6428. var charset, encoding;
  6429. if (cff.isCIDFont) {
  6430. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6431. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6432. var dictRaw = fdArrayIndex.get(i);
  6433. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6434. this.parsePrivateDict(fontDict);
  6435. cff.fdArray.push(fontDict);
  6436. }
  6437. encoding = null;
  6438. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6439. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6440. } else {
  6441. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6442. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6443. }
  6444. cff.charset = charset;
  6445. cff.encoding = encoding;
  6446. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6447. cff.charStrings = charStringsAndSeacs.charStrings;
  6448. cff.seacs = charStringsAndSeacs.seacs;
  6449. cff.widths = charStringsAndSeacs.widths;
  6450. return cff;
  6451. },
  6452. parseHeader: function CFFParser_parseHeader() {
  6453. var bytes = this.bytes;
  6454. var bytesLength = bytes.length;
  6455. var offset = 0;
  6456. while (offset < bytesLength && bytes[offset] !== 1) {
  6457. ++offset;
  6458. }
  6459. if (offset >= bytesLength) {
  6460. error('Invalid CFF header');
  6461. } else if (offset !== 0) {
  6462. info('cff data is shifted');
  6463. bytes = bytes.subarray(offset);
  6464. this.bytes = bytes;
  6465. }
  6466. var major = bytes[0];
  6467. var minor = bytes[1];
  6468. var hdrSize = bytes[2];
  6469. var offSize = bytes[3];
  6470. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6471. return {
  6472. obj: header,
  6473. endPos: hdrSize
  6474. };
  6475. },
  6476. parseDict: function CFFParser_parseDict(dict) {
  6477. var pos = 0;
  6478. function parseOperand() {
  6479. var value = dict[pos++];
  6480. if (value === 30) {
  6481. return parseFloatOperand();
  6482. } else if (value === 28) {
  6483. value = dict[pos++];
  6484. value = (value << 24 | dict[pos++] << 16) >> 16;
  6485. return value;
  6486. } else if (value === 29) {
  6487. value = dict[pos++];
  6488. value = value << 8 | dict[pos++];
  6489. value = value << 8 | dict[pos++];
  6490. value = value << 8 | dict[pos++];
  6491. return value;
  6492. } else if (value >= 32 && value <= 246) {
  6493. return value - 139;
  6494. } else if (value >= 247 && value <= 250) {
  6495. return (value - 247) * 256 + dict[pos++] + 108;
  6496. } else if (value >= 251 && value <= 254) {
  6497. return -((value - 251) * 256) - dict[pos++] - 108;
  6498. } else {
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. }
  6503. function parseFloatOperand() {
  6504. var str = '';
  6505. var eof = 15;
  6506. var lookup = [
  6507. '0',
  6508. '1',
  6509. '2',
  6510. '3',
  6511. '4',
  6512. '5',
  6513. '6',
  6514. '7',
  6515. '8',
  6516. '9',
  6517. '.',
  6518. 'E',
  6519. 'E-',
  6520. null,
  6521. '-'
  6522. ];
  6523. var length = dict.length;
  6524. while (pos < length) {
  6525. var b = dict[pos++];
  6526. var b1 = b >> 4;
  6527. var b2 = b & 15;
  6528. if (b1 === eof) {
  6529. break;
  6530. }
  6531. str += lookup[b1];
  6532. if (b2 === eof) {
  6533. break;
  6534. }
  6535. str += lookup[b2];
  6536. }
  6537. return parseFloat(str);
  6538. }
  6539. var operands = [];
  6540. var entries = [];
  6541. pos = 0;
  6542. var end = dict.length;
  6543. while (pos < end) {
  6544. var b = dict[pos];
  6545. if (b <= 21) {
  6546. if (b === 12) {
  6547. b = b << 8 | dict[++pos];
  6548. }
  6549. entries.push([
  6550. b,
  6551. operands
  6552. ]);
  6553. operands = [];
  6554. ++pos;
  6555. } else {
  6556. operands.push(parseOperand());
  6557. }
  6558. }
  6559. return entries;
  6560. },
  6561. parseIndex: function CFFParser_parseIndex(pos) {
  6562. var cffIndex = new CFFIndex();
  6563. var bytes = this.bytes;
  6564. var count = bytes[pos++] << 8 | bytes[pos++];
  6565. var offsets = [];
  6566. var end = pos;
  6567. var i, ii;
  6568. if (count !== 0) {
  6569. var offsetSize = bytes[pos++];
  6570. var startPos = pos + (count + 1) * offsetSize - 1;
  6571. for (i = 0, ii = count + 1; i < ii; ++i) {
  6572. var offset = 0;
  6573. for (var j = 0; j < offsetSize; ++j) {
  6574. offset <<= 8;
  6575. offset += bytes[pos++];
  6576. }
  6577. offsets.push(startPos + offset);
  6578. }
  6579. end = offsets[count];
  6580. }
  6581. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6582. var offsetStart = offsets[i];
  6583. var offsetEnd = offsets[i + 1];
  6584. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6585. }
  6586. return {
  6587. obj: cffIndex,
  6588. endPos: end
  6589. };
  6590. },
  6591. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6592. var names = [];
  6593. for (var i = 0, ii = index.count; i < ii; ++i) {
  6594. var name = index.get(i);
  6595. var length = Math.min(name.length, 127);
  6596. var data = [];
  6597. for (var j = 0; j < length; ++j) {
  6598. var c = name[j];
  6599. if (j === 0 && c === 0) {
  6600. data[j] = c;
  6601. continue;
  6602. }
  6603. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35)
  6604. {
  6605. data[j] = 95;
  6606. continue;
  6607. }
  6608. data[j] = c;
  6609. }
  6610. names.push(bytesToString(data));
  6611. }
  6612. return names;
  6613. },
  6614. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6615. var strings = new CFFStrings();
  6616. for (var i = 0, ii = index.count; i < ii; ++i) {
  6617. var data = index.get(i);
  6618. strings.add(bytesToString(data));
  6619. }
  6620. return strings;
  6621. },
  6622. createDict: function CFFParser_createDict(Type, dict, strings) {
  6623. var cffDict = new Type(strings);
  6624. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6625. var pair = dict[i];
  6626. var key = pair[0];
  6627. var value = pair[1];
  6628. cffDict.setByKey(key, value);
  6629. }
  6630. return cffDict;
  6631. },
  6632. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6633. if (state.callDepth > MAX_SUBR_NESTING) {
  6634. return false;
  6635. }
  6636. var stackSize = state.stackSize;
  6637. var stack = state.stack;
  6638. var length = data.length;
  6639. for (var j = 0; j < length;) {
  6640. var value = data[j++];
  6641. var validationCommand = null;
  6642. if (value === 12) {
  6643. var q = data[j++];
  6644. if (q === 0) {
  6645. data[j - 2] = 139;
  6646. data[j - 1] = 22;
  6647. stackSize = 0;
  6648. } else {
  6649. validationCommand = CharstringValidationData12[q];
  6650. }
  6651. } else if (value === 28) {
  6652. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6653. j += 2;
  6654. stackSize++;
  6655. } else if (value === 14) {
  6656. if (stackSize >= 4) {
  6657. stackSize -= 4;
  6658. if (this.seacAnalysisEnabled) {
  6659. state.seac = stack.slice(stackSize, stackSize + 4);
  6660. return false;
  6661. }
  6662. }
  6663. validationCommand = CharstringValidationData[value];
  6664. } else if (value >= 32 && value <= 246) {
  6665. stack[stackSize] = value - 139;
  6666. stackSize++;
  6667. } else if (value >= 247 && value <= 254) {
  6668. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6669. j++;
  6670. stackSize++;
  6671. } else if (value === 255) {
  6672. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6673. j += 4;
  6674. stackSize++;
  6675. } else if (value === 19 || value === 20) {
  6676. state.hints += stackSize >> 1;
  6677. j += state.hints + 7 >> 3;
  6678. stackSize %= 2;
  6679. validationCommand = CharstringValidationData[value];
  6680. } else if (value === 10 || value === 29) {
  6681. var subrsIndex;
  6682. if (value === 10) {
  6683. subrsIndex = localSubrIndex;
  6684. } else {
  6685. subrsIndex = globalSubrIndex;
  6686. }
  6687. if (!subrsIndex) {
  6688. validationCommand = CharstringValidationData[value];
  6689. warn('Missing subrsIndex for ' + validationCommand.id);
  6690. return false;
  6691. }
  6692. var bias = 32768;
  6693. if (subrsIndex.count < 1240) {
  6694. bias = 107;
  6695. } else if (subrsIndex.count < 33900) {
  6696. bias = 1131;
  6697. }
  6698. var subrNumber = stack[--stackSize] + bias;
  6699. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6700. validationCommand = CharstringValidationData[value];
  6701. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6702. return false;
  6703. }
  6704. state.stackSize = stackSize;
  6705. state.callDepth++;
  6706. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6707. if (!valid) {
  6708. return false;
  6709. }
  6710. state.callDepth--;
  6711. stackSize = state.stackSize;
  6712. continue;
  6713. } else if (value === 11) {
  6714. state.stackSize = stackSize;
  6715. return true;
  6716. } else {
  6717. validationCommand = CharstringValidationData[value];
  6718. }
  6719. if (validationCommand) {
  6720. if (validationCommand.stem) {
  6721. state.hints += stackSize >> 1;
  6722. }
  6723. if ('min' in validationCommand) {
  6724. if (!state.undefStack && stackSize < validationCommand.min) {
  6725. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6726. return false;
  6727. }
  6728. }
  6729. if (state.firstStackClearing && validationCommand.stackClearing) {
  6730. state.firstStackClearing = false;
  6731. stackSize -= validationCommand.min;
  6732. if (stackSize >= 2 && validationCommand.stem) {
  6733. stackSize %= 2;
  6734. } else if (stackSize > 1) {
  6735. warn('Found too many parameters for stack-clearing command');
  6736. }
  6737. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6738. state.width = stack[stackSize - 1];
  6739. }
  6740. }
  6741. if ('stackDelta' in validationCommand) {
  6742. if ('stackFn' in validationCommand) {
  6743. validationCommand.stackFn(stack, stackSize);
  6744. }
  6745. stackSize += validationCommand.stackDelta;
  6746. } else if (validationCommand.stackClearing) {
  6747. stackSize = 0;
  6748. } else if (validationCommand.resetStack) {
  6749. stackSize = 0;
  6750. state.undefStack = false;
  6751. } else if (validationCommand.undefStack) {
  6752. stackSize = 0;
  6753. state.undefStack = true;
  6754. state.firstStackClearing = false;
  6755. }
  6756. }
  6757. }
  6758. state.stackSize = stackSize;
  6759. return true;
  6760. },
  6761. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6762. var seacs = [];
  6763. var widths = [];
  6764. var count = charStrings.count;
  6765. for (var i = 0; i < count; i++) {
  6766. var charstring = charStrings.get(i);
  6767. var state = {
  6768. callDepth: 0,
  6769. stackSize: 0,
  6770. stack: [],
  6771. undefStack: true,
  6772. hints: 0,
  6773. firstStackClearing: true,
  6774. seac: null,
  6775. width: null
  6776. };
  6777. var valid = true;
  6778. var localSubrToUse = null;
  6779. if (fdSelect && fdArray.length) {
  6780. var fdIndex = fdSelect.getFDIndex(i);
  6781. if (fdIndex === -1) {
  6782. warn('Glyph index is not in fd select.');
  6783. valid = false;
  6784. }
  6785. if (fdIndex >= fdArray.length) {
  6786. warn('Invalid fd index for glyph index.');
  6787. valid = false;
  6788. }
  6789. if (valid) {
  6790. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6791. }
  6792. } else if (localSubrIndex) {
  6793. localSubrToUse = localSubrIndex;
  6794. }
  6795. if (valid) {
  6796. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6797. }
  6798. if (state.width !== null) {
  6799. widths[i] = state.width;
  6800. }
  6801. if (state.seac !== null) {
  6802. seacs[i] = state.seac;
  6803. }
  6804. if (!valid) {
  6805. charStrings.set(i, new Uint8Array([14]));
  6806. }
  6807. }
  6808. return {
  6809. charStrings: charStrings,
  6810. seacs: seacs,
  6811. widths: widths
  6812. };
  6813. },
  6814. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6815. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6816. parentDict.setByKey(18, [
  6817. 0,
  6818. 0
  6819. ]);
  6820. parentDict.privateDict = privateDict;
  6821. },
  6822. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6823. if (!parentDict.hasName('Private')) {
  6824. this.emptyPrivateDictionary(parentDict);
  6825. return;
  6826. }
  6827. var privateOffset = parentDict.getByName('Private');
  6828. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6829. parentDict.removeByName('Private');
  6830. return;
  6831. }
  6832. var size = privateOffset[0];
  6833. var offset = privateOffset[1];
  6834. if (size === 0 || offset >= this.bytes.length) {
  6835. this.emptyPrivateDictionary(parentDict);
  6836. return;
  6837. }
  6838. var privateDictEnd = offset + size;
  6839. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6840. var dict = this.parseDict(dictData);
  6841. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6842. parentDict.privateDict = privateDict;
  6843. if (!privateDict.getByName('Subrs')) {
  6844. return;
  6845. }
  6846. var subrsOffset = privateDict.getByName('Subrs');
  6847. var relativeOffset = offset + subrsOffset;
  6848. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6849. this.emptyPrivateDictionary(parentDict);
  6850. return;
  6851. }
  6852. var subrsIndex = this.parseIndex(relativeOffset);
  6853. privateDict.subrsIndex = subrsIndex.obj;
  6854. },
  6855. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6856. if (pos === 0) {
  6857. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6858. } else if (pos === 1) {
  6859. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6860. } else if (pos === 2) {
  6861. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6862. }
  6863. var bytes = this.bytes;
  6864. var start = pos;
  6865. var format = bytes[pos++];
  6866. var charset = ['.notdef'];
  6867. var id, count, i;
  6868. length -= 1;
  6869. switch (format) {
  6870. case 0:
  6871. for (i = 0; i < length; i++) {
  6872. id = bytes[pos++] << 8 | bytes[pos++];
  6873. charset.push(cid ? id : strings.get(id));
  6874. }
  6875. break;
  6876. case 1:
  6877. while (charset.length <= length) {
  6878. id = bytes[pos++] << 8 | bytes[pos++];
  6879. count = bytes[pos++];
  6880. for (i = 0; i <= count; i++) {
  6881. charset.push(cid ? id++ : strings.get(id++));
  6882. }
  6883. }
  6884. break;
  6885. case 2:
  6886. while (charset.length <= length) {
  6887. id = bytes[pos++] << 8 | bytes[pos++];
  6888. count = bytes[pos++] << 8 | bytes[pos++];
  6889. for (i = 0; i <= count; i++) {
  6890. charset.push(cid ? id++ : strings.get(id++));
  6891. }
  6892. }
  6893. break;
  6894. default:
  6895. error('Unknown charset format');
  6896. }
  6897. var end = pos;
  6898. var raw = bytes.subarray(start, end);
  6899. return new CFFCharset(false, format, charset, raw);
  6900. },
  6901. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6902. var encoding = Object.create(null);
  6903. var bytes = this.bytes;
  6904. var predefined = false;
  6905. var hasSupplement = false;
  6906. var format, i, ii;
  6907. var raw = null;
  6908. function readSupplement() {
  6909. var supplementsCount = bytes[pos++];
  6910. for (i = 0; i < supplementsCount; i++) {
  6911. var code = bytes[pos++];
  6912. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6913. encoding[code] = charset.indexOf(strings.get(sid));
  6914. }
  6915. }
  6916. if (pos === 0 || pos === 1) {
  6917. predefined = true;
  6918. format = pos;
  6919. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6920. for (i = 0, ii = charset.length; i < ii; i++) {
  6921. var index = baseEncoding.indexOf(charset[i]);
  6922. if (index !== -1) {
  6923. encoding[index] = i;
  6924. }
  6925. }
  6926. } else {
  6927. var dataStart = pos;
  6928. format = bytes[pos++];
  6929. switch (format & 0x7f) {
  6930. case 0:
  6931. var glyphsCount = bytes[pos++];
  6932. for (i = 1; i <= glyphsCount; i++) {
  6933. encoding[bytes[pos++]] = i;
  6934. }
  6935. break;
  6936. case 1:
  6937. var rangesCount = bytes[pos++];
  6938. var gid = 1;
  6939. for (i = 0; i < rangesCount; i++) {
  6940. var start = bytes[pos++];
  6941. var left = bytes[pos++];
  6942. for (var j = start; j <= start + left; j++) {
  6943. encoding[j] = gid++;
  6944. }
  6945. }
  6946. break;
  6947. default:
  6948. error('Unknown encoding format: ' + format + ' in CFF');
  6949. break;
  6950. }
  6951. var dataEnd = pos;
  6952. if (format & 0x80) {
  6953. bytes[dataStart] &= 0x7f;
  6954. readSupplement();
  6955. hasSupplement = true;
  6956. }
  6957. raw = bytes.subarray(dataStart, dataEnd);
  6958. }
  6959. format = format & 0x7f;
  6960. return new CFFEncoding(predefined, format, encoding, raw);
  6961. },
  6962. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6963. var start = pos;
  6964. var bytes = this.bytes;
  6965. var format = bytes[pos++];
  6966. var fdSelect = [], rawBytes;
  6967. var i, invalidFirstGID = false;
  6968. switch (format) {
  6969. case 0:
  6970. for (i = 0; i < length; ++i) {
  6971. var id = bytes[pos++];
  6972. fdSelect.push(id);
  6973. }
  6974. rawBytes = bytes.subarray(start, pos);
  6975. break;
  6976. case 3:
  6977. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6978. for (i = 0; i < rangesCount; ++i) {
  6979. var first = bytes[pos++] << 8 | bytes[pos++];
  6980. if (i === 0 && first !== 0) {
  6981. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6982. invalidFirstGID = true;
  6983. first = 0;
  6984. }
  6985. var fdIndex = bytes[pos++];
  6986. var next = bytes[pos] << 8 | bytes[pos + 1];
  6987. for (var j = first; j < next; ++j) {
  6988. fdSelect.push(fdIndex);
  6989. }
  6990. }
  6991. pos += 2;
  6992. rawBytes = bytes.subarray(start, pos);
  6993. if (invalidFirstGID) {
  6994. rawBytes[3] = rawBytes[4] = 0;
  6995. }
  6996. break;
  6997. default:
  6998. error('parseFDSelect: Unknown format "' + format + '".');
  6999. break;
  7000. }
  7001. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  7002. return new CFFFDSelect(fdSelect, rawBytes);
  7003. }
  7004. };
  7005. return CFFParser;
  7006. }();
  7007. var CFF = function CFFClosure() {
  7008. function CFF() {
  7009. this.header = null;
  7010. this.names = [];
  7011. this.topDict = null;
  7012. this.strings = new CFFStrings();
  7013. this.globalSubrIndex = null;
  7014. this.encoding = null;
  7015. this.charset = null;
  7016. this.charStrings = null;
  7017. this.fdArray = [];
  7018. this.fdSelect = null;
  7019. this.isCIDFont = false;
  7020. }
  7021. return CFF;
  7022. }();
  7023. var CFFHeader = function CFFHeaderClosure() {
  7024. function CFFHeader(major, minor, hdrSize, offSize) {
  7025. this.major = major;
  7026. this.minor = minor;
  7027. this.hdrSize = hdrSize;
  7028. this.offSize = offSize;
  7029. }
  7030. return CFFHeader;
  7031. }();
  7032. var CFFStrings = function CFFStringsClosure() {
  7033. function CFFStrings() {
  7034. this.strings = [];
  7035. }
  7036. CFFStrings.prototype = {
  7037. get: function CFFStrings_get(index) {
  7038. if (index >= 0 && index <= 390) {
  7039. return CFFStandardStrings[index];
  7040. }
  7041. if (index - 391 <= this.strings.length) {
  7042. return this.strings[index - 391];
  7043. }
  7044. return CFFStandardStrings[0];
  7045. },
  7046. add: function CFFStrings_add(value) {
  7047. this.strings.push(value);
  7048. },
  7049. get count() {
  7050. return this.strings.length;
  7051. }
  7052. };
  7053. return CFFStrings;
  7054. }();
  7055. var CFFIndex = function CFFIndexClosure() {
  7056. function CFFIndex() {
  7057. this.objects = [];
  7058. this.length = 0;
  7059. }
  7060. CFFIndex.prototype = {
  7061. add: function CFFIndex_add(data) {
  7062. this.length += data.length;
  7063. this.objects.push(data);
  7064. },
  7065. set: function CFFIndex_set(index, data) {
  7066. this.length += data.length - this.objects[index].length;
  7067. this.objects[index] = data;
  7068. },
  7069. get: function CFFIndex_get(index) {
  7070. return this.objects[index];
  7071. },
  7072. get count() {
  7073. return this.objects.length;
  7074. }
  7075. };
  7076. return CFFIndex;
  7077. }();
  7078. var CFFDict = function CFFDictClosure() {
  7079. function CFFDict(tables, strings) {
  7080. this.keyToNameMap = tables.keyToNameMap;
  7081. this.nameToKeyMap = tables.nameToKeyMap;
  7082. this.defaults = tables.defaults;
  7083. this.types = tables.types;
  7084. this.opcodes = tables.opcodes;
  7085. this.order = tables.order;
  7086. this.strings = strings;
  7087. this.values = Object.create(null);
  7088. }
  7089. CFFDict.prototype = {
  7090. setByKey: function CFFDict_setByKey(key, value) {
  7091. if (!(key in this.keyToNameMap)) {
  7092. return false;
  7093. }
  7094. var valueLength = value.length;
  7095. if (valueLength === 0) {
  7096. return true;
  7097. }
  7098. for (var i = 0; i < valueLength; i++) {
  7099. if (isNaN(value[i])) {
  7100. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7101. return true;
  7102. }
  7103. }
  7104. var type = this.types[key];
  7105. if (type === 'num' || type === 'sid' || type === 'offset') {
  7106. value = value[0];
  7107. }
  7108. this.values[key] = value;
  7109. return true;
  7110. },
  7111. setByName: function CFFDict_setByName(name, value) {
  7112. if (!(name in this.nameToKeyMap)) {
  7113. error('Invalid dictionary name "' + name + '"');
  7114. }
  7115. this.values[this.nameToKeyMap[name]] = value;
  7116. },
  7117. hasName: function CFFDict_hasName(name) {
  7118. return this.nameToKeyMap[name] in this.values;
  7119. },
  7120. getByName: function CFFDict_getByName(name) {
  7121. if (!(name in this.nameToKeyMap)) {
  7122. error('Invalid dictionary name "' + name + '"');
  7123. }
  7124. var key = this.nameToKeyMap[name];
  7125. if (!(key in this.values)) {
  7126. return this.defaults[key];
  7127. }
  7128. return this.values[key];
  7129. },
  7130. removeByName: function CFFDict_removeByName(name) {
  7131. delete this.values[this.nameToKeyMap[name]];
  7132. }
  7133. };
  7134. CFFDict.createTables = function CFFDict_createTables(layout) {
  7135. var tables = {
  7136. keyToNameMap: {},
  7137. nameToKeyMap: {},
  7138. defaults: {},
  7139. types: {},
  7140. opcodes: {},
  7141. order: []
  7142. };
  7143. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7144. var entry = layout[i];
  7145. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7146. tables.keyToNameMap[key] = entry[1];
  7147. tables.nameToKeyMap[entry[1]] = key;
  7148. tables.types[key] = entry[2];
  7149. tables.defaults[key] = entry[3];
  7150. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7151. tables.order.push(key);
  7152. }
  7153. return tables;
  7154. };
  7155. return CFFDict;
  7156. }();
  7157. var CFFTopDict = function CFFTopDictClosure() {
  7158. var layout = [
  7159. [
  7160. [
  7161. 12,
  7162. 30
  7163. ],
  7164. 'ROS',
  7165. [
  7166. 'sid',
  7167. 'sid',
  7168. 'num'
  7169. ],
  7170. null
  7171. ],
  7172. [
  7173. [
  7174. 12,
  7175. 20
  7176. ],
  7177. 'SyntheticBase',
  7178. 'num',
  7179. null
  7180. ],
  7181. [
  7182. 0,
  7183. 'version',
  7184. 'sid',
  7185. null
  7186. ],
  7187. [
  7188. 1,
  7189. 'Notice',
  7190. 'sid',
  7191. null
  7192. ],
  7193. [
  7194. [
  7195. 12,
  7196. 0
  7197. ],
  7198. 'Copyright',
  7199. 'sid',
  7200. null
  7201. ],
  7202. [
  7203. 2,
  7204. 'FullName',
  7205. 'sid',
  7206. null
  7207. ],
  7208. [
  7209. 3,
  7210. 'FamilyName',
  7211. 'sid',
  7212. null
  7213. ],
  7214. [
  7215. 4,
  7216. 'Weight',
  7217. 'sid',
  7218. null
  7219. ],
  7220. [
  7221. [
  7222. 12,
  7223. 1
  7224. ],
  7225. 'isFixedPitch',
  7226. 'num',
  7227. 0
  7228. ],
  7229. [
  7230. [
  7231. 12,
  7232. 2
  7233. ],
  7234. 'ItalicAngle',
  7235. 'num',
  7236. 0
  7237. ],
  7238. [
  7239. [
  7240. 12,
  7241. 3
  7242. ],
  7243. 'UnderlinePosition',
  7244. 'num',
  7245. -100
  7246. ],
  7247. [
  7248. [
  7249. 12,
  7250. 4
  7251. ],
  7252. 'UnderlineThickness',
  7253. 'num',
  7254. 50
  7255. ],
  7256. [
  7257. [
  7258. 12,
  7259. 5
  7260. ],
  7261. 'PaintType',
  7262. 'num',
  7263. 0
  7264. ],
  7265. [
  7266. [
  7267. 12,
  7268. 6
  7269. ],
  7270. 'CharstringType',
  7271. 'num',
  7272. 2
  7273. ],
  7274. [
  7275. [
  7276. 12,
  7277. 7
  7278. ],
  7279. 'FontMatrix',
  7280. [
  7281. 'num',
  7282. 'num',
  7283. 'num',
  7284. 'num',
  7285. 'num',
  7286. 'num'
  7287. ],
  7288. [
  7289. 0.001,
  7290. 0,
  7291. 0,
  7292. 0.001,
  7293. 0,
  7294. 0
  7295. ]
  7296. ],
  7297. [
  7298. 13,
  7299. 'UniqueID',
  7300. 'num',
  7301. null
  7302. ],
  7303. [
  7304. 5,
  7305. 'FontBBox',
  7306. [
  7307. 'num',
  7308. 'num',
  7309. 'num',
  7310. 'num'
  7311. ],
  7312. [
  7313. 0,
  7314. 0,
  7315. 0,
  7316. 0
  7317. ]
  7318. ],
  7319. [
  7320. [
  7321. 12,
  7322. 8
  7323. ],
  7324. 'StrokeWidth',
  7325. 'num',
  7326. 0
  7327. ],
  7328. [
  7329. 14,
  7330. 'XUID',
  7331. 'array',
  7332. null
  7333. ],
  7334. [
  7335. 15,
  7336. 'charset',
  7337. 'offset',
  7338. 0
  7339. ],
  7340. [
  7341. 16,
  7342. 'Encoding',
  7343. 'offset',
  7344. 0
  7345. ],
  7346. [
  7347. 17,
  7348. 'CharStrings',
  7349. 'offset',
  7350. 0
  7351. ],
  7352. [
  7353. 18,
  7354. 'Private',
  7355. [
  7356. 'offset',
  7357. 'offset'
  7358. ],
  7359. null
  7360. ],
  7361. [
  7362. [
  7363. 12,
  7364. 21
  7365. ],
  7366. 'PostScript',
  7367. 'sid',
  7368. null
  7369. ],
  7370. [
  7371. [
  7372. 12,
  7373. 22
  7374. ],
  7375. 'BaseFontName',
  7376. 'sid',
  7377. null
  7378. ],
  7379. [
  7380. [
  7381. 12,
  7382. 23
  7383. ],
  7384. 'BaseFontBlend',
  7385. 'delta',
  7386. null
  7387. ],
  7388. [
  7389. [
  7390. 12,
  7391. 31
  7392. ],
  7393. 'CIDFontVersion',
  7394. 'num',
  7395. 0
  7396. ],
  7397. [
  7398. [
  7399. 12,
  7400. 32
  7401. ],
  7402. 'CIDFontRevision',
  7403. 'num',
  7404. 0
  7405. ],
  7406. [
  7407. [
  7408. 12,
  7409. 33
  7410. ],
  7411. 'CIDFontType',
  7412. 'num',
  7413. 0
  7414. ],
  7415. [
  7416. [
  7417. 12,
  7418. 34
  7419. ],
  7420. 'CIDCount',
  7421. 'num',
  7422. 8720
  7423. ],
  7424. [
  7425. [
  7426. 12,
  7427. 35
  7428. ],
  7429. 'UIDBase',
  7430. 'num',
  7431. null
  7432. ],
  7433. [
  7434. [
  7435. 12,
  7436. 37
  7437. ],
  7438. 'FDSelect',
  7439. 'offset',
  7440. null
  7441. ],
  7442. [
  7443. [
  7444. 12,
  7445. 36
  7446. ],
  7447. 'FDArray',
  7448. 'offset',
  7449. null
  7450. ],
  7451. [
  7452. [
  7453. 12,
  7454. 38
  7455. ],
  7456. 'FontName',
  7457. 'sid',
  7458. null
  7459. ]
  7460. ];
  7461. var tables = null;
  7462. function CFFTopDict(strings) {
  7463. if (tables === null) {
  7464. tables = CFFDict.createTables(layout);
  7465. }
  7466. CFFDict.call(this, tables, strings);
  7467. this.privateDict = null;
  7468. }
  7469. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7470. return CFFTopDict;
  7471. }();
  7472. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7473. var layout = [
  7474. [
  7475. 6,
  7476. 'BlueValues',
  7477. 'delta',
  7478. null
  7479. ],
  7480. [
  7481. 7,
  7482. 'OtherBlues',
  7483. 'delta',
  7484. null
  7485. ],
  7486. [
  7487. 8,
  7488. 'FamilyBlues',
  7489. 'delta',
  7490. null
  7491. ],
  7492. [
  7493. 9,
  7494. 'FamilyOtherBlues',
  7495. 'delta',
  7496. null
  7497. ],
  7498. [
  7499. [
  7500. 12,
  7501. 9
  7502. ],
  7503. 'BlueScale',
  7504. 'num',
  7505. 0.039625
  7506. ],
  7507. [
  7508. [
  7509. 12,
  7510. 10
  7511. ],
  7512. 'BlueShift',
  7513. 'num',
  7514. 7
  7515. ],
  7516. [
  7517. [
  7518. 12,
  7519. 11
  7520. ],
  7521. 'BlueFuzz',
  7522. 'num',
  7523. 1
  7524. ],
  7525. [
  7526. 10,
  7527. 'StdHW',
  7528. 'num',
  7529. null
  7530. ],
  7531. [
  7532. 11,
  7533. 'StdVW',
  7534. 'num',
  7535. null
  7536. ],
  7537. [
  7538. [
  7539. 12,
  7540. 12
  7541. ],
  7542. 'StemSnapH',
  7543. 'delta',
  7544. null
  7545. ],
  7546. [
  7547. [
  7548. 12,
  7549. 13
  7550. ],
  7551. 'StemSnapV',
  7552. 'delta',
  7553. null
  7554. ],
  7555. [
  7556. [
  7557. 12,
  7558. 14
  7559. ],
  7560. 'ForceBold',
  7561. 'num',
  7562. 0
  7563. ],
  7564. [
  7565. [
  7566. 12,
  7567. 17
  7568. ],
  7569. 'LanguageGroup',
  7570. 'num',
  7571. 0
  7572. ],
  7573. [
  7574. [
  7575. 12,
  7576. 18
  7577. ],
  7578. 'ExpansionFactor',
  7579. 'num',
  7580. 0.06
  7581. ],
  7582. [
  7583. [
  7584. 12,
  7585. 19
  7586. ],
  7587. 'initialRandomSeed',
  7588. 'num',
  7589. 0
  7590. ],
  7591. [
  7592. 20,
  7593. 'defaultWidthX',
  7594. 'num',
  7595. 0
  7596. ],
  7597. [
  7598. 21,
  7599. 'nominalWidthX',
  7600. 'num',
  7601. 0
  7602. ],
  7603. [
  7604. 19,
  7605. 'Subrs',
  7606. 'offset',
  7607. null
  7608. ]
  7609. ];
  7610. var tables = null;
  7611. function CFFPrivateDict(strings) {
  7612. if (tables === null) {
  7613. tables = CFFDict.createTables(layout);
  7614. }
  7615. CFFDict.call(this, tables, strings);
  7616. this.subrsIndex = null;
  7617. }
  7618. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7619. return CFFPrivateDict;
  7620. }();
  7621. var CFFCharsetPredefinedTypes = {
  7622. ISO_ADOBE: 0,
  7623. EXPERT: 1,
  7624. EXPERT_SUBSET: 2
  7625. };
  7626. var CFFCharset = function CFFCharsetClosure() {
  7627. function CFFCharset(predefined, format, charset, raw) {
  7628. this.predefined = predefined;
  7629. this.format = format;
  7630. this.charset = charset;
  7631. this.raw = raw;
  7632. }
  7633. return CFFCharset;
  7634. }();
  7635. var CFFEncoding = function CFFEncodingClosure() {
  7636. function CFFEncoding(predefined, format, encoding, raw) {
  7637. this.predefined = predefined;
  7638. this.format = format;
  7639. this.encoding = encoding;
  7640. this.raw = raw;
  7641. }
  7642. return CFFEncoding;
  7643. }();
  7644. var CFFFDSelect = function CFFFDSelectClosure() {
  7645. function CFFFDSelect(fdSelect, raw) {
  7646. this.fdSelect = fdSelect;
  7647. this.raw = raw;
  7648. }
  7649. CFFFDSelect.prototype = {
  7650. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7651. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7652. return -1;
  7653. }
  7654. return this.fdSelect[glyphIndex];
  7655. }
  7656. };
  7657. return CFFFDSelect;
  7658. }();
  7659. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7660. function CFFOffsetTracker() {
  7661. this.offsets = Object.create(null);
  7662. }
  7663. CFFOffsetTracker.prototype = {
  7664. isTracking: function CFFOffsetTracker_isTracking(key) {
  7665. return key in this.offsets;
  7666. },
  7667. track: function CFFOffsetTracker_track(key, location) {
  7668. if (key in this.offsets) {
  7669. error('Already tracking location of ' + key);
  7670. }
  7671. this.offsets[key] = location;
  7672. },
  7673. offset: function CFFOffsetTracker_offset(value) {
  7674. for (var key in this.offsets) {
  7675. this.offsets[key] += value;
  7676. }
  7677. },
  7678. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7679. if (!(key in this.offsets)) {
  7680. error('Not tracking location of ' + key);
  7681. }
  7682. var data = output.data;
  7683. var dataOffset = this.offsets[key];
  7684. var size = 5;
  7685. for (var i = 0, ii = values.length; i < ii; ++i) {
  7686. var offset0 = i * size + dataOffset;
  7687. var offset1 = offset0 + 1;
  7688. var offset2 = offset0 + 2;
  7689. var offset3 = offset0 + 3;
  7690. var offset4 = offset0 + 4;
  7691. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7692. error('writing to an offset that is not empty');
  7693. }
  7694. var value = values[i];
  7695. data[offset0] = 0x1d;
  7696. data[offset1] = value >> 24 & 0xFF;
  7697. data[offset2] = value >> 16 & 0xFF;
  7698. data[offset3] = value >> 8 & 0xFF;
  7699. data[offset4] = value & 0xFF;
  7700. }
  7701. }
  7702. };
  7703. return CFFOffsetTracker;
  7704. }();
  7705. var CFFCompiler = function CFFCompilerClosure() {
  7706. function CFFCompiler(cff) {
  7707. this.cff = cff;
  7708. }
  7709. CFFCompiler.prototype = {
  7710. compile: function CFFCompiler_compile() {
  7711. var cff = this.cff;
  7712. var output = {
  7713. data: [],
  7714. length: 0,
  7715. add: function CFFCompiler_add(data) {
  7716. this.data = this.data.concat(data);
  7717. this.length = this.data.length;
  7718. }
  7719. };
  7720. var header = this.compileHeader(cff.header);
  7721. output.add(header);
  7722. var nameIndex = this.compileNameIndex(cff.names);
  7723. output.add(nameIndex);
  7724. if (cff.isCIDFont) {
  7725. if (cff.topDict.hasName('FontMatrix')) {
  7726. var base = cff.topDict.getByName('FontMatrix');
  7727. cff.topDict.removeByName('FontMatrix');
  7728. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7729. var subDict = cff.fdArray[i];
  7730. var matrix = base.slice(0);
  7731. if (subDict.hasName('FontMatrix')) {
  7732. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7733. }
  7734. subDict.setByName('FontMatrix', matrix);
  7735. }
  7736. }
  7737. }
  7738. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7739. output.add(compiled.output);
  7740. var topDictTracker = compiled.trackers[0];
  7741. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7742. output.add(stringIndex);
  7743. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7744. output.add(globalSubrIndex);
  7745. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7746. if (cff.encoding.predefined) {
  7747. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7748. } else {
  7749. var encoding = this.compileEncoding(cff.encoding);
  7750. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7751. output.add(encoding);
  7752. }
  7753. }
  7754. if (cff.charset && cff.topDict.hasName('charset')) {
  7755. if (cff.charset.predefined) {
  7756. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7757. } else {
  7758. var charset = this.compileCharset(cff.charset);
  7759. topDictTracker.setEntryLocation('charset', [output.length], output);
  7760. output.add(charset);
  7761. }
  7762. }
  7763. var charStrings = this.compileCharStrings(cff.charStrings);
  7764. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7765. output.add(charStrings);
  7766. if (cff.isCIDFont) {
  7767. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7768. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7769. output.add(fdSelect);
  7770. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7771. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7772. output.add(compiled.output);
  7773. var fontDictTrackers = compiled.trackers;
  7774. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7775. }
  7776. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7777. output.add([0]);
  7778. return output.data;
  7779. },
  7780. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7781. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7782. return this.encodeInteger(value);
  7783. } else {
  7784. return this.encodeFloat(value);
  7785. }
  7786. },
  7787. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7788. var value = num.toString();
  7789. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7790. if (m) {
  7791. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7792. value = (Math.round(num * epsilon) / epsilon).toString();
  7793. }
  7794. var nibbles = '';
  7795. var i, ii;
  7796. for (i = 0, ii = value.length; i < ii; ++i) {
  7797. var a = value[i];
  7798. if (a === 'e') {
  7799. nibbles += value[++i] === '-' ? 'c' : 'b';
  7800. } else if (a === '.') {
  7801. nibbles += 'a';
  7802. } else if (a === '-') {
  7803. nibbles += 'e';
  7804. } else {
  7805. nibbles += a;
  7806. }
  7807. }
  7808. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7809. var out = [30];
  7810. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7811. out.push(parseInt(nibbles.substr(i, 2), 16));
  7812. }
  7813. return out;
  7814. },
  7815. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7816. var code;
  7817. if (value >= -107 && value <= 107) {
  7818. code = [value + 139];
  7819. } else if (value >= 108 && value <= 1131) {
  7820. value = value - 108;
  7821. code = [
  7822. (value >> 8) + 247,
  7823. value & 0xFF
  7824. ];
  7825. } else if (value >= -1131 && value <= -108) {
  7826. value = -value - 108;
  7827. code = [
  7828. (value >> 8) + 251,
  7829. value & 0xFF
  7830. ];
  7831. } else if (value >= -32768 && value <= 32767) {
  7832. code = [
  7833. 0x1c,
  7834. value >> 8 & 0xFF,
  7835. value & 0xFF
  7836. ];
  7837. } else {
  7838. code = [
  7839. 0x1d,
  7840. value >> 24 & 0xFF,
  7841. value >> 16 & 0xFF,
  7842. value >> 8 & 0xFF,
  7843. value & 0xFF
  7844. ];
  7845. }
  7846. return code;
  7847. },
  7848. compileHeader: function CFFCompiler_compileHeader(header) {
  7849. return [
  7850. header.major,
  7851. header.minor,
  7852. header.hdrSize,
  7853. header.offSize
  7854. ];
  7855. },
  7856. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7857. var nameIndex = new CFFIndex();
  7858. for (var i = 0, ii = names.length; i < ii; ++i) {
  7859. nameIndex.add(stringToBytes(names[i]));
  7860. }
  7861. return this.compileIndex(nameIndex);
  7862. },
  7863. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7864. var fontDictTrackers = [];
  7865. var fdArrayIndex = new CFFIndex();
  7866. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7867. var fontDict = dicts[i];
  7868. if (removeCidKeys) {
  7869. fontDict.removeByName('CIDFontVersion');
  7870. fontDict.removeByName('CIDFontRevision');
  7871. fontDict.removeByName('CIDFontType');
  7872. fontDict.removeByName('CIDCount');
  7873. fontDict.removeByName('UIDBase');
  7874. }
  7875. var fontDictTracker = new CFFOffsetTracker();
  7876. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7877. fontDictTrackers.push(fontDictTracker);
  7878. fdArrayIndex.add(fontDictData);
  7879. fontDictTracker.offset(length);
  7880. }
  7881. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7882. return {
  7883. trackers: fontDictTrackers,
  7884. output: fdArrayIndex
  7885. };
  7886. },
  7887. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7888. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7889. var fontDict = dicts[i];
  7890. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7891. var privateDict = fontDict.privateDict;
  7892. var privateDictTracker = new CFFOffsetTracker();
  7893. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7894. var outputLength = output.length;
  7895. privateDictTracker.offset(outputLength);
  7896. if (!privateDictData.length) {
  7897. outputLength = 0;
  7898. }
  7899. trackers[i].setEntryLocation('Private', [
  7900. privateDictData.length,
  7901. outputLength
  7902. ], output);
  7903. output.add(privateDictData);
  7904. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7905. var subrs = this.compileIndex(privateDict.subrsIndex);
  7906. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7907. output.add(subrs);
  7908. }
  7909. }
  7910. },
  7911. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7912. var out = [];
  7913. var order = dict.order;
  7914. for (var i = 0; i < order.length; ++i) {
  7915. var key = order[i];
  7916. if (!(key in dict.values)) {
  7917. continue;
  7918. }
  7919. var values = dict.values[key];
  7920. var types = dict.types[key];
  7921. if (!isArray(types)) {
  7922. types = [types];
  7923. }
  7924. if (!isArray(values)) {
  7925. values = [values];
  7926. }
  7927. if (values.length === 0) {
  7928. continue;
  7929. }
  7930. for (var j = 0, jj = types.length; j < jj; ++j) {
  7931. var type = types[j];
  7932. var value = values[j];
  7933. switch (type) {
  7934. case 'num':
  7935. case 'sid':
  7936. out = out.concat(this.encodeNumber(value));
  7937. break;
  7938. case 'offset':
  7939. var name = dict.keyToNameMap[key];
  7940. if (!offsetTracker.isTracking(name)) {
  7941. offsetTracker.track(name, out.length);
  7942. }
  7943. out = out.concat([
  7944. 0x1d,
  7945. 0,
  7946. 0,
  7947. 0,
  7948. 0
  7949. ]);
  7950. break;
  7951. case 'array':
  7952. case 'delta':
  7953. out = out.concat(this.encodeNumber(value));
  7954. for (var k = 1, kk = values.length; k < kk; ++k) {
  7955. out = out.concat(this.encodeNumber(values[k]));
  7956. }
  7957. break;
  7958. default:
  7959. error('Unknown data type of ' + type);
  7960. break;
  7961. }
  7962. }
  7963. out = out.concat(dict.opcodes[key]);
  7964. }
  7965. return out;
  7966. },
  7967. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7968. var stringIndex = new CFFIndex();
  7969. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7970. stringIndex.add(stringToBytes(strings[i]));
  7971. }
  7972. return this.compileIndex(stringIndex);
  7973. },
  7974. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7975. var globalSubrIndex = this.cff.globalSubrIndex;
  7976. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7977. },
  7978. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7979. return this.compileIndex(charStrings);
  7980. },
  7981. compileCharset: function CFFCompiler_compileCharset(charset) {
  7982. return this.compileTypedArray(charset.raw);
  7983. },
  7984. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7985. return this.compileTypedArray(encoding.raw);
  7986. },
  7987. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7988. return this.compileTypedArray(fdSelect);
  7989. },
  7990. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7991. var out = [];
  7992. for (var i = 0, ii = data.length; i < ii; ++i) {
  7993. out[i] = data[i];
  7994. }
  7995. return out;
  7996. },
  7997. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7998. trackers = trackers || [];
  7999. var objects = index.objects;
  8000. var count = objects.length;
  8001. if (count === 0) {
  8002. return [
  8003. 0,
  8004. 0,
  8005. 0
  8006. ];
  8007. }
  8008. var data = [
  8009. count >> 8 & 0xFF,
  8010. count & 0xff
  8011. ];
  8012. var lastOffset = 1, i;
  8013. for (i = 0; i < count; ++i) {
  8014. lastOffset += objects[i].length;
  8015. }
  8016. var offsetSize;
  8017. if (lastOffset < 0x100) {
  8018. offsetSize = 1;
  8019. } else if (lastOffset < 0x10000) {
  8020. offsetSize = 2;
  8021. } else if (lastOffset < 0x1000000) {
  8022. offsetSize = 3;
  8023. } else {
  8024. offsetSize = 4;
  8025. }
  8026. data.push(offsetSize);
  8027. var relativeOffset = 1;
  8028. for (i = 0; i < count + 1; i++) {
  8029. if (offsetSize === 1) {
  8030. data.push(relativeOffset & 0xFF);
  8031. } else if (offsetSize === 2) {
  8032. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. } else if (offsetSize === 3) {
  8034. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8035. } else {
  8036. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8037. }
  8038. if (objects[i]) {
  8039. relativeOffset += objects[i].length;
  8040. }
  8041. }
  8042. for (i = 0; i < count; i++) {
  8043. if (trackers[i]) {
  8044. trackers[i].offset(data.length);
  8045. }
  8046. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8047. data.push(objects[i][j]);
  8048. }
  8049. }
  8050. return data;
  8051. }
  8052. };
  8053. return CFFCompiler;
  8054. }();
  8055. exports.CFFStandardStrings = CFFStandardStrings;
  8056. exports.CFFParser = CFFParser;
  8057. exports.CFF = CFF;
  8058. exports.CFFHeader = CFFHeader;
  8059. exports.CFFStrings = CFFStrings;
  8060. exports.CFFIndex = CFFIndex;
  8061. exports.CFFCharset = CFFCharset;
  8062. exports.CFFTopDict = CFFTopDict;
  8063. exports.CFFPrivateDict = CFFPrivateDict;
  8064. exports.CFFCompiler = CFFCompiler;
  8065. }));
  8066. (function (root, factory) {
  8067. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8068. }(this, function (exports, sharedUtil) {
  8069. var MissingDataException = sharedUtil.MissingDataException;
  8070. var arrayByteLength = sharedUtil.arrayByteLength;
  8071. var arraysToBytes = sharedUtil.arraysToBytes;
  8072. var assert = sharedUtil.assert;
  8073. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8074. var isInt = sharedUtil.isInt;
  8075. var isEmptyObj = sharedUtil.isEmptyObj;
  8076. var ChunkedStream = function ChunkedStreamClosure() {
  8077. function ChunkedStream(length, chunkSize, manager) {
  8078. this.bytes = new Uint8Array(length);
  8079. this.start = 0;
  8080. this.pos = 0;
  8081. this.end = length;
  8082. this.chunkSize = chunkSize;
  8083. this.loadedChunks = [];
  8084. this.numChunksLoaded = 0;
  8085. this.numChunks = Math.ceil(length / chunkSize);
  8086. this.manager = manager;
  8087. this.progressiveDataLength = 0;
  8088. this.lastSuccessfulEnsureByteChunk = -1;
  8089. }
  8090. ChunkedStream.prototype = {
  8091. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8092. var chunks = [];
  8093. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8094. if (!this.loadedChunks[chunk]) {
  8095. chunks.push(chunk);
  8096. }
  8097. }
  8098. return chunks;
  8099. },
  8100. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8101. return [this];
  8102. },
  8103. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8104. return this.numChunksLoaded === this.numChunks;
  8105. },
  8106. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8107. var end = begin + chunk.byteLength;
  8108. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8109. var length = this.bytes.length;
  8110. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8111. this.bytes.set(new Uint8Array(chunk), begin);
  8112. var chunkSize = this.chunkSize;
  8113. var beginChunk = Math.floor(begin / chunkSize);
  8114. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8115. var curChunk;
  8116. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8117. if (!this.loadedChunks[curChunk]) {
  8118. this.loadedChunks[curChunk] = true;
  8119. ++this.numChunksLoaded;
  8120. }
  8121. }
  8122. },
  8123. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8124. var position = this.progressiveDataLength;
  8125. var beginChunk = Math.floor(position / this.chunkSize);
  8126. this.bytes.set(new Uint8Array(data), position);
  8127. position += data.byteLength;
  8128. this.progressiveDataLength = position;
  8129. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8130. var curChunk;
  8131. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8132. if (!this.loadedChunks[curChunk]) {
  8133. this.loadedChunks[curChunk] = true;
  8134. ++this.numChunksLoaded;
  8135. }
  8136. }
  8137. },
  8138. ensureByte: function ChunkedStream_ensureByte(pos) {
  8139. var chunk = Math.floor(pos / this.chunkSize);
  8140. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8141. return;
  8142. }
  8143. if (!this.loadedChunks[chunk]) {
  8144. throw new MissingDataException(pos, pos + 1);
  8145. }
  8146. this.lastSuccessfulEnsureByteChunk = chunk;
  8147. },
  8148. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8149. if (begin >= end) {
  8150. return;
  8151. }
  8152. if (end <= this.progressiveDataLength) {
  8153. return;
  8154. }
  8155. var chunkSize = this.chunkSize;
  8156. var beginChunk = Math.floor(begin / chunkSize);
  8157. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8158. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8159. if (!this.loadedChunks[chunk]) {
  8160. throw new MissingDataException(begin, end);
  8161. }
  8162. }
  8163. },
  8164. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8165. var chunk, numChunks = this.numChunks;
  8166. for (var i = 0; i < numChunks; ++i) {
  8167. chunk = (beginChunk + i) % numChunks;
  8168. if (!this.loadedChunks[chunk]) {
  8169. return chunk;
  8170. }
  8171. }
  8172. return null;
  8173. },
  8174. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8175. return !!this.loadedChunks[chunk];
  8176. },
  8177. get length() {
  8178. return this.end - this.start;
  8179. },
  8180. get isEmpty() {
  8181. return this.length === 0;
  8182. },
  8183. getByte: function ChunkedStream_getByte() {
  8184. var pos = this.pos;
  8185. if (pos >= this.end) {
  8186. return -1;
  8187. }
  8188. this.ensureByte(pos);
  8189. return this.bytes[this.pos++];
  8190. },
  8191. getUint16: function ChunkedStream_getUint16() {
  8192. var b0 = this.getByte();
  8193. var b1 = this.getByte();
  8194. if (b0 === -1 || b1 === -1) {
  8195. return -1;
  8196. }
  8197. return (b0 << 8) + b1;
  8198. },
  8199. getInt32: function ChunkedStream_getInt32() {
  8200. var b0 = this.getByte();
  8201. var b1 = this.getByte();
  8202. var b2 = this.getByte();
  8203. var b3 = this.getByte();
  8204. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8205. },
  8206. getBytes: function ChunkedStream_getBytes(length) {
  8207. var bytes = this.bytes;
  8208. var pos = this.pos;
  8209. var strEnd = this.end;
  8210. if (!length) {
  8211. this.ensureRange(pos, strEnd);
  8212. return bytes.subarray(pos, strEnd);
  8213. }
  8214. var end = pos + length;
  8215. if (end > strEnd) {
  8216. end = strEnd;
  8217. }
  8218. this.ensureRange(pos, end);
  8219. this.pos = end;
  8220. return bytes.subarray(pos, end);
  8221. },
  8222. peekByte: function ChunkedStream_peekByte() {
  8223. var peekedByte = this.getByte();
  8224. this.pos--;
  8225. return peekedByte;
  8226. },
  8227. peekBytes: function ChunkedStream_peekBytes(length) {
  8228. var bytes = this.getBytes(length);
  8229. this.pos -= bytes.length;
  8230. return bytes;
  8231. },
  8232. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8233. this.ensureRange(begin, end);
  8234. return this.bytes.subarray(begin, end);
  8235. },
  8236. skip: function ChunkedStream_skip(n) {
  8237. if (!n) {
  8238. n = 1;
  8239. }
  8240. this.pos += n;
  8241. },
  8242. reset: function ChunkedStream_reset() {
  8243. this.pos = this.start;
  8244. },
  8245. moveStart: function ChunkedStream_moveStart() {
  8246. this.start = this.pos;
  8247. },
  8248. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8249. this.ensureRange(start, start + length);
  8250. function ChunkedStreamSubstream() {
  8251. }
  8252. ChunkedStreamSubstream.prototype = Object.create(this);
  8253. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8254. var chunkSize = this.chunkSize;
  8255. var beginChunk = Math.floor(this.start / chunkSize);
  8256. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8257. var missingChunks = [];
  8258. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8259. if (!this.loadedChunks[chunk]) {
  8260. missingChunks.push(chunk);
  8261. }
  8262. }
  8263. return missingChunks;
  8264. };
  8265. var subStream = new ChunkedStreamSubstream();
  8266. subStream.pos = subStream.start = start;
  8267. subStream.end = start + length || this.end;
  8268. subStream.dict = dict;
  8269. return subStream;
  8270. },
  8271. isStream: true
  8272. };
  8273. return ChunkedStream;
  8274. }();
  8275. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8276. function ChunkedStreamManager(pdfNetworkStream, args) {
  8277. var chunkSize = args.rangeChunkSize;
  8278. var length = args.length;
  8279. this.stream = new ChunkedStream(length, chunkSize, this);
  8280. this.length = length;
  8281. this.chunkSize = chunkSize;
  8282. this.pdfNetworkStream = pdfNetworkStream;
  8283. this.url = args.url;
  8284. this.disableAutoFetch = args.disableAutoFetch;
  8285. this.msgHandler = args.msgHandler;
  8286. this.currRequestId = 0;
  8287. this.chunksNeededByRequest = Object.create(null);
  8288. this.requestsByChunk = Object.create(null);
  8289. this.promisesByRequest = Object.create(null);
  8290. this.progressiveDataLength = 0;
  8291. this.aborted = false;
  8292. this._loadedStreamCapability = createPromiseCapability();
  8293. }
  8294. ChunkedStreamManager.prototype = {
  8295. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8296. return this._loadedStreamCapability.promise;
  8297. },
  8298. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8299. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8300. if (!rangeReader.isStreamingSupported) {
  8301. rangeReader.onProgress = this.onProgress.bind(this);
  8302. }
  8303. var chunks = [], loaded = 0;
  8304. var manager = this;
  8305. var promise = new Promise(function (resolve, reject) {
  8306. var readChunk = function (chunk) {
  8307. try {
  8308. if (!chunk.done) {
  8309. var data = chunk.value;
  8310. chunks.push(data);
  8311. loaded += arrayByteLength(data);
  8312. if (rangeReader.isStreamingSupported) {
  8313. manager.onProgress({ loaded: loaded });
  8314. }
  8315. rangeReader.read().then(readChunk, reject);
  8316. return;
  8317. }
  8318. var chunkData = arraysToBytes(chunks);
  8319. chunks = null;
  8320. resolve(chunkData);
  8321. } catch (e) {
  8322. reject(e);
  8323. }
  8324. };
  8325. rangeReader.read().then(readChunk, reject);
  8326. });
  8327. promise.then(function (data) {
  8328. if (this.aborted) {
  8329. return;
  8330. }
  8331. this.onReceiveData({
  8332. chunk: data,
  8333. begin: begin
  8334. });
  8335. }.bind(this));
  8336. },
  8337. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8338. var missingChunks = this.stream.getMissingChunks();
  8339. this._requestChunks(missingChunks);
  8340. return this._loadedStreamCapability.promise;
  8341. },
  8342. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8343. var requestId = this.currRequestId++;
  8344. var i, ii;
  8345. var chunksNeeded = Object.create(null);
  8346. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8347. for (i = 0, ii = chunks.length; i < ii; i++) {
  8348. if (!this.stream.hasChunk(chunks[i])) {
  8349. chunksNeeded[chunks[i]] = true;
  8350. }
  8351. }
  8352. if (isEmptyObj(chunksNeeded)) {
  8353. return Promise.resolve();
  8354. }
  8355. var capability = createPromiseCapability();
  8356. this.promisesByRequest[requestId] = capability;
  8357. var chunksToRequest = [];
  8358. for (var chunk in chunksNeeded) {
  8359. chunk = chunk | 0;
  8360. if (!(chunk in this.requestsByChunk)) {
  8361. this.requestsByChunk[chunk] = [];
  8362. chunksToRequest.push(chunk);
  8363. }
  8364. this.requestsByChunk[chunk].push(requestId);
  8365. }
  8366. if (!chunksToRequest.length) {
  8367. return capability.promise;
  8368. }
  8369. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8370. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8371. var groupedChunk = groupedChunksToRequest[i];
  8372. var begin = groupedChunk.beginChunk * this.chunkSize;
  8373. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8374. this.sendRequest(begin, end);
  8375. }
  8376. return capability.promise;
  8377. },
  8378. getStream: function ChunkedStreamManager_getStream() {
  8379. return this.stream;
  8380. },
  8381. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8382. end = Math.min(end, this.length);
  8383. var beginChunk = this.getBeginChunk(begin);
  8384. var endChunk = this.getEndChunk(end);
  8385. var chunks = [];
  8386. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8387. chunks.push(chunk);
  8388. }
  8389. return this._requestChunks(chunks);
  8390. },
  8391. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8392. ranges = ranges || [];
  8393. var chunksToRequest = [];
  8394. for (var i = 0; i < ranges.length; i++) {
  8395. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8396. var endChunk = this.getEndChunk(ranges[i].end);
  8397. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8398. if (chunksToRequest.indexOf(chunk) < 0) {
  8399. chunksToRequest.push(chunk);
  8400. }
  8401. }
  8402. }
  8403. chunksToRequest.sort(function (a, b) {
  8404. return a - b;
  8405. });
  8406. return this._requestChunks(chunksToRequest);
  8407. },
  8408. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8409. var groupedChunks = [];
  8410. var beginChunk = -1;
  8411. var prevChunk = -1;
  8412. for (var i = 0; i < chunks.length; ++i) {
  8413. var chunk = chunks[i];
  8414. if (beginChunk < 0) {
  8415. beginChunk = chunk;
  8416. }
  8417. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8418. groupedChunks.push({
  8419. beginChunk: beginChunk,
  8420. endChunk: prevChunk + 1
  8421. });
  8422. beginChunk = chunk;
  8423. }
  8424. if (i + 1 === chunks.length) {
  8425. groupedChunks.push({
  8426. beginChunk: beginChunk,
  8427. endChunk: chunk + 1
  8428. });
  8429. }
  8430. prevChunk = chunk;
  8431. }
  8432. return groupedChunks;
  8433. },
  8434. onProgress: function ChunkedStreamManager_onProgress(args) {
  8435. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8436. this.msgHandler.send('DocProgress', {
  8437. loaded: bytesLoaded,
  8438. total: this.length
  8439. });
  8440. },
  8441. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8442. var chunk = args.chunk;
  8443. var isProgressive = args.begin === undefined;
  8444. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8445. var end = begin + chunk.byteLength;
  8446. var beginChunk = Math.floor(begin / this.chunkSize);
  8447. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8448. if (isProgressive) {
  8449. this.stream.onReceiveProgressiveData(chunk);
  8450. this.progressiveDataLength = end;
  8451. } else {
  8452. this.stream.onReceiveData(begin, chunk);
  8453. }
  8454. if (this.stream.allChunksLoaded()) {
  8455. this._loadedStreamCapability.resolve(this.stream);
  8456. }
  8457. var loadedRequests = [];
  8458. var i, requestId;
  8459. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8460. var requestIds = this.requestsByChunk[chunk] || [];
  8461. delete this.requestsByChunk[chunk];
  8462. for (i = 0; i < requestIds.length; ++i) {
  8463. requestId = requestIds[i];
  8464. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8465. if (chunk in chunksNeeded) {
  8466. delete chunksNeeded[chunk];
  8467. }
  8468. if (!isEmptyObj(chunksNeeded)) {
  8469. continue;
  8470. }
  8471. loadedRequests.push(requestId);
  8472. }
  8473. }
  8474. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8475. var nextEmptyChunk;
  8476. if (this.stream.numChunksLoaded === 1) {
  8477. var lastChunk = this.stream.numChunks - 1;
  8478. if (!this.stream.hasChunk(lastChunk)) {
  8479. nextEmptyChunk = lastChunk;
  8480. }
  8481. } else {
  8482. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8483. }
  8484. if (isInt(nextEmptyChunk)) {
  8485. this._requestChunks([nextEmptyChunk]);
  8486. }
  8487. }
  8488. for (i = 0; i < loadedRequests.length; ++i) {
  8489. requestId = loadedRequests[i];
  8490. var capability = this.promisesByRequest[requestId];
  8491. delete this.promisesByRequest[requestId];
  8492. capability.resolve();
  8493. }
  8494. this.msgHandler.send('DocProgress', {
  8495. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8496. total: this.length
  8497. });
  8498. },
  8499. onError: function ChunkedStreamManager_onError(err) {
  8500. this._loadedStreamCapability.reject(err);
  8501. },
  8502. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8503. var chunk = Math.floor(begin / this.chunkSize);
  8504. return chunk;
  8505. },
  8506. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8507. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8508. return chunk;
  8509. },
  8510. abort: function ChunkedStreamManager_abort() {
  8511. this.aborted = true;
  8512. if (this.pdfNetworkStream) {
  8513. this.pdfNetworkStream.cancelAllRequests('abort');
  8514. }
  8515. for (var requestId in this.promisesByRequest) {
  8516. var capability = this.promisesByRequest[requestId];
  8517. capability.reject(new Error('Request was aborted'));
  8518. }
  8519. }
  8520. };
  8521. return ChunkedStreamManager;
  8522. }();
  8523. exports.ChunkedStream = ChunkedStream;
  8524. exports.ChunkedStreamManager = ChunkedStreamManager;
  8525. }));
  8526. (function (root, factory) {
  8527. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8528. }(this, function (exports, sharedUtil) {
  8529. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8530. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8531. t['A'] = 0x0041;
  8532. t['AE'] = 0x00C6;
  8533. t['AEacute'] = 0x01FC;
  8534. t['AEmacron'] = 0x01E2;
  8535. t['AEsmall'] = 0xF7E6;
  8536. t['Aacute'] = 0x00C1;
  8537. t['Aacutesmall'] = 0xF7E1;
  8538. t['Abreve'] = 0x0102;
  8539. t['Abreveacute'] = 0x1EAE;
  8540. t['Abrevecyrillic'] = 0x04D0;
  8541. t['Abrevedotbelow'] = 0x1EB6;
  8542. t['Abrevegrave'] = 0x1EB0;
  8543. t['Abrevehookabove'] = 0x1EB2;
  8544. t['Abrevetilde'] = 0x1EB4;
  8545. t['Acaron'] = 0x01CD;
  8546. t['Acircle'] = 0x24B6;
  8547. t['Acircumflex'] = 0x00C2;
  8548. t['Acircumflexacute'] = 0x1EA4;
  8549. t['Acircumflexdotbelow'] = 0x1EAC;
  8550. t['Acircumflexgrave'] = 0x1EA6;
  8551. t['Acircumflexhookabove'] = 0x1EA8;
  8552. t['Acircumflexsmall'] = 0xF7E2;
  8553. t['Acircumflextilde'] = 0x1EAA;
  8554. t['Acute'] = 0xF6C9;
  8555. t['Acutesmall'] = 0xF7B4;
  8556. t['Acyrillic'] = 0x0410;
  8557. t['Adblgrave'] = 0x0200;
  8558. t['Adieresis'] = 0x00C4;
  8559. t['Adieresiscyrillic'] = 0x04D2;
  8560. t['Adieresismacron'] = 0x01DE;
  8561. t['Adieresissmall'] = 0xF7E4;
  8562. t['Adotbelow'] = 0x1EA0;
  8563. t['Adotmacron'] = 0x01E0;
  8564. t['Agrave'] = 0x00C0;
  8565. t['Agravesmall'] = 0xF7E0;
  8566. t['Ahookabove'] = 0x1EA2;
  8567. t['Aiecyrillic'] = 0x04D4;
  8568. t['Ainvertedbreve'] = 0x0202;
  8569. t['Alpha'] = 0x0391;
  8570. t['Alphatonos'] = 0x0386;
  8571. t['Amacron'] = 0x0100;
  8572. t['Amonospace'] = 0xFF21;
  8573. t['Aogonek'] = 0x0104;
  8574. t['Aring'] = 0x00C5;
  8575. t['Aringacute'] = 0x01FA;
  8576. t['Aringbelow'] = 0x1E00;
  8577. t['Aringsmall'] = 0xF7E5;
  8578. t['Asmall'] = 0xF761;
  8579. t['Atilde'] = 0x00C3;
  8580. t['Atildesmall'] = 0xF7E3;
  8581. t['Aybarmenian'] = 0x0531;
  8582. t['B'] = 0x0042;
  8583. t['Bcircle'] = 0x24B7;
  8584. t['Bdotaccent'] = 0x1E02;
  8585. t['Bdotbelow'] = 0x1E04;
  8586. t['Becyrillic'] = 0x0411;
  8587. t['Benarmenian'] = 0x0532;
  8588. t['Beta'] = 0x0392;
  8589. t['Bhook'] = 0x0181;
  8590. t['Blinebelow'] = 0x1E06;
  8591. t['Bmonospace'] = 0xFF22;
  8592. t['Brevesmall'] = 0xF6F4;
  8593. t['Bsmall'] = 0xF762;
  8594. t['Btopbar'] = 0x0182;
  8595. t['C'] = 0x0043;
  8596. t['Caarmenian'] = 0x053E;
  8597. t['Cacute'] = 0x0106;
  8598. t['Caron'] = 0xF6CA;
  8599. t['Caronsmall'] = 0xF6F5;
  8600. t['Ccaron'] = 0x010C;
  8601. t['Ccedilla'] = 0x00C7;
  8602. t['Ccedillaacute'] = 0x1E08;
  8603. t['Ccedillasmall'] = 0xF7E7;
  8604. t['Ccircle'] = 0x24B8;
  8605. t['Ccircumflex'] = 0x0108;
  8606. t['Cdot'] = 0x010A;
  8607. t['Cdotaccent'] = 0x010A;
  8608. t['Cedillasmall'] = 0xF7B8;
  8609. t['Chaarmenian'] = 0x0549;
  8610. t['Cheabkhasiancyrillic'] = 0x04BC;
  8611. t['Checyrillic'] = 0x0427;
  8612. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8613. t['Chedescendercyrillic'] = 0x04B6;
  8614. t['Chedieresiscyrillic'] = 0x04F4;
  8615. t['Cheharmenian'] = 0x0543;
  8616. t['Chekhakassiancyrillic'] = 0x04CB;
  8617. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8618. t['Chi'] = 0x03A7;
  8619. t['Chook'] = 0x0187;
  8620. t['Circumflexsmall'] = 0xF6F6;
  8621. t['Cmonospace'] = 0xFF23;
  8622. t['Coarmenian'] = 0x0551;
  8623. t['Csmall'] = 0xF763;
  8624. t['D'] = 0x0044;
  8625. t['DZ'] = 0x01F1;
  8626. t['DZcaron'] = 0x01C4;
  8627. t['Daarmenian'] = 0x0534;
  8628. t['Dafrican'] = 0x0189;
  8629. t['Dcaron'] = 0x010E;
  8630. t['Dcedilla'] = 0x1E10;
  8631. t['Dcircle'] = 0x24B9;
  8632. t['Dcircumflexbelow'] = 0x1E12;
  8633. t['Dcroat'] = 0x0110;
  8634. t['Ddotaccent'] = 0x1E0A;
  8635. t['Ddotbelow'] = 0x1E0C;
  8636. t['Decyrillic'] = 0x0414;
  8637. t['Deicoptic'] = 0x03EE;
  8638. t['Delta'] = 0x2206;
  8639. t['Deltagreek'] = 0x0394;
  8640. t['Dhook'] = 0x018A;
  8641. t['Dieresis'] = 0xF6CB;
  8642. t['DieresisAcute'] = 0xF6CC;
  8643. t['DieresisGrave'] = 0xF6CD;
  8644. t['Dieresissmall'] = 0xF7A8;
  8645. t['Digammagreek'] = 0x03DC;
  8646. t['Djecyrillic'] = 0x0402;
  8647. t['Dlinebelow'] = 0x1E0E;
  8648. t['Dmonospace'] = 0xFF24;
  8649. t['Dotaccentsmall'] = 0xF6F7;
  8650. t['Dslash'] = 0x0110;
  8651. t['Dsmall'] = 0xF764;
  8652. t['Dtopbar'] = 0x018B;
  8653. t['Dz'] = 0x01F2;
  8654. t['Dzcaron'] = 0x01C5;
  8655. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8656. t['Dzecyrillic'] = 0x0405;
  8657. t['Dzhecyrillic'] = 0x040F;
  8658. t['E'] = 0x0045;
  8659. t['Eacute'] = 0x00C9;
  8660. t['Eacutesmall'] = 0xF7E9;
  8661. t['Ebreve'] = 0x0114;
  8662. t['Ecaron'] = 0x011A;
  8663. t['Ecedillabreve'] = 0x1E1C;
  8664. t['Echarmenian'] = 0x0535;
  8665. t['Ecircle'] = 0x24BA;
  8666. t['Ecircumflex'] = 0x00CA;
  8667. t['Ecircumflexacute'] = 0x1EBE;
  8668. t['Ecircumflexbelow'] = 0x1E18;
  8669. t['Ecircumflexdotbelow'] = 0x1EC6;
  8670. t['Ecircumflexgrave'] = 0x1EC0;
  8671. t['Ecircumflexhookabove'] = 0x1EC2;
  8672. t['Ecircumflexsmall'] = 0xF7EA;
  8673. t['Ecircumflextilde'] = 0x1EC4;
  8674. t['Ecyrillic'] = 0x0404;
  8675. t['Edblgrave'] = 0x0204;
  8676. t['Edieresis'] = 0x00CB;
  8677. t['Edieresissmall'] = 0xF7EB;
  8678. t['Edot'] = 0x0116;
  8679. t['Edotaccent'] = 0x0116;
  8680. t['Edotbelow'] = 0x1EB8;
  8681. t['Efcyrillic'] = 0x0424;
  8682. t['Egrave'] = 0x00C8;
  8683. t['Egravesmall'] = 0xF7E8;
  8684. t['Eharmenian'] = 0x0537;
  8685. t['Ehookabove'] = 0x1EBA;
  8686. t['Eightroman'] = 0x2167;
  8687. t['Einvertedbreve'] = 0x0206;
  8688. t['Eiotifiedcyrillic'] = 0x0464;
  8689. t['Elcyrillic'] = 0x041B;
  8690. t['Elevenroman'] = 0x216A;
  8691. t['Emacron'] = 0x0112;
  8692. t['Emacronacute'] = 0x1E16;
  8693. t['Emacrongrave'] = 0x1E14;
  8694. t['Emcyrillic'] = 0x041C;
  8695. t['Emonospace'] = 0xFF25;
  8696. t['Encyrillic'] = 0x041D;
  8697. t['Endescendercyrillic'] = 0x04A2;
  8698. t['Eng'] = 0x014A;
  8699. t['Enghecyrillic'] = 0x04A4;
  8700. t['Enhookcyrillic'] = 0x04C7;
  8701. t['Eogonek'] = 0x0118;
  8702. t['Eopen'] = 0x0190;
  8703. t['Epsilon'] = 0x0395;
  8704. t['Epsilontonos'] = 0x0388;
  8705. t['Ercyrillic'] = 0x0420;
  8706. t['Ereversed'] = 0x018E;
  8707. t['Ereversedcyrillic'] = 0x042D;
  8708. t['Escyrillic'] = 0x0421;
  8709. t['Esdescendercyrillic'] = 0x04AA;
  8710. t['Esh'] = 0x01A9;
  8711. t['Esmall'] = 0xF765;
  8712. t['Eta'] = 0x0397;
  8713. t['Etarmenian'] = 0x0538;
  8714. t['Etatonos'] = 0x0389;
  8715. t['Eth'] = 0x00D0;
  8716. t['Ethsmall'] = 0xF7F0;
  8717. t['Etilde'] = 0x1EBC;
  8718. t['Etildebelow'] = 0x1E1A;
  8719. t['Euro'] = 0x20AC;
  8720. t['Ezh'] = 0x01B7;
  8721. t['Ezhcaron'] = 0x01EE;
  8722. t['Ezhreversed'] = 0x01B8;
  8723. t['F'] = 0x0046;
  8724. t['Fcircle'] = 0x24BB;
  8725. t['Fdotaccent'] = 0x1E1E;
  8726. t['Feharmenian'] = 0x0556;
  8727. t['Feicoptic'] = 0x03E4;
  8728. t['Fhook'] = 0x0191;
  8729. t['Fitacyrillic'] = 0x0472;
  8730. t['Fiveroman'] = 0x2164;
  8731. t['Fmonospace'] = 0xFF26;
  8732. t['Fourroman'] = 0x2163;
  8733. t['Fsmall'] = 0xF766;
  8734. t['G'] = 0x0047;
  8735. t['GBsquare'] = 0x3387;
  8736. t['Gacute'] = 0x01F4;
  8737. t['Gamma'] = 0x0393;
  8738. t['Gammaafrican'] = 0x0194;
  8739. t['Gangiacoptic'] = 0x03EA;
  8740. t['Gbreve'] = 0x011E;
  8741. t['Gcaron'] = 0x01E6;
  8742. t['Gcedilla'] = 0x0122;
  8743. t['Gcircle'] = 0x24BC;
  8744. t['Gcircumflex'] = 0x011C;
  8745. t['Gcommaaccent'] = 0x0122;
  8746. t['Gdot'] = 0x0120;
  8747. t['Gdotaccent'] = 0x0120;
  8748. t['Gecyrillic'] = 0x0413;
  8749. t['Ghadarmenian'] = 0x0542;
  8750. t['Ghemiddlehookcyrillic'] = 0x0494;
  8751. t['Ghestrokecyrillic'] = 0x0492;
  8752. t['Gheupturncyrillic'] = 0x0490;
  8753. t['Ghook'] = 0x0193;
  8754. t['Gimarmenian'] = 0x0533;
  8755. t['Gjecyrillic'] = 0x0403;
  8756. t['Gmacron'] = 0x1E20;
  8757. t['Gmonospace'] = 0xFF27;
  8758. t['Grave'] = 0xF6CE;
  8759. t['Gravesmall'] = 0xF760;
  8760. t['Gsmall'] = 0xF767;
  8761. t['Gsmallhook'] = 0x029B;
  8762. t['Gstroke'] = 0x01E4;
  8763. t['H'] = 0x0048;
  8764. t['H18533'] = 0x25CF;
  8765. t['H18543'] = 0x25AA;
  8766. t['H18551'] = 0x25AB;
  8767. t['H22073'] = 0x25A1;
  8768. t['HPsquare'] = 0x33CB;
  8769. t['Haabkhasiancyrillic'] = 0x04A8;
  8770. t['Hadescendercyrillic'] = 0x04B2;
  8771. t['Hardsigncyrillic'] = 0x042A;
  8772. t['Hbar'] = 0x0126;
  8773. t['Hbrevebelow'] = 0x1E2A;
  8774. t['Hcedilla'] = 0x1E28;
  8775. t['Hcircle'] = 0x24BD;
  8776. t['Hcircumflex'] = 0x0124;
  8777. t['Hdieresis'] = 0x1E26;
  8778. t['Hdotaccent'] = 0x1E22;
  8779. t['Hdotbelow'] = 0x1E24;
  8780. t['Hmonospace'] = 0xFF28;
  8781. t['Hoarmenian'] = 0x0540;
  8782. t['Horicoptic'] = 0x03E8;
  8783. t['Hsmall'] = 0xF768;
  8784. t['Hungarumlaut'] = 0xF6CF;
  8785. t['Hungarumlautsmall'] = 0xF6F8;
  8786. t['Hzsquare'] = 0x3390;
  8787. t['I'] = 0x0049;
  8788. t['IAcyrillic'] = 0x042F;
  8789. t['IJ'] = 0x0132;
  8790. t['IUcyrillic'] = 0x042E;
  8791. t['Iacute'] = 0x00CD;
  8792. t['Iacutesmall'] = 0xF7ED;
  8793. t['Ibreve'] = 0x012C;
  8794. t['Icaron'] = 0x01CF;
  8795. t['Icircle'] = 0x24BE;
  8796. t['Icircumflex'] = 0x00CE;
  8797. t['Icircumflexsmall'] = 0xF7EE;
  8798. t['Icyrillic'] = 0x0406;
  8799. t['Idblgrave'] = 0x0208;
  8800. t['Idieresis'] = 0x00CF;
  8801. t['Idieresisacute'] = 0x1E2E;
  8802. t['Idieresiscyrillic'] = 0x04E4;
  8803. t['Idieresissmall'] = 0xF7EF;
  8804. t['Idot'] = 0x0130;
  8805. t['Idotaccent'] = 0x0130;
  8806. t['Idotbelow'] = 0x1ECA;
  8807. t['Iebrevecyrillic'] = 0x04D6;
  8808. t['Iecyrillic'] = 0x0415;
  8809. t['Ifraktur'] = 0x2111;
  8810. t['Igrave'] = 0x00CC;
  8811. t['Igravesmall'] = 0xF7EC;
  8812. t['Ihookabove'] = 0x1EC8;
  8813. t['Iicyrillic'] = 0x0418;
  8814. t['Iinvertedbreve'] = 0x020A;
  8815. t['Iishortcyrillic'] = 0x0419;
  8816. t['Imacron'] = 0x012A;
  8817. t['Imacroncyrillic'] = 0x04E2;
  8818. t['Imonospace'] = 0xFF29;
  8819. t['Iniarmenian'] = 0x053B;
  8820. t['Iocyrillic'] = 0x0401;
  8821. t['Iogonek'] = 0x012E;
  8822. t['Iota'] = 0x0399;
  8823. t['Iotaafrican'] = 0x0196;
  8824. t['Iotadieresis'] = 0x03AA;
  8825. t['Iotatonos'] = 0x038A;
  8826. t['Ismall'] = 0xF769;
  8827. t['Istroke'] = 0x0197;
  8828. t['Itilde'] = 0x0128;
  8829. t['Itildebelow'] = 0x1E2C;
  8830. t['Izhitsacyrillic'] = 0x0474;
  8831. t['Izhitsadblgravecyrillic'] = 0x0476;
  8832. t['J'] = 0x004A;
  8833. t['Jaarmenian'] = 0x0541;
  8834. t['Jcircle'] = 0x24BF;
  8835. t['Jcircumflex'] = 0x0134;
  8836. t['Jecyrillic'] = 0x0408;
  8837. t['Jheharmenian'] = 0x054B;
  8838. t['Jmonospace'] = 0xFF2A;
  8839. t['Jsmall'] = 0xF76A;
  8840. t['K'] = 0x004B;
  8841. t['KBsquare'] = 0x3385;
  8842. t['KKsquare'] = 0x33CD;
  8843. t['Kabashkircyrillic'] = 0x04A0;
  8844. t['Kacute'] = 0x1E30;
  8845. t['Kacyrillic'] = 0x041A;
  8846. t['Kadescendercyrillic'] = 0x049A;
  8847. t['Kahookcyrillic'] = 0x04C3;
  8848. t['Kappa'] = 0x039A;
  8849. t['Kastrokecyrillic'] = 0x049E;
  8850. t['Kaverticalstrokecyrillic'] = 0x049C;
  8851. t['Kcaron'] = 0x01E8;
  8852. t['Kcedilla'] = 0x0136;
  8853. t['Kcircle'] = 0x24C0;
  8854. t['Kcommaaccent'] = 0x0136;
  8855. t['Kdotbelow'] = 0x1E32;
  8856. t['Keharmenian'] = 0x0554;
  8857. t['Kenarmenian'] = 0x053F;
  8858. t['Khacyrillic'] = 0x0425;
  8859. t['Kheicoptic'] = 0x03E6;
  8860. t['Khook'] = 0x0198;
  8861. t['Kjecyrillic'] = 0x040C;
  8862. t['Klinebelow'] = 0x1E34;
  8863. t['Kmonospace'] = 0xFF2B;
  8864. t['Koppacyrillic'] = 0x0480;
  8865. t['Koppagreek'] = 0x03DE;
  8866. t['Ksicyrillic'] = 0x046E;
  8867. t['Ksmall'] = 0xF76B;
  8868. t['L'] = 0x004C;
  8869. t['LJ'] = 0x01C7;
  8870. t['LL'] = 0xF6BF;
  8871. t['Lacute'] = 0x0139;
  8872. t['Lambda'] = 0x039B;
  8873. t['Lcaron'] = 0x013D;
  8874. t['Lcedilla'] = 0x013B;
  8875. t['Lcircle'] = 0x24C1;
  8876. t['Lcircumflexbelow'] = 0x1E3C;
  8877. t['Lcommaaccent'] = 0x013B;
  8878. t['Ldot'] = 0x013F;
  8879. t['Ldotaccent'] = 0x013F;
  8880. t['Ldotbelow'] = 0x1E36;
  8881. t['Ldotbelowmacron'] = 0x1E38;
  8882. t['Liwnarmenian'] = 0x053C;
  8883. t['Lj'] = 0x01C8;
  8884. t['Ljecyrillic'] = 0x0409;
  8885. t['Llinebelow'] = 0x1E3A;
  8886. t['Lmonospace'] = 0xFF2C;
  8887. t['Lslash'] = 0x0141;
  8888. t['Lslashsmall'] = 0xF6F9;
  8889. t['Lsmall'] = 0xF76C;
  8890. t['M'] = 0x004D;
  8891. t['MBsquare'] = 0x3386;
  8892. t['Macron'] = 0xF6D0;
  8893. t['Macronsmall'] = 0xF7AF;
  8894. t['Macute'] = 0x1E3E;
  8895. t['Mcircle'] = 0x24C2;
  8896. t['Mdotaccent'] = 0x1E40;
  8897. t['Mdotbelow'] = 0x1E42;
  8898. t['Menarmenian'] = 0x0544;
  8899. t['Mmonospace'] = 0xFF2D;
  8900. t['Msmall'] = 0xF76D;
  8901. t['Mturned'] = 0x019C;
  8902. t['Mu'] = 0x039C;
  8903. t['N'] = 0x004E;
  8904. t['NJ'] = 0x01CA;
  8905. t['Nacute'] = 0x0143;
  8906. t['Ncaron'] = 0x0147;
  8907. t['Ncedilla'] = 0x0145;
  8908. t['Ncircle'] = 0x24C3;
  8909. t['Ncircumflexbelow'] = 0x1E4A;
  8910. t['Ncommaaccent'] = 0x0145;
  8911. t['Ndotaccent'] = 0x1E44;
  8912. t['Ndotbelow'] = 0x1E46;
  8913. t['Nhookleft'] = 0x019D;
  8914. t['Nineroman'] = 0x2168;
  8915. t['Nj'] = 0x01CB;
  8916. t['Njecyrillic'] = 0x040A;
  8917. t['Nlinebelow'] = 0x1E48;
  8918. t['Nmonospace'] = 0xFF2E;
  8919. t['Nowarmenian'] = 0x0546;
  8920. t['Nsmall'] = 0xF76E;
  8921. t['Ntilde'] = 0x00D1;
  8922. t['Ntildesmall'] = 0xF7F1;
  8923. t['Nu'] = 0x039D;
  8924. t['O'] = 0x004F;
  8925. t['OE'] = 0x0152;
  8926. t['OEsmall'] = 0xF6FA;
  8927. t['Oacute'] = 0x00D3;
  8928. t['Oacutesmall'] = 0xF7F3;
  8929. t['Obarredcyrillic'] = 0x04E8;
  8930. t['Obarreddieresiscyrillic'] = 0x04EA;
  8931. t['Obreve'] = 0x014E;
  8932. t['Ocaron'] = 0x01D1;
  8933. t['Ocenteredtilde'] = 0x019F;
  8934. t['Ocircle'] = 0x24C4;
  8935. t['Ocircumflex'] = 0x00D4;
  8936. t['Ocircumflexacute'] = 0x1ED0;
  8937. t['Ocircumflexdotbelow'] = 0x1ED8;
  8938. t['Ocircumflexgrave'] = 0x1ED2;
  8939. t['Ocircumflexhookabove'] = 0x1ED4;
  8940. t['Ocircumflexsmall'] = 0xF7F4;
  8941. t['Ocircumflextilde'] = 0x1ED6;
  8942. t['Ocyrillic'] = 0x041E;
  8943. t['Odblacute'] = 0x0150;
  8944. t['Odblgrave'] = 0x020C;
  8945. t['Odieresis'] = 0x00D6;
  8946. t['Odieresiscyrillic'] = 0x04E6;
  8947. t['Odieresissmall'] = 0xF7F6;
  8948. t['Odotbelow'] = 0x1ECC;
  8949. t['Ogoneksmall'] = 0xF6FB;
  8950. t['Ograve'] = 0x00D2;
  8951. t['Ogravesmall'] = 0xF7F2;
  8952. t['Oharmenian'] = 0x0555;
  8953. t['Ohm'] = 0x2126;
  8954. t['Ohookabove'] = 0x1ECE;
  8955. t['Ohorn'] = 0x01A0;
  8956. t['Ohornacute'] = 0x1EDA;
  8957. t['Ohorndotbelow'] = 0x1EE2;
  8958. t['Ohorngrave'] = 0x1EDC;
  8959. t['Ohornhookabove'] = 0x1EDE;
  8960. t['Ohorntilde'] = 0x1EE0;
  8961. t['Ohungarumlaut'] = 0x0150;
  8962. t['Oi'] = 0x01A2;
  8963. t['Oinvertedbreve'] = 0x020E;
  8964. t['Omacron'] = 0x014C;
  8965. t['Omacronacute'] = 0x1E52;
  8966. t['Omacrongrave'] = 0x1E50;
  8967. t['Omega'] = 0x2126;
  8968. t['Omegacyrillic'] = 0x0460;
  8969. t['Omegagreek'] = 0x03A9;
  8970. t['Omegaroundcyrillic'] = 0x047A;
  8971. t['Omegatitlocyrillic'] = 0x047C;
  8972. t['Omegatonos'] = 0x038F;
  8973. t['Omicron'] = 0x039F;
  8974. t['Omicrontonos'] = 0x038C;
  8975. t['Omonospace'] = 0xFF2F;
  8976. t['Oneroman'] = 0x2160;
  8977. t['Oogonek'] = 0x01EA;
  8978. t['Oogonekmacron'] = 0x01EC;
  8979. t['Oopen'] = 0x0186;
  8980. t['Oslash'] = 0x00D8;
  8981. t['Oslashacute'] = 0x01FE;
  8982. t['Oslashsmall'] = 0xF7F8;
  8983. t['Osmall'] = 0xF76F;
  8984. t['Ostrokeacute'] = 0x01FE;
  8985. t['Otcyrillic'] = 0x047E;
  8986. t['Otilde'] = 0x00D5;
  8987. t['Otildeacute'] = 0x1E4C;
  8988. t['Otildedieresis'] = 0x1E4E;
  8989. t['Otildesmall'] = 0xF7F5;
  8990. t['P'] = 0x0050;
  8991. t['Pacute'] = 0x1E54;
  8992. t['Pcircle'] = 0x24C5;
  8993. t['Pdotaccent'] = 0x1E56;
  8994. t['Pecyrillic'] = 0x041F;
  8995. t['Peharmenian'] = 0x054A;
  8996. t['Pemiddlehookcyrillic'] = 0x04A6;
  8997. t['Phi'] = 0x03A6;
  8998. t['Phook'] = 0x01A4;
  8999. t['Pi'] = 0x03A0;
  9000. t['Piwrarmenian'] = 0x0553;
  9001. t['Pmonospace'] = 0xFF30;
  9002. t['Psi'] = 0x03A8;
  9003. t['Psicyrillic'] = 0x0470;
  9004. t['Psmall'] = 0xF770;
  9005. t['Q'] = 0x0051;
  9006. t['Qcircle'] = 0x24C6;
  9007. t['Qmonospace'] = 0xFF31;
  9008. t['Qsmall'] = 0xF771;
  9009. t['R'] = 0x0052;
  9010. t['Raarmenian'] = 0x054C;
  9011. t['Racute'] = 0x0154;
  9012. t['Rcaron'] = 0x0158;
  9013. t['Rcedilla'] = 0x0156;
  9014. t['Rcircle'] = 0x24C7;
  9015. t['Rcommaaccent'] = 0x0156;
  9016. t['Rdblgrave'] = 0x0210;
  9017. t['Rdotaccent'] = 0x1E58;
  9018. t['Rdotbelow'] = 0x1E5A;
  9019. t['Rdotbelowmacron'] = 0x1E5C;
  9020. t['Reharmenian'] = 0x0550;
  9021. t['Rfraktur'] = 0x211C;
  9022. t['Rho'] = 0x03A1;
  9023. t['Ringsmall'] = 0xF6FC;
  9024. t['Rinvertedbreve'] = 0x0212;
  9025. t['Rlinebelow'] = 0x1E5E;
  9026. t['Rmonospace'] = 0xFF32;
  9027. t['Rsmall'] = 0xF772;
  9028. t['Rsmallinverted'] = 0x0281;
  9029. t['Rsmallinvertedsuperior'] = 0x02B6;
  9030. t['S'] = 0x0053;
  9031. t['SF010000'] = 0x250C;
  9032. t['SF020000'] = 0x2514;
  9033. t['SF030000'] = 0x2510;
  9034. t['SF040000'] = 0x2518;
  9035. t['SF050000'] = 0x253C;
  9036. t['SF060000'] = 0x252C;
  9037. t['SF070000'] = 0x2534;
  9038. t['SF080000'] = 0x251C;
  9039. t['SF090000'] = 0x2524;
  9040. t['SF100000'] = 0x2500;
  9041. t['SF110000'] = 0x2502;
  9042. t['SF190000'] = 0x2561;
  9043. t['SF200000'] = 0x2562;
  9044. t['SF210000'] = 0x2556;
  9045. t['SF220000'] = 0x2555;
  9046. t['SF230000'] = 0x2563;
  9047. t['SF240000'] = 0x2551;
  9048. t['SF250000'] = 0x2557;
  9049. t['SF260000'] = 0x255D;
  9050. t['SF270000'] = 0x255C;
  9051. t['SF280000'] = 0x255B;
  9052. t['SF360000'] = 0x255E;
  9053. t['SF370000'] = 0x255F;
  9054. t['SF380000'] = 0x255A;
  9055. t['SF390000'] = 0x2554;
  9056. t['SF400000'] = 0x2569;
  9057. t['SF410000'] = 0x2566;
  9058. t['SF420000'] = 0x2560;
  9059. t['SF430000'] = 0x2550;
  9060. t['SF440000'] = 0x256C;
  9061. t['SF450000'] = 0x2567;
  9062. t['SF460000'] = 0x2568;
  9063. t['SF470000'] = 0x2564;
  9064. t['SF480000'] = 0x2565;
  9065. t['SF490000'] = 0x2559;
  9066. t['SF500000'] = 0x2558;
  9067. t['SF510000'] = 0x2552;
  9068. t['SF520000'] = 0x2553;
  9069. t['SF530000'] = 0x256B;
  9070. t['SF540000'] = 0x256A;
  9071. t['Sacute'] = 0x015A;
  9072. t['Sacutedotaccent'] = 0x1E64;
  9073. t['Sampigreek'] = 0x03E0;
  9074. t['Scaron'] = 0x0160;
  9075. t['Scarondotaccent'] = 0x1E66;
  9076. t['Scaronsmall'] = 0xF6FD;
  9077. t['Scedilla'] = 0x015E;
  9078. t['Schwa'] = 0x018F;
  9079. t['Schwacyrillic'] = 0x04D8;
  9080. t['Schwadieresiscyrillic'] = 0x04DA;
  9081. t['Scircle'] = 0x24C8;
  9082. t['Scircumflex'] = 0x015C;
  9083. t['Scommaaccent'] = 0x0218;
  9084. t['Sdotaccent'] = 0x1E60;
  9085. t['Sdotbelow'] = 0x1E62;
  9086. t['Sdotbelowdotaccent'] = 0x1E68;
  9087. t['Seharmenian'] = 0x054D;
  9088. t['Sevenroman'] = 0x2166;
  9089. t['Shaarmenian'] = 0x0547;
  9090. t['Shacyrillic'] = 0x0428;
  9091. t['Shchacyrillic'] = 0x0429;
  9092. t['Sheicoptic'] = 0x03E2;
  9093. t['Shhacyrillic'] = 0x04BA;
  9094. t['Shimacoptic'] = 0x03EC;
  9095. t['Sigma'] = 0x03A3;
  9096. t['Sixroman'] = 0x2165;
  9097. t['Smonospace'] = 0xFF33;
  9098. t['Softsigncyrillic'] = 0x042C;
  9099. t['Ssmall'] = 0xF773;
  9100. t['Stigmagreek'] = 0x03DA;
  9101. t['T'] = 0x0054;
  9102. t['Tau'] = 0x03A4;
  9103. t['Tbar'] = 0x0166;
  9104. t['Tcaron'] = 0x0164;
  9105. t['Tcedilla'] = 0x0162;
  9106. t['Tcircle'] = 0x24C9;
  9107. t['Tcircumflexbelow'] = 0x1E70;
  9108. t['Tcommaaccent'] = 0x0162;
  9109. t['Tdotaccent'] = 0x1E6A;
  9110. t['Tdotbelow'] = 0x1E6C;
  9111. t['Tecyrillic'] = 0x0422;
  9112. t['Tedescendercyrillic'] = 0x04AC;
  9113. t['Tenroman'] = 0x2169;
  9114. t['Tetsecyrillic'] = 0x04B4;
  9115. t['Theta'] = 0x0398;
  9116. t['Thook'] = 0x01AC;
  9117. t['Thorn'] = 0x00DE;
  9118. t['Thornsmall'] = 0xF7FE;
  9119. t['Threeroman'] = 0x2162;
  9120. t['Tildesmall'] = 0xF6FE;
  9121. t['Tiwnarmenian'] = 0x054F;
  9122. t['Tlinebelow'] = 0x1E6E;
  9123. t['Tmonospace'] = 0xFF34;
  9124. t['Toarmenian'] = 0x0539;
  9125. t['Tonefive'] = 0x01BC;
  9126. t['Tonesix'] = 0x0184;
  9127. t['Tonetwo'] = 0x01A7;
  9128. t['Tretroflexhook'] = 0x01AE;
  9129. t['Tsecyrillic'] = 0x0426;
  9130. t['Tshecyrillic'] = 0x040B;
  9131. t['Tsmall'] = 0xF774;
  9132. t['Twelveroman'] = 0x216B;
  9133. t['Tworoman'] = 0x2161;
  9134. t['U'] = 0x0055;
  9135. t['Uacute'] = 0x00DA;
  9136. t['Uacutesmall'] = 0xF7FA;
  9137. t['Ubreve'] = 0x016C;
  9138. t['Ucaron'] = 0x01D3;
  9139. t['Ucircle'] = 0x24CA;
  9140. t['Ucircumflex'] = 0x00DB;
  9141. t['Ucircumflexbelow'] = 0x1E76;
  9142. t['Ucircumflexsmall'] = 0xF7FB;
  9143. t['Ucyrillic'] = 0x0423;
  9144. t['Udblacute'] = 0x0170;
  9145. t['Udblgrave'] = 0x0214;
  9146. t['Udieresis'] = 0x00DC;
  9147. t['Udieresisacute'] = 0x01D7;
  9148. t['Udieresisbelow'] = 0x1E72;
  9149. t['Udieresiscaron'] = 0x01D9;
  9150. t['Udieresiscyrillic'] = 0x04F0;
  9151. t['Udieresisgrave'] = 0x01DB;
  9152. t['Udieresismacron'] = 0x01D5;
  9153. t['Udieresissmall'] = 0xF7FC;
  9154. t['Udotbelow'] = 0x1EE4;
  9155. t['Ugrave'] = 0x00D9;
  9156. t['Ugravesmall'] = 0xF7F9;
  9157. t['Uhookabove'] = 0x1EE6;
  9158. t['Uhorn'] = 0x01AF;
  9159. t['Uhornacute'] = 0x1EE8;
  9160. t['Uhorndotbelow'] = 0x1EF0;
  9161. t['Uhorngrave'] = 0x1EEA;
  9162. t['Uhornhookabove'] = 0x1EEC;
  9163. t['Uhorntilde'] = 0x1EEE;
  9164. t['Uhungarumlaut'] = 0x0170;
  9165. t['Uhungarumlautcyrillic'] = 0x04F2;
  9166. t['Uinvertedbreve'] = 0x0216;
  9167. t['Ukcyrillic'] = 0x0478;
  9168. t['Umacron'] = 0x016A;
  9169. t['Umacroncyrillic'] = 0x04EE;
  9170. t['Umacrondieresis'] = 0x1E7A;
  9171. t['Umonospace'] = 0xFF35;
  9172. t['Uogonek'] = 0x0172;
  9173. t['Upsilon'] = 0x03A5;
  9174. t['Upsilon1'] = 0x03D2;
  9175. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9176. t['Upsilonafrican'] = 0x01B1;
  9177. t['Upsilondieresis'] = 0x03AB;
  9178. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9179. t['Upsilonhooksymbol'] = 0x03D2;
  9180. t['Upsilontonos'] = 0x038E;
  9181. t['Uring'] = 0x016E;
  9182. t['Ushortcyrillic'] = 0x040E;
  9183. t['Usmall'] = 0xF775;
  9184. t['Ustraightcyrillic'] = 0x04AE;
  9185. t['Ustraightstrokecyrillic'] = 0x04B0;
  9186. t['Utilde'] = 0x0168;
  9187. t['Utildeacute'] = 0x1E78;
  9188. t['Utildebelow'] = 0x1E74;
  9189. t['V'] = 0x0056;
  9190. t['Vcircle'] = 0x24CB;
  9191. t['Vdotbelow'] = 0x1E7E;
  9192. t['Vecyrillic'] = 0x0412;
  9193. t['Vewarmenian'] = 0x054E;
  9194. t['Vhook'] = 0x01B2;
  9195. t['Vmonospace'] = 0xFF36;
  9196. t['Voarmenian'] = 0x0548;
  9197. t['Vsmall'] = 0xF776;
  9198. t['Vtilde'] = 0x1E7C;
  9199. t['W'] = 0x0057;
  9200. t['Wacute'] = 0x1E82;
  9201. t['Wcircle'] = 0x24CC;
  9202. t['Wcircumflex'] = 0x0174;
  9203. t['Wdieresis'] = 0x1E84;
  9204. t['Wdotaccent'] = 0x1E86;
  9205. t['Wdotbelow'] = 0x1E88;
  9206. t['Wgrave'] = 0x1E80;
  9207. t['Wmonospace'] = 0xFF37;
  9208. t['Wsmall'] = 0xF777;
  9209. t['X'] = 0x0058;
  9210. t['Xcircle'] = 0x24CD;
  9211. t['Xdieresis'] = 0x1E8C;
  9212. t['Xdotaccent'] = 0x1E8A;
  9213. t['Xeharmenian'] = 0x053D;
  9214. t['Xi'] = 0x039E;
  9215. t['Xmonospace'] = 0xFF38;
  9216. t['Xsmall'] = 0xF778;
  9217. t['Y'] = 0x0059;
  9218. t['Yacute'] = 0x00DD;
  9219. t['Yacutesmall'] = 0xF7FD;
  9220. t['Yatcyrillic'] = 0x0462;
  9221. t['Ycircle'] = 0x24CE;
  9222. t['Ycircumflex'] = 0x0176;
  9223. t['Ydieresis'] = 0x0178;
  9224. t['Ydieresissmall'] = 0xF7FF;
  9225. t['Ydotaccent'] = 0x1E8E;
  9226. t['Ydotbelow'] = 0x1EF4;
  9227. t['Yericyrillic'] = 0x042B;
  9228. t['Yerudieresiscyrillic'] = 0x04F8;
  9229. t['Ygrave'] = 0x1EF2;
  9230. t['Yhook'] = 0x01B3;
  9231. t['Yhookabove'] = 0x1EF6;
  9232. t['Yiarmenian'] = 0x0545;
  9233. t['Yicyrillic'] = 0x0407;
  9234. t['Yiwnarmenian'] = 0x0552;
  9235. t['Ymonospace'] = 0xFF39;
  9236. t['Ysmall'] = 0xF779;
  9237. t['Ytilde'] = 0x1EF8;
  9238. t['Yusbigcyrillic'] = 0x046A;
  9239. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9240. t['Yuslittlecyrillic'] = 0x0466;
  9241. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9242. t['Z'] = 0x005A;
  9243. t['Zaarmenian'] = 0x0536;
  9244. t['Zacute'] = 0x0179;
  9245. t['Zcaron'] = 0x017D;
  9246. t['Zcaronsmall'] = 0xF6FF;
  9247. t['Zcircle'] = 0x24CF;
  9248. t['Zcircumflex'] = 0x1E90;
  9249. t['Zdot'] = 0x017B;
  9250. t['Zdotaccent'] = 0x017B;
  9251. t['Zdotbelow'] = 0x1E92;
  9252. t['Zecyrillic'] = 0x0417;
  9253. t['Zedescendercyrillic'] = 0x0498;
  9254. t['Zedieresiscyrillic'] = 0x04DE;
  9255. t['Zeta'] = 0x0396;
  9256. t['Zhearmenian'] = 0x053A;
  9257. t['Zhebrevecyrillic'] = 0x04C1;
  9258. t['Zhecyrillic'] = 0x0416;
  9259. t['Zhedescendercyrillic'] = 0x0496;
  9260. t['Zhedieresiscyrillic'] = 0x04DC;
  9261. t['Zlinebelow'] = 0x1E94;
  9262. t['Zmonospace'] = 0xFF3A;
  9263. t['Zsmall'] = 0xF77A;
  9264. t['Zstroke'] = 0x01B5;
  9265. t['a'] = 0x0061;
  9266. t['aabengali'] = 0x0986;
  9267. t['aacute'] = 0x00E1;
  9268. t['aadeva'] = 0x0906;
  9269. t['aagujarati'] = 0x0A86;
  9270. t['aagurmukhi'] = 0x0A06;
  9271. t['aamatragurmukhi'] = 0x0A3E;
  9272. t['aarusquare'] = 0x3303;
  9273. t['aavowelsignbengali'] = 0x09BE;
  9274. t['aavowelsigndeva'] = 0x093E;
  9275. t['aavowelsigngujarati'] = 0x0ABE;
  9276. t['abbreviationmarkarmenian'] = 0x055F;
  9277. t['abbreviationsigndeva'] = 0x0970;
  9278. t['abengali'] = 0x0985;
  9279. t['abopomofo'] = 0x311A;
  9280. t['abreve'] = 0x0103;
  9281. t['abreveacute'] = 0x1EAF;
  9282. t['abrevecyrillic'] = 0x04D1;
  9283. t['abrevedotbelow'] = 0x1EB7;
  9284. t['abrevegrave'] = 0x1EB1;
  9285. t['abrevehookabove'] = 0x1EB3;
  9286. t['abrevetilde'] = 0x1EB5;
  9287. t['acaron'] = 0x01CE;
  9288. t['acircle'] = 0x24D0;
  9289. t['acircumflex'] = 0x00E2;
  9290. t['acircumflexacute'] = 0x1EA5;
  9291. t['acircumflexdotbelow'] = 0x1EAD;
  9292. t['acircumflexgrave'] = 0x1EA7;
  9293. t['acircumflexhookabove'] = 0x1EA9;
  9294. t['acircumflextilde'] = 0x1EAB;
  9295. t['acute'] = 0x00B4;
  9296. t['acutebelowcmb'] = 0x0317;
  9297. t['acutecmb'] = 0x0301;
  9298. t['acutecomb'] = 0x0301;
  9299. t['acutedeva'] = 0x0954;
  9300. t['acutelowmod'] = 0x02CF;
  9301. t['acutetonecmb'] = 0x0341;
  9302. t['acyrillic'] = 0x0430;
  9303. t['adblgrave'] = 0x0201;
  9304. t['addakgurmukhi'] = 0x0A71;
  9305. t['adeva'] = 0x0905;
  9306. t['adieresis'] = 0x00E4;
  9307. t['adieresiscyrillic'] = 0x04D3;
  9308. t['adieresismacron'] = 0x01DF;
  9309. t['adotbelow'] = 0x1EA1;
  9310. t['adotmacron'] = 0x01E1;
  9311. t['ae'] = 0x00E6;
  9312. t['aeacute'] = 0x01FD;
  9313. t['aekorean'] = 0x3150;
  9314. t['aemacron'] = 0x01E3;
  9315. t['afii00208'] = 0x2015;
  9316. t['afii08941'] = 0x20A4;
  9317. t['afii10017'] = 0x0410;
  9318. t['afii10018'] = 0x0411;
  9319. t['afii10019'] = 0x0412;
  9320. t['afii10020'] = 0x0413;
  9321. t['afii10021'] = 0x0414;
  9322. t['afii10022'] = 0x0415;
  9323. t['afii10023'] = 0x0401;
  9324. t['afii10024'] = 0x0416;
  9325. t['afii10025'] = 0x0417;
  9326. t['afii10026'] = 0x0418;
  9327. t['afii10027'] = 0x0419;
  9328. t['afii10028'] = 0x041A;
  9329. t['afii10029'] = 0x041B;
  9330. t['afii10030'] = 0x041C;
  9331. t['afii10031'] = 0x041D;
  9332. t['afii10032'] = 0x041E;
  9333. t['afii10033'] = 0x041F;
  9334. t['afii10034'] = 0x0420;
  9335. t['afii10035'] = 0x0421;
  9336. t['afii10036'] = 0x0422;
  9337. t['afii10037'] = 0x0423;
  9338. t['afii10038'] = 0x0424;
  9339. t['afii10039'] = 0x0425;
  9340. t['afii10040'] = 0x0426;
  9341. t['afii10041'] = 0x0427;
  9342. t['afii10042'] = 0x0428;
  9343. t['afii10043'] = 0x0429;
  9344. t['afii10044'] = 0x042A;
  9345. t['afii10045'] = 0x042B;
  9346. t['afii10046'] = 0x042C;
  9347. t['afii10047'] = 0x042D;
  9348. t['afii10048'] = 0x042E;
  9349. t['afii10049'] = 0x042F;
  9350. t['afii10050'] = 0x0490;
  9351. t['afii10051'] = 0x0402;
  9352. t['afii10052'] = 0x0403;
  9353. t['afii10053'] = 0x0404;
  9354. t['afii10054'] = 0x0405;
  9355. t['afii10055'] = 0x0406;
  9356. t['afii10056'] = 0x0407;
  9357. t['afii10057'] = 0x0408;
  9358. t['afii10058'] = 0x0409;
  9359. t['afii10059'] = 0x040A;
  9360. t['afii10060'] = 0x040B;
  9361. t['afii10061'] = 0x040C;
  9362. t['afii10062'] = 0x040E;
  9363. t['afii10063'] = 0xF6C4;
  9364. t['afii10064'] = 0xF6C5;
  9365. t['afii10065'] = 0x0430;
  9366. t['afii10066'] = 0x0431;
  9367. t['afii10067'] = 0x0432;
  9368. t['afii10068'] = 0x0433;
  9369. t['afii10069'] = 0x0434;
  9370. t['afii10070'] = 0x0435;
  9371. t['afii10071'] = 0x0451;
  9372. t['afii10072'] = 0x0436;
  9373. t['afii10073'] = 0x0437;
  9374. t['afii10074'] = 0x0438;
  9375. t['afii10075'] = 0x0439;
  9376. t['afii10076'] = 0x043A;
  9377. t['afii10077'] = 0x043B;
  9378. t['afii10078'] = 0x043C;
  9379. t['afii10079'] = 0x043D;
  9380. t['afii10080'] = 0x043E;
  9381. t['afii10081'] = 0x043F;
  9382. t['afii10082'] = 0x0440;
  9383. t['afii10083'] = 0x0441;
  9384. t['afii10084'] = 0x0442;
  9385. t['afii10085'] = 0x0443;
  9386. t['afii10086'] = 0x0444;
  9387. t['afii10087'] = 0x0445;
  9388. t['afii10088'] = 0x0446;
  9389. t['afii10089'] = 0x0447;
  9390. t['afii10090'] = 0x0448;
  9391. t['afii10091'] = 0x0449;
  9392. t['afii10092'] = 0x044A;
  9393. t['afii10093'] = 0x044B;
  9394. t['afii10094'] = 0x044C;
  9395. t['afii10095'] = 0x044D;
  9396. t['afii10096'] = 0x044E;
  9397. t['afii10097'] = 0x044F;
  9398. t['afii10098'] = 0x0491;
  9399. t['afii10099'] = 0x0452;
  9400. t['afii10100'] = 0x0453;
  9401. t['afii10101'] = 0x0454;
  9402. t['afii10102'] = 0x0455;
  9403. t['afii10103'] = 0x0456;
  9404. t['afii10104'] = 0x0457;
  9405. t['afii10105'] = 0x0458;
  9406. t['afii10106'] = 0x0459;
  9407. t['afii10107'] = 0x045A;
  9408. t['afii10108'] = 0x045B;
  9409. t['afii10109'] = 0x045C;
  9410. t['afii10110'] = 0x045E;
  9411. t['afii10145'] = 0x040F;
  9412. t['afii10146'] = 0x0462;
  9413. t['afii10147'] = 0x0472;
  9414. t['afii10148'] = 0x0474;
  9415. t['afii10192'] = 0xF6C6;
  9416. t['afii10193'] = 0x045F;
  9417. t['afii10194'] = 0x0463;
  9418. t['afii10195'] = 0x0473;
  9419. t['afii10196'] = 0x0475;
  9420. t['afii10831'] = 0xF6C7;
  9421. t['afii10832'] = 0xF6C8;
  9422. t['afii10846'] = 0x04D9;
  9423. t['afii299'] = 0x200E;
  9424. t['afii300'] = 0x200F;
  9425. t['afii301'] = 0x200D;
  9426. t['afii57381'] = 0x066A;
  9427. t['afii57388'] = 0x060C;
  9428. t['afii57392'] = 0x0660;
  9429. t['afii57393'] = 0x0661;
  9430. t['afii57394'] = 0x0662;
  9431. t['afii57395'] = 0x0663;
  9432. t['afii57396'] = 0x0664;
  9433. t['afii57397'] = 0x0665;
  9434. t['afii57398'] = 0x0666;
  9435. t['afii57399'] = 0x0667;
  9436. t['afii57400'] = 0x0668;
  9437. t['afii57401'] = 0x0669;
  9438. t['afii57403'] = 0x061B;
  9439. t['afii57407'] = 0x061F;
  9440. t['afii57409'] = 0x0621;
  9441. t['afii57410'] = 0x0622;
  9442. t['afii57411'] = 0x0623;
  9443. t['afii57412'] = 0x0624;
  9444. t['afii57413'] = 0x0625;
  9445. t['afii57414'] = 0x0626;
  9446. t['afii57415'] = 0x0627;
  9447. t['afii57416'] = 0x0628;
  9448. t['afii57417'] = 0x0629;
  9449. t['afii57418'] = 0x062A;
  9450. t['afii57419'] = 0x062B;
  9451. t['afii57420'] = 0x062C;
  9452. t['afii57421'] = 0x062D;
  9453. t['afii57422'] = 0x062E;
  9454. t['afii57423'] = 0x062F;
  9455. t['afii57424'] = 0x0630;
  9456. t['afii57425'] = 0x0631;
  9457. t['afii57426'] = 0x0632;
  9458. t['afii57427'] = 0x0633;
  9459. t['afii57428'] = 0x0634;
  9460. t['afii57429'] = 0x0635;
  9461. t['afii57430'] = 0x0636;
  9462. t['afii57431'] = 0x0637;
  9463. t['afii57432'] = 0x0638;
  9464. t['afii57433'] = 0x0639;
  9465. t['afii57434'] = 0x063A;
  9466. t['afii57440'] = 0x0640;
  9467. t['afii57441'] = 0x0641;
  9468. t['afii57442'] = 0x0642;
  9469. t['afii57443'] = 0x0643;
  9470. t['afii57444'] = 0x0644;
  9471. t['afii57445'] = 0x0645;
  9472. t['afii57446'] = 0x0646;
  9473. t['afii57448'] = 0x0648;
  9474. t['afii57449'] = 0x0649;
  9475. t['afii57450'] = 0x064A;
  9476. t['afii57451'] = 0x064B;
  9477. t['afii57452'] = 0x064C;
  9478. t['afii57453'] = 0x064D;
  9479. t['afii57454'] = 0x064E;
  9480. t['afii57455'] = 0x064F;
  9481. t['afii57456'] = 0x0650;
  9482. t['afii57457'] = 0x0651;
  9483. t['afii57458'] = 0x0652;
  9484. t['afii57470'] = 0x0647;
  9485. t['afii57505'] = 0x06A4;
  9486. t['afii57506'] = 0x067E;
  9487. t['afii57507'] = 0x0686;
  9488. t['afii57508'] = 0x0698;
  9489. t['afii57509'] = 0x06AF;
  9490. t['afii57511'] = 0x0679;
  9491. t['afii57512'] = 0x0688;
  9492. t['afii57513'] = 0x0691;
  9493. t['afii57514'] = 0x06BA;
  9494. t['afii57519'] = 0x06D2;
  9495. t['afii57534'] = 0x06D5;
  9496. t['afii57636'] = 0x20AA;
  9497. t['afii57645'] = 0x05BE;
  9498. t['afii57658'] = 0x05C3;
  9499. t['afii57664'] = 0x05D0;
  9500. t['afii57665'] = 0x05D1;
  9501. t['afii57666'] = 0x05D2;
  9502. t['afii57667'] = 0x05D3;
  9503. t['afii57668'] = 0x05D4;
  9504. t['afii57669'] = 0x05D5;
  9505. t['afii57670'] = 0x05D6;
  9506. t['afii57671'] = 0x05D7;
  9507. t['afii57672'] = 0x05D8;
  9508. t['afii57673'] = 0x05D9;
  9509. t['afii57674'] = 0x05DA;
  9510. t['afii57675'] = 0x05DB;
  9511. t['afii57676'] = 0x05DC;
  9512. t['afii57677'] = 0x05DD;
  9513. t['afii57678'] = 0x05DE;
  9514. t['afii57679'] = 0x05DF;
  9515. t['afii57680'] = 0x05E0;
  9516. t['afii57681'] = 0x05E1;
  9517. t['afii57682'] = 0x05E2;
  9518. t['afii57683'] = 0x05E3;
  9519. t['afii57684'] = 0x05E4;
  9520. t['afii57685'] = 0x05E5;
  9521. t['afii57686'] = 0x05E6;
  9522. t['afii57687'] = 0x05E7;
  9523. t['afii57688'] = 0x05E8;
  9524. t['afii57689'] = 0x05E9;
  9525. t['afii57690'] = 0x05EA;
  9526. t['afii57694'] = 0xFB2A;
  9527. t['afii57695'] = 0xFB2B;
  9528. t['afii57700'] = 0xFB4B;
  9529. t['afii57705'] = 0xFB1F;
  9530. t['afii57716'] = 0x05F0;
  9531. t['afii57717'] = 0x05F1;
  9532. t['afii57718'] = 0x05F2;
  9533. t['afii57723'] = 0xFB35;
  9534. t['afii57793'] = 0x05B4;
  9535. t['afii57794'] = 0x05B5;
  9536. t['afii57795'] = 0x05B6;
  9537. t['afii57796'] = 0x05BB;
  9538. t['afii57797'] = 0x05B8;
  9539. t['afii57798'] = 0x05B7;
  9540. t['afii57799'] = 0x05B0;
  9541. t['afii57800'] = 0x05B2;
  9542. t['afii57801'] = 0x05B1;
  9543. t['afii57802'] = 0x05B3;
  9544. t['afii57803'] = 0x05C2;
  9545. t['afii57804'] = 0x05C1;
  9546. t['afii57806'] = 0x05B9;
  9547. t['afii57807'] = 0x05BC;
  9548. t['afii57839'] = 0x05BD;
  9549. t['afii57841'] = 0x05BF;
  9550. t['afii57842'] = 0x05C0;
  9551. t['afii57929'] = 0x02BC;
  9552. t['afii61248'] = 0x2105;
  9553. t['afii61289'] = 0x2113;
  9554. t['afii61352'] = 0x2116;
  9555. t['afii61573'] = 0x202C;
  9556. t['afii61574'] = 0x202D;
  9557. t['afii61575'] = 0x202E;
  9558. t['afii61664'] = 0x200C;
  9559. t['afii63167'] = 0x066D;
  9560. t['afii64937'] = 0x02BD;
  9561. t['agrave'] = 0x00E0;
  9562. t['agujarati'] = 0x0A85;
  9563. t['agurmukhi'] = 0x0A05;
  9564. t['ahiragana'] = 0x3042;
  9565. t['ahookabove'] = 0x1EA3;
  9566. t['aibengali'] = 0x0990;
  9567. t['aibopomofo'] = 0x311E;
  9568. t['aideva'] = 0x0910;
  9569. t['aiecyrillic'] = 0x04D5;
  9570. t['aigujarati'] = 0x0A90;
  9571. t['aigurmukhi'] = 0x0A10;
  9572. t['aimatragurmukhi'] = 0x0A48;
  9573. t['ainarabic'] = 0x0639;
  9574. t['ainfinalarabic'] = 0xFECA;
  9575. t['aininitialarabic'] = 0xFECB;
  9576. t['ainmedialarabic'] = 0xFECC;
  9577. t['ainvertedbreve'] = 0x0203;
  9578. t['aivowelsignbengali'] = 0x09C8;
  9579. t['aivowelsigndeva'] = 0x0948;
  9580. t['aivowelsigngujarati'] = 0x0AC8;
  9581. t['akatakana'] = 0x30A2;
  9582. t['akatakanahalfwidth'] = 0xFF71;
  9583. t['akorean'] = 0x314F;
  9584. t['alef'] = 0x05D0;
  9585. t['alefarabic'] = 0x0627;
  9586. t['alefdageshhebrew'] = 0xFB30;
  9587. t['aleffinalarabic'] = 0xFE8E;
  9588. t['alefhamzaabovearabic'] = 0x0623;
  9589. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9590. t['alefhamzabelowarabic'] = 0x0625;
  9591. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9592. t['alefhebrew'] = 0x05D0;
  9593. t['aleflamedhebrew'] = 0xFB4F;
  9594. t['alefmaddaabovearabic'] = 0x0622;
  9595. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9596. t['alefmaksuraarabic'] = 0x0649;
  9597. t['alefmaksurafinalarabic'] = 0xFEF0;
  9598. t['alefmaksurainitialarabic'] = 0xFEF3;
  9599. t['alefmaksuramedialarabic'] = 0xFEF4;
  9600. t['alefpatahhebrew'] = 0xFB2E;
  9601. t['alefqamatshebrew'] = 0xFB2F;
  9602. t['aleph'] = 0x2135;
  9603. t['allequal'] = 0x224C;
  9604. t['alpha'] = 0x03B1;
  9605. t['alphatonos'] = 0x03AC;
  9606. t['amacron'] = 0x0101;
  9607. t['amonospace'] = 0xFF41;
  9608. t['ampersand'] = 0x0026;
  9609. t['ampersandmonospace'] = 0xFF06;
  9610. t['ampersandsmall'] = 0xF726;
  9611. t['amsquare'] = 0x33C2;
  9612. t['anbopomofo'] = 0x3122;
  9613. t['angbopomofo'] = 0x3124;
  9614. t['angbracketleft'] = 0x3008;
  9615. t['angbracketright'] = 0x3009;
  9616. t['angkhankhuthai'] = 0x0E5A;
  9617. t['angle'] = 0x2220;
  9618. t['anglebracketleft'] = 0x3008;
  9619. t['anglebracketleftvertical'] = 0xFE3F;
  9620. t['anglebracketright'] = 0x3009;
  9621. t['anglebracketrightvertical'] = 0xFE40;
  9622. t['angleleft'] = 0x2329;
  9623. t['angleright'] = 0x232A;
  9624. t['angstrom'] = 0x212B;
  9625. t['anoteleia'] = 0x0387;
  9626. t['anudattadeva'] = 0x0952;
  9627. t['anusvarabengali'] = 0x0982;
  9628. t['anusvaradeva'] = 0x0902;
  9629. t['anusvaragujarati'] = 0x0A82;
  9630. t['aogonek'] = 0x0105;
  9631. t['apaatosquare'] = 0x3300;
  9632. t['aparen'] = 0x249C;
  9633. t['apostrophearmenian'] = 0x055A;
  9634. t['apostrophemod'] = 0x02BC;
  9635. t['apple'] = 0xF8FF;
  9636. t['approaches'] = 0x2250;
  9637. t['approxequal'] = 0x2248;
  9638. t['approxequalorimage'] = 0x2252;
  9639. t['approximatelyequal'] = 0x2245;
  9640. t['araeaekorean'] = 0x318E;
  9641. t['araeakorean'] = 0x318D;
  9642. t['arc'] = 0x2312;
  9643. t['arighthalfring'] = 0x1E9A;
  9644. t['aring'] = 0x00E5;
  9645. t['aringacute'] = 0x01FB;
  9646. t['aringbelow'] = 0x1E01;
  9647. t['arrowboth'] = 0x2194;
  9648. t['arrowdashdown'] = 0x21E3;
  9649. t['arrowdashleft'] = 0x21E0;
  9650. t['arrowdashright'] = 0x21E2;
  9651. t['arrowdashup'] = 0x21E1;
  9652. t['arrowdblboth'] = 0x21D4;
  9653. t['arrowdbldown'] = 0x21D3;
  9654. t['arrowdblleft'] = 0x21D0;
  9655. t['arrowdblright'] = 0x21D2;
  9656. t['arrowdblup'] = 0x21D1;
  9657. t['arrowdown'] = 0x2193;
  9658. t['arrowdownleft'] = 0x2199;
  9659. t['arrowdownright'] = 0x2198;
  9660. t['arrowdownwhite'] = 0x21E9;
  9661. t['arrowheaddownmod'] = 0x02C5;
  9662. t['arrowheadleftmod'] = 0x02C2;
  9663. t['arrowheadrightmod'] = 0x02C3;
  9664. t['arrowheadupmod'] = 0x02C4;
  9665. t['arrowhorizex'] = 0xF8E7;
  9666. t['arrowleft'] = 0x2190;
  9667. t['arrowleftdbl'] = 0x21D0;
  9668. t['arrowleftdblstroke'] = 0x21CD;
  9669. t['arrowleftoverright'] = 0x21C6;
  9670. t['arrowleftwhite'] = 0x21E6;
  9671. t['arrowright'] = 0x2192;
  9672. t['arrowrightdblstroke'] = 0x21CF;
  9673. t['arrowrightheavy'] = 0x279E;
  9674. t['arrowrightoverleft'] = 0x21C4;
  9675. t['arrowrightwhite'] = 0x21E8;
  9676. t['arrowtableft'] = 0x21E4;
  9677. t['arrowtabright'] = 0x21E5;
  9678. t['arrowup'] = 0x2191;
  9679. t['arrowupdn'] = 0x2195;
  9680. t['arrowupdnbse'] = 0x21A8;
  9681. t['arrowupdownbase'] = 0x21A8;
  9682. t['arrowupleft'] = 0x2196;
  9683. t['arrowupleftofdown'] = 0x21C5;
  9684. t['arrowupright'] = 0x2197;
  9685. t['arrowupwhite'] = 0x21E7;
  9686. t['arrowvertex'] = 0xF8E6;
  9687. t['asciicircum'] = 0x005E;
  9688. t['asciicircummonospace'] = 0xFF3E;
  9689. t['asciitilde'] = 0x007E;
  9690. t['asciitildemonospace'] = 0xFF5E;
  9691. t['ascript'] = 0x0251;
  9692. t['ascriptturned'] = 0x0252;
  9693. t['asmallhiragana'] = 0x3041;
  9694. t['asmallkatakana'] = 0x30A1;
  9695. t['asmallkatakanahalfwidth'] = 0xFF67;
  9696. t['asterisk'] = 0x002A;
  9697. t['asteriskaltonearabic'] = 0x066D;
  9698. t['asteriskarabic'] = 0x066D;
  9699. t['asteriskmath'] = 0x2217;
  9700. t['asteriskmonospace'] = 0xFF0A;
  9701. t['asterisksmall'] = 0xFE61;
  9702. t['asterism'] = 0x2042;
  9703. t['asuperior'] = 0xF6E9;
  9704. t['asymptoticallyequal'] = 0x2243;
  9705. t['at'] = 0x0040;
  9706. t['atilde'] = 0x00E3;
  9707. t['atmonospace'] = 0xFF20;
  9708. t['atsmall'] = 0xFE6B;
  9709. t['aturned'] = 0x0250;
  9710. t['aubengali'] = 0x0994;
  9711. t['aubopomofo'] = 0x3120;
  9712. t['audeva'] = 0x0914;
  9713. t['augujarati'] = 0x0A94;
  9714. t['augurmukhi'] = 0x0A14;
  9715. t['aulengthmarkbengali'] = 0x09D7;
  9716. t['aumatragurmukhi'] = 0x0A4C;
  9717. t['auvowelsignbengali'] = 0x09CC;
  9718. t['auvowelsigndeva'] = 0x094C;
  9719. t['auvowelsigngujarati'] = 0x0ACC;
  9720. t['avagrahadeva'] = 0x093D;
  9721. t['aybarmenian'] = 0x0561;
  9722. t['ayin'] = 0x05E2;
  9723. t['ayinaltonehebrew'] = 0xFB20;
  9724. t['ayinhebrew'] = 0x05E2;
  9725. t['b'] = 0x0062;
  9726. t['babengali'] = 0x09AC;
  9727. t['backslash'] = 0x005C;
  9728. t['backslashmonospace'] = 0xFF3C;
  9729. t['badeva'] = 0x092C;
  9730. t['bagujarati'] = 0x0AAC;
  9731. t['bagurmukhi'] = 0x0A2C;
  9732. t['bahiragana'] = 0x3070;
  9733. t['bahtthai'] = 0x0E3F;
  9734. t['bakatakana'] = 0x30D0;
  9735. t['bar'] = 0x007C;
  9736. t['barmonospace'] = 0xFF5C;
  9737. t['bbopomofo'] = 0x3105;
  9738. t['bcircle'] = 0x24D1;
  9739. t['bdotaccent'] = 0x1E03;
  9740. t['bdotbelow'] = 0x1E05;
  9741. t['beamedsixteenthnotes'] = 0x266C;
  9742. t['because'] = 0x2235;
  9743. t['becyrillic'] = 0x0431;
  9744. t['beharabic'] = 0x0628;
  9745. t['behfinalarabic'] = 0xFE90;
  9746. t['behinitialarabic'] = 0xFE91;
  9747. t['behiragana'] = 0x3079;
  9748. t['behmedialarabic'] = 0xFE92;
  9749. t['behmeeminitialarabic'] = 0xFC9F;
  9750. t['behmeemisolatedarabic'] = 0xFC08;
  9751. t['behnoonfinalarabic'] = 0xFC6D;
  9752. t['bekatakana'] = 0x30D9;
  9753. t['benarmenian'] = 0x0562;
  9754. t['bet'] = 0x05D1;
  9755. t['beta'] = 0x03B2;
  9756. t['betasymbolgreek'] = 0x03D0;
  9757. t['betdagesh'] = 0xFB31;
  9758. t['betdageshhebrew'] = 0xFB31;
  9759. t['bethebrew'] = 0x05D1;
  9760. t['betrafehebrew'] = 0xFB4C;
  9761. t['bhabengali'] = 0x09AD;
  9762. t['bhadeva'] = 0x092D;
  9763. t['bhagujarati'] = 0x0AAD;
  9764. t['bhagurmukhi'] = 0x0A2D;
  9765. t['bhook'] = 0x0253;
  9766. t['bihiragana'] = 0x3073;
  9767. t['bikatakana'] = 0x30D3;
  9768. t['bilabialclick'] = 0x0298;
  9769. t['bindigurmukhi'] = 0x0A02;
  9770. t['birusquare'] = 0x3331;
  9771. t['blackcircle'] = 0x25CF;
  9772. t['blackdiamond'] = 0x25C6;
  9773. t['blackdownpointingtriangle'] = 0x25BC;
  9774. t['blackleftpointingpointer'] = 0x25C4;
  9775. t['blackleftpointingtriangle'] = 0x25C0;
  9776. t['blacklenticularbracketleft'] = 0x3010;
  9777. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9778. t['blacklenticularbracketright'] = 0x3011;
  9779. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9780. t['blacklowerlefttriangle'] = 0x25E3;
  9781. t['blacklowerrighttriangle'] = 0x25E2;
  9782. t['blackrectangle'] = 0x25AC;
  9783. t['blackrightpointingpointer'] = 0x25BA;
  9784. t['blackrightpointingtriangle'] = 0x25B6;
  9785. t['blacksmallsquare'] = 0x25AA;
  9786. t['blacksmilingface'] = 0x263B;
  9787. t['blacksquare'] = 0x25A0;
  9788. t['blackstar'] = 0x2605;
  9789. t['blackupperlefttriangle'] = 0x25E4;
  9790. t['blackupperrighttriangle'] = 0x25E5;
  9791. t['blackuppointingsmalltriangle'] = 0x25B4;
  9792. t['blackuppointingtriangle'] = 0x25B2;
  9793. t['blank'] = 0x2423;
  9794. t['blinebelow'] = 0x1E07;
  9795. t['block'] = 0x2588;
  9796. t['bmonospace'] = 0xFF42;
  9797. t['bobaimaithai'] = 0x0E1A;
  9798. t['bohiragana'] = 0x307C;
  9799. t['bokatakana'] = 0x30DC;
  9800. t['bparen'] = 0x249D;
  9801. t['bqsquare'] = 0x33C3;
  9802. t['braceex'] = 0xF8F4;
  9803. t['braceleft'] = 0x007B;
  9804. t['braceleftbt'] = 0xF8F3;
  9805. t['braceleftmid'] = 0xF8F2;
  9806. t['braceleftmonospace'] = 0xFF5B;
  9807. t['braceleftsmall'] = 0xFE5B;
  9808. t['bracelefttp'] = 0xF8F1;
  9809. t['braceleftvertical'] = 0xFE37;
  9810. t['braceright'] = 0x007D;
  9811. t['bracerightbt'] = 0xF8FE;
  9812. t['bracerightmid'] = 0xF8FD;
  9813. t['bracerightmonospace'] = 0xFF5D;
  9814. t['bracerightsmall'] = 0xFE5C;
  9815. t['bracerighttp'] = 0xF8FC;
  9816. t['bracerightvertical'] = 0xFE38;
  9817. t['bracketleft'] = 0x005B;
  9818. t['bracketleftbt'] = 0xF8F0;
  9819. t['bracketleftex'] = 0xF8EF;
  9820. t['bracketleftmonospace'] = 0xFF3B;
  9821. t['bracketlefttp'] = 0xF8EE;
  9822. t['bracketright'] = 0x005D;
  9823. t['bracketrightbt'] = 0xF8FB;
  9824. t['bracketrightex'] = 0xF8FA;
  9825. t['bracketrightmonospace'] = 0xFF3D;
  9826. t['bracketrighttp'] = 0xF8F9;
  9827. t['breve'] = 0x02D8;
  9828. t['brevebelowcmb'] = 0x032E;
  9829. t['brevecmb'] = 0x0306;
  9830. t['breveinvertedbelowcmb'] = 0x032F;
  9831. t['breveinvertedcmb'] = 0x0311;
  9832. t['breveinverteddoublecmb'] = 0x0361;
  9833. t['bridgebelowcmb'] = 0x032A;
  9834. t['bridgeinvertedbelowcmb'] = 0x033A;
  9835. t['brokenbar'] = 0x00A6;
  9836. t['bstroke'] = 0x0180;
  9837. t['bsuperior'] = 0xF6EA;
  9838. t['btopbar'] = 0x0183;
  9839. t['buhiragana'] = 0x3076;
  9840. t['bukatakana'] = 0x30D6;
  9841. t['bullet'] = 0x2022;
  9842. t['bulletinverse'] = 0x25D8;
  9843. t['bulletoperator'] = 0x2219;
  9844. t['bullseye'] = 0x25CE;
  9845. t['c'] = 0x0063;
  9846. t['caarmenian'] = 0x056E;
  9847. t['cabengali'] = 0x099A;
  9848. t['cacute'] = 0x0107;
  9849. t['cadeva'] = 0x091A;
  9850. t['cagujarati'] = 0x0A9A;
  9851. t['cagurmukhi'] = 0x0A1A;
  9852. t['calsquare'] = 0x3388;
  9853. t['candrabindubengali'] = 0x0981;
  9854. t['candrabinducmb'] = 0x0310;
  9855. t['candrabindudeva'] = 0x0901;
  9856. t['candrabindugujarati'] = 0x0A81;
  9857. t['capslock'] = 0x21EA;
  9858. t['careof'] = 0x2105;
  9859. t['caron'] = 0x02C7;
  9860. t['caronbelowcmb'] = 0x032C;
  9861. t['caroncmb'] = 0x030C;
  9862. t['carriagereturn'] = 0x21B5;
  9863. t['cbopomofo'] = 0x3118;
  9864. t['ccaron'] = 0x010D;
  9865. t['ccedilla'] = 0x00E7;
  9866. t['ccedillaacute'] = 0x1E09;
  9867. t['ccircle'] = 0x24D2;
  9868. t['ccircumflex'] = 0x0109;
  9869. t['ccurl'] = 0x0255;
  9870. t['cdot'] = 0x010B;
  9871. t['cdotaccent'] = 0x010B;
  9872. t['cdsquare'] = 0x33C5;
  9873. t['cedilla'] = 0x00B8;
  9874. t['cedillacmb'] = 0x0327;
  9875. t['cent'] = 0x00A2;
  9876. t['centigrade'] = 0x2103;
  9877. t['centinferior'] = 0xF6DF;
  9878. t['centmonospace'] = 0xFFE0;
  9879. t['centoldstyle'] = 0xF7A2;
  9880. t['centsuperior'] = 0xF6E0;
  9881. t['chaarmenian'] = 0x0579;
  9882. t['chabengali'] = 0x099B;
  9883. t['chadeva'] = 0x091B;
  9884. t['chagujarati'] = 0x0A9B;
  9885. t['chagurmukhi'] = 0x0A1B;
  9886. t['chbopomofo'] = 0x3114;
  9887. t['cheabkhasiancyrillic'] = 0x04BD;
  9888. t['checkmark'] = 0x2713;
  9889. t['checyrillic'] = 0x0447;
  9890. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9891. t['chedescendercyrillic'] = 0x04B7;
  9892. t['chedieresiscyrillic'] = 0x04F5;
  9893. t['cheharmenian'] = 0x0573;
  9894. t['chekhakassiancyrillic'] = 0x04CC;
  9895. t['cheverticalstrokecyrillic'] = 0x04B9;
  9896. t['chi'] = 0x03C7;
  9897. t['chieuchacirclekorean'] = 0x3277;
  9898. t['chieuchaparenkorean'] = 0x3217;
  9899. t['chieuchcirclekorean'] = 0x3269;
  9900. t['chieuchkorean'] = 0x314A;
  9901. t['chieuchparenkorean'] = 0x3209;
  9902. t['chochangthai'] = 0x0E0A;
  9903. t['chochanthai'] = 0x0E08;
  9904. t['chochingthai'] = 0x0E09;
  9905. t['chochoethai'] = 0x0E0C;
  9906. t['chook'] = 0x0188;
  9907. t['cieucacirclekorean'] = 0x3276;
  9908. t['cieucaparenkorean'] = 0x3216;
  9909. t['cieuccirclekorean'] = 0x3268;
  9910. t['cieuckorean'] = 0x3148;
  9911. t['cieucparenkorean'] = 0x3208;
  9912. t['cieucuparenkorean'] = 0x321C;
  9913. t['circle'] = 0x25CB;
  9914. t['circlecopyrt'] = 0x00A9;
  9915. t['circlemultiply'] = 0x2297;
  9916. t['circleot'] = 0x2299;
  9917. t['circleplus'] = 0x2295;
  9918. t['circlepostalmark'] = 0x3036;
  9919. t['circlewithlefthalfblack'] = 0x25D0;
  9920. t['circlewithrighthalfblack'] = 0x25D1;
  9921. t['circumflex'] = 0x02C6;
  9922. t['circumflexbelowcmb'] = 0x032D;
  9923. t['circumflexcmb'] = 0x0302;
  9924. t['clear'] = 0x2327;
  9925. t['clickalveolar'] = 0x01C2;
  9926. t['clickdental'] = 0x01C0;
  9927. t['clicklateral'] = 0x01C1;
  9928. t['clickretroflex'] = 0x01C3;
  9929. t['club'] = 0x2663;
  9930. t['clubsuitblack'] = 0x2663;
  9931. t['clubsuitwhite'] = 0x2667;
  9932. t['cmcubedsquare'] = 0x33A4;
  9933. t['cmonospace'] = 0xFF43;
  9934. t['cmsquaredsquare'] = 0x33A0;
  9935. t['coarmenian'] = 0x0581;
  9936. t['colon'] = 0x003A;
  9937. t['colonmonetary'] = 0x20A1;
  9938. t['colonmonospace'] = 0xFF1A;
  9939. t['colonsign'] = 0x20A1;
  9940. t['colonsmall'] = 0xFE55;
  9941. t['colontriangularhalfmod'] = 0x02D1;
  9942. t['colontriangularmod'] = 0x02D0;
  9943. t['comma'] = 0x002C;
  9944. t['commaabovecmb'] = 0x0313;
  9945. t['commaaboverightcmb'] = 0x0315;
  9946. t['commaaccent'] = 0xF6C3;
  9947. t['commaarabic'] = 0x060C;
  9948. t['commaarmenian'] = 0x055D;
  9949. t['commainferior'] = 0xF6E1;
  9950. t['commamonospace'] = 0xFF0C;
  9951. t['commareversedabovecmb'] = 0x0314;
  9952. t['commareversedmod'] = 0x02BD;
  9953. t['commasmall'] = 0xFE50;
  9954. t['commasuperior'] = 0xF6E2;
  9955. t['commaturnedabovecmb'] = 0x0312;
  9956. t['commaturnedmod'] = 0x02BB;
  9957. t['compass'] = 0x263C;
  9958. t['congruent'] = 0x2245;
  9959. t['contourintegral'] = 0x222E;
  9960. t['control'] = 0x2303;
  9961. t['controlACK'] = 0x0006;
  9962. t['controlBEL'] = 0x0007;
  9963. t['controlBS'] = 0x0008;
  9964. t['controlCAN'] = 0x0018;
  9965. t['controlCR'] = 0x000D;
  9966. t['controlDC1'] = 0x0011;
  9967. t['controlDC2'] = 0x0012;
  9968. t['controlDC3'] = 0x0013;
  9969. t['controlDC4'] = 0x0014;
  9970. t['controlDEL'] = 0x007F;
  9971. t['controlDLE'] = 0x0010;
  9972. t['controlEM'] = 0x0019;
  9973. t['controlENQ'] = 0x0005;
  9974. t['controlEOT'] = 0x0004;
  9975. t['controlESC'] = 0x001B;
  9976. t['controlETB'] = 0x0017;
  9977. t['controlETX'] = 0x0003;
  9978. t['controlFF'] = 0x000C;
  9979. t['controlFS'] = 0x001C;
  9980. t['controlGS'] = 0x001D;
  9981. t['controlHT'] = 0x0009;
  9982. t['controlLF'] = 0x000A;
  9983. t['controlNAK'] = 0x0015;
  9984. t['controlNULL'] = 0x0000;
  9985. t['controlRS'] = 0x001E;
  9986. t['controlSI'] = 0x000F;
  9987. t['controlSO'] = 0x000E;
  9988. t['controlSOT'] = 0x0002;
  9989. t['controlSTX'] = 0x0001;
  9990. t['controlSUB'] = 0x001A;
  9991. t['controlSYN'] = 0x0016;
  9992. t['controlUS'] = 0x001F;
  9993. t['controlVT'] = 0x000B;
  9994. t['copyright'] = 0x00A9;
  9995. t['copyrightsans'] = 0xF8E9;
  9996. t['copyrightserif'] = 0xF6D9;
  9997. t['cornerbracketleft'] = 0x300C;
  9998. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9999. t['cornerbracketleftvertical'] = 0xFE41;
  10000. t['cornerbracketright'] = 0x300D;
  10001. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10002. t['cornerbracketrightvertical'] = 0xFE42;
  10003. t['corporationsquare'] = 0x337F;
  10004. t['cosquare'] = 0x33C7;
  10005. t['coverkgsquare'] = 0x33C6;
  10006. t['cparen'] = 0x249E;
  10007. t['cruzeiro'] = 0x20A2;
  10008. t['cstretched'] = 0x0297;
  10009. t['curlyand'] = 0x22CF;
  10010. t['curlyor'] = 0x22CE;
  10011. t['currency'] = 0x00A4;
  10012. t['cyrBreve'] = 0xF6D1;
  10013. t['cyrFlex'] = 0xF6D2;
  10014. t['cyrbreve'] = 0xF6D4;
  10015. t['cyrflex'] = 0xF6D5;
  10016. t['d'] = 0x0064;
  10017. t['daarmenian'] = 0x0564;
  10018. t['dabengali'] = 0x09A6;
  10019. t['dadarabic'] = 0x0636;
  10020. t['dadeva'] = 0x0926;
  10021. t['dadfinalarabic'] = 0xFEBE;
  10022. t['dadinitialarabic'] = 0xFEBF;
  10023. t['dadmedialarabic'] = 0xFEC0;
  10024. t['dagesh'] = 0x05BC;
  10025. t['dageshhebrew'] = 0x05BC;
  10026. t['dagger'] = 0x2020;
  10027. t['daggerdbl'] = 0x2021;
  10028. t['dagujarati'] = 0x0AA6;
  10029. t['dagurmukhi'] = 0x0A26;
  10030. t['dahiragana'] = 0x3060;
  10031. t['dakatakana'] = 0x30C0;
  10032. t['dalarabic'] = 0x062F;
  10033. t['dalet'] = 0x05D3;
  10034. t['daletdagesh'] = 0xFB33;
  10035. t['daletdageshhebrew'] = 0xFB33;
  10036. t['dalethebrew'] = 0x05D3;
  10037. t['dalfinalarabic'] = 0xFEAA;
  10038. t['dammaarabic'] = 0x064F;
  10039. t['dammalowarabic'] = 0x064F;
  10040. t['dammatanaltonearabic'] = 0x064C;
  10041. t['dammatanarabic'] = 0x064C;
  10042. t['danda'] = 0x0964;
  10043. t['dargahebrew'] = 0x05A7;
  10044. t['dargalefthebrew'] = 0x05A7;
  10045. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10046. t['dblGrave'] = 0xF6D3;
  10047. t['dblanglebracketleft'] = 0x300A;
  10048. t['dblanglebracketleftvertical'] = 0xFE3D;
  10049. t['dblanglebracketright'] = 0x300B;
  10050. t['dblanglebracketrightvertical'] = 0xFE3E;
  10051. t['dblarchinvertedbelowcmb'] = 0x032B;
  10052. t['dblarrowleft'] = 0x21D4;
  10053. t['dblarrowright'] = 0x21D2;
  10054. t['dbldanda'] = 0x0965;
  10055. t['dblgrave'] = 0xF6D6;
  10056. t['dblgravecmb'] = 0x030F;
  10057. t['dblintegral'] = 0x222C;
  10058. t['dbllowline'] = 0x2017;
  10059. t['dbllowlinecmb'] = 0x0333;
  10060. t['dbloverlinecmb'] = 0x033F;
  10061. t['dblprimemod'] = 0x02BA;
  10062. t['dblverticalbar'] = 0x2016;
  10063. t['dblverticallineabovecmb'] = 0x030E;
  10064. t['dbopomofo'] = 0x3109;
  10065. t['dbsquare'] = 0x33C8;
  10066. t['dcaron'] = 0x010F;
  10067. t['dcedilla'] = 0x1E11;
  10068. t['dcircle'] = 0x24D3;
  10069. t['dcircumflexbelow'] = 0x1E13;
  10070. t['dcroat'] = 0x0111;
  10071. t['ddabengali'] = 0x09A1;
  10072. t['ddadeva'] = 0x0921;
  10073. t['ddagujarati'] = 0x0AA1;
  10074. t['ddagurmukhi'] = 0x0A21;
  10075. t['ddalarabic'] = 0x0688;
  10076. t['ddalfinalarabic'] = 0xFB89;
  10077. t['dddhadeva'] = 0x095C;
  10078. t['ddhabengali'] = 0x09A2;
  10079. t['ddhadeva'] = 0x0922;
  10080. t['ddhagujarati'] = 0x0AA2;
  10081. t['ddhagurmukhi'] = 0x0A22;
  10082. t['ddotaccent'] = 0x1E0B;
  10083. t['ddotbelow'] = 0x1E0D;
  10084. t['decimalseparatorarabic'] = 0x066B;
  10085. t['decimalseparatorpersian'] = 0x066B;
  10086. t['decyrillic'] = 0x0434;
  10087. t['degree'] = 0x00B0;
  10088. t['dehihebrew'] = 0x05AD;
  10089. t['dehiragana'] = 0x3067;
  10090. t['deicoptic'] = 0x03EF;
  10091. t['dekatakana'] = 0x30C7;
  10092. t['deleteleft'] = 0x232B;
  10093. t['deleteright'] = 0x2326;
  10094. t['delta'] = 0x03B4;
  10095. t['deltaturned'] = 0x018D;
  10096. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10097. t['dezh'] = 0x02A4;
  10098. t['dhabengali'] = 0x09A7;
  10099. t['dhadeva'] = 0x0927;
  10100. t['dhagujarati'] = 0x0AA7;
  10101. t['dhagurmukhi'] = 0x0A27;
  10102. t['dhook'] = 0x0257;
  10103. t['dialytikatonos'] = 0x0385;
  10104. t['dialytikatonoscmb'] = 0x0344;
  10105. t['diamond'] = 0x2666;
  10106. t['diamondsuitwhite'] = 0x2662;
  10107. t['dieresis'] = 0x00A8;
  10108. t['dieresisacute'] = 0xF6D7;
  10109. t['dieresisbelowcmb'] = 0x0324;
  10110. t['dieresiscmb'] = 0x0308;
  10111. t['dieresisgrave'] = 0xF6D8;
  10112. t['dieresistonos'] = 0x0385;
  10113. t['dihiragana'] = 0x3062;
  10114. t['dikatakana'] = 0x30C2;
  10115. t['dittomark'] = 0x3003;
  10116. t['divide'] = 0x00F7;
  10117. t['divides'] = 0x2223;
  10118. t['divisionslash'] = 0x2215;
  10119. t['djecyrillic'] = 0x0452;
  10120. t['dkshade'] = 0x2593;
  10121. t['dlinebelow'] = 0x1E0F;
  10122. t['dlsquare'] = 0x3397;
  10123. t['dmacron'] = 0x0111;
  10124. t['dmonospace'] = 0xFF44;
  10125. t['dnblock'] = 0x2584;
  10126. t['dochadathai'] = 0x0E0E;
  10127. t['dodekthai'] = 0x0E14;
  10128. t['dohiragana'] = 0x3069;
  10129. t['dokatakana'] = 0x30C9;
  10130. t['dollar'] = 0x0024;
  10131. t['dollarinferior'] = 0xF6E3;
  10132. t['dollarmonospace'] = 0xFF04;
  10133. t['dollaroldstyle'] = 0xF724;
  10134. t['dollarsmall'] = 0xFE69;
  10135. t['dollarsuperior'] = 0xF6E4;
  10136. t['dong'] = 0x20AB;
  10137. t['dorusquare'] = 0x3326;
  10138. t['dotaccent'] = 0x02D9;
  10139. t['dotaccentcmb'] = 0x0307;
  10140. t['dotbelowcmb'] = 0x0323;
  10141. t['dotbelowcomb'] = 0x0323;
  10142. t['dotkatakana'] = 0x30FB;
  10143. t['dotlessi'] = 0x0131;
  10144. t['dotlessj'] = 0xF6BE;
  10145. t['dotlessjstrokehook'] = 0x0284;
  10146. t['dotmath'] = 0x22C5;
  10147. t['dottedcircle'] = 0x25CC;
  10148. t['doubleyodpatah'] = 0xFB1F;
  10149. t['doubleyodpatahhebrew'] = 0xFB1F;
  10150. t['downtackbelowcmb'] = 0x031E;
  10151. t['downtackmod'] = 0x02D5;
  10152. t['dparen'] = 0x249F;
  10153. t['dsuperior'] = 0xF6EB;
  10154. t['dtail'] = 0x0256;
  10155. t['dtopbar'] = 0x018C;
  10156. t['duhiragana'] = 0x3065;
  10157. t['dukatakana'] = 0x30C5;
  10158. t['dz'] = 0x01F3;
  10159. t['dzaltone'] = 0x02A3;
  10160. t['dzcaron'] = 0x01C6;
  10161. t['dzcurl'] = 0x02A5;
  10162. t['dzeabkhasiancyrillic'] = 0x04E1;
  10163. t['dzecyrillic'] = 0x0455;
  10164. t['dzhecyrillic'] = 0x045F;
  10165. t['e'] = 0x0065;
  10166. t['eacute'] = 0x00E9;
  10167. t['earth'] = 0x2641;
  10168. t['ebengali'] = 0x098F;
  10169. t['ebopomofo'] = 0x311C;
  10170. t['ebreve'] = 0x0115;
  10171. t['ecandradeva'] = 0x090D;
  10172. t['ecandragujarati'] = 0x0A8D;
  10173. t['ecandravowelsigndeva'] = 0x0945;
  10174. t['ecandravowelsigngujarati'] = 0x0AC5;
  10175. t['ecaron'] = 0x011B;
  10176. t['ecedillabreve'] = 0x1E1D;
  10177. t['echarmenian'] = 0x0565;
  10178. t['echyiwnarmenian'] = 0x0587;
  10179. t['ecircle'] = 0x24D4;
  10180. t['ecircumflex'] = 0x00EA;
  10181. t['ecircumflexacute'] = 0x1EBF;
  10182. t['ecircumflexbelow'] = 0x1E19;
  10183. t['ecircumflexdotbelow'] = 0x1EC7;
  10184. t['ecircumflexgrave'] = 0x1EC1;
  10185. t['ecircumflexhookabove'] = 0x1EC3;
  10186. t['ecircumflextilde'] = 0x1EC5;
  10187. t['ecyrillic'] = 0x0454;
  10188. t['edblgrave'] = 0x0205;
  10189. t['edeva'] = 0x090F;
  10190. t['edieresis'] = 0x00EB;
  10191. t['edot'] = 0x0117;
  10192. t['edotaccent'] = 0x0117;
  10193. t['edotbelow'] = 0x1EB9;
  10194. t['eegurmukhi'] = 0x0A0F;
  10195. t['eematragurmukhi'] = 0x0A47;
  10196. t['efcyrillic'] = 0x0444;
  10197. t['egrave'] = 0x00E8;
  10198. t['egujarati'] = 0x0A8F;
  10199. t['eharmenian'] = 0x0567;
  10200. t['ehbopomofo'] = 0x311D;
  10201. t['ehiragana'] = 0x3048;
  10202. t['ehookabove'] = 0x1EBB;
  10203. t['eibopomofo'] = 0x311F;
  10204. t['eight'] = 0x0038;
  10205. t['eightarabic'] = 0x0668;
  10206. t['eightbengali'] = 0x09EE;
  10207. t['eightcircle'] = 0x2467;
  10208. t['eightcircleinversesansserif'] = 0x2791;
  10209. t['eightdeva'] = 0x096E;
  10210. t['eighteencircle'] = 0x2471;
  10211. t['eighteenparen'] = 0x2485;
  10212. t['eighteenperiod'] = 0x2499;
  10213. t['eightgujarati'] = 0x0AEE;
  10214. t['eightgurmukhi'] = 0x0A6E;
  10215. t['eighthackarabic'] = 0x0668;
  10216. t['eighthangzhou'] = 0x3028;
  10217. t['eighthnotebeamed'] = 0x266B;
  10218. t['eightideographicparen'] = 0x3227;
  10219. t['eightinferior'] = 0x2088;
  10220. t['eightmonospace'] = 0xFF18;
  10221. t['eightoldstyle'] = 0xF738;
  10222. t['eightparen'] = 0x247B;
  10223. t['eightperiod'] = 0x248F;
  10224. t['eightpersian'] = 0x06F8;
  10225. t['eightroman'] = 0x2177;
  10226. t['eightsuperior'] = 0x2078;
  10227. t['eightthai'] = 0x0E58;
  10228. t['einvertedbreve'] = 0x0207;
  10229. t['eiotifiedcyrillic'] = 0x0465;
  10230. t['ekatakana'] = 0x30A8;
  10231. t['ekatakanahalfwidth'] = 0xFF74;
  10232. t['ekonkargurmukhi'] = 0x0A74;
  10233. t['ekorean'] = 0x3154;
  10234. t['elcyrillic'] = 0x043B;
  10235. t['element'] = 0x2208;
  10236. t['elevencircle'] = 0x246A;
  10237. t['elevenparen'] = 0x247E;
  10238. t['elevenperiod'] = 0x2492;
  10239. t['elevenroman'] = 0x217A;
  10240. t['ellipsis'] = 0x2026;
  10241. t['ellipsisvertical'] = 0x22EE;
  10242. t['emacron'] = 0x0113;
  10243. t['emacronacute'] = 0x1E17;
  10244. t['emacrongrave'] = 0x1E15;
  10245. t['emcyrillic'] = 0x043C;
  10246. t['emdash'] = 0x2014;
  10247. t['emdashvertical'] = 0xFE31;
  10248. t['emonospace'] = 0xFF45;
  10249. t['emphasismarkarmenian'] = 0x055B;
  10250. t['emptyset'] = 0x2205;
  10251. t['enbopomofo'] = 0x3123;
  10252. t['encyrillic'] = 0x043D;
  10253. t['endash'] = 0x2013;
  10254. t['endashvertical'] = 0xFE32;
  10255. t['endescendercyrillic'] = 0x04A3;
  10256. t['eng'] = 0x014B;
  10257. t['engbopomofo'] = 0x3125;
  10258. t['enghecyrillic'] = 0x04A5;
  10259. t['enhookcyrillic'] = 0x04C8;
  10260. t['enspace'] = 0x2002;
  10261. t['eogonek'] = 0x0119;
  10262. t['eokorean'] = 0x3153;
  10263. t['eopen'] = 0x025B;
  10264. t['eopenclosed'] = 0x029A;
  10265. t['eopenreversed'] = 0x025C;
  10266. t['eopenreversedclosed'] = 0x025E;
  10267. t['eopenreversedhook'] = 0x025D;
  10268. t['eparen'] = 0x24A0;
  10269. t['epsilon'] = 0x03B5;
  10270. t['epsilontonos'] = 0x03AD;
  10271. t['equal'] = 0x003D;
  10272. t['equalmonospace'] = 0xFF1D;
  10273. t['equalsmall'] = 0xFE66;
  10274. t['equalsuperior'] = 0x207C;
  10275. t['equivalence'] = 0x2261;
  10276. t['erbopomofo'] = 0x3126;
  10277. t['ercyrillic'] = 0x0440;
  10278. t['ereversed'] = 0x0258;
  10279. t['ereversedcyrillic'] = 0x044D;
  10280. t['escyrillic'] = 0x0441;
  10281. t['esdescendercyrillic'] = 0x04AB;
  10282. t['esh'] = 0x0283;
  10283. t['eshcurl'] = 0x0286;
  10284. t['eshortdeva'] = 0x090E;
  10285. t['eshortvowelsigndeva'] = 0x0946;
  10286. t['eshreversedloop'] = 0x01AA;
  10287. t['eshsquatreversed'] = 0x0285;
  10288. t['esmallhiragana'] = 0x3047;
  10289. t['esmallkatakana'] = 0x30A7;
  10290. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10291. t['estimated'] = 0x212E;
  10292. t['esuperior'] = 0xF6EC;
  10293. t['eta'] = 0x03B7;
  10294. t['etarmenian'] = 0x0568;
  10295. t['etatonos'] = 0x03AE;
  10296. t['eth'] = 0x00F0;
  10297. t['etilde'] = 0x1EBD;
  10298. t['etildebelow'] = 0x1E1B;
  10299. t['etnahtafoukhhebrew'] = 0x0591;
  10300. t['etnahtafoukhlefthebrew'] = 0x0591;
  10301. t['etnahtahebrew'] = 0x0591;
  10302. t['etnahtalefthebrew'] = 0x0591;
  10303. t['eturned'] = 0x01DD;
  10304. t['eukorean'] = 0x3161;
  10305. t['euro'] = 0x20AC;
  10306. t['evowelsignbengali'] = 0x09C7;
  10307. t['evowelsigndeva'] = 0x0947;
  10308. t['evowelsigngujarati'] = 0x0AC7;
  10309. t['exclam'] = 0x0021;
  10310. t['exclamarmenian'] = 0x055C;
  10311. t['exclamdbl'] = 0x203C;
  10312. t['exclamdown'] = 0x00A1;
  10313. t['exclamdownsmall'] = 0xF7A1;
  10314. t['exclammonospace'] = 0xFF01;
  10315. t['exclamsmall'] = 0xF721;
  10316. t['existential'] = 0x2203;
  10317. t['ezh'] = 0x0292;
  10318. t['ezhcaron'] = 0x01EF;
  10319. t['ezhcurl'] = 0x0293;
  10320. t['ezhreversed'] = 0x01B9;
  10321. t['ezhtail'] = 0x01BA;
  10322. t['f'] = 0x0066;
  10323. t['fadeva'] = 0x095E;
  10324. t['fagurmukhi'] = 0x0A5E;
  10325. t['fahrenheit'] = 0x2109;
  10326. t['fathaarabic'] = 0x064E;
  10327. t['fathalowarabic'] = 0x064E;
  10328. t['fathatanarabic'] = 0x064B;
  10329. t['fbopomofo'] = 0x3108;
  10330. t['fcircle'] = 0x24D5;
  10331. t['fdotaccent'] = 0x1E1F;
  10332. t['feharabic'] = 0x0641;
  10333. t['feharmenian'] = 0x0586;
  10334. t['fehfinalarabic'] = 0xFED2;
  10335. t['fehinitialarabic'] = 0xFED3;
  10336. t['fehmedialarabic'] = 0xFED4;
  10337. t['feicoptic'] = 0x03E5;
  10338. t['female'] = 0x2640;
  10339. t['ff'] = 0xFB00;
  10340. t['ffi'] = 0xFB03;
  10341. t['ffl'] = 0xFB04;
  10342. t['fi'] = 0xFB01;
  10343. t['fifteencircle'] = 0x246E;
  10344. t['fifteenparen'] = 0x2482;
  10345. t['fifteenperiod'] = 0x2496;
  10346. t['figuredash'] = 0x2012;
  10347. t['filledbox'] = 0x25A0;
  10348. t['filledrect'] = 0x25AC;
  10349. t['finalkaf'] = 0x05DA;
  10350. t['finalkafdagesh'] = 0xFB3A;
  10351. t['finalkafdageshhebrew'] = 0xFB3A;
  10352. t['finalkafhebrew'] = 0x05DA;
  10353. t['finalmem'] = 0x05DD;
  10354. t['finalmemhebrew'] = 0x05DD;
  10355. t['finalnun'] = 0x05DF;
  10356. t['finalnunhebrew'] = 0x05DF;
  10357. t['finalpe'] = 0x05E3;
  10358. t['finalpehebrew'] = 0x05E3;
  10359. t['finaltsadi'] = 0x05E5;
  10360. t['finaltsadihebrew'] = 0x05E5;
  10361. t['firsttonechinese'] = 0x02C9;
  10362. t['fisheye'] = 0x25C9;
  10363. t['fitacyrillic'] = 0x0473;
  10364. t['five'] = 0x0035;
  10365. t['fivearabic'] = 0x0665;
  10366. t['fivebengali'] = 0x09EB;
  10367. t['fivecircle'] = 0x2464;
  10368. t['fivecircleinversesansserif'] = 0x278E;
  10369. t['fivedeva'] = 0x096B;
  10370. t['fiveeighths'] = 0x215D;
  10371. t['fivegujarati'] = 0x0AEB;
  10372. t['fivegurmukhi'] = 0x0A6B;
  10373. t['fivehackarabic'] = 0x0665;
  10374. t['fivehangzhou'] = 0x3025;
  10375. t['fiveideographicparen'] = 0x3224;
  10376. t['fiveinferior'] = 0x2085;
  10377. t['fivemonospace'] = 0xFF15;
  10378. t['fiveoldstyle'] = 0xF735;
  10379. t['fiveparen'] = 0x2478;
  10380. t['fiveperiod'] = 0x248C;
  10381. t['fivepersian'] = 0x06F5;
  10382. t['fiveroman'] = 0x2174;
  10383. t['fivesuperior'] = 0x2075;
  10384. t['fivethai'] = 0x0E55;
  10385. t['fl'] = 0xFB02;
  10386. t['florin'] = 0x0192;
  10387. t['fmonospace'] = 0xFF46;
  10388. t['fmsquare'] = 0x3399;
  10389. t['fofanthai'] = 0x0E1F;
  10390. t['fofathai'] = 0x0E1D;
  10391. t['fongmanthai'] = 0x0E4F;
  10392. t['forall'] = 0x2200;
  10393. t['four'] = 0x0034;
  10394. t['fourarabic'] = 0x0664;
  10395. t['fourbengali'] = 0x09EA;
  10396. t['fourcircle'] = 0x2463;
  10397. t['fourcircleinversesansserif'] = 0x278D;
  10398. t['fourdeva'] = 0x096A;
  10399. t['fourgujarati'] = 0x0AEA;
  10400. t['fourgurmukhi'] = 0x0A6A;
  10401. t['fourhackarabic'] = 0x0664;
  10402. t['fourhangzhou'] = 0x3024;
  10403. t['fourideographicparen'] = 0x3223;
  10404. t['fourinferior'] = 0x2084;
  10405. t['fourmonospace'] = 0xFF14;
  10406. t['fournumeratorbengali'] = 0x09F7;
  10407. t['fouroldstyle'] = 0xF734;
  10408. t['fourparen'] = 0x2477;
  10409. t['fourperiod'] = 0x248B;
  10410. t['fourpersian'] = 0x06F4;
  10411. t['fourroman'] = 0x2173;
  10412. t['foursuperior'] = 0x2074;
  10413. t['fourteencircle'] = 0x246D;
  10414. t['fourteenparen'] = 0x2481;
  10415. t['fourteenperiod'] = 0x2495;
  10416. t['fourthai'] = 0x0E54;
  10417. t['fourthtonechinese'] = 0x02CB;
  10418. t['fparen'] = 0x24A1;
  10419. t['fraction'] = 0x2044;
  10420. t['franc'] = 0x20A3;
  10421. t['g'] = 0x0067;
  10422. t['gabengali'] = 0x0997;
  10423. t['gacute'] = 0x01F5;
  10424. t['gadeva'] = 0x0917;
  10425. t['gafarabic'] = 0x06AF;
  10426. t['gaffinalarabic'] = 0xFB93;
  10427. t['gafinitialarabic'] = 0xFB94;
  10428. t['gafmedialarabic'] = 0xFB95;
  10429. t['gagujarati'] = 0x0A97;
  10430. t['gagurmukhi'] = 0x0A17;
  10431. t['gahiragana'] = 0x304C;
  10432. t['gakatakana'] = 0x30AC;
  10433. t['gamma'] = 0x03B3;
  10434. t['gammalatinsmall'] = 0x0263;
  10435. t['gammasuperior'] = 0x02E0;
  10436. t['gangiacoptic'] = 0x03EB;
  10437. t['gbopomofo'] = 0x310D;
  10438. t['gbreve'] = 0x011F;
  10439. t['gcaron'] = 0x01E7;
  10440. t['gcedilla'] = 0x0123;
  10441. t['gcircle'] = 0x24D6;
  10442. t['gcircumflex'] = 0x011D;
  10443. t['gcommaaccent'] = 0x0123;
  10444. t['gdot'] = 0x0121;
  10445. t['gdotaccent'] = 0x0121;
  10446. t['gecyrillic'] = 0x0433;
  10447. t['gehiragana'] = 0x3052;
  10448. t['gekatakana'] = 0x30B2;
  10449. t['geometricallyequal'] = 0x2251;
  10450. t['gereshaccenthebrew'] = 0x059C;
  10451. t['gereshhebrew'] = 0x05F3;
  10452. t['gereshmuqdamhebrew'] = 0x059D;
  10453. t['germandbls'] = 0x00DF;
  10454. t['gershayimaccenthebrew'] = 0x059E;
  10455. t['gershayimhebrew'] = 0x05F4;
  10456. t['getamark'] = 0x3013;
  10457. t['ghabengali'] = 0x0998;
  10458. t['ghadarmenian'] = 0x0572;
  10459. t['ghadeva'] = 0x0918;
  10460. t['ghagujarati'] = 0x0A98;
  10461. t['ghagurmukhi'] = 0x0A18;
  10462. t['ghainarabic'] = 0x063A;
  10463. t['ghainfinalarabic'] = 0xFECE;
  10464. t['ghaininitialarabic'] = 0xFECF;
  10465. t['ghainmedialarabic'] = 0xFED0;
  10466. t['ghemiddlehookcyrillic'] = 0x0495;
  10467. t['ghestrokecyrillic'] = 0x0493;
  10468. t['gheupturncyrillic'] = 0x0491;
  10469. t['ghhadeva'] = 0x095A;
  10470. t['ghhagurmukhi'] = 0x0A5A;
  10471. t['ghook'] = 0x0260;
  10472. t['ghzsquare'] = 0x3393;
  10473. t['gihiragana'] = 0x304E;
  10474. t['gikatakana'] = 0x30AE;
  10475. t['gimarmenian'] = 0x0563;
  10476. t['gimel'] = 0x05D2;
  10477. t['gimeldagesh'] = 0xFB32;
  10478. t['gimeldageshhebrew'] = 0xFB32;
  10479. t['gimelhebrew'] = 0x05D2;
  10480. t['gjecyrillic'] = 0x0453;
  10481. t['glottalinvertedstroke'] = 0x01BE;
  10482. t['glottalstop'] = 0x0294;
  10483. t['glottalstopinverted'] = 0x0296;
  10484. t['glottalstopmod'] = 0x02C0;
  10485. t['glottalstopreversed'] = 0x0295;
  10486. t['glottalstopreversedmod'] = 0x02C1;
  10487. t['glottalstopreversedsuperior'] = 0x02E4;
  10488. t['glottalstopstroke'] = 0x02A1;
  10489. t['glottalstopstrokereversed'] = 0x02A2;
  10490. t['gmacron'] = 0x1E21;
  10491. t['gmonospace'] = 0xFF47;
  10492. t['gohiragana'] = 0x3054;
  10493. t['gokatakana'] = 0x30B4;
  10494. t['gparen'] = 0x24A2;
  10495. t['gpasquare'] = 0x33AC;
  10496. t['gradient'] = 0x2207;
  10497. t['grave'] = 0x0060;
  10498. t['gravebelowcmb'] = 0x0316;
  10499. t['gravecmb'] = 0x0300;
  10500. t['gravecomb'] = 0x0300;
  10501. t['gravedeva'] = 0x0953;
  10502. t['gravelowmod'] = 0x02CE;
  10503. t['gravemonospace'] = 0xFF40;
  10504. t['gravetonecmb'] = 0x0340;
  10505. t['greater'] = 0x003E;
  10506. t['greaterequal'] = 0x2265;
  10507. t['greaterequalorless'] = 0x22DB;
  10508. t['greatermonospace'] = 0xFF1E;
  10509. t['greaterorequivalent'] = 0x2273;
  10510. t['greaterorless'] = 0x2277;
  10511. t['greateroverequal'] = 0x2267;
  10512. t['greatersmall'] = 0xFE65;
  10513. t['gscript'] = 0x0261;
  10514. t['gstroke'] = 0x01E5;
  10515. t['guhiragana'] = 0x3050;
  10516. t['guillemotleft'] = 0x00AB;
  10517. t['guillemotright'] = 0x00BB;
  10518. t['guilsinglleft'] = 0x2039;
  10519. t['guilsinglright'] = 0x203A;
  10520. t['gukatakana'] = 0x30B0;
  10521. t['guramusquare'] = 0x3318;
  10522. t['gysquare'] = 0x33C9;
  10523. t['h'] = 0x0068;
  10524. t['haabkhasiancyrillic'] = 0x04A9;
  10525. t['haaltonearabic'] = 0x06C1;
  10526. t['habengali'] = 0x09B9;
  10527. t['hadescendercyrillic'] = 0x04B3;
  10528. t['hadeva'] = 0x0939;
  10529. t['hagujarati'] = 0x0AB9;
  10530. t['hagurmukhi'] = 0x0A39;
  10531. t['haharabic'] = 0x062D;
  10532. t['hahfinalarabic'] = 0xFEA2;
  10533. t['hahinitialarabic'] = 0xFEA3;
  10534. t['hahiragana'] = 0x306F;
  10535. t['hahmedialarabic'] = 0xFEA4;
  10536. t['haitusquare'] = 0x332A;
  10537. t['hakatakana'] = 0x30CF;
  10538. t['hakatakanahalfwidth'] = 0xFF8A;
  10539. t['halantgurmukhi'] = 0x0A4D;
  10540. t['hamzaarabic'] = 0x0621;
  10541. t['hamzalowarabic'] = 0x0621;
  10542. t['hangulfiller'] = 0x3164;
  10543. t['hardsigncyrillic'] = 0x044A;
  10544. t['harpoonleftbarbup'] = 0x21BC;
  10545. t['harpoonrightbarbup'] = 0x21C0;
  10546. t['hasquare'] = 0x33CA;
  10547. t['hatafpatah'] = 0x05B2;
  10548. t['hatafpatah16'] = 0x05B2;
  10549. t['hatafpatah23'] = 0x05B2;
  10550. t['hatafpatah2f'] = 0x05B2;
  10551. t['hatafpatahhebrew'] = 0x05B2;
  10552. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10553. t['hatafpatahquarterhebrew'] = 0x05B2;
  10554. t['hatafpatahwidehebrew'] = 0x05B2;
  10555. t['hatafqamats'] = 0x05B3;
  10556. t['hatafqamats1b'] = 0x05B3;
  10557. t['hatafqamats28'] = 0x05B3;
  10558. t['hatafqamats34'] = 0x05B3;
  10559. t['hatafqamatshebrew'] = 0x05B3;
  10560. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10561. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10562. t['hatafqamatswidehebrew'] = 0x05B3;
  10563. t['hatafsegol'] = 0x05B1;
  10564. t['hatafsegol17'] = 0x05B1;
  10565. t['hatafsegol24'] = 0x05B1;
  10566. t['hatafsegol30'] = 0x05B1;
  10567. t['hatafsegolhebrew'] = 0x05B1;
  10568. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10569. t['hatafsegolquarterhebrew'] = 0x05B1;
  10570. t['hatafsegolwidehebrew'] = 0x05B1;
  10571. t['hbar'] = 0x0127;
  10572. t['hbopomofo'] = 0x310F;
  10573. t['hbrevebelow'] = 0x1E2B;
  10574. t['hcedilla'] = 0x1E29;
  10575. t['hcircle'] = 0x24D7;
  10576. t['hcircumflex'] = 0x0125;
  10577. t['hdieresis'] = 0x1E27;
  10578. t['hdotaccent'] = 0x1E23;
  10579. t['hdotbelow'] = 0x1E25;
  10580. t['he'] = 0x05D4;
  10581. t['heart'] = 0x2665;
  10582. t['heartsuitblack'] = 0x2665;
  10583. t['heartsuitwhite'] = 0x2661;
  10584. t['hedagesh'] = 0xFB34;
  10585. t['hedageshhebrew'] = 0xFB34;
  10586. t['hehaltonearabic'] = 0x06C1;
  10587. t['heharabic'] = 0x0647;
  10588. t['hehebrew'] = 0x05D4;
  10589. t['hehfinalaltonearabic'] = 0xFBA7;
  10590. t['hehfinalalttwoarabic'] = 0xFEEA;
  10591. t['hehfinalarabic'] = 0xFEEA;
  10592. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10593. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10594. t['hehinitialaltonearabic'] = 0xFBA8;
  10595. t['hehinitialarabic'] = 0xFEEB;
  10596. t['hehiragana'] = 0x3078;
  10597. t['hehmedialaltonearabic'] = 0xFBA9;
  10598. t['hehmedialarabic'] = 0xFEEC;
  10599. t['heiseierasquare'] = 0x337B;
  10600. t['hekatakana'] = 0x30D8;
  10601. t['hekatakanahalfwidth'] = 0xFF8D;
  10602. t['hekutaarusquare'] = 0x3336;
  10603. t['henghook'] = 0x0267;
  10604. t['herutusquare'] = 0x3339;
  10605. t['het'] = 0x05D7;
  10606. t['hethebrew'] = 0x05D7;
  10607. t['hhook'] = 0x0266;
  10608. t['hhooksuperior'] = 0x02B1;
  10609. t['hieuhacirclekorean'] = 0x327B;
  10610. t['hieuhaparenkorean'] = 0x321B;
  10611. t['hieuhcirclekorean'] = 0x326D;
  10612. t['hieuhkorean'] = 0x314E;
  10613. t['hieuhparenkorean'] = 0x320D;
  10614. t['hihiragana'] = 0x3072;
  10615. t['hikatakana'] = 0x30D2;
  10616. t['hikatakanahalfwidth'] = 0xFF8B;
  10617. t['hiriq'] = 0x05B4;
  10618. t['hiriq14'] = 0x05B4;
  10619. t['hiriq21'] = 0x05B4;
  10620. t['hiriq2d'] = 0x05B4;
  10621. t['hiriqhebrew'] = 0x05B4;
  10622. t['hiriqnarrowhebrew'] = 0x05B4;
  10623. t['hiriqquarterhebrew'] = 0x05B4;
  10624. t['hiriqwidehebrew'] = 0x05B4;
  10625. t['hlinebelow'] = 0x1E96;
  10626. t['hmonospace'] = 0xFF48;
  10627. t['hoarmenian'] = 0x0570;
  10628. t['hohipthai'] = 0x0E2B;
  10629. t['hohiragana'] = 0x307B;
  10630. t['hokatakana'] = 0x30DB;
  10631. t['hokatakanahalfwidth'] = 0xFF8E;
  10632. t['holam'] = 0x05B9;
  10633. t['holam19'] = 0x05B9;
  10634. t['holam26'] = 0x05B9;
  10635. t['holam32'] = 0x05B9;
  10636. t['holamhebrew'] = 0x05B9;
  10637. t['holamnarrowhebrew'] = 0x05B9;
  10638. t['holamquarterhebrew'] = 0x05B9;
  10639. t['holamwidehebrew'] = 0x05B9;
  10640. t['honokhukthai'] = 0x0E2E;
  10641. t['hookabovecomb'] = 0x0309;
  10642. t['hookcmb'] = 0x0309;
  10643. t['hookpalatalizedbelowcmb'] = 0x0321;
  10644. t['hookretroflexbelowcmb'] = 0x0322;
  10645. t['hoonsquare'] = 0x3342;
  10646. t['horicoptic'] = 0x03E9;
  10647. t['horizontalbar'] = 0x2015;
  10648. t['horncmb'] = 0x031B;
  10649. t['hotsprings'] = 0x2668;
  10650. t['house'] = 0x2302;
  10651. t['hparen'] = 0x24A3;
  10652. t['hsuperior'] = 0x02B0;
  10653. t['hturned'] = 0x0265;
  10654. t['huhiragana'] = 0x3075;
  10655. t['huiitosquare'] = 0x3333;
  10656. t['hukatakana'] = 0x30D5;
  10657. t['hukatakanahalfwidth'] = 0xFF8C;
  10658. t['hungarumlaut'] = 0x02DD;
  10659. t['hungarumlautcmb'] = 0x030B;
  10660. t['hv'] = 0x0195;
  10661. t['hyphen'] = 0x002D;
  10662. t['hypheninferior'] = 0xF6E5;
  10663. t['hyphenmonospace'] = 0xFF0D;
  10664. t['hyphensmall'] = 0xFE63;
  10665. t['hyphensuperior'] = 0xF6E6;
  10666. t['hyphentwo'] = 0x2010;
  10667. t['i'] = 0x0069;
  10668. t['iacute'] = 0x00ED;
  10669. t['iacyrillic'] = 0x044F;
  10670. t['ibengali'] = 0x0987;
  10671. t['ibopomofo'] = 0x3127;
  10672. t['ibreve'] = 0x012D;
  10673. t['icaron'] = 0x01D0;
  10674. t['icircle'] = 0x24D8;
  10675. t['icircumflex'] = 0x00EE;
  10676. t['icyrillic'] = 0x0456;
  10677. t['idblgrave'] = 0x0209;
  10678. t['ideographearthcircle'] = 0x328F;
  10679. t['ideographfirecircle'] = 0x328B;
  10680. t['ideographicallianceparen'] = 0x323F;
  10681. t['ideographiccallparen'] = 0x323A;
  10682. t['ideographiccentrecircle'] = 0x32A5;
  10683. t['ideographicclose'] = 0x3006;
  10684. t['ideographiccomma'] = 0x3001;
  10685. t['ideographiccommaleft'] = 0xFF64;
  10686. t['ideographiccongratulationparen'] = 0x3237;
  10687. t['ideographiccorrectcircle'] = 0x32A3;
  10688. t['ideographicearthparen'] = 0x322F;
  10689. t['ideographicenterpriseparen'] = 0x323D;
  10690. t['ideographicexcellentcircle'] = 0x329D;
  10691. t['ideographicfestivalparen'] = 0x3240;
  10692. t['ideographicfinancialcircle'] = 0x3296;
  10693. t['ideographicfinancialparen'] = 0x3236;
  10694. t['ideographicfireparen'] = 0x322B;
  10695. t['ideographichaveparen'] = 0x3232;
  10696. t['ideographichighcircle'] = 0x32A4;
  10697. t['ideographiciterationmark'] = 0x3005;
  10698. t['ideographiclaborcircle'] = 0x3298;
  10699. t['ideographiclaborparen'] = 0x3238;
  10700. t['ideographicleftcircle'] = 0x32A7;
  10701. t['ideographiclowcircle'] = 0x32A6;
  10702. t['ideographicmedicinecircle'] = 0x32A9;
  10703. t['ideographicmetalparen'] = 0x322E;
  10704. t['ideographicmoonparen'] = 0x322A;
  10705. t['ideographicnameparen'] = 0x3234;
  10706. t['ideographicperiod'] = 0x3002;
  10707. t['ideographicprintcircle'] = 0x329E;
  10708. t['ideographicreachparen'] = 0x3243;
  10709. t['ideographicrepresentparen'] = 0x3239;
  10710. t['ideographicresourceparen'] = 0x323E;
  10711. t['ideographicrightcircle'] = 0x32A8;
  10712. t['ideographicsecretcircle'] = 0x3299;
  10713. t['ideographicselfparen'] = 0x3242;
  10714. t['ideographicsocietyparen'] = 0x3233;
  10715. t['ideographicspace'] = 0x3000;
  10716. t['ideographicspecialparen'] = 0x3235;
  10717. t['ideographicstockparen'] = 0x3231;
  10718. t['ideographicstudyparen'] = 0x323B;
  10719. t['ideographicsunparen'] = 0x3230;
  10720. t['ideographicsuperviseparen'] = 0x323C;
  10721. t['ideographicwaterparen'] = 0x322C;
  10722. t['ideographicwoodparen'] = 0x322D;
  10723. t['ideographiczero'] = 0x3007;
  10724. t['ideographmetalcircle'] = 0x328E;
  10725. t['ideographmooncircle'] = 0x328A;
  10726. t['ideographnamecircle'] = 0x3294;
  10727. t['ideographsuncircle'] = 0x3290;
  10728. t['ideographwatercircle'] = 0x328C;
  10729. t['ideographwoodcircle'] = 0x328D;
  10730. t['ideva'] = 0x0907;
  10731. t['idieresis'] = 0x00EF;
  10732. t['idieresisacute'] = 0x1E2F;
  10733. t['idieresiscyrillic'] = 0x04E5;
  10734. t['idotbelow'] = 0x1ECB;
  10735. t['iebrevecyrillic'] = 0x04D7;
  10736. t['iecyrillic'] = 0x0435;
  10737. t['ieungacirclekorean'] = 0x3275;
  10738. t['ieungaparenkorean'] = 0x3215;
  10739. t['ieungcirclekorean'] = 0x3267;
  10740. t['ieungkorean'] = 0x3147;
  10741. t['ieungparenkorean'] = 0x3207;
  10742. t['igrave'] = 0x00EC;
  10743. t['igujarati'] = 0x0A87;
  10744. t['igurmukhi'] = 0x0A07;
  10745. t['ihiragana'] = 0x3044;
  10746. t['ihookabove'] = 0x1EC9;
  10747. t['iibengali'] = 0x0988;
  10748. t['iicyrillic'] = 0x0438;
  10749. t['iideva'] = 0x0908;
  10750. t['iigujarati'] = 0x0A88;
  10751. t['iigurmukhi'] = 0x0A08;
  10752. t['iimatragurmukhi'] = 0x0A40;
  10753. t['iinvertedbreve'] = 0x020B;
  10754. t['iishortcyrillic'] = 0x0439;
  10755. t['iivowelsignbengali'] = 0x09C0;
  10756. t['iivowelsigndeva'] = 0x0940;
  10757. t['iivowelsigngujarati'] = 0x0AC0;
  10758. t['ij'] = 0x0133;
  10759. t['ikatakana'] = 0x30A4;
  10760. t['ikatakanahalfwidth'] = 0xFF72;
  10761. t['ikorean'] = 0x3163;
  10762. t['ilde'] = 0x02DC;
  10763. t['iluyhebrew'] = 0x05AC;
  10764. t['imacron'] = 0x012B;
  10765. t['imacroncyrillic'] = 0x04E3;
  10766. t['imageorapproximatelyequal'] = 0x2253;
  10767. t['imatragurmukhi'] = 0x0A3F;
  10768. t['imonospace'] = 0xFF49;
  10769. t['increment'] = 0x2206;
  10770. t['infinity'] = 0x221E;
  10771. t['iniarmenian'] = 0x056B;
  10772. t['integral'] = 0x222B;
  10773. t['integralbottom'] = 0x2321;
  10774. t['integralbt'] = 0x2321;
  10775. t['integralex'] = 0xF8F5;
  10776. t['integraltop'] = 0x2320;
  10777. t['integraltp'] = 0x2320;
  10778. t['intersection'] = 0x2229;
  10779. t['intisquare'] = 0x3305;
  10780. t['invbullet'] = 0x25D8;
  10781. t['invcircle'] = 0x25D9;
  10782. t['invsmileface'] = 0x263B;
  10783. t['iocyrillic'] = 0x0451;
  10784. t['iogonek'] = 0x012F;
  10785. t['iota'] = 0x03B9;
  10786. t['iotadieresis'] = 0x03CA;
  10787. t['iotadieresistonos'] = 0x0390;
  10788. t['iotalatin'] = 0x0269;
  10789. t['iotatonos'] = 0x03AF;
  10790. t['iparen'] = 0x24A4;
  10791. t['irigurmukhi'] = 0x0A72;
  10792. t['ismallhiragana'] = 0x3043;
  10793. t['ismallkatakana'] = 0x30A3;
  10794. t['ismallkatakanahalfwidth'] = 0xFF68;
  10795. t['issharbengali'] = 0x09FA;
  10796. t['istroke'] = 0x0268;
  10797. t['isuperior'] = 0xF6ED;
  10798. t['iterationhiragana'] = 0x309D;
  10799. t['iterationkatakana'] = 0x30FD;
  10800. t['itilde'] = 0x0129;
  10801. t['itildebelow'] = 0x1E2D;
  10802. t['iubopomofo'] = 0x3129;
  10803. t['iucyrillic'] = 0x044E;
  10804. t['ivowelsignbengali'] = 0x09BF;
  10805. t['ivowelsigndeva'] = 0x093F;
  10806. t['ivowelsigngujarati'] = 0x0ABF;
  10807. t['izhitsacyrillic'] = 0x0475;
  10808. t['izhitsadblgravecyrillic'] = 0x0477;
  10809. t['j'] = 0x006A;
  10810. t['jaarmenian'] = 0x0571;
  10811. t['jabengali'] = 0x099C;
  10812. t['jadeva'] = 0x091C;
  10813. t['jagujarati'] = 0x0A9C;
  10814. t['jagurmukhi'] = 0x0A1C;
  10815. t['jbopomofo'] = 0x3110;
  10816. t['jcaron'] = 0x01F0;
  10817. t['jcircle'] = 0x24D9;
  10818. t['jcircumflex'] = 0x0135;
  10819. t['jcrossedtail'] = 0x029D;
  10820. t['jdotlessstroke'] = 0x025F;
  10821. t['jecyrillic'] = 0x0458;
  10822. t['jeemarabic'] = 0x062C;
  10823. t['jeemfinalarabic'] = 0xFE9E;
  10824. t['jeeminitialarabic'] = 0xFE9F;
  10825. t['jeemmedialarabic'] = 0xFEA0;
  10826. t['jeharabic'] = 0x0698;
  10827. t['jehfinalarabic'] = 0xFB8B;
  10828. t['jhabengali'] = 0x099D;
  10829. t['jhadeva'] = 0x091D;
  10830. t['jhagujarati'] = 0x0A9D;
  10831. t['jhagurmukhi'] = 0x0A1D;
  10832. t['jheharmenian'] = 0x057B;
  10833. t['jis'] = 0x3004;
  10834. t['jmonospace'] = 0xFF4A;
  10835. t['jparen'] = 0x24A5;
  10836. t['jsuperior'] = 0x02B2;
  10837. t['k'] = 0x006B;
  10838. t['kabashkircyrillic'] = 0x04A1;
  10839. t['kabengali'] = 0x0995;
  10840. t['kacute'] = 0x1E31;
  10841. t['kacyrillic'] = 0x043A;
  10842. t['kadescendercyrillic'] = 0x049B;
  10843. t['kadeva'] = 0x0915;
  10844. t['kaf'] = 0x05DB;
  10845. t['kafarabic'] = 0x0643;
  10846. t['kafdagesh'] = 0xFB3B;
  10847. t['kafdageshhebrew'] = 0xFB3B;
  10848. t['kaffinalarabic'] = 0xFEDA;
  10849. t['kafhebrew'] = 0x05DB;
  10850. t['kafinitialarabic'] = 0xFEDB;
  10851. t['kafmedialarabic'] = 0xFEDC;
  10852. t['kafrafehebrew'] = 0xFB4D;
  10853. t['kagujarati'] = 0x0A95;
  10854. t['kagurmukhi'] = 0x0A15;
  10855. t['kahiragana'] = 0x304B;
  10856. t['kahookcyrillic'] = 0x04C4;
  10857. t['kakatakana'] = 0x30AB;
  10858. t['kakatakanahalfwidth'] = 0xFF76;
  10859. t['kappa'] = 0x03BA;
  10860. t['kappasymbolgreek'] = 0x03F0;
  10861. t['kapyeounmieumkorean'] = 0x3171;
  10862. t['kapyeounphieuphkorean'] = 0x3184;
  10863. t['kapyeounpieupkorean'] = 0x3178;
  10864. t['kapyeounssangpieupkorean'] = 0x3179;
  10865. t['karoriisquare'] = 0x330D;
  10866. t['kashidaautoarabic'] = 0x0640;
  10867. t['kashidaautonosidebearingarabic'] = 0x0640;
  10868. t['kasmallkatakana'] = 0x30F5;
  10869. t['kasquare'] = 0x3384;
  10870. t['kasraarabic'] = 0x0650;
  10871. t['kasratanarabic'] = 0x064D;
  10872. t['kastrokecyrillic'] = 0x049F;
  10873. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10874. t['kaverticalstrokecyrillic'] = 0x049D;
  10875. t['kbopomofo'] = 0x310E;
  10876. t['kcalsquare'] = 0x3389;
  10877. t['kcaron'] = 0x01E9;
  10878. t['kcedilla'] = 0x0137;
  10879. t['kcircle'] = 0x24DA;
  10880. t['kcommaaccent'] = 0x0137;
  10881. t['kdotbelow'] = 0x1E33;
  10882. t['keharmenian'] = 0x0584;
  10883. t['kehiragana'] = 0x3051;
  10884. t['kekatakana'] = 0x30B1;
  10885. t['kekatakanahalfwidth'] = 0xFF79;
  10886. t['kenarmenian'] = 0x056F;
  10887. t['kesmallkatakana'] = 0x30F6;
  10888. t['kgreenlandic'] = 0x0138;
  10889. t['khabengali'] = 0x0996;
  10890. t['khacyrillic'] = 0x0445;
  10891. t['khadeva'] = 0x0916;
  10892. t['khagujarati'] = 0x0A96;
  10893. t['khagurmukhi'] = 0x0A16;
  10894. t['khaharabic'] = 0x062E;
  10895. t['khahfinalarabic'] = 0xFEA6;
  10896. t['khahinitialarabic'] = 0xFEA7;
  10897. t['khahmedialarabic'] = 0xFEA8;
  10898. t['kheicoptic'] = 0x03E7;
  10899. t['khhadeva'] = 0x0959;
  10900. t['khhagurmukhi'] = 0x0A59;
  10901. t['khieukhacirclekorean'] = 0x3278;
  10902. t['khieukhaparenkorean'] = 0x3218;
  10903. t['khieukhcirclekorean'] = 0x326A;
  10904. t['khieukhkorean'] = 0x314B;
  10905. t['khieukhparenkorean'] = 0x320A;
  10906. t['khokhaithai'] = 0x0E02;
  10907. t['khokhonthai'] = 0x0E05;
  10908. t['khokhuatthai'] = 0x0E03;
  10909. t['khokhwaithai'] = 0x0E04;
  10910. t['khomutthai'] = 0x0E5B;
  10911. t['khook'] = 0x0199;
  10912. t['khorakhangthai'] = 0x0E06;
  10913. t['khzsquare'] = 0x3391;
  10914. t['kihiragana'] = 0x304D;
  10915. t['kikatakana'] = 0x30AD;
  10916. t['kikatakanahalfwidth'] = 0xFF77;
  10917. t['kiroguramusquare'] = 0x3315;
  10918. t['kiromeetorusquare'] = 0x3316;
  10919. t['kirosquare'] = 0x3314;
  10920. t['kiyeokacirclekorean'] = 0x326E;
  10921. t['kiyeokaparenkorean'] = 0x320E;
  10922. t['kiyeokcirclekorean'] = 0x3260;
  10923. t['kiyeokkorean'] = 0x3131;
  10924. t['kiyeokparenkorean'] = 0x3200;
  10925. t['kiyeoksioskorean'] = 0x3133;
  10926. t['kjecyrillic'] = 0x045C;
  10927. t['klinebelow'] = 0x1E35;
  10928. t['klsquare'] = 0x3398;
  10929. t['kmcubedsquare'] = 0x33A6;
  10930. t['kmonospace'] = 0xFF4B;
  10931. t['kmsquaredsquare'] = 0x33A2;
  10932. t['kohiragana'] = 0x3053;
  10933. t['kohmsquare'] = 0x33C0;
  10934. t['kokaithai'] = 0x0E01;
  10935. t['kokatakana'] = 0x30B3;
  10936. t['kokatakanahalfwidth'] = 0xFF7A;
  10937. t['kooposquare'] = 0x331E;
  10938. t['koppacyrillic'] = 0x0481;
  10939. t['koreanstandardsymbol'] = 0x327F;
  10940. t['koroniscmb'] = 0x0343;
  10941. t['kparen'] = 0x24A6;
  10942. t['kpasquare'] = 0x33AA;
  10943. t['ksicyrillic'] = 0x046F;
  10944. t['ktsquare'] = 0x33CF;
  10945. t['kturned'] = 0x029E;
  10946. t['kuhiragana'] = 0x304F;
  10947. t['kukatakana'] = 0x30AF;
  10948. t['kukatakanahalfwidth'] = 0xFF78;
  10949. t['kvsquare'] = 0x33B8;
  10950. t['kwsquare'] = 0x33BE;
  10951. t['l'] = 0x006C;
  10952. t['labengali'] = 0x09B2;
  10953. t['lacute'] = 0x013A;
  10954. t['ladeva'] = 0x0932;
  10955. t['lagujarati'] = 0x0AB2;
  10956. t['lagurmukhi'] = 0x0A32;
  10957. t['lakkhangyaothai'] = 0x0E45;
  10958. t['lamaleffinalarabic'] = 0xFEFC;
  10959. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10960. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10961. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10962. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10963. t['lamalefisolatedarabic'] = 0xFEFB;
  10964. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10965. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10966. t['lamarabic'] = 0x0644;
  10967. t['lambda'] = 0x03BB;
  10968. t['lambdastroke'] = 0x019B;
  10969. t['lamed'] = 0x05DC;
  10970. t['lameddagesh'] = 0xFB3C;
  10971. t['lameddageshhebrew'] = 0xFB3C;
  10972. t['lamedhebrew'] = 0x05DC;
  10973. t['lamfinalarabic'] = 0xFEDE;
  10974. t['lamhahinitialarabic'] = 0xFCCA;
  10975. t['laminitialarabic'] = 0xFEDF;
  10976. t['lamjeeminitialarabic'] = 0xFCC9;
  10977. t['lamkhahinitialarabic'] = 0xFCCB;
  10978. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10979. t['lammedialarabic'] = 0xFEE0;
  10980. t['lammeemhahinitialarabic'] = 0xFD88;
  10981. t['lammeeminitialarabic'] = 0xFCCC;
  10982. t['largecircle'] = 0x25EF;
  10983. t['lbar'] = 0x019A;
  10984. t['lbelt'] = 0x026C;
  10985. t['lbopomofo'] = 0x310C;
  10986. t['lcaron'] = 0x013E;
  10987. t['lcedilla'] = 0x013C;
  10988. t['lcircle'] = 0x24DB;
  10989. t['lcircumflexbelow'] = 0x1E3D;
  10990. t['lcommaaccent'] = 0x013C;
  10991. t['ldot'] = 0x0140;
  10992. t['ldotaccent'] = 0x0140;
  10993. t['ldotbelow'] = 0x1E37;
  10994. t['ldotbelowmacron'] = 0x1E39;
  10995. t['leftangleabovecmb'] = 0x031A;
  10996. t['lefttackbelowcmb'] = 0x0318;
  10997. t['less'] = 0x003C;
  10998. t['lessequal'] = 0x2264;
  10999. t['lessequalorgreater'] = 0x22DA;
  11000. t['lessmonospace'] = 0xFF1C;
  11001. t['lessorequivalent'] = 0x2272;
  11002. t['lessorgreater'] = 0x2276;
  11003. t['lessoverequal'] = 0x2266;
  11004. t['lesssmall'] = 0xFE64;
  11005. t['lezh'] = 0x026E;
  11006. t['lfblock'] = 0x258C;
  11007. t['lhookretroflex'] = 0x026D;
  11008. t['lira'] = 0x20A4;
  11009. t['liwnarmenian'] = 0x056C;
  11010. t['lj'] = 0x01C9;
  11011. t['ljecyrillic'] = 0x0459;
  11012. t['ll'] = 0xF6C0;
  11013. t['lladeva'] = 0x0933;
  11014. t['llagujarati'] = 0x0AB3;
  11015. t['llinebelow'] = 0x1E3B;
  11016. t['llladeva'] = 0x0934;
  11017. t['llvocalicbengali'] = 0x09E1;
  11018. t['llvocalicdeva'] = 0x0961;
  11019. t['llvocalicvowelsignbengali'] = 0x09E3;
  11020. t['llvocalicvowelsigndeva'] = 0x0963;
  11021. t['lmiddletilde'] = 0x026B;
  11022. t['lmonospace'] = 0xFF4C;
  11023. t['lmsquare'] = 0x33D0;
  11024. t['lochulathai'] = 0x0E2C;
  11025. t['logicaland'] = 0x2227;
  11026. t['logicalnot'] = 0x00AC;
  11027. t['logicalnotreversed'] = 0x2310;
  11028. t['logicalor'] = 0x2228;
  11029. t['lolingthai'] = 0x0E25;
  11030. t['longs'] = 0x017F;
  11031. t['lowlinecenterline'] = 0xFE4E;
  11032. t['lowlinecmb'] = 0x0332;
  11033. t['lowlinedashed'] = 0xFE4D;
  11034. t['lozenge'] = 0x25CA;
  11035. t['lparen'] = 0x24A7;
  11036. t['lslash'] = 0x0142;
  11037. t['lsquare'] = 0x2113;
  11038. t['lsuperior'] = 0xF6EE;
  11039. t['ltshade'] = 0x2591;
  11040. t['luthai'] = 0x0E26;
  11041. t['lvocalicbengali'] = 0x098C;
  11042. t['lvocalicdeva'] = 0x090C;
  11043. t['lvocalicvowelsignbengali'] = 0x09E2;
  11044. t['lvocalicvowelsigndeva'] = 0x0962;
  11045. t['lxsquare'] = 0x33D3;
  11046. t['m'] = 0x006D;
  11047. t['mabengali'] = 0x09AE;
  11048. t['macron'] = 0x00AF;
  11049. t['macronbelowcmb'] = 0x0331;
  11050. t['macroncmb'] = 0x0304;
  11051. t['macronlowmod'] = 0x02CD;
  11052. t['macronmonospace'] = 0xFFE3;
  11053. t['macute'] = 0x1E3F;
  11054. t['madeva'] = 0x092E;
  11055. t['magujarati'] = 0x0AAE;
  11056. t['magurmukhi'] = 0x0A2E;
  11057. t['mahapakhhebrew'] = 0x05A4;
  11058. t['mahapakhlefthebrew'] = 0x05A4;
  11059. t['mahiragana'] = 0x307E;
  11060. t['maichattawalowleftthai'] = 0xF895;
  11061. t['maichattawalowrightthai'] = 0xF894;
  11062. t['maichattawathai'] = 0x0E4B;
  11063. t['maichattawaupperleftthai'] = 0xF893;
  11064. t['maieklowleftthai'] = 0xF88C;
  11065. t['maieklowrightthai'] = 0xF88B;
  11066. t['maiekthai'] = 0x0E48;
  11067. t['maiekupperleftthai'] = 0xF88A;
  11068. t['maihanakatleftthai'] = 0xF884;
  11069. t['maihanakatthai'] = 0x0E31;
  11070. t['maitaikhuleftthai'] = 0xF889;
  11071. t['maitaikhuthai'] = 0x0E47;
  11072. t['maitholowleftthai'] = 0xF88F;
  11073. t['maitholowrightthai'] = 0xF88E;
  11074. t['maithothai'] = 0x0E49;
  11075. t['maithoupperleftthai'] = 0xF88D;
  11076. t['maitrilowleftthai'] = 0xF892;
  11077. t['maitrilowrightthai'] = 0xF891;
  11078. t['maitrithai'] = 0x0E4A;
  11079. t['maitriupperleftthai'] = 0xF890;
  11080. t['maiyamokthai'] = 0x0E46;
  11081. t['makatakana'] = 0x30DE;
  11082. t['makatakanahalfwidth'] = 0xFF8F;
  11083. t['male'] = 0x2642;
  11084. t['mansyonsquare'] = 0x3347;
  11085. t['maqafhebrew'] = 0x05BE;
  11086. t['mars'] = 0x2642;
  11087. t['masoracirclehebrew'] = 0x05AF;
  11088. t['masquare'] = 0x3383;
  11089. t['mbopomofo'] = 0x3107;
  11090. t['mbsquare'] = 0x33D4;
  11091. t['mcircle'] = 0x24DC;
  11092. t['mcubedsquare'] = 0x33A5;
  11093. t['mdotaccent'] = 0x1E41;
  11094. t['mdotbelow'] = 0x1E43;
  11095. t['meemarabic'] = 0x0645;
  11096. t['meemfinalarabic'] = 0xFEE2;
  11097. t['meeminitialarabic'] = 0xFEE3;
  11098. t['meemmedialarabic'] = 0xFEE4;
  11099. t['meemmeeminitialarabic'] = 0xFCD1;
  11100. t['meemmeemisolatedarabic'] = 0xFC48;
  11101. t['meetorusquare'] = 0x334D;
  11102. t['mehiragana'] = 0x3081;
  11103. t['meizierasquare'] = 0x337E;
  11104. t['mekatakana'] = 0x30E1;
  11105. t['mekatakanahalfwidth'] = 0xFF92;
  11106. t['mem'] = 0x05DE;
  11107. t['memdagesh'] = 0xFB3E;
  11108. t['memdageshhebrew'] = 0xFB3E;
  11109. t['memhebrew'] = 0x05DE;
  11110. t['menarmenian'] = 0x0574;
  11111. t['merkhahebrew'] = 0x05A5;
  11112. t['merkhakefulahebrew'] = 0x05A6;
  11113. t['merkhakefulalefthebrew'] = 0x05A6;
  11114. t['merkhalefthebrew'] = 0x05A5;
  11115. t['mhook'] = 0x0271;
  11116. t['mhzsquare'] = 0x3392;
  11117. t['middledotkatakanahalfwidth'] = 0xFF65;
  11118. t['middot'] = 0x00B7;
  11119. t['mieumacirclekorean'] = 0x3272;
  11120. t['mieumaparenkorean'] = 0x3212;
  11121. t['mieumcirclekorean'] = 0x3264;
  11122. t['mieumkorean'] = 0x3141;
  11123. t['mieumpansioskorean'] = 0x3170;
  11124. t['mieumparenkorean'] = 0x3204;
  11125. t['mieumpieupkorean'] = 0x316E;
  11126. t['mieumsioskorean'] = 0x316F;
  11127. t['mihiragana'] = 0x307F;
  11128. t['mikatakana'] = 0x30DF;
  11129. t['mikatakanahalfwidth'] = 0xFF90;
  11130. t['minus'] = 0x2212;
  11131. t['minusbelowcmb'] = 0x0320;
  11132. t['minuscircle'] = 0x2296;
  11133. t['minusmod'] = 0x02D7;
  11134. t['minusplus'] = 0x2213;
  11135. t['minute'] = 0x2032;
  11136. t['miribaarusquare'] = 0x334A;
  11137. t['mirisquare'] = 0x3349;
  11138. t['mlonglegturned'] = 0x0270;
  11139. t['mlsquare'] = 0x3396;
  11140. t['mmcubedsquare'] = 0x33A3;
  11141. t['mmonospace'] = 0xFF4D;
  11142. t['mmsquaredsquare'] = 0x339F;
  11143. t['mohiragana'] = 0x3082;
  11144. t['mohmsquare'] = 0x33C1;
  11145. t['mokatakana'] = 0x30E2;
  11146. t['mokatakanahalfwidth'] = 0xFF93;
  11147. t['molsquare'] = 0x33D6;
  11148. t['momathai'] = 0x0E21;
  11149. t['moverssquare'] = 0x33A7;
  11150. t['moverssquaredsquare'] = 0x33A8;
  11151. t['mparen'] = 0x24A8;
  11152. t['mpasquare'] = 0x33AB;
  11153. t['mssquare'] = 0x33B3;
  11154. t['msuperior'] = 0xF6EF;
  11155. t['mturned'] = 0x026F;
  11156. t['mu'] = 0x00B5;
  11157. t['mu1'] = 0x00B5;
  11158. t['muasquare'] = 0x3382;
  11159. t['muchgreater'] = 0x226B;
  11160. t['muchless'] = 0x226A;
  11161. t['mufsquare'] = 0x338C;
  11162. t['mugreek'] = 0x03BC;
  11163. t['mugsquare'] = 0x338D;
  11164. t['muhiragana'] = 0x3080;
  11165. t['mukatakana'] = 0x30E0;
  11166. t['mukatakanahalfwidth'] = 0xFF91;
  11167. t['mulsquare'] = 0x3395;
  11168. t['multiply'] = 0x00D7;
  11169. t['mumsquare'] = 0x339B;
  11170. t['munahhebrew'] = 0x05A3;
  11171. t['munahlefthebrew'] = 0x05A3;
  11172. t['musicalnote'] = 0x266A;
  11173. t['musicalnotedbl'] = 0x266B;
  11174. t['musicflatsign'] = 0x266D;
  11175. t['musicsharpsign'] = 0x266F;
  11176. t['mussquare'] = 0x33B2;
  11177. t['muvsquare'] = 0x33B6;
  11178. t['muwsquare'] = 0x33BC;
  11179. t['mvmegasquare'] = 0x33B9;
  11180. t['mvsquare'] = 0x33B7;
  11181. t['mwmegasquare'] = 0x33BF;
  11182. t['mwsquare'] = 0x33BD;
  11183. t['n'] = 0x006E;
  11184. t['nabengali'] = 0x09A8;
  11185. t['nabla'] = 0x2207;
  11186. t['nacute'] = 0x0144;
  11187. t['nadeva'] = 0x0928;
  11188. t['nagujarati'] = 0x0AA8;
  11189. t['nagurmukhi'] = 0x0A28;
  11190. t['nahiragana'] = 0x306A;
  11191. t['nakatakana'] = 0x30CA;
  11192. t['nakatakanahalfwidth'] = 0xFF85;
  11193. t['napostrophe'] = 0x0149;
  11194. t['nasquare'] = 0x3381;
  11195. t['nbopomofo'] = 0x310B;
  11196. t['nbspace'] = 0x00A0;
  11197. t['ncaron'] = 0x0148;
  11198. t['ncedilla'] = 0x0146;
  11199. t['ncircle'] = 0x24DD;
  11200. t['ncircumflexbelow'] = 0x1E4B;
  11201. t['ncommaaccent'] = 0x0146;
  11202. t['ndotaccent'] = 0x1E45;
  11203. t['ndotbelow'] = 0x1E47;
  11204. t['nehiragana'] = 0x306D;
  11205. t['nekatakana'] = 0x30CD;
  11206. t['nekatakanahalfwidth'] = 0xFF88;
  11207. t['newsheqelsign'] = 0x20AA;
  11208. t['nfsquare'] = 0x338B;
  11209. t['ngabengali'] = 0x0999;
  11210. t['ngadeva'] = 0x0919;
  11211. t['ngagujarati'] = 0x0A99;
  11212. t['ngagurmukhi'] = 0x0A19;
  11213. t['ngonguthai'] = 0x0E07;
  11214. t['nhiragana'] = 0x3093;
  11215. t['nhookleft'] = 0x0272;
  11216. t['nhookretroflex'] = 0x0273;
  11217. t['nieunacirclekorean'] = 0x326F;
  11218. t['nieunaparenkorean'] = 0x320F;
  11219. t['nieuncieuckorean'] = 0x3135;
  11220. t['nieuncirclekorean'] = 0x3261;
  11221. t['nieunhieuhkorean'] = 0x3136;
  11222. t['nieunkorean'] = 0x3134;
  11223. t['nieunpansioskorean'] = 0x3168;
  11224. t['nieunparenkorean'] = 0x3201;
  11225. t['nieunsioskorean'] = 0x3167;
  11226. t['nieuntikeutkorean'] = 0x3166;
  11227. t['nihiragana'] = 0x306B;
  11228. t['nikatakana'] = 0x30CB;
  11229. t['nikatakanahalfwidth'] = 0xFF86;
  11230. t['nikhahitleftthai'] = 0xF899;
  11231. t['nikhahitthai'] = 0x0E4D;
  11232. t['nine'] = 0x0039;
  11233. t['ninearabic'] = 0x0669;
  11234. t['ninebengali'] = 0x09EF;
  11235. t['ninecircle'] = 0x2468;
  11236. t['ninecircleinversesansserif'] = 0x2792;
  11237. t['ninedeva'] = 0x096F;
  11238. t['ninegujarati'] = 0x0AEF;
  11239. t['ninegurmukhi'] = 0x0A6F;
  11240. t['ninehackarabic'] = 0x0669;
  11241. t['ninehangzhou'] = 0x3029;
  11242. t['nineideographicparen'] = 0x3228;
  11243. t['nineinferior'] = 0x2089;
  11244. t['ninemonospace'] = 0xFF19;
  11245. t['nineoldstyle'] = 0xF739;
  11246. t['nineparen'] = 0x247C;
  11247. t['nineperiod'] = 0x2490;
  11248. t['ninepersian'] = 0x06F9;
  11249. t['nineroman'] = 0x2178;
  11250. t['ninesuperior'] = 0x2079;
  11251. t['nineteencircle'] = 0x2472;
  11252. t['nineteenparen'] = 0x2486;
  11253. t['nineteenperiod'] = 0x249A;
  11254. t['ninethai'] = 0x0E59;
  11255. t['nj'] = 0x01CC;
  11256. t['njecyrillic'] = 0x045A;
  11257. t['nkatakana'] = 0x30F3;
  11258. t['nkatakanahalfwidth'] = 0xFF9D;
  11259. t['nlegrightlong'] = 0x019E;
  11260. t['nlinebelow'] = 0x1E49;
  11261. t['nmonospace'] = 0xFF4E;
  11262. t['nmsquare'] = 0x339A;
  11263. t['nnabengali'] = 0x09A3;
  11264. t['nnadeva'] = 0x0923;
  11265. t['nnagujarati'] = 0x0AA3;
  11266. t['nnagurmukhi'] = 0x0A23;
  11267. t['nnnadeva'] = 0x0929;
  11268. t['nohiragana'] = 0x306E;
  11269. t['nokatakana'] = 0x30CE;
  11270. t['nokatakanahalfwidth'] = 0xFF89;
  11271. t['nonbreakingspace'] = 0x00A0;
  11272. t['nonenthai'] = 0x0E13;
  11273. t['nonuthai'] = 0x0E19;
  11274. t['noonarabic'] = 0x0646;
  11275. t['noonfinalarabic'] = 0xFEE6;
  11276. t['noonghunnaarabic'] = 0x06BA;
  11277. t['noonghunnafinalarabic'] = 0xFB9F;
  11278. t['nooninitialarabic'] = 0xFEE7;
  11279. t['noonjeeminitialarabic'] = 0xFCD2;
  11280. t['noonjeemisolatedarabic'] = 0xFC4B;
  11281. t['noonmedialarabic'] = 0xFEE8;
  11282. t['noonmeeminitialarabic'] = 0xFCD5;
  11283. t['noonmeemisolatedarabic'] = 0xFC4E;
  11284. t['noonnoonfinalarabic'] = 0xFC8D;
  11285. t['notcontains'] = 0x220C;
  11286. t['notelement'] = 0x2209;
  11287. t['notelementof'] = 0x2209;
  11288. t['notequal'] = 0x2260;
  11289. t['notgreater'] = 0x226F;
  11290. t['notgreaternorequal'] = 0x2271;
  11291. t['notgreaternorless'] = 0x2279;
  11292. t['notidentical'] = 0x2262;
  11293. t['notless'] = 0x226E;
  11294. t['notlessnorequal'] = 0x2270;
  11295. t['notparallel'] = 0x2226;
  11296. t['notprecedes'] = 0x2280;
  11297. t['notsubset'] = 0x2284;
  11298. t['notsucceeds'] = 0x2281;
  11299. t['notsuperset'] = 0x2285;
  11300. t['nowarmenian'] = 0x0576;
  11301. t['nparen'] = 0x24A9;
  11302. t['nssquare'] = 0x33B1;
  11303. t['nsuperior'] = 0x207F;
  11304. t['ntilde'] = 0x00F1;
  11305. t['nu'] = 0x03BD;
  11306. t['nuhiragana'] = 0x306C;
  11307. t['nukatakana'] = 0x30CC;
  11308. t['nukatakanahalfwidth'] = 0xFF87;
  11309. t['nuktabengali'] = 0x09BC;
  11310. t['nuktadeva'] = 0x093C;
  11311. t['nuktagujarati'] = 0x0ABC;
  11312. t['nuktagurmukhi'] = 0x0A3C;
  11313. t['numbersign'] = 0x0023;
  11314. t['numbersignmonospace'] = 0xFF03;
  11315. t['numbersignsmall'] = 0xFE5F;
  11316. t['numeralsigngreek'] = 0x0374;
  11317. t['numeralsignlowergreek'] = 0x0375;
  11318. t['numero'] = 0x2116;
  11319. t['nun'] = 0x05E0;
  11320. t['nundagesh'] = 0xFB40;
  11321. t['nundageshhebrew'] = 0xFB40;
  11322. t['nunhebrew'] = 0x05E0;
  11323. t['nvsquare'] = 0x33B5;
  11324. t['nwsquare'] = 0x33BB;
  11325. t['nyabengali'] = 0x099E;
  11326. t['nyadeva'] = 0x091E;
  11327. t['nyagujarati'] = 0x0A9E;
  11328. t['nyagurmukhi'] = 0x0A1E;
  11329. t['o'] = 0x006F;
  11330. t['oacute'] = 0x00F3;
  11331. t['oangthai'] = 0x0E2D;
  11332. t['obarred'] = 0x0275;
  11333. t['obarredcyrillic'] = 0x04E9;
  11334. t['obarreddieresiscyrillic'] = 0x04EB;
  11335. t['obengali'] = 0x0993;
  11336. t['obopomofo'] = 0x311B;
  11337. t['obreve'] = 0x014F;
  11338. t['ocandradeva'] = 0x0911;
  11339. t['ocandragujarati'] = 0x0A91;
  11340. t['ocandravowelsigndeva'] = 0x0949;
  11341. t['ocandravowelsigngujarati'] = 0x0AC9;
  11342. t['ocaron'] = 0x01D2;
  11343. t['ocircle'] = 0x24DE;
  11344. t['ocircumflex'] = 0x00F4;
  11345. t['ocircumflexacute'] = 0x1ED1;
  11346. t['ocircumflexdotbelow'] = 0x1ED9;
  11347. t['ocircumflexgrave'] = 0x1ED3;
  11348. t['ocircumflexhookabove'] = 0x1ED5;
  11349. t['ocircumflextilde'] = 0x1ED7;
  11350. t['ocyrillic'] = 0x043E;
  11351. t['odblacute'] = 0x0151;
  11352. t['odblgrave'] = 0x020D;
  11353. t['odeva'] = 0x0913;
  11354. t['odieresis'] = 0x00F6;
  11355. t['odieresiscyrillic'] = 0x04E7;
  11356. t['odotbelow'] = 0x1ECD;
  11357. t['oe'] = 0x0153;
  11358. t['oekorean'] = 0x315A;
  11359. t['ogonek'] = 0x02DB;
  11360. t['ogonekcmb'] = 0x0328;
  11361. t['ograve'] = 0x00F2;
  11362. t['ogujarati'] = 0x0A93;
  11363. t['oharmenian'] = 0x0585;
  11364. t['ohiragana'] = 0x304A;
  11365. t['ohookabove'] = 0x1ECF;
  11366. t['ohorn'] = 0x01A1;
  11367. t['ohornacute'] = 0x1EDB;
  11368. t['ohorndotbelow'] = 0x1EE3;
  11369. t['ohorngrave'] = 0x1EDD;
  11370. t['ohornhookabove'] = 0x1EDF;
  11371. t['ohorntilde'] = 0x1EE1;
  11372. t['ohungarumlaut'] = 0x0151;
  11373. t['oi'] = 0x01A3;
  11374. t['oinvertedbreve'] = 0x020F;
  11375. t['okatakana'] = 0x30AA;
  11376. t['okatakanahalfwidth'] = 0xFF75;
  11377. t['okorean'] = 0x3157;
  11378. t['olehebrew'] = 0x05AB;
  11379. t['omacron'] = 0x014D;
  11380. t['omacronacute'] = 0x1E53;
  11381. t['omacrongrave'] = 0x1E51;
  11382. t['omdeva'] = 0x0950;
  11383. t['omega'] = 0x03C9;
  11384. t['omega1'] = 0x03D6;
  11385. t['omegacyrillic'] = 0x0461;
  11386. t['omegalatinclosed'] = 0x0277;
  11387. t['omegaroundcyrillic'] = 0x047B;
  11388. t['omegatitlocyrillic'] = 0x047D;
  11389. t['omegatonos'] = 0x03CE;
  11390. t['omgujarati'] = 0x0AD0;
  11391. t['omicron'] = 0x03BF;
  11392. t['omicrontonos'] = 0x03CC;
  11393. t['omonospace'] = 0xFF4F;
  11394. t['one'] = 0x0031;
  11395. t['onearabic'] = 0x0661;
  11396. t['onebengali'] = 0x09E7;
  11397. t['onecircle'] = 0x2460;
  11398. t['onecircleinversesansserif'] = 0x278A;
  11399. t['onedeva'] = 0x0967;
  11400. t['onedotenleader'] = 0x2024;
  11401. t['oneeighth'] = 0x215B;
  11402. t['onefitted'] = 0xF6DC;
  11403. t['onegujarati'] = 0x0AE7;
  11404. t['onegurmukhi'] = 0x0A67;
  11405. t['onehackarabic'] = 0x0661;
  11406. t['onehalf'] = 0x00BD;
  11407. t['onehangzhou'] = 0x3021;
  11408. t['oneideographicparen'] = 0x3220;
  11409. t['oneinferior'] = 0x2081;
  11410. t['onemonospace'] = 0xFF11;
  11411. t['onenumeratorbengali'] = 0x09F4;
  11412. t['oneoldstyle'] = 0xF731;
  11413. t['oneparen'] = 0x2474;
  11414. t['oneperiod'] = 0x2488;
  11415. t['onepersian'] = 0x06F1;
  11416. t['onequarter'] = 0x00BC;
  11417. t['oneroman'] = 0x2170;
  11418. t['onesuperior'] = 0x00B9;
  11419. t['onethai'] = 0x0E51;
  11420. t['onethird'] = 0x2153;
  11421. t['oogonek'] = 0x01EB;
  11422. t['oogonekmacron'] = 0x01ED;
  11423. t['oogurmukhi'] = 0x0A13;
  11424. t['oomatragurmukhi'] = 0x0A4B;
  11425. t['oopen'] = 0x0254;
  11426. t['oparen'] = 0x24AA;
  11427. t['openbullet'] = 0x25E6;
  11428. t['option'] = 0x2325;
  11429. t['ordfeminine'] = 0x00AA;
  11430. t['ordmasculine'] = 0x00BA;
  11431. t['orthogonal'] = 0x221F;
  11432. t['oshortdeva'] = 0x0912;
  11433. t['oshortvowelsigndeva'] = 0x094A;
  11434. t['oslash'] = 0x00F8;
  11435. t['oslashacute'] = 0x01FF;
  11436. t['osmallhiragana'] = 0x3049;
  11437. t['osmallkatakana'] = 0x30A9;
  11438. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11439. t['ostrokeacute'] = 0x01FF;
  11440. t['osuperior'] = 0xF6F0;
  11441. t['otcyrillic'] = 0x047F;
  11442. t['otilde'] = 0x00F5;
  11443. t['otildeacute'] = 0x1E4D;
  11444. t['otildedieresis'] = 0x1E4F;
  11445. t['oubopomofo'] = 0x3121;
  11446. t['overline'] = 0x203E;
  11447. t['overlinecenterline'] = 0xFE4A;
  11448. t['overlinecmb'] = 0x0305;
  11449. t['overlinedashed'] = 0xFE49;
  11450. t['overlinedblwavy'] = 0xFE4C;
  11451. t['overlinewavy'] = 0xFE4B;
  11452. t['overscore'] = 0x00AF;
  11453. t['ovowelsignbengali'] = 0x09CB;
  11454. t['ovowelsigndeva'] = 0x094B;
  11455. t['ovowelsigngujarati'] = 0x0ACB;
  11456. t['p'] = 0x0070;
  11457. t['paampssquare'] = 0x3380;
  11458. t['paasentosquare'] = 0x332B;
  11459. t['pabengali'] = 0x09AA;
  11460. t['pacute'] = 0x1E55;
  11461. t['padeva'] = 0x092A;
  11462. t['pagedown'] = 0x21DF;
  11463. t['pageup'] = 0x21DE;
  11464. t['pagujarati'] = 0x0AAA;
  11465. t['pagurmukhi'] = 0x0A2A;
  11466. t['pahiragana'] = 0x3071;
  11467. t['paiyannoithai'] = 0x0E2F;
  11468. t['pakatakana'] = 0x30D1;
  11469. t['palatalizationcyrilliccmb'] = 0x0484;
  11470. t['palochkacyrillic'] = 0x04C0;
  11471. t['pansioskorean'] = 0x317F;
  11472. t['paragraph'] = 0x00B6;
  11473. t['parallel'] = 0x2225;
  11474. t['parenleft'] = 0x0028;
  11475. t['parenleftaltonearabic'] = 0xFD3E;
  11476. t['parenleftbt'] = 0xF8ED;
  11477. t['parenleftex'] = 0xF8EC;
  11478. t['parenleftinferior'] = 0x208D;
  11479. t['parenleftmonospace'] = 0xFF08;
  11480. t['parenleftsmall'] = 0xFE59;
  11481. t['parenleftsuperior'] = 0x207D;
  11482. t['parenlefttp'] = 0xF8EB;
  11483. t['parenleftvertical'] = 0xFE35;
  11484. t['parenright'] = 0x0029;
  11485. t['parenrightaltonearabic'] = 0xFD3F;
  11486. t['parenrightbt'] = 0xF8F8;
  11487. t['parenrightex'] = 0xF8F7;
  11488. t['parenrightinferior'] = 0x208E;
  11489. t['parenrightmonospace'] = 0xFF09;
  11490. t['parenrightsmall'] = 0xFE5A;
  11491. t['parenrightsuperior'] = 0x207E;
  11492. t['parenrighttp'] = 0xF8F6;
  11493. t['parenrightvertical'] = 0xFE36;
  11494. t['partialdiff'] = 0x2202;
  11495. t['paseqhebrew'] = 0x05C0;
  11496. t['pashtahebrew'] = 0x0599;
  11497. t['pasquare'] = 0x33A9;
  11498. t['patah'] = 0x05B7;
  11499. t['patah11'] = 0x05B7;
  11500. t['patah1d'] = 0x05B7;
  11501. t['patah2a'] = 0x05B7;
  11502. t['patahhebrew'] = 0x05B7;
  11503. t['patahnarrowhebrew'] = 0x05B7;
  11504. t['patahquarterhebrew'] = 0x05B7;
  11505. t['patahwidehebrew'] = 0x05B7;
  11506. t['pazerhebrew'] = 0x05A1;
  11507. t['pbopomofo'] = 0x3106;
  11508. t['pcircle'] = 0x24DF;
  11509. t['pdotaccent'] = 0x1E57;
  11510. t['pe'] = 0x05E4;
  11511. t['pecyrillic'] = 0x043F;
  11512. t['pedagesh'] = 0xFB44;
  11513. t['pedageshhebrew'] = 0xFB44;
  11514. t['peezisquare'] = 0x333B;
  11515. t['pefinaldageshhebrew'] = 0xFB43;
  11516. t['peharabic'] = 0x067E;
  11517. t['peharmenian'] = 0x057A;
  11518. t['pehebrew'] = 0x05E4;
  11519. t['pehfinalarabic'] = 0xFB57;
  11520. t['pehinitialarabic'] = 0xFB58;
  11521. t['pehiragana'] = 0x307A;
  11522. t['pehmedialarabic'] = 0xFB59;
  11523. t['pekatakana'] = 0x30DA;
  11524. t['pemiddlehookcyrillic'] = 0x04A7;
  11525. t['perafehebrew'] = 0xFB4E;
  11526. t['percent'] = 0x0025;
  11527. t['percentarabic'] = 0x066A;
  11528. t['percentmonospace'] = 0xFF05;
  11529. t['percentsmall'] = 0xFE6A;
  11530. t['period'] = 0x002E;
  11531. t['periodarmenian'] = 0x0589;
  11532. t['periodcentered'] = 0x00B7;
  11533. t['periodhalfwidth'] = 0xFF61;
  11534. t['periodinferior'] = 0xF6E7;
  11535. t['periodmonospace'] = 0xFF0E;
  11536. t['periodsmall'] = 0xFE52;
  11537. t['periodsuperior'] = 0xF6E8;
  11538. t['perispomenigreekcmb'] = 0x0342;
  11539. t['perpendicular'] = 0x22A5;
  11540. t['perthousand'] = 0x2030;
  11541. t['peseta'] = 0x20A7;
  11542. t['pfsquare'] = 0x338A;
  11543. t['phabengali'] = 0x09AB;
  11544. t['phadeva'] = 0x092B;
  11545. t['phagujarati'] = 0x0AAB;
  11546. t['phagurmukhi'] = 0x0A2B;
  11547. t['phi'] = 0x03C6;
  11548. t['phi1'] = 0x03D5;
  11549. t['phieuphacirclekorean'] = 0x327A;
  11550. t['phieuphaparenkorean'] = 0x321A;
  11551. t['phieuphcirclekorean'] = 0x326C;
  11552. t['phieuphkorean'] = 0x314D;
  11553. t['phieuphparenkorean'] = 0x320C;
  11554. t['philatin'] = 0x0278;
  11555. t['phinthuthai'] = 0x0E3A;
  11556. t['phisymbolgreek'] = 0x03D5;
  11557. t['phook'] = 0x01A5;
  11558. t['phophanthai'] = 0x0E1E;
  11559. t['phophungthai'] = 0x0E1C;
  11560. t['phosamphaothai'] = 0x0E20;
  11561. t['pi'] = 0x03C0;
  11562. t['pieupacirclekorean'] = 0x3273;
  11563. t['pieupaparenkorean'] = 0x3213;
  11564. t['pieupcieuckorean'] = 0x3176;
  11565. t['pieupcirclekorean'] = 0x3265;
  11566. t['pieupkiyeokkorean'] = 0x3172;
  11567. t['pieupkorean'] = 0x3142;
  11568. t['pieupparenkorean'] = 0x3205;
  11569. t['pieupsioskiyeokkorean'] = 0x3174;
  11570. t['pieupsioskorean'] = 0x3144;
  11571. t['pieupsiostikeutkorean'] = 0x3175;
  11572. t['pieupthieuthkorean'] = 0x3177;
  11573. t['pieuptikeutkorean'] = 0x3173;
  11574. t['pihiragana'] = 0x3074;
  11575. t['pikatakana'] = 0x30D4;
  11576. t['pisymbolgreek'] = 0x03D6;
  11577. t['piwrarmenian'] = 0x0583;
  11578. t['plus'] = 0x002B;
  11579. t['plusbelowcmb'] = 0x031F;
  11580. t['pluscircle'] = 0x2295;
  11581. t['plusminus'] = 0x00B1;
  11582. t['plusmod'] = 0x02D6;
  11583. t['plusmonospace'] = 0xFF0B;
  11584. t['plussmall'] = 0xFE62;
  11585. t['plussuperior'] = 0x207A;
  11586. t['pmonospace'] = 0xFF50;
  11587. t['pmsquare'] = 0x33D8;
  11588. t['pohiragana'] = 0x307D;
  11589. t['pointingindexdownwhite'] = 0x261F;
  11590. t['pointingindexleftwhite'] = 0x261C;
  11591. t['pointingindexrightwhite'] = 0x261E;
  11592. t['pointingindexupwhite'] = 0x261D;
  11593. t['pokatakana'] = 0x30DD;
  11594. t['poplathai'] = 0x0E1B;
  11595. t['postalmark'] = 0x3012;
  11596. t['postalmarkface'] = 0x3020;
  11597. t['pparen'] = 0x24AB;
  11598. t['precedes'] = 0x227A;
  11599. t['prescription'] = 0x211E;
  11600. t['primemod'] = 0x02B9;
  11601. t['primereversed'] = 0x2035;
  11602. t['product'] = 0x220F;
  11603. t['projective'] = 0x2305;
  11604. t['prolongedkana'] = 0x30FC;
  11605. t['propellor'] = 0x2318;
  11606. t['propersubset'] = 0x2282;
  11607. t['propersuperset'] = 0x2283;
  11608. t['proportion'] = 0x2237;
  11609. t['proportional'] = 0x221D;
  11610. t['psi'] = 0x03C8;
  11611. t['psicyrillic'] = 0x0471;
  11612. t['psilipneumatacyrilliccmb'] = 0x0486;
  11613. t['pssquare'] = 0x33B0;
  11614. t['puhiragana'] = 0x3077;
  11615. t['pukatakana'] = 0x30D7;
  11616. t['pvsquare'] = 0x33B4;
  11617. t['pwsquare'] = 0x33BA;
  11618. t['q'] = 0x0071;
  11619. t['qadeva'] = 0x0958;
  11620. t['qadmahebrew'] = 0x05A8;
  11621. t['qafarabic'] = 0x0642;
  11622. t['qaffinalarabic'] = 0xFED6;
  11623. t['qafinitialarabic'] = 0xFED7;
  11624. t['qafmedialarabic'] = 0xFED8;
  11625. t['qamats'] = 0x05B8;
  11626. t['qamats10'] = 0x05B8;
  11627. t['qamats1a'] = 0x05B8;
  11628. t['qamats1c'] = 0x05B8;
  11629. t['qamats27'] = 0x05B8;
  11630. t['qamats29'] = 0x05B8;
  11631. t['qamats33'] = 0x05B8;
  11632. t['qamatsde'] = 0x05B8;
  11633. t['qamatshebrew'] = 0x05B8;
  11634. t['qamatsnarrowhebrew'] = 0x05B8;
  11635. t['qamatsqatanhebrew'] = 0x05B8;
  11636. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11637. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11638. t['qamatsqatanwidehebrew'] = 0x05B8;
  11639. t['qamatsquarterhebrew'] = 0x05B8;
  11640. t['qamatswidehebrew'] = 0x05B8;
  11641. t['qarneyparahebrew'] = 0x059F;
  11642. t['qbopomofo'] = 0x3111;
  11643. t['qcircle'] = 0x24E0;
  11644. t['qhook'] = 0x02A0;
  11645. t['qmonospace'] = 0xFF51;
  11646. t['qof'] = 0x05E7;
  11647. t['qofdagesh'] = 0xFB47;
  11648. t['qofdageshhebrew'] = 0xFB47;
  11649. t['qofhebrew'] = 0x05E7;
  11650. t['qparen'] = 0x24AC;
  11651. t['quarternote'] = 0x2669;
  11652. t['qubuts'] = 0x05BB;
  11653. t['qubuts18'] = 0x05BB;
  11654. t['qubuts25'] = 0x05BB;
  11655. t['qubuts31'] = 0x05BB;
  11656. t['qubutshebrew'] = 0x05BB;
  11657. t['qubutsnarrowhebrew'] = 0x05BB;
  11658. t['qubutsquarterhebrew'] = 0x05BB;
  11659. t['qubutswidehebrew'] = 0x05BB;
  11660. t['question'] = 0x003F;
  11661. t['questionarabic'] = 0x061F;
  11662. t['questionarmenian'] = 0x055E;
  11663. t['questiondown'] = 0x00BF;
  11664. t['questiondownsmall'] = 0xF7BF;
  11665. t['questiongreek'] = 0x037E;
  11666. t['questionmonospace'] = 0xFF1F;
  11667. t['questionsmall'] = 0xF73F;
  11668. t['quotedbl'] = 0x0022;
  11669. t['quotedblbase'] = 0x201E;
  11670. t['quotedblleft'] = 0x201C;
  11671. t['quotedblmonospace'] = 0xFF02;
  11672. t['quotedblprime'] = 0x301E;
  11673. t['quotedblprimereversed'] = 0x301D;
  11674. t['quotedblright'] = 0x201D;
  11675. t['quoteleft'] = 0x2018;
  11676. t['quoteleftreversed'] = 0x201B;
  11677. t['quotereversed'] = 0x201B;
  11678. t['quoteright'] = 0x2019;
  11679. t['quoterightn'] = 0x0149;
  11680. t['quotesinglbase'] = 0x201A;
  11681. t['quotesingle'] = 0x0027;
  11682. t['quotesinglemonospace'] = 0xFF07;
  11683. t['r'] = 0x0072;
  11684. t['raarmenian'] = 0x057C;
  11685. t['rabengali'] = 0x09B0;
  11686. t['racute'] = 0x0155;
  11687. t['radeva'] = 0x0930;
  11688. t['radical'] = 0x221A;
  11689. t['radicalex'] = 0xF8E5;
  11690. t['radoverssquare'] = 0x33AE;
  11691. t['radoverssquaredsquare'] = 0x33AF;
  11692. t['radsquare'] = 0x33AD;
  11693. t['rafe'] = 0x05BF;
  11694. t['rafehebrew'] = 0x05BF;
  11695. t['ragujarati'] = 0x0AB0;
  11696. t['ragurmukhi'] = 0x0A30;
  11697. t['rahiragana'] = 0x3089;
  11698. t['rakatakana'] = 0x30E9;
  11699. t['rakatakanahalfwidth'] = 0xFF97;
  11700. t['ralowerdiagonalbengali'] = 0x09F1;
  11701. t['ramiddlediagonalbengali'] = 0x09F0;
  11702. t['ramshorn'] = 0x0264;
  11703. t['ratio'] = 0x2236;
  11704. t['rbopomofo'] = 0x3116;
  11705. t['rcaron'] = 0x0159;
  11706. t['rcedilla'] = 0x0157;
  11707. t['rcircle'] = 0x24E1;
  11708. t['rcommaaccent'] = 0x0157;
  11709. t['rdblgrave'] = 0x0211;
  11710. t['rdotaccent'] = 0x1E59;
  11711. t['rdotbelow'] = 0x1E5B;
  11712. t['rdotbelowmacron'] = 0x1E5D;
  11713. t['referencemark'] = 0x203B;
  11714. t['reflexsubset'] = 0x2286;
  11715. t['reflexsuperset'] = 0x2287;
  11716. t['registered'] = 0x00AE;
  11717. t['registersans'] = 0xF8E8;
  11718. t['registerserif'] = 0xF6DA;
  11719. t['reharabic'] = 0x0631;
  11720. t['reharmenian'] = 0x0580;
  11721. t['rehfinalarabic'] = 0xFEAE;
  11722. t['rehiragana'] = 0x308C;
  11723. t['rekatakana'] = 0x30EC;
  11724. t['rekatakanahalfwidth'] = 0xFF9A;
  11725. t['resh'] = 0x05E8;
  11726. t['reshdageshhebrew'] = 0xFB48;
  11727. t['reshhebrew'] = 0x05E8;
  11728. t['reversedtilde'] = 0x223D;
  11729. t['reviahebrew'] = 0x0597;
  11730. t['reviamugrashhebrew'] = 0x0597;
  11731. t['revlogicalnot'] = 0x2310;
  11732. t['rfishhook'] = 0x027E;
  11733. t['rfishhookreversed'] = 0x027F;
  11734. t['rhabengali'] = 0x09DD;
  11735. t['rhadeva'] = 0x095D;
  11736. t['rho'] = 0x03C1;
  11737. t['rhook'] = 0x027D;
  11738. t['rhookturned'] = 0x027B;
  11739. t['rhookturnedsuperior'] = 0x02B5;
  11740. t['rhosymbolgreek'] = 0x03F1;
  11741. t['rhotichookmod'] = 0x02DE;
  11742. t['rieulacirclekorean'] = 0x3271;
  11743. t['rieulaparenkorean'] = 0x3211;
  11744. t['rieulcirclekorean'] = 0x3263;
  11745. t['rieulhieuhkorean'] = 0x3140;
  11746. t['rieulkiyeokkorean'] = 0x313A;
  11747. t['rieulkiyeoksioskorean'] = 0x3169;
  11748. t['rieulkorean'] = 0x3139;
  11749. t['rieulmieumkorean'] = 0x313B;
  11750. t['rieulpansioskorean'] = 0x316C;
  11751. t['rieulparenkorean'] = 0x3203;
  11752. t['rieulphieuphkorean'] = 0x313F;
  11753. t['rieulpieupkorean'] = 0x313C;
  11754. t['rieulpieupsioskorean'] = 0x316B;
  11755. t['rieulsioskorean'] = 0x313D;
  11756. t['rieulthieuthkorean'] = 0x313E;
  11757. t['rieultikeutkorean'] = 0x316A;
  11758. t['rieulyeorinhieuhkorean'] = 0x316D;
  11759. t['rightangle'] = 0x221F;
  11760. t['righttackbelowcmb'] = 0x0319;
  11761. t['righttriangle'] = 0x22BF;
  11762. t['rihiragana'] = 0x308A;
  11763. t['rikatakana'] = 0x30EA;
  11764. t['rikatakanahalfwidth'] = 0xFF98;
  11765. t['ring'] = 0x02DA;
  11766. t['ringbelowcmb'] = 0x0325;
  11767. t['ringcmb'] = 0x030A;
  11768. t['ringhalfleft'] = 0x02BF;
  11769. t['ringhalfleftarmenian'] = 0x0559;
  11770. t['ringhalfleftbelowcmb'] = 0x031C;
  11771. t['ringhalfleftcentered'] = 0x02D3;
  11772. t['ringhalfright'] = 0x02BE;
  11773. t['ringhalfrightbelowcmb'] = 0x0339;
  11774. t['ringhalfrightcentered'] = 0x02D2;
  11775. t['rinvertedbreve'] = 0x0213;
  11776. t['rittorusquare'] = 0x3351;
  11777. t['rlinebelow'] = 0x1E5F;
  11778. t['rlongleg'] = 0x027C;
  11779. t['rlonglegturned'] = 0x027A;
  11780. t['rmonospace'] = 0xFF52;
  11781. t['rohiragana'] = 0x308D;
  11782. t['rokatakana'] = 0x30ED;
  11783. t['rokatakanahalfwidth'] = 0xFF9B;
  11784. t['roruathai'] = 0x0E23;
  11785. t['rparen'] = 0x24AD;
  11786. t['rrabengali'] = 0x09DC;
  11787. t['rradeva'] = 0x0931;
  11788. t['rragurmukhi'] = 0x0A5C;
  11789. t['rreharabic'] = 0x0691;
  11790. t['rrehfinalarabic'] = 0xFB8D;
  11791. t['rrvocalicbengali'] = 0x09E0;
  11792. t['rrvocalicdeva'] = 0x0960;
  11793. t['rrvocalicgujarati'] = 0x0AE0;
  11794. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11795. t['rrvocalicvowelsigndeva'] = 0x0944;
  11796. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11797. t['rsuperior'] = 0xF6F1;
  11798. t['rtblock'] = 0x2590;
  11799. t['rturned'] = 0x0279;
  11800. t['rturnedsuperior'] = 0x02B4;
  11801. t['ruhiragana'] = 0x308B;
  11802. t['rukatakana'] = 0x30EB;
  11803. t['rukatakanahalfwidth'] = 0xFF99;
  11804. t['rupeemarkbengali'] = 0x09F2;
  11805. t['rupeesignbengali'] = 0x09F3;
  11806. t['rupiah'] = 0xF6DD;
  11807. t['ruthai'] = 0x0E24;
  11808. t['rvocalicbengali'] = 0x098B;
  11809. t['rvocalicdeva'] = 0x090B;
  11810. t['rvocalicgujarati'] = 0x0A8B;
  11811. t['rvocalicvowelsignbengali'] = 0x09C3;
  11812. t['rvocalicvowelsigndeva'] = 0x0943;
  11813. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11814. t['s'] = 0x0073;
  11815. t['sabengali'] = 0x09B8;
  11816. t['sacute'] = 0x015B;
  11817. t['sacutedotaccent'] = 0x1E65;
  11818. t['sadarabic'] = 0x0635;
  11819. t['sadeva'] = 0x0938;
  11820. t['sadfinalarabic'] = 0xFEBA;
  11821. t['sadinitialarabic'] = 0xFEBB;
  11822. t['sadmedialarabic'] = 0xFEBC;
  11823. t['sagujarati'] = 0x0AB8;
  11824. t['sagurmukhi'] = 0x0A38;
  11825. t['sahiragana'] = 0x3055;
  11826. t['sakatakana'] = 0x30B5;
  11827. t['sakatakanahalfwidth'] = 0xFF7B;
  11828. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11829. t['samekh'] = 0x05E1;
  11830. t['samekhdagesh'] = 0xFB41;
  11831. t['samekhdageshhebrew'] = 0xFB41;
  11832. t['samekhhebrew'] = 0x05E1;
  11833. t['saraaathai'] = 0x0E32;
  11834. t['saraaethai'] = 0x0E41;
  11835. t['saraaimaimalaithai'] = 0x0E44;
  11836. t['saraaimaimuanthai'] = 0x0E43;
  11837. t['saraamthai'] = 0x0E33;
  11838. t['saraathai'] = 0x0E30;
  11839. t['saraethai'] = 0x0E40;
  11840. t['saraiileftthai'] = 0xF886;
  11841. t['saraiithai'] = 0x0E35;
  11842. t['saraileftthai'] = 0xF885;
  11843. t['saraithai'] = 0x0E34;
  11844. t['saraothai'] = 0x0E42;
  11845. t['saraueeleftthai'] = 0xF888;
  11846. t['saraueethai'] = 0x0E37;
  11847. t['saraueleftthai'] = 0xF887;
  11848. t['sarauethai'] = 0x0E36;
  11849. t['sarauthai'] = 0x0E38;
  11850. t['sarauuthai'] = 0x0E39;
  11851. t['sbopomofo'] = 0x3119;
  11852. t['scaron'] = 0x0161;
  11853. t['scarondotaccent'] = 0x1E67;
  11854. t['scedilla'] = 0x015F;
  11855. t['schwa'] = 0x0259;
  11856. t['schwacyrillic'] = 0x04D9;
  11857. t['schwadieresiscyrillic'] = 0x04DB;
  11858. t['schwahook'] = 0x025A;
  11859. t['scircle'] = 0x24E2;
  11860. t['scircumflex'] = 0x015D;
  11861. t['scommaaccent'] = 0x0219;
  11862. t['sdotaccent'] = 0x1E61;
  11863. t['sdotbelow'] = 0x1E63;
  11864. t['sdotbelowdotaccent'] = 0x1E69;
  11865. t['seagullbelowcmb'] = 0x033C;
  11866. t['second'] = 0x2033;
  11867. t['secondtonechinese'] = 0x02CA;
  11868. t['section'] = 0x00A7;
  11869. t['seenarabic'] = 0x0633;
  11870. t['seenfinalarabic'] = 0xFEB2;
  11871. t['seeninitialarabic'] = 0xFEB3;
  11872. t['seenmedialarabic'] = 0xFEB4;
  11873. t['segol'] = 0x05B6;
  11874. t['segol13'] = 0x05B6;
  11875. t['segol1f'] = 0x05B6;
  11876. t['segol2c'] = 0x05B6;
  11877. t['segolhebrew'] = 0x05B6;
  11878. t['segolnarrowhebrew'] = 0x05B6;
  11879. t['segolquarterhebrew'] = 0x05B6;
  11880. t['segoltahebrew'] = 0x0592;
  11881. t['segolwidehebrew'] = 0x05B6;
  11882. t['seharmenian'] = 0x057D;
  11883. t['sehiragana'] = 0x305B;
  11884. t['sekatakana'] = 0x30BB;
  11885. t['sekatakanahalfwidth'] = 0xFF7E;
  11886. t['semicolon'] = 0x003B;
  11887. t['semicolonarabic'] = 0x061B;
  11888. t['semicolonmonospace'] = 0xFF1B;
  11889. t['semicolonsmall'] = 0xFE54;
  11890. t['semivoicedmarkkana'] = 0x309C;
  11891. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11892. t['sentisquare'] = 0x3322;
  11893. t['sentosquare'] = 0x3323;
  11894. t['seven'] = 0x0037;
  11895. t['sevenarabic'] = 0x0667;
  11896. t['sevenbengali'] = 0x09ED;
  11897. t['sevencircle'] = 0x2466;
  11898. t['sevencircleinversesansserif'] = 0x2790;
  11899. t['sevendeva'] = 0x096D;
  11900. t['seveneighths'] = 0x215E;
  11901. t['sevengujarati'] = 0x0AED;
  11902. t['sevengurmukhi'] = 0x0A6D;
  11903. t['sevenhackarabic'] = 0x0667;
  11904. t['sevenhangzhou'] = 0x3027;
  11905. t['sevenideographicparen'] = 0x3226;
  11906. t['seveninferior'] = 0x2087;
  11907. t['sevenmonospace'] = 0xFF17;
  11908. t['sevenoldstyle'] = 0xF737;
  11909. t['sevenparen'] = 0x247A;
  11910. t['sevenperiod'] = 0x248E;
  11911. t['sevenpersian'] = 0x06F7;
  11912. t['sevenroman'] = 0x2176;
  11913. t['sevensuperior'] = 0x2077;
  11914. t['seventeencircle'] = 0x2470;
  11915. t['seventeenparen'] = 0x2484;
  11916. t['seventeenperiod'] = 0x2498;
  11917. t['seventhai'] = 0x0E57;
  11918. t['sfthyphen'] = 0x00AD;
  11919. t['shaarmenian'] = 0x0577;
  11920. t['shabengali'] = 0x09B6;
  11921. t['shacyrillic'] = 0x0448;
  11922. t['shaddaarabic'] = 0x0651;
  11923. t['shaddadammaarabic'] = 0xFC61;
  11924. t['shaddadammatanarabic'] = 0xFC5E;
  11925. t['shaddafathaarabic'] = 0xFC60;
  11926. t['shaddakasraarabic'] = 0xFC62;
  11927. t['shaddakasratanarabic'] = 0xFC5F;
  11928. t['shade'] = 0x2592;
  11929. t['shadedark'] = 0x2593;
  11930. t['shadelight'] = 0x2591;
  11931. t['shademedium'] = 0x2592;
  11932. t['shadeva'] = 0x0936;
  11933. t['shagujarati'] = 0x0AB6;
  11934. t['shagurmukhi'] = 0x0A36;
  11935. t['shalshelethebrew'] = 0x0593;
  11936. t['shbopomofo'] = 0x3115;
  11937. t['shchacyrillic'] = 0x0449;
  11938. t['sheenarabic'] = 0x0634;
  11939. t['sheenfinalarabic'] = 0xFEB6;
  11940. t['sheeninitialarabic'] = 0xFEB7;
  11941. t['sheenmedialarabic'] = 0xFEB8;
  11942. t['sheicoptic'] = 0x03E3;
  11943. t['sheqel'] = 0x20AA;
  11944. t['sheqelhebrew'] = 0x20AA;
  11945. t['sheva'] = 0x05B0;
  11946. t['sheva115'] = 0x05B0;
  11947. t['sheva15'] = 0x05B0;
  11948. t['sheva22'] = 0x05B0;
  11949. t['sheva2e'] = 0x05B0;
  11950. t['shevahebrew'] = 0x05B0;
  11951. t['shevanarrowhebrew'] = 0x05B0;
  11952. t['shevaquarterhebrew'] = 0x05B0;
  11953. t['shevawidehebrew'] = 0x05B0;
  11954. t['shhacyrillic'] = 0x04BB;
  11955. t['shimacoptic'] = 0x03ED;
  11956. t['shin'] = 0x05E9;
  11957. t['shindagesh'] = 0xFB49;
  11958. t['shindageshhebrew'] = 0xFB49;
  11959. t['shindageshshindot'] = 0xFB2C;
  11960. t['shindageshshindothebrew'] = 0xFB2C;
  11961. t['shindageshsindot'] = 0xFB2D;
  11962. t['shindageshsindothebrew'] = 0xFB2D;
  11963. t['shindothebrew'] = 0x05C1;
  11964. t['shinhebrew'] = 0x05E9;
  11965. t['shinshindot'] = 0xFB2A;
  11966. t['shinshindothebrew'] = 0xFB2A;
  11967. t['shinsindot'] = 0xFB2B;
  11968. t['shinsindothebrew'] = 0xFB2B;
  11969. t['shook'] = 0x0282;
  11970. t['sigma'] = 0x03C3;
  11971. t['sigma1'] = 0x03C2;
  11972. t['sigmafinal'] = 0x03C2;
  11973. t['sigmalunatesymbolgreek'] = 0x03F2;
  11974. t['sihiragana'] = 0x3057;
  11975. t['sikatakana'] = 0x30B7;
  11976. t['sikatakanahalfwidth'] = 0xFF7C;
  11977. t['siluqhebrew'] = 0x05BD;
  11978. t['siluqlefthebrew'] = 0x05BD;
  11979. t['similar'] = 0x223C;
  11980. t['sindothebrew'] = 0x05C2;
  11981. t['siosacirclekorean'] = 0x3274;
  11982. t['siosaparenkorean'] = 0x3214;
  11983. t['sioscieuckorean'] = 0x317E;
  11984. t['sioscirclekorean'] = 0x3266;
  11985. t['sioskiyeokkorean'] = 0x317A;
  11986. t['sioskorean'] = 0x3145;
  11987. t['siosnieunkorean'] = 0x317B;
  11988. t['siosparenkorean'] = 0x3206;
  11989. t['siospieupkorean'] = 0x317D;
  11990. t['siostikeutkorean'] = 0x317C;
  11991. t['six'] = 0x0036;
  11992. t['sixarabic'] = 0x0666;
  11993. t['sixbengali'] = 0x09EC;
  11994. t['sixcircle'] = 0x2465;
  11995. t['sixcircleinversesansserif'] = 0x278F;
  11996. t['sixdeva'] = 0x096C;
  11997. t['sixgujarati'] = 0x0AEC;
  11998. t['sixgurmukhi'] = 0x0A6C;
  11999. t['sixhackarabic'] = 0x0666;
  12000. t['sixhangzhou'] = 0x3026;
  12001. t['sixideographicparen'] = 0x3225;
  12002. t['sixinferior'] = 0x2086;
  12003. t['sixmonospace'] = 0xFF16;
  12004. t['sixoldstyle'] = 0xF736;
  12005. t['sixparen'] = 0x2479;
  12006. t['sixperiod'] = 0x248D;
  12007. t['sixpersian'] = 0x06F6;
  12008. t['sixroman'] = 0x2175;
  12009. t['sixsuperior'] = 0x2076;
  12010. t['sixteencircle'] = 0x246F;
  12011. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12012. t['sixteenparen'] = 0x2483;
  12013. t['sixteenperiod'] = 0x2497;
  12014. t['sixthai'] = 0x0E56;
  12015. t['slash'] = 0x002F;
  12016. t['slashmonospace'] = 0xFF0F;
  12017. t['slong'] = 0x017F;
  12018. t['slongdotaccent'] = 0x1E9B;
  12019. t['smileface'] = 0x263A;
  12020. t['smonospace'] = 0xFF53;
  12021. t['sofpasuqhebrew'] = 0x05C3;
  12022. t['softhyphen'] = 0x00AD;
  12023. t['softsigncyrillic'] = 0x044C;
  12024. t['sohiragana'] = 0x305D;
  12025. t['sokatakana'] = 0x30BD;
  12026. t['sokatakanahalfwidth'] = 0xFF7F;
  12027. t['soliduslongoverlaycmb'] = 0x0338;
  12028. t['solidusshortoverlaycmb'] = 0x0337;
  12029. t['sorusithai'] = 0x0E29;
  12030. t['sosalathai'] = 0x0E28;
  12031. t['sosothai'] = 0x0E0B;
  12032. t['sosuathai'] = 0x0E2A;
  12033. t['space'] = 0x0020;
  12034. t['spacehackarabic'] = 0x0020;
  12035. t['spade'] = 0x2660;
  12036. t['spadesuitblack'] = 0x2660;
  12037. t['spadesuitwhite'] = 0x2664;
  12038. t['sparen'] = 0x24AE;
  12039. t['squarebelowcmb'] = 0x033B;
  12040. t['squarecc'] = 0x33C4;
  12041. t['squarecm'] = 0x339D;
  12042. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12043. t['squarehorizontalfill'] = 0x25A4;
  12044. t['squarekg'] = 0x338F;
  12045. t['squarekm'] = 0x339E;
  12046. t['squarekmcapital'] = 0x33CE;
  12047. t['squareln'] = 0x33D1;
  12048. t['squarelog'] = 0x33D2;
  12049. t['squaremg'] = 0x338E;
  12050. t['squaremil'] = 0x33D5;
  12051. t['squaremm'] = 0x339C;
  12052. t['squaremsquared'] = 0x33A1;
  12053. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12054. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12055. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12056. t['squareverticalfill'] = 0x25A5;
  12057. t['squarewhitewithsmallblack'] = 0x25A3;
  12058. t['srsquare'] = 0x33DB;
  12059. t['ssabengali'] = 0x09B7;
  12060. t['ssadeva'] = 0x0937;
  12061. t['ssagujarati'] = 0x0AB7;
  12062. t['ssangcieuckorean'] = 0x3149;
  12063. t['ssanghieuhkorean'] = 0x3185;
  12064. t['ssangieungkorean'] = 0x3180;
  12065. t['ssangkiyeokkorean'] = 0x3132;
  12066. t['ssangnieunkorean'] = 0x3165;
  12067. t['ssangpieupkorean'] = 0x3143;
  12068. t['ssangsioskorean'] = 0x3146;
  12069. t['ssangtikeutkorean'] = 0x3138;
  12070. t['ssuperior'] = 0xF6F2;
  12071. t['sterling'] = 0x00A3;
  12072. t['sterlingmonospace'] = 0xFFE1;
  12073. t['strokelongoverlaycmb'] = 0x0336;
  12074. t['strokeshortoverlaycmb'] = 0x0335;
  12075. t['subset'] = 0x2282;
  12076. t['subsetnotequal'] = 0x228A;
  12077. t['subsetorequal'] = 0x2286;
  12078. t['succeeds'] = 0x227B;
  12079. t['suchthat'] = 0x220B;
  12080. t['suhiragana'] = 0x3059;
  12081. t['sukatakana'] = 0x30B9;
  12082. t['sukatakanahalfwidth'] = 0xFF7D;
  12083. t['sukunarabic'] = 0x0652;
  12084. t['summation'] = 0x2211;
  12085. t['sun'] = 0x263C;
  12086. t['superset'] = 0x2283;
  12087. t['supersetnotequal'] = 0x228B;
  12088. t['supersetorequal'] = 0x2287;
  12089. t['svsquare'] = 0x33DC;
  12090. t['syouwaerasquare'] = 0x337C;
  12091. t['t'] = 0x0074;
  12092. t['tabengali'] = 0x09A4;
  12093. t['tackdown'] = 0x22A4;
  12094. t['tackleft'] = 0x22A3;
  12095. t['tadeva'] = 0x0924;
  12096. t['tagujarati'] = 0x0AA4;
  12097. t['tagurmukhi'] = 0x0A24;
  12098. t['taharabic'] = 0x0637;
  12099. t['tahfinalarabic'] = 0xFEC2;
  12100. t['tahinitialarabic'] = 0xFEC3;
  12101. t['tahiragana'] = 0x305F;
  12102. t['tahmedialarabic'] = 0xFEC4;
  12103. t['taisyouerasquare'] = 0x337D;
  12104. t['takatakana'] = 0x30BF;
  12105. t['takatakanahalfwidth'] = 0xFF80;
  12106. t['tatweelarabic'] = 0x0640;
  12107. t['tau'] = 0x03C4;
  12108. t['tav'] = 0x05EA;
  12109. t['tavdages'] = 0xFB4A;
  12110. t['tavdagesh'] = 0xFB4A;
  12111. t['tavdageshhebrew'] = 0xFB4A;
  12112. t['tavhebrew'] = 0x05EA;
  12113. t['tbar'] = 0x0167;
  12114. t['tbopomofo'] = 0x310A;
  12115. t['tcaron'] = 0x0165;
  12116. t['tccurl'] = 0x02A8;
  12117. t['tcedilla'] = 0x0163;
  12118. t['tcheharabic'] = 0x0686;
  12119. t['tchehfinalarabic'] = 0xFB7B;
  12120. t['tchehinitialarabic'] = 0xFB7C;
  12121. t['tchehmedialarabic'] = 0xFB7D;
  12122. t['tcircle'] = 0x24E3;
  12123. t['tcircumflexbelow'] = 0x1E71;
  12124. t['tcommaaccent'] = 0x0163;
  12125. t['tdieresis'] = 0x1E97;
  12126. t['tdotaccent'] = 0x1E6B;
  12127. t['tdotbelow'] = 0x1E6D;
  12128. t['tecyrillic'] = 0x0442;
  12129. t['tedescendercyrillic'] = 0x04AD;
  12130. t['teharabic'] = 0x062A;
  12131. t['tehfinalarabic'] = 0xFE96;
  12132. t['tehhahinitialarabic'] = 0xFCA2;
  12133. t['tehhahisolatedarabic'] = 0xFC0C;
  12134. t['tehinitialarabic'] = 0xFE97;
  12135. t['tehiragana'] = 0x3066;
  12136. t['tehjeeminitialarabic'] = 0xFCA1;
  12137. t['tehjeemisolatedarabic'] = 0xFC0B;
  12138. t['tehmarbutaarabic'] = 0x0629;
  12139. t['tehmarbutafinalarabic'] = 0xFE94;
  12140. t['tehmedialarabic'] = 0xFE98;
  12141. t['tehmeeminitialarabic'] = 0xFCA4;
  12142. t['tehmeemisolatedarabic'] = 0xFC0E;
  12143. t['tehnoonfinalarabic'] = 0xFC73;
  12144. t['tekatakana'] = 0x30C6;
  12145. t['tekatakanahalfwidth'] = 0xFF83;
  12146. t['telephone'] = 0x2121;
  12147. t['telephoneblack'] = 0x260E;
  12148. t['telishagedolahebrew'] = 0x05A0;
  12149. t['telishaqetanahebrew'] = 0x05A9;
  12150. t['tencircle'] = 0x2469;
  12151. t['tenideographicparen'] = 0x3229;
  12152. t['tenparen'] = 0x247D;
  12153. t['tenperiod'] = 0x2491;
  12154. t['tenroman'] = 0x2179;
  12155. t['tesh'] = 0x02A7;
  12156. t['tet'] = 0x05D8;
  12157. t['tetdagesh'] = 0xFB38;
  12158. t['tetdageshhebrew'] = 0xFB38;
  12159. t['tethebrew'] = 0x05D8;
  12160. t['tetsecyrillic'] = 0x04B5;
  12161. t['tevirhebrew'] = 0x059B;
  12162. t['tevirlefthebrew'] = 0x059B;
  12163. t['thabengali'] = 0x09A5;
  12164. t['thadeva'] = 0x0925;
  12165. t['thagujarati'] = 0x0AA5;
  12166. t['thagurmukhi'] = 0x0A25;
  12167. t['thalarabic'] = 0x0630;
  12168. t['thalfinalarabic'] = 0xFEAC;
  12169. t['thanthakhatlowleftthai'] = 0xF898;
  12170. t['thanthakhatlowrightthai'] = 0xF897;
  12171. t['thanthakhatthai'] = 0x0E4C;
  12172. t['thanthakhatupperleftthai'] = 0xF896;
  12173. t['theharabic'] = 0x062B;
  12174. t['thehfinalarabic'] = 0xFE9A;
  12175. t['thehinitialarabic'] = 0xFE9B;
  12176. t['thehmedialarabic'] = 0xFE9C;
  12177. t['thereexists'] = 0x2203;
  12178. t['therefore'] = 0x2234;
  12179. t['theta'] = 0x03B8;
  12180. t['theta1'] = 0x03D1;
  12181. t['thetasymbolgreek'] = 0x03D1;
  12182. t['thieuthacirclekorean'] = 0x3279;
  12183. t['thieuthaparenkorean'] = 0x3219;
  12184. t['thieuthcirclekorean'] = 0x326B;
  12185. t['thieuthkorean'] = 0x314C;
  12186. t['thieuthparenkorean'] = 0x320B;
  12187. t['thirteencircle'] = 0x246C;
  12188. t['thirteenparen'] = 0x2480;
  12189. t['thirteenperiod'] = 0x2494;
  12190. t['thonangmonthothai'] = 0x0E11;
  12191. t['thook'] = 0x01AD;
  12192. t['thophuthaothai'] = 0x0E12;
  12193. t['thorn'] = 0x00FE;
  12194. t['thothahanthai'] = 0x0E17;
  12195. t['thothanthai'] = 0x0E10;
  12196. t['thothongthai'] = 0x0E18;
  12197. t['thothungthai'] = 0x0E16;
  12198. t['thousandcyrillic'] = 0x0482;
  12199. t['thousandsseparatorarabic'] = 0x066C;
  12200. t['thousandsseparatorpersian'] = 0x066C;
  12201. t['three'] = 0x0033;
  12202. t['threearabic'] = 0x0663;
  12203. t['threebengali'] = 0x09E9;
  12204. t['threecircle'] = 0x2462;
  12205. t['threecircleinversesansserif'] = 0x278C;
  12206. t['threedeva'] = 0x0969;
  12207. t['threeeighths'] = 0x215C;
  12208. t['threegujarati'] = 0x0AE9;
  12209. t['threegurmukhi'] = 0x0A69;
  12210. t['threehackarabic'] = 0x0663;
  12211. t['threehangzhou'] = 0x3023;
  12212. t['threeideographicparen'] = 0x3222;
  12213. t['threeinferior'] = 0x2083;
  12214. t['threemonospace'] = 0xFF13;
  12215. t['threenumeratorbengali'] = 0x09F6;
  12216. t['threeoldstyle'] = 0xF733;
  12217. t['threeparen'] = 0x2476;
  12218. t['threeperiod'] = 0x248A;
  12219. t['threepersian'] = 0x06F3;
  12220. t['threequarters'] = 0x00BE;
  12221. t['threequartersemdash'] = 0xF6DE;
  12222. t['threeroman'] = 0x2172;
  12223. t['threesuperior'] = 0x00B3;
  12224. t['threethai'] = 0x0E53;
  12225. t['thzsquare'] = 0x3394;
  12226. t['tihiragana'] = 0x3061;
  12227. t['tikatakana'] = 0x30C1;
  12228. t['tikatakanahalfwidth'] = 0xFF81;
  12229. t['tikeutacirclekorean'] = 0x3270;
  12230. t['tikeutaparenkorean'] = 0x3210;
  12231. t['tikeutcirclekorean'] = 0x3262;
  12232. t['tikeutkorean'] = 0x3137;
  12233. t['tikeutparenkorean'] = 0x3202;
  12234. t['tilde'] = 0x02DC;
  12235. t['tildebelowcmb'] = 0x0330;
  12236. t['tildecmb'] = 0x0303;
  12237. t['tildecomb'] = 0x0303;
  12238. t['tildedoublecmb'] = 0x0360;
  12239. t['tildeoperator'] = 0x223C;
  12240. t['tildeoverlaycmb'] = 0x0334;
  12241. t['tildeverticalcmb'] = 0x033E;
  12242. t['timescircle'] = 0x2297;
  12243. t['tipehahebrew'] = 0x0596;
  12244. t['tipehalefthebrew'] = 0x0596;
  12245. t['tippigurmukhi'] = 0x0A70;
  12246. t['titlocyrilliccmb'] = 0x0483;
  12247. t['tiwnarmenian'] = 0x057F;
  12248. t['tlinebelow'] = 0x1E6F;
  12249. t['tmonospace'] = 0xFF54;
  12250. t['toarmenian'] = 0x0569;
  12251. t['tohiragana'] = 0x3068;
  12252. t['tokatakana'] = 0x30C8;
  12253. t['tokatakanahalfwidth'] = 0xFF84;
  12254. t['tonebarextrahighmod'] = 0x02E5;
  12255. t['tonebarextralowmod'] = 0x02E9;
  12256. t['tonebarhighmod'] = 0x02E6;
  12257. t['tonebarlowmod'] = 0x02E8;
  12258. t['tonebarmidmod'] = 0x02E7;
  12259. t['tonefive'] = 0x01BD;
  12260. t['tonesix'] = 0x0185;
  12261. t['tonetwo'] = 0x01A8;
  12262. t['tonos'] = 0x0384;
  12263. t['tonsquare'] = 0x3327;
  12264. t['topatakthai'] = 0x0E0F;
  12265. t['tortoiseshellbracketleft'] = 0x3014;
  12266. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12267. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12268. t['tortoiseshellbracketright'] = 0x3015;
  12269. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12270. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12271. t['totaothai'] = 0x0E15;
  12272. t['tpalatalhook'] = 0x01AB;
  12273. t['tparen'] = 0x24AF;
  12274. t['trademark'] = 0x2122;
  12275. t['trademarksans'] = 0xF8EA;
  12276. t['trademarkserif'] = 0xF6DB;
  12277. t['tretroflexhook'] = 0x0288;
  12278. t['triagdn'] = 0x25BC;
  12279. t['triaglf'] = 0x25C4;
  12280. t['triagrt'] = 0x25BA;
  12281. t['triagup'] = 0x25B2;
  12282. t['ts'] = 0x02A6;
  12283. t['tsadi'] = 0x05E6;
  12284. t['tsadidagesh'] = 0xFB46;
  12285. t['tsadidageshhebrew'] = 0xFB46;
  12286. t['tsadihebrew'] = 0x05E6;
  12287. t['tsecyrillic'] = 0x0446;
  12288. t['tsere'] = 0x05B5;
  12289. t['tsere12'] = 0x05B5;
  12290. t['tsere1e'] = 0x05B5;
  12291. t['tsere2b'] = 0x05B5;
  12292. t['tserehebrew'] = 0x05B5;
  12293. t['tserenarrowhebrew'] = 0x05B5;
  12294. t['tserequarterhebrew'] = 0x05B5;
  12295. t['tserewidehebrew'] = 0x05B5;
  12296. t['tshecyrillic'] = 0x045B;
  12297. t['tsuperior'] = 0xF6F3;
  12298. t['ttabengali'] = 0x099F;
  12299. t['ttadeva'] = 0x091F;
  12300. t['ttagujarati'] = 0x0A9F;
  12301. t['ttagurmukhi'] = 0x0A1F;
  12302. t['tteharabic'] = 0x0679;
  12303. t['ttehfinalarabic'] = 0xFB67;
  12304. t['ttehinitialarabic'] = 0xFB68;
  12305. t['ttehmedialarabic'] = 0xFB69;
  12306. t['tthabengali'] = 0x09A0;
  12307. t['tthadeva'] = 0x0920;
  12308. t['tthagujarati'] = 0x0AA0;
  12309. t['tthagurmukhi'] = 0x0A20;
  12310. t['tturned'] = 0x0287;
  12311. t['tuhiragana'] = 0x3064;
  12312. t['tukatakana'] = 0x30C4;
  12313. t['tukatakanahalfwidth'] = 0xFF82;
  12314. t['tusmallhiragana'] = 0x3063;
  12315. t['tusmallkatakana'] = 0x30C3;
  12316. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12317. t['twelvecircle'] = 0x246B;
  12318. t['twelveparen'] = 0x247F;
  12319. t['twelveperiod'] = 0x2493;
  12320. t['twelveroman'] = 0x217B;
  12321. t['twentycircle'] = 0x2473;
  12322. t['twentyhangzhou'] = 0x5344;
  12323. t['twentyparen'] = 0x2487;
  12324. t['twentyperiod'] = 0x249B;
  12325. t['two'] = 0x0032;
  12326. t['twoarabic'] = 0x0662;
  12327. t['twobengali'] = 0x09E8;
  12328. t['twocircle'] = 0x2461;
  12329. t['twocircleinversesansserif'] = 0x278B;
  12330. t['twodeva'] = 0x0968;
  12331. t['twodotenleader'] = 0x2025;
  12332. t['twodotleader'] = 0x2025;
  12333. t['twodotleadervertical'] = 0xFE30;
  12334. t['twogujarati'] = 0x0AE8;
  12335. t['twogurmukhi'] = 0x0A68;
  12336. t['twohackarabic'] = 0x0662;
  12337. t['twohangzhou'] = 0x3022;
  12338. t['twoideographicparen'] = 0x3221;
  12339. t['twoinferior'] = 0x2082;
  12340. t['twomonospace'] = 0xFF12;
  12341. t['twonumeratorbengali'] = 0x09F5;
  12342. t['twooldstyle'] = 0xF732;
  12343. t['twoparen'] = 0x2475;
  12344. t['twoperiod'] = 0x2489;
  12345. t['twopersian'] = 0x06F2;
  12346. t['tworoman'] = 0x2171;
  12347. t['twostroke'] = 0x01BB;
  12348. t['twosuperior'] = 0x00B2;
  12349. t['twothai'] = 0x0E52;
  12350. t['twothirds'] = 0x2154;
  12351. t['u'] = 0x0075;
  12352. t['uacute'] = 0x00FA;
  12353. t['ubar'] = 0x0289;
  12354. t['ubengali'] = 0x0989;
  12355. t['ubopomofo'] = 0x3128;
  12356. t['ubreve'] = 0x016D;
  12357. t['ucaron'] = 0x01D4;
  12358. t['ucircle'] = 0x24E4;
  12359. t['ucircumflex'] = 0x00FB;
  12360. t['ucircumflexbelow'] = 0x1E77;
  12361. t['ucyrillic'] = 0x0443;
  12362. t['udattadeva'] = 0x0951;
  12363. t['udblacute'] = 0x0171;
  12364. t['udblgrave'] = 0x0215;
  12365. t['udeva'] = 0x0909;
  12366. t['udieresis'] = 0x00FC;
  12367. t['udieresisacute'] = 0x01D8;
  12368. t['udieresisbelow'] = 0x1E73;
  12369. t['udieresiscaron'] = 0x01DA;
  12370. t['udieresiscyrillic'] = 0x04F1;
  12371. t['udieresisgrave'] = 0x01DC;
  12372. t['udieresismacron'] = 0x01D6;
  12373. t['udotbelow'] = 0x1EE5;
  12374. t['ugrave'] = 0x00F9;
  12375. t['ugujarati'] = 0x0A89;
  12376. t['ugurmukhi'] = 0x0A09;
  12377. t['uhiragana'] = 0x3046;
  12378. t['uhookabove'] = 0x1EE7;
  12379. t['uhorn'] = 0x01B0;
  12380. t['uhornacute'] = 0x1EE9;
  12381. t['uhorndotbelow'] = 0x1EF1;
  12382. t['uhorngrave'] = 0x1EEB;
  12383. t['uhornhookabove'] = 0x1EED;
  12384. t['uhorntilde'] = 0x1EEF;
  12385. t['uhungarumlaut'] = 0x0171;
  12386. t['uhungarumlautcyrillic'] = 0x04F3;
  12387. t['uinvertedbreve'] = 0x0217;
  12388. t['ukatakana'] = 0x30A6;
  12389. t['ukatakanahalfwidth'] = 0xFF73;
  12390. t['ukcyrillic'] = 0x0479;
  12391. t['ukorean'] = 0x315C;
  12392. t['umacron'] = 0x016B;
  12393. t['umacroncyrillic'] = 0x04EF;
  12394. t['umacrondieresis'] = 0x1E7B;
  12395. t['umatragurmukhi'] = 0x0A41;
  12396. t['umonospace'] = 0xFF55;
  12397. t['underscore'] = 0x005F;
  12398. t['underscoredbl'] = 0x2017;
  12399. t['underscoremonospace'] = 0xFF3F;
  12400. t['underscorevertical'] = 0xFE33;
  12401. t['underscorewavy'] = 0xFE4F;
  12402. t['union'] = 0x222A;
  12403. t['universal'] = 0x2200;
  12404. t['uogonek'] = 0x0173;
  12405. t['uparen'] = 0x24B0;
  12406. t['upblock'] = 0x2580;
  12407. t['upperdothebrew'] = 0x05C4;
  12408. t['upsilon'] = 0x03C5;
  12409. t['upsilondieresis'] = 0x03CB;
  12410. t['upsilondieresistonos'] = 0x03B0;
  12411. t['upsilonlatin'] = 0x028A;
  12412. t['upsilontonos'] = 0x03CD;
  12413. t['uptackbelowcmb'] = 0x031D;
  12414. t['uptackmod'] = 0x02D4;
  12415. t['uragurmukhi'] = 0x0A73;
  12416. t['uring'] = 0x016F;
  12417. t['ushortcyrillic'] = 0x045E;
  12418. t['usmallhiragana'] = 0x3045;
  12419. t['usmallkatakana'] = 0x30A5;
  12420. t['usmallkatakanahalfwidth'] = 0xFF69;
  12421. t['ustraightcyrillic'] = 0x04AF;
  12422. t['ustraightstrokecyrillic'] = 0x04B1;
  12423. t['utilde'] = 0x0169;
  12424. t['utildeacute'] = 0x1E79;
  12425. t['utildebelow'] = 0x1E75;
  12426. t['uubengali'] = 0x098A;
  12427. t['uudeva'] = 0x090A;
  12428. t['uugujarati'] = 0x0A8A;
  12429. t['uugurmukhi'] = 0x0A0A;
  12430. t['uumatragurmukhi'] = 0x0A42;
  12431. t['uuvowelsignbengali'] = 0x09C2;
  12432. t['uuvowelsigndeva'] = 0x0942;
  12433. t['uuvowelsigngujarati'] = 0x0AC2;
  12434. t['uvowelsignbengali'] = 0x09C1;
  12435. t['uvowelsigndeva'] = 0x0941;
  12436. t['uvowelsigngujarati'] = 0x0AC1;
  12437. t['v'] = 0x0076;
  12438. t['vadeva'] = 0x0935;
  12439. t['vagujarati'] = 0x0AB5;
  12440. t['vagurmukhi'] = 0x0A35;
  12441. t['vakatakana'] = 0x30F7;
  12442. t['vav'] = 0x05D5;
  12443. t['vavdagesh'] = 0xFB35;
  12444. t['vavdagesh65'] = 0xFB35;
  12445. t['vavdageshhebrew'] = 0xFB35;
  12446. t['vavhebrew'] = 0x05D5;
  12447. t['vavholam'] = 0xFB4B;
  12448. t['vavholamhebrew'] = 0xFB4B;
  12449. t['vavvavhebrew'] = 0x05F0;
  12450. t['vavyodhebrew'] = 0x05F1;
  12451. t['vcircle'] = 0x24E5;
  12452. t['vdotbelow'] = 0x1E7F;
  12453. t['vecyrillic'] = 0x0432;
  12454. t['veharabic'] = 0x06A4;
  12455. t['vehfinalarabic'] = 0xFB6B;
  12456. t['vehinitialarabic'] = 0xFB6C;
  12457. t['vehmedialarabic'] = 0xFB6D;
  12458. t['vekatakana'] = 0x30F9;
  12459. t['venus'] = 0x2640;
  12460. t['verticalbar'] = 0x007C;
  12461. t['verticallineabovecmb'] = 0x030D;
  12462. t['verticallinebelowcmb'] = 0x0329;
  12463. t['verticallinelowmod'] = 0x02CC;
  12464. t['verticallinemod'] = 0x02C8;
  12465. t['vewarmenian'] = 0x057E;
  12466. t['vhook'] = 0x028B;
  12467. t['vikatakana'] = 0x30F8;
  12468. t['viramabengali'] = 0x09CD;
  12469. t['viramadeva'] = 0x094D;
  12470. t['viramagujarati'] = 0x0ACD;
  12471. t['visargabengali'] = 0x0983;
  12472. t['visargadeva'] = 0x0903;
  12473. t['visargagujarati'] = 0x0A83;
  12474. t['vmonospace'] = 0xFF56;
  12475. t['voarmenian'] = 0x0578;
  12476. t['voicediterationhiragana'] = 0x309E;
  12477. t['voicediterationkatakana'] = 0x30FE;
  12478. t['voicedmarkkana'] = 0x309B;
  12479. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12480. t['vokatakana'] = 0x30FA;
  12481. t['vparen'] = 0x24B1;
  12482. t['vtilde'] = 0x1E7D;
  12483. t['vturned'] = 0x028C;
  12484. t['vuhiragana'] = 0x3094;
  12485. t['vukatakana'] = 0x30F4;
  12486. t['w'] = 0x0077;
  12487. t['wacute'] = 0x1E83;
  12488. t['waekorean'] = 0x3159;
  12489. t['wahiragana'] = 0x308F;
  12490. t['wakatakana'] = 0x30EF;
  12491. t['wakatakanahalfwidth'] = 0xFF9C;
  12492. t['wakorean'] = 0x3158;
  12493. t['wasmallhiragana'] = 0x308E;
  12494. t['wasmallkatakana'] = 0x30EE;
  12495. t['wattosquare'] = 0x3357;
  12496. t['wavedash'] = 0x301C;
  12497. t['wavyunderscorevertical'] = 0xFE34;
  12498. t['wawarabic'] = 0x0648;
  12499. t['wawfinalarabic'] = 0xFEEE;
  12500. t['wawhamzaabovearabic'] = 0x0624;
  12501. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12502. t['wbsquare'] = 0x33DD;
  12503. t['wcircle'] = 0x24E6;
  12504. t['wcircumflex'] = 0x0175;
  12505. t['wdieresis'] = 0x1E85;
  12506. t['wdotaccent'] = 0x1E87;
  12507. t['wdotbelow'] = 0x1E89;
  12508. t['wehiragana'] = 0x3091;
  12509. t['weierstrass'] = 0x2118;
  12510. t['wekatakana'] = 0x30F1;
  12511. t['wekorean'] = 0x315E;
  12512. t['weokorean'] = 0x315D;
  12513. t['wgrave'] = 0x1E81;
  12514. t['whitebullet'] = 0x25E6;
  12515. t['whitecircle'] = 0x25CB;
  12516. t['whitecircleinverse'] = 0x25D9;
  12517. t['whitecornerbracketleft'] = 0x300E;
  12518. t['whitecornerbracketleftvertical'] = 0xFE43;
  12519. t['whitecornerbracketright'] = 0x300F;
  12520. t['whitecornerbracketrightvertical'] = 0xFE44;
  12521. t['whitediamond'] = 0x25C7;
  12522. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12523. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12524. t['whitedownpointingtriangle'] = 0x25BD;
  12525. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12526. t['whiteleftpointingtriangle'] = 0x25C1;
  12527. t['whitelenticularbracketleft'] = 0x3016;
  12528. t['whitelenticularbracketright'] = 0x3017;
  12529. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12530. t['whiterightpointingtriangle'] = 0x25B7;
  12531. t['whitesmallsquare'] = 0x25AB;
  12532. t['whitesmilingface'] = 0x263A;
  12533. t['whitesquare'] = 0x25A1;
  12534. t['whitestar'] = 0x2606;
  12535. t['whitetelephone'] = 0x260F;
  12536. t['whitetortoiseshellbracketleft'] = 0x3018;
  12537. t['whitetortoiseshellbracketright'] = 0x3019;
  12538. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12539. t['whiteuppointingtriangle'] = 0x25B3;
  12540. t['wihiragana'] = 0x3090;
  12541. t['wikatakana'] = 0x30F0;
  12542. t['wikorean'] = 0x315F;
  12543. t['wmonospace'] = 0xFF57;
  12544. t['wohiragana'] = 0x3092;
  12545. t['wokatakana'] = 0x30F2;
  12546. t['wokatakanahalfwidth'] = 0xFF66;
  12547. t['won'] = 0x20A9;
  12548. t['wonmonospace'] = 0xFFE6;
  12549. t['wowaenthai'] = 0x0E27;
  12550. t['wparen'] = 0x24B2;
  12551. t['wring'] = 0x1E98;
  12552. t['wsuperior'] = 0x02B7;
  12553. t['wturned'] = 0x028D;
  12554. t['wynn'] = 0x01BF;
  12555. t['x'] = 0x0078;
  12556. t['xabovecmb'] = 0x033D;
  12557. t['xbopomofo'] = 0x3112;
  12558. t['xcircle'] = 0x24E7;
  12559. t['xdieresis'] = 0x1E8D;
  12560. t['xdotaccent'] = 0x1E8B;
  12561. t['xeharmenian'] = 0x056D;
  12562. t['xi'] = 0x03BE;
  12563. t['xmonospace'] = 0xFF58;
  12564. t['xparen'] = 0x24B3;
  12565. t['xsuperior'] = 0x02E3;
  12566. t['y'] = 0x0079;
  12567. t['yaadosquare'] = 0x334E;
  12568. t['yabengali'] = 0x09AF;
  12569. t['yacute'] = 0x00FD;
  12570. t['yadeva'] = 0x092F;
  12571. t['yaekorean'] = 0x3152;
  12572. t['yagujarati'] = 0x0AAF;
  12573. t['yagurmukhi'] = 0x0A2F;
  12574. t['yahiragana'] = 0x3084;
  12575. t['yakatakana'] = 0x30E4;
  12576. t['yakatakanahalfwidth'] = 0xFF94;
  12577. t['yakorean'] = 0x3151;
  12578. t['yamakkanthai'] = 0x0E4E;
  12579. t['yasmallhiragana'] = 0x3083;
  12580. t['yasmallkatakana'] = 0x30E3;
  12581. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12582. t['yatcyrillic'] = 0x0463;
  12583. t['ycircle'] = 0x24E8;
  12584. t['ycircumflex'] = 0x0177;
  12585. t['ydieresis'] = 0x00FF;
  12586. t['ydotaccent'] = 0x1E8F;
  12587. t['ydotbelow'] = 0x1EF5;
  12588. t['yeharabic'] = 0x064A;
  12589. t['yehbarreearabic'] = 0x06D2;
  12590. t['yehbarreefinalarabic'] = 0xFBAF;
  12591. t['yehfinalarabic'] = 0xFEF2;
  12592. t['yehhamzaabovearabic'] = 0x0626;
  12593. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12594. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12595. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12596. t['yehinitialarabic'] = 0xFEF3;
  12597. t['yehmedialarabic'] = 0xFEF4;
  12598. t['yehmeeminitialarabic'] = 0xFCDD;
  12599. t['yehmeemisolatedarabic'] = 0xFC58;
  12600. t['yehnoonfinalarabic'] = 0xFC94;
  12601. t['yehthreedotsbelowarabic'] = 0x06D1;
  12602. t['yekorean'] = 0x3156;
  12603. t['yen'] = 0x00A5;
  12604. t['yenmonospace'] = 0xFFE5;
  12605. t['yeokorean'] = 0x3155;
  12606. t['yeorinhieuhkorean'] = 0x3186;
  12607. t['yerahbenyomohebrew'] = 0x05AA;
  12608. t['yerahbenyomolefthebrew'] = 0x05AA;
  12609. t['yericyrillic'] = 0x044B;
  12610. t['yerudieresiscyrillic'] = 0x04F9;
  12611. t['yesieungkorean'] = 0x3181;
  12612. t['yesieungpansioskorean'] = 0x3183;
  12613. t['yesieungsioskorean'] = 0x3182;
  12614. t['yetivhebrew'] = 0x059A;
  12615. t['ygrave'] = 0x1EF3;
  12616. t['yhook'] = 0x01B4;
  12617. t['yhookabove'] = 0x1EF7;
  12618. t['yiarmenian'] = 0x0575;
  12619. t['yicyrillic'] = 0x0457;
  12620. t['yikorean'] = 0x3162;
  12621. t['yinyang'] = 0x262F;
  12622. t['yiwnarmenian'] = 0x0582;
  12623. t['ymonospace'] = 0xFF59;
  12624. t['yod'] = 0x05D9;
  12625. t['yoddagesh'] = 0xFB39;
  12626. t['yoddageshhebrew'] = 0xFB39;
  12627. t['yodhebrew'] = 0x05D9;
  12628. t['yodyodhebrew'] = 0x05F2;
  12629. t['yodyodpatahhebrew'] = 0xFB1F;
  12630. t['yohiragana'] = 0x3088;
  12631. t['yoikorean'] = 0x3189;
  12632. t['yokatakana'] = 0x30E8;
  12633. t['yokatakanahalfwidth'] = 0xFF96;
  12634. t['yokorean'] = 0x315B;
  12635. t['yosmallhiragana'] = 0x3087;
  12636. t['yosmallkatakana'] = 0x30E7;
  12637. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12638. t['yotgreek'] = 0x03F3;
  12639. t['yoyaekorean'] = 0x3188;
  12640. t['yoyakorean'] = 0x3187;
  12641. t['yoyakthai'] = 0x0E22;
  12642. t['yoyingthai'] = 0x0E0D;
  12643. t['yparen'] = 0x24B4;
  12644. t['ypogegrammeni'] = 0x037A;
  12645. t['ypogegrammenigreekcmb'] = 0x0345;
  12646. t['yr'] = 0x01A6;
  12647. t['yring'] = 0x1E99;
  12648. t['ysuperior'] = 0x02B8;
  12649. t['ytilde'] = 0x1EF9;
  12650. t['yturned'] = 0x028E;
  12651. t['yuhiragana'] = 0x3086;
  12652. t['yuikorean'] = 0x318C;
  12653. t['yukatakana'] = 0x30E6;
  12654. t['yukatakanahalfwidth'] = 0xFF95;
  12655. t['yukorean'] = 0x3160;
  12656. t['yusbigcyrillic'] = 0x046B;
  12657. t['yusbigiotifiedcyrillic'] = 0x046D;
  12658. t['yuslittlecyrillic'] = 0x0467;
  12659. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12660. t['yusmallhiragana'] = 0x3085;
  12661. t['yusmallkatakana'] = 0x30E5;
  12662. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12663. t['yuyekorean'] = 0x318B;
  12664. t['yuyeokorean'] = 0x318A;
  12665. t['yyabengali'] = 0x09DF;
  12666. t['yyadeva'] = 0x095F;
  12667. t['z'] = 0x007A;
  12668. t['zaarmenian'] = 0x0566;
  12669. t['zacute'] = 0x017A;
  12670. t['zadeva'] = 0x095B;
  12671. t['zagurmukhi'] = 0x0A5B;
  12672. t['zaharabic'] = 0x0638;
  12673. t['zahfinalarabic'] = 0xFEC6;
  12674. t['zahinitialarabic'] = 0xFEC7;
  12675. t['zahiragana'] = 0x3056;
  12676. t['zahmedialarabic'] = 0xFEC8;
  12677. t['zainarabic'] = 0x0632;
  12678. t['zainfinalarabic'] = 0xFEB0;
  12679. t['zakatakana'] = 0x30B6;
  12680. t['zaqefgadolhebrew'] = 0x0595;
  12681. t['zaqefqatanhebrew'] = 0x0594;
  12682. t['zarqahebrew'] = 0x0598;
  12683. t['zayin'] = 0x05D6;
  12684. t['zayindagesh'] = 0xFB36;
  12685. t['zayindageshhebrew'] = 0xFB36;
  12686. t['zayinhebrew'] = 0x05D6;
  12687. t['zbopomofo'] = 0x3117;
  12688. t['zcaron'] = 0x017E;
  12689. t['zcircle'] = 0x24E9;
  12690. t['zcircumflex'] = 0x1E91;
  12691. t['zcurl'] = 0x0291;
  12692. t['zdot'] = 0x017C;
  12693. t['zdotaccent'] = 0x017C;
  12694. t['zdotbelow'] = 0x1E93;
  12695. t['zecyrillic'] = 0x0437;
  12696. t['zedescendercyrillic'] = 0x0499;
  12697. t['zedieresiscyrillic'] = 0x04DF;
  12698. t['zehiragana'] = 0x305C;
  12699. t['zekatakana'] = 0x30BC;
  12700. t['zero'] = 0x0030;
  12701. t['zeroarabic'] = 0x0660;
  12702. t['zerobengali'] = 0x09E6;
  12703. t['zerodeva'] = 0x0966;
  12704. t['zerogujarati'] = 0x0AE6;
  12705. t['zerogurmukhi'] = 0x0A66;
  12706. t['zerohackarabic'] = 0x0660;
  12707. t['zeroinferior'] = 0x2080;
  12708. t['zeromonospace'] = 0xFF10;
  12709. t['zerooldstyle'] = 0xF730;
  12710. t['zeropersian'] = 0x06F0;
  12711. t['zerosuperior'] = 0x2070;
  12712. t['zerothai'] = 0x0E50;
  12713. t['zerowidthjoiner'] = 0xFEFF;
  12714. t['zerowidthnonjoiner'] = 0x200C;
  12715. t['zerowidthspace'] = 0x200B;
  12716. t['zeta'] = 0x03B6;
  12717. t['zhbopomofo'] = 0x3113;
  12718. t['zhearmenian'] = 0x056A;
  12719. t['zhebrevecyrillic'] = 0x04C2;
  12720. t['zhecyrillic'] = 0x0436;
  12721. t['zhedescendercyrillic'] = 0x0497;
  12722. t['zhedieresiscyrillic'] = 0x04DD;
  12723. t['zihiragana'] = 0x3058;
  12724. t['zikatakana'] = 0x30B8;
  12725. t['zinorhebrew'] = 0x05AE;
  12726. t['zlinebelow'] = 0x1E95;
  12727. t['zmonospace'] = 0xFF5A;
  12728. t['zohiragana'] = 0x305E;
  12729. t['zokatakana'] = 0x30BE;
  12730. t['zparen'] = 0x24B5;
  12731. t['zretroflexhook'] = 0x0290;
  12732. t['zstroke'] = 0x01B6;
  12733. t['zuhiragana'] = 0x305A;
  12734. t['zukatakana'] = 0x30BA;
  12735. t['.notdef'] = 0x0000;
  12736. t['angbracketleftbig'] = 0x2329;
  12737. t['angbracketleftBig'] = 0x2329;
  12738. t['angbracketleftbigg'] = 0x2329;
  12739. t['angbracketleftBigg'] = 0x2329;
  12740. t['angbracketrightBig'] = 0x232A;
  12741. t['angbracketrightbig'] = 0x232A;
  12742. t['angbracketrightBigg'] = 0x232A;
  12743. t['angbracketrightbigg'] = 0x232A;
  12744. t['arrowhookleft'] = 0x21AA;
  12745. t['arrowhookright'] = 0x21A9;
  12746. t['arrowlefttophalf'] = 0x21BC;
  12747. t['arrowleftbothalf'] = 0x21BD;
  12748. t['arrownortheast'] = 0x2197;
  12749. t['arrownorthwest'] = 0x2196;
  12750. t['arrowrighttophalf'] = 0x21C0;
  12751. t['arrowrightbothalf'] = 0x21C1;
  12752. t['arrowsoutheast'] = 0x2198;
  12753. t['arrowsouthwest'] = 0x2199;
  12754. t['backslashbig'] = 0x2216;
  12755. t['backslashBig'] = 0x2216;
  12756. t['backslashBigg'] = 0x2216;
  12757. t['backslashbigg'] = 0x2216;
  12758. t['bardbl'] = 0x2016;
  12759. t['bracehtipdownleft'] = 0xFE37;
  12760. t['bracehtipdownright'] = 0xFE37;
  12761. t['bracehtipupleft'] = 0xFE38;
  12762. t['bracehtipupright'] = 0xFE38;
  12763. t['braceleftBig'] = 0x007B;
  12764. t['braceleftbig'] = 0x007B;
  12765. t['braceleftbigg'] = 0x007B;
  12766. t['braceleftBigg'] = 0x007B;
  12767. t['bracerightBig'] = 0x007D;
  12768. t['bracerightbig'] = 0x007D;
  12769. t['bracerightbigg'] = 0x007D;
  12770. t['bracerightBigg'] = 0x007D;
  12771. t['bracketleftbig'] = 0x005B;
  12772. t['bracketleftBig'] = 0x005B;
  12773. t['bracketleftbigg'] = 0x005B;
  12774. t['bracketleftBigg'] = 0x005B;
  12775. t['bracketrightBig'] = 0x005D;
  12776. t['bracketrightbig'] = 0x005D;
  12777. t['bracketrightbigg'] = 0x005D;
  12778. t['bracketrightBigg'] = 0x005D;
  12779. t['ceilingleftbig'] = 0x2308;
  12780. t['ceilingleftBig'] = 0x2308;
  12781. t['ceilingleftBigg'] = 0x2308;
  12782. t['ceilingleftbigg'] = 0x2308;
  12783. t['ceilingrightbig'] = 0x2309;
  12784. t['ceilingrightBig'] = 0x2309;
  12785. t['ceilingrightbigg'] = 0x2309;
  12786. t['ceilingrightBigg'] = 0x2309;
  12787. t['circledotdisplay'] = 0x2299;
  12788. t['circledottext'] = 0x2299;
  12789. t['circlemultiplydisplay'] = 0x2297;
  12790. t['circlemultiplytext'] = 0x2297;
  12791. t['circleplusdisplay'] = 0x2295;
  12792. t['circleplustext'] = 0x2295;
  12793. t['contintegraldisplay'] = 0x222E;
  12794. t['contintegraltext'] = 0x222E;
  12795. t['coproductdisplay'] = 0x2210;
  12796. t['coproducttext'] = 0x2210;
  12797. t['floorleftBig'] = 0x230A;
  12798. t['floorleftbig'] = 0x230A;
  12799. t['floorleftbigg'] = 0x230A;
  12800. t['floorleftBigg'] = 0x230A;
  12801. t['floorrightbig'] = 0x230B;
  12802. t['floorrightBig'] = 0x230B;
  12803. t['floorrightBigg'] = 0x230B;
  12804. t['floorrightbigg'] = 0x230B;
  12805. t['hatwide'] = 0x0302;
  12806. t['hatwider'] = 0x0302;
  12807. t['hatwidest'] = 0x0302;
  12808. t['intercal'] = 0x1D40;
  12809. t['integraldisplay'] = 0x222B;
  12810. t['integraltext'] = 0x222B;
  12811. t['intersectiondisplay'] = 0x22C2;
  12812. t['intersectiontext'] = 0x22C2;
  12813. t['logicalanddisplay'] = 0x2227;
  12814. t['logicalandtext'] = 0x2227;
  12815. t['logicalordisplay'] = 0x2228;
  12816. t['logicalortext'] = 0x2228;
  12817. t['parenleftBig'] = 0x0028;
  12818. t['parenleftbig'] = 0x0028;
  12819. t['parenleftBigg'] = 0x0028;
  12820. t['parenleftbigg'] = 0x0028;
  12821. t['parenrightBig'] = 0x0029;
  12822. t['parenrightbig'] = 0x0029;
  12823. t['parenrightBigg'] = 0x0029;
  12824. t['parenrightbigg'] = 0x0029;
  12825. t['prime'] = 0x2032;
  12826. t['productdisplay'] = 0x220F;
  12827. t['producttext'] = 0x220F;
  12828. t['radicalbig'] = 0x221A;
  12829. t['radicalBig'] = 0x221A;
  12830. t['radicalBigg'] = 0x221A;
  12831. t['radicalbigg'] = 0x221A;
  12832. t['radicalbt'] = 0x221A;
  12833. t['radicaltp'] = 0x221A;
  12834. t['radicalvertex'] = 0x221A;
  12835. t['slashbig'] = 0x002F;
  12836. t['slashBig'] = 0x002F;
  12837. t['slashBigg'] = 0x002F;
  12838. t['slashbigg'] = 0x002F;
  12839. t['summationdisplay'] = 0x2211;
  12840. t['summationtext'] = 0x2211;
  12841. t['tildewide'] = 0x02DC;
  12842. t['tildewider'] = 0x02DC;
  12843. t['tildewidest'] = 0x02DC;
  12844. t['uniondisplay'] = 0x22C3;
  12845. t['unionmultidisplay'] = 0x228E;
  12846. t['unionmultitext'] = 0x228E;
  12847. t['unionsqdisplay'] = 0x2294;
  12848. t['unionsqtext'] = 0x2294;
  12849. t['uniontext'] = 0x22C3;
  12850. t['vextenddouble'] = 0x2225;
  12851. t['vextendsingle'] = 0x2223;
  12852. });
  12853. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12854. t['space'] = 0x0020;
  12855. t['a1'] = 0x2701;
  12856. t['a2'] = 0x2702;
  12857. t['a202'] = 0x2703;
  12858. t['a3'] = 0x2704;
  12859. t['a4'] = 0x260E;
  12860. t['a5'] = 0x2706;
  12861. t['a119'] = 0x2707;
  12862. t['a118'] = 0x2708;
  12863. t['a117'] = 0x2709;
  12864. t['a11'] = 0x261B;
  12865. t['a12'] = 0x261E;
  12866. t['a13'] = 0x270C;
  12867. t['a14'] = 0x270D;
  12868. t['a15'] = 0x270E;
  12869. t['a16'] = 0x270F;
  12870. t['a105'] = 0x2710;
  12871. t['a17'] = 0x2711;
  12872. t['a18'] = 0x2712;
  12873. t['a19'] = 0x2713;
  12874. t['a20'] = 0x2714;
  12875. t['a21'] = 0x2715;
  12876. t['a22'] = 0x2716;
  12877. t['a23'] = 0x2717;
  12878. t['a24'] = 0x2718;
  12879. t['a25'] = 0x2719;
  12880. t['a26'] = 0x271A;
  12881. t['a27'] = 0x271B;
  12882. t['a28'] = 0x271C;
  12883. t['a6'] = 0x271D;
  12884. t['a7'] = 0x271E;
  12885. t['a8'] = 0x271F;
  12886. t['a9'] = 0x2720;
  12887. t['a10'] = 0x2721;
  12888. t['a29'] = 0x2722;
  12889. t['a30'] = 0x2723;
  12890. t['a31'] = 0x2724;
  12891. t['a32'] = 0x2725;
  12892. t['a33'] = 0x2726;
  12893. t['a34'] = 0x2727;
  12894. t['a35'] = 0x2605;
  12895. t['a36'] = 0x2729;
  12896. t['a37'] = 0x272A;
  12897. t['a38'] = 0x272B;
  12898. t['a39'] = 0x272C;
  12899. t['a40'] = 0x272D;
  12900. t['a41'] = 0x272E;
  12901. t['a42'] = 0x272F;
  12902. t['a43'] = 0x2730;
  12903. t['a44'] = 0x2731;
  12904. t['a45'] = 0x2732;
  12905. t['a46'] = 0x2733;
  12906. t['a47'] = 0x2734;
  12907. t['a48'] = 0x2735;
  12908. t['a49'] = 0x2736;
  12909. t['a50'] = 0x2737;
  12910. t['a51'] = 0x2738;
  12911. t['a52'] = 0x2739;
  12912. t['a53'] = 0x273A;
  12913. t['a54'] = 0x273B;
  12914. t['a55'] = 0x273C;
  12915. t['a56'] = 0x273D;
  12916. t['a57'] = 0x273E;
  12917. t['a58'] = 0x273F;
  12918. t['a59'] = 0x2740;
  12919. t['a60'] = 0x2741;
  12920. t['a61'] = 0x2742;
  12921. t['a62'] = 0x2743;
  12922. t['a63'] = 0x2744;
  12923. t['a64'] = 0x2745;
  12924. t['a65'] = 0x2746;
  12925. t['a66'] = 0x2747;
  12926. t['a67'] = 0x2748;
  12927. t['a68'] = 0x2749;
  12928. t['a69'] = 0x274A;
  12929. t['a70'] = 0x274B;
  12930. t['a71'] = 0x25CF;
  12931. t['a72'] = 0x274D;
  12932. t['a73'] = 0x25A0;
  12933. t['a74'] = 0x274F;
  12934. t['a203'] = 0x2750;
  12935. t['a75'] = 0x2751;
  12936. t['a204'] = 0x2752;
  12937. t['a76'] = 0x25B2;
  12938. t['a77'] = 0x25BC;
  12939. t['a78'] = 0x25C6;
  12940. t['a79'] = 0x2756;
  12941. t['a81'] = 0x25D7;
  12942. t['a82'] = 0x2758;
  12943. t['a83'] = 0x2759;
  12944. t['a84'] = 0x275A;
  12945. t['a97'] = 0x275B;
  12946. t['a98'] = 0x275C;
  12947. t['a99'] = 0x275D;
  12948. t['a100'] = 0x275E;
  12949. t['a101'] = 0x2761;
  12950. t['a102'] = 0x2762;
  12951. t['a103'] = 0x2763;
  12952. t['a104'] = 0x2764;
  12953. t['a106'] = 0x2765;
  12954. t['a107'] = 0x2766;
  12955. t['a108'] = 0x2767;
  12956. t['a112'] = 0x2663;
  12957. t['a111'] = 0x2666;
  12958. t['a110'] = 0x2665;
  12959. t['a109'] = 0x2660;
  12960. t['a120'] = 0x2460;
  12961. t['a121'] = 0x2461;
  12962. t['a122'] = 0x2462;
  12963. t['a123'] = 0x2463;
  12964. t['a124'] = 0x2464;
  12965. t['a125'] = 0x2465;
  12966. t['a126'] = 0x2466;
  12967. t['a127'] = 0x2467;
  12968. t['a128'] = 0x2468;
  12969. t['a129'] = 0x2469;
  12970. t['a130'] = 0x2776;
  12971. t['a131'] = 0x2777;
  12972. t['a132'] = 0x2778;
  12973. t['a133'] = 0x2779;
  12974. t['a134'] = 0x277A;
  12975. t['a135'] = 0x277B;
  12976. t['a136'] = 0x277C;
  12977. t['a137'] = 0x277D;
  12978. t['a138'] = 0x277E;
  12979. t['a139'] = 0x277F;
  12980. t['a140'] = 0x2780;
  12981. t['a141'] = 0x2781;
  12982. t['a142'] = 0x2782;
  12983. t['a143'] = 0x2783;
  12984. t['a144'] = 0x2784;
  12985. t['a145'] = 0x2785;
  12986. t['a146'] = 0x2786;
  12987. t['a147'] = 0x2787;
  12988. t['a148'] = 0x2788;
  12989. t['a149'] = 0x2789;
  12990. t['a150'] = 0x278A;
  12991. t['a151'] = 0x278B;
  12992. t['a152'] = 0x278C;
  12993. t['a153'] = 0x278D;
  12994. t['a154'] = 0x278E;
  12995. t['a155'] = 0x278F;
  12996. t['a156'] = 0x2790;
  12997. t['a157'] = 0x2791;
  12998. t['a158'] = 0x2792;
  12999. t['a159'] = 0x2793;
  13000. t['a160'] = 0x2794;
  13001. t['a161'] = 0x2192;
  13002. t['a163'] = 0x2194;
  13003. t['a164'] = 0x2195;
  13004. t['a196'] = 0x2798;
  13005. t['a165'] = 0x2799;
  13006. t['a192'] = 0x279A;
  13007. t['a166'] = 0x279B;
  13008. t['a167'] = 0x279C;
  13009. t['a168'] = 0x279D;
  13010. t['a169'] = 0x279E;
  13011. t['a170'] = 0x279F;
  13012. t['a171'] = 0x27A0;
  13013. t['a172'] = 0x27A1;
  13014. t['a173'] = 0x27A2;
  13015. t['a162'] = 0x27A3;
  13016. t['a174'] = 0x27A4;
  13017. t['a175'] = 0x27A5;
  13018. t['a176'] = 0x27A6;
  13019. t['a177'] = 0x27A7;
  13020. t['a178'] = 0x27A8;
  13021. t['a179'] = 0x27A9;
  13022. t['a193'] = 0x27AA;
  13023. t['a180'] = 0x27AB;
  13024. t['a199'] = 0x27AC;
  13025. t['a181'] = 0x27AD;
  13026. t['a200'] = 0x27AE;
  13027. t['a182'] = 0x27AF;
  13028. t['a201'] = 0x27B1;
  13029. t['a183'] = 0x27B2;
  13030. t['a184'] = 0x27B3;
  13031. t['a197'] = 0x27B4;
  13032. t['a185'] = 0x27B5;
  13033. t['a194'] = 0x27B6;
  13034. t['a198'] = 0x27B7;
  13035. t['a186'] = 0x27B8;
  13036. t['a195'] = 0x27B9;
  13037. t['a187'] = 0x27BA;
  13038. t['a188'] = 0x27BB;
  13039. t['a189'] = 0x27BC;
  13040. t['a190'] = 0x27BD;
  13041. t['a191'] = 0x27BE;
  13042. t['a89'] = 0x2768;
  13043. t['a90'] = 0x2769;
  13044. t['a93'] = 0x276A;
  13045. t['a94'] = 0x276B;
  13046. t['a91'] = 0x276C;
  13047. t['a92'] = 0x276D;
  13048. t['a205'] = 0x276E;
  13049. t['a85'] = 0x276F;
  13050. t['a206'] = 0x2770;
  13051. t['a86'] = 0x2771;
  13052. t['a87'] = 0x2772;
  13053. t['a88'] = 0x2773;
  13054. t['a95'] = 0x2774;
  13055. t['a96'] = 0x2775;
  13056. t['.notdef'] = 0x0000;
  13057. });
  13058. exports.getGlyphsUnicode = getGlyphsUnicode;
  13059. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  13060. }));
  13061. (function (root, factory) {
  13062. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  13063. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  13064. var error = sharedUtil.error;
  13065. var log2 = sharedUtil.log2;
  13066. var readInt8 = sharedUtil.readInt8;
  13067. var readUint16 = sharedUtil.readUint16;
  13068. var readUint32 = sharedUtil.readUint32;
  13069. var shadow = sharedUtil.shadow;
  13070. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  13071. var Jbig2Image = function Jbig2ImageClosure() {
  13072. function ContextCache() {
  13073. }
  13074. ContextCache.prototype = {
  13075. getContexts: function (id) {
  13076. if (id in this) {
  13077. return this[id];
  13078. }
  13079. return this[id] = new Int8Array(1 << 16);
  13080. }
  13081. };
  13082. function DecodingContext(data, start, end) {
  13083. this.data = data;
  13084. this.start = start;
  13085. this.end = end;
  13086. }
  13087. DecodingContext.prototype = {
  13088. get decoder() {
  13089. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  13090. return shadow(this, 'decoder', decoder);
  13091. },
  13092. get contextCache() {
  13093. var cache = new ContextCache();
  13094. return shadow(this, 'contextCache', cache);
  13095. }
  13096. };
  13097. function decodeInteger(contextCache, procedure, decoder) {
  13098. var contexts = contextCache.getContexts(procedure);
  13099. var prev = 1;
  13100. function readBits(length) {
  13101. var v = 0;
  13102. for (var i = 0; i < length; i++) {
  13103. var bit = decoder.readBit(contexts, prev);
  13104. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  13105. v = v << 1 | bit;
  13106. }
  13107. return v >>> 0;
  13108. }
  13109. var sign = readBits(1);
  13110. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  13111. return sign === 0 ? value : value > 0 ? -value : null;
  13112. }
  13113. function decodeIAID(contextCache, decoder, codeLength) {
  13114. var contexts = contextCache.getContexts('IAID');
  13115. var prev = 1;
  13116. for (var i = 0; i < codeLength; i++) {
  13117. var bit = decoder.readBit(contexts, prev);
  13118. prev = prev << 1 | bit;
  13119. }
  13120. if (codeLength < 31) {
  13121. return prev & (1 << codeLength) - 1;
  13122. }
  13123. return prev & 0x7FFFFFFF;
  13124. }
  13125. var SegmentTypes = [
  13126. 'SymbolDictionary',
  13127. null,
  13128. null,
  13129. null,
  13130. 'IntermediateTextRegion',
  13131. null,
  13132. 'ImmediateTextRegion',
  13133. 'ImmediateLosslessTextRegion',
  13134. null,
  13135. null,
  13136. null,
  13137. null,
  13138. null,
  13139. null,
  13140. null,
  13141. null,
  13142. 'patternDictionary',
  13143. null,
  13144. null,
  13145. null,
  13146. 'IntermediateHalftoneRegion',
  13147. null,
  13148. 'ImmediateHalftoneRegion',
  13149. 'ImmediateLosslessHalftoneRegion',
  13150. null,
  13151. null,
  13152. null,
  13153. null,
  13154. null,
  13155. null,
  13156. null,
  13157. null,
  13158. null,
  13159. null,
  13160. null,
  13161. null,
  13162. 'IntermediateGenericRegion',
  13163. null,
  13164. 'ImmediateGenericRegion',
  13165. 'ImmediateLosslessGenericRegion',
  13166. 'IntermediateGenericRefinementRegion',
  13167. null,
  13168. 'ImmediateGenericRefinementRegion',
  13169. 'ImmediateLosslessGenericRefinementRegion',
  13170. null,
  13171. null,
  13172. null,
  13173. null,
  13174. 'PageInformation',
  13175. 'EndOfPage',
  13176. 'EndOfStripe',
  13177. 'EndOfFile',
  13178. 'Profiles',
  13179. 'Tables',
  13180. null,
  13181. null,
  13182. null,
  13183. null,
  13184. null,
  13185. null,
  13186. null,
  13187. null,
  13188. 'Extension'
  13189. ];
  13190. var CodingTemplates = [
  13191. [
  13192. {
  13193. x: -1,
  13194. y: -2
  13195. },
  13196. {
  13197. x: 0,
  13198. y: -2
  13199. },
  13200. {
  13201. x: 1,
  13202. y: -2
  13203. },
  13204. {
  13205. x: -2,
  13206. y: -1
  13207. },
  13208. {
  13209. x: -1,
  13210. y: -1
  13211. },
  13212. {
  13213. x: 0,
  13214. y: -1
  13215. },
  13216. {
  13217. x: 1,
  13218. y: -1
  13219. },
  13220. {
  13221. x: 2,
  13222. y: -1
  13223. },
  13224. {
  13225. x: -4,
  13226. y: 0
  13227. },
  13228. {
  13229. x: -3,
  13230. y: 0
  13231. },
  13232. {
  13233. x: -2,
  13234. y: 0
  13235. },
  13236. {
  13237. x: -1,
  13238. y: 0
  13239. }
  13240. ],
  13241. [
  13242. {
  13243. x: -1,
  13244. y: -2
  13245. },
  13246. {
  13247. x: 0,
  13248. y: -2
  13249. },
  13250. {
  13251. x: 1,
  13252. y: -2
  13253. },
  13254. {
  13255. x: 2,
  13256. y: -2
  13257. },
  13258. {
  13259. x: -2,
  13260. y: -1
  13261. },
  13262. {
  13263. x: -1,
  13264. y: -1
  13265. },
  13266. {
  13267. x: 0,
  13268. y: -1
  13269. },
  13270. {
  13271. x: 1,
  13272. y: -1
  13273. },
  13274. {
  13275. x: 2,
  13276. y: -1
  13277. },
  13278. {
  13279. x: -3,
  13280. y: 0
  13281. },
  13282. {
  13283. x: -2,
  13284. y: 0
  13285. },
  13286. {
  13287. x: -1,
  13288. y: 0
  13289. }
  13290. ],
  13291. [
  13292. {
  13293. x: -1,
  13294. y: -2
  13295. },
  13296. {
  13297. x: 0,
  13298. y: -2
  13299. },
  13300. {
  13301. x: 1,
  13302. y: -2
  13303. },
  13304. {
  13305. x: -2,
  13306. y: -1
  13307. },
  13308. {
  13309. x: -1,
  13310. y: -1
  13311. },
  13312. {
  13313. x: 0,
  13314. y: -1
  13315. },
  13316. {
  13317. x: 1,
  13318. y: -1
  13319. },
  13320. {
  13321. x: -2,
  13322. y: 0
  13323. },
  13324. {
  13325. x: -1,
  13326. y: 0
  13327. }
  13328. ],
  13329. [
  13330. {
  13331. x: -3,
  13332. y: -1
  13333. },
  13334. {
  13335. x: -2,
  13336. y: -1
  13337. },
  13338. {
  13339. x: -1,
  13340. y: -1
  13341. },
  13342. {
  13343. x: 0,
  13344. y: -1
  13345. },
  13346. {
  13347. x: 1,
  13348. y: -1
  13349. },
  13350. {
  13351. x: -4,
  13352. y: 0
  13353. },
  13354. {
  13355. x: -3,
  13356. y: 0
  13357. },
  13358. {
  13359. x: -2,
  13360. y: 0
  13361. },
  13362. {
  13363. x: -1,
  13364. y: 0
  13365. }
  13366. ]
  13367. ];
  13368. var RefinementTemplates = [
  13369. {
  13370. coding: [
  13371. {
  13372. x: 0,
  13373. y: -1
  13374. },
  13375. {
  13376. x: 1,
  13377. y: -1
  13378. },
  13379. {
  13380. x: -1,
  13381. y: 0
  13382. }
  13383. ],
  13384. reference: [
  13385. {
  13386. x: 0,
  13387. y: -1
  13388. },
  13389. {
  13390. x: 1,
  13391. y: -1
  13392. },
  13393. {
  13394. x: -1,
  13395. y: 0
  13396. },
  13397. {
  13398. x: 0,
  13399. y: 0
  13400. },
  13401. {
  13402. x: 1,
  13403. y: 0
  13404. },
  13405. {
  13406. x: -1,
  13407. y: 1
  13408. },
  13409. {
  13410. x: 0,
  13411. y: 1
  13412. },
  13413. {
  13414. x: 1,
  13415. y: 1
  13416. }
  13417. ]
  13418. },
  13419. {
  13420. coding: [
  13421. {
  13422. x: -1,
  13423. y: -1
  13424. },
  13425. {
  13426. x: 0,
  13427. y: -1
  13428. },
  13429. {
  13430. x: 1,
  13431. y: -1
  13432. },
  13433. {
  13434. x: -1,
  13435. y: 0
  13436. }
  13437. ],
  13438. reference: [
  13439. {
  13440. x: 0,
  13441. y: -1
  13442. },
  13443. {
  13444. x: -1,
  13445. y: 0
  13446. },
  13447. {
  13448. x: 0,
  13449. y: 0
  13450. },
  13451. {
  13452. x: 1,
  13453. y: 0
  13454. },
  13455. {
  13456. x: 0,
  13457. y: 1
  13458. },
  13459. {
  13460. x: 1,
  13461. y: 1
  13462. }
  13463. ]
  13464. }
  13465. ];
  13466. var ReusedContexts = [
  13467. 0x9B25,
  13468. 0x0795,
  13469. 0x00E5,
  13470. 0x0195
  13471. ];
  13472. var RefinementReusedContexts = [
  13473. 0x0020,
  13474. 0x0008
  13475. ];
  13476. function decodeBitmapTemplate0(width, height, decodingContext) {
  13477. var decoder = decodingContext.decoder;
  13478. var contexts = decodingContext.contextCache.getContexts('GB');
  13479. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13480. var OLD_PIXEL_MASK = 0x7BF7;
  13481. for (i = 0; i < height; i++) {
  13482. row = bitmap[i] = new Uint8Array(width);
  13483. row1 = i < 1 ? row : bitmap[i - 1];
  13484. row2 = i < 2 ? row : bitmap[i - 2];
  13485. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13486. for (j = 0; j < width; j++) {
  13487. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13488. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13489. }
  13490. }
  13491. return bitmap;
  13492. }
  13493. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13494. if (mmr) {
  13495. error('JBIG2 error: MMR encoding is not supported');
  13496. }
  13497. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  13498. return decodeBitmapTemplate0(width, height, decodingContext);
  13499. }
  13500. var useskip = !!skip;
  13501. var template = CodingTemplates[templateIndex].concat(at);
  13502. template.sort(function (a, b) {
  13503. return a.y - b.y || a.x - b.x;
  13504. });
  13505. var templateLength = template.length;
  13506. var templateX = new Int8Array(templateLength);
  13507. var templateY = new Int8Array(templateLength);
  13508. var changingTemplateEntries = [];
  13509. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13510. var c, k;
  13511. for (k = 0; k < templateLength; k++) {
  13512. templateX[k] = template[k].x;
  13513. templateY[k] = template[k].y;
  13514. minX = Math.min(minX, template[k].x);
  13515. maxX = Math.max(maxX, template[k].x);
  13516. minY = Math.min(minY, template[k].y);
  13517. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13518. reuseMask |= 1 << templateLength - 1 - k;
  13519. } else {
  13520. changingTemplateEntries.push(k);
  13521. }
  13522. }
  13523. var changingEntriesLength = changingTemplateEntries.length;
  13524. var changingTemplateX = new Int8Array(changingEntriesLength);
  13525. var changingTemplateY = new Int8Array(changingEntriesLength);
  13526. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13527. for (c = 0; c < changingEntriesLength; c++) {
  13528. k = changingTemplateEntries[c];
  13529. changingTemplateX[c] = template[k].x;
  13530. changingTemplateY[c] = template[k].y;
  13531. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13532. }
  13533. var sbb_left = -minX;
  13534. var sbb_top = -minY;
  13535. var sbb_right = width - maxX;
  13536. var pseudoPixelContext = ReusedContexts[templateIndex];
  13537. var row = new Uint8Array(width);
  13538. var bitmap = [];
  13539. var decoder = decodingContext.decoder;
  13540. var contexts = decodingContext.contextCache.getContexts('GB');
  13541. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13542. for (var i = 0; i < height; i++) {
  13543. if (prediction) {
  13544. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13545. ltp ^= sltp;
  13546. if (ltp) {
  13547. bitmap.push(row);
  13548. continue;
  13549. }
  13550. }
  13551. row = new Uint8Array(row);
  13552. bitmap.push(row);
  13553. for (j = 0; j < width; j++) {
  13554. if (useskip && skip[i][j]) {
  13555. row[j] = 0;
  13556. continue;
  13557. }
  13558. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13559. contextLabel = contextLabel << 1 & reuseMask;
  13560. for (k = 0; k < changingEntriesLength; k++) {
  13561. i0 = i + changingTemplateY[k];
  13562. j0 = j + changingTemplateX[k];
  13563. bit = bitmap[i0][j0];
  13564. if (bit) {
  13565. bit = changingTemplateBit[k];
  13566. contextLabel |= bit;
  13567. }
  13568. }
  13569. } else {
  13570. contextLabel = 0;
  13571. shift = templateLength - 1;
  13572. for (k = 0; k < templateLength; k++, shift--) {
  13573. j0 = j + templateX[k];
  13574. if (j0 >= 0 && j0 < width) {
  13575. i0 = i + templateY[k];
  13576. if (i0 >= 0) {
  13577. bit = bitmap[i0][j0];
  13578. if (bit) {
  13579. contextLabel |= bit << shift;
  13580. }
  13581. }
  13582. }
  13583. }
  13584. }
  13585. var pixel = decoder.readBit(contexts, contextLabel);
  13586. row[j] = pixel;
  13587. }
  13588. }
  13589. return bitmap;
  13590. }
  13591. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13592. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13593. if (templateIndex === 0) {
  13594. codingTemplate = codingTemplate.concat([at[0]]);
  13595. }
  13596. var codingTemplateLength = codingTemplate.length;
  13597. var codingTemplateX = new Int32Array(codingTemplateLength);
  13598. var codingTemplateY = new Int32Array(codingTemplateLength);
  13599. var k;
  13600. for (k = 0; k < codingTemplateLength; k++) {
  13601. codingTemplateX[k] = codingTemplate[k].x;
  13602. codingTemplateY[k] = codingTemplate[k].y;
  13603. }
  13604. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13605. if (templateIndex === 0) {
  13606. referenceTemplate = referenceTemplate.concat([at[1]]);
  13607. }
  13608. var referenceTemplateLength = referenceTemplate.length;
  13609. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13610. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13611. for (k = 0; k < referenceTemplateLength; k++) {
  13612. referenceTemplateX[k] = referenceTemplate[k].x;
  13613. referenceTemplateY[k] = referenceTemplate[k].y;
  13614. }
  13615. var referenceWidth = referenceBitmap[0].length;
  13616. var referenceHeight = referenceBitmap.length;
  13617. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13618. var bitmap = [];
  13619. var decoder = decodingContext.decoder;
  13620. var contexts = decodingContext.contextCache.getContexts('GR');
  13621. var ltp = 0;
  13622. for (var i = 0; i < height; i++) {
  13623. if (prediction) {
  13624. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13625. ltp ^= sltp;
  13626. if (ltp) {
  13627. error('JBIG2 error: prediction is not supported');
  13628. }
  13629. }
  13630. var row = new Uint8Array(width);
  13631. bitmap.push(row);
  13632. for (var j = 0; j < width; j++) {
  13633. var i0, j0;
  13634. var contextLabel = 0;
  13635. for (k = 0; k < codingTemplateLength; k++) {
  13636. i0 = i + codingTemplateY[k];
  13637. j0 = j + codingTemplateX[k];
  13638. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13639. contextLabel <<= 1;
  13640. } else
  13641. {
  13642. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13643. }
  13644. }
  13645. for (k = 0; k < referenceTemplateLength; k++) {
  13646. i0 = i + referenceTemplateY[k] + offsetY;
  13647. j0 = j + referenceTemplateX[k] + offsetX;
  13648. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13649. contextLabel <<= 1;
  13650. } else
  13651. {
  13652. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13653. }
  13654. }
  13655. var pixel = decoder.readBit(contexts, contextLabel);
  13656. row[j] = pixel;
  13657. }
  13658. }
  13659. return bitmap;
  13660. }
  13661. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13662. if (huffman) {
  13663. error('JBIG2 error: huffman is not supported');
  13664. }
  13665. var newSymbols = [];
  13666. var currentHeight = 0;
  13667. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13668. var decoder = decodingContext.decoder;
  13669. var contextCache = decodingContext.contextCache;
  13670. while (newSymbols.length < numberOfNewSymbols) {
  13671. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13672. currentHeight += deltaHeight;
  13673. var currentWidth = 0;
  13674. var totalWidth = 0;
  13675. while (true) {
  13676. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13677. if (deltaWidth === null) {
  13678. break;
  13679. }
  13680. currentWidth += deltaWidth;
  13681. totalWidth += currentWidth;
  13682. var bitmap;
  13683. if (refinement) {
  13684. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13685. if (numberOfInstances > 1) {
  13686. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13687. } else {
  13688. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13689. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13690. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13691. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13692. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13693. }
  13694. } else {
  13695. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13696. }
  13697. newSymbols.push(bitmap);
  13698. }
  13699. }
  13700. var exportedSymbols = [];
  13701. var flags = [], currentFlag = false;
  13702. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13703. while (flags.length < totalSymbolsLength) {
  13704. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13705. while (runLength--) {
  13706. flags.push(currentFlag);
  13707. }
  13708. currentFlag = !currentFlag;
  13709. }
  13710. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13711. if (flags[i]) {
  13712. exportedSymbols.push(symbols[i]);
  13713. }
  13714. }
  13715. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13716. if (flags[i]) {
  13717. exportedSymbols.push(newSymbols[j]);
  13718. }
  13719. }
  13720. return exportedSymbols;
  13721. }
  13722. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13723. if (huffman) {
  13724. error('JBIG2 error: huffman is not supported');
  13725. }
  13726. var bitmap = [];
  13727. var i, row;
  13728. for (i = 0; i < height; i++) {
  13729. row = new Uint8Array(width);
  13730. if (defaultPixelValue) {
  13731. for (var j = 0; j < width; j++) {
  13732. row[j] = defaultPixelValue;
  13733. }
  13734. }
  13735. bitmap.push(row);
  13736. }
  13737. var decoder = decodingContext.decoder;
  13738. var contextCache = decodingContext.contextCache;
  13739. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13740. var firstS = 0;
  13741. i = 0;
  13742. while (i < numberOfSymbolInstances) {
  13743. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13744. stripT += deltaT;
  13745. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13746. firstS += deltaFirstS;
  13747. var currentS = firstS;
  13748. do {
  13749. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13750. var t = stripSize * stripT + currentT;
  13751. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13752. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13753. var symbolBitmap = inputSymbols[symbolId];
  13754. var symbolWidth = symbolBitmap[0].length;
  13755. var symbolHeight = symbolBitmap.length;
  13756. if (applyRefinement) {
  13757. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13758. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13759. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13760. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13761. symbolWidth += rdw;
  13762. symbolHeight += rdh;
  13763. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13764. }
  13765. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13766. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13767. var s2, t2, symbolRow;
  13768. if (transposed) {
  13769. for (s2 = 0; s2 < symbolHeight; s2++) {
  13770. row = bitmap[offsetS + s2];
  13771. if (!row) {
  13772. continue;
  13773. }
  13774. symbolRow = symbolBitmap[s2];
  13775. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13776. switch (combinationOperator) {
  13777. case 0:
  13778. for (t2 = 0; t2 < maxWidth; t2++) {
  13779. row[offsetT + t2] |= symbolRow[t2];
  13780. }
  13781. break;
  13782. case 2:
  13783. for (t2 = 0; t2 < maxWidth; t2++) {
  13784. row[offsetT + t2] ^= symbolRow[t2];
  13785. }
  13786. break;
  13787. default:
  13788. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13789. }
  13790. }
  13791. currentS += symbolHeight - 1;
  13792. } else {
  13793. for (t2 = 0; t2 < symbolHeight; t2++) {
  13794. row = bitmap[offsetT + t2];
  13795. if (!row) {
  13796. continue;
  13797. }
  13798. symbolRow = symbolBitmap[t2];
  13799. switch (combinationOperator) {
  13800. case 0:
  13801. for (s2 = 0; s2 < symbolWidth; s2++) {
  13802. row[offsetS + s2] |= symbolRow[s2];
  13803. }
  13804. break;
  13805. case 2:
  13806. for (s2 = 0; s2 < symbolWidth; s2++) {
  13807. row[offsetS + s2] ^= symbolRow[s2];
  13808. }
  13809. break;
  13810. default:
  13811. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13812. }
  13813. }
  13814. currentS += symbolWidth - 1;
  13815. }
  13816. i++;
  13817. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13818. if (deltaS === null) {
  13819. break;
  13820. }
  13821. currentS += deltaS + dsOffset;
  13822. } while (true);
  13823. }
  13824. return bitmap;
  13825. }
  13826. function readSegmentHeader(data, start) {
  13827. var segmentHeader = {};
  13828. segmentHeader.number = readUint32(data, start);
  13829. var flags = data[start + 4];
  13830. var segmentType = flags & 0x3F;
  13831. if (!SegmentTypes[segmentType]) {
  13832. error('JBIG2 error: invalid segment type: ' + segmentType);
  13833. }
  13834. segmentHeader.type = segmentType;
  13835. segmentHeader.typeName = SegmentTypes[segmentType];
  13836. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13837. var pageAssociationFieldSize = !!(flags & 0x40);
  13838. var referredFlags = data[start + 5];
  13839. var referredToCount = referredFlags >> 5 & 7;
  13840. var retainBits = [referredFlags & 31];
  13841. var position = start + 6;
  13842. if (referredFlags === 7) {
  13843. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13844. position += 3;
  13845. var bytes = referredToCount + 7 >> 3;
  13846. retainBits[0] = data[position++];
  13847. while (--bytes > 0) {
  13848. retainBits.push(data[position++]);
  13849. }
  13850. } else if (referredFlags === 5 || referredFlags === 6) {
  13851. error('JBIG2 error: invalid referred-to flags');
  13852. }
  13853. segmentHeader.retainBits = retainBits;
  13854. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13855. var referredTo = [];
  13856. var i, ii;
  13857. for (i = 0; i < referredToCount; i++) {
  13858. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13859. referredTo.push(number);
  13860. position += referredToSegmentNumberSize;
  13861. }
  13862. segmentHeader.referredTo = referredTo;
  13863. if (!pageAssociationFieldSize) {
  13864. segmentHeader.pageAssociation = data[position++];
  13865. } else {
  13866. segmentHeader.pageAssociation = readUint32(data, position);
  13867. position += 4;
  13868. }
  13869. segmentHeader.length = readUint32(data, position);
  13870. position += 4;
  13871. if (segmentHeader.length === 0xFFFFFFFF) {
  13872. if (segmentType === 38) {
  13873. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13874. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13875. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13876. var searchPatternLength = 6;
  13877. var searchPattern = new Uint8Array(searchPatternLength);
  13878. if (!genericRegionMmr) {
  13879. searchPattern[0] = 0xFF;
  13880. searchPattern[1] = 0xAC;
  13881. }
  13882. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13883. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13884. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13885. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13886. for (i = position, ii = data.length; i < ii; i++) {
  13887. var j = 0;
  13888. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13889. j++;
  13890. }
  13891. if (j === searchPatternLength) {
  13892. segmentHeader.length = i + searchPatternLength;
  13893. break;
  13894. }
  13895. }
  13896. if (segmentHeader.length === 0xFFFFFFFF) {
  13897. error('JBIG2 error: segment end was not found');
  13898. }
  13899. } else {
  13900. error('JBIG2 error: invalid unknown segment length');
  13901. }
  13902. }
  13903. segmentHeader.headerEnd = position;
  13904. return segmentHeader;
  13905. }
  13906. function readSegments(header, data, start, end) {
  13907. var segments = [];
  13908. var position = start;
  13909. while (position < end) {
  13910. var segmentHeader = readSegmentHeader(data, position);
  13911. position = segmentHeader.headerEnd;
  13912. var segment = {
  13913. header: segmentHeader,
  13914. data: data
  13915. };
  13916. if (!header.randomAccess) {
  13917. segment.start = position;
  13918. position += segmentHeader.length;
  13919. segment.end = position;
  13920. }
  13921. segments.push(segment);
  13922. if (segmentHeader.type === 51) {
  13923. break;
  13924. }
  13925. }
  13926. if (header.randomAccess) {
  13927. for (var i = 0, ii = segments.length; i < ii; i++) {
  13928. segments[i].start = position;
  13929. position += segments[i].header.length;
  13930. segments[i].end = position;
  13931. }
  13932. }
  13933. return segments;
  13934. }
  13935. function readRegionSegmentInformation(data, start) {
  13936. return {
  13937. width: readUint32(data, start),
  13938. height: readUint32(data, start + 4),
  13939. x: readUint32(data, start + 8),
  13940. y: readUint32(data, start + 12),
  13941. combinationOperator: data[start + 16] & 7
  13942. };
  13943. }
  13944. var RegionSegmentInformationFieldLength = 17;
  13945. function processSegment(segment, visitor) {
  13946. var header = segment.header;
  13947. var data = segment.data, position = segment.start, end = segment.end;
  13948. var args, at, i, atLength;
  13949. switch (header.type) {
  13950. case 0:
  13951. var dictionary = {};
  13952. var dictionaryFlags = readUint16(data, position);
  13953. dictionary.huffman = !!(dictionaryFlags & 1);
  13954. dictionary.refinement = !!(dictionaryFlags & 2);
  13955. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13956. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13957. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13958. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13959. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13960. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13961. dictionary.template = dictionaryFlags >> 10 & 3;
  13962. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13963. position += 2;
  13964. if (!dictionary.huffman) {
  13965. atLength = dictionary.template === 0 ? 4 : 1;
  13966. at = [];
  13967. for (i = 0; i < atLength; i++) {
  13968. at.push({
  13969. x: readInt8(data, position),
  13970. y: readInt8(data, position + 1)
  13971. });
  13972. position += 2;
  13973. }
  13974. dictionary.at = at;
  13975. }
  13976. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13977. at = [];
  13978. for (i = 0; i < 2; i++) {
  13979. at.push({
  13980. x: readInt8(data, position),
  13981. y: readInt8(data, position + 1)
  13982. });
  13983. position += 2;
  13984. }
  13985. dictionary.refinementAt = at;
  13986. }
  13987. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13988. position += 4;
  13989. dictionary.numberOfNewSymbols = readUint32(data, position);
  13990. position += 4;
  13991. args = [
  13992. dictionary,
  13993. header.number,
  13994. header.referredTo,
  13995. data,
  13996. position,
  13997. end
  13998. ];
  13999. break;
  14000. case 6:
  14001. case 7:
  14002. var textRegion = {};
  14003. textRegion.info = readRegionSegmentInformation(data, position);
  14004. position += RegionSegmentInformationFieldLength;
  14005. var textRegionSegmentFlags = readUint16(data, position);
  14006. position += 2;
  14007. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  14008. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  14009. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  14010. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  14011. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  14012. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  14013. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  14014. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  14015. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  14016. if (textRegion.huffman) {
  14017. var textRegionHuffmanFlags = readUint16(data, position);
  14018. position += 2;
  14019. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  14020. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  14021. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  14022. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  14023. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  14024. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  14025. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  14026. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  14027. }
  14028. if (textRegion.refinement && !textRegion.refinementTemplate) {
  14029. at = [];
  14030. for (i = 0; i < 2; i++) {
  14031. at.push({
  14032. x: readInt8(data, position),
  14033. y: readInt8(data, position + 1)
  14034. });
  14035. position += 2;
  14036. }
  14037. textRegion.refinementAt = at;
  14038. }
  14039. textRegion.numberOfSymbolInstances = readUint32(data, position);
  14040. position += 4;
  14041. if (textRegion.huffman) {
  14042. error('JBIG2 error: huffman is not supported');
  14043. }
  14044. args = [
  14045. textRegion,
  14046. header.referredTo,
  14047. data,
  14048. position,
  14049. end
  14050. ];
  14051. break;
  14052. case 38:
  14053. case 39:
  14054. var genericRegion = {};
  14055. genericRegion.info = readRegionSegmentInformation(data, position);
  14056. position += RegionSegmentInformationFieldLength;
  14057. var genericRegionSegmentFlags = data[position++];
  14058. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  14059. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  14060. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  14061. if (!genericRegion.mmr) {
  14062. atLength = genericRegion.template === 0 ? 4 : 1;
  14063. at = [];
  14064. for (i = 0; i < atLength; i++) {
  14065. at.push({
  14066. x: readInt8(data, position),
  14067. y: readInt8(data, position + 1)
  14068. });
  14069. position += 2;
  14070. }
  14071. genericRegion.at = at;
  14072. }
  14073. args = [
  14074. genericRegion,
  14075. data,
  14076. position,
  14077. end
  14078. ];
  14079. break;
  14080. case 48:
  14081. var pageInfo = {
  14082. width: readUint32(data, position),
  14083. height: readUint32(data, position + 4),
  14084. resolutionX: readUint32(data, position + 8),
  14085. resolutionY: readUint32(data, position + 12)
  14086. };
  14087. if (pageInfo.height === 0xFFFFFFFF) {
  14088. delete pageInfo.height;
  14089. }
  14090. var pageSegmentFlags = data[position + 16];
  14091. var pageStripingInformation = readUint16(data, position + 17);
  14092. pageInfo.lossless = !!(pageSegmentFlags & 1);
  14093. pageInfo.refinement = !!(pageSegmentFlags & 2);
  14094. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  14095. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  14096. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  14097. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  14098. args = [pageInfo];
  14099. break;
  14100. case 49:
  14101. break;
  14102. case 50:
  14103. break;
  14104. case 51:
  14105. break;
  14106. case 62:
  14107. break;
  14108. default:
  14109. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  14110. }
  14111. var callbackName = 'on' + header.typeName;
  14112. if (callbackName in visitor) {
  14113. visitor[callbackName].apply(visitor, args);
  14114. }
  14115. }
  14116. function processSegments(segments, visitor) {
  14117. for (var i = 0, ii = segments.length; i < ii; i++) {
  14118. processSegment(segments[i], visitor);
  14119. }
  14120. }
  14121. function parseJbig2(data, start, end) {
  14122. var position = start;
  14123. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  14124. error('JBIG2 error: invalid header');
  14125. }
  14126. var header = {};
  14127. position += 8;
  14128. var flags = data[position++];
  14129. header.randomAccess = !(flags & 1);
  14130. if (!(flags & 2)) {
  14131. header.numberOfPages = readUint32(data, position);
  14132. position += 4;
  14133. }
  14134. var segments = readSegments(header, data, position, end);
  14135. error('Not implemented');
  14136. }
  14137. function parseJbig2Chunks(chunks) {
  14138. var visitor = new SimpleSegmentVisitor();
  14139. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14140. var chunk = chunks[i];
  14141. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14142. processSegments(segments, visitor);
  14143. }
  14144. return visitor.buffer;
  14145. }
  14146. function SimpleSegmentVisitor() {
  14147. }
  14148. SimpleSegmentVisitor.prototype = {
  14149. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14150. this.currentPageInfo = info;
  14151. var rowSize = info.width + 7 >> 3;
  14152. var buffer = new Uint8Array(rowSize * info.height);
  14153. if (info.defaultPixelValue) {
  14154. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14155. buffer[i] = 0xFF;
  14156. }
  14157. }
  14158. this.buffer = buffer;
  14159. },
  14160. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14161. var pageInfo = this.currentPageInfo;
  14162. var width = regionInfo.width, height = regionInfo.height;
  14163. var rowSize = pageInfo.width + 7 >> 3;
  14164. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14165. var buffer = this.buffer;
  14166. var mask0 = 128 >> (regionInfo.x & 7);
  14167. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14168. var i, j, mask, offset;
  14169. switch (combinationOperator) {
  14170. case 0:
  14171. for (i = 0; i < height; i++) {
  14172. mask = mask0;
  14173. offset = offset0;
  14174. for (j = 0; j < width; j++) {
  14175. if (bitmap[i][j]) {
  14176. buffer[offset] |= mask;
  14177. }
  14178. mask >>= 1;
  14179. if (!mask) {
  14180. mask = 128;
  14181. offset++;
  14182. }
  14183. }
  14184. offset0 += rowSize;
  14185. }
  14186. break;
  14187. case 2:
  14188. for (i = 0; i < height; i++) {
  14189. mask = mask0;
  14190. offset = offset0;
  14191. for (j = 0; j < width; j++) {
  14192. if (bitmap[i][j]) {
  14193. buffer[offset] ^= mask;
  14194. }
  14195. mask >>= 1;
  14196. if (!mask) {
  14197. mask = 128;
  14198. offset++;
  14199. }
  14200. }
  14201. offset0 += rowSize;
  14202. }
  14203. break;
  14204. default:
  14205. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14206. }
  14207. },
  14208. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14209. var regionInfo = region.info;
  14210. var decodingContext = new DecodingContext(data, start, end);
  14211. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14212. this.drawBitmap(regionInfo, bitmap);
  14213. },
  14214. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14215. this.onImmediateGenericRegion.apply(this, arguments);
  14216. },
  14217. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14218. var huffmanTables;
  14219. if (dictionary.huffman) {
  14220. error('JBIG2 error: huffman is not supported');
  14221. }
  14222. var symbols = this.symbols;
  14223. if (!symbols) {
  14224. this.symbols = symbols = {};
  14225. }
  14226. var inputSymbols = [];
  14227. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14228. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14229. }
  14230. var decodingContext = new DecodingContext(data, start, end);
  14231. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14232. },
  14233. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14234. var regionInfo = region.info;
  14235. var huffmanTables;
  14236. var symbols = this.symbols;
  14237. var inputSymbols = [];
  14238. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14239. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14240. }
  14241. var symbolCodeLength = log2(inputSymbols.length);
  14242. var decodingContext = new DecodingContext(data, start, end);
  14243. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext);
  14244. this.drawBitmap(regionInfo, bitmap);
  14245. },
  14246. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14247. this.onImmediateTextRegion.apply(this, arguments);
  14248. }
  14249. };
  14250. function Jbig2Image() {
  14251. }
  14252. Jbig2Image.prototype = {
  14253. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14254. return parseJbig2Chunks(chunks);
  14255. }
  14256. };
  14257. return Jbig2Image;
  14258. }();
  14259. exports.Jbig2Image = Jbig2Image;
  14260. }));
  14261. (function (root, factory) {
  14262. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14263. }(this, function (exports, sharedUtil) {
  14264. var error = sharedUtil.error;
  14265. var JpegImage = function JpegImageClosure() {
  14266. var dctZigZag = new Uint8Array([
  14267. 0,
  14268. 1,
  14269. 8,
  14270. 16,
  14271. 9,
  14272. 2,
  14273. 3,
  14274. 10,
  14275. 17,
  14276. 24,
  14277. 32,
  14278. 25,
  14279. 18,
  14280. 11,
  14281. 4,
  14282. 5,
  14283. 12,
  14284. 19,
  14285. 26,
  14286. 33,
  14287. 40,
  14288. 48,
  14289. 41,
  14290. 34,
  14291. 27,
  14292. 20,
  14293. 13,
  14294. 6,
  14295. 7,
  14296. 14,
  14297. 21,
  14298. 28,
  14299. 35,
  14300. 42,
  14301. 49,
  14302. 56,
  14303. 57,
  14304. 50,
  14305. 43,
  14306. 36,
  14307. 29,
  14308. 22,
  14309. 15,
  14310. 23,
  14311. 30,
  14312. 37,
  14313. 44,
  14314. 51,
  14315. 58,
  14316. 59,
  14317. 52,
  14318. 45,
  14319. 38,
  14320. 31,
  14321. 39,
  14322. 46,
  14323. 53,
  14324. 60,
  14325. 61,
  14326. 54,
  14327. 47,
  14328. 55,
  14329. 62,
  14330. 63
  14331. ]);
  14332. var dctCos1 = 4017;
  14333. var dctSin1 = 799;
  14334. var dctCos3 = 3406;
  14335. var dctSin3 = 2276;
  14336. var dctCos6 = 1567;
  14337. var dctSin6 = 3784;
  14338. var dctSqrt2 = 5793;
  14339. var dctSqrt1d2 = 2896;
  14340. function JpegImage() {
  14341. this.decodeTransform = null;
  14342. this.colorTransform = -1;
  14343. }
  14344. function buildHuffmanTable(codeLengths, values) {
  14345. var k = 0, code = [], i, j, length = 16;
  14346. while (length > 0 && !codeLengths[length - 1]) {
  14347. length--;
  14348. }
  14349. code.push({
  14350. children: [],
  14351. index: 0
  14352. });
  14353. var p = code[0], q;
  14354. for (i = 0; i < length; i++) {
  14355. for (j = 0; j < codeLengths[i]; j++) {
  14356. p = code.pop();
  14357. p.children[p.index] = values[k];
  14358. while (p.index > 0) {
  14359. p = code.pop();
  14360. }
  14361. p.index++;
  14362. code.push(p);
  14363. while (code.length <= i) {
  14364. code.push(q = {
  14365. children: [],
  14366. index: 0
  14367. });
  14368. p.children[p.index] = q.children;
  14369. p = q;
  14370. }
  14371. k++;
  14372. }
  14373. if (i + 1 < length) {
  14374. code.push(q = {
  14375. children: [],
  14376. index: 0
  14377. });
  14378. p.children[p.index] = q.children;
  14379. p = q;
  14380. }
  14381. }
  14382. return code[0].children;
  14383. }
  14384. function getBlockBufferOffset(component, row, col) {
  14385. return 64 * ((component.blocksPerLine + 1) * row + col);
  14386. }
  14387. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14388. var mcusPerLine = frame.mcusPerLine;
  14389. var progressive = frame.progressive;
  14390. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14391. function readBit() {
  14392. if (bitsCount > 0) {
  14393. bitsCount--;
  14394. return bitsData >> bitsCount & 1;
  14395. }
  14396. bitsData = data[offset++];
  14397. if (bitsData === 0xFF) {
  14398. var nextByte = data[offset++];
  14399. if (nextByte) {
  14400. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14401. }
  14402. }
  14403. bitsCount = 7;
  14404. return bitsData >>> 7;
  14405. }
  14406. function decodeHuffman(tree) {
  14407. var node = tree;
  14408. while (true) {
  14409. node = node[readBit()];
  14410. if (typeof node === 'number') {
  14411. return node;
  14412. }
  14413. if (typeof node !== 'object') {
  14414. error('JPEG error: invalid huffman sequence');
  14415. }
  14416. }
  14417. }
  14418. function receive(length) {
  14419. var n = 0;
  14420. while (length > 0) {
  14421. n = n << 1 | readBit();
  14422. length--;
  14423. }
  14424. return n;
  14425. }
  14426. function receiveAndExtend(length) {
  14427. if (length === 1) {
  14428. return readBit() === 1 ? 1 : -1;
  14429. }
  14430. var n = receive(length);
  14431. if (n >= 1 << length - 1) {
  14432. return n;
  14433. }
  14434. return n + (-1 << length) + 1;
  14435. }
  14436. function decodeBaseline(component, offset) {
  14437. var t = decodeHuffman(component.huffmanTableDC);
  14438. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14439. component.blockData[offset] = component.pred += diff;
  14440. var k = 1;
  14441. while (k < 64) {
  14442. var rs = decodeHuffman(component.huffmanTableAC);
  14443. var s = rs & 15, r = rs >> 4;
  14444. if (s === 0) {
  14445. if (r < 15) {
  14446. break;
  14447. }
  14448. k += 16;
  14449. continue;
  14450. }
  14451. k += r;
  14452. var z = dctZigZag[k];
  14453. component.blockData[offset + z] = receiveAndExtend(s);
  14454. k++;
  14455. }
  14456. }
  14457. function decodeDCFirst(component, offset) {
  14458. var t = decodeHuffman(component.huffmanTableDC);
  14459. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14460. component.blockData[offset] = component.pred += diff;
  14461. }
  14462. function decodeDCSuccessive(component, offset) {
  14463. component.blockData[offset] |= readBit() << successive;
  14464. }
  14465. var eobrun = 0;
  14466. function decodeACFirst(component, offset) {
  14467. if (eobrun > 0) {
  14468. eobrun--;
  14469. return;
  14470. }
  14471. var k = spectralStart, e = spectralEnd;
  14472. while (k <= e) {
  14473. var rs = decodeHuffman(component.huffmanTableAC);
  14474. var s = rs & 15, r = rs >> 4;
  14475. if (s === 0) {
  14476. if (r < 15) {
  14477. eobrun = receive(r) + (1 << r) - 1;
  14478. break;
  14479. }
  14480. k += 16;
  14481. continue;
  14482. }
  14483. k += r;
  14484. var z = dctZigZag[k];
  14485. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14486. k++;
  14487. }
  14488. }
  14489. var successiveACState = 0, successiveACNextValue;
  14490. function decodeACSuccessive(component, offset) {
  14491. var k = spectralStart;
  14492. var e = spectralEnd;
  14493. var r = 0;
  14494. var s;
  14495. var rs;
  14496. while (k <= e) {
  14497. var z = dctZigZag[k];
  14498. switch (successiveACState) {
  14499. case 0:
  14500. rs = decodeHuffman(component.huffmanTableAC);
  14501. s = rs & 15;
  14502. r = rs >> 4;
  14503. if (s === 0) {
  14504. if (r < 15) {
  14505. eobrun = receive(r) + (1 << r);
  14506. successiveACState = 4;
  14507. } else {
  14508. r = 16;
  14509. successiveACState = 1;
  14510. }
  14511. } else {
  14512. if (s !== 1) {
  14513. error('JPEG error: invalid ACn encoding');
  14514. }
  14515. successiveACNextValue = receiveAndExtend(s);
  14516. successiveACState = r ? 2 : 3;
  14517. }
  14518. continue;
  14519. case 1:
  14520. case 2:
  14521. if (component.blockData[offset + z]) {
  14522. component.blockData[offset + z] += readBit() << successive;
  14523. } else {
  14524. r--;
  14525. if (r === 0) {
  14526. successiveACState = successiveACState === 2 ? 3 : 0;
  14527. }
  14528. }
  14529. break;
  14530. case 3:
  14531. if (component.blockData[offset + z]) {
  14532. component.blockData[offset + z] += readBit() << successive;
  14533. } else {
  14534. component.blockData[offset + z] = successiveACNextValue << successive;
  14535. successiveACState = 0;
  14536. }
  14537. break;
  14538. case 4:
  14539. if (component.blockData[offset + z]) {
  14540. component.blockData[offset + z] += readBit() << successive;
  14541. }
  14542. break;
  14543. }
  14544. k++;
  14545. }
  14546. if (successiveACState === 4) {
  14547. eobrun--;
  14548. if (eobrun === 0) {
  14549. successiveACState = 0;
  14550. }
  14551. }
  14552. }
  14553. function decodeMcu(component, decode, mcu, row, col) {
  14554. var mcuRow = mcu / mcusPerLine | 0;
  14555. var mcuCol = mcu % mcusPerLine;
  14556. var blockRow = mcuRow * component.v + row;
  14557. var blockCol = mcuCol * component.h + col;
  14558. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14559. decode(component, offset);
  14560. }
  14561. function decodeBlock(component, decode, mcu) {
  14562. var blockRow = mcu / component.blocksPerLine | 0;
  14563. var blockCol = mcu % component.blocksPerLine;
  14564. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14565. decode(component, offset);
  14566. }
  14567. var componentsLength = components.length;
  14568. var component, i, j, k, n;
  14569. var decodeFn;
  14570. if (progressive) {
  14571. if (spectralStart === 0) {
  14572. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14573. } else {
  14574. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14575. }
  14576. } else {
  14577. decodeFn = decodeBaseline;
  14578. }
  14579. var mcu = 0, marker;
  14580. var mcuExpected;
  14581. if (componentsLength === 1) {
  14582. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14583. } else {
  14584. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14585. }
  14586. if (!resetInterval) {
  14587. resetInterval = mcuExpected;
  14588. }
  14589. var h, v;
  14590. while (mcu < mcuExpected) {
  14591. for (i = 0; i < componentsLength; i++) {
  14592. components[i].pred = 0;
  14593. }
  14594. eobrun = 0;
  14595. if (componentsLength === 1) {
  14596. component = components[0];
  14597. for (n = 0; n < resetInterval; n++) {
  14598. decodeBlock(component, decodeFn, mcu);
  14599. mcu++;
  14600. }
  14601. } else {
  14602. for (n = 0; n < resetInterval; n++) {
  14603. for (i = 0; i < componentsLength; i++) {
  14604. component = components[i];
  14605. h = component.h;
  14606. v = component.v;
  14607. for (j = 0; j < v; j++) {
  14608. for (k = 0; k < h; k++) {
  14609. decodeMcu(component, decodeFn, mcu, j, k);
  14610. }
  14611. }
  14612. }
  14613. mcu++;
  14614. }
  14615. }
  14616. bitsCount = 0;
  14617. marker = data[offset] << 8 | data[offset + 1];
  14618. while (data[offset] === 0x00 && offset < data.length - 1) {
  14619. offset++;
  14620. marker = data[offset] << 8 | data[offset + 1];
  14621. }
  14622. if (marker <= 0xFF00) {
  14623. error('JPEG error: marker was not found');
  14624. }
  14625. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14626. offset += 2;
  14627. } else {
  14628. break;
  14629. }
  14630. }
  14631. return offset - startOffset;
  14632. }
  14633. function quantizeAndInverse(component, blockBufferOffset, p) {
  14634. var qt = component.quantizationTable, blockData = component.blockData;
  14635. var v0, v1, v2, v3, v4, v5, v6, v7;
  14636. var p0, p1, p2, p3, p4, p5, p6, p7;
  14637. var t;
  14638. if (!qt) {
  14639. error('JPEG error: missing required Quantization Table.');
  14640. }
  14641. for (var row = 0; row < 64; row += 8) {
  14642. p0 = blockData[blockBufferOffset + row];
  14643. p1 = blockData[blockBufferOffset + row + 1];
  14644. p2 = blockData[blockBufferOffset + row + 2];
  14645. p3 = blockData[blockBufferOffset + row + 3];
  14646. p4 = blockData[blockBufferOffset + row + 4];
  14647. p5 = blockData[blockBufferOffset + row + 5];
  14648. p6 = blockData[blockBufferOffset + row + 6];
  14649. p7 = blockData[blockBufferOffset + row + 7];
  14650. p0 *= qt[row];
  14651. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14652. t = dctSqrt2 * p0 + 512 >> 10;
  14653. p[row] = t;
  14654. p[row + 1] = t;
  14655. p[row + 2] = t;
  14656. p[row + 3] = t;
  14657. p[row + 4] = t;
  14658. p[row + 5] = t;
  14659. p[row + 6] = t;
  14660. p[row + 7] = t;
  14661. continue;
  14662. }
  14663. p1 *= qt[row + 1];
  14664. p2 *= qt[row + 2];
  14665. p3 *= qt[row + 3];
  14666. p4 *= qt[row + 4];
  14667. p5 *= qt[row + 5];
  14668. p6 *= qt[row + 6];
  14669. p7 *= qt[row + 7];
  14670. v0 = dctSqrt2 * p0 + 128 >> 8;
  14671. v1 = dctSqrt2 * p4 + 128 >> 8;
  14672. v2 = p2;
  14673. v3 = p6;
  14674. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14675. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14676. v5 = p3 << 4;
  14677. v6 = p5 << 4;
  14678. v0 = v0 + v1 + 1 >> 1;
  14679. v1 = v0 - v1;
  14680. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14681. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14682. v3 = t;
  14683. v4 = v4 + v6 + 1 >> 1;
  14684. v6 = v4 - v6;
  14685. v7 = v7 + v5 + 1 >> 1;
  14686. v5 = v7 - v5;
  14687. v0 = v0 + v3 + 1 >> 1;
  14688. v3 = v0 - v3;
  14689. v1 = v1 + v2 + 1 >> 1;
  14690. v2 = v1 - v2;
  14691. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14692. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14693. v7 = t;
  14694. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14695. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14696. v6 = t;
  14697. p[row] = v0 + v7;
  14698. p[row + 7] = v0 - v7;
  14699. p[row + 1] = v1 + v6;
  14700. p[row + 6] = v1 - v6;
  14701. p[row + 2] = v2 + v5;
  14702. p[row + 5] = v2 - v5;
  14703. p[row + 3] = v3 + v4;
  14704. p[row + 4] = v3 - v4;
  14705. }
  14706. for (var col = 0; col < 8; ++col) {
  14707. p0 = p[col];
  14708. p1 = p[col + 8];
  14709. p2 = p[col + 16];
  14710. p3 = p[col + 24];
  14711. p4 = p[col + 32];
  14712. p5 = p[col + 40];
  14713. p6 = p[col + 48];
  14714. p7 = p[col + 56];
  14715. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14716. t = dctSqrt2 * p0 + 8192 >> 14;
  14717. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14718. blockData[blockBufferOffset + col] = t;
  14719. blockData[blockBufferOffset + col + 8] = t;
  14720. blockData[blockBufferOffset + col + 16] = t;
  14721. blockData[blockBufferOffset + col + 24] = t;
  14722. blockData[blockBufferOffset + col + 32] = t;
  14723. blockData[blockBufferOffset + col + 40] = t;
  14724. blockData[blockBufferOffset + col + 48] = t;
  14725. blockData[blockBufferOffset + col + 56] = t;
  14726. continue;
  14727. }
  14728. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14729. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14730. v2 = p2;
  14731. v3 = p6;
  14732. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14733. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14734. v5 = p3;
  14735. v6 = p5;
  14736. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14737. v1 = v0 - v1;
  14738. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14739. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14740. v3 = t;
  14741. v4 = v4 + v6 + 1 >> 1;
  14742. v6 = v4 - v6;
  14743. v7 = v7 + v5 + 1 >> 1;
  14744. v5 = v7 - v5;
  14745. v0 = v0 + v3 + 1 >> 1;
  14746. v3 = v0 - v3;
  14747. v1 = v1 + v2 + 1 >> 1;
  14748. v2 = v1 - v2;
  14749. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14750. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14751. v7 = t;
  14752. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14753. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14754. v6 = t;
  14755. p0 = v0 + v7;
  14756. p7 = v0 - v7;
  14757. p1 = v1 + v6;
  14758. p6 = v1 - v6;
  14759. p2 = v2 + v5;
  14760. p5 = v2 - v5;
  14761. p3 = v3 + v4;
  14762. p4 = v3 - v4;
  14763. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14764. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14765. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14766. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14767. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14768. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14769. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14770. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14771. blockData[blockBufferOffset + col] = p0;
  14772. blockData[blockBufferOffset + col + 8] = p1;
  14773. blockData[blockBufferOffset + col + 16] = p2;
  14774. blockData[blockBufferOffset + col + 24] = p3;
  14775. blockData[blockBufferOffset + col + 32] = p4;
  14776. blockData[blockBufferOffset + col + 40] = p5;
  14777. blockData[blockBufferOffset + col + 48] = p6;
  14778. blockData[blockBufferOffset + col + 56] = p7;
  14779. }
  14780. }
  14781. function buildComponentData(frame, component) {
  14782. var blocksPerLine = component.blocksPerLine;
  14783. var blocksPerColumn = component.blocksPerColumn;
  14784. var computationBuffer = new Int16Array(64);
  14785. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14786. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14787. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14788. quantizeAndInverse(component, offset, computationBuffer);
  14789. }
  14790. }
  14791. return component.blockData;
  14792. }
  14793. function clamp0to255(a) {
  14794. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14795. }
  14796. JpegImage.prototype = {
  14797. parse: function parse(data) {
  14798. function readUint16() {
  14799. var value = data[offset] << 8 | data[offset + 1];
  14800. offset += 2;
  14801. return value;
  14802. }
  14803. function readDataBlock() {
  14804. var length = readUint16();
  14805. var array = data.subarray(offset, offset + length - 2);
  14806. offset += array.length;
  14807. return array;
  14808. }
  14809. function prepareComponents(frame) {
  14810. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14811. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14812. for (var i = 0; i < frame.components.length; i++) {
  14813. component = frame.components[i];
  14814. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14815. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14816. var blocksPerLineForMcu = mcusPerLine * component.h;
  14817. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14818. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14819. component.blockData = new Int16Array(blocksBufferSize);
  14820. component.blocksPerLine = blocksPerLine;
  14821. component.blocksPerColumn = blocksPerColumn;
  14822. }
  14823. frame.mcusPerLine = mcusPerLine;
  14824. frame.mcusPerColumn = mcusPerColumn;
  14825. }
  14826. var offset = 0;
  14827. var jfif = null;
  14828. var adobe = null;
  14829. var frame, resetInterval;
  14830. var quantizationTables = [];
  14831. var huffmanTablesAC = [], huffmanTablesDC = [];
  14832. var fileMarker = readUint16();
  14833. if (fileMarker !== 0xFFD8) {
  14834. error('JPEG error: SOI not found');
  14835. }
  14836. fileMarker = readUint16();
  14837. while (fileMarker !== 0xFFD9) {
  14838. var i, j, l;
  14839. switch (fileMarker) {
  14840. case 0xFFE0:
  14841. case 0xFFE1:
  14842. case 0xFFE2:
  14843. case 0xFFE3:
  14844. case 0xFFE4:
  14845. case 0xFFE5:
  14846. case 0xFFE6:
  14847. case 0xFFE7:
  14848. case 0xFFE8:
  14849. case 0xFFE9:
  14850. case 0xFFEA:
  14851. case 0xFFEB:
  14852. case 0xFFEC:
  14853. case 0xFFED:
  14854. case 0xFFEE:
  14855. case 0xFFEF:
  14856. case 0xFFFE:
  14857. var appData = readDataBlock();
  14858. if (fileMarker === 0xFFE0) {
  14859. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14860. jfif = {
  14861. version: {
  14862. major: appData[5],
  14863. minor: appData[6]
  14864. },
  14865. densityUnits: appData[7],
  14866. xDensity: appData[8] << 8 | appData[9],
  14867. yDensity: appData[10] << 8 | appData[11],
  14868. thumbWidth: appData[12],
  14869. thumbHeight: appData[13],
  14870. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14871. };
  14872. }
  14873. }
  14874. if (fileMarker === 0xFFEE) {
  14875. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14876. adobe = {
  14877. version: appData[5] << 8 | appData[6],
  14878. flags0: appData[7] << 8 | appData[8],
  14879. flags1: appData[9] << 8 | appData[10],
  14880. transformCode: appData[11]
  14881. };
  14882. }
  14883. }
  14884. break;
  14885. case 0xFFDB:
  14886. var quantizationTablesLength = readUint16();
  14887. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14888. var z;
  14889. while (offset < quantizationTablesEnd) {
  14890. var quantizationTableSpec = data[offset++];
  14891. var tableData = new Uint16Array(64);
  14892. if (quantizationTableSpec >> 4 === 0) {
  14893. for (j = 0; j < 64; j++) {
  14894. z = dctZigZag[j];
  14895. tableData[z] = data[offset++];
  14896. }
  14897. } else if (quantizationTableSpec >> 4 === 1) {
  14898. for (j = 0; j < 64; j++) {
  14899. z = dctZigZag[j];
  14900. tableData[z] = readUint16();
  14901. }
  14902. } else {
  14903. error('JPEG error: DQT - invalid table spec');
  14904. }
  14905. quantizationTables[quantizationTableSpec & 15] = tableData;
  14906. }
  14907. break;
  14908. case 0xFFC0:
  14909. case 0xFFC1:
  14910. case 0xFFC2:
  14911. if (frame) {
  14912. error('JPEG error: Only single frame JPEGs supported');
  14913. }
  14914. readUint16();
  14915. frame = {};
  14916. frame.extended = fileMarker === 0xFFC1;
  14917. frame.progressive = fileMarker === 0xFFC2;
  14918. frame.precision = data[offset++];
  14919. frame.scanLines = readUint16();
  14920. frame.samplesPerLine = readUint16();
  14921. frame.components = [];
  14922. frame.componentIds = {};
  14923. var componentsCount = data[offset++], componentId;
  14924. var maxH = 0, maxV = 0;
  14925. for (i = 0; i < componentsCount; i++) {
  14926. componentId = data[offset];
  14927. var h = data[offset + 1] >> 4;
  14928. var v = data[offset + 1] & 15;
  14929. if (maxH < h) {
  14930. maxH = h;
  14931. }
  14932. if (maxV < v) {
  14933. maxV = v;
  14934. }
  14935. var qId = data[offset + 2];
  14936. l = frame.components.push({
  14937. h: h,
  14938. v: v,
  14939. quantizationId: qId,
  14940. quantizationTable: null
  14941. });
  14942. frame.componentIds[componentId] = l - 1;
  14943. offset += 3;
  14944. }
  14945. frame.maxH = maxH;
  14946. frame.maxV = maxV;
  14947. prepareComponents(frame);
  14948. break;
  14949. case 0xFFC4:
  14950. var huffmanLength = readUint16();
  14951. for (i = 2; i < huffmanLength;) {
  14952. var huffmanTableSpec = data[offset++];
  14953. var codeLengths = new Uint8Array(16);
  14954. var codeLengthSum = 0;
  14955. for (j = 0; j < 16; j++, offset++) {
  14956. codeLengthSum += codeLengths[j] = data[offset];
  14957. }
  14958. var huffmanValues = new Uint8Array(codeLengthSum);
  14959. for (j = 0; j < codeLengthSum; j++, offset++) {
  14960. huffmanValues[j] = data[offset];
  14961. }
  14962. i += 17 + codeLengthSum;
  14963. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14964. }
  14965. break;
  14966. case 0xFFDD:
  14967. readUint16();
  14968. resetInterval = readUint16();
  14969. break;
  14970. case 0xFFDA:
  14971. var scanLength = readUint16();
  14972. var selectorsCount = data[offset++];
  14973. var components = [], component;
  14974. for (i = 0; i < selectorsCount; i++) {
  14975. var componentIndex = frame.componentIds[data[offset++]];
  14976. component = frame.components[componentIndex];
  14977. var tableSpec = data[offset++];
  14978. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14979. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14980. components.push(component);
  14981. }
  14982. var spectralStart = data[offset++];
  14983. var spectralEnd = data[offset++];
  14984. var successiveApproximation = data[offset++];
  14985. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14986. offset += processed;
  14987. break;
  14988. case 0xFFFF:
  14989. if (data[offset] !== 0xFF) {
  14990. offset--;
  14991. }
  14992. break;
  14993. default:
  14994. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14995. offset -= 3;
  14996. break;
  14997. }
  14998. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14999. }
  15000. fileMarker = readUint16();
  15001. }
  15002. this.width = frame.samplesPerLine;
  15003. this.height = frame.scanLines;
  15004. this.jfif = jfif;
  15005. this.adobe = adobe;
  15006. this.components = [];
  15007. for (i = 0; i < frame.components.length; i++) {
  15008. component = frame.components[i];
  15009. var quantizationTable = quantizationTables[component.quantizationId];
  15010. if (quantizationTable) {
  15011. component.quantizationTable = quantizationTable;
  15012. }
  15013. this.components.push({
  15014. output: buildComponentData(frame, component),
  15015. scaleX: component.h / frame.maxH,
  15016. scaleY: component.v / frame.maxV,
  15017. blocksPerLine: component.blocksPerLine,
  15018. blocksPerColumn: component.blocksPerColumn
  15019. });
  15020. }
  15021. this.numComponents = this.components.length;
  15022. },
  15023. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  15024. var scaleX = this.width / width, scaleY = this.height / height;
  15025. var component, componentScaleX, componentScaleY, blocksPerScanline;
  15026. var x, y, i, j, k;
  15027. var index;
  15028. var offset = 0;
  15029. var output;
  15030. var numComponents = this.components.length;
  15031. var dataLength = width * height * numComponents;
  15032. var data = new Uint8Array(dataLength);
  15033. var xScaleBlockOffset = new Uint32Array(width);
  15034. var mask3LSB = 0xfffffff8;
  15035. for (i = 0; i < numComponents; i++) {
  15036. component = this.components[i];
  15037. componentScaleX = component.scaleX * scaleX;
  15038. componentScaleY = component.scaleY * scaleY;
  15039. offset = i;
  15040. output = component.output;
  15041. blocksPerScanline = component.blocksPerLine + 1 << 3;
  15042. for (x = 0; x < width; x++) {
  15043. j = 0 | x * componentScaleX;
  15044. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  15045. }
  15046. for (y = 0; y < height; y++) {
  15047. j = 0 | y * componentScaleY;
  15048. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  15049. for (x = 0; x < width; x++) {
  15050. data[offset] = output[index + xScaleBlockOffset[x]];
  15051. offset += numComponents;
  15052. }
  15053. }
  15054. }
  15055. var transform = this.decodeTransform;
  15056. if (transform) {
  15057. for (i = 0; i < dataLength;) {
  15058. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  15059. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  15060. }
  15061. }
  15062. }
  15063. return data;
  15064. },
  15065. _isColorConversionNeeded: function isColorConversionNeeded() {
  15066. if (this.adobe && this.adobe.transformCode) {
  15067. return true;
  15068. } else if (this.numComponents === 3) {
  15069. if (!this.adobe && this.colorTransform === 0) {
  15070. return false;
  15071. }
  15072. return true;
  15073. } else {
  15074. if (!this.adobe && this.colorTransform === 1) {
  15075. return true;
  15076. }
  15077. return false;
  15078. }
  15079. },
  15080. _convertYccToRgb: function convertYccToRgb(data) {
  15081. var Y, Cb, Cr;
  15082. for (var i = 0, length = data.length; i < length; i += 3) {
  15083. Y = data[i];
  15084. Cb = data[i + 1];
  15085. Cr = data[i + 2];
  15086. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  15087. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  15088. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  15089. }
  15090. return data;
  15091. },
  15092. _convertYcckToRgb: function convertYcckToRgb(data) {
  15093. var Y, Cb, Cr, k;
  15094. var offset = 0;
  15095. for (var i = 0, length = data.length; i < length; i += 4) {
  15096. Y = data[i];
  15097. Cb = data[i + 1];
  15098. Cr = data[i + 2];
  15099. k = data[i + 3];
  15100. var r = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  15101. var g = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  15102. var b = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  15103. data[offset++] = clamp0to255(r);
  15104. data[offset++] = clamp0to255(g);
  15105. data[offset++] = clamp0to255(b);
  15106. }
  15107. return data;
  15108. },
  15109. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  15110. var Y, Cb, Cr;
  15111. for (var i = 0, length = data.length; i < length; i += 4) {
  15112. Y = data[i];
  15113. Cb = data[i + 1];
  15114. Cr = data[i + 2];
  15115. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  15116. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15117. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15118. }
  15119. return data;
  15120. },
  15121. _convertCmykToRgb: function convertCmykToRgb(data) {
  15122. var c, m, y, k;
  15123. var offset = 0;
  15124. var min = -255 * 255 * 255;
  15125. var scale = 1 / 255 / 255;
  15126. for (var i = 0, length = data.length; i < length; i += 4) {
  15127. c = data[i];
  15128. m = data[i + 1];
  15129. y = data[i + 2];
  15130. k = data[i + 3];
  15131. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 72734.4411664936) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 1401.7366389350734) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 4465.541406466231) - k * (21.86122147463605 * k + 48317.86113160301);
  15132. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 20220.756542821975) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 48691.05921601825) + y * (4.444339102852739 * y + 9.8632861493405 * k - 6341.191035517494) - k * (20.737325471181034 * k + 47890.15695978492);
  15133. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 3616.812083916688) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 28620.90484698408) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 49363.43385999684) - k * (22.33816807309886 * k + 45932.16563550634);
  15134. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15135. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15136. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15137. }
  15138. return data;
  15139. },
  15140. getData: function getData(width, height, forceRGBoutput) {
  15141. if (this.numComponents > 4) {
  15142. error('JPEG error: Unsupported color mode');
  15143. }
  15144. var data = this._getLinearizedBlockData(width, height);
  15145. if (this.numComponents === 1 && forceRGBoutput) {
  15146. var dataLength = data.length;
  15147. var rgbData = new Uint8Array(dataLength * 3);
  15148. var offset = 0;
  15149. for (var i = 0; i < dataLength; i++) {
  15150. var grayColor = data[i];
  15151. rgbData[offset++] = grayColor;
  15152. rgbData[offset++] = grayColor;
  15153. rgbData[offset++] = grayColor;
  15154. }
  15155. return rgbData;
  15156. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15157. return this._convertYccToRgb(data);
  15158. } else if (this.numComponents === 4) {
  15159. if (this._isColorConversionNeeded()) {
  15160. if (forceRGBoutput) {
  15161. return this._convertYcckToRgb(data);
  15162. } else {
  15163. return this._convertYcckToCmyk(data);
  15164. }
  15165. } else if (forceRGBoutput) {
  15166. return this._convertCmykToRgb(data);
  15167. }
  15168. }
  15169. return data;
  15170. }
  15171. };
  15172. return JpegImage;
  15173. }();
  15174. exports.JpegImage = JpegImage;
  15175. }));
  15176. (function (root, factory) {
  15177. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15178. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15179. var info = sharedUtil.info;
  15180. var warn = sharedUtil.warn;
  15181. var error = sharedUtil.error;
  15182. var log2 = sharedUtil.log2;
  15183. var readUint16 = sharedUtil.readUint16;
  15184. var readUint32 = sharedUtil.readUint32;
  15185. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15186. var JpxImage = function JpxImageClosure() {
  15187. var SubbandsGainLog2 = {
  15188. 'LL': 0,
  15189. 'LH': 1,
  15190. 'HL': 1,
  15191. 'HH': 2
  15192. };
  15193. function JpxImage() {
  15194. this.failOnCorruptedImage = false;
  15195. }
  15196. JpxImage.prototype = {
  15197. parse: function JpxImage_parse(data) {
  15198. var head = readUint16(data, 0);
  15199. if (head === 0xFF4F) {
  15200. this.parseCodestream(data, 0, data.length);
  15201. return;
  15202. }
  15203. var position = 0, length = data.length;
  15204. while (position < length) {
  15205. var headerSize = 8;
  15206. var lbox = readUint32(data, position);
  15207. var tbox = readUint32(data, position + 4);
  15208. position += headerSize;
  15209. if (lbox === 1) {
  15210. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15211. position += 8;
  15212. headerSize += 8;
  15213. }
  15214. if (lbox === 0) {
  15215. lbox = length - position + headerSize;
  15216. }
  15217. if (lbox < headerSize) {
  15218. error('JPX Error: Invalid box field size');
  15219. }
  15220. var dataLength = lbox - headerSize;
  15221. var jumpDataLength = true;
  15222. switch (tbox) {
  15223. case 0x6A703268:
  15224. jumpDataLength = false;
  15225. break;
  15226. case 0x636F6C72:
  15227. var method = data[position];
  15228. if (method === 1) {
  15229. var colorspace = readUint32(data, position + 3);
  15230. switch (colorspace) {
  15231. case 16:
  15232. case 17:
  15233. case 18:
  15234. break;
  15235. default:
  15236. warn('Unknown colorspace ' + colorspace);
  15237. break;
  15238. }
  15239. } else if (method === 2) {
  15240. info('ICC profile not supported');
  15241. }
  15242. break;
  15243. case 0x6A703263:
  15244. this.parseCodestream(data, position, position + dataLength);
  15245. break;
  15246. case 0x6A502020:
  15247. if (0x0d0a870a !== readUint32(data, position)) {
  15248. warn('Invalid JP2 signature');
  15249. }
  15250. break;
  15251. case 0x6A501A1A:
  15252. case 0x66747970:
  15253. case 0x72726571:
  15254. case 0x72657320:
  15255. case 0x69686472:
  15256. break;
  15257. default:
  15258. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15259. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15260. break;
  15261. }
  15262. if (jumpDataLength) {
  15263. position += dataLength;
  15264. }
  15265. }
  15266. },
  15267. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15268. var newByte = stream.getByte();
  15269. while (newByte >= 0) {
  15270. var oldByte = newByte;
  15271. newByte = stream.getByte();
  15272. var code = oldByte << 8 | newByte;
  15273. if (code === 0xFF51) {
  15274. stream.skip(4);
  15275. var Xsiz = stream.getInt32() >>> 0;
  15276. var Ysiz = stream.getInt32() >>> 0;
  15277. var XOsiz = stream.getInt32() >>> 0;
  15278. var YOsiz = stream.getInt32() >>> 0;
  15279. stream.skip(16);
  15280. var Csiz = stream.getUint16();
  15281. this.width = Xsiz - XOsiz;
  15282. this.height = Ysiz - YOsiz;
  15283. this.componentsCount = Csiz;
  15284. this.bitsPerComponent = 8;
  15285. return;
  15286. }
  15287. }
  15288. error('JPX Error: No size marker found in JPX stream');
  15289. },
  15290. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15291. var context = {};
  15292. var doNotRecover = false;
  15293. try {
  15294. var position = start;
  15295. while (position + 1 < end) {
  15296. var code = readUint16(data, position);
  15297. position += 2;
  15298. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15299. switch (code) {
  15300. case 0xFF4F:
  15301. context.mainHeader = true;
  15302. break;
  15303. case 0xFFD9:
  15304. break;
  15305. case 0xFF51:
  15306. length = readUint16(data, position);
  15307. var siz = {};
  15308. siz.Xsiz = readUint32(data, position + 4);
  15309. siz.Ysiz = readUint32(data, position + 8);
  15310. siz.XOsiz = readUint32(data, position + 12);
  15311. siz.YOsiz = readUint32(data, position + 16);
  15312. siz.XTsiz = readUint32(data, position + 20);
  15313. siz.YTsiz = readUint32(data, position + 24);
  15314. siz.XTOsiz = readUint32(data, position + 28);
  15315. siz.YTOsiz = readUint32(data, position + 32);
  15316. var componentsCount = readUint16(data, position + 36);
  15317. siz.Csiz = componentsCount;
  15318. var components = [];
  15319. j = position + 38;
  15320. for (var i = 0; i < componentsCount; i++) {
  15321. var component = {
  15322. precision: (data[j] & 0x7F) + 1,
  15323. isSigned: !!(data[j] & 0x80),
  15324. XRsiz: data[j + 1],
  15325. YRsiz: data[j + 1]
  15326. };
  15327. calculateComponentDimensions(component, siz);
  15328. components.push(component);
  15329. }
  15330. context.SIZ = siz;
  15331. context.components = components;
  15332. calculateTileGrids(context, components);
  15333. context.QCC = [];
  15334. context.COC = [];
  15335. break;
  15336. case 0xFF5C:
  15337. length = readUint16(data, position);
  15338. var qcd = {};
  15339. j = position + 2;
  15340. sqcd = data[j++];
  15341. switch (sqcd & 0x1F) {
  15342. case 0:
  15343. spqcdSize = 8;
  15344. scalarExpounded = true;
  15345. break;
  15346. case 1:
  15347. spqcdSize = 16;
  15348. scalarExpounded = false;
  15349. break;
  15350. case 2:
  15351. spqcdSize = 16;
  15352. scalarExpounded = true;
  15353. break;
  15354. default:
  15355. throw new Error('Invalid SQcd value ' + sqcd);
  15356. }
  15357. qcd.noQuantization = spqcdSize === 8;
  15358. qcd.scalarExpounded = scalarExpounded;
  15359. qcd.guardBits = sqcd >> 5;
  15360. spqcds = [];
  15361. while (j < length + position) {
  15362. var spqcd = {};
  15363. if (spqcdSize === 8) {
  15364. spqcd.epsilon = data[j++] >> 3;
  15365. spqcd.mu = 0;
  15366. } else {
  15367. spqcd.epsilon = data[j] >> 3;
  15368. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15369. j += 2;
  15370. }
  15371. spqcds.push(spqcd);
  15372. }
  15373. qcd.SPqcds = spqcds;
  15374. if (context.mainHeader) {
  15375. context.QCD = qcd;
  15376. } else {
  15377. context.currentTile.QCD = qcd;
  15378. context.currentTile.QCC = [];
  15379. }
  15380. break;
  15381. case 0xFF5D:
  15382. length = readUint16(data, position);
  15383. var qcc = {};
  15384. j = position + 2;
  15385. var cqcc;
  15386. if (context.SIZ.Csiz < 257) {
  15387. cqcc = data[j++];
  15388. } else {
  15389. cqcc = readUint16(data, j);
  15390. j += 2;
  15391. }
  15392. sqcd = data[j++];
  15393. switch (sqcd & 0x1F) {
  15394. case 0:
  15395. spqcdSize = 8;
  15396. scalarExpounded = true;
  15397. break;
  15398. case 1:
  15399. spqcdSize = 16;
  15400. scalarExpounded = false;
  15401. break;
  15402. case 2:
  15403. spqcdSize = 16;
  15404. scalarExpounded = true;
  15405. break;
  15406. default:
  15407. throw new Error('Invalid SQcd value ' + sqcd);
  15408. }
  15409. qcc.noQuantization = spqcdSize === 8;
  15410. qcc.scalarExpounded = scalarExpounded;
  15411. qcc.guardBits = sqcd >> 5;
  15412. spqcds = [];
  15413. while (j < length + position) {
  15414. spqcd = {};
  15415. if (spqcdSize === 8) {
  15416. spqcd.epsilon = data[j++] >> 3;
  15417. spqcd.mu = 0;
  15418. } else {
  15419. spqcd.epsilon = data[j] >> 3;
  15420. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15421. j += 2;
  15422. }
  15423. spqcds.push(spqcd);
  15424. }
  15425. qcc.SPqcds = spqcds;
  15426. if (context.mainHeader) {
  15427. context.QCC[cqcc] = qcc;
  15428. } else {
  15429. context.currentTile.QCC[cqcc] = qcc;
  15430. }
  15431. break;
  15432. case 0xFF52:
  15433. length = readUint16(data, position);
  15434. var cod = {};
  15435. j = position + 2;
  15436. var scod = data[j++];
  15437. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15438. cod.sopMarkerUsed = !!(scod & 2);
  15439. cod.ephMarkerUsed = !!(scod & 4);
  15440. cod.progressionOrder = data[j++];
  15441. cod.layersCount = readUint16(data, j);
  15442. j += 2;
  15443. cod.multipleComponentTransform = data[j++];
  15444. cod.decompositionLevelsCount = data[j++];
  15445. cod.xcb = (data[j++] & 0xF) + 2;
  15446. cod.ycb = (data[j++] & 0xF) + 2;
  15447. var blockStyle = data[j++];
  15448. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15449. cod.resetContextProbabilities = !!(blockStyle & 2);
  15450. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15451. cod.verticalyStripe = !!(blockStyle & 8);
  15452. cod.predictableTermination = !!(blockStyle & 16);
  15453. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15454. cod.reversibleTransformation = data[j++];
  15455. if (cod.entropyCoderWithCustomPrecincts) {
  15456. var precinctsSizes = [];
  15457. while (j < length + position) {
  15458. var precinctsSize = data[j++];
  15459. precinctsSizes.push({
  15460. PPx: precinctsSize & 0xF,
  15461. PPy: precinctsSize >> 4
  15462. });
  15463. }
  15464. cod.precinctsSizes = precinctsSizes;
  15465. }
  15466. var unsupported = [];
  15467. if (cod.selectiveArithmeticCodingBypass) {
  15468. unsupported.push('selectiveArithmeticCodingBypass');
  15469. }
  15470. if (cod.resetContextProbabilities) {
  15471. unsupported.push('resetContextProbabilities');
  15472. }
  15473. if (cod.terminationOnEachCodingPass) {
  15474. unsupported.push('terminationOnEachCodingPass');
  15475. }
  15476. if (cod.verticalyStripe) {
  15477. unsupported.push('verticalyStripe');
  15478. }
  15479. if (cod.predictableTermination) {
  15480. unsupported.push('predictableTermination');
  15481. }
  15482. if (unsupported.length > 0) {
  15483. doNotRecover = true;
  15484. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15485. }
  15486. if (context.mainHeader) {
  15487. context.COD = cod;
  15488. } else {
  15489. context.currentTile.COD = cod;
  15490. context.currentTile.COC = [];
  15491. }
  15492. break;
  15493. case 0xFF90:
  15494. length = readUint16(data, position);
  15495. tile = {};
  15496. tile.index = readUint16(data, position + 2);
  15497. tile.length = readUint32(data, position + 4);
  15498. tile.dataEnd = tile.length + position - 2;
  15499. tile.partIndex = data[position + 8];
  15500. tile.partsCount = data[position + 9];
  15501. context.mainHeader = false;
  15502. if (tile.partIndex === 0) {
  15503. tile.COD = context.COD;
  15504. tile.COC = context.COC.slice(0);
  15505. tile.QCD = context.QCD;
  15506. tile.QCC = context.QCC.slice(0);
  15507. }
  15508. context.currentTile = tile;
  15509. break;
  15510. case 0xFF93:
  15511. tile = context.currentTile;
  15512. if (tile.partIndex === 0) {
  15513. initializeTile(context, tile.index);
  15514. buildPackets(context);
  15515. }
  15516. length = tile.dataEnd - position;
  15517. parseTilePackets(context, data, position, length);
  15518. break;
  15519. case 0xFF55:
  15520. case 0xFF57:
  15521. case 0xFF58:
  15522. case 0xFF64:
  15523. length = readUint16(data, position);
  15524. break;
  15525. case 0xFF53:
  15526. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15527. default:
  15528. throw new Error('Unknown codestream code: ' + code.toString(16));
  15529. }
  15530. position += length;
  15531. }
  15532. } catch (e) {
  15533. if (doNotRecover || this.failOnCorruptedImage) {
  15534. error('JPX Error: ' + e.message);
  15535. } else {
  15536. warn('JPX: Trying to recover from: ' + e.message);
  15537. }
  15538. }
  15539. this.tiles = transformComponents(context);
  15540. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15541. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15542. this.componentsCount = context.SIZ.Csiz;
  15543. }
  15544. };
  15545. function calculateComponentDimensions(component, siz) {
  15546. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15547. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15548. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15549. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15550. component.width = component.x1 - component.x0;
  15551. component.height = component.y1 - component.y0;
  15552. }
  15553. function calculateTileGrids(context, components) {
  15554. var siz = context.SIZ;
  15555. var tile, tiles = [];
  15556. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15557. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15558. for (var q = 0; q < numYtiles; q++) {
  15559. for (var p = 0; p < numXtiles; p++) {
  15560. tile = {};
  15561. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15562. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15563. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15564. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15565. tile.width = tile.tx1 - tile.tx0;
  15566. tile.height = tile.ty1 - tile.ty0;
  15567. tile.components = [];
  15568. tiles.push(tile);
  15569. }
  15570. }
  15571. context.tiles = tiles;
  15572. var componentsCount = siz.Csiz;
  15573. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15574. var component = components[i];
  15575. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15576. var tileComponent = {};
  15577. tile = tiles[j];
  15578. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15579. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15580. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15581. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15582. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15583. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15584. tile.components[i] = tileComponent;
  15585. }
  15586. }
  15587. }
  15588. function getBlocksDimensions(context, component, r) {
  15589. var codOrCoc = component.codingStyleParameters;
  15590. var result = {};
  15591. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15592. result.PPx = 15;
  15593. result.PPy = 15;
  15594. } else {
  15595. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15596. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15597. }
  15598. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15599. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15600. return result;
  15601. }
  15602. function buildPrecincts(context, resolution, dimensions) {
  15603. var precinctWidth = 1 << dimensions.PPx;
  15604. var precinctHeight = 1 << dimensions.PPy;
  15605. var isZeroRes = resolution.resLevel === 0;
  15606. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15607. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15608. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15609. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15610. var numprecincts = numprecinctswide * numprecinctshigh;
  15611. resolution.precinctParameters = {
  15612. precinctWidth: precinctWidth,
  15613. precinctHeight: precinctHeight,
  15614. numprecinctswide: numprecinctswide,
  15615. numprecinctshigh: numprecinctshigh,
  15616. numprecincts: numprecincts,
  15617. precinctWidthInSubband: precinctWidthInSubband,
  15618. precinctHeightInSubband: precinctHeightInSubband
  15619. };
  15620. }
  15621. function buildCodeblocks(context, subband, dimensions) {
  15622. var xcb_ = dimensions.xcb_;
  15623. var ycb_ = dimensions.ycb_;
  15624. var codeblockWidth = 1 << xcb_;
  15625. var codeblockHeight = 1 << ycb_;
  15626. var cbx0 = subband.tbx0 >> xcb_;
  15627. var cby0 = subband.tby0 >> ycb_;
  15628. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15629. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15630. var precinctParameters = subband.resolution.precinctParameters;
  15631. var codeblocks = [];
  15632. var precincts = [];
  15633. var i, j, codeblock, precinctNumber;
  15634. for (j = cby0; j < cby1; j++) {
  15635. for (i = cbx0; i < cbx1; i++) {
  15636. codeblock = {
  15637. cbx: i,
  15638. cby: j,
  15639. tbx0: codeblockWidth * i,
  15640. tby0: codeblockHeight * j,
  15641. tbx1: codeblockWidth * (i + 1),
  15642. tby1: codeblockHeight * (j + 1)
  15643. };
  15644. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15645. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15646. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15647. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15648. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15649. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15650. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15651. codeblock.precinctNumber = precinctNumber;
  15652. codeblock.subbandType = subband.type;
  15653. codeblock.Lblock = 3;
  15654. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15655. continue;
  15656. }
  15657. codeblocks.push(codeblock);
  15658. var precinct = precincts[precinctNumber];
  15659. if (precinct !== undefined) {
  15660. if (i < precinct.cbxMin) {
  15661. precinct.cbxMin = i;
  15662. } else if (i > precinct.cbxMax) {
  15663. precinct.cbxMax = i;
  15664. }
  15665. if (j < precinct.cbyMin) {
  15666. precinct.cbxMin = j;
  15667. } else if (j > precinct.cbyMax) {
  15668. precinct.cbyMax = j;
  15669. }
  15670. } else {
  15671. precincts[precinctNumber] = precinct = {
  15672. cbxMin: i,
  15673. cbyMin: j,
  15674. cbxMax: i,
  15675. cbyMax: j
  15676. };
  15677. }
  15678. codeblock.precinct = precinct;
  15679. }
  15680. }
  15681. subband.codeblockParameters = {
  15682. codeblockWidth: xcb_,
  15683. codeblockHeight: ycb_,
  15684. numcodeblockwide: cbx1 - cbx0 + 1,
  15685. numcodeblockhigh: cby1 - cby0 + 1
  15686. };
  15687. subband.codeblocks = codeblocks;
  15688. subband.precincts = precincts;
  15689. }
  15690. function createPacket(resolution, precinctNumber, layerNumber) {
  15691. var precinctCodeblocks = [];
  15692. var subbands = resolution.subbands;
  15693. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15694. var subband = subbands[i];
  15695. var codeblocks = subband.codeblocks;
  15696. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15697. var codeblock = codeblocks[j];
  15698. if (codeblock.precinctNumber !== precinctNumber) {
  15699. continue;
  15700. }
  15701. precinctCodeblocks.push(codeblock);
  15702. }
  15703. }
  15704. return {
  15705. layerNumber: layerNumber,
  15706. codeblocks: precinctCodeblocks
  15707. };
  15708. }
  15709. function LayerResolutionComponentPositionIterator(context) {
  15710. var siz = context.SIZ;
  15711. var tileIndex = context.currentTile.index;
  15712. var tile = context.tiles[tileIndex];
  15713. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15714. var componentsCount = siz.Csiz;
  15715. var maxDecompositionLevelsCount = 0;
  15716. for (var q = 0; q < componentsCount; q++) {
  15717. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15718. }
  15719. var l = 0, r = 0, i = 0, k = 0;
  15720. this.nextPacket = function JpxImage_nextPacket() {
  15721. for (; l < layersCount; l++) {
  15722. for (; r <= maxDecompositionLevelsCount; r++) {
  15723. for (; i < componentsCount; i++) {
  15724. var component = tile.components[i];
  15725. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15726. continue;
  15727. }
  15728. var resolution = component.resolutions[r];
  15729. var numprecincts = resolution.precinctParameters.numprecincts;
  15730. for (; k < numprecincts;) {
  15731. var packet = createPacket(resolution, k, l);
  15732. k++;
  15733. return packet;
  15734. }
  15735. k = 0;
  15736. }
  15737. i = 0;
  15738. }
  15739. r = 0;
  15740. }
  15741. error('JPX Error: Out of packets');
  15742. };
  15743. }
  15744. function ResolutionLayerComponentPositionIterator(context) {
  15745. var siz = context.SIZ;
  15746. var tileIndex = context.currentTile.index;
  15747. var tile = context.tiles[tileIndex];
  15748. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15749. var componentsCount = siz.Csiz;
  15750. var maxDecompositionLevelsCount = 0;
  15751. for (var q = 0; q < componentsCount; q++) {
  15752. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15753. }
  15754. var r = 0, l = 0, i = 0, k = 0;
  15755. this.nextPacket = function JpxImage_nextPacket() {
  15756. for (; r <= maxDecompositionLevelsCount; r++) {
  15757. for (; l < layersCount; l++) {
  15758. for (; i < componentsCount; i++) {
  15759. var component = tile.components[i];
  15760. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15761. continue;
  15762. }
  15763. var resolution = component.resolutions[r];
  15764. var numprecincts = resolution.precinctParameters.numprecincts;
  15765. for (; k < numprecincts;) {
  15766. var packet = createPacket(resolution, k, l);
  15767. k++;
  15768. return packet;
  15769. }
  15770. k = 0;
  15771. }
  15772. i = 0;
  15773. }
  15774. l = 0;
  15775. }
  15776. error('JPX Error: Out of packets');
  15777. };
  15778. }
  15779. function ResolutionPositionComponentLayerIterator(context) {
  15780. var siz = context.SIZ;
  15781. var tileIndex = context.currentTile.index;
  15782. var tile = context.tiles[tileIndex];
  15783. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15784. var componentsCount = siz.Csiz;
  15785. var l, r, c, p;
  15786. var maxDecompositionLevelsCount = 0;
  15787. for (c = 0; c < componentsCount; c++) {
  15788. var component = tile.components[c];
  15789. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15790. }
  15791. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15792. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15793. var maxNumPrecincts = 0;
  15794. for (c = 0; c < componentsCount; ++c) {
  15795. var resolutions = tile.components[c].resolutions;
  15796. if (r < resolutions.length) {
  15797. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15798. }
  15799. }
  15800. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15801. }
  15802. l = 0;
  15803. r = 0;
  15804. c = 0;
  15805. p = 0;
  15806. this.nextPacket = function JpxImage_nextPacket() {
  15807. for (; r <= maxDecompositionLevelsCount; r++) {
  15808. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15809. for (; c < componentsCount; c++) {
  15810. var component = tile.components[c];
  15811. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15812. continue;
  15813. }
  15814. var resolution = component.resolutions[r];
  15815. var numprecincts = resolution.precinctParameters.numprecincts;
  15816. if (p >= numprecincts) {
  15817. continue;
  15818. }
  15819. for (; l < layersCount;) {
  15820. var packet = createPacket(resolution, p, l);
  15821. l++;
  15822. return packet;
  15823. }
  15824. l = 0;
  15825. }
  15826. c = 0;
  15827. }
  15828. p = 0;
  15829. }
  15830. error('JPX Error: Out of packets');
  15831. };
  15832. }
  15833. function PositionComponentResolutionLayerIterator(context) {
  15834. var siz = context.SIZ;
  15835. var tileIndex = context.currentTile.index;
  15836. var tile = context.tiles[tileIndex];
  15837. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15838. var componentsCount = siz.Csiz;
  15839. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15840. var precinctsIterationSizes = precinctsSizes;
  15841. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15842. this.nextPacket = function JpxImage_nextPacket() {
  15843. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15844. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15845. for (; c < componentsCount; c++) {
  15846. var component = tile.components[c];
  15847. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15848. for (; r <= decompositionLevelsCount; r++) {
  15849. var resolution = component.resolutions[r];
  15850. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15851. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15852. if (k === null) {
  15853. continue;
  15854. }
  15855. for (; l < layersCount;) {
  15856. var packet = createPacket(resolution, k, l);
  15857. l++;
  15858. return packet;
  15859. }
  15860. l = 0;
  15861. }
  15862. r = 0;
  15863. }
  15864. c = 0;
  15865. }
  15866. px = 0;
  15867. }
  15868. error('JPX Error: Out of packets');
  15869. };
  15870. }
  15871. function ComponentPositionResolutionLayerIterator(context) {
  15872. var siz = context.SIZ;
  15873. var tileIndex = context.currentTile.index;
  15874. var tile = context.tiles[tileIndex];
  15875. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15876. var componentsCount = siz.Csiz;
  15877. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15878. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15879. this.nextPacket = function JpxImage_nextPacket() {
  15880. for (; c < componentsCount; ++c) {
  15881. var component = tile.components[c];
  15882. var precinctsIterationSizes = precinctsSizes.components[c];
  15883. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15884. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15885. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15886. for (; r <= decompositionLevelsCount; r++) {
  15887. var resolution = component.resolutions[r];
  15888. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15889. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15890. if (k === null) {
  15891. continue;
  15892. }
  15893. for (; l < layersCount;) {
  15894. var packet = createPacket(resolution, k, l);
  15895. l++;
  15896. return packet;
  15897. }
  15898. l = 0;
  15899. }
  15900. r = 0;
  15901. }
  15902. px = 0;
  15903. }
  15904. py = 0;
  15905. }
  15906. error('JPX Error: Out of packets');
  15907. };
  15908. }
  15909. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15910. var posX = pxIndex * precinctIterationSizes.minWidth;
  15911. var posY = pyIndex * precinctIterationSizes.minHeight;
  15912. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15913. return null;
  15914. }
  15915. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15916. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15917. }
  15918. function getPrecinctSizesInImageScale(tile) {
  15919. var componentsCount = tile.components.length;
  15920. var minWidth = Number.MAX_VALUE;
  15921. var minHeight = Number.MAX_VALUE;
  15922. var maxNumWide = 0;
  15923. var maxNumHigh = 0;
  15924. var sizePerComponent = new Array(componentsCount);
  15925. for (var c = 0; c < componentsCount; c++) {
  15926. var component = tile.components[c];
  15927. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15928. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15929. var minWidthCurrentComponent = Number.MAX_VALUE;
  15930. var minHeightCurrentComponent = Number.MAX_VALUE;
  15931. var maxNumWideCurrentComponent = 0;
  15932. var maxNumHighCurrentComponent = 0;
  15933. var scale = 1;
  15934. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15935. var resolution = component.resolutions[r];
  15936. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15937. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15938. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15939. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15940. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15941. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15942. sizePerResolution[r] = {
  15943. width: widthCurrentResolution,
  15944. height: heightCurrentResolution
  15945. };
  15946. scale <<= 1;
  15947. }
  15948. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15949. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15950. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15951. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15952. sizePerComponent[c] = {
  15953. resolutions: sizePerResolution,
  15954. minWidth: minWidthCurrentComponent,
  15955. minHeight: minHeightCurrentComponent,
  15956. maxNumWide: maxNumWideCurrentComponent,
  15957. maxNumHigh: maxNumHighCurrentComponent
  15958. };
  15959. }
  15960. return {
  15961. components: sizePerComponent,
  15962. minWidth: minWidth,
  15963. minHeight: minHeight,
  15964. maxNumWide: maxNumWide,
  15965. maxNumHigh: maxNumHigh
  15966. };
  15967. }
  15968. function buildPackets(context) {
  15969. var siz = context.SIZ;
  15970. var tileIndex = context.currentTile.index;
  15971. var tile = context.tiles[tileIndex];
  15972. var componentsCount = siz.Csiz;
  15973. for (var c = 0; c < componentsCount; c++) {
  15974. var component = tile.components[c];
  15975. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15976. var resolutions = [];
  15977. var subbands = [];
  15978. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15979. var blocksDimensions = getBlocksDimensions(context, component, r);
  15980. var resolution = {};
  15981. var scale = 1 << decompositionLevelsCount - r;
  15982. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15983. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15984. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15985. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15986. resolution.resLevel = r;
  15987. buildPrecincts(context, resolution, blocksDimensions);
  15988. resolutions.push(resolution);
  15989. var subband;
  15990. if (r === 0) {
  15991. subband = {};
  15992. subband.type = 'LL';
  15993. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15994. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15995. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15996. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15997. subband.resolution = resolution;
  15998. buildCodeblocks(context, subband, blocksDimensions);
  15999. subbands.push(subband);
  16000. resolution.subbands = [subband];
  16001. } else {
  16002. var bscale = 1 << decompositionLevelsCount - r + 1;
  16003. var resolutionSubbands = [];
  16004. subband = {};
  16005. subband.type = 'HL';
  16006. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16007. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  16008. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16009. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  16010. subband.resolution = resolution;
  16011. buildCodeblocks(context, subband, blocksDimensions);
  16012. subbands.push(subband);
  16013. resolutionSubbands.push(subband);
  16014. subband = {};
  16015. subband.type = 'LH';
  16016. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  16017. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16018. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  16019. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16020. subband.resolution = resolution;
  16021. buildCodeblocks(context, subband, blocksDimensions);
  16022. subbands.push(subband);
  16023. resolutionSubbands.push(subband);
  16024. subband = {};
  16025. subband.type = 'HH';
  16026. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16027. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16028. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16029. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16030. subband.resolution = resolution;
  16031. buildCodeblocks(context, subband, blocksDimensions);
  16032. subbands.push(subband);
  16033. resolutionSubbands.push(subband);
  16034. resolution.subbands = resolutionSubbands;
  16035. }
  16036. }
  16037. component.resolutions = resolutions;
  16038. component.subbands = subbands;
  16039. }
  16040. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  16041. switch (progressionOrder) {
  16042. case 0:
  16043. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  16044. break;
  16045. case 1:
  16046. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  16047. break;
  16048. case 2:
  16049. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  16050. break;
  16051. case 3:
  16052. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  16053. break;
  16054. case 4:
  16055. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  16056. break;
  16057. default:
  16058. error('JPX Error: Unsupported progression order ' + progressionOrder);
  16059. }
  16060. }
  16061. function parseTilePackets(context, data, offset, dataLength) {
  16062. var position = 0;
  16063. var buffer, bufferSize = 0, skipNextBit = false;
  16064. function readBits(count) {
  16065. while (bufferSize < count) {
  16066. var b = data[offset + position];
  16067. position++;
  16068. if (skipNextBit) {
  16069. buffer = buffer << 7 | b;
  16070. bufferSize += 7;
  16071. skipNextBit = false;
  16072. } else {
  16073. buffer = buffer << 8 | b;
  16074. bufferSize += 8;
  16075. }
  16076. if (b === 0xFF) {
  16077. skipNextBit = true;
  16078. }
  16079. }
  16080. bufferSize -= count;
  16081. return buffer >>> bufferSize & (1 << count) - 1;
  16082. }
  16083. function skipMarkerIfEqual(value) {
  16084. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  16085. skipBytes(1);
  16086. return true;
  16087. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  16088. skipBytes(2);
  16089. return true;
  16090. }
  16091. return false;
  16092. }
  16093. function skipBytes(count) {
  16094. position += count;
  16095. }
  16096. function alignToByte() {
  16097. bufferSize = 0;
  16098. if (skipNextBit) {
  16099. position++;
  16100. skipNextBit = false;
  16101. }
  16102. }
  16103. function readCodingpasses() {
  16104. if (readBits(1) === 0) {
  16105. return 1;
  16106. }
  16107. if (readBits(1) === 0) {
  16108. return 2;
  16109. }
  16110. var value = readBits(2);
  16111. if (value < 3) {
  16112. return value + 3;
  16113. }
  16114. value = readBits(5);
  16115. if (value < 31) {
  16116. return value + 6;
  16117. }
  16118. value = readBits(7);
  16119. return value + 37;
  16120. }
  16121. var tileIndex = context.currentTile.index;
  16122. var tile = context.tiles[tileIndex];
  16123. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16124. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16125. var packetsIterator = tile.packetsIterator;
  16126. while (position < dataLength) {
  16127. alignToByte();
  16128. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16129. skipBytes(4);
  16130. }
  16131. var packet = packetsIterator.nextPacket();
  16132. if (!readBits(1)) {
  16133. continue;
  16134. }
  16135. var layerNumber = packet.layerNumber;
  16136. var queue = [], codeblock;
  16137. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16138. codeblock = packet.codeblocks[i];
  16139. var precinct = codeblock.precinct;
  16140. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16141. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16142. var codeblockIncluded = false;
  16143. var firstTimeInclusion = false;
  16144. var valueReady;
  16145. if (codeblock['included'] !== undefined) {
  16146. codeblockIncluded = !!readBits(1);
  16147. } else {
  16148. precinct = codeblock.precinct;
  16149. var inclusionTree, zeroBitPlanesTree;
  16150. if (precinct['inclusionTree'] !== undefined) {
  16151. inclusionTree = precinct.inclusionTree;
  16152. } else {
  16153. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16154. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16155. inclusionTree = new InclusionTree(width, height, layerNumber);
  16156. zeroBitPlanesTree = new TagTree(width, height);
  16157. precinct.inclusionTree = inclusionTree;
  16158. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16159. }
  16160. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16161. while (true) {
  16162. if (readBits(1)) {
  16163. valueReady = !inclusionTree.nextLevel();
  16164. if (valueReady) {
  16165. codeblock.included = true;
  16166. codeblockIncluded = firstTimeInclusion = true;
  16167. break;
  16168. }
  16169. } else {
  16170. inclusionTree.incrementValue(layerNumber);
  16171. break;
  16172. }
  16173. }
  16174. }
  16175. }
  16176. if (!codeblockIncluded) {
  16177. continue;
  16178. }
  16179. if (firstTimeInclusion) {
  16180. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16181. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16182. while (true) {
  16183. if (readBits(1)) {
  16184. valueReady = !zeroBitPlanesTree.nextLevel();
  16185. if (valueReady) {
  16186. break;
  16187. }
  16188. } else {
  16189. zeroBitPlanesTree.incrementValue();
  16190. }
  16191. }
  16192. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16193. }
  16194. var codingpasses = readCodingpasses();
  16195. while (readBits(1)) {
  16196. codeblock.Lblock++;
  16197. }
  16198. var codingpassesLog2 = log2(codingpasses);
  16199. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16200. var codedDataLength = readBits(bits);
  16201. queue.push({
  16202. codeblock: codeblock,
  16203. codingpasses: codingpasses,
  16204. dataLength: codedDataLength
  16205. });
  16206. }
  16207. alignToByte();
  16208. if (ephMarkerUsed) {
  16209. skipMarkerIfEqual(0x92);
  16210. }
  16211. while (queue.length > 0) {
  16212. var packetItem = queue.shift();
  16213. codeblock = packetItem.codeblock;
  16214. if (codeblock['data'] === undefined) {
  16215. codeblock.data = [];
  16216. }
  16217. codeblock.data.push({
  16218. data: data,
  16219. start: offset + position,
  16220. end: offset + position + packetItem.dataLength,
  16221. codingpasses: packetItem.codingpasses
  16222. });
  16223. position += packetItem.dataLength;
  16224. }
  16225. }
  16226. return position;
  16227. }
  16228. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16229. var x0 = subband.tbx0;
  16230. var y0 = subband.tby0;
  16231. var width = subband.tbx1 - subband.tbx0;
  16232. var codeblocks = subband.codeblocks;
  16233. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16234. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16235. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16236. var codeblock = codeblocks[i];
  16237. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16238. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16239. if (blockWidth === 0 || blockHeight === 0) {
  16240. continue;
  16241. }
  16242. if (codeblock['data'] === undefined) {
  16243. continue;
  16244. }
  16245. var bitModel, currentCodingpassType;
  16246. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16247. currentCodingpassType = 2;
  16248. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16249. var j, jj, dataItem;
  16250. for (j = 0, jj = data.length; j < jj; j++) {
  16251. dataItem = data[j];
  16252. totalLength += dataItem.end - dataItem.start;
  16253. codingpasses += dataItem.codingpasses;
  16254. }
  16255. var encodedData = new Uint8Array(totalLength);
  16256. var position = 0;
  16257. for (j = 0, jj = data.length; j < jj; j++) {
  16258. dataItem = data[j];
  16259. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16260. encodedData.set(chunk, position);
  16261. position += chunk.length;
  16262. }
  16263. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16264. bitModel.setDecoder(decoder);
  16265. for (j = 0; j < codingpasses; j++) {
  16266. switch (currentCodingpassType) {
  16267. case 0:
  16268. bitModel.runSignificancePropagationPass();
  16269. break;
  16270. case 1:
  16271. bitModel.runMagnitudeRefinementPass();
  16272. break;
  16273. case 2:
  16274. bitModel.runCleanupPass();
  16275. if (segmentationSymbolUsed) {
  16276. bitModel.checkSegmentationSymbol();
  16277. }
  16278. break;
  16279. }
  16280. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16281. }
  16282. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16283. var sign = bitModel.coefficentsSign;
  16284. var magnitude = bitModel.coefficentsMagnitude;
  16285. var bitsDecoded = bitModel.bitsDecoded;
  16286. var magnitudeCorrection = reversible ? 0 : 0.5;
  16287. var k, n, nb;
  16288. position = 0;
  16289. var interleave = subband.type !== 'LL';
  16290. for (j = 0; j < blockHeight; j++) {
  16291. var row = offset / width | 0;
  16292. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16293. for (k = 0; k < blockWidth; k++) {
  16294. n = magnitude[position];
  16295. if (n !== 0) {
  16296. n = (n + magnitudeCorrection) * delta;
  16297. if (sign[position] !== 0) {
  16298. n = -n;
  16299. }
  16300. nb = bitsDecoded[position];
  16301. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16302. if (reversible && nb >= mb) {
  16303. coefficients[pos] = n;
  16304. } else {
  16305. coefficients[pos] = n * (1 << mb - nb);
  16306. }
  16307. }
  16308. offset++;
  16309. position++;
  16310. }
  16311. offset += width - blockWidth;
  16312. }
  16313. }
  16314. }
  16315. function transformTile(context, tile, c) {
  16316. var component = tile.components[c];
  16317. var codingStyleParameters = component.codingStyleParameters;
  16318. var quantizationParameters = component.quantizationParameters;
  16319. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16320. var spqcds = quantizationParameters.SPqcds;
  16321. var scalarExpounded = quantizationParameters.scalarExpounded;
  16322. var guardBits = quantizationParameters.guardBits;
  16323. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16324. var precision = context.components[c].precision;
  16325. var reversible = codingStyleParameters.reversibleTransformation;
  16326. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16327. var subbandCoefficients = [];
  16328. var b = 0;
  16329. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16330. var resolution = component.resolutions[i];
  16331. var width = resolution.trx1 - resolution.trx0;
  16332. var height = resolution.try1 - resolution.try0;
  16333. var coefficients = new Float32Array(width * height);
  16334. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16335. var mu, epsilon;
  16336. if (!scalarExpounded) {
  16337. mu = spqcds[0].mu;
  16338. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16339. } else {
  16340. mu = spqcds[b].mu;
  16341. epsilon = spqcds[b].epsilon;
  16342. b++;
  16343. }
  16344. var subband = resolution.subbands[j];
  16345. var gainLog2 = SubbandsGainLog2[subband.type];
  16346. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16347. var mb = guardBits + epsilon - 1;
  16348. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16349. }
  16350. subbandCoefficients.push({
  16351. width: width,
  16352. height: height,
  16353. items: coefficients
  16354. });
  16355. }
  16356. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16357. return {
  16358. left: component.tcx0,
  16359. top: component.tcy0,
  16360. width: result.width,
  16361. height: result.height,
  16362. items: result.items
  16363. };
  16364. }
  16365. function transformComponents(context) {
  16366. var siz = context.SIZ;
  16367. var components = context.components;
  16368. var componentsCount = siz.Csiz;
  16369. var resultImages = [];
  16370. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16371. var tile = context.tiles[i];
  16372. var transformedTiles = [];
  16373. var c;
  16374. for (c = 0; c < componentsCount; c++) {
  16375. transformedTiles[c] = transformTile(context, tile, c);
  16376. }
  16377. var tile0 = transformedTiles[0];
  16378. var out = new Uint8Array(tile0.items.length * componentsCount);
  16379. var result = {
  16380. left: tile0.left,
  16381. top: tile0.top,
  16382. width: tile0.width,
  16383. height: tile0.height,
  16384. items: out
  16385. };
  16386. var shift, offset, max, min, maxK;
  16387. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16388. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16389. var fourComponents = componentsCount === 4;
  16390. var y0items = transformedTiles[0].items;
  16391. var y1items = transformedTiles[1].items;
  16392. var y2items = transformedTiles[2].items;
  16393. var y3items = fourComponents ? transformedTiles[3].items : null;
  16394. shift = components[0].precision - 8;
  16395. offset = (128 << shift) + 0.5;
  16396. max = 255 * (1 << shift);
  16397. maxK = max * 0.5;
  16398. min = -maxK;
  16399. var component0 = tile.components[0];
  16400. var alpha01 = componentsCount - 3;
  16401. jj = y0items.length;
  16402. if (!component0.codingStyleParameters.reversibleTransformation) {
  16403. for (j = 0; j < jj; j++, pos += alpha01) {
  16404. y0 = y0items[j] + offset;
  16405. y1 = y1items[j];
  16406. y2 = y2items[j];
  16407. r = y0 + 1.402 * y2;
  16408. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16409. b = y0 + 1.772 * y1;
  16410. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16411. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16412. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16413. }
  16414. } else {
  16415. for (j = 0; j < jj; j++, pos += alpha01) {
  16416. y0 = y0items[j] + offset;
  16417. y1 = y1items[j];
  16418. y2 = y2items[j];
  16419. g = y0 - (y2 + y1 >> 2);
  16420. r = g + y2;
  16421. b = g + y1;
  16422. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16423. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16424. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16425. }
  16426. }
  16427. if (fourComponents) {
  16428. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16429. k = y3items[j];
  16430. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16431. }
  16432. }
  16433. } else {
  16434. for (c = 0; c < componentsCount; c++) {
  16435. var items = transformedTiles[c].items;
  16436. shift = components[c].precision - 8;
  16437. offset = (128 << shift) + 0.5;
  16438. max = 127.5 * (1 << shift);
  16439. min = -max;
  16440. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16441. val = items[j];
  16442. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16443. pos += componentsCount;
  16444. }
  16445. }
  16446. }
  16447. resultImages.push(result);
  16448. }
  16449. return resultImages;
  16450. }
  16451. function initializeTile(context, tileIndex) {
  16452. var siz = context.SIZ;
  16453. var componentsCount = siz.Csiz;
  16454. var tile = context.tiles[tileIndex];
  16455. for (var c = 0; c < componentsCount; c++) {
  16456. var component = tile.components[c];
  16457. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16458. component.quantizationParameters = qcdOrQcc;
  16459. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16460. component.codingStyleParameters = codOrCoc;
  16461. }
  16462. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16463. }
  16464. var TagTree = function TagTreeClosure() {
  16465. function TagTree(width, height) {
  16466. var levelsLength = log2(Math.max(width, height)) + 1;
  16467. this.levels = [];
  16468. for (var i = 0; i < levelsLength; i++) {
  16469. var level = {
  16470. width: width,
  16471. height: height,
  16472. items: []
  16473. };
  16474. this.levels.push(level);
  16475. width = Math.ceil(width / 2);
  16476. height = Math.ceil(height / 2);
  16477. }
  16478. }
  16479. TagTree.prototype = {
  16480. reset: function TagTree_reset(i, j) {
  16481. var currentLevel = 0, value = 0, level;
  16482. while (currentLevel < this.levels.length) {
  16483. level = this.levels[currentLevel];
  16484. var index = i + j * level.width;
  16485. if (level.items[index] !== undefined) {
  16486. value = level.items[index];
  16487. break;
  16488. }
  16489. level.index = index;
  16490. i >>= 1;
  16491. j >>= 1;
  16492. currentLevel++;
  16493. }
  16494. currentLevel--;
  16495. level = this.levels[currentLevel];
  16496. level.items[level.index] = value;
  16497. this.currentLevel = currentLevel;
  16498. delete this.value;
  16499. },
  16500. incrementValue: function TagTree_incrementValue() {
  16501. var level = this.levels[this.currentLevel];
  16502. level.items[level.index]++;
  16503. },
  16504. nextLevel: function TagTree_nextLevel() {
  16505. var currentLevel = this.currentLevel;
  16506. var level = this.levels[currentLevel];
  16507. var value = level.items[level.index];
  16508. currentLevel--;
  16509. if (currentLevel < 0) {
  16510. this.value = value;
  16511. return false;
  16512. }
  16513. this.currentLevel = currentLevel;
  16514. level = this.levels[currentLevel];
  16515. level.items[level.index] = value;
  16516. return true;
  16517. }
  16518. };
  16519. return TagTree;
  16520. }();
  16521. var InclusionTree = function InclusionTreeClosure() {
  16522. function InclusionTree(width, height, defaultValue) {
  16523. var levelsLength = log2(Math.max(width, height)) + 1;
  16524. this.levels = [];
  16525. for (var i = 0; i < levelsLength; i++) {
  16526. var items = new Uint8Array(width * height);
  16527. for (var j = 0, jj = items.length; j < jj; j++) {
  16528. items[j] = defaultValue;
  16529. }
  16530. var level = {
  16531. width: width,
  16532. height: height,
  16533. items: items
  16534. };
  16535. this.levels.push(level);
  16536. width = Math.ceil(width / 2);
  16537. height = Math.ceil(height / 2);
  16538. }
  16539. }
  16540. InclusionTree.prototype = {
  16541. reset: function InclusionTree_reset(i, j, stopValue) {
  16542. var currentLevel = 0;
  16543. while (currentLevel < this.levels.length) {
  16544. var level = this.levels[currentLevel];
  16545. var index = i + j * level.width;
  16546. level.index = index;
  16547. var value = level.items[index];
  16548. if (value === 0xFF) {
  16549. break;
  16550. }
  16551. if (value > stopValue) {
  16552. this.currentLevel = currentLevel;
  16553. this.propagateValues();
  16554. return false;
  16555. }
  16556. i >>= 1;
  16557. j >>= 1;
  16558. currentLevel++;
  16559. }
  16560. this.currentLevel = currentLevel - 1;
  16561. return true;
  16562. },
  16563. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16564. var level = this.levels[this.currentLevel];
  16565. level.items[level.index] = stopValue + 1;
  16566. this.propagateValues();
  16567. },
  16568. propagateValues: function InclusionTree_propagateValues() {
  16569. var levelIndex = this.currentLevel;
  16570. var level = this.levels[levelIndex];
  16571. var currentValue = level.items[level.index];
  16572. while (--levelIndex >= 0) {
  16573. level = this.levels[levelIndex];
  16574. level.items[level.index] = currentValue;
  16575. }
  16576. },
  16577. nextLevel: function InclusionTree_nextLevel() {
  16578. var currentLevel = this.currentLevel;
  16579. var level = this.levels[currentLevel];
  16580. var value = level.items[level.index];
  16581. level.items[level.index] = 0xFF;
  16582. currentLevel--;
  16583. if (currentLevel < 0) {
  16584. return false;
  16585. }
  16586. this.currentLevel = currentLevel;
  16587. level = this.levels[currentLevel];
  16588. level.items[level.index] = value;
  16589. return true;
  16590. }
  16591. };
  16592. return InclusionTree;
  16593. }();
  16594. var BitModel = function BitModelClosure() {
  16595. var UNIFORM_CONTEXT = 17;
  16596. var RUNLENGTH_CONTEXT = 18;
  16597. var LLAndLHContextsLabel = new Uint8Array([
  16598. 0,
  16599. 5,
  16600. 8,
  16601. 0,
  16602. 3,
  16603. 7,
  16604. 8,
  16605. 0,
  16606. 4,
  16607. 7,
  16608. 8,
  16609. 0,
  16610. 0,
  16611. 0,
  16612. 0,
  16613. 0,
  16614. 1,
  16615. 6,
  16616. 8,
  16617. 0,
  16618. 3,
  16619. 7,
  16620. 8,
  16621. 0,
  16622. 4,
  16623. 7,
  16624. 8,
  16625. 0,
  16626. 0,
  16627. 0,
  16628. 0,
  16629. 0,
  16630. 2,
  16631. 6,
  16632. 8,
  16633. 0,
  16634. 3,
  16635. 7,
  16636. 8,
  16637. 0,
  16638. 4,
  16639. 7,
  16640. 8,
  16641. 0,
  16642. 0,
  16643. 0,
  16644. 0,
  16645. 0,
  16646. 2,
  16647. 6,
  16648. 8,
  16649. 0,
  16650. 3,
  16651. 7,
  16652. 8,
  16653. 0,
  16654. 4,
  16655. 7,
  16656. 8,
  16657. 0,
  16658. 0,
  16659. 0,
  16660. 0,
  16661. 0,
  16662. 2,
  16663. 6,
  16664. 8,
  16665. 0,
  16666. 3,
  16667. 7,
  16668. 8,
  16669. 0,
  16670. 4,
  16671. 7,
  16672. 8
  16673. ]);
  16674. var HLContextLabel = new Uint8Array([
  16675. 0,
  16676. 3,
  16677. 4,
  16678. 0,
  16679. 5,
  16680. 7,
  16681. 7,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 0,
  16688. 0,
  16689. 0,
  16690. 0,
  16691. 1,
  16692. 3,
  16693. 4,
  16694. 0,
  16695. 6,
  16696. 7,
  16697. 7,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 0,
  16704. 0,
  16705. 0,
  16706. 0,
  16707. 2,
  16708. 3,
  16709. 4,
  16710. 0,
  16711. 6,
  16712. 7,
  16713. 7,
  16714. 0,
  16715. 8,
  16716. 8,
  16717. 8,
  16718. 0,
  16719. 0,
  16720. 0,
  16721. 0,
  16722. 0,
  16723. 2,
  16724. 3,
  16725. 4,
  16726. 0,
  16727. 6,
  16728. 7,
  16729. 7,
  16730. 0,
  16731. 8,
  16732. 8,
  16733. 8,
  16734. 0,
  16735. 0,
  16736. 0,
  16737. 0,
  16738. 0,
  16739. 2,
  16740. 3,
  16741. 4,
  16742. 0,
  16743. 6,
  16744. 7,
  16745. 7,
  16746. 0,
  16747. 8,
  16748. 8,
  16749. 8
  16750. ]);
  16751. var HHContextLabel = new Uint8Array([
  16752. 0,
  16753. 1,
  16754. 2,
  16755. 0,
  16756. 1,
  16757. 2,
  16758. 2,
  16759. 0,
  16760. 2,
  16761. 2,
  16762. 2,
  16763. 0,
  16764. 0,
  16765. 0,
  16766. 0,
  16767. 0,
  16768. 3,
  16769. 4,
  16770. 5,
  16771. 0,
  16772. 4,
  16773. 5,
  16774. 5,
  16775. 0,
  16776. 5,
  16777. 5,
  16778. 5,
  16779. 0,
  16780. 0,
  16781. 0,
  16782. 0,
  16783. 0,
  16784. 6,
  16785. 7,
  16786. 7,
  16787. 0,
  16788. 7,
  16789. 7,
  16790. 7,
  16791. 0,
  16792. 7,
  16793. 7,
  16794. 7,
  16795. 0,
  16796. 0,
  16797. 0,
  16798. 0,
  16799. 0,
  16800. 8,
  16801. 8,
  16802. 8,
  16803. 0,
  16804. 8,
  16805. 8,
  16806. 8,
  16807. 0,
  16808. 8,
  16809. 8,
  16810. 8,
  16811. 0,
  16812. 0,
  16813. 0,
  16814. 0,
  16815. 0,
  16816. 8,
  16817. 8,
  16818. 8,
  16819. 0,
  16820. 8,
  16821. 8,
  16822. 8,
  16823. 0,
  16824. 8,
  16825. 8,
  16826. 8
  16827. ]);
  16828. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16829. this.width = width;
  16830. this.height = height;
  16831. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16832. var coefficientCount = width * height;
  16833. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16834. this.coefficentsSign = new Uint8Array(coefficientCount);
  16835. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16836. this.processingFlags = new Uint8Array(coefficientCount);
  16837. var bitsDecoded = new Uint8Array(coefficientCount);
  16838. if (zeroBitPlanes !== 0) {
  16839. for (var i = 0; i < coefficientCount; i++) {
  16840. bitsDecoded[i] = zeroBitPlanes;
  16841. }
  16842. }
  16843. this.bitsDecoded = bitsDecoded;
  16844. this.reset();
  16845. }
  16846. BitModel.prototype = {
  16847. setDecoder: function BitModel_setDecoder(decoder) {
  16848. this.decoder = decoder;
  16849. },
  16850. reset: function BitModel_reset() {
  16851. this.contexts = new Int8Array(19);
  16852. this.contexts[0] = 4 << 1 | 0;
  16853. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16854. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16855. },
  16856. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16857. var neighborsSignificance = this.neighborsSignificance;
  16858. var width = this.width, height = this.height;
  16859. var left = column > 0;
  16860. var right = column + 1 < width;
  16861. var i;
  16862. if (row > 0) {
  16863. i = index - width;
  16864. if (left) {
  16865. neighborsSignificance[i - 1] += 0x10;
  16866. }
  16867. if (right) {
  16868. neighborsSignificance[i + 1] += 0x10;
  16869. }
  16870. neighborsSignificance[i] += 0x04;
  16871. }
  16872. if (row + 1 < height) {
  16873. i = index + width;
  16874. if (left) {
  16875. neighborsSignificance[i - 1] += 0x10;
  16876. }
  16877. if (right) {
  16878. neighborsSignificance[i + 1] += 0x10;
  16879. }
  16880. neighborsSignificance[i] += 0x04;
  16881. }
  16882. if (left) {
  16883. neighborsSignificance[index - 1] += 0x01;
  16884. }
  16885. if (right) {
  16886. neighborsSignificance[index + 1] += 0x01;
  16887. }
  16888. neighborsSignificance[index] |= 0x80;
  16889. },
  16890. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16891. var decoder = this.decoder;
  16892. var width = this.width, height = this.height;
  16893. var coefficentsMagnitude = this.coefficentsMagnitude;
  16894. var coefficentsSign = this.coefficentsSign;
  16895. var neighborsSignificance = this.neighborsSignificance;
  16896. var processingFlags = this.processingFlags;
  16897. var contexts = this.contexts;
  16898. var labels = this.contextLabelTable;
  16899. var bitsDecoded = this.bitsDecoded;
  16900. var processedInverseMask = ~1;
  16901. var processedMask = 1;
  16902. var firstMagnitudeBitMask = 2;
  16903. for (var i0 = 0; i0 < height; i0 += 4) {
  16904. for (var j = 0; j < width; j++) {
  16905. var index = i0 * width + j;
  16906. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16907. var i = i0 + i1;
  16908. if (i >= height) {
  16909. break;
  16910. }
  16911. processingFlags[index] &= processedInverseMask;
  16912. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16913. continue;
  16914. }
  16915. var contextLabel = labels[neighborsSignificance[index]];
  16916. var decision = decoder.readBit(contexts, contextLabel);
  16917. if (decision) {
  16918. var sign = this.decodeSignBit(i, j, index);
  16919. coefficentsSign[index] = sign;
  16920. coefficentsMagnitude[index] = 1;
  16921. this.setNeighborsSignificance(i, j, index);
  16922. processingFlags[index] |= firstMagnitudeBitMask;
  16923. }
  16924. bitsDecoded[index]++;
  16925. processingFlags[index] |= processedMask;
  16926. }
  16927. }
  16928. }
  16929. },
  16930. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16931. var width = this.width, height = this.height;
  16932. var coefficentsMagnitude = this.coefficentsMagnitude;
  16933. var coefficentsSign = this.coefficentsSign;
  16934. var contribution, sign0, sign1, significance1;
  16935. var contextLabel, decoded;
  16936. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16937. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16938. sign1 = coefficentsSign[index + 1];
  16939. if (significance1) {
  16940. sign0 = coefficentsSign[index - 1];
  16941. contribution = 1 - sign1 - sign0;
  16942. } else {
  16943. contribution = 1 - sign1 - sign1;
  16944. }
  16945. } else if (significance1) {
  16946. sign0 = coefficentsSign[index - 1];
  16947. contribution = 1 - sign0 - sign0;
  16948. } else {
  16949. contribution = 0;
  16950. }
  16951. var horizontalContribution = 3 * contribution;
  16952. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16953. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16954. sign1 = coefficentsSign[index + width];
  16955. if (significance1) {
  16956. sign0 = coefficentsSign[index - width];
  16957. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16958. } else {
  16959. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16960. }
  16961. } else if (significance1) {
  16962. sign0 = coefficentsSign[index - width];
  16963. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16964. } else {
  16965. contribution = horizontalContribution;
  16966. }
  16967. if (contribution >= 0) {
  16968. contextLabel = 9 + contribution;
  16969. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16970. } else {
  16971. contextLabel = 9 - contribution;
  16972. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16973. }
  16974. return decoded;
  16975. },
  16976. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16977. var decoder = this.decoder;
  16978. var width = this.width, height = this.height;
  16979. var coefficentsMagnitude = this.coefficentsMagnitude;
  16980. var neighborsSignificance = this.neighborsSignificance;
  16981. var contexts = this.contexts;
  16982. var bitsDecoded = this.bitsDecoded;
  16983. var processingFlags = this.processingFlags;
  16984. var processedMask = 1;
  16985. var firstMagnitudeBitMask = 2;
  16986. var length = width * height;
  16987. var width4 = width * 4;
  16988. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16989. indexNext = Math.min(length, index0 + width4);
  16990. for (var j = 0; j < width; j++) {
  16991. for (var index = index0 + j; index < indexNext; index += width) {
  16992. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16993. continue;
  16994. }
  16995. var contextLabel = 16;
  16996. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16997. processingFlags[index] ^= firstMagnitudeBitMask;
  16998. var significance = neighborsSignificance[index] & 127;
  16999. contextLabel = significance === 0 ? 15 : 14;
  17000. }
  17001. var bit = decoder.readBit(contexts, contextLabel);
  17002. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  17003. bitsDecoded[index]++;
  17004. processingFlags[index] |= processedMask;
  17005. }
  17006. }
  17007. }
  17008. },
  17009. runCleanupPass: function BitModel_runCleanupPass() {
  17010. var decoder = this.decoder;
  17011. var width = this.width, height = this.height;
  17012. var neighborsSignificance = this.neighborsSignificance;
  17013. var coefficentsMagnitude = this.coefficentsMagnitude;
  17014. var coefficentsSign = this.coefficentsSign;
  17015. var contexts = this.contexts;
  17016. var labels = this.contextLabelTable;
  17017. var bitsDecoded = this.bitsDecoded;
  17018. var processingFlags = this.processingFlags;
  17019. var processedMask = 1;
  17020. var firstMagnitudeBitMask = 2;
  17021. var oneRowDown = width;
  17022. var twoRowsDown = width * 2;
  17023. var threeRowsDown = width * 3;
  17024. var iNext;
  17025. for (var i0 = 0; i0 < height; i0 = iNext) {
  17026. iNext = Math.min(i0 + 4, height);
  17027. var indexBase = i0 * width;
  17028. var checkAllEmpty = i0 + 3 < height;
  17029. for (var j = 0; j < width; j++) {
  17030. var index0 = indexBase + j;
  17031. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  17032. var i1 = 0, index = index0;
  17033. var i = i0, sign;
  17034. if (allEmpty) {
  17035. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  17036. if (!hasSignificantCoefficent) {
  17037. bitsDecoded[index0]++;
  17038. bitsDecoded[index0 + oneRowDown]++;
  17039. bitsDecoded[index0 + twoRowsDown]++;
  17040. bitsDecoded[index0 + threeRowsDown]++;
  17041. continue;
  17042. }
  17043. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17044. if (i1 !== 0) {
  17045. i = i0 + i1;
  17046. index += i1 * width;
  17047. }
  17048. sign = this.decodeSignBit(i, j, index);
  17049. coefficentsSign[index] = sign;
  17050. coefficentsMagnitude[index] = 1;
  17051. this.setNeighborsSignificance(i, j, index);
  17052. processingFlags[index] |= firstMagnitudeBitMask;
  17053. index = index0;
  17054. for (var i2 = i0; i2 <= i; i2++, index += width) {
  17055. bitsDecoded[index]++;
  17056. }
  17057. i1++;
  17058. }
  17059. for (i = i0 + i1; i < iNext; i++, index += width) {
  17060. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  17061. continue;
  17062. }
  17063. var contextLabel = labels[neighborsSignificance[index]];
  17064. var decision = decoder.readBit(contexts, contextLabel);
  17065. if (decision === 1) {
  17066. sign = this.decodeSignBit(i, j, index);
  17067. coefficentsSign[index] = sign;
  17068. coefficentsMagnitude[index] = 1;
  17069. this.setNeighborsSignificance(i, j, index);
  17070. processingFlags[index] |= firstMagnitudeBitMask;
  17071. }
  17072. bitsDecoded[index]++;
  17073. }
  17074. }
  17075. }
  17076. },
  17077. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  17078. var decoder = this.decoder;
  17079. var contexts = this.contexts;
  17080. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17081. if (symbol !== 0xA) {
  17082. error('JPX Error: Invalid segmentation symbol');
  17083. }
  17084. }
  17085. };
  17086. return BitModel;
  17087. }();
  17088. var Transform = function TransformClosure() {
  17089. function Transform() {
  17090. }
  17091. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  17092. var ll = subbands[0];
  17093. for (var i = 1, ii = subbands.length; i < ii; i++) {
  17094. ll = this.iterate(ll, subbands[i], u0, v0);
  17095. }
  17096. return ll;
  17097. };
  17098. Transform.prototype.extend = function extend(buffer, offset, size) {
  17099. var i1 = offset - 1, j1 = offset + 1;
  17100. var i2 = offset + size - 2, j2 = offset + size;
  17101. buffer[i1--] = buffer[j1++];
  17102. buffer[j2++] = buffer[i2--];
  17103. buffer[i1--] = buffer[j1++];
  17104. buffer[j2++] = buffer[i2--];
  17105. buffer[i1--] = buffer[j1++];
  17106. buffer[j2++] = buffer[i2--];
  17107. buffer[i1] = buffer[j1];
  17108. buffer[j2] = buffer[i2];
  17109. };
  17110. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  17111. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  17112. var width = hl_lh_hh.width;
  17113. var height = hl_lh_hh.height;
  17114. var items = hl_lh_hh.items;
  17115. var i, j, k, l, u, v;
  17116. for (k = 0, i = 0; i < llHeight; i++) {
  17117. l = i * 2 * width;
  17118. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17119. items[l] = llItems[k];
  17120. }
  17121. }
  17122. llItems = ll.items = null;
  17123. var bufferPadding = 4;
  17124. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17125. if (width === 1) {
  17126. if ((u0 & 1) !== 0) {
  17127. for (v = 0, k = 0; v < height; v++, k += width) {
  17128. items[k] *= 0.5;
  17129. }
  17130. }
  17131. } else {
  17132. for (v = 0, k = 0; v < height; v++, k += width) {
  17133. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17134. this.extend(rowBuffer, bufferPadding, width);
  17135. this.filter(rowBuffer, bufferPadding, width);
  17136. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17137. }
  17138. }
  17139. var numBuffers = 16;
  17140. var colBuffers = [];
  17141. for (i = 0; i < numBuffers; i++) {
  17142. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17143. }
  17144. var b, currentBuffer = 0;
  17145. ll = bufferPadding + height;
  17146. if (height === 1) {
  17147. if ((v0 & 1) !== 0) {
  17148. for (u = 0; u < width; u++) {
  17149. items[u] *= 0.5;
  17150. }
  17151. }
  17152. } else {
  17153. for (u = 0; u < width; u++) {
  17154. if (currentBuffer === 0) {
  17155. numBuffers = Math.min(width - u, numBuffers);
  17156. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17157. for (b = 0; b < numBuffers; b++) {
  17158. colBuffers[b][l] = items[k + b];
  17159. }
  17160. }
  17161. currentBuffer = numBuffers;
  17162. }
  17163. currentBuffer--;
  17164. var buffer = colBuffers[currentBuffer];
  17165. this.extend(buffer, bufferPadding, height);
  17166. this.filter(buffer, bufferPadding, height);
  17167. if (currentBuffer === 0) {
  17168. k = u - numBuffers + 1;
  17169. for (l = bufferPadding; l < ll; k += width, l++) {
  17170. for (b = 0; b < numBuffers; b++) {
  17171. items[k + b] = colBuffers[b][l];
  17172. }
  17173. }
  17174. }
  17175. }
  17176. }
  17177. return {
  17178. width: width,
  17179. height: height,
  17180. items: items
  17181. };
  17182. };
  17183. return Transform;
  17184. }();
  17185. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17186. function IrreversibleTransform() {
  17187. Transform.call(this);
  17188. }
  17189. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17190. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17191. var len = length >> 1;
  17192. offset = offset | 0;
  17193. var j, n, current, next;
  17194. var alpha = -1.586134342059924;
  17195. var beta = -0.052980118572961;
  17196. var gamma = 0.882911075530934;
  17197. var delta = 0.443506852043971;
  17198. var K = 1.230174104914001;
  17199. var K_ = 1 / K;
  17200. j = offset - 3;
  17201. for (n = len + 4; n--; j += 2) {
  17202. x[j] *= K_;
  17203. }
  17204. j = offset - 2;
  17205. current = delta * x[j - 1];
  17206. for (n = len + 3; n--; j += 2) {
  17207. next = delta * x[j + 1];
  17208. x[j] = K * x[j] - current - next;
  17209. if (n--) {
  17210. j += 2;
  17211. current = delta * x[j + 1];
  17212. x[j] = K * x[j] - current - next;
  17213. } else {
  17214. break;
  17215. }
  17216. }
  17217. j = offset - 1;
  17218. current = gamma * x[j - 1];
  17219. for (n = len + 2; n--; j += 2) {
  17220. next = gamma * x[j + 1];
  17221. x[j] -= current + next;
  17222. if (n--) {
  17223. j += 2;
  17224. current = gamma * x[j + 1];
  17225. x[j] -= current + next;
  17226. } else {
  17227. break;
  17228. }
  17229. }
  17230. j = offset;
  17231. current = beta * x[j - 1];
  17232. for (n = len + 1; n--; j += 2) {
  17233. next = beta * x[j + 1];
  17234. x[j] -= current + next;
  17235. if (n--) {
  17236. j += 2;
  17237. current = beta * x[j + 1];
  17238. x[j] -= current + next;
  17239. } else {
  17240. break;
  17241. }
  17242. }
  17243. if (len !== 0) {
  17244. j = offset + 1;
  17245. current = alpha * x[j - 1];
  17246. for (n = len; n--; j += 2) {
  17247. next = alpha * x[j + 1];
  17248. x[j] -= current + next;
  17249. if (n--) {
  17250. j += 2;
  17251. current = alpha * x[j + 1];
  17252. x[j] -= current + next;
  17253. } else {
  17254. break;
  17255. }
  17256. }
  17257. }
  17258. };
  17259. return IrreversibleTransform;
  17260. }();
  17261. var ReversibleTransform = function ReversibleTransformClosure() {
  17262. function ReversibleTransform() {
  17263. Transform.call(this);
  17264. }
  17265. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17266. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17267. var len = length >> 1;
  17268. offset = offset | 0;
  17269. var j, n;
  17270. for (j = offset, n = len + 1; n--; j += 2) {
  17271. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17272. }
  17273. for (j = offset + 1, n = len; n--; j += 2) {
  17274. x[j] += x[j - 1] + x[j + 1] >> 1;
  17275. }
  17276. };
  17277. return ReversibleTransform;
  17278. }();
  17279. return JpxImage;
  17280. }();
  17281. exports.JpxImage = JpxImage;
  17282. }));
  17283. (function (root, factory) {
  17284. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17285. }(this, function (exports, sharedUtil) {
  17286. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17287. var getMetrics = getLookupTableFactory(function (t) {
  17288. t['Courier'] = 600;
  17289. t['Courier-Bold'] = 600;
  17290. t['Courier-BoldOblique'] = 600;
  17291. t['Courier-Oblique'] = 600;
  17292. t['Helvetica'] = getLookupTableFactory(function (t) {
  17293. t['space'] = 278;
  17294. t['exclam'] = 278;
  17295. t['quotedbl'] = 355;
  17296. t['numbersign'] = 556;
  17297. t['dollar'] = 556;
  17298. t['percent'] = 889;
  17299. t['ampersand'] = 667;
  17300. t['quoteright'] = 222;
  17301. t['parenleft'] = 333;
  17302. t['parenright'] = 333;
  17303. t['asterisk'] = 389;
  17304. t['plus'] = 584;
  17305. t['comma'] = 278;
  17306. t['hyphen'] = 333;
  17307. t['period'] = 278;
  17308. t['slash'] = 278;
  17309. t['zero'] = 556;
  17310. t['one'] = 556;
  17311. t['two'] = 556;
  17312. t['three'] = 556;
  17313. t['four'] = 556;
  17314. t['five'] = 556;
  17315. t['six'] = 556;
  17316. t['seven'] = 556;
  17317. t['eight'] = 556;
  17318. t['nine'] = 556;
  17319. t['colon'] = 278;
  17320. t['semicolon'] = 278;
  17321. t['less'] = 584;
  17322. t['equal'] = 584;
  17323. t['greater'] = 584;
  17324. t['question'] = 556;
  17325. t['at'] = 1015;
  17326. t['A'] = 667;
  17327. t['B'] = 667;
  17328. t['C'] = 722;
  17329. t['D'] = 722;
  17330. t['E'] = 667;
  17331. t['F'] = 611;
  17332. t['G'] = 778;
  17333. t['H'] = 722;
  17334. t['I'] = 278;
  17335. t['J'] = 500;
  17336. t['K'] = 667;
  17337. t['L'] = 556;
  17338. t['M'] = 833;
  17339. t['N'] = 722;
  17340. t['O'] = 778;
  17341. t['P'] = 667;
  17342. t['Q'] = 778;
  17343. t['R'] = 722;
  17344. t['S'] = 667;
  17345. t['T'] = 611;
  17346. t['U'] = 722;
  17347. t['V'] = 667;
  17348. t['W'] = 944;
  17349. t['X'] = 667;
  17350. t['Y'] = 667;
  17351. t['Z'] = 611;
  17352. t['bracketleft'] = 278;
  17353. t['backslash'] = 278;
  17354. t['bracketright'] = 278;
  17355. t['asciicircum'] = 469;
  17356. t['underscore'] = 556;
  17357. t['quoteleft'] = 222;
  17358. t['a'] = 556;
  17359. t['b'] = 556;
  17360. t['c'] = 500;
  17361. t['d'] = 556;
  17362. t['e'] = 556;
  17363. t['f'] = 278;
  17364. t['g'] = 556;
  17365. t['h'] = 556;
  17366. t['i'] = 222;
  17367. t['j'] = 222;
  17368. t['k'] = 500;
  17369. t['l'] = 222;
  17370. t['m'] = 833;
  17371. t['n'] = 556;
  17372. t['o'] = 556;
  17373. t['p'] = 556;
  17374. t['q'] = 556;
  17375. t['r'] = 333;
  17376. t['s'] = 500;
  17377. t['t'] = 278;
  17378. t['u'] = 556;
  17379. t['v'] = 500;
  17380. t['w'] = 722;
  17381. t['x'] = 500;
  17382. t['y'] = 500;
  17383. t['z'] = 500;
  17384. t['braceleft'] = 334;
  17385. t['bar'] = 260;
  17386. t['braceright'] = 334;
  17387. t['asciitilde'] = 584;
  17388. t['exclamdown'] = 333;
  17389. t['cent'] = 556;
  17390. t['sterling'] = 556;
  17391. t['fraction'] = 167;
  17392. t['yen'] = 556;
  17393. t['florin'] = 556;
  17394. t['section'] = 556;
  17395. t['currency'] = 556;
  17396. t['quotesingle'] = 191;
  17397. t['quotedblleft'] = 333;
  17398. t['guillemotleft'] = 556;
  17399. t['guilsinglleft'] = 333;
  17400. t['guilsinglright'] = 333;
  17401. t['fi'] = 500;
  17402. t['fl'] = 500;
  17403. t['endash'] = 556;
  17404. t['dagger'] = 556;
  17405. t['daggerdbl'] = 556;
  17406. t['periodcentered'] = 278;
  17407. t['paragraph'] = 537;
  17408. t['bullet'] = 350;
  17409. t['quotesinglbase'] = 222;
  17410. t['quotedblbase'] = 333;
  17411. t['quotedblright'] = 333;
  17412. t['guillemotright'] = 556;
  17413. t['ellipsis'] = 1000;
  17414. t['perthousand'] = 1000;
  17415. t['questiondown'] = 611;
  17416. t['grave'] = 333;
  17417. t['acute'] = 333;
  17418. t['circumflex'] = 333;
  17419. t['tilde'] = 333;
  17420. t['macron'] = 333;
  17421. t['breve'] = 333;
  17422. t['dotaccent'] = 333;
  17423. t['dieresis'] = 333;
  17424. t['ring'] = 333;
  17425. t['cedilla'] = 333;
  17426. t['hungarumlaut'] = 333;
  17427. t['ogonek'] = 333;
  17428. t['caron'] = 333;
  17429. t['emdash'] = 1000;
  17430. t['AE'] = 1000;
  17431. t['ordfeminine'] = 370;
  17432. t['Lslash'] = 556;
  17433. t['Oslash'] = 778;
  17434. t['OE'] = 1000;
  17435. t['ordmasculine'] = 365;
  17436. t['ae'] = 889;
  17437. t['dotlessi'] = 278;
  17438. t['lslash'] = 222;
  17439. t['oslash'] = 611;
  17440. t['oe'] = 944;
  17441. t['germandbls'] = 611;
  17442. t['Idieresis'] = 278;
  17443. t['eacute'] = 556;
  17444. t['abreve'] = 556;
  17445. t['uhungarumlaut'] = 556;
  17446. t['ecaron'] = 556;
  17447. t['Ydieresis'] = 667;
  17448. t['divide'] = 584;
  17449. t['Yacute'] = 667;
  17450. t['Acircumflex'] = 667;
  17451. t['aacute'] = 556;
  17452. t['Ucircumflex'] = 722;
  17453. t['yacute'] = 500;
  17454. t['scommaaccent'] = 500;
  17455. t['ecircumflex'] = 556;
  17456. t['Uring'] = 722;
  17457. t['Udieresis'] = 722;
  17458. t['aogonek'] = 556;
  17459. t['Uacute'] = 722;
  17460. t['uogonek'] = 556;
  17461. t['Edieresis'] = 667;
  17462. t['Dcroat'] = 722;
  17463. t['commaaccent'] = 250;
  17464. t['copyright'] = 737;
  17465. t['Emacron'] = 667;
  17466. t['ccaron'] = 500;
  17467. t['aring'] = 556;
  17468. t['Ncommaaccent'] = 722;
  17469. t['lacute'] = 222;
  17470. t['agrave'] = 556;
  17471. t['Tcommaaccent'] = 611;
  17472. t['Cacute'] = 722;
  17473. t['atilde'] = 556;
  17474. t['Edotaccent'] = 667;
  17475. t['scaron'] = 500;
  17476. t['scedilla'] = 500;
  17477. t['iacute'] = 278;
  17478. t['lozenge'] = 471;
  17479. t['Rcaron'] = 722;
  17480. t['Gcommaaccent'] = 778;
  17481. t['ucircumflex'] = 556;
  17482. t['acircumflex'] = 556;
  17483. t['Amacron'] = 667;
  17484. t['rcaron'] = 333;
  17485. t['ccedilla'] = 500;
  17486. t['Zdotaccent'] = 611;
  17487. t['Thorn'] = 667;
  17488. t['Omacron'] = 778;
  17489. t['Racute'] = 722;
  17490. t['Sacute'] = 667;
  17491. t['dcaron'] = 643;
  17492. t['Umacron'] = 722;
  17493. t['uring'] = 556;
  17494. t['threesuperior'] = 333;
  17495. t['Ograve'] = 778;
  17496. t['Agrave'] = 667;
  17497. t['Abreve'] = 667;
  17498. t['multiply'] = 584;
  17499. t['uacute'] = 556;
  17500. t['Tcaron'] = 611;
  17501. t['partialdiff'] = 476;
  17502. t['ydieresis'] = 500;
  17503. t['Nacute'] = 722;
  17504. t['icircumflex'] = 278;
  17505. t['Ecircumflex'] = 667;
  17506. t['adieresis'] = 556;
  17507. t['edieresis'] = 556;
  17508. t['cacute'] = 500;
  17509. t['nacute'] = 556;
  17510. t['umacron'] = 556;
  17511. t['Ncaron'] = 722;
  17512. t['Iacute'] = 278;
  17513. t['plusminus'] = 584;
  17514. t['brokenbar'] = 260;
  17515. t['registered'] = 737;
  17516. t['Gbreve'] = 778;
  17517. t['Idotaccent'] = 278;
  17518. t['summation'] = 600;
  17519. t['Egrave'] = 667;
  17520. t['racute'] = 333;
  17521. t['omacron'] = 556;
  17522. t['Zacute'] = 611;
  17523. t['Zcaron'] = 611;
  17524. t['greaterequal'] = 549;
  17525. t['Eth'] = 722;
  17526. t['Ccedilla'] = 722;
  17527. t['lcommaaccent'] = 222;
  17528. t['tcaron'] = 317;
  17529. t['eogonek'] = 556;
  17530. t['Uogonek'] = 722;
  17531. t['Aacute'] = 667;
  17532. t['Adieresis'] = 667;
  17533. t['egrave'] = 556;
  17534. t['zacute'] = 500;
  17535. t['iogonek'] = 222;
  17536. t['Oacute'] = 778;
  17537. t['oacute'] = 556;
  17538. t['amacron'] = 556;
  17539. t['sacute'] = 500;
  17540. t['idieresis'] = 278;
  17541. t['Ocircumflex'] = 778;
  17542. t['Ugrave'] = 722;
  17543. t['Delta'] = 612;
  17544. t['thorn'] = 556;
  17545. t['twosuperior'] = 333;
  17546. t['Odieresis'] = 778;
  17547. t['mu'] = 556;
  17548. t['igrave'] = 278;
  17549. t['ohungarumlaut'] = 556;
  17550. t['Eogonek'] = 667;
  17551. t['dcroat'] = 556;
  17552. t['threequarters'] = 834;
  17553. t['Scedilla'] = 667;
  17554. t['lcaron'] = 299;
  17555. t['Kcommaaccent'] = 667;
  17556. t['Lacute'] = 556;
  17557. t['trademark'] = 1000;
  17558. t['edotaccent'] = 556;
  17559. t['Igrave'] = 278;
  17560. t['Imacron'] = 278;
  17561. t['Lcaron'] = 556;
  17562. t['onehalf'] = 834;
  17563. t['lessequal'] = 549;
  17564. t['ocircumflex'] = 556;
  17565. t['ntilde'] = 556;
  17566. t['Uhungarumlaut'] = 722;
  17567. t['Eacute'] = 667;
  17568. t['emacron'] = 556;
  17569. t['gbreve'] = 556;
  17570. t['onequarter'] = 834;
  17571. t['Scaron'] = 667;
  17572. t['Scommaaccent'] = 667;
  17573. t['Ohungarumlaut'] = 778;
  17574. t['degree'] = 400;
  17575. t['ograve'] = 556;
  17576. t['Ccaron'] = 722;
  17577. t['ugrave'] = 556;
  17578. t['radical'] = 453;
  17579. t['Dcaron'] = 722;
  17580. t['rcommaaccent'] = 333;
  17581. t['Ntilde'] = 722;
  17582. t['otilde'] = 556;
  17583. t['Rcommaaccent'] = 722;
  17584. t['Lcommaaccent'] = 556;
  17585. t['Atilde'] = 667;
  17586. t['Aogonek'] = 667;
  17587. t['Aring'] = 667;
  17588. t['Otilde'] = 778;
  17589. t['zdotaccent'] = 500;
  17590. t['Ecaron'] = 667;
  17591. t['Iogonek'] = 278;
  17592. t['kcommaaccent'] = 500;
  17593. t['minus'] = 584;
  17594. t['Icircumflex'] = 278;
  17595. t['ncaron'] = 556;
  17596. t['tcommaaccent'] = 278;
  17597. t['logicalnot'] = 584;
  17598. t['odieresis'] = 556;
  17599. t['udieresis'] = 556;
  17600. t['notequal'] = 549;
  17601. t['gcommaaccent'] = 556;
  17602. t['eth'] = 556;
  17603. t['zcaron'] = 500;
  17604. t['ncommaaccent'] = 556;
  17605. t['onesuperior'] = 333;
  17606. t['imacron'] = 278;
  17607. t['Euro'] = 556;
  17608. });
  17609. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17610. t['space'] = 278;
  17611. t['exclam'] = 333;
  17612. t['quotedbl'] = 474;
  17613. t['numbersign'] = 556;
  17614. t['dollar'] = 556;
  17615. t['percent'] = 889;
  17616. t['ampersand'] = 722;
  17617. t['quoteright'] = 278;
  17618. t['parenleft'] = 333;
  17619. t['parenright'] = 333;
  17620. t['asterisk'] = 389;
  17621. t['plus'] = 584;
  17622. t['comma'] = 278;
  17623. t['hyphen'] = 333;
  17624. t['period'] = 278;
  17625. t['slash'] = 278;
  17626. t['zero'] = 556;
  17627. t['one'] = 556;
  17628. t['two'] = 556;
  17629. t['three'] = 556;
  17630. t['four'] = 556;
  17631. t['five'] = 556;
  17632. t['six'] = 556;
  17633. t['seven'] = 556;
  17634. t['eight'] = 556;
  17635. t['nine'] = 556;
  17636. t['colon'] = 333;
  17637. t['semicolon'] = 333;
  17638. t['less'] = 584;
  17639. t['equal'] = 584;
  17640. t['greater'] = 584;
  17641. t['question'] = 611;
  17642. t['at'] = 975;
  17643. t['A'] = 722;
  17644. t['B'] = 722;
  17645. t['C'] = 722;
  17646. t['D'] = 722;
  17647. t['E'] = 667;
  17648. t['F'] = 611;
  17649. t['G'] = 778;
  17650. t['H'] = 722;
  17651. t['I'] = 278;
  17652. t['J'] = 556;
  17653. t['K'] = 722;
  17654. t['L'] = 611;
  17655. t['M'] = 833;
  17656. t['N'] = 722;
  17657. t['O'] = 778;
  17658. t['P'] = 667;
  17659. t['Q'] = 778;
  17660. t['R'] = 722;
  17661. t['S'] = 667;
  17662. t['T'] = 611;
  17663. t['U'] = 722;
  17664. t['V'] = 667;
  17665. t['W'] = 944;
  17666. t['X'] = 667;
  17667. t['Y'] = 667;
  17668. t['Z'] = 611;
  17669. t['bracketleft'] = 333;
  17670. t['backslash'] = 278;
  17671. t['bracketright'] = 333;
  17672. t['asciicircum'] = 584;
  17673. t['underscore'] = 556;
  17674. t['quoteleft'] = 278;
  17675. t['a'] = 556;
  17676. t['b'] = 611;
  17677. t['c'] = 556;
  17678. t['d'] = 611;
  17679. t['e'] = 556;
  17680. t['f'] = 333;
  17681. t['g'] = 611;
  17682. t['h'] = 611;
  17683. t['i'] = 278;
  17684. t['j'] = 278;
  17685. t['k'] = 556;
  17686. t['l'] = 278;
  17687. t['m'] = 889;
  17688. t['n'] = 611;
  17689. t['o'] = 611;
  17690. t['p'] = 611;
  17691. t['q'] = 611;
  17692. t['r'] = 389;
  17693. t['s'] = 556;
  17694. t['t'] = 333;
  17695. t['u'] = 611;
  17696. t['v'] = 556;
  17697. t['w'] = 778;
  17698. t['x'] = 556;
  17699. t['y'] = 556;
  17700. t['z'] = 500;
  17701. t['braceleft'] = 389;
  17702. t['bar'] = 280;
  17703. t['braceright'] = 389;
  17704. t['asciitilde'] = 584;
  17705. t['exclamdown'] = 333;
  17706. t['cent'] = 556;
  17707. t['sterling'] = 556;
  17708. t['fraction'] = 167;
  17709. t['yen'] = 556;
  17710. t['florin'] = 556;
  17711. t['section'] = 556;
  17712. t['currency'] = 556;
  17713. t['quotesingle'] = 238;
  17714. t['quotedblleft'] = 500;
  17715. t['guillemotleft'] = 556;
  17716. t['guilsinglleft'] = 333;
  17717. t['guilsinglright'] = 333;
  17718. t['fi'] = 611;
  17719. t['fl'] = 611;
  17720. t['endash'] = 556;
  17721. t['dagger'] = 556;
  17722. t['daggerdbl'] = 556;
  17723. t['periodcentered'] = 278;
  17724. t['paragraph'] = 556;
  17725. t['bullet'] = 350;
  17726. t['quotesinglbase'] = 278;
  17727. t['quotedblbase'] = 500;
  17728. t['quotedblright'] = 500;
  17729. t['guillemotright'] = 556;
  17730. t['ellipsis'] = 1000;
  17731. t['perthousand'] = 1000;
  17732. t['questiondown'] = 611;
  17733. t['grave'] = 333;
  17734. t['acute'] = 333;
  17735. t['circumflex'] = 333;
  17736. t['tilde'] = 333;
  17737. t['macron'] = 333;
  17738. t['breve'] = 333;
  17739. t['dotaccent'] = 333;
  17740. t['dieresis'] = 333;
  17741. t['ring'] = 333;
  17742. t['cedilla'] = 333;
  17743. t['hungarumlaut'] = 333;
  17744. t['ogonek'] = 333;
  17745. t['caron'] = 333;
  17746. t['emdash'] = 1000;
  17747. t['AE'] = 1000;
  17748. t['ordfeminine'] = 370;
  17749. t['Lslash'] = 611;
  17750. t['Oslash'] = 778;
  17751. t['OE'] = 1000;
  17752. t['ordmasculine'] = 365;
  17753. t['ae'] = 889;
  17754. t['dotlessi'] = 278;
  17755. t['lslash'] = 278;
  17756. t['oslash'] = 611;
  17757. t['oe'] = 944;
  17758. t['germandbls'] = 611;
  17759. t['Idieresis'] = 278;
  17760. t['eacute'] = 556;
  17761. t['abreve'] = 556;
  17762. t['uhungarumlaut'] = 611;
  17763. t['ecaron'] = 556;
  17764. t['Ydieresis'] = 667;
  17765. t['divide'] = 584;
  17766. t['Yacute'] = 667;
  17767. t['Acircumflex'] = 722;
  17768. t['aacute'] = 556;
  17769. t['Ucircumflex'] = 722;
  17770. t['yacute'] = 556;
  17771. t['scommaaccent'] = 556;
  17772. t['ecircumflex'] = 556;
  17773. t['Uring'] = 722;
  17774. t['Udieresis'] = 722;
  17775. t['aogonek'] = 556;
  17776. t['Uacute'] = 722;
  17777. t['uogonek'] = 611;
  17778. t['Edieresis'] = 667;
  17779. t['Dcroat'] = 722;
  17780. t['commaaccent'] = 250;
  17781. t['copyright'] = 737;
  17782. t['Emacron'] = 667;
  17783. t['ccaron'] = 556;
  17784. t['aring'] = 556;
  17785. t['Ncommaaccent'] = 722;
  17786. t['lacute'] = 278;
  17787. t['agrave'] = 556;
  17788. t['Tcommaaccent'] = 611;
  17789. t['Cacute'] = 722;
  17790. t['atilde'] = 556;
  17791. t['Edotaccent'] = 667;
  17792. t['scaron'] = 556;
  17793. t['scedilla'] = 556;
  17794. t['iacute'] = 278;
  17795. t['lozenge'] = 494;
  17796. t['Rcaron'] = 722;
  17797. t['Gcommaaccent'] = 778;
  17798. t['ucircumflex'] = 611;
  17799. t['acircumflex'] = 556;
  17800. t['Amacron'] = 722;
  17801. t['rcaron'] = 389;
  17802. t['ccedilla'] = 556;
  17803. t['Zdotaccent'] = 611;
  17804. t['Thorn'] = 667;
  17805. t['Omacron'] = 778;
  17806. t['Racute'] = 722;
  17807. t['Sacute'] = 667;
  17808. t['dcaron'] = 743;
  17809. t['Umacron'] = 722;
  17810. t['uring'] = 611;
  17811. t['threesuperior'] = 333;
  17812. t['Ograve'] = 778;
  17813. t['Agrave'] = 722;
  17814. t['Abreve'] = 722;
  17815. t['multiply'] = 584;
  17816. t['uacute'] = 611;
  17817. t['Tcaron'] = 611;
  17818. t['partialdiff'] = 494;
  17819. t['ydieresis'] = 556;
  17820. t['Nacute'] = 722;
  17821. t['icircumflex'] = 278;
  17822. t['Ecircumflex'] = 667;
  17823. t['adieresis'] = 556;
  17824. t['edieresis'] = 556;
  17825. t['cacute'] = 556;
  17826. t['nacute'] = 611;
  17827. t['umacron'] = 611;
  17828. t['Ncaron'] = 722;
  17829. t['Iacute'] = 278;
  17830. t['plusminus'] = 584;
  17831. t['brokenbar'] = 280;
  17832. t['registered'] = 737;
  17833. t['Gbreve'] = 778;
  17834. t['Idotaccent'] = 278;
  17835. t['summation'] = 600;
  17836. t['Egrave'] = 667;
  17837. t['racute'] = 389;
  17838. t['omacron'] = 611;
  17839. t['Zacute'] = 611;
  17840. t['Zcaron'] = 611;
  17841. t['greaterequal'] = 549;
  17842. t['Eth'] = 722;
  17843. t['Ccedilla'] = 722;
  17844. t['lcommaaccent'] = 278;
  17845. t['tcaron'] = 389;
  17846. t['eogonek'] = 556;
  17847. t['Uogonek'] = 722;
  17848. t['Aacute'] = 722;
  17849. t['Adieresis'] = 722;
  17850. t['egrave'] = 556;
  17851. t['zacute'] = 500;
  17852. t['iogonek'] = 278;
  17853. t['Oacute'] = 778;
  17854. t['oacute'] = 611;
  17855. t['amacron'] = 556;
  17856. t['sacute'] = 556;
  17857. t['idieresis'] = 278;
  17858. t['Ocircumflex'] = 778;
  17859. t['Ugrave'] = 722;
  17860. t['Delta'] = 612;
  17861. t['thorn'] = 611;
  17862. t['twosuperior'] = 333;
  17863. t['Odieresis'] = 778;
  17864. t['mu'] = 611;
  17865. t['igrave'] = 278;
  17866. t['ohungarumlaut'] = 611;
  17867. t['Eogonek'] = 667;
  17868. t['dcroat'] = 611;
  17869. t['threequarters'] = 834;
  17870. t['Scedilla'] = 667;
  17871. t['lcaron'] = 400;
  17872. t['Kcommaaccent'] = 722;
  17873. t['Lacute'] = 611;
  17874. t['trademark'] = 1000;
  17875. t['edotaccent'] = 556;
  17876. t['Igrave'] = 278;
  17877. t['Imacron'] = 278;
  17878. t['Lcaron'] = 611;
  17879. t['onehalf'] = 834;
  17880. t['lessequal'] = 549;
  17881. t['ocircumflex'] = 611;
  17882. t['ntilde'] = 611;
  17883. t['Uhungarumlaut'] = 722;
  17884. t['Eacute'] = 667;
  17885. t['emacron'] = 556;
  17886. t['gbreve'] = 611;
  17887. t['onequarter'] = 834;
  17888. t['Scaron'] = 667;
  17889. t['Scommaaccent'] = 667;
  17890. t['Ohungarumlaut'] = 778;
  17891. t['degree'] = 400;
  17892. t['ograve'] = 611;
  17893. t['Ccaron'] = 722;
  17894. t['ugrave'] = 611;
  17895. t['radical'] = 549;
  17896. t['Dcaron'] = 722;
  17897. t['rcommaaccent'] = 389;
  17898. t['Ntilde'] = 722;
  17899. t['otilde'] = 611;
  17900. t['Rcommaaccent'] = 722;
  17901. t['Lcommaaccent'] = 611;
  17902. t['Atilde'] = 722;
  17903. t['Aogonek'] = 722;
  17904. t['Aring'] = 722;
  17905. t['Otilde'] = 778;
  17906. t['zdotaccent'] = 500;
  17907. t['Ecaron'] = 667;
  17908. t['Iogonek'] = 278;
  17909. t['kcommaaccent'] = 556;
  17910. t['minus'] = 584;
  17911. t['Icircumflex'] = 278;
  17912. t['ncaron'] = 611;
  17913. t['tcommaaccent'] = 333;
  17914. t['logicalnot'] = 584;
  17915. t['odieresis'] = 611;
  17916. t['udieresis'] = 611;
  17917. t['notequal'] = 549;
  17918. t['gcommaaccent'] = 611;
  17919. t['eth'] = 611;
  17920. t['zcaron'] = 500;
  17921. t['ncommaaccent'] = 611;
  17922. t['onesuperior'] = 333;
  17923. t['imacron'] = 278;
  17924. t['Euro'] = 556;
  17925. });
  17926. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17927. t['space'] = 278;
  17928. t['exclam'] = 333;
  17929. t['quotedbl'] = 474;
  17930. t['numbersign'] = 556;
  17931. t['dollar'] = 556;
  17932. t['percent'] = 889;
  17933. t['ampersand'] = 722;
  17934. t['quoteright'] = 278;
  17935. t['parenleft'] = 333;
  17936. t['parenright'] = 333;
  17937. t['asterisk'] = 389;
  17938. t['plus'] = 584;
  17939. t['comma'] = 278;
  17940. t['hyphen'] = 333;
  17941. t['period'] = 278;
  17942. t['slash'] = 278;
  17943. t['zero'] = 556;
  17944. t['one'] = 556;
  17945. t['two'] = 556;
  17946. t['three'] = 556;
  17947. t['four'] = 556;
  17948. t['five'] = 556;
  17949. t['six'] = 556;
  17950. t['seven'] = 556;
  17951. t['eight'] = 556;
  17952. t['nine'] = 556;
  17953. t['colon'] = 333;
  17954. t['semicolon'] = 333;
  17955. t['less'] = 584;
  17956. t['equal'] = 584;
  17957. t['greater'] = 584;
  17958. t['question'] = 611;
  17959. t['at'] = 975;
  17960. t['A'] = 722;
  17961. t['B'] = 722;
  17962. t['C'] = 722;
  17963. t['D'] = 722;
  17964. t['E'] = 667;
  17965. t['F'] = 611;
  17966. t['G'] = 778;
  17967. t['H'] = 722;
  17968. t['I'] = 278;
  17969. t['J'] = 556;
  17970. t['K'] = 722;
  17971. t['L'] = 611;
  17972. t['M'] = 833;
  17973. t['N'] = 722;
  17974. t['O'] = 778;
  17975. t['P'] = 667;
  17976. t['Q'] = 778;
  17977. t['R'] = 722;
  17978. t['S'] = 667;
  17979. t['T'] = 611;
  17980. t['U'] = 722;
  17981. t['V'] = 667;
  17982. t['W'] = 944;
  17983. t['X'] = 667;
  17984. t['Y'] = 667;
  17985. t['Z'] = 611;
  17986. t['bracketleft'] = 333;
  17987. t['backslash'] = 278;
  17988. t['bracketright'] = 333;
  17989. t['asciicircum'] = 584;
  17990. t['underscore'] = 556;
  17991. t['quoteleft'] = 278;
  17992. t['a'] = 556;
  17993. t['b'] = 611;
  17994. t['c'] = 556;
  17995. t['d'] = 611;
  17996. t['e'] = 556;
  17997. t['f'] = 333;
  17998. t['g'] = 611;
  17999. t['h'] = 611;
  18000. t['i'] = 278;
  18001. t['j'] = 278;
  18002. t['k'] = 556;
  18003. t['l'] = 278;
  18004. t['m'] = 889;
  18005. t['n'] = 611;
  18006. t['o'] = 611;
  18007. t['p'] = 611;
  18008. t['q'] = 611;
  18009. t['r'] = 389;
  18010. t['s'] = 556;
  18011. t['t'] = 333;
  18012. t['u'] = 611;
  18013. t['v'] = 556;
  18014. t['w'] = 778;
  18015. t['x'] = 556;
  18016. t['y'] = 556;
  18017. t['z'] = 500;
  18018. t['braceleft'] = 389;
  18019. t['bar'] = 280;
  18020. t['braceright'] = 389;
  18021. t['asciitilde'] = 584;
  18022. t['exclamdown'] = 333;
  18023. t['cent'] = 556;
  18024. t['sterling'] = 556;
  18025. t['fraction'] = 167;
  18026. t['yen'] = 556;
  18027. t['florin'] = 556;
  18028. t['section'] = 556;
  18029. t['currency'] = 556;
  18030. t['quotesingle'] = 238;
  18031. t['quotedblleft'] = 500;
  18032. t['guillemotleft'] = 556;
  18033. t['guilsinglleft'] = 333;
  18034. t['guilsinglright'] = 333;
  18035. t['fi'] = 611;
  18036. t['fl'] = 611;
  18037. t['endash'] = 556;
  18038. t['dagger'] = 556;
  18039. t['daggerdbl'] = 556;
  18040. t['periodcentered'] = 278;
  18041. t['paragraph'] = 556;
  18042. t['bullet'] = 350;
  18043. t['quotesinglbase'] = 278;
  18044. t['quotedblbase'] = 500;
  18045. t['quotedblright'] = 500;
  18046. t['guillemotright'] = 556;
  18047. t['ellipsis'] = 1000;
  18048. t['perthousand'] = 1000;
  18049. t['questiondown'] = 611;
  18050. t['grave'] = 333;
  18051. t['acute'] = 333;
  18052. t['circumflex'] = 333;
  18053. t['tilde'] = 333;
  18054. t['macron'] = 333;
  18055. t['breve'] = 333;
  18056. t['dotaccent'] = 333;
  18057. t['dieresis'] = 333;
  18058. t['ring'] = 333;
  18059. t['cedilla'] = 333;
  18060. t['hungarumlaut'] = 333;
  18061. t['ogonek'] = 333;
  18062. t['caron'] = 333;
  18063. t['emdash'] = 1000;
  18064. t['AE'] = 1000;
  18065. t['ordfeminine'] = 370;
  18066. t['Lslash'] = 611;
  18067. t['Oslash'] = 778;
  18068. t['OE'] = 1000;
  18069. t['ordmasculine'] = 365;
  18070. t['ae'] = 889;
  18071. t['dotlessi'] = 278;
  18072. t['lslash'] = 278;
  18073. t['oslash'] = 611;
  18074. t['oe'] = 944;
  18075. t['germandbls'] = 611;
  18076. t['Idieresis'] = 278;
  18077. t['eacute'] = 556;
  18078. t['abreve'] = 556;
  18079. t['uhungarumlaut'] = 611;
  18080. t['ecaron'] = 556;
  18081. t['Ydieresis'] = 667;
  18082. t['divide'] = 584;
  18083. t['Yacute'] = 667;
  18084. t['Acircumflex'] = 722;
  18085. t['aacute'] = 556;
  18086. t['Ucircumflex'] = 722;
  18087. t['yacute'] = 556;
  18088. t['scommaaccent'] = 556;
  18089. t['ecircumflex'] = 556;
  18090. t['Uring'] = 722;
  18091. t['Udieresis'] = 722;
  18092. t['aogonek'] = 556;
  18093. t['Uacute'] = 722;
  18094. t['uogonek'] = 611;
  18095. t['Edieresis'] = 667;
  18096. t['Dcroat'] = 722;
  18097. t['commaaccent'] = 250;
  18098. t['copyright'] = 737;
  18099. t['Emacron'] = 667;
  18100. t['ccaron'] = 556;
  18101. t['aring'] = 556;
  18102. t['Ncommaaccent'] = 722;
  18103. t['lacute'] = 278;
  18104. t['agrave'] = 556;
  18105. t['Tcommaaccent'] = 611;
  18106. t['Cacute'] = 722;
  18107. t['atilde'] = 556;
  18108. t['Edotaccent'] = 667;
  18109. t['scaron'] = 556;
  18110. t['scedilla'] = 556;
  18111. t['iacute'] = 278;
  18112. t['lozenge'] = 494;
  18113. t['Rcaron'] = 722;
  18114. t['Gcommaaccent'] = 778;
  18115. t['ucircumflex'] = 611;
  18116. t['acircumflex'] = 556;
  18117. t['Amacron'] = 722;
  18118. t['rcaron'] = 389;
  18119. t['ccedilla'] = 556;
  18120. t['Zdotaccent'] = 611;
  18121. t['Thorn'] = 667;
  18122. t['Omacron'] = 778;
  18123. t['Racute'] = 722;
  18124. t['Sacute'] = 667;
  18125. t['dcaron'] = 743;
  18126. t['Umacron'] = 722;
  18127. t['uring'] = 611;
  18128. t['threesuperior'] = 333;
  18129. t['Ograve'] = 778;
  18130. t['Agrave'] = 722;
  18131. t['Abreve'] = 722;
  18132. t['multiply'] = 584;
  18133. t['uacute'] = 611;
  18134. t['Tcaron'] = 611;
  18135. t['partialdiff'] = 494;
  18136. t['ydieresis'] = 556;
  18137. t['Nacute'] = 722;
  18138. t['icircumflex'] = 278;
  18139. t['Ecircumflex'] = 667;
  18140. t['adieresis'] = 556;
  18141. t['edieresis'] = 556;
  18142. t['cacute'] = 556;
  18143. t['nacute'] = 611;
  18144. t['umacron'] = 611;
  18145. t['Ncaron'] = 722;
  18146. t['Iacute'] = 278;
  18147. t['plusminus'] = 584;
  18148. t['brokenbar'] = 280;
  18149. t['registered'] = 737;
  18150. t['Gbreve'] = 778;
  18151. t['Idotaccent'] = 278;
  18152. t['summation'] = 600;
  18153. t['Egrave'] = 667;
  18154. t['racute'] = 389;
  18155. t['omacron'] = 611;
  18156. t['Zacute'] = 611;
  18157. t['Zcaron'] = 611;
  18158. t['greaterequal'] = 549;
  18159. t['Eth'] = 722;
  18160. t['Ccedilla'] = 722;
  18161. t['lcommaaccent'] = 278;
  18162. t['tcaron'] = 389;
  18163. t['eogonek'] = 556;
  18164. t['Uogonek'] = 722;
  18165. t['Aacute'] = 722;
  18166. t['Adieresis'] = 722;
  18167. t['egrave'] = 556;
  18168. t['zacute'] = 500;
  18169. t['iogonek'] = 278;
  18170. t['Oacute'] = 778;
  18171. t['oacute'] = 611;
  18172. t['amacron'] = 556;
  18173. t['sacute'] = 556;
  18174. t['idieresis'] = 278;
  18175. t['Ocircumflex'] = 778;
  18176. t['Ugrave'] = 722;
  18177. t['Delta'] = 612;
  18178. t['thorn'] = 611;
  18179. t['twosuperior'] = 333;
  18180. t['Odieresis'] = 778;
  18181. t['mu'] = 611;
  18182. t['igrave'] = 278;
  18183. t['ohungarumlaut'] = 611;
  18184. t['Eogonek'] = 667;
  18185. t['dcroat'] = 611;
  18186. t['threequarters'] = 834;
  18187. t['Scedilla'] = 667;
  18188. t['lcaron'] = 400;
  18189. t['Kcommaaccent'] = 722;
  18190. t['Lacute'] = 611;
  18191. t['trademark'] = 1000;
  18192. t['edotaccent'] = 556;
  18193. t['Igrave'] = 278;
  18194. t['Imacron'] = 278;
  18195. t['Lcaron'] = 611;
  18196. t['onehalf'] = 834;
  18197. t['lessequal'] = 549;
  18198. t['ocircumflex'] = 611;
  18199. t['ntilde'] = 611;
  18200. t['Uhungarumlaut'] = 722;
  18201. t['Eacute'] = 667;
  18202. t['emacron'] = 556;
  18203. t['gbreve'] = 611;
  18204. t['onequarter'] = 834;
  18205. t['Scaron'] = 667;
  18206. t['Scommaaccent'] = 667;
  18207. t['Ohungarumlaut'] = 778;
  18208. t['degree'] = 400;
  18209. t['ograve'] = 611;
  18210. t['Ccaron'] = 722;
  18211. t['ugrave'] = 611;
  18212. t['radical'] = 549;
  18213. t['Dcaron'] = 722;
  18214. t['rcommaaccent'] = 389;
  18215. t['Ntilde'] = 722;
  18216. t['otilde'] = 611;
  18217. t['Rcommaaccent'] = 722;
  18218. t['Lcommaaccent'] = 611;
  18219. t['Atilde'] = 722;
  18220. t['Aogonek'] = 722;
  18221. t['Aring'] = 722;
  18222. t['Otilde'] = 778;
  18223. t['zdotaccent'] = 500;
  18224. t['Ecaron'] = 667;
  18225. t['Iogonek'] = 278;
  18226. t['kcommaaccent'] = 556;
  18227. t['minus'] = 584;
  18228. t['Icircumflex'] = 278;
  18229. t['ncaron'] = 611;
  18230. t['tcommaaccent'] = 333;
  18231. t['logicalnot'] = 584;
  18232. t['odieresis'] = 611;
  18233. t['udieresis'] = 611;
  18234. t['notequal'] = 549;
  18235. t['gcommaaccent'] = 611;
  18236. t['eth'] = 611;
  18237. t['zcaron'] = 500;
  18238. t['ncommaaccent'] = 611;
  18239. t['onesuperior'] = 333;
  18240. t['imacron'] = 278;
  18241. t['Euro'] = 556;
  18242. });
  18243. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18244. t['space'] = 278;
  18245. t['exclam'] = 278;
  18246. t['quotedbl'] = 355;
  18247. t['numbersign'] = 556;
  18248. t['dollar'] = 556;
  18249. t['percent'] = 889;
  18250. t['ampersand'] = 667;
  18251. t['quoteright'] = 222;
  18252. t['parenleft'] = 333;
  18253. t['parenright'] = 333;
  18254. t['asterisk'] = 389;
  18255. t['plus'] = 584;
  18256. t['comma'] = 278;
  18257. t['hyphen'] = 333;
  18258. t['period'] = 278;
  18259. t['slash'] = 278;
  18260. t['zero'] = 556;
  18261. t['one'] = 556;
  18262. t['two'] = 556;
  18263. t['three'] = 556;
  18264. t['four'] = 556;
  18265. t['five'] = 556;
  18266. t['six'] = 556;
  18267. t['seven'] = 556;
  18268. t['eight'] = 556;
  18269. t['nine'] = 556;
  18270. t['colon'] = 278;
  18271. t['semicolon'] = 278;
  18272. t['less'] = 584;
  18273. t['equal'] = 584;
  18274. t['greater'] = 584;
  18275. t['question'] = 556;
  18276. t['at'] = 1015;
  18277. t['A'] = 667;
  18278. t['B'] = 667;
  18279. t['C'] = 722;
  18280. t['D'] = 722;
  18281. t['E'] = 667;
  18282. t['F'] = 611;
  18283. t['G'] = 778;
  18284. t['H'] = 722;
  18285. t['I'] = 278;
  18286. t['J'] = 500;
  18287. t['K'] = 667;
  18288. t['L'] = 556;
  18289. t['M'] = 833;
  18290. t['N'] = 722;
  18291. t['O'] = 778;
  18292. t['P'] = 667;
  18293. t['Q'] = 778;
  18294. t['R'] = 722;
  18295. t['S'] = 667;
  18296. t['T'] = 611;
  18297. t['U'] = 722;
  18298. t['V'] = 667;
  18299. t['W'] = 944;
  18300. t['X'] = 667;
  18301. t['Y'] = 667;
  18302. t['Z'] = 611;
  18303. t['bracketleft'] = 278;
  18304. t['backslash'] = 278;
  18305. t['bracketright'] = 278;
  18306. t['asciicircum'] = 469;
  18307. t['underscore'] = 556;
  18308. t['quoteleft'] = 222;
  18309. t['a'] = 556;
  18310. t['b'] = 556;
  18311. t['c'] = 500;
  18312. t['d'] = 556;
  18313. t['e'] = 556;
  18314. t['f'] = 278;
  18315. t['g'] = 556;
  18316. t['h'] = 556;
  18317. t['i'] = 222;
  18318. t['j'] = 222;
  18319. t['k'] = 500;
  18320. t['l'] = 222;
  18321. t['m'] = 833;
  18322. t['n'] = 556;
  18323. t['o'] = 556;
  18324. t['p'] = 556;
  18325. t['q'] = 556;
  18326. t['r'] = 333;
  18327. t['s'] = 500;
  18328. t['t'] = 278;
  18329. t['u'] = 556;
  18330. t['v'] = 500;
  18331. t['w'] = 722;
  18332. t['x'] = 500;
  18333. t['y'] = 500;
  18334. t['z'] = 500;
  18335. t['braceleft'] = 334;
  18336. t['bar'] = 260;
  18337. t['braceright'] = 334;
  18338. t['asciitilde'] = 584;
  18339. t['exclamdown'] = 333;
  18340. t['cent'] = 556;
  18341. t['sterling'] = 556;
  18342. t['fraction'] = 167;
  18343. t['yen'] = 556;
  18344. t['florin'] = 556;
  18345. t['section'] = 556;
  18346. t['currency'] = 556;
  18347. t['quotesingle'] = 191;
  18348. t['quotedblleft'] = 333;
  18349. t['guillemotleft'] = 556;
  18350. t['guilsinglleft'] = 333;
  18351. t['guilsinglright'] = 333;
  18352. t['fi'] = 500;
  18353. t['fl'] = 500;
  18354. t['endash'] = 556;
  18355. t['dagger'] = 556;
  18356. t['daggerdbl'] = 556;
  18357. t['periodcentered'] = 278;
  18358. t['paragraph'] = 537;
  18359. t['bullet'] = 350;
  18360. t['quotesinglbase'] = 222;
  18361. t['quotedblbase'] = 333;
  18362. t['quotedblright'] = 333;
  18363. t['guillemotright'] = 556;
  18364. t['ellipsis'] = 1000;
  18365. t['perthousand'] = 1000;
  18366. t['questiondown'] = 611;
  18367. t['grave'] = 333;
  18368. t['acute'] = 333;
  18369. t['circumflex'] = 333;
  18370. t['tilde'] = 333;
  18371. t['macron'] = 333;
  18372. t['breve'] = 333;
  18373. t['dotaccent'] = 333;
  18374. t['dieresis'] = 333;
  18375. t['ring'] = 333;
  18376. t['cedilla'] = 333;
  18377. t['hungarumlaut'] = 333;
  18378. t['ogonek'] = 333;
  18379. t['caron'] = 333;
  18380. t['emdash'] = 1000;
  18381. t['AE'] = 1000;
  18382. t['ordfeminine'] = 370;
  18383. t['Lslash'] = 556;
  18384. t['Oslash'] = 778;
  18385. t['OE'] = 1000;
  18386. t['ordmasculine'] = 365;
  18387. t['ae'] = 889;
  18388. t['dotlessi'] = 278;
  18389. t['lslash'] = 222;
  18390. t['oslash'] = 611;
  18391. t['oe'] = 944;
  18392. t['germandbls'] = 611;
  18393. t['Idieresis'] = 278;
  18394. t['eacute'] = 556;
  18395. t['abreve'] = 556;
  18396. t['uhungarumlaut'] = 556;
  18397. t['ecaron'] = 556;
  18398. t['Ydieresis'] = 667;
  18399. t['divide'] = 584;
  18400. t['Yacute'] = 667;
  18401. t['Acircumflex'] = 667;
  18402. t['aacute'] = 556;
  18403. t['Ucircumflex'] = 722;
  18404. t['yacute'] = 500;
  18405. t['scommaaccent'] = 500;
  18406. t['ecircumflex'] = 556;
  18407. t['Uring'] = 722;
  18408. t['Udieresis'] = 722;
  18409. t['aogonek'] = 556;
  18410. t['Uacute'] = 722;
  18411. t['uogonek'] = 556;
  18412. t['Edieresis'] = 667;
  18413. t['Dcroat'] = 722;
  18414. t['commaaccent'] = 250;
  18415. t['copyright'] = 737;
  18416. t['Emacron'] = 667;
  18417. t['ccaron'] = 500;
  18418. t['aring'] = 556;
  18419. t['Ncommaaccent'] = 722;
  18420. t['lacute'] = 222;
  18421. t['agrave'] = 556;
  18422. t['Tcommaaccent'] = 611;
  18423. t['Cacute'] = 722;
  18424. t['atilde'] = 556;
  18425. t['Edotaccent'] = 667;
  18426. t['scaron'] = 500;
  18427. t['scedilla'] = 500;
  18428. t['iacute'] = 278;
  18429. t['lozenge'] = 471;
  18430. t['Rcaron'] = 722;
  18431. t['Gcommaaccent'] = 778;
  18432. t['ucircumflex'] = 556;
  18433. t['acircumflex'] = 556;
  18434. t['Amacron'] = 667;
  18435. t['rcaron'] = 333;
  18436. t['ccedilla'] = 500;
  18437. t['Zdotaccent'] = 611;
  18438. t['Thorn'] = 667;
  18439. t['Omacron'] = 778;
  18440. t['Racute'] = 722;
  18441. t['Sacute'] = 667;
  18442. t['dcaron'] = 643;
  18443. t['Umacron'] = 722;
  18444. t['uring'] = 556;
  18445. t['threesuperior'] = 333;
  18446. t['Ograve'] = 778;
  18447. t['Agrave'] = 667;
  18448. t['Abreve'] = 667;
  18449. t['multiply'] = 584;
  18450. t['uacute'] = 556;
  18451. t['Tcaron'] = 611;
  18452. t['partialdiff'] = 476;
  18453. t['ydieresis'] = 500;
  18454. t['Nacute'] = 722;
  18455. t['icircumflex'] = 278;
  18456. t['Ecircumflex'] = 667;
  18457. t['adieresis'] = 556;
  18458. t['edieresis'] = 556;
  18459. t['cacute'] = 500;
  18460. t['nacute'] = 556;
  18461. t['umacron'] = 556;
  18462. t['Ncaron'] = 722;
  18463. t['Iacute'] = 278;
  18464. t['plusminus'] = 584;
  18465. t['brokenbar'] = 260;
  18466. t['registered'] = 737;
  18467. t['Gbreve'] = 778;
  18468. t['Idotaccent'] = 278;
  18469. t['summation'] = 600;
  18470. t['Egrave'] = 667;
  18471. t['racute'] = 333;
  18472. t['omacron'] = 556;
  18473. t['Zacute'] = 611;
  18474. t['Zcaron'] = 611;
  18475. t['greaterequal'] = 549;
  18476. t['Eth'] = 722;
  18477. t['Ccedilla'] = 722;
  18478. t['lcommaaccent'] = 222;
  18479. t['tcaron'] = 317;
  18480. t['eogonek'] = 556;
  18481. t['Uogonek'] = 722;
  18482. t['Aacute'] = 667;
  18483. t['Adieresis'] = 667;
  18484. t['egrave'] = 556;
  18485. t['zacute'] = 500;
  18486. t['iogonek'] = 222;
  18487. t['Oacute'] = 778;
  18488. t['oacute'] = 556;
  18489. t['amacron'] = 556;
  18490. t['sacute'] = 500;
  18491. t['idieresis'] = 278;
  18492. t['Ocircumflex'] = 778;
  18493. t['Ugrave'] = 722;
  18494. t['Delta'] = 612;
  18495. t['thorn'] = 556;
  18496. t['twosuperior'] = 333;
  18497. t['Odieresis'] = 778;
  18498. t['mu'] = 556;
  18499. t['igrave'] = 278;
  18500. t['ohungarumlaut'] = 556;
  18501. t['Eogonek'] = 667;
  18502. t['dcroat'] = 556;
  18503. t['threequarters'] = 834;
  18504. t['Scedilla'] = 667;
  18505. t['lcaron'] = 299;
  18506. t['Kcommaaccent'] = 667;
  18507. t['Lacute'] = 556;
  18508. t['trademark'] = 1000;
  18509. t['edotaccent'] = 556;
  18510. t['Igrave'] = 278;
  18511. t['Imacron'] = 278;
  18512. t['Lcaron'] = 556;
  18513. t['onehalf'] = 834;
  18514. t['lessequal'] = 549;
  18515. t['ocircumflex'] = 556;
  18516. t['ntilde'] = 556;
  18517. t['Uhungarumlaut'] = 722;
  18518. t['Eacute'] = 667;
  18519. t['emacron'] = 556;
  18520. t['gbreve'] = 556;
  18521. t['onequarter'] = 834;
  18522. t['Scaron'] = 667;
  18523. t['Scommaaccent'] = 667;
  18524. t['Ohungarumlaut'] = 778;
  18525. t['degree'] = 400;
  18526. t['ograve'] = 556;
  18527. t['Ccaron'] = 722;
  18528. t['ugrave'] = 556;
  18529. t['radical'] = 453;
  18530. t['Dcaron'] = 722;
  18531. t['rcommaaccent'] = 333;
  18532. t['Ntilde'] = 722;
  18533. t['otilde'] = 556;
  18534. t['Rcommaaccent'] = 722;
  18535. t['Lcommaaccent'] = 556;
  18536. t['Atilde'] = 667;
  18537. t['Aogonek'] = 667;
  18538. t['Aring'] = 667;
  18539. t['Otilde'] = 778;
  18540. t['zdotaccent'] = 500;
  18541. t['Ecaron'] = 667;
  18542. t['Iogonek'] = 278;
  18543. t['kcommaaccent'] = 500;
  18544. t['minus'] = 584;
  18545. t['Icircumflex'] = 278;
  18546. t['ncaron'] = 556;
  18547. t['tcommaaccent'] = 278;
  18548. t['logicalnot'] = 584;
  18549. t['odieresis'] = 556;
  18550. t['udieresis'] = 556;
  18551. t['notequal'] = 549;
  18552. t['gcommaaccent'] = 556;
  18553. t['eth'] = 556;
  18554. t['zcaron'] = 500;
  18555. t['ncommaaccent'] = 556;
  18556. t['onesuperior'] = 333;
  18557. t['imacron'] = 278;
  18558. t['Euro'] = 556;
  18559. });
  18560. t['Symbol'] = getLookupTableFactory(function (t) {
  18561. t['space'] = 250;
  18562. t['exclam'] = 333;
  18563. t['universal'] = 713;
  18564. t['numbersign'] = 500;
  18565. t['existential'] = 549;
  18566. t['percent'] = 833;
  18567. t['ampersand'] = 778;
  18568. t['suchthat'] = 439;
  18569. t['parenleft'] = 333;
  18570. t['parenright'] = 333;
  18571. t['asteriskmath'] = 500;
  18572. t['plus'] = 549;
  18573. t['comma'] = 250;
  18574. t['minus'] = 549;
  18575. t['period'] = 250;
  18576. t['slash'] = 278;
  18577. t['zero'] = 500;
  18578. t['one'] = 500;
  18579. t['two'] = 500;
  18580. t['three'] = 500;
  18581. t['four'] = 500;
  18582. t['five'] = 500;
  18583. t['six'] = 500;
  18584. t['seven'] = 500;
  18585. t['eight'] = 500;
  18586. t['nine'] = 500;
  18587. t['colon'] = 278;
  18588. t['semicolon'] = 278;
  18589. t['less'] = 549;
  18590. t['equal'] = 549;
  18591. t['greater'] = 549;
  18592. t['question'] = 444;
  18593. t['congruent'] = 549;
  18594. t['Alpha'] = 722;
  18595. t['Beta'] = 667;
  18596. t['Chi'] = 722;
  18597. t['Delta'] = 612;
  18598. t['Epsilon'] = 611;
  18599. t['Phi'] = 763;
  18600. t['Gamma'] = 603;
  18601. t['Eta'] = 722;
  18602. t['Iota'] = 333;
  18603. t['theta1'] = 631;
  18604. t['Kappa'] = 722;
  18605. t['Lambda'] = 686;
  18606. t['Mu'] = 889;
  18607. t['Nu'] = 722;
  18608. t['Omicron'] = 722;
  18609. t['Pi'] = 768;
  18610. t['Theta'] = 741;
  18611. t['Rho'] = 556;
  18612. t['Sigma'] = 592;
  18613. t['Tau'] = 611;
  18614. t['Upsilon'] = 690;
  18615. t['sigma1'] = 439;
  18616. t['Omega'] = 768;
  18617. t['Xi'] = 645;
  18618. t['Psi'] = 795;
  18619. t['Zeta'] = 611;
  18620. t['bracketleft'] = 333;
  18621. t['therefore'] = 863;
  18622. t['bracketright'] = 333;
  18623. t['perpendicular'] = 658;
  18624. t['underscore'] = 500;
  18625. t['radicalex'] = 500;
  18626. t['alpha'] = 631;
  18627. t['beta'] = 549;
  18628. t['chi'] = 549;
  18629. t['delta'] = 494;
  18630. t['epsilon'] = 439;
  18631. t['phi'] = 521;
  18632. t['gamma'] = 411;
  18633. t['eta'] = 603;
  18634. t['iota'] = 329;
  18635. t['phi1'] = 603;
  18636. t['kappa'] = 549;
  18637. t['lambda'] = 549;
  18638. t['mu'] = 576;
  18639. t['nu'] = 521;
  18640. t['omicron'] = 549;
  18641. t['pi'] = 549;
  18642. t['theta'] = 521;
  18643. t['rho'] = 549;
  18644. t['sigma'] = 603;
  18645. t['tau'] = 439;
  18646. t['upsilon'] = 576;
  18647. t['omega1'] = 713;
  18648. t['omega'] = 686;
  18649. t['xi'] = 493;
  18650. t['psi'] = 686;
  18651. t['zeta'] = 494;
  18652. t['braceleft'] = 480;
  18653. t['bar'] = 200;
  18654. t['braceright'] = 480;
  18655. t['similar'] = 549;
  18656. t['Euro'] = 750;
  18657. t['Upsilon1'] = 620;
  18658. t['minute'] = 247;
  18659. t['lessequal'] = 549;
  18660. t['fraction'] = 167;
  18661. t['infinity'] = 713;
  18662. t['florin'] = 500;
  18663. t['club'] = 753;
  18664. t['diamond'] = 753;
  18665. t['heart'] = 753;
  18666. t['spade'] = 753;
  18667. t['arrowboth'] = 1042;
  18668. t['arrowleft'] = 987;
  18669. t['arrowup'] = 603;
  18670. t['arrowright'] = 987;
  18671. t['arrowdown'] = 603;
  18672. t['degree'] = 400;
  18673. t['plusminus'] = 549;
  18674. t['second'] = 411;
  18675. t['greaterequal'] = 549;
  18676. t['multiply'] = 549;
  18677. t['proportional'] = 713;
  18678. t['partialdiff'] = 494;
  18679. t['bullet'] = 460;
  18680. t['divide'] = 549;
  18681. t['notequal'] = 549;
  18682. t['equivalence'] = 549;
  18683. t['approxequal'] = 549;
  18684. t['ellipsis'] = 1000;
  18685. t['arrowvertex'] = 603;
  18686. t['arrowhorizex'] = 1000;
  18687. t['carriagereturn'] = 658;
  18688. t['aleph'] = 823;
  18689. t['Ifraktur'] = 686;
  18690. t['Rfraktur'] = 795;
  18691. t['weierstrass'] = 987;
  18692. t['circlemultiply'] = 768;
  18693. t['circleplus'] = 768;
  18694. t['emptyset'] = 823;
  18695. t['intersection'] = 768;
  18696. t['union'] = 768;
  18697. t['propersuperset'] = 713;
  18698. t['reflexsuperset'] = 713;
  18699. t['notsubset'] = 713;
  18700. t['propersubset'] = 713;
  18701. t['reflexsubset'] = 713;
  18702. t['element'] = 713;
  18703. t['notelement'] = 713;
  18704. t['angle'] = 768;
  18705. t['gradient'] = 713;
  18706. t['registerserif'] = 790;
  18707. t['copyrightserif'] = 790;
  18708. t['trademarkserif'] = 890;
  18709. t['product'] = 823;
  18710. t['radical'] = 549;
  18711. t['dotmath'] = 250;
  18712. t['logicalnot'] = 713;
  18713. t['logicaland'] = 603;
  18714. t['logicalor'] = 603;
  18715. t['arrowdblboth'] = 1042;
  18716. t['arrowdblleft'] = 987;
  18717. t['arrowdblup'] = 603;
  18718. t['arrowdblright'] = 987;
  18719. t['arrowdbldown'] = 603;
  18720. t['lozenge'] = 494;
  18721. t['angleleft'] = 329;
  18722. t['registersans'] = 790;
  18723. t['copyrightsans'] = 790;
  18724. t['trademarksans'] = 786;
  18725. t['summation'] = 713;
  18726. t['parenlefttp'] = 384;
  18727. t['parenleftex'] = 384;
  18728. t['parenleftbt'] = 384;
  18729. t['bracketlefttp'] = 384;
  18730. t['bracketleftex'] = 384;
  18731. t['bracketleftbt'] = 384;
  18732. t['bracelefttp'] = 494;
  18733. t['braceleftmid'] = 494;
  18734. t['braceleftbt'] = 494;
  18735. t['braceex'] = 494;
  18736. t['angleright'] = 329;
  18737. t['integral'] = 274;
  18738. t['integraltp'] = 686;
  18739. t['integralex'] = 686;
  18740. t['integralbt'] = 686;
  18741. t['parenrighttp'] = 384;
  18742. t['parenrightex'] = 384;
  18743. t['parenrightbt'] = 384;
  18744. t['bracketrighttp'] = 384;
  18745. t['bracketrightex'] = 384;
  18746. t['bracketrightbt'] = 384;
  18747. t['bracerighttp'] = 494;
  18748. t['bracerightmid'] = 494;
  18749. t['bracerightbt'] = 494;
  18750. t['apple'] = 790;
  18751. });
  18752. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18753. t['space'] = 250;
  18754. t['exclam'] = 333;
  18755. t['quotedbl'] = 408;
  18756. t['numbersign'] = 500;
  18757. t['dollar'] = 500;
  18758. t['percent'] = 833;
  18759. t['ampersand'] = 778;
  18760. t['quoteright'] = 333;
  18761. t['parenleft'] = 333;
  18762. t['parenright'] = 333;
  18763. t['asterisk'] = 500;
  18764. t['plus'] = 564;
  18765. t['comma'] = 250;
  18766. t['hyphen'] = 333;
  18767. t['period'] = 250;
  18768. t['slash'] = 278;
  18769. t['zero'] = 500;
  18770. t['one'] = 500;
  18771. t['two'] = 500;
  18772. t['three'] = 500;
  18773. t['four'] = 500;
  18774. t['five'] = 500;
  18775. t['six'] = 500;
  18776. t['seven'] = 500;
  18777. t['eight'] = 500;
  18778. t['nine'] = 500;
  18779. t['colon'] = 278;
  18780. t['semicolon'] = 278;
  18781. t['less'] = 564;
  18782. t['equal'] = 564;
  18783. t['greater'] = 564;
  18784. t['question'] = 444;
  18785. t['at'] = 921;
  18786. t['A'] = 722;
  18787. t['B'] = 667;
  18788. t['C'] = 667;
  18789. t['D'] = 722;
  18790. t['E'] = 611;
  18791. t['F'] = 556;
  18792. t['G'] = 722;
  18793. t['H'] = 722;
  18794. t['I'] = 333;
  18795. t['J'] = 389;
  18796. t['K'] = 722;
  18797. t['L'] = 611;
  18798. t['M'] = 889;
  18799. t['N'] = 722;
  18800. t['O'] = 722;
  18801. t['P'] = 556;
  18802. t['Q'] = 722;
  18803. t['R'] = 667;
  18804. t['S'] = 556;
  18805. t['T'] = 611;
  18806. t['U'] = 722;
  18807. t['V'] = 722;
  18808. t['W'] = 944;
  18809. t['X'] = 722;
  18810. t['Y'] = 722;
  18811. t['Z'] = 611;
  18812. t['bracketleft'] = 333;
  18813. t['backslash'] = 278;
  18814. t['bracketright'] = 333;
  18815. t['asciicircum'] = 469;
  18816. t['underscore'] = 500;
  18817. t['quoteleft'] = 333;
  18818. t['a'] = 444;
  18819. t['b'] = 500;
  18820. t['c'] = 444;
  18821. t['d'] = 500;
  18822. t['e'] = 444;
  18823. t['f'] = 333;
  18824. t['g'] = 500;
  18825. t['h'] = 500;
  18826. t['i'] = 278;
  18827. t['j'] = 278;
  18828. t['k'] = 500;
  18829. t['l'] = 278;
  18830. t['m'] = 778;
  18831. t['n'] = 500;
  18832. t['o'] = 500;
  18833. t['p'] = 500;
  18834. t['q'] = 500;
  18835. t['r'] = 333;
  18836. t['s'] = 389;
  18837. t['t'] = 278;
  18838. t['u'] = 500;
  18839. t['v'] = 500;
  18840. t['w'] = 722;
  18841. t['x'] = 500;
  18842. t['y'] = 500;
  18843. t['z'] = 444;
  18844. t['braceleft'] = 480;
  18845. t['bar'] = 200;
  18846. t['braceright'] = 480;
  18847. t['asciitilde'] = 541;
  18848. t['exclamdown'] = 333;
  18849. t['cent'] = 500;
  18850. t['sterling'] = 500;
  18851. t['fraction'] = 167;
  18852. t['yen'] = 500;
  18853. t['florin'] = 500;
  18854. t['section'] = 500;
  18855. t['currency'] = 500;
  18856. t['quotesingle'] = 180;
  18857. t['quotedblleft'] = 444;
  18858. t['guillemotleft'] = 500;
  18859. t['guilsinglleft'] = 333;
  18860. t['guilsinglright'] = 333;
  18861. t['fi'] = 556;
  18862. t['fl'] = 556;
  18863. t['endash'] = 500;
  18864. t['dagger'] = 500;
  18865. t['daggerdbl'] = 500;
  18866. t['periodcentered'] = 250;
  18867. t['paragraph'] = 453;
  18868. t['bullet'] = 350;
  18869. t['quotesinglbase'] = 333;
  18870. t['quotedblbase'] = 444;
  18871. t['quotedblright'] = 444;
  18872. t['guillemotright'] = 500;
  18873. t['ellipsis'] = 1000;
  18874. t['perthousand'] = 1000;
  18875. t['questiondown'] = 444;
  18876. t['grave'] = 333;
  18877. t['acute'] = 333;
  18878. t['circumflex'] = 333;
  18879. t['tilde'] = 333;
  18880. t['macron'] = 333;
  18881. t['breve'] = 333;
  18882. t['dotaccent'] = 333;
  18883. t['dieresis'] = 333;
  18884. t['ring'] = 333;
  18885. t['cedilla'] = 333;
  18886. t['hungarumlaut'] = 333;
  18887. t['ogonek'] = 333;
  18888. t['caron'] = 333;
  18889. t['emdash'] = 1000;
  18890. t['AE'] = 889;
  18891. t['ordfeminine'] = 276;
  18892. t['Lslash'] = 611;
  18893. t['Oslash'] = 722;
  18894. t['OE'] = 889;
  18895. t['ordmasculine'] = 310;
  18896. t['ae'] = 667;
  18897. t['dotlessi'] = 278;
  18898. t['lslash'] = 278;
  18899. t['oslash'] = 500;
  18900. t['oe'] = 722;
  18901. t['germandbls'] = 500;
  18902. t['Idieresis'] = 333;
  18903. t['eacute'] = 444;
  18904. t['abreve'] = 444;
  18905. t['uhungarumlaut'] = 500;
  18906. t['ecaron'] = 444;
  18907. t['Ydieresis'] = 722;
  18908. t['divide'] = 564;
  18909. t['Yacute'] = 722;
  18910. t['Acircumflex'] = 722;
  18911. t['aacute'] = 444;
  18912. t['Ucircumflex'] = 722;
  18913. t['yacute'] = 500;
  18914. t['scommaaccent'] = 389;
  18915. t['ecircumflex'] = 444;
  18916. t['Uring'] = 722;
  18917. t['Udieresis'] = 722;
  18918. t['aogonek'] = 444;
  18919. t['Uacute'] = 722;
  18920. t['uogonek'] = 500;
  18921. t['Edieresis'] = 611;
  18922. t['Dcroat'] = 722;
  18923. t['commaaccent'] = 250;
  18924. t['copyright'] = 760;
  18925. t['Emacron'] = 611;
  18926. t['ccaron'] = 444;
  18927. t['aring'] = 444;
  18928. t['Ncommaaccent'] = 722;
  18929. t['lacute'] = 278;
  18930. t['agrave'] = 444;
  18931. t['Tcommaaccent'] = 611;
  18932. t['Cacute'] = 667;
  18933. t['atilde'] = 444;
  18934. t['Edotaccent'] = 611;
  18935. t['scaron'] = 389;
  18936. t['scedilla'] = 389;
  18937. t['iacute'] = 278;
  18938. t['lozenge'] = 471;
  18939. t['Rcaron'] = 667;
  18940. t['Gcommaaccent'] = 722;
  18941. t['ucircumflex'] = 500;
  18942. t['acircumflex'] = 444;
  18943. t['Amacron'] = 722;
  18944. t['rcaron'] = 333;
  18945. t['ccedilla'] = 444;
  18946. t['Zdotaccent'] = 611;
  18947. t['Thorn'] = 556;
  18948. t['Omacron'] = 722;
  18949. t['Racute'] = 667;
  18950. t['Sacute'] = 556;
  18951. t['dcaron'] = 588;
  18952. t['Umacron'] = 722;
  18953. t['uring'] = 500;
  18954. t['threesuperior'] = 300;
  18955. t['Ograve'] = 722;
  18956. t['Agrave'] = 722;
  18957. t['Abreve'] = 722;
  18958. t['multiply'] = 564;
  18959. t['uacute'] = 500;
  18960. t['Tcaron'] = 611;
  18961. t['partialdiff'] = 476;
  18962. t['ydieresis'] = 500;
  18963. t['Nacute'] = 722;
  18964. t['icircumflex'] = 278;
  18965. t['Ecircumflex'] = 611;
  18966. t['adieresis'] = 444;
  18967. t['edieresis'] = 444;
  18968. t['cacute'] = 444;
  18969. t['nacute'] = 500;
  18970. t['umacron'] = 500;
  18971. t['Ncaron'] = 722;
  18972. t['Iacute'] = 333;
  18973. t['plusminus'] = 564;
  18974. t['brokenbar'] = 200;
  18975. t['registered'] = 760;
  18976. t['Gbreve'] = 722;
  18977. t['Idotaccent'] = 333;
  18978. t['summation'] = 600;
  18979. t['Egrave'] = 611;
  18980. t['racute'] = 333;
  18981. t['omacron'] = 500;
  18982. t['Zacute'] = 611;
  18983. t['Zcaron'] = 611;
  18984. t['greaterequal'] = 549;
  18985. t['Eth'] = 722;
  18986. t['Ccedilla'] = 667;
  18987. t['lcommaaccent'] = 278;
  18988. t['tcaron'] = 326;
  18989. t['eogonek'] = 444;
  18990. t['Uogonek'] = 722;
  18991. t['Aacute'] = 722;
  18992. t['Adieresis'] = 722;
  18993. t['egrave'] = 444;
  18994. t['zacute'] = 444;
  18995. t['iogonek'] = 278;
  18996. t['Oacute'] = 722;
  18997. t['oacute'] = 500;
  18998. t['amacron'] = 444;
  18999. t['sacute'] = 389;
  19000. t['idieresis'] = 278;
  19001. t['Ocircumflex'] = 722;
  19002. t['Ugrave'] = 722;
  19003. t['Delta'] = 612;
  19004. t['thorn'] = 500;
  19005. t['twosuperior'] = 300;
  19006. t['Odieresis'] = 722;
  19007. t['mu'] = 500;
  19008. t['igrave'] = 278;
  19009. t['ohungarumlaut'] = 500;
  19010. t['Eogonek'] = 611;
  19011. t['dcroat'] = 500;
  19012. t['threequarters'] = 750;
  19013. t['Scedilla'] = 556;
  19014. t['lcaron'] = 344;
  19015. t['Kcommaaccent'] = 722;
  19016. t['Lacute'] = 611;
  19017. t['trademark'] = 980;
  19018. t['edotaccent'] = 444;
  19019. t['Igrave'] = 333;
  19020. t['Imacron'] = 333;
  19021. t['Lcaron'] = 611;
  19022. t['onehalf'] = 750;
  19023. t['lessequal'] = 549;
  19024. t['ocircumflex'] = 500;
  19025. t['ntilde'] = 500;
  19026. t['Uhungarumlaut'] = 722;
  19027. t['Eacute'] = 611;
  19028. t['emacron'] = 444;
  19029. t['gbreve'] = 500;
  19030. t['onequarter'] = 750;
  19031. t['Scaron'] = 556;
  19032. t['Scommaaccent'] = 556;
  19033. t['Ohungarumlaut'] = 722;
  19034. t['degree'] = 400;
  19035. t['ograve'] = 500;
  19036. t['Ccaron'] = 667;
  19037. t['ugrave'] = 500;
  19038. t['radical'] = 453;
  19039. t['Dcaron'] = 722;
  19040. t['rcommaaccent'] = 333;
  19041. t['Ntilde'] = 722;
  19042. t['otilde'] = 500;
  19043. t['Rcommaaccent'] = 667;
  19044. t['Lcommaaccent'] = 611;
  19045. t['Atilde'] = 722;
  19046. t['Aogonek'] = 722;
  19047. t['Aring'] = 722;
  19048. t['Otilde'] = 722;
  19049. t['zdotaccent'] = 444;
  19050. t['Ecaron'] = 611;
  19051. t['Iogonek'] = 333;
  19052. t['kcommaaccent'] = 500;
  19053. t['minus'] = 564;
  19054. t['Icircumflex'] = 333;
  19055. t['ncaron'] = 500;
  19056. t['tcommaaccent'] = 278;
  19057. t['logicalnot'] = 564;
  19058. t['odieresis'] = 500;
  19059. t['udieresis'] = 500;
  19060. t['notequal'] = 549;
  19061. t['gcommaaccent'] = 500;
  19062. t['eth'] = 500;
  19063. t['zcaron'] = 444;
  19064. t['ncommaaccent'] = 500;
  19065. t['onesuperior'] = 300;
  19066. t['imacron'] = 278;
  19067. t['Euro'] = 500;
  19068. });
  19069. t['Times-Bold'] = getLookupTableFactory(function (t) {
  19070. t['space'] = 250;
  19071. t['exclam'] = 333;
  19072. t['quotedbl'] = 555;
  19073. t['numbersign'] = 500;
  19074. t['dollar'] = 500;
  19075. t['percent'] = 1000;
  19076. t['ampersand'] = 833;
  19077. t['quoteright'] = 333;
  19078. t['parenleft'] = 333;
  19079. t['parenright'] = 333;
  19080. t['asterisk'] = 500;
  19081. t['plus'] = 570;
  19082. t['comma'] = 250;
  19083. t['hyphen'] = 333;
  19084. t['period'] = 250;
  19085. t['slash'] = 278;
  19086. t['zero'] = 500;
  19087. t['one'] = 500;
  19088. t['two'] = 500;
  19089. t['three'] = 500;
  19090. t['four'] = 500;
  19091. t['five'] = 500;
  19092. t['six'] = 500;
  19093. t['seven'] = 500;
  19094. t['eight'] = 500;
  19095. t['nine'] = 500;
  19096. t['colon'] = 333;
  19097. t['semicolon'] = 333;
  19098. t['less'] = 570;
  19099. t['equal'] = 570;
  19100. t['greater'] = 570;
  19101. t['question'] = 500;
  19102. t['at'] = 930;
  19103. t['A'] = 722;
  19104. t['B'] = 667;
  19105. t['C'] = 722;
  19106. t['D'] = 722;
  19107. t['E'] = 667;
  19108. t['F'] = 611;
  19109. t['G'] = 778;
  19110. t['H'] = 778;
  19111. t['I'] = 389;
  19112. t['J'] = 500;
  19113. t['K'] = 778;
  19114. t['L'] = 667;
  19115. t['M'] = 944;
  19116. t['N'] = 722;
  19117. t['O'] = 778;
  19118. t['P'] = 611;
  19119. t['Q'] = 778;
  19120. t['R'] = 722;
  19121. t['S'] = 556;
  19122. t['T'] = 667;
  19123. t['U'] = 722;
  19124. t['V'] = 722;
  19125. t['W'] = 1000;
  19126. t['X'] = 722;
  19127. t['Y'] = 722;
  19128. t['Z'] = 667;
  19129. t['bracketleft'] = 333;
  19130. t['backslash'] = 278;
  19131. t['bracketright'] = 333;
  19132. t['asciicircum'] = 581;
  19133. t['underscore'] = 500;
  19134. t['quoteleft'] = 333;
  19135. t['a'] = 500;
  19136. t['b'] = 556;
  19137. t['c'] = 444;
  19138. t['d'] = 556;
  19139. t['e'] = 444;
  19140. t['f'] = 333;
  19141. t['g'] = 500;
  19142. t['h'] = 556;
  19143. t['i'] = 278;
  19144. t['j'] = 333;
  19145. t['k'] = 556;
  19146. t['l'] = 278;
  19147. t['m'] = 833;
  19148. t['n'] = 556;
  19149. t['o'] = 500;
  19150. t['p'] = 556;
  19151. t['q'] = 556;
  19152. t['r'] = 444;
  19153. t['s'] = 389;
  19154. t['t'] = 333;
  19155. t['u'] = 556;
  19156. t['v'] = 500;
  19157. t['w'] = 722;
  19158. t['x'] = 500;
  19159. t['y'] = 500;
  19160. t['z'] = 444;
  19161. t['braceleft'] = 394;
  19162. t['bar'] = 220;
  19163. t['braceright'] = 394;
  19164. t['asciitilde'] = 520;
  19165. t['exclamdown'] = 333;
  19166. t['cent'] = 500;
  19167. t['sterling'] = 500;
  19168. t['fraction'] = 167;
  19169. t['yen'] = 500;
  19170. t['florin'] = 500;
  19171. t['section'] = 500;
  19172. t['currency'] = 500;
  19173. t['quotesingle'] = 278;
  19174. t['quotedblleft'] = 500;
  19175. t['guillemotleft'] = 500;
  19176. t['guilsinglleft'] = 333;
  19177. t['guilsinglright'] = 333;
  19178. t['fi'] = 556;
  19179. t['fl'] = 556;
  19180. t['endash'] = 500;
  19181. t['dagger'] = 500;
  19182. t['daggerdbl'] = 500;
  19183. t['periodcentered'] = 250;
  19184. t['paragraph'] = 540;
  19185. t['bullet'] = 350;
  19186. t['quotesinglbase'] = 333;
  19187. t['quotedblbase'] = 500;
  19188. t['quotedblright'] = 500;
  19189. t['guillemotright'] = 500;
  19190. t['ellipsis'] = 1000;
  19191. t['perthousand'] = 1000;
  19192. t['questiondown'] = 500;
  19193. t['grave'] = 333;
  19194. t['acute'] = 333;
  19195. t['circumflex'] = 333;
  19196. t['tilde'] = 333;
  19197. t['macron'] = 333;
  19198. t['breve'] = 333;
  19199. t['dotaccent'] = 333;
  19200. t['dieresis'] = 333;
  19201. t['ring'] = 333;
  19202. t['cedilla'] = 333;
  19203. t['hungarumlaut'] = 333;
  19204. t['ogonek'] = 333;
  19205. t['caron'] = 333;
  19206. t['emdash'] = 1000;
  19207. t['AE'] = 1000;
  19208. t['ordfeminine'] = 300;
  19209. t['Lslash'] = 667;
  19210. t['Oslash'] = 778;
  19211. t['OE'] = 1000;
  19212. t['ordmasculine'] = 330;
  19213. t['ae'] = 722;
  19214. t['dotlessi'] = 278;
  19215. t['lslash'] = 278;
  19216. t['oslash'] = 500;
  19217. t['oe'] = 722;
  19218. t['germandbls'] = 556;
  19219. t['Idieresis'] = 389;
  19220. t['eacute'] = 444;
  19221. t['abreve'] = 500;
  19222. t['uhungarumlaut'] = 556;
  19223. t['ecaron'] = 444;
  19224. t['Ydieresis'] = 722;
  19225. t['divide'] = 570;
  19226. t['Yacute'] = 722;
  19227. t['Acircumflex'] = 722;
  19228. t['aacute'] = 500;
  19229. t['Ucircumflex'] = 722;
  19230. t['yacute'] = 500;
  19231. t['scommaaccent'] = 389;
  19232. t['ecircumflex'] = 444;
  19233. t['Uring'] = 722;
  19234. t['Udieresis'] = 722;
  19235. t['aogonek'] = 500;
  19236. t['Uacute'] = 722;
  19237. t['uogonek'] = 556;
  19238. t['Edieresis'] = 667;
  19239. t['Dcroat'] = 722;
  19240. t['commaaccent'] = 250;
  19241. t['copyright'] = 747;
  19242. t['Emacron'] = 667;
  19243. t['ccaron'] = 444;
  19244. t['aring'] = 500;
  19245. t['Ncommaaccent'] = 722;
  19246. t['lacute'] = 278;
  19247. t['agrave'] = 500;
  19248. t['Tcommaaccent'] = 667;
  19249. t['Cacute'] = 722;
  19250. t['atilde'] = 500;
  19251. t['Edotaccent'] = 667;
  19252. t['scaron'] = 389;
  19253. t['scedilla'] = 389;
  19254. t['iacute'] = 278;
  19255. t['lozenge'] = 494;
  19256. t['Rcaron'] = 722;
  19257. t['Gcommaaccent'] = 778;
  19258. t['ucircumflex'] = 556;
  19259. t['acircumflex'] = 500;
  19260. t['Amacron'] = 722;
  19261. t['rcaron'] = 444;
  19262. t['ccedilla'] = 444;
  19263. t['Zdotaccent'] = 667;
  19264. t['Thorn'] = 611;
  19265. t['Omacron'] = 778;
  19266. t['Racute'] = 722;
  19267. t['Sacute'] = 556;
  19268. t['dcaron'] = 672;
  19269. t['Umacron'] = 722;
  19270. t['uring'] = 556;
  19271. t['threesuperior'] = 300;
  19272. t['Ograve'] = 778;
  19273. t['Agrave'] = 722;
  19274. t['Abreve'] = 722;
  19275. t['multiply'] = 570;
  19276. t['uacute'] = 556;
  19277. t['Tcaron'] = 667;
  19278. t['partialdiff'] = 494;
  19279. t['ydieresis'] = 500;
  19280. t['Nacute'] = 722;
  19281. t['icircumflex'] = 278;
  19282. t['Ecircumflex'] = 667;
  19283. t['adieresis'] = 500;
  19284. t['edieresis'] = 444;
  19285. t['cacute'] = 444;
  19286. t['nacute'] = 556;
  19287. t['umacron'] = 556;
  19288. t['Ncaron'] = 722;
  19289. t['Iacute'] = 389;
  19290. t['plusminus'] = 570;
  19291. t['brokenbar'] = 220;
  19292. t['registered'] = 747;
  19293. t['Gbreve'] = 778;
  19294. t['Idotaccent'] = 389;
  19295. t['summation'] = 600;
  19296. t['Egrave'] = 667;
  19297. t['racute'] = 444;
  19298. t['omacron'] = 500;
  19299. t['Zacute'] = 667;
  19300. t['Zcaron'] = 667;
  19301. t['greaterequal'] = 549;
  19302. t['Eth'] = 722;
  19303. t['Ccedilla'] = 722;
  19304. t['lcommaaccent'] = 278;
  19305. t['tcaron'] = 416;
  19306. t['eogonek'] = 444;
  19307. t['Uogonek'] = 722;
  19308. t['Aacute'] = 722;
  19309. t['Adieresis'] = 722;
  19310. t['egrave'] = 444;
  19311. t['zacute'] = 444;
  19312. t['iogonek'] = 278;
  19313. t['Oacute'] = 778;
  19314. t['oacute'] = 500;
  19315. t['amacron'] = 500;
  19316. t['sacute'] = 389;
  19317. t['idieresis'] = 278;
  19318. t['Ocircumflex'] = 778;
  19319. t['Ugrave'] = 722;
  19320. t['Delta'] = 612;
  19321. t['thorn'] = 556;
  19322. t['twosuperior'] = 300;
  19323. t['Odieresis'] = 778;
  19324. t['mu'] = 556;
  19325. t['igrave'] = 278;
  19326. t['ohungarumlaut'] = 500;
  19327. t['Eogonek'] = 667;
  19328. t['dcroat'] = 556;
  19329. t['threequarters'] = 750;
  19330. t['Scedilla'] = 556;
  19331. t['lcaron'] = 394;
  19332. t['Kcommaaccent'] = 778;
  19333. t['Lacute'] = 667;
  19334. t['trademark'] = 1000;
  19335. t['edotaccent'] = 444;
  19336. t['Igrave'] = 389;
  19337. t['Imacron'] = 389;
  19338. t['Lcaron'] = 667;
  19339. t['onehalf'] = 750;
  19340. t['lessequal'] = 549;
  19341. t['ocircumflex'] = 500;
  19342. t['ntilde'] = 556;
  19343. t['Uhungarumlaut'] = 722;
  19344. t['Eacute'] = 667;
  19345. t['emacron'] = 444;
  19346. t['gbreve'] = 500;
  19347. t['onequarter'] = 750;
  19348. t['Scaron'] = 556;
  19349. t['Scommaaccent'] = 556;
  19350. t['Ohungarumlaut'] = 778;
  19351. t['degree'] = 400;
  19352. t['ograve'] = 500;
  19353. t['Ccaron'] = 722;
  19354. t['ugrave'] = 556;
  19355. t['radical'] = 549;
  19356. t['Dcaron'] = 722;
  19357. t['rcommaaccent'] = 444;
  19358. t['Ntilde'] = 722;
  19359. t['otilde'] = 500;
  19360. t['Rcommaaccent'] = 722;
  19361. t['Lcommaaccent'] = 667;
  19362. t['Atilde'] = 722;
  19363. t['Aogonek'] = 722;
  19364. t['Aring'] = 722;
  19365. t['Otilde'] = 778;
  19366. t['zdotaccent'] = 444;
  19367. t['Ecaron'] = 667;
  19368. t['Iogonek'] = 389;
  19369. t['kcommaaccent'] = 556;
  19370. t['minus'] = 570;
  19371. t['Icircumflex'] = 389;
  19372. t['ncaron'] = 556;
  19373. t['tcommaaccent'] = 333;
  19374. t['logicalnot'] = 570;
  19375. t['odieresis'] = 500;
  19376. t['udieresis'] = 556;
  19377. t['notequal'] = 549;
  19378. t['gcommaaccent'] = 500;
  19379. t['eth'] = 500;
  19380. t['zcaron'] = 444;
  19381. t['ncommaaccent'] = 556;
  19382. t['onesuperior'] = 300;
  19383. t['imacron'] = 278;
  19384. t['Euro'] = 500;
  19385. });
  19386. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19387. t['space'] = 250;
  19388. t['exclam'] = 389;
  19389. t['quotedbl'] = 555;
  19390. t['numbersign'] = 500;
  19391. t['dollar'] = 500;
  19392. t['percent'] = 833;
  19393. t['ampersand'] = 778;
  19394. t['quoteright'] = 333;
  19395. t['parenleft'] = 333;
  19396. t['parenright'] = 333;
  19397. t['asterisk'] = 500;
  19398. t['plus'] = 570;
  19399. t['comma'] = 250;
  19400. t['hyphen'] = 333;
  19401. t['period'] = 250;
  19402. t['slash'] = 278;
  19403. t['zero'] = 500;
  19404. t['one'] = 500;
  19405. t['two'] = 500;
  19406. t['three'] = 500;
  19407. t['four'] = 500;
  19408. t['five'] = 500;
  19409. t['six'] = 500;
  19410. t['seven'] = 500;
  19411. t['eight'] = 500;
  19412. t['nine'] = 500;
  19413. t['colon'] = 333;
  19414. t['semicolon'] = 333;
  19415. t['less'] = 570;
  19416. t['equal'] = 570;
  19417. t['greater'] = 570;
  19418. t['question'] = 500;
  19419. t['at'] = 832;
  19420. t['A'] = 667;
  19421. t['B'] = 667;
  19422. t['C'] = 667;
  19423. t['D'] = 722;
  19424. t['E'] = 667;
  19425. t['F'] = 667;
  19426. t['G'] = 722;
  19427. t['H'] = 778;
  19428. t['I'] = 389;
  19429. t['J'] = 500;
  19430. t['K'] = 667;
  19431. t['L'] = 611;
  19432. t['M'] = 889;
  19433. t['N'] = 722;
  19434. t['O'] = 722;
  19435. t['P'] = 611;
  19436. t['Q'] = 722;
  19437. t['R'] = 667;
  19438. t['S'] = 556;
  19439. t['T'] = 611;
  19440. t['U'] = 722;
  19441. t['V'] = 667;
  19442. t['W'] = 889;
  19443. t['X'] = 667;
  19444. t['Y'] = 611;
  19445. t['Z'] = 611;
  19446. t['bracketleft'] = 333;
  19447. t['backslash'] = 278;
  19448. t['bracketright'] = 333;
  19449. t['asciicircum'] = 570;
  19450. t['underscore'] = 500;
  19451. t['quoteleft'] = 333;
  19452. t['a'] = 500;
  19453. t['b'] = 500;
  19454. t['c'] = 444;
  19455. t['d'] = 500;
  19456. t['e'] = 444;
  19457. t['f'] = 333;
  19458. t['g'] = 500;
  19459. t['h'] = 556;
  19460. t['i'] = 278;
  19461. t['j'] = 278;
  19462. t['k'] = 500;
  19463. t['l'] = 278;
  19464. t['m'] = 778;
  19465. t['n'] = 556;
  19466. t['o'] = 500;
  19467. t['p'] = 500;
  19468. t['q'] = 500;
  19469. t['r'] = 389;
  19470. t['s'] = 389;
  19471. t['t'] = 278;
  19472. t['u'] = 556;
  19473. t['v'] = 444;
  19474. t['w'] = 667;
  19475. t['x'] = 500;
  19476. t['y'] = 444;
  19477. t['z'] = 389;
  19478. t['braceleft'] = 348;
  19479. t['bar'] = 220;
  19480. t['braceright'] = 348;
  19481. t['asciitilde'] = 570;
  19482. t['exclamdown'] = 389;
  19483. t['cent'] = 500;
  19484. t['sterling'] = 500;
  19485. t['fraction'] = 167;
  19486. t['yen'] = 500;
  19487. t['florin'] = 500;
  19488. t['section'] = 500;
  19489. t['currency'] = 500;
  19490. t['quotesingle'] = 278;
  19491. t['quotedblleft'] = 500;
  19492. t['guillemotleft'] = 500;
  19493. t['guilsinglleft'] = 333;
  19494. t['guilsinglright'] = 333;
  19495. t['fi'] = 556;
  19496. t['fl'] = 556;
  19497. t['endash'] = 500;
  19498. t['dagger'] = 500;
  19499. t['daggerdbl'] = 500;
  19500. t['periodcentered'] = 250;
  19501. t['paragraph'] = 500;
  19502. t['bullet'] = 350;
  19503. t['quotesinglbase'] = 333;
  19504. t['quotedblbase'] = 500;
  19505. t['quotedblright'] = 500;
  19506. t['guillemotright'] = 500;
  19507. t['ellipsis'] = 1000;
  19508. t['perthousand'] = 1000;
  19509. t['questiondown'] = 500;
  19510. t['grave'] = 333;
  19511. t['acute'] = 333;
  19512. t['circumflex'] = 333;
  19513. t['tilde'] = 333;
  19514. t['macron'] = 333;
  19515. t['breve'] = 333;
  19516. t['dotaccent'] = 333;
  19517. t['dieresis'] = 333;
  19518. t['ring'] = 333;
  19519. t['cedilla'] = 333;
  19520. t['hungarumlaut'] = 333;
  19521. t['ogonek'] = 333;
  19522. t['caron'] = 333;
  19523. t['emdash'] = 1000;
  19524. t['AE'] = 944;
  19525. t['ordfeminine'] = 266;
  19526. t['Lslash'] = 611;
  19527. t['Oslash'] = 722;
  19528. t['OE'] = 944;
  19529. t['ordmasculine'] = 300;
  19530. t['ae'] = 722;
  19531. t['dotlessi'] = 278;
  19532. t['lslash'] = 278;
  19533. t['oslash'] = 500;
  19534. t['oe'] = 722;
  19535. t['germandbls'] = 500;
  19536. t['Idieresis'] = 389;
  19537. t['eacute'] = 444;
  19538. t['abreve'] = 500;
  19539. t['uhungarumlaut'] = 556;
  19540. t['ecaron'] = 444;
  19541. t['Ydieresis'] = 611;
  19542. t['divide'] = 570;
  19543. t['Yacute'] = 611;
  19544. t['Acircumflex'] = 667;
  19545. t['aacute'] = 500;
  19546. t['Ucircumflex'] = 722;
  19547. t['yacute'] = 444;
  19548. t['scommaaccent'] = 389;
  19549. t['ecircumflex'] = 444;
  19550. t['Uring'] = 722;
  19551. t['Udieresis'] = 722;
  19552. t['aogonek'] = 500;
  19553. t['Uacute'] = 722;
  19554. t['uogonek'] = 556;
  19555. t['Edieresis'] = 667;
  19556. t['Dcroat'] = 722;
  19557. t['commaaccent'] = 250;
  19558. t['copyright'] = 747;
  19559. t['Emacron'] = 667;
  19560. t['ccaron'] = 444;
  19561. t['aring'] = 500;
  19562. t['Ncommaaccent'] = 722;
  19563. t['lacute'] = 278;
  19564. t['agrave'] = 500;
  19565. t['Tcommaaccent'] = 611;
  19566. t['Cacute'] = 667;
  19567. t['atilde'] = 500;
  19568. t['Edotaccent'] = 667;
  19569. t['scaron'] = 389;
  19570. t['scedilla'] = 389;
  19571. t['iacute'] = 278;
  19572. t['lozenge'] = 494;
  19573. t['Rcaron'] = 667;
  19574. t['Gcommaaccent'] = 722;
  19575. t['ucircumflex'] = 556;
  19576. t['acircumflex'] = 500;
  19577. t['Amacron'] = 667;
  19578. t['rcaron'] = 389;
  19579. t['ccedilla'] = 444;
  19580. t['Zdotaccent'] = 611;
  19581. t['Thorn'] = 611;
  19582. t['Omacron'] = 722;
  19583. t['Racute'] = 667;
  19584. t['Sacute'] = 556;
  19585. t['dcaron'] = 608;
  19586. t['Umacron'] = 722;
  19587. t['uring'] = 556;
  19588. t['threesuperior'] = 300;
  19589. t['Ograve'] = 722;
  19590. t['Agrave'] = 667;
  19591. t['Abreve'] = 667;
  19592. t['multiply'] = 570;
  19593. t['uacute'] = 556;
  19594. t['Tcaron'] = 611;
  19595. t['partialdiff'] = 494;
  19596. t['ydieresis'] = 444;
  19597. t['Nacute'] = 722;
  19598. t['icircumflex'] = 278;
  19599. t['Ecircumflex'] = 667;
  19600. t['adieresis'] = 500;
  19601. t['edieresis'] = 444;
  19602. t['cacute'] = 444;
  19603. t['nacute'] = 556;
  19604. t['umacron'] = 556;
  19605. t['Ncaron'] = 722;
  19606. t['Iacute'] = 389;
  19607. t['plusminus'] = 570;
  19608. t['brokenbar'] = 220;
  19609. t['registered'] = 747;
  19610. t['Gbreve'] = 722;
  19611. t['Idotaccent'] = 389;
  19612. t['summation'] = 600;
  19613. t['Egrave'] = 667;
  19614. t['racute'] = 389;
  19615. t['omacron'] = 500;
  19616. t['Zacute'] = 611;
  19617. t['Zcaron'] = 611;
  19618. t['greaterequal'] = 549;
  19619. t['Eth'] = 722;
  19620. t['Ccedilla'] = 667;
  19621. t['lcommaaccent'] = 278;
  19622. t['tcaron'] = 366;
  19623. t['eogonek'] = 444;
  19624. t['Uogonek'] = 722;
  19625. t['Aacute'] = 667;
  19626. t['Adieresis'] = 667;
  19627. t['egrave'] = 444;
  19628. t['zacute'] = 389;
  19629. t['iogonek'] = 278;
  19630. t['Oacute'] = 722;
  19631. t['oacute'] = 500;
  19632. t['amacron'] = 500;
  19633. t['sacute'] = 389;
  19634. t['idieresis'] = 278;
  19635. t['Ocircumflex'] = 722;
  19636. t['Ugrave'] = 722;
  19637. t['Delta'] = 612;
  19638. t['thorn'] = 500;
  19639. t['twosuperior'] = 300;
  19640. t['Odieresis'] = 722;
  19641. t['mu'] = 576;
  19642. t['igrave'] = 278;
  19643. t['ohungarumlaut'] = 500;
  19644. t['Eogonek'] = 667;
  19645. t['dcroat'] = 500;
  19646. t['threequarters'] = 750;
  19647. t['Scedilla'] = 556;
  19648. t['lcaron'] = 382;
  19649. t['Kcommaaccent'] = 667;
  19650. t['Lacute'] = 611;
  19651. t['trademark'] = 1000;
  19652. t['edotaccent'] = 444;
  19653. t['Igrave'] = 389;
  19654. t['Imacron'] = 389;
  19655. t['Lcaron'] = 611;
  19656. t['onehalf'] = 750;
  19657. t['lessequal'] = 549;
  19658. t['ocircumflex'] = 500;
  19659. t['ntilde'] = 556;
  19660. t['Uhungarumlaut'] = 722;
  19661. t['Eacute'] = 667;
  19662. t['emacron'] = 444;
  19663. t['gbreve'] = 500;
  19664. t['onequarter'] = 750;
  19665. t['Scaron'] = 556;
  19666. t['Scommaaccent'] = 556;
  19667. t['Ohungarumlaut'] = 722;
  19668. t['degree'] = 400;
  19669. t['ograve'] = 500;
  19670. t['Ccaron'] = 667;
  19671. t['ugrave'] = 556;
  19672. t['radical'] = 549;
  19673. t['Dcaron'] = 722;
  19674. t['rcommaaccent'] = 389;
  19675. t['Ntilde'] = 722;
  19676. t['otilde'] = 500;
  19677. t['Rcommaaccent'] = 667;
  19678. t['Lcommaaccent'] = 611;
  19679. t['Atilde'] = 667;
  19680. t['Aogonek'] = 667;
  19681. t['Aring'] = 667;
  19682. t['Otilde'] = 722;
  19683. t['zdotaccent'] = 389;
  19684. t['Ecaron'] = 667;
  19685. t['Iogonek'] = 389;
  19686. t['kcommaaccent'] = 500;
  19687. t['minus'] = 606;
  19688. t['Icircumflex'] = 389;
  19689. t['ncaron'] = 556;
  19690. t['tcommaaccent'] = 278;
  19691. t['logicalnot'] = 606;
  19692. t['odieresis'] = 500;
  19693. t['udieresis'] = 556;
  19694. t['notequal'] = 549;
  19695. t['gcommaaccent'] = 500;
  19696. t['eth'] = 500;
  19697. t['zcaron'] = 389;
  19698. t['ncommaaccent'] = 556;
  19699. t['onesuperior'] = 300;
  19700. t['imacron'] = 278;
  19701. t['Euro'] = 500;
  19702. });
  19703. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19704. t['space'] = 250;
  19705. t['exclam'] = 333;
  19706. t['quotedbl'] = 420;
  19707. t['numbersign'] = 500;
  19708. t['dollar'] = 500;
  19709. t['percent'] = 833;
  19710. t['ampersand'] = 778;
  19711. t['quoteright'] = 333;
  19712. t['parenleft'] = 333;
  19713. t['parenright'] = 333;
  19714. t['asterisk'] = 500;
  19715. t['plus'] = 675;
  19716. t['comma'] = 250;
  19717. t['hyphen'] = 333;
  19718. t['period'] = 250;
  19719. t['slash'] = 278;
  19720. t['zero'] = 500;
  19721. t['one'] = 500;
  19722. t['two'] = 500;
  19723. t['three'] = 500;
  19724. t['four'] = 500;
  19725. t['five'] = 500;
  19726. t['six'] = 500;
  19727. t['seven'] = 500;
  19728. t['eight'] = 500;
  19729. t['nine'] = 500;
  19730. t['colon'] = 333;
  19731. t['semicolon'] = 333;
  19732. t['less'] = 675;
  19733. t['equal'] = 675;
  19734. t['greater'] = 675;
  19735. t['question'] = 500;
  19736. t['at'] = 920;
  19737. t['A'] = 611;
  19738. t['B'] = 611;
  19739. t['C'] = 667;
  19740. t['D'] = 722;
  19741. t['E'] = 611;
  19742. t['F'] = 611;
  19743. t['G'] = 722;
  19744. t['H'] = 722;
  19745. t['I'] = 333;
  19746. t['J'] = 444;
  19747. t['K'] = 667;
  19748. t['L'] = 556;
  19749. t['M'] = 833;
  19750. t['N'] = 667;
  19751. t['O'] = 722;
  19752. t['P'] = 611;
  19753. t['Q'] = 722;
  19754. t['R'] = 611;
  19755. t['S'] = 500;
  19756. t['T'] = 556;
  19757. t['U'] = 722;
  19758. t['V'] = 611;
  19759. t['W'] = 833;
  19760. t['X'] = 611;
  19761. t['Y'] = 556;
  19762. t['Z'] = 556;
  19763. t['bracketleft'] = 389;
  19764. t['backslash'] = 278;
  19765. t['bracketright'] = 389;
  19766. t['asciicircum'] = 422;
  19767. t['underscore'] = 500;
  19768. t['quoteleft'] = 333;
  19769. t['a'] = 500;
  19770. t['b'] = 500;
  19771. t['c'] = 444;
  19772. t['d'] = 500;
  19773. t['e'] = 444;
  19774. t['f'] = 278;
  19775. t['g'] = 500;
  19776. t['h'] = 500;
  19777. t['i'] = 278;
  19778. t['j'] = 278;
  19779. t['k'] = 444;
  19780. t['l'] = 278;
  19781. t['m'] = 722;
  19782. t['n'] = 500;
  19783. t['o'] = 500;
  19784. t['p'] = 500;
  19785. t['q'] = 500;
  19786. t['r'] = 389;
  19787. t['s'] = 389;
  19788. t['t'] = 278;
  19789. t['u'] = 500;
  19790. t['v'] = 444;
  19791. t['w'] = 667;
  19792. t['x'] = 444;
  19793. t['y'] = 444;
  19794. t['z'] = 389;
  19795. t['braceleft'] = 400;
  19796. t['bar'] = 275;
  19797. t['braceright'] = 400;
  19798. t['asciitilde'] = 541;
  19799. t['exclamdown'] = 389;
  19800. t['cent'] = 500;
  19801. t['sterling'] = 500;
  19802. t['fraction'] = 167;
  19803. t['yen'] = 500;
  19804. t['florin'] = 500;
  19805. t['section'] = 500;
  19806. t['currency'] = 500;
  19807. t['quotesingle'] = 214;
  19808. t['quotedblleft'] = 556;
  19809. t['guillemotleft'] = 500;
  19810. t['guilsinglleft'] = 333;
  19811. t['guilsinglright'] = 333;
  19812. t['fi'] = 500;
  19813. t['fl'] = 500;
  19814. t['endash'] = 500;
  19815. t['dagger'] = 500;
  19816. t['daggerdbl'] = 500;
  19817. t['periodcentered'] = 250;
  19818. t['paragraph'] = 523;
  19819. t['bullet'] = 350;
  19820. t['quotesinglbase'] = 333;
  19821. t['quotedblbase'] = 556;
  19822. t['quotedblright'] = 556;
  19823. t['guillemotright'] = 500;
  19824. t['ellipsis'] = 889;
  19825. t['perthousand'] = 1000;
  19826. t['questiondown'] = 500;
  19827. t['grave'] = 333;
  19828. t['acute'] = 333;
  19829. t['circumflex'] = 333;
  19830. t['tilde'] = 333;
  19831. t['macron'] = 333;
  19832. t['breve'] = 333;
  19833. t['dotaccent'] = 333;
  19834. t['dieresis'] = 333;
  19835. t['ring'] = 333;
  19836. t['cedilla'] = 333;
  19837. t['hungarumlaut'] = 333;
  19838. t['ogonek'] = 333;
  19839. t['caron'] = 333;
  19840. t['emdash'] = 889;
  19841. t['AE'] = 889;
  19842. t['ordfeminine'] = 276;
  19843. t['Lslash'] = 556;
  19844. t['Oslash'] = 722;
  19845. t['OE'] = 944;
  19846. t['ordmasculine'] = 310;
  19847. t['ae'] = 667;
  19848. t['dotlessi'] = 278;
  19849. t['lslash'] = 278;
  19850. t['oslash'] = 500;
  19851. t['oe'] = 667;
  19852. t['germandbls'] = 500;
  19853. t['Idieresis'] = 333;
  19854. t['eacute'] = 444;
  19855. t['abreve'] = 500;
  19856. t['uhungarumlaut'] = 500;
  19857. t['ecaron'] = 444;
  19858. t['Ydieresis'] = 556;
  19859. t['divide'] = 675;
  19860. t['Yacute'] = 556;
  19861. t['Acircumflex'] = 611;
  19862. t['aacute'] = 500;
  19863. t['Ucircumflex'] = 722;
  19864. t['yacute'] = 444;
  19865. t['scommaaccent'] = 389;
  19866. t['ecircumflex'] = 444;
  19867. t['Uring'] = 722;
  19868. t['Udieresis'] = 722;
  19869. t['aogonek'] = 500;
  19870. t['Uacute'] = 722;
  19871. t['uogonek'] = 500;
  19872. t['Edieresis'] = 611;
  19873. t['Dcroat'] = 722;
  19874. t['commaaccent'] = 250;
  19875. t['copyright'] = 760;
  19876. t['Emacron'] = 611;
  19877. t['ccaron'] = 444;
  19878. t['aring'] = 500;
  19879. t['Ncommaaccent'] = 667;
  19880. t['lacute'] = 278;
  19881. t['agrave'] = 500;
  19882. t['Tcommaaccent'] = 556;
  19883. t['Cacute'] = 667;
  19884. t['atilde'] = 500;
  19885. t['Edotaccent'] = 611;
  19886. t['scaron'] = 389;
  19887. t['scedilla'] = 389;
  19888. t['iacute'] = 278;
  19889. t['lozenge'] = 471;
  19890. t['Rcaron'] = 611;
  19891. t['Gcommaaccent'] = 722;
  19892. t['ucircumflex'] = 500;
  19893. t['acircumflex'] = 500;
  19894. t['Amacron'] = 611;
  19895. t['rcaron'] = 389;
  19896. t['ccedilla'] = 444;
  19897. t['Zdotaccent'] = 556;
  19898. t['Thorn'] = 611;
  19899. t['Omacron'] = 722;
  19900. t['Racute'] = 611;
  19901. t['Sacute'] = 500;
  19902. t['dcaron'] = 544;
  19903. t['Umacron'] = 722;
  19904. t['uring'] = 500;
  19905. t['threesuperior'] = 300;
  19906. t['Ograve'] = 722;
  19907. t['Agrave'] = 611;
  19908. t['Abreve'] = 611;
  19909. t['multiply'] = 675;
  19910. t['uacute'] = 500;
  19911. t['Tcaron'] = 556;
  19912. t['partialdiff'] = 476;
  19913. t['ydieresis'] = 444;
  19914. t['Nacute'] = 667;
  19915. t['icircumflex'] = 278;
  19916. t['Ecircumflex'] = 611;
  19917. t['adieresis'] = 500;
  19918. t['edieresis'] = 444;
  19919. t['cacute'] = 444;
  19920. t['nacute'] = 500;
  19921. t['umacron'] = 500;
  19922. t['Ncaron'] = 667;
  19923. t['Iacute'] = 333;
  19924. t['plusminus'] = 675;
  19925. t['brokenbar'] = 275;
  19926. t['registered'] = 760;
  19927. t['Gbreve'] = 722;
  19928. t['Idotaccent'] = 333;
  19929. t['summation'] = 600;
  19930. t['Egrave'] = 611;
  19931. t['racute'] = 389;
  19932. t['omacron'] = 500;
  19933. t['Zacute'] = 556;
  19934. t['Zcaron'] = 556;
  19935. t['greaterequal'] = 549;
  19936. t['Eth'] = 722;
  19937. t['Ccedilla'] = 667;
  19938. t['lcommaaccent'] = 278;
  19939. t['tcaron'] = 300;
  19940. t['eogonek'] = 444;
  19941. t['Uogonek'] = 722;
  19942. t['Aacute'] = 611;
  19943. t['Adieresis'] = 611;
  19944. t['egrave'] = 444;
  19945. t['zacute'] = 389;
  19946. t['iogonek'] = 278;
  19947. t['Oacute'] = 722;
  19948. t['oacute'] = 500;
  19949. t['amacron'] = 500;
  19950. t['sacute'] = 389;
  19951. t['idieresis'] = 278;
  19952. t['Ocircumflex'] = 722;
  19953. t['Ugrave'] = 722;
  19954. t['Delta'] = 612;
  19955. t['thorn'] = 500;
  19956. t['twosuperior'] = 300;
  19957. t['Odieresis'] = 722;
  19958. t['mu'] = 500;
  19959. t['igrave'] = 278;
  19960. t['ohungarumlaut'] = 500;
  19961. t['Eogonek'] = 611;
  19962. t['dcroat'] = 500;
  19963. t['threequarters'] = 750;
  19964. t['Scedilla'] = 500;
  19965. t['lcaron'] = 300;
  19966. t['Kcommaaccent'] = 667;
  19967. t['Lacute'] = 556;
  19968. t['trademark'] = 980;
  19969. t['edotaccent'] = 444;
  19970. t['Igrave'] = 333;
  19971. t['Imacron'] = 333;
  19972. t['Lcaron'] = 611;
  19973. t['onehalf'] = 750;
  19974. t['lessequal'] = 549;
  19975. t['ocircumflex'] = 500;
  19976. t['ntilde'] = 500;
  19977. t['Uhungarumlaut'] = 722;
  19978. t['Eacute'] = 611;
  19979. t['emacron'] = 444;
  19980. t['gbreve'] = 500;
  19981. t['onequarter'] = 750;
  19982. t['Scaron'] = 500;
  19983. t['Scommaaccent'] = 500;
  19984. t['Ohungarumlaut'] = 722;
  19985. t['degree'] = 400;
  19986. t['ograve'] = 500;
  19987. t['Ccaron'] = 667;
  19988. t['ugrave'] = 500;
  19989. t['radical'] = 453;
  19990. t['Dcaron'] = 722;
  19991. t['rcommaaccent'] = 389;
  19992. t['Ntilde'] = 667;
  19993. t['otilde'] = 500;
  19994. t['Rcommaaccent'] = 611;
  19995. t['Lcommaaccent'] = 556;
  19996. t['Atilde'] = 611;
  19997. t['Aogonek'] = 611;
  19998. t['Aring'] = 611;
  19999. t['Otilde'] = 722;
  20000. t['zdotaccent'] = 389;
  20001. t['Ecaron'] = 611;
  20002. t['Iogonek'] = 333;
  20003. t['kcommaaccent'] = 444;
  20004. t['minus'] = 675;
  20005. t['Icircumflex'] = 333;
  20006. t['ncaron'] = 500;
  20007. t['tcommaaccent'] = 278;
  20008. t['logicalnot'] = 675;
  20009. t['odieresis'] = 500;
  20010. t['udieresis'] = 500;
  20011. t['notequal'] = 549;
  20012. t['gcommaaccent'] = 500;
  20013. t['eth'] = 500;
  20014. t['zcaron'] = 389;
  20015. t['ncommaaccent'] = 500;
  20016. t['onesuperior'] = 300;
  20017. t['imacron'] = 278;
  20018. t['Euro'] = 500;
  20019. });
  20020. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  20021. t['space'] = 278;
  20022. t['a1'] = 974;
  20023. t['a2'] = 961;
  20024. t['a202'] = 974;
  20025. t['a3'] = 980;
  20026. t['a4'] = 719;
  20027. t['a5'] = 789;
  20028. t['a119'] = 790;
  20029. t['a118'] = 791;
  20030. t['a117'] = 690;
  20031. t['a11'] = 960;
  20032. t['a12'] = 939;
  20033. t['a13'] = 549;
  20034. t['a14'] = 855;
  20035. t['a15'] = 911;
  20036. t['a16'] = 933;
  20037. t['a105'] = 911;
  20038. t['a17'] = 945;
  20039. t['a18'] = 974;
  20040. t['a19'] = 755;
  20041. t['a20'] = 846;
  20042. t['a21'] = 762;
  20043. t['a22'] = 761;
  20044. t['a23'] = 571;
  20045. t['a24'] = 677;
  20046. t['a25'] = 763;
  20047. t['a26'] = 760;
  20048. t['a27'] = 759;
  20049. t['a28'] = 754;
  20050. t['a6'] = 494;
  20051. t['a7'] = 552;
  20052. t['a8'] = 537;
  20053. t['a9'] = 577;
  20054. t['a10'] = 692;
  20055. t['a29'] = 786;
  20056. t['a30'] = 788;
  20057. t['a31'] = 788;
  20058. t['a32'] = 790;
  20059. t['a33'] = 793;
  20060. t['a34'] = 794;
  20061. t['a35'] = 816;
  20062. t['a36'] = 823;
  20063. t['a37'] = 789;
  20064. t['a38'] = 841;
  20065. t['a39'] = 823;
  20066. t['a40'] = 833;
  20067. t['a41'] = 816;
  20068. t['a42'] = 831;
  20069. t['a43'] = 923;
  20070. t['a44'] = 744;
  20071. t['a45'] = 723;
  20072. t['a46'] = 749;
  20073. t['a47'] = 790;
  20074. t['a48'] = 792;
  20075. t['a49'] = 695;
  20076. t['a50'] = 776;
  20077. t['a51'] = 768;
  20078. t['a52'] = 792;
  20079. t['a53'] = 759;
  20080. t['a54'] = 707;
  20081. t['a55'] = 708;
  20082. t['a56'] = 682;
  20083. t['a57'] = 701;
  20084. t['a58'] = 826;
  20085. t['a59'] = 815;
  20086. t['a60'] = 789;
  20087. t['a61'] = 789;
  20088. t['a62'] = 707;
  20089. t['a63'] = 687;
  20090. t['a64'] = 696;
  20091. t['a65'] = 689;
  20092. t['a66'] = 786;
  20093. t['a67'] = 787;
  20094. t['a68'] = 713;
  20095. t['a69'] = 791;
  20096. t['a70'] = 785;
  20097. t['a71'] = 791;
  20098. t['a72'] = 873;
  20099. t['a73'] = 761;
  20100. t['a74'] = 762;
  20101. t['a203'] = 762;
  20102. t['a75'] = 759;
  20103. t['a204'] = 759;
  20104. t['a76'] = 892;
  20105. t['a77'] = 892;
  20106. t['a78'] = 788;
  20107. t['a79'] = 784;
  20108. t['a81'] = 438;
  20109. t['a82'] = 138;
  20110. t['a83'] = 277;
  20111. t['a84'] = 415;
  20112. t['a97'] = 392;
  20113. t['a98'] = 392;
  20114. t['a99'] = 668;
  20115. t['a100'] = 668;
  20116. t['a89'] = 390;
  20117. t['a90'] = 390;
  20118. t['a93'] = 317;
  20119. t['a94'] = 317;
  20120. t['a91'] = 276;
  20121. t['a92'] = 276;
  20122. t['a205'] = 509;
  20123. t['a85'] = 509;
  20124. t['a206'] = 410;
  20125. t['a86'] = 410;
  20126. t['a87'] = 234;
  20127. t['a88'] = 234;
  20128. t['a95'] = 334;
  20129. t['a96'] = 334;
  20130. t['a101'] = 732;
  20131. t['a102'] = 544;
  20132. t['a103'] = 544;
  20133. t['a104'] = 910;
  20134. t['a106'] = 667;
  20135. t['a107'] = 760;
  20136. t['a108'] = 760;
  20137. t['a112'] = 776;
  20138. t['a111'] = 595;
  20139. t['a110'] = 694;
  20140. t['a109'] = 626;
  20141. t['a120'] = 788;
  20142. t['a121'] = 788;
  20143. t['a122'] = 788;
  20144. t['a123'] = 788;
  20145. t['a124'] = 788;
  20146. t['a125'] = 788;
  20147. t['a126'] = 788;
  20148. t['a127'] = 788;
  20149. t['a128'] = 788;
  20150. t['a129'] = 788;
  20151. t['a130'] = 788;
  20152. t['a131'] = 788;
  20153. t['a132'] = 788;
  20154. t['a133'] = 788;
  20155. t['a134'] = 788;
  20156. t['a135'] = 788;
  20157. t['a136'] = 788;
  20158. t['a137'] = 788;
  20159. t['a138'] = 788;
  20160. t['a139'] = 788;
  20161. t['a140'] = 788;
  20162. t['a141'] = 788;
  20163. t['a142'] = 788;
  20164. t['a143'] = 788;
  20165. t['a144'] = 788;
  20166. t['a145'] = 788;
  20167. t['a146'] = 788;
  20168. t['a147'] = 788;
  20169. t['a148'] = 788;
  20170. t['a149'] = 788;
  20171. t['a150'] = 788;
  20172. t['a151'] = 788;
  20173. t['a152'] = 788;
  20174. t['a153'] = 788;
  20175. t['a154'] = 788;
  20176. t['a155'] = 788;
  20177. t['a156'] = 788;
  20178. t['a157'] = 788;
  20179. t['a158'] = 788;
  20180. t['a159'] = 788;
  20181. t['a160'] = 894;
  20182. t['a161'] = 838;
  20183. t['a163'] = 1016;
  20184. t['a164'] = 458;
  20185. t['a196'] = 748;
  20186. t['a165'] = 924;
  20187. t['a192'] = 748;
  20188. t['a166'] = 918;
  20189. t['a167'] = 927;
  20190. t['a168'] = 928;
  20191. t['a169'] = 928;
  20192. t['a170'] = 834;
  20193. t['a171'] = 873;
  20194. t['a172'] = 828;
  20195. t['a173'] = 924;
  20196. t['a162'] = 924;
  20197. t['a174'] = 917;
  20198. t['a175'] = 930;
  20199. t['a176'] = 931;
  20200. t['a177'] = 463;
  20201. t['a178'] = 883;
  20202. t['a179'] = 836;
  20203. t['a193'] = 836;
  20204. t['a180'] = 867;
  20205. t['a199'] = 867;
  20206. t['a181'] = 696;
  20207. t['a200'] = 696;
  20208. t['a182'] = 874;
  20209. t['a201'] = 874;
  20210. t['a183'] = 760;
  20211. t['a184'] = 946;
  20212. t['a197'] = 771;
  20213. t['a185'] = 865;
  20214. t['a194'] = 771;
  20215. t['a198'] = 888;
  20216. t['a186'] = 967;
  20217. t['a195'] = 888;
  20218. t['a187'] = 831;
  20219. t['a188'] = 873;
  20220. t['a189'] = 927;
  20221. t['a190'] = 970;
  20222. t['a191'] = 918;
  20223. });
  20224. });
  20225. exports.getMetrics = getMetrics;
  20226. }));
  20227. (function (root, factory) {
  20228. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20229. }(this, function (exports, sharedUtil) {
  20230. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20231. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20232. var MASK_HIGH = 0xffff0000;
  20233. var MASK_LOW = 0xffff;
  20234. function MurmurHash3_64(seed) {
  20235. var SEED = 0xc3d2e1f0;
  20236. this.h1 = seed ? seed & 0xffffffff : SEED;
  20237. this.h2 = seed ? seed & 0xffffffff : SEED;
  20238. }
  20239. var alwaysUseUint32ArrayView = false;
  20240. try {
  20241. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20242. } catch (e) {
  20243. alwaysUseUint32ArrayView = true;
  20244. }
  20245. MurmurHash3_64.prototype = {
  20246. update: function MurmurHash3_64_update(input) {
  20247. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20248. var i;
  20249. if (typeof input === 'string') {
  20250. var data = new Uint8Array(input.length * 2);
  20251. var length = 0;
  20252. for (i = 0; i < input.length; i++) {
  20253. var code = input.charCodeAt(i);
  20254. if (code <= 0xff) {
  20255. data[length++] = code;
  20256. } else {
  20257. data[length++] = code >>> 8;
  20258. data[length++] = code & 0xff;
  20259. }
  20260. }
  20261. } else if (input instanceof Uint8Array) {
  20262. data = input;
  20263. length = data.length;
  20264. } else if (typeof input === 'object' && 'length' in input) {
  20265. data = input;
  20266. length = data.length;
  20267. useUint32ArrayView = true;
  20268. } else {
  20269. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20270. }
  20271. var blockCounts = length >> 2;
  20272. var tailLength = length - blockCounts * 4;
  20273. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20274. var k1 = 0;
  20275. var k2 = 0;
  20276. var h1 = this.h1;
  20277. var h2 = this.h2;
  20278. var C1 = 0xcc9e2d51;
  20279. var C2 = 0x1b873593;
  20280. var C1_LOW = C1 & MASK_LOW;
  20281. var C2_LOW = C2 & MASK_LOW;
  20282. for (i = 0; i < blockCounts; i++) {
  20283. if (i & 1) {
  20284. k1 = dataUint32[i];
  20285. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20286. k1 = k1 << 15 | k1 >>> 17;
  20287. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20288. h1 ^= k1;
  20289. h1 = h1 << 13 | h1 >>> 19;
  20290. h1 = h1 * 5 + 0xe6546b64;
  20291. } else {
  20292. k2 = dataUint32[i];
  20293. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20294. k2 = k2 << 15 | k2 >>> 17;
  20295. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20296. h2 ^= k2;
  20297. h2 = h2 << 13 | h2 >>> 19;
  20298. h2 = h2 * 5 + 0xe6546b64;
  20299. }
  20300. }
  20301. k1 = 0;
  20302. switch (tailLength) {
  20303. case 3:
  20304. k1 ^= data[blockCounts * 4 + 2] << 16;
  20305. case 2:
  20306. k1 ^= data[blockCounts * 4 + 1] << 8;
  20307. case 1:
  20308. k1 ^= data[blockCounts * 4];
  20309. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20310. k1 = k1 << 15 | k1 >>> 17;
  20311. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20312. if (blockCounts & 1) {
  20313. h1 ^= k1;
  20314. } else {
  20315. h2 ^= k1;
  20316. }
  20317. }
  20318. this.h1 = h1;
  20319. this.h2 = h2;
  20320. return this;
  20321. },
  20322. hexdigest: function MurmurHash3_64_hexdigest() {
  20323. var h1 = this.h1;
  20324. var h2 = this.h2;
  20325. h1 ^= h2 >>> 1;
  20326. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20327. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20328. h1 ^= h2 >>> 1;
  20329. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20330. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20331. h1 ^= h2 >>> 1;
  20332. for (var i = 0, arr = [
  20333. h1,
  20334. h2
  20335. ], str = ''; i < arr.length; i++) {
  20336. var hex = (arr[i] >>> 0).toString(16);
  20337. while (hex.length < 8) {
  20338. hex = '0' + hex;
  20339. }
  20340. str += hex;
  20341. }
  20342. return str;
  20343. }
  20344. };
  20345. return MurmurHash3_64;
  20346. }();
  20347. exports.MurmurHash3_64 = MurmurHash3_64;
  20348. }));
  20349. (function (root, factory) {
  20350. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20351. }(this, function (exports, sharedUtil) {
  20352. var isArray = sharedUtil.isArray;
  20353. var Name = function NameClosure() {
  20354. function Name(name) {
  20355. this.name = name;
  20356. }
  20357. Name.prototype = {};
  20358. var nameCache = Object.create(null);
  20359. Name.get = function Name_get(name) {
  20360. var nameValue = nameCache[name];
  20361. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20362. };
  20363. return Name;
  20364. }();
  20365. var Cmd = function CmdClosure() {
  20366. function Cmd(cmd) {
  20367. this.cmd = cmd;
  20368. }
  20369. Cmd.prototype = {};
  20370. var cmdCache = Object.create(null);
  20371. Cmd.get = function Cmd_get(cmd) {
  20372. var cmdValue = cmdCache[cmd];
  20373. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20374. };
  20375. return Cmd;
  20376. }();
  20377. var Dict = function DictClosure() {
  20378. var nonSerializable = function nonSerializableClosure() {
  20379. return nonSerializable;
  20380. };
  20381. function Dict(xref) {
  20382. this.map = Object.create(null);
  20383. this.xref = xref;
  20384. this.objId = null;
  20385. this.suppressEncryption = false;
  20386. this.__nonSerializable__ = nonSerializable;
  20387. }
  20388. Dict.prototype = {
  20389. assignXref: function Dict_assignXref(newXref) {
  20390. this.xref = newXref;
  20391. },
  20392. get: function Dict_get(key1, key2, key3) {
  20393. var value;
  20394. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20395. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20396. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20397. }
  20398. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20399. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20400. }
  20401. value = this.map[key3] || null;
  20402. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20403. },
  20404. getAsync: function Dict_getAsync(key1, key2, key3) {
  20405. var value;
  20406. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20407. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20408. if (xref) {
  20409. return xref.fetchIfRefAsync(value, suppressEncryption);
  20410. }
  20411. return Promise.resolve(value);
  20412. }
  20413. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20414. if (xref) {
  20415. return xref.fetchIfRefAsync(value, suppressEncryption);
  20416. }
  20417. return Promise.resolve(value);
  20418. }
  20419. value = this.map[key3] || null;
  20420. if (xref) {
  20421. return xref.fetchIfRefAsync(value, suppressEncryption);
  20422. }
  20423. return Promise.resolve(value);
  20424. },
  20425. getArray: function Dict_getArray(key1, key2, key3) {
  20426. var value = this.get(key1, key2, key3);
  20427. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20428. if (!isArray(value) || !xref) {
  20429. return value;
  20430. }
  20431. value = value.slice();
  20432. for (var i = 0, ii = value.length; i < ii; i++) {
  20433. if (!isRef(value[i])) {
  20434. continue;
  20435. }
  20436. value[i] = xref.fetch(value[i], suppressEncryption);
  20437. }
  20438. return value;
  20439. },
  20440. getRaw: function Dict_getRaw(key) {
  20441. return this.map[key];
  20442. },
  20443. getKeys: function Dict_getKeys() {
  20444. return Object.keys(this.map);
  20445. },
  20446. set: function Dict_set(key, value) {
  20447. this.map[key] = value;
  20448. },
  20449. has: function Dict_has(key) {
  20450. return key in this.map;
  20451. },
  20452. forEach: function Dict_forEach(callback) {
  20453. for (var key in this.map) {
  20454. callback(key, this.get(key));
  20455. }
  20456. }
  20457. };
  20458. Dict.empty = new Dict(null);
  20459. Dict.merge = function Dict_merge(xref, dictArray) {
  20460. var mergedDict = new Dict(xref);
  20461. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20462. var dict = dictArray[i];
  20463. if (!isDict(dict)) {
  20464. continue;
  20465. }
  20466. for (var keyName in dict.map) {
  20467. if (mergedDict.map[keyName]) {
  20468. continue;
  20469. }
  20470. mergedDict.map[keyName] = dict.map[keyName];
  20471. }
  20472. }
  20473. return mergedDict;
  20474. };
  20475. return Dict;
  20476. }();
  20477. var Ref = function RefClosure() {
  20478. function Ref(num, gen) {
  20479. this.num = num;
  20480. this.gen = gen;
  20481. }
  20482. Ref.prototype = {
  20483. toString: function Ref_toString() {
  20484. var str = this.num + 'R';
  20485. if (this.gen !== 0) {
  20486. str += this.gen;
  20487. }
  20488. return str;
  20489. }
  20490. };
  20491. return Ref;
  20492. }();
  20493. var RefSet = function RefSetClosure() {
  20494. function RefSet() {
  20495. this.dict = Object.create(null);
  20496. }
  20497. RefSet.prototype = {
  20498. has: function RefSet_has(ref) {
  20499. return ref.toString() in this.dict;
  20500. },
  20501. put: function RefSet_put(ref) {
  20502. this.dict[ref.toString()] = true;
  20503. },
  20504. remove: function RefSet_remove(ref) {
  20505. delete this.dict[ref.toString()];
  20506. }
  20507. };
  20508. return RefSet;
  20509. }();
  20510. var RefSetCache = function RefSetCacheClosure() {
  20511. function RefSetCache() {
  20512. this.dict = Object.create(null);
  20513. }
  20514. RefSetCache.prototype = {
  20515. get: function RefSetCache_get(ref) {
  20516. return this.dict[ref.toString()];
  20517. },
  20518. has: function RefSetCache_has(ref) {
  20519. return ref.toString() in this.dict;
  20520. },
  20521. put: function RefSetCache_put(ref, obj) {
  20522. this.dict[ref.toString()] = obj;
  20523. },
  20524. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20525. this.dict[ref.toString()] = this.get(aliasRef);
  20526. },
  20527. forEach: function RefSetCache_forEach(fn, thisArg) {
  20528. for (var i in this.dict) {
  20529. fn.call(thisArg, this.dict[i]);
  20530. }
  20531. },
  20532. clear: function RefSetCache_clear() {
  20533. this.dict = Object.create(null);
  20534. }
  20535. };
  20536. return RefSetCache;
  20537. }();
  20538. function isName(v, name) {
  20539. return v instanceof Name && (name === undefined || v.name === name);
  20540. }
  20541. function isCmd(v, cmd) {
  20542. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20543. }
  20544. function isDict(v, type) {
  20545. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20546. }
  20547. function isRef(v) {
  20548. return v instanceof Ref;
  20549. }
  20550. function isRefsEqual(v1, v2) {
  20551. return v1.num === v2.num && v1.gen === v2.gen;
  20552. }
  20553. function isStream(v) {
  20554. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20555. }
  20556. exports.Cmd = Cmd;
  20557. exports.Dict = Dict;
  20558. exports.Name = Name;
  20559. exports.Ref = Ref;
  20560. exports.RefSet = RefSet;
  20561. exports.RefSetCache = RefSetCache;
  20562. exports.isCmd = isCmd;
  20563. exports.isDict = isDict;
  20564. exports.isName = isName;
  20565. exports.isRef = isRef;
  20566. exports.isRefsEqual = isRefsEqual;
  20567. exports.isStream = isStream;
  20568. }));
  20569. (function (root, factory) {
  20570. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20571. }(this, function (exports, sharedUtil) {
  20572. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20573. var getStdFontMap = getLookupTableFactory(function (t) {
  20574. t['ArialNarrow'] = 'Helvetica';
  20575. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20576. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20577. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20578. t['ArialBlack'] = 'Helvetica';
  20579. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20580. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20581. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20582. t['Arial-Black'] = 'Helvetica';
  20583. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20584. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20585. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20586. t['Arial'] = 'Helvetica';
  20587. t['Arial-Bold'] = 'Helvetica-Bold';
  20588. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20589. t['Arial-Italic'] = 'Helvetica-Oblique';
  20590. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20591. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20592. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20593. t['ArialMT'] = 'Helvetica';
  20594. t['Courier-Bold'] = 'Courier-Bold';
  20595. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20596. t['Courier-Italic'] = 'Courier-Oblique';
  20597. t['CourierNew'] = 'Courier';
  20598. t['CourierNew-Bold'] = 'Courier-Bold';
  20599. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20600. t['CourierNew-Italic'] = 'Courier-Oblique';
  20601. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20602. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20603. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20604. t['CourierNewPSMT'] = 'Courier';
  20605. t['Helvetica'] = 'Helvetica';
  20606. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20607. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20608. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20609. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20610. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20611. t['Symbol-Bold'] = 'Symbol';
  20612. t['Symbol-BoldItalic'] = 'Symbol';
  20613. t['Symbol-Italic'] = 'Symbol';
  20614. t['TimesNewRoman'] = 'Times-Roman';
  20615. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20616. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20617. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20618. t['TimesNewRomanPS'] = 'Times-Roman';
  20619. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20620. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20621. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20622. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20623. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20624. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20625. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20626. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20627. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20628. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20629. });
  20630. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20631. t['CenturyGothic'] = 'Helvetica';
  20632. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20633. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20634. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20635. t['ComicSansMS'] = 'Comic Sans MS';
  20636. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20637. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20638. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20639. t['LucidaConsole'] = 'Courier';
  20640. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20641. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20642. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20643. t['MS-Gothic'] = 'MS Gothic';
  20644. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20645. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20646. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20647. t['MS-Mincho'] = 'MS Mincho';
  20648. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20649. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20650. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20651. t['MS-PGothic'] = 'MS PGothic';
  20652. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20653. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20654. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20655. t['MS-PMincho'] = 'MS PMincho';
  20656. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20657. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20658. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20659. t['NuptialScript'] = 'Times-Italic';
  20660. t['Wingdings'] = 'ZapfDingbats';
  20661. });
  20662. var getSerifFonts = getLookupTableFactory(function (t) {
  20663. t['Adobe Jenson'] = true;
  20664. t['Adobe Text'] = true;
  20665. t['Albertus'] = true;
  20666. t['Aldus'] = true;
  20667. t['Alexandria'] = true;
  20668. t['Algerian'] = true;
  20669. t['American Typewriter'] = true;
  20670. t['Antiqua'] = true;
  20671. t['Apex'] = true;
  20672. t['Arno'] = true;
  20673. t['Aster'] = true;
  20674. t['Aurora'] = true;
  20675. t['Baskerville'] = true;
  20676. t['Bell'] = true;
  20677. t['Bembo'] = true;
  20678. t['Bembo Schoolbook'] = true;
  20679. t['Benguiat'] = true;
  20680. t['Berkeley Old Style'] = true;
  20681. t['Bernhard Modern'] = true;
  20682. t['Berthold City'] = true;
  20683. t['Bodoni'] = true;
  20684. t['Bauer Bodoni'] = true;
  20685. t['Book Antiqua'] = true;
  20686. t['Bookman'] = true;
  20687. t['Bordeaux Roman'] = true;
  20688. t['Californian FB'] = true;
  20689. t['Calisto'] = true;
  20690. t['Calvert'] = true;
  20691. t['Capitals'] = true;
  20692. t['Cambria'] = true;
  20693. t['Cartier'] = true;
  20694. t['Caslon'] = true;
  20695. t['Catull'] = true;
  20696. t['Centaur'] = true;
  20697. t['Century Old Style'] = true;
  20698. t['Century Schoolbook'] = true;
  20699. t['Chaparral'] = true;
  20700. t['Charis SIL'] = true;
  20701. t['Cheltenham'] = true;
  20702. t['Cholla Slab'] = true;
  20703. t['Clarendon'] = true;
  20704. t['Clearface'] = true;
  20705. t['Cochin'] = true;
  20706. t['Colonna'] = true;
  20707. t['Computer Modern'] = true;
  20708. t['Concrete Roman'] = true;
  20709. t['Constantia'] = true;
  20710. t['Cooper Black'] = true;
  20711. t['Corona'] = true;
  20712. t['Ecotype'] = true;
  20713. t['Egyptienne'] = true;
  20714. t['Elephant'] = true;
  20715. t['Excelsior'] = true;
  20716. t['Fairfield'] = true;
  20717. t['FF Scala'] = true;
  20718. t['Folkard'] = true;
  20719. t['Footlight'] = true;
  20720. t['FreeSerif'] = true;
  20721. t['Friz Quadrata'] = true;
  20722. t['Garamond'] = true;
  20723. t['Gentium'] = true;
  20724. t['Georgia'] = true;
  20725. t['Gloucester'] = true;
  20726. t['Goudy Old Style'] = true;
  20727. t['Goudy Schoolbook'] = true;
  20728. t['Goudy Pro Font'] = true;
  20729. t['Granjon'] = true;
  20730. t['Guardian Egyptian'] = true;
  20731. t['Heather'] = true;
  20732. t['Hercules'] = true;
  20733. t['High Tower Text'] = true;
  20734. t['Hiroshige'] = true;
  20735. t['Hoefler Text'] = true;
  20736. t['Humana Serif'] = true;
  20737. t['Imprint'] = true;
  20738. t['Ionic No. 5'] = true;
  20739. t['Janson'] = true;
  20740. t['Joanna'] = true;
  20741. t['Korinna'] = true;
  20742. t['Lexicon'] = true;
  20743. t['Liberation Serif'] = true;
  20744. t['Linux Libertine'] = true;
  20745. t['Literaturnaya'] = true;
  20746. t['Lucida'] = true;
  20747. t['Lucida Bright'] = true;
  20748. t['Melior'] = true;
  20749. t['Memphis'] = true;
  20750. t['Miller'] = true;
  20751. t['Minion'] = true;
  20752. t['Modern'] = true;
  20753. t['Mona Lisa'] = true;
  20754. t['Mrs Eaves'] = true;
  20755. t['MS Serif'] = true;
  20756. t['Museo Slab'] = true;
  20757. t['New York'] = true;
  20758. t['Nimbus Roman'] = true;
  20759. t['NPS Rawlinson Roadway'] = true;
  20760. t['NuptialScript'] = true;
  20761. t['Palatino'] = true;
  20762. t['Perpetua'] = true;
  20763. t['Plantin'] = true;
  20764. t['Plantin Schoolbook'] = true;
  20765. t['Playbill'] = true;
  20766. t['Poor Richard'] = true;
  20767. t['Rawlinson Roadway'] = true;
  20768. t['Renault'] = true;
  20769. t['Requiem'] = true;
  20770. t['Rockwell'] = true;
  20771. t['Roman'] = true;
  20772. t['Rotis Serif'] = true;
  20773. t['Sabon'] = true;
  20774. t['Scala'] = true;
  20775. t['Seagull'] = true;
  20776. t['Sistina'] = true;
  20777. t['Souvenir'] = true;
  20778. t['STIX'] = true;
  20779. t['Stone Informal'] = true;
  20780. t['Stone Serif'] = true;
  20781. t['Sylfaen'] = true;
  20782. t['Times'] = true;
  20783. t['Trajan'] = true;
  20784. t['Trinité'] = true;
  20785. t['Trump Mediaeval'] = true;
  20786. t['Utopia'] = true;
  20787. t['Vale Type'] = true;
  20788. t['Bitstream Vera'] = true;
  20789. t['Vera Serif'] = true;
  20790. t['Versailles'] = true;
  20791. t['Wanted'] = true;
  20792. t['Weiss'] = true;
  20793. t['Wide Latin'] = true;
  20794. t['Windsor'] = true;
  20795. t['XITS'] = true;
  20796. });
  20797. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20798. t['Dingbats'] = true;
  20799. t['Symbol'] = true;
  20800. t['ZapfDingbats'] = true;
  20801. });
  20802. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20803. t[2] = 10;
  20804. t[3] = 32;
  20805. t[4] = 33;
  20806. t[5] = 34;
  20807. t[6] = 35;
  20808. t[7] = 36;
  20809. t[8] = 37;
  20810. t[9] = 38;
  20811. t[10] = 39;
  20812. t[11] = 40;
  20813. t[12] = 41;
  20814. t[13] = 42;
  20815. t[14] = 43;
  20816. t[15] = 44;
  20817. t[16] = 45;
  20818. t[17] = 46;
  20819. t[18] = 47;
  20820. t[19] = 48;
  20821. t[20] = 49;
  20822. t[21] = 50;
  20823. t[22] = 51;
  20824. t[23] = 52;
  20825. t[24] = 53;
  20826. t[25] = 54;
  20827. t[26] = 55;
  20828. t[27] = 56;
  20829. t[28] = 57;
  20830. t[29] = 58;
  20831. t[30] = 894;
  20832. t[31] = 60;
  20833. t[32] = 61;
  20834. t[33] = 62;
  20835. t[34] = 63;
  20836. t[35] = 64;
  20837. t[36] = 65;
  20838. t[37] = 66;
  20839. t[38] = 67;
  20840. t[39] = 68;
  20841. t[40] = 69;
  20842. t[41] = 70;
  20843. t[42] = 71;
  20844. t[43] = 72;
  20845. t[44] = 73;
  20846. t[45] = 74;
  20847. t[46] = 75;
  20848. t[47] = 76;
  20849. t[48] = 77;
  20850. t[49] = 78;
  20851. t[50] = 79;
  20852. t[51] = 80;
  20853. t[52] = 81;
  20854. t[53] = 82;
  20855. t[54] = 83;
  20856. t[55] = 84;
  20857. t[56] = 85;
  20858. t[57] = 86;
  20859. t[58] = 87;
  20860. t[59] = 88;
  20861. t[60] = 89;
  20862. t[61] = 90;
  20863. t[62] = 91;
  20864. t[63] = 92;
  20865. t[64] = 93;
  20866. t[65] = 94;
  20867. t[66] = 95;
  20868. t[67] = 96;
  20869. t[68] = 97;
  20870. t[69] = 98;
  20871. t[70] = 99;
  20872. t[71] = 100;
  20873. t[72] = 101;
  20874. t[73] = 102;
  20875. t[74] = 103;
  20876. t[75] = 104;
  20877. t[76] = 105;
  20878. t[77] = 106;
  20879. t[78] = 107;
  20880. t[79] = 108;
  20881. t[80] = 109;
  20882. t[81] = 110;
  20883. t[82] = 111;
  20884. t[83] = 112;
  20885. t[84] = 113;
  20886. t[85] = 114;
  20887. t[86] = 115;
  20888. t[87] = 116;
  20889. t[88] = 117;
  20890. t[89] = 118;
  20891. t[90] = 119;
  20892. t[91] = 120;
  20893. t[92] = 121;
  20894. t[93] = 122;
  20895. t[94] = 123;
  20896. t[95] = 124;
  20897. t[96] = 125;
  20898. t[97] = 126;
  20899. t[98] = 196;
  20900. t[99] = 197;
  20901. t[100] = 199;
  20902. t[101] = 201;
  20903. t[102] = 209;
  20904. t[103] = 214;
  20905. t[104] = 220;
  20906. t[105] = 225;
  20907. t[106] = 224;
  20908. t[107] = 226;
  20909. t[108] = 228;
  20910. t[109] = 227;
  20911. t[110] = 229;
  20912. t[111] = 231;
  20913. t[112] = 233;
  20914. t[113] = 232;
  20915. t[114] = 234;
  20916. t[115] = 235;
  20917. t[116] = 237;
  20918. t[117] = 236;
  20919. t[118] = 238;
  20920. t[119] = 239;
  20921. t[120] = 241;
  20922. t[121] = 243;
  20923. t[122] = 242;
  20924. t[123] = 244;
  20925. t[124] = 246;
  20926. t[125] = 245;
  20927. t[126] = 250;
  20928. t[127] = 249;
  20929. t[128] = 251;
  20930. t[129] = 252;
  20931. t[130] = 8224;
  20932. t[131] = 176;
  20933. t[132] = 162;
  20934. t[133] = 163;
  20935. t[134] = 167;
  20936. t[135] = 8226;
  20937. t[136] = 182;
  20938. t[137] = 223;
  20939. t[138] = 174;
  20940. t[139] = 169;
  20941. t[140] = 8482;
  20942. t[141] = 180;
  20943. t[142] = 168;
  20944. t[143] = 8800;
  20945. t[144] = 198;
  20946. t[145] = 216;
  20947. t[146] = 8734;
  20948. t[147] = 177;
  20949. t[148] = 8804;
  20950. t[149] = 8805;
  20951. t[150] = 165;
  20952. t[151] = 181;
  20953. t[152] = 8706;
  20954. t[153] = 8721;
  20955. t[154] = 8719;
  20956. t[156] = 8747;
  20957. t[157] = 170;
  20958. t[158] = 186;
  20959. t[159] = 8486;
  20960. t[160] = 230;
  20961. t[161] = 248;
  20962. t[162] = 191;
  20963. t[163] = 161;
  20964. t[164] = 172;
  20965. t[165] = 8730;
  20966. t[166] = 402;
  20967. t[167] = 8776;
  20968. t[168] = 8710;
  20969. t[169] = 171;
  20970. t[170] = 187;
  20971. t[171] = 8230;
  20972. t[210] = 218;
  20973. t[223] = 711;
  20974. t[224] = 321;
  20975. t[225] = 322;
  20976. t[227] = 353;
  20977. t[229] = 382;
  20978. t[234] = 253;
  20979. t[252] = 263;
  20980. t[253] = 268;
  20981. t[254] = 269;
  20982. t[258] = 258;
  20983. t[260] = 260;
  20984. t[261] = 261;
  20985. t[265] = 280;
  20986. t[266] = 281;
  20987. t[268] = 283;
  20988. t[269] = 313;
  20989. t[275] = 323;
  20990. t[276] = 324;
  20991. t[278] = 328;
  20992. t[284] = 345;
  20993. t[285] = 346;
  20994. t[286] = 347;
  20995. t[292] = 367;
  20996. t[295] = 377;
  20997. t[296] = 378;
  20998. t[298] = 380;
  20999. t[305] = 963;
  21000. t[306] = 964;
  21001. t[307] = 966;
  21002. t[308] = 8215;
  21003. t[309] = 8252;
  21004. t[310] = 8319;
  21005. t[311] = 8359;
  21006. t[312] = 8592;
  21007. t[313] = 8593;
  21008. t[337] = 9552;
  21009. t[493] = 1039;
  21010. t[494] = 1040;
  21011. t[705] = 1524;
  21012. t[706] = 8362;
  21013. t[710] = 64288;
  21014. t[711] = 64298;
  21015. t[759] = 1617;
  21016. t[761] = 1776;
  21017. t[763] = 1778;
  21018. t[775] = 1652;
  21019. t[777] = 1764;
  21020. t[778] = 1780;
  21021. t[779] = 1781;
  21022. t[780] = 1782;
  21023. t[782] = 771;
  21024. t[783] = 64726;
  21025. t[786] = 8363;
  21026. t[788] = 8532;
  21027. t[790] = 768;
  21028. t[791] = 769;
  21029. t[792] = 768;
  21030. t[795] = 803;
  21031. t[797] = 64336;
  21032. t[798] = 64337;
  21033. t[799] = 64342;
  21034. t[800] = 64343;
  21035. t[801] = 64344;
  21036. t[802] = 64345;
  21037. t[803] = 64362;
  21038. t[804] = 64363;
  21039. t[805] = 64364;
  21040. t[2424] = 7821;
  21041. t[2425] = 7822;
  21042. t[2426] = 7823;
  21043. t[2427] = 7824;
  21044. t[2428] = 7825;
  21045. t[2429] = 7826;
  21046. t[2430] = 7827;
  21047. t[2433] = 7682;
  21048. t[2678] = 8045;
  21049. t[2679] = 8046;
  21050. t[2830] = 1552;
  21051. t[2838] = 686;
  21052. t[2840] = 751;
  21053. t[2842] = 753;
  21054. t[2843] = 754;
  21055. t[2844] = 755;
  21056. t[2846] = 757;
  21057. t[2856] = 767;
  21058. t[2857] = 848;
  21059. t[2858] = 849;
  21060. t[2862] = 853;
  21061. t[2863] = 854;
  21062. t[2864] = 855;
  21063. t[2865] = 861;
  21064. t[2866] = 862;
  21065. t[2906] = 7460;
  21066. t[2908] = 7462;
  21067. t[2909] = 7463;
  21068. t[2910] = 7464;
  21069. t[2912] = 7466;
  21070. t[2913] = 7467;
  21071. t[2914] = 7468;
  21072. t[2916] = 7470;
  21073. t[2917] = 7471;
  21074. t[2918] = 7472;
  21075. t[2920] = 7474;
  21076. t[2921] = 7475;
  21077. t[2922] = 7476;
  21078. t[2924] = 7478;
  21079. t[2925] = 7479;
  21080. t[2926] = 7480;
  21081. t[2928] = 7482;
  21082. t[2929] = 7483;
  21083. t[2930] = 7484;
  21084. t[2932] = 7486;
  21085. t[2933] = 7487;
  21086. t[2934] = 7488;
  21087. t[2936] = 7490;
  21088. t[2937] = 7491;
  21089. t[2938] = 7492;
  21090. t[2940] = 7494;
  21091. t[2941] = 7495;
  21092. t[2942] = 7496;
  21093. t[2944] = 7498;
  21094. t[2946] = 7500;
  21095. t[2948] = 7502;
  21096. t[2950] = 7504;
  21097. t[2951] = 7505;
  21098. t[2952] = 7506;
  21099. t[2954] = 7508;
  21100. t[2955] = 7509;
  21101. t[2956] = 7510;
  21102. t[2958] = 7512;
  21103. t[2959] = 7513;
  21104. t[2960] = 7514;
  21105. t[2962] = 7516;
  21106. t[2963] = 7517;
  21107. t[2964] = 7518;
  21108. t[2966] = 7520;
  21109. t[2967] = 7521;
  21110. t[2968] = 7522;
  21111. t[2970] = 7524;
  21112. t[2971] = 7525;
  21113. t[2972] = 7526;
  21114. t[2974] = 7528;
  21115. t[2975] = 7529;
  21116. t[2976] = 7530;
  21117. t[2978] = 1537;
  21118. t[2979] = 1538;
  21119. t[2980] = 1539;
  21120. t[2982] = 1549;
  21121. t[2983] = 1551;
  21122. t[2984] = 1552;
  21123. t[2986] = 1554;
  21124. t[2987] = 1555;
  21125. t[2988] = 1556;
  21126. t[2990] = 1623;
  21127. t[2991] = 1624;
  21128. t[2995] = 1775;
  21129. t[2999] = 1791;
  21130. t[3002] = 64290;
  21131. t[3003] = 64291;
  21132. t[3004] = 64292;
  21133. t[3006] = 64294;
  21134. t[3007] = 64295;
  21135. t[3008] = 64296;
  21136. t[3011] = 1900;
  21137. t[3014] = 8223;
  21138. t[3015] = 8244;
  21139. t[3017] = 7532;
  21140. t[3018] = 7533;
  21141. t[3019] = 7534;
  21142. t[3075] = 7590;
  21143. t[3076] = 7591;
  21144. t[3079] = 7594;
  21145. t[3080] = 7595;
  21146. t[3083] = 7598;
  21147. t[3084] = 7599;
  21148. t[3087] = 7602;
  21149. t[3088] = 7603;
  21150. t[3091] = 7606;
  21151. t[3092] = 7607;
  21152. t[3095] = 7610;
  21153. t[3096] = 7611;
  21154. t[3099] = 7614;
  21155. t[3100] = 7615;
  21156. t[3103] = 7618;
  21157. t[3104] = 7619;
  21158. t[3107] = 8337;
  21159. t[3108] = 8338;
  21160. t[3116] = 1884;
  21161. t[3119] = 1885;
  21162. t[3120] = 1885;
  21163. t[3123] = 1886;
  21164. t[3124] = 1886;
  21165. t[3127] = 1887;
  21166. t[3128] = 1887;
  21167. t[3131] = 1888;
  21168. t[3132] = 1888;
  21169. t[3135] = 1889;
  21170. t[3136] = 1889;
  21171. t[3139] = 1890;
  21172. t[3140] = 1890;
  21173. t[3143] = 1891;
  21174. t[3144] = 1891;
  21175. t[3147] = 1892;
  21176. t[3148] = 1892;
  21177. t[3153] = 580;
  21178. t[3154] = 581;
  21179. t[3157] = 584;
  21180. t[3158] = 585;
  21181. t[3161] = 588;
  21182. t[3162] = 589;
  21183. t[3165] = 891;
  21184. t[3166] = 892;
  21185. t[3169] = 1274;
  21186. t[3170] = 1275;
  21187. t[3173] = 1278;
  21188. t[3174] = 1279;
  21189. t[3181] = 7622;
  21190. t[3182] = 7623;
  21191. t[3282] = 11799;
  21192. t[3316] = 578;
  21193. t[3379] = 42785;
  21194. t[3393] = 1159;
  21195. t[3416] = 8377;
  21196. });
  21197. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21198. t[227] = 322;
  21199. t[264] = 261;
  21200. t[291] = 346;
  21201. });
  21202. exports.getStdFontMap = getStdFontMap;
  21203. exports.getNonStdFontMap = getNonStdFontMap;
  21204. exports.getSerifFonts = getSerifFonts;
  21205. exports.getSymbolsFonts = getSymbolsFonts;
  21206. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21207. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21208. }));
  21209. (function (root, factory) {
  21210. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21211. }(this, function (exports, sharedUtil) {
  21212. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21213. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21214. t[63721] = 0x00A9;
  21215. t[63193] = 0x00A9;
  21216. t[63720] = 0x00AE;
  21217. t[63194] = 0x00AE;
  21218. t[63722] = 0x2122;
  21219. t[63195] = 0x2122;
  21220. t[63729] = 0x23A7;
  21221. t[63730] = 0x23A8;
  21222. t[63731] = 0x23A9;
  21223. t[63740] = 0x23AB;
  21224. t[63741] = 0x23AC;
  21225. t[63742] = 0x23AD;
  21226. t[63726] = 0x23A1;
  21227. t[63727] = 0x23A2;
  21228. t[63728] = 0x23A3;
  21229. t[63737] = 0x23A4;
  21230. t[63738] = 0x23A5;
  21231. t[63739] = 0x23A6;
  21232. t[63723] = 0x239B;
  21233. t[63724] = 0x239C;
  21234. t[63725] = 0x239D;
  21235. t[63734] = 0x239E;
  21236. t[63735] = 0x239F;
  21237. t[63736] = 0x23A0;
  21238. });
  21239. function mapSpecialUnicodeValues(code) {
  21240. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21241. return 0;
  21242. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21243. return getSpecialPUASymbols()[code] || code;
  21244. }
  21245. return code;
  21246. }
  21247. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21248. var unicode = glyphsUnicodeMap[name];
  21249. if (unicode !== undefined) {
  21250. return unicode;
  21251. }
  21252. if (!name) {
  21253. return -1;
  21254. }
  21255. if (name[0] === 'u') {
  21256. var nameLen = name.length, hexStr;
  21257. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21258. hexStr = name.substr(3);
  21259. } else if (nameLen >= 5 && nameLen <= 7) {
  21260. hexStr = name.substr(1);
  21261. } else {
  21262. return -1;
  21263. }
  21264. if (hexStr === hexStr.toUpperCase()) {
  21265. unicode = parseInt(hexStr, 16);
  21266. if (unicode >= 0) {
  21267. return unicode;
  21268. }
  21269. }
  21270. }
  21271. return -1;
  21272. }
  21273. var UnicodeRanges = [
  21274. {
  21275. 'begin': 0x0000,
  21276. 'end': 0x007F
  21277. },
  21278. {
  21279. 'begin': 0x0080,
  21280. 'end': 0x00FF
  21281. },
  21282. {
  21283. 'begin': 0x0100,
  21284. 'end': 0x017F
  21285. },
  21286. {
  21287. 'begin': 0x0180,
  21288. 'end': 0x024F
  21289. },
  21290. {
  21291. 'begin': 0x0250,
  21292. 'end': 0x02AF
  21293. },
  21294. {
  21295. 'begin': 0x02B0,
  21296. 'end': 0x02FF
  21297. },
  21298. {
  21299. 'begin': 0x0300,
  21300. 'end': 0x036F
  21301. },
  21302. {
  21303. 'begin': 0x0370,
  21304. 'end': 0x03FF
  21305. },
  21306. {
  21307. 'begin': 0x2C80,
  21308. 'end': 0x2CFF
  21309. },
  21310. {
  21311. 'begin': 0x0400,
  21312. 'end': 0x04FF
  21313. },
  21314. {
  21315. 'begin': 0x0530,
  21316. 'end': 0x058F
  21317. },
  21318. {
  21319. 'begin': 0x0590,
  21320. 'end': 0x05FF
  21321. },
  21322. {
  21323. 'begin': 0xA500,
  21324. 'end': 0xA63F
  21325. },
  21326. {
  21327. 'begin': 0x0600,
  21328. 'end': 0x06FF
  21329. },
  21330. {
  21331. 'begin': 0x07C0,
  21332. 'end': 0x07FF
  21333. },
  21334. {
  21335. 'begin': 0x0900,
  21336. 'end': 0x097F
  21337. },
  21338. {
  21339. 'begin': 0x0980,
  21340. 'end': 0x09FF
  21341. },
  21342. {
  21343. 'begin': 0x0A00,
  21344. 'end': 0x0A7F
  21345. },
  21346. {
  21347. 'begin': 0x0A80,
  21348. 'end': 0x0AFF
  21349. },
  21350. {
  21351. 'begin': 0x0B00,
  21352. 'end': 0x0B7F
  21353. },
  21354. {
  21355. 'begin': 0x0B80,
  21356. 'end': 0x0BFF
  21357. },
  21358. {
  21359. 'begin': 0x0C00,
  21360. 'end': 0x0C7F
  21361. },
  21362. {
  21363. 'begin': 0x0C80,
  21364. 'end': 0x0CFF
  21365. },
  21366. {
  21367. 'begin': 0x0D00,
  21368. 'end': 0x0D7F
  21369. },
  21370. {
  21371. 'begin': 0x0E00,
  21372. 'end': 0x0E7F
  21373. },
  21374. {
  21375. 'begin': 0x0E80,
  21376. 'end': 0x0EFF
  21377. },
  21378. {
  21379. 'begin': 0x10A0,
  21380. 'end': 0x10FF
  21381. },
  21382. {
  21383. 'begin': 0x1B00,
  21384. 'end': 0x1B7F
  21385. },
  21386. {
  21387. 'begin': 0x1100,
  21388. 'end': 0x11FF
  21389. },
  21390. {
  21391. 'begin': 0x1E00,
  21392. 'end': 0x1EFF
  21393. },
  21394. {
  21395. 'begin': 0x1F00,
  21396. 'end': 0x1FFF
  21397. },
  21398. {
  21399. 'begin': 0x2000,
  21400. 'end': 0x206F
  21401. },
  21402. {
  21403. 'begin': 0x2070,
  21404. 'end': 0x209F
  21405. },
  21406. {
  21407. 'begin': 0x20A0,
  21408. 'end': 0x20CF
  21409. },
  21410. {
  21411. 'begin': 0x20D0,
  21412. 'end': 0x20FF
  21413. },
  21414. {
  21415. 'begin': 0x2100,
  21416. 'end': 0x214F
  21417. },
  21418. {
  21419. 'begin': 0x2150,
  21420. 'end': 0x218F
  21421. },
  21422. {
  21423. 'begin': 0x2190,
  21424. 'end': 0x21FF
  21425. },
  21426. {
  21427. 'begin': 0x2200,
  21428. 'end': 0x22FF
  21429. },
  21430. {
  21431. 'begin': 0x2300,
  21432. 'end': 0x23FF
  21433. },
  21434. {
  21435. 'begin': 0x2400,
  21436. 'end': 0x243F
  21437. },
  21438. {
  21439. 'begin': 0x2440,
  21440. 'end': 0x245F
  21441. },
  21442. {
  21443. 'begin': 0x2460,
  21444. 'end': 0x24FF
  21445. },
  21446. {
  21447. 'begin': 0x2500,
  21448. 'end': 0x257F
  21449. },
  21450. {
  21451. 'begin': 0x2580,
  21452. 'end': 0x259F
  21453. },
  21454. {
  21455. 'begin': 0x25A0,
  21456. 'end': 0x25FF
  21457. },
  21458. {
  21459. 'begin': 0x2600,
  21460. 'end': 0x26FF
  21461. },
  21462. {
  21463. 'begin': 0x2700,
  21464. 'end': 0x27BF
  21465. },
  21466. {
  21467. 'begin': 0x3000,
  21468. 'end': 0x303F
  21469. },
  21470. {
  21471. 'begin': 0x3040,
  21472. 'end': 0x309F
  21473. },
  21474. {
  21475. 'begin': 0x30A0,
  21476. 'end': 0x30FF
  21477. },
  21478. {
  21479. 'begin': 0x3100,
  21480. 'end': 0x312F
  21481. },
  21482. {
  21483. 'begin': 0x3130,
  21484. 'end': 0x318F
  21485. },
  21486. {
  21487. 'begin': 0xA840,
  21488. 'end': 0xA87F
  21489. },
  21490. {
  21491. 'begin': 0x3200,
  21492. 'end': 0x32FF
  21493. },
  21494. {
  21495. 'begin': 0x3300,
  21496. 'end': 0x33FF
  21497. },
  21498. {
  21499. 'begin': 0xAC00,
  21500. 'end': 0xD7AF
  21501. },
  21502. {
  21503. 'begin': 0xD800,
  21504. 'end': 0xDFFF
  21505. },
  21506. {
  21507. 'begin': 0x10900,
  21508. 'end': 0x1091F
  21509. },
  21510. {
  21511. 'begin': 0x4E00,
  21512. 'end': 0x9FFF
  21513. },
  21514. {
  21515. 'begin': 0xE000,
  21516. 'end': 0xF8FF
  21517. },
  21518. {
  21519. 'begin': 0x31C0,
  21520. 'end': 0x31EF
  21521. },
  21522. {
  21523. 'begin': 0xFB00,
  21524. 'end': 0xFB4F
  21525. },
  21526. {
  21527. 'begin': 0xFB50,
  21528. 'end': 0xFDFF
  21529. },
  21530. {
  21531. 'begin': 0xFE20,
  21532. 'end': 0xFE2F
  21533. },
  21534. {
  21535. 'begin': 0xFE10,
  21536. 'end': 0xFE1F
  21537. },
  21538. {
  21539. 'begin': 0xFE50,
  21540. 'end': 0xFE6F
  21541. },
  21542. {
  21543. 'begin': 0xFE70,
  21544. 'end': 0xFEFF
  21545. },
  21546. {
  21547. 'begin': 0xFF00,
  21548. 'end': 0xFFEF
  21549. },
  21550. {
  21551. 'begin': 0xFFF0,
  21552. 'end': 0xFFFF
  21553. },
  21554. {
  21555. 'begin': 0x0F00,
  21556. 'end': 0x0FFF
  21557. },
  21558. {
  21559. 'begin': 0x0700,
  21560. 'end': 0x074F
  21561. },
  21562. {
  21563. 'begin': 0x0780,
  21564. 'end': 0x07BF
  21565. },
  21566. {
  21567. 'begin': 0x0D80,
  21568. 'end': 0x0DFF
  21569. },
  21570. {
  21571. 'begin': 0x1000,
  21572. 'end': 0x109F
  21573. },
  21574. {
  21575. 'begin': 0x1200,
  21576. 'end': 0x137F
  21577. },
  21578. {
  21579. 'begin': 0x13A0,
  21580. 'end': 0x13FF
  21581. },
  21582. {
  21583. 'begin': 0x1400,
  21584. 'end': 0x167F
  21585. },
  21586. {
  21587. 'begin': 0x1680,
  21588. 'end': 0x169F
  21589. },
  21590. {
  21591. 'begin': 0x16A0,
  21592. 'end': 0x16FF
  21593. },
  21594. {
  21595. 'begin': 0x1780,
  21596. 'end': 0x17FF
  21597. },
  21598. {
  21599. 'begin': 0x1800,
  21600. 'end': 0x18AF
  21601. },
  21602. {
  21603. 'begin': 0x2800,
  21604. 'end': 0x28FF
  21605. },
  21606. {
  21607. 'begin': 0xA000,
  21608. 'end': 0xA48F
  21609. },
  21610. {
  21611. 'begin': 0x1700,
  21612. 'end': 0x171F
  21613. },
  21614. {
  21615. 'begin': 0x10300,
  21616. 'end': 0x1032F
  21617. },
  21618. {
  21619. 'begin': 0x10330,
  21620. 'end': 0x1034F
  21621. },
  21622. {
  21623. 'begin': 0x10400,
  21624. 'end': 0x1044F
  21625. },
  21626. {
  21627. 'begin': 0x1D000,
  21628. 'end': 0x1D0FF
  21629. },
  21630. {
  21631. 'begin': 0x1D400,
  21632. 'end': 0x1D7FF
  21633. },
  21634. {
  21635. 'begin': 0xFF000,
  21636. 'end': 0xFFFFD
  21637. },
  21638. {
  21639. 'begin': 0xFE00,
  21640. 'end': 0xFE0F
  21641. },
  21642. {
  21643. 'begin': 0xE0000,
  21644. 'end': 0xE007F
  21645. },
  21646. {
  21647. 'begin': 0x1900,
  21648. 'end': 0x194F
  21649. },
  21650. {
  21651. 'begin': 0x1950,
  21652. 'end': 0x197F
  21653. },
  21654. {
  21655. 'begin': 0x1980,
  21656. 'end': 0x19DF
  21657. },
  21658. {
  21659. 'begin': 0x1A00,
  21660. 'end': 0x1A1F
  21661. },
  21662. {
  21663. 'begin': 0x2C00,
  21664. 'end': 0x2C5F
  21665. },
  21666. {
  21667. 'begin': 0x2D30,
  21668. 'end': 0x2D7F
  21669. },
  21670. {
  21671. 'begin': 0x4DC0,
  21672. 'end': 0x4DFF
  21673. },
  21674. {
  21675. 'begin': 0xA800,
  21676. 'end': 0xA82F
  21677. },
  21678. {
  21679. 'begin': 0x10000,
  21680. 'end': 0x1007F
  21681. },
  21682. {
  21683. 'begin': 0x10140,
  21684. 'end': 0x1018F
  21685. },
  21686. {
  21687. 'begin': 0x10380,
  21688. 'end': 0x1039F
  21689. },
  21690. {
  21691. 'begin': 0x103A0,
  21692. 'end': 0x103DF
  21693. },
  21694. {
  21695. 'begin': 0x10450,
  21696. 'end': 0x1047F
  21697. },
  21698. {
  21699. 'begin': 0x10480,
  21700. 'end': 0x104AF
  21701. },
  21702. {
  21703. 'begin': 0x10800,
  21704. 'end': 0x1083F
  21705. },
  21706. {
  21707. 'begin': 0x10A00,
  21708. 'end': 0x10A5F
  21709. },
  21710. {
  21711. 'begin': 0x1D300,
  21712. 'end': 0x1D35F
  21713. },
  21714. {
  21715. 'begin': 0x12000,
  21716. 'end': 0x123FF
  21717. },
  21718. {
  21719. 'begin': 0x1D360,
  21720. 'end': 0x1D37F
  21721. },
  21722. {
  21723. 'begin': 0x1B80,
  21724. 'end': 0x1BBF
  21725. },
  21726. {
  21727. 'begin': 0x1C00,
  21728. 'end': 0x1C4F
  21729. },
  21730. {
  21731. 'begin': 0x1C50,
  21732. 'end': 0x1C7F
  21733. },
  21734. {
  21735. 'begin': 0xA880,
  21736. 'end': 0xA8DF
  21737. },
  21738. {
  21739. 'begin': 0xA900,
  21740. 'end': 0xA92F
  21741. },
  21742. {
  21743. 'begin': 0xA930,
  21744. 'end': 0xA95F
  21745. },
  21746. {
  21747. 'begin': 0xAA00,
  21748. 'end': 0xAA5F
  21749. },
  21750. {
  21751. 'begin': 0x10190,
  21752. 'end': 0x101CF
  21753. },
  21754. {
  21755. 'begin': 0x101D0,
  21756. 'end': 0x101FF
  21757. },
  21758. {
  21759. 'begin': 0x102A0,
  21760. 'end': 0x102DF
  21761. },
  21762. {
  21763. 'begin': 0x1F030,
  21764. 'end': 0x1F09F
  21765. }
  21766. ];
  21767. function getUnicodeRangeFor(value) {
  21768. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21769. var range = UnicodeRanges[i];
  21770. if (value >= range.begin && value < range.end) {
  21771. return i;
  21772. }
  21773. }
  21774. return -1;
  21775. }
  21776. function isRTLRangeFor(value) {
  21777. var range = UnicodeRanges[13];
  21778. if (value >= range.begin && value < range.end) {
  21779. return true;
  21780. }
  21781. range = UnicodeRanges[11];
  21782. if (value >= range.begin && value < range.end) {
  21783. return true;
  21784. }
  21785. return false;
  21786. }
  21787. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21788. t['\u00A8'] = '\u0020\u0308';
  21789. t['\u00AF'] = '\u0020\u0304';
  21790. t['\u00B4'] = '\u0020\u0301';
  21791. t['\u00B5'] = '\u03BC';
  21792. t['\u00B8'] = '\u0020\u0327';
  21793. t['\u0132'] = '\u0049\u004A';
  21794. t['\u0133'] = '\u0069\u006A';
  21795. t['\u013F'] = '\u004C\u00B7';
  21796. t['\u0140'] = '\u006C\u00B7';
  21797. t['\u0149'] = '\u02BC\u006E';
  21798. t['\u017F'] = '\u0073';
  21799. t['\u01C4'] = '\u0044\u017D';
  21800. t['\u01C5'] = '\u0044\u017E';
  21801. t['\u01C6'] = '\u0064\u017E';
  21802. t['\u01C7'] = '\u004C\u004A';
  21803. t['\u01C8'] = '\u004C\u006A';
  21804. t['\u01C9'] = '\u006C\u006A';
  21805. t['\u01CA'] = '\u004E\u004A';
  21806. t['\u01CB'] = '\u004E\u006A';
  21807. t['\u01CC'] = '\u006E\u006A';
  21808. t['\u01F1'] = '\u0044\u005A';
  21809. t['\u01F2'] = '\u0044\u007A';
  21810. t['\u01F3'] = '\u0064\u007A';
  21811. t['\u02D8'] = '\u0020\u0306';
  21812. t['\u02D9'] = '\u0020\u0307';
  21813. t['\u02DA'] = '\u0020\u030A';
  21814. t['\u02DB'] = '\u0020\u0328';
  21815. t['\u02DC'] = '\u0020\u0303';
  21816. t['\u02DD'] = '\u0020\u030B';
  21817. t['\u037A'] = '\u0020\u0345';
  21818. t['\u0384'] = '\u0020\u0301';
  21819. t['\u03D0'] = '\u03B2';
  21820. t['\u03D1'] = '\u03B8';
  21821. t['\u03D2'] = '\u03A5';
  21822. t['\u03D5'] = '\u03C6';
  21823. t['\u03D6'] = '\u03C0';
  21824. t['\u03F0'] = '\u03BA';
  21825. t['\u03F1'] = '\u03C1';
  21826. t['\u03F2'] = '\u03C2';
  21827. t['\u03F4'] = '\u0398';
  21828. t['\u03F5'] = '\u03B5';
  21829. t['\u03F9'] = '\u03A3';
  21830. t['\u0587'] = '\u0565\u0582';
  21831. t['\u0675'] = '\u0627\u0674';
  21832. t['\u0676'] = '\u0648\u0674';
  21833. t['\u0677'] = '\u06C7\u0674';
  21834. t['\u0678'] = '\u064A\u0674';
  21835. t['\u0E33'] = '\u0E4D\u0E32';
  21836. t['\u0EB3'] = '\u0ECD\u0EB2';
  21837. t['\u0EDC'] = '\u0EAB\u0E99';
  21838. t['\u0EDD'] = '\u0EAB\u0EA1';
  21839. t['\u0F77'] = '\u0FB2\u0F81';
  21840. t['\u0F79'] = '\u0FB3\u0F81';
  21841. t['\u1E9A'] = '\u0061\u02BE';
  21842. t['\u1FBD'] = '\u0020\u0313';
  21843. t['\u1FBF'] = '\u0020\u0313';
  21844. t['\u1FC0'] = '\u0020\u0342';
  21845. t['\u1FFE'] = '\u0020\u0314';
  21846. t['\u2002'] = '\u0020';
  21847. t['\u2003'] = '\u0020';
  21848. t['\u2004'] = '\u0020';
  21849. t['\u2005'] = '\u0020';
  21850. t['\u2006'] = '\u0020';
  21851. t['\u2008'] = '\u0020';
  21852. t['\u2009'] = '\u0020';
  21853. t['\u200A'] = '\u0020';
  21854. t['\u2017'] = '\u0020\u0333';
  21855. t['\u2024'] = '\u002E';
  21856. t['\u2025'] = '\u002E\u002E';
  21857. t['\u2026'] = '\u002E\u002E\u002E';
  21858. t['\u2033'] = '\u2032\u2032';
  21859. t['\u2034'] = '\u2032\u2032\u2032';
  21860. t['\u2036'] = '\u2035\u2035';
  21861. t['\u2037'] = '\u2035\u2035\u2035';
  21862. t['\u203C'] = '\u0021\u0021';
  21863. t['\u203E'] = '\u0020\u0305';
  21864. t['\u2047'] = '\u003F\u003F';
  21865. t['\u2048'] = '\u003F\u0021';
  21866. t['\u2049'] = '\u0021\u003F';
  21867. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21868. t['\u205F'] = '\u0020';
  21869. t['\u20A8'] = '\u0052\u0073';
  21870. t['\u2100'] = '\u0061\u002F\u0063';
  21871. t['\u2101'] = '\u0061\u002F\u0073';
  21872. t['\u2103'] = '\u00B0\u0043';
  21873. t['\u2105'] = '\u0063\u002F\u006F';
  21874. t['\u2106'] = '\u0063\u002F\u0075';
  21875. t['\u2107'] = '\u0190';
  21876. t['\u2109'] = '\u00B0\u0046';
  21877. t['\u2116'] = '\u004E\u006F';
  21878. t['\u2121'] = '\u0054\u0045\u004C';
  21879. t['\u2135'] = '\u05D0';
  21880. t['\u2136'] = '\u05D1';
  21881. t['\u2137'] = '\u05D2';
  21882. t['\u2138'] = '\u05D3';
  21883. t['\u213B'] = '\u0046\u0041\u0058';
  21884. t['\u2160'] = '\u0049';
  21885. t['\u2161'] = '\u0049\u0049';
  21886. t['\u2162'] = '\u0049\u0049\u0049';
  21887. t['\u2163'] = '\u0049\u0056';
  21888. t['\u2164'] = '\u0056';
  21889. t['\u2165'] = '\u0056\u0049';
  21890. t['\u2166'] = '\u0056\u0049\u0049';
  21891. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21892. t['\u2168'] = '\u0049\u0058';
  21893. t['\u2169'] = '\u0058';
  21894. t['\u216A'] = '\u0058\u0049';
  21895. t['\u216B'] = '\u0058\u0049\u0049';
  21896. t['\u216C'] = '\u004C';
  21897. t['\u216D'] = '\u0043';
  21898. t['\u216E'] = '\u0044';
  21899. t['\u216F'] = '\u004D';
  21900. t['\u2170'] = '\u0069';
  21901. t['\u2171'] = '\u0069\u0069';
  21902. t['\u2172'] = '\u0069\u0069\u0069';
  21903. t['\u2173'] = '\u0069\u0076';
  21904. t['\u2174'] = '\u0076';
  21905. t['\u2175'] = '\u0076\u0069';
  21906. t['\u2176'] = '\u0076\u0069\u0069';
  21907. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21908. t['\u2178'] = '\u0069\u0078';
  21909. t['\u2179'] = '\u0078';
  21910. t['\u217A'] = '\u0078\u0069';
  21911. t['\u217B'] = '\u0078\u0069\u0069';
  21912. t['\u217C'] = '\u006C';
  21913. t['\u217D'] = '\u0063';
  21914. t['\u217E'] = '\u0064';
  21915. t['\u217F'] = '\u006D';
  21916. t['\u222C'] = '\u222B\u222B';
  21917. t['\u222D'] = '\u222B\u222B\u222B';
  21918. t['\u222F'] = '\u222E\u222E';
  21919. t['\u2230'] = '\u222E\u222E\u222E';
  21920. t['\u2474'] = '\u0028\u0031\u0029';
  21921. t['\u2475'] = '\u0028\u0032\u0029';
  21922. t['\u2476'] = '\u0028\u0033\u0029';
  21923. t['\u2477'] = '\u0028\u0034\u0029';
  21924. t['\u2478'] = '\u0028\u0035\u0029';
  21925. t['\u2479'] = '\u0028\u0036\u0029';
  21926. t['\u247A'] = '\u0028\u0037\u0029';
  21927. t['\u247B'] = '\u0028\u0038\u0029';
  21928. t['\u247C'] = '\u0028\u0039\u0029';
  21929. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21930. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21931. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21932. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21933. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21934. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21935. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21936. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21937. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21938. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21939. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21940. t['\u2488'] = '\u0031\u002E';
  21941. t['\u2489'] = '\u0032\u002E';
  21942. t['\u248A'] = '\u0033\u002E';
  21943. t['\u248B'] = '\u0034\u002E';
  21944. t['\u248C'] = '\u0035\u002E';
  21945. t['\u248D'] = '\u0036\u002E';
  21946. t['\u248E'] = '\u0037\u002E';
  21947. t['\u248F'] = '\u0038\u002E';
  21948. t['\u2490'] = '\u0039\u002E';
  21949. t['\u2491'] = '\u0031\u0030\u002E';
  21950. t['\u2492'] = '\u0031\u0031\u002E';
  21951. t['\u2493'] = '\u0031\u0032\u002E';
  21952. t['\u2494'] = '\u0031\u0033\u002E';
  21953. t['\u2495'] = '\u0031\u0034\u002E';
  21954. t['\u2496'] = '\u0031\u0035\u002E';
  21955. t['\u2497'] = '\u0031\u0036\u002E';
  21956. t['\u2498'] = '\u0031\u0037\u002E';
  21957. t['\u2499'] = '\u0031\u0038\u002E';
  21958. t['\u249A'] = '\u0031\u0039\u002E';
  21959. t['\u249B'] = '\u0032\u0030\u002E';
  21960. t['\u249C'] = '\u0028\u0061\u0029';
  21961. t['\u249D'] = '\u0028\u0062\u0029';
  21962. t['\u249E'] = '\u0028\u0063\u0029';
  21963. t['\u249F'] = '\u0028\u0064\u0029';
  21964. t['\u24A0'] = '\u0028\u0065\u0029';
  21965. t['\u24A1'] = '\u0028\u0066\u0029';
  21966. t['\u24A2'] = '\u0028\u0067\u0029';
  21967. t['\u24A3'] = '\u0028\u0068\u0029';
  21968. t['\u24A4'] = '\u0028\u0069\u0029';
  21969. t['\u24A5'] = '\u0028\u006A\u0029';
  21970. t['\u24A6'] = '\u0028\u006B\u0029';
  21971. t['\u24A7'] = '\u0028\u006C\u0029';
  21972. t['\u24A8'] = '\u0028\u006D\u0029';
  21973. t['\u24A9'] = '\u0028\u006E\u0029';
  21974. t['\u24AA'] = '\u0028\u006F\u0029';
  21975. t['\u24AB'] = '\u0028\u0070\u0029';
  21976. t['\u24AC'] = '\u0028\u0071\u0029';
  21977. t['\u24AD'] = '\u0028\u0072\u0029';
  21978. t['\u24AE'] = '\u0028\u0073\u0029';
  21979. t['\u24AF'] = '\u0028\u0074\u0029';
  21980. t['\u24B0'] = '\u0028\u0075\u0029';
  21981. t['\u24B1'] = '\u0028\u0076\u0029';
  21982. t['\u24B2'] = '\u0028\u0077\u0029';
  21983. t['\u24B3'] = '\u0028\u0078\u0029';
  21984. t['\u24B4'] = '\u0028\u0079\u0029';
  21985. t['\u24B5'] = '\u0028\u007A\u0029';
  21986. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21987. t['\u2A74'] = '\u003A\u003A\u003D';
  21988. t['\u2A75'] = '\u003D\u003D';
  21989. t['\u2A76'] = '\u003D\u003D\u003D';
  21990. t['\u2E9F'] = '\u6BCD';
  21991. t['\u2EF3'] = '\u9F9F';
  21992. t['\u2F00'] = '\u4E00';
  21993. t['\u2F01'] = '\u4E28';
  21994. t['\u2F02'] = '\u4E36';
  21995. t['\u2F03'] = '\u4E3F';
  21996. t['\u2F04'] = '\u4E59';
  21997. t['\u2F05'] = '\u4E85';
  21998. t['\u2F06'] = '\u4E8C';
  21999. t['\u2F07'] = '\u4EA0';
  22000. t['\u2F08'] = '\u4EBA';
  22001. t['\u2F09'] = '\u513F';
  22002. t['\u2F0A'] = '\u5165';
  22003. t['\u2F0B'] = '\u516B';
  22004. t['\u2F0C'] = '\u5182';
  22005. t['\u2F0D'] = '\u5196';
  22006. t['\u2F0E'] = '\u51AB';
  22007. t['\u2F0F'] = '\u51E0';
  22008. t['\u2F10'] = '\u51F5';
  22009. t['\u2F11'] = '\u5200';
  22010. t['\u2F12'] = '\u529B';
  22011. t['\u2F13'] = '\u52F9';
  22012. t['\u2F14'] = '\u5315';
  22013. t['\u2F15'] = '\u531A';
  22014. t['\u2F16'] = '\u5338';
  22015. t['\u2F17'] = '\u5341';
  22016. t['\u2F18'] = '\u535C';
  22017. t['\u2F19'] = '\u5369';
  22018. t['\u2F1A'] = '\u5382';
  22019. t['\u2F1B'] = '\u53B6';
  22020. t['\u2F1C'] = '\u53C8';
  22021. t['\u2F1D'] = '\u53E3';
  22022. t['\u2F1E'] = '\u56D7';
  22023. t['\u2F1F'] = '\u571F';
  22024. t['\u2F20'] = '\u58EB';
  22025. t['\u2F21'] = '\u5902';
  22026. t['\u2F22'] = '\u590A';
  22027. t['\u2F23'] = '\u5915';
  22028. t['\u2F24'] = '\u5927';
  22029. t['\u2F25'] = '\u5973';
  22030. t['\u2F26'] = '\u5B50';
  22031. t['\u2F27'] = '\u5B80';
  22032. t['\u2F28'] = '\u5BF8';
  22033. t['\u2F29'] = '\u5C0F';
  22034. t['\u2F2A'] = '\u5C22';
  22035. t['\u2F2B'] = '\u5C38';
  22036. t['\u2F2C'] = '\u5C6E';
  22037. t['\u2F2D'] = '\u5C71';
  22038. t['\u2F2E'] = '\u5DDB';
  22039. t['\u2F2F'] = '\u5DE5';
  22040. t['\u2F30'] = '\u5DF1';
  22041. t['\u2F31'] = '\u5DFE';
  22042. t['\u2F32'] = '\u5E72';
  22043. t['\u2F33'] = '\u5E7A';
  22044. t['\u2F34'] = '\u5E7F';
  22045. t['\u2F35'] = '\u5EF4';
  22046. t['\u2F36'] = '\u5EFE';
  22047. t['\u2F37'] = '\u5F0B';
  22048. t['\u2F38'] = '\u5F13';
  22049. t['\u2F39'] = '\u5F50';
  22050. t['\u2F3A'] = '\u5F61';
  22051. t['\u2F3B'] = '\u5F73';
  22052. t['\u2F3C'] = '\u5FC3';
  22053. t['\u2F3D'] = '\u6208';
  22054. t['\u2F3E'] = '\u6236';
  22055. t['\u2F3F'] = '\u624B';
  22056. t['\u2F40'] = '\u652F';
  22057. t['\u2F41'] = '\u6534';
  22058. t['\u2F42'] = '\u6587';
  22059. t['\u2F43'] = '\u6597';
  22060. t['\u2F44'] = '\u65A4';
  22061. t['\u2F45'] = '\u65B9';
  22062. t['\u2F46'] = '\u65E0';
  22063. t['\u2F47'] = '\u65E5';
  22064. t['\u2F48'] = '\u66F0';
  22065. t['\u2F49'] = '\u6708';
  22066. t['\u2F4A'] = '\u6728';
  22067. t['\u2F4B'] = '\u6B20';
  22068. t['\u2F4C'] = '\u6B62';
  22069. t['\u2F4D'] = '\u6B79';
  22070. t['\u2F4E'] = '\u6BB3';
  22071. t['\u2F4F'] = '\u6BCB';
  22072. t['\u2F50'] = '\u6BD4';
  22073. t['\u2F51'] = '\u6BDB';
  22074. t['\u2F52'] = '\u6C0F';
  22075. t['\u2F53'] = '\u6C14';
  22076. t['\u2F54'] = '\u6C34';
  22077. t['\u2F55'] = '\u706B';
  22078. t['\u2F56'] = '\u722A';
  22079. t['\u2F57'] = '\u7236';
  22080. t['\u2F58'] = '\u723B';
  22081. t['\u2F59'] = '\u723F';
  22082. t['\u2F5A'] = '\u7247';
  22083. t['\u2F5B'] = '\u7259';
  22084. t['\u2F5C'] = '\u725B';
  22085. t['\u2F5D'] = '\u72AC';
  22086. t['\u2F5E'] = '\u7384';
  22087. t['\u2F5F'] = '\u7389';
  22088. t['\u2F60'] = '\u74DC';
  22089. t['\u2F61'] = '\u74E6';
  22090. t['\u2F62'] = '\u7518';
  22091. t['\u2F63'] = '\u751F';
  22092. t['\u2F64'] = '\u7528';
  22093. t['\u2F65'] = '\u7530';
  22094. t['\u2F66'] = '\u758B';
  22095. t['\u2F67'] = '\u7592';
  22096. t['\u2F68'] = '\u7676';
  22097. t['\u2F69'] = '\u767D';
  22098. t['\u2F6A'] = '\u76AE';
  22099. t['\u2F6B'] = '\u76BF';
  22100. t['\u2F6C'] = '\u76EE';
  22101. t['\u2F6D'] = '\u77DB';
  22102. t['\u2F6E'] = '\u77E2';
  22103. t['\u2F6F'] = '\u77F3';
  22104. t['\u2F70'] = '\u793A';
  22105. t['\u2F71'] = '\u79B8';
  22106. t['\u2F72'] = '\u79BE';
  22107. t['\u2F73'] = '\u7A74';
  22108. t['\u2F74'] = '\u7ACB';
  22109. t['\u2F75'] = '\u7AF9';
  22110. t['\u2F76'] = '\u7C73';
  22111. t['\u2F77'] = '\u7CF8';
  22112. t['\u2F78'] = '\u7F36';
  22113. t['\u2F79'] = '\u7F51';
  22114. t['\u2F7A'] = '\u7F8A';
  22115. t['\u2F7B'] = '\u7FBD';
  22116. t['\u2F7C'] = '\u8001';
  22117. t['\u2F7D'] = '\u800C';
  22118. t['\u2F7E'] = '\u8012';
  22119. t['\u2F7F'] = '\u8033';
  22120. t['\u2F80'] = '\u807F';
  22121. t['\u2F81'] = '\u8089';
  22122. t['\u2F82'] = '\u81E3';
  22123. t['\u2F83'] = '\u81EA';
  22124. t['\u2F84'] = '\u81F3';
  22125. t['\u2F85'] = '\u81FC';
  22126. t['\u2F86'] = '\u820C';
  22127. t['\u2F87'] = '\u821B';
  22128. t['\u2F88'] = '\u821F';
  22129. t['\u2F89'] = '\u826E';
  22130. t['\u2F8A'] = '\u8272';
  22131. t['\u2F8B'] = '\u8278';
  22132. t['\u2F8C'] = '\u864D';
  22133. t['\u2F8D'] = '\u866B';
  22134. t['\u2F8E'] = '\u8840';
  22135. t['\u2F8F'] = '\u884C';
  22136. t['\u2F90'] = '\u8863';
  22137. t['\u2F91'] = '\u897E';
  22138. t['\u2F92'] = '\u898B';
  22139. t['\u2F93'] = '\u89D2';
  22140. t['\u2F94'] = '\u8A00';
  22141. t['\u2F95'] = '\u8C37';
  22142. t['\u2F96'] = '\u8C46';
  22143. t['\u2F97'] = '\u8C55';
  22144. t['\u2F98'] = '\u8C78';
  22145. t['\u2F99'] = '\u8C9D';
  22146. t['\u2F9A'] = '\u8D64';
  22147. t['\u2F9B'] = '\u8D70';
  22148. t['\u2F9C'] = '\u8DB3';
  22149. t['\u2F9D'] = '\u8EAB';
  22150. t['\u2F9E'] = '\u8ECA';
  22151. t['\u2F9F'] = '\u8F9B';
  22152. t['\u2FA0'] = '\u8FB0';
  22153. t['\u2FA1'] = '\u8FB5';
  22154. t['\u2FA2'] = '\u9091';
  22155. t['\u2FA3'] = '\u9149';
  22156. t['\u2FA4'] = '\u91C6';
  22157. t['\u2FA5'] = '\u91CC';
  22158. t['\u2FA6'] = '\u91D1';
  22159. t['\u2FA7'] = '\u9577';
  22160. t['\u2FA8'] = '\u9580';
  22161. t['\u2FA9'] = '\u961C';
  22162. t['\u2FAA'] = '\u96B6';
  22163. t['\u2FAB'] = '\u96B9';
  22164. t['\u2FAC'] = '\u96E8';
  22165. t['\u2FAD'] = '\u9751';
  22166. t['\u2FAE'] = '\u975E';
  22167. t['\u2FAF'] = '\u9762';
  22168. t['\u2FB0'] = '\u9769';
  22169. t['\u2FB1'] = '\u97CB';
  22170. t['\u2FB2'] = '\u97ED';
  22171. t['\u2FB3'] = '\u97F3';
  22172. t['\u2FB4'] = '\u9801';
  22173. t['\u2FB5'] = '\u98A8';
  22174. t['\u2FB6'] = '\u98DB';
  22175. t['\u2FB7'] = '\u98DF';
  22176. t['\u2FB8'] = '\u9996';
  22177. t['\u2FB9'] = '\u9999';
  22178. t['\u2FBA'] = '\u99AC';
  22179. t['\u2FBB'] = '\u9AA8';
  22180. t['\u2FBC'] = '\u9AD8';
  22181. t['\u2FBD'] = '\u9ADF';
  22182. t['\u2FBE'] = '\u9B25';
  22183. t['\u2FBF'] = '\u9B2F';
  22184. t['\u2FC0'] = '\u9B32';
  22185. t['\u2FC1'] = '\u9B3C';
  22186. t['\u2FC2'] = '\u9B5A';
  22187. t['\u2FC3'] = '\u9CE5';
  22188. t['\u2FC4'] = '\u9E75';
  22189. t['\u2FC5'] = '\u9E7F';
  22190. t['\u2FC6'] = '\u9EA5';
  22191. t['\u2FC7'] = '\u9EBB';
  22192. t['\u2FC8'] = '\u9EC3';
  22193. t['\u2FC9'] = '\u9ECD';
  22194. t['\u2FCA'] = '\u9ED1';
  22195. t['\u2FCB'] = '\u9EF9';
  22196. t['\u2FCC'] = '\u9EFD';
  22197. t['\u2FCD'] = '\u9F0E';
  22198. t['\u2FCE'] = '\u9F13';
  22199. t['\u2FCF'] = '\u9F20';
  22200. t['\u2FD0'] = '\u9F3B';
  22201. t['\u2FD1'] = '\u9F4A';
  22202. t['\u2FD2'] = '\u9F52';
  22203. t['\u2FD3'] = '\u9F8D';
  22204. t['\u2FD4'] = '\u9F9C';
  22205. t['\u2FD5'] = '\u9FA0';
  22206. t['\u3036'] = '\u3012';
  22207. t['\u3038'] = '\u5341';
  22208. t['\u3039'] = '\u5344';
  22209. t['\u303A'] = '\u5345';
  22210. t['\u309B'] = '\u0020\u3099';
  22211. t['\u309C'] = '\u0020\u309A';
  22212. t['\u3131'] = '\u1100';
  22213. t['\u3132'] = '\u1101';
  22214. t['\u3133'] = '\u11AA';
  22215. t['\u3134'] = '\u1102';
  22216. t['\u3135'] = '\u11AC';
  22217. t['\u3136'] = '\u11AD';
  22218. t['\u3137'] = '\u1103';
  22219. t['\u3138'] = '\u1104';
  22220. t['\u3139'] = '\u1105';
  22221. t['\u313A'] = '\u11B0';
  22222. t['\u313B'] = '\u11B1';
  22223. t['\u313C'] = '\u11B2';
  22224. t['\u313D'] = '\u11B3';
  22225. t['\u313E'] = '\u11B4';
  22226. t['\u313F'] = '\u11B5';
  22227. t['\u3140'] = '\u111A';
  22228. t['\u3141'] = '\u1106';
  22229. t['\u3142'] = '\u1107';
  22230. t['\u3143'] = '\u1108';
  22231. t['\u3144'] = '\u1121';
  22232. t['\u3145'] = '\u1109';
  22233. t['\u3146'] = '\u110A';
  22234. t['\u3147'] = '\u110B';
  22235. t['\u3148'] = '\u110C';
  22236. t['\u3149'] = '\u110D';
  22237. t['\u314A'] = '\u110E';
  22238. t['\u314B'] = '\u110F';
  22239. t['\u314C'] = '\u1110';
  22240. t['\u314D'] = '\u1111';
  22241. t['\u314E'] = '\u1112';
  22242. t['\u314F'] = '\u1161';
  22243. t['\u3150'] = '\u1162';
  22244. t['\u3151'] = '\u1163';
  22245. t['\u3152'] = '\u1164';
  22246. t['\u3153'] = '\u1165';
  22247. t['\u3154'] = '\u1166';
  22248. t['\u3155'] = '\u1167';
  22249. t['\u3156'] = '\u1168';
  22250. t['\u3157'] = '\u1169';
  22251. t['\u3158'] = '\u116A';
  22252. t['\u3159'] = '\u116B';
  22253. t['\u315A'] = '\u116C';
  22254. t['\u315B'] = '\u116D';
  22255. t['\u315C'] = '\u116E';
  22256. t['\u315D'] = '\u116F';
  22257. t['\u315E'] = '\u1170';
  22258. t['\u315F'] = '\u1171';
  22259. t['\u3160'] = '\u1172';
  22260. t['\u3161'] = '\u1173';
  22261. t['\u3162'] = '\u1174';
  22262. t['\u3163'] = '\u1175';
  22263. t['\u3164'] = '\u1160';
  22264. t['\u3165'] = '\u1114';
  22265. t['\u3166'] = '\u1115';
  22266. t['\u3167'] = '\u11C7';
  22267. t['\u3168'] = '\u11C8';
  22268. t['\u3169'] = '\u11CC';
  22269. t['\u316A'] = '\u11CE';
  22270. t['\u316B'] = '\u11D3';
  22271. t['\u316C'] = '\u11D7';
  22272. t['\u316D'] = '\u11D9';
  22273. t['\u316E'] = '\u111C';
  22274. t['\u316F'] = '\u11DD';
  22275. t['\u3170'] = '\u11DF';
  22276. t['\u3171'] = '\u111D';
  22277. t['\u3172'] = '\u111E';
  22278. t['\u3173'] = '\u1120';
  22279. t['\u3174'] = '\u1122';
  22280. t['\u3175'] = '\u1123';
  22281. t['\u3176'] = '\u1127';
  22282. t['\u3177'] = '\u1129';
  22283. t['\u3178'] = '\u112B';
  22284. t['\u3179'] = '\u112C';
  22285. t['\u317A'] = '\u112D';
  22286. t['\u317B'] = '\u112E';
  22287. t['\u317C'] = '\u112F';
  22288. t['\u317D'] = '\u1132';
  22289. t['\u317E'] = '\u1136';
  22290. t['\u317F'] = '\u1140';
  22291. t['\u3180'] = '\u1147';
  22292. t['\u3181'] = '\u114C';
  22293. t['\u3182'] = '\u11F1';
  22294. t['\u3183'] = '\u11F2';
  22295. t['\u3184'] = '\u1157';
  22296. t['\u3185'] = '\u1158';
  22297. t['\u3186'] = '\u1159';
  22298. t['\u3187'] = '\u1184';
  22299. t['\u3188'] = '\u1185';
  22300. t['\u3189'] = '\u1188';
  22301. t['\u318A'] = '\u1191';
  22302. t['\u318B'] = '\u1192';
  22303. t['\u318C'] = '\u1194';
  22304. t['\u318D'] = '\u119E';
  22305. t['\u318E'] = '\u11A1';
  22306. t['\u3200'] = '\u0028\u1100\u0029';
  22307. t['\u3201'] = '\u0028\u1102\u0029';
  22308. t['\u3202'] = '\u0028\u1103\u0029';
  22309. t['\u3203'] = '\u0028\u1105\u0029';
  22310. t['\u3204'] = '\u0028\u1106\u0029';
  22311. t['\u3205'] = '\u0028\u1107\u0029';
  22312. t['\u3206'] = '\u0028\u1109\u0029';
  22313. t['\u3207'] = '\u0028\u110B\u0029';
  22314. t['\u3208'] = '\u0028\u110C\u0029';
  22315. t['\u3209'] = '\u0028\u110E\u0029';
  22316. t['\u320A'] = '\u0028\u110F\u0029';
  22317. t['\u320B'] = '\u0028\u1110\u0029';
  22318. t['\u320C'] = '\u0028\u1111\u0029';
  22319. t['\u320D'] = '\u0028\u1112\u0029';
  22320. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22321. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22322. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22323. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22324. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22325. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22326. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22327. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22328. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22329. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22330. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22331. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22332. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22333. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22334. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22335. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22336. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22337. t['\u3220'] = '\u0028\u4E00\u0029';
  22338. t['\u3221'] = '\u0028\u4E8C\u0029';
  22339. t['\u3222'] = '\u0028\u4E09\u0029';
  22340. t['\u3223'] = '\u0028\u56DB\u0029';
  22341. t['\u3224'] = '\u0028\u4E94\u0029';
  22342. t['\u3225'] = '\u0028\u516D\u0029';
  22343. t['\u3226'] = '\u0028\u4E03\u0029';
  22344. t['\u3227'] = '\u0028\u516B\u0029';
  22345. t['\u3228'] = '\u0028\u4E5D\u0029';
  22346. t['\u3229'] = '\u0028\u5341\u0029';
  22347. t['\u322A'] = '\u0028\u6708\u0029';
  22348. t['\u322B'] = '\u0028\u706B\u0029';
  22349. t['\u322C'] = '\u0028\u6C34\u0029';
  22350. t['\u322D'] = '\u0028\u6728\u0029';
  22351. t['\u322E'] = '\u0028\u91D1\u0029';
  22352. t['\u322F'] = '\u0028\u571F\u0029';
  22353. t['\u3230'] = '\u0028\u65E5\u0029';
  22354. t['\u3231'] = '\u0028\u682A\u0029';
  22355. t['\u3232'] = '\u0028\u6709\u0029';
  22356. t['\u3233'] = '\u0028\u793E\u0029';
  22357. t['\u3234'] = '\u0028\u540D\u0029';
  22358. t['\u3235'] = '\u0028\u7279\u0029';
  22359. t['\u3236'] = '\u0028\u8CA1\u0029';
  22360. t['\u3237'] = '\u0028\u795D\u0029';
  22361. t['\u3238'] = '\u0028\u52B4\u0029';
  22362. t['\u3239'] = '\u0028\u4EE3\u0029';
  22363. t['\u323A'] = '\u0028\u547C\u0029';
  22364. t['\u323B'] = '\u0028\u5B66\u0029';
  22365. t['\u323C'] = '\u0028\u76E3\u0029';
  22366. t['\u323D'] = '\u0028\u4F01\u0029';
  22367. t['\u323E'] = '\u0028\u8CC7\u0029';
  22368. t['\u323F'] = '\u0028\u5354\u0029';
  22369. t['\u3240'] = '\u0028\u796D\u0029';
  22370. t['\u3241'] = '\u0028\u4F11\u0029';
  22371. t['\u3242'] = '\u0028\u81EA\u0029';
  22372. t['\u3243'] = '\u0028\u81F3\u0029';
  22373. t['\u32C0'] = '\u0031\u6708';
  22374. t['\u32C1'] = '\u0032\u6708';
  22375. t['\u32C2'] = '\u0033\u6708';
  22376. t['\u32C3'] = '\u0034\u6708';
  22377. t['\u32C4'] = '\u0035\u6708';
  22378. t['\u32C5'] = '\u0036\u6708';
  22379. t['\u32C6'] = '\u0037\u6708';
  22380. t['\u32C7'] = '\u0038\u6708';
  22381. t['\u32C8'] = '\u0039\u6708';
  22382. t['\u32C9'] = '\u0031\u0030\u6708';
  22383. t['\u32CA'] = '\u0031\u0031\u6708';
  22384. t['\u32CB'] = '\u0031\u0032\u6708';
  22385. t['\u3358'] = '\u0030\u70B9';
  22386. t['\u3359'] = '\u0031\u70B9';
  22387. t['\u335A'] = '\u0032\u70B9';
  22388. t['\u335B'] = '\u0033\u70B9';
  22389. t['\u335C'] = '\u0034\u70B9';
  22390. t['\u335D'] = '\u0035\u70B9';
  22391. t['\u335E'] = '\u0036\u70B9';
  22392. t['\u335F'] = '\u0037\u70B9';
  22393. t['\u3360'] = '\u0038\u70B9';
  22394. t['\u3361'] = '\u0039\u70B9';
  22395. t['\u3362'] = '\u0031\u0030\u70B9';
  22396. t['\u3363'] = '\u0031\u0031\u70B9';
  22397. t['\u3364'] = '\u0031\u0032\u70B9';
  22398. t['\u3365'] = '\u0031\u0033\u70B9';
  22399. t['\u3366'] = '\u0031\u0034\u70B9';
  22400. t['\u3367'] = '\u0031\u0035\u70B9';
  22401. t['\u3368'] = '\u0031\u0036\u70B9';
  22402. t['\u3369'] = '\u0031\u0037\u70B9';
  22403. t['\u336A'] = '\u0031\u0038\u70B9';
  22404. t['\u336B'] = '\u0031\u0039\u70B9';
  22405. t['\u336C'] = '\u0032\u0030\u70B9';
  22406. t['\u336D'] = '\u0032\u0031\u70B9';
  22407. t['\u336E'] = '\u0032\u0032\u70B9';
  22408. t['\u336F'] = '\u0032\u0033\u70B9';
  22409. t['\u3370'] = '\u0032\u0034\u70B9';
  22410. t['\u33E0'] = '\u0031\u65E5';
  22411. t['\u33E1'] = '\u0032\u65E5';
  22412. t['\u33E2'] = '\u0033\u65E5';
  22413. t['\u33E3'] = '\u0034\u65E5';
  22414. t['\u33E4'] = '\u0035\u65E5';
  22415. t['\u33E5'] = '\u0036\u65E5';
  22416. t['\u33E6'] = '\u0037\u65E5';
  22417. t['\u33E7'] = '\u0038\u65E5';
  22418. t['\u33E8'] = '\u0039\u65E5';
  22419. t['\u33E9'] = '\u0031\u0030\u65E5';
  22420. t['\u33EA'] = '\u0031\u0031\u65E5';
  22421. t['\u33EB'] = '\u0031\u0032\u65E5';
  22422. t['\u33EC'] = '\u0031\u0033\u65E5';
  22423. t['\u33ED'] = '\u0031\u0034\u65E5';
  22424. t['\u33EE'] = '\u0031\u0035\u65E5';
  22425. t['\u33EF'] = '\u0031\u0036\u65E5';
  22426. t['\u33F0'] = '\u0031\u0037\u65E5';
  22427. t['\u33F1'] = '\u0031\u0038\u65E5';
  22428. t['\u33F2'] = '\u0031\u0039\u65E5';
  22429. t['\u33F3'] = '\u0032\u0030\u65E5';
  22430. t['\u33F4'] = '\u0032\u0031\u65E5';
  22431. t['\u33F5'] = '\u0032\u0032\u65E5';
  22432. t['\u33F6'] = '\u0032\u0033\u65E5';
  22433. t['\u33F7'] = '\u0032\u0034\u65E5';
  22434. t['\u33F8'] = '\u0032\u0035\u65E5';
  22435. t['\u33F9'] = '\u0032\u0036\u65E5';
  22436. t['\u33FA'] = '\u0032\u0037\u65E5';
  22437. t['\u33FB'] = '\u0032\u0038\u65E5';
  22438. t['\u33FC'] = '\u0032\u0039\u65E5';
  22439. t['\u33FD'] = '\u0033\u0030\u65E5';
  22440. t['\u33FE'] = '\u0033\u0031\u65E5';
  22441. t['\uFB00'] = '\u0066\u0066';
  22442. t['\uFB01'] = '\u0066\u0069';
  22443. t['\uFB02'] = '\u0066\u006C';
  22444. t['\uFB03'] = '\u0066\u0066\u0069';
  22445. t['\uFB04'] = '\u0066\u0066\u006C';
  22446. t['\uFB05'] = '\u017F\u0074';
  22447. t['\uFB06'] = '\u0073\u0074';
  22448. t['\uFB13'] = '\u0574\u0576';
  22449. t['\uFB14'] = '\u0574\u0565';
  22450. t['\uFB15'] = '\u0574\u056B';
  22451. t['\uFB16'] = '\u057E\u0576';
  22452. t['\uFB17'] = '\u0574\u056D';
  22453. t['\uFB4F'] = '\u05D0\u05DC';
  22454. t['\uFB50'] = '\u0671';
  22455. t['\uFB51'] = '\u0671';
  22456. t['\uFB52'] = '\u067B';
  22457. t['\uFB53'] = '\u067B';
  22458. t['\uFB54'] = '\u067B';
  22459. t['\uFB55'] = '\u067B';
  22460. t['\uFB56'] = '\u067E';
  22461. t['\uFB57'] = '\u067E';
  22462. t['\uFB58'] = '\u067E';
  22463. t['\uFB59'] = '\u067E';
  22464. t['\uFB5A'] = '\u0680';
  22465. t['\uFB5B'] = '\u0680';
  22466. t['\uFB5C'] = '\u0680';
  22467. t['\uFB5D'] = '\u0680';
  22468. t['\uFB5E'] = '\u067A';
  22469. t['\uFB5F'] = '\u067A';
  22470. t['\uFB60'] = '\u067A';
  22471. t['\uFB61'] = '\u067A';
  22472. t['\uFB62'] = '\u067F';
  22473. t['\uFB63'] = '\u067F';
  22474. t['\uFB64'] = '\u067F';
  22475. t['\uFB65'] = '\u067F';
  22476. t['\uFB66'] = '\u0679';
  22477. t['\uFB67'] = '\u0679';
  22478. t['\uFB68'] = '\u0679';
  22479. t['\uFB69'] = '\u0679';
  22480. t['\uFB6A'] = '\u06A4';
  22481. t['\uFB6B'] = '\u06A4';
  22482. t['\uFB6C'] = '\u06A4';
  22483. t['\uFB6D'] = '\u06A4';
  22484. t['\uFB6E'] = '\u06A6';
  22485. t['\uFB6F'] = '\u06A6';
  22486. t['\uFB70'] = '\u06A6';
  22487. t['\uFB71'] = '\u06A6';
  22488. t['\uFB72'] = '\u0684';
  22489. t['\uFB73'] = '\u0684';
  22490. t['\uFB74'] = '\u0684';
  22491. t['\uFB75'] = '\u0684';
  22492. t['\uFB76'] = '\u0683';
  22493. t['\uFB77'] = '\u0683';
  22494. t['\uFB78'] = '\u0683';
  22495. t['\uFB79'] = '\u0683';
  22496. t['\uFB7A'] = '\u0686';
  22497. t['\uFB7B'] = '\u0686';
  22498. t['\uFB7C'] = '\u0686';
  22499. t['\uFB7D'] = '\u0686';
  22500. t['\uFB7E'] = '\u0687';
  22501. t['\uFB7F'] = '\u0687';
  22502. t['\uFB80'] = '\u0687';
  22503. t['\uFB81'] = '\u0687';
  22504. t['\uFB82'] = '\u068D';
  22505. t['\uFB83'] = '\u068D';
  22506. t['\uFB84'] = '\u068C';
  22507. t['\uFB85'] = '\u068C';
  22508. t['\uFB86'] = '\u068E';
  22509. t['\uFB87'] = '\u068E';
  22510. t['\uFB88'] = '\u0688';
  22511. t['\uFB89'] = '\u0688';
  22512. t['\uFB8A'] = '\u0698';
  22513. t['\uFB8B'] = '\u0698';
  22514. t['\uFB8C'] = '\u0691';
  22515. t['\uFB8D'] = '\u0691';
  22516. t['\uFB8E'] = '\u06A9';
  22517. t['\uFB8F'] = '\u06A9';
  22518. t['\uFB90'] = '\u06A9';
  22519. t['\uFB91'] = '\u06A9';
  22520. t['\uFB92'] = '\u06AF';
  22521. t['\uFB93'] = '\u06AF';
  22522. t['\uFB94'] = '\u06AF';
  22523. t['\uFB95'] = '\u06AF';
  22524. t['\uFB96'] = '\u06B3';
  22525. t['\uFB97'] = '\u06B3';
  22526. t['\uFB98'] = '\u06B3';
  22527. t['\uFB99'] = '\u06B3';
  22528. t['\uFB9A'] = '\u06B1';
  22529. t['\uFB9B'] = '\u06B1';
  22530. t['\uFB9C'] = '\u06B1';
  22531. t['\uFB9D'] = '\u06B1';
  22532. t['\uFB9E'] = '\u06BA';
  22533. t['\uFB9F'] = '\u06BA';
  22534. t['\uFBA0'] = '\u06BB';
  22535. t['\uFBA1'] = '\u06BB';
  22536. t['\uFBA2'] = '\u06BB';
  22537. t['\uFBA3'] = '\u06BB';
  22538. t['\uFBA4'] = '\u06C0';
  22539. t['\uFBA5'] = '\u06C0';
  22540. t['\uFBA6'] = '\u06C1';
  22541. t['\uFBA7'] = '\u06C1';
  22542. t['\uFBA8'] = '\u06C1';
  22543. t['\uFBA9'] = '\u06C1';
  22544. t['\uFBAA'] = '\u06BE';
  22545. t['\uFBAB'] = '\u06BE';
  22546. t['\uFBAC'] = '\u06BE';
  22547. t['\uFBAD'] = '\u06BE';
  22548. t['\uFBAE'] = '\u06D2';
  22549. t['\uFBAF'] = '\u06D2';
  22550. t['\uFBB0'] = '\u06D3';
  22551. t['\uFBB1'] = '\u06D3';
  22552. t['\uFBD3'] = '\u06AD';
  22553. t['\uFBD4'] = '\u06AD';
  22554. t['\uFBD5'] = '\u06AD';
  22555. t['\uFBD6'] = '\u06AD';
  22556. t['\uFBD7'] = '\u06C7';
  22557. t['\uFBD8'] = '\u06C7';
  22558. t['\uFBD9'] = '\u06C6';
  22559. t['\uFBDA'] = '\u06C6';
  22560. t['\uFBDB'] = '\u06C8';
  22561. t['\uFBDC'] = '\u06C8';
  22562. t['\uFBDD'] = '\u0677';
  22563. t['\uFBDE'] = '\u06CB';
  22564. t['\uFBDF'] = '\u06CB';
  22565. t['\uFBE0'] = '\u06C5';
  22566. t['\uFBE1'] = '\u06C5';
  22567. t['\uFBE2'] = '\u06C9';
  22568. t['\uFBE3'] = '\u06C9';
  22569. t['\uFBE4'] = '\u06D0';
  22570. t['\uFBE5'] = '\u06D0';
  22571. t['\uFBE6'] = '\u06D0';
  22572. t['\uFBE7'] = '\u06D0';
  22573. t['\uFBE8'] = '\u0649';
  22574. t['\uFBE9'] = '\u0649';
  22575. t['\uFBEA'] = '\u0626\u0627';
  22576. t['\uFBEB'] = '\u0626\u0627';
  22577. t['\uFBEC'] = '\u0626\u06D5';
  22578. t['\uFBED'] = '\u0626\u06D5';
  22579. t['\uFBEE'] = '\u0626\u0648';
  22580. t['\uFBEF'] = '\u0626\u0648';
  22581. t['\uFBF0'] = '\u0626\u06C7';
  22582. t['\uFBF1'] = '\u0626\u06C7';
  22583. t['\uFBF2'] = '\u0626\u06C6';
  22584. t['\uFBF3'] = '\u0626\u06C6';
  22585. t['\uFBF4'] = '\u0626\u06C8';
  22586. t['\uFBF5'] = '\u0626\u06C8';
  22587. t['\uFBF6'] = '\u0626\u06D0';
  22588. t['\uFBF7'] = '\u0626\u06D0';
  22589. t['\uFBF8'] = '\u0626\u06D0';
  22590. t['\uFBF9'] = '\u0626\u0649';
  22591. t['\uFBFA'] = '\u0626\u0649';
  22592. t['\uFBFB'] = '\u0626\u0649';
  22593. t['\uFBFC'] = '\u06CC';
  22594. t['\uFBFD'] = '\u06CC';
  22595. t['\uFBFE'] = '\u06CC';
  22596. t['\uFBFF'] = '\u06CC';
  22597. t['\uFC00'] = '\u0626\u062C';
  22598. t['\uFC01'] = '\u0626\u062D';
  22599. t['\uFC02'] = '\u0626\u0645';
  22600. t['\uFC03'] = '\u0626\u0649';
  22601. t['\uFC04'] = '\u0626\u064A';
  22602. t['\uFC05'] = '\u0628\u062C';
  22603. t['\uFC06'] = '\u0628\u062D';
  22604. t['\uFC07'] = '\u0628\u062E';
  22605. t['\uFC08'] = '\u0628\u0645';
  22606. t['\uFC09'] = '\u0628\u0649';
  22607. t['\uFC0A'] = '\u0628\u064A';
  22608. t['\uFC0B'] = '\u062A\u062C';
  22609. t['\uFC0C'] = '\u062A\u062D';
  22610. t['\uFC0D'] = '\u062A\u062E';
  22611. t['\uFC0E'] = '\u062A\u0645';
  22612. t['\uFC0F'] = '\u062A\u0649';
  22613. t['\uFC10'] = '\u062A\u064A';
  22614. t['\uFC11'] = '\u062B\u062C';
  22615. t['\uFC12'] = '\u062B\u0645';
  22616. t['\uFC13'] = '\u062B\u0649';
  22617. t['\uFC14'] = '\u062B\u064A';
  22618. t['\uFC15'] = '\u062C\u062D';
  22619. t['\uFC16'] = '\u062C\u0645';
  22620. t['\uFC17'] = '\u062D\u062C';
  22621. t['\uFC18'] = '\u062D\u0645';
  22622. t['\uFC19'] = '\u062E\u062C';
  22623. t['\uFC1A'] = '\u062E\u062D';
  22624. t['\uFC1B'] = '\u062E\u0645';
  22625. t['\uFC1C'] = '\u0633\u062C';
  22626. t['\uFC1D'] = '\u0633\u062D';
  22627. t['\uFC1E'] = '\u0633\u062E';
  22628. t['\uFC1F'] = '\u0633\u0645';
  22629. t['\uFC20'] = '\u0635\u062D';
  22630. t['\uFC21'] = '\u0635\u0645';
  22631. t['\uFC22'] = '\u0636\u062C';
  22632. t['\uFC23'] = '\u0636\u062D';
  22633. t['\uFC24'] = '\u0636\u062E';
  22634. t['\uFC25'] = '\u0636\u0645';
  22635. t['\uFC26'] = '\u0637\u062D';
  22636. t['\uFC27'] = '\u0637\u0645';
  22637. t['\uFC28'] = '\u0638\u0645';
  22638. t['\uFC29'] = '\u0639\u062C';
  22639. t['\uFC2A'] = '\u0639\u0645';
  22640. t['\uFC2B'] = '\u063A\u062C';
  22641. t['\uFC2C'] = '\u063A\u0645';
  22642. t['\uFC2D'] = '\u0641\u062C';
  22643. t['\uFC2E'] = '\u0641\u062D';
  22644. t['\uFC2F'] = '\u0641\u062E';
  22645. t['\uFC30'] = '\u0641\u0645';
  22646. t['\uFC31'] = '\u0641\u0649';
  22647. t['\uFC32'] = '\u0641\u064A';
  22648. t['\uFC33'] = '\u0642\u062D';
  22649. t['\uFC34'] = '\u0642\u0645';
  22650. t['\uFC35'] = '\u0642\u0649';
  22651. t['\uFC36'] = '\u0642\u064A';
  22652. t['\uFC37'] = '\u0643\u0627';
  22653. t['\uFC38'] = '\u0643\u062C';
  22654. t['\uFC39'] = '\u0643\u062D';
  22655. t['\uFC3A'] = '\u0643\u062E';
  22656. t['\uFC3B'] = '\u0643\u0644';
  22657. t['\uFC3C'] = '\u0643\u0645';
  22658. t['\uFC3D'] = '\u0643\u0649';
  22659. t['\uFC3E'] = '\u0643\u064A';
  22660. t['\uFC3F'] = '\u0644\u062C';
  22661. t['\uFC40'] = '\u0644\u062D';
  22662. t['\uFC41'] = '\u0644\u062E';
  22663. t['\uFC42'] = '\u0644\u0645';
  22664. t['\uFC43'] = '\u0644\u0649';
  22665. t['\uFC44'] = '\u0644\u064A';
  22666. t['\uFC45'] = '\u0645\u062C';
  22667. t['\uFC46'] = '\u0645\u062D';
  22668. t['\uFC47'] = '\u0645\u062E';
  22669. t['\uFC48'] = '\u0645\u0645';
  22670. t['\uFC49'] = '\u0645\u0649';
  22671. t['\uFC4A'] = '\u0645\u064A';
  22672. t['\uFC4B'] = '\u0646\u062C';
  22673. t['\uFC4C'] = '\u0646\u062D';
  22674. t['\uFC4D'] = '\u0646\u062E';
  22675. t['\uFC4E'] = '\u0646\u0645';
  22676. t['\uFC4F'] = '\u0646\u0649';
  22677. t['\uFC50'] = '\u0646\u064A';
  22678. t['\uFC51'] = '\u0647\u062C';
  22679. t['\uFC52'] = '\u0647\u0645';
  22680. t['\uFC53'] = '\u0647\u0649';
  22681. t['\uFC54'] = '\u0647\u064A';
  22682. t['\uFC55'] = '\u064A\u062C';
  22683. t['\uFC56'] = '\u064A\u062D';
  22684. t['\uFC57'] = '\u064A\u062E';
  22685. t['\uFC58'] = '\u064A\u0645';
  22686. t['\uFC59'] = '\u064A\u0649';
  22687. t['\uFC5A'] = '\u064A\u064A';
  22688. t['\uFC5B'] = '\u0630\u0670';
  22689. t['\uFC5C'] = '\u0631\u0670';
  22690. t['\uFC5D'] = '\u0649\u0670';
  22691. t['\uFC5E'] = '\u0020\u064C\u0651';
  22692. t['\uFC5F'] = '\u0020\u064D\u0651';
  22693. t['\uFC60'] = '\u0020\u064E\u0651';
  22694. t['\uFC61'] = '\u0020\u064F\u0651';
  22695. t['\uFC62'] = '\u0020\u0650\u0651';
  22696. t['\uFC63'] = '\u0020\u0651\u0670';
  22697. t['\uFC64'] = '\u0626\u0631';
  22698. t['\uFC65'] = '\u0626\u0632';
  22699. t['\uFC66'] = '\u0626\u0645';
  22700. t['\uFC67'] = '\u0626\u0646';
  22701. t['\uFC68'] = '\u0626\u0649';
  22702. t['\uFC69'] = '\u0626\u064A';
  22703. t['\uFC6A'] = '\u0628\u0631';
  22704. t['\uFC6B'] = '\u0628\u0632';
  22705. t['\uFC6C'] = '\u0628\u0645';
  22706. t['\uFC6D'] = '\u0628\u0646';
  22707. t['\uFC6E'] = '\u0628\u0649';
  22708. t['\uFC6F'] = '\u0628\u064A';
  22709. t['\uFC70'] = '\u062A\u0631';
  22710. t['\uFC71'] = '\u062A\u0632';
  22711. t['\uFC72'] = '\u062A\u0645';
  22712. t['\uFC73'] = '\u062A\u0646';
  22713. t['\uFC74'] = '\u062A\u0649';
  22714. t['\uFC75'] = '\u062A\u064A';
  22715. t['\uFC76'] = '\u062B\u0631';
  22716. t['\uFC77'] = '\u062B\u0632';
  22717. t['\uFC78'] = '\u062B\u0645';
  22718. t['\uFC79'] = '\u062B\u0646';
  22719. t['\uFC7A'] = '\u062B\u0649';
  22720. t['\uFC7B'] = '\u062B\u064A';
  22721. t['\uFC7C'] = '\u0641\u0649';
  22722. t['\uFC7D'] = '\u0641\u064A';
  22723. t['\uFC7E'] = '\u0642\u0649';
  22724. t['\uFC7F'] = '\u0642\u064A';
  22725. t['\uFC80'] = '\u0643\u0627';
  22726. t['\uFC81'] = '\u0643\u0644';
  22727. t['\uFC82'] = '\u0643\u0645';
  22728. t['\uFC83'] = '\u0643\u0649';
  22729. t['\uFC84'] = '\u0643\u064A';
  22730. t['\uFC85'] = '\u0644\u0645';
  22731. t['\uFC86'] = '\u0644\u0649';
  22732. t['\uFC87'] = '\u0644\u064A';
  22733. t['\uFC88'] = '\u0645\u0627';
  22734. t['\uFC89'] = '\u0645\u0645';
  22735. t['\uFC8A'] = '\u0646\u0631';
  22736. t['\uFC8B'] = '\u0646\u0632';
  22737. t['\uFC8C'] = '\u0646\u0645';
  22738. t['\uFC8D'] = '\u0646\u0646';
  22739. t['\uFC8E'] = '\u0646\u0649';
  22740. t['\uFC8F'] = '\u0646\u064A';
  22741. t['\uFC90'] = '\u0649\u0670';
  22742. t['\uFC91'] = '\u064A\u0631';
  22743. t['\uFC92'] = '\u064A\u0632';
  22744. t['\uFC93'] = '\u064A\u0645';
  22745. t['\uFC94'] = '\u064A\u0646';
  22746. t['\uFC95'] = '\u064A\u0649';
  22747. t['\uFC96'] = '\u064A\u064A';
  22748. t['\uFC97'] = '\u0626\u062C';
  22749. t['\uFC98'] = '\u0626\u062D';
  22750. t['\uFC99'] = '\u0626\u062E';
  22751. t['\uFC9A'] = '\u0626\u0645';
  22752. t['\uFC9B'] = '\u0626\u0647';
  22753. t['\uFC9C'] = '\u0628\u062C';
  22754. t['\uFC9D'] = '\u0628\u062D';
  22755. t['\uFC9E'] = '\u0628\u062E';
  22756. t['\uFC9F'] = '\u0628\u0645';
  22757. t['\uFCA0'] = '\u0628\u0647';
  22758. t['\uFCA1'] = '\u062A\u062C';
  22759. t['\uFCA2'] = '\u062A\u062D';
  22760. t['\uFCA3'] = '\u062A\u062E';
  22761. t['\uFCA4'] = '\u062A\u0645';
  22762. t['\uFCA5'] = '\u062A\u0647';
  22763. t['\uFCA6'] = '\u062B\u0645';
  22764. t['\uFCA7'] = '\u062C\u062D';
  22765. t['\uFCA8'] = '\u062C\u0645';
  22766. t['\uFCA9'] = '\u062D\u062C';
  22767. t['\uFCAA'] = '\u062D\u0645';
  22768. t['\uFCAB'] = '\u062E\u062C';
  22769. t['\uFCAC'] = '\u062E\u0645';
  22770. t['\uFCAD'] = '\u0633\u062C';
  22771. t['\uFCAE'] = '\u0633\u062D';
  22772. t['\uFCAF'] = '\u0633\u062E';
  22773. t['\uFCB0'] = '\u0633\u0645';
  22774. t['\uFCB1'] = '\u0635\u062D';
  22775. t['\uFCB2'] = '\u0635\u062E';
  22776. t['\uFCB3'] = '\u0635\u0645';
  22777. t['\uFCB4'] = '\u0636\u062C';
  22778. t['\uFCB5'] = '\u0636\u062D';
  22779. t['\uFCB6'] = '\u0636\u062E';
  22780. t['\uFCB7'] = '\u0636\u0645';
  22781. t['\uFCB8'] = '\u0637\u062D';
  22782. t['\uFCB9'] = '\u0638\u0645';
  22783. t['\uFCBA'] = '\u0639\u062C';
  22784. t['\uFCBB'] = '\u0639\u0645';
  22785. t['\uFCBC'] = '\u063A\u062C';
  22786. t['\uFCBD'] = '\u063A\u0645';
  22787. t['\uFCBE'] = '\u0641\u062C';
  22788. t['\uFCBF'] = '\u0641\u062D';
  22789. t['\uFCC0'] = '\u0641\u062E';
  22790. t['\uFCC1'] = '\u0641\u0645';
  22791. t['\uFCC2'] = '\u0642\u062D';
  22792. t['\uFCC3'] = '\u0642\u0645';
  22793. t['\uFCC4'] = '\u0643\u062C';
  22794. t['\uFCC5'] = '\u0643\u062D';
  22795. t['\uFCC6'] = '\u0643\u062E';
  22796. t['\uFCC7'] = '\u0643\u0644';
  22797. t['\uFCC8'] = '\u0643\u0645';
  22798. t['\uFCC9'] = '\u0644\u062C';
  22799. t['\uFCCA'] = '\u0644\u062D';
  22800. t['\uFCCB'] = '\u0644\u062E';
  22801. t['\uFCCC'] = '\u0644\u0645';
  22802. t['\uFCCD'] = '\u0644\u0647';
  22803. t['\uFCCE'] = '\u0645\u062C';
  22804. t['\uFCCF'] = '\u0645\u062D';
  22805. t['\uFCD0'] = '\u0645\u062E';
  22806. t['\uFCD1'] = '\u0645\u0645';
  22807. t['\uFCD2'] = '\u0646\u062C';
  22808. t['\uFCD3'] = '\u0646\u062D';
  22809. t['\uFCD4'] = '\u0646\u062E';
  22810. t['\uFCD5'] = '\u0646\u0645';
  22811. t['\uFCD6'] = '\u0646\u0647';
  22812. t['\uFCD7'] = '\u0647\u062C';
  22813. t['\uFCD8'] = '\u0647\u0645';
  22814. t['\uFCD9'] = '\u0647\u0670';
  22815. t['\uFCDA'] = '\u064A\u062C';
  22816. t['\uFCDB'] = '\u064A\u062D';
  22817. t['\uFCDC'] = '\u064A\u062E';
  22818. t['\uFCDD'] = '\u064A\u0645';
  22819. t['\uFCDE'] = '\u064A\u0647';
  22820. t['\uFCDF'] = '\u0626\u0645';
  22821. t['\uFCE0'] = '\u0626\u0647';
  22822. t['\uFCE1'] = '\u0628\u0645';
  22823. t['\uFCE2'] = '\u0628\u0647';
  22824. t['\uFCE3'] = '\u062A\u0645';
  22825. t['\uFCE4'] = '\u062A\u0647';
  22826. t['\uFCE5'] = '\u062B\u0645';
  22827. t['\uFCE6'] = '\u062B\u0647';
  22828. t['\uFCE7'] = '\u0633\u0645';
  22829. t['\uFCE8'] = '\u0633\u0647';
  22830. t['\uFCE9'] = '\u0634\u0645';
  22831. t['\uFCEA'] = '\u0634\u0647';
  22832. t['\uFCEB'] = '\u0643\u0644';
  22833. t['\uFCEC'] = '\u0643\u0645';
  22834. t['\uFCED'] = '\u0644\u0645';
  22835. t['\uFCEE'] = '\u0646\u0645';
  22836. t['\uFCEF'] = '\u0646\u0647';
  22837. t['\uFCF0'] = '\u064A\u0645';
  22838. t['\uFCF1'] = '\u064A\u0647';
  22839. t['\uFCF2'] = '\u0640\u064E\u0651';
  22840. t['\uFCF3'] = '\u0640\u064F\u0651';
  22841. t['\uFCF4'] = '\u0640\u0650\u0651';
  22842. t['\uFCF5'] = '\u0637\u0649';
  22843. t['\uFCF6'] = '\u0637\u064A';
  22844. t['\uFCF7'] = '\u0639\u0649';
  22845. t['\uFCF8'] = '\u0639\u064A';
  22846. t['\uFCF9'] = '\u063A\u0649';
  22847. t['\uFCFA'] = '\u063A\u064A';
  22848. t['\uFCFB'] = '\u0633\u0649';
  22849. t['\uFCFC'] = '\u0633\u064A';
  22850. t['\uFCFD'] = '\u0634\u0649';
  22851. t['\uFCFE'] = '\u0634\u064A';
  22852. t['\uFCFF'] = '\u062D\u0649';
  22853. t['\uFD00'] = '\u062D\u064A';
  22854. t['\uFD01'] = '\u062C\u0649';
  22855. t['\uFD02'] = '\u062C\u064A';
  22856. t['\uFD03'] = '\u062E\u0649';
  22857. t['\uFD04'] = '\u062E\u064A';
  22858. t['\uFD05'] = '\u0635\u0649';
  22859. t['\uFD06'] = '\u0635\u064A';
  22860. t['\uFD07'] = '\u0636\u0649';
  22861. t['\uFD08'] = '\u0636\u064A';
  22862. t['\uFD09'] = '\u0634\u062C';
  22863. t['\uFD0A'] = '\u0634\u062D';
  22864. t['\uFD0B'] = '\u0634\u062E';
  22865. t['\uFD0C'] = '\u0634\u0645';
  22866. t['\uFD0D'] = '\u0634\u0631';
  22867. t['\uFD0E'] = '\u0633\u0631';
  22868. t['\uFD0F'] = '\u0635\u0631';
  22869. t['\uFD10'] = '\u0636\u0631';
  22870. t['\uFD11'] = '\u0637\u0649';
  22871. t['\uFD12'] = '\u0637\u064A';
  22872. t['\uFD13'] = '\u0639\u0649';
  22873. t['\uFD14'] = '\u0639\u064A';
  22874. t['\uFD15'] = '\u063A\u0649';
  22875. t['\uFD16'] = '\u063A\u064A';
  22876. t['\uFD17'] = '\u0633\u0649';
  22877. t['\uFD18'] = '\u0633\u064A';
  22878. t['\uFD19'] = '\u0634\u0649';
  22879. t['\uFD1A'] = '\u0634\u064A';
  22880. t['\uFD1B'] = '\u062D\u0649';
  22881. t['\uFD1C'] = '\u062D\u064A';
  22882. t['\uFD1D'] = '\u062C\u0649';
  22883. t['\uFD1E'] = '\u062C\u064A';
  22884. t['\uFD1F'] = '\u062E\u0649';
  22885. t['\uFD20'] = '\u062E\u064A';
  22886. t['\uFD21'] = '\u0635\u0649';
  22887. t['\uFD22'] = '\u0635\u064A';
  22888. t['\uFD23'] = '\u0636\u0649';
  22889. t['\uFD24'] = '\u0636\u064A';
  22890. t['\uFD25'] = '\u0634\u062C';
  22891. t['\uFD26'] = '\u0634\u062D';
  22892. t['\uFD27'] = '\u0634\u062E';
  22893. t['\uFD28'] = '\u0634\u0645';
  22894. t['\uFD29'] = '\u0634\u0631';
  22895. t['\uFD2A'] = '\u0633\u0631';
  22896. t['\uFD2B'] = '\u0635\u0631';
  22897. t['\uFD2C'] = '\u0636\u0631';
  22898. t['\uFD2D'] = '\u0634\u062C';
  22899. t['\uFD2E'] = '\u0634\u062D';
  22900. t['\uFD2F'] = '\u0634\u062E';
  22901. t['\uFD30'] = '\u0634\u0645';
  22902. t['\uFD31'] = '\u0633\u0647';
  22903. t['\uFD32'] = '\u0634\u0647';
  22904. t['\uFD33'] = '\u0637\u0645';
  22905. t['\uFD34'] = '\u0633\u062C';
  22906. t['\uFD35'] = '\u0633\u062D';
  22907. t['\uFD36'] = '\u0633\u062E';
  22908. t['\uFD37'] = '\u0634\u062C';
  22909. t['\uFD38'] = '\u0634\u062D';
  22910. t['\uFD39'] = '\u0634\u062E';
  22911. t['\uFD3A'] = '\u0637\u0645';
  22912. t['\uFD3B'] = '\u0638\u0645';
  22913. t['\uFD3C'] = '\u0627\u064B';
  22914. t['\uFD3D'] = '\u0627\u064B';
  22915. t['\uFD50'] = '\u062A\u062C\u0645';
  22916. t['\uFD51'] = '\u062A\u062D\u062C';
  22917. t['\uFD52'] = '\u062A\u062D\u062C';
  22918. t['\uFD53'] = '\u062A\u062D\u0645';
  22919. t['\uFD54'] = '\u062A\u062E\u0645';
  22920. t['\uFD55'] = '\u062A\u0645\u062C';
  22921. t['\uFD56'] = '\u062A\u0645\u062D';
  22922. t['\uFD57'] = '\u062A\u0645\u062E';
  22923. t['\uFD58'] = '\u062C\u0645\u062D';
  22924. t['\uFD59'] = '\u062C\u0645\u062D';
  22925. t['\uFD5A'] = '\u062D\u0645\u064A';
  22926. t['\uFD5B'] = '\u062D\u0645\u0649';
  22927. t['\uFD5C'] = '\u0633\u062D\u062C';
  22928. t['\uFD5D'] = '\u0633\u062C\u062D';
  22929. t['\uFD5E'] = '\u0633\u062C\u0649';
  22930. t['\uFD5F'] = '\u0633\u0645\u062D';
  22931. t['\uFD60'] = '\u0633\u0645\u062D';
  22932. t['\uFD61'] = '\u0633\u0645\u062C';
  22933. t['\uFD62'] = '\u0633\u0645\u0645';
  22934. t['\uFD63'] = '\u0633\u0645\u0645';
  22935. t['\uFD64'] = '\u0635\u062D\u062D';
  22936. t['\uFD65'] = '\u0635\u062D\u062D';
  22937. t['\uFD66'] = '\u0635\u0645\u0645';
  22938. t['\uFD67'] = '\u0634\u062D\u0645';
  22939. t['\uFD68'] = '\u0634\u062D\u0645';
  22940. t['\uFD69'] = '\u0634\u062C\u064A';
  22941. t['\uFD6A'] = '\u0634\u0645\u062E';
  22942. t['\uFD6B'] = '\u0634\u0645\u062E';
  22943. t['\uFD6C'] = '\u0634\u0645\u0645';
  22944. t['\uFD6D'] = '\u0634\u0645\u0645';
  22945. t['\uFD6E'] = '\u0636\u062D\u0649';
  22946. t['\uFD6F'] = '\u0636\u062E\u0645';
  22947. t['\uFD70'] = '\u0636\u062E\u0645';
  22948. t['\uFD71'] = '\u0637\u0645\u062D';
  22949. t['\uFD72'] = '\u0637\u0645\u062D';
  22950. t['\uFD73'] = '\u0637\u0645\u0645';
  22951. t['\uFD74'] = '\u0637\u0645\u064A';
  22952. t['\uFD75'] = '\u0639\u062C\u0645';
  22953. t['\uFD76'] = '\u0639\u0645\u0645';
  22954. t['\uFD77'] = '\u0639\u0645\u0645';
  22955. t['\uFD78'] = '\u0639\u0645\u0649';
  22956. t['\uFD79'] = '\u063A\u0645\u0645';
  22957. t['\uFD7A'] = '\u063A\u0645\u064A';
  22958. t['\uFD7B'] = '\u063A\u0645\u0649';
  22959. t['\uFD7C'] = '\u0641\u062E\u0645';
  22960. t['\uFD7D'] = '\u0641\u062E\u0645';
  22961. t['\uFD7E'] = '\u0642\u0645\u062D';
  22962. t['\uFD7F'] = '\u0642\u0645\u0645';
  22963. t['\uFD80'] = '\u0644\u062D\u0645';
  22964. t['\uFD81'] = '\u0644\u062D\u064A';
  22965. t['\uFD82'] = '\u0644\u062D\u0649';
  22966. t['\uFD83'] = '\u0644\u062C\u062C';
  22967. t['\uFD84'] = '\u0644\u062C\u062C';
  22968. t['\uFD85'] = '\u0644\u062E\u0645';
  22969. t['\uFD86'] = '\u0644\u062E\u0645';
  22970. t['\uFD87'] = '\u0644\u0645\u062D';
  22971. t['\uFD88'] = '\u0644\u0645\u062D';
  22972. t['\uFD89'] = '\u0645\u062D\u062C';
  22973. t['\uFD8A'] = '\u0645\u062D\u0645';
  22974. t['\uFD8B'] = '\u0645\u062D\u064A';
  22975. t['\uFD8C'] = '\u0645\u062C\u062D';
  22976. t['\uFD8D'] = '\u0645\u062C\u0645';
  22977. t['\uFD8E'] = '\u0645\u062E\u062C';
  22978. t['\uFD8F'] = '\u0645\u062E\u0645';
  22979. t['\uFD92'] = '\u0645\u062C\u062E';
  22980. t['\uFD93'] = '\u0647\u0645\u062C';
  22981. t['\uFD94'] = '\u0647\u0645\u0645';
  22982. t['\uFD95'] = '\u0646\u062D\u0645';
  22983. t['\uFD96'] = '\u0646\u062D\u0649';
  22984. t['\uFD97'] = '\u0646\u062C\u0645';
  22985. t['\uFD98'] = '\u0646\u062C\u0645';
  22986. t['\uFD99'] = '\u0646\u062C\u0649';
  22987. t['\uFD9A'] = '\u0646\u0645\u064A';
  22988. t['\uFD9B'] = '\u0646\u0645\u0649';
  22989. t['\uFD9C'] = '\u064A\u0645\u0645';
  22990. t['\uFD9D'] = '\u064A\u0645\u0645';
  22991. t['\uFD9E'] = '\u0628\u062E\u064A';
  22992. t['\uFD9F'] = '\u062A\u062C\u064A';
  22993. t['\uFDA0'] = '\u062A\u062C\u0649';
  22994. t['\uFDA1'] = '\u062A\u062E\u064A';
  22995. t['\uFDA2'] = '\u062A\u062E\u0649';
  22996. t['\uFDA3'] = '\u062A\u0645\u064A';
  22997. t['\uFDA4'] = '\u062A\u0645\u0649';
  22998. t['\uFDA5'] = '\u062C\u0645\u064A';
  22999. t['\uFDA6'] = '\u062C\u062D\u0649';
  23000. t['\uFDA7'] = '\u062C\u0645\u0649';
  23001. t['\uFDA8'] = '\u0633\u062E\u0649';
  23002. t['\uFDA9'] = '\u0635\u062D\u064A';
  23003. t['\uFDAA'] = '\u0634\u062D\u064A';
  23004. t['\uFDAB'] = '\u0636\u062D\u064A';
  23005. t['\uFDAC'] = '\u0644\u062C\u064A';
  23006. t['\uFDAD'] = '\u0644\u0645\u064A';
  23007. t['\uFDAE'] = '\u064A\u062D\u064A';
  23008. t['\uFDAF'] = '\u064A\u062C\u064A';
  23009. t['\uFDB0'] = '\u064A\u0645\u064A';
  23010. t['\uFDB1'] = '\u0645\u0645\u064A';
  23011. t['\uFDB2'] = '\u0642\u0645\u064A';
  23012. t['\uFDB3'] = '\u0646\u062D\u064A';
  23013. t['\uFDB4'] = '\u0642\u0645\u062D';
  23014. t['\uFDB5'] = '\u0644\u062D\u0645';
  23015. t['\uFDB6'] = '\u0639\u0645\u064A';
  23016. t['\uFDB7'] = '\u0643\u0645\u064A';
  23017. t['\uFDB8'] = '\u0646\u062C\u062D';
  23018. t['\uFDB9'] = '\u0645\u062E\u064A';
  23019. t['\uFDBA'] = '\u0644\u062C\u0645';
  23020. t['\uFDBB'] = '\u0643\u0645\u0645';
  23021. t['\uFDBC'] = '\u0644\u062C\u0645';
  23022. t['\uFDBD'] = '\u0646\u062C\u062D';
  23023. t['\uFDBE'] = '\u062C\u062D\u064A';
  23024. t['\uFDBF'] = '\u062D\u062C\u064A';
  23025. t['\uFDC0'] = '\u0645\u062C\u064A';
  23026. t['\uFDC1'] = '\u0641\u0645\u064A';
  23027. t['\uFDC2'] = '\u0628\u062D\u064A';
  23028. t['\uFDC3'] = '\u0643\u0645\u0645';
  23029. t['\uFDC4'] = '\u0639\u062C\u0645';
  23030. t['\uFDC5'] = '\u0635\u0645\u0645';
  23031. t['\uFDC6'] = '\u0633\u062E\u064A';
  23032. t['\uFDC7'] = '\u0646\u062C\u064A';
  23033. t['\uFE49'] = '\u203E';
  23034. t['\uFE4A'] = '\u203E';
  23035. t['\uFE4B'] = '\u203E';
  23036. t['\uFE4C'] = '\u203E';
  23037. t['\uFE4D'] = '\u005F';
  23038. t['\uFE4E'] = '\u005F';
  23039. t['\uFE4F'] = '\u005F';
  23040. t['\uFE80'] = '\u0621';
  23041. t['\uFE81'] = '\u0622';
  23042. t['\uFE82'] = '\u0622';
  23043. t['\uFE83'] = '\u0623';
  23044. t['\uFE84'] = '\u0623';
  23045. t['\uFE85'] = '\u0624';
  23046. t['\uFE86'] = '\u0624';
  23047. t['\uFE87'] = '\u0625';
  23048. t['\uFE88'] = '\u0625';
  23049. t['\uFE89'] = '\u0626';
  23050. t['\uFE8A'] = '\u0626';
  23051. t['\uFE8B'] = '\u0626';
  23052. t['\uFE8C'] = '\u0626';
  23053. t['\uFE8D'] = '\u0627';
  23054. t['\uFE8E'] = '\u0627';
  23055. t['\uFE8F'] = '\u0628';
  23056. t['\uFE90'] = '\u0628';
  23057. t['\uFE91'] = '\u0628';
  23058. t['\uFE92'] = '\u0628';
  23059. t['\uFE93'] = '\u0629';
  23060. t['\uFE94'] = '\u0629';
  23061. t['\uFE95'] = '\u062A';
  23062. t['\uFE96'] = '\u062A';
  23063. t['\uFE97'] = '\u062A';
  23064. t['\uFE98'] = '\u062A';
  23065. t['\uFE99'] = '\u062B';
  23066. t['\uFE9A'] = '\u062B';
  23067. t['\uFE9B'] = '\u062B';
  23068. t['\uFE9C'] = '\u062B';
  23069. t['\uFE9D'] = '\u062C';
  23070. t['\uFE9E'] = '\u062C';
  23071. t['\uFE9F'] = '\u062C';
  23072. t['\uFEA0'] = '\u062C';
  23073. t['\uFEA1'] = '\u062D';
  23074. t['\uFEA2'] = '\u062D';
  23075. t['\uFEA3'] = '\u062D';
  23076. t['\uFEA4'] = '\u062D';
  23077. t['\uFEA5'] = '\u062E';
  23078. t['\uFEA6'] = '\u062E';
  23079. t['\uFEA7'] = '\u062E';
  23080. t['\uFEA8'] = '\u062E';
  23081. t['\uFEA9'] = '\u062F';
  23082. t['\uFEAA'] = '\u062F';
  23083. t['\uFEAB'] = '\u0630';
  23084. t['\uFEAC'] = '\u0630';
  23085. t['\uFEAD'] = '\u0631';
  23086. t['\uFEAE'] = '\u0631';
  23087. t['\uFEAF'] = '\u0632';
  23088. t['\uFEB0'] = '\u0632';
  23089. t['\uFEB1'] = '\u0633';
  23090. t['\uFEB2'] = '\u0633';
  23091. t['\uFEB3'] = '\u0633';
  23092. t['\uFEB4'] = '\u0633';
  23093. t['\uFEB5'] = '\u0634';
  23094. t['\uFEB6'] = '\u0634';
  23095. t['\uFEB7'] = '\u0634';
  23096. t['\uFEB8'] = '\u0634';
  23097. t['\uFEB9'] = '\u0635';
  23098. t['\uFEBA'] = '\u0635';
  23099. t['\uFEBB'] = '\u0635';
  23100. t['\uFEBC'] = '\u0635';
  23101. t['\uFEBD'] = '\u0636';
  23102. t['\uFEBE'] = '\u0636';
  23103. t['\uFEBF'] = '\u0636';
  23104. t['\uFEC0'] = '\u0636';
  23105. t['\uFEC1'] = '\u0637';
  23106. t['\uFEC2'] = '\u0637';
  23107. t['\uFEC3'] = '\u0637';
  23108. t['\uFEC4'] = '\u0637';
  23109. t['\uFEC5'] = '\u0638';
  23110. t['\uFEC6'] = '\u0638';
  23111. t['\uFEC7'] = '\u0638';
  23112. t['\uFEC8'] = '\u0638';
  23113. t['\uFEC9'] = '\u0639';
  23114. t['\uFECA'] = '\u0639';
  23115. t['\uFECB'] = '\u0639';
  23116. t['\uFECC'] = '\u0639';
  23117. t['\uFECD'] = '\u063A';
  23118. t['\uFECE'] = '\u063A';
  23119. t['\uFECF'] = '\u063A';
  23120. t['\uFED0'] = '\u063A';
  23121. t['\uFED1'] = '\u0641';
  23122. t['\uFED2'] = '\u0641';
  23123. t['\uFED3'] = '\u0641';
  23124. t['\uFED4'] = '\u0641';
  23125. t['\uFED5'] = '\u0642';
  23126. t['\uFED6'] = '\u0642';
  23127. t['\uFED7'] = '\u0642';
  23128. t['\uFED8'] = '\u0642';
  23129. t['\uFED9'] = '\u0643';
  23130. t['\uFEDA'] = '\u0643';
  23131. t['\uFEDB'] = '\u0643';
  23132. t['\uFEDC'] = '\u0643';
  23133. t['\uFEDD'] = '\u0644';
  23134. t['\uFEDE'] = '\u0644';
  23135. t['\uFEDF'] = '\u0644';
  23136. t['\uFEE0'] = '\u0644';
  23137. t['\uFEE1'] = '\u0645';
  23138. t['\uFEE2'] = '\u0645';
  23139. t['\uFEE3'] = '\u0645';
  23140. t['\uFEE4'] = '\u0645';
  23141. t['\uFEE5'] = '\u0646';
  23142. t['\uFEE6'] = '\u0646';
  23143. t['\uFEE7'] = '\u0646';
  23144. t['\uFEE8'] = '\u0646';
  23145. t['\uFEE9'] = '\u0647';
  23146. t['\uFEEA'] = '\u0647';
  23147. t['\uFEEB'] = '\u0647';
  23148. t['\uFEEC'] = '\u0647';
  23149. t['\uFEED'] = '\u0648';
  23150. t['\uFEEE'] = '\u0648';
  23151. t['\uFEEF'] = '\u0649';
  23152. t['\uFEF0'] = '\u0649';
  23153. t['\uFEF1'] = '\u064A';
  23154. t['\uFEF2'] = '\u064A';
  23155. t['\uFEF3'] = '\u064A';
  23156. t['\uFEF4'] = '\u064A';
  23157. t['\uFEF5'] = '\u0644\u0622';
  23158. t['\uFEF6'] = '\u0644\u0622';
  23159. t['\uFEF7'] = '\u0644\u0623';
  23160. t['\uFEF8'] = '\u0644\u0623';
  23161. t['\uFEF9'] = '\u0644\u0625';
  23162. t['\uFEFA'] = '\u0644\u0625';
  23163. t['\uFEFB'] = '\u0644\u0627';
  23164. t['\uFEFC'] = '\u0644\u0627';
  23165. });
  23166. function reverseIfRtl(chars) {
  23167. var charsLength = chars.length;
  23168. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23169. return chars;
  23170. }
  23171. var s = '';
  23172. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23173. s += chars[ii];
  23174. }
  23175. return s;
  23176. }
  23177. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23178. exports.reverseIfRtl = reverseIfRtl;
  23179. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23180. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23181. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23182. }));
  23183. (function (root, factory) {
  23184. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23185. }(this, function (exports, sharedUtil) {
  23186. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23187. var warn = sharedUtil.warn;
  23188. var deprecated = sharedUtil.deprecated;
  23189. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23190. var CustomStyle = function CustomStyleClosure() {
  23191. var prefixes = [
  23192. 'ms',
  23193. 'Moz',
  23194. 'Webkit',
  23195. 'O'
  23196. ];
  23197. var _cache = Object.create(null);
  23198. function CustomStyle() {
  23199. }
  23200. CustomStyle.getProp = function get(propName, element) {
  23201. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23202. return _cache[propName];
  23203. }
  23204. element = element || document.documentElement;
  23205. var style = element.style, prefixed, uPropName;
  23206. if (typeof style[propName] === 'string') {
  23207. return _cache[propName] = propName;
  23208. }
  23209. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23210. for (var i = 0, l = prefixes.length; i < l; i++) {
  23211. prefixed = prefixes[i] + uPropName;
  23212. if (typeof style[prefixed] === 'string') {
  23213. return _cache[propName] = prefixed;
  23214. }
  23215. }
  23216. return _cache[propName] = 'undefined';
  23217. };
  23218. CustomStyle.setProp = function set(propName, element, str) {
  23219. var prop = this.getProp(propName);
  23220. if (prop !== 'undefined') {
  23221. element.style[prop] = str;
  23222. }
  23223. };
  23224. return CustomStyle;
  23225. }();
  23226. var hasCanvasTypedArrays;
  23227. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23228. var canvas = document.createElement('canvas');
  23229. canvas.width = canvas.height = 1;
  23230. var ctx = canvas.getContext('2d');
  23231. var imageData = ctx.createImageData(1, 1);
  23232. return typeof imageData.data.buffer !== 'undefined';
  23233. };
  23234. var LinkTarget = {
  23235. NONE: 0,
  23236. SELF: 1,
  23237. BLANK: 2,
  23238. PARENT: 3,
  23239. TOP: 4
  23240. };
  23241. var LinkTargetStringMap = [
  23242. '',
  23243. '_self',
  23244. '_blank',
  23245. '_parent',
  23246. '_top'
  23247. ];
  23248. function addLinkAttributes(link, params) {
  23249. var url = params && params.url;
  23250. link.href = link.title = url ? removeNullCharacters(url) : '';
  23251. if (url) {
  23252. var target = params.target;
  23253. if (typeof target === 'undefined') {
  23254. target = getDefaultSetting('externalLinkTarget');
  23255. }
  23256. link.target = LinkTargetStringMap[target];
  23257. var rel = params.rel;
  23258. if (typeof rel === 'undefined') {
  23259. rel = getDefaultSetting('externalLinkRel');
  23260. }
  23261. link.rel = rel;
  23262. }
  23263. }
  23264. function getFilenameFromUrl(url) {
  23265. var anchor = url.indexOf('#');
  23266. var query = url.indexOf('?');
  23267. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23268. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23269. }
  23270. function getDefaultSetting(id) {
  23271. var globalSettings = sharedUtil.globalScope.PDFJS;
  23272. switch (id) {
  23273. case 'pdfBug':
  23274. return globalSettings ? globalSettings.pdfBug : false;
  23275. case 'disableAutoFetch':
  23276. return globalSettings ? globalSettings.disableAutoFetch : false;
  23277. case 'disableStream':
  23278. return globalSettings ? globalSettings.disableStream : false;
  23279. case 'disableRange':
  23280. return globalSettings ? globalSettings.disableRange : false;
  23281. case 'disableFontFace':
  23282. return globalSettings ? globalSettings.disableFontFace : false;
  23283. case 'disableCreateObjectURL':
  23284. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23285. case 'disableWebGL':
  23286. return globalSettings ? globalSettings.disableWebGL : true;
  23287. case 'cMapUrl':
  23288. return globalSettings ? globalSettings.cMapUrl : null;
  23289. case 'cMapPacked':
  23290. return globalSettings ? globalSettings.cMapPacked : false;
  23291. case 'postMessageTransfers':
  23292. return globalSettings ? globalSettings.postMessageTransfers : true;
  23293. case 'workerSrc':
  23294. return globalSettings ? globalSettings.workerSrc : null;
  23295. case 'disableWorker':
  23296. return globalSettings ? globalSettings.disableWorker : false;
  23297. case 'maxImageSize':
  23298. return globalSettings ? globalSettings.maxImageSize : -1;
  23299. case 'imageResourcesPath':
  23300. return globalSettings ? globalSettings.imageResourcesPath : '';
  23301. case 'isEvalSupported':
  23302. return globalSettings ? globalSettings.isEvalSupported : true;
  23303. case 'externalLinkTarget':
  23304. if (!globalSettings) {
  23305. return LinkTarget.NONE;
  23306. }
  23307. switch (globalSettings.externalLinkTarget) {
  23308. case LinkTarget.NONE:
  23309. case LinkTarget.SELF:
  23310. case LinkTarget.BLANK:
  23311. case LinkTarget.PARENT:
  23312. case LinkTarget.TOP:
  23313. return globalSettings.externalLinkTarget;
  23314. }
  23315. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23316. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23317. return LinkTarget.NONE;
  23318. case 'externalLinkRel':
  23319. return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
  23320. case 'enableStats':
  23321. return !!(globalSettings && globalSettings.enableStats);
  23322. default:
  23323. throw new Error('Unknown default setting: ' + id);
  23324. }
  23325. }
  23326. function isExternalLinkTargetSet() {
  23327. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23328. switch (externalLinkTarget) {
  23329. case LinkTarget.NONE:
  23330. return false;
  23331. case LinkTarget.SELF:
  23332. case LinkTarget.BLANK:
  23333. case LinkTarget.PARENT:
  23334. case LinkTarget.TOP:
  23335. return true;
  23336. }
  23337. }
  23338. function isValidUrl(url, allowRelative) {
  23339. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23340. var baseUrl = allowRelative ? 'http://example.com' : null;
  23341. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23342. }
  23343. exports.CustomStyle = CustomStyle;
  23344. exports.addLinkAttributes = addLinkAttributes;
  23345. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23346. exports.isValidUrl = isValidUrl;
  23347. exports.getFilenameFromUrl = getFilenameFromUrl;
  23348. exports.LinkTarget = LinkTarget;
  23349. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23350. exports.getDefaultSetting = getDefaultSetting;
  23351. }));
  23352. (function (root, factory) {
  23353. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23354. }(this, function (exports, sharedUtil) {
  23355. var assert = sharedUtil.assert;
  23356. var bytesToString = sharedUtil.bytesToString;
  23357. var string32 = sharedUtil.string32;
  23358. var shadow = sharedUtil.shadow;
  23359. var warn = sharedUtil.warn;
  23360. function FontLoader(docId) {
  23361. this.docId = docId;
  23362. this.styleElement = null;
  23363. this.nativeFontFaces = [];
  23364. this.loadTestFontId = 0;
  23365. this.loadingContext = {
  23366. requests: [],
  23367. nextRequestId: 0
  23368. };
  23369. }
  23370. FontLoader.prototype = {
  23371. insertRule: function fontLoaderInsertRule(rule) {
  23372. var styleElement = this.styleElement;
  23373. if (!styleElement) {
  23374. styleElement = this.styleElement = document.createElement('style');
  23375. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23376. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23377. }
  23378. var styleSheet = styleElement.sheet;
  23379. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23380. },
  23381. clear: function fontLoaderClear() {
  23382. var styleElement = this.styleElement;
  23383. if (styleElement) {
  23384. styleElement.parentNode.removeChild(styleElement);
  23385. styleElement = this.styleElement = null;
  23386. }
  23387. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23388. document.fonts.delete(nativeFontFace);
  23389. });
  23390. this.nativeFontFaces.length = 0;
  23391. }
  23392. };
  23393. var getLoadTestFont = function () {
  23394. 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==');
  23395. };
  23396. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23397. get: function () {
  23398. return shadow(this, 'loadTestFont', getLoadTestFont());
  23399. },
  23400. configurable: true
  23401. });
  23402. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23403. this.nativeFontFaces.push(nativeFontFace);
  23404. document.fonts.add(nativeFontFace);
  23405. };
  23406. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23407. var rules = [];
  23408. var fontsToLoad = [];
  23409. var fontLoadPromises = [];
  23410. var getNativeFontPromise = function (nativeFontFace) {
  23411. return nativeFontFace.loaded.catch(function (e) {
  23412. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23413. });
  23414. };
  23415. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23416. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23417. var font = fonts[i];
  23418. if (font.attached || font.loading === false) {
  23419. continue;
  23420. }
  23421. font.attached = true;
  23422. if (isFontLoadingAPISupported) {
  23423. var nativeFontFace = font.createNativeFontFace();
  23424. if (nativeFontFace) {
  23425. this.addNativeFontFace(nativeFontFace);
  23426. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23427. }
  23428. } else {
  23429. var rule = font.createFontFaceRule();
  23430. if (rule) {
  23431. this.insertRule(rule);
  23432. rules.push(rule);
  23433. fontsToLoad.push(font);
  23434. }
  23435. }
  23436. }
  23437. var request = this.queueLoadingCallback(callback);
  23438. if (isFontLoadingAPISupported) {
  23439. Promise.all(fontLoadPromises).then(function () {
  23440. request.complete();
  23441. });
  23442. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23443. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23444. } else {
  23445. request.complete();
  23446. }
  23447. };
  23448. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23449. function LoadLoader_completeRequest() {
  23450. assert(!request.end, 'completeRequest() cannot be called twice');
  23451. request.end = Date.now();
  23452. while (context.requests.length > 0 && context.requests[0].end) {
  23453. var otherRequest = context.requests.shift();
  23454. setTimeout(otherRequest.callback, 0);
  23455. }
  23456. }
  23457. var context = this.loadingContext;
  23458. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23459. var request = {
  23460. id: requestId,
  23461. complete: LoadLoader_completeRequest,
  23462. callback: callback,
  23463. started: Date.now()
  23464. };
  23465. context.requests.push(request);
  23466. return request;
  23467. };
  23468. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23469. function int32(data, offset) {
  23470. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23471. }
  23472. function spliceString(s, offset, remove, insert) {
  23473. var chunk1 = s.substr(0, offset);
  23474. var chunk2 = s.substr(offset + remove);
  23475. return chunk1 + insert + chunk2;
  23476. }
  23477. var i, ii;
  23478. var canvas = document.createElement('canvas');
  23479. canvas.width = 1;
  23480. canvas.height = 1;
  23481. var ctx = canvas.getContext('2d');
  23482. var called = 0;
  23483. function isFontReady(name, callback) {
  23484. called++;
  23485. if (called > 30) {
  23486. warn('Load test font never loaded.');
  23487. callback();
  23488. return;
  23489. }
  23490. ctx.font = '30px ' + name;
  23491. ctx.fillText('.', 0, 20);
  23492. var imageData = ctx.getImageData(0, 0, 1, 1);
  23493. if (imageData.data[3] > 0) {
  23494. callback();
  23495. return;
  23496. }
  23497. setTimeout(isFontReady.bind(null, name, callback));
  23498. }
  23499. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23500. var data = this.loadTestFont;
  23501. var COMMENT_OFFSET = 976;
  23502. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23503. var CFF_CHECKSUM_OFFSET = 16;
  23504. var XXXX_VALUE = 0x58585858;
  23505. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23506. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23507. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23508. }
  23509. if (i < loadTestFontId.length) {
  23510. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23511. }
  23512. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23513. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23514. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23515. this.insertRule(rule);
  23516. var names = [];
  23517. for (i = 0, ii = fonts.length; i < ii; i++) {
  23518. names.push(fonts[i].loadedName);
  23519. }
  23520. names.push(loadTestFontId);
  23521. var div = document.createElement('div');
  23522. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23523. for (i = 0, ii = names.length; i < ii; ++i) {
  23524. var span = document.createElement('span');
  23525. span.textContent = 'Hi';
  23526. span.style.fontFamily = names[i];
  23527. div.appendChild(span);
  23528. }
  23529. document.body.appendChild(div);
  23530. isFontReady(loadTestFontId, function () {
  23531. document.body.removeChild(div);
  23532. request.complete();
  23533. });
  23534. };
  23535. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23536. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23537. if (typeof navigator === 'undefined') {
  23538. return true;
  23539. }
  23540. var supported = false;
  23541. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23542. if (m && m[1] >= 14) {
  23543. supported = true;
  23544. }
  23545. return supported;
  23546. };
  23547. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23548. get: function () {
  23549. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23550. },
  23551. enumerable: true,
  23552. configurable: true
  23553. });
  23554. var IsEvalSupportedCached = {
  23555. get value() {
  23556. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23557. }
  23558. };
  23559. var FontFaceObject = function FontFaceObjectClosure() {
  23560. function FontFaceObject(translatedData, options) {
  23561. this.compiledGlyphs = Object.create(null);
  23562. for (var i in translatedData) {
  23563. this[i] = translatedData[i];
  23564. }
  23565. this.options = options;
  23566. }
  23567. FontFaceObject.prototype = {
  23568. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23569. if (!this.data) {
  23570. return null;
  23571. }
  23572. if (this.options.disableFontFace) {
  23573. this.disableFontFace = true;
  23574. return null;
  23575. }
  23576. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23577. if (this.options.fontRegistry) {
  23578. this.options.fontRegistry.registerFont(this);
  23579. }
  23580. return nativeFontFace;
  23581. },
  23582. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23583. if (!this.data) {
  23584. return null;
  23585. }
  23586. if (this.options.disableFontFace) {
  23587. this.disableFontFace = true;
  23588. return null;
  23589. }
  23590. var data = bytesToString(new Uint8Array(this.data));
  23591. var fontName = this.loadedName;
  23592. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23593. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23594. if (this.options.fontRegistry) {
  23595. this.options.fontRegistry.registerFont(this, url);
  23596. }
  23597. return rule;
  23598. },
  23599. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23600. if (!(character in this.compiledGlyphs)) {
  23601. var cmds = objs.get(this.loadedName + '_path_' + character);
  23602. var current, i, len;
  23603. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23604. var args, js = '';
  23605. for (i = 0, len = cmds.length; i < len; i++) {
  23606. current = cmds[i];
  23607. if (current.args !== undefined) {
  23608. args = current.args.join(',');
  23609. } else {
  23610. args = '';
  23611. }
  23612. js += 'c.' + current.cmd + '(' + args + ');\n';
  23613. }
  23614. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23615. } else {
  23616. this.compiledGlyphs[character] = function (c, size) {
  23617. for (i = 0, len = cmds.length; i < len; i++) {
  23618. current = cmds[i];
  23619. if (current.cmd === 'scale') {
  23620. current.args = [
  23621. size,
  23622. -size
  23623. ];
  23624. }
  23625. c[current.cmd].apply(c, current.args);
  23626. }
  23627. };
  23628. }
  23629. }
  23630. return this.compiledGlyphs[character];
  23631. }
  23632. };
  23633. return FontFaceObject;
  23634. }();
  23635. exports.FontFaceObject = FontFaceObject;
  23636. exports.FontLoader = FontLoader;
  23637. }));
  23638. (function (root, factory) {
  23639. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23640. }(this, function (exports, sharedUtil) {
  23641. var error = sharedUtil.error;
  23642. function fixMetadata(meta) {
  23643. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23644. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23645. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23646. });
  23647. var chars = '';
  23648. for (var i = 0; i < bytes.length; i += 2) {
  23649. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23650. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23651. }
  23652. return '>' + chars;
  23653. });
  23654. }
  23655. function Metadata(meta) {
  23656. if (typeof meta === 'string') {
  23657. meta = fixMetadata(meta);
  23658. var parser = new DOMParser();
  23659. meta = parser.parseFromString(meta, 'application/xml');
  23660. } else if (!(meta instanceof Document)) {
  23661. error('Metadata: Invalid metadata object');
  23662. }
  23663. this.metaDocument = meta;
  23664. this.metadata = Object.create(null);
  23665. this.parse();
  23666. }
  23667. Metadata.prototype = {
  23668. parse: function Metadata_parse() {
  23669. var doc = this.metaDocument;
  23670. var rdf = doc.documentElement;
  23671. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23672. rdf = rdf.firstChild;
  23673. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23674. rdf = rdf.nextSibling;
  23675. }
  23676. }
  23677. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23678. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23679. return;
  23680. }
  23681. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23682. for (i = 0, length = children.length; i < length; i++) {
  23683. desc = children[i];
  23684. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23685. continue;
  23686. }
  23687. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23688. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23689. entry = desc.childNodes[ii];
  23690. name = entry.nodeName.toLowerCase();
  23691. this.metadata[name] = entry.textContent.trim();
  23692. }
  23693. }
  23694. }
  23695. },
  23696. get: function Metadata_get(name) {
  23697. return this.metadata[name] || null;
  23698. },
  23699. has: function Metadata_has(name) {
  23700. return typeof this.metadata[name] !== 'undefined';
  23701. }
  23702. };
  23703. exports.Metadata = Metadata;
  23704. }));
  23705. (function (root, factory) {
  23706. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23707. }(this, function (exports, sharedUtil) {
  23708. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23709. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23710. var ImageKind = sharedUtil.ImageKind;
  23711. var OPS = sharedUtil.OPS;
  23712. var Util = sharedUtil.Util;
  23713. var isNum = sharedUtil.isNum;
  23714. var isArray = sharedUtil.isArray;
  23715. var warn = sharedUtil.warn;
  23716. var createObjectURL = sharedUtil.createObjectURL;
  23717. var SVG_DEFAULTS = {
  23718. fontStyle: 'normal',
  23719. fontWeight: 'normal',
  23720. fillColor: '#000000'
  23721. };
  23722. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23723. var PNG_HEADER = new Uint8Array([
  23724. 0x89,
  23725. 0x50,
  23726. 0x4e,
  23727. 0x47,
  23728. 0x0d,
  23729. 0x0a,
  23730. 0x1a,
  23731. 0x0a
  23732. ]);
  23733. var CHUNK_WRAPPER_SIZE = 12;
  23734. var crcTable = new Int32Array(256);
  23735. for (var i = 0; i < 256; i++) {
  23736. var c = i;
  23737. for (var h = 0; h < 8; h++) {
  23738. if (c & 1) {
  23739. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23740. } else {
  23741. c = c >> 1 & 0x7fffffff;
  23742. }
  23743. }
  23744. crcTable[i] = c;
  23745. }
  23746. function crc32(data, start, end) {
  23747. var crc = -1;
  23748. for (var i = start; i < end; i++) {
  23749. var a = (crc ^ data[i]) & 0xff;
  23750. var b = crcTable[a];
  23751. crc = crc >>> 8 ^ b;
  23752. }
  23753. return crc ^ -1;
  23754. }
  23755. function writePngChunk(type, body, data, offset) {
  23756. var p = offset;
  23757. var len = body.length;
  23758. data[p] = len >> 24 & 0xff;
  23759. data[p + 1] = len >> 16 & 0xff;
  23760. data[p + 2] = len >> 8 & 0xff;
  23761. data[p + 3] = len & 0xff;
  23762. p += 4;
  23763. data[p] = type.charCodeAt(0) & 0xff;
  23764. data[p + 1] = type.charCodeAt(1) & 0xff;
  23765. data[p + 2] = type.charCodeAt(2) & 0xff;
  23766. data[p + 3] = type.charCodeAt(3) & 0xff;
  23767. p += 4;
  23768. data.set(body, p);
  23769. p += body.length;
  23770. var crc = crc32(data, offset + 4, p);
  23771. data[p] = crc >> 24 & 0xff;
  23772. data[p + 1] = crc >> 16 & 0xff;
  23773. data[p + 2] = crc >> 8 & 0xff;
  23774. data[p + 3] = crc & 0xff;
  23775. }
  23776. function adler32(data, start, end) {
  23777. var a = 1;
  23778. var b = 0;
  23779. for (var i = start; i < end; ++i) {
  23780. a = (a + (data[i] & 0xff)) % 65521;
  23781. b = (b + a) % 65521;
  23782. }
  23783. return b << 16 | a;
  23784. }
  23785. function encode(imgData, kind, forceDataSchema) {
  23786. var width = imgData.width;
  23787. var height = imgData.height;
  23788. var bitDepth, colorType, lineSize;
  23789. var bytes = imgData.data;
  23790. switch (kind) {
  23791. case ImageKind.GRAYSCALE_1BPP:
  23792. colorType = 0;
  23793. bitDepth = 1;
  23794. lineSize = width + 7 >> 3;
  23795. break;
  23796. case ImageKind.RGB_24BPP:
  23797. colorType = 2;
  23798. bitDepth = 8;
  23799. lineSize = width * 3;
  23800. break;
  23801. case ImageKind.RGBA_32BPP:
  23802. colorType = 6;
  23803. bitDepth = 8;
  23804. lineSize = width * 4;
  23805. break;
  23806. default:
  23807. throw new Error('invalid format');
  23808. }
  23809. var literals = new Uint8Array((1 + lineSize) * height);
  23810. var offsetLiterals = 0, offsetBytes = 0;
  23811. var y, i;
  23812. for (y = 0; y < height; ++y) {
  23813. literals[offsetLiterals++] = 0;
  23814. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23815. offsetBytes += lineSize;
  23816. offsetLiterals += lineSize;
  23817. }
  23818. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23819. offsetLiterals = 0;
  23820. for (y = 0; y < height; y++) {
  23821. offsetLiterals++;
  23822. for (i = 0; i < lineSize; i++) {
  23823. literals[offsetLiterals++] ^= 0xFF;
  23824. }
  23825. }
  23826. }
  23827. var ihdr = new Uint8Array([
  23828. width >> 24 & 0xff,
  23829. width >> 16 & 0xff,
  23830. width >> 8 & 0xff,
  23831. width & 0xff,
  23832. height >> 24 & 0xff,
  23833. height >> 16 & 0xff,
  23834. height >> 8 & 0xff,
  23835. height & 0xff,
  23836. bitDepth,
  23837. colorType,
  23838. 0x00,
  23839. 0x00,
  23840. 0x00
  23841. ]);
  23842. var len = literals.length;
  23843. var maxBlockLength = 0xFFFF;
  23844. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23845. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23846. var pi = 0;
  23847. idat[pi++] = 0x78;
  23848. idat[pi++] = 0x9c;
  23849. var pos = 0;
  23850. while (len > maxBlockLength) {
  23851. idat[pi++] = 0x00;
  23852. idat[pi++] = 0xff;
  23853. idat[pi++] = 0xff;
  23854. idat[pi++] = 0x00;
  23855. idat[pi++] = 0x00;
  23856. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23857. pi += maxBlockLength;
  23858. pos += maxBlockLength;
  23859. len -= maxBlockLength;
  23860. }
  23861. idat[pi++] = 0x01;
  23862. idat[pi++] = len & 0xff;
  23863. idat[pi++] = len >> 8 & 0xff;
  23864. idat[pi++] = ~len & 0xffff & 0xff;
  23865. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23866. idat.set(literals.subarray(pos), pi);
  23867. pi += literals.length - pos;
  23868. var adler = adler32(literals, 0, literals.length);
  23869. idat[pi++] = adler >> 24 & 0xff;
  23870. idat[pi++] = adler >> 16 & 0xff;
  23871. idat[pi++] = adler >> 8 & 0xff;
  23872. idat[pi++] = adler & 0xff;
  23873. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23874. var data = new Uint8Array(pngLength);
  23875. var offset = 0;
  23876. data.set(PNG_HEADER, offset);
  23877. offset += PNG_HEADER.length;
  23878. writePngChunk('IHDR', ihdr, data, offset);
  23879. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23880. writePngChunk('IDATA', idat, data, offset);
  23881. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23882. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23883. return createObjectURL(data, 'image/png', forceDataSchema);
  23884. }
  23885. return function convertImgDataToPng(imgData, forceDataSchema) {
  23886. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23887. return encode(imgData, kind, forceDataSchema);
  23888. };
  23889. }();
  23890. var SVGExtraState = function SVGExtraStateClosure() {
  23891. function SVGExtraState() {
  23892. this.fontSizeScale = 1;
  23893. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23894. this.fontSize = 0;
  23895. this.textMatrix = IDENTITY_MATRIX;
  23896. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23897. this.leading = 0;
  23898. this.x = 0;
  23899. this.y = 0;
  23900. this.lineX = 0;
  23901. this.lineY = 0;
  23902. this.charSpacing = 0;
  23903. this.wordSpacing = 0;
  23904. this.textHScale = 1;
  23905. this.textRise = 0;
  23906. this.fillColor = SVG_DEFAULTS.fillColor;
  23907. this.strokeColor = '#000000';
  23908. this.fillAlpha = 1;
  23909. this.strokeAlpha = 1;
  23910. this.lineWidth = 1;
  23911. this.lineJoin = '';
  23912. this.lineCap = '';
  23913. this.miterLimit = 0;
  23914. this.dashArray = [];
  23915. this.dashPhase = 0;
  23916. this.dependencies = [];
  23917. this.activeClipUrl = null;
  23918. this.clipGroup = null;
  23919. this.maskId = '';
  23920. }
  23921. SVGExtraState.prototype = {
  23922. clone: function SVGExtraState_clone() {
  23923. return Object.create(this);
  23924. },
  23925. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23926. this.x = x;
  23927. this.y = y;
  23928. }
  23929. };
  23930. return SVGExtraState;
  23931. }();
  23932. var SVGGraphics = function SVGGraphicsClosure() {
  23933. function opListToTree(opList) {
  23934. var opTree = [];
  23935. var tmp = [];
  23936. var opListLen = opList.length;
  23937. for (var x = 0; x < opListLen; x++) {
  23938. if (opList[x].fn === 'save') {
  23939. opTree.push({
  23940. 'fnId': 92,
  23941. 'fn': 'group',
  23942. 'items': []
  23943. });
  23944. tmp.push(opTree);
  23945. opTree = opTree[opTree.length - 1].items;
  23946. continue;
  23947. }
  23948. if (opList[x].fn === 'restore') {
  23949. opTree = tmp.pop();
  23950. } else {
  23951. opTree.push(opList[x]);
  23952. }
  23953. }
  23954. return opTree;
  23955. }
  23956. function pf(value) {
  23957. if (value === (value | 0)) {
  23958. return value.toString();
  23959. }
  23960. var s = value.toFixed(10);
  23961. var i = s.length - 1;
  23962. if (s[i] !== '0') {
  23963. return s;
  23964. }
  23965. do {
  23966. i--;
  23967. } while (s[i] === '0');
  23968. return s.substr(0, s[i] === '.' ? i : i + 1);
  23969. }
  23970. function pm(m) {
  23971. if (m[4] === 0 && m[5] === 0) {
  23972. if (m[1] === 0 && m[2] === 0) {
  23973. if (m[0] === 1 && m[3] === 1) {
  23974. return '';
  23975. }
  23976. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  23977. }
  23978. if (m[0] === m[3] && m[1] === -m[2]) {
  23979. var a = Math.acos(m[0]) * 180 / Math.PI;
  23980. return 'rotate(' + pf(a) + ')';
  23981. }
  23982. } else {
  23983. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  23984. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23985. }
  23986. }
  23987. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23988. }
  23989. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  23990. this.current = new SVGExtraState();
  23991. this.transformMatrix = IDENTITY_MATRIX;
  23992. this.transformStack = [];
  23993. this.extraStack = [];
  23994. this.commonObjs = commonObjs;
  23995. this.objs = objs;
  23996. this.pendingEOFill = false;
  23997. this.embedFonts = false;
  23998. this.embeddedFonts = Object.create(null);
  23999. this.cssStyle = null;
  24000. this.forceDataSchema = !!forceDataSchema;
  24001. }
  24002. var NS = 'http://www.w3.org/2000/svg';
  24003. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  24004. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  24005. var LINE_CAP_STYLES = [
  24006. 'butt',
  24007. 'round',
  24008. 'square'
  24009. ];
  24010. var LINE_JOIN_STYLES = [
  24011. 'miter',
  24012. 'round',
  24013. 'bevel'
  24014. ];
  24015. var clipCount = 0;
  24016. var maskCount = 0;
  24017. SVGGraphics.prototype = {
  24018. save: function SVGGraphics_save() {
  24019. this.transformStack.push(this.transformMatrix);
  24020. var old = this.current;
  24021. this.extraStack.push(old);
  24022. this.current = old.clone();
  24023. },
  24024. restore: function SVGGraphics_restore() {
  24025. this.transformMatrix = this.transformStack.pop();
  24026. this.current = this.extraStack.pop();
  24027. this.tgrp = null;
  24028. },
  24029. group: function SVGGraphics_group(items) {
  24030. this.save();
  24031. this.executeOpTree(items);
  24032. this.restore();
  24033. },
  24034. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  24035. var fnArray = operatorList.fnArray;
  24036. var fnArrayLen = fnArray.length;
  24037. var argsArray = operatorList.argsArray;
  24038. var self = this;
  24039. for (var i = 0; i < fnArrayLen; i++) {
  24040. if (OPS.dependency === fnArray[i]) {
  24041. var deps = argsArray[i];
  24042. for (var n = 0, nn = deps.length; n < nn; n++) {
  24043. var obj = deps[n];
  24044. var common = obj.substring(0, 2) === 'g_';
  24045. var promise;
  24046. if (common) {
  24047. promise = new Promise(function (resolve) {
  24048. self.commonObjs.get(obj, resolve);
  24049. });
  24050. } else {
  24051. promise = new Promise(function (resolve) {
  24052. self.objs.get(obj, resolve);
  24053. });
  24054. }
  24055. this.current.dependencies.push(promise);
  24056. }
  24057. }
  24058. }
  24059. return Promise.all(this.current.dependencies);
  24060. },
  24061. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  24062. var transformMatrix = [
  24063. a,
  24064. b,
  24065. c,
  24066. d,
  24067. e,
  24068. f
  24069. ];
  24070. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  24071. this.tgrp = null;
  24072. },
  24073. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  24074. this.viewport = viewport;
  24075. var svgElement = this._initialize(viewport);
  24076. return this.loadDependencies(operatorList).then(function () {
  24077. this.transformMatrix = IDENTITY_MATRIX;
  24078. var opTree = this.convertOpList(operatorList);
  24079. this.executeOpTree(opTree);
  24080. return svgElement;
  24081. }.bind(this));
  24082. },
  24083. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  24084. var argsArray = operatorList.argsArray;
  24085. var fnArray = operatorList.fnArray;
  24086. var fnArrayLen = fnArray.length;
  24087. var REVOPS = [];
  24088. var opList = [];
  24089. for (var op in OPS) {
  24090. REVOPS[OPS[op]] = op;
  24091. }
  24092. for (var x = 0; x < fnArrayLen; x++) {
  24093. var fnId = fnArray[x];
  24094. opList.push({
  24095. 'fnId': fnId,
  24096. 'fn': REVOPS[fnId],
  24097. 'args': argsArray[x]
  24098. });
  24099. }
  24100. return opListToTree(opList);
  24101. },
  24102. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  24103. var opTreeLen = opTree.length;
  24104. for (var x = 0; x < opTreeLen; x++) {
  24105. var fn = opTree[x].fn;
  24106. var fnId = opTree[x].fnId;
  24107. var args = opTree[x].args;
  24108. switch (fnId | 0) {
  24109. case OPS.beginText:
  24110. this.beginText();
  24111. break;
  24112. case OPS.setLeading:
  24113. this.setLeading(args);
  24114. break;
  24115. case OPS.setLeadingMoveText:
  24116. this.setLeadingMoveText(args[0], args[1]);
  24117. break;
  24118. case OPS.setFont:
  24119. this.setFont(args);
  24120. break;
  24121. case OPS.showText:
  24122. this.showText(args[0]);
  24123. break;
  24124. case OPS.showSpacedText:
  24125. this.showText(args[0]);
  24126. break;
  24127. case OPS.endText:
  24128. this.endText();
  24129. break;
  24130. case OPS.moveText:
  24131. this.moveText(args[0], args[1]);
  24132. break;
  24133. case OPS.setCharSpacing:
  24134. this.setCharSpacing(args[0]);
  24135. break;
  24136. case OPS.setWordSpacing:
  24137. this.setWordSpacing(args[0]);
  24138. break;
  24139. case OPS.setHScale:
  24140. this.setHScale(args[0]);
  24141. break;
  24142. case OPS.setTextMatrix:
  24143. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24144. break;
  24145. case OPS.setLineWidth:
  24146. this.setLineWidth(args[0]);
  24147. break;
  24148. case OPS.setLineJoin:
  24149. this.setLineJoin(args[0]);
  24150. break;
  24151. case OPS.setLineCap:
  24152. this.setLineCap(args[0]);
  24153. break;
  24154. case OPS.setMiterLimit:
  24155. this.setMiterLimit(args[0]);
  24156. break;
  24157. case OPS.setFillRGBColor:
  24158. this.setFillRGBColor(args[0], args[1], args[2]);
  24159. break;
  24160. case OPS.setStrokeRGBColor:
  24161. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24162. break;
  24163. case OPS.setDash:
  24164. this.setDash(args[0], args[1]);
  24165. break;
  24166. case OPS.setGState:
  24167. this.setGState(args[0]);
  24168. break;
  24169. case OPS.fill:
  24170. this.fill();
  24171. break;
  24172. case OPS.eoFill:
  24173. this.eoFill();
  24174. break;
  24175. case OPS.stroke:
  24176. this.stroke();
  24177. break;
  24178. case OPS.fillStroke:
  24179. this.fillStroke();
  24180. break;
  24181. case OPS.eoFillStroke:
  24182. this.eoFillStroke();
  24183. break;
  24184. case OPS.clip:
  24185. this.clip('nonzero');
  24186. break;
  24187. case OPS.eoClip:
  24188. this.clip('evenodd');
  24189. break;
  24190. case OPS.paintSolidColorImageMask:
  24191. this.paintSolidColorImageMask();
  24192. break;
  24193. case OPS.paintJpegXObject:
  24194. this.paintJpegXObject(args[0], args[1], args[2]);
  24195. break;
  24196. case OPS.paintImageXObject:
  24197. this.paintImageXObject(args[0]);
  24198. break;
  24199. case OPS.paintInlineImageXObject:
  24200. this.paintInlineImageXObject(args[0]);
  24201. break;
  24202. case OPS.paintImageMaskXObject:
  24203. this.paintImageMaskXObject(args[0]);
  24204. break;
  24205. case OPS.paintFormXObjectBegin:
  24206. this.paintFormXObjectBegin(args[0], args[1]);
  24207. break;
  24208. case OPS.paintFormXObjectEnd:
  24209. this.paintFormXObjectEnd();
  24210. break;
  24211. case OPS.closePath:
  24212. this.closePath();
  24213. break;
  24214. case OPS.closeStroke:
  24215. this.closeStroke();
  24216. break;
  24217. case OPS.closeFillStroke:
  24218. this.closeFillStroke();
  24219. break;
  24220. case OPS.nextLine:
  24221. this.nextLine();
  24222. break;
  24223. case OPS.transform:
  24224. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24225. break;
  24226. case OPS.constructPath:
  24227. this.constructPath(args[0], args[1]);
  24228. break;
  24229. case OPS.endPath:
  24230. this.endPath();
  24231. break;
  24232. case 92:
  24233. this.group(opTree[x].items);
  24234. break;
  24235. default:
  24236. warn('Unimplemented operator ' + fn);
  24237. break;
  24238. }
  24239. }
  24240. },
  24241. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24242. this.current.wordSpacing = wordSpacing;
  24243. },
  24244. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24245. this.current.charSpacing = charSpacing;
  24246. },
  24247. nextLine: function SVGGraphics_nextLine() {
  24248. this.moveText(0, this.current.leading);
  24249. },
  24250. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24251. var current = this.current;
  24252. this.current.textMatrix = this.current.lineMatrix = [
  24253. a,
  24254. b,
  24255. c,
  24256. d,
  24257. e,
  24258. f
  24259. ];
  24260. this.current.x = this.current.lineX = 0;
  24261. this.current.y = this.current.lineY = 0;
  24262. current.xcoords = [];
  24263. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24264. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24265. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24266. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24267. current.txtElement = document.createElementNS(NS, 'svg:text');
  24268. current.txtElement.appendChild(current.tspan);
  24269. },
  24270. beginText: function SVGGraphics_beginText() {
  24271. this.current.x = this.current.lineX = 0;
  24272. this.current.y = this.current.lineY = 0;
  24273. this.current.textMatrix = IDENTITY_MATRIX;
  24274. this.current.lineMatrix = IDENTITY_MATRIX;
  24275. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24276. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24277. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24278. this.current.xcoords = [];
  24279. },
  24280. moveText: function SVGGraphics_moveText(x, y) {
  24281. var current = this.current;
  24282. this.current.x = this.current.lineX += x;
  24283. this.current.y = this.current.lineY += y;
  24284. current.xcoords = [];
  24285. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24286. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24287. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24288. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24289. },
  24290. showText: function SVGGraphics_showText(glyphs) {
  24291. var current = this.current;
  24292. var font = current.font;
  24293. var fontSize = current.fontSize;
  24294. if (fontSize === 0) {
  24295. return;
  24296. }
  24297. var charSpacing = current.charSpacing;
  24298. var wordSpacing = current.wordSpacing;
  24299. var fontDirection = current.fontDirection;
  24300. var textHScale = current.textHScale * fontDirection;
  24301. var glyphsLength = glyphs.length;
  24302. var vertical = font.vertical;
  24303. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24304. var x = 0, i;
  24305. for (i = 0; i < glyphsLength; ++i) {
  24306. var glyph = glyphs[i];
  24307. if (glyph === null) {
  24308. x += fontDirection * wordSpacing;
  24309. continue;
  24310. } else if (isNum(glyph)) {
  24311. x += -glyph * fontSize * 0.001;
  24312. continue;
  24313. }
  24314. current.xcoords.push(current.x + x * textHScale);
  24315. var width = glyph.width;
  24316. var character = glyph.fontChar;
  24317. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24318. x += charWidth;
  24319. current.tspan.textContent += character;
  24320. }
  24321. if (vertical) {
  24322. current.y -= x * textHScale;
  24323. } else {
  24324. current.x += x * textHScale;
  24325. }
  24326. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24327. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24328. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24329. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24330. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24331. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24332. }
  24333. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24334. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24335. }
  24336. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24337. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24338. }
  24339. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24340. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24341. current.txtElement.appendChild(current.tspan);
  24342. current.txtgrp.appendChild(current.txtElement);
  24343. this._ensureTransformGroup().appendChild(current.txtElement);
  24344. },
  24345. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24346. this.setLeading(-y);
  24347. this.moveText(x, y);
  24348. },
  24349. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24350. if (!this.cssStyle) {
  24351. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24352. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24353. this.defs.appendChild(this.cssStyle);
  24354. }
  24355. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24356. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24357. },
  24358. setFont: function SVGGraphics_setFont(details) {
  24359. var current = this.current;
  24360. var fontObj = this.commonObjs.get(details[0]);
  24361. var size = details[1];
  24362. this.current.font = fontObj;
  24363. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24364. this.addFontStyle(fontObj);
  24365. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24366. }
  24367. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24368. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24369. var italic = fontObj.italic ? 'italic' : 'normal';
  24370. if (size < 0) {
  24371. size = -size;
  24372. current.fontDirection = -1;
  24373. } else {
  24374. current.fontDirection = 1;
  24375. }
  24376. current.fontSize = size;
  24377. current.fontFamily = fontObj.loadedName;
  24378. current.fontWeight = bold;
  24379. current.fontStyle = italic;
  24380. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24381. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24382. current.xcoords = [];
  24383. },
  24384. endText: function SVGGraphics_endText() {
  24385. },
  24386. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24387. this.current.lineWidth = width;
  24388. },
  24389. setLineCap: function SVGGraphics_setLineCap(style) {
  24390. this.current.lineCap = LINE_CAP_STYLES[style];
  24391. },
  24392. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24393. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24394. },
  24395. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24396. this.current.miterLimit = limit;
  24397. },
  24398. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24399. var color = Util.makeCssRgb(r, g, b);
  24400. this.current.strokeColor = color;
  24401. },
  24402. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24403. var color = Util.makeCssRgb(r, g, b);
  24404. this.current.fillColor = color;
  24405. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24406. this.current.xcoords = [];
  24407. },
  24408. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24409. this.current.dashArray = dashArray;
  24410. this.current.dashPhase = dashPhase;
  24411. },
  24412. constructPath: function SVGGraphics_constructPath(ops, args) {
  24413. var current = this.current;
  24414. var x = current.x, y = current.y;
  24415. current.path = document.createElementNS(NS, 'svg:path');
  24416. var d = [];
  24417. var opLength = ops.length;
  24418. for (var i = 0, j = 0; i < opLength; i++) {
  24419. switch (ops[i] | 0) {
  24420. case OPS.rectangle:
  24421. x = args[j++];
  24422. y = args[j++];
  24423. var width = args[j++];
  24424. var height = args[j++];
  24425. var xw = x + width;
  24426. var yh = y + height;
  24427. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24428. break;
  24429. case OPS.moveTo:
  24430. x = args[j++];
  24431. y = args[j++];
  24432. d.push('M', pf(x), pf(y));
  24433. break;
  24434. case OPS.lineTo:
  24435. x = args[j++];
  24436. y = args[j++];
  24437. d.push('L', pf(x), pf(y));
  24438. break;
  24439. case OPS.curveTo:
  24440. x = args[j + 4];
  24441. y = args[j + 5];
  24442. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24443. j += 6;
  24444. break;
  24445. case OPS.curveTo2:
  24446. x = args[j + 2];
  24447. y = args[j + 3];
  24448. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24449. j += 4;
  24450. break;
  24451. case OPS.curveTo3:
  24452. x = args[j + 2];
  24453. y = args[j + 3];
  24454. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24455. j += 4;
  24456. break;
  24457. case OPS.closePath:
  24458. d.push('Z');
  24459. break;
  24460. }
  24461. }
  24462. current.path.setAttributeNS(null, 'd', d.join(' '));
  24463. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24464. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24465. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24466. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24467. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24468. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24469. current.path.setAttributeNS(null, 'fill', 'none');
  24470. this._ensureTransformGroup().appendChild(current.path);
  24471. current.element = current.path;
  24472. current.setCurrentPoint(x, y);
  24473. },
  24474. endPath: function SVGGraphics_endPath() {
  24475. },
  24476. clip: function SVGGraphics_clip(type) {
  24477. var current = this.current;
  24478. var clipId = 'clippath' + clipCount;
  24479. clipCount++;
  24480. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24481. clipPath.setAttributeNS(null, 'id', clipId);
  24482. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24483. var clipElement = current.element.cloneNode();
  24484. if (type === 'evenodd') {
  24485. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24486. } else {
  24487. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24488. }
  24489. clipPath.appendChild(clipElement);
  24490. this.defs.appendChild(clipPath);
  24491. if (current.activeClipUrl) {
  24492. current.clipGroup = null;
  24493. this.extraStack.forEach(function (prev) {
  24494. prev.clipGroup = null;
  24495. });
  24496. }
  24497. current.activeClipUrl = 'url(#' + clipId + ')';
  24498. this.tgrp = null;
  24499. },
  24500. closePath: function SVGGraphics_closePath() {
  24501. var current = this.current;
  24502. var d = current.path.getAttributeNS(null, 'd');
  24503. d += 'Z';
  24504. current.path.setAttributeNS(null, 'd', d);
  24505. },
  24506. setLeading: function SVGGraphics_setLeading(leading) {
  24507. this.current.leading = -leading;
  24508. },
  24509. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24510. this.current.textRise = textRise;
  24511. },
  24512. setHScale: function SVGGraphics_setHScale(scale) {
  24513. this.current.textHScale = scale / 100;
  24514. },
  24515. setGState: function SVGGraphics_setGState(states) {
  24516. for (var i = 0, ii = states.length; i < ii; i++) {
  24517. var state = states[i];
  24518. var key = state[0];
  24519. var value = state[1];
  24520. switch (key) {
  24521. case 'LW':
  24522. this.setLineWidth(value);
  24523. break;
  24524. case 'LC':
  24525. this.setLineCap(value);
  24526. break;
  24527. case 'LJ':
  24528. this.setLineJoin(value);
  24529. break;
  24530. case 'ML':
  24531. this.setMiterLimit(value);
  24532. break;
  24533. case 'D':
  24534. this.setDash(value[0], value[1]);
  24535. break;
  24536. case 'Font':
  24537. this.setFont(value);
  24538. break;
  24539. default:
  24540. warn('Unimplemented graphic state ' + key);
  24541. break;
  24542. }
  24543. }
  24544. },
  24545. fill: function SVGGraphics_fill() {
  24546. var current = this.current;
  24547. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24548. },
  24549. stroke: function SVGGraphics_stroke() {
  24550. var current = this.current;
  24551. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24552. current.element.setAttributeNS(null, 'fill', 'none');
  24553. },
  24554. eoFill: function SVGGraphics_eoFill() {
  24555. var current = this.current;
  24556. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24557. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24558. },
  24559. fillStroke: function SVGGraphics_fillStroke() {
  24560. this.stroke();
  24561. this.fill();
  24562. },
  24563. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24564. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24565. this.fillStroke();
  24566. },
  24567. closeStroke: function SVGGraphics_closeStroke() {
  24568. this.closePath();
  24569. this.stroke();
  24570. },
  24571. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24572. this.closePath();
  24573. this.fillStroke();
  24574. },
  24575. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24576. var current = this.current;
  24577. var rect = document.createElementNS(NS, 'svg:rect');
  24578. rect.setAttributeNS(null, 'x', '0');
  24579. rect.setAttributeNS(null, 'y', '0');
  24580. rect.setAttributeNS(null, 'width', '1px');
  24581. rect.setAttributeNS(null, 'height', '1px');
  24582. rect.setAttributeNS(null, 'fill', current.fillColor);
  24583. this._ensureTransformGroup().appendChild(rect);
  24584. },
  24585. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24586. var imgObj = this.objs.get(objId);
  24587. var imgEl = document.createElementNS(NS, 'svg:image');
  24588. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24589. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24590. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24591. imgEl.setAttributeNS(null, 'x', '0');
  24592. imgEl.setAttributeNS(null, 'y', pf(-h));
  24593. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24594. this._ensureTransformGroup().appendChild(imgEl);
  24595. },
  24596. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24597. var imgData = this.objs.get(objId);
  24598. if (!imgData) {
  24599. warn('Dependent image isn\'t ready yet');
  24600. return;
  24601. }
  24602. this.paintInlineImageXObject(imgData);
  24603. },
  24604. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24605. var width = imgData.width;
  24606. var height = imgData.height;
  24607. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24608. var cliprect = document.createElementNS(NS, 'svg:rect');
  24609. cliprect.setAttributeNS(null, 'x', '0');
  24610. cliprect.setAttributeNS(null, 'y', '0');
  24611. cliprect.setAttributeNS(null, 'width', pf(width));
  24612. cliprect.setAttributeNS(null, 'height', pf(height));
  24613. this.current.element = cliprect;
  24614. this.clip('nonzero');
  24615. var imgEl = document.createElementNS(NS, 'svg:image');
  24616. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24617. imgEl.setAttributeNS(null, 'x', '0');
  24618. imgEl.setAttributeNS(null, 'y', pf(-height));
  24619. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24620. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24621. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24622. if (mask) {
  24623. mask.appendChild(imgEl);
  24624. } else {
  24625. this._ensureTransformGroup().appendChild(imgEl);
  24626. }
  24627. },
  24628. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24629. var current = this.current;
  24630. var width = imgData.width;
  24631. var height = imgData.height;
  24632. var fillColor = current.fillColor;
  24633. current.maskId = 'mask' + maskCount++;
  24634. var mask = document.createElementNS(NS, 'svg:mask');
  24635. mask.setAttributeNS(null, 'id', current.maskId);
  24636. var rect = document.createElementNS(NS, 'svg:rect');
  24637. rect.setAttributeNS(null, 'x', '0');
  24638. rect.setAttributeNS(null, 'y', '0');
  24639. rect.setAttributeNS(null, 'width', pf(width));
  24640. rect.setAttributeNS(null, 'height', pf(height));
  24641. rect.setAttributeNS(null, 'fill', fillColor);
  24642. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24643. this.defs.appendChild(mask);
  24644. this._ensureTransformGroup().appendChild(rect);
  24645. this.paintInlineImageXObject(imgData, mask);
  24646. },
  24647. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24648. if (isArray(matrix) && matrix.length === 6) {
  24649. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24650. }
  24651. if (isArray(bbox) && bbox.length === 4) {
  24652. var width = bbox[2] - bbox[0];
  24653. var height = bbox[3] - bbox[1];
  24654. var cliprect = document.createElementNS(NS, 'svg:rect');
  24655. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24656. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24657. cliprect.setAttributeNS(null, 'width', pf(width));
  24658. cliprect.setAttributeNS(null, 'height', pf(height));
  24659. this.current.element = cliprect;
  24660. this.clip('nonzero');
  24661. this.endPath();
  24662. }
  24663. },
  24664. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24665. },
  24666. _initialize: function SVGGraphics_initialize(viewport) {
  24667. var svg = document.createElementNS(NS, 'svg:svg');
  24668. svg.setAttributeNS(null, 'version', '1.1');
  24669. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24670. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24671. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24672. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24673. var definitions = document.createElementNS(NS, 'svg:defs');
  24674. svg.appendChild(definitions);
  24675. this.defs = definitions;
  24676. var rootGroup = document.createElementNS(NS, 'svg:g');
  24677. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24678. svg.appendChild(rootGroup);
  24679. this.svg = rootGroup;
  24680. return svg;
  24681. },
  24682. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24683. if (!this.current.clipGroup) {
  24684. var clipGroup = document.createElementNS(NS, 'svg:g');
  24685. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24686. this.svg.appendChild(clipGroup);
  24687. this.current.clipGroup = clipGroup;
  24688. }
  24689. return this.current.clipGroup;
  24690. },
  24691. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24692. if (!this.tgrp) {
  24693. this.tgrp = document.createElementNS(NS, 'svg:g');
  24694. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24695. if (this.current.activeClipUrl) {
  24696. this._ensureClipGroup().appendChild(this.tgrp);
  24697. } else {
  24698. this.svg.appendChild(this.tgrp);
  24699. }
  24700. }
  24701. return this.tgrp;
  24702. }
  24703. };
  24704. return SVGGraphics;
  24705. }();
  24706. exports.SVGGraphics = SVGGraphics;
  24707. }));
  24708. (function (root, factory) {
  24709. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24710. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24711. var Util = sharedUtil.Util;
  24712. var error = sharedUtil.error;
  24713. var info = sharedUtil.info;
  24714. var isInt = sharedUtil.isInt;
  24715. var isArray = sharedUtil.isArray;
  24716. var createObjectURL = sharedUtil.createObjectURL;
  24717. var shadow = sharedUtil.shadow;
  24718. var warn = sharedUtil.warn;
  24719. var isSpace = sharedUtil.isSpace;
  24720. var Dict = corePrimitives.Dict;
  24721. var isDict = corePrimitives.isDict;
  24722. var isStream = corePrimitives.isStream;
  24723. var Jbig2Image = coreJbig2.Jbig2Image;
  24724. var JpegImage = coreJpg.JpegImage;
  24725. var JpxImage = coreJpx.JpxImage;
  24726. var Stream = function StreamClosure() {
  24727. function Stream(arrayBuffer, start, length, dict) {
  24728. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24729. this.start = start || 0;
  24730. this.pos = this.start;
  24731. this.end = start + length || this.bytes.length;
  24732. this.dict = dict;
  24733. }
  24734. Stream.prototype = {
  24735. get length() {
  24736. return this.end - this.start;
  24737. },
  24738. get isEmpty() {
  24739. return this.length === 0;
  24740. },
  24741. getByte: function Stream_getByte() {
  24742. if (this.pos >= this.end) {
  24743. return -1;
  24744. }
  24745. return this.bytes[this.pos++];
  24746. },
  24747. getUint16: function Stream_getUint16() {
  24748. var b0 = this.getByte();
  24749. var b1 = this.getByte();
  24750. if (b0 === -1 || b1 === -1) {
  24751. return -1;
  24752. }
  24753. return (b0 << 8) + b1;
  24754. },
  24755. getInt32: function Stream_getInt32() {
  24756. var b0 = this.getByte();
  24757. var b1 = this.getByte();
  24758. var b2 = this.getByte();
  24759. var b3 = this.getByte();
  24760. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24761. },
  24762. getBytes: function Stream_getBytes(length) {
  24763. var bytes = this.bytes;
  24764. var pos = this.pos;
  24765. var strEnd = this.end;
  24766. if (!length) {
  24767. return bytes.subarray(pos, strEnd);
  24768. }
  24769. var end = pos + length;
  24770. if (end > strEnd) {
  24771. end = strEnd;
  24772. }
  24773. this.pos = end;
  24774. return bytes.subarray(pos, end);
  24775. },
  24776. peekByte: function Stream_peekByte() {
  24777. var peekedByte = this.getByte();
  24778. this.pos--;
  24779. return peekedByte;
  24780. },
  24781. peekBytes: function Stream_peekBytes(length) {
  24782. var bytes = this.getBytes(length);
  24783. this.pos -= bytes.length;
  24784. return bytes;
  24785. },
  24786. skip: function Stream_skip(n) {
  24787. if (!n) {
  24788. n = 1;
  24789. }
  24790. this.pos += n;
  24791. },
  24792. reset: function Stream_reset() {
  24793. this.pos = this.start;
  24794. },
  24795. moveStart: function Stream_moveStart() {
  24796. this.start = this.pos;
  24797. },
  24798. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24799. return new Stream(this.bytes.buffer, start, length, dict);
  24800. },
  24801. isStream: true
  24802. };
  24803. return Stream;
  24804. }();
  24805. var StringStream = function StringStreamClosure() {
  24806. function StringStream(str) {
  24807. var length = str.length;
  24808. var bytes = new Uint8Array(length);
  24809. for (var n = 0; n < length; ++n) {
  24810. bytes[n] = str.charCodeAt(n);
  24811. }
  24812. Stream.call(this, bytes);
  24813. }
  24814. StringStream.prototype = Stream.prototype;
  24815. return StringStream;
  24816. }();
  24817. var DecodeStream = function DecodeStreamClosure() {
  24818. var emptyBuffer = new Uint8Array(0);
  24819. function DecodeStream(maybeMinBufferLength) {
  24820. this.pos = 0;
  24821. this.bufferLength = 0;
  24822. this.eof = false;
  24823. this.buffer = emptyBuffer;
  24824. this.minBufferLength = 512;
  24825. if (maybeMinBufferLength) {
  24826. while (this.minBufferLength < maybeMinBufferLength) {
  24827. this.minBufferLength *= 2;
  24828. }
  24829. }
  24830. }
  24831. DecodeStream.prototype = {
  24832. get isEmpty() {
  24833. while (!this.eof && this.bufferLength === 0) {
  24834. this.readBlock();
  24835. }
  24836. return this.bufferLength === 0;
  24837. },
  24838. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24839. var buffer = this.buffer;
  24840. if (requested <= buffer.byteLength) {
  24841. return buffer;
  24842. }
  24843. var size = this.minBufferLength;
  24844. while (size < requested) {
  24845. size *= 2;
  24846. }
  24847. var buffer2 = new Uint8Array(size);
  24848. buffer2.set(buffer);
  24849. return this.buffer = buffer2;
  24850. },
  24851. getByte: function DecodeStream_getByte() {
  24852. var pos = this.pos;
  24853. while (this.bufferLength <= pos) {
  24854. if (this.eof) {
  24855. return -1;
  24856. }
  24857. this.readBlock();
  24858. }
  24859. return this.buffer[this.pos++];
  24860. },
  24861. getUint16: function DecodeStream_getUint16() {
  24862. var b0 = this.getByte();
  24863. var b1 = this.getByte();
  24864. if (b0 === -1 || b1 === -1) {
  24865. return -1;
  24866. }
  24867. return (b0 << 8) + b1;
  24868. },
  24869. getInt32: function DecodeStream_getInt32() {
  24870. var b0 = this.getByte();
  24871. var b1 = this.getByte();
  24872. var b2 = this.getByte();
  24873. var b3 = this.getByte();
  24874. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24875. },
  24876. getBytes: function DecodeStream_getBytes(length) {
  24877. var end, pos = this.pos;
  24878. if (length) {
  24879. this.ensureBuffer(pos + length);
  24880. end = pos + length;
  24881. while (!this.eof && this.bufferLength < end) {
  24882. this.readBlock();
  24883. }
  24884. var bufEnd = this.bufferLength;
  24885. if (end > bufEnd) {
  24886. end = bufEnd;
  24887. }
  24888. } else {
  24889. while (!this.eof) {
  24890. this.readBlock();
  24891. }
  24892. end = this.bufferLength;
  24893. }
  24894. this.pos = end;
  24895. return this.buffer.subarray(pos, end);
  24896. },
  24897. peekByte: function DecodeStream_peekByte() {
  24898. var peekedByte = this.getByte();
  24899. this.pos--;
  24900. return peekedByte;
  24901. },
  24902. peekBytes: function DecodeStream_peekBytes(length) {
  24903. var bytes = this.getBytes(length);
  24904. this.pos -= bytes.length;
  24905. return bytes;
  24906. },
  24907. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24908. var end = start + length;
  24909. while (this.bufferLength <= end && !this.eof) {
  24910. this.readBlock();
  24911. }
  24912. return new Stream(this.buffer, start, length, dict);
  24913. },
  24914. skip: function DecodeStream_skip(n) {
  24915. if (!n) {
  24916. n = 1;
  24917. }
  24918. this.pos += n;
  24919. },
  24920. reset: function DecodeStream_reset() {
  24921. this.pos = 0;
  24922. },
  24923. getBaseStreams: function DecodeStream_getBaseStreams() {
  24924. if (this.str && this.str.getBaseStreams) {
  24925. return this.str.getBaseStreams();
  24926. }
  24927. return [];
  24928. }
  24929. };
  24930. return DecodeStream;
  24931. }();
  24932. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24933. function StreamsSequenceStream(streams) {
  24934. this.streams = streams;
  24935. DecodeStream.call(this, null);
  24936. }
  24937. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24938. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24939. var streams = this.streams;
  24940. if (streams.length === 0) {
  24941. this.eof = true;
  24942. return;
  24943. }
  24944. var stream = streams.shift();
  24945. var chunk = stream.getBytes();
  24946. var bufferLength = this.bufferLength;
  24947. var newLength = bufferLength + chunk.length;
  24948. var buffer = this.ensureBuffer(newLength);
  24949. buffer.set(chunk, bufferLength);
  24950. this.bufferLength = newLength;
  24951. };
  24952. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24953. var baseStreams = [];
  24954. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24955. var stream = this.streams[i];
  24956. if (stream.getBaseStreams) {
  24957. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24958. }
  24959. }
  24960. return baseStreams;
  24961. };
  24962. return StreamsSequenceStream;
  24963. }();
  24964. var FlateStream = function FlateStreamClosure() {
  24965. var codeLenCodeMap = new Int32Array([
  24966. 16,
  24967. 17,
  24968. 18,
  24969. 0,
  24970. 8,
  24971. 7,
  24972. 9,
  24973. 6,
  24974. 10,
  24975. 5,
  24976. 11,
  24977. 4,
  24978. 12,
  24979. 3,
  24980. 13,
  24981. 2,
  24982. 14,
  24983. 1,
  24984. 15
  24985. ]);
  24986. var lengthDecode = new Int32Array([
  24987. 0x00003,
  24988. 0x00004,
  24989. 0x00005,
  24990. 0x00006,
  24991. 0x00007,
  24992. 0x00008,
  24993. 0x00009,
  24994. 0x0000a,
  24995. 0x1000b,
  24996. 0x1000d,
  24997. 0x1000f,
  24998. 0x10011,
  24999. 0x20013,
  25000. 0x20017,
  25001. 0x2001b,
  25002. 0x2001f,
  25003. 0x30023,
  25004. 0x3002b,
  25005. 0x30033,
  25006. 0x3003b,
  25007. 0x40043,
  25008. 0x40053,
  25009. 0x40063,
  25010. 0x40073,
  25011. 0x50083,
  25012. 0x500a3,
  25013. 0x500c3,
  25014. 0x500e3,
  25015. 0x00102,
  25016. 0x00102,
  25017. 0x00102
  25018. ]);
  25019. var distDecode = new Int32Array([
  25020. 0x00001,
  25021. 0x00002,
  25022. 0x00003,
  25023. 0x00004,
  25024. 0x10005,
  25025. 0x10007,
  25026. 0x20009,
  25027. 0x2000d,
  25028. 0x30011,
  25029. 0x30019,
  25030. 0x40021,
  25031. 0x40031,
  25032. 0x50041,
  25033. 0x50061,
  25034. 0x60081,
  25035. 0x600c1,
  25036. 0x70101,
  25037. 0x70181,
  25038. 0x80201,
  25039. 0x80301,
  25040. 0x90401,
  25041. 0x90601,
  25042. 0xa0801,
  25043. 0xa0c01,
  25044. 0xb1001,
  25045. 0xb1801,
  25046. 0xc2001,
  25047. 0xc3001,
  25048. 0xd4001,
  25049. 0xd6001
  25050. ]);
  25051. var fixedLitCodeTab = [
  25052. new Int32Array([
  25053. 0x70100,
  25054. 0x80050,
  25055. 0x80010,
  25056. 0x80118,
  25057. 0x70110,
  25058. 0x80070,
  25059. 0x80030,
  25060. 0x900c0,
  25061. 0x70108,
  25062. 0x80060,
  25063. 0x80020,
  25064. 0x900a0,
  25065. 0x80000,
  25066. 0x80080,
  25067. 0x80040,
  25068. 0x900e0,
  25069. 0x70104,
  25070. 0x80058,
  25071. 0x80018,
  25072. 0x90090,
  25073. 0x70114,
  25074. 0x80078,
  25075. 0x80038,
  25076. 0x900d0,
  25077. 0x7010c,
  25078. 0x80068,
  25079. 0x80028,
  25080. 0x900b0,
  25081. 0x80008,
  25082. 0x80088,
  25083. 0x80048,
  25084. 0x900f0,
  25085. 0x70102,
  25086. 0x80054,
  25087. 0x80014,
  25088. 0x8011c,
  25089. 0x70112,
  25090. 0x80074,
  25091. 0x80034,
  25092. 0x900c8,
  25093. 0x7010a,
  25094. 0x80064,
  25095. 0x80024,
  25096. 0x900a8,
  25097. 0x80004,
  25098. 0x80084,
  25099. 0x80044,
  25100. 0x900e8,
  25101. 0x70106,
  25102. 0x8005c,
  25103. 0x8001c,
  25104. 0x90098,
  25105. 0x70116,
  25106. 0x8007c,
  25107. 0x8003c,
  25108. 0x900d8,
  25109. 0x7010e,
  25110. 0x8006c,
  25111. 0x8002c,
  25112. 0x900b8,
  25113. 0x8000c,
  25114. 0x8008c,
  25115. 0x8004c,
  25116. 0x900f8,
  25117. 0x70101,
  25118. 0x80052,
  25119. 0x80012,
  25120. 0x8011a,
  25121. 0x70111,
  25122. 0x80072,
  25123. 0x80032,
  25124. 0x900c4,
  25125. 0x70109,
  25126. 0x80062,
  25127. 0x80022,
  25128. 0x900a4,
  25129. 0x80002,
  25130. 0x80082,
  25131. 0x80042,
  25132. 0x900e4,
  25133. 0x70105,
  25134. 0x8005a,
  25135. 0x8001a,
  25136. 0x90094,
  25137. 0x70115,
  25138. 0x8007a,
  25139. 0x8003a,
  25140. 0x900d4,
  25141. 0x7010d,
  25142. 0x8006a,
  25143. 0x8002a,
  25144. 0x900b4,
  25145. 0x8000a,
  25146. 0x8008a,
  25147. 0x8004a,
  25148. 0x900f4,
  25149. 0x70103,
  25150. 0x80056,
  25151. 0x80016,
  25152. 0x8011e,
  25153. 0x70113,
  25154. 0x80076,
  25155. 0x80036,
  25156. 0x900cc,
  25157. 0x7010b,
  25158. 0x80066,
  25159. 0x80026,
  25160. 0x900ac,
  25161. 0x80006,
  25162. 0x80086,
  25163. 0x80046,
  25164. 0x900ec,
  25165. 0x70107,
  25166. 0x8005e,
  25167. 0x8001e,
  25168. 0x9009c,
  25169. 0x70117,
  25170. 0x8007e,
  25171. 0x8003e,
  25172. 0x900dc,
  25173. 0x7010f,
  25174. 0x8006e,
  25175. 0x8002e,
  25176. 0x900bc,
  25177. 0x8000e,
  25178. 0x8008e,
  25179. 0x8004e,
  25180. 0x900fc,
  25181. 0x70100,
  25182. 0x80051,
  25183. 0x80011,
  25184. 0x80119,
  25185. 0x70110,
  25186. 0x80071,
  25187. 0x80031,
  25188. 0x900c2,
  25189. 0x70108,
  25190. 0x80061,
  25191. 0x80021,
  25192. 0x900a2,
  25193. 0x80001,
  25194. 0x80081,
  25195. 0x80041,
  25196. 0x900e2,
  25197. 0x70104,
  25198. 0x80059,
  25199. 0x80019,
  25200. 0x90092,
  25201. 0x70114,
  25202. 0x80079,
  25203. 0x80039,
  25204. 0x900d2,
  25205. 0x7010c,
  25206. 0x80069,
  25207. 0x80029,
  25208. 0x900b2,
  25209. 0x80009,
  25210. 0x80089,
  25211. 0x80049,
  25212. 0x900f2,
  25213. 0x70102,
  25214. 0x80055,
  25215. 0x80015,
  25216. 0x8011d,
  25217. 0x70112,
  25218. 0x80075,
  25219. 0x80035,
  25220. 0x900ca,
  25221. 0x7010a,
  25222. 0x80065,
  25223. 0x80025,
  25224. 0x900aa,
  25225. 0x80005,
  25226. 0x80085,
  25227. 0x80045,
  25228. 0x900ea,
  25229. 0x70106,
  25230. 0x8005d,
  25231. 0x8001d,
  25232. 0x9009a,
  25233. 0x70116,
  25234. 0x8007d,
  25235. 0x8003d,
  25236. 0x900da,
  25237. 0x7010e,
  25238. 0x8006d,
  25239. 0x8002d,
  25240. 0x900ba,
  25241. 0x8000d,
  25242. 0x8008d,
  25243. 0x8004d,
  25244. 0x900fa,
  25245. 0x70101,
  25246. 0x80053,
  25247. 0x80013,
  25248. 0x8011b,
  25249. 0x70111,
  25250. 0x80073,
  25251. 0x80033,
  25252. 0x900c6,
  25253. 0x70109,
  25254. 0x80063,
  25255. 0x80023,
  25256. 0x900a6,
  25257. 0x80003,
  25258. 0x80083,
  25259. 0x80043,
  25260. 0x900e6,
  25261. 0x70105,
  25262. 0x8005b,
  25263. 0x8001b,
  25264. 0x90096,
  25265. 0x70115,
  25266. 0x8007b,
  25267. 0x8003b,
  25268. 0x900d6,
  25269. 0x7010d,
  25270. 0x8006b,
  25271. 0x8002b,
  25272. 0x900b6,
  25273. 0x8000b,
  25274. 0x8008b,
  25275. 0x8004b,
  25276. 0x900f6,
  25277. 0x70103,
  25278. 0x80057,
  25279. 0x80017,
  25280. 0x8011f,
  25281. 0x70113,
  25282. 0x80077,
  25283. 0x80037,
  25284. 0x900ce,
  25285. 0x7010b,
  25286. 0x80067,
  25287. 0x80027,
  25288. 0x900ae,
  25289. 0x80007,
  25290. 0x80087,
  25291. 0x80047,
  25292. 0x900ee,
  25293. 0x70107,
  25294. 0x8005f,
  25295. 0x8001f,
  25296. 0x9009e,
  25297. 0x70117,
  25298. 0x8007f,
  25299. 0x8003f,
  25300. 0x900de,
  25301. 0x7010f,
  25302. 0x8006f,
  25303. 0x8002f,
  25304. 0x900be,
  25305. 0x8000f,
  25306. 0x8008f,
  25307. 0x8004f,
  25308. 0x900fe,
  25309. 0x70100,
  25310. 0x80050,
  25311. 0x80010,
  25312. 0x80118,
  25313. 0x70110,
  25314. 0x80070,
  25315. 0x80030,
  25316. 0x900c1,
  25317. 0x70108,
  25318. 0x80060,
  25319. 0x80020,
  25320. 0x900a1,
  25321. 0x80000,
  25322. 0x80080,
  25323. 0x80040,
  25324. 0x900e1,
  25325. 0x70104,
  25326. 0x80058,
  25327. 0x80018,
  25328. 0x90091,
  25329. 0x70114,
  25330. 0x80078,
  25331. 0x80038,
  25332. 0x900d1,
  25333. 0x7010c,
  25334. 0x80068,
  25335. 0x80028,
  25336. 0x900b1,
  25337. 0x80008,
  25338. 0x80088,
  25339. 0x80048,
  25340. 0x900f1,
  25341. 0x70102,
  25342. 0x80054,
  25343. 0x80014,
  25344. 0x8011c,
  25345. 0x70112,
  25346. 0x80074,
  25347. 0x80034,
  25348. 0x900c9,
  25349. 0x7010a,
  25350. 0x80064,
  25351. 0x80024,
  25352. 0x900a9,
  25353. 0x80004,
  25354. 0x80084,
  25355. 0x80044,
  25356. 0x900e9,
  25357. 0x70106,
  25358. 0x8005c,
  25359. 0x8001c,
  25360. 0x90099,
  25361. 0x70116,
  25362. 0x8007c,
  25363. 0x8003c,
  25364. 0x900d9,
  25365. 0x7010e,
  25366. 0x8006c,
  25367. 0x8002c,
  25368. 0x900b9,
  25369. 0x8000c,
  25370. 0x8008c,
  25371. 0x8004c,
  25372. 0x900f9,
  25373. 0x70101,
  25374. 0x80052,
  25375. 0x80012,
  25376. 0x8011a,
  25377. 0x70111,
  25378. 0x80072,
  25379. 0x80032,
  25380. 0x900c5,
  25381. 0x70109,
  25382. 0x80062,
  25383. 0x80022,
  25384. 0x900a5,
  25385. 0x80002,
  25386. 0x80082,
  25387. 0x80042,
  25388. 0x900e5,
  25389. 0x70105,
  25390. 0x8005a,
  25391. 0x8001a,
  25392. 0x90095,
  25393. 0x70115,
  25394. 0x8007a,
  25395. 0x8003a,
  25396. 0x900d5,
  25397. 0x7010d,
  25398. 0x8006a,
  25399. 0x8002a,
  25400. 0x900b5,
  25401. 0x8000a,
  25402. 0x8008a,
  25403. 0x8004a,
  25404. 0x900f5,
  25405. 0x70103,
  25406. 0x80056,
  25407. 0x80016,
  25408. 0x8011e,
  25409. 0x70113,
  25410. 0x80076,
  25411. 0x80036,
  25412. 0x900cd,
  25413. 0x7010b,
  25414. 0x80066,
  25415. 0x80026,
  25416. 0x900ad,
  25417. 0x80006,
  25418. 0x80086,
  25419. 0x80046,
  25420. 0x900ed,
  25421. 0x70107,
  25422. 0x8005e,
  25423. 0x8001e,
  25424. 0x9009d,
  25425. 0x70117,
  25426. 0x8007e,
  25427. 0x8003e,
  25428. 0x900dd,
  25429. 0x7010f,
  25430. 0x8006e,
  25431. 0x8002e,
  25432. 0x900bd,
  25433. 0x8000e,
  25434. 0x8008e,
  25435. 0x8004e,
  25436. 0x900fd,
  25437. 0x70100,
  25438. 0x80051,
  25439. 0x80011,
  25440. 0x80119,
  25441. 0x70110,
  25442. 0x80071,
  25443. 0x80031,
  25444. 0x900c3,
  25445. 0x70108,
  25446. 0x80061,
  25447. 0x80021,
  25448. 0x900a3,
  25449. 0x80001,
  25450. 0x80081,
  25451. 0x80041,
  25452. 0x900e3,
  25453. 0x70104,
  25454. 0x80059,
  25455. 0x80019,
  25456. 0x90093,
  25457. 0x70114,
  25458. 0x80079,
  25459. 0x80039,
  25460. 0x900d3,
  25461. 0x7010c,
  25462. 0x80069,
  25463. 0x80029,
  25464. 0x900b3,
  25465. 0x80009,
  25466. 0x80089,
  25467. 0x80049,
  25468. 0x900f3,
  25469. 0x70102,
  25470. 0x80055,
  25471. 0x80015,
  25472. 0x8011d,
  25473. 0x70112,
  25474. 0x80075,
  25475. 0x80035,
  25476. 0x900cb,
  25477. 0x7010a,
  25478. 0x80065,
  25479. 0x80025,
  25480. 0x900ab,
  25481. 0x80005,
  25482. 0x80085,
  25483. 0x80045,
  25484. 0x900eb,
  25485. 0x70106,
  25486. 0x8005d,
  25487. 0x8001d,
  25488. 0x9009b,
  25489. 0x70116,
  25490. 0x8007d,
  25491. 0x8003d,
  25492. 0x900db,
  25493. 0x7010e,
  25494. 0x8006d,
  25495. 0x8002d,
  25496. 0x900bb,
  25497. 0x8000d,
  25498. 0x8008d,
  25499. 0x8004d,
  25500. 0x900fb,
  25501. 0x70101,
  25502. 0x80053,
  25503. 0x80013,
  25504. 0x8011b,
  25505. 0x70111,
  25506. 0x80073,
  25507. 0x80033,
  25508. 0x900c7,
  25509. 0x70109,
  25510. 0x80063,
  25511. 0x80023,
  25512. 0x900a7,
  25513. 0x80003,
  25514. 0x80083,
  25515. 0x80043,
  25516. 0x900e7,
  25517. 0x70105,
  25518. 0x8005b,
  25519. 0x8001b,
  25520. 0x90097,
  25521. 0x70115,
  25522. 0x8007b,
  25523. 0x8003b,
  25524. 0x900d7,
  25525. 0x7010d,
  25526. 0x8006b,
  25527. 0x8002b,
  25528. 0x900b7,
  25529. 0x8000b,
  25530. 0x8008b,
  25531. 0x8004b,
  25532. 0x900f7,
  25533. 0x70103,
  25534. 0x80057,
  25535. 0x80017,
  25536. 0x8011f,
  25537. 0x70113,
  25538. 0x80077,
  25539. 0x80037,
  25540. 0x900cf,
  25541. 0x7010b,
  25542. 0x80067,
  25543. 0x80027,
  25544. 0x900af,
  25545. 0x80007,
  25546. 0x80087,
  25547. 0x80047,
  25548. 0x900ef,
  25549. 0x70107,
  25550. 0x8005f,
  25551. 0x8001f,
  25552. 0x9009f,
  25553. 0x70117,
  25554. 0x8007f,
  25555. 0x8003f,
  25556. 0x900df,
  25557. 0x7010f,
  25558. 0x8006f,
  25559. 0x8002f,
  25560. 0x900bf,
  25561. 0x8000f,
  25562. 0x8008f,
  25563. 0x8004f,
  25564. 0x900ff
  25565. ]),
  25566. 9
  25567. ];
  25568. var fixedDistCodeTab = [
  25569. new Int32Array([
  25570. 0x50000,
  25571. 0x50010,
  25572. 0x50008,
  25573. 0x50018,
  25574. 0x50004,
  25575. 0x50014,
  25576. 0x5000c,
  25577. 0x5001c,
  25578. 0x50002,
  25579. 0x50012,
  25580. 0x5000a,
  25581. 0x5001a,
  25582. 0x50006,
  25583. 0x50016,
  25584. 0x5000e,
  25585. 0x00000,
  25586. 0x50001,
  25587. 0x50011,
  25588. 0x50009,
  25589. 0x50019,
  25590. 0x50005,
  25591. 0x50015,
  25592. 0x5000d,
  25593. 0x5001d,
  25594. 0x50003,
  25595. 0x50013,
  25596. 0x5000b,
  25597. 0x5001b,
  25598. 0x50007,
  25599. 0x50017,
  25600. 0x5000f,
  25601. 0x00000
  25602. ]),
  25603. 5
  25604. ];
  25605. function FlateStream(str, maybeLength) {
  25606. this.str = str;
  25607. this.dict = str.dict;
  25608. var cmf = str.getByte();
  25609. var flg = str.getByte();
  25610. if (cmf === -1 || flg === -1) {
  25611. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25612. }
  25613. if ((cmf & 0x0f) !== 0x08) {
  25614. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25615. }
  25616. if (((cmf << 8) + flg) % 31 !== 0) {
  25617. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25618. }
  25619. if (flg & 0x20) {
  25620. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25621. }
  25622. this.codeSize = 0;
  25623. this.codeBuf = 0;
  25624. DecodeStream.call(this, maybeLength);
  25625. }
  25626. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25627. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25628. var str = this.str;
  25629. var codeSize = this.codeSize;
  25630. var codeBuf = this.codeBuf;
  25631. var b;
  25632. while (codeSize < bits) {
  25633. if ((b = str.getByte()) === -1) {
  25634. error('Bad encoding in flate stream');
  25635. }
  25636. codeBuf |= b << codeSize;
  25637. codeSize += 8;
  25638. }
  25639. b = codeBuf & (1 << bits) - 1;
  25640. this.codeBuf = codeBuf >> bits;
  25641. this.codeSize = codeSize -= bits;
  25642. return b;
  25643. };
  25644. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25645. var str = this.str;
  25646. var codes = table[0];
  25647. var maxLen = table[1];
  25648. var codeSize = this.codeSize;
  25649. var codeBuf = this.codeBuf;
  25650. var b;
  25651. while (codeSize < maxLen) {
  25652. if ((b = str.getByte()) === -1) {
  25653. break;
  25654. }
  25655. codeBuf |= b << codeSize;
  25656. codeSize += 8;
  25657. }
  25658. var code = codes[codeBuf & (1 << maxLen) - 1];
  25659. var codeLen = code >> 16;
  25660. var codeVal = code & 0xffff;
  25661. if (codeLen < 1 || codeSize < codeLen) {
  25662. error('Bad encoding in flate stream');
  25663. }
  25664. this.codeBuf = codeBuf >> codeLen;
  25665. this.codeSize = codeSize - codeLen;
  25666. return codeVal;
  25667. };
  25668. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25669. var n = lengths.length;
  25670. var maxLen = 0;
  25671. var i;
  25672. for (i = 0; i < n; ++i) {
  25673. if (lengths[i] > maxLen) {
  25674. maxLen = lengths[i];
  25675. }
  25676. }
  25677. var size = 1 << maxLen;
  25678. var codes = new Int32Array(size);
  25679. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25680. for (var val = 0; val < n; ++val) {
  25681. if (lengths[val] === len) {
  25682. var code2 = 0;
  25683. var t = code;
  25684. for (i = 0; i < len; ++i) {
  25685. code2 = code2 << 1 | t & 1;
  25686. t >>= 1;
  25687. }
  25688. for (i = code2; i < size; i += skip) {
  25689. codes[i] = len << 16 | val;
  25690. }
  25691. ++code;
  25692. }
  25693. }
  25694. }
  25695. return [
  25696. codes,
  25697. maxLen
  25698. ];
  25699. };
  25700. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25701. var buffer, len;
  25702. var str = this.str;
  25703. var hdr = this.getBits(3);
  25704. if (hdr & 1) {
  25705. this.eof = true;
  25706. }
  25707. hdr >>= 1;
  25708. if (hdr === 0) {
  25709. var b;
  25710. if ((b = str.getByte()) === -1) {
  25711. error('Bad block header in flate stream');
  25712. }
  25713. var blockLen = b;
  25714. if ((b = str.getByte()) === -1) {
  25715. error('Bad block header in flate stream');
  25716. }
  25717. blockLen |= b << 8;
  25718. if ((b = str.getByte()) === -1) {
  25719. error('Bad block header in flate stream');
  25720. }
  25721. var check = b;
  25722. if ((b = str.getByte()) === -1) {
  25723. error('Bad block header in flate stream');
  25724. }
  25725. check |= b << 8;
  25726. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25727. error('Bad uncompressed block length in flate stream');
  25728. }
  25729. this.codeBuf = 0;
  25730. this.codeSize = 0;
  25731. var bufferLength = this.bufferLength;
  25732. buffer = this.ensureBuffer(bufferLength + blockLen);
  25733. var end = bufferLength + blockLen;
  25734. this.bufferLength = end;
  25735. if (blockLen === 0) {
  25736. if (str.peekByte() === -1) {
  25737. this.eof = true;
  25738. }
  25739. } else {
  25740. for (var n = bufferLength; n < end; ++n) {
  25741. if ((b = str.getByte()) === -1) {
  25742. this.eof = true;
  25743. break;
  25744. }
  25745. buffer[n] = b;
  25746. }
  25747. }
  25748. return;
  25749. }
  25750. var litCodeTable;
  25751. var distCodeTable;
  25752. if (hdr === 1) {
  25753. litCodeTable = fixedLitCodeTab;
  25754. distCodeTable = fixedDistCodeTab;
  25755. } else if (hdr === 2) {
  25756. var numLitCodes = this.getBits(5) + 257;
  25757. var numDistCodes = this.getBits(5) + 1;
  25758. var numCodeLenCodes = this.getBits(4) + 4;
  25759. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25760. var i;
  25761. for (i = 0; i < numCodeLenCodes; ++i) {
  25762. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25763. }
  25764. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25765. len = 0;
  25766. i = 0;
  25767. var codes = numLitCodes + numDistCodes;
  25768. var codeLengths = new Uint8Array(codes);
  25769. var bitsLength, bitsOffset, what;
  25770. while (i < codes) {
  25771. var code = this.getCode(codeLenCodeTab);
  25772. if (code === 16) {
  25773. bitsLength = 2;
  25774. bitsOffset = 3;
  25775. what = len;
  25776. } else if (code === 17) {
  25777. bitsLength = 3;
  25778. bitsOffset = 3;
  25779. what = len = 0;
  25780. } else if (code === 18) {
  25781. bitsLength = 7;
  25782. bitsOffset = 11;
  25783. what = len = 0;
  25784. } else {
  25785. codeLengths[i++] = len = code;
  25786. continue;
  25787. }
  25788. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25789. while (repeatLength-- > 0) {
  25790. codeLengths[i++] = what;
  25791. }
  25792. }
  25793. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25794. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25795. } else {
  25796. error('Unknown block type in flate stream');
  25797. }
  25798. buffer = this.buffer;
  25799. var limit = buffer ? buffer.length : 0;
  25800. var pos = this.bufferLength;
  25801. while (true) {
  25802. var code1 = this.getCode(litCodeTable);
  25803. if (code1 < 256) {
  25804. if (pos + 1 >= limit) {
  25805. buffer = this.ensureBuffer(pos + 1);
  25806. limit = buffer.length;
  25807. }
  25808. buffer[pos++] = code1;
  25809. continue;
  25810. }
  25811. if (code1 === 256) {
  25812. this.bufferLength = pos;
  25813. return;
  25814. }
  25815. code1 -= 257;
  25816. code1 = lengthDecode[code1];
  25817. var code2 = code1 >> 16;
  25818. if (code2 > 0) {
  25819. code2 = this.getBits(code2);
  25820. }
  25821. len = (code1 & 0xffff) + code2;
  25822. code1 = this.getCode(distCodeTable);
  25823. code1 = distDecode[code1];
  25824. code2 = code1 >> 16;
  25825. if (code2 > 0) {
  25826. code2 = this.getBits(code2);
  25827. }
  25828. var dist = (code1 & 0xffff) + code2;
  25829. if (pos + len >= limit) {
  25830. buffer = this.ensureBuffer(pos + len);
  25831. limit = buffer.length;
  25832. }
  25833. for (var k = 0; k < len; ++k, ++pos) {
  25834. buffer[pos] = buffer[pos - dist];
  25835. }
  25836. }
  25837. };
  25838. return FlateStream;
  25839. }();
  25840. var PredictorStream = function PredictorStreamClosure() {
  25841. function PredictorStream(str, maybeLength, params) {
  25842. if (!isDict(params)) {
  25843. return str;
  25844. }
  25845. var predictor = this.predictor = params.get('Predictor') || 1;
  25846. if (predictor <= 1) {
  25847. return str;
  25848. }
  25849. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25850. error('Unsupported predictor: ' + predictor);
  25851. }
  25852. if (predictor === 2) {
  25853. this.readBlock = this.readBlockTiff;
  25854. } else {
  25855. this.readBlock = this.readBlockPng;
  25856. }
  25857. this.str = str;
  25858. this.dict = str.dict;
  25859. var colors = this.colors = params.get('Colors') || 1;
  25860. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25861. var columns = this.columns = params.get('Columns') || 1;
  25862. this.pixBytes = colors * bits + 7 >> 3;
  25863. this.rowBytes = columns * colors * bits + 7 >> 3;
  25864. DecodeStream.call(this, maybeLength);
  25865. return this;
  25866. }
  25867. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25868. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25869. var rowBytes = this.rowBytes;
  25870. var bufferLength = this.bufferLength;
  25871. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25872. var bits = this.bits;
  25873. var colors = this.colors;
  25874. var rawBytes = this.str.getBytes(rowBytes);
  25875. this.eof = !rawBytes.length;
  25876. if (this.eof) {
  25877. return;
  25878. }
  25879. var inbuf = 0, outbuf = 0;
  25880. var inbits = 0, outbits = 0;
  25881. var pos = bufferLength;
  25882. var i;
  25883. if (bits === 1) {
  25884. for (i = 0; i < rowBytes; ++i) {
  25885. var c = rawBytes[i];
  25886. inbuf = inbuf << 8 | c;
  25887. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  25888. inbuf &= 0xFFFF;
  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. } else {
  31297. warn('Unimplemented button widget annotation: pushbutton');
  31298. }
  31299. break;
  31300. case 'Ch':
  31301. return new ChoiceWidgetAnnotationElement(parameters);
  31302. }
  31303. return new WidgetAnnotationElement(parameters);
  31304. case AnnotationType.POPUP:
  31305. return new PopupAnnotationElement(parameters);
  31306. case AnnotationType.HIGHLIGHT:
  31307. return new HighlightAnnotationElement(parameters);
  31308. case AnnotationType.UNDERLINE:
  31309. return new UnderlineAnnotationElement(parameters);
  31310. case AnnotationType.SQUIGGLY:
  31311. return new SquigglyAnnotationElement(parameters);
  31312. case AnnotationType.STRIKEOUT:
  31313. return new StrikeOutAnnotationElement(parameters);
  31314. case AnnotationType.FILEATTACHMENT:
  31315. return new FileAttachmentAnnotationElement(parameters);
  31316. default:
  31317. return new AnnotationElement(parameters);
  31318. }
  31319. }
  31320. };
  31321. var AnnotationElement = function AnnotationElementClosure() {
  31322. function AnnotationElement(parameters, isRenderable) {
  31323. this.isRenderable = isRenderable || false;
  31324. this.data = parameters.data;
  31325. this.layer = parameters.layer;
  31326. this.page = parameters.page;
  31327. this.viewport = parameters.viewport;
  31328. this.linkService = parameters.linkService;
  31329. this.downloadManager = parameters.downloadManager;
  31330. this.imageResourcesPath = parameters.imageResourcesPath;
  31331. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31332. if (isRenderable) {
  31333. this.container = this._createContainer();
  31334. }
  31335. }
  31336. AnnotationElement.prototype = {
  31337. _createContainer: function AnnotationElement_createContainer() {
  31338. var data = this.data, page = this.page, viewport = this.viewport;
  31339. var container = document.createElement('section');
  31340. var width = data.rect[2] - data.rect[0];
  31341. var height = data.rect[3] - data.rect[1];
  31342. container.setAttribute('data-annotation-id', data.id);
  31343. var rect = Util.normalizeRect([
  31344. data.rect[0],
  31345. page.view[3] - data.rect[1] + page.view[1],
  31346. data.rect[2],
  31347. page.view[3] - data.rect[3] + page.view[1]
  31348. ]);
  31349. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31350. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31351. if (data.borderStyle.width > 0) {
  31352. container.style.borderWidth = data.borderStyle.width + 'px';
  31353. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31354. width = width - 2 * data.borderStyle.width;
  31355. height = height - 2 * data.borderStyle.width;
  31356. }
  31357. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31358. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31359. if (horizontalRadius > 0 || verticalRadius > 0) {
  31360. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31361. CustomStyle.setProp('borderRadius', container, radius);
  31362. }
  31363. switch (data.borderStyle.style) {
  31364. case AnnotationBorderStyleType.SOLID:
  31365. container.style.borderStyle = 'solid';
  31366. break;
  31367. case AnnotationBorderStyleType.DASHED:
  31368. container.style.borderStyle = 'dashed';
  31369. break;
  31370. case AnnotationBorderStyleType.BEVELED:
  31371. warn('Unimplemented border style: beveled');
  31372. break;
  31373. case AnnotationBorderStyleType.INSET:
  31374. warn('Unimplemented border style: inset');
  31375. break;
  31376. case AnnotationBorderStyleType.UNDERLINE:
  31377. container.style.borderBottomStyle = 'solid';
  31378. break;
  31379. default:
  31380. break;
  31381. }
  31382. if (data.color) {
  31383. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31384. } else {
  31385. container.style.borderWidth = 0;
  31386. }
  31387. }
  31388. container.style.left = rect[0] + 'px';
  31389. container.style.top = rect[1] + 'px';
  31390. container.style.width = width + 'px';
  31391. container.style.height = height + 'px';
  31392. return container;
  31393. },
  31394. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31395. if (!trigger) {
  31396. trigger = document.createElement('div');
  31397. trigger.style.height = container.style.height;
  31398. trigger.style.width = container.style.width;
  31399. container.appendChild(trigger);
  31400. }
  31401. var popupElement = new PopupElement({
  31402. container: container,
  31403. trigger: trigger,
  31404. color: data.color,
  31405. title: data.title,
  31406. contents: data.contents,
  31407. hideWrapper: true
  31408. });
  31409. var popup = popupElement.render();
  31410. popup.style.left = container.style.width;
  31411. container.appendChild(popup);
  31412. },
  31413. render: function AnnotationElement_render() {
  31414. throw new Error('Abstract method AnnotationElement.render called');
  31415. }
  31416. };
  31417. return AnnotationElement;
  31418. }();
  31419. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31420. function LinkAnnotationElement(parameters) {
  31421. AnnotationElement.call(this, parameters, true);
  31422. }
  31423. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31424. render: function LinkAnnotationElement_render() {
  31425. this.container.className = 'linkAnnotation';
  31426. var link = document.createElement('a');
  31427. addLinkAttributes(link, {
  31428. url: this.data.url,
  31429. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31430. });
  31431. if (!this.data.url) {
  31432. if (this.data.action) {
  31433. this._bindNamedAction(link, this.data.action);
  31434. } else {
  31435. this._bindLink(link, this.data.dest);
  31436. }
  31437. }
  31438. this.container.appendChild(link);
  31439. return this.container;
  31440. },
  31441. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31442. var self = this;
  31443. link.href = this.linkService.getDestinationHash(destination);
  31444. link.onclick = function () {
  31445. if (destination) {
  31446. self.linkService.navigateTo(destination);
  31447. }
  31448. return false;
  31449. };
  31450. if (destination) {
  31451. link.className = 'internalLink';
  31452. }
  31453. },
  31454. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31455. var self = this;
  31456. link.href = this.linkService.getAnchorUrl('');
  31457. link.onclick = function () {
  31458. self.linkService.executeNamedAction(action);
  31459. return false;
  31460. };
  31461. link.className = 'internalLink';
  31462. }
  31463. });
  31464. return LinkAnnotationElement;
  31465. }();
  31466. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31467. function TextAnnotationElement(parameters) {
  31468. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31469. AnnotationElement.call(this, parameters, isRenderable);
  31470. }
  31471. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31472. render: function TextAnnotationElement_render() {
  31473. this.container.className = 'textAnnotation';
  31474. var image = document.createElement('img');
  31475. image.style.height = this.container.style.height;
  31476. image.style.width = this.container.style.width;
  31477. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31478. image.alt = '[{{type}} Annotation]';
  31479. image.dataset.l10nId = 'text_annotation_type';
  31480. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31481. if (!this.data.hasPopup) {
  31482. this._createPopup(this.container, image, this.data);
  31483. }
  31484. this.container.appendChild(image);
  31485. return this.container;
  31486. }
  31487. });
  31488. return TextAnnotationElement;
  31489. }();
  31490. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31491. function WidgetAnnotationElement(parameters, isRenderable) {
  31492. AnnotationElement.call(this, parameters, isRenderable);
  31493. }
  31494. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31495. render: function WidgetAnnotationElement_render() {
  31496. return this.container;
  31497. }
  31498. });
  31499. return WidgetAnnotationElement;
  31500. }();
  31501. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31502. var TEXT_ALIGNMENT = [
  31503. 'left',
  31504. 'center',
  31505. 'right'
  31506. ];
  31507. function TextWidgetAnnotationElement(parameters) {
  31508. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31509. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31510. }
  31511. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31512. render: function TextWidgetAnnotationElement_render() {
  31513. this.container.className = 'textWidgetAnnotation';
  31514. var element = null;
  31515. if (this.renderInteractiveForms) {
  31516. if (this.data.multiLine) {
  31517. element = document.createElement('textarea');
  31518. element.textContent = this.data.fieldValue;
  31519. } else {
  31520. element = document.createElement('input');
  31521. element.type = 'text';
  31522. element.setAttribute('value', this.data.fieldValue);
  31523. }
  31524. element.disabled = this.data.readOnly;
  31525. if (this.data.maxLen !== null) {
  31526. element.maxLength = this.data.maxLen;
  31527. }
  31528. if (this.data.comb) {
  31529. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31530. var combWidth = fieldWidth / this.data.maxLen;
  31531. element.classList.add('comb');
  31532. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31533. }
  31534. } else {
  31535. element = document.createElement('div');
  31536. element.textContent = this.data.fieldValue;
  31537. element.style.verticalAlign = 'middle';
  31538. element.style.display = 'table-cell';
  31539. var font = null;
  31540. if (this.data.fontRefName) {
  31541. font = this.page.commonObjs.getData(this.data.fontRefName);
  31542. }
  31543. this._setTextStyle(element, font);
  31544. }
  31545. if (this.data.textAlignment !== null) {
  31546. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31547. }
  31548. this.container.appendChild(element);
  31549. return this.container;
  31550. },
  31551. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31552. var style = element.style;
  31553. style.fontSize = this.data.fontSize + 'px';
  31554. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31555. if (!font) {
  31556. return;
  31557. }
  31558. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31559. style.fontStyle = font.italic ? 'italic' : 'normal';
  31560. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31561. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31562. style.fontFamily = fontFamily + fallbackName;
  31563. }
  31564. });
  31565. return TextWidgetAnnotationElement;
  31566. }();
  31567. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  31568. function CheckboxWidgetAnnotationElement(parameters) {
  31569. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31570. }
  31571. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  31572. render: function CheckboxWidgetAnnotationElement_render() {
  31573. this.container.className = 'buttonWidgetAnnotation checkBox';
  31574. var element = document.createElement('input');
  31575. element.disabled = this.data.readOnly;
  31576. element.type = 'checkbox';
  31577. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  31578. element.setAttribute('checked', true);
  31579. }
  31580. this.container.appendChild(element);
  31581. return this.container;
  31582. }
  31583. });
  31584. return CheckboxWidgetAnnotationElement;
  31585. }();
  31586. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  31587. function RadioButtonWidgetAnnotationElement(parameters) {
  31588. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31589. }
  31590. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  31591. render: function RadioButtonWidgetAnnotationElement_render() {
  31592. this.container.className = 'buttonWidgetAnnotation radioButton';
  31593. var element = document.createElement('input');
  31594. element.disabled = this.data.readOnly;
  31595. element.type = 'radio';
  31596. element.name = this.data.fieldName;
  31597. if (this.data.fieldValue === this.data.buttonValue) {
  31598. element.setAttribute('checked', true);
  31599. }
  31600. this.container.appendChild(element);
  31601. return this.container;
  31602. }
  31603. });
  31604. return RadioButtonWidgetAnnotationElement;
  31605. }();
  31606. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31607. function ChoiceWidgetAnnotationElement(parameters) {
  31608. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31609. }
  31610. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31611. render: function ChoiceWidgetAnnotationElement_render() {
  31612. this.container.className = 'choiceWidgetAnnotation';
  31613. var selectElement = document.createElement('select');
  31614. selectElement.disabled = this.data.readOnly;
  31615. if (!this.data.combo) {
  31616. selectElement.size = this.data.options.length;
  31617. if (this.data.multiSelect) {
  31618. selectElement.multiple = true;
  31619. }
  31620. }
  31621. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31622. var option = this.data.options[i];
  31623. var optionElement = document.createElement('option');
  31624. optionElement.textContent = option.displayValue;
  31625. optionElement.value = option.exportValue;
  31626. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31627. optionElement.setAttribute('selected', true);
  31628. }
  31629. selectElement.appendChild(optionElement);
  31630. }
  31631. this.container.appendChild(selectElement);
  31632. return this.container;
  31633. }
  31634. });
  31635. return ChoiceWidgetAnnotationElement;
  31636. }();
  31637. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31638. function PopupAnnotationElement(parameters) {
  31639. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31640. AnnotationElement.call(this, parameters, isRenderable);
  31641. }
  31642. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31643. render: function PopupAnnotationElement_render() {
  31644. this.container.className = 'popupAnnotation';
  31645. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31646. var parentElement = this.layer.querySelector(selector);
  31647. if (!parentElement) {
  31648. return this.container;
  31649. }
  31650. var popup = new PopupElement({
  31651. container: this.container,
  31652. trigger: parentElement,
  31653. color: this.data.color,
  31654. title: this.data.title,
  31655. contents: this.data.contents
  31656. });
  31657. var parentLeft = parseFloat(parentElement.style.left);
  31658. var parentWidth = parseFloat(parentElement.style.width);
  31659. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31660. this.container.style.left = parentLeft + parentWidth + 'px';
  31661. this.container.appendChild(popup.render());
  31662. return this.container;
  31663. }
  31664. });
  31665. return PopupAnnotationElement;
  31666. }();
  31667. var PopupElement = function PopupElementClosure() {
  31668. var BACKGROUND_ENLIGHT = 0.7;
  31669. function PopupElement(parameters) {
  31670. this.container = parameters.container;
  31671. this.trigger = parameters.trigger;
  31672. this.color = parameters.color;
  31673. this.title = parameters.title;
  31674. this.contents = parameters.contents;
  31675. this.hideWrapper = parameters.hideWrapper || false;
  31676. this.pinned = false;
  31677. }
  31678. PopupElement.prototype = {
  31679. render: function PopupElement_render() {
  31680. var wrapper = document.createElement('div');
  31681. wrapper.className = 'popupWrapper';
  31682. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31683. this.hideElement.setAttribute('hidden', true);
  31684. var popup = document.createElement('div');
  31685. popup.className = 'popup';
  31686. var color = this.color;
  31687. if (color) {
  31688. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31689. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31690. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31691. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31692. }
  31693. var contents = this._formatContents(this.contents);
  31694. var title = document.createElement('h1');
  31695. title.textContent = this.title;
  31696. this.trigger.addEventListener('click', this._toggle.bind(this));
  31697. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31698. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31699. popup.addEventListener('click', this._hide.bind(this, true));
  31700. popup.appendChild(title);
  31701. popup.appendChild(contents);
  31702. wrapper.appendChild(popup);
  31703. return wrapper;
  31704. },
  31705. _formatContents: function PopupElement_formatContents(contents) {
  31706. var p = document.createElement('p');
  31707. var lines = contents.split(/(?:\r\n?|\n)/);
  31708. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31709. var line = lines[i];
  31710. p.appendChild(document.createTextNode(line));
  31711. if (i < ii - 1) {
  31712. p.appendChild(document.createElement('br'));
  31713. }
  31714. }
  31715. return p;
  31716. },
  31717. _toggle: function PopupElement_toggle() {
  31718. if (this.pinned) {
  31719. this._hide(true);
  31720. } else {
  31721. this._show(true);
  31722. }
  31723. },
  31724. _show: function PopupElement_show(pin) {
  31725. if (pin) {
  31726. this.pinned = true;
  31727. }
  31728. if (this.hideElement.hasAttribute('hidden')) {
  31729. this.hideElement.removeAttribute('hidden');
  31730. this.container.style.zIndex += 1;
  31731. }
  31732. },
  31733. _hide: function PopupElement_hide(unpin) {
  31734. if (unpin) {
  31735. this.pinned = false;
  31736. }
  31737. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31738. this.hideElement.setAttribute('hidden', true);
  31739. this.container.style.zIndex -= 1;
  31740. }
  31741. }
  31742. };
  31743. return PopupElement;
  31744. }();
  31745. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31746. function HighlightAnnotationElement(parameters) {
  31747. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31748. AnnotationElement.call(this, parameters, isRenderable);
  31749. }
  31750. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31751. render: function HighlightAnnotationElement_render() {
  31752. this.container.className = 'highlightAnnotation';
  31753. if (!this.data.hasPopup) {
  31754. this._createPopup(this.container, null, this.data);
  31755. }
  31756. return this.container;
  31757. }
  31758. });
  31759. return HighlightAnnotationElement;
  31760. }();
  31761. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31762. function UnderlineAnnotationElement(parameters) {
  31763. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31764. AnnotationElement.call(this, parameters, isRenderable);
  31765. }
  31766. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31767. render: function UnderlineAnnotationElement_render() {
  31768. this.container.className = 'underlineAnnotation';
  31769. if (!this.data.hasPopup) {
  31770. this._createPopup(this.container, null, this.data);
  31771. }
  31772. return this.container;
  31773. }
  31774. });
  31775. return UnderlineAnnotationElement;
  31776. }();
  31777. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31778. function SquigglyAnnotationElement(parameters) {
  31779. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31780. AnnotationElement.call(this, parameters, isRenderable);
  31781. }
  31782. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31783. render: function SquigglyAnnotationElement_render() {
  31784. this.container.className = 'squigglyAnnotation';
  31785. if (!this.data.hasPopup) {
  31786. this._createPopup(this.container, null, this.data);
  31787. }
  31788. return this.container;
  31789. }
  31790. });
  31791. return SquigglyAnnotationElement;
  31792. }();
  31793. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31794. function StrikeOutAnnotationElement(parameters) {
  31795. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31796. AnnotationElement.call(this, parameters, isRenderable);
  31797. }
  31798. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31799. render: function StrikeOutAnnotationElement_render() {
  31800. this.container.className = 'strikeoutAnnotation';
  31801. if (!this.data.hasPopup) {
  31802. this._createPopup(this.container, null, this.data);
  31803. }
  31804. return this.container;
  31805. }
  31806. });
  31807. return StrikeOutAnnotationElement;
  31808. }();
  31809. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31810. function FileAttachmentAnnotationElement(parameters) {
  31811. AnnotationElement.call(this, parameters, true);
  31812. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31813. this.content = parameters.data.file.content;
  31814. }
  31815. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31816. render: function FileAttachmentAnnotationElement_render() {
  31817. this.container.className = 'fileAttachmentAnnotation';
  31818. var trigger = document.createElement('div');
  31819. trigger.style.height = this.container.style.height;
  31820. trigger.style.width = this.container.style.width;
  31821. trigger.addEventListener('dblclick', this._download.bind(this));
  31822. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31823. this._createPopup(this.container, trigger, this.data);
  31824. }
  31825. this.container.appendChild(trigger);
  31826. return this.container;
  31827. },
  31828. _download: function FileAttachmentAnnotationElement_download() {
  31829. if (!this.downloadManager) {
  31830. warn('Download cannot be started due to unavailable download manager');
  31831. return;
  31832. }
  31833. this.downloadManager.downloadData(this.content, this.filename, '');
  31834. }
  31835. });
  31836. return FileAttachmentAnnotationElement;
  31837. }();
  31838. var AnnotationLayer = function AnnotationLayerClosure() {
  31839. return {
  31840. render: function AnnotationLayer_render(parameters) {
  31841. var annotationElementFactory = new AnnotationElementFactory();
  31842. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31843. var data = parameters.annotations[i];
  31844. if (!data) {
  31845. continue;
  31846. }
  31847. var properties = {
  31848. data: data,
  31849. layer: parameters.div,
  31850. page: parameters.page,
  31851. viewport: parameters.viewport,
  31852. linkService: parameters.linkService,
  31853. downloadManager: parameters.downloadManager,
  31854. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31855. renderInteractiveForms: parameters.renderInteractiveForms || false
  31856. };
  31857. var element = annotationElementFactory.create(properties);
  31858. if (element.isRenderable) {
  31859. parameters.div.appendChild(element.render());
  31860. }
  31861. }
  31862. },
  31863. update: function AnnotationLayer_update(parameters) {
  31864. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31865. var data = parameters.annotations[i];
  31866. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31867. if (element) {
  31868. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31869. }
  31870. }
  31871. parameters.div.removeAttribute('hidden');
  31872. }
  31873. };
  31874. }();
  31875. exports.AnnotationLayer = AnnotationLayer;
  31876. }));
  31877. (function (root, factory) {
  31878. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31879. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31880. var Util = sharedUtil.Util;
  31881. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31882. var CustomStyle = displayDOMUtils.CustomStyle;
  31883. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31884. var renderTextLayer = function renderTextLayerClosure() {
  31885. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31886. var NonWhitespaceRegexp = /\S/;
  31887. function isAllWhitespace(str) {
  31888. return !NonWhitespaceRegexp.test(str);
  31889. }
  31890. var styleBuf = [
  31891. 'left: ',
  31892. 0,
  31893. 'px; top: ',
  31894. 0,
  31895. 'px; font-size: ',
  31896. 0,
  31897. 'px; font-family: ',
  31898. '',
  31899. ';'
  31900. ];
  31901. function appendText(task, geom, styles) {
  31902. var textDiv = document.createElement('div');
  31903. var textDivProperties = {
  31904. style: null,
  31905. angle: 0,
  31906. canvasWidth: 0,
  31907. isWhitespace: false,
  31908. originalTransform: null,
  31909. paddingBottom: 0,
  31910. paddingLeft: 0,
  31911. paddingRight: 0,
  31912. paddingTop: 0,
  31913. scale: 1
  31914. };
  31915. task._textDivs.push(textDiv);
  31916. if (isAllWhitespace(geom.str)) {
  31917. textDivProperties.isWhitespace = true;
  31918. task._textDivProperties.set(textDiv, textDivProperties);
  31919. return;
  31920. }
  31921. var tx = Util.transform(task._viewport.transform, geom.transform);
  31922. var angle = Math.atan2(tx[1], tx[0]);
  31923. var style = styles[geom.fontName];
  31924. if (style.vertical) {
  31925. angle += Math.PI / 2;
  31926. }
  31927. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31928. var fontAscent = fontHeight;
  31929. if (style.ascent) {
  31930. fontAscent = style.ascent * fontAscent;
  31931. } else if (style.descent) {
  31932. fontAscent = (1 + style.descent) * fontAscent;
  31933. }
  31934. var left;
  31935. var top;
  31936. if (angle === 0) {
  31937. left = tx[4];
  31938. top = tx[5] - fontAscent;
  31939. } else {
  31940. left = tx[4] + fontAscent * Math.sin(angle);
  31941. top = tx[5] - fontAscent * Math.cos(angle);
  31942. }
  31943. styleBuf[1] = left;
  31944. styleBuf[3] = top;
  31945. styleBuf[5] = fontHeight;
  31946. styleBuf[7] = style.fontFamily;
  31947. textDivProperties.style = styleBuf.join('');
  31948. textDiv.setAttribute('style', textDivProperties.style);
  31949. textDiv.textContent = geom.str;
  31950. if (getDefaultSetting('pdfBug')) {
  31951. textDiv.dataset.fontName = geom.fontName;
  31952. }
  31953. if (angle !== 0) {
  31954. textDivProperties.angle = angle * (180 / Math.PI);
  31955. }
  31956. if (geom.str.length > 1) {
  31957. if (style.vertical) {
  31958. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31959. } else {
  31960. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31961. }
  31962. }
  31963. task._textDivProperties.set(textDiv, textDivProperties);
  31964. if (task._enhanceTextSelection) {
  31965. var angleCos = 1, angleSin = 0;
  31966. if (angle !== 0) {
  31967. angleCos = Math.cos(angle);
  31968. angleSin = Math.sin(angle);
  31969. }
  31970. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31971. var divHeight = fontHeight;
  31972. var m, b;
  31973. if (angle !== 0) {
  31974. m = [
  31975. angleCos,
  31976. angleSin,
  31977. -angleSin,
  31978. angleCos,
  31979. left,
  31980. top
  31981. ];
  31982. b = Util.getAxialAlignedBoundingBox([
  31983. 0,
  31984. 0,
  31985. divWidth,
  31986. divHeight
  31987. ], m);
  31988. } else {
  31989. b = [
  31990. left,
  31991. top,
  31992. left + divWidth,
  31993. top + divHeight
  31994. ];
  31995. }
  31996. task._bounds.push({
  31997. left: b[0],
  31998. top: b[1],
  31999. right: b[2],
  32000. bottom: b[3],
  32001. div: textDiv,
  32002. size: [
  32003. divWidth,
  32004. divHeight
  32005. ],
  32006. m: m
  32007. });
  32008. }
  32009. }
  32010. function render(task) {
  32011. if (task._canceled) {
  32012. return;
  32013. }
  32014. var textLayerFrag = task._container;
  32015. var textDivs = task._textDivs;
  32016. var capability = task._capability;
  32017. var textDivsLength = textDivs.length;
  32018. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  32019. task._renderingDone = true;
  32020. capability.resolve();
  32021. return;
  32022. }
  32023. var canvas = document.createElement('canvas');
  32024. var ctx = canvas.getContext('2d', { alpha: false });
  32025. var lastFontSize;
  32026. var lastFontFamily;
  32027. for (var i = 0; i < textDivsLength; i++) {
  32028. var textDiv = textDivs[i];
  32029. var textDivProperties = task._textDivProperties.get(textDiv);
  32030. if (textDivProperties.isWhitespace) {
  32031. continue;
  32032. }
  32033. var fontSize = textDiv.style.fontSize;
  32034. var fontFamily = textDiv.style.fontFamily;
  32035. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  32036. ctx.font = fontSize + ' ' + fontFamily;
  32037. lastFontSize = fontSize;
  32038. lastFontFamily = fontFamily;
  32039. }
  32040. var width = ctx.measureText(textDiv.textContent).width;
  32041. textLayerFrag.appendChild(textDiv);
  32042. var transform = '';
  32043. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  32044. textDivProperties.scale = textDivProperties.canvasWidth / width;
  32045. transform = 'scaleX(' + textDivProperties.scale + ')';
  32046. }
  32047. if (textDivProperties.angle !== 0) {
  32048. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  32049. }
  32050. if (transform !== '') {
  32051. textDivProperties.originalTransform = transform;
  32052. CustomStyle.setProp('transform', textDiv, transform);
  32053. }
  32054. task._textDivProperties.set(textDiv, textDivProperties);
  32055. }
  32056. task._renderingDone = true;
  32057. capability.resolve();
  32058. }
  32059. function expand(task) {
  32060. var bounds = task._bounds;
  32061. var viewport = task._viewport;
  32062. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  32063. for (var i = 0; i < expanded.length; i++) {
  32064. var div = bounds[i].div;
  32065. var divProperties = task._textDivProperties.get(div);
  32066. if (divProperties.angle === 0) {
  32067. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  32068. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  32069. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  32070. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  32071. task._textDivProperties.set(div, divProperties);
  32072. continue;
  32073. }
  32074. var e = expanded[i], b = bounds[i];
  32075. var m = b.m, c = m[0], s = m[1];
  32076. var points = [
  32077. [
  32078. 0,
  32079. 0
  32080. ],
  32081. [
  32082. 0,
  32083. b.size[1]
  32084. ],
  32085. [
  32086. b.size[0],
  32087. 0
  32088. ],
  32089. b.size
  32090. ];
  32091. var ts = new Float64Array(64);
  32092. points.forEach(function (p, i) {
  32093. var t = Util.applyTransform(p, m);
  32094. ts[i + 0] = c && (e.left - t[0]) / c;
  32095. ts[i + 4] = s && (e.top - t[1]) / s;
  32096. ts[i + 8] = c && (e.right - t[0]) / c;
  32097. ts[i + 12] = s && (e.bottom - t[1]) / s;
  32098. ts[i + 16] = s && (e.left - t[0]) / -s;
  32099. ts[i + 20] = c && (e.top - t[1]) / c;
  32100. ts[i + 24] = s && (e.right - t[0]) / -s;
  32101. ts[i + 28] = c && (e.bottom - t[1]) / c;
  32102. ts[i + 32] = c && (e.left - t[0]) / -c;
  32103. ts[i + 36] = s && (e.top - t[1]) / -s;
  32104. ts[i + 40] = c && (e.right - t[0]) / -c;
  32105. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  32106. ts[i + 48] = s && (e.left - t[0]) / s;
  32107. ts[i + 52] = c && (e.top - t[1]) / -c;
  32108. ts[i + 56] = s && (e.right - t[0]) / s;
  32109. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  32110. });
  32111. var findPositiveMin = function (ts, offset, count) {
  32112. var result = 0;
  32113. for (var i = 0; i < count; i++) {
  32114. var t = ts[offset++];
  32115. if (t > 0) {
  32116. result = result ? Math.min(t, result) : t;
  32117. }
  32118. }
  32119. return result;
  32120. };
  32121. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  32122. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  32123. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  32124. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  32125. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  32126. task._textDivProperties.set(div, divProperties);
  32127. }
  32128. }
  32129. function expandBounds(width, height, boxes) {
  32130. var bounds = boxes.map(function (box, i) {
  32131. return {
  32132. x1: box.left,
  32133. y1: box.top,
  32134. x2: box.right,
  32135. y2: box.bottom,
  32136. index: i,
  32137. x1New: undefined,
  32138. x2New: undefined
  32139. };
  32140. });
  32141. expandBoundsLTR(width, bounds);
  32142. var expanded = new Array(boxes.length);
  32143. bounds.forEach(function (b) {
  32144. var i = b.index;
  32145. expanded[i] = {
  32146. left: b.x1New,
  32147. top: 0,
  32148. right: b.x2New,
  32149. bottom: 0
  32150. };
  32151. });
  32152. boxes.map(function (box, i) {
  32153. var e = expanded[i], b = bounds[i];
  32154. b.x1 = box.top;
  32155. b.y1 = width - e.right;
  32156. b.x2 = box.bottom;
  32157. b.y2 = width - e.left;
  32158. b.index = i;
  32159. b.x1New = undefined;
  32160. b.x2New = undefined;
  32161. });
  32162. expandBoundsLTR(height, bounds);
  32163. bounds.forEach(function (b) {
  32164. var i = b.index;
  32165. expanded[i].top = b.x1New;
  32166. expanded[i].bottom = b.x2New;
  32167. });
  32168. return expanded;
  32169. }
  32170. function expandBoundsLTR(width, bounds) {
  32171. bounds.sort(function (a, b) {
  32172. return a.x1 - b.x1 || a.index - b.index;
  32173. });
  32174. var fakeBoundary = {
  32175. x1: -Infinity,
  32176. y1: -Infinity,
  32177. x2: 0,
  32178. y2: Infinity,
  32179. index: -1,
  32180. x1New: 0,
  32181. x2New: 0
  32182. };
  32183. var horizon = [{
  32184. start: -Infinity,
  32185. end: Infinity,
  32186. boundary: fakeBoundary
  32187. }];
  32188. bounds.forEach(function (boundary) {
  32189. var i = 0;
  32190. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32191. i++;
  32192. }
  32193. var j = horizon.length - 1;
  32194. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32195. j--;
  32196. }
  32197. var horizonPart, affectedBoundary;
  32198. var q, k, maxXNew = -Infinity;
  32199. for (q = i; q <= j; q++) {
  32200. horizonPart = horizon[q];
  32201. affectedBoundary = horizonPart.boundary;
  32202. var xNew;
  32203. if (affectedBoundary.x2 > boundary.x1) {
  32204. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32205. } else if (affectedBoundary.x2New === undefined) {
  32206. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32207. } else {
  32208. xNew = affectedBoundary.x2New;
  32209. }
  32210. if (xNew > maxXNew) {
  32211. maxXNew = xNew;
  32212. }
  32213. }
  32214. boundary.x1New = maxXNew;
  32215. for (q = i; q <= j; q++) {
  32216. horizonPart = horizon[q];
  32217. affectedBoundary = horizonPart.boundary;
  32218. if (affectedBoundary.x2New === undefined) {
  32219. if (affectedBoundary.x2 > boundary.x1) {
  32220. if (affectedBoundary.index > boundary.index) {
  32221. affectedBoundary.x2New = affectedBoundary.x2;
  32222. }
  32223. } else {
  32224. affectedBoundary.x2New = maxXNew;
  32225. }
  32226. } else if (affectedBoundary.x2New > maxXNew) {
  32227. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32228. }
  32229. }
  32230. var changedHorizon = [], lastBoundary = null;
  32231. for (q = i; q <= j; q++) {
  32232. horizonPart = horizon[q];
  32233. affectedBoundary = horizonPart.boundary;
  32234. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32235. if (lastBoundary === useBoundary) {
  32236. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32237. } else {
  32238. changedHorizon.push({
  32239. start: horizonPart.start,
  32240. end: horizonPart.end,
  32241. boundary: useBoundary
  32242. });
  32243. lastBoundary = useBoundary;
  32244. }
  32245. }
  32246. if (horizon[i].start < boundary.y1) {
  32247. changedHorizon[0].start = boundary.y1;
  32248. changedHorizon.unshift({
  32249. start: horizon[i].start,
  32250. end: boundary.y1,
  32251. boundary: horizon[i].boundary
  32252. });
  32253. }
  32254. if (boundary.y2 < horizon[j].end) {
  32255. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32256. changedHorizon.push({
  32257. start: boundary.y2,
  32258. end: horizon[j].end,
  32259. boundary: horizon[j].boundary
  32260. });
  32261. }
  32262. for (q = i; q <= j; q++) {
  32263. horizonPart = horizon[q];
  32264. affectedBoundary = horizonPart.boundary;
  32265. if (affectedBoundary.x2New !== undefined) {
  32266. continue;
  32267. }
  32268. var used = false;
  32269. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32270. used = horizon[k].boundary === affectedBoundary;
  32271. }
  32272. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32273. used = horizon[k].boundary === affectedBoundary;
  32274. }
  32275. for (k = 0; !used && k < changedHorizon.length; k++) {
  32276. used = changedHorizon[k].boundary === affectedBoundary;
  32277. }
  32278. if (!used) {
  32279. affectedBoundary.x2New = maxXNew;
  32280. }
  32281. }
  32282. Array.prototype.splice.apply(horizon, [
  32283. i,
  32284. j - i + 1
  32285. ].concat(changedHorizon));
  32286. });
  32287. horizon.forEach(function (horizonPart) {
  32288. var affectedBoundary = horizonPart.boundary;
  32289. if (affectedBoundary.x2New === undefined) {
  32290. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32291. }
  32292. });
  32293. }
  32294. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32295. this._textContent = textContent;
  32296. this._container = container;
  32297. this._viewport = viewport;
  32298. this._textDivs = textDivs || [];
  32299. this._textDivProperties = new WeakMap();
  32300. this._renderingDone = false;
  32301. this._canceled = false;
  32302. this._capability = createPromiseCapability();
  32303. this._renderTimer = null;
  32304. this._bounds = [];
  32305. this._enhanceTextSelection = !!enhanceTextSelection;
  32306. }
  32307. TextLayerRenderTask.prototype = {
  32308. get promise() {
  32309. return this._capability.promise;
  32310. },
  32311. cancel: function TextLayer_cancel() {
  32312. this._canceled = true;
  32313. if (this._renderTimer !== null) {
  32314. clearTimeout(this._renderTimer);
  32315. this._renderTimer = null;
  32316. }
  32317. this._capability.reject('canceled');
  32318. },
  32319. _render: function TextLayer_render(timeout) {
  32320. var textItems = this._textContent.items;
  32321. var textStyles = this._textContent.styles;
  32322. for (var i = 0, len = textItems.length; i < len; i++) {
  32323. appendText(this, textItems[i], textStyles);
  32324. }
  32325. if (!timeout) {
  32326. render(this);
  32327. } else {
  32328. var self = this;
  32329. this._renderTimer = setTimeout(function () {
  32330. render(self);
  32331. self._renderTimer = null;
  32332. }, timeout);
  32333. }
  32334. },
  32335. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32336. if (!this._enhanceTextSelection || !this._renderingDone) {
  32337. return;
  32338. }
  32339. if (this._bounds !== null) {
  32340. expand(this);
  32341. this._bounds = null;
  32342. }
  32343. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32344. var div = this._textDivs[i];
  32345. var divProperties = this._textDivProperties.get(div);
  32346. if (divProperties.isWhitespace) {
  32347. continue;
  32348. }
  32349. if (expandDivs) {
  32350. var transform = '', padding = '';
  32351. if (divProperties.scale !== 1) {
  32352. transform = 'scaleX(' + divProperties.scale + ')';
  32353. }
  32354. if (divProperties.angle !== 0) {
  32355. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32356. }
  32357. if (divProperties.paddingLeft !== 0) {
  32358. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32359. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32360. }
  32361. if (divProperties.paddingTop !== 0) {
  32362. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32363. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32364. }
  32365. if (divProperties.paddingRight !== 0) {
  32366. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32367. }
  32368. if (divProperties.paddingBottom !== 0) {
  32369. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32370. }
  32371. if (padding !== '') {
  32372. div.setAttribute('style', divProperties.style + padding);
  32373. }
  32374. if (transform !== '') {
  32375. CustomStyle.setProp('transform', div, transform);
  32376. }
  32377. } else {
  32378. div.style.padding = 0;
  32379. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32380. }
  32381. }
  32382. }
  32383. };
  32384. function renderTextLayer(renderParameters) {
  32385. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32386. task._render(renderParameters.timeout);
  32387. return task;
  32388. }
  32389. return renderTextLayer;
  32390. }();
  32391. exports.renderTextLayer = renderTextLayer;
  32392. }));
  32393. (function (root, factory) {
  32394. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32395. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32396. var shadow = sharedUtil.shadow;
  32397. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32398. var WebGLUtils = function WebGLUtilsClosure() {
  32399. function loadShader(gl, code, shaderType) {
  32400. var shader = gl.createShader(shaderType);
  32401. gl.shaderSource(shader, code);
  32402. gl.compileShader(shader);
  32403. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32404. if (!compiled) {
  32405. var errorMsg = gl.getShaderInfoLog(shader);
  32406. throw new Error('Error during shader compilation: ' + errorMsg);
  32407. }
  32408. return shader;
  32409. }
  32410. function createVertexShader(gl, code) {
  32411. return loadShader(gl, code, gl.VERTEX_SHADER);
  32412. }
  32413. function createFragmentShader(gl, code) {
  32414. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32415. }
  32416. function createProgram(gl, shaders) {
  32417. var program = gl.createProgram();
  32418. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32419. gl.attachShader(program, shaders[i]);
  32420. }
  32421. gl.linkProgram(program);
  32422. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32423. if (!linked) {
  32424. var errorMsg = gl.getProgramInfoLog(program);
  32425. throw new Error('Error during program linking: ' + errorMsg);
  32426. }
  32427. return program;
  32428. }
  32429. function createTexture(gl, image, textureId) {
  32430. gl.activeTexture(textureId);
  32431. var texture = gl.createTexture();
  32432. gl.bindTexture(gl.TEXTURE_2D, texture);
  32433. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32434. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32435. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32436. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32437. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32438. return texture;
  32439. }
  32440. var currentGL, currentCanvas;
  32441. function generateGL() {
  32442. if (currentGL) {
  32443. return;
  32444. }
  32445. currentCanvas = document.createElement('canvas');
  32446. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32447. }
  32448. var smaskVertexShaderCode = '\
  32449. attribute vec2 a_position; \
  32450. attribute vec2 a_texCoord; \
  32451. \
  32452. uniform vec2 u_resolution; \
  32453. \
  32454. varying vec2 v_texCoord; \
  32455. \
  32456. void main() { \
  32457. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32458. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32459. \
  32460. v_texCoord = a_texCoord; \
  32461. } ';
  32462. var smaskFragmentShaderCode = '\
  32463. precision mediump float; \
  32464. \
  32465. uniform vec4 u_backdrop; \
  32466. uniform int u_subtype; \
  32467. uniform sampler2D u_image; \
  32468. uniform sampler2D u_mask; \
  32469. \
  32470. varying vec2 v_texCoord; \
  32471. \
  32472. void main() { \
  32473. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32474. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32475. if (u_backdrop.a > 0.0) { \
  32476. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32477. u_backdrop.rgb * (1.0 - maskColor.a); \
  32478. } \
  32479. float lum; \
  32480. if (u_subtype == 0) { \
  32481. lum = maskColor.a; \
  32482. } else { \
  32483. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32484. maskColor.b * 0.11; \
  32485. } \
  32486. imageColor.a *= lum; \
  32487. imageColor.rgb *= imageColor.a; \
  32488. gl_FragColor = imageColor; \
  32489. } ';
  32490. var smaskCache = null;
  32491. function initSmaskGL() {
  32492. var canvas, gl;
  32493. generateGL();
  32494. canvas = currentCanvas;
  32495. currentCanvas = null;
  32496. gl = currentGL;
  32497. currentGL = null;
  32498. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32499. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32500. var program = createProgram(gl, [
  32501. vertexShader,
  32502. fragmentShader
  32503. ]);
  32504. gl.useProgram(program);
  32505. var cache = {};
  32506. cache.gl = gl;
  32507. cache.canvas = canvas;
  32508. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32509. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32510. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32511. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32512. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32513. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32514. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32515. var texCoordBuffer = gl.createBuffer();
  32516. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32517. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32518. 0.0,
  32519. 0.0,
  32520. 1.0,
  32521. 0.0,
  32522. 0.0,
  32523. 1.0,
  32524. 0.0,
  32525. 1.0,
  32526. 1.0,
  32527. 0.0,
  32528. 1.0,
  32529. 1.0
  32530. ]), gl.STATIC_DRAW);
  32531. gl.enableVertexAttribArray(texCoordLocation);
  32532. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32533. gl.uniform1i(texLayerLocation, 0);
  32534. gl.uniform1i(texMaskLocation, 1);
  32535. smaskCache = cache;
  32536. }
  32537. function composeSMask(layer, mask, properties) {
  32538. var width = layer.width, height = layer.height;
  32539. if (!smaskCache) {
  32540. initSmaskGL();
  32541. }
  32542. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32543. canvas.width = width;
  32544. canvas.height = height;
  32545. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32546. gl.uniform2f(cache.resolutionLocation, width, height);
  32547. if (properties.backdrop) {
  32548. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32549. } else {
  32550. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32551. }
  32552. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32553. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32554. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32555. var buffer = gl.createBuffer();
  32556. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32557. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32558. 0,
  32559. 0,
  32560. width,
  32561. 0,
  32562. 0,
  32563. height,
  32564. 0,
  32565. height,
  32566. width,
  32567. 0,
  32568. width,
  32569. height
  32570. ]), gl.STATIC_DRAW);
  32571. gl.enableVertexAttribArray(cache.positionLocation);
  32572. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32573. gl.clearColor(0, 0, 0, 0);
  32574. gl.enable(gl.BLEND);
  32575. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32576. gl.clear(gl.COLOR_BUFFER_BIT);
  32577. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32578. gl.flush();
  32579. gl.deleteTexture(texture);
  32580. gl.deleteTexture(maskTexture);
  32581. gl.deleteBuffer(buffer);
  32582. return canvas;
  32583. }
  32584. var figuresVertexShaderCode = '\
  32585. attribute vec2 a_position; \
  32586. attribute vec3 a_color; \
  32587. \
  32588. uniform vec2 u_resolution; \
  32589. uniform vec2 u_scale; \
  32590. uniform vec2 u_offset; \
  32591. \
  32592. varying vec4 v_color; \
  32593. \
  32594. void main() { \
  32595. vec2 position = (a_position + u_offset) * u_scale; \
  32596. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32597. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32598. \
  32599. v_color = vec4(a_color / 255.0, 1.0); \
  32600. } ';
  32601. var figuresFragmentShaderCode = '\
  32602. precision mediump float; \
  32603. \
  32604. varying vec4 v_color; \
  32605. \
  32606. void main() { \
  32607. gl_FragColor = v_color; \
  32608. } ';
  32609. var figuresCache = null;
  32610. function initFiguresGL() {
  32611. var canvas, gl;
  32612. generateGL();
  32613. canvas = currentCanvas;
  32614. currentCanvas = null;
  32615. gl = currentGL;
  32616. currentGL = null;
  32617. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32618. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32619. var program = createProgram(gl, [
  32620. vertexShader,
  32621. fragmentShader
  32622. ]);
  32623. gl.useProgram(program);
  32624. var cache = {};
  32625. cache.gl = gl;
  32626. cache.canvas = canvas;
  32627. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32628. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32629. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32630. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32631. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32632. figuresCache = cache;
  32633. }
  32634. function drawFigures(width, height, backgroundColor, figures, context) {
  32635. if (!figuresCache) {
  32636. initFiguresGL();
  32637. }
  32638. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32639. canvas.width = width;
  32640. canvas.height = height;
  32641. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32642. gl.uniform2f(cache.resolutionLocation, width, height);
  32643. var count = 0;
  32644. var i, ii, rows;
  32645. for (i = 0, ii = figures.length; i < ii; i++) {
  32646. switch (figures[i].type) {
  32647. case 'lattice':
  32648. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32649. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32650. break;
  32651. case 'triangles':
  32652. count += figures[i].coords.length;
  32653. break;
  32654. }
  32655. }
  32656. var coords = new Float32Array(count * 2);
  32657. var colors = new Uint8Array(count * 3);
  32658. var coordsMap = context.coords, colorsMap = context.colors;
  32659. var pIndex = 0, cIndex = 0;
  32660. for (i = 0, ii = figures.length; i < ii; i++) {
  32661. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32662. switch (figure.type) {
  32663. case 'lattice':
  32664. var cols = figure.verticesPerRow;
  32665. rows = ps.length / cols | 0;
  32666. for (var row = 1; row < rows; row++) {
  32667. var offset = row * cols + 1;
  32668. for (var col = 1; col < cols; col++, offset++) {
  32669. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32670. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32671. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32672. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32673. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32674. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32675. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32676. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32677. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32678. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32679. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32680. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32681. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32682. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32683. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32684. coords[pIndex + 6] = coords[pIndex + 2];
  32685. coords[pIndex + 7] = coords[pIndex + 3];
  32686. coords[pIndex + 8] = coords[pIndex + 4];
  32687. coords[pIndex + 9] = coords[pIndex + 5];
  32688. coords[pIndex + 10] = coordsMap[ps[offset]];
  32689. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32690. colors[cIndex + 9] = colors[cIndex + 3];
  32691. colors[cIndex + 10] = colors[cIndex + 4];
  32692. colors[cIndex + 11] = colors[cIndex + 5];
  32693. colors[cIndex + 12] = colors[cIndex + 6];
  32694. colors[cIndex + 13] = colors[cIndex + 7];
  32695. colors[cIndex + 14] = colors[cIndex + 8];
  32696. colors[cIndex + 15] = colorsMap[cs[offset]];
  32697. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32698. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32699. pIndex += 12;
  32700. cIndex += 18;
  32701. }
  32702. }
  32703. break;
  32704. case 'triangles':
  32705. for (var j = 0, jj = ps.length; j < jj; j++) {
  32706. coords[pIndex] = coordsMap[ps[j]];
  32707. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32708. colors[cIndex] = colorsMap[cs[j]];
  32709. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32710. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32711. pIndex += 2;
  32712. cIndex += 3;
  32713. }
  32714. break;
  32715. }
  32716. }
  32717. if (backgroundColor) {
  32718. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32719. } else {
  32720. gl.clearColor(0, 0, 0, 0);
  32721. }
  32722. gl.clear(gl.COLOR_BUFFER_BIT);
  32723. var coordsBuffer = gl.createBuffer();
  32724. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32725. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32726. gl.enableVertexAttribArray(cache.positionLocation);
  32727. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32728. var colorsBuffer = gl.createBuffer();
  32729. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32730. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32731. gl.enableVertexAttribArray(cache.colorLocation);
  32732. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32733. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32734. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32735. gl.drawArrays(gl.TRIANGLES, 0, count);
  32736. gl.flush();
  32737. gl.deleteBuffer(coordsBuffer);
  32738. gl.deleteBuffer(colorsBuffer);
  32739. return canvas;
  32740. }
  32741. function cleanup() {
  32742. if (smaskCache && smaskCache.canvas) {
  32743. smaskCache.canvas.width = 0;
  32744. smaskCache.canvas.height = 0;
  32745. }
  32746. if (figuresCache && figuresCache.canvas) {
  32747. figuresCache.canvas.width = 0;
  32748. figuresCache.canvas.height = 0;
  32749. }
  32750. smaskCache = null;
  32751. figuresCache = null;
  32752. }
  32753. return {
  32754. get isEnabled() {
  32755. if (getDefaultSetting('disableWebGL')) {
  32756. return false;
  32757. }
  32758. var enabled = false;
  32759. try {
  32760. generateGL();
  32761. enabled = !!currentGL;
  32762. } catch (e) {
  32763. }
  32764. return shadow(this, 'isEnabled', enabled);
  32765. },
  32766. composeSMask: composeSMask,
  32767. drawFigures: drawFigures,
  32768. clear: cleanup
  32769. };
  32770. }();
  32771. exports.WebGLUtils = WebGLUtils;
  32772. }));
  32773. (function (root, factory) {
  32774. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32775. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32776. var PasswordException = sharedUtil.PasswordException;
  32777. var PasswordResponses = sharedUtil.PasswordResponses;
  32778. var bytesToString = sharedUtil.bytesToString;
  32779. var warn = sharedUtil.warn;
  32780. var error = sharedUtil.error;
  32781. var assert = sharedUtil.assert;
  32782. var isInt = sharedUtil.isInt;
  32783. var stringToBytes = sharedUtil.stringToBytes;
  32784. var utf8StringToString = sharedUtil.utf8StringToString;
  32785. var Name = corePrimitives.Name;
  32786. var isName = corePrimitives.isName;
  32787. var isDict = corePrimitives.isDict;
  32788. var DecryptStream = coreStream.DecryptStream;
  32789. var ARCFourCipher = function ARCFourCipherClosure() {
  32790. function ARCFourCipher(key) {
  32791. this.a = 0;
  32792. this.b = 0;
  32793. var s = new Uint8Array(256);
  32794. var i, j = 0, tmp, keyLength = key.length;
  32795. for (i = 0; i < 256; ++i) {
  32796. s[i] = i;
  32797. }
  32798. for (i = 0; i < 256; ++i) {
  32799. tmp = s[i];
  32800. j = j + tmp + key[i % keyLength] & 0xFF;
  32801. s[i] = s[j];
  32802. s[j] = tmp;
  32803. }
  32804. this.s = s;
  32805. }
  32806. ARCFourCipher.prototype = {
  32807. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32808. var i, n = data.length, tmp, tmp2;
  32809. var a = this.a, b = this.b, s = this.s;
  32810. var output = new Uint8Array(n);
  32811. for (i = 0; i < n; ++i) {
  32812. a = a + 1 & 0xFF;
  32813. tmp = s[a];
  32814. b = b + tmp & 0xFF;
  32815. tmp2 = s[b];
  32816. s[a] = tmp2;
  32817. s[b] = tmp;
  32818. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32819. }
  32820. this.a = a;
  32821. this.b = b;
  32822. return output;
  32823. }
  32824. };
  32825. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32826. return ARCFourCipher;
  32827. }();
  32828. var calculateMD5 = function calculateMD5Closure() {
  32829. var r = new Uint8Array([
  32830. 7,
  32831. 12,
  32832. 17,
  32833. 22,
  32834. 7,
  32835. 12,
  32836. 17,
  32837. 22,
  32838. 7,
  32839. 12,
  32840. 17,
  32841. 22,
  32842. 7,
  32843. 12,
  32844. 17,
  32845. 22,
  32846. 5,
  32847. 9,
  32848. 14,
  32849. 20,
  32850. 5,
  32851. 9,
  32852. 14,
  32853. 20,
  32854. 5,
  32855. 9,
  32856. 14,
  32857. 20,
  32858. 5,
  32859. 9,
  32860. 14,
  32861. 20,
  32862. 4,
  32863. 11,
  32864. 16,
  32865. 23,
  32866. 4,
  32867. 11,
  32868. 16,
  32869. 23,
  32870. 4,
  32871. 11,
  32872. 16,
  32873. 23,
  32874. 4,
  32875. 11,
  32876. 16,
  32877. 23,
  32878. 6,
  32879. 10,
  32880. 15,
  32881. 21,
  32882. 6,
  32883. 10,
  32884. 15,
  32885. 21,
  32886. 6,
  32887. 10,
  32888. 15,
  32889. 21,
  32890. 6,
  32891. 10,
  32892. 15,
  32893. 21
  32894. ]);
  32895. var k = new Int32Array([
  32896. -680876936,
  32897. -389564586,
  32898. 606105819,
  32899. -1044525330,
  32900. -176418897,
  32901. 1200080426,
  32902. -1473231341,
  32903. -45705983,
  32904. 1770035416,
  32905. -1958414417,
  32906. -42063,
  32907. -1990404162,
  32908. 1804603682,
  32909. -40341101,
  32910. -1502002290,
  32911. 1236535329,
  32912. -165796510,
  32913. -1069501632,
  32914. 643717713,
  32915. -373897302,
  32916. -701558691,
  32917. 38016083,
  32918. -660478335,
  32919. -405537848,
  32920. 568446438,
  32921. -1019803690,
  32922. -187363961,
  32923. 1163531501,
  32924. -1444681467,
  32925. -51403784,
  32926. 1735328473,
  32927. -1926607734,
  32928. -378558,
  32929. -2022574463,
  32930. 1839030562,
  32931. -35309556,
  32932. -1530992060,
  32933. 1272893353,
  32934. -155497632,
  32935. -1094730640,
  32936. 681279174,
  32937. -358537222,
  32938. -722521979,
  32939. 76029189,
  32940. -640364487,
  32941. -421815835,
  32942. 530742520,
  32943. -995338651,
  32944. -198630844,
  32945. 1126891415,
  32946. -1416354905,
  32947. -57434055,
  32948. 1700485571,
  32949. -1894986606,
  32950. -1051523,
  32951. -2054922799,
  32952. 1873313359,
  32953. -30611744,
  32954. -1560198380,
  32955. 1309151649,
  32956. -145523070,
  32957. -1120210379,
  32958. 718787259,
  32959. -343485551
  32960. ]);
  32961. function hash(data, offset, length) {
  32962. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32963. var paddedLength = length + 72 & ~63;
  32964. var padded = new Uint8Array(paddedLength);
  32965. var i, j, n;
  32966. for (i = 0; i < length; ++i) {
  32967. padded[i] = data[offset++];
  32968. }
  32969. padded[i++] = 0x80;
  32970. n = paddedLength - 8;
  32971. while (i < n) {
  32972. padded[i++] = 0;
  32973. }
  32974. padded[i++] = length << 3 & 0xFF;
  32975. padded[i++] = length >> 5 & 0xFF;
  32976. padded[i++] = length >> 13 & 0xFF;
  32977. padded[i++] = length >> 21 & 0xFF;
  32978. padded[i++] = length >>> 29 & 0xFF;
  32979. padded[i++] = 0;
  32980. padded[i++] = 0;
  32981. padded[i++] = 0;
  32982. var w = new Int32Array(16);
  32983. for (i = 0; i < paddedLength;) {
  32984. for (j = 0; j < 16; ++j, i += 4) {
  32985. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32986. }
  32987. var a = h0, b = h1, c = h2, d = h3, f, g;
  32988. for (j = 0; j < 64; ++j) {
  32989. if (j < 16) {
  32990. f = b & c | ~b & d;
  32991. g = j;
  32992. } else if (j < 32) {
  32993. f = d & b | ~d & c;
  32994. g = 5 * j + 1 & 15;
  32995. } else if (j < 48) {
  32996. f = b ^ c ^ d;
  32997. g = 3 * j + 5 & 15;
  32998. } else {
  32999. f = c ^ (b | ~d);
  33000. g = 7 * j & 15;
  33001. }
  33002. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  33003. d = c;
  33004. c = b;
  33005. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  33006. a = tmp;
  33007. }
  33008. h0 = h0 + a | 0;
  33009. h1 = h1 + b | 0;
  33010. h2 = h2 + c | 0;
  33011. h3 = h3 + d | 0;
  33012. }
  33013. return new Uint8Array([
  33014. h0 & 0xFF,
  33015. h0 >> 8 & 0xFF,
  33016. h0 >> 16 & 0xFF,
  33017. h0 >>> 24 & 0xFF,
  33018. h1 & 0xFF,
  33019. h1 >> 8 & 0xFF,
  33020. h1 >> 16 & 0xFF,
  33021. h1 >>> 24 & 0xFF,
  33022. h2 & 0xFF,
  33023. h2 >> 8 & 0xFF,
  33024. h2 >> 16 & 0xFF,
  33025. h2 >>> 24 & 0xFF,
  33026. h3 & 0xFF,
  33027. h3 >> 8 & 0xFF,
  33028. h3 >> 16 & 0xFF,
  33029. h3 >>> 24 & 0xFF
  33030. ]);
  33031. }
  33032. return hash;
  33033. }();
  33034. var Word64 = function Word64Closure() {
  33035. function Word64(highInteger, lowInteger) {
  33036. this.high = highInteger | 0;
  33037. this.low = lowInteger | 0;
  33038. }
  33039. Word64.prototype = {
  33040. and: function Word64_and(word) {
  33041. this.high &= word.high;
  33042. this.low &= word.low;
  33043. },
  33044. xor: function Word64_xor(word) {
  33045. this.high ^= word.high;
  33046. this.low ^= word.low;
  33047. },
  33048. or: function Word64_or(word) {
  33049. this.high |= word.high;
  33050. this.low |= word.low;
  33051. },
  33052. shiftRight: function Word64_shiftRight(places) {
  33053. if (places >= 32) {
  33054. this.low = this.high >>> places - 32 | 0;
  33055. this.high = 0;
  33056. } else {
  33057. this.low = this.low >>> places | this.high << 32 - places;
  33058. this.high = this.high >>> places | 0;
  33059. }
  33060. },
  33061. shiftLeft: function Word64_shiftLeft(places) {
  33062. if (places >= 32) {
  33063. this.high = this.low << places - 32;
  33064. this.low = 0;
  33065. } else {
  33066. this.high = this.high << places | this.low >>> 32 - places;
  33067. this.low = this.low << places;
  33068. }
  33069. },
  33070. rotateRight: function Word64_rotateRight(places) {
  33071. var low, high;
  33072. if (places & 32) {
  33073. high = this.low;
  33074. low = this.high;
  33075. } else {
  33076. low = this.low;
  33077. high = this.high;
  33078. }
  33079. places &= 31;
  33080. this.low = low >>> places | high << 32 - places;
  33081. this.high = high >>> places | low << 32 - places;
  33082. },
  33083. not: function Word64_not() {
  33084. this.high = ~this.high;
  33085. this.low = ~this.low;
  33086. },
  33087. add: function Word64_add(word) {
  33088. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  33089. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  33090. if (lowAdd > 0xFFFFFFFF) {
  33091. highAdd += 1;
  33092. }
  33093. this.low = lowAdd | 0;
  33094. this.high = highAdd | 0;
  33095. },
  33096. copyTo: function Word64_copyTo(bytes, offset) {
  33097. bytes[offset] = this.high >>> 24 & 0xFF;
  33098. bytes[offset + 1] = this.high >> 16 & 0xFF;
  33099. bytes[offset + 2] = this.high >> 8 & 0xFF;
  33100. bytes[offset + 3] = this.high & 0xFF;
  33101. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  33102. bytes[offset + 5] = this.low >> 16 & 0xFF;
  33103. bytes[offset + 6] = this.low >> 8 & 0xFF;
  33104. bytes[offset + 7] = this.low & 0xFF;
  33105. },
  33106. assign: function Word64_assign(word) {
  33107. this.high = word.high;
  33108. this.low = word.low;
  33109. }
  33110. };
  33111. return Word64;
  33112. }();
  33113. var calculateSHA256 = function calculateSHA256Closure() {
  33114. function rotr(x, n) {
  33115. return x >>> n | x << 32 - n;
  33116. }
  33117. function ch(x, y, z) {
  33118. return x & y ^ ~x & z;
  33119. }
  33120. function maj(x, y, z) {
  33121. return x & y ^ x & z ^ y & z;
  33122. }
  33123. function sigma(x) {
  33124. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  33125. }
  33126. function sigmaPrime(x) {
  33127. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  33128. }
  33129. function littleSigma(x) {
  33130. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  33131. }
  33132. function littleSigmaPrime(x) {
  33133. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  33134. }
  33135. var k = [
  33136. 0x428a2f98,
  33137. 0x71374491,
  33138. 0xb5c0fbcf,
  33139. 0xe9b5dba5,
  33140. 0x3956c25b,
  33141. 0x59f111f1,
  33142. 0x923f82a4,
  33143. 0xab1c5ed5,
  33144. 0xd807aa98,
  33145. 0x12835b01,
  33146. 0x243185be,
  33147. 0x550c7dc3,
  33148. 0x72be5d74,
  33149. 0x80deb1fe,
  33150. 0x9bdc06a7,
  33151. 0xc19bf174,
  33152. 0xe49b69c1,
  33153. 0xefbe4786,
  33154. 0x0fc19dc6,
  33155. 0x240ca1cc,
  33156. 0x2de92c6f,
  33157. 0x4a7484aa,
  33158. 0x5cb0a9dc,
  33159. 0x76f988da,
  33160. 0x983e5152,
  33161. 0xa831c66d,
  33162. 0xb00327c8,
  33163. 0xbf597fc7,
  33164. 0xc6e00bf3,
  33165. 0xd5a79147,
  33166. 0x06ca6351,
  33167. 0x14292967,
  33168. 0x27b70a85,
  33169. 0x2e1b2138,
  33170. 0x4d2c6dfc,
  33171. 0x53380d13,
  33172. 0x650a7354,
  33173. 0x766a0abb,
  33174. 0x81c2c92e,
  33175. 0x92722c85,
  33176. 0xa2bfe8a1,
  33177. 0xa81a664b,
  33178. 0xc24b8b70,
  33179. 0xc76c51a3,
  33180. 0xd192e819,
  33181. 0xd6990624,
  33182. 0xf40e3585,
  33183. 0x106aa070,
  33184. 0x19a4c116,
  33185. 0x1e376c08,
  33186. 0x2748774c,
  33187. 0x34b0bcb5,
  33188. 0x391c0cb3,
  33189. 0x4ed8aa4a,
  33190. 0x5b9cca4f,
  33191. 0x682e6ff3,
  33192. 0x748f82ee,
  33193. 0x78a5636f,
  33194. 0x84c87814,
  33195. 0x8cc70208,
  33196. 0x90befffa,
  33197. 0xa4506ceb,
  33198. 0xbef9a3f7,
  33199. 0xc67178f2
  33200. ];
  33201. function hash(data, offset, length) {
  33202. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33203. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33204. var padded = new Uint8Array(paddedLength);
  33205. var i, j, n;
  33206. for (i = 0; i < length; ++i) {
  33207. padded[i] = data[offset++];
  33208. }
  33209. padded[i++] = 0x80;
  33210. n = paddedLength - 8;
  33211. while (i < n) {
  33212. padded[i++] = 0;
  33213. }
  33214. padded[i++] = 0;
  33215. padded[i++] = 0;
  33216. padded[i++] = 0;
  33217. padded[i++] = length >>> 29 & 0xFF;
  33218. padded[i++] = length >> 21 & 0xFF;
  33219. padded[i++] = length >> 13 & 0xFF;
  33220. padded[i++] = length >> 5 & 0xFF;
  33221. padded[i++] = length << 3 & 0xFF;
  33222. var w = new Uint32Array(64);
  33223. for (i = 0; i < paddedLength;) {
  33224. for (j = 0; j < 16; ++j) {
  33225. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33226. i += 4;
  33227. }
  33228. for (j = 16; j < 64; ++j) {
  33229. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33230. }
  33231. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33232. for (j = 0; j < 64; ++j) {
  33233. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33234. t2 = sigma(a) + maj(a, b, c);
  33235. h = g;
  33236. g = f;
  33237. f = e;
  33238. e = d + t1 | 0;
  33239. d = c;
  33240. c = b;
  33241. b = a;
  33242. a = t1 + t2 | 0;
  33243. }
  33244. h0 = h0 + a | 0;
  33245. h1 = h1 + b | 0;
  33246. h2 = h2 + c | 0;
  33247. h3 = h3 + d | 0;
  33248. h4 = h4 + e | 0;
  33249. h5 = h5 + f | 0;
  33250. h6 = h6 + g | 0;
  33251. h7 = h7 + h | 0;
  33252. }
  33253. return new Uint8Array([
  33254. h0 >> 24 & 0xFF,
  33255. h0 >> 16 & 0xFF,
  33256. h0 >> 8 & 0xFF,
  33257. h0 & 0xFF,
  33258. h1 >> 24 & 0xFF,
  33259. h1 >> 16 & 0xFF,
  33260. h1 >> 8 & 0xFF,
  33261. h1 & 0xFF,
  33262. h2 >> 24 & 0xFF,
  33263. h2 >> 16 & 0xFF,
  33264. h2 >> 8 & 0xFF,
  33265. h2 & 0xFF,
  33266. h3 >> 24 & 0xFF,
  33267. h3 >> 16 & 0xFF,
  33268. h3 >> 8 & 0xFF,
  33269. h3 & 0xFF,
  33270. h4 >> 24 & 0xFF,
  33271. h4 >> 16 & 0xFF,
  33272. h4 >> 8 & 0xFF,
  33273. h4 & 0xFF,
  33274. h5 >> 24 & 0xFF,
  33275. h5 >> 16 & 0xFF,
  33276. h5 >> 8 & 0xFF,
  33277. h5 & 0xFF,
  33278. h6 >> 24 & 0xFF,
  33279. h6 >> 16 & 0xFF,
  33280. h6 >> 8 & 0xFF,
  33281. h6 & 0xFF,
  33282. h7 >> 24 & 0xFF,
  33283. h7 >> 16 & 0xFF,
  33284. h7 >> 8 & 0xFF,
  33285. h7 & 0xFF
  33286. ]);
  33287. }
  33288. return hash;
  33289. }();
  33290. var calculateSHA512 = function calculateSHA512Closure() {
  33291. function ch(result, x, y, z, tmp) {
  33292. result.assign(x);
  33293. result.and(y);
  33294. tmp.assign(x);
  33295. tmp.not();
  33296. tmp.and(z);
  33297. result.xor(tmp);
  33298. }
  33299. function maj(result, x, y, z, tmp) {
  33300. result.assign(x);
  33301. result.and(y);
  33302. tmp.assign(x);
  33303. tmp.and(z);
  33304. result.xor(tmp);
  33305. tmp.assign(y);
  33306. tmp.and(z);
  33307. result.xor(tmp);
  33308. }
  33309. function sigma(result, x, tmp) {
  33310. result.assign(x);
  33311. result.rotateRight(28);
  33312. tmp.assign(x);
  33313. tmp.rotateRight(34);
  33314. result.xor(tmp);
  33315. tmp.assign(x);
  33316. tmp.rotateRight(39);
  33317. result.xor(tmp);
  33318. }
  33319. function sigmaPrime(result, x, tmp) {
  33320. result.assign(x);
  33321. result.rotateRight(14);
  33322. tmp.assign(x);
  33323. tmp.rotateRight(18);
  33324. result.xor(tmp);
  33325. tmp.assign(x);
  33326. tmp.rotateRight(41);
  33327. result.xor(tmp);
  33328. }
  33329. function littleSigma(result, x, tmp) {
  33330. result.assign(x);
  33331. result.rotateRight(1);
  33332. tmp.assign(x);
  33333. tmp.rotateRight(8);
  33334. result.xor(tmp);
  33335. tmp.assign(x);
  33336. tmp.shiftRight(7);
  33337. result.xor(tmp);
  33338. }
  33339. function littleSigmaPrime(result, x, tmp) {
  33340. result.assign(x);
  33341. result.rotateRight(19);
  33342. tmp.assign(x);
  33343. tmp.rotateRight(61);
  33344. result.xor(tmp);
  33345. tmp.assign(x);
  33346. tmp.shiftRight(6);
  33347. result.xor(tmp);
  33348. }
  33349. var k = [
  33350. new Word64(0x428a2f98, 0xd728ae22),
  33351. new Word64(0x71374491, 0x23ef65cd),
  33352. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33353. new Word64(0xe9b5dba5, 0x8189dbbc),
  33354. new Word64(0x3956c25b, 0xf348b538),
  33355. new Word64(0x59f111f1, 0xb605d019),
  33356. new Word64(0x923f82a4, 0xaf194f9b),
  33357. new Word64(0xab1c5ed5, 0xda6d8118),
  33358. new Word64(0xd807aa98, 0xa3030242),
  33359. new Word64(0x12835b01, 0x45706fbe),
  33360. new Word64(0x243185be, 0x4ee4b28c),
  33361. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33362. new Word64(0x72be5d74, 0xf27b896f),
  33363. new Word64(0x80deb1fe, 0x3b1696b1),
  33364. new Word64(0x9bdc06a7, 0x25c71235),
  33365. new Word64(0xc19bf174, 0xcf692694),
  33366. new Word64(0xe49b69c1, 0x9ef14ad2),
  33367. new Word64(0xefbe4786, 0x384f25e3),
  33368. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33369. new Word64(0x240ca1cc, 0x77ac9c65),
  33370. new Word64(0x2de92c6f, 0x592b0275),
  33371. new Word64(0x4a7484aa, 0x6ea6e483),
  33372. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33373. new Word64(0x76f988da, 0x831153b5),
  33374. new Word64(0x983e5152, 0xee66dfab),
  33375. new Word64(0xa831c66d, 0x2db43210),
  33376. new Word64(0xb00327c8, 0x98fb213f),
  33377. new Word64(0xbf597fc7, 0xbeef0ee4),
  33378. new Word64(0xc6e00bf3, 0x3da88fc2),
  33379. new Word64(0xd5a79147, 0x930aa725),
  33380. new Word64(0x06ca6351, 0xe003826f),
  33381. new Word64(0x14292967, 0x0a0e6e70),
  33382. new Word64(0x27b70a85, 0x46d22ffc),
  33383. new Word64(0x2e1b2138, 0x5c26c926),
  33384. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33385. new Word64(0x53380d13, 0x9d95b3df),
  33386. new Word64(0x650a7354, 0x8baf63de),
  33387. new Word64(0x766a0abb, 0x3c77b2a8),
  33388. new Word64(0x81c2c92e, 0x47edaee6),
  33389. new Word64(0x92722c85, 0x1482353b),
  33390. new Word64(0xa2bfe8a1, 0x4cf10364),
  33391. new Word64(0xa81a664b, 0xbc423001),
  33392. new Word64(0xc24b8b70, 0xd0f89791),
  33393. new Word64(0xc76c51a3, 0x0654be30),
  33394. new Word64(0xd192e819, 0xd6ef5218),
  33395. new Word64(0xd6990624, 0x5565a910),
  33396. new Word64(0xf40e3585, 0x5771202a),
  33397. new Word64(0x106aa070, 0x32bbd1b8),
  33398. new Word64(0x19a4c116, 0xb8d2d0c8),
  33399. new Word64(0x1e376c08, 0x5141ab53),
  33400. new Word64(0x2748774c, 0xdf8eeb99),
  33401. new Word64(0x34b0bcb5, 0xe19b48a8),
  33402. new Word64(0x391c0cb3, 0xc5c95a63),
  33403. new Word64(0x4ed8aa4a, 0xe3418acb),
  33404. new Word64(0x5b9cca4f, 0x7763e373),
  33405. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33406. new Word64(0x748f82ee, 0x5defb2fc),
  33407. new Word64(0x78a5636f, 0x43172f60),
  33408. new Word64(0x84c87814, 0xa1f0ab72),
  33409. new Word64(0x8cc70208, 0x1a6439ec),
  33410. new Word64(0x90befffa, 0x23631e28),
  33411. new Word64(0xa4506ceb, 0xde82bde9),
  33412. new Word64(0xbef9a3f7, 0xb2c67915),
  33413. new Word64(0xc67178f2, 0xe372532b),
  33414. new Word64(0xca273ece, 0xea26619c),
  33415. new Word64(0xd186b8c7, 0x21c0c207),
  33416. new Word64(0xeada7dd6, 0xcde0eb1e),
  33417. new Word64(0xf57d4f7f, 0xee6ed178),
  33418. new Word64(0x06f067aa, 0x72176fba),
  33419. new Word64(0x0a637dc5, 0xa2c898a6),
  33420. new Word64(0x113f9804, 0xbef90dae),
  33421. new Word64(0x1b710b35, 0x131c471b),
  33422. new Word64(0x28db77f5, 0x23047d84),
  33423. new Word64(0x32caab7b, 0x40c72493),
  33424. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33425. new Word64(0x431d67c4, 0x9c100d4c),
  33426. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33427. new Word64(0x597f299c, 0xfc657e2a),
  33428. new Word64(0x5fcb6fab, 0x3ad6faec),
  33429. new Word64(0x6c44198c, 0x4a475817)
  33430. ];
  33431. function hash(data, offset, length, mode384) {
  33432. mode384 = !!mode384;
  33433. var h0, h1, h2, h3, h4, h5, h6, h7;
  33434. if (!mode384) {
  33435. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33436. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33437. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33438. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33439. h4 = new Word64(0x510e527f, 0xade682d1);
  33440. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33441. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33442. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33443. } else {
  33444. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33445. h1 = new Word64(0x629a292a, 0x367cd507);
  33446. h2 = new Word64(0x9159015a, 0x3070dd17);
  33447. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33448. h4 = new Word64(0x67332667, 0xffc00b31);
  33449. h5 = new Word64(0x8eb44a87, 0x68581511);
  33450. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33451. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33452. }
  33453. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33454. var padded = new Uint8Array(paddedLength);
  33455. var i, j, n;
  33456. for (i = 0; i < length; ++i) {
  33457. padded[i] = data[offset++];
  33458. }
  33459. padded[i++] = 0x80;
  33460. n = paddedLength - 16;
  33461. while (i < n) {
  33462. padded[i++] = 0;
  33463. }
  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++] = 0;
  33475. padded[i++] = length >>> 29 & 0xFF;
  33476. padded[i++] = length >> 21 & 0xFF;
  33477. padded[i++] = length >> 13 & 0xFF;
  33478. padded[i++] = length >> 5 & 0xFF;
  33479. padded[i++] = length << 3 & 0xFF;
  33480. var w = new Array(80);
  33481. for (i = 0; i < 80; i++) {
  33482. w[i] = new Word64(0, 0);
  33483. }
  33484. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33485. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33486. var g = new Word64(0, 0), h = new Word64(0, 0);
  33487. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33488. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33489. for (i = 0; i < paddedLength;) {
  33490. for (j = 0; j < 16; ++j) {
  33491. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33492. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33493. i += 8;
  33494. }
  33495. for (j = 16; j < 80; ++j) {
  33496. tmp3 = w[j];
  33497. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33498. tmp3.add(w[j - 7]);
  33499. littleSigma(tmp1, w[j - 15], tmp2);
  33500. tmp3.add(tmp1);
  33501. tmp3.add(w[j - 16]);
  33502. }
  33503. a.assign(h0);
  33504. b.assign(h1);
  33505. c.assign(h2);
  33506. d.assign(h3);
  33507. e.assign(h4);
  33508. f.assign(h5);
  33509. g.assign(h6);
  33510. h.assign(h7);
  33511. for (j = 0; j < 80; ++j) {
  33512. t1.assign(h);
  33513. sigmaPrime(tmp1, e, tmp2);
  33514. t1.add(tmp1);
  33515. ch(tmp1, e, f, g, tmp2);
  33516. t1.add(tmp1);
  33517. t1.add(k[j]);
  33518. t1.add(w[j]);
  33519. sigma(t2, a, tmp2);
  33520. maj(tmp1, a, b, c, tmp2);
  33521. t2.add(tmp1);
  33522. tmp3 = h;
  33523. h = g;
  33524. g = f;
  33525. f = e;
  33526. d.add(t1);
  33527. e = d;
  33528. d = c;
  33529. c = b;
  33530. b = a;
  33531. tmp3.assign(t1);
  33532. tmp3.add(t2);
  33533. a = tmp3;
  33534. }
  33535. h0.add(a);
  33536. h1.add(b);
  33537. h2.add(c);
  33538. h3.add(d);
  33539. h4.add(e);
  33540. h5.add(f);
  33541. h6.add(g);
  33542. h7.add(h);
  33543. }
  33544. var result;
  33545. if (!mode384) {
  33546. result = new Uint8Array(64);
  33547. h0.copyTo(result, 0);
  33548. h1.copyTo(result, 8);
  33549. h2.copyTo(result, 16);
  33550. h3.copyTo(result, 24);
  33551. h4.copyTo(result, 32);
  33552. h5.copyTo(result, 40);
  33553. h6.copyTo(result, 48);
  33554. h7.copyTo(result, 56);
  33555. } else {
  33556. result = new Uint8Array(48);
  33557. h0.copyTo(result, 0);
  33558. h1.copyTo(result, 8);
  33559. h2.copyTo(result, 16);
  33560. h3.copyTo(result, 24);
  33561. h4.copyTo(result, 32);
  33562. h5.copyTo(result, 40);
  33563. }
  33564. return result;
  33565. }
  33566. return hash;
  33567. }();
  33568. var calculateSHA384 = function calculateSHA384Closure() {
  33569. function hash(data, offset, length) {
  33570. return calculateSHA512(data, offset, length, true);
  33571. }
  33572. return hash;
  33573. }();
  33574. var NullCipher = function NullCipherClosure() {
  33575. function NullCipher() {
  33576. }
  33577. NullCipher.prototype = {
  33578. decryptBlock: function NullCipher_decryptBlock(data) {
  33579. return data;
  33580. }
  33581. };
  33582. return NullCipher;
  33583. }();
  33584. var AES128Cipher = function AES128CipherClosure() {
  33585. var rcon = new Uint8Array([
  33586. 0x8d,
  33587. 0x01,
  33588. 0x02,
  33589. 0x04,
  33590. 0x08,
  33591. 0x10,
  33592. 0x20,
  33593. 0x40,
  33594. 0x80,
  33595. 0x1b,
  33596. 0x36,
  33597. 0x6c,
  33598. 0xd8,
  33599. 0xab,
  33600. 0x4d,
  33601. 0x9a,
  33602. 0x2f,
  33603. 0x5e,
  33604. 0xbc,
  33605. 0x63,
  33606. 0xc6,
  33607. 0x97,
  33608. 0x35,
  33609. 0x6a,
  33610. 0xd4,
  33611. 0xb3,
  33612. 0x7d,
  33613. 0xfa,
  33614. 0xef,
  33615. 0xc5,
  33616. 0x91,
  33617. 0x39,
  33618. 0x72,
  33619. 0xe4,
  33620. 0xd3,
  33621. 0xbd,
  33622. 0x61,
  33623. 0xc2,
  33624. 0x9f,
  33625. 0x25,
  33626. 0x4a,
  33627. 0x94,
  33628. 0x33,
  33629. 0x66,
  33630. 0xcc,
  33631. 0x83,
  33632. 0x1d,
  33633. 0x3a,
  33634. 0x74,
  33635. 0xe8,
  33636. 0xcb,
  33637. 0x8d,
  33638. 0x01,
  33639. 0x02,
  33640. 0x04,
  33641. 0x08,
  33642. 0x10,
  33643. 0x20,
  33644. 0x40,
  33645. 0x80,
  33646. 0x1b,
  33647. 0x36,
  33648. 0x6c,
  33649. 0xd8,
  33650. 0xab,
  33651. 0x4d,
  33652. 0x9a,
  33653. 0x2f,
  33654. 0x5e,
  33655. 0xbc,
  33656. 0x63,
  33657. 0xc6,
  33658. 0x97,
  33659. 0x35,
  33660. 0x6a,
  33661. 0xd4,
  33662. 0xb3,
  33663. 0x7d,
  33664. 0xfa,
  33665. 0xef,
  33666. 0xc5,
  33667. 0x91,
  33668. 0x39,
  33669. 0x72,
  33670. 0xe4,
  33671. 0xd3,
  33672. 0xbd,
  33673. 0x61,
  33674. 0xc2,
  33675. 0x9f,
  33676. 0x25,
  33677. 0x4a,
  33678. 0x94,
  33679. 0x33,
  33680. 0x66,
  33681. 0xcc,
  33682. 0x83,
  33683. 0x1d,
  33684. 0x3a,
  33685. 0x74,
  33686. 0xe8,
  33687. 0xcb,
  33688. 0x8d,
  33689. 0x01,
  33690. 0x02,
  33691. 0x04,
  33692. 0x08,
  33693. 0x10,
  33694. 0x20,
  33695. 0x40,
  33696. 0x80,
  33697. 0x1b,
  33698. 0x36,
  33699. 0x6c,
  33700. 0xd8,
  33701. 0xab,
  33702. 0x4d,
  33703. 0x9a,
  33704. 0x2f,
  33705. 0x5e,
  33706. 0xbc,
  33707. 0x63,
  33708. 0xc6,
  33709. 0x97,
  33710. 0x35,
  33711. 0x6a,
  33712. 0xd4,
  33713. 0xb3,
  33714. 0x7d,
  33715. 0xfa,
  33716. 0xef,
  33717. 0xc5,
  33718. 0x91,
  33719. 0x39,
  33720. 0x72,
  33721. 0xe4,
  33722. 0xd3,
  33723. 0xbd,
  33724. 0x61,
  33725. 0xc2,
  33726. 0x9f,
  33727. 0x25,
  33728. 0x4a,
  33729. 0x94,
  33730. 0x33,
  33731. 0x66,
  33732. 0xcc,
  33733. 0x83,
  33734. 0x1d,
  33735. 0x3a,
  33736. 0x74,
  33737. 0xe8,
  33738. 0xcb,
  33739. 0x8d,
  33740. 0x01,
  33741. 0x02,
  33742. 0x04,
  33743. 0x08,
  33744. 0x10,
  33745. 0x20,
  33746. 0x40,
  33747. 0x80,
  33748. 0x1b,
  33749. 0x36,
  33750. 0x6c,
  33751. 0xd8,
  33752. 0xab,
  33753. 0x4d,
  33754. 0x9a,
  33755. 0x2f,
  33756. 0x5e,
  33757. 0xbc,
  33758. 0x63,
  33759. 0xc6,
  33760. 0x97,
  33761. 0x35,
  33762. 0x6a,
  33763. 0xd4,
  33764. 0xb3,
  33765. 0x7d,
  33766. 0xfa,
  33767. 0xef,
  33768. 0xc5,
  33769. 0x91,
  33770. 0x39,
  33771. 0x72,
  33772. 0xe4,
  33773. 0xd3,
  33774. 0xbd,
  33775. 0x61,
  33776. 0xc2,
  33777. 0x9f,
  33778. 0x25,
  33779. 0x4a,
  33780. 0x94,
  33781. 0x33,
  33782. 0x66,
  33783. 0xcc,
  33784. 0x83,
  33785. 0x1d,
  33786. 0x3a,
  33787. 0x74,
  33788. 0xe8,
  33789. 0xcb,
  33790. 0x8d,
  33791. 0x01,
  33792. 0x02,
  33793. 0x04,
  33794. 0x08,
  33795. 0x10,
  33796. 0x20,
  33797. 0x40,
  33798. 0x80,
  33799. 0x1b,
  33800. 0x36,
  33801. 0x6c,
  33802. 0xd8,
  33803. 0xab,
  33804. 0x4d,
  33805. 0x9a,
  33806. 0x2f,
  33807. 0x5e,
  33808. 0xbc,
  33809. 0x63,
  33810. 0xc6,
  33811. 0x97,
  33812. 0x35,
  33813. 0x6a,
  33814. 0xd4,
  33815. 0xb3,
  33816. 0x7d,
  33817. 0xfa,
  33818. 0xef,
  33819. 0xc5,
  33820. 0x91,
  33821. 0x39,
  33822. 0x72,
  33823. 0xe4,
  33824. 0xd3,
  33825. 0xbd,
  33826. 0x61,
  33827. 0xc2,
  33828. 0x9f,
  33829. 0x25,
  33830. 0x4a,
  33831. 0x94,
  33832. 0x33,
  33833. 0x66,
  33834. 0xcc,
  33835. 0x83,
  33836. 0x1d,
  33837. 0x3a,
  33838. 0x74,
  33839. 0xe8,
  33840. 0xcb,
  33841. 0x8d
  33842. ]);
  33843. var s = new Uint8Array([
  33844. 0x63,
  33845. 0x7c,
  33846. 0x77,
  33847. 0x7b,
  33848. 0xf2,
  33849. 0x6b,
  33850. 0x6f,
  33851. 0xc5,
  33852. 0x30,
  33853. 0x01,
  33854. 0x67,
  33855. 0x2b,
  33856. 0xfe,
  33857. 0xd7,
  33858. 0xab,
  33859. 0x76,
  33860. 0xca,
  33861. 0x82,
  33862. 0xc9,
  33863. 0x7d,
  33864. 0xfa,
  33865. 0x59,
  33866. 0x47,
  33867. 0xf0,
  33868. 0xad,
  33869. 0xd4,
  33870. 0xa2,
  33871. 0xaf,
  33872. 0x9c,
  33873. 0xa4,
  33874. 0x72,
  33875. 0xc0,
  33876. 0xb7,
  33877. 0xfd,
  33878. 0x93,
  33879. 0x26,
  33880. 0x36,
  33881. 0x3f,
  33882. 0xf7,
  33883. 0xcc,
  33884. 0x34,
  33885. 0xa5,
  33886. 0xe5,
  33887. 0xf1,
  33888. 0x71,
  33889. 0xd8,
  33890. 0x31,
  33891. 0x15,
  33892. 0x04,
  33893. 0xc7,
  33894. 0x23,
  33895. 0xc3,
  33896. 0x18,
  33897. 0x96,
  33898. 0x05,
  33899. 0x9a,
  33900. 0x07,
  33901. 0x12,
  33902. 0x80,
  33903. 0xe2,
  33904. 0xeb,
  33905. 0x27,
  33906. 0xb2,
  33907. 0x75,
  33908. 0x09,
  33909. 0x83,
  33910. 0x2c,
  33911. 0x1a,
  33912. 0x1b,
  33913. 0x6e,
  33914. 0x5a,
  33915. 0xa0,
  33916. 0x52,
  33917. 0x3b,
  33918. 0xd6,
  33919. 0xb3,
  33920. 0x29,
  33921. 0xe3,
  33922. 0x2f,
  33923. 0x84,
  33924. 0x53,
  33925. 0xd1,
  33926. 0x00,
  33927. 0xed,
  33928. 0x20,
  33929. 0xfc,
  33930. 0xb1,
  33931. 0x5b,
  33932. 0x6a,
  33933. 0xcb,
  33934. 0xbe,
  33935. 0x39,
  33936. 0x4a,
  33937. 0x4c,
  33938. 0x58,
  33939. 0xcf,
  33940. 0xd0,
  33941. 0xef,
  33942. 0xaa,
  33943. 0xfb,
  33944. 0x43,
  33945. 0x4d,
  33946. 0x33,
  33947. 0x85,
  33948. 0x45,
  33949. 0xf9,
  33950. 0x02,
  33951. 0x7f,
  33952. 0x50,
  33953. 0x3c,
  33954. 0x9f,
  33955. 0xa8,
  33956. 0x51,
  33957. 0xa3,
  33958. 0x40,
  33959. 0x8f,
  33960. 0x92,
  33961. 0x9d,
  33962. 0x38,
  33963. 0xf5,
  33964. 0xbc,
  33965. 0xb6,
  33966. 0xda,
  33967. 0x21,
  33968. 0x10,
  33969. 0xff,
  33970. 0xf3,
  33971. 0xd2,
  33972. 0xcd,
  33973. 0x0c,
  33974. 0x13,
  33975. 0xec,
  33976. 0x5f,
  33977. 0x97,
  33978. 0x44,
  33979. 0x17,
  33980. 0xc4,
  33981. 0xa7,
  33982. 0x7e,
  33983. 0x3d,
  33984. 0x64,
  33985. 0x5d,
  33986. 0x19,
  33987. 0x73,
  33988. 0x60,
  33989. 0x81,
  33990. 0x4f,
  33991. 0xdc,
  33992. 0x22,
  33993. 0x2a,
  33994. 0x90,
  33995. 0x88,
  33996. 0x46,
  33997. 0xee,
  33998. 0xb8,
  33999. 0x14,
  34000. 0xde,
  34001. 0x5e,
  34002. 0x0b,
  34003. 0xdb,
  34004. 0xe0,
  34005. 0x32,
  34006. 0x3a,
  34007. 0x0a,
  34008. 0x49,
  34009. 0x06,
  34010. 0x24,
  34011. 0x5c,
  34012. 0xc2,
  34013. 0xd3,
  34014. 0xac,
  34015. 0x62,
  34016. 0x91,
  34017. 0x95,
  34018. 0xe4,
  34019. 0x79,
  34020. 0xe7,
  34021. 0xc8,
  34022. 0x37,
  34023. 0x6d,
  34024. 0x8d,
  34025. 0xd5,
  34026. 0x4e,
  34027. 0xa9,
  34028. 0x6c,
  34029. 0x56,
  34030. 0xf4,
  34031. 0xea,
  34032. 0x65,
  34033. 0x7a,
  34034. 0xae,
  34035. 0x08,
  34036. 0xba,
  34037. 0x78,
  34038. 0x25,
  34039. 0x2e,
  34040. 0x1c,
  34041. 0xa6,
  34042. 0xb4,
  34043. 0xc6,
  34044. 0xe8,
  34045. 0xdd,
  34046. 0x74,
  34047. 0x1f,
  34048. 0x4b,
  34049. 0xbd,
  34050. 0x8b,
  34051. 0x8a,
  34052. 0x70,
  34053. 0x3e,
  34054. 0xb5,
  34055. 0x66,
  34056. 0x48,
  34057. 0x03,
  34058. 0xf6,
  34059. 0x0e,
  34060. 0x61,
  34061. 0x35,
  34062. 0x57,
  34063. 0xb9,
  34064. 0x86,
  34065. 0xc1,
  34066. 0x1d,
  34067. 0x9e,
  34068. 0xe1,
  34069. 0xf8,
  34070. 0x98,
  34071. 0x11,
  34072. 0x69,
  34073. 0xd9,
  34074. 0x8e,
  34075. 0x94,
  34076. 0x9b,
  34077. 0x1e,
  34078. 0x87,
  34079. 0xe9,
  34080. 0xce,
  34081. 0x55,
  34082. 0x28,
  34083. 0xdf,
  34084. 0x8c,
  34085. 0xa1,
  34086. 0x89,
  34087. 0x0d,
  34088. 0xbf,
  34089. 0xe6,
  34090. 0x42,
  34091. 0x68,
  34092. 0x41,
  34093. 0x99,
  34094. 0x2d,
  34095. 0x0f,
  34096. 0xb0,
  34097. 0x54,
  34098. 0xbb,
  34099. 0x16
  34100. ]);
  34101. var inv_s = new Uint8Array([
  34102. 0x52,
  34103. 0x09,
  34104. 0x6a,
  34105. 0xd5,
  34106. 0x30,
  34107. 0x36,
  34108. 0xa5,
  34109. 0x38,
  34110. 0xbf,
  34111. 0x40,
  34112. 0xa3,
  34113. 0x9e,
  34114. 0x81,
  34115. 0xf3,
  34116. 0xd7,
  34117. 0xfb,
  34118. 0x7c,
  34119. 0xe3,
  34120. 0x39,
  34121. 0x82,
  34122. 0x9b,
  34123. 0x2f,
  34124. 0xff,
  34125. 0x87,
  34126. 0x34,
  34127. 0x8e,
  34128. 0x43,
  34129. 0x44,
  34130. 0xc4,
  34131. 0xde,
  34132. 0xe9,
  34133. 0xcb,
  34134. 0x54,
  34135. 0x7b,
  34136. 0x94,
  34137. 0x32,
  34138. 0xa6,
  34139. 0xc2,
  34140. 0x23,
  34141. 0x3d,
  34142. 0xee,
  34143. 0x4c,
  34144. 0x95,
  34145. 0x0b,
  34146. 0x42,
  34147. 0xfa,
  34148. 0xc3,
  34149. 0x4e,
  34150. 0x08,
  34151. 0x2e,
  34152. 0xa1,
  34153. 0x66,
  34154. 0x28,
  34155. 0xd9,
  34156. 0x24,
  34157. 0xb2,
  34158. 0x76,
  34159. 0x5b,
  34160. 0xa2,
  34161. 0x49,
  34162. 0x6d,
  34163. 0x8b,
  34164. 0xd1,
  34165. 0x25,
  34166. 0x72,
  34167. 0xf8,
  34168. 0xf6,
  34169. 0x64,
  34170. 0x86,
  34171. 0x68,
  34172. 0x98,
  34173. 0x16,
  34174. 0xd4,
  34175. 0xa4,
  34176. 0x5c,
  34177. 0xcc,
  34178. 0x5d,
  34179. 0x65,
  34180. 0xb6,
  34181. 0x92,
  34182. 0x6c,
  34183. 0x70,
  34184. 0x48,
  34185. 0x50,
  34186. 0xfd,
  34187. 0xed,
  34188. 0xb9,
  34189. 0xda,
  34190. 0x5e,
  34191. 0x15,
  34192. 0x46,
  34193. 0x57,
  34194. 0xa7,
  34195. 0x8d,
  34196. 0x9d,
  34197. 0x84,
  34198. 0x90,
  34199. 0xd8,
  34200. 0xab,
  34201. 0x00,
  34202. 0x8c,
  34203. 0xbc,
  34204. 0xd3,
  34205. 0x0a,
  34206. 0xf7,
  34207. 0xe4,
  34208. 0x58,
  34209. 0x05,
  34210. 0xb8,
  34211. 0xb3,
  34212. 0x45,
  34213. 0x06,
  34214. 0xd0,
  34215. 0x2c,
  34216. 0x1e,
  34217. 0x8f,
  34218. 0xca,
  34219. 0x3f,
  34220. 0x0f,
  34221. 0x02,
  34222. 0xc1,
  34223. 0xaf,
  34224. 0xbd,
  34225. 0x03,
  34226. 0x01,
  34227. 0x13,
  34228. 0x8a,
  34229. 0x6b,
  34230. 0x3a,
  34231. 0x91,
  34232. 0x11,
  34233. 0x41,
  34234. 0x4f,
  34235. 0x67,
  34236. 0xdc,
  34237. 0xea,
  34238. 0x97,
  34239. 0xf2,
  34240. 0xcf,
  34241. 0xce,
  34242. 0xf0,
  34243. 0xb4,
  34244. 0xe6,
  34245. 0x73,
  34246. 0x96,
  34247. 0xac,
  34248. 0x74,
  34249. 0x22,
  34250. 0xe7,
  34251. 0xad,
  34252. 0x35,
  34253. 0x85,
  34254. 0xe2,
  34255. 0xf9,
  34256. 0x37,
  34257. 0xe8,
  34258. 0x1c,
  34259. 0x75,
  34260. 0xdf,
  34261. 0x6e,
  34262. 0x47,
  34263. 0xf1,
  34264. 0x1a,
  34265. 0x71,
  34266. 0x1d,
  34267. 0x29,
  34268. 0xc5,
  34269. 0x89,
  34270. 0x6f,
  34271. 0xb7,
  34272. 0x62,
  34273. 0x0e,
  34274. 0xaa,
  34275. 0x18,
  34276. 0xbe,
  34277. 0x1b,
  34278. 0xfc,
  34279. 0x56,
  34280. 0x3e,
  34281. 0x4b,
  34282. 0xc6,
  34283. 0xd2,
  34284. 0x79,
  34285. 0x20,
  34286. 0x9a,
  34287. 0xdb,
  34288. 0xc0,
  34289. 0xfe,
  34290. 0x78,
  34291. 0xcd,
  34292. 0x5a,
  34293. 0xf4,
  34294. 0x1f,
  34295. 0xdd,
  34296. 0xa8,
  34297. 0x33,
  34298. 0x88,
  34299. 0x07,
  34300. 0xc7,
  34301. 0x31,
  34302. 0xb1,
  34303. 0x12,
  34304. 0x10,
  34305. 0x59,
  34306. 0x27,
  34307. 0x80,
  34308. 0xec,
  34309. 0x5f,
  34310. 0x60,
  34311. 0x51,
  34312. 0x7f,
  34313. 0xa9,
  34314. 0x19,
  34315. 0xb5,
  34316. 0x4a,
  34317. 0x0d,
  34318. 0x2d,
  34319. 0xe5,
  34320. 0x7a,
  34321. 0x9f,
  34322. 0x93,
  34323. 0xc9,
  34324. 0x9c,
  34325. 0xef,
  34326. 0xa0,
  34327. 0xe0,
  34328. 0x3b,
  34329. 0x4d,
  34330. 0xae,
  34331. 0x2a,
  34332. 0xf5,
  34333. 0xb0,
  34334. 0xc8,
  34335. 0xeb,
  34336. 0xbb,
  34337. 0x3c,
  34338. 0x83,
  34339. 0x53,
  34340. 0x99,
  34341. 0x61,
  34342. 0x17,
  34343. 0x2b,
  34344. 0x04,
  34345. 0x7e,
  34346. 0xba,
  34347. 0x77,
  34348. 0xd6,
  34349. 0x26,
  34350. 0xe1,
  34351. 0x69,
  34352. 0x14,
  34353. 0x63,
  34354. 0x55,
  34355. 0x21,
  34356. 0x0c,
  34357. 0x7d
  34358. ]);
  34359. var mixCol = new Uint8Array(256);
  34360. for (var i = 0; i < 256; i++) {
  34361. if (i < 128) {
  34362. mixCol[i] = i << 1;
  34363. } else {
  34364. mixCol[i] = i << 1 ^ 0x1b;
  34365. }
  34366. }
  34367. var mix = new Uint32Array([
  34368. 0x00000000,
  34369. 0x0e090d0b,
  34370. 0x1c121a16,
  34371. 0x121b171d,
  34372. 0x3824342c,
  34373. 0x362d3927,
  34374. 0x24362e3a,
  34375. 0x2a3f2331,
  34376. 0x70486858,
  34377. 0x7e416553,
  34378. 0x6c5a724e,
  34379. 0x62537f45,
  34380. 0x486c5c74,
  34381. 0x4665517f,
  34382. 0x547e4662,
  34383. 0x5a774b69,
  34384. 0xe090d0b0,
  34385. 0xee99ddbb,
  34386. 0xfc82caa6,
  34387. 0xf28bc7ad,
  34388. 0xd8b4e49c,
  34389. 0xd6bde997,
  34390. 0xc4a6fe8a,
  34391. 0xcaaff381,
  34392. 0x90d8b8e8,
  34393. 0x9ed1b5e3,
  34394. 0x8ccaa2fe,
  34395. 0x82c3aff5,
  34396. 0xa8fc8cc4,
  34397. 0xa6f581cf,
  34398. 0xb4ee96d2,
  34399. 0xbae79bd9,
  34400. 0xdb3bbb7b,
  34401. 0xd532b670,
  34402. 0xc729a16d,
  34403. 0xc920ac66,
  34404. 0xe31f8f57,
  34405. 0xed16825c,
  34406. 0xff0d9541,
  34407. 0xf104984a,
  34408. 0xab73d323,
  34409. 0xa57ade28,
  34410. 0xb761c935,
  34411. 0xb968c43e,
  34412. 0x9357e70f,
  34413. 0x9d5eea04,
  34414. 0x8f45fd19,
  34415. 0x814cf012,
  34416. 0x3bab6bcb,
  34417. 0x35a266c0,
  34418. 0x27b971dd,
  34419. 0x29b07cd6,
  34420. 0x038f5fe7,
  34421. 0x0d8652ec,
  34422. 0x1f9d45f1,
  34423. 0x119448fa,
  34424. 0x4be30393,
  34425. 0x45ea0e98,
  34426. 0x57f11985,
  34427. 0x59f8148e,
  34428. 0x73c737bf,
  34429. 0x7dce3ab4,
  34430. 0x6fd52da9,
  34431. 0x61dc20a2,
  34432. 0xad766df6,
  34433. 0xa37f60fd,
  34434. 0xb16477e0,
  34435. 0xbf6d7aeb,
  34436. 0x955259da,
  34437. 0x9b5b54d1,
  34438. 0x894043cc,
  34439. 0x87494ec7,
  34440. 0xdd3e05ae,
  34441. 0xd33708a5,
  34442. 0xc12c1fb8,
  34443. 0xcf2512b3,
  34444. 0xe51a3182,
  34445. 0xeb133c89,
  34446. 0xf9082b94,
  34447. 0xf701269f,
  34448. 0x4de6bd46,
  34449. 0x43efb04d,
  34450. 0x51f4a750,
  34451. 0x5ffdaa5b,
  34452. 0x75c2896a,
  34453. 0x7bcb8461,
  34454. 0x69d0937c,
  34455. 0x67d99e77,
  34456. 0x3daed51e,
  34457. 0x33a7d815,
  34458. 0x21bccf08,
  34459. 0x2fb5c203,
  34460. 0x058ae132,
  34461. 0x0b83ec39,
  34462. 0x1998fb24,
  34463. 0x1791f62f,
  34464. 0x764dd68d,
  34465. 0x7844db86,
  34466. 0x6a5fcc9b,
  34467. 0x6456c190,
  34468. 0x4e69e2a1,
  34469. 0x4060efaa,
  34470. 0x527bf8b7,
  34471. 0x5c72f5bc,
  34472. 0x0605bed5,
  34473. 0x080cb3de,
  34474. 0x1a17a4c3,
  34475. 0x141ea9c8,
  34476. 0x3e218af9,
  34477. 0x302887f2,
  34478. 0x223390ef,
  34479. 0x2c3a9de4,
  34480. 0x96dd063d,
  34481. 0x98d40b36,
  34482. 0x8acf1c2b,
  34483. 0x84c61120,
  34484. 0xaef93211,
  34485. 0xa0f03f1a,
  34486. 0xb2eb2807,
  34487. 0xbce2250c,
  34488. 0xe6956e65,
  34489. 0xe89c636e,
  34490. 0xfa877473,
  34491. 0xf48e7978,
  34492. 0xdeb15a49,
  34493. 0xd0b85742,
  34494. 0xc2a3405f,
  34495. 0xccaa4d54,
  34496. 0x41ecdaf7,
  34497. 0x4fe5d7fc,
  34498. 0x5dfec0e1,
  34499. 0x53f7cdea,
  34500. 0x79c8eedb,
  34501. 0x77c1e3d0,
  34502. 0x65daf4cd,
  34503. 0x6bd3f9c6,
  34504. 0x31a4b2af,
  34505. 0x3fadbfa4,
  34506. 0x2db6a8b9,
  34507. 0x23bfa5b2,
  34508. 0x09808683,
  34509. 0x07898b88,
  34510. 0x15929c95,
  34511. 0x1b9b919e,
  34512. 0xa17c0a47,
  34513. 0xaf75074c,
  34514. 0xbd6e1051,
  34515. 0xb3671d5a,
  34516. 0x99583e6b,
  34517. 0x97513360,
  34518. 0x854a247d,
  34519. 0x8b432976,
  34520. 0xd134621f,
  34521. 0xdf3d6f14,
  34522. 0xcd267809,
  34523. 0xc32f7502,
  34524. 0xe9105633,
  34525. 0xe7195b38,
  34526. 0xf5024c25,
  34527. 0xfb0b412e,
  34528. 0x9ad7618c,
  34529. 0x94de6c87,
  34530. 0x86c57b9a,
  34531. 0x88cc7691,
  34532. 0xa2f355a0,
  34533. 0xacfa58ab,
  34534. 0xbee14fb6,
  34535. 0xb0e842bd,
  34536. 0xea9f09d4,
  34537. 0xe49604df,
  34538. 0xf68d13c2,
  34539. 0xf8841ec9,
  34540. 0xd2bb3df8,
  34541. 0xdcb230f3,
  34542. 0xcea927ee,
  34543. 0xc0a02ae5,
  34544. 0x7a47b13c,
  34545. 0x744ebc37,
  34546. 0x6655ab2a,
  34547. 0x685ca621,
  34548. 0x42638510,
  34549. 0x4c6a881b,
  34550. 0x5e719f06,
  34551. 0x5078920d,
  34552. 0x0a0fd964,
  34553. 0x0406d46f,
  34554. 0x161dc372,
  34555. 0x1814ce79,
  34556. 0x322bed48,
  34557. 0x3c22e043,
  34558. 0x2e39f75e,
  34559. 0x2030fa55,
  34560. 0xec9ab701,
  34561. 0xe293ba0a,
  34562. 0xf088ad17,
  34563. 0xfe81a01c,
  34564. 0xd4be832d,
  34565. 0xdab78e26,
  34566. 0xc8ac993b,
  34567. 0xc6a59430,
  34568. 0x9cd2df59,
  34569. 0x92dbd252,
  34570. 0x80c0c54f,
  34571. 0x8ec9c844,
  34572. 0xa4f6eb75,
  34573. 0xaaffe67e,
  34574. 0xb8e4f163,
  34575. 0xb6edfc68,
  34576. 0x0c0a67b1,
  34577. 0x02036aba,
  34578. 0x10187da7,
  34579. 0x1e1170ac,
  34580. 0x342e539d,
  34581. 0x3a275e96,
  34582. 0x283c498b,
  34583. 0x26354480,
  34584. 0x7c420fe9,
  34585. 0x724b02e2,
  34586. 0x605015ff,
  34587. 0x6e5918f4,
  34588. 0x44663bc5,
  34589. 0x4a6f36ce,
  34590. 0x587421d3,
  34591. 0x567d2cd8,
  34592. 0x37a10c7a,
  34593. 0x39a80171,
  34594. 0x2bb3166c,
  34595. 0x25ba1b67,
  34596. 0x0f853856,
  34597. 0x018c355d,
  34598. 0x13972240,
  34599. 0x1d9e2f4b,
  34600. 0x47e96422,
  34601. 0x49e06929,
  34602. 0x5bfb7e34,
  34603. 0x55f2733f,
  34604. 0x7fcd500e,
  34605. 0x71c45d05,
  34606. 0x63df4a18,
  34607. 0x6dd64713,
  34608. 0xd731dcca,
  34609. 0xd938d1c1,
  34610. 0xcb23c6dc,
  34611. 0xc52acbd7,
  34612. 0xef15e8e6,
  34613. 0xe11ce5ed,
  34614. 0xf307f2f0,
  34615. 0xfd0efffb,
  34616. 0xa779b492,
  34617. 0xa970b999,
  34618. 0xbb6bae84,
  34619. 0xb562a38f,
  34620. 0x9f5d80be,
  34621. 0x91548db5,
  34622. 0x834f9aa8,
  34623. 0x8d4697a3
  34624. ]);
  34625. function expandKey128(cipherKey) {
  34626. var b = 176, result = new Uint8Array(b);
  34627. result.set(cipherKey);
  34628. for (var j = 16, i = 1; j < b; ++i) {
  34629. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34630. t1 = s[t1];
  34631. t2 = s[t2];
  34632. t3 = s[t3];
  34633. t4 = s[t4];
  34634. t1 = t1 ^ rcon[i];
  34635. for (var n = 0; n < 4; ++n) {
  34636. result[j] = t1 ^= result[j - 16];
  34637. j++;
  34638. result[j] = t2 ^= result[j - 16];
  34639. j++;
  34640. result[j] = t3 ^= result[j - 16];
  34641. j++;
  34642. result[j] = t4 ^= result[j - 16];
  34643. j++;
  34644. }
  34645. }
  34646. return result;
  34647. }
  34648. function decrypt128(input, key) {
  34649. var state = new Uint8Array(16);
  34650. state.set(input);
  34651. var i, j, k;
  34652. var t, u, v;
  34653. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34654. state[j] ^= key[k];
  34655. }
  34656. for (i = 9; i >= 1; --i) {
  34657. t = state[13];
  34658. state[13] = state[9];
  34659. state[9] = state[5];
  34660. state[5] = state[1];
  34661. state[1] = t;
  34662. t = state[14];
  34663. u = state[10];
  34664. state[14] = state[6];
  34665. state[10] = state[2];
  34666. state[6] = t;
  34667. state[2] = u;
  34668. t = state[15];
  34669. u = state[11];
  34670. v = state[7];
  34671. state[15] = state[3];
  34672. state[11] = t;
  34673. state[7] = u;
  34674. state[3] = v;
  34675. for (j = 0; j < 16; ++j) {
  34676. state[j] = inv_s[state[j]];
  34677. }
  34678. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34679. state[j] ^= key[k];
  34680. }
  34681. for (j = 0; j < 16; j += 4) {
  34682. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34683. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34684. state[j] = t >>> 24 & 0xFF;
  34685. state[j + 1] = t >> 16 & 0xFF;
  34686. state[j + 2] = t >> 8 & 0xFF;
  34687. state[j + 3] = t & 0xFF;
  34688. }
  34689. }
  34690. t = state[13];
  34691. state[13] = state[9];
  34692. state[9] = state[5];
  34693. state[5] = state[1];
  34694. state[1] = t;
  34695. t = state[14];
  34696. u = state[10];
  34697. state[14] = state[6];
  34698. state[10] = state[2];
  34699. state[6] = t;
  34700. state[2] = u;
  34701. t = state[15];
  34702. u = state[11];
  34703. v = state[7];
  34704. state[15] = state[3];
  34705. state[11] = t;
  34706. state[7] = u;
  34707. state[3] = v;
  34708. for (j = 0; j < 16; ++j) {
  34709. state[j] = inv_s[state[j]];
  34710. state[j] ^= key[j];
  34711. }
  34712. return state;
  34713. }
  34714. function encrypt128(input, key) {
  34715. var t, u, v, k;
  34716. var state = new Uint8Array(16);
  34717. state.set(input);
  34718. for (j = 0; j < 16; ++j) {
  34719. state[j] ^= key[j];
  34720. }
  34721. for (i = 1; i < 10; i++) {
  34722. for (j = 0; j < 16; ++j) {
  34723. state[j] = s[state[j]];
  34724. }
  34725. v = state[1];
  34726. state[1] = state[5];
  34727. state[5] = state[9];
  34728. state[9] = state[13];
  34729. state[13] = v;
  34730. v = state[2];
  34731. u = state[6];
  34732. state[2] = state[10];
  34733. state[6] = state[14];
  34734. state[10] = v;
  34735. state[14] = u;
  34736. v = state[3];
  34737. u = state[7];
  34738. t = state[11];
  34739. state[3] = state[15];
  34740. state[7] = v;
  34741. state[11] = u;
  34742. state[15] = t;
  34743. for (var j = 0; j < 16; j += 4) {
  34744. var s0 = state[j + 0], s1 = state[j + 1];
  34745. var s2 = state[j + 2], s3 = state[j + 3];
  34746. t = s0 ^ s1 ^ s2 ^ s3;
  34747. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34748. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34749. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34750. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34751. }
  34752. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34753. state[j] ^= key[k];
  34754. }
  34755. }
  34756. for (j = 0; j < 16; ++j) {
  34757. state[j] = s[state[j]];
  34758. }
  34759. v = state[1];
  34760. state[1] = state[5];
  34761. state[5] = state[9];
  34762. state[9] = state[13];
  34763. state[13] = v;
  34764. v = state[2];
  34765. u = state[6];
  34766. state[2] = state[10];
  34767. state[6] = state[14];
  34768. state[10] = v;
  34769. state[14] = u;
  34770. v = state[3];
  34771. u = state[7];
  34772. t = state[11];
  34773. state[3] = state[15];
  34774. state[7] = v;
  34775. state[11] = u;
  34776. state[15] = t;
  34777. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34778. state[j] ^= key[k];
  34779. }
  34780. return state;
  34781. }
  34782. function AES128Cipher(key) {
  34783. this.key = expandKey128(key);
  34784. this.buffer = new Uint8Array(16);
  34785. this.bufferPosition = 0;
  34786. }
  34787. function decryptBlock2(data, finalize) {
  34788. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34789. for (i = 0; i < sourceLength; ++i) {
  34790. buffer[bufferLength] = data[i];
  34791. ++bufferLength;
  34792. if (bufferLength < 16) {
  34793. continue;
  34794. }
  34795. var plain = decrypt128(buffer, this.key);
  34796. for (j = 0; j < 16; ++j) {
  34797. plain[j] ^= iv[j];
  34798. }
  34799. iv = buffer;
  34800. result.push(plain);
  34801. buffer = new Uint8Array(16);
  34802. bufferLength = 0;
  34803. }
  34804. this.buffer = buffer;
  34805. this.bufferLength = bufferLength;
  34806. this.iv = iv;
  34807. if (result.length === 0) {
  34808. return new Uint8Array([]);
  34809. }
  34810. var outputLength = 16 * result.length;
  34811. if (finalize) {
  34812. var lastBlock = result[result.length - 1];
  34813. var psLen = lastBlock[15];
  34814. if (psLen <= 16) {
  34815. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34816. if (lastBlock[i] !== psLen) {
  34817. psLen = 0;
  34818. break;
  34819. }
  34820. }
  34821. outputLength -= psLen;
  34822. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34823. }
  34824. }
  34825. var output = new Uint8Array(outputLength);
  34826. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34827. output.set(result[i], j);
  34828. }
  34829. return output;
  34830. }
  34831. AES128Cipher.prototype = {
  34832. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34833. var i, sourceLength = data.length;
  34834. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34835. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34836. buffer[bufferLength] = data[i];
  34837. }
  34838. if (bufferLength < 16) {
  34839. this.bufferLength = bufferLength;
  34840. return new Uint8Array([]);
  34841. }
  34842. this.iv = buffer;
  34843. this.buffer = new Uint8Array(16);
  34844. this.bufferLength = 0;
  34845. this.decryptBlock = decryptBlock2;
  34846. return this.decryptBlock(data.subarray(16), finalize);
  34847. },
  34848. encrypt: function AES128Cipher_encrypt(data, iv) {
  34849. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34850. if (!iv) {
  34851. iv = new Uint8Array(16);
  34852. }
  34853. for (i = 0; i < sourceLength; ++i) {
  34854. buffer[bufferLength] = data[i];
  34855. ++bufferLength;
  34856. if (bufferLength < 16) {
  34857. continue;
  34858. }
  34859. for (j = 0; j < 16; ++j) {
  34860. buffer[j] ^= iv[j];
  34861. }
  34862. var cipher = encrypt128(buffer, this.key);
  34863. iv = cipher;
  34864. result.push(cipher);
  34865. buffer = new Uint8Array(16);
  34866. bufferLength = 0;
  34867. }
  34868. this.buffer = buffer;
  34869. this.bufferLength = bufferLength;
  34870. this.iv = iv;
  34871. if (result.length === 0) {
  34872. return new Uint8Array([]);
  34873. }
  34874. var outputLength = 16 * result.length;
  34875. var output = new Uint8Array(outputLength);
  34876. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34877. output.set(result[i], j);
  34878. }
  34879. return output;
  34880. }
  34881. };
  34882. return AES128Cipher;
  34883. }();
  34884. var AES256Cipher = function AES256CipherClosure() {
  34885. var rcon = new Uint8Array([
  34886. 0x8d,
  34887. 0x01,
  34888. 0x02,
  34889. 0x04,
  34890. 0x08,
  34891. 0x10,
  34892. 0x20,
  34893. 0x40,
  34894. 0x80,
  34895. 0x1b,
  34896. 0x36,
  34897. 0x6c,
  34898. 0xd8,
  34899. 0xab,
  34900. 0x4d,
  34901. 0x9a,
  34902. 0x2f,
  34903. 0x5e,
  34904. 0xbc,
  34905. 0x63,
  34906. 0xc6,
  34907. 0x97,
  34908. 0x35,
  34909. 0x6a,
  34910. 0xd4,
  34911. 0xb3,
  34912. 0x7d,
  34913. 0xfa,
  34914. 0xef,
  34915. 0xc5,
  34916. 0x91,
  34917. 0x39,
  34918. 0x72,
  34919. 0xe4,
  34920. 0xd3,
  34921. 0xbd,
  34922. 0x61,
  34923. 0xc2,
  34924. 0x9f,
  34925. 0x25,
  34926. 0x4a,
  34927. 0x94,
  34928. 0x33,
  34929. 0x66,
  34930. 0xcc,
  34931. 0x83,
  34932. 0x1d,
  34933. 0x3a,
  34934. 0x74,
  34935. 0xe8,
  34936. 0xcb,
  34937. 0x8d,
  34938. 0x01,
  34939. 0x02,
  34940. 0x04,
  34941. 0x08,
  34942. 0x10,
  34943. 0x20,
  34944. 0x40,
  34945. 0x80,
  34946. 0x1b,
  34947. 0x36,
  34948. 0x6c,
  34949. 0xd8,
  34950. 0xab,
  34951. 0x4d,
  34952. 0x9a,
  34953. 0x2f,
  34954. 0x5e,
  34955. 0xbc,
  34956. 0x63,
  34957. 0xc6,
  34958. 0x97,
  34959. 0x35,
  34960. 0x6a,
  34961. 0xd4,
  34962. 0xb3,
  34963. 0x7d,
  34964. 0xfa,
  34965. 0xef,
  34966. 0xc5,
  34967. 0x91,
  34968. 0x39,
  34969. 0x72,
  34970. 0xe4,
  34971. 0xd3,
  34972. 0xbd,
  34973. 0x61,
  34974. 0xc2,
  34975. 0x9f,
  34976. 0x25,
  34977. 0x4a,
  34978. 0x94,
  34979. 0x33,
  34980. 0x66,
  34981. 0xcc,
  34982. 0x83,
  34983. 0x1d,
  34984. 0x3a,
  34985. 0x74,
  34986. 0xe8,
  34987. 0xcb,
  34988. 0x8d,
  34989. 0x01,
  34990. 0x02,
  34991. 0x04,
  34992. 0x08,
  34993. 0x10,
  34994. 0x20,
  34995. 0x40,
  34996. 0x80,
  34997. 0x1b,
  34998. 0x36,
  34999. 0x6c,
  35000. 0xd8,
  35001. 0xab,
  35002. 0x4d,
  35003. 0x9a,
  35004. 0x2f,
  35005. 0x5e,
  35006. 0xbc,
  35007. 0x63,
  35008. 0xc6,
  35009. 0x97,
  35010. 0x35,
  35011. 0x6a,
  35012. 0xd4,
  35013. 0xb3,
  35014. 0x7d,
  35015. 0xfa,
  35016. 0xef,
  35017. 0xc5,
  35018. 0x91,
  35019. 0x39,
  35020. 0x72,
  35021. 0xe4,
  35022. 0xd3,
  35023. 0xbd,
  35024. 0x61,
  35025. 0xc2,
  35026. 0x9f,
  35027. 0x25,
  35028. 0x4a,
  35029. 0x94,
  35030. 0x33,
  35031. 0x66,
  35032. 0xcc,
  35033. 0x83,
  35034. 0x1d,
  35035. 0x3a,
  35036. 0x74,
  35037. 0xe8,
  35038. 0xcb,
  35039. 0x8d,
  35040. 0x01,
  35041. 0x02,
  35042. 0x04,
  35043. 0x08,
  35044. 0x10,
  35045. 0x20,
  35046. 0x40,
  35047. 0x80,
  35048. 0x1b,
  35049. 0x36,
  35050. 0x6c,
  35051. 0xd8,
  35052. 0xab,
  35053. 0x4d,
  35054. 0x9a,
  35055. 0x2f,
  35056. 0x5e,
  35057. 0xbc,
  35058. 0x63,
  35059. 0xc6,
  35060. 0x97,
  35061. 0x35,
  35062. 0x6a,
  35063. 0xd4,
  35064. 0xb3,
  35065. 0x7d,
  35066. 0xfa,
  35067. 0xef,
  35068. 0xc5,
  35069. 0x91,
  35070. 0x39,
  35071. 0x72,
  35072. 0xe4,
  35073. 0xd3,
  35074. 0xbd,
  35075. 0x61,
  35076. 0xc2,
  35077. 0x9f,
  35078. 0x25,
  35079. 0x4a,
  35080. 0x94,
  35081. 0x33,
  35082. 0x66,
  35083. 0xcc,
  35084. 0x83,
  35085. 0x1d,
  35086. 0x3a,
  35087. 0x74,
  35088. 0xe8,
  35089. 0xcb,
  35090. 0x8d,
  35091. 0x01,
  35092. 0x02,
  35093. 0x04,
  35094. 0x08,
  35095. 0x10,
  35096. 0x20,
  35097. 0x40,
  35098. 0x80,
  35099. 0x1b,
  35100. 0x36,
  35101. 0x6c,
  35102. 0xd8,
  35103. 0xab,
  35104. 0x4d,
  35105. 0x9a,
  35106. 0x2f,
  35107. 0x5e,
  35108. 0xbc,
  35109. 0x63,
  35110. 0xc6,
  35111. 0x97,
  35112. 0x35,
  35113. 0x6a,
  35114. 0xd4,
  35115. 0xb3,
  35116. 0x7d,
  35117. 0xfa,
  35118. 0xef,
  35119. 0xc5,
  35120. 0x91,
  35121. 0x39,
  35122. 0x72,
  35123. 0xe4,
  35124. 0xd3,
  35125. 0xbd,
  35126. 0x61,
  35127. 0xc2,
  35128. 0x9f,
  35129. 0x25,
  35130. 0x4a,
  35131. 0x94,
  35132. 0x33,
  35133. 0x66,
  35134. 0xcc,
  35135. 0x83,
  35136. 0x1d,
  35137. 0x3a,
  35138. 0x74,
  35139. 0xe8,
  35140. 0xcb,
  35141. 0x8d
  35142. ]);
  35143. var s = new Uint8Array([
  35144. 0x63,
  35145. 0x7c,
  35146. 0x77,
  35147. 0x7b,
  35148. 0xf2,
  35149. 0x6b,
  35150. 0x6f,
  35151. 0xc5,
  35152. 0x30,
  35153. 0x01,
  35154. 0x67,
  35155. 0x2b,
  35156. 0xfe,
  35157. 0xd7,
  35158. 0xab,
  35159. 0x76,
  35160. 0xca,
  35161. 0x82,
  35162. 0xc9,
  35163. 0x7d,
  35164. 0xfa,
  35165. 0x59,
  35166. 0x47,
  35167. 0xf0,
  35168. 0xad,
  35169. 0xd4,
  35170. 0xa2,
  35171. 0xaf,
  35172. 0x9c,
  35173. 0xa4,
  35174. 0x72,
  35175. 0xc0,
  35176. 0xb7,
  35177. 0xfd,
  35178. 0x93,
  35179. 0x26,
  35180. 0x36,
  35181. 0x3f,
  35182. 0xf7,
  35183. 0xcc,
  35184. 0x34,
  35185. 0xa5,
  35186. 0xe5,
  35187. 0xf1,
  35188. 0x71,
  35189. 0xd8,
  35190. 0x31,
  35191. 0x15,
  35192. 0x04,
  35193. 0xc7,
  35194. 0x23,
  35195. 0xc3,
  35196. 0x18,
  35197. 0x96,
  35198. 0x05,
  35199. 0x9a,
  35200. 0x07,
  35201. 0x12,
  35202. 0x80,
  35203. 0xe2,
  35204. 0xeb,
  35205. 0x27,
  35206. 0xb2,
  35207. 0x75,
  35208. 0x09,
  35209. 0x83,
  35210. 0x2c,
  35211. 0x1a,
  35212. 0x1b,
  35213. 0x6e,
  35214. 0x5a,
  35215. 0xa0,
  35216. 0x52,
  35217. 0x3b,
  35218. 0xd6,
  35219. 0xb3,
  35220. 0x29,
  35221. 0xe3,
  35222. 0x2f,
  35223. 0x84,
  35224. 0x53,
  35225. 0xd1,
  35226. 0x00,
  35227. 0xed,
  35228. 0x20,
  35229. 0xfc,
  35230. 0xb1,
  35231. 0x5b,
  35232. 0x6a,
  35233. 0xcb,
  35234. 0xbe,
  35235. 0x39,
  35236. 0x4a,
  35237. 0x4c,
  35238. 0x58,
  35239. 0xcf,
  35240. 0xd0,
  35241. 0xef,
  35242. 0xaa,
  35243. 0xfb,
  35244. 0x43,
  35245. 0x4d,
  35246. 0x33,
  35247. 0x85,
  35248. 0x45,
  35249. 0xf9,
  35250. 0x02,
  35251. 0x7f,
  35252. 0x50,
  35253. 0x3c,
  35254. 0x9f,
  35255. 0xa8,
  35256. 0x51,
  35257. 0xa3,
  35258. 0x40,
  35259. 0x8f,
  35260. 0x92,
  35261. 0x9d,
  35262. 0x38,
  35263. 0xf5,
  35264. 0xbc,
  35265. 0xb6,
  35266. 0xda,
  35267. 0x21,
  35268. 0x10,
  35269. 0xff,
  35270. 0xf3,
  35271. 0xd2,
  35272. 0xcd,
  35273. 0x0c,
  35274. 0x13,
  35275. 0xec,
  35276. 0x5f,
  35277. 0x97,
  35278. 0x44,
  35279. 0x17,
  35280. 0xc4,
  35281. 0xa7,
  35282. 0x7e,
  35283. 0x3d,
  35284. 0x64,
  35285. 0x5d,
  35286. 0x19,
  35287. 0x73,
  35288. 0x60,
  35289. 0x81,
  35290. 0x4f,
  35291. 0xdc,
  35292. 0x22,
  35293. 0x2a,
  35294. 0x90,
  35295. 0x88,
  35296. 0x46,
  35297. 0xee,
  35298. 0xb8,
  35299. 0x14,
  35300. 0xde,
  35301. 0x5e,
  35302. 0x0b,
  35303. 0xdb,
  35304. 0xe0,
  35305. 0x32,
  35306. 0x3a,
  35307. 0x0a,
  35308. 0x49,
  35309. 0x06,
  35310. 0x24,
  35311. 0x5c,
  35312. 0xc2,
  35313. 0xd3,
  35314. 0xac,
  35315. 0x62,
  35316. 0x91,
  35317. 0x95,
  35318. 0xe4,
  35319. 0x79,
  35320. 0xe7,
  35321. 0xc8,
  35322. 0x37,
  35323. 0x6d,
  35324. 0x8d,
  35325. 0xd5,
  35326. 0x4e,
  35327. 0xa9,
  35328. 0x6c,
  35329. 0x56,
  35330. 0xf4,
  35331. 0xea,
  35332. 0x65,
  35333. 0x7a,
  35334. 0xae,
  35335. 0x08,
  35336. 0xba,
  35337. 0x78,
  35338. 0x25,
  35339. 0x2e,
  35340. 0x1c,
  35341. 0xa6,
  35342. 0xb4,
  35343. 0xc6,
  35344. 0xe8,
  35345. 0xdd,
  35346. 0x74,
  35347. 0x1f,
  35348. 0x4b,
  35349. 0xbd,
  35350. 0x8b,
  35351. 0x8a,
  35352. 0x70,
  35353. 0x3e,
  35354. 0xb5,
  35355. 0x66,
  35356. 0x48,
  35357. 0x03,
  35358. 0xf6,
  35359. 0x0e,
  35360. 0x61,
  35361. 0x35,
  35362. 0x57,
  35363. 0xb9,
  35364. 0x86,
  35365. 0xc1,
  35366. 0x1d,
  35367. 0x9e,
  35368. 0xe1,
  35369. 0xf8,
  35370. 0x98,
  35371. 0x11,
  35372. 0x69,
  35373. 0xd9,
  35374. 0x8e,
  35375. 0x94,
  35376. 0x9b,
  35377. 0x1e,
  35378. 0x87,
  35379. 0xe9,
  35380. 0xce,
  35381. 0x55,
  35382. 0x28,
  35383. 0xdf,
  35384. 0x8c,
  35385. 0xa1,
  35386. 0x89,
  35387. 0x0d,
  35388. 0xbf,
  35389. 0xe6,
  35390. 0x42,
  35391. 0x68,
  35392. 0x41,
  35393. 0x99,
  35394. 0x2d,
  35395. 0x0f,
  35396. 0xb0,
  35397. 0x54,
  35398. 0xbb,
  35399. 0x16
  35400. ]);
  35401. var inv_s = new Uint8Array([
  35402. 0x52,
  35403. 0x09,
  35404. 0x6a,
  35405. 0xd5,
  35406. 0x30,
  35407. 0x36,
  35408. 0xa5,
  35409. 0x38,
  35410. 0xbf,
  35411. 0x40,
  35412. 0xa3,
  35413. 0x9e,
  35414. 0x81,
  35415. 0xf3,
  35416. 0xd7,
  35417. 0xfb,
  35418. 0x7c,
  35419. 0xe3,
  35420. 0x39,
  35421. 0x82,
  35422. 0x9b,
  35423. 0x2f,
  35424. 0xff,
  35425. 0x87,
  35426. 0x34,
  35427. 0x8e,
  35428. 0x43,
  35429. 0x44,
  35430. 0xc4,
  35431. 0xde,
  35432. 0xe9,
  35433. 0xcb,
  35434. 0x54,
  35435. 0x7b,
  35436. 0x94,
  35437. 0x32,
  35438. 0xa6,
  35439. 0xc2,
  35440. 0x23,
  35441. 0x3d,
  35442. 0xee,
  35443. 0x4c,
  35444. 0x95,
  35445. 0x0b,
  35446. 0x42,
  35447. 0xfa,
  35448. 0xc3,
  35449. 0x4e,
  35450. 0x08,
  35451. 0x2e,
  35452. 0xa1,
  35453. 0x66,
  35454. 0x28,
  35455. 0xd9,
  35456. 0x24,
  35457. 0xb2,
  35458. 0x76,
  35459. 0x5b,
  35460. 0xa2,
  35461. 0x49,
  35462. 0x6d,
  35463. 0x8b,
  35464. 0xd1,
  35465. 0x25,
  35466. 0x72,
  35467. 0xf8,
  35468. 0xf6,
  35469. 0x64,
  35470. 0x86,
  35471. 0x68,
  35472. 0x98,
  35473. 0x16,
  35474. 0xd4,
  35475. 0xa4,
  35476. 0x5c,
  35477. 0xcc,
  35478. 0x5d,
  35479. 0x65,
  35480. 0xb6,
  35481. 0x92,
  35482. 0x6c,
  35483. 0x70,
  35484. 0x48,
  35485. 0x50,
  35486. 0xfd,
  35487. 0xed,
  35488. 0xb9,
  35489. 0xda,
  35490. 0x5e,
  35491. 0x15,
  35492. 0x46,
  35493. 0x57,
  35494. 0xa7,
  35495. 0x8d,
  35496. 0x9d,
  35497. 0x84,
  35498. 0x90,
  35499. 0xd8,
  35500. 0xab,
  35501. 0x00,
  35502. 0x8c,
  35503. 0xbc,
  35504. 0xd3,
  35505. 0x0a,
  35506. 0xf7,
  35507. 0xe4,
  35508. 0x58,
  35509. 0x05,
  35510. 0xb8,
  35511. 0xb3,
  35512. 0x45,
  35513. 0x06,
  35514. 0xd0,
  35515. 0x2c,
  35516. 0x1e,
  35517. 0x8f,
  35518. 0xca,
  35519. 0x3f,
  35520. 0x0f,
  35521. 0x02,
  35522. 0xc1,
  35523. 0xaf,
  35524. 0xbd,
  35525. 0x03,
  35526. 0x01,
  35527. 0x13,
  35528. 0x8a,
  35529. 0x6b,
  35530. 0x3a,
  35531. 0x91,
  35532. 0x11,
  35533. 0x41,
  35534. 0x4f,
  35535. 0x67,
  35536. 0xdc,
  35537. 0xea,
  35538. 0x97,
  35539. 0xf2,
  35540. 0xcf,
  35541. 0xce,
  35542. 0xf0,
  35543. 0xb4,
  35544. 0xe6,
  35545. 0x73,
  35546. 0x96,
  35547. 0xac,
  35548. 0x74,
  35549. 0x22,
  35550. 0xe7,
  35551. 0xad,
  35552. 0x35,
  35553. 0x85,
  35554. 0xe2,
  35555. 0xf9,
  35556. 0x37,
  35557. 0xe8,
  35558. 0x1c,
  35559. 0x75,
  35560. 0xdf,
  35561. 0x6e,
  35562. 0x47,
  35563. 0xf1,
  35564. 0x1a,
  35565. 0x71,
  35566. 0x1d,
  35567. 0x29,
  35568. 0xc5,
  35569. 0x89,
  35570. 0x6f,
  35571. 0xb7,
  35572. 0x62,
  35573. 0x0e,
  35574. 0xaa,
  35575. 0x18,
  35576. 0xbe,
  35577. 0x1b,
  35578. 0xfc,
  35579. 0x56,
  35580. 0x3e,
  35581. 0x4b,
  35582. 0xc6,
  35583. 0xd2,
  35584. 0x79,
  35585. 0x20,
  35586. 0x9a,
  35587. 0xdb,
  35588. 0xc0,
  35589. 0xfe,
  35590. 0x78,
  35591. 0xcd,
  35592. 0x5a,
  35593. 0xf4,
  35594. 0x1f,
  35595. 0xdd,
  35596. 0xa8,
  35597. 0x33,
  35598. 0x88,
  35599. 0x07,
  35600. 0xc7,
  35601. 0x31,
  35602. 0xb1,
  35603. 0x12,
  35604. 0x10,
  35605. 0x59,
  35606. 0x27,
  35607. 0x80,
  35608. 0xec,
  35609. 0x5f,
  35610. 0x60,
  35611. 0x51,
  35612. 0x7f,
  35613. 0xa9,
  35614. 0x19,
  35615. 0xb5,
  35616. 0x4a,
  35617. 0x0d,
  35618. 0x2d,
  35619. 0xe5,
  35620. 0x7a,
  35621. 0x9f,
  35622. 0x93,
  35623. 0xc9,
  35624. 0x9c,
  35625. 0xef,
  35626. 0xa0,
  35627. 0xe0,
  35628. 0x3b,
  35629. 0x4d,
  35630. 0xae,
  35631. 0x2a,
  35632. 0xf5,
  35633. 0xb0,
  35634. 0xc8,
  35635. 0xeb,
  35636. 0xbb,
  35637. 0x3c,
  35638. 0x83,
  35639. 0x53,
  35640. 0x99,
  35641. 0x61,
  35642. 0x17,
  35643. 0x2b,
  35644. 0x04,
  35645. 0x7e,
  35646. 0xba,
  35647. 0x77,
  35648. 0xd6,
  35649. 0x26,
  35650. 0xe1,
  35651. 0x69,
  35652. 0x14,
  35653. 0x63,
  35654. 0x55,
  35655. 0x21,
  35656. 0x0c,
  35657. 0x7d
  35658. ]);
  35659. var mixCol = new Uint8Array(256);
  35660. for (var i = 0; i < 256; i++) {
  35661. if (i < 128) {
  35662. mixCol[i] = i << 1;
  35663. } else {
  35664. mixCol[i] = i << 1 ^ 0x1b;
  35665. }
  35666. }
  35667. var mix = new Uint32Array([
  35668. 0x00000000,
  35669. 0x0e090d0b,
  35670. 0x1c121a16,
  35671. 0x121b171d,
  35672. 0x3824342c,
  35673. 0x362d3927,
  35674. 0x24362e3a,
  35675. 0x2a3f2331,
  35676. 0x70486858,
  35677. 0x7e416553,
  35678. 0x6c5a724e,
  35679. 0x62537f45,
  35680. 0x486c5c74,
  35681. 0x4665517f,
  35682. 0x547e4662,
  35683. 0x5a774b69,
  35684. 0xe090d0b0,
  35685. 0xee99ddbb,
  35686. 0xfc82caa6,
  35687. 0xf28bc7ad,
  35688. 0xd8b4e49c,
  35689. 0xd6bde997,
  35690. 0xc4a6fe8a,
  35691. 0xcaaff381,
  35692. 0x90d8b8e8,
  35693. 0x9ed1b5e3,
  35694. 0x8ccaa2fe,
  35695. 0x82c3aff5,
  35696. 0xa8fc8cc4,
  35697. 0xa6f581cf,
  35698. 0xb4ee96d2,
  35699. 0xbae79bd9,
  35700. 0xdb3bbb7b,
  35701. 0xd532b670,
  35702. 0xc729a16d,
  35703. 0xc920ac66,
  35704. 0xe31f8f57,
  35705. 0xed16825c,
  35706. 0xff0d9541,
  35707. 0xf104984a,
  35708. 0xab73d323,
  35709. 0xa57ade28,
  35710. 0xb761c935,
  35711. 0xb968c43e,
  35712. 0x9357e70f,
  35713. 0x9d5eea04,
  35714. 0x8f45fd19,
  35715. 0x814cf012,
  35716. 0x3bab6bcb,
  35717. 0x35a266c0,
  35718. 0x27b971dd,
  35719. 0x29b07cd6,
  35720. 0x038f5fe7,
  35721. 0x0d8652ec,
  35722. 0x1f9d45f1,
  35723. 0x119448fa,
  35724. 0x4be30393,
  35725. 0x45ea0e98,
  35726. 0x57f11985,
  35727. 0x59f8148e,
  35728. 0x73c737bf,
  35729. 0x7dce3ab4,
  35730. 0x6fd52da9,
  35731. 0x61dc20a2,
  35732. 0xad766df6,
  35733. 0xa37f60fd,
  35734. 0xb16477e0,
  35735. 0xbf6d7aeb,
  35736. 0x955259da,
  35737. 0x9b5b54d1,
  35738. 0x894043cc,
  35739. 0x87494ec7,
  35740. 0xdd3e05ae,
  35741. 0xd33708a5,
  35742. 0xc12c1fb8,
  35743. 0xcf2512b3,
  35744. 0xe51a3182,
  35745. 0xeb133c89,
  35746. 0xf9082b94,
  35747. 0xf701269f,
  35748. 0x4de6bd46,
  35749. 0x43efb04d,
  35750. 0x51f4a750,
  35751. 0x5ffdaa5b,
  35752. 0x75c2896a,
  35753. 0x7bcb8461,
  35754. 0x69d0937c,
  35755. 0x67d99e77,
  35756. 0x3daed51e,
  35757. 0x33a7d815,
  35758. 0x21bccf08,
  35759. 0x2fb5c203,
  35760. 0x058ae132,
  35761. 0x0b83ec39,
  35762. 0x1998fb24,
  35763. 0x1791f62f,
  35764. 0x764dd68d,
  35765. 0x7844db86,
  35766. 0x6a5fcc9b,
  35767. 0x6456c190,
  35768. 0x4e69e2a1,
  35769. 0x4060efaa,
  35770. 0x527bf8b7,
  35771. 0x5c72f5bc,
  35772. 0x0605bed5,
  35773. 0x080cb3de,
  35774. 0x1a17a4c3,
  35775. 0x141ea9c8,
  35776. 0x3e218af9,
  35777. 0x302887f2,
  35778. 0x223390ef,
  35779. 0x2c3a9de4,
  35780. 0x96dd063d,
  35781. 0x98d40b36,
  35782. 0x8acf1c2b,
  35783. 0x84c61120,
  35784. 0xaef93211,
  35785. 0xa0f03f1a,
  35786. 0xb2eb2807,
  35787. 0xbce2250c,
  35788. 0xe6956e65,
  35789. 0xe89c636e,
  35790. 0xfa877473,
  35791. 0xf48e7978,
  35792. 0xdeb15a49,
  35793. 0xd0b85742,
  35794. 0xc2a3405f,
  35795. 0xccaa4d54,
  35796. 0x41ecdaf7,
  35797. 0x4fe5d7fc,
  35798. 0x5dfec0e1,
  35799. 0x53f7cdea,
  35800. 0x79c8eedb,
  35801. 0x77c1e3d0,
  35802. 0x65daf4cd,
  35803. 0x6bd3f9c6,
  35804. 0x31a4b2af,
  35805. 0x3fadbfa4,
  35806. 0x2db6a8b9,
  35807. 0x23bfa5b2,
  35808. 0x09808683,
  35809. 0x07898b88,
  35810. 0x15929c95,
  35811. 0x1b9b919e,
  35812. 0xa17c0a47,
  35813. 0xaf75074c,
  35814. 0xbd6e1051,
  35815. 0xb3671d5a,
  35816. 0x99583e6b,
  35817. 0x97513360,
  35818. 0x854a247d,
  35819. 0x8b432976,
  35820. 0xd134621f,
  35821. 0xdf3d6f14,
  35822. 0xcd267809,
  35823. 0xc32f7502,
  35824. 0xe9105633,
  35825. 0xe7195b38,
  35826. 0xf5024c25,
  35827. 0xfb0b412e,
  35828. 0x9ad7618c,
  35829. 0x94de6c87,
  35830. 0x86c57b9a,
  35831. 0x88cc7691,
  35832. 0xa2f355a0,
  35833. 0xacfa58ab,
  35834. 0xbee14fb6,
  35835. 0xb0e842bd,
  35836. 0xea9f09d4,
  35837. 0xe49604df,
  35838. 0xf68d13c2,
  35839. 0xf8841ec9,
  35840. 0xd2bb3df8,
  35841. 0xdcb230f3,
  35842. 0xcea927ee,
  35843. 0xc0a02ae5,
  35844. 0x7a47b13c,
  35845. 0x744ebc37,
  35846. 0x6655ab2a,
  35847. 0x685ca621,
  35848. 0x42638510,
  35849. 0x4c6a881b,
  35850. 0x5e719f06,
  35851. 0x5078920d,
  35852. 0x0a0fd964,
  35853. 0x0406d46f,
  35854. 0x161dc372,
  35855. 0x1814ce79,
  35856. 0x322bed48,
  35857. 0x3c22e043,
  35858. 0x2e39f75e,
  35859. 0x2030fa55,
  35860. 0xec9ab701,
  35861. 0xe293ba0a,
  35862. 0xf088ad17,
  35863. 0xfe81a01c,
  35864. 0xd4be832d,
  35865. 0xdab78e26,
  35866. 0xc8ac993b,
  35867. 0xc6a59430,
  35868. 0x9cd2df59,
  35869. 0x92dbd252,
  35870. 0x80c0c54f,
  35871. 0x8ec9c844,
  35872. 0xa4f6eb75,
  35873. 0xaaffe67e,
  35874. 0xb8e4f163,
  35875. 0xb6edfc68,
  35876. 0x0c0a67b1,
  35877. 0x02036aba,
  35878. 0x10187da7,
  35879. 0x1e1170ac,
  35880. 0x342e539d,
  35881. 0x3a275e96,
  35882. 0x283c498b,
  35883. 0x26354480,
  35884. 0x7c420fe9,
  35885. 0x724b02e2,
  35886. 0x605015ff,
  35887. 0x6e5918f4,
  35888. 0x44663bc5,
  35889. 0x4a6f36ce,
  35890. 0x587421d3,
  35891. 0x567d2cd8,
  35892. 0x37a10c7a,
  35893. 0x39a80171,
  35894. 0x2bb3166c,
  35895. 0x25ba1b67,
  35896. 0x0f853856,
  35897. 0x018c355d,
  35898. 0x13972240,
  35899. 0x1d9e2f4b,
  35900. 0x47e96422,
  35901. 0x49e06929,
  35902. 0x5bfb7e34,
  35903. 0x55f2733f,
  35904. 0x7fcd500e,
  35905. 0x71c45d05,
  35906. 0x63df4a18,
  35907. 0x6dd64713,
  35908. 0xd731dcca,
  35909. 0xd938d1c1,
  35910. 0xcb23c6dc,
  35911. 0xc52acbd7,
  35912. 0xef15e8e6,
  35913. 0xe11ce5ed,
  35914. 0xf307f2f0,
  35915. 0xfd0efffb,
  35916. 0xa779b492,
  35917. 0xa970b999,
  35918. 0xbb6bae84,
  35919. 0xb562a38f,
  35920. 0x9f5d80be,
  35921. 0x91548db5,
  35922. 0x834f9aa8,
  35923. 0x8d4697a3
  35924. ]);
  35925. function expandKey256(cipherKey) {
  35926. var b = 240, result = new Uint8Array(b);
  35927. var r = 1;
  35928. result.set(cipherKey);
  35929. for (var j = 32, i = 1; j < b; ++i) {
  35930. if (j % 32 === 16) {
  35931. t1 = s[t1];
  35932. t2 = s[t2];
  35933. t3 = s[t3];
  35934. t4 = s[t4];
  35935. } else if (j % 32 === 0) {
  35936. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35937. t1 = s[t1];
  35938. t2 = s[t2];
  35939. t3 = s[t3];
  35940. t4 = s[t4];
  35941. t1 = t1 ^ r;
  35942. if ((r <<= 1) >= 256) {
  35943. r = (r ^ 0x1b) & 0xFF;
  35944. }
  35945. }
  35946. for (var n = 0; n < 4; ++n) {
  35947. result[j] = t1 ^= result[j - 32];
  35948. j++;
  35949. result[j] = t2 ^= result[j - 32];
  35950. j++;
  35951. result[j] = t3 ^= result[j - 32];
  35952. j++;
  35953. result[j] = t4 ^= result[j - 32];
  35954. j++;
  35955. }
  35956. }
  35957. return result;
  35958. }
  35959. function decrypt256(input, key) {
  35960. var state = new Uint8Array(16);
  35961. state.set(input);
  35962. var i, j, k;
  35963. var t, u, v;
  35964. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35965. state[j] ^= key[k];
  35966. }
  35967. for (i = 13; i >= 1; --i) {
  35968. t = state[13];
  35969. state[13] = state[9];
  35970. state[9] = state[5];
  35971. state[5] = state[1];
  35972. state[1] = t;
  35973. t = state[14];
  35974. u = state[10];
  35975. state[14] = state[6];
  35976. state[10] = state[2];
  35977. state[6] = t;
  35978. state[2] = u;
  35979. t = state[15];
  35980. u = state[11];
  35981. v = state[7];
  35982. state[15] = state[3];
  35983. state[11] = t;
  35984. state[7] = u;
  35985. state[3] = v;
  35986. for (j = 0; j < 16; ++j) {
  35987. state[j] = inv_s[state[j]];
  35988. }
  35989. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35990. state[j] ^= key[k];
  35991. }
  35992. for (j = 0; j < 16; j += 4) {
  35993. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35994. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35995. state[j] = t >>> 24 & 0xFF;
  35996. state[j + 1] = t >> 16 & 0xFF;
  35997. state[j + 2] = t >> 8 & 0xFF;
  35998. state[j + 3] = t & 0xFF;
  35999. }
  36000. }
  36001. t = state[13];
  36002. state[13] = state[9];
  36003. state[9] = state[5];
  36004. state[5] = state[1];
  36005. state[1] = t;
  36006. t = state[14];
  36007. u = state[10];
  36008. state[14] = state[6];
  36009. state[10] = state[2];
  36010. state[6] = t;
  36011. state[2] = u;
  36012. t = state[15];
  36013. u = state[11];
  36014. v = state[7];
  36015. state[15] = state[3];
  36016. state[11] = t;
  36017. state[7] = u;
  36018. state[3] = v;
  36019. for (j = 0; j < 16; ++j) {
  36020. state[j] = inv_s[state[j]];
  36021. state[j] ^= key[j];
  36022. }
  36023. return state;
  36024. }
  36025. function encrypt256(input, key) {
  36026. var t, u, v, k;
  36027. var state = new Uint8Array(16);
  36028. state.set(input);
  36029. for (j = 0; j < 16; ++j) {
  36030. state[j] ^= key[j];
  36031. }
  36032. for (i = 1; i < 14; i++) {
  36033. for (j = 0; j < 16; ++j) {
  36034. state[j] = s[state[j]];
  36035. }
  36036. v = state[1];
  36037. state[1] = state[5];
  36038. state[5] = state[9];
  36039. state[9] = state[13];
  36040. state[13] = v;
  36041. v = state[2];
  36042. u = state[6];
  36043. state[2] = state[10];
  36044. state[6] = state[14];
  36045. state[10] = v;
  36046. state[14] = u;
  36047. v = state[3];
  36048. u = state[7];
  36049. t = state[11];
  36050. state[3] = state[15];
  36051. state[7] = v;
  36052. state[11] = u;
  36053. state[15] = t;
  36054. for (var j = 0; j < 16; j += 4) {
  36055. var s0 = state[j + 0], s1 = state[j + 1];
  36056. var s2 = state[j + 2], s3 = state[j + 3];
  36057. t = s0 ^ s1 ^ s2 ^ s3;
  36058. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  36059. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  36060. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  36061. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  36062. }
  36063. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  36064. state[j] ^= key[k];
  36065. }
  36066. }
  36067. for (j = 0; j < 16; ++j) {
  36068. state[j] = s[state[j]];
  36069. }
  36070. v = state[1];
  36071. state[1] = state[5];
  36072. state[5] = state[9];
  36073. state[9] = state[13];
  36074. state[13] = v;
  36075. v = state[2];
  36076. u = state[6];
  36077. state[2] = state[10];
  36078. state[6] = state[14];
  36079. state[10] = v;
  36080. state[14] = u;
  36081. v = state[3];
  36082. u = state[7];
  36083. t = state[11];
  36084. state[3] = state[15];
  36085. state[7] = v;
  36086. state[11] = u;
  36087. state[15] = t;
  36088. for (j = 0, k = 224; j < 16; ++j, ++k) {
  36089. state[j] ^= key[k];
  36090. }
  36091. return state;
  36092. }
  36093. function AES256Cipher(key) {
  36094. this.key = expandKey256(key);
  36095. this.buffer = new Uint8Array(16);
  36096. this.bufferPosition = 0;
  36097. }
  36098. function decryptBlock2(data, finalize) {
  36099. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  36100. for (i = 0; i < sourceLength; ++i) {
  36101. buffer[bufferLength] = data[i];
  36102. ++bufferLength;
  36103. if (bufferLength < 16) {
  36104. continue;
  36105. }
  36106. var plain = decrypt256(buffer, this.key);
  36107. for (j = 0; j < 16; ++j) {
  36108. plain[j] ^= iv[j];
  36109. }
  36110. iv = buffer;
  36111. result.push(plain);
  36112. buffer = new Uint8Array(16);
  36113. bufferLength = 0;
  36114. }
  36115. this.buffer = buffer;
  36116. this.bufferLength = bufferLength;
  36117. this.iv = iv;
  36118. if (result.length === 0) {
  36119. return new Uint8Array([]);
  36120. }
  36121. var outputLength = 16 * result.length;
  36122. if (finalize) {
  36123. var lastBlock = result[result.length - 1];
  36124. var psLen = lastBlock[15];
  36125. if (psLen <= 16) {
  36126. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  36127. if (lastBlock[i] !== psLen) {
  36128. psLen = 0;
  36129. break;
  36130. }
  36131. }
  36132. outputLength -= psLen;
  36133. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  36134. }
  36135. }
  36136. var output = new Uint8Array(outputLength);
  36137. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36138. output.set(result[i], j);
  36139. }
  36140. return output;
  36141. }
  36142. AES256Cipher.prototype = {
  36143. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  36144. var i, sourceLength = data.length;
  36145. var buffer = this.buffer, bufferLength = this.bufferPosition;
  36146. if (iv) {
  36147. this.iv = iv;
  36148. } else {
  36149. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  36150. buffer[bufferLength] = data[i];
  36151. }
  36152. if (bufferLength < 16) {
  36153. this.bufferLength = bufferLength;
  36154. return new Uint8Array([]);
  36155. }
  36156. this.iv = buffer;
  36157. data = data.subarray(16);
  36158. }
  36159. this.buffer = new Uint8Array(16);
  36160. this.bufferLength = 0;
  36161. this.decryptBlock = decryptBlock2;
  36162. return this.decryptBlock(data, finalize);
  36163. },
  36164. encrypt: function AES256Cipher_encrypt(data, iv) {
  36165. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  36166. if (!iv) {
  36167. iv = new Uint8Array(16);
  36168. }
  36169. for (i = 0; i < sourceLength; ++i) {
  36170. buffer[bufferLength] = data[i];
  36171. ++bufferLength;
  36172. if (bufferLength < 16) {
  36173. continue;
  36174. }
  36175. for (j = 0; j < 16; ++j) {
  36176. buffer[j] ^= iv[j];
  36177. }
  36178. var cipher = encrypt256(buffer, this.key);
  36179. this.iv = cipher;
  36180. result.push(cipher);
  36181. buffer = new Uint8Array(16);
  36182. bufferLength = 0;
  36183. }
  36184. this.buffer = buffer;
  36185. this.bufferLength = bufferLength;
  36186. this.iv = iv;
  36187. if (result.length === 0) {
  36188. return new Uint8Array([]);
  36189. }
  36190. var outputLength = 16 * result.length;
  36191. var output = new Uint8Array(outputLength);
  36192. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36193. output.set(result[i], j);
  36194. }
  36195. return output;
  36196. }
  36197. };
  36198. return AES256Cipher;
  36199. }();
  36200. var PDF17 = function PDF17Closure() {
  36201. function compareByteArrays(array1, array2) {
  36202. if (array1.length !== array2.length) {
  36203. return false;
  36204. }
  36205. for (var i = 0; i < array1.length; i++) {
  36206. if (array1[i] !== array2[i]) {
  36207. return false;
  36208. }
  36209. }
  36210. return true;
  36211. }
  36212. function PDF17() {
  36213. }
  36214. PDF17.prototype = {
  36215. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36216. var hashData = new Uint8Array(password.length + 56);
  36217. hashData.set(password, 0);
  36218. hashData.set(ownerValidationSalt, password.length);
  36219. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36220. var result = calculateSHA256(hashData, 0, hashData.length);
  36221. return compareByteArrays(result, ownerPassword);
  36222. },
  36223. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36224. var hashData = new Uint8Array(password.length + 8);
  36225. hashData.set(password, 0);
  36226. hashData.set(userValidationSalt, password.length);
  36227. var result = calculateSHA256(hashData, 0, hashData.length);
  36228. return compareByteArrays(result, userPassword);
  36229. },
  36230. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36231. var hashData = new Uint8Array(password.length + 56);
  36232. hashData.set(password, 0);
  36233. hashData.set(ownerKeySalt, password.length);
  36234. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36235. var key = calculateSHA256(hashData, 0, hashData.length);
  36236. var cipher = new AES256Cipher(key);
  36237. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36238. },
  36239. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36240. var hashData = new Uint8Array(password.length + 8);
  36241. hashData.set(password, 0);
  36242. hashData.set(userKeySalt, password.length);
  36243. var key = calculateSHA256(hashData, 0, hashData.length);
  36244. var cipher = new AES256Cipher(key);
  36245. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36246. }
  36247. };
  36248. return PDF17;
  36249. }();
  36250. var PDF20 = function PDF20Closure() {
  36251. function concatArrays(array1, array2) {
  36252. var t = new Uint8Array(array1.length + array2.length);
  36253. t.set(array1, 0);
  36254. t.set(array2, array1.length);
  36255. return t;
  36256. }
  36257. function calculatePDF20Hash(password, input, userBytes) {
  36258. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36259. var e = [0];
  36260. var i = 0;
  36261. while (i < 64 || e[e.length - 1] > i - 32) {
  36262. var arrayLength = password.length + k.length + userBytes.length;
  36263. var k1 = new Uint8Array(arrayLength * 64);
  36264. var array = concatArrays(password, k);
  36265. array = concatArrays(array, userBytes);
  36266. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36267. k1.set(array, pos);
  36268. }
  36269. var cipher = new AES128Cipher(k.subarray(0, 16));
  36270. e = cipher.encrypt(k1, k.subarray(16, 32));
  36271. var remainder = 0;
  36272. for (var z = 0; z < 16; z++) {
  36273. remainder *= 256 % 3;
  36274. remainder %= 3;
  36275. remainder += (e[z] >>> 0) % 3;
  36276. remainder %= 3;
  36277. }
  36278. if (remainder === 0) {
  36279. k = calculateSHA256(e, 0, e.length);
  36280. } else if (remainder === 1) {
  36281. k = calculateSHA384(e, 0, e.length);
  36282. } else if (remainder === 2) {
  36283. k = calculateSHA512(e, 0, e.length);
  36284. }
  36285. i++;
  36286. }
  36287. return k.subarray(0, 32);
  36288. }
  36289. function PDF20() {
  36290. }
  36291. function compareByteArrays(array1, array2) {
  36292. if (array1.length !== array2.length) {
  36293. return false;
  36294. }
  36295. for (var i = 0; i < array1.length; i++) {
  36296. if (array1[i] !== array2[i]) {
  36297. return false;
  36298. }
  36299. }
  36300. return true;
  36301. }
  36302. PDF20.prototype = {
  36303. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36304. return calculatePDF20Hash(password, concatBytes, userBytes);
  36305. },
  36306. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36307. var hashData = new Uint8Array(password.length + 56);
  36308. hashData.set(password, 0);
  36309. hashData.set(ownerValidationSalt, password.length);
  36310. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36311. var result = calculatePDF20Hash(password, hashData, userBytes);
  36312. return compareByteArrays(result, ownerPassword);
  36313. },
  36314. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36315. var hashData = new Uint8Array(password.length + 8);
  36316. hashData.set(password, 0);
  36317. hashData.set(userValidationSalt, password.length);
  36318. var result = calculatePDF20Hash(password, hashData, []);
  36319. return compareByteArrays(result, userPassword);
  36320. },
  36321. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36322. var hashData = new Uint8Array(password.length + 56);
  36323. hashData.set(password, 0);
  36324. hashData.set(ownerKeySalt, password.length);
  36325. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36326. var key = calculatePDF20Hash(password, hashData, userBytes);
  36327. var cipher = new AES256Cipher(key);
  36328. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36329. },
  36330. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36331. var hashData = new Uint8Array(password.length + 8);
  36332. hashData.set(password, 0);
  36333. hashData.set(userKeySalt, password.length);
  36334. var key = calculatePDF20Hash(password, hashData, []);
  36335. var cipher = new AES256Cipher(key);
  36336. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36337. }
  36338. };
  36339. return PDF20;
  36340. }();
  36341. var CipherTransform = function CipherTransformClosure() {
  36342. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36343. this.StringCipherConstructor = stringCipherConstructor;
  36344. this.StreamCipherConstructor = streamCipherConstructor;
  36345. }
  36346. CipherTransform.prototype = {
  36347. createStream: function CipherTransform_createStream(stream, length) {
  36348. var cipher = new this.StreamCipherConstructor();
  36349. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36350. return cipher.decryptBlock(data, finalize);
  36351. });
  36352. },
  36353. decryptString: function CipherTransform_decryptString(s) {
  36354. var cipher = new this.StringCipherConstructor();
  36355. var data = stringToBytes(s);
  36356. data = cipher.decryptBlock(data, true);
  36357. return bytesToString(data);
  36358. }
  36359. };
  36360. return CipherTransform;
  36361. }();
  36362. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36363. var defaultPasswordBytes = new Uint8Array([
  36364. 0x28,
  36365. 0xBF,
  36366. 0x4E,
  36367. 0x5E,
  36368. 0x4E,
  36369. 0x75,
  36370. 0x8A,
  36371. 0x41,
  36372. 0x64,
  36373. 0x00,
  36374. 0x4E,
  36375. 0x56,
  36376. 0xFF,
  36377. 0xFA,
  36378. 0x01,
  36379. 0x08,
  36380. 0x2E,
  36381. 0x2E,
  36382. 0x00,
  36383. 0xB6,
  36384. 0xD0,
  36385. 0x68,
  36386. 0x3E,
  36387. 0x80,
  36388. 0x2F,
  36389. 0x0C,
  36390. 0xA9,
  36391. 0xFE,
  36392. 0x64,
  36393. 0x53,
  36394. 0x69,
  36395. 0x7A
  36396. ]);
  36397. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36398. if (password) {
  36399. var passwordLength = Math.min(127, password.length);
  36400. password = password.subarray(0, passwordLength);
  36401. } else {
  36402. password = [];
  36403. }
  36404. var pdfAlgorithm;
  36405. if (revision === 6) {
  36406. pdfAlgorithm = new PDF20();
  36407. } else {
  36408. pdfAlgorithm = new PDF17();
  36409. }
  36410. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36411. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36412. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36413. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36414. }
  36415. return null;
  36416. }
  36417. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36418. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36419. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36420. if (password) {
  36421. n = Math.min(32, password.length);
  36422. for (; i < n; ++i) {
  36423. hashData[i] = password[i];
  36424. }
  36425. }
  36426. j = 0;
  36427. while (i < 32) {
  36428. hashData[i++] = defaultPasswordBytes[j++];
  36429. }
  36430. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36431. hashData[i++] = ownerPassword[j];
  36432. }
  36433. hashData[i++] = flags & 0xFF;
  36434. hashData[i++] = flags >> 8 & 0xFF;
  36435. hashData[i++] = flags >> 16 & 0xFF;
  36436. hashData[i++] = flags >>> 24 & 0xFF;
  36437. for (j = 0, n = fileId.length; j < n; ++j) {
  36438. hashData[i++] = fileId[j];
  36439. }
  36440. if (revision >= 4 && !encryptMetadata) {
  36441. hashData[i++] = 0xFF;
  36442. hashData[i++] = 0xFF;
  36443. hashData[i++] = 0xFF;
  36444. hashData[i++] = 0xFF;
  36445. }
  36446. var hash = calculateMD5(hashData, 0, i);
  36447. var keyLengthInBytes = keyLength >> 3;
  36448. if (revision >= 3) {
  36449. for (j = 0; j < 50; ++j) {
  36450. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36451. }
  36452. }
  36453. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36454. var cipher, checkData;
  36455. if (revision >= 3) {
  36456. for (i = 0; i < 32; ++i) {
  36457. hashData[i] = defaultPasswordBytes[i];
  36458. }
  36459. for (j = 0, n = fileId.length; j < n; ++j) {
  36460. hashData[i++] = fileId[j];
  36461. }
  36462. cipher = new ARCFourCipher(encryptionKey);
  36463. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36464. n = encryptionKey.length;
  36465. var derivedKey = new Uint8Array(n), k;
  36466. for (j = 1; j <= 19; ++j) {
  36467. for (k = 0; k < n; ++k) {
  36468. derivedKey[k] = encryptionKey[k] ^ j;
  36469. }
  36470. cipher = new ARCFourCipher(derivedKey);
  36471. checkData = cipher.encryptBlock(checkData);
  36472. }
  36473. for (j = 0, n = checkData.length; j < n; ++j) {
  36474. if (userPassword[j] !== checkData[j]) {
  36475. return null;
  36476. }
  36477. }
  36478. } else {
  36479. cipher = new ARCFourCipher(encryptionKey);
  36480. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36481. for (j = 0, n = checkData.length; j < n; ++j) {
  36482. if (userPassword[j] !== checkData[j]) {
  36483. return null;
  36484. }
  36485. }
  36486. }
  36487. return encryptionKey;
  36488. }
  36489. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36490. var hashData = new Uint8Array(32), i = 0, j, n;
  36491. n = Math.min(32, password.length);
  36492. for (; i < n; ++i) {
  36493. hashData[i] = password[i];
  36494. }
  36495. j = 0;
  36496. while (i < 32) {
  36497. hashData[i++] = defaultPasswordBytes[j++];
  36498. }
  36499. var hash = calculateMD5(hashData, 0, i);
  36500. var keyLengthInBytes = keyLength >> 3;
  36501. if (revision >= 3) {
  36502. for (j = 0; j < 50; ++j) {
  36503. hash = calculateMD5(hash, 0, hash.length);
  36504. }
  36505. }
  36506. var cipher, userPassword;
  36507. if (revision >= 3) {
  36508. userPassword = ownerPassword;
  36509. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36510. for (j = 19; j >= 0; j--) {
  36511. for (k = 0; k < keyLengthInBytes; ++k) {
  36512. derivedKey[k] = hash[k] ^ j;
  36513. }
  36514. cipher = new ARCFourCipher(derivedKey);
  36515. userPassword = cipher.encryptBlock(userPassword);
  36516. }
  36517. } else {
  36518. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36519. userPassword = cipher.encryptBlock(ownerPassword);
  36520. }
  36521. return userPassword;
  36522. }
  36523. var identityName = Name.get('Identity');
  36524. function CipherTransformFactory(dict, fileId, password) {
  36525. var filter = dict.get('Filter');
  36526. if (!isName(filter, 'Standard')) {
  36527. error('unknown encryption method');
  36528. }
  36529. this.dict = dict;
  36530. var algorithm = dict.get('V');
  36531. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36532. error('unsupported encryption algorithm');
  36533. }
  36534. this.algorithm = algorithm;
  36535. var keyLength = dict.get('Length');
  36536. if (!keyLength) {
  36537. if (algorithm <= 3) {
  36538. keyLength = 40;
  36539. } else {
  36540. var cfDict = dict.get('CF');
  36541. var streamCryptoName = dict.get('StmF');
  36542. if (isDict(cfDict) && isName(streamCryptoName)) {
  36543. cfDict.suppressEncryption = true;
  36544. var handlerDict = cfDict.get(streamCryptoName.name);
  36545. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36546. if (keyLength < 40) {
  36547. keyLength <<= 3;
  36548. }
  36549. }
  36550. }
  36551. }
  36552. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36553. error('invalid key length');
  36554. }
  36555. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36556. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36557. var flags = dict.get('P');
  36558. var revision = dict.get('R');
  36559. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36560. this.encryptMetadata = encryptMetadata;
  36561. var fileIdBytes = stringToBytes(fileId);
  36562. var passwordBytes;
  36563. if (password) {
  36564. if (revision === 6) {
  36565. try {
  36566. password = utf8StringToString(password);
  36567. } catch (ex) {
  36568. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36569. }
  36570. }
  36571. passwordBytes = stringToBytes(password);
  36572. }
  36573. var encryptionKey;
  36574. if (algorithm !== 5) {
  36575. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36576. } else {
  36577. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36578. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36579. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36580. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36581. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36582. var ownerEncryption = stringToBytes(dict.get('OE'));
  36583. var userEncryption = stringToBytes(dict.get('UE'));
  36584. var perms = stringToBytes(dict.get('Perms'));
  36585. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36586. }
  36587. if (!encryptionKey && !password) {
  36588. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36589. } else if (!encryptionKey && password) {
  36590. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36591. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36592. }
  36593. if (!encryptionKey) {
  36594. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36595. }
  36596. this.encryptionKey = encryptionKey;
  36597. if (algorithm >= 4) {
  36598. var cf = dict.get('CF');
  36599. if (isDict(cf)) {
  36600. cf.suppressEncryption = true;
  36601. }
  36602. this.cf = cf;
  36603. this.stmf = dict.get('StmF') || identityName;
  36604. this.strf = dict.get('StrF') || identityName;
  36605. this.eff = dict.get('EFF') || this.stmf;
  36606. }
  36607. }
  36608. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36609. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36610. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36611. key[i] = encryptionKey[i];
  36612. }
  36613. key[i++] = num & 0xFF;
  36614. key[i++] = num >> 8 & 0xFF;
  36615. key[i++] = num >> 16 & 0xFF;
  36616. key[i++] = gen & 0xFF;
  36617. key[i++] = gen >> 8 & 0xFF;
  36618. if (isAes) {
  36619. key[i++] = 0x73;
  36620. key[i++] = 0x41;
  36621. key[i++] = 0x6C;
  36622. key[i++] = 0x54;
  36623. }
  36624. var hash = calculateMD5(key, 0, i);
  36625. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36626. }
  36627. function buildCipherConstructor(cf, name, num, gen, key) {
  36628. assert(isName(name), 'Invalid crypt filter name.');
  36629. var cryptFilter = cf.get(name.name);
  36630. var cfm;
  36631. if (cryptFilter !== null && cryptFilter !== undefined) {
  36632. cfm = cryptFilter.get('CFM');
  36633. }
  36634. if (!cfm || cfm.name === 'None') {
  36635. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36636. return new NullCipher();
  36637. };
  36638. }
  36639. if (cfm.name === 'V2') {
  36640. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36641. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36642. };
  36643. }
  36644. if (cfm.name === 'AESV2') {
  36645. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36646. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36647. };
  36648. }
  36649. if (cfm.name === 'AESV3') {
  36650. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36651. return new AES256Cipher(key);
  36652. };
  36653. }
  36654. error('Unknown crypto method');
  36655. }
  36656. CipherTransformFactory.prototype = {
  36657. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36658. if (this.algorithm === 4 || this.algorithm === 5) {
  36659. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36660. }
  36661. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36662. var cipherConstructor = function buildCipherCipherConstructor() {
  36663. return new ARCFourCipher(key);
  36664. };
  36665. return new CipherTransform(cipherConstructor, cipherConstructor);
  36666. }
  36667. };
  36668. return CipherTransformFactory;
  36669. }();
  36670. exports.AES128Cipher = AES128Cipher;
  36671. exports.AES256Cipher = AES256Cipher;
  36672. exports.ARCFourCipher = ARCFourCipher;
  36673. exports.CipherTransformFactory = CipherTransformFactory;
  36674. exports.PDF17 = PDF17;
  36675. exports.PDF20 = PDF20;
  36676. exports.calculateMD5 = calculateMD5;
  36677. exports.calculateSHA256 = calculateSHA256;
  36678. exports.calculateSHA384 = calculateSHA384;
  36679. exports.calculateSHA512 = calculateSHA512;
  36680. }));
  36681. (function (root, factory) {
  36682. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36683. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36684. var Util = sharedUtil.Util;
  36685. var bytesToString = sharedUtil.bytesToString;
  36686. var error = sharedUtil.error;
  36687. var Stream = coreStream.Stream;
  36688. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36689. var StandardEncoding = coreEncodings.StandardEncoding;
  36690. var CFFParser = coreCFFParser.CFFParser;
  36691. var FontRendererFactory = function FontRendererFactoryClosure() {
  36692. function getLong(data, offset) {
  36693. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36694. }
  36695. function getUshort(data, offset) {
  36696. return data[offset] << 8 | data[offset + 1];
  36697. }
  36698. function parseCmap(data, start, end) {
  36699. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36700. var format = getUshort(data, start + offset);
  36701. var length, ranges, p, i;
  36702. if (format === 4) {
  36703. length = getUshort(data, start + offset + 2);
  36704. var segCount = getUshort(data, start + offset + 6) >> 1;
  36705. p = start + offset + 14;
  36706. ranges = [];
  36707. for (i = 0; i < segCount; i++, p += 2) {
  36708. ranges[i] = { end: getUshort(data, p) };
  36709. }
  36710. p += 2;
  36711. for (i = 0; i < segCount; i++, p += 2) {
  36712. ranges[i].start = getUshort(data, p);
  36713. }
  36714. for (i = 0; i < segCount; i++, p += 2) {
  36715. ranges[i].idDelta = getUshort(data, p);
  36716. }
  36717. for (i = 0; i < segCount; i++, p += 2) {
  36718. var idOffset = getUshort(data, p);
  36719. if (idOffset === 0) {
  36720. continue;
  36721. }
  36722. ranges[i].ids = [];
  36723. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36724. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36725. idOffset += 2;
  36726. }
  36727. }
  36728. return ranges;
  36729. } else if (format === 12) {
  36730. length = getLong(data, start + offset + 4);
  36731. var groups = getLong(data, start + offset + 12);
  36732. p = start + offset + 16;
  36733. ranges = [];
  36734. for (i = 0; i < groups; i++) {
  36735. ranges.push({
  36736. start: getLong(data, p),
  36737. end: getLong(data, p + 4),
  36738. idDelta: getLong(data, p + 8) - getLong(data, p)
  36739. });
  36740. p += 12;
  36741. }
  36742. return ranges;
  36743. }
  36744. error('not supported cmap: ' + format);
  36745. }
  36746. function parseCff(data, start, end, seacAnalysisEnabled) {
  36747. var properties = {};
  36748. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36749. var cff = parser.parse();
  36750. return {
  36751. glyphs: cff.charStrings.objects,
  36752. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36753. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36754. };
  36755. }
  36756. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36757. var itemSize, itemDecode;
  36758. if (isGlyphLocationsLong) {
  36759. itemSize = 4;
  36760. itemDecode = function fontItemDecodeLong(data, offset) {
  36761. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36762. };
  36763. } else {
  36764. itemSize = 2;
  36765. itemDecode = function fontItemDecode(data, offset) {
  36766. return data[offset] << 9 | data[offset + 1] << 1;
  36767. };
  36768. }
  36769. var glyphs = [];
  36770. var startOffset = itemDecode(loca, 0);
  36771. for (var j = itemSize; j < loca.length; j += itemSize) {
  36772. var endOffset = itemDecode(loca, j);
  36773. glyphs.push(glyf.subarray(startOffset, endOffset));
  36774. startOffset = endOffset;
  36775. }
  36776. return glyphs;
  36777. }
  36778. function lookupCmap(ranges, unicode) {
  36779. var code = unicode.charCodeAt(0), gid = 0;
  36780. var l = 0, r = ranges.length - 1;
  36781. while (l < r) {
  36782. var c = l + r + 1 >> 1;
  36783. if (code < ranges[c].start) {
  36784. r = c - 1;
  36785. } else {
  36786. l = c;
  36787. }
  36788. }
  36789. if (ranges[l].start <= code && code <= ranges[l].end) {
  36790. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36791. }
  36792. return {
  36793. charCode: code,
  36794. glyphId: gid
  36795. };
  36796. }
  36797. function compileGlyf(code, cmds, font) {
  36798. function moveTo(x, y) {
  36799. cmds.push({
  36800. cmd: 'moveTo',
  36801. args: [
  36802. x,
  36803. y
  36804. ]
  36805. });
  36806. }
  36807. function lineTo(x, y) {
  36808. cmds.push({
  36809. cmd: 'lineTo',
  36810. args: [
  36811. x,
  36812. y
  36813. ]
  36814. });
  36815. }
  36816. function quadraticCurveTo(xa, ya, x, y) {
  36817. cmds.push({
  36818. cmd: 'quadraticCurveTo',
  36819. args: [
  36820. xa,
  36821. ya,
  36822. x,
  36823. y
  36824. ]
  36825. });
  36826. }
  36827. var i = 0;
  36828. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36829. var flags;
  36830. var x = 0, y = 0;
  36831. i += 10;
  36832. if (numberOfContours < 0) {
  36833. do {
  36834. flags = code[i] << 8 | code[i + 1];
  36835. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36836. i += 4;
  36837. var arg1, arg2;
  36838. if (flags & 0x01) {
  36839. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36840. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36841. i += 4;
  36842. } else {
  36843. arg1 = code[i++];
  36844. arg2 = code[i++];
  36845. }
  36846. if (flags & 0x02) {
  36847. x = arg1;
  36848. y = arg2;
  36849. } else {
  36850. x = 0;
  36851. y = 0;
  36852. }
  36853. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36854. if (flags & 0x08) {
  36855. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36856. i += 2;
  36857. } else if (flags & 0x40) {
  36858. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36859. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36860. i += 4;
  36861. } else if (flags & 0x80) {
  36862. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36863. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36864. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36865. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36866. i += 8;
  36867. }
  36868. var subglyph = font.glyphs[glyphIndex];
  36869. if (subglyph) {
  36870. cmds.push({ cmd: 'save' });
  36871. cmds.push({
  36872. cmd: 'transform',
  36873. args: [
  36874. scaleX,
  36875. scale01,
  36876. scale10,
  36877. scaleY,
  36878. x,
  36879. y
  36880. ]
  36881. });
  36882. compileGlyf(subglyph, cmds, font);
  36883. cmds.push({ cmd: 'restore' });
  36884. }
  36885. } while (flags & 0x20);
  36886. } else {
  36887. var endPtsOfContours = [];
  36888. var j, jj;
  36889. for (j = 0; j < numberOfContours; j++) {
  36890. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36891. i += 2;
  36892. }
  36893. var instructionLength = code[i] << 8 | code[i + 1];
  36894. i += 2 + instructionLength;
  36895. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36896. var points = [];
  36897. while (points.length < numberOfPoints) {
  36898. flags = code[i++];
  36899. var repeat = 1;
  36900. if (flags & 0x08) {
  36901. repeat += code[i++];
  36902. }
  36903. while (repeat-- > 0) {
  36904. points.push({ flags: flags });
  36905. }
  36906. }
  36907. for (j = 0; j < numberOfPoints; j++) {
  36908. switch (points[j].flags & 0x12) {
  36909. case 0x00:
  36910. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36911. i += 2;
  36912. break;
  36913. case 0x02:
  36914. x -= code[i++];
  36915. break;
  36916. case 0x12:
  36917. x += code[i++];
  36918. break;
  36919. }
  36920. points[j].x = x;
  36921. }
  36922. for (j = 0; j < numberOfPoints; j++) {
  36923. switch (points[j].flags & 0x24) {
  36924. case 0x00:
  36925. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36926. i += 2;
  36927. break;
  36928. case 0x04:
  36929. y -= code[i++];
  36930. break;
  36931. case 0x24:
  36932. y += code[i++];
  36933. break;
  36934. }
  36935. points[j].y = y;
  36936. }
  36937. var startPoint = 0;
  36938. for (i = 0; i < numberOfContours; i++) {
  36939. var endPoint = endPtsOfContours[i];
  36940. var contour = points.slice(startPoint, endPoint + 1);
  36941. if (contour[0].flags & 1) {
  36942. contour.push(contour[0]);
  36943. } else if (contour[contour.length - 1].flags & 1) {
  36944. contour.unshift(contour[contour.length - 1]);
  36945. } else {
  36946. var p = {
  36947. flags: 1,
  36948. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36949. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36950. };
  36951. contour.unshift(p);
  36952. contour.push(p);
  36953. }
  36954. moveTo(contour[0].x, contour[0].y);
  36955. for (j = 1, jj = contour.length; j < jj; j++) {
  36956. if (contour[j].flags & 1) {
  36957. lineTo(contour[j].x, contour[j].y);
  36958. } else if (contour[j + 1].flags & 1) {
  36959. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36960. j++;
  36961. } else {
  36962. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36963. }
  36964. }
  36965. startPoint = endPoint + 1;
  36966. }
  36967. }
  36968. }
  36969. function compileCharString(code, cmds, font) {
  36970. var stack = [];
  36971. var x = 0, y = 0;
  36972. var stems = 0;
  36973. function moveTo(x, y) {
  36974. cmds.push({
  36975. cmd: 'moveTo',
  36976. args: [
  36977. x,
  36978. y
  36979. ]
  36980. });
  36981. }
  36982. function lineTo(x, y) {
  36983. cmds.push({
  36984. cmd: 'lineTo',
  36985. args: [
  36986. x,
  36987. y
  36988. ]
  36989. });
  36990. }
  36991. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36992. cmds.push({
  36993. cmd: 'bezierCurveTo',
  36994. args: [
  36995. x1,
  36996. y1,
  36997. x2,
  36998. y2,
  36999. x,
  37000. y
  37001. ]
  37002. });
  37003. }
  37004. function parse(code) {
  37005. var i = 0;
  37006. while (i < code.length) {
  37007. var stackClean = false;
  37008. var v = code[i++];
  37009. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  37010. switch (v) {
  37011. case 1:
  37012. stems += stack.length >> 1;
  37013. stackClean = true;
  37014. break;
  37015. case 3:
  37016. stems += stack.length >> 1;
  37017. stackClean = true;
  37018. break;
  37019. case 4:
  37020. y += stack.pop();
  37021. moveTo(x, y);
  37022. stackClean = true;
  37023. break;
  37024. case 5:
  37025. while (stack.length > 0) {
  37026. x += stack.shift();
  37027. y += stack.shift();
  37028. lineTo(x, y);
  37029. }
  37030. break;
  37031. case 6:
  37032. while (stack.length > 0) {
  37033. x += stack.shift();
  37034. lineTo(x, y);
  37035. if (stack.length === 0) {
  37036. break;
  37037. }
  37038. y += stack.shift();
  37039. lineTo(x, y);
  37040. }
  37041. break;
  37042. case 7:
  37043. while (stack.length > 0) {
  37044. y += stack.shift();
  37045. lineTo(x, y);
  37046. if (stack.length === 0) {
  37047. break;
  37048. }
  37049. x += stack.shift();
  37050. lineTo(x, y);
  37051. }
  37052. break;
  37053. case 8:
  37054. while (stack.length > 0) {
  37055. xa = x + stack.shift();
  37056. ya = y + stack.shift();
  37057. xb = xa + stack.shift();
  37058. yb = ya + stack.shift();
  37059. x = xb + stack.shift();
  37060. y = yb + stack.shift();
  37061. bezierCurveTo(xa, ya, xb, yb, x, y);
  37062. }
  37063. break;
  37064. case 10:
  37065. n = stack.pop() + font.subrsBias;
  37066. subrCode = font.subrs[n];
  37067. if (subrCode) {
  37068. parse(subrCode);
  37069. }
  37070. break;
  37071. case 11:
  37072. return;
  37073. case 12:
  37074. v = code[i++];
  37075. switch (v) {
  37076. case 34:
  37077. xa = x + stack.shift();
  37078. xb = xa + stack.shift();
  37079. y1 = y + stack.shift();
  37080. x = xb + stack.shift();
  37081. bezierCurveTo(xa, y, xb, y1, x, y1);
  37082. xa = x + stack.shift();
  37083. xb = xa + stack.shift();
  37084. x = xb + stack.shift();
  37085. bezierCurveTo(xa, y1, xb, y, x, y);
  37086. break;
  37087. case 35:
  37088. xa = x + stack.shift();
  37089. ya = y + stack.shift();
  37090. xb = xa + stack.shift();
  37091. yb = ya + stack.shift();
  37092. x = xb + stack.shift();
  37093. y = yb + stack.shift();
  37094. bezierCurveTo(xa, ya, xb, yb, x, y);
  37095. xa = x + stack.shift();
  37096. ya = y + stack.shift();
  37097. xb = xa + stack.shift();
  37098. yb = ya + stack.shift();
  37099. x = xb + stack.shift();
  37100. y = yb + stack.shift();
  37101. bezierCurveTo(xa, ya, xb, yb, x, y);
  37102. stack.pop();
  37103. break;
  37104. case 36:
  37105. xa = x + stack.shift();
  37106. y1 = y + stack.shift();
  37107. xb = xa + stack.shift();
  37108. y2 = y1 + stack.shift();
  37109. x = xb + stack.shift();
  37110. bezierCurveTo(xa, y1, xb, y2, x, y2);
  37111. xa = x + stack.shift();
  37112. xb = xa + stack.shift();
  37113. y3 = y2 + stack.shift();
  37114. x = xb + stack.shift();
  37115. bezierCurveTo(xa, y2, xb, y3, x, y);
  37116. break;
  37117. case 37:
  37118. var x0 = x, y0 = y;
  37119. xa = x + stack.shift();
  37120. ya = y + stack.shift();
  37121. xb = xa + stack.shift();
  37122. yb = ya + stack.shift();
  37123. x = xb + stack.shift();
  37124. y = yb + stack.shift();
  37125. bezierCurveTo(xa, ya, xb, yb, x, y);
  37126. xa = x + stack.shift();
  37127. ya = y + stack.shift();
  37128. xb = xa + stack.shift();
  37129. yb = ya + stack.shift();
  37130. x = xb;
  37131. y = yb;
  37132. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  37133. x += stack.shift();
  37134. } else {
  37135. y += stack.shift();
  37136. }
  37137. bezierCurveTo(xa, ya, xb, yb, x, y);
  37138. break;
  37139. default:
  37140. error('unknown operator: 12 ' + v);
  37141. }
  37142. break;
  37143. case 14:
  37144. if (stack.length >= 4) {
  37145. var achar = stack.pop();
  37146. var bchar = stack.pop();
  37147. y = stack.pop();
  37148. x = stack.pop();
  37149. cmds.push({ cmd: 'save' });
  37150. cmds.push({
  37151. cmd: 'translate',
  37152. args: [
  37153. x,
  37154. y
  37155. ]
  37156. });
  37157. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  37158. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  37159. cmds.push({ cmd: 'restore' });
  37160. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  37161. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  37162. }
  37163. return;
  37164. case 18:
  37165. stems += stack.length >> 1;
  37166. stackClean = true;
  37167. break;
  37168. case 19:
  37169. stems += stack.length >> 1;
  37170. i += stems + 7 >> 3;
  37171. stackClean = true;
  37172. break;
  37173. case 20:
  37174. stems += stack.length >> 1;
  37175. i += stems + 7 >> 3;
  37176. stackClean = true;
  37177. break;
  37178. case 21:
  37179. y += stack.pop();
  37180. x += stack.pop();
  37181. moveTo(x, y);
  37182. stackClean = true;
  37183. break;
  37184. case 22:
  37185. x += stack.pop();
  37186. moveTo(x, y);
  37187. stackClean = true;
  37188. break;
  37189. case 23:
  37190. stems += stack.length >> 1;
  37191. stackClean = true;
  37192. break;
  37193. case 24:
  37194. while (stack.length > 2) {
  37195. xa = x + stack.shift();
  37196. ya = y + stack.shift();
  37197. xb = xa + stack.shift();
  37198. yb = ya + stack.shift();
  37199. x = xb + stack.shift();
  37200. y = yb + stack.shift();
  37201. bezierCurveTo(xa, ya, xb, yb, x, y);
  37202. }
  37203. x += stack.shift();
  37204. y += stack.shift();
  37205. lineTo(x, y);
  37206. break;
  37207. case 25:
  37208. while (stack.length > 6) {
  37209. x += stack.shift();
  37210. y += stack.shift();
  37211. lineTo(x, y);
  37212. }
  37213. xa = x + stack.shift();
  37214. ya = y + stack.shift();
  37215. xb = xa + stack.shift();
  37216. yb = ya + stack.shift();
  37217. x = xb + stack.shift();
  37218. y = yb + stack.shift();
  37219. bezierCurveTo(xa, ya, xb, yb, x, y);
  37220. break;
  37221. case 26:
  37222. if (stack.length % 2) {
  37223. x += stack.shift();
  37224. }
  37225. while (stack.length > 0) {
  37226. xa = x;
  37227. ya = y + stack.shift();
  37228. xb = xa + stack.shift();
  37229. yb = ya + stack.shift();
  37230. x = xb;
  37231. y = yb + stack.shift();
  37232. bezierCurveTo(xa, ya, xb, yb, x, y);
  37233. }
  37234. break;
  37235. case 27:
  37236. if (stack.length % 2) {
  37237. y += stack.shift();
  37238. }
  37239. while (stack.length > 0) {
  37240. xa = x + stack.shift();
  37241. ya = y;
  37242. xb = xa + stack.shift();
  37243. yb = ya + stack.shift();
  37244. x = xb + stack.shift();
  37245. y = yb;
  37246. bezierCurveTo(xa, ya, xb, yb, x, y);
  37247. }
  37248. break;
  37249. case 28:
  37250. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37251. i += 2;
  37252. break;
  37253. case 29:
  37254. n = stack.pop() + font.gsubrsBias;
  37255. subrCode = font.gsubrs[n];
  37256. if (subrCode) {
  37257. parse(subrCode);
  37258. }
  37259. break;
  37260. case 30:
  37261. while (stack.length > 0) {
  37262. xa = x;
  37263. ya = y + stack.shift();
  37264. xb = xa + stack.shift();
  37265. yb = ya + stack.shift();
  37266. x = xb + stack.shift();
  37267. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37268. bezierCurveTo(xa, ya, xb, yb, x, y);
  37269. if (stack.length === 0) {
  37270. break;
  37271. }
  37272. xa = x + stack.shift();
  37273. ya = y;
  37274. xb = xa + stack.shift();
  37275. yb = ya + stack.shift();
  37276. y = yb + stack.shift();
  37277. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37278. bezierCurveTo(xa, ya, xb, yb, x, y);
  37279. }
  37280. break;
  37281. case 31:
  37282. while (stack.length > 0) {
  37283. xa = x + stack.shift();
  37284. ya = y;
  37285. xb = xa + stack.shift();
  37286. yb = ya + stack.shift();
  37287. y = yb + stack.shift();
  37288. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37289. bezierCurveTo(xa, ya, xb, yb, x, y);
  37290. if (stack.length === 0) {
  37291. break;
  37292. }
  37293. xa = x;
  37294. ya = y + stack.shift();
  37295. xb = xa + stack.shift();
  37296. yb = ya + stack.shift();
  37297. x = xb + stack.shift();
  37298. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37299. bezierCurveTo(xa, ya, xb, yb, x, y);
  37300. }
  37301. break;
  37302. default:
  37303. if (v < 32) {
  37304. error('unknown operator: ' + v);
  37305. }
  37306. if (v < 247) {
  37307. stack.push(v - 139);
  37308. } else if (v < 251) {
  37309. stack.push((v - 247) * 256 + code[i++] + 108);
  37310. } else if (v < 255) {
  37311. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37312. } else {
  37313. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37314. i += 4;
  37315. }
  37316. break;
  37317. }
  37318. if (stackClean) {
  37319. stack.length = 0;
  37320. }
  37321. }
  37322. }
  37323. parse(code);
  37324. }
  37325. var noop = '';
  37326. function CompiledFont(fontMatrix) {
  37327. this.compiledGlyphs = Object.create(null);
  37328. this.compiledCharCodeToGlyphId = Object.create(null);
  37329. this.fontMatrix = fontMatrix;
  37330. }
  37331. CompiledFont.prototype = {
  37332. getPathJs: function (unicode) {
  37333. var cmap = lookupCmap(this.cmap, unicode);
  37334. var fn = this.compiledGlyphs[cmap.glyphId];
  37335. if (!fn) {
  37336. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37337. this.compiledGlyphs[cmap.glyphId] = fn;
  37338. }
  37339. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37340. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37341. }
  37342. return fn;
  37343. },
  37344. compileGlyph: function (code) {
  37345. if (!code || code.length === 0 || code[0] === 14) {
  37346. return noop;
  37347. }
  37348. var cmds = [];
  37349. cmds.push({ cmd: 'save' });
  37350. cmds.push({
  37351. cmd: 'transform',
  37352. args: this.fontMatrix.slice()
  37353. });
  37354. cmds.push({
  37355. cmd: 'scale',
  37356. args: [
  37357. 'size',
  37358. '-size'
  37359. ]
  37360. });
  37361. this.compileGlyphImpl(code, cmds);
  37362. cmds.push({ cmd: 'restore' });
  37363. return cmds;
  37364. },
  37365. compileGlyphImpl: function () {
  37366. error('Children classes should implement this.');
  37367. },
  37368. hasBuiltPath: function (unicode) {
  37369. var cmap = lookupCmap(this.cmap, unicode);
  37370. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37371. }
  37372. };
  37373. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37374. fontMatrix = fontMatrix || [
  37375. 0.000488,
  37376. 0,
  37377. 0,
  37378. 0.000488,
  37379. 0,
  37380. 0
  37381. ];
  37382. CompiledFont.call(this, fontMatrix);
  37383. this.glyphs = glyphs;
  37384. this.cmap = cmap;
  37385. }
  37386. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37387. compileGlyphImpl: function (code, cmds) {
  37388. compileGlyf(code, cmds, this);
  37389. }
  37390. });
  37391. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37392. fontMatrix = fontMatrix || [
  37393. 0.001,
  37394. 0,
  37395. 0,
  37396. 0.001,
  37397. 0,
  37398. 0
  37399. ];
  37400. CompiledFont.call(this, fontMatrix);
  37401. this.glyphs = cffInfo.glyphs;
  37402. this.gsubrs = cffInfo.gsubrs || [];
  37403. this.subrs = cffInfo.subrs || [];
  37404. this.cmap = cmap;
  37405. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37406. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37407. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37408. }
  37409. Util.inherit(Type2Compiled, CompiledFont, {
  37410. compileGlyphImpl: function (code, cmds) {
  37411. compileCharString(code, cmds, this);
  37412. }
  37413. });
  37414. return {
  37415. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37416. var data = new Uint8Array(font.data);
  37417. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37418. var numTables = getUshort(data, 4);
  37419. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37420. var tag = bytesToString(data.subarray(p, p + 4));
  37421. var offset = getLong(data, p + 8);
  37422. var length = getLong(data, p + 12);
  37423. switch (tag) {
  37424. case 'cmap':
  37425. cmap = parseCmap(data, offset, offset + length);
  37426. break;
  37427. case 'glyf':
  37428. glyf = data.subarray(offset, offset + length);
  37429. break;
  37430. case 'loca':
  37431. loca = data.subarray(offset, offset + length);
  37432. break;
  37433. case 'head':
  37434. unitsPerEm = getUshort(data, offset + 18);
  37435. indexToLocFormat = getUshort(data, offset + 50);
  37436. break;
  37437. case 'CFF ':
  37438. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37439. break;
  37440. }
  37441. }
  37442. if (glyf) {
  37443. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37444. 1 / unitsPerEm,
  37445. 0,
  37446. 0,
  37447. 1 / unitsPerEm,
  37448. 0,
  37449. 0
  37450. ];
  37451. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37452. } else {
  37453. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37454. }
  37455. }
  37456. };
  37457. }();
  37458. exports.FontRendererFactory = FontRendererFactory;
  37459. }));
  37460. (function (root, factory) {
  37461. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37462. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37463. var MissingDataException = sharedUtil.MissingDataException;
  37464. var StreamType = sharedUtil.StreamType;
  37465. var assert = sharedUtil.assert;
  37466. var error = sharedUtil.error;
  37467. var info = sharedUtil.info;
  37468. var isArray = sharedUtil.isArray;
  37469. var isInt = sharedUtil.isInt;
  37470. var isNum = sharedUtil.isNum;
  37471. var isString = sharedUtil.isString;
  37472. var warn = sharedUtil.warn;
  37473. var Cmd = corePrimitives.Cmd;
  37474. var Dict = corePrimitives.Dict;
  37475. var Name = corePrimitives.Name;
  37476. var Ref = corePrimitives.Ref;
  37477. var isCmd = corePrimitives.isCmd;
  37478. var isDict = corePrimitives.isDict;
  37479. var isName = corePrimitives.isName;
  37480. var Ascii85Stream = coreStream.Ascii85Stream;
  37481. var AsciiHexStream = coreStream.AsciiHexStream;
  37482. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37483. var FlateStream = coreStream.FlateStream;
  37484. var Jbig2Stream = coreStream.Jbig2Stream;
  37485. var JpegStream = coreStream.JpegStream;
  37486. var JpxStream = coreStream.JpxStream;
  37487. var LZWStream = coreStream.LZWStream;
  37488. var NullStream = coreStream.NullStream;
  37489. var PredictorStream = coreStream.PredictorStream;
  37490. var RunLengthStream = coreStream.RunLengthStream;
  37491. var EOF = {};
  37492. function isEOF(v) {
  37493. return v === EOF;
  37494. }
  37495. var MAX_LENGTH_TO_CACHE = 1000;
  37496. var Parser = function ParserClosure() {
  37497. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37498. this.lexer = lexer;
  37499. this.allowStreams = allowStreams;
  37500. this.xref = xref;
  37501. this.recoveryMode = recoveryMode || false;
  37502. this.imageCache = Object.create(null);
  37503. this.refill();
  37504. }
  37505. Parser.prototype = {
  37506. refill: function Parser_refill() {
  37507. this.buf1 = this.lexer.getObj();
  37508. this.buf2 = this.lexer.getObj();
  37509. },
  37510. shift: function Parser_shift() {
  37511. if (isCmd(this.buf2, 'ID')) {
  37512. this.buf1 = this.buf2;
  37513. this.buf2 = null;
  37514. } else {
  37515. this.buf1 = this.buf2;
  37516. this.buf2 = this.lexer.getObj();
  37517. }
  37518. },
  37519. tryShift: function Parser_tryShift() {
  37520. try {
  37521. this.shift();
  37522. return true;
  37523. } catch (e) {
  37524. if (e instanceof MissingDataException) {
  37525. throw e;
  37526. }
  37527. return false;
  37528. }
  37529. },
  37530. getObj: function Parser_getObj(cipherTransform) {
  37531. var buf1 = this.buf1;
  37532. this.shift();
  37533. if (buf1 instanceof Cmd) {
  37534. switch (buf1.cmd) {
  37535. case 'BI':
  37536. return this.makeInlineImage(cipherTransform);
  37537. case '[':
  37538. var array = [];
  37539. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37540. array.push(this.getObj(cipherTransform));
  37541. }
  37542. if (isEOF(this.buf1)) {
  37543. if (!this.recoveryMode) {
  37544. error('End of file inside array');
  37545. }
  37546. return array;
  37547. }
  37548. this.shift();
  37549. return array;
  37550. case '<<':
  37551. var dict = new Dict(this.xref);
  37552. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37553. if (!isName(this.buf1)) {
  37554. info('Malformed dictionary: key must be a name object');
  37555. this.shift();
  37556. continue;
  37557. }
  37558. var key = this.buf1.name;
  37559. this.shift();
  37560. if (isEOF(this.buf1)) {
  37561. break;
  37562. }
  37563. dict.set(key, this.getObj(cipherTransform));
  37564. }
  37565. if (isEOF(this.buf1)) {
  37566. if (!this.recoveryMode) {
  37567. error('End of file inside dictionary');
  37568. }
  37569. return dict;
  37570. }
  37571. if (isCmd(this.buf2, 'stream')) {
  37572. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37573. }
  37574. this.shift();
  37575. return dict;
  37576. default:
  37577. return buf1;
  37578. }
  37579. }
  37580. if (isInt(buf1)) {
  37581. var num = buf1;
  37582. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37583. var ref = new Ref(num, this.buf1);
  37584. this.shift();
  37585. this.shift();
  37586. return ref;
  37587. }
  37588. return num;
  37589. }
  37590. if (isString(buf1)) {
  37591. var str = buf1;
  37592. if (cipherTransform) {
  37593. str = cipherTransform.decryptString(str);
  37594. }
  37595. return str;
  37596. }
  37597. return buf1;
  37598. },
  37599. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37600. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37601. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37602. while ((ch = stream.getByte()) !== -1) {
  37603. if (state === 0) {
  37604. state = ch === E ? 1 : 0;
  37605. } else if (state === 1) {
  37606. state = ch === I ? 2 : 0;
  37607. } else {
  37608. assert(state === 2);
  37609. if (ch === SPACE || ch === LF || ch === CR) {
  37610. n = 5;
  37611. followingBytes = stream.peekBytes(n);
  37612. for (i = 0; i < n; i++) {
  37613. ch = followingBytes[i];
  37614. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37615. state = 0;
  37616. break;
  37617. }
  37618. }
  37619. if (state === 2) {
  37620. break;
  37621. }
  37622. } else
  37623. {
  37624. state = 0;
  37625. }
  37626. }
  37627. }
  37628. return stream.pos - 4 - startPos;
  37629. },
  37630. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37631. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37632. while ((b = stream.getByte()) !== -1) {
  37633. if (b !== 0xFF) {
  37634. continue;
  37635. }
  37636. switch (stream.getByte()) {
  37637. case 0x00:
  37638. break;
  37639. case 0xFF:
  37640. stream.skip(-1);
  37641. break;
  37642. case 0xD9:
  37643. foundEOI = true;
  37644. break;
  37645. case 0xC0:
  37646. case 0xC1:
  37647. case 0xC2:
  37648. case 0xC3:
  37649. case 0xC5:
  37650. case 0xC6:
  37651. case 0xC7:
  37652. case 0xC9:
  37653. case 0xCA:
  37654. case 0xCB:
  37655. case 0xCD:
  37656. case 0xCE:
  37657. case 0xCF:
  37658. case 0xC4:
  37659. case 0xCC:
  37660. case 0xDA:
  37661. case 0xDB:
  37662. case 0xDC:
  37663. case 0xDD:
  37664. case 0xDE:
  37665. case 0xDF:
  37666. case 0xE0:
  37667. case 0xE1:
  37668. case 0xE2:
  37669. case 0xE3:
  37670. case 0xE4:
  37671. case 0xE5:
  37672. case 0xE6:
  37673. case 0xE7:
  37674. case 0xE8:
  37675. case 0xE9:
  37676. case 0xEA:
  37677. case 0xEB:
  37678. case 0xEC:
  37679. case 0xED:
  37680. case 0xEE:
  37681. case 0xEF:
  37682. case 0xFE:
  37683. markerLength = stream.getUint16();
  37684. if (markerLength > 2) {
  37685. stream.skip(markerLength - 2);
  37686. } else
  37687. {
  37688. stream.skip(-2);
  37689. }
  37690. break;
  37691. }
  37692. if (foundEOI) {
  37693. break;
  37694. }
  37695. }
  37696. length = stream.pos - startPos;
  37697. if (b === -1) {
  37698. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37699. stream.skip(-length);
  37700. return this.findDefaultInlineStreamEnd(stream);
  37701. }
  37702. this.inlineStreamSkipEI(stream);
  37703. return length;
  37704. },
  37705. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37706. var TILDE = 0x7E, GT = 0x3E;
  37707. var startPos = stream.pos, ch, length;
  37708. while ((ch = stream.getByte()) !== -1) {
  37709. if (ch === TILDE && stream.peekByte() === GT) {
  37710. stream.skip();
  37711. break;
  37712. }
  37713. }
  37714. length = stream.pos - startPos;
  37715. if (ch === -1) {
  37716. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37717. stream.skip(-length);
  37718. return this.findDefaultInlineStreamEnd(stream);
  37719. }
  37720. this.inlineStreamSkipEI(stream);
  37721. return length;
  37722. },
  37723. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37724. var GT = 0x3E;
  37725. var startPos = stream.pos, ch, length;
  37726. while ((ch = stream.getByte()) !== -1) {
  37727. if (ch === GT) {
  37728. break;
  37729. }
  37730. }
  37731. length = stream.pos - startPos;
  37732. if (ch === -1) {
  37733. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37734. stream.skip(-length);
  37735. return this.findDefaultInlineStreamEnd(stream);
  37736. }
  37737. this.inlineStreamSkipEI(stream);
  37738. return length;
  37739. },
  37740. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37741. var E = 0x45, I = 0x49;
  37742. var state = 0, ch;
  37743. while ((ch = stream.getByte()) !== -1) {
  37744. if (state === 0) {
  37745. state = ch === E ? 1 : 0;
  37746. } else if (state === 1) {
  37747. state = ch === I ? 2 : 0;
  37748. } else if (state === 2) {
  37749. break;
  37750. }
  37751. }
  37752. },
  37753. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37754. var lexer = this.lexer;
  37755. var stream = lexer.stream;
  37756. var dict = new Dict(this.xref);
  37757. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37758. if (!isName(this.buf1)) {
  37759. error('Dictionary key must be a name object');
  37760. }
  37761. var key = this.buf1.name;
  37762. this.shift();
  37763. if (isEOF(this.buf1)) {
  37764. break;
  37765. }
  37766. dict.set(key, this.getObj(cipherTransform));
  37767. }
  37768. var filter = dict.get('Filter', 'F'), filterName;
  37769. if (isName(filter)) {
  37770. filterName = filter.name;
  37771. } else if (isArray(filter)) {
  37772. var filterZero = this.xref.fetchIfRef(filter[0]);
  37773. if (isName(filterZero)) {
  37774. filterName = filterZero.name;
  37775. }
  37776. }
  37777. var startPos = stream.pos, length, i, ii;
  37778. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37779. length = this.findDCTDecodeInlineStreamEnd(stream);
  37780. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37781. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37782. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37783. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37784. } else {
  37785. length = this.findDefaultInlineStreamEnd(stream);
  37786. }
  37787. var imageStream = stream.makeSubStream(startPos, length, dict);
  37788. var adler32;
  37789. if (length < MAX_LENGTH_TO_CACHE) {
  37790. var imageBytes = imageStream.getBytes();
  37791. imageStream.reset();
  37792. var a = 1;
  37793. var b = 0;
  37794. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37795. a += imageBytes[i] & 0xff;
  37796. b += a;
  37797. }
  37798. adler32 = b % 65521 << 16 | a % 65521;
  37799. if (this.imageCache.adler32 === adler32) {
  37800. this.buf2 = Cmd.get('EI');
  37801. this.shift();
  37802. this.imageCache[adler32].reset();
  37803. return this.imageCache[adler32];
  37804. }
  37805. }
  37806. if (cipherTransform) {
  37807. imageStream = cipherTransform.createStream(imageStream, length);
  37808. }
  37809. imageStream = this.filter(imageStream, dict, length);
  37810. imageStream.dict = dict;
  37811. if (adler32 !== undefined) {
  37812. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37813. this.imageCache[adler32] = imageStream;
  37814. }
  37815. this.buf2 = Cmd.get('EI');
  37816. this.shift();
  37817. return imageStream;
  37818. },
  37819. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37820. var lexer = this.lexer;
  37821. var stream = lexer.stream;
  37822. lexer.skipToNextLine();
  37823. var pos = stream.pos - 1;
  37824. var length = dict.get('Length');
  37825. if (!isInt(length)) {
  37826. info('Bad ' + length + ' attribute in stream');
  37827. length = 0;
  37828. }
  37829. stream.pos = pos + length;
  37830. lexer.nextChar();
  37831. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37832. this.shift();
  37833. } else
  37834. {
  37835. stream.pos = pos;
  37836. var SCAN_BLOCK_SIZE = 2048;
  37837. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37838. var ENDSTREAM_SIGNATURE = [
  37839. 0x65,
  37840. 0x6E,
  37841. 0x64,
  37842. 0x73,
  37843. 0x74,
  37844. 0x72,
  37845. 0x65,
  37846. 0x61,
  37847. 0x6D
  37848. ];
  37849. var skipped = 0, found = false, i, j;
  37850. while (stream.pos < stream.end) {
  37851. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37852. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37853. if (scanLength <= 0) {
  37854. break;
  37855. }
  37856. found = false;
  37857. i = 0;
  37858. while (i < scanLength) {
  37859. j = 0;
  37860. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37861. j++;
  37862. }
  37863. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37864. found = true;
  37865. break;
  37866. }
  37867. i++;
  37868. }
  37869. if (found) {
  37870. skipped += i;
  37871. stream.pos += i;
  37872. break;
  37873. }
  37874. skipped += scanLength;
  37875. stream.pos += scanLength;
  37876. }
  37877. if (!found) {
  37878. error('Missing endstream');
  37879. }
  37880. length = skipped;
  37881. lexer.nextChar();
  37882. this.shift();
  37883. this.shift();
  37884. }
  37885. this.shift();
  37886. stream = stream.makeSubStream(pos, length, dict);
  37887. if (cipherTransform) {
  37888. stream = cipherTransform.createStream(stream, length);
  37889. }
  37890. stream = this.filter(stream, dict, length);
  37891. stream.dict = dict;
  37892. return stream;
  37893. },
  37894. filter: function Parser_filter(stream, dict, length) {
  37895. var filter = dict.get('Filter', 'F');
  37896. var params = dict.get('DecodeParms', 'DP');
  37897. if (isName(filter)) {
  37898. if (isArray(params)) {
  37899. params = this.xref.fetchIfRef(params[0]);
  37900. }
  37901. return this.makeFilter(stream, filter.name, length, params);
  37902. }
  37903. var maybeLength = length;
  37904. if (isArray(filter)) {
  37905. var filterArray = filter;
  37906. var paramsArray = params;
  37907. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37908. filter = this.xref.fetchIfRef(filterArray[i]);
  37909. if (!isName(filter)) {
  37910. error('Bad filter name: ' + filter);
  37911. }
  37912. params = null;
  37913. if (isArray(paramsArray) && i in paramsArray) {
  37914. params = this.xref.fetchIfRef(paramsArray[i]);
  37915. }
  37916. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37917. maybeLength = null;
  37918. }
  37919. }
  37920. return stream;
  37921. },
  37922. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37923. if (maybeLength === 0) {
  37924. warn('Empty "' + name + '" stream.');
  37925. return new NullStream(stream);
  37926. }
  37927. try {
  37928. var xrefStreamStats = this.xref.stats.streamTypes;
  37929. if (name === 'FlateDecode' || name === 'Fl') {
  37930. xrefStreamStats[StreamType.FLATE] = true;
  37931. if (params) {
  37932. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37933. }
  37934. return new FlateStream(stream, maybeLength);
  37935. }
  37936. if (name === 'LZWDecode' || name === 'LZW') {
  37937. xrefStreamStats[StreamType.LZW] = true;
  37938. var earlyChange = 1;
  37939. if (params) {
  37940. if (params.has('EarlyChange')) {
  37941. earlyChange = params.get('EarlyChange');
  37942. }
  37943. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37944. }
  37945. return new LZWStream(stream, maybeLength, earlyChange);
  37946. }
  37947. if (name === 'DCTDecode' || name === 'DCT') {
  37948. xrefStreamStats[StreamType.DCT] = true;
  37949. return new JpegStream(stream, maybeLength, stream.dict, params);
  37950. }
  37951. if (name === 'JPXDecode' || name === 'JPX') {
  37952. xrefStreamStats[StreamType.JPX] = true;
  37953. return new JpxStream(stream, maybeLength, stream.dict, params);
  37954. }
  37955. if (name === 'ASCII85Decode' || name === 'A85') {
  37956. xrefStreamStats[StreamType.A85] = true;
  37957. return new Ascii85Stream(stream, maybeLength);
  37958. }
  37959. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37960. xrefStreamStats[StreamType.AHX] = true;
  37961. return new AsciiHexStream(stream, maybeLength);
  37962. }
  37963. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37964. xrefStreamStats[StreamType.CCF] = true;
  37965. return new CCITTFaxStream(stream, maybeLength, params);
  37966. }
  37967. if (name === 'RunLengthDecode' || name === 'RL') {
  37968. xrefStreamStats[StreamType.RL] = true;
  37969. return new RunLengthStream(stream, maybeLength);
  37970. }
  37971. if (name === 'JBIG2Decode') {
  37972. xrefStreamStats[StreamType.JBIG] = true;
  37973. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37974. }
  37975. warn('filter "' + name + '" not supported yet');
  37976. return stream;
  37977. } catch (ex) {
  37978. if (ex instanceof MissingDataException) {
  37979. throw ex;
  37980. }
  37981. warn('Invalid stream: \"' + ex + '\"');
  37982. return new NullStream(stream);
  37983. }
  37984. }
  37985. };
  37986. return Parser;
  37987. }();
  37988. var Lexer = function LexerClosure() {
  37989. function Lexer(stream, knownCommands) {
  37990. this.stream = stream;
  37991. this.nextChar();
  37992. this.strBuf = [];
  37993. this.knownCommands = knownCommands;
  37994. }
  37995. var specialChars = [
  37996. 1,
  37997. 0,
  37998. 0,
  37999. 0,
  38000. 0,
  38001. 0,
  38002. 0,
  38003. 0,
  38004. 0,
  38005. 1,
  38006. 1,
  38007. 0,
  38008. 1,
  38009. 1,
  38010. 0,
  38011. 0,
  38012. 0,
  38013. 0,
  38014. 0,
  38015. 0,
  38016. 0,
  38017. 0,
  38018. 0,
  38019. 0,
  38020. 0,
  38021. 0,
  38022. 0,
  38023. 0,
  38024. 0,
  38025. 0,
  38026. 0,
  38027. 0,
  38028. 1,
  38029. 0,
  38030. 0,
  38031. 0,
  38032. 0,
  38033. 2,
  38034. 0,
  38035. 0,
  38036. 2,
  38037. 2,
  38038. 0,
  38039. 0,
  38040. 0,
  38041. 0,
  38042. 0,
  38043. 2,
  38044. 0,
  38045. 0,
  38046. 0,
  38047. 0,
  38048. 0,
  38049. 0,
  38050. 0,
  38051. 0,
  38052. 0,
  38053. 0,
  38054. 0,
  38055. 0,
  38056. 2,
  38057. 0,
  38058. 2,
  38059. 0,
  38060. 0,
  38061. 0,
  38062. 0,
  38063. 0,
  38064. 0,
  38065. 0,
  38066. 0,
  38067. 0,
  38068. 0,
  38069. 0,
  38070. 0,
  38071. 0,
  38072. 0,
  38073. 0,
  38074. 0,
  38075. 0,
  38076. 0,
  38077. 0,
  38078. 0,
  38079. 0,
  38080. 0,
  38081. 0,
  38082. 0,
  38083. 0,
  38084. 0,
  38085. 0,
  38086. 0,
  38087. 2,
  38088. 0,
  38089. 2,
  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. 0,
  38118. 0,
  38119. 2,
  38120. 0,
  38121. 2,
  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. 0,
  38251. 0
  38252. ];
  38253. function toHexDigit(ch) {
  38254. if (ch >= 0x30 && ch <= 0x39) {
  38255. return ch & 0x0F;
  38256. }
  38257. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38258. return (ch & 0x0F) + 9;
  38259. }
  38260. return -1;
  38261. }
  38262. Lexer.prototype = {
  38263. nextChar: function Lexer_nextChar() {
  38264. return this.currentChar = this.stream.getByte();
  38265. },
  38266. peekChar: function Lexer_peekChar() {
  38267. return this.stream.peekByte();
  38268. },
  38269. getNumber: function Lexer_getNumber() {
  38270. var ch = this.currentChar;
  38271. var eNotation = false;
  38272. var divideBy = 0;
  38273. var sign = 1;
  38274. if (ch === 0x2D) {
  38275. sign = -1;
  38276. ch = this.nextChar();
  38277. if (ch === 0x2D) {
  38278. ch = this.nextChar();
  38279. }
  38280. } else if (ch === 0x2B) {
  38281. ch = this.nextChar();
  38282. }
  38283. if (ch === 0x2E) {
  38284. divideBy = 10;
  38285. ch = this.nextChar();
  38286. }
  38287. if (ch < 0x30 || ch > 0x39) {
  38288. error('Invalid number: ' + String.fromCharCode(ch));
  38289. return 0;
  38290. }
  38291. var baseValue = ch - 0x30;
  38292. var powerValue = 0;
  38293. var powerValueSign = 1;
  38294. while ((ch = this.nextChar()) >= 0) {
  38295. if (0x30 <= ch && ch <= 0x39) {
  38296. var currentDigit = ch - 0x30;
  38297. if (eNotation) {
  38298. powerValue = powerValue * 10 + currentDigit;
  38299. } else {
  38300. if (divideBy !== 0) {
  38301. divideBy *= 10;
  38302. }
  38303. baseValue = baseValue * 10 + currentDigit;
  38304. }
  38305. } else if (ch === 0x2E) {
  38306. if (divideBy === 0) {
  38307. divideBy = 1;
  38308. } else {
  38309. break;
  38310. }
  38311. } else if (ch === 0x2D) {
  38312. warn('Badly formatted number');
  38313. } else if (ch === 0x45 || ch === 0x65) {
  38314. ch = this.peekChar();
  38315. if (ch === 0x2B || ch === 0x2D) {
  38316. powerValueSign = ch === 0x2D ? -1 : 1;
  38317. this.nextChar();
  38318. } else if (ch < 0x30 || ch > 0x39) {
  38319. break;
  38320. }
  38321. eNotation = true;
  38322. } else {
  38323. break;
  38324. }
  38325. }
  38326. if (divideBy !== 0) {
  38327. baseValue /= divideBy;
  38328. }
  38329. if (eNotation) {
  38330. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38331. }
  38332. return sign * baseValue;
  38333. },
  38334. getString: function Lexer_getString() {
  38335. var numParen = 1;
  38336. var done = false;
  38337. var strBuf = this.strBuf;
  38338. strBuf.length = 0;
  38339. var ch = this.nextChar();
  38340. while (true) {
  38341. var charBuffered = false;
  38342. switch (ch | 0) {
  38343. case -1:
  38344. warn('Unterminated string');
  38345. done = true;
  38346. break;
  38347. case 0x28:
  38348. ++numParen;
  38349. strBuf.push('(');
  38350. break;
  38351. case 0x29:
  38352. if (--numParen === 0) {
  38353. this.nextChar();
  38354. done = true;
  38355. } else {
  38356. strBuf.push(')');
  38357. }
  38358. break;
  38359. case 0x5C:
  38360. ch = this.nextChar();
  38361. switch (ch) {
  38362. case -1:
  38363. warn('Unterminated string');
  38364. done = true;
  38365. break;
  38366. case 0x6E:
  38367. strBuf.push('\n');
  38368. break;
  38369. case 0x72:
  38370. strBuf.push('\r');
  38371. break;
  38372. case 0x74:
  38373. strBuf.push('\t');
  38374. break;
  38375. case 0x62:
  38376. strBuf.push('\b');
  38377. break;
  38378. case 0x66:
  38379. strBuf.push('\f');
  38380. break;
  38381. case 0x5C:
  38382. case 0x28:
  38383. case 0x29:
  38384. strBuf.push(String.fromCharCode(ch));
  38385. break;
  38386. case 0x30:
  38387. case 0x31:
  38388. case 0x32:
  38389. case 0x33:
  38390. case 0x34:
  38391. case 0x35:
  38392. case 0x36:
  38393. case 0x37:
  38394. var x = ch & 0x0F;
  38395. ch = this.nextChar();
  38396. charBuffered = true;
  38397. if (ch >= 0x30 && ch <= 0x37) {
  38398. x = (x << 3) + (ch & 0x0F);
  38399. ch = this.nextChar();
  38400. if (ch >= 0x30 && ch <= 0x37) {
  38401. charBuffered = false;
  38402. x = (x << 3) + (ch & 0x0F);
  38403. }
  38404. }
  38405. strBuf.push(String.fromCharCode(x));
  38406. break;
  38407. case 0x0D:
  38408. if (this.peekChar() === 0x0A) {
  38409. this.nextChar();
  38410. }
  38411. break;
  38412. case 0x0A:
  38413. break;
  38414. default:
  38415. strBuf.push(String.fromCharCode(ch));
  38416. break;
  38417. }
  38418. break;
  38419. default:
  38420. strBuf.push(String.fromCharCode(ch));
  38421. break;
  38422. }
  38423. if (done) {
  38424. break;
  38425. }
  38426. if (!charBuffered) {
  38427. ch = this.nextChar();
  38428. }
  38429. }
  38430. return strBuf.join('');
  38431. },
  38432. getName: function Lexer_getName() {
  38433. var ch, previousCh;
  38434. var strBuf = this.strBuf;
  38435. strBuf.length = 0;
  38436. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38437. if (ch === 0x23) {
  38438. ch = this.nextChar();
  38439. if (specialChars[ch]) {
  38440. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38441. strBuf.push('#');
  38442. break;
  38443. }
  38444. var x = toHexDigit(ch);
  38445. if (x !== -1) {
  38446. previousCh = ch;
  38447. ch = this.nextChar();
  38448. var x2 = toHexDigit(ch);
  38449. if (x2 === -1) {
  38450. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38451. strBuf.push('#', String.fromCharCode(previousCh));
  38452. if (specialChars[ch]) {
  38453. break;
  38454. }
  38455. strBuf.push(String.fromCharCode(ch));
  38456. continue;
  38457. }
  38458. strBuf.push(String.fromCharCode(x << 4 | x2));
  38459. } else {
  38460. strBuf.push('#', String.fromCharCode(ch));
  38461. }
  38462. } else {
  38463. strBuf.push(String.fromCharCode(ch));
  38464. }
  38465. }
  38466. if (strBuf.length > 127) {
  38467. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38468. }
  38469. return Name.get(strBuf.join(''));
  38470. },
  38471. getHexString: function Lexer_getHexString() {
  38472. var strBuf = this.strBuf;
  38473. strBuf.length = 0;
  38474. var ch = this.currentChar;
  38475. var isFirstHex = true;
  38476. var firstDigit;
  38477. var secondDigit;
  38478. while (true) {
  38479. if (ch < 0) {
  38480. warn('Unterminated hex string');
  38481. break;
  38482. } else if (ch === 0x3E) {
  38483. this.nextChar();
  38484. break;
  38485. } else if (specialChars[ch] === 1) {
  38486. ch = this.nextChar();
  38487. continue;
  38488. } else {
  38489. if (isFirstHex) {
  38490. firstDigit = toHexDigit(ch);
  38491. if (firstDigit === -1) {
  38492. warn('Ignoring invalid character "' + ch + '" in hex string');
  38493. ch = this.nextChar();
  38494. continue;
  38495. }
  38496. } else {
  38497. secondDigit = toHexDigit(ch);
  38498. if (secondDigit === -1) {
  38499. warn('Ignoring invalid character "' + ch + '" in hex string');
  38500. ch = this.nextChar();
  38501. continue;
  38502. }
  38503. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38504. }
  38505. isFirstHex = !isFirstHex;
  38506. ch = this.nextChar();
  38507. }
  38508. }
  38509. return strBuf.join('');
  38510. },
  38511. getObj: function Lexer_getObj() {
  38512. var comment = false;
  38513. var ch = this.currentChar;
  38514. while (true) {
  38515. if (ch < 0) {
  38516. return EOF;
  38517. }
  38518. if (comment) {
  38519. if (ch === 0x0A || ch === 0x0D) {
  38520. comment = false;
  38521. }
  38522. } else if (ch === 0x25) {
  38523. comment = true;
  38524. } else if (specialChars[ch] !== 1) {
  38525. break;
  38526. }
  38527. ch = this.nextChar();
  38528. }
  38529. switch (ch | 0) {
  38530. case 0x30:
  38531. case 0x31:
  38532. case 0x32:
  38533. case 0x33:
  38534. case 0x34:
  38535. case 0x35:
  38536. case 0x36:
  38537. case 0x37:
  38538. case 0x38:
  38539. case 0x39:
  38540. case 0x2B:
  38541. case 0x2D:
  38542. case 0x2E:
  38543. return this.getNumber();
  38544. case 0x28:
  38545. return this.getString();
  38546. case 0x2F:
  38547. return this.getName();
  38548. case 0x5B:
  38549. this.nextChar();
  38550. return Cmd.get('[');
  38551. case 0x5D:
  38552. this.nextChar();
  38553. return Cmd.get(']');
  38554. case 0x3C:
  38555. ch = this.nextChar();
  38556. if (ch === 0x3C) {
  38557. this.nextChar();
  38558. return Cmd.get('<<');
  38559. }
  38560. return this.getHexString();
  38561. case 0x3E:
  38562. ch = this.nextChar();
  38563. if (ch === 0x3E) {
  38564. this.nextChar();
  38565. return Cmd.get('>>');
  38566. }
  38567. return Cmd.get('>');
  38568. case 0x7B:
  38569. this.nextChar();
  38570. return Cmd.get('{');
  38571. case 0x7D:
  38572. this.nextChar();
  38573. return Cmd.get('}');
  38574. case 0x29:
  38575. error('Illegal character: ' + ch);
  38576. break;
  38577. }
  38578. var str = String.fromCharCode(ch);
  38579. var knownCommands = this.knownCommands;
  38580. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38581. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38582. var possibleCommand = str + String.fromCharCode(ch);
  38583. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38584. break;
  38585. }
  38586. if (str.length === 128) {
  38587. error('Command token too long: ' + str.length);
  38588. }
  38589. str = possibleCommand;
  38590. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38591. }
  38592. if (str === 'true') {
  38593. return true;
  38594. }
  38595. if (str === 'false') {
  38596. return false;
  38597. }
  38598. if (str === 'null') {
  38599. return null;
  38600. }
  38601. return Cmd.get(str);
  38602. },
  38603. skipToNextLine: function Lexer_skipToNextLine() {
  38604. var ch = this.currentChar;
  38605. while (ch >= 0) {
  38606. if (ch === 0x0D) {
  38607. ch = this.nextChar();
  38608. if (ch === 0x0A) {
  38609. this.nextChar();
  38610. }
  38611. break;
  38612. } else if (ch === 0x0A) {
  38613. this.nextChar();
  38614. break;
  38615. }
  38616. ch = this.nextChar();
  38617. }
  38618. }
  38619. };
  38620. return Lexer;
  38621. }();
  38622. var Linearization = {
  38623. create: function LinearizationCreate(stream) {
  38624. function getInt(name, allowZeroValue) {
  38625. var obj = linDict.get(name);
  38626. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38627. return obj;
  38628. }
  38629. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38630. }
  38631. function getHints() {
  38632. var hints = linDict.get('H'), hintsLength, item;
  38633. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38634. for (var index = 0; index < hintsLength; index++) {
  38635. if (!(isInt(item = hints[index]) && item > 0)) {
  38636. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38637. }
  38638. }
  38639. return hints;
  38640. }
  38641. throw new Error('Hint array in the linearization dictionary is invalid.');
  38642. }
  38643. var parser = new Parser(new Lexer(stream), false, null);
  38644. var obj1 = parser.getObj();
  38645. var obj2 = parser.getObj();
  38646. var obj3 = parser.getObj();
  38647. var linDict = parser.getObj();
  38648. var obj, length;
  38649. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38650. return null;
  38651. } else if ((length = getInt('L')) !== stream.length) {
  38652. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38653. }
  38654. return {
  38655. length: length,
  38656. hints: getHints(),
  38657. objectNumberFirst: getInt('O'),
  38658. endFirst: getInt('E'),
  38659. numPages: getInt('N'),
  38660. mainXRefEntriesOffset: getInt('T'),
  38661. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38662. };
  38663. }
  38664. };
  38665. exports.EOF = EOF;
  38666. exports.Lexer = Lexer;
  38667. exports.Linearization = Linearization;
  38668. exports.Parser = Parser;
  38669. exports.isEOF = isEOF;
  38670. }));
  38671. (function (root, factory) {
  38672. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38673. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38674. var warn = sharedUtil.warn;
  38675. var isSpace = sharedUtil.isSpace;
  38676. var Stream = coreStream.Stream;
  38677. var getEncoding = coreEncodings.getEncoding;
  38678. var HINTING_ENABLED = false;
  38679. var Type1CharString = function Type1CharStringClosure() {
  38680. var COMMAND_MAP = {
  38681. 'hstem': [1],
  38682. 'vstem': [3],
  38683. 'vmoveto': [4],
  38684. 'rlineto': [5],
  38685. 'hlineto': [6],
  38686. 'vlineto': [7],
  38687. 'rrcurveto': [8],
  38688. 'callsubr': [10],
  38689. 'flex': [
  38690. 12,
  38691. 35
  38692. ],
  38693. 'drop': [
  38694. 12,
  38695. 18
  38696. ],
  38697. 'endchar': [14],
  38698. 'rmoveto': [21],
  38699. 'hmoveto': [22],
  38700. 'vhcurveto': [30],
  38701. 'hvcurveto': [31]
  38702. };
  38703. function Type1CharString() {
  38704. this.width = 0;
  38705. this.lsb = 0;
  38706. this.flexing = false;
  38707. this.output = [];
  38708. this.stack = [];
  38709. }
  38710. Type1CharString.prototype = {
  38711. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38712. var count = encoded.length;
  38713. var error = false;
  38714. var wx, sbx, subrNumber;
  38715. for (var i = 0; i < count; i++) {
  38716. var value = encoded[i];
  38717. if (value < 32) {
  38718. if (value === 12) {
  38719. value = (value << 8) + encoded[++i];
  38720. }
  38721. switch (value) {
  38722. case 1:
  38723. if (!HINTING_ENABLED) {
  38724. this.stack = [];
  38725. break;
  38726. }
  38727. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38728. break;
  38729. case 3:
  38730. if (!HINTING_ENABLED) {
  38731. this.stack = [];
  38732. break;
  38733. }
  38734. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38735. break;
  38736. case 4:
  38737. if (this.flexing) {
  38738. if (this.stack.length < 1) {
  38739. error = true;
  38740. break;
  38741. }
  38742. var dy = this.stack.pop();
  38743. this.stack.push(0, dy);
  38744. break;
  38745. }
  38746. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38747. break;
  38748. case 5:
  38749. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38750. break;
  38751. case 6:
  38752. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38753. break;
  38754. case 7:
  38755. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38756. break;
  38757. case 8:
  38758. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38759. break;
  38760. case 9:
  38761. this.stack = [];
  38762. break;
  38763. case 10:
  38764. if (this.stack.length < 1) {
  38765. error = true;
  38766. break;
  38767. }
  38768. subrNumber = this.stack.pop();
  38769. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38770. break;
  38771. case 11:
  38772. return error;
  38773. case 13:
  38774. if (this.stack.length < 2) {
  38775. error = true;
  38776. break;
  38777. }
  38778. wx = this.stack.pop();
  38779. sbx = this.stack.pop();
  38780. this.lsb = sbx;
  38781. this.width = wx;
  38782. this.stack.push(wx, sbx);
  38783. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38784. break;
  38785. case 14:
  38786. this.output.push(COMMAND_MAP.endchar[0]);
  38787. break;
  38788. case 21:
  38789. if (this.flexing) {
  38790. break;
  38791. }
  38792. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38793. break;
  38794. case 22:
  38795. if (this.flexing) {
  38796. this.stack.push(0);
  38797. break;
  38798. }
  38799. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38800. break;
  38801. case 30:
  38802. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38803. break;
  38804. case 31:
  38805. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38806. break;
  38807. case (12 << 8) + 0:
  38808. this.stack = [];
  38809. break;
  38810. case (12 << 8) + 1:
  38811. if (!HINTING_ENABLED) {
  38812. this.stack = [];
  38813. break;
  38814. }
  38815. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38816. break;
  38817. case (12 << 8) + 2:
  38818. if (!HINTING_ENABLED) {
  38819. this.stack = [];
  38820. break;
  38821. }
  38822. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38823. break;
  38824. case (12 << 8) + 6:
  38825. if (seacAnalysisEnabled) {
  38826. this.seac = this.stack.splice(-4, 4);
  38827. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38828. } else {
  38829. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38830. }
  38831. break;
  38832. case (12 << 8) + 7:
  38833. if (this.stack.length < 4) {
  38834. error = true;
  38835. break;
  38836. }
  38837. var wy = this.stack.pop();
  38838. wx = this.stack.pop();
  38839. var sby = this.stack.pop();
  38840. sbx = this.stack.pop();
  38841. this.lsb = sbx;
  38842. this.width = wx;
  38843. this.stack.push(wx, sbx, sby);
  38844. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38845. break;
  38846. case (12 << 8) + 12:
  38847. if (this.stack.length < 2) {
  38848. error = true;
  38849. break;
  38850. }
  38851. var num2 = this.stack.pop();
  38852. var num1 = this.stack.pop();
  38853. this.stack.push(num1 / num2);
  38854. break;
  38855. case (12 << 8) + 16:
  38856. if (this.stack.length < 2) {
  38857. error = true;
  38858. break;
  38859. }
  38860. subrNumber = this.stack.pop();
  38861. var numArgs = this.stack.pop();
  38862. if (subrNumber === 0 && numArgs === 3) {
  38863. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38864. 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]);
  38865. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38866. this.flexing = false;
  38867. this.stack.push(flexArgs[15], flexArgs[16]);
  38868. } else if (subrNumber === 1 && numArgs === 0) {
  38869. this.flexing = true;
  38870. }
  38871. break;
  38872. case (12 << 8) + 17:
  38873. break;
  38874. case (12 << 8) + 33:
  38875. this.stack = [];
  38876. break;
  38877. default:
  38878. warn('Unknown type 1 charstring command of "' + value + '"');
  38879. break;
  38880. }
  38881. if (error) {
  38882. break;
  38883. }
  38884. continue;
  38885. } else if (value <= 246) {
  38886. value = value - 139;
  38887. } else if (value <= 250) {
  38888. value = (value - 247) * 256 + encoded[++i] + 108;
  38889. } else if (value <= 254) {
  38890. value = -((value - 251) * 256) - encoded[++i] - 108;
  38891. } else {
  38892. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38893. }
  38894. this.stack.push(value);
  38895. }
  38896. return error;
  38897. },
  38898. executeCommand: function (howManyArgs, command, keepStack) {
  38899. var stackLength = this.stack.length;
  38900. if (howManyArgs > stackLength) {
  38901. return true;
  38902. }
  38903. var start = stackLength - howManyArgs;
  38904. for (var i = start; i < stackLength; i++) {
  38905. var value = this.stack[i];
  38906. if (value === (value | 0)) {
  38907. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38908. } else {
  38909. value = 65536 * value | 0;
  38910. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38911. }
  38912. }
  38913. this.output.push.apply(this.output, command);
  38914. if (keepStack) {
  38915. this.stack.splice(start, howManyArgs);
  38916. } else {
  38917. this.stack.length = 0;
  38918. }
  38919. return false;
  38920. }
  38921. };
  38922. return Type1CharString;
  38923. }();
  38924. var Type1Parser = function Type1ParserClosure() {
  38925. var EEXEC_ENCRYPT_KEY = 55665;
  38926. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38927. function isHexDigit(code) {
  38928. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38929. }
  38930. function decrypt(data, key, discardNumber) {
  38931. if (discardNumber >= data.length) {
  38932. return new Uint8Array(0);
  38933. }
  38934. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38935. for (i = 0; i < discardNumber; i++) {
  38936. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38937. }
  38938. var count = data.length - discardNumber;
  38939. var decrypted = new Uint8Array(count);
  38940. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38941. var value = data[i];
  38942. decrypted[j] = value ^ r >> 8;
  38943. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38944. }
  38945. return decrypted;
  38946. }
  38947. function decryptAscii(data, key, discardNumber) {
  38948. var r = key | 0, c1 = 52845, c2 = 22719;
  38949. var count = data.length, maybeLength = count >>> 1;
  38950. var decrypted = new Uint8Array(maybeLength);
  38951. var i, j;
  38952. for (i = 0, j = 0; i < count; i++) {
  38953. var digit1 = data[i];
  38954. if (!isHexDigit(digit1)) {
  38955. continue;
  38956. }
  38957. i++;
  38958. var digit2;
  38959. while (i < count && !isHexDigit(digit2 = data[i])) {
  38960. i++;
  38961. }
  38962. if (i < count) {
  38963. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38964. decrypted[j++] = value ^ r >> 8;
  38965. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38966. }
  38967. }
  38968. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38969. }
  38970. function isSpecial(c) {
  38971. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38972. }
  38973. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38974. if (encrypted) {
  38975. var data = stream.getBytes();
  38976. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38977. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38978. }
  38979. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38980. this.stream = stream;
  38981. this.nextChar();
  38982. }
  38983. Type1Parser.prototype = {
  38984. readNumberArray: function Type1Parser_readNumberArray() {
  38985. this.getToken();
  38986. var array = [];
  38987. while (true) {
  38988. var token = this.getToken();
  38989. if (token === null || token === ']' || token === '}') {
  38990. break;
  38991. }
  38992. array.push(parseFloat(token || 0));
  38993. }
  38994. return array;
  38995. },
  38996. readNumber: function Type1Parser_readNumber() {
  38997. var token = this.getToken();
  38998. return parseFloat(token || 0);
  38999. },
  39000. readInt: function Type1Parser_readInt() {
  39001. var token = this.getToken();
  39002. return parseInt(token || 0, 10) | 0;
  39003. },
  39004. readBoolean: function Type1Parser_readBoolean() {
  39005. var token = this.getToken();
  39006. return token === 'true' ? 1 : 0;
  39007. },
  39008. nextChar: function Type1_nextChar() {
  39009. return this.currentChar = this.stream.getByte();
  39010. },
  39011. getToken: function Type1Parser_getToken() {
  39012. var comment = false;
  39013. var ch = this.currentChar;
  39014. while (true) {
  39015. if (ch === -1) {
  39016. return null;
  39017. }
  39018. if (comment) {
  39019. if (ch === 0x0A || ch === 0x0D) {
  39020. comment = false;
  39021. }
  39022. } else if (ch === 0x25) {
  39023. comment = true;
  39024. } else if (!isSpace(ch)) {
  39025. break;
  39026. }
  39027. ch = this.nextChar();
  39028. }
  39029. if (isSpecial(ch)) {
  39030. this.nextChar();
  39031. return String.fromCharCode(ch);
  39032. }
  39033. var token = '';
  39034. do {
  39035. token += String.fromCharCode(ch);
  39036. ch = this.nextChar();
  39037. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  39038. return token;
  39039. },
  39040. extractFontProgram: function Type1Parser_extractFontProgram() {
  39041. var stream = this.stream;
  39042. var subrs = [], charstrings = [];
  39043. var privateData = Object.create(null);
  39044. privateData['lenIV'] = 4;
  39045. var program = {
  39046. subrs: [],
  39047. charstrings: [],
  39048. properties: { 'privateData': privateData }
  39049. };
  39050. var token, length, data, lenIV, encoded;
  39051. while ((token = this.getToken()) !== null) {
  39052. if (token !== '/') {
  39053. continue;
  39054. }
  39055. token = this.getToken();
  39056. switch (token) {
  39057. case 'CharStrings':
  39058. this.getToken();
  39059. this.getToken();
  39060. this.getToken();
  39061. this.getToken();
  39062. while (true) {
  39063. token = this.getToken();
  39064. if (token === null || token === 'end') {
  39065. break;
  39066. }
  39067. if (token !== '/') {
  39068. continue;
  39069. }
  39070. var glyph = this.getToken();
  39071. length = this.readInt();
  39072. this.getToken();
  39073. data = stream.makeSubStream(stream.pos, length);
  39074. lenIV = program.properties.privateData['lenIV'];
  39075. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  39076. stream.skip(length);
  39077. this.nextChar();
  39078. token = this.getToken();
  39079. if (token === 'noaccess') {
  39080. this.getToken();
  39081. }
  39082. charstrings.push({
  39083. glyph: glyph,
  39084. encoded: encoded
  39085. });
  39086. }
  39087. break;
  39088. case 'Subrs':
  39089. var num = this.readInt();
  39090. this.getToken();
  39091. while ((token = this.getToken()) === 'dup') {
  39092. var index = this.readInt();
  39093. length = this.readInt();
  39094. this.getToken();
  39095. data = stream.makeSubStream(stream.pos, length);
  39096. lenIV = program.properties.privateData['lenIV'];
  39097. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  39098. stream.skip(length);
  39099. this.nextChar();
  39100. token = this.getToken();
  39101. if (token === 'noaccess') {
  39102. this.getToken();
  39103. }
  39104. subrs[index] = encoded;
  39105. }
  39106. break;
  39107. case 'BlueValues':
  39108. case 'OtherBlues':
  39109. case 'FamilyBlues':
  39110. case 'FamilyOtherBlues':
  39111. var blueArray = this.readNumberArray();
  39112. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  39113. program.properties.privateData[token] = blueArray;
  39114. }
  39115. break;
  39116. case 'StemSnapH':
  39117. case 'StemSnapV':
  39118. program.properties.privateData[token] = this.readNumberArray();
  39119. break;
  39120. case 'StdHW':
  39121. case 'StdVW':
  39122. program.properties.privateData[token] = this.readNumberArray()[0];
  39123. break;
  39124. case 'BlueShift':
  39125. case 'lenIV':
  39126. case 'BlueFuzz':
  39127. case 'BlueScale':
  39128. case 'LanguageGroup':
  39129. case 'ExpansionFactor':
  39130. program.properties.privateData[token] = this.readNumber();
  39131. break;
  39132. case 'ForceBold':
  39133. program.properties.privateData[token] = this.readBoolean();
  39134. break;
  39135. }
  39136. }
  39137. for (var i = 0; i < charstrings.length; i++) {
  39138. glyph = charstrings[i].glyph;
  39139. encoded = charstrings[i].encoded;
  39140. var charString = new Type1CharString();
  39141. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  39142. var output = charString.output;
  39143. if (error) {
  39144. output = [14];
  39145. }
  39146. program.charstrings.push({
  39147. glyphName: glyph,
  39148. charstring: output,
  39149. width: charString.width,
  39150. lsb: charString.lsb,
  39151. seac: charString.seac
  39152. });
  39153. }
  39154. return program;
  39155. },
  39156. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  39157. var token;
  39158. while ((token = this.getToken()) !== null) {
  39159. if (token !== '/') {
  39160. continue;
  39161. }
  39162. token = this.getToken();
  39163. switch (token) {
  39164. case 'FontMatrix':
  39165. var matrix = this.readNumberArray();
  39166. properties.fontMatrix = matrix;
  39167. break;
  39168. case 'Encoding':
  39169. var encodingArg = this.getToken();
  39170. var encoding;
  39171. if (!/^\d+$/.test(encodingArg)) {
  39172. encoding = getEncoding(encodingArg);
  39173. } else {
  39174. encoding = [];
  39175. var size = parseInt(encodingArg, 10) | 0;
  39176. this.getToken();
  39177. for (var j = 0; j < size; j++) {
  39178. token = this.getToken();
  39179. while (token !== 'dup' && token !== 'def') {
  39180. token = this.getToken();
  39181. if (token === null) {
  39182. return;
  39183. }
  39184. }
  39185. if (token === 'def') {
  39186. break;
  39187. }
  39188. var index = this.readInt();
  39189. this.getToken();
  39190. var glyph = this.getToken();
  39191. encoding[index] = glyph;
  39192. this.getToken();
  39193. }
  39194. }
  39195. properties.builtInEncoding = encoding;
  39196. break;
  39197. case 'FontBBox':
  39198. var fontBBox = this.readNumberArray();
  39199. properties.ascent = fontBBox[3];
  39200. properties.descent = fontBBox[1];
  39201. properties.ascentScaled = true;
  39202. break;
  39203. }
  39204. }
  39205. }
  39206. };
  39207. return Type1Parser;
  39208. }();
  39209. exports.Type1Parser = Type1Parser;
  39210. }));
  39211. (function (root, factory) {
  39212. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39213. }(this, function (exports, sharedUtil, displayWebGL) {
  39214. var Util = sharedUtil.Util;
  39215. var info = sharedUtil.info;
  39216. var isArray = sharedUtil.isArray;
  39217. var error = sharedUtil.error;
  39218. var WebGLUtils = displayWebGL.WebGLUtils;
  39219. var ShadingIRs = {};
  39220. ShadingIRs.RadialAxial = {
  39221. fromIR: function RadialAxial_fromIR(raw) {
  39222. var type = raw[1];
  39223. var colorStops = raw[2];
  39224. var p0 = raw[3];
  39225. var p1 = raw[4];
  39226. var r0 = raw[5];
  39227. var r1 = raw[6];
  39228. return {
  39229. type: 'Pattern',
  39230. getPattern: function RadialAxial_getPattern(ctx) {
  39231. var grad;
  39232. if (type === 'axial') {
  39233. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39234. } else if (type === 'radial') {
  39235. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39236. }
  39237. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39238. var c = colorStops[i];
  39239. grad.addColorStop(c[0], c[1]);
  39240. }
  39241. return grad;
  39242. }
  39243. };
  39244. }
  39245. };
  39246. var createMeshCanvas = function createMeshCanvasClosure() {
  39247. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39248. var coords = context.coords, colors = context.colors;
  39249. var bytes = data.data, rowSize = data.width * 4;
  39250. var tmp;
  39251. if (coords[p1 + 1] > coords[p2 + 1]) {
  39252. tmp = p1;
  39253. p1 = p2;
  39254. p2 = tmp;
  39255. tmp = c1;
  39256. c1 = c2;
  39257. c2 = tmp;
  39258. }
  39259. if (coords[p2 + 1] > coords[p3 + 1]) {
  39260. tmp = p2;
  39261. p2 = p3;
  39262. p3 = tmp;
  39263. tmp = c2;
  39264. c2 = c3;
  39265. c3 = tmp;
  39266. }
  39267. if (coords[p1 + 1] > coords[p2 + 1]) {
  39268. tmp = p1;
  39269. p1 = p2;
  39270. p2 = tmp;
  39271. tmp = c1;
  39272. c1 = c2;
  39273. c2 = tmp;
  39274. }
  39275. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39276. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39277. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39278. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39279. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39280. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39281. if (y1 >= y3) {
  39282. return;
  39283. }
  39284. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39285. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39286. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39287. var minY = Math.round(y1), maxY = Math.round(y3);
  39288. var xa, car, cag, cab;
  39289. var xb, cbr, cbg, cbb;
  39290. var k;
  39291. for (var y = minY; y <= maxY; y++) {
  39292. if (y < y2) {
  39293. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39294. xa = x1 - (x1 - x2) * k;
  39295. car = c1r - (c1r - c2r) * k;
  39296. cag = c1g - (c1g - c2g) * k;
  39297. cab = c1b - (c1b - c2b) * k;
  39298. } else {
  39299. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39300. xa = x2 - (x2 - x3) * k;
  39301. car = c2r - (c2r - c3r) * k;
  39302. cag = c2g - (c2g - c3g) * k;
  39303. cab = c2b - (c2b - c3b) * k;
  39304. }
  39305. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39306. xb = x1 - (x1 - x3) * k;
  39307. cbr = c1r - (c1r - c3r) * k;
  39308. cbg = c1g - (c1g - c3g) * k;
  39309. cbb = c1b - (c1b - c3b) * k;
  39310. var x1_ = Math.round(Math.min(xa, xb));
  39311. var x2_ = Math.round(Math.max(xa, xb));
  39312. var j = rowSize * y + x1_ * 4;
  39313. for (var x = x1_; x <= x2_; x++) {
  39314. k = (xa - x) / (xa - xb);
  39315. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39316. bytes[j++] = car - (car - cbr) * k | 0;
  39317. bytes[j++] = cag - (cag - cbg) * k | 0;
  39318. bytes[j++] = cab - (cab - cbb) * k | 0;
  39319. bytes[j++] = 255;
  39320. }
  39321. }
  39322. }
  39323. function drawFigure(data, figure, context) {
  39324. var ps = figure.coords;
  39325. var cs = figure.colors;
  39326. var i, ii;
  39327. switch (figure.type) {
  39328. case 'lattice':
  39329. var verticesPerRow = figure.verticesPerRow;
  39330. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39331. var cols = verticesPerRow - 1;
  39332. for (i = 0; i < rows; i++) {
  39333. var q = i * verticesPerRow;
  39334. for (var j = 0; j < cols; j++, q++) {
  39335. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39336. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39337. }
  39338. }
  39339. break;
  39340. case 'triangles':
  39341. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39342. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39343. }
  39344. break;
  39345. default:
  39346. error('illigal figure');
  39347. break;
  39348. }
  39349. }
  39350. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39351. var EXPECTED_SCALE = 1.1;
  39352. var MAX_PATTERN_SIZE = 3000;
  39353. var BORDER_SIZE = 2;
  39354. var offsetX = Math.floor(bounds[0]);
  39355. var offsetY = Math.floor(bounds[1]);
  39356. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39357. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39358. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39359. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39360. var scaleX = boundsWidth / width;
  39361. var scaleY = boundsHeight / height;
  39362. var context = {
  39363. coords: coords,
  39364. colors: colors,
  39365. offsetX: -offsetX,
  39366. offsetY: -offsetY,
  39367. scaleX: 1 / scaleX,
  39368. scaleY: 1 / scaleY
  39369. };
  39370. var paddedWidth = width + BORDER_SIZE * 2;
  39371. var paddedHeight = height + BORDER_SIZE * 2;
  39372. var canvas, tmpCanvas, i, ii;
  39373. if (WebGLUtils.isEnabled) {
  39374. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39375. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39376. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39377. canvas = tmpCanvas.canvas;
  39378. } else {
  39379. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39380. var tmpCtx = tmpCanvas.context;
  39381. var data = tmpCtx.createImageData(width, height);
  39382. if (backgroundColor) {
  39383. var bytes = data.data;
  39384. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39385. bytes[i] = backgroundColor[0];
  39386. bytes[i + 1] = backgroundColor[1];
  39387. bytes[i + 2] = backgroundColor[2];
  39388. bytes[i + 3] = 255;
  39389. }
  39390. }
  39391. for (i = 0; i < figures.length; i++) {
  39392. drawFigure(data, figures[i], context);
  39393. }
  39394. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39395. canvas = tmpCanvas.canvas;
  39396. }
  39397. return {
  39398. canvas: canvas,
  39399. offsetX: offsetX - BORDER_SIZE * scaleX,
  39400. offsetY: offsetY - BORDER_SIZE * scaleY,
  39401. scaleX: scaleX,
  39402. scaleY: scaleY
  39403. };
  39404. }
  39405. return createMeshCanvas;
  39406. }();
  39407. ShadingIRs.Mesh = {
  39408. fromIR: function Mesh_fromIR(raw) {
  39409. var coords = raw[2];
  39410. var colors = raw[3];
  39411. var figures = raw[4];
  39412. var bounds = raw[5];
  39413. var matrix = raw[6];
  39414. var background = raw[8];
  39415. return {
  39416. type: 'Pattern',
  39417. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39418. var scale;
  39419. if (shadingFill) {
  39420. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39421. } else {
  39422. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39423. if (matrix) {
  39424. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39425. scale = [
  39426. scale[0] * matrixScale[0],
  39427. scale[1] * matrixScale[1]
  39428. ];
  39429. }
  39430. }
  39431. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39432. if (!shadingFill) {
  39433. ctx.setTransform.apply(ctx, owner.baseTransform);
  39434. if (matrix) {
  39435. ctx.transform.apply(ctx, matrix);
  39436. }
  39437. }
  39438. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39439. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39440. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39441. }
  39442. };
  39443. }
  39444. };
  39445. ShadingIRs.Dummy = {
  39446. fromIR: function Dummy_fromIR() {
  39447. return {
  39448. type: 'Pattern',
  39449. getPattern: function Dummy_fromIR_getPattern() {
  39450. return 'hotpink';
  39451. }
  39452. };
  39453. }
  39454. };
  39455. function getShadingPatternFromIR(raw) {
  39456. var shadingIR = ShadingIRs[raw[0]];
  39457. if (!shadingIR) {
  39458. error('Unknown IR type: ' + raw[0]);
  39459. }
  39460. return shadingIR.fromIR(raw);
  39461. }
  39462. var TilingPattern = function TilingPatternClosure() {
  39463. var PaintType = {
  39464. COLORED: 1,
  39465. UNCOLORED: 2
  39466. };
  39467. var MAX_PATTERN_SIZE = 3000;
  39468. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39469. this.operatorList = IR[2];
  39470. this.matrix = IR[3] || [
  39471. 1,
  39472. 0,
  39473. 0,
  39474. 1,
  39475. 0,
  39476. 0
  39477. ];
  39478. this.bbox = IR[4];
  39479. this.xstep = IR[5];
  39480. this.ystep = IR[6];
  39481. this.paintType = IR[7];
  39482. this.tilingType = IR[8];
  39483. this.color = color;
  39484. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39485. this.baseTransform = baseTransform;
  39486. this.type = 'Pattern';
  39487. this.ctx = ctx;
  39488. }
  39489. TilingPattern.prototype = {
  39490. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39491. var operatorList = this.operatorList;
  39492. var bbox = this.bbox;
  39493. var xstep = this.xstep;
  39494. var ystep = this.ystep;
  39495. var paintType = this.paintType;
  39496. var tilingType = this.tilingType;
  39497. var color = this.color;
  39498. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39499. info('TilingType: ' + tilingType);
  39500. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39501. var topLeft = [
  39502. x0,
  39503. y0
  39504. ];
  39505. var botRight = [
  39506. x0 + xstep,
  39507. y0 + ystep
  39508. ];
  39509. var width = botRight[0] - topLeft[0];
  39510. var height = botRight[1] - topLeft[1];
  39511. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39512. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39513. var combinedScale = [
  39514. matrixScale[0] * curMatrixScale[0],
  39515. matrixScale[1] * curMatrixScale[1]
  39516. ];
  39517. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39518. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39519. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39520. var tmpCtx = tmpCanvas.context;
  39521. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39522. graphics.groupLevel = owner.groupLevel;
  39523. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39524. this.setScale(width, height, xstep, ystep);
  39525. this.transformToScale(graphics);
  39526. var tmpTranslate = [
  39527. 1,
  39528. 0,
  39529. 0,
  39530. 1,
  39531. -topLeft[0],
  39532. -topLeft[1]
  39533. ];
  39534. graphics.transform.apply(graphics, tmpTranslate);
  39535. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39536. graphics.executeOperatorList(operatorList);
  39537. return tmpCanvas.canvas;
  39538. },
  39539. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39540. this.scale = [
  39541. width / xstep,
  39542. height / ystep
  39543. ];
  39544. },
  39545. transformToScale: function TilingPattern_transformToScale(graphics) {
  39546. var scale = this.scale;
  39547. var tmpScale = [
  39548. scale[0],
  39549. 0,
  39550. 0,
  39551. scale[1],
  39552. 0,
  39553. 0
  39554. ];
  39555. graphics.transform.apply(graphics, tmpScale);
  39556. },
  39557. scaleToContext: function TilingPattern_scaleToContext() {
  39558. var scale = this.scale;
  39559. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39560. },
  39561. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39562. if (bbox && isArray(bbox) && bbox.length === 4) {
  39563. var bboxWidth = x1 - x0;
  39564. var bboxHeight = y1 - y0;
  39565. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39566. graphics.clip();
  39567. graphics.endPath();
  39568. }
  39569. },
  39570. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39571. switch (paintType) {
  39572. case PaintType.COLORED:
  39573. var ctx = this.ctx;
  39574. context.fillStyle = ctx.fillStyle;
  39575. context.strokeStyle = ctx.strokeStyle;
  39576. break;
  39577. case PaintType.UNCOLORED:
  39578. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39579. context.fillStyle = cssColor;
  39580. context.strokeStyle = cssColor;
  39581. break;
  39582. default:
  39583. error('Unsupported paint type: ' + paintType);
  39584. }
  39585. },
  39586. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39587. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39588. ctx = this.ctx;
  39589. ctx.setTransform.apply(ctx, this.baseTransform);
  39590. ctx.transform.apply(ctx, this.matrix);
  39591. this.scaleToContext();
  39592. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39593. }
  39594. };
  39595. return TilingPattern;
  39596. }();
  39597. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39598. exports.TilingPattern = TilingPattern;
  39599. }));
  39600. (function (root, factory) {
  39601. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39602. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39603. var Util = sharedUtil.Util;
  39604. var assert = sharedUtil.assert;
  39605. var warn = sharedUtil.warn;
  39606. var error = sharedUtil.error;
  39607. var isInt = sharedUtil.isInt;
  39608. var isString = sharedUtil.isString;
  39609. var MissingDataException = sharedUtil.MissingDataException;
  39610. var isName = corePrimitives.isName;
  39611. var isCmd = corePrimitives.isCmd;
  39612. var isStream = corePrimitives.isStream;
  39613. var StringStream = coreStream.StringStream;
  39614. var Lexer = coreParser.Lexer;
  39615. var isEOF = coreParser.isEOF;
  39616. var BUILT_IN_CMAPS = [
  39617. 'Adobe-GB1-UCS2',
  39618. 'Adobe-CNS1-UCS2',
  39619. 'Adobe-Japan1-UCS2',
  39620. 'Adobe-Korea1-UCS2',
  39621. '78-EUC-H',
  39622. '78-EUC-V',
  39623. '78-H',
  39624. '78-RKSJ-H',
  39625. '78-RKSJ-V',
  39626. '78-V',
  39627. '78ms-RKSJ-H',
  39628. '78ms-RKSJ-V',
  39629. '83pv-RKSJ-H',
  39630. '90ms-RKSJ-H',
  39631. '90ms-RKSJ-V',
  39632. '90msp-RKSJ-H',
  39633. '90msp-RKSJ-V',
  39634. '90pv-RKSJ-H',
  39635. '90pv-RKSJ-V',
  39636. 'Add-H',
  39637. 'Add-RKSJ-H',
  39638. 'Add-RKSJ-V',
  39639. 'Add-V',
  39640. 'Adobe-CNS1-0',
  39641. 'Adobe-CNS1-1',
  39642. 'Adobe-CNS1-2',
  39643. 'Adobe-CNS1-3',
  39644. 'Adobe-CNS1-4',
  39645. 'Adobe-CNS1-5',
  39646. 'Adobe-CNS1-6',
  39647. 'Adobe-GB1-0',
  39648. 'Adobe-GB1-1',
  39649. 'Adobe-GB1-2',
  39650. 'Adobe-GB1-3',
  39651. 'Adobe-GB1-4',
  39652. 'Adobe-GB1-5',
  39653. 'Adobe-Japan1-0',
  39654. 'Adobe-Japan1-1',
  39655. 'Adobe-Japan1-2',
  39656. 'Adobe-Japan1-3',
  39657. 'Adobe-Japan1-4',
  39658. 'Adobe-Japan1-5',
  39659. 'Adobe-Japan1-6',
  39660. 'Adobe-Korea1-0',
  39661. 'Adobe-Korea1-1',
  39662. 'Adobe-Korea1-2',
  39663. 'B5-H',
  39664. 'B5-V',
  39665. 'B5pc-H',
  39666. 'B5pc-V',
  39667. 'CNS-EUC-H',
  39668. 'CNS-EUC-V',
  39669. 'CNS1-H',
  39670. 'CNS1-V',
  39671. 'CNS2-H',
  39672. 'CNS2-V',
  39673. 'ETHK-B5-H',
  39674. 'ETHK-B5-V',
  39675. 'ETen-B5-H',
  39676. 'ETen-B5-V',
  39677. 'ETenms-B5-H',
  39678. 'ETenms-B5-V',
  39679. 'EUC-H',
  39680. 'EUC-V',
  39681. 'Ext-H',
  39682. 'Ext-RKSJ-H',
  39683. 'Ext-RKSJ-V',
  39684. 'Ext-V',
  39685. 'GB-EUC-H',
  39686. 'GB-EUC-V',
  39687. 'GB-H',
  39688. 'GB-V',
  39689. 'GBK-EUC-H',
  39690. 'GBK-EUC-V',
  39691. 'GBK2K-H',
  39692. 'GBK2K-V',
  39693. 'GBKp-EUC-H',
  39694. 'GBKp-EUC-V',
  39695. 'GBT-EUC-H',
  39696. 'GBT-EUC-V',
  39697. 'GBT-H',
  39698. 'GBT-V',
  39699. 'GBTpc-EUC-H',
  39700. 'GBTpc-EUC-V',
  39701. 'GBpc-EUC-H',
  39702. 'GBpc-EUC-V',
  39703. 'H',
  39704. 'HKdla-B5-H',
  39705. 'HKdla-B5-V',
  39706. 'HKdlb-B5-H',
  39707. 'HKdlb-B5-V',
  39708. 'HKgccs-B5-H',
  39709. 'HKgccs-B5-V',
  39710. 'HKm314-B5-H',
  39711. 'HKm314-B5-V',
  39712. 'HKm471-B5-H',
  39713. 'HKm471-B5-V',
  39714. 'HKscs-B5-H',
  39715. 'HKscs-B5-V',
  39716. 'Hankaku',
  39717. 'Hiragana',
  39718. 'KSC-EUC-H',
  39719. 'KSC-EUC-V',
  39720. 'KSC-H',
  39721. 'KSC-Johab-H',
  39722. 'KSC-Johab-V',
  39723. 'KSC-V',
  39724. 'KSCms-UHC-H',
  39725. 'KSCms-UHC-HW-H',
  39726. 'KSCms-UHC-HW-V',
  39727. 'KSCms-UHC-V',
  39728. 'KSCpc-EUC-H',
  39729. 'KSCpc-EUC-V',
  39730. 'Katakana',
  39731. 'NWP-H',
  39732. 'NWP-V',
  39733. 'RKSJ-H',
  39734. 'RKSJ-V',
  39735. 'Roman',
  39736. 'UniCNS-UCS2-H',
  39737. 'UniCNS-UCS2-V',
  39738. 'UniCNS-UTF16-H',
  39739. 'UniCNS-UTF16-V',
  39740. 'UniCNS-UTF32-H',
  39741. 'UniCNS-UTF32-V',
  39742. 'UniCNS-UTF8-H',
  39743. 'UniCNS-UTF8-V',
  39744. 'UniGB-UCS2-H',
  39745. 'UniGB-UCS2-V',
  39746. 'UniGB-UTF16-H',
  39747. 'UniGB-UTF16-V',
  39748. 'UniGB-UTF32-H',
  39749. 'UniGB-UTF32-V',
  39750. 'UniGB-UTF8-H',
  39751. 'UniGB-UTF8-V',
  39752. 'UniJIS-UCS2-H',
  39753. 'UniJIS-UCS2-HW-H',
  39754. 'UniJIS-UCS2-HW-V',
  39755. 'UniJIS-UCS2-V',
  39756. 'UniJIS-UTF16-H',
  39757. 'UniJIS-UTF16-V',
  39758. 'UniJIS-UTF32-H',
  39759. 'UniJIS-UTF32-V',
  39760. 'UniJIS-UTF8-H',
  39761. 'UniJIS-UTF8-V',
  39762. 'UniJIS2004-UTF16-H',
  39763. 'UniJIS2004-UTF16-V',
  39764. 'UniJIS2004-UTF32-H',
  39765. 'UniJIS2004-UTF32-V',
  39766. 'UniJIS2004-UTF8-H',
  39767. 'UniJIS2004-UTF8-V',
  39768. 'UniJISPro-UCS2-HW-V',
  39769. 'UniJISPro-UCS2-V',
  39770. 'UniJISPro-UTF8-V',
  39771. 'UniJISX0213-UTF32-H',
  39772. 'UniJISX0213-UTF32-V',
  39773. 'UniJISX02132004-UTF32-H',
  39774. 'UniJISX02132004-UTF32-V',
  39775. 'UniKS-UCS2-H',
  39776. 'UniKS-UCS2-V',
  39777. 'UniKS-UTF16-H',
  39778. 'UniKS-UTF16-V',
  39779. 'UniKS-UTF32-H',
  39780. 'UniKS-UTF32-V',
  39781. 'UniKS-UTF8-H',
  39782. 'UniKS-UTF8-V',
  39783. 'V',
  39784. 'WP-Symbol'
  39785. ];
  39786. var CMap = function CMapClosure() {
  39787. function CMap(builtInCMap) {
  39788. this.codespaceRanges = [
  39789. [],
  39790. [],
  39791. [],
  39792. []
  39793. ];
  39794. this.numCodespaceRanges = 0;
  39795. this._map = [];
  39796. this.name = '';
  39797. this.vertical = false;
  39798. this.useCMap = null;
  39799. this.builtInCMap = builtInCMap;
  39800. }
  39801. CMap.prototype = {
  39802. addCodespaceRange: function (n, low, high) {
  39803. this.codespaceRanges[n - 1].push(low, high);
  39804. this.numCodespaceRanges++;
  39805. },
  39806. mapCidRange: function (low, high, dstLow) {
  39807. while (low <= high) {
  39808. this._map[low++] = dstLow++;
  39809. }
  39810. },
  39811. mapBfRange: function (low, high, dstLow) {
  39812. var lastByte = dstLow.length - 1;
  39813. while (low <= high) {
  39814. this._map[low++] = dstLow;
  39815. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39816. }
  39817. },
  39818. mapBfRangeToArray: function (low, high, array) {
  39819. var i = 0, ii = array.length;
  39820. while (low <= high && i < ii) {
  39821. this._map[low] = array[i++];
  39822. ++low;
  39823. }
  39824. },
  39825. mapOne: function (src, dst) {
  39826. this._map[src] = dst;
  39827. },
  39828. lookup: function (code) {
  39829. return this._map[code];
  39830. },
  39831. contains: function (code) {
  39832. return this._map[code] !== undefined;
  39833. },
  39834. forEach: function (callback) {
  39835. var map = this._map;
  39836. var length = map.length;
  39837. var i;
  39838. if (length <= 0x10000) {
  39839. for (i = 0; i < length; i++) {
  39840. if (map[i] !== undefined) {
  39841. callback(i, map[i]);
  39842. }
  39843. }
  39844. } else {
  39845. for (i in this._map) {
  39846. callback(i, map[i]);
  39847. }
  39848. }
  39849. },
  39850. charCodeOf: function (value) {
  39851. return this._map.indexOf(value);
  39852. },
  39853. getMap: function () {
  39854. return this._map;
  39855. },
  39856. readCharCode: function (str, offset, out) {
  39857. var c = 0;
  39858. var codespaceRanges = this.codespaceRanges;
  39859. var codespaceRangesLen = this.codespaceRanges.length;
  39860. for (var n = 0; n < codespaceRangesLen; n++) {
  39861. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39862. var codespaceRange = codespaceRanges[n];
  39863. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39864. var low = codespaceRange[k++];
  39865. var high = codespaceRange[k++];
  39866. if (c >= low && c <= high) {
  39867. out.charcode = c;
  39868. out.length = n + 1;
  39869. return;
  39870. }
  39871. }
  39872. }
  39873. out.charcode = 0;
  39874. out.length = 1;
  39875. },
  39876. get length() {
  39877. return this._map.length;
  39878. },
  39879. get isIdentityCMap() {
  39880. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39881. return false;
  39882. }
  39883. if (this._map.length !== 0x10000) {
  39884. return false;
  39885. }
  39886. for (var i = 0; i < 0x10000; i++) {
  39887. if (this._map[i] !== i) {
  39888. return false;
  39889. }
  39890. }
  39891. return true;
  39892. }
  39893. };
  39894. return CMap;
  39895. }();
  39896. var IdentityCMap = function IdentityCMapClosure() {
  39897. function IdentityCMap(vertical, n) {
  39898. CMap.call(this);
  39899. this.vertical = vertical;
  39900. this.addCodespaceRange(n, 0, 0xffff);
  39901. }
  39902. Util.inherit(IdentityCMap, CMap, {});
  39903. IdentityCMap.prototype = {
  39904. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39905. mapCidRange: function (low, high, dstLow) {
  39906. error('should not call mapCidRange');
  39907. },
  39908. mapBfRange: function (low, high, dstLow) {
  39909. error('should not call mapBfRange');
  39910. },
  39911. mapBfRangeToArray: function (low, high, array) {
  39912. error('should not call mapBfRangeToArray');
  39913. },
  39914. mapOne: function (src, dst) {
  39915. error('should not call mapCidOne');
  39916. },
  39917. lookup: function (code) {
  39918. return isInt(code) && code <= 0xffff ? code : undefined;
  39919. },
  39920. contains: function (code) {
  39921. return isInt(code) && code <= 0xffff;
  39922. },
  39923. forEach: function (callback) {
  39924. for (var i = 0; i <= 0xffff; i++) {
  39925. callback(i, i);
  39926. }
  39927. },
  39928. charCodeOf: function (value) {
  39929. return isInt(value) && value <= 0xffff ? value : -1;
  39930. },
  39931. getMap: function () {
  39932. var map = new Array(0x10000);
  39933. for (var i = 0; i <= 0xffff; i++) {
  39934. map[i] = i;
  39935. }
  39936. return map;
  39937. },
  39938. readCharCode: CMap.prototype.readCharCode,
  39939. get length() {
  39940. return 0x10000;
  39941. },
  39942. get isIdentityCMap() {
  39943. error('should not access .isIdentityCMap');
  39944. }
  39945. };
  39946. return IdentityCMap;
  39947. }();
  39948. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39949. function fetchBinaryData(url) {
  39950. return new Promise(function (resolve, reject) {
  39951. var request = new XMLHttpRequest();
  39952. request.open('GET', url, true);
  39953. request.responseType = 'arraybuffer';
  39954. request.onreadystatechange = function () {
  39955. if (request.readyState === XMLHttpRequest.DONE) {
  39956. if (!request.response || request.status !== 200 && request.status !== 0) {
  39957. reject(new Error('Unable to get binary cMap at: ' + url));
  39958. } else {
  39959. resolve(new Uint8Array(request.response));
  39960. }
  39961. }
  39962. };
  39963. request.send(null);
  39964. });
  39965. }
  39966. function hexToInt(a, size) {
  39967. var n = 0;
  39968. for (var i = 0; i <= size; i++) {
  39969. n = n << 8 | a[i];
  39970. }
  39971. return n >>> 0;
  39972. }
  39973. function hexToStr(a, size) {
  39974. if (size === 1) {
  39975. return String.fromCharCode(a[0], a[1]);
  39976. }
  39977. if (size === 3) {
  39978. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39979. }
  39980. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39981. }
  39982. function addHex(a, b, size) {
  39983. var c = 0;
  39984. for (var i = size; i >= 0; i--) {
  39985. c += a[i] + b[i];
  39986. a[i] = c & 255;
  39987. c >>= 8;
  39988. }
  39989. }
  39990. function incHex(a, size) {
  39991. var c = 1;
  39992. for (var i = size; i >= 0 && c > 0; i--) {
  39993. c += a[i];
  39994. a[i] = c & 255;
  39995. c >>= 8;
  39996. }
  39997. }
  39998. var MAX_NUM_SIZE = 16;
  39999. var MAX_ENCODED_NUM_SIZE = 19;
  40000. function BinaryCMapStream(data) {
  40001. this.buffer = data;
  40002. this.pos = 0;
  40003. this.end = data.length;
  40004. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  40005. }
  40006. BinaryCMapStream.prototype = {
  40007. readByte: function () {
  40008. if (this.pos >= this.end) {
  40009. return -1;
  40010. }
  40011. return this.buffer[this.pos++];
  40012. },
  40013. readNumber: function () {
  40014. var n = 0;
  40015. var last;
  40016. do {
  40017. var b = this.readByte();
  40018. if (b < 0) {
  40019. error('unexpected EOF in bcmap');
  40020. }
  40021. last = !(b & 0x80);
  40022. n = n << 7 | b & 0x7F;
  40023. } while (!last);
  40024. return n;
  40025. },
  40026. readSigned: function () {
  40027. var n = this.readNumber();
  40028. return n & 1 ? ~(n >>> 1) : n >>> 1;
  40029. },
  40030. readHex: function (num, size) {
  40031. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  40032. this.pos += size + 1;
  40033. },
  40034. readHexNumber: function (num, size) {
  40035. var last;
  40036. var stack = this.tmpBuf, sp = 0;
  40037. do {
  40038. var b = this.readByte();
  40039. if (b < 0) {
  40040. error('unexpected EOF in bcmap');
  40041. }
  40042. last = !(b & 0x80);
  40043. stack[sp++] = b & 0x7F;
  40044. } while (!last);
  40045. var i = size, buffer = 0, bufferSize = 0;
  40046. while (i >= 0) {
  40047. while (bufferSize < 8 && stack.length > 0) {
  40048. buffer = stack[--sp] << bufferSize | buffer;
  40049. bufferSize += 7;
  40050. }
  40051. num[i] = buffer & 255;
  40052. i--;
  40053. buffer >>= 8;
  40054. bufferSize -= 8;
  40055. }
  40056. },
  40057. readHexSigned: function (num, size) {
  40058. this.readHexNumber(num, size);
  40059. var sign = num[size] & 1 ? 255 : 0;
  40060. var c = 0;
  40061. for (var i = 0; i <= size; i++) {
  40062. c = (c & 1) << 8 | num[i];
  40063. num[i] = c >> 1 ^ sign;
  40064. }
  40065. },
  40066. readString: function () {
  40067. var len = this.readNumber();
  40068. var s = '';
  40069. for (var i = 0; i < len; i++) {
  40070. s += String.fromCharCode(this.readNumber());
  40071. }
  40072. return s;
  40073. }
  40074. };
  40075. function processBinaryCMap(url, cMap, extend) {
  40076. return fetchBinaryData(url).then(function (data) {
  40077. var stream = new BinaryCMapStream(data);
  40078. var header = stream.readByte();
  40079. cMap.vertical = !!(header & 1);
  40080. var useCMap = null;
  40081. var start = new Uint8Array(MAX_NUM_SIZE);
  40082. var end = new Uint8Array(MAX_NUM_SIZE);
  40083. var char = new Uint8Array(MAX_NUM_SIZE);
  40084. var charCode = new Uint8Array(MAX_NUM_SIZE);
  40085. var tmp = new Uint8Array(MAX_NUM_SIZE);
  40086. var code;
  40087. var b;
  40088. while ((b = stream.readByte()) >= 0) {
  40089. var type = b >> 5;
  40090. if (type === 7) {
  40091. switch (b & 0x1F) {
  40092. case 0:
  40093. stream.readString();
  40094. break;
  40095. case 1:
  40096. useCMap = stream.readString();
  40097. break;
  40098. }
  40099. continue;
  40100. }
  40101. var sequence = !!(b & 0x10);
  40102. var dataSize = b & 15;
  40103. assert(dataSize + 1 <= MAX_NUM_SIZE);
  40104. var ucs2DataSize = 1;
  40105. var subitemsCount = stream.readNumber();
  40106. var i;
  40107. switch (type) {
  40108. case 0:
  40109. stream.readHex(start, dataSize);
  40110. stream.readHexNumber(end, dataSize);
  40111. addHex(end, start, dataSize);
  40112. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  40113. for (i = 1; i < subitemsCount; i++) {
  40114. incHex(end, dataSize);
  40115. stream.readHexNumber(start, dataSize);
  40116. addHex(start, end, dataSize);
  40117. stream.readHexNumber(end, dataSize);
  40118. addHex(end, start, dataSize);
  40119. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  40120. }
  40121. break;
  40122. case 1:
  40123. stream.readHex(start, dataSize);
  40124. stream.readHexNumber(end, dataSize);
  40125. addHex(end, start, dataSize);
  40126. code = stream.readNumber();
  40127. for (i = 1; i < subitemsCount; i++) {
  40128. incHex(end, dataSize);
  40129. stream.readHexNumber(start, dataSize);
  40130. addHex(start, end, dataSize);
  40131. stream.readHexNumber(end, dataSize);
  40132. addHex(end, start, dataSize);
  40133. code = stream.readNumber();
  40134. }
  40135. break;
  40136. case 2:
  40137. stream.readHex(char, dataSize);
  40138. code = stream.readNumber();
  40139. cMap.mapOne(hexToInt(char, dataSize), code);
  40140. for (i = 1; i < subitemsCount; i++) {
  40141. incHex(char, dataSize);
  40142. if (!sequence) {
  40143. stream.readHexNumber(tmp, dataSize);
  40144. addHex(char, tmp, dataSize);
  40145. }
  40146. code = stream.readSigned() + (code + 1);
  40147. cMap.mapOne(hexToInt(char, dataSize), code);
  40148. }
  40149. break;
  40150. case 3:
  40151. stream.readHex(start, dataSize);
  40152. stream.readHexNumber(end, dataSize);
  40153. addHex(end, start, dataSize);
  40154. code = stream.readNumber();
  40155. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  40156. for (i = 1; i < subitemsCount; i++) {
  40157. incHex(end, dataSize);
  40158. if (!sequence) {
  40159. stream.readHexNumber(start, dataSize);
  40160. addHex(start, end, dataSize);
  40161. } else {
  40162. start.set(end);
  40163. }
  40164. stream.readHexNumber(end, dataSize);
  40165. addHex(end, start, dataSize);
  40166. code = stream.readNumber();
  40167. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  40168. }
  40169. break;
  40170. case 4:
  40171. stream.readHex(char, ucs2DataSize);
  40172. stream.readHex(charCode, dataSize);
  40173. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40174. for (i = 1; i < subitemsCount; i++) {
  40175. incHex(char, ucs2DataSize);
  40176. if (!sequence) {
  40177. stream.readHexNumber(tmp, ucs2DataSize);
  40178. addHex(char, tmp, ucs2DataSize);
  40179. }
  40180. incHex(charCode, dataSize);
  40181. stream.readHexSigned(tmp, dataSize);
  40182. addHex(charCode, tmp, dataSize);
  40183. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40184. }
  40185. break;
  40186. case 5:
  40187. stream.readHex(start, ucs2DataSize);
  40188. stream.readHexNumber(end, ucs2DataSize);
  40189. addHex(end, start, ucs2DataSize);
  40190. stream.readHex(charCode, dataSize);
  40191. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40192. for (i = 1; i < subitemsCount; i++) {
  40193. incHex(end, ucs2DataSize);
  40194. if (!sequence) {
  40195. stream.readHexNumber(start, ucs2DataSize);
  40196. addHex(start, end, ucs2DataSize);
  40197. } else {
  40198. start.set(end);
  40199. }
  40200. stream.readHexNumber(end, ucs2DataSize);
  40201. addHex(end, start, ucs2DataSize);
  40202. stream.readHex(charCode, dataSize);
  40203. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40204. }
  40205. break;
  40206. default:
  40207. error('Unknown type: ' + type);
  40208. break;
  40209. }
  40210. }
  40211. if (useCMap) {
  40212. return extend(useCMap);
  40213. }
  40214. return cMap;
  40215. });
  40216. }
  40217. function BinaryCMapReader() {
  40218. }
  40219. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40220. return BinaryCMapReader;
  40221. }();
  40222. var CMapFactory = function CMapFactoryClosure() {
  40223. function strToInt(str) {
  40224. var a = 0;
  40225. for (var i = 0; i < str.length; i++) {
  40226. a = a << 8 | str.charCodeAt(i);
  40227. }
  40228. return a >>> 0;
  40229. }
  40230. function expectString(obj) {
  40231. if (!isString(obj)) {
  40232. error('Malformed CMap: expected string.');
  40233. }
  40234. }
  40235. function expectInt(obj) {
  40236. if (!isInt(obj)) {
  40237. error('Malformed CMap: expected int.');
  40238. }
  40239. }
  40240. function parseBfChar(cMap, lexer) {
  40241. while (true) {
  40242. var obj = lexer.getObj();
  40243. if (isEOF(obj)) {
  40244. break;
  40245. }
  40246. if (isCmd(obj, 'endbfchar')) {
  40247. return;
  40248. }
  40249. expectString(obj);
  40250. var src = strToInt(obj);
  40251. obj = lexer.getObj();
  40252. expectString(obj);
  40253. var dst = obj;
  40254. cMap.mapOne(src, dst);
  40255. }
  40256. }
  40257. function parseBfRange(cMap, lexer) {
  40258. while (true) {
  40259. var obj = lexer.getObj();
  40260. if (isEOF(obj)) {
  40261. break;
  40262. }
  40263. if (isCmd(obj, 'endbfrange')) {
  40264. return;
  40265. }
  40266. expectString(obj);
  40267. var low = strToInt(obj);
  40268. obj = lexer.getObj();
  40269. expectString(obj);
  40270. var high = strToInt(obj);
  40271. obj = lexer.getObj();
  40272. if (isInt(obj) || isString(obj)) {
  40273. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40274. cMap.mapBfRange(low, high, dstLow);
  40275. } else if (isCmd(obj, '[')) {
  40276. obj = lexer.getObj();
  40277. var array = [];
  40278. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40279. array.push(obj);
  40280. obj = lexer.getObj();
  40281. }
  40282. cMap.mapBfRangeToArray(low, high, array);
  40283. } else {
  40284. break;
  40285. }
  40286. }
  40287. error('Invalid bf range.');
  40288. }
  40289. function parseCidChar(cMap, lexer) {
  40290. while (true) {
  40291. var obj = lexer.getObj();
  40292. if (isEOF(obj)) {
  40293. break;
  40294. }
  40295. if (isCmd(obj, 'endcidchar')) {
  40296. return;
  40297. }
  40298. expectString(obj);
  40299. var src = strToInt(obj);
  40300. obj = lexer.getObj();
  40301. expectInt(obj);
  40302. var dst = obj;
  40303. cMap.mapOne(src, dst);
  40304. }
  40305. }
  40306. function parseCidRange(cMap, lexer) {
  40307. while (true) {
  40308. var obj = lexer.getObj();
  40309. if (isEOF(obj)) {
  40310. break;
  40311. }
  40312. if (isCmd(obj, 'endcidrange')) {
  40313. return;
  40314. }
  40315. expectString(obj);
  40316. var low = strToInt(obj);
  40317. obj = lexer.getObj();
  40318. expectString(obj);
  40319. var high = strToInt(obj);
  40320. obj = lexer.getObj();
  40321. expectInt(obj);
  40322. var dstLow = obj;
  40323. cMap.mapCidRange(low, high, dstLow);
  40324. }
  40325. }
  40326. function parseCodespaceRange(cMap, lexer) {
  40327. while (true) {
  40328. var obj = lexer.getObj();
  40329. if (isEOF(obj)) {
  40330. break;
  40331. }
  40332. if (isCmd(obj, 'endcodespacerange')) {
  40333. return;
  40334. }
  40335. if (!isString(obj)) {
  40336. break;
  40337. }
  40338. var low = strToInt(obj);
  40339. obj = lexer.getObj();
  40340. if (!isString(obj)) {
  40341. break;
  40342. }
  40343. var high = strToInt(obj);
  40344. cMap.addCodespaceRange(obj.length, low, high);
  40345. }
  40346. error('Invalid codespace range.');
  40347. }
  40348. function parseWMode(cMap, lexer) {
  40349. var obj = lexer.getObj();
  40350. if (isInt(obj)) {
  40351. cMap.vertical = !!obj;
  40352. }
  40353. }
  40354. function parseCMapName(cMap, lexer) {
  40355. var obj = lexer.getObj();
  40356. if (isName(obj) && isString(obj.name)) {
  40357. cMap.name = obj.name;
  40358. }
  40359. }
  40360. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40361. var previous;
  40362. var embededUseCMap;
  40363. objLoop:
  40364. while (true) {
  40365. try {
  40366. var obj = lexer.getObj();
  40367. if (isEOF(obj)) {
  40368. break;
  40369. } else if (isName(obj)) {
  40370. if (obj.name === 'WMode') {
  40371. parseWMode(cMap, lexer);
  40372. } else if (obj.name === 'CMapName') {
  40373. parseCMapName(cMap, lexer);
  40374. }
  40375. previous = obj;
  40376. } else if (isCmd(obj)) {
  40377. switch (obj.cmd) {
  40378. case 'endcmap':
  40379. break objLoop;
  40380. case 'usecmap':
  40381. if (isName(previous)) {
  40382. embededUseCMap = previous.name;
  40383. }
  40384. break;
  40385. case 'begincodespacerange':
  40386. parseCodespaceRange(cMap, lexer);
  40387. break;
  40388. case 'beginbfchar':
  40389. parseBfChar(cMap, lexer);
  40390. break;
  40391. case 'begincidchar':
  40392. parseCidChar(cMap, lexer);
  40393. break;
  40394. case 'beginbfrange':
  40395. parseBfRange(cMap, lexer);
  40396. break;
  40397. case 'begincidrange':
  40398. parseCidRange(cMap, lexer);
  40399. break;
  40400. }
  40401. }
  40402. } catch (ex) {
  40403. if (ex instanceof MissingDataException) {
  40404. throw ex;
  40405. }
  40406. warn('Invalid cMap data: ' + ex);
  40407. continue;
  40408. }
  40409. }
  40410. if (!useCMap && embededUseCMap) {
  40411. useCMap = embededUseCMap;
  40412. }
  40413. if (useCMap) {
  40414. return extendCMap(cMap, builtInCMapParams, useCMap);
  40415. }
  40416. return Promise.resolve(cMap);
  40417. }
  40418. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40419. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40420. cMap.useCMap = newCMap;
  40421. if (cMap.numCodespaceRanges === 0) {
  40422. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40423. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40424. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40425. }
  40426. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40427. }
  40428. cMap.useCMap.forEach(function (key, value) {
  40429. if (!cMap.contains(key)) {
  40430. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40431. }
  40432. });
  40433. return cMap;
  40434. });
  40435. }
  40436. function parseBinaryCMap(name, builtInCMapParams) {
  40437. var url = builtInCMapParams.url + name + '.bcmap';
  40438. var cMap = new CMap(true);
  40439. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40440. return extendCMap(cMap, builtInCMapParams, useCMap);
  40441. });
  40442. }
  40443. function createBuiltInCMap(name, builtInCMapParams) {
  40444. if (name === 'Identity-H') {
  40445. return Promise.resolve(new IdentityCMap(false, 2));
  40446. } else if (name === 'Identity-V') {
  40447. return Promise.resolve(new IdentityCMap(true, 2));
  40448. }
  40449. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40450. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40451. }
  40452. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40453. if (builtInCMapParams.packed) {
  40454. return parseBinaryCMap(name, builtInCMapParams);
  40455. }
  40456. return new Promise(function (resolve, reject) {
  40457. var url = builtInCMapParams.url + name;
  40458. var request = new XMLHttpRequest();
  40459. request.onreadystatechange = function () {
  40460. if (request.readyState === XMLHttpRequest.DONE) {
  40461. if (request.status === 200 || request.status === 0) {
  40462. var cMap = new CMap(true);
  40463. var lexer = new Lexer(new StringStream(request.responseText));
  40464. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40465. resolve(parsedCMap);
  40466. });
  40467. } else {
  40468. reject(new Error('Unable to get cMap at: ' + url));
  40469. }
  40470. }
  40471. };
  40472. request.open('GET', url, true);
  40473. request.send(null);
  40474. });
  40475. }
  40476. return {
  40477. create: function (encoding, builtInCMapParams, useCMap) {
  40478. if (isName(encoding)) {
  40479. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40480. } else if (isStream(encoding)) {
  40481. var cMap = new CMap();
  40482. var lexer = new Lexer(encoding);
  40483. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40484. if (parsedCMap.isIdentityCMap) {
  40485. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40486. }
  40487. return parsedCMap;
  40488. });
  40489. }
  40490. return Promise.reject(new Error('Encoding required.'));
  40491. }
  40492. };
  40493. }();
  40494. exports.CMap = CMap;
  40495. exports.CMapFactory = CMapFactory;
  40496. exports.IdentityCMap = IdentityCMap;
  40497. }));
  40498. (function (root, factory) {
  40499. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40500. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40501. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40502. var FontType = sharedUtil.FontType;
  40503. var assert = sharedUtil.assert;
  40504. var bytesToString = sharedUtil.bytesToString;
  40505. var error = sharedUtil.error;
  40506. var info = sharedUtil.info;
  40507. var isArray = sharedUtil.isArray;
  40508. var isInt = sharedUtil.isInt;
  40509. var isNum = sharedUtil.isNum;
  40510. var readUint32 = sharedUtil.readUint32;
  40511. var shadow = sharedUtil.shadow;
  40512. var string32 = sharedUtil.string32;
  40513. var warn = sharedUtil.warn;
  40514. var MissingDataException = sharedUtil.MissingDataException;
  40515. var isSpace = sharedUtil.isSpace;
  40516. var Stream = coreStream.Stream;
  40517. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40518. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40519. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40520. var StandardEncoding = coreEncodings.StandardEncoding;
  40521. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40522. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40523. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40524. var getEncoding = coreEncodings.getEncoding;
  40525. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40526. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40527. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40528. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40529. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40530. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40531. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40532. var Type1Parser = coreType1Parser.Type1Parser;
  40533. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40534. var CFFParser = coreCFFParser.CFFParser;
  40535. var CFFCompiler = coreCFFParser.CFFCompiler;
  40536. var CFF = coreCFFParser.CFF;
  40537. var CFFHeader = coreCFFParser.CFFHeader;
  40538. var CFFTopDict = coreCFFParser.CFFTopDict;
  40539. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40540. var CFFStrings = coreCFFParser.CFFStrings;
  40541. var CFFIndex = coreCFFParser.CFFIndex;
  40542. var CFFCharset = coreCFFParser.CFFCharset;
  40543. var PRIVATE_USE_OFFSET_START = 0xE000;
  40544. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40545. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40546. var PDF_GLYPH_SPACE_UNITS = 1000;
  40547. var SEAC_ANALYSIS_ENABLED = false;
  40548. var FontFlags = {
  40549. FixedPitch: 1,
  40550. Serif: 2,
  40551. Symbolic: 4,
  40552. Script: 8,
  40553. Nonsymbolic: 32,
  40554. Italic: 64,
  40555. AllCap: 65536,
  40556. SmallCap: 131072,
  40557. ForceBold: 262144
  40558. };
  40559. var MacStandardGlyphOrdering = [
  40560. '.notdef',
  40561. '.null',
  40562. 'nonmarkingreturn',
  40563. 'space',
  40564. 'exclam',
  40565. 'quotedbl',
  40566. 'numbersign',
  40567. 'dollar',
  40568. 'percent',
  40569. 'ampersand',
  40570. 'quotesingle',
  40571. 'parenleft',
  40572. 'parenright',
  40573. 'asterisk',
  40574. 'plus',
  40575. 'comma',
  40576. 'hyphen',
  40577. 'period',
  40578. 'slash',
  40579. 'zero',
  40580. 'one',
  40581. 'two',
  40582. 'three',
  40583. 'four',
  40584. 'five',
  40585. 'six',
  40586. 'seven',
  40587. 'eight',
  40588. 'nine',
  40589. 'colon',
  40590. 'semicolon',
  40591. 'less',
  40592. 'equal',
  40593. 'greater',
  40594. 'question',
  40595. 'at',
  40596. 'A',
  40597. 'B',
  40598. 'C',
  40599. 'D',
  40600. 'E',
  40601. 'F',
  40602. 'G',
  40603. 'H',
  40604. 'I',
  40605. 'J',
  40606. 'K',
  40607. 'L',
  40608. 'M',
  40609. 'N',
  40610. 'O',
  40611. 'P',
  40612. 'Q',
  40613. 'R',
  40614. 'S',
  40615. 'T',
  40616. 'U',
  40617. 'V',
  40618. 'W',
  40619. 'X',
  40620. 'Y',
  40621. 'Z',
  40622. 'bracketleft',
  40623. 'backslash',
  40624. 'bracketright',
  40625. 'asciicircum',
  40626. 'underscore',
  40627. 'grave',
  40628. 'a',
  40629. 'b',
  40630. 'c',
  40631. 'd',
  40632. 'e',
  40633. 'f',
  40634. 'g',
  40635. 'h',
  40636. 'i',
  40637. 'j',
  40638. 'k',
  40639. 'l',
  40640. 'm',
  40641. 'n',
  40642. 'o',
  40643. 'p',
  40644. 'q',
  40645. 'r',
  40646. 's',
  40647. 't',
  40648. 'u',
  40649. 'v',
  40650. 'w',
  40651. 'x',
  40652. 'y',
  40653. 'z',
  40654. 'braceleft',
  40655. 'bar',
  40656. 'braceright',
  40657. 'asciitilde',
  40658. 'Adieresis',
  40659. 'Aring',
  40660. 'Ccedilla',
  40661. 'Eacute',
  40662. 'Ntilde',
  40663. 'Odieresis',
  40664. 'Udieresis',
  40665. 'aacute',
  40666. 'agrave',
  40667. 'acircumflex',
  40668. 'adieresis',
  40669. 'atilde',
  40670. 'aring',
  40671. 'ccedilla',
  40672. 'eacute',
  40673. 'egrave',
  40674. 'ecircumflex',
  40675. 'edieresis',
  40676. 'iacute',
  40677. 'igrave',
  40678. 'icircumflex',
  40679. 'idieresis',
  40680. 'ntilde',
  40681. 'oacute',
  40682. 'ograve',
  40683. 'ocircumflex',
  40684. 'odieresis',
  40685. 'otilde',
  40686. 'uacute',
  40687. 'ugrave',
  40688. 'ucircumflex',
  40689. 'udieresis',
  40690. 'dagger',
  40691. 'degree',
  40692. 'cent',
  40693. 'sterling',
  40694. 'section',
  40695. 'bullet',
  40696. 'paragraph',
  40697. 'germandbls',
  40698. 'registered',
  40699. 'copyright',
  40700. 'trademark',
  40701. 'acute',
  40702. 'dieresis',
  40703. 'notequal',
  40704. 'AE',
  40705. 'Oslash',
  40706. 'infinity',
  40707. 'plusminus',
  40708. 'lessequal',
  40709. 'greaterequal',
  40710. 'yen',
  40711. 'mu',
  40712. 'partialdiff',
  40713. 'summation',
  40714. 'product',
  40715. 'pi',
  40716. 'integral',
  40717. 'ordfeminine',
  40718. 'ordmasculine',
  40719. 'Omega',
  40720. 'ae',
  40721. 'oslash',
  40722. 'questiondown',
  40723. 'exclamdown',
  40724. 'logicalnot',
  40725. 'radical',
  40726. 'florin',
  40727. 'approxequal',
  40728. 'Delta',
  40729. 'guillemotleft',
  40730. 'guillemotright',
  40731. 'ellipsis',
  40732. 'nonbreakingspace',
  40733. 'Agrave',
  40734. 'Atilde',
  40735. 'Otilde',
  40736. 'OE',
  40737. 'oe',
  40738. 'endash',
  40739. 'emdash',
  40740. 'quotedblleft',
  40741. 'quotedblright',
  40742. 'quoteleft',
  40743. 'quoteright',
  40744. 'divide',
  40745. 'lozenge',
  40746. 'ydieresis',
  40747. 'Ydieresis',
  40748. 'fraction',
  40749. 'currency',
  40750. 'guilsinglleft',
  40751. 'guilsinglright',
  40752. 'fi',
  40753. 'fl',
  40754. 'daggerdbl',
  40755. 'periodcentered',
  40756. 'quotesinglbase',
  40757. 'quotedblbase',
  40758. 'perthousand',
  40759. 'Acircumflex',
  40760. 'Ecircumflex',
  40761. 'Aacute',
  40762. 'Edieresis',
  40763. 'Egrave',
  40764. 'Iacute',
  40765. 'Icircumflex',
  40766. 'Idieresis',
  40767. 'Igrave',
  40768. 'Oacute',
  40769. 'Ocircumflex',
  40770. 'apple',
  40771. 'Ograve',
  40772. 'Uacute',
  40773. 'Ucircumflex',
  40774. 'Ugrave',
  40775. 'dotlessi',
  40776. 'circumflex',
  40777. 'tilde',
  40778. 'macron',
  40779. 'breve',
  40780. 'dotaccent',
  40781. 'ring',
  40782. 'cedilla',
  40783. 'hungarumlaut',
  40784. 'ogonek',
  40785. 'caron',
  40786. 'Lslash',
  40787. 'lslash',
  40788. 'Scaron',
  40789. 'scaron',
  40790. 'Zcaron',
  40791. 'zcaron',
  40792. 'brokenbar',
  40793. 'Eth',
  40794. 'eth',
  40795. 'Yacute',
  40796. 'yacute',
  40797. 'Thorn',
  40798. 'thorn',
  40799. 'minus',
  40800. 'multiply',
  40801. 'onesuperior',
  40802. 'twosuperior',
  40803. 'threesuperior',
  40804. 'onehalf',
  40805. 'onequarter',
  40806. 'threequarters',
  40807. 'franc',
  40808. 'Gbreve',
  40809. 'gbreve',
  40810. 'Idotaccent',
  40811. 'Scedilla',
  40812. 'scedilla',
  40813. 'Cacute',
  40814. 'cacute',
  40815. 'Ccaron',
  40816. 'ccaron',
  40817. 'dcroat'
  40818. ];
  40819. function adjustWidths(properties) {
  40820. if (!properties.fontMatrix) {
  40821. return;
  40822. }
  40823. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40824. return;
  40825. }
  40826. var scale = 0.001 / properties.fontMatrix[0];
  40827. var glyphsWidths = properties.widths;
  40828. for (var glyph in glyphsWidths) {
  40829. glyphsWidths[glyph] *= scale;
  40830. }
  40831. properties.defaultWidth *= scale;
  40832. }
  40833. function adjustToUnicode(properties, builtInEncoding) {
  40834. if (properties.hasIncludedToUnicodeMap) {
  40835. return;
  40836. }
  40837. if (properties.hasEncoding) {
  40838. return;
  40839. }
  40840. if (builtInEncoding === properties.defaultEncoding) {
  40841. return;
  40842. }
  40843. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40844. return;
  40845. }
  40846. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40847. for (var charCode in builtInEncoding) {
  40848. var glyphName = builtInEncoding[charCode];
  40849. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40850. if (unicode !== -1) {
  40851. toUnicode[charCode] = String.fromCharCode(unicode);
  40852. }
  40853. }
  40854. properties.toUnicode.amend(toUnicode);
  40855. }
  40856. function getFontType(type, subtype) {
  40857. switch (type) {
  40858. case 'Type1':
  40859. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40860. case 'CIDFontType0':
  40861. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40862. case 'OpenType':
  40863. return FontType.OPENTYPE;
  40864. case 'TrueType':
  40865. return FontType.TRUETYPE;
  40866. case 'CIDFontType2':
  40867. return FontType.CIDFONTTYPE2;
  40868. case 'MMType1':
  40869. return FontType.MMTYPE1;
  40870. case 'Type0':
  40871. return FontType.TYPE0;
  40872. default:
  40873. return FontType.UNKNOWN;
  40874. }
  40875. }
  40876. function recoverGlyphName(name, glyphsUnicodeMap) {
  40877. if (glyphsUnicodeMap[name] !== undefined) {
  40878. return name;
  40879. }
  40880. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40881. if (unicode !== -1) {
  40882. for (var key in glyphsUnicodeMap) {
  40883. if (glyphsUnicodeMap[key] === unicode) {
  40884. return key;
  40885. }
  40886. }
  40887. }
  40888. info('Unable to recover a standard glyph name for: ' + name);
  40889. return name;
  40890. }
  40891. var Glyph = function GlyphClosure() {
  40892. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40893. this.fontChar = fontChar;
  40894. this.unicode = unicode;
  40895. this.accent = accent;
  40896. this.width = width;
  40897. this.vmetric = vmetric;
  40898. this.operatorListId = operatorListId;
  40899. this.isSpace = isSpace;
  40900. this.isInFont = isInFont;
  40901. }
  40902. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40903. 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;
  40904. };
  40905. return Glyph;
  40906. }();
  40907. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40908. function ToUnicodeMap(cmap) {
  40909. this._map = cmap;
  40910. }
  40911. ToUnicodeMap.prototype = {
  40912. get length() {
  40913. return this._map.length;
  40914. },
  40915. forEach: function (callback) {
  40916. for (var charCode in this._map) {
  40917. callback(charCode, this._map[charCode].charCodeAt(0));
  40918. }
  40919. },
  40920. has: function (i) {
  40921. return this._map[i] !== undefined;
  40922. },
  40923. get: function (i) {
  40924. return this._map[i];
  40925. },
  40926. charCodeOf: function (v) {
  40927. return this._map.indexOf(v);
  40928. },
  40929. amend: function (map) {
  40930. for (var charCode in map) {
  40931. this._map[charCode] = map[charCode];
  40932. }
  40933. }
  40934. };
  40935. return ToUnicodeMap;
  40936. }();
  40937. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40938. function IdentityToUnicodeMap(firstChar, lastChar) {
  40939. this.firstChar = firstChar;
  40940. this.lastChar = lastChar;
  40941. }
  40942. IdentityToUnicodeMap.prototype = {
  40943. get length() {
  40944. return this.lastChar + 1 - this.firstChar;
  40945. },
  40946. forEach: function (callback) {
  40947. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40948. callback(i, i);
  40949. }
  40950. },
  40951. has: function (i) {
  40952. return this.firstChar <= i && i <= this.lastChar;
  40953. },
  40954. get: function (i) {
  40955. if (this.firstChar <= i && i <= this.lastChar) {
  40956. return String.fromCharCode(i);
  40957. }
  40958. return undefined;
  40959. },
  40960. charCodeOf: function (v) {
  40961. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40962. },
  40963. amend: function (map) {
  40964. error('Should not call amend()');
  40965. }
  40966. };
  40967. return IdentityToUnicodeMap;
  40968. }();
  40969. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40970. function writeInt16(dest, offset, num) {
  40971. dest[offset] = num >> 8 & 0xFF;
  40972. dest[offset + 1] = num & 0xFF;
  40973. }
  40974. function writeInt32(dest, offset, num) {
  40975. dest[offset] = num >> 24 & 0xFF;
  40976. dest[offset + 1] = num >> 16 & 0xFF;
  40977. dest[offset + 2] = num >> 8 & 0xFF;
  40978. dest[offset + 3] = num & 0xFF;
  40979. }
  40980. function writeData(dest, offset, data) {
  40981. var i, ii;
  40982. if (data instanceof Uint8Array) {
  40983. dest.set(data, offset);
  40984. } else if (typeof data === 'string') {
  40985. for (i = 0, ii = data.length; i < ii; i++) {
  40986. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40987. }
  40988. } else {
  40989. for (i = 0, ii = data.length; i < ii; i++) {
  40990. dest[offset++] = data[i] & 0xFF;
  40991. }
  40992. }
  40993. }
  40994. function OpenTypeFileBuilder(sfnt) {
  40995. this.sfnt = sfnt;
  40996. this.tables = Object.create(null);
  40997. }
  40998. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40999. var maxPower2 = 1, log2 = 0;
  41000. while ((maxPower2 ^ entriesCount) > maxPower2) {
  41001. maxPower2 <<= 1;
  41002. log2++;
  41003. }
  41004. var searchRange = maxPower2 * entrySize;
  41005. return {
  41006. range: searchRange,
  41007. entry: log2,
  41008. rangeShift: entrySize * entriesCount - searchRange
  41009. };
  41010. };
  41011. var OTF_HEADER_SIZE = 12;
  41012. var OTF_TABLE_ENTRY_SIZE = 16;
  41013. OpenTypeFileBuilder.prototype = {
  41014. toArray: function OpenTypeFileBuilder_toArray() {
  41015. var sfnt = this.sfnt;
  41016. var tables = this.tables;
  41017. var tablesNames = Object.keys(tables);
  41018. tablesNames.sort();
  41019. var numTables = tablesNames.length;
  41020. var i, j, jj, table, tableName;
  41021. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  41022. var tableOffsets = [offset];
  41023. for (i = 0; i < numTables; i++) {
  41024. table = tables[tablesNames[i]];
  41025. var paddedLength = (table.length + 3 & ~3) >>> 0;
  41026. offset += paddedLength;
  41027. tableOffsets.push(offset);
  41028. }
  41029. var file = new Uint8Array(offset);
  41030. for (i = 0; i < numTables; i++) {
  41031. table = tables[tablesNames[i]];
  41032. writeData(file, tableOffsets[i], table);
  41033. }
  41034. if (sfnt === 'true') {
  41035. sfnt = string32(0x00010000);
  41036. }
  41037. file[0] = sfnt.charCodeAt(0) & 0xFF;
  41038. file[1] = sfnt.charCodeAt(1) & 0xFF;
  41039. file[2] = sfnt.charCodeAt(2) & 0xFF;
  41040. file[3] = sfnt.charCodeAt(3) & 0xFF;
  41041. writeInt16(file, 4, numTables);
  41042. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  41043. writeInt16(file, 6, searchParams.range);
  41044. writeInt16(file, 8, searchParams.entry);
  41045. writeInt16(file, 10, searchParams.rangeShift);
  41046. offset = OTF_HEADER_SIZE;
  41047. for (i = 0; i < numTables; i++) {
  41048. tableName = tablesNames[i];
  41049. file[offset] = tableName.charCodeAt(0) & 0xFF;
  41050. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  41051. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  41052. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  41053. var checksum = 0;
  41054. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  41055. var quad = readUint32(file, j);
  41056. checksum = checksum + quad >>> 0;
  41057. }
  41058. writeInt32(file, offset + 4, checksum);
  41059. writeInt32(file, offset + 8, tableOffsets[i]);
  41060. writeInt32(file, offset + 12, tables[tableName].length);
  41061. offset += OTF_TABLE_ENTRY_SIZE;
  41062. }
  41063. return file;
  41064. },
  41065. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  41066. if (tag in this.tables) {
  41067. throw new Error('Table ' + tag + ' already exists');
  41068. }
  41069. this.tables[tag] = data;
  41070. }
  41071. };
  41072. return OpenTypeFileBuilder;
  41073. }();
  41074. var ProblematicCharRanges = new Int32Array([
  41075. 0x0000,
  41076. 0x0020,
  41077. 0x007F,
  41078. 0x00A1,
  41079. 0x00AD,
  41080. 0x00AE,
  41081. 0x0600,
  41082. 0x0780,
  41083. 0x08A0,
  41084. 0x10A0,
  41085. 0x1780,
  41086. 0x1800,
  41087. 0x1C00,
  41088. 0x1C50,
  41089. 0x2000,
  41090. 0x2010,
  41091. 0x2011,
  41092. 0x2012,
  41093. 0x2028,
  41094. 0x2030,
  41095. 0x205F,
  41096. 0x2070,
  41097. 0x25CC,
  41098. 0x25CD,
  41099. 0x3000,
  41100. 0x3001,
  41101. 0xAA60,
  41102. 0xAA80,
  41103. 0xFFF0,
  41104. 0x10000
  41105. ]);
  41106. var Font = function FontClosure() {
  41107. function Font(name, file, properties) {
  41108. var charCode, glyphName, unicode;
  41109. this.name = name;
  41110. this.loadedName = properties.loadedName;
  41111. this.isType3Font = properties.isType3Font;
  41112. this.sizes = [];
  41113. this.missingFile = false;
  41114. this.glyphCache = Object.create(null);
  41115. var names = name.split('+');
  41116. names = names.length > 1 ? names[1] : names[0];
  41117. names = names.split(/[-,_]/g)[0];
  41118. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  41119. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  41120. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  41121. var type = properties.type;
  41122. var subtype = properties.subtype;
  41123. this.type = type;
  41124. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  41125. this.differences = properties.differences;
  41126. this.widths = properties.widths;
  41127. this.defaultWidth = properties.defaultWidth;
  41128. this.composite = properties.composite;
  41129. this.wideChars = properties.wideChars;
  41130. this.cMap = properties.cMap;
  41131. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  41132. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  41133. this.fontMatrix = properties.fontMatrix;
  41134. this.bbox = properties.bbox;
  41135. this.toUnicode = properties.toUnicode;
  41136. this.toFontChar = [];
  41137. if (properties.type === 'Type3') {
  41138. for (charCode = 0; charCode < 256; charCode++) {
  41139. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  41140. }
  41141. this.fontType = FontType.TYPE3;
  41142. return;
  41143. }
  41144. this.cidEncoding = properties.cidEncoding;
  41145. this.vertical = properties.vertical;
  41146. if (this.vertical) {
  41147. this.vmetrics = properties.vmetrics;
  41148. this.defaultVMetrics = properties.defaultVMetrics;
  41149. }
  41150. var glyphsUnicodeMap;
  41151. if (!file || file.isEmpty) {
  41152. if (file) {
  41153. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  41154. }
  41155. this.missingFile = true;
  41156. var fontName = name.replace(/[,_]/g, '-');
  41157. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  41158. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  41159. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  41160. this.bold = fontName.search(/bold/gi) !== -1;
  41161. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  41162. this.black = name.search(/Black/g) !== -1;
  41163. this.remeasure = Object.keys(this.widths).length > 0;
  41164. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  41165. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  41166. var map = [];
  41167. for (charCode in GlyphMapForStandardFonts) {
  41168. map[+charCode] = GlyphMapForStandardFonts[charCode];
  41169. }
  41170. if (/Arial-?Black/i.test(name)) {
  41171. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  41172. for (charCode in SupplementalGlyphMapForArialBlack) {
  41173. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  41174. }
  41175. }
  41176. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41177. if (!isIdentityUnicode) {
  41178. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41179. map[+charCode] = unicodeCharCode;
  41180. });
  41181. }
  41182. this.toFontChar = map;
  41183. this.toUnicode = new ToUnicodeMap(map);
  41184. } else if (/Symbol/i.test(fontName)) {
  41185. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41186. } else if (/Dingbats/i.test(fontName)) {
  41187. if (/Wingdings/i.test(name)) {
  41188. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41189. }
  41190. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41191. } else if (isStandardFont) {
  41192. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41193. } else {
  41194. glyphsUnicodeMap = getGlyphsUnicode();
  41195. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41196. if (!this.composite) {
  41197. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41198. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41199. if (unicode !== -1) {
  41200. unicodeCharCode = unicode;
  41201. }
  41202. }
  41203. this.toFontChar[charCode] = unicodeCharCode;
  41204. }.bind(this));
  41205. }
  41206. this.loadedName = fontName.split('-')[0];
  41207. this.loading = false;
  41208. this.fontType = getFontType(type, subtype);
  41209. return;
  41210. }
  41211. if (subtype === 'Type1C') {
  41212. if (type !== 'Type1' && type !== 'MMType1') {
  41213. if (isTrueTypeFile(file)) {
  41214. subtype = 'TrueType';
  41215. } else {
  41216. type = 'Type1';
  41217. }
  41218. } else if (isOpenTypeFile(file)) {
  41219. type = subtype = 'OpenType';
  41220. }
  41221. }
  41222. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41223. type = 'CIDFontType0';
  41224. }
  41225. if (subtype === 'OpenType') {
  41226. type = 'OpenType';
  41227. }
  41228. if (type === 'CIDFontType0') {
  41229. if (isType1File(file)) {
  41230. subtype = 'CIDFontType0';
  41231. } else if (isOpenTypeFile(file)) {
  41232. type = subtype = 'OpenType';
  41233. } else {
  41234. subtype = 'CIDFontType0C';
  41235. }
  41236. }
  41237. var data;
  41238. switch (type) {
  41239. case 'MMType1':
  41240. info('MMType1 font (' + name + '), falling back to Type1.');
  41241. case 'Type1':
  41242. case 'CIDFontType0':
  41243. this.mimetype = 'font/opentype';
  41244. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41245. adjustWidths(properties);
  41246. data = this.convert(name, cff, properties);
  41247. break;
  41248. case 'OpenType':
  41249. case 'TrueType':
  41250. case 'CIDFontType2':
  41251. this.mimetype = 'font/opentype';
  41252. data = this.checkAndRepair(name, file, properties);
  41253. if (this.isOpenType) {
  41254. adjustWidths(properties);
  41255. type = 'OpenType';
  41256. }
  41257. break;
  41258. default:
  41259. error('Font ' + type + ' is not supported');
  41260. break;
  41261. }
  41262. this.data = data;
  41263. this.fontType = getFontType(type, subtype);
  41264. this.fontMatrix = properties.fontMatrix;
  41265. this.widths = properties.widths;
  41266. this.defaultWidth = properties.defaultWidth;
  41267. this.toUnicode = properties.toUnicode;
  41268. this.encoding = properties.baseEncoding;
  41269. this.seacMap = properties.seacMap;
  41270. this.loading = true;
  41271. }
  41272. Font.getFontID = function () {
  41273. var ID = 1;
  41274. return function Font_getFontID() {
  41275. return String(ID++);
  41276. };
  41277. }();
  41278. function int16(b0, b1) {
  41279. return (b0 << 8) + b1;
  41280. }
  41281. function signedInt16(b0, b1) {
  41282. var value = (b0 << 8) + b1;
  41283. return value & 1 << 15 ? value - 0x10000 : value;
  41284. }
  41285. function int32(b0, b1, b2, b3) {
  41286. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41287. }
  41288. function string16(value) {
  41289. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41290. }
  41291. function safeString16(value) {
  41292. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41293. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41294. }
  41295. function isTrueTypeFile(file) {
  41296. var header = file.peekBytes(4);
  41297. return readUint32(header, 0) === 0x00010000;
  41298. }
  41299. function isOpenTypeFile(file) {
  41300. var header = file.peekBytes(4);
  41301. return bytesToString(header) === 'OTTO';
  41302. }
  41303. function isType1File(file) {
  41304. var header = file.peekBytes(2);
  41305. if (header[0] === 0x25 && header[1] === 0x21) {
  41306. return true;
  41307. }
  41308. if (header[0] === 0x80 && header[1] === 0x01) {
  41309. return true;
  41310. }
  41311. return false;
  41312. }
  41313. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41314. var toFontChar = [], unicode;
  41315. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41316. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41317. if (unicode !== -1) {
  41318. toFontChar[i] = unicode;
  41319. }
  41320. }
  41321. for (var charCode in differences) {
  41322. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41323. if (unicode !== -1) {
  41324. toFontChar[+charCode] = unicode;
  41325. }
  41326. }
  41327. return toFontChar;
  41328. }
  41329. function isProblematicUnicodeLocation(code) {
  41330. var i = 0, j = ProblematicCharRanges.length - 1;
  41331. while (i < j) {
  41332. var c = i + j + 1 >> 1;
  41333. if (code < ProblematicCharRanges[c]) {
  41334. j = c - 1;
  41335. } else {
  41336. i = c;
  41337. }
  41338. }
  41339. return !(i & 1);
  41340. }
  41341. function adjustMapping(charCodeToGlyphId, properties) {
  41342. var toUnicode = properties.toUnicode;
  41343. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41344. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41345. var newMap = Object.create(null);
  41346. var toFontChar = [];
  41347. var usedFontCharCodes = [];
  41348. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41349. for (var originalCharCode in charCodeToGlyphId) {
  41350. originalCharCode |= 0;
  41351. var glyphId = charCodeToGlyphId[originalCharCode];
  41352. var fontCharCode = originalCharCode;
  41353. var hasUnicodeValue = false;
  41354. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41355. hasUnicodeValue = true;
  41356. var unicode = toUnicode.get(fontCharCode);
  41357. if (unicode.length === 1) {
  41358. fontCharCode = unicode.charCodeAt(0);
  41359. }
  41360. }
  41361. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41362. do {
  41363. fontCharCode = nextAvailableFontCharCode++;
  41364. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41365. fontCharCode = 0xF020;
  41366. nextAvailableFontCharCode = fontCharCode + 1;
  41367. }
  41368. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41369. }
  41370. newMap[fontCharCode] = glyphId;
  41371. toFontChar[originalCharCode] = fontCharCode;
  41372. usedFontCharCodes[fontCharCode] = true;
  41373. }
  41374. return {
  41375. toFontChar: toFontChar,
  41376. charCodeToGlyphId: newMap,
  41377. nextAvailableFontCharCode: nextAvailableFontCharCode
  41378. };
  41379. }
  41380. function getRanges(glyphs, numGlyphs) {
  41381. var codes = [];
  41382. for (var charCode in glyphs) {
  41383. if (glyphs[charCode] >= numGlyphs) {
  41384. continue;
  41385. }
  41386. codes.push({
  41387. fontCharCode: charCode | 0,
  41388. glyphId: glyphs[charCode]
  41389. });
  41390. }
  41391. codes.sort(function fontGetRangesSort(a, b) {
  41392. return a.fontCharCode - b.fontCharCode;
  41393. });
  41394. var ranges = [];
  41395. var length = codes.length;
  41396. for (var n = 0; n < length;) {
  41397. var start = codes[n].fontCharCode;
  41398. var codeIndices = [codes[n].glyphId];
  41399. ++n;
  41400. var end = start;
  41401. while (n < length && end + 1 === codes[n].fontCharCode) {
  41402. codeIndices.push(codes[n].glyphId);
  41403. ++end;
  41404. ++n;
  41405. if (end === 0xFFFF) {
  41406. break;
  41407. }
  41408. }
  41409. ranges.push([
  41410. start,
  41411. end,
  41412. codeIndices
  41413. ]);
  41414. }
  41415. return ranges;
  41416. }
  41417. function createCmapTable(glyphs, numGlyphs) {
  41418. var ranges = getRanges(glyphs, numGlyphs);
  41419. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41420. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41421. var i, ii, j, jj;
  41422. for (i = ranges.length - 1; i >= 0; --i) {
  41423. if (ranges[i][0] <= 0xFFFF) {
  41424. break;
  41425. }
  41426. }
  41427. var bmpLength = i + 1;
  41428. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41429. ranges[i][1] = 0xFFFE;
  41430. }
  41431. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41432. var segCount = bmpLength + trailingRangesCount;
  41433. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41434. var startCount = '';
  41435. var endCount = '';
  41436. var idDeltas = '';
  41437. var idRangeOffsets = '';
  41438. var glyphsIds = '';
  41439. var bias = 0;
  41440. var range, start, end, codes;
  41441. for (i = 0, ii = bmpLength; i < ii; i++) {
  41442. range = ranges[i];
  41443. start = range[0];
  41444. end = range[1];
  41445. startCount += string16(start);
  41446. endCount += string16(end);
  41447. codes = range[2];
  41448. var contiguous = true;
  41449. for (j = 1, jj = codes.length; j < jj; ++j) {
  41450. if (codes[j] !== codes[j - 1] + 1) {
  41451. contiguous = false;
  41452. break;
  41453. }
  41454. }
  41455. if (!contiguous) {
  41456. var offset = (segCount - i) * 2 + bias * 2;
  41457. bias += end - start + 1;
  41458. idDeltas += string16(0);
  41459. idRangeOffsets += string16(offset);
  41460. for (j = 0, jj = codes.length; j < jj; ++j) {
  41461. glyphsIds += string16(codes[j]);
  41462. }
  41463. } else {
  41464. var startCode = codes[0];
  41465. idDeltas += string16(startCode - start & 0xFFFF);
  41466. idRangeOffsets += string16(0);
  41467. }
  41468. }
  41469. if (trailingRangesCount > 0) {
  41470. endCount += '\xFF\xFF';
  41471. startCount += '\xFF\xFF';
  41472. idDeltas += '\x00\x01';
  41473. idRangeOffsets += '\x00\x00';
  41474. }
  41475. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41476. var format31012 = '';
  41477. var header31012 = '';
  41478. if (numTables > 1) {
  41479. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41480. format31012 = '';
  41481. for (i = 0, ii = ranges.length; i < ii; i++) {
  41482. range = ranges[i];
  41483. start = range[0];
  41484. codes = range[2];
  41485. var code = codes[0];
  41486. for (j = 1, jj = codes.length; j < jj; ++j) {
  41487. if (codes[j] !== codes[j - 1] + 1) {
  41488. end = range[0] + j - 1;
  41489. format31012 += string32(start) + string32(end) + string32(code);
  41490. start = end + 1;
  41491. code = codes[j];
  41492. }
  41493. }
  41494. format31012 += string32(start) + string32(range[1]) + string32(code);
  41495. }
  41496. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41497. }
  41498. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41499. }
  41500. function validateOS2Table(os2) {
  41501. var stream = new Stream(os2.data);
  41502. var version = stream.getUint16();
  41503. stream.getBytes(60);
  41504. var selection = stream.getUint16();
  41505. if (version < 4 && selection & 0x0300) {
  41506. return false;
  41507. }
  41508. var firstChar = stream.getUint16();
  41509. var lastChar = stream.getUint16();
  41510. if (firstChar > lastChar) {
  41511. return false;
  41512. }
  41513. stream.getBytes(6);
  41514. var usWinAscent = stream.getUint16();
  41515. if (usWinAscent === 0) {
  41516. return false;
  41517. }
  41518. os2.data[8] = os2.data[9] = 0;
  41519. return true;
  41520. }
  41521. function createOS2Table(properties, charstrings, override) {
  41522. override = override || {
  41523. unitsPerEm: 0,
  41524. yMax: 0,
  41525. yMin: 0,
  41526. ascent: 0,
  41527. descent: 0
  41528. };
  41529. var ulUnicodeRange1 = 0;
  41530. var ulUnicodeRange2 = 0;
  41531. var ulUnicodeRange3 = 0;
  41532. var ulUnicodeRange4 = 0;
  41533. var firstCharIndex = null;
  41534. var lastCharIndex = 0;
  41535. if (charstrings) {
  41536. for (var code in charstrings) {
  41537. code |= 0;
  41538. if (firstCharIndex > code || !firstCharIndex) {
  41539. firstCharIndex = code;
  41540. }
  41541. if (lastCharIndex < code) {
  41542. lastCharIndex = code;
  41543. }
  41544. var position = getUnicodeRangeFor(code);
  41545. if (position < 32) {
  41546. ulUnicodeRange1 |= 1 << position;
  41547. } else if (position < 64) {
  41548. ulUnicodeRange2 |= 1 << position - 32;
  41549. } else if (position < 96) {
  41550. ulUnicodeRange3 |= 1 << position - 64;
  41551. } else if (position < 123) {
  41552. ulUnicodeRange4 |= 1 << position - 96;
  41553. } else {
  41554. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41555. }
  41556. }
  41557. } else {
  41558. firstCharIndex = 0;
  41559. lastCharIndex = 255;
  41560. }
  41561. var bbox = properties.bbox || [
  41562. 0,
  41563. 0,
  41564. 0,
  41565. 0
  41566. ];
  41567. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41568. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41569. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41570. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41571. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41572. typoDescent = -typoDescent;
  41573. }
  41574. var winAscent = override.yMax || typoAscent;
  41575. var winDescent = -override.yMin || -typoDescent;
  41576. 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';
  41577. }
  41578. function createPostTable(properties) {
  41579. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41580. 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';
  41581. }
  41582. function createNameTable(name, proto) {
  41583. if (!proto) {
  41584. proto = [
  41585. [],
  41586. []
  41587. ];
  41588. }
  41589. var strings = [
  41590. proto[0][0] || 'Original licence',
  41591. proto[0][1] || name,
  41592. proto[0][2] || 'Unknown',
  41593. proto[0][3] || 'uniqueID',
  41594. proto[0][4] || name,
  41595. proto[0][5] || 'Version 0.11',
  41596. proto[0][6] || '',
  41597. proto[0][7] || 'Unknown',
  41598. proto[0][8] || 'Unknown',
  41599. proto[0][9] || 'Unknown'
  41600. ];
  41601. var stringsUnicode = [];
  41602. var i, ii, j, jj, str;
  41603. for (i = 0, ii = strings.length; i < ii; i++) {
  41604. str = proto[1][i] || strings[i];
  41605. var strBufUnicode = [];
  41606. for (j = 0, jj = str.length; j < jj; j++) {
  41607. strBufUnicode.push(string16(str.charCodeAt(j)));
  41608. }
  41609. stringsUnicode.push(strBufUnicode.join(''));
  41610. }
  41611. var names = [
  41612. strings,
  41613. stringsUnicode
  41614. ];
  41615. var platforms = [
  41616. '\x00\x01',
  41617. '\x00\x03'
  41618. ];
  41619. var encodings = [
  41620. '\x00\x00',
  41621. '\x00\x01'
  41622. ];
  41623. var languages = [
  41624. '\x00\x00',
  41625. '\x04\x09'
  41626. ];
  41627. var namesRecordCount = strings.length * platforms.length;
  41628. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41629. var strOffset = 0;
  41630. for (i = 0, ii = platforms.length; i < ii; i++) {
  41631. var strs = names[i];
  41632. for (j = 0, jj = strs.length; j < jj; j++) {
  41633. str = strs[j];
  41634. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41635. nameTable += nameRecord;
  41636. strOffset += str.length;
  41637. }
  41638. }
  41639. nameTable += strings.join('') + stringsUnicode.join('');
  41640. return nameTable;
  41641. }
  41642. Font.prototype = {
  41643. name: null,
  41644. font: null,
  41645. mimetype: null,
  41646. encoding: null,
  41647. get renderer() {
  41648. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41649. return shadow(this, 'renderer', renderer);
  41650. },
  41651. exportData: function Font_exportData() {
  41652. var data = {};
  41653. for (var i in this) {
  41654. if (this.hasOwnProperty(i)) {
  41655. data[i] = this[i];
  41656. }
  41657. }
  41658. return data;
  41659. },
  41660. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41661. function readTableEntry(file) {
  41662. var tag = bytesToString(file.getBytes(4));
  41663. var checksum = file.getInt32() >>> 0;
  41664. var offset = file.getInt32() >>> 0;
  41665. var length = file.getInt32() >>> 0;
  41666. var previousPosition = file.pos;
  41667. file.pos = file.start ? file.start : 0;
  41668. file.skip(offset);
  41669. var data = file.getBytes(length);
  41670. file.pos = previousPosition;
  41671. if (tag === 'head') {
  41672. data[8] = data[9] = data[10] = data[11] = 0;
  41673. data[17] |= 0x20;
  41674. }
  41675. return {
  41676. tag: tag,
  41677. checksum: checksum,
  41678. length: length,
  41679. offset: offset,
  41680. data: data
  41681. };
  41682. }
  41683. function readOpenTypeHeader(ttf) {
  41684. return {
  41685. version: bytesToString(ttf.getBytes(4)),
  41686. numTables: ttf.getUint16(),
  41687. searchRange: ttf.getUint16(),
  41688. entrySelector: ttf.getUint16(),
  41689. rangeShift: ttf.getUint16()
  41690. };
  41691. }
  41692. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41693. if (!cmap) {
  41694. warn('No cmap table available.');
  41695. return {
  41696. platformId: -1,
  41697. encodingId: -1,
  41698. mappings: [],
  41699. hasShortCmap: false
  41700. };
  41701. }
  41702. var segment;
  41703. var start = (font.start ? font.start : 0) + cmap.offset;
  41704. font.pos = start;
  41705. var version = font.getUint16();
  41706. var numTables = font.getUint16();
  41707. var potentialTable;
  41708. var canBreak = false;
  41709. for (var i = 0; i < numTables; i++) {
  41710. var platformId = font.getUint16();
  41711. var encodingId = font.getUint16();
  41712. var offset = font.getInt32() >>> 0;
  41713. var useTable = false;
  41714. if (platformId === 0 && encodingId === 0) {
  41715. useTable = true;
  41716. } else if (platformId === 1 && encodingId === 0) {
  41717. useTable = true;
  41718. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41719. useTable = true;
  41720. if (!isSymbolicFont) {
  41721. canBreak = true;
  41722. }
  41723. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41724. useTable = true;
  41725. canBreak = true;
  41726. }
  41727. if (useTable) {
  41728. potentialTable = {
  41729. platformId: platformId,
  41730. encodingId: encodingId,
  41731. offset: offset
  41732. };
  41733. }
  41734. if (canBreak) {
  41735. break;
  41736. }
  41737. }
  41738. if (potentialTable) {
  41739. font.pos = start + potentialTable.offset;
  41740. }
  41741. if (!potentialTable || font.peekByte() === -1) {
  41742. warn('Could not find a preferred cmap table.');
  41743. return {
  41744. platformId: -1,
  41745. encodingId: -1,
  41746. mappings: [],
  41747. hasShortCmap: false
  41748. };
  41749. }
  41750. var format = font.getUint16();
  41751. var length = font.getUint16();
  41752. var language = font.getUint16();
  41753. var hasShortCmap = false;
  41754. var mappings = [];
  41755. var j, glyphId;
  41756. if (format === 0) {
  41757. for (j = 0; j < 256; j++) {
  41758. var index = font.getByte();
  41759. if (!index) {
  41760. continue;
  41761. }
  41762. mappings.push({
  41763. charCode: j,
  41764. glyphId: index
  41765. });
  41766. }
  41767. hasShortCmap = true;
  41768. } else if (format === 4) {
  41769. var segCount = font.getUint16() >> 1;
  41770. font.getBytes(6);
  41771. var segIndex, segments = [];
  41772. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41773. segments.push({ end: font.getUint16() });
  41774. }
  41775. font.getUint16();
  41776. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41777. segments[segIndex].start = font.getUint16();
  41778. }
  41779. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41780. segments[segIndex].delta = font.getUint16();
  41781. }
  41782. var offsetsCount = 0;
  41783. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41784. segment = segments[segIndex];
  41785. var rangeOffset = font.getUint16();
  41786. if (!rangeOffset) {
  41787. segment.offsetIndex = -1;
  41788. continue;
  41789. }
  41790. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41791. segment.offsetIndex = offsetIndex;
  41792. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41793. }
  41794. var offsets = [];
  41795. for (j = 0; j < offsetsCount; j++) {
  41796. offsets.push(font.getUint16());
  41797. }
  41798. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41799. segment = segments[segIndex];
  41800. start = segment.start;
  41801. var end = segment.end;
  41802. var delta = segment.delta;
  41803. offsetIndex = segment.offsetIndex;
  41804. for (j = start; j <= end; j++) {
  41805. if (j === 0xFFFF) {
  41806. continue;
  41807. }
  41808. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41809. glyphId = glyphId + delta & 0xFFFF;
  41810. if (glyphId === 0) {
  41811. continue;
  41812. }
  41813. mappings.push({
  41814. charCode: j,
  41815. glyphId: glyphId
  41816. });
  41817. }
  41818. }
  41819. } else if (format === 6) {
  41820. var firstCode = font.getUint16();
  41821. var entryCount = font.getUint16();
  41822. for (j = 0; j < entryCount; j++) {
  41823. glyphId = font.getUint16();
  41824. var charCode = firstCode + j;
  41825. mappings.push({
  41826. charCode: charCode,
  41827. glyphId: glyphId
  41828. });
  41829. }
  41830. } else {
  41831. warn('cmap table has unsupported format: ' + format);
  41832. return {
  41833. platformId: -1,
  41834. encodingId: -1,
  41835. mappings: [],
  41836. hasShortCmap: false
  41837. };
  41838. }
  41839. mappings.sort(function (a, b) {
  41840. return a.charCode - b.charCode;
  41841. });
  41842. for (i = 1; i < mappings.length; i++) {
  41843. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41844. mappings.splice(i, 1);
  41845. i--;
  41846. }
  41847. }
  41848. return {
  41849. platformId: potentialTable.platformId,
  41850. encodingId: potentialTable.encodingId,
  41851. mappings: mappings,
  41852. hasShortCmap: hasShortCmap
  41853. };
  41854. }
  41855. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41856. if (!header) {
  41857. if (metrics) {
  41858. metrics.data = null;
  41859. }
  41860. return;
  41861. }
  41862. font.pos = (font.start ? font.start : 0) + header.offset;
  41863. font.pos += header.length - 2;
  41864. var numOfMetrics = font.getUint16();
  41865. if (numOfMetrics > numGlyphs) {
  41866. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41867. numOfMetrics = numGlyphs;
  41868. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41869. header.data[35] = numOfMetrics & 0x00ff;
  41870. }
  41871. var numOfSidebearings = numGlyphs - numOfMetrics;
  41872. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41873. if (numMissing > 0) {
  41874. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41875. entries.set(metrics.data);
  41876. metrics.data = entries;
  41877. }
  41878. }
  41879. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41880. if (sourceEnd - sourceStart <= 12) {
  41881. return 0;
  41882. }
  41883. var glyf = source.subarray(sourceStart, sourceEnd);
  41884. var contoursCount = glyf[0] << 8 | glyf[1];
  41885. if (contoursCount & 0x8000) {
  41886. dest.set(glyf, destStart);
  41887. return glyf.length;
  41888. }
  41889. var i, j = 10, flagsCount = 0;
  41890. for (i = 0; i < contoursCount; i++) {
  41891. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41892. flagsCount = endPoint + 1;
  41893. j += 2;
  41894. }
  41895. var instructionsStart = j;
  41896. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41897. j += 2 + instructionsLength;
  41898. var instructionsEnd = j;
  41899. var coordinatesLength = 0;
  41900. for (i = 0; i < flagsCount; i++) {
  41901. var flag = glyf[j++];
  41902. if (flag & 0xC0) {
  41903. glyf[j - 1] = flag & 0x3F;
  41904. }
  41905. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41906. coordinatesLength += xyLength;
  41907. if (flag & 8) {
  41908. var repeat = glyf[j++];
  41909. i += repeat;
  41910. coordinatesLength += repeat * xyLength;
  41911. }
  41912. }
  41913. if (coordinatesLength === 0) {
  41914. return 0;
  41915. }
  41916. var glyphDataLength = j + coordinatesLength;
  41917. if (glyphDataLength > glyf.length) {
  41918. return 0;
  41919. }
  41920. if (!hintsValid && instructionsLength > 0) {
  41921. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41922. dest.set([
  41923. 0,
  41924. 0
  41925. ], destStart + instructionsStart);
  41926. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41927. glyphDataLength -= instructionsLength;
  41928. if (glyf.length - glyphDataLength > 3) {
  41929. glyphDataLength = glyphDataLength + 3 & ~3;
  41930. }
  41931. return glyphDataLength;
  41932. }
  41933. if (glyf.length - glyphDataLength > 3) {
  41934. glyphDataLength = glyphDataLength + 3 & ~3;
  41935. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41936. return glyphDataLength;
  41937. }
  41938. dest.set(glyf, destStart);
  41939. return glyf.length;
  41940. }
  41941. function sanitizeHead(head, numGlyphs, locaLength) {
  41942. var data = head.data;
  41943. var version = int32(data[0], data[1], data[2], data[3]);
  41944. if (version >> 16 !== 1) {
  41945. info('Attempting to fix invalid version in head table: ' + version);
  41946. data[0] = 0;
  41947. data[1] = 1;
  41948. data[2] = 0;
  41949. data[3] = 0;
  41950. }
  41951. var indexToLocFormat = int16(data[50], data[51]);
  41952. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41953. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41954. var numGlyphsPlusOne = numGlyphs + 1;
  41955. if (locaLength === numGlyphsPlusOne << 1) {
  41956. data[50] = 0;
  41957. data[51] = 0;
  41958. } else if (locaLength === numGlyphsPlusOne << 2) {
  41959. data[50] = 0;
  41960. data[51] = 1;
  41961. } else {
  41962. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41963. }
  41964. }
  41965. }
  41966. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41967. var itemSize, itemDecode, itemEncode;
  41968. if (isGlyphLocationsLong) {
  41969. itemSize = 4;
  41970. itemDecode = function fontItemDecodeLong(data, offset) {
  41971. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41972. };
  41973. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41974. data[offset] = value >>> 24 & 0xFF;
  41975. data[offset + 1] = value >> 16 & 0xFF;
  41976. data[offset + 2] = value >> 8 & 0xFF;
  41977. data[offset + 3] = value & 0xFF;
  41978. };
  41979. } else {
  41980. itemSize = 2;
  41981. itemDecode = function fontItemDecode(data, offset) {
  41982. return data[offset] << 9 | data[offset + 1] << 1;
  41983. };
  41984. itemEncode = function fontItemEncode(data, offset, value) {
  41985. data[offset] = value >> 9 & 0xFF;
  41986. data[offset + 1] = value >> 1 & 0xFF;
  41987. };
  41988. }
  41989. var locaData = loca.data;
  41990. var locaDataSize = itemSize * (1 + numGlyphs);
  41991. if (locaData.length !== locaDataSize) {
  41992. locaData = new Uint8Array(locaDataSize);
  41993. locaData.set(loca.data.subarray(0, locaDataSize));
  41994. loca.data = locaData;
  41995. }
  41996. var oldGlyfData = glyf.data;
  41997. var oldGlyfDataLength = oldGlyfData.length;
  41998. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41999. var startOffset = itemDecode(locaData, 0);
  42000. var writeOffset = 0;
  42001. var missingGlyphData = Object.create(null);
  42002. itemEncode(locaData, 0, writeOffset);
  42003. var i, j;
  42004. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  42005. var endOffset = itemDecode(locaData, j);
  42006. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  42007. endOffset = oldGlyfDataLength;
  42008. }
  42009. if (endOffset > oldGlyfDataLength) {
  42010. itemEncode(locaData, j, writeOffset);
  42011. startOffset = endOffset;
  42012. continue;
  42013. }
  42014. if (startOffset === endOffset) {
  42015. missingGlyphData[i] = true;
  42016. }
  42017. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  42018. writeOffset += newLength;
  42019. itemEncode(locaData, j, writeOffset);
  42020. startOffset = endOffset;
  42021. }
  42022. if (writeOffset === 0) {
  42023. var simpleGlyph = new Uint8Array([
  42024. 0,
  42025. 1,
  42026. 0,
  42027. 0,
  42028. 0,
  42029. 0,
  42030. 0,
  42031. 0,
  42032. 0,
  42033. 0,
  42034. 0,
  42035. 0,
  42036. 0,
  42037. 0,
  42038. 49,
  42039. 0
  42040. ]);
  42041. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  42042. itemEncode(locaData, j, simpleGlyph.length);
  42043. }
  42044. glyf.data = simpleGlyph;
  42045. return missingGlyphData;
  42046. }
  42047. if (dupFirstEntry) {
  42048. var firstEntryLength = itemDecode(locaData, itemSize);
  42049. if (newGlyfData.length > firstEntryLength + writeOffset) {
  42050. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  42051. } else {
  42052. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  42053. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  42054. }
  42055. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  42056. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  42057. } else {
  42058. glyf.data = newGlyfData.subarray(0, writeOffset);
  42059. }
  42060. return missingGlyphData;
  42061. }
  42062. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  42063. var start = (font.start ? font.start : 0) + post.offset;
  42064. font.pos = start;
  42065. var length = post.length, end = start + length;
  42066. var version = font.getInt32();
  42067. font.getBytes(28);
  42068. var glyphNames;
  42069. var valid = true;
  42070. var i;
  42071. switch (version) {
  42072. case 0x00010000:
  42073. glyphNames = MacStandardGlyphOrdering;
  42074. break;
  42075. case 0x00020000:
  42076. var numGlyphs = font.getUint16();
  42077. if (numGlyphs !== maxpNumGlyphs) {
  42078. valid = false;
  42079. break;
  42080. }
  42081. var glyphNameIndexes = [];
  42082. for (i = 0; i < numGlyphs; ++i) {
  42083. var index = font.getUint16();
  42084. if (index >= 32768) {
  42085. valid = false;
  42086. break;
  42087. }
  42088. glyphNameIndexes.push(index);
  42089. }
  42090. if (!valid) {
  42091. break;
  42092. }
  42093. var customNames = [];
  42094. var strBuf = [];
  42095. while (font.pos < end) {
  42096. var stringLength = font.getByte();
  42097. strBuf.length = stringLength;
  42098. for (i = 0; i < stringLength; ++i) {
  42099. strBuf[i] = String.fromCharCode(font.getByte());
  42100. }
  42101. customNames.push(strBuf.join(''));
  42102. }
  42103. glyphNames = [];
  42104. for (i = 0; i < numGlyphs; ++i) {
  42105. var j = glyphNameIndexes[i];
  42106. if (j < 258) {
  42107. glyphNames.push(MacStandardGlyphOrdering[j]);
  42108. continue;
  42109. }
  42110. glyphNames.push(customNames[j - 258]);
  42111. }
  42112. break;
  42113. case 0x00030000:
  42114. break;
  42115. default:
  42116. warn('Unknown/unsupported post table version ' + version);
  42117. valid = false;
  42118. if (properties.defaultEncoding) {
  42119. glyphNames = properties.defaultEncoding;
  42120. }
  42121. break;
  42122. }
  42123. properties.glyphNames = glyphNames;
  42124. return valid;
  42125. }
  42126. function readNameTable(nameTable) {
  42127. var start = (font.start ? font.start : 0) + nameTable.offset;
  42128. font.pos = start;
  42129. var names = [
  42130. [],
  42131. []
  42132. ];
  42133. var length = nameTable.length, end = start + length;
  42134. var format = font.getUint16();
  42135. var FORMAT_0_HEADER_LENGTH = 6;
  42136. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  42137. return names;
  42138. }
  42139. var numRecords = font.getUint16();
  42140. var stringsStart = font.getUint16();
  42141. var records = [];
  42142. var NAME_RECORD_LENGTH = 12;
  42143. var i, ii;
  42144. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  42145. var r = {
  42146. platform: font.getUint16(),
  42147. encoding: font.getUint16(),
  42148. language: font.getUint16(),
  42149. name: font.getUint16(),
  42150. length: font.getUint16(),
  42151. offset: font.getUint16()
  42152. };
  42153. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  42154. records.push(r);
  42155. }
  42156. }
  42157. for (i = 0, ii = records.length; i < ii; i++) {
  42158. var record = records[i];
  42159. if (record.length <= 0) {
  42160. continue;
  42161. }
  42162. var pos = start + stringsStart + record.offset;
  42163. if (pos + record.length > end) {
  42164. continue;
  42165. }
  42166. font.pos = pos;
  42167. var nameIndex = record.name;
  42168. if (record.encoding) {
  42169. var str = '';
  42170. for (var j = 0, jj = record.length; j < jj; j += 2) {
  42171. str += String.fromCharCode(font.getUint16());
  42172. }
  42173. names[1][nameIndex] = str;
  42174. } else {
  42175. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  42176. }
  42177. }
  42178. return names;
  42179. }
  42180. var TTOpsStackDeltas = [
  42181. 0,
  42182. 0,
  42183. 0,
  42184. 0,
  42185. 0,
  42186. 0,
  42187. 0,
  42188. 0,
  42189. -2,
  42190. -2,
  42191. -2,
  42192. -2,
  42193. 0,
  42194. 0,
  42195. -2,
  42196. -5,
  42197. -1,
  42198. -1,
  42199. -1,
  42200. -1,
  42201. -1,
  42202. -1,
  42203. -1,
  42204. -1,
  42205. 0,
  42206. 0,
  42207. -1,
  42208. 0,
  42209. -1,
  42210. -1,
  42211. -1,
  42212. -1,
  42213. 1,
  42214. -1,
  42215. -999,
  42216. 0,
  42217. 1,
  42218. 0,
  42219. -1,
  42220. -2,
  42221. 0,
  42222. -1,
  42223. -2,
  42224. -1,
  42225. -1,
  42226. 0,
  42227. -1,
  42228. -1,
  42229. 0,
  42230. 0,
  42231. -999,
  42232. -999,
  42233. -1,
  42234. -1,
  42235. -1,
  42236. -1,
  42237. -2,
  42238. -999,
  42239. -2,
  42240. -2,
  42241. -999,
  42242. 0,
  42243. -2,
  42244. -2,
  42245. 0,
  42246. 0,
  42247. -2,
  42248. 0,
  42249. -2,
  42250. 0,
  42251. 0,
  42252. 0,
  42253. -2,
  42254. -1,
  42255. -1,
  42256. 1,
  42257. 1,
  42258. 0,
  42259. 0,
  42260. -1,
  42261. -1,
  42262. -1,
  42263. -1,
  42264. -1,
  42265. -1,
  42266. -1,
  42267. 0,
  42268. 0,
  42269. -1,
  42270. 0,
  42271. -1,
  42272. -1,
  42273. 0,
  42274. -999,
  42275. -1,
  42276. -1,
  42277. -1,
  42278. -1,
  42279. -1,
  42280. -1,
  42281. 0,
  42282. 0,
  42283. 0,
  42284. 0,
  42285. 0,
  42286. 0,
  42287. 0,
  42288. 0,
  42289. 0,
  42290. 0,
  42291. 0,
  42292. 0,
  42293. -2,
  42294. -999,
  42295. -999,
  42296. -999,
  42297. -999,
  42298. -999,
  42299. -1,
  42300. -1,
  42301. -2,
  42302. -2,
  42303. 0,
  42304. 0,
  42305. 0,
  42306. 0,
  42307. -1,
  42308. -1,
  42309. -999,
  42310. -2,
  42311. -2,
  42312. 0,
  42313. 0,
  42314. -1,
  42315. -2,
  42316. -2,
  42317. 0,
  42318. 0,
  42319. 0,
  42320. -1,
  42321. -1,
  42322. -1,
  42323. -2
  42324. ];
  42325. function sanitizeTTProgram(table, ttContext) {
  42326. var data = table.data;
  42327. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42328. var stack = [];
  42329. var callstack = [];
  42330. var functionsCalled = [];
  42331. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42332. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42333. for (var ii = data.length; i < ii;) {
  42334. var op = data[i++];
  42335. if (op === 0x40) {
  42336. n = data[i++];
  42337. if (inFDEF || inELSE) {
  42338. i += n;
  42339. } else {
  42340. for (j = 0; j < n; j++) {
  42341. stack.push(data[i++]);
  42342. }
  42343. }
  42344. } else if (op === 0x41) {
  42345. n = data[i++];
  42346. if (inFDEF || inELSE) {
  42347. i += n * 2;
  42348. } else {
  42349. for (j = 0; j < n; j++) {
  42350. b = data[i++];
  42351. stack.push(b << 8 | data[i++]);
  42352. }
  42353. }
  42354. } else if ((op & 0xF8) === 0xB0) {
  42355. n = op - 0xB0 + 1;
  42356. if (inFDEF || inELSE) {
  42357. i += n;
  42358. } else {
  42359. for (j = 0; j < n; j++) {
  42360. stack.push(data[i++]);
  42361. }
  42362. }
  42363. } else if ((op & 0xF8) === 0xB8) {
  42364. n = op - 0xB8 + 1;
  42365. if (inFDEF || inELSE) {
  42366. i += n * 2;
  42367. } else {
  42368. for (j = 0; j < n; j++) {
  42369. b = data[i++];
  42370. stack.push(b << 8 | data[i++]);
  42371. }
  42372. }
  42373. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42374. if (!inFDEF && !inELSE) {
  42375. funcId = stack[stack.length - 1];
  42376. ttContext.functionsUsed[funcId] = true;
  42377. if (funcId in ttContext.functionsStackDeltas) {
  42378. stack.length += ttContext.functionsStackDeltas[funcId];
  42379. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42380. callstack.push({
  42381. data: data,
  42382. i: i,
  42383. stackTop: stack.length - 1
  42384. });
  42385. functionsCalled.push(funcId);
  42386. pc = ttContext.functionsDefined[funcId];
  42387. if (!pc) {
  42388. warn('TT: CALL non-existent function');
  42389. ttContext.hintsValid = false;
  42390. return;
  42391. }
  42392. data = pc.data;
  42393. i = pc.i;
  42394. }
  42395. }
  42396. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42397. if (inFDEF || inELSE) {
  42398. warn('TT: nested FDEFs not allowed');
  42399. tooComplexToFollowFunctions = true;
  42400. }
  42401. inFDEF = true;
  42402. lastDeff = i;
  42403. funcId = stack.pop();
  42404. ttContext.functionsDefined[funcId] = {
  42405. data: data,
  42406. i: i
  42407. };
  42408. } else if (op === 0x2D) {
  42409. if (inFDEF) {
  42410. inFDEF = false;
  42411. lastEndf = i;
  42412. } else {
  42413. pc = callstack.pop();
  42414. if (!pc) {
  42415. warn('TT: ENDF bad stack');
  42416. ttContext.hintsValid = false;
  42417. return;
  42418. }
  42419. funcId = functionsCalled.pop();
  42420. data = pc.data;
  42421. i = pc.i;
  42422. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42423. }
  42424. } else if (op === 0x89) {
  42425. if (inFDEF || inELSE) {
  42426. warn('TT: nested IDEFs not allowed');
  42427. tooComplexToFollowFunctions = true;
  42428. }
  42429. inFDEF = true;
  42430. lastDeff = i;
  42431. } else if (op === 0x58) {
  42432. ++ifLevel;
  42433. } else if (op === 0x1B) {
  42434. inELSE = ifLevel;
  42435. } else if (op === 0x59) {
  42436. if (inELSE === ifLevel) {
  42437. inELSE = 0;
  42438. }
  42439. --ifLevel;
  42440. } else if (op === 0x1C) {
  42441. if (!inFDEF && !inELSE) {
  42442. var offset = stack[stack.length - 1];
  42443. if (offset > 0) {
  42444. i += offset - 1;
  42445. }
  42446. }
  42447. }
  42448. if (!inFDEF && !inELSE) {
  42449. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42450. if (op >= 0x71 && op <= 0x75) {
  42451. n = stack.pop();
  42452. if (n === n) {
  42453. stackDelta = -n * 2;
  42454. }
  42455. }
  42456. while (stackDelta < 0 && stack.length > 0) {
  42457. stack.pop();
  42458. stackDelta++;
  42459. }
  42460. while (stackDelta > 0) {
  42461. stack.push(NaN);
  42462. stackDelta--;
  42463. }
  42464. }
  42465. }
  42466. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42467. var content = [data];
  42468. if (i > data.length) {
  42469. content.push(new Uint8Array(i - data.length));
  42470. }
  42471. if (lastDeff > lastEndf) {
  42472. warn('TT: complementing a missing function tail');
  42473. content.push(new Uint8Array([
  42474. 0x22,
  42475. 0x2D
  42476. ]));
  42477. }
  42478. foldTTTable(table, content);
  42479. }
  42480. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42481. if (ttContext.tooComplexToFollowFunctions) {
  42482. return;
  42483. }
  42484. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42485. warn('TT: more functions defined than expected');
  42486. ttContext.hintsValid = false;
  42487. return;
  42488. }
  42489. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42490. if (j > maxFunctionDefs) {
  42491. warn('TT: invalid function id: ' + j);
  42492. ttContext.hintsValid = false;
  42493. return;
  42494. }
  42495. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42496. warn('TT: undefined function: ' + j);
  42497. ttContext.hintsValid = false;
  42498. return;
  42499. }
  42500. }
  42501. }
  42502. function foldTTTable(table, content) {
  42503. if (content.length > 1) {
  42504. var newLength = 0;
  42505. var j, jj;
  42506. for (j = 0, jj = content.length; j < jj; j++) {
  42507. newLength += content[j].length;
  42508. }
  42509. newLength = newLength + 3 & ~3;
  42510. var result = new Uint8Array(newLength);
  42511. var pos = 0;
  42512. for (j = 0, jj = content.length; j < jj; j++) {
  42513. result.set(content[j], pos);
  42514. pos += content[j].length;
  42515. }
  42516. table.data = result;
  42517. table.length = newLength;
  42518. }
  42519. }
  42520. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42521. var ttContext = {
  42522. functionsDefined: [],
  42523. functionsUsed: [],
  42524. functionsStackDeltas: [],
  42525. tooComplexToFollowFunctions: false,
  42526. hintsValid: true
  42527. };
  42528. if (fpgm) {
  42529. sanitizeTTProgram(fpgm, ttContext);
  42530. }
  42531. if (prep) {
  42532. sanitizeTTProgram(prep, ttContext);
  42533. }
  42534. if (fpgm) {
  42535. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42536. }
  42537. if (cvt && cvt.length & 1) {
  42538. var cvtData = new Uint8Array(cvt.length + 1);
  42539. cvtData.set(cvt.data);
  42540. cvt.data = cvtData;
  42541. }
  42542. return ttContext.hintsValid;
  42543. }
  42544. font = new Stream(new Uint8Array(font.getBytes()));
  42545. var VALID_TABLES = [
  42546. 'OS/2',
  42547. 'cmap',
  42548. 'head',
  42549. 'hhea',
  42550. 'hmtx',
  42551. 'maxp',
  42552. 'name',
  42553. 'post',
  42554. 'loca',
  42555. 'glyf',
  42556. 'fpgm',
  42557. 'prep',
  42558. 'cvt ',
  42559. 'CFF '
  42560. ];
  42561. var header = readOpenTypeHeader(font);
  42562. var numTables = header.numTables;
  42563. var cff, cffFile;
  42564. var tables = Object.create(null);
  42565. tables['OS/2'] = null;
  42566. tables['cmap'] = null;
  42567. tables['head'] = null;
  42568. tables['hhea'] = null;
  42569. tables['hmtx'] = null;
  42570. tables['maxp'] = null;
  42571. tables['name'] = null;
  42572. tables['post'] = null;
  42573. var table;
  42574. for (var i = 0; i < numTables; i++) {
  42575. table = readTableEntry(font);
  42576. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42577. continue;
  42578. }
  42579. if (table.length === 0) {
  42580. continue;
  42581. }
  42582. tables[table.tag] = table;
  42583. }
  42584. var isTrueType = !tables['CFF '];
  42585. if (!isTrueType) {
  42586. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42587. cffFile = new Stream(tables['CFF '].data);
  42588. cff = new CFFFont(cffFile, properties);
  42589. adjustWidths(properties);
  42590. return this.convert(name, cff, properties);
  42591. }
  42592. delete tables['glyf'];
  42593. delete tables['loca'];
  42594. delete tables['fpgm'];
  42595. delete tables['prep'];
  42596. delete tables['cvt '];
  42597. this.isOpenType = true;
  42598. } else {
  42599. if (!tables['loca']) {
  42600. error('Required "loca" table is not found');
  42601. }
  42602. if (!tables['glyf']) {
  42603. warn('Required "glyf" table is not found -- trying to recover.');
  42604. tables['glyf'] = {
  42605. tag: 'glyf',
  42606. data: new Uint8Array(0)
  42607. };
  42608. }
  42609. this.isOpenType = false;
  42610. }
  42611. if (!tables['maxp']) {
  42612. error('Required "maxp" table is not found');
  42613. }
  42614. font.pos = (font.start || 0) + tables['maxp'].offset;
  42615. var version = font.getInt32();
  42616. var numGlyphs = font.getUint16();
  42617. var maxFunctionDefs = 0;
  42618. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42619. font.pos += 8;
  42620. var maxZones = font.getUint16();
  42621. if (maxZones > 2) {
  42622. tables['maxp'].data[14] = 0;
  42623. tables['maxp'].data[15] = 2;
  42624. }
  42625. font.pos += 4;
  42626. maxFunctionDefs = font.getUint16();
  42627. }
  42628. var dupFirstEntry = false;
  42629. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42630. dupFirstEntry = true;
  42631. numGlyphs++;
  42632. tables['maxp'].data[4] = numGlyphs >> 8;
  42633. tables['maxp'].data[5] = numGlyphs & 255;
  42634. }
  42635. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42636. if (!hintsValid) {
  42637. delete tables['fpgm'];
  42638. delete tables['prep'];
  42639. delete tables['cvt '];
  42640. }
  42641. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42642. if (!tables['head']) {
  42643. error('Required "head" table is not found');
  42644. }
  42645. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42646. var missingGlyphs = Object.create(null);
  42647. if (isTrueType) {
  42648. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42649. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42650. }
  42651. if (!tables['hhea']) {
  42652. error('Required "hhea" table is not found');
  42653. }
  42654. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42655. tables['hhea'].data[10] = 0xFF;
  42656. tables['hhea'].data[11] = 0xFF;
  42657. }
  42658. var metricsOverride = {
  42659. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42660. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42661. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42662. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42663. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42664. };
  42665. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42666. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42667. if (tables['post']) {
  42668. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42669. if (!valid) {
  42670. tables['post'] = null;
  42671. }
  42672. }
  42673. var charCodeToGlyphId = [], charCode;
  42674. var toUnicode = properties.toUnicode, widths = properties.widths;
  42675. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42676. function hasGlyph(glyphId, charCode, widthCode) {
  42677. if (!missingGlyphs[glyphId]) {
  42678. return true;
  42679. }
  42680. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42681. return true;
  42682. }
  42683. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42684. return true;
  42685. }
  42686. return false;
  42687. }
  42688. if (properties.type === 'CIDFontType2') {
  42689. var cidToGidMap = properties.cidToGidMap || [];
  42690. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42691. properties.cMap.forEach(function (charCode, cid) {
  42692. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42693. var glyphId = -1;
  42694. if (isCidToGidMapEmpty) {
  42695. glyphId = cid;
  42696. } else if (cidToGidMap[cid] !== undefined) {
  42697. glyphId = cidToGidMap[cid];
  42698. }
  42699. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42700. charCodeToGlyphId[charCode] = glyphId;
  42701. }
  42702. });
  42703. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42704. charCodeToGlyphId[0] = numGlyphs - 1;
  42705. }
  42706. } else {
  42707. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42708. var cmapPlatformId = cmapTable.platformId;
  42709. var cmapEncodingId = cmapTable.encodingId;
  42710. var cmapMappings = cmapTable.mappings;
  42711. var cmapMappingsLength = cmapMappings.length;
  42712. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42713. var baseEncoding = [];
  42714. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42715. baseEncoding = getEncoding(properties.baseEncodingName);
  42716. }
  42717. var glyphsUnicodeMap = getGlyphsUnicode();
  42718. for (charCode = 0; charCode < 256; charCode++) {
  42719. var glyphName, standardGlyphName;
  42720. if (this.differences && charCode in this.differences) {
  42721. glyphName = this.differences[charCode];
  42722. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42723. glyphName = baseEncoding[charCode];
  42724. } else {
  42725. glyphName = StandardEncoding[charCode];
  42726. }
  42727. if (!glyphName) {
  42728. continue;
  42729. }
  42730. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42731. var unicodeOrCharCode, isUnicode = false;
  42732. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42733. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42734. isUnicode = true;
  42735. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42736. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42737. }
  42738. var found = false;
  42739. for (i = 0; i < cmapMappingsLength; ++i) {
  42740. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42741. continue;
  42742. }
  42743. var code = isUnicode ? charCode : unicodeOrCharCode;
  42744. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42745. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42746. found = true;
  42747. break;
  42748. }
  42749. }
  42750. if (!found && properties.glyphNames) {
  42751. var glyphId = properties.glyphNames.indexOf(glyphName);
  42752. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42753. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42754. }
  42755. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42756. charCodeToGlyphId[charCode] = glyphId;
  42757. found = true;
  42758. }
  42759. }
  42760. if (!found) {
  42761. charCodeToGlyphId[charCode] = 0;
  42762. }
  42763. }
  42764. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42765. for (i = 0; i < cmapMappingsLength; ++i) {
  42766. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42767. }
  42768. } else {
  42769. for (i = 0; i < cmapMappingsLength; ++i) {
  42770. charCode = cmapMappings[i].charCode & 0xFF;
  42771. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42772. }
  42773. }
  42774. }
  42775. if (charCodeToGlyphId.length === 0) {
  42776. charCodeToGlyphId[0] = 0;
  42777. }
  42778. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42779. this.toFontChar = newMapping.toFontChar;
  42780. tables['cmap'] = {
  42781. tag: 'cmap',
  42782. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42783. };
  42784. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42785. tables['OS/2'] = {
  42786. tag: 'OS/2',
  42787. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42788. };
  42789. }
  42790. if (!tables['post']) {
  42791. tables['post'] = {
  42792. tag: 'post',
  42793. data: createPostTable(properties)
  42794. };
  42795. }
  42796. if (!isTrueType) {
  42797. try {
  42798. cffFile = new Stream(tables['CFF '].data);
  42799. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42800. cff = parser.parse();
  42801. var compiler = new CFFCompiler(cff);
  42802. tables['CFF '].data = compiler.compile();
  42803. } catch (e) {
  42804. warn('Failed to compile font ' + properties.loadedName);
  42805. }
  42806. }
  42807. if (!tables['name']) {
  42808. tables['name'] = {
  42809. tag: 'name',
  42810. data: createNameTable(this.name)
  42811. };
  42812. } else {
  42813. var namePrototype = readNameTable(tables['name']);
  42814. tables['name'].data = createNameTable(name, namePrototype);
  42815. }
  42816. var builder = new OpenTypeFileBuilder(header.version);
  42817. for (var tableTag in tables) {
  42818. builder.addTable(tableTag, tables[tableTag].data);
  42819. }
  42820. return builder.toArray();
  42821. },
  42822. convert: function Font_convert(fontName, font, properties) {
  42823. properties.fixedPitch = false;
  42824. if (properties.builtInEncoding) {
  42825. adjustToUnicode(properties, properties.builtInEncoding);
  42826. }
  42827. var mapping = font.getGlyphMapping(properties);
  42828. var newMapping = adjustMapping(mapping, properties);
  42829. this.toFontChar = newMapping.toFontChar;
  42830. var numGlyphs = font.numGlyphs;
  42831. function getCharCodes(charCodeToGlyphId, glyphId) {
  42832. var charCodes = null;
  42833. for (var charCode in charCodeToGlyphId) {
  42834. if (glyphId === charCodeToGlyphId[charCode]) {
  42835. if (!charCodes) {
  42836. charCodes = [];
  42837. }
  42838. charCodes.push(charCode | 0);
  42839. }
  42840. }
  42841. return charCodes;
  42842. }
  42843. function createCharCode(charCodeToGlyphId, glyphId) {
  42844. for (var charCode in charCodeToGlyphId) {
  42845. if (glyphId === charCodeToGlyphId[charCode]) {
  42846. return charCode | 0;
  42847. }
  42848. }
  42849. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42850. return newMapping.nextAvailableFontCharCode++;
  42851. }
  42852. var seacs = font.seacs;
  42853. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42854. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42855. var charset = font.getCharset();
  42856. var seacMap = Object.create(null);
  42857. for (var glyphId in seacs) {
  42858. glyphId |= 0;
  42859. var seac = seacs[glyphId];
  42860. var baseGlyphName = StandardEncoding[seac[2]];
  42861. var accentGlyphName = StandardEncoding[seac[3]];
  42862. var baseGlyphId = charset.indexOf(baseGlyphName);
  42863. var accentGlyphId = charset.indexOf(accentGlyphName);
  42864. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42865. continue;
  42866. }
  42867. var accentOffset = {
  42868. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42869. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42870. };
  42871. var charCodes = getCharCodes(mapping, glyphId);
  42872. if (!charCodes) {
  42873. continue;
  42874. }
  42875. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42876. var charCode = charCodes[i];
  42877. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42878. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42879. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42880. seacMap[charCode] = {
  42881. baseFontCharCode: baseFontCharCode,
  42882. accentFontCharCode: accentFontCharCode,
  42883. accentOffset: accentOffset
  42884. };
  42885. }
  42886. }
  42887. properties.seacMap = seacMap;
  42888. }
  42889. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42890. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42891. builder.addTable('CFF ', font.data);
  42892. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42893. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42894. 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');
  42895. 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));
  42896. builder.addTable('hmtx', function fontFieldsHmtx() {
  42897. var charstrings = font.charstrings;
  42898. var cffWidths = font.cff ? font.cff.widths : null;
  42899. var hmtx = '\x00\x00\x00\x00';
  42900. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42901. var width = 0;
  42902. if (charstrings) {
  42903. var charstring = charstrings[i - 1];
  42904. width = 'width' in charstring ? charstring.width : 0;
  42905. } else if (cffWidths) {
  42906. width = Math.ceil(cffWidths[i] || 0);
  42907. }
  42908. hmtx += string16(width) + string16(0);
  42909. }
  42910. return hmtx;
  42911. }());
  42912. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42913. builder.addTable('name', createNameTable(fontName));
  42914. builder.addTable('post', createPostTable(properties));
  42915. return builder.toArray();
  42916. },
  42917. get spaceWidth() {
  42918. if ('_shadowWidth' in this) {
  42919. return this._shadowWidth;
  42920. }
  42921. var possibleSpaceReplacements = [
  42922. 'space',
  42923. 'minus',
  42924. 'one',
  42925. 'i',
  42926. 'I'
  42927. ];
  42928. var width;
  42929. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42930. var glyphName = possibleSpaceReplacements[i];
  42931. if (glyphName in this.widths) {
  42932. width = this.widths[glyphName];
  42933. break;
  42934. }
  42935. var glyphsUnicodeMap = getGlyphsUnicode();
  42936. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42937. var charcode = 0;
  42938. if (this.composite) {
  42939. if (this.cMap.contains(glyphUnicode)) {
  42940. charcode = this.cMap.lookup(glyphUnicode);
  42941. }
  42942. }
  42943. if (!charcode && this.toUnicode) {
  42944. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42945. }
  42946. if (charcode <= 0) {
  42947. charcode = glyphUnicode;
  42948. }
  42949. width = this.widths[charcode];
  42950. if (width) {
  42951. break;
  42952. }
  42953. }
  42954. width = width || this.defaultWidth;
  42955. this._shadowWidth = width;
  42956. return width;
  42957. },
  42958. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42959. var fontCharCode, width, operatorListId;
  42960. var widthCode = charcode;
  42961. if (this.cMap && this.cMap.contains(charcode)) {
  42962. widthCode = this.cMap.lookup(charcode);
  42963. }
  42964. width = this.widths[widthCode];
  42965. width = isNum(width) ? width : this.defaultWidth;
  42966. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42967. var unicode = this.toUnicode.get(charcode) || charcode;
  42968. if (typeof unicode === 'number') {
  42969. unicode = String.fromCharCode(unicode);
  42970. }
  42971. var isInFont = charcode in this.toFontChar;
  42972. fontCharCode = this.toFontChar[charcode] || charcode;
  42973. if (this.missingFile) {
  42974. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42975. }
  42976. if (this.isType3Font) {
  42977. operatorListId = fontCharCode;
  42978. }
  42979. var accent = null;
  42980. if (this.seacMap && this.seacMap[charcode]) {
  42981. isInFont = true;
  42982. var seac = this.seacMap[charcode];
  42983. fontCharCode = seac.baseFontCharCode;
  42984. accent = {
  42985. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42986. offset: seac.accentOffset
  42987. };
  42988. }
  42989. var fontChar = String.fromCharCode(fontCharCode);
  42990. var glyph = this.glyphCache[charcode];
  42991. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42992. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42993. this.glyphCache[charcode] = glyph;
  42994. }
  42995. return glyph;
  42996. },
  42997. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42998. var charsCache = this.charsCache;
  42999. var glyphs, glyph, charcode;
  43000. if (charsCache) {
  43001. glyphs = charsCache[chars];
  43002. if (glyphs) {
  43003. return glyphs;
  43004. }
  43005. }
  43006. if (!charsCache) {
  43007. charsCache = this.charsCache = Object.create(null);
  43008. }
  43009. glyphs = [];
  43010. var charsCacheKey = chars;
  43011. var i = 0, ii;
  43012. if (this.cMap) {
  43013. var c = Object.create(null);
  43014. while (i < chars.length) {
  43015. this.cMap.readCharCode(chars, i, c);
  43016. charcode = c.charcode;
  43017. var length = c.length;
  43018. i += length;
  43019. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  43020. glyph = this.charToGlyph(charcode, isSpace);
  43021. glyphs.push(glyph);
  43022. }
  43023. } else {
  43024. for (i = 0, ii = chars.length; i < ii; ++i) {
  43025. charcode = chars.charCodeAt(i);
  43026. glyph = this.charToGlyph(charcode, charcode === 0x20);
  43027. glyphs.push(glyph);
  43028. }
  43029. }
  43030. return charsCache[charsCacheKey] = glyphs;
  43031. }
  43032. };
  43033. return Font;
  43034. }();
  43035. var ErrorFont = function ErrorFontClosure() {
  43036. function ErrorFont(error) {
  43037. this.error = error;
  43038. this.loadedName = 'g_font_error';
  43039. this.loading = false;
  43040. }
  43041. ErrorFont.prototype = {
  43042. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  43043. return [];
  43044. },
  43045. exportData: function ErrorFont_exportData() {
  43046. return { error: this.error };
  43047. }
  43048. };
  43049. return ErrorFont;
  43050. }();
  43051. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  43052. var charCodeToGlyphId = Object.create(null);
  43053. var glyphId, charCode, baseEncoding;
  43054. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43055. if (properties.baseEncodingName) {
  43056. baseEncoding = getEncoding(properties.baseEncodingName);
  43057. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  43058. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  43059. if (glyphId >= 0) {
  43060. charCodeToGlyphId[charCode] = glyphId;
  43061. } else {
  43062. charCodeToGlyphId[charCode] = 0;
  43063. }
  43064. }
  43065. } else if (isSymbolicFont) {
  43066. for (charCode in builtInEncoding) {
  43067. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  43068. }
  43069. } else {
  43070. baseEncoding = StandardEncoding;
  43071. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  43072. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  43073. if (glyphId >= 0) {
  43074. charCodeToGlyphId[charCode] = glyphId;
  43075. } else {
  43076. charCodeToGlyphId[charCode] = 0;
  43077. }
  43078. }
  43079. }
  43080. var differences = properties.differences, glyphsUnicodeMap;
  43081. if (differences) {
  43082. for (charCode in differences) {
  43083. var glyphName = differences[charCode];
  43084. glyphId = glyphNames.indexOf(glyphName);
  43085. if (glyphId === -1) {
  43086. if (!glyphsUnicodeMap) {
  43087. glyphsUnicodeMap = getGlyphsUnicode();
  43088. }
  43089. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  43090. if (standardGlyphName !== glyphName) {
  43091. glyphId = glyphNames.indexOf(standardGlyphName);
  43092. }
  43093. }
  43094. if (glyphId >= 0) {
  43095. charCodeToGlyphId[charCode] = glyphId;
  43096. } else {
  43097. charCodeToGlyphId[charCode] = 0;
  43098. }
  43099. }
  43100. }
  43101. return charCodeToGlyphId;
  43102. }
  43103. var Type1Font = function Type1FontClosure() {
  43104. function findBlock(streamBytes, signature, startIndex) {
  43105. var streamBytesLength = streamBytes.length;
  43106. var signatureLength = signature.length;
  43107. var scanLength = streamBytesLength - signatureLength;
  43108. var i = startIndex, j, found = false;
  43109. while (i < scanLength) {
  43110. j = 0;
  43111. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  43112. j++;
  43113. }
  43114. if (j >= signatureLength) {
  43115. i += j;
  43116. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  43117. i++;
  43118. }
  43119. found = true;
  43120. break;
  43121. }
  43122. i++;
  43123. }
  43124. return {
  43125. found: found,
  43126. length: i
  43127. };
  43128. }
  43129. function getHeaderBlock(stream, suggestedLength) {
  43130. var EEXEC_SIGNATURE = [
  43131. 0x65,
  43132. 0x65,
  43133. 0x78,
  43134. 0x65,
  43135. 0x63
  43136. ];
  43137. var streamStartPos = stream.pos;
  43138. var headerBytes, headerBytesLength, block;
  43139. try {
  43140. headerBytes = stream.getBytes(suggestedLength);
  43141. headerBytesLength = headerBytes.length;
  43142. } catch (ex) {
  43143. if (ex instanceof MissingDataException) {
  43144. throw ex;
  43145. }
  43146. }
  43147. if (headerBytesLength === suggestedLength) {
  43148. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  43149. if (block.found && block.length === suggestedLength) {
  43150. return {
  43151. stream: new Stream(headerBytes),
  43152. length: suggestedLength
  43153. };
  43154. }
  43155. }
  43156. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  43157. stream.pos = streamStartPos;
  43158. var SCAN_BLOCK_LENGTH = 2048;
  43159. var actualLength;
  43160. while (true) {
  43161. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  43162. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  43163. if (block.length === 0) {
  43164. break;
  43165. }
  43166. stream.pos += block.length;
  43167. if (block.found) {
  43168. actualLength = stream.pos - streamStartPos;
  43169. break;
  43170. }
  43171. }
  43172. stream.pos = streamStartPos;
  43173. if (actualLength) {
  43174. return {
  43175. stream: new Stream(stream.getBytes(actualLength)),
  43176. length: actualLength
  43177. };
  43178. }
  43179. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43180. return {
  43181. stream: new Stream(stream.getBytes(suggestedLength)),
  43182. length: suggestedLength
  43183. };
  43184. }
  43185. function getEexecBlock(stream, suggestedLength) {
  43186. var eexecBytes = stream.getBytes();
  43187. return {
  43188. stream: new Stream(eexecBytes),
  43189. length: eexecBytes.length
  43190. };
  43191. }
  43192. function Type1Font(name, file, properties) {
  43193. var PFB_HEADER_SIZE = 6;
  43194. var headerBlockLength = properties.length1;
  43195. var eexecBlockLength = properties.length2;
  43196. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43197. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43198. if (pfbHeaderPresent) {
  43199. file.skip(PFB_HEADER_SIZE);
  43200. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43201. }
  43202. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43203. headerBlockLength = headerBlock.length;
  43204. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43205. headerBlockParser.extractFontHeader(properties);
  43206. if (pfbHeaderPresent) {
  43207. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43208. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43209. }
  43210. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43211. eexecBlockLength = eexecBlock.length;
  43212. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43213. var data = eexecBlockParser.extractFontProgram();
  43214. for (var info in data.properties) {
  43215. properties[info] = data.properties[info];
  43216. }
  43217. var charstrings = data.charstrings;
  43218. var type2Charstrings = this.getType2Charstrings(charstrings);
  43219. var subrs = this.getType2Subrs(data.subrs);
  43220. this.charstrings = charstrings;
  43221. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43222. this.seacs = this.getSeacs(data.charstrings);
  43223. }
  43224. Type1Font.prototype = {
  43225. get numGlyphs() {
  43226. return this.charstrings.length + 1;
  43227. },
  43228. getCharset: function Type1Font_getCharset() {
  43229. var charset = ['.notdef'];
  43230. var charstrings = this.charstrings;
  43231. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43232. charset.push(charstrings[glyphId].glyphName);
  43233. }
  43234. return charset;
  43235. },
  43236. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43237. var charstrings = this.charstrings;
  43238. var glyphNames = ['.notdef'], glyphId;
  43239. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43240. glyphNames.push(charstrings[glyphId].glyphName);
  43241. }
  43242. var encoding = properties.builtInEncoding;
  43243. if (encoding) {
  43244. var builtInEncoding = Object.create(null);
  43245. for (var charCode in encoding) {
  43246. glyphId = glyphNames.indexOf(encoding[charCode]);
  43247. if (glyphId >= 0) {
  43248. builtInEncoding[charCode] = glyphId;
  43249. }
  43250. }
  43251. }
  43252. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43253. },
  43254. getSeacs: function Type1Font_getSeacs(charstrings) {
  43255. var i, ii;
  43256. var seacMap = [];
  43257. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43258. var charstring = charstrings[i];
  43259. if (charstring.seac) {
  43260. seacMap[i + 1] = charstring.seac;
  43261. }
  43262. }
  43263. return seacMap;
  43264. },
  43265. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43266. var type2Charstrings = [];
  43267. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43268. type2Charstrings.push(type1Charstrings[i].charstring);
  43269. }
  43270. return type2Charstrings;
  43271. },
  43272. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43273. var bias = 0;
  43274. var count = type1Subrs.length;
  43275. if (count < 1133) {
  43276. bias = 107;
  43277. } else if (count < 33769) {
  43278. bias = 1131;
  43279. } else {
  43280. bias = 32768;
  43281. }
  43282. var type2Subrs = [];
  43283. var i;
  43284. for (i = 0; i < bias; i++) {
  43285. type2Subrs.push([0x0B]);
  43286. }
  43287. for (i = 0; i < count; i++) {
  43288. type2Subrs.push(type1Subrs[i]);
  43289. }
  43290. return type2Subrs;
  43291. },
  43292. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43293. var cff = new CFF();
  43294. cff.header = new CFFHeader(1, 0, 4, 4);
  43295. cff.names = [name];
  43296. var topDict = new CFFTopDict();
  43297. topDict.setByName('version', 391);
  43298. topDict.setByName('Notice', 392);
  43299. topDict.setByName('FullName', 393);
  43300. topDict.setByName('FamilyName', 394);
  43301. topDict.setByName('Weight', 395);
  43302. topDict.setByName('Encoding', null);
  43303. topDict.setByName('FontMatrix', properties.fontMatrix);
  43304. topDict.setByName('FontBBox', properties.bbox);
  43305. topDict.setByName('charset', null);
  43306. topDict.setByName('CharStrings', null);
  43307. topDict.setByName('Private', null);
  43308. cff.topDict = topDict;
  43309. var strings = new CFFStrings();
  43310. strings.add('Version 0.11');
  43311. strings.add('See original notice');
  43312. strings.add(name);
  43313. strings.add(name);
  43314. strings.add('Medium');
  43315. cff.strings = strings;
  43316. cff.globalSubrIndex = new CFFIndex();
  43317. var count = glyphs.length;
  43318. var charsetArray = [0];
  43319. var i, ii;
  43320. for (i = 0; i < count; i++) {
  43321. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43322. if (index === -1) {
  43323. index = 0;
  43324. }
  43325. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43326. }
  43327. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43328. var charStringsIndex = new CFFIndex();
  43329. charStringsIndex.add([
  43330. 0x8B,
  43331. 0x0E
  43332. ]);
  43333. for (i = 0; i < count; i++) {
  43334. var glyph = glyphs[i];
  43335. if (glyph.length === 0) {
  43336. charStringsIndex.add([
  43337. 0x8B,
  43338. 0x0E
  43339. ]);
  43340. continue;
  43341. }
  43342. charStringsIndex.add(glyph);
  43343. }
  43344. cff.charStrings = charStringsIndex;
  43345. var privateDict = new CFFPrivateDict();
  43346. privateDict.setByName('Subrs', null);
  43347. var fields = [
  43348. 'BlueValues',
  43349. 'OtherBlues',
  43350. 'FamilyBlues',
  43351. 'FamilyOtherBlues',
  43352. 'StemSnapH',
  43353. 'StemSnapV',
  43354. 'BlueShift',
  43355. 'BlueFuzz',
  43356. 'BlueScale',
  43357. 'LanguageGroup',
  43358. 'ExpansionFactor',
  43359. 'ForceBold',
  43360. 'StdHW',
  43361. 'StdVW'
  43362. ];
  43363. for (i = 0, ii = fields.length; i < ii; i++) {
  43364. var field = fields[i];
  43365. if (!(field in properties.privateData)) {
  43366. continue;
  43367. }
  43368. var value = properties.privateData[field];
  43369. if (isArray(value)) {
  43370. for (var j = value.length - 1; j > 0; j--) {
  43371. value[j] -= value[j - 1];
  43372. }
  43373. }
  43374. privateDict.setByName(field, value);
  43375. }
  43376. cff.topDict.privateDict = privateDict;
  43377. var subrIndex = new CFFIndex();
  43378. for (i = 0, ii = subrs.length; i < ii; i++) {
  43379. subrIndex.add(subrs[i]);
  43380. }
  43381. privateDict.subrsIndex = subrIndex;
  43382. var compiler = new CFFCompiler(cff);
  43383. return compiler.compile();
  43384. }
  43385. };
  43386. return Type1Font;
  43387. }();
  43388. var CFFFont = function CFFFontClosure() {
  43389. function CFFFont(file, properties) {
  43390. this.properties = properties;
  43391. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43392. this.cff = parser.parse();
  43393. var compiler = new CFFCompiler(this.cff);
  43394. this.seacs = this.cff.seacs;
  43395. try {
  43396. this.data = compiler.compile();
  43397. } catch (e) {
  43398. warn('Failed to compile font ' + properties.loadedName);
  43399. this.data = file;
  43400. }
  43401. }
  43402. CFFFont.prototype = {
  43403. get numGlyphs() {
  43404. return this.cff.charStrings.count;
  43405. },
  43406. getCharset: function CFFFont_getCharset() {
  43407. return this.cff.charset.charset;
  43408. },
  43409. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43410. var cff = this.cff;
  43411. var properties = this.properties;
  43412. var charsets = cff.charset.charset;
  43413. var charCodeToGlyphId;
  43414. var glyphId;
  43415. if (properties.composite) {
  43416. charCodeToGlyphId = Object.create(null);
  43417. if (cff.isCIDFont) {
  43418. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43419. var cid = charsets[glyphId];
  43420. var charCode = properties.cMap.charCodeOf(cid);
  43421. charCodeToGlyphId[charCode] = glyphId;
  43422. }
  43423. } else {
  43424. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43425. charCodeToGlyphId[glyphId] = glyphId;
  43426. }
  43427. }
  43428. return charCodeToGlyphId;
  43429. }
  43430. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43431. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43432. return charCodeToGlyphId;
  43433. }
  43434. };
  43435. return CFFFont;
  43436. }();
  43437. (function checkSeacSupport() {
  43438. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43439. SEAC_ANALYSIS_ENABLED = true;
  43440. }
  43441. }());
  43442. (function checkChromeWindows() {
  43443. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43444. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43445. }
  43446. }());
  43447. exports.ErrorFont = ErrorFont;
  43448. exports.Font = Font;
  43449. exports.FontFlags = FontFlags;
  43450. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43451. exports.ToUnicodeMap = ToUnicodeMap;
  43452. exports.getFontType = getFontType;
  43453. }));
  43454. (function (root, factory) {
  43455. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43456. }(this, function (exports, sharedUtil, coreParser) {
  43457. var error = sharedUtil.error;
  43458. var isSpace = sharedUtil.isSpace;
  43459. var EOF = coreParser.EOF;
  43460. var PostScriptParser = function PostScriptParserClosure() {
  43461. function PostScriptParser(lexer) {
  43462. this.lexer = lexer;
  43463. this.operators = [];
  43464. this.token = null;
  43465. this.prev = null;
  43466. }
  43467. PostScriptParser.prototype = {
  43468. nextToken: function PostScriptParser_nextToken() {
  43469. this.prev = this.token;
  43470. this.token = this.lexer.getToken();
  43471. },
  43472. accept: function PostScriptParser_accept(type) {
  43473. if (this.token.type === type) {
  43474. this.nextToken();
  43475. return true;
  43476. }
  43477. return false;
  43478. },
  43479. expect: function PostScriptParser_expect(type) {
  43480. if (this.accept(type)) {
  43481. return true;
  43482. }
  43483. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43484. },
  43485. parse: function PostScriptParser_parse() {
  43486. this.nextToken();
  43487. this.expect(PostScriptTokenTypes.LBRACE);
  43488. this.parseBlock();
  43489. this.expect(PostScriptTokenTypes.RBRACE);
  43490. return this.operators;
  43491. },
  43492. parseBlock: function PostScriptParser_parseBlock() {
  43493. while (true) {
  43494. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43495. this.operators.push(this.prev.value);
  43496. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43497. this.operators.push(this.prev.value);
  43498. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43499. this.parseCondition();
  43500. } else {
  43501. return;
  43502. }
  43503. }
  43504. },
  43505. parseCondition: function PostScriptParser_parseCondition() {
  43506. var conditionLocation = this.operators.length;
  43507. this.operators.push(null, null);
  43508. this.parseBlock();
  43509. this.expect(PostScriptTokenTypes.RBRACE);
  43510. if (this.accept(PostScriptTokenTypes.IF)) {
  43511. this.operators[conditionLocation] = this.operators.length;
  43512. this.operators[conditionLocation + 1] = 'jz';
  43513. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43514. var jumpLocation = this.operators.length;
  43515. this.operators.push(null, null);
  43516. var endOfTrue = this.operators.length;
  43517. this.parseBlock();
  43518. this.expect(PostScriptTokenTypes.RBRACE);
  43519. this.expect(PostScriptTokenTypes.IFELSE);
  43520. this.operators[jumpLocation] = this.operators.length;
  43521. this.operators[jumpLocation + 1] = 'j';
  43522. this.operators[conditionLocation] = endOfTrue;
  43523. this.operators[conditionLocation + 1] = 'jz';
  43524. } else {
  43525. error('PS Function: error parsing conditional.');
  43526. }
  43527. }
  43528. };
  43529. return PostScriptParser;
  43530. }();
  43531. var PostScriptTokenTypes = {
  43532. LBRACE: 0,
  43533. RBRACE: 1,
  43534. NUMBER: 2,
  43535. OPERATOR: 3,
  43536. IF: 4,
  43537. IFELSE: 5
  43538. };
  43539. var PostScriptToken = function PostScriptTokenClosure() {
  43540. function PostScriptToken(type, value) {
  43541. this.type = type;
  43542. this.value = value;
  43543. }
  43544. var opCache = Object.create(null);
  43545. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43546. var opValue = opCache[op];
  43547. if (opValue) {
  43548. return opValue;
  43549. }
  43550. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43551. };
  43552. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43553. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43554. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43555. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43556. return PostScriptToken;
  43557. }();
  43558. var PostScriptLexer = function PostScriptLexerClosure() {
  43559. function PostScriptLexer(stream) {
  43560. this.stream = stream;
  43561. this.nextChar();
  43562. this.strBuf = [];
  43563. }
  43564. PostScriptLexer.prototype = {
  43565. nextChar: function PostScriptLexer_nextChar() {
  43566. return this.currentChar = this.stream.getByte();
  43567. },
  43568. getToken: function PostScriptLexer_getToken() {
  43569. var comment = false;
  43570. var ch = this.currentChar;
  43571. while (true) {
  43572. if (ch < 0) {
  43573. return EOF;
  43574. }
  43575. if (comment) {
  43576. if (ch === 0x0A || ch === 0x0D) {
  43577. comment = false;
  43578. }
  43579. } else if (ch === 0x25) {
  43580. comment = true;
  43581. } else if (!isSpace(ch)) {
  43582. break;
  43583. }
  43584. ch = this.nextChar();
  43585. }
  43586. switch (ch | 0) {
  43587. case 0x30:
  43588. case 0x31:
  43589. case 0x32:
  43590. case 0x33:
  43591. case 0x34:
  43592. case 0x35:
  43593. case 0x36:
  43594. case 0x37:
  43595. case 0x38:
  43596. case 0x39:
  43597. case 0x2B:
  43598. case 0x2D:
  43599. case 0x2E:
  43600. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43601. case 0x7B:
  43602. this.nextChar();
  43603. return PostScriptToken.LBRACE;
  43604. case 0x7D:
  43605. this.nextChar();
  43606. return PostScriptToken.RBRACE;
  43607. }
  43608. var strBuf = this.strBuf;
  43609. strBuf.length = 0;
  43610. strBuf[0] = String.fromCharCode(ch);
  43611. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43612. strBuf.push(String.fromCharCode(ch));
  43613. }
  43614. var str = strBuf.join('');
  43615. switch (str.toLowerCase()) {
  43616. case 'if':
  43617. return PostScriptToken.IF;
  43618. case 'ifelse':
  43619. return PostScriptToken.IFELSE;
  43620. default:
  43621. return PostScriptToken.getOperator(str);
  43622. }
  43623. },
  43624. getNumber: function PostScriptLexer_getNumber() {
  43625. var ch = this.currentChar;
  43626. var strBuf = this.strBuf;
  43627. strBuf.length = 0;
  43628. strBuf[0] = String.fromCharCode(ch);
  43629. while ((ch = this.nextChar()) >= 0) {
  43630. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43631. strBuf.push(String.fromCharCode(ch));
  43632. } else {
  43633. break;
  43634. }
  43635. }
  43636. var value = parseFloat(strBuf.join(''));
  43637. if (isNaN(value)) {
  43638. error('Invalid floating point number: ' + value);
  43639. }
  43640. return value;
  43641. }
  43642. };
  43643. return PostScriptLexer;
  43644. }();
  43645. exports.PostScriptLexer = PostScriptLexer;
  43646. exports.PostScriptParser = PostScriptParser;
  43647. }));
  43648. (function (root, factory) {
  43649. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43650. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43651. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43652. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43653. var ImageKind = sharedUtil.ImageKind;
  43654. var OPS = sharedUtil.OPS;
  43655. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43656. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43657. var Util = sharedUtil.Util;
  43658. var assert = sharedUtil.assert;
  43659. var info = sharedUtil.info;
  43660. var isNum = sharedUtil.isNum;
  43661. var isArray = sharedUtil.isArray;
  43662. var isLittleEndian = sharedUtil.isLittleEndian;
  43663. var error = sharedUtil.error;
  43664. var shadow = sharedUtil.shadow;
  43665. var warn = sharedUtil.warn;
  43666. var TilingPattern = displayPatternHelper.TilingPattern;
  43667. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43668. var WebGLUtils = displayWebGL.WebGLUtils;
  43669. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43670. var MIN_FONT_SIZE = 16;
  43671. var MAX_FONT_SIZE = 100;
  43672. var MAX_GROUP_SIZE = 4096;
  43673. var MIN_WIDTH_FACTOR = 0.65;
  43674. var COMPILE_TYPE3_GLYPHS = true;
  43675. var MAX_SIZE_TO_COMPILE = 1000;
  43676. var FULL_CHUNK_HEIGHT = 16;
  43677. var HasCanvasTypedArraysCached = {
  43678. get value() {
  43679. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43680. }
  43681. };
  43682. var IsLittleEndianCached = {
  43683. get value() {
  43684. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43685. }
  43686. };
  43687. function createScratchCanvas(width, height) {
  43688. var canvas = document.createElement('canvas');
  43689. canvas.width = width;
  43690. canvas.height = height;
  43691. return canvas;
  43692. }
  43693. function addContextCurrentTransform(ctx) {
  43694. if (!ctx.mozCurrentTransform) {
  43695. ctx._originalSave = ctx.save;
  43696. ctx._originalRestore = ctx.restore;
  43697. ctx._originalRotate = ctx.rotate;
  43698. ctx._originalScale = ctx.scale;
  43699. ctx._originalTranslate = ctx.translate;
  43700. ctx._originalTransform = ctx.transform;
  43701. ctx._originalSetTransform = ctx.setTransform;
  43702. ctx._transformMatrix = ctx._transformMatrix || [
  43703. 1,
  43704. 0,
  43705. 0,
  43706. 1,
  43707. 0,
  43708. 0
  43709. ];
  43710. ctx._transformStack = [];
  43711. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43712. get: function getCurrentTransform() {
  43713. return this._transformMatrix;
  43714. }
  43715. });
  43716. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43717. get: function getCurrentTransformInverse() {
  43718. var m = this._transformMatrix;
  43719. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43720. var ad_bc = a * d - b * c;
  43721. var bc_ad = b * c - a * d;
  43722. return [
  43723. d / ad_bc,
  43724. b / bc_ad,
  43725. c / bc_ad,
  43726. a / ad_bc,
  43727. (d * e - c * f) / bc_ad,
  43728. (b * e - a * f) / ad_bc
  43729. ];
  43730. }
  43731. });
  43732. ctx.save = function ctxSave() {
  43733. var old = this._transformMatrix;
  43734. this._transformStack.push(old);
  43735. this._transformMatrix = old.slice(0, 6);
  43736. this._originalSave();
  43737. };
  43738. ctx.restore = function ctxRestore() {
  43739. var prev = this._transformStack.pop();
  43740. if (prev) {
  43741. this._transformMatrix = prev;
  43742. this._originalRestore();
  43743. }
  43744. };
  43745. ctx.translate = function ctxTranslate(x, y) {
  43746. var m = this._transformMatrix;
  43747. m[4] = m[0] * x + m[2] * y + m[4];
  43748. m[5] = m[1] * x + m[3] * y + m[5];
  43749. this._originalTranslate(x, y);
  43750. };
  43751. ctx.scale = function ctxScale(x, y) {
  43752. var m = this._transformMatrix;
  43753. m[0] = m[0] * x;
  43754. m[1] = m[1] * x;
  43755. m[2] = m[2] * y;
  43756. m[3] = m[3] * y;
  43757. this._originalScale(x, y);
  43758. };
  43759. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43760. var m = this._transformMatrix;
  43761. this._transformMatrix = [
  43762. m[0] * a + m[2] * b,
  43763. m[1] * a + m[3] * b,
  43764. m[0] * c + m[2] * d,
  43765. m[1] * c + m[3] * d,
  43766. m[0] * e + m[2] * f + m[4],
  43767. m[1] * e + m[3] * f + m[5]
  43768. ];
  43769. ctx._originalTransform(a, b, c, d, e, f);
  43770. };
  43771. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43772. this._transformMatrix = [
  43773. a,
  43774. b,
  43775. c,
  43776. d,
  43777. e,
  43778. f
  43779. ];
  43780. ctx._originalSetTransform(a, b, c, d, e, f);
  43781. };
  43782. ctx.rotate = function ctxRotate(angle) {
  43783. var cosValue = Math.cos(angle);
  43784. var sinValue = Math.sin(angle);
  43785. var m = this._transformMatrix;
  43786. this._transformMatrix = [
  43787. m[0] * cosValue + m[2] * sinValue,
  43788. m[1] * cosValue + m[3] * sinValue,
  43789. m[0] * -sinValue + m[2] * cosValue,
  43790. m[1] * -sinValue + m[3] * cosValue,
  43791. m[4],
  43792. m[5]
  43793. ];
  43794. this._originalRotate(angle);
  43795. };
  43796. }
  43797. }
  43798. var CachedCanvases = function CachedCanvasesClosure() {
  43799. function CachedCanvases() {
  43800. this.cache = Object.create(null);
  43801. }
  43802. CachedCanvases.prototype = {
  43803. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43804. var canvasEntry;
  43805. if (this.cache[id] !== undefined) {
  43806. canvasEntry = this.cache[id];
  43807. canvasEntry.canvas.width = width;
  43808. canvasEntry.canvas.height = height;
  43809. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43810. } else {
  43811. var canvas = createScratchCanvas(width, height);
  43812. var ctx = canvas.getContext('2d');
  43813. if (trackTransform) {
  43814. addContextCurrentTransform(ctx);
  43815. }
  43816. this.cache[id] = canvasEntry = {
  43817. canvas: canvas,
  43818. context: ctx
  43819. };
  43820. }
  43821. return canvasEntry;
  43822. },
  43823. clear: function () {
  43824. for (var id in this.cache) {
  43825. var canvasEntry = this.cache[id];
  43826. canvasEntry.canvas.width = 0;
  43827. canvasEntry.canvas.height = 0;
  43828. delete this.cache[id];
  43829. }
  43830. }
  43831. };
  43832. return CachedCanvases;
  43833. }();
  43834. function compileType3Glyph(imgData) {
  43835. var POINT_TO_PROCESS_LIMIT = 1000;
  43836. var width = imgData.width, height = imgData.height;
  43837. var i, j, j0, width1 = width + 1;
  43838. var points = new Uint8Array(width1 * (height + 1));
  43839. var POINT_TYPES = new Uint8Array([
  43840. 0,
  43841. 2,
  43842. 4,
  43843. 0,
  43844. 1,
  43845. 0,
  43846. 5,
  43847. 4,
  43848. 8,
  43849. 10,
  43850. 0,
  43851. 8,
  43852. 0,
  43853. 2,
  43854. 1,
  43855. 0
  43856. ]);
  43857. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43858. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43859. for (i = 0, ii = data0.length; i < ii; i++) {
  43860. var mask = 128, elem = data0[i];
  43861. while (mask > 0) {
  43862. data[pos++] = elem & mask ? 0 : 255;
  43863. mask >>= 1;
  43864. }
  43865. }
  43866. var count = 0;
  43867. pos = 0;
  43868. if (data[pos] !== 0) {
  43869. points[0] = 1;
  43870. ++count;
  43871. }
  43872. for (j = 1; j < width; j++) {
  43873. if (data[pos] !== data[pos + 1]) {
  43874. points[j] = data[pos] ? 2 : 1;
  43875. ++count;
  43876. }
  43877. pos++;
  43878. }
  43879. if (data[pos] !== 0) {
  43880. points[j] = 2;
  43881. ++count;
  43882. }
  43883. for (i = 1; i < height; i++) {
  43884. pos = i * lineSize;
  43885. j0 = i * width1;
  43886. if (data[pos - lineSize] !== data[pos]) {
  43887. points[j0] = data[pos] ? 1 : 8;
  43888. ++count;
  43889. }
  43890. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43891. for (j = 1; j < width; j++) {
  43892. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43893. if (POINT_TYPES[sum]) {
  43894. points[j0 + j] = POINT_TYPES[sum];
  43895. ++count;
  43896. }
  43897. pos++;
  43898. }
  43899. if (data[pos - lineSize] !== data[pos]) {
  43900. points[j0 + j] = data[pos] ? 2 : 4;
  43901. ++count;
  43902. }
  43903. if (count > POINT_TO_PROCESS_LIMIT) {
  43904. return null;
  43905. }
  43906. }
  43907. pos = lineSize * (height - 1);
  43908. j0 = i * width1;
  43909. if (data[pos] !== 0) {
  43910. points[j0] = 8;
  43911. ++count;
  43912. }
  43913. for (j = 1; j < width; j++) {
  43914. if (data[pos] !== data[pos + 1]) {
  43915. points[j0 + j] = data[pos] ? 4 : 8;
  43916. ++count;
  43917. }
  43918. pos++;
  43919. }
  43920. if (data[pos] !== 0) {
  43921. points[j0 + j] = 4;
  43922. ++count;
  43923. }
  43924. if (count > POINT_TO_PROCESS_LIMIT) {
  43925. return null;
  43926. }
  43927. var steps = new Int32Array([
  43928. 0,
  43929. width1,
  43930. -1,
  43931. 0,
  43932. -width1,
  43933. 0,
  43934. 0,
  43935. 0,
  43936. 1
  43937. ]);
  43938. var outlines = [];
  43939. for (i = 0; count && i <= height; i++) {
  43940. var p = i * width1;
  43941. var end = p + width;
  43942. while (p < end && !points[p]) {
  43943. p++;
  43944. }
  43945. if (p === end) {
  43946. continue;
  43947. }
  43948. var coords = [
  43949. p % width1,
  43950. i
  43951. ];
  43952. var type = points[p], p0 = p, pp;
  43953. do {
  43954. var step = steps[type];
  43955. do {
  43956. p += step;
  43957. } while (!points[p]);
  43958. pp = points[p];
  43959. if (pp !== 5 && pp !== 10) {
  43960. type = pp;
  43961. points[p] = 0;
  43962. } else {
  43963. type = pp & 0x33 * type >> 4;
  43964. points[p] &= type >> 2 | type << 2;
  43965. }
  43966. coords.push(p % width1);
  43967. coords.push(p / width1 | 0);
  43968. --count;
  43969. } while (p0 !== p);
  43970. outlines.push(coords);
  43971. --i;
  43972. }
  43973. var drawOutline = function (c) {
  43974. c.save();
  43975. c.scale(1 / width, -1 / height);
  43976. c.translate(0, -height);
  43977. c.beginPath();
  43978. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43979. var o = outlines[i];
  43980. c.moveTo(o[0], o[1]);
  43981. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43982. c.lineTo(o[j], o[j + 1]);
  43983. }
  43984. }
  43985. c.fill();
  43986. c.beginPath();
  43987. c.restore();
  43988. };
  43989. return drawOutline;
  43990. }
  43991. var CanvasExtraState = function CanvasExtraStateClosure() {
  43992. function CanvasExtraState(old) {
  43993. this.alphaIsShape = false;
  43994. this.fontSize = 0;
  43995. this.fontSizeScale = 1;
  43996. this.textMatrix = IDENTITY_MATRIX;
  43997. this.textMatrixScale = 1;
  43998. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43999. this.leading = 0;
  44000. this.x = 0;
  44001. this.y = 0;
  44002. this.lineX = 0;
  44003. this.lineY = 0;
  44004. this.charSpacing = 0;
  44005. this.wordSpacing = 0;
  44006. this.textHScale = 1;
  44007. this.textRenderingMode = TextRenderingMode.FILL;
  44008. this.textRise = 0;
  44009. this.fillColor = '#000000';
  44010. this.strokeColor = '#000000';
  44011. this.patternFill = false;
  44012. this.fillAlpha = 1;
  44013. this.strokeAlpha = 1;
  44014. this.lineWidth = 1;
  44015. this.activeSMask = null;
  44016. this.resumeSMaskCtx = null;
  44017. this.old = old;
  44018. }
  44019. CanvasExtraState.prototype = {
  44020. clone: function CanvasExtraState_clone() {
  44021. return Object.create(this);
  44022. },
  44023. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  44024. this.x = x;
  44025. this.y = y;
  44026. }
  44027. };
  44028. return CanvasExtraState;
  44029. }();
  44030. var CanvasGraphics = function CanvasGraphicsClosure() {
  44031. var EXECUTION_TIME = 15;
  44032. var EXECUTION_STEPS = 10;
  44033. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  44034. this.ctx = canvasCtx;
  44035. this.current = new CanvasExtraState();
  44036. this.stateStack = [];
  44037. this.pendingClip = null;
  44038. this.pendingEOFill = false;
  44039. this.res = null;
  44040. this.xobjs = null;
  44041. this.commonObjs = commonObjs;
  44042. this.objs = objs;
  44043. this.imageLayer = imageLayer;
  44044. this.groupStack = [];
  44045. this.processingType3 = null;
  44046. this.baseTransform = null;
  44047. this.baseTransformStack = [];
  44048. this.groupLevel = 0;
  44049. this.smaskStack = [];
  44050. this.smaskCounter = 0;
  44051. this.tempSMask = null;
  44052. this.cachedCanvases = new CachedCanvases();
  44053. if (canvasCtx) {
  44054. addContextCurrentTransform(canvasCtx);
  44055. }
  44056. this.cachedGetSinglePixelWidth = null;
  44057. }
  44058. function putBinaryImageData(ctx, imgData) {
  44059. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  44060. ctx.putImageData(imgData, 0, 0);
  44061. return;
  44062. }
  44063. var height = imgData.height, width = imgData.width;
  44064. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  44065. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  44066. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  44067. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  44068. var srcPos = 0, destPos;
  44069. var src = imgData.data;
  44070. var dest = chunkImgData.data;
  44071. var i, j, thisChunkHeight, elemsInThisChunk;
  44072. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  44073. var srcLength = src.byteLength;
  44074. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  44075. var dest32DataLength = dest32.length;
  44076. var fullSrcDiff = width + 7 >> 3;
  44077. var white = 0xFFFFFFFF;
  44078. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  44079. for (i = 0; i < totalChunks; i++) {
  44080. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  44081. destPos = 0;
  44082. for (j = 0; j < thisChunkHeight; j++) {
  44083. var srcDiff = srcLength - srcPos;
  44084. var k = 0;
  44085. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  44086. var kEndUnrolled = kEnd & ~7;
  44087. var mask = 0;
  44088. var srcByte = 0;
  44089. for (; k < kEndUnrolled; k += 8) {
  44090. srcByte = src[srcPos++];
  44091. dest32[destPos++] = srcByte & 128 ? white : black;
  44092. dest32[destPos++] = srcByte & 64 ? white : black;
  44093. dest32[destPos++] = srcByte & 32 ? white : black;
  44094. dest32[destPos++] = srcByte & 16 ? white : black;
  44095. dest32[destPos++] = srcByte & 8 ? white : black;
  44096. dest32[destPos++] = srcByte & 4 ? white : black;
  44097. dest32[destPos++] = srcByte & 2 ? white : black;
  44098. dest32[destPos++] = srcByte & 1 ? white : black;
  44099. }
  44100. for (; k < kEnd; k++) {
  44101. if (mask === 0) {
  44102. srcByte = src[srcPos++];
  44103. mask = 128;
  44104. }
  44105. dest32[destPos++] = srcByte & mask ? white : black;
  44106. mask >>= 1;
  44107. }
  44108. }
  44109. while (destPos < dest32DataLength) {
  44110. dest32[destPos++] = 0;
  44111. }
  44112. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44113. }
  44114. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  44115. j = 0;
  44116. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  44117. for (i = 0; i < fullChunks; i++) {
  44118. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  44119. srcPos += elemsInThisChunk;
  44120. ctx.putImageData(chunkImgData, 0, j);
  44121. j += FULL_CHUNK_HEIGHT;
  44122. }
  44123. if (i < totalChunks) {
  44124. elemsInThisChunk = width * partialChunkHeight * 4;
  44125. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  44126. ctx.putImageData(chunkImgData, 0, j);
  44127. }
  44128. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  44129. thisChunkHeight = FULL_CHUNK_HEIGHT;
  44130. elemsInThisChunk = width * thisChunkHeight;
  44131. for (i = 0; i < totalChunks; i++) {
  44132. if (i >= fullChunks) {
  44133. thisChunkHeight = partialChunkHeight;
  44134. elemsInThisChunk = width * thisChunkHeight;
  44135. }
  44136. destPos = 0;
  44137. for (j = elemsInThisChunk; j--;) {
  44138. dest[destPos++] = src[srcPos++];
  44139. dest[destPos++] = src[srcPos++];
  44140. dest[destPos++] = src[srcPos++];
  44141. dest[destPos++] = 255;
  44142. }
  44143. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44144. }
  44145. } else {
  44146. error('bad image kind: ' + imgData.kind);
  44147. }
  44148. }
  44149. function putBinaryImageMask(ctx, imgData) {
  44150. var height = imgData.height, width = imgData.width;
  44151. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  44152. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  44153. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  44154. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  44155. var srcPos = 0;
  44156. var src = imgData.data;
  44157. var dest = chunkImgData.data;
  44158. for (var i = 0; i < totalChunks; i++) {
  44159. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  44160. var destPos = 3;
  44161. for (var j = 0; j < thisChunkHeight; j++) {
  44162. var mask = 0;
  44163. for (var k = 0; k < width; k++) {
  44164. if (!mask) {
  44165. var elem = src[srcPos++];
  44166. mask = 128;
  44167. }
  44168. dest[destPos] = elem & mask ? 0 : 255;
  44169. destPos += 4;
  44170. mask >>= 1;
  44171. }
  44172. }
  44173. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44174. }
  44175. }
  44176. function copyCtxState(sourceCtx, destCtx) {
  44177. var properties = [
  44178. 'strokeStyle',
  44179. 'fillStyle',
  44180. 'fillRule',
  44181. 'globalAlpha',
  44182. 'lineWidth',
  44183. 'lineCap',
  44184. 'lineJoin',
  44185. 'miterLimit',
  44186. 'globalCompositeOperation',
  44187. 'font'
  44188. ];
  44189. for (var i = 0, ii = properties.length; i < ii; i++) {
  44190. var property = properties[i];
  44191. if (sourceCtx[property] !== undefined) {
  44192. destCtx[property] = sourceCtx[property];
  44193. }
  44194. }
  44195. if (sourceCtx.setLineDash !== undefined) {
  44196. destCtx.setLineDash(sourceCtx.getLineDash());
  44197. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44198. }
  44199. }
  44200. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44201. var length = bytes.length;
  44202. for (var i = 3; i < length; i += 4) {
  44203. var alpha = bytes[i];
  44204. if (alpha === 0) {
  44205. bytes[i - 3] = r0;
  44206. bytes[i - 2] = g0;
  44207. bytes[i - 1] = b0;
  44208. } else if (alpha < 255) {
  44209. var alpha_ = 255 - alpha;
  44210. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44211. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44212. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44213. }
  44214. }
  44215. }
  44216. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44217. var length = maskData.length;
  44218. var scale = 1 / 255;
  44219. for (var i = 3; i < length; i += 4) {
  44220. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44221. layerData[i] = layerData[i] * alpha * scale | 0;
  44222. }
  44223. }
  44224. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44225. var length = maskData.length;
  44226. for (var i = 3; i < length; i += 4) {
  44227. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44228. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44229. }
  44230. }
  44231. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44232. var hasBackdrop = !!backdrop;
  44233. var r0 = hasBackdrop ? backdrop[0] : 0;
  44234. var g0 = hasBackdrop ? backdrop[1] : 0;
  44235. var b0 = hasBackdrop ? backdrop[2] : 0;
  44236. var composeFn;
  44237. if (subtype === 'Luminosity') {
  44238. composeFn = composeSMaskLuminosity;
  44239. } else {
  44240. composeFn = composeSMaskAlpha;
  44241. }
  44242. var PIXELS_TO_PROCESS = 1048576;
  44243. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44244. for (var row = 0; row < height; row += chunkSize) {
  44245. var chunkHeight = Math.min(chunkSize, height - row);
  44246. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44247. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44248. if (hasBackdrop) {
  44249. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44250. }
  44251. composeFn(maskData.data, layerData.data, transferMap);
  44252. maskCtx.putImageData(layerData, 0, row);
  44253. }
  44254. }
  44255. function composeSMask(ctx, smask, layerCtx) {
  44256. var mask = smask.canvas;
  44257. var maskCtx = smask.context;
  44258. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44259. var backdrop = smask.backdrop || null;
  44260. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44261. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44262. subtype: smask.subtype,
  44263. backdrop: backdrop
  44264. });
  44265. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44266. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44267. return;
  44268. }
  44269. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44270. ctx.drawImage(mask, 0, 0);
  44271. }
  44272. var LINE_CAP_STYLES = [
  44273. 'butt',
  44274. 'round',
  44275. 'square'
  44276. ];
  44277. var LINE_JOIN_STYLES = [
  44278. 'miter',
  44279. 'round',
  44280. 'bevel'
  44281. ];
  44282. var NORMAL_CLIP = {};
  44283. var EO_CLIP = {};
  44284. CanvasGraphics.prototype = {
  44285. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44286. var width = this.ctx.canvas.width;
  44287. var height = this.ctx.canvas.height;
  44288. this.ctx.save();
  44289. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44290. this.ctx.fillRect(0, 0, width, height);
  44291. this.ctx.restore();
  44292. if (transparency) {
  44293. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44294. this.compositeCtx = this.ctx;
  44295. this.transparentCanvas = transparentCanvas.canvas;
  44296. this.ctx = transparentCanvas.context;
  44297. this.ctx.save();
  44298. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44299. }
  44300. this.ctx.save();
  44301. if (transform) {
  44302. this.ctx.transform.apply(this.ctx, transform);
  44303. }
  44304. this.ctx.transform.apply(this.ctx, viewport.transform);
  44305. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44306. if (this.imageLayer) {
  44307. this.imageLayer.beginLayout();
  44308. }
  44309. },
  44310. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44311. var argsArray = operatorList.argsArray;
  44312. var fnArray = operatorList.fnArray;
  44313. var i = executionStartIdx || 0;
  44314. var argsArrayLen = argsArray.length;
  44315. if (argsArrayLen === i) {
  44316. return i;
  44317. }
  44318. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44319. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44320. var steps = 0;
  44321. var commonObjs = this.commonObjs;
  44322. var objs = this.objs;
  44323. var fnId;
  44324. while (true) {
  44325. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44326. stepper.breakIt(i, continueCallback);
  44327. return i;
  44328. }
  44329. fnId = fnArray[i];
  44330. if (fnId !== OPS.dependency) {
  44331. this[fnId].apply(this, argsArray[i]);
  44332. } else {
  44333. var deps = argsArray[i];
  44334. for (var n = 0, nn = deps.length; n < nn; n++) {
  44335. var depObjId = deps[n];
  44336. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44337. var objsPool = common ? commonObjs : objs;
  44338. if (!objsPool.isResolved(depObjId)) {
  44339. objsPool.get(depObjId, continueCallback);
  44340. return i;
  44341. }
  44342. }
  44343. }
  44344. i++;
  44345. if (i === argsArrayLen) {
  44346. return i;
  44347. }
  44348. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44349. if (Date.now() > endTime) {
  44350. continueCallback();
  44351. return i;
  44352. }
  44353. steps = 0;
  44354. }
  44355. }
  44356. },
  44357. endDrawing: function CanvasGraphics_endDrawing() {
  44358. if (this.current.activeSMask !== null) {
  44359. this.endSMaskGroup();
  44360. }
  44361. this.ctx.restore();
  44362. if (this.transparentCanvas) {
  44363. this.ctx = this.compositeCtx;
  44364. this.ctx.save();
  44365. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44366. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44367. this.ctx.restore();
  44368. this.transparentCanvas = null;
  44369. }
  44370. this.cachedCanvases.clear();
  44371. WebGLUtils.clear();
  44372. if (this.imageLayer) {
  44373. this.imageLayer.endLayout();
  44374. }
  44375. },
  44376. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44377. this.current.lineWidth = width;
  44378. this.ctx.lineWidth = width;
  44379. },
  44380. setLineCap: function CanvasGraphics_setLineCap(style) {
  44381. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44382. },
  44383. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44384. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44385. },
  44386. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44387. this.ctx.miterLimit = limit;
  44388. },
  44389. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44390. var ctx = this.ctx;
  44391. if (ctx.setLineDash !== undefined) {
  44392. ctx.setLineDash(dashArray);
  44393. ctx.lineDashOffset = dashPhase;
  44394. }
  44395. },
  44396. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44397. },
  44398. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44399. },
  44400. setGState: function CanvasGraphics_setGState(states) {
  44401. for (var i = 0, ii = states.length; i < ii; i++) {
  44402. var state = states[i];
  44403. var key = state[0];
  44404. var value = state[1];
  44405. switch (key) {
  44406. case 'LW':
  44407. this.setLineWidth(value);
  44408. break;
  44409. case 'LC':
  44410. this.setLineCap(value);
  44411. break;
  44412. case 'LJ':
  44413. this.setLineJoin(value);
  44414. break;
  44415. case 'ML':
  44416. this.setMiterLimit(value);
  44417. break;
  44418. case 'D':
  44419. this.setDash(value[0], value[1]);
  44420. break;
  44421. case 'RI':
  44422. this.setRenderingIntent(value);
  44423. break;
  44424. case 'FL':
  44425. this.setFlatness(value);
  44426. break;
  44427. case 'Font':
  44428. this.setFont(value[0], value[1]);
  44429. break;
  44430. case 'CA':
  44431. this.current.strokeAlpha = state[1];
  44432. break;
  44433. case 'ca':
  44434. this.current.fillAlpha = state[1];
  44435. this.ctx.globalAlpha = state[1];
  44436. break;
  44437. case 'BM':
  44438. if (value && value.name && value.name !== 'Normal') {
  44439. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44440. return '-' + c.toLowerCase();
  44441. }).substring(1);
  44442. this.ctx.globalCompositeOperation = mode;
  44443. if (this.ctx.globalCompositeOperation !== mode) {
  44444. warn('globalCompositeOperation "' + mode + '" is not supported');
  44445. }
  44446. } else {
  44447. this.ctx.globalCompositeOperation = 'source-over';
  44448. }
  44449. break;
  44450. case 'SMask':
  44451. if (this.current.activeSMask) {
  44452. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44453. this.suspendSMaskGroup();
  44454. } else {
  44455. this.endSMaskGroup();
  44456. }
  44457. }
  44458. this.current.activeSMask = value ? this.tempSMask : null;
  44459. if (this.current.activeSMask) {
  44460. this.beginSMaskGroup();
  44461. }
  44462. this.tempSMask = null;
  44463. break;
  44464. }
  44465. }
  44466. },
  44467. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44468. var activeSMask = this.current.activeSMask;
  44469. var drawnWidth = activeSMask.canvas.width;
  44470. var drawnHeight = activeSMask.canvas.height;
  44471. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44472. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44473. var currentCtx = this.ctx;
  44474. var currentTransform = currentCtx.mozCurrentTransform;
  44475. this.ctx.save();
  44476. var groupCtx = scratchCanvas.context;
  44477. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44478. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44479. groupCtx.transform.apply(groupCtx, currentTransform);
  44480. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44481. copyCtxState(currentCtx, groupCtx);
  44482. this.ctx = groupCtx;
  44483. this.setGState([
  44484. [
  44485. 'BM',
  44486. 'Normal'
  44487. ],
  44488. [
  44489. 'ca',
  44490. 1
  44491. ],
  44492. [
  44493. 'CA',
  44494. 1
  44495. ]
  44496. ]);
  44497. this.groupStack.push(currentCtx);
  44498. this.groupLevel++;
  44499. },
  44500. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44501. var groupCtx = this.ctx;
  44502. this.groupLevel--;
  44503. this.ctx = this.groupStack.pop();
  44504. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44505. this.ctx.restore();
  44506. this.ctx.save();
  44507. copyCtxState(groupCtx, this.ctx);
  44508. this.current.resumeSMaskCtx = groupCtx;
  44509. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44510. this.ctx.transform.apply(this.ctx, deltaTransform);
  44511. groupCtx.save();
  44512. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44513. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44514. groupCtx.restore();
  44515. },
  44516. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44517. var groupCtx = this.current.resumeSMaskCtx;
  44518. var currentCtx = this.ctx;
  44519. this.ctx = groupCtx;
  44520. this.groupStack.push(currentCtx);
  44521. this.groupLevel++;
  44522. },
  44523. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44524. var groupCtx = this.ctx;
  44525. this.groupLevel--;
  44526. this.ctx = this.groupStack.pop();
  44527. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44528. this.ctx.restore();
  44529. copyCtxState(groupCtx, this.ctx);
  44530. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44531. this.ctx.transform.apply(this.ctx, deltaTransform);
  44532. },
  44533. save: function CanvasGraphics_save() {
  44534. this.ctx.save();
  44535. var old = this.current;
  44536. this.stateStack.push(old);
  44537. this.current = old.clone();
  44538. this.current.resumeSMaskCtx = null;
  44539. },
  44540. restore: function CanvasGraphics_restore() {
  44541. if (this.current.resumeSMaskCtx) {
  44542. this.resumeSMaskGroup();
  44543. }
  44544. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44545. this.endSMaskGroup();
  44546. }
  44547. if (this.stateStack.length !== 0) {
  44548. this.current = this.stateStack.pop();
  44549. this.ctx.restore();
  44550. this.pendingClip = null;
  44551. this.cachedGetSinglePixelWidth = null;
  44552. }
  44553. },
  44554. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44555. this.ctx.transform(a, b, c, d, e, f);
  44556. this.cachedGetSinglePixelWidth = null;
  44557. },
  44558. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44559. var ctx = this.ctx;
  44560. var current = this.current;
  44561. var x = current.x, y = current.y;
  44562. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44563. switch (ops[i] | 0) {
  44564. case OPS.rectangle:
  44565. x = args[j++];
  44566. y = args[j++];
  44567. var width = args[j++];
  44568. var height = args[j++];
  44569. if (width === 0) {
  44570. width = this.getSinglePixelWidth();
  44571. }
  44572. if (height === 0) {
  44573. height = this.getSinglePixelWidth();
  44574. }
  44575. var xw = x + width;
  44576. var yh = y + height;
  44577. this.ctx.moveTo(x, y);
  44578. this.ctx.lineTo(xw, y);
  44579. this.ctx.lineTo(xw, yh);
  44580. this.ctx.lineTo(x, yh);
  44581. this.ctx.lineTo(x, y);
  44582. this.ctx.closePath();
  44583. break;
  44584. case OPS.moveTo:
  44585. x = args[j++];
  44586. y = args[j++];
  44587. ctx.moveTo(x, y);
  44588. break;
  44589. case OPS.lineTo:
  44590. x = args[j++];
  44591. y = args[j++];
  44592. ctx.lineTo(x, y);
  44593. break;
  44594. case OPS.curveTo:
  44595. x = args[j + 4];
  44596. y = args[j + 5];
  44597. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44598. j += 6;
  44599. break;
  44600. case OPS.curveTo2:
  44601. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44602. x = args[j + 2];
  44603. y = args[j + 3];
  44604. j += 4;
  44605. break;
  44606. case OPS.curveTo3:
  44607. x = args[j + 2];
  44608. y = args[j + 3];
  44609. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44610. j += 4;
  44611. break;
  44612. case OPS.closePath:
  44613. ctx.closePath();
  44614. break;
  44615. }
  44616. }
  44617. current.setCurrentPoint(x, y);
  44618. },
  44619. closePath: function CanvasGraphics_closePath() {
  44620. this.ctx.closePath();
  44621. },
  44622. stroke: function CanvasGraphics_stroke(consumePath) {
  44623. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44624. var ctx = this.ctx;
  44625. var strokeColor = this.current.strokeColor;
  44626. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44627. ctx.globalAlpha = this.current.strokeAlpha;
  44628. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44629. ctx.save();
  44630. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44631. ctx.stroke();
  44632. ctx.restore();
  44633. } else {
  44634. ctx.stroke();
  44635. }
  44636. if (consumePath) {
  44637. this.consumePath();
  44638. }
  44639. ctx.globalAlpha = this.current.fillAlpha;
  44640. },
  44641. closeStroke: function CanvasGraphics_closeStroke() {
  44642. this.closePath();
  44643. this.stroke();
  44644. },
  44645. fill: function CanvasGraphics_fill(consumePath) {
  44646. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44647. var ctx = this.ctx;
  44648. var fillColor = this.current.fillColor;
  44649. var isPatternFill = this.current.patternFill;
  44650. var needRestore = false;
  44651. if (isPatternFill) {
  44652. ctx.save();
  44653. if (this.baseTransform) {
  44654. ctx.setTransform.apply(ctx, this.baseTransform);
  44655. }
  44656. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44657. needRestore = true;
  44658. }
  44659. if (this.pendingEOFill) {
  44660. if (ctx.mozFillRule !== undefined) {
  44661. ctx.mozFillRule = 'evenodd';
  44662. ctx.fill();
  44663. ctx.mozFillRule = 'nonzero';
  44664. } else {
  44665. ctx.fill('evenodd');
  44666. }
  44667. this.pendingEOFill = false;
  44668. } else {
  44669. ctx.fill();
  44670. }
  44671. if (needRestore) {
  44672. ctx.restore();
  44673. }
  44674. if (consumePath) {
  44675. this.consumePath();
  44676. }
  44677. },
  44678. eoFill: function CanvasGraphics_eoFill() {
  44679. this.pendingEOFill = true;
  44680. this.fill();
  44681. },
  44682. fillStroke: function CanvasGraphics_fillStroke() {
  44683. this.fill(false);
  44684. this.stroke(false);
  44685. this.consumePath();
  44686. },
  44687. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44688. this.pendingEOFill = true;
  44689. this.fillStroke();
  44690. },
  44691. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44692. this.closePath();
  44693. this.fillStroke();
  44694. },
  44695. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44696. this.pendingEOFill = true;
  44697. this.closePath();
  44698. this.fillStroke();
  44699. },
  44700. endPath: function CanvasGraphics_endPath() {
  44701. this.consumePath();
  44702. },
  44703. clip: function CanvasGraphics_clip() {
  44704. this.pendingClip = NORMAL_CLIP;
  44705. },
  44706. eoClip: function CanvasGraphics_eoClip() {
  44707. this.pendingClip = EO_CLIP;
  44708. },
  44709. beginText: function CanvasGraphics_beginText() {
  44710. this.current.textMatrix = IDENTITY_MATRIX;
  44711. this.current.textMatrixScale = 1;
  44712. this.current.x = this.current.lineX = 0;
  44713. this.current.y = this.current.lineY = 0;
  44714. },
  44715. endText: function CanvasGraphics_endText() {
  44716. var paths = this.pendingTextPaths;
  44717. var ctx = this.ctx;
  44718. if (paths === undefined) {
  44719. ctx.beginPath();
  44720. return;
  44721. }
  44722. ctx.save();
  44723. ctx.beginPath();
  44724. for (var i = 0; i < paths.length; i++) {
  44725. var path = paths[i];
  44726. ctx.setTransform.apply(ctx, path.transform);
  44727. ctx.translate(path.x, path.y);
  44728. path.addToPath(ctx, path.fontSize);
  44729. }
  44730. ctx.restore();
  44731. ctx.clip();
  44732. ctx.beginPath();
  44733. delete this.pendingTextPaths;
  44734. },
  44735. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44736. this.current.charSpacing = spacing;
  44737. },
  44738. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44739. this.current.wordSpacing = spacing;
  44740. },
  44741. setHScale: function CanvasGraphics_setHScale(scale) {
  44742. this.current.textHScale = scale / 100;
  44743. },
  44744. setLeading: function CanvasGraphics_setLeading(leading) {
  44745. this.current.leading = -leading;
  44746. },
  44747. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44748. var fontObj = this.commonObjs.get(fontRefName);
  44749. var current = this.current;
  44750. if (!fontObj) {
  44751. error('Can\'t find font for ' + fontRefName);
  44752. }
  44753. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44754. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44755. warn('Invalid font matrix for font ' + fontRefName);
  44756. }
  44757. if (size < 0) {
  44758. size = -size;
  44759. current.fontDirection = -1;
  44760. } else {
  44761. current.fontDirection = 1;
  44762. }
  44763. this.current.font = fontObj;
  44764. this.current.fontSize = size;
  44765. if (fontObj.isType3Font) {
  44766. return;
  44767. }
  44768. var name = fontObj.loadedName || 'sans-serif';
  44769. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  44770. var italic = fontObj.italic ? 'italic' : 'normal';
  44771. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44772. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44773. this.current.fontSizeScale = size / browserFontSize;
  44774. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44775. this.ctx.font = rule;
  44776. },
  44777. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44778. this.current.textRenderingMode = mode;
  44779. },
  44780. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44781. this.current.textRise = rise;
  44782. },
  44783. moveText: function CanvasGraphics_moveText(x, y) {
  44784. this.current.x = this.current.lineX += x;
  44785. this.current.y = this.current.lineY += y;
  44786. },
  44787. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44788. this.setLeading(-y);
  44789. this.moveText(x, y);
  44790. },
  44791. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44792. this.current.textMatrix = [
  44793. a,
  44794. b,
  44795. c,
  44796. d,
  44797. e,
  44798. f
  44799. ];
  44800. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44801. this.current.x = this.current.lineX = 0;
  44802. this.current.y = this.current.lineY = 0;
  44803. },
  44804. nextLine: function CanvasGraphics_nextLine() {
  44805. this.moveText(0, this.current.leading);
  44806. },
  44807. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44808. var ctx = this.ctx;
  44809. var current = this.current;
  44810. var font = current.font;
  44811. var textRenderingMode = current.textRenderingMode;
  44812. var fontSize = current.fontSize / current.fontSizeScale;
  44813. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44814. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44815. var addToPath;
  44816. if (font.disableFontFace || isAddToPathSet) {
  44817. addToPath = font.getPathGenerator(this.commonObjs, character);
  44818. }
  44819. if (font.disableFontFace) {
  44820. ctx.save();
  44821. ctx.translate(x, y);
  44822. ctx.beginPath();
  44823. addToPath(ctx, fontSize);
  44824. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44825. ctx.fill();
  44826. }
  44827. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44828. ctx.stroke();
  44829. }
  44830. ctx.restore();
  44831. } else {
  44832. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44833. ctx.fillText(character, x, y);
  44834. }
  44835. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44836. ctx.strokeText(character, x, y);
  44837. }
  44838. }
  44839. if (isAddToPathSet) {
  44840. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44841. paths.push({
  44842. transform: ctx.mozCurrentTransform,
  44843. x: x,
  44844. y: y,
  44845. fontSize: fontSize,
  44846. addToPath: addToPath
  44847. });
  44848. }
  44849. },
  44850. get isFontSubpixelAAEnabled() {
  44851. var ctx = document.createElement('canvas').getContext('2d');
  44852. ctx.scale(1.5, 1);
  44853. ctx.fillText('I', 0, 10);
  44854. var data = ctx.getImageData(0, 0, 10, 10).data;
  44855. var enabled = false;
  44856. for (var i = 3; i < data.length; i += 4) {
  44857. if (data[i] > 0 && data[i] < 255) {
  44858. enabled = true;
  44859. break;
  44860. }
  44861. }
  44862. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44863. },
  44864. showText: function CanvasGraphics_showText(glyphs) {
  44865. var current = this.current;
  44866. var font = current.font;
  44867. if (font.isType3Font) {
  44868. return this.showType3Text(glyphs);
  44869. }
  44870. var fontSize = current.fontSize;
  44871. if (fontSize === 0) {
  44872. return;
  44873. }
  44874. var ctx = this.ctx;
  44875. var fontSizeScale = current.fontSizeScale;
  44876. var charSpacing = current.charSpacing;
  44877. var wordSpacing = current.wordSpacing;
  44878. var fontDirection = current.fontDirection;
  44879. var textHScale = current.textHScale * fontDirection;
  44880. var glyphsLength = glyphs.length;
  44881. var vertical = font.vertical;
  44882. var spacingDir = vertical ? 1 : -1;
  44883. var defaultVMetrics = font.defaultVMetrics;
  44884. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44885. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44886. ctx.save();
  44887. ctx.transform.apply(ctx, current.textMatrix);
  44888. ctx.translate(current.x, current.y + current.textRise);
  44889. if (current.patternFill) {
  44890. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44891. }
  44892. if (fontDirection > 0) {
  44893. ctx.scale(textHScale, -1);
  44894. } else {
  44895. ctx.scale(textHScale, 1);
  44896. }
  44897. var lineWidth = current.lineWidth;
  44898. var scale = current.textMatrixScale;
  44899. if (scale === 0 || lineWidth === 0) {
  44900. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44901. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44902. this.cachedGetSinglePixelWidth = null;
  44903. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44904. }
  44905. } else {
  44906. lineWidth /= scale;
  44907. }
  44908. if (fontSizeScale !== 1.0) {
  44909. ctx.scale(fontSizeScale, fontSizeScale);
  44910. lineWidth /= fontSizeScale;
  44911. }
  44912. ctx.lineWidth = lineWidth;
  44913. var x = 0, i;
  44914. for (i = 0; i < glyphsLength; ++i) {
  44915. var glyph = glyphs[i];
  44916. if (isNum(glyph)) {
  44917. x += spacingDir * glyph * fontSize / 1000;
  44918. continue;
  44919. }
  44920. var restoreNeeded = false;
  44921. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44922. var character = glyph.fontChar;
  44923. var accent = glyph.accent;
  44924. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44925. var width = glyph.width;
  44926. if (vertical) {
  44927. var vmetric, vx, vy;
  44928. vmetric = glyph.vmetric || defaultVMetrics;
  44929. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44930. vx = -vx * widthAdvanceScale;
  44931. vy = vmetric[2] * widthAdvanceScale;
  44932. width = vmetric ? -vmetric[0] : width;
  44933. scaledX = vx / fontSizeScale;
  44934. scaledY = (x + vy) / fontSizeScale;
  44935. } else {
  44936. scaledX = x / fontSizeScale;
  44937. scaledY = 0;
  44938. }
  44939. if (font.remeasure && width > 0) {
  44940. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44941. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44942. var characterScaleX = width / measuredWidth;
  44943. restoreNeeded = true;
  44944. ctx.save();
  44945. ctx.scale(characterScaleX, 1);
  44946. scaledX /= characterScaleX;
  44947. } else if (width !== measuredWidth) {
  44948. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44949. }
  44950. }
  44951. if (glyph.isInFont || font.missingFile) {
  44952. if (simpleFillText && !accent) {
  44953. ctx.fillText(character, scaledX, scaledY);
  44954. } else {
  44955. this.paintChar(character, scaledX, scaledY);
  44956. if (accent) {
  44957. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44958. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44959. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44960. }
  44961. }
  44962. }
  44963. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44964. x += charWidth;
  44965. if (restoreNeeded) {
  44966. ctx.restore();
  44967. }
  44968. }
  44969. if (vertical) {
  44970. current.y -= x * textHScale;
  44971. } else {
  44972. current.x += x * textHScale;
  44973. }
  44974. ctx.restore();
  44975. },
  44976. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44977. var ctx = this.ctx;
  44978. var current = this.current;
  44979. var font = current.font;
  44980. var fontSize = current.fontSize;
  44981. var fontDirection = current.fontDirection;
  44982. var spacingDir = font.vertical ? 1 : -1;
  44983. var charSpacing = current.charSpacing;
  44984. var wordSpacing = current.wordSpacing;
  44985. var textHScale = current.textHScale * fontDirection;
  44986. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44987. var glyphsLength = glyphs.length;
  44988. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44989. var i, glyph, width, spacingLength;
  44990. if (isTextInvisible || fontSize === 0) {
  44991. return;
  44992. }
  44993. this.cachedGetSinglePixelWidth = null;
  44994. ctx.save();
  44995. ctx.transform.apply(ctx, current.textMatrix);
  44996. ctx.translate(current.x, current.y);
  44997. ctx.scale(textHScale, fontDirection);
  44998. for (i = 0; i < glyphsLength; ++i) {
  44999. glyph = glyphs[i];
  45000. if (isNum(glyph)) {
  45001. spacingLength = spacingDir * glyph * fontSize / 1000;
  45002. this.ctx.translate(spacingLength, 0);
  45003. current.x += spacingLength * textHScale;
  45004. continue;
  45005. }
  45006. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  45007. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  45008. if (!operatorList) {
  45009. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  45010. continue;
  45011. }
  45012. this.processingType3 = glyph;
  45013. this.save();
  45014. ctx.scale(fontSize, fontSize);
  45015. ctx.transform.apply(ctx, fontMatrix);
  45016. this.executeOperatorList(operatorList);
  45017. this.restore();
  45018. var transformed = Util.applyTransform([
  45019. glyph.width,
  45020. 0
  45021. ], fontMatrix);
  45022. width = transformed[0] * fontSize + spacing;
  45023. ctx.translate(width, 0);
  45024. current.x += width * textHScale;
  45025. }
  45026. ctx.restore();
  45027. this.processingType3 = null;
  45028. },
  45029. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  45030. },
  45031. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  45032. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  45033. this.clip();
  45034. this.endPath();
  45035. },
  45036. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  45037. var pattern;
  45038. if (IR[0] === 'TilingPattern') {
  45039. var color = IR[1];
  45040. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  45041. var self = this;
  45042. var canvasGraphicsFactory = {
  45043. createCanvasGraphics: function (ctx) {
  45044. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  45045. }
  45046. };
  45047. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  45048. } else {
  45049. pattern = getShadingPatternFromIR(IR);
  45050. }
  45051. return pattern;
  45052. },
  45053. setStrokeColorN: function CanvasGraphics_setStrokeColorN()
  45054. {
  45055. this.current.strokeColor = this.getColorN_Pattern(arguments);
  45056. },
  45057. setFillColorN: function CanvasGraphics_setFillColorN()
  45058. {
  45059. this.current.fillColor = this.getColorN_Pattern(arguments);
  45060. this.current.patternFill = true;
  45061. },
  45062. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  45063. var color = Util.makeCssRgb(r, g, b);
  45064. this.ctx.strokeStyle = color;
  45065. this.current.strokeColor = color;
  45066. },
  45067. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  45068. var color = Util.makeCssRgb(r, g, b);
  45069. this.ctx.fillStyle = color;
  45070. this.current.fillColor = color;
  45071. this.current.patternFill = false;
  45072. },
  45073. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  45074. var ctx = this.ctx;
  45075. this.save();
  45076. var pattern = getShadingPatternFromIR(patternIR);
  45077. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  45078. var inv = ctx.mozCurrentTransformInverse;
  45079. if (inv) {
  45080. var canvas = ctx.canvas;
  45081. var width = canvas.width;
  45082. var height = canvas.height;
  45083. var bl = Util.applyTransform([
  45084. 0,
  45085. 0
  45086. ], inv);
  45087. var br = Util.applyTransform([
  45088. 0,
  45089. height
  45090. ], inv);
  45091. var ul = Util.applyTransform([
  45092. width,
  45093. 0
  45094. ], inv);
  45095. var ur = Util.applyTransform([
  45096. width,
  45097. height
  45098. ], inv);
  45099. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  45100. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  45101. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  45102. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  45103. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  45104. } else {
  45105. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  45106. }
  45107. this.restore();
  45108. },
  45109. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  45110. error('Should not call beginInlineImage');
  45111. },
  45112. beginImageData: function CanvasGraphics_beginImageData() {
  45113. error('Should not call beginImageData');
  45114. },
  45115. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  45116. this.save();
  45117. this.baseTransformStack.push(this.baseTransform);
  45118. if (isArray(matrix) && matrix.length === 6) {
  45119. this.transform.apply(this, matrix);
  45120. }
  45121. this.baseTransform = this.ctx.mozCurrentTransform;
  45122. if (isArray(bbox) && bbox.length === 4) {
  45123. var width = bbox[2] - bbox[0];
  45124. var height = bbox[3] - bbox[1];
  45125. this.ctx.rect(bbox[0], bbox[1], width, height);
  45126. this.clip();
  45127. this.endPath();
  45128. }
  45129. },
  45130. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  45131. this.restore();
  45132. this.baseTransform = this.baseTransformStack.pop();
  45133. },
  45134. beginGroup: function CanvasGraphics_beginGroup(group) {
  45135. this.save();
  45136. var currentCtx = this.ctx;
  45137. if (!group.isolated) {
  45138. info('TODO: Support non-isolated groups.');
  45139. }
  45140. if (group.knockout) {
  45141. warn('Knockout groups not supported.');
  45142. }
  45143. var currentTransform = currentCtx.mozCurrentTransform;
  45144. if (group.matrix) {
  45145. currentCtx.transform.apply(currentCtx, group.matrix);
  45146. }
  45147. assert(group.bbox, 'Bounding box is required.');
  45148. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  45149. var canvasBounds = [
  45150. 0,
  45151. 0,
  45152. currentCtx.canvas.width,
  45153. currentCtx.canvas.height
  45154. ];
  45155. bounds = Util.intersect(bounds, canvasBounds) || [
  45156. 0,
  45157. 0,
  45158. 0,
  45159. 0
  45160. ];
  45161. var offsetX = Math.floor(bounds[0]);
  45162. var offsetY = Math.floor(bounds[1]);
  45163. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  45164. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  45165. var scaleX = 1, scaleY = 1;
  45166. if (drawnWidth > MAX_GROUP_SIZE) {
  45167. scaleX = drawnWidth / MAX_GROUP_SIZE;
  45168. drawnWidth = MAX_GROUP_SIZE;
  45169. }
  45170. if (drawnHeight > MAX_GROUP_SIZE) {
  45171. scaleY = drawnHeight / MAX_GROUP_SIZE;
  45172. drawnHeight = MAX_GROUP_SIZE;
  45173. }
  45174. var cacheId = 'groupAt' + this.groupLevel;
  45175. if (group.smask) {
  45176. cacheId += '_smask_' + this.smaskCounter++ % 2;
  45177. }
  45178. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45179. var groupCtx = scratchCanvas.context;
  45180. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45181. groupCtx.translate(-offsetX, -offsetY);
  45182. groupCtx.transform.apply(groupCtx, currentTransform);
  45183. if (group.smask) {
  45184. this.smaskStack.push({
  45185. canvas: scratchCanvas.canvas,
  45186. context: groupCtx,
  45187. offsetX: offsetX,
  45188. offsetY: offsetY,
  45189. scaleX: scaleX,
  45190. scaleY: scaleY,
  45191. subtype: group.smask.subtype,
  45192. backdrop: group.smask.backdrop,
  45193. transferMap: group.smask.transferMap || null,
  45194. startTransformInverse: null
  45195. });
  45196. } else
  45197. {
  45198. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45199. currentCtx.translate(offsetX, offsetY);
  45200. currentCtx.scale(scaleX, scaleY);
  45201. }
  45202. copyCtxState(currentCtx, groupCtx);
  45203. this.ctx = groupCtx;
  45204. this.setGState([
  45205. [
  45206. 'BM',
  45207. 'Normal'
  45208. ],
  45209. [
  45210. 'ca',
  45211. 1
  45212. ],
  45213. [
  45214. 'CA',
  45215. 1
  45216. ]
  45217. ]);
  45218. this.groupStack.push(currentCtx);
  45219. this.groupLevel++;
  45220. this.current.activeSMask = null;
  45221. },
  45222. endGroup: function CanvasGraphics_endGroup(group) {
  45223. this.groupLevel--;
  45224. var groupCtx = this.ctx;
  45225. this.ctx = this.groupStack.pop();
  45226. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45227. this.ctx.imageSmoothingEnabled = false;
  45228. } else {
  45229. this.ctx.mozImageSmoothingEnabled = false;
  45230. }
  45231. if (group.smask) {
  45232. this.tempSMask = this.smaskStack.pop();
  45233. } else {
  45234. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45235. }
  45236. this.restore();
  45237. },
  45238. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45239. this.save();
  45240. this.current = new CanvasExtraState();
  45241. if (this.baseTransform) {
  45242. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45243. }
  45244. },
  45245. endAnnotations: function CanvasGraphics_endAnnotations() {
  45246. this.restore();
  45247. },
  45248. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45249. this.save();
  45250. if (isArray(rect) && rect.length === 4) {
  45251. var width = rect[2] - rect[0];
  45252. var height = rect[3] - rect[1];
  45253. this.ctx.rect(rect[0], rect[1], width, height);
  45254. this.clip();
  45255. this.endPath();
  45256. }
  45257. this.transform.apply(this, transform);
  45258. this.transform.apply(this, matrix);
  45259. },
  45260. endAnnotation: function CanvasGraphics_endAnnotation() {
  45261. this.restore();
  45262. },
  45263. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45264. var domImage = this.objs.get(objId);
  45265. if (!domImage) {
  45266. warn('Dependent image isn\'t ready yet');
  45267. return;
  45268. }
  45269. this.save();
  45270. var ctx = this.ctx;
  45271. ctx.scale(1 / w, -1 / h);
  45272. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45273. if (this.imageLayer) {
  45274. var currentTransform = ctx.mozCurrentTransformInverse;
  45275. var position = this.getCanvasPosition(0, 0);
  45276. this.imageLayer.appendImage({
  45277. objId: objId,
  45278. left: position[0],
  45279. top: position[1],
  45280. width: w / currentTransform[0],
  45281. height: h / currentTransform[3]
  45282. });
  45283. }
  45284. this.restore();
  45285. },
  45286. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45287. var ctx = this.ctx;
  45288. var width = img.width, height = img.height;
  45289. var fillColor = this.current.fillColor;
  45290. var isPatternFill = this.current.patternFill;
  45291. var glyph = this.processingType3;
  45292. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45293. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45294. glyph.compiled = compileType3Glyph({
  45295. data: img.data,
  45296. width: width,
  45297. height: height
  45298. });
  45299. } else {
  45300. glyph.compiled = null;
  45301. }
  45302. }
  45303. if (glyph && glyph.compiled) {
  45304. glyph.compiled(ctx);
  45305. return;
  45306. }
  45307. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45308. var maskCtx = maskCanvas.context;
  45309. maskCtx.save();
  45310. putBinaryImageMask(maskCtx, img);
  45311. maskCtx.globalCompositeOperation = 'source-in';
  45312. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45313. maskCtx.fillRect(0, 0, width, height);
  45314. maskCtx.restore();
  45315. this.paintInlineImageXObject(maskCanvas.canvas);
  45316. },
  45317. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45318. var width = imgData.width;
  45319. var height = imgData.height;
  45320. var fillColor = this.current.fillColor;
  45321. var isPatternFill = this.current.patternFill;
  45322. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45323. var maskCtx = maskCanvas.context;
  45324. maskCtx.save();
  45325. putBinaryImageMask(maskCtx, imgData);
  45326. maskCtx.globalCompositeOperation = 'source-in';
  45327. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45328. maskCtx.fillRect(0, 0, width, height);
  45329. maskCtx.restore();
  45330. var ctx = this.ctx;
  45331. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45332. ctx.save();
  45333. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45334. ctx.scale(1, -1);
  45335. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45336. ctx.restore();
  45337. }
  45338. },
  45339. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45340. var ctx = this.ctx;
  45341. var fillColor = this.current.fillColor;
  45342. var isPatternFill = this.current.patternFill;
  45343. for (var i = 0, ii = images.length; i < ii; i++) {
  45344. var image = images[i];
  45345. var width = image.width, height = image.height;
  45346. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45347. var maskCtx = maskCanvas.context;
  45348. maskCtx.save();
  45349. putBinaryImageMask(maskCtx, image);
  45350. maskCtx.globalCompositeOperation = 'source-in';
  45351. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45352. maskCtx.fillRect(0, 0, width, height);
  45353. maskCtx.restore();
  45354. ctx.save();
  45355. ctx.transform.apply(ctx, image.transform);
  45356. ctx.scale(1, -1);
  45357. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45358. ctx.restore();
  45359. }
  45360. },
  45361. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45362. var imgData = this.objs.get(objId);
  45363. if (!imgData) {
  45364. warn('Dependent image isn\'t ready yet');
  45365. return;
  45366. }
  45367. this.paintInlineImageXObject(imgData);
  45368. },
  45369. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45370. var imgData = this.objs.get(objId);
  45371. if (!imgData) {
  45372. warn('Dependent image isn\'t ready yet');
  45373. return;
  45374. }
  45375. var width = imgData.width;
  45376. var height = imgData.height;
  45377. var map = [];
  45378. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45379. map.push({
  45380. transform: [
  45381. scaleX,
  45382. 0,
  45383. 0,
  45384. scaleY,
  45385. positions[i],
  45386. positions[i + 1]
  45387. ],
  45388. x: 0,
  45389. y: 0,
  45390. w: width,
  45391. h: height
  45392. });
  45393. }
  45394. this.paintInlineImageXObjectGroup(imgData, map);
  45395. },
  45396. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45397. var width = imgData.width;
  45398. var height = imgData.height;
  45399. var ctx = this.ctx;
  45400. this.save();
  45401. ctx.scale(1 / width, -1 / height);
  45402. var currentTransform = ctx.mozCurrentTransformInverse;
  45403. var a = currentTransform[0], b = currentTransform[1];
  45404. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45405. var c = currentTransform[2], d = currentTransform[3];
  45406. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45407. var imgToPaint, tmpCanvas;
  45408. if (imgData instanceof HTMLElement || !imgData.data) {
  45409. imgToPaint = imgData;
  45410. } else {
  45411. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45412. var tmpCtx = tmpCanvas.context;
  45413. putBinaryImageData(tmpCtx, imgData);
  45414. imgToPaint = tmpCanvas.canvas;
  45415. }
  45416. var paintWidth = width, paintHeight = height;
  45417. var tmpCanvasId = 'prescale1';
  45418. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45419. var newWidth = paintWidth, newHeight = paintHeight;
  45420. if (widthScale > 2 && paintWidth > 1) {
  45421. newWidth = Math.ceil(paintWidth / 2);
  45422. widthScale /= paintWidth / newWidth;
  45423. }
  45424. if (heightScale > 2 && paintHeight > 1) {
  45425. newHeight = Math.ceil(paintHeight / 2);
  45426. heightScale /= paintHeight / newHeight;
  45427. }
  45428. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45429. tmpCtx = tmpCanvas.context;
  45430. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45431. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45432. imgToPaint = tmpCanvas.canvas;
  45433. paintWidth = newWidth;
  45434. paintHeight = newHeight;
  45435. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45436. }
  45437. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45438. if (this.imageLayer) {
  45439. var position = this.getCanvasPosition(0, -height);
  45440. this.imageLayer.appendImage({
  45441. imgData: imgData,
  45442. left: position[0],
  45443. top: position[1],
  45444. width: width / currentTransform[0],
  45445. height: height / currentTransform[3]
  45446. });
  45447. }
  45448. this.restore();
  45449. },
  45450. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45451. var ctx = this.ctx;
  45452. var w = imgData.width;
  45453. var h = imgData.height;
  45454. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45455. var tmpCtx = tmpCanvas.context;
  45456. putBinaryImageData(tmpCtx, imgData);
  45457. for (var i = 0, ii = map.length; i < ii; i++) {
  45458. var entry = map[i];
  45459. ctx.save();
  45460. ctx.transform.apply(ctx, entry.transform);
  45461. ctx.scale(1, -1);
  45462. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45463. if (this.imageLayer) {
  45464. var position = this.getCanvasPosition(entry.x, entry.y);
  45465. this.imageLayer.appendImage({
  45466. imgData: imgData,
  45467. left: position[0],
  45468. top: position[1],
  45469. width: w,
  45470. height: h
  45471. });
  45472. }
  45473. ctx.restore();
  45474. }
  45475. },
  45476. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45477. this.ctx.fillRect(0, 0, 1, 1);
  45478. },
  45479. paintXObject: function CanvasGraphics_paintXObject() {
  45480. warn('Unsupported \'paintXObject\' command.');
  45481. },
  45482. markPoint: function CanvasGraphics_markPoint(tag) {
  45483. },
  45484. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45485. },
  45486. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45487. },
  45488. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45489. },
  45490. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45491. },
  45492. beginCompat: function CanvasGraphics_beginCompat() {
  45493. },
  45494. endCompat: function CanvasGraphics_endCompat() {
  45495. },
  45496. consumePath: function CanvasGraphics_consumePath() {
  45497. var ctx = this.ctx;
  45498. if (this.pendingClip) {
  45499. if (this.pendingClip === EO_CLIP) {
  45500. if (ctx.mozFillRule !== undefined) {
  45501. ctx.mozFillRule = 'evenodd';
  45502. ctx.clip();
  45503. ctx.mozFillRule = 'nonzero';
  45504. } else {
  45505. ctx.clip('evenodd');
  45506. }
  45507. } else {
  45508. ctx.clip();
  45509. }
  45510. this.pendingClip = null;
  45511. }
  45512. ctx.beginPath();
  45513. },
  45514. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45515. if (this.cachedGetSinglePixelWidth === null) {
  45516. this.ctx.save();
  45517. var inverse = this.ctx.mozCurrentTransformInverse;
  45518. this.ctx.restore();
  45519. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45520. }
  45521. return this.cachedGetSinglePixelWidth;
  45522. },
  45523. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45524. var transform = this.ctx.mozCurrentTransform;
  45525. return [
  45526. transform[0] * x + transform[2] * y + transform[4],
  45527. transform[1] * x + transform[3] * y + transform[5]
  45528. ];
  45529. }
  45530. };
  45531. for (var op in OPS) {
  45532. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45533. }
  45534. return CanvasGraphics;
  45535. }();
  45536. exports.CanvasGraphics = CanvasGraphics;
  45537. exports.createScratchCanvas = createScratchCanvas;
  45538. }));
  45539. (function (root, factory) {
  45540. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45541. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45542. var error = sharedUtil.error;
  45543. var info = sharedUtil.info;
  45544. var isArray = sharedUtil.isArray;
  45545. var isBool = sharedUtil.isBool;
  45546. var isDict = corePrimitives.isDict;
  45547. var isStream = corePrimitives.isStream;
  45548. var PostScriptLexer = corePsParser.PostScriptLexer;
  45549. var PostScriptParser = corePsParser.PostScriptParser;
  45550. var PDFFunction = function PDFFunctionClosure() {
  45551. var CONSTRUCT_SAMPLED = 0;
  45552. var CONSTRUCT_INTERPOLATED = 2;
  45553. var CONSTRUCT_STICHED = 3;
  45554. var CONSTRUCT_POSTSCRIPT = 4;
  45555. return {
  45556. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45557. var i, ii;
  45558. var length = 1;
  45559. for (i = 0, ii = size.length; i < ii; i++) {
  45560. length *= size[i];
  45561. }
  45562. length *= outputSize;
  45563. var array = new Array(length);
  45564. var codeSize = 0;
  45565. var codeBuf = 0;
  45566. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45567. var strBytes = str.getBytes((length * bps + 7) / 8);
  45568. var strIdx = 0;
  45569. for (i = 0; i < length; i++) {
  45570. while (codeSize < bps) {
  45571. codeBuf <<= 8;
  45572. codeBuf |= strBytes[strIdx++];
  45573. codeSize += 8;
  45574. }
  45575. codeSize -= bps;
  45576. array[i] = (codeBuf >> codeSize) * sampleMul;
  45577. codeBuf &= (1 << codeSize) - 1;
  45578. }
  45579. return array;
  45580. },
  45581. getIR: function PDFFunction_getIR(xref, fn) {
  45582. var dict = fn.dict;
  45583. if (!dict) {
  45584. dict = fn;
  45585. }
  45586. var types = [
  45587. this.constructSampled,
  45588. null,
  45589. this.constructInterpolated,
  45590. this.constructStiched,
  45591. this.constructPostScript
  45592. ];
  45593. var typeNum = dict.get('FunctionType');
  45594. var typeFn = types[typeNum];
  45595. if (!typeFn) {
  45596. error('Unknown type of function');
  45597. }
  45598. return typeFn.call(this, fn, dict, xref);
  45599. },
  45600. fromIR: function PDFFunction_fromIR(IR) {
  45601. var type = IR[0];
  45602. switch (type) {
  45603. case CONSTRUCT_SAMPLED:
  45604. return this.constructSampledFromIR(IR);
  45605. case CONSTRUCT_INTERPOLATED:
  45606. return this.constructInterpolatedFromIR(IR);
  45607. case CONSTRUCT_STICHED:
  45608. return this.constructStichedFromIR(IR);
  45609. default:
  45610. return this.constructPostScriptFromIR(IR);
  45611. }
  45612. },
  45613. parse: function PDFFunction_parse(xref, fn) {
  45614. var IR = this.getIR(xref, fn);
  45615. return this.fromIR(IR);
  45616. },
  45617. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45618. if (!isArray(fnObj)) {
  45619. return this.parse(xref, fnObj);
  45620. }
  45621. var fnArray = [];
  45622. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45623. var obj = xref.fetchIfRef(fnObj[j]);
  45624. fnArray.push(PDFFunction.parse(xref, obj));
  45625. }
  45626. return function (src, srcOffset, dest, destOffset) {
  45627. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45628. fnArray[i](src, srcOffset, dest, destOffset + i);
  45629. }
  45630. };
  45631. },
  45632. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45633. function toMultiArray(arr) {
  45634. var inputLength = arr.length;
  45635. var out = [];
  45636. var index = 0;
  45637. for (var i = 0; i < inputLength; i += 2) {
  45638. out[index] = [
  45639. arr[i],
  45640. arr[i + 1]
  45641. ];
  45642. ++index;
  45643. }
  45644. return out;
  45645. }
  45646. var domain = dict.getArray('Domain');
  45647. var range = dict.getArray('Range');
  45648. if (!domain || !range) {
  45649. error('No domain or range');
  45650. }
  45651. var inputSize = domain.length / 2;
  45652. var outputSize = range.length / 2;
  45653. domain = toMultiArray(domain);
  45654. range = toMultiArray(range);
  45655. var size = dict.get('Size');
  45656. var bps = dict.get('BitsPerSample');
  45657. var order = dict.get('Order') || 1;
  45658. if (order !== 1) {
  45659. info('No support for cubic spline interpolation: ' + order);
  45660. }
  45661. var encode = dict.getArray('Encode');
  45662. if (!encode) {
  45663. encode = [];
  45664. for (var i = 0; i < inputSize; ++i) {
  45665. encode.push(0);
  45666. encode.push(size[i] - 1);
  45667. }
  45668. }
  45669. encode = toMultiArray(encode);
  45670. var decode = dict.getArray('Decode');
  45671. if (!decode) {
  45672. decode = range;
  45673. } else {
  45674. decode = toMultiArray(decode);
  45675. }
  45676. var samples = this.getSampleArray(size, outputSize, bps, str);
  45677. return [
  45678. CONSTRUCT_SAMPLED,
  45679. inputSize,
  45680. domain,
  45681. encode,
  45682. decode,
  45683. samples,
  45684. size,
  45685. outputSize,
  45686. Math.pow(2, bps) - 1,
  45687. range
  45688. ];
  45689. },
  45690. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45691. function interpolate(x, xmin, xmax, ymin, ymax) {
  45692. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45693. }
  45694. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45695. var m = IR[1];
  45696. var domain = IR[2];
  45697. var encode = IR[3];
  45698. var decode = IR[4];
  45699. var samples = IR[5];
  45700. var size = IR[6];
  45701. var n = IR[7];
  45702. var range = IR[9];
  45703. var cubeVertices = 1 << m;
  45704. var cubeN = new Float64Array(cubeVertices);
  45705. var cubeVertex = new Uint32Array(cubeVertices);
  45706. var i, j;
  45707. for (j = 0; j < cubeVertices; j++) {
  45708. cubeN[j] = 1;
  45709. }
  45710. var k = n, pos = 1;
  45711. for (i = 0; i < m; ++i) {
  45712. var domain_2i = domain[i][0];
  45713. var domain_2i_1 = domain[i][1];
  45714. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45715. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45716. var size_i = size[i];
  45717. e = Math.min(Math.max(e, 0), size_i - 1);
  45718. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45719. var n0 = e0 + 1 - e;
  45720. var n1 = e - e0;
  45721. var offset0 = e0 * k;
  45722. var offset1 = offset0 + k;
  45723. for (j = 0; j < cubeVertices; j++) {
  45724. if (j & pos) {
  45725. cubeN[j] *= n1;
  45726. cubeVertex[j] += offset1;
  45727. } else {
  45728. cubeN[j] *= n0;
  45729. cubeVertex[j] += offset0;
  45730. }
  45731. }
  45732. k *= size_i;
  45733. pos <<= 1;
  45734. }
  45735. for (j = 0; j < n; ++j) {
  45736. var rj = 0;
  45737. for (i = 0; i < cubeVertices; i++) {
  45738. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45739. }
  45740. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45741. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45742. }
  45743. };
  45744. },
  45745. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45746. var c0 = dict.getArray('C0') || [0];
  45747. var c1 = dict.getArray('C1') || [1];
  45748. var n = dict.get('N');
  45749. if (!isArray(c0) || !isArray(c1)) {
  45750. error('Illegal dictionary for interpolated function');
  45751. }
  45752. var length = c0.length;
  45753. var diff = [];
  45754. for (var i = 0; i < length; ++i) {
  45755. diff.push(c1[i] - c0[i]);
  45756. }
  45757. return [
  45758. CONSTRUCT_INTERPOLATED,
  45759. c0,
  45760. diff,
  45761. n
  45762. ];
  45763. },
  45764. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45765. var c0 = IR[1];
  45766. var diff = IR[2];
  45767. var n = IR[3];
  45768. var length = diff.length;
  45769. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45770. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45771. for (var j = 0; j < length; ++j) {
  45772. dest[destOffset + j] = c0[j] + x * diff[j];
  45773. }
  45774. };
  45775. },
  45776. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45777. var domain = dict.getArray('Domain');
  45778. if (!domain) {
  45779. error('No domain');
  45780. }
  45781. var inputSize = domain.length / 2;
  45782. if (inputSize !== 1) {
  45783. error('Bad domain for stiched function');
  45784. }
  45785. var fnRefs = dict.get('Functions');
  45786. var fns = [];
  45787. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45788. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45789. }
  45790. var bounds = dict.getArray('Bounds');
  45791. var encode = dict.getArray('Encode');
  45792. return [
  45793. CONSTRUCT_STICHED,
  45794. domain,
  45795. bounds,
  45796. encode,
  45797. fns
  45798. ];
  45799. },
  45800. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45801. var domain = IR[1];
  45802. var bounds = IR[2];
  45803. var encode = IR[3];
  45804. var fnsIR = IR[4];
  45805. var fns = [];
  45806. var tmpBuf = new Float32Array(1);
  45807. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45808. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45809. }
  45810. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45811. var clip = function constructStichedFromIRClip(v, min, max) {
  45812. if (v > max) {
  45813. v = max;
  45814. } else if (v < min) {
  45815. v = min;
  45816. }
  45817. return v;
  45818. };
  45819. var v = clip(src[srcOffset], domain[0], domain[1]);
  45820. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45821. if (v < bounds[i]) {
  45822. break;
  45823. }
  45824. }
  45825. var dmin = domain[0];
  45826. if (i > 0) {
  45827. dmin = bounds[i - 1];
  45828. }
  45829. var dmax = domain[1];
  45830. if (i < bounds.length) {
  45831. dmax = bounds[i];
  45832. }
  45833. var rmin = encode[2 * i];
  45834. var rmax = encode[2 * i + 1];
  45835. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45836. fns[i](tmpBuf, 0, dest, destOffset);
  45837. };
  45838. },
  45839. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45840. var domain = dict.getArray('Domain');
  45841. var range = dict.getArray('Range');
  45842. if (!domain) {
  45843. error('No domain.');
  45844. }
  45845. if (!range) {
  45846. error('No range.');
  45847. }
  45848. var lexer = new PostScriptLexer(fn);
  45849. var parser = new PostScriptParser(lexer);
  45850. var code = parser.parse();
  45851. return [
  45852. CONSTRUCT_POSTSCRIPT,
  45853. domain,
  45854. range,
  45855. code
  45856. ];
  45857. },
  45858. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45859. var domain = IR[1];
  45860. var range = IR[2];
  45861. var code = IR[3];
  45862. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45863. if (compiled) {
  45864. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45865. }
  45866. info('Unable to compile PS function');
  45867. var numOutputs = range.length >> 1;
  45868. var numInputs = domain.length >> 1;
  45869. var evaluator = new PostScriptEvaluator(code);
  45870. var cache = Object.create(null);
  45871. var MAX_CACHE_SIZE = 2048 * 4;
  45872. var cache_available = MAX_CACHE_SIZE;
  45873. var tmpBuf = new Float32Array(numInputs);
  45874. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45875. var i, value;
  45876. var key = '';
  45877. var input = tmpBuf;
  45878. for (i = 0; i < numInputs; i++) {
  45879. value = src[srcOffset + i];
  45880. input[i] = value;
  45881. key += value + '_';
  45882. }
  45883. var cachedValue = cache[key];
  45884. if (cachedValue !== undefined) {
  45885. dest.set(cachedValue, destOffset);
  45886. return;
  45887. }
  45888. var output = new Float32Array(numOutputs);
  45889. var stack = evaluator.execute(input);
  45890. var stackIndex = stack.length - numOutputs;
  45891. for (i = 0; i < numOutputs; i++) {
  45892. value = stack[stackIndex + i];
  45893. var bound = range[i * 2];
  45894. if (value < bound) {
  45895. value = bound;
  45896. } else {
  45897. bound = range[i * 2 + 1];
  45898. if (value > bound) {
  45899. value = bound;
  45900. }
  45901. }
  45902. output[i] = value;
  45903. }
  45904. if (cache_available > 0) {
  45905. cache_available--;
  45906. cache[key] = output;
  45907. }
  45908. dest.set(output, destOffset);
  45909. };
  45910. }
  45911. };
  45912. }();
  45913. function isPDFFunction(v) {
  45914. var fnDict;
  45915. if (typeof v !== 'object') {
  45916. return false;
  45917. } else if (isDict(v)) {
  45918. fnDict = v;
  45919. } else if (isStream(v)) {
  45920. fnDict = v.dict;
  45921. } else {
  45922. return false;
  45923. }
  45924. return fnDict.has('FunctionType');
  45925. }
  45926. var PostScriptStack = function PostScriptStackClosure() {
  45927. var MAX_STACK_SIZE = 100;
  45928. function PostScriptStack(initialStack) {
  45929. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45930. }
  45931. PostScriptStack.prototype = {
  45932. push: function PostScriptStack_push(value) {
  45933. if (this.stack.length >= MAX_STACK_SIZE) {
  45934. error('PostScript function stack overflow.');
  45935. }
  45936. this.stack.push(value);
  45937. },
  45938. pop: function PostScriptStack_pop() {
  45939. if (this.stack.length <= 0) {
  45940. error('PostScript function stack underflow.');
  45941. }
  45942. return this.stack.pop();
  45943. },
  45944. copy: function PostScriptStack_copy(n) {
  45945. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45946. error('PostScript function stack overflow.');
  45947. }
  45948. var stack = this.stack;
  45949. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45950. stack.push(stack[i]);
  45951. }
  45952. },
  45953. index: function PostScriptStack_index(n) {
  45954. this.push(this.stack[this.stack.length - n - 1]);
  45955. },
  45956. roll: function PostScriptStack_roll(n, p) {
  45957. var stack = this.stack;
  45958. var l = stack.length - n;
  45959. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45960. for (i = l, j = r; i < j; i++, j--) {
  45961. t = stack[i];
  45962. stack[i] = stack[j];
  45963. stack[j] = t;
  45964. }
  45965. for (i = l, j = c - 1; i < j; i++, j--) {
  45966. t = stack[i];
  45967. stack[i] = stack[j];
  45968. stack[j] = t;
  45969. }
  45970. for (i = c, j = r; i < j; i++, j--) {
  45971. t = stack[i];
  45972. stack[i] = stack[j];
  45973. stack[j] = t;
  45974. }
  45975. }
  45976. };
  45977. return PostScriptStack;
  45978. }();
  45979. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45980. function PostScriptEvaluator(operators) {
  45981. this.operators = operators;
  45982. }
  45983. PostScriptEvaluator.prototype = {
  45984. execute: function PostScriptEvaluator_execute(initialStack) {
  45985. var stack = new PostScriptStack(initialStack);
  45986. var counter = 0;
  45987. var operators = this.operators;
  45988. var length = operators.length;
  45989. var operator, a, b;
  45990. while (counter < length) {
  45991. operator = operators[counter++];
  45992. if (typeof operator === 'number') {
  45993. stack.push(operator);
  45994. continue;
  45995. }
  45996. switch (operator) {
  45997. case 'jz':
  45998. b = stack.pop();
  45999. a = stack.pop();
  46000. if (!a) {
  46001. counter = b;
  46002. }
  46003. break;
  46004. case 'j':
  46005. a = stack.pop();
  46006. counter = a;
  46007. break;
  46008. case 'abs':
  46009. a = stack.pop();
  46010. stack.push(Math.abs(a));
  46011. break;
  46012. case 'add':
  46013. b = stack.pop();
  46014. a = stack.pop();
  46015. stack.push(a + b);
  46016. break;
  46017. case 'and':
  46018. b = stack.pop();
  46019. a = stack.pop();
  46020. if (isBool(a) && isBool(b)) {
  46021. stack.push(a && b);
  46022. } else {
  46023. stack.push(a & b);
  46024. }
  46025. break;
  46026. case 'atan':
  46027. a = stack.pop();
  46028. stack.push(Math.atan(a));
  46029. break;
  46030. case 'bitshift':
  46031. b = stack.pop();
  46032. a = stack.pop();
  46033. if (a > 0) {
  46034. stack.push(a << b);
  46035. } else {
  46036. stack.push(a >> b);
  46037. }
  46038. break;
  46039. case 'ceiling':
  46040. a = stack.pop();
  46041. stack.push(Math.ceil(a));
  46042. break;
  46043. case 'copy':
  46044. a = stack.pop();
  46045. stack.copy(a);
  46046. break;
  46047. case 'cos':
  46048. a = stack.pop();
  46049. stack.push(Math.cos(a));
  46050. break;
  46051. case 'cvi':
  46052. a = stack.pop() | 0;
  46053. stack.push(a);
  46054. break;
  46055. case 'cvr':
  46056. break;
  46057. case 'div':
  46058. b = stack.pop();
  46059. a = stack.pop();
  46060. stack.push(a / b);
  46061. break;
  46062. case 'dup':
  46063. stack.copy(1);
  46064. break;
  46065. case 'eq':
  46066. b = stack.pop();
  46067. a = stack.pop();
  46068. stack.push(a === b);
  46069. break;
  46070. case 'exch':
  46071. stack.roll(2, 1);
  46072. break;
  46073. case 'exp':
  46074. b = stack.pop();
  46075. a = stack.pop();
  46076. stack.push(Math.pow(a, b));
  46077. break;
  46078. case 'false':
  46079. stack.push(false);
  46080. break;
  46081. case 'floor':
  46082. a = stack.pop();
  46083. stack.push(Math.floor(a));
  46084. break;
  46085. case 'ge':
  46086. b = stack.pop();
  46087. a = stack.pop();
  46088. stack.push(a >= b);
  46089. break;
  46090. case 'gt':
  46091. b = stack.pop();
  46092. a = stack.pop();
  46093. stack.push(a > b);
  46094. break;
  46095. case 'idiv':
  46096. b = stack.pop();
  46097. a = stack.pop();
  46098. stack.push(a / b | 0);
  46099. break;
  46100. case 'index':
  46101. a = stack.pop();
  46102. stack.index(a);
  46103. break;
  46104. case 'le':
  46105. b = stack.pop();
  46106. a = stack.pop();
  46107. stack.push(a <= b);
  46108. break;
  46109. case 'ln':
  46110. a = stack.pop();
  46111. stack.push(Math.log(a));
  46112. break;
  46113. case 'log':
  46114. a = stack.pop();
  46115. stack.push(Math.log(a) / Math.LN10);
  46116. break;
  46117. case 'lt':
  46118. b = stack.pop();
  46119. a = stack.pop();
  46120. stack.push(a < b);
  46121. break;
  46122. case 'mod':
  46123. b = stack.pop();
  46124. a = stack.pop();
  46125. stack.push(a % b);
  46126. break;
  46127. case 'mul':
  46128. b = stack.pop();
  46129. a = stack.pop();
  46130. stack.push(a * b);
  46131. break;
  46132. case 'ne':
  46133. b = stack.pop();
  46134. a = stack.pop();
  46135. stack.push(a !== b);
  46136. break;
  46137. case 'neg':
  46138. a = stack.pop();
  46139. stack.push(-a);
  46140. break;
  46141. case 'not':
  46142. a = stack.pop();
  46143. if (isBool(a)) {
  46144. stack.push(!a);
  46145. } else {
  46146. stack.push(~a);
  46147. }
  46148. break;
  46149. case 'or':
  46150. b = stack.pop();
  46151. a = stack.pop();
  46152. if (isBool(a) && isBool(b)) {
  46153. stack.push(a || b);
  46154. } else {
  46155. stack.push(a | b);
  46156. }
  46157. break;
  46158. case 'pop':
  46159. stack.pop();
  46160. break;
  46161. case 'roll':
  46162. b = stack.pop();
  46163. a = stack.pop();
  46164. stack.roll(a, b);
  46165. break;
  46166. case 'round':
  46167. a = stack.pop();
  46168. stack.push(Math.round(a));
  46169. break;
  46170. case 'sin':
  46171. a = stack.pop();
  46172. stack.push(Math.sin(a));
  46173. break;
  46174. case 'sqrt':
  46175. a = stack.pop();
  46176. stack.push(Math.sqrt(a));
  46177. break;
  46178. case 'sub':
  46179. b = stack.pop();
  46180. a = stack.pop();
  46181. stack.push(a - b);
  46182. break;
  46183. case 'true':
  46184. stack.push(true);
  46185. break;
  46186. case 'truncate':
  46187. a = stack.pop();
  46188. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46189. stack.push(a);
  46190. break;
  46191. case 'xor':
  46192. b = stack.pop();
  46193. a = stack.pop();
  46194. if (isBool(a) && isBool(b)) {
  46195. stack.push(a !== b);
  46196. } else {
  46197. stack.push(a ^ b);
  46198. }
  46199. break;
  46200. default:
  46201. error('Unknown operator ' + operator);
  46202. break;
  46203. }
  46204. }
  46205. return stack.stack;
  46206. }
  46207. };
  46208. return PostScriptEvaluator;
  46209. }();
  46210. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46211. function AstNode(type) {
  46212. this.type = type;
  46213. }
  46214. AstNode.prototype.visit = function (visitor) {
  46215. throw new Error('abstract method');
  46216. };
  46217. function AstArgument(index, min, max) {
  46218. AstNode.call(this, 'args');
  46219. this.index = index;
  46220. this.min = min;
  46221. this.max = max;
  46222. }
  46223. AstArgument.prototype = Object.create(AstNode.prototype);
  46224. AstArgument.prototype.visit = function (visitor) {
  46225. visitor.visitArgument(this);
  46226. };
  46227. function AstLiteral(number) {
  46228. AstNode.call(this, 'literal');
  46229. this.number = number;
  46230. this.min = number;
  46231. this.max = number;
  46232. }
  46233. AstLiteral.prototype = Object.create(AstNode.prototype);
  46234. AstLiteral.prototype.visit = function (visitor) {
  46235. visitor.visitLiteral(this);
  46236. };
  46237. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46238. AstNode.call(this, 'binary');
  46239. this.op = op;
  46240. this.arg1 = arg1;
  46241. this.arg2 = arg2;
  46242. this.min = min;
  46243. this.max = max;
  46244. }
  46245. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46246. AstBinaryOperation.prototype.visit = function (visitor) {
  46247. visitor.visitBinaryOperation(this);
  46248. };
  46249. function AstMin(arg, max) {
  46250. AstNode.call(this, 'max');
  46251. this.arg = arg;
  46252. this.min = arg.min;
  46253. this.max = max;
  46254. }
  46255. AstMin.prototype = Object.create(AstNode.prototype);
  46256. AstMin.prototype.visit = function (visitor) {
  46257. visitor.visitMin(this);
  46258. };
  46259. function AstVariable(index, min, max) {
  46260. AstNode.call(this, 'var');
  46261. this.index = index;
  46262. this.min = min;
  46263. this.max = max;
  46264. }
  46265. AstVariable.prototype = Object.create(AstNode.prototype);
  46266. AstVariable.prototype.visit = function (visitor) {
  46267. visitor.visitVariable(this);
  46268. };
  46269. function AstVariableDefinition(variable, arg) {
  46270. AstNode.call(this, 'definition');
  46271. this.variable = variable;
  46272. this.arg = arg;
  46273. }
  46274. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46275. AstVariableDefinition.prototype.visit = function (visitor) {
  46276. visitor.visitVariableDefinition(this);
  46277. };
  46278. function ExpressionBuilderVisitor() {
  46279. this.parts = [];
  46280. }
  46281. ExpressionBuilderVisitor.prototype = {
  46282. visitArgument: function (arg) {
  46283. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46284. },
  46285. visitVariable: function (variable) {
  46286. this.parts.push('v', variable.index);
  46287. },
  46288. visitLiteral: function (literal) {
  46289. this.parts.push(literal.number);
  46290. },
  46291. visitBinaryOperation: function (operation) {
  46292. this.parts.push('(');
  46293. operation.arg1.visit(this);
  46294. this.parts.push(' ', operation.op, ' ');
  46295. operation.arg2.visit(this);
  46296. this.parts.push(')');
  46297. },
  46298. visitVariableDefinition: function (definition) {
  46299. this.parts.push('var ');
  46300. definition.variable.visit(this);
  46301. this.parts.push(' = ');
  46302. definition.arg.visit(this);
  46303. this.parts.push(';');
  46304. },
  46305. visitMin: function (max) {
  46306. this.parts.push('Math.min(');
  46307. max.arg.visit(this);
  46308. this.parts.push(', ', max.max, ')');
  46309. },
  46310. toString: function () {
  46311. return this.parts.join('');
  46312. }
  46313. };
  46314. function buildAddOperation(num1, num2) {
  46315. if (num2.type === 'literal' && num2.number === 0) {
  46316. return num1;
  46317. }
  46318. if (num1.type === 'literal' && num1.number === 0) {
  46319. return num2;
  46320. }
  46321. if (num2.type === 'literal' && num1.type === 'literal') {
  46322. return new AstLiteral(num1.number + num2.number);
  46323. }
  46324. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46325. }
  46326. function buildMulOperation(num1, num2) {
  46327. if (num2.type === 'literal') {
  46328. if (num2.number === 0) {
  46329. return new AstLiteral(0);
  46330. } else if (num2.number === 1) {
  46331. return num1;
  46332. } else if (num1.type === 'literal') {
  46333. return new AstLiteral(num1.number * num2.number);
  46334. }
  46335. }
  46336. if (num1.type === 'literal') {
  46337. if (num1.number === 0) {
  46338. return new AstLiteral(0);
  46339. } else if (num1.number === 1) {
  46340. return num2;
  46341. }
  46342. }
  46343. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46344. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46345. return new AstBinaryOperation('*', num1, num2, min, max);
  46346. }
  46347. function buildSubOperation(num1, num2) {
  46348. if (num2.type === 'literal') {
  46349. if (num2.number === 0) {
  46350. return num1;
  46351. } else if (num1.type === 'literal') {
  46352. return new AstLiteral(num1.number - num2.number);
  46353. }
  46354. }
  46355. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46356. return num2.arg2;
  46357. }
  46358. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46359. }
  46360. function buildMinOperation(num1, max) {
  46361. if (num1.min >= max) {
  46362. return new AstLiteral(max);
  46363. } else if (num1.max <= max) {
  46364. return num1;
  46365. }
  46366. return new AstMin(num1, max);
  46367. }
  46368. function PostScriptCompiler() {
  46369. }
  46370. PostScriptCompiler.prototype = {
  46371. compile: function PostScriptCompiler_compile(code, domain, range) {
  46372. var stack = [];
  46373. var i, ii;
  46374. var instructions = [];
  46375. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46376. var lastRegister = 0;
  46377. var n, j;
  46378. var num1, num2, ast1, ast2, tmpVar, item;
  46379. for (i = 0; i < inputSize; i++) {
  46380. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46381. }
  46382. for (i = 0, ii = code.length; i < ii; i++) {
  46383. item = code[i];
  46384. if (typeof item === 'number') {
  46385. stack.push(new AstLiteral(item));
  46386. continue;
  46387. }
  46388. switch (item) {
  46389. case 'add':
  46390. if (stack.length < 2) {
  46391. return null;
  46392. }
  46393. num2 = stack.pop();
  46394. num1 = stack.pop();
  46395. stack.push(buildAddOperation(num1, num2));
  46396. break;
  46397. case 'cvr':
  46398. if (stack.length < 1) {
  46399. return null;
  46400. }
  46401. break;
  46402. case 'mul':
  46403. if (stack.length < 2) {
  46404. return null;
  46405. }
  46406. num2 = stack.pop();
  46407. num1 = stack.pop();
  46408. stack.push(buildMulOperation(num1, num2));
  46409. break;
  46410. case 'sub':
  46411. if (stack.length < 2) {
  46412. return null;
  46413. }
  46414. num2 = stack.pop();
  46415. num1 = stack.pop();
  46416. stack.push(buildSubOperation(num1, num2));
  46417. break;
  46418. case 'exch':
  46419. if (stack.length < 2) {
  46420. return null;
  46421. }
  46422. ast1 = stack.pop();
  46423. ast2 = stack.pop();
  46424. stack.push(ast1, ast2);
  46425. break;
  46426. case 'pop':
  46427. if (stack.length < 1) {
  46428. return null;
  46429. }
  46430. stack.pop();
  46431. break;
  46432. case 'index':
  46433. if (stack.length < 1) {
  46434. return null;
  46435. }
  46436. num1 = stack.pop();
  46437. if (num1.type !== 'literal') {
  46438. return null;
  46439. }
  46440. n = num1.number;
  46441. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46442. return null;
  46443. }
  46444. ast1 = stack[stack.length - n - 1];
  46445. if (ast1.type === 'literal' || ast1.type === 'var') {
  46446. stack.push(ast1);
  46447. break;
  46448. }
  46449. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46450. stack[stack.length - n - 1] = tmpVar;
  46451. stack.push(tmpVar);
  46452. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46453. break;
  46454. case 'dup':
  46455. if (stack.length < 1) {
  46456. return null;
  46457. }
  46458. 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]) {
  46459. num1 = stack.pop();
  46460. stack.push(buildMinOperation(num1, code[i + 1]));
  46461. i += 6;
  46462. break;
  46463. }
  46464. ast1 = stack[stack.length - 1];
  46465. if (ast1.type === 'literal' || ast1.type === 'var') {
  46466. stack.push(ast1);
  46467. break;
  46468. }
  46469. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46470. stack[stack.length - 1] = tmpVar;
  46471. stack.push(tmpVar);
  46472. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46473. break;
  46474. case 'roll':
  46475. if (stack.length < 2) {
  46476. return null;
  46477. }
  46478. num2 = stack.pop();
  46479. num1 = stack.pop();
  46480. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46481. return null;
  46482. }
  46483. j = num2.number;
  46484. n = num1.number;
  46485. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46486. return null;
  46487. }
  46488. j = (j % n + n) % n;
  46489. if (j === 0) {
  46490. break;
  46491. }
  46492. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46493. break;
  46494. default:
  46495. return null;
  46496. }
  46497. }
  46498. if (stack.length !== outputSize) {
  46499. return null;
  46500. }
  46501. var result = [];
  46502. instructions.forEach(function (instruction) {
  46503. var statementBuilder = new ExpressionBuilderVisitor();
  46504. instruction.visit(statementBuilder);
  46505. result.push(statementBuilder.toString());
  46506. });
  46507. stack.forEach(function (expr, i) {
  46508. var statementBuilder = new ExpressionBuilderVisitor();
  46509. expr.visit(statementBuilder);
  46510. var min = range[i * 2], max = range[i * 2 + 1];
  46511. var out = [statementBuilder.toString()];
  46512. if (min > expr.min) {
  46513. out.unshift('Math.max(', min, ', ');
  46514. out.push(')');
  46515. }
  46516. if (max < expr.max) {
  46517. out.unshift('Math.min(', max, ', ');
  46518. out.push(')');
  46519. }
  46520. out.unshift('dest[destOffset + ', i, '] = ');
  46521. out.push(';');
  46522. result.push(out.join(''));
  46523. });
  46524. return result.join('\n');
  46525. }
  46526. };
  46527. return PostScriptCompiler;
  46528. }();
  46529. exports.isPDFFunction = isPDFFunction;
  46530. exports.PDFFunction = PDFFunction;
  46531. exports.PostScriptEvaluator = PostScriptEvaluator;
  46532. exports.PostScriptCompiler = PostScriptCompiler;
  46533. }));
  46534. (function (root, factory) {
  46535. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46536. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46537. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46538. var MessageHandler = sharedUtil.MessageHandler;
  46539. var MissingPDFException = sharedUtil.MissingPDFException;
  46540. var PageViewport = sharedUtil.PageViewport;
  46541. var PasswordResponses = sharedUtil.PasswordResponses;
  46542. var PasswordException = sharedUtil.PasswordException;
  46543. var StatTimer = sharedUtil.StatTimer;
  46544. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46545. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46546. var Util = sharedUtil.Util;
  46547. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46548. var error = sharedUtil.error;
  46549. var deprecated = sharedUtil.deprecated;
  46550. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46551. var info = sharedUtil.info;
  46552. var isInt = sharedUtil.isInt;
  46553. var isArray = sharedUtil.isArray;
  46554. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46555. var isSameOrigin = sharedUtil.isSameOrigin;
  46556. var loadJpegStream = sharedUtil.loadJpegStream;
  46557. var stringToBytes = sharedUtil.stringToBytes;
  46558. var globalScope = sharedUtil.globalScope;
  46559. var warn = sharedUtil.warn;
  46560. var FontFaceObject = displayFontLoader.FontFaceObject;
  46561. var FontLoader = displayFontLoader.FontLoader;
  46562. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46563. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46564. var Metadata = displayMetadata.Metadata;
  46565. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46566. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46567. var isWorkerDisabled = false;
  46568. var workerSrc;
  46569. var isPostMessageTransfersDisabled = false;
  46570. var fakeWorkerFilesLoader = null;
  46571. var useRequireEnsure = false;
  46572. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46573. var task = new PDFDocumentLoadingTask();
  46574. if (arguments.length > 1) {
  46575. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46576. }
  46577. if (pdfDataRangeTransport) {
  46578. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46579. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46580. pdfDataRangeTransport.length = src.length;
  46581. pdfDataRangeTransport.initialData = src.initialData;
  46582. if (!pdfDataRangeTransport.abort) {
  46583. pdfDataRangeTransport.abort = function () {
  46584. };
  46585. }
  46586. }
  46587. src = Object.create(src);
  46588. src.range = pdfDataRangeTransport;
  46589. }
  46590. task.onPassword = passwordCallback || null;
  46591. task.onProgress = progressCallback || null;
  46592. var source;
  46593. if (typeof src === 'string') {
  46594. source = { url: src };
  46595. } else if (isArrayBuffer(src)) {
  46596. source = { data: src };
  46597. } else if (src instanceof PDFDataRangeTransport) {
  46598. source = { range: src };
  46599. } else {
  46600. if (typeof src !== 'object') {
  46601. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46602. }
  46603. if (!src.url && !src.data && !src.range) {
  46604. error('Invalid parameter object: need either .data, .range or .url');
  46605. }
  46606. source = src;
  46607. }
  46608. var params = {};
  46609. var rangeTransport = null;
  46610. var worker = null;
  46611. for (var key in source) {
  46612. if (key === 'url' && typeof window !== 'undefined') {
  46613. params[key] = new URL(source[key], window.location).href;
  46614. continue;
  46615. } else if (key === 'range') {
  46616. rangeTransport = source[key];
  46617. continue;
  46618. } else if (key === 'worker') {
  46619. worker = source[key];
  46620. continue;
  46621. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46622. var pdfBytes = source[key];
  46623. if (typeof pdfBytes === 'string') {
  46624. params[key] = stringToBytes(pdfBytes);
  46625. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46626. params[key] = new Uint8Array(pdfBytes);
  46627. } else if (isArrayBuffer(pdfBytes)) {
  46628. params[key] = new Uint8Array(pdfBytes);
  46629. } else {
  46630. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46631. }
  46632. continue;
  46633. }
  46634. params[key] = source[key];
  46635. }
  46636. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46637. if (!worker) {
  46638. worker = new PDFWorker();
  46639. task._worker = worker;
  46640. }
  46641. var docId = task.docId;
  46642. worker.promise.then(function () {
  46643. if (task.destroyed) {
  46644. throw new Error('Loading aborted');
  46645. }
  46646. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46647. if (task.destroyed) {
  46648. throw new Error('Loading aborted');
  46649. }
  46650. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46651. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46652. task._transport = transport;
  46653. messageHandler.send('Ready', null);
  46654. });
  46655. }).catch(task._capability.reject);
  46656. return task;
  46657. }
  46658. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46659. if (worker.destroyed) {
  46660. return Promise.reject(new Error('Worker was destroyed'));
  46661. }
  46662. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46663. source.disableStream = getDefaultSetting('disableStream');
  46664. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46665. if (pdfDataRangeTransport) {
  46666. source.length = pdfDataRangeTransport.length;
  46667. source.initialData = pdfDataRangeTransport.initialData;
  46668. }
  46669. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46670. docId: docId,
  46671. source: source,
  46672. disableRange: getDefaultSetting('disableRange'),
  46673. maxImageSize: getDefaultSetting('maxImageSize'),
  46674. cMapUrl: getDefaultSetting('cMapUrl'),
  46675. cMapPacked: getDefaultSetting('cMapPacked'),
  46676. disableFontFace: getDefaultSetting('disableFontFace'),
  46677. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46678. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46679. docBaseUrl: source.docBaseUrl
  46680. }).then(function (workerId) {
  46681. if (worker.destroyed) {
  46682. throw new Error('Worker was destroyed');
  46683. }
  46684. return workerId;
  46685. });
  46686. }
  46687. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46688. var nextDocumentId = 0;
  46689. function PDFDocumentLoadingTask() {
  46690. this._capability = createPromiseCapability();
  46691. this._transport = null;
  46692. this._worker = null;
  46693. this.docId = 'd' + nextDocumentId++;
  46694. this.destroyed = false;
  46695. this.onPassword = null;
  46696. this.onProgress = null;
  46697. this.onUnsupportedFeature = null;
  46698. }
  46699. PDFDocumentLoadingTask.prototype = {
  46700. get promise() {
  46701. return this._capability.promise;
  46702. },
  46703. destroy: function () {
  46704. this.destroyed = true;
  46705. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46706. return transportDestroyed.then(function () {
  46707. this._transport = null;
  46708. if (this._worker) {
  46709. this._worker.destroy();
  46710. this._worker = null;
  46711. }
  46712. }.bind(this));
  46713. },
  46714. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46715. return this.promise.then.apply(this.promise, arguments);
  46716. }
  46717. };
  46718. return PDFDocumentLoadingTask;
  46719. }();
  46720. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46721. function PDFDataRangeTransport(length, initialData) {
  46722. this.length = length;
  46723. this.initialData = initialData;
  46724. this._rangeListeners = [];
  46725. this._progressListeners = [];
  46726. this._progressiveReadListeners = [];
  46727. this._readyCapability = createPromiseCapability();
  46728. }
  46729. PDFDataRangeTransport.prototype = {
  46730. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46731. this._rangeListeners.push(listener);
  46732. },
  46733. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46734. this._progressListeners.push(listener);
  46735. },
  46736. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46737. this._progressiveReadListeners.push(listener);
  46738. },
  46739. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46740. var listeners = this._rangeListeners;
  46741. for (var i = 0, n = listeners.length; i < n; ++i) {
  46742. listeners[i](begin, chunk);
  46743. }
  46744. },
  46745. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46746. this._readyCapability.promise.then(function () {
  46747. var listeners = this._progressListeners;
  46748. for (var i = 0, n = listeners.length; i < n; ++i) {
  46749. listeners[i](loaded);
  46750. }
  46751. }.bind(this));
  46752. },
  46753. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46754. this._readyCapability.promise.then(function () {
  46755. var listeners = this._progressiveReadListeners;
  46756. for (var i = 0, n = listeners.length; i < n; ++i) {
  46757. listeners[i](chunk);
  46758. }
  46759. }.bind(this));
  46760. },
  46761. transportReady: function PDFDataRangeTransport_transportReady() {
  46762. this._readyCapability.resolve();
  46763. },
  46764. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46765. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46766. },
  46767. abort: function PDFDataRangeTransport_abort() {
  46768. }
  46769. };
  46770. return PDFDataRangeTransport;
  46771. }();
  46772. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46773. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46774. this.pdfInfo = pdfInfo;
  46775. this.transport = transport;
  46776. this.loadingTask = loadingTask;
  46777. }
  46778. PDFDocumentProxy.prototype = {
  46779. get numPages() {
  46780. return this.pdfInfo.numPages;
  46781. },
  46782. get fingerprint() {
  46783. return this.pdfInfo.fingerprint;
  46784. },
  46785. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46786. return this.transport.getPage(pageNumber);
  46787. },
  46788. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46789. return this.transport.getPageIndex(ref);
  46790. },
  46791. getDestinations: function PDFDocumentProxy_getDestinations() {
  46792. return this.transport.getDestinations();
  46793. },
  46794. getDestination: function PDFDocumentProxy_getDestination(id) {
  46795. return this.transport.getDestination(id);
  46796. },
  46797. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46798. return this.transport.getPageLabels();
  46799. },
  46800. getAttachments: function PDFDocumentProxy_getAttachments() {
  46801. return this.transport.getAttachments();
  46802. },
  46803. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46804. return this.transport.getJavaScript();
  46805. },
  46806. getOutline: function PDFDocumentProxy_getOutline() {
  46807. return this.transport.getOutline();
  46808. },
  46809. getMetadata: function PDFDocumentProxy_getMetadata() {
  46810. return this.transport.getMetadata();
  46811. },
  46812. getData: function PDFDocumentProxy_getData() {
  46813. return this.transport.getData();
  46814. },
  46815. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46816. return this.transport.downloadInfoCapability.promise;
  46817. },
  46818. getStats: function PDFDocumentProxy_getStats() {
  46819. return this.transport.getStats();
  46820. },
  46821. cleanup: function PDFDocumentProxy_cleanup() {
  46822. this.transport.startCleanup();
  46823. },
  46824. destroy: function PDFDocumentProxy_destroy() {
  46825. return this.loadingTask.destroy();
  46826. }
  46827. };
  46828. return PDFDocumentProxy;
  46829. }();
  46830. var PDFPageProxy = function PDFPageProxyClosure() {
  46831. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46832. this.pageIndex = pageIndex;
  46833. this.pageInfo = pageInfo;
  46834. this.transport = transport;
  46835. this.stats = new StatTimer();
  46836. this.stats.enabled = getDefaultSetting('enableStats');
  46837. this.commonObjs = transport.commonObjs;
  46838. this.objs = new PDFObjects();
  46839. this.cleanupAfterRender = false;
  46840. this.pendingCleanup = false;
  46841. this.intentStates = Object.create(null);
  46842. this.destroyed = false;
  46843. }
  46844. PDFPageProxy.prototype = {
  46845. get pageNumber() {
  46846. return this.pageIndex + 1;
  46847. },
  46848. get rotate() {
  46849. return this.pageInfo.rotate;
  46850. },
  46851. get ref() {
  46852. return this.pageInfo.ref;
  46853. },
  46854. get userUnit() {
  46855. return this.pageInfo.userUnit;
  46856. },
  46857. get view() {
  46858. return this.pageInfo.view;
  46859. },
  46860. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46861. if (arguments.length < 2) {
  46862. rotate = this.rotate;
  46863. }
  46864. return new PageViewport(this.view, scale, rotate, 0, 0);
  46865. },
  46866. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46867. var intent = params && params.intent || null;
  46868. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46869. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46870. this.annotationsIntent = intent;
  46871. }
  46872. return this.annotationsPromise;
  46873. },
  46874. render: function PDFPageProxy_render(params) {
  46875. var stats = this.stats;
  46876. stats.time('Overall');
  46877. this.pendingCleanup = false;
  46878. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46879. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46880. if (!this.intentStates[renderingIntent]) {
  46881. this.intentStates[renderingIntent] = Object.create(null);
  46882. }
  46883. var intentState = this.intentStates[renderingIntent];
  46884. if (!intentState.displayReadyCapability) {
  46885. intentState.receivingOperatorList = true;
  46886. intentState.displayReadyCapability = createPromiseCapability();
  46887. intentState.operatorList = {
  46888. fnArray: [],
  46889. argsArray: [],
  46890. lastChunk: false
  46891. };
  46892. this.stats.time('Page Request');
  46893. this.transport.messageHandler.send('RenderPageRequest', {
  46894. pageIndex: this.pageNumber - 1,
  46895. intent: renderingIntent,
  46896. renderInteractiveForms: renderInteractiveForms
  46897. });
  46898. }
  46899. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46900. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46901. if (!intentState.renderTasks) {
  46902. intentState.renderTasks = [];
  46903. }
  46904. intentState.renderTasks.push(internalRenderTask);
  46905. var renderTask = internalRenderTask.task;
  46906. if (params.continueCallback) {
  46907. deprecated('render is used with continueCallback parameter');
  46908. renderTask.onContinue = params.continueCallback;
  46909. }
  46910. var self = this;
  46911. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46912. if (self.pendingCleanup) {
  46913. complete();
  46914. return;
  46915. }
  46916. stats.time('Rendering');
  46917. internalRenderTask.initializeGraphics(transparency);
  46918. internalRenderTask.operatorListChanged();
  46919. }, function pageDisplayReadPromiseError(reason) {
  46920. complete(reason);
  46921. });
  46922. function complete(error) {
  46923. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46924. if (i >= 0) {
  46925. intentState.renderTasks.splice(i, 1);
  46926. }
  46927. if (self.cleanupAfterRender) {
  46928. self.pendingCleanup = true;
  46929. }
  46930. self._tryCleanup();
  46931. if (error) {
  46932. internalRenderTask.capability.reject(error);
  46933. } else {
  46934. internalRenderTask.capability.resolve();
  46935. }
  46936. stats.timeEnd('Rendering');
  46937. stats.timeEnd('Overall');
  46938. }
  46939. return renderTask;
  46940. },
  46941. getOperatorList: function PDFPageProxy_getOperatorList() {
  46942. function operatorListChanged() {
  46943. if (intentState.operatorList.lastChunk) {
  46944. intentState.opListReadCapability.resolve(intentState.operatorList);
  46945. var i = intentState.renderTasks.indexOf(opListTask);
  46946. if (i >= 0) {
  46947. intentState.renderTasks.splice(i, 1);
  46948. }
  46949. }
  46950. }
  46951. var renderingIntent = 'oplist';
  46952. if (!this.intentStates[renderingIntent]) {
  46953. this.intentStates[renderingIntent] = Object.create(null);
  46954. }
  46955. var intentState = this.intentStates[renderingIntent];
  46956. var opListTask;
  46957. if (!intentState.opListReadCapability) {
  46958. opListTask = {};
  46959. opListTask.operatorListChanged = operatorListChanged;
  46960. intentState.receivingOperatorList = true;
  46961. intentState.opListReadCapability = createPromiseCapability();
  46962. intentState.renderTasks = [];
  46963. intentState.renderTasks.push(opListTask);
  46964. intentState.operatorList = {
  46965. fnArray: [],
  46966. argsArray: [],
  46967. lastChunk: false
  46968. };
  46969. this.transport.messageHandler.send('RenderPageRequest', {
  46970. pageIndex: this.pageIndex,
  46971. intent: renderingIntent
  46972. });
  46973. }
  46974. return intentState.opListReadCapability.promise;
  46975. },
  46976. getTextContent: function PDFPageProxy_getTextContent(params) {
  46977. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46978. pageIndex: this.pageNumber - 1,
  46979. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46980. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46981. });
  46982. },
  46983. _destroy: function PDFPageProxy_destroy() {
  46984. this.destroyed = true;
  46985. this.transport.pageCache[this.pageIndex] = null;
  46986. var waitOn = [];
  46987. Object.keys(this.intentStates).forEach(function (intent) {
  46988. if (intent === 'oplist') {
  46989. return;
  46990. }
  46991. var intentState = this.intentStates[intent];
  46992. intentState.renderTasks.forEach(function (renderTask) {
  46993. var renderCompleted = renderTask.capability.promise.catch(function () {
  46994. });
  46995. waitOn.push(renderCompleted);
  46996. renderTask.cancel();
  46997. });
  46998. }, this);
  46999. this.objs.clear();
  47000. this.annotationsPromise = null;
  47001. this.pendingCleanup = false;
  47002. return Promise.all(waitOn);
  47003. },
  47004. destroy: function () {
  47005. deprecated('page destroy method, use cleanup() instead');
  47006. this.cleanup();
  47007. },
  47008. cleanup: function PDFPageProxy_cleanup() {
  47009. this.pendingCleanup = true;
  47010. this._tryCleanup();
  47011. },
  47012. _tryCleanup: function PDFPageProxy_tryCleanup() {
  47013. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  47014. var intentState = this.intentStates[intent];
  47015. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  47016. }, this)) {
  47017. return;
  47018. }
  47019. Object.keys(this.intentStates).forEach(function (intent) {
  47020. delete this.intentStates[intent];
  47021. }, this);
  47022. this.objs.clear();
  47023. this.annotationsPromise = null;
  47024. this.pendingCleanup = false;
  47025. },
  47026. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  47027. var intentState = this.intentStates[intent];
  47028. if (intentState.displayReadyCapability) {
  47029. intentState.displayReadyCapability.resolve(transparency);
  47030. }
  47031. },
  47032. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  47033. var intentState = this.intentStates[intent];
  47034. var i, ii;
  47035. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  47036. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  47037. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  47038. }
  47039. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  47040. for (i = 0; i < intentState.renderTasks.length; i++) {
  47041. intentState.renderTasks[i].operatorListChanged();
  47042. }
  47043. if (operatorListChunk.lastChunk) {
  47044. intentState.receivingOperatorList = false;
  47045. this._tryCleanup();
  47046. }
  47047. }
  47048. };
  47049. return PDFPageProxy;
  47050. }();
  47051. var PDFWorker = function PDFWorkerClosure() {
  47052. var nextFakeWorkerId = 0;
  47053. function getWorkerSrc() {
  47054. if (typeof workerSrc !== 'undefined') {
  47055. return workerSrc;
  47056. }
  47057. if (getDefaultSetting('workerSrc')) {
  47058. return getDefaultSetting('workerSrc');
  47059. }
  47060. if (pdfjsFilePath) {
  47061. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  47062. }
  47063. error('No PDFJS.workerSrc specified');
  47064. }
  47065. var fakeWorkerFilesLoadedCapability;
  47066. function setupFakeWorkerGlobal() {
  47067. var WorkerMessageHandler;
  47068. if (fakeWorkerFilesLoadedCapability) {
  47069. return fakeWorkerFilesLoadedCapability.promise;
  47070. }
  47071. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  47072. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  47073. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  47074. return fakeWorkerFilesLoadedCapability.promise;
  47075. }
  47076. function FakeWorkerPort(defer) {
  47077. this._listeners = [];
  47078. this._defer = defer;
  47079. this._deferred = Promise.resolve(undefined);
  47080. }
  47081. FakeWorkerPort.prototype = {
  47082. postMessage: function (obj, transfers) {
  47083. function cloneValue(value) {
  47084. if (typeof value !== 'object' || value === null) {
  47085. return value;
  47086. }
  47087. if (cloned.has(value)) {
  47088. return cloned.get(value);
  47089. }
  47090. var result;
  47091. var buffer;
  47092. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  47093. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  47094. if (value === buffer) {
  47095. result = value;
  47096. } else if (transferable) {
  47097. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  47098. } else {
  47099. result = new value.constructor(value);
  47100. }
  47101. cloned.set(value, result);
  47102. return result;
  47103. }
  47104. result = isArray(value) ? [] : {};
  47105. cloned.set(value, result);
  47106. for (var i in value) {
  47107. var desc, p = value;
  47108. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  47109. p = Object.getPrototypeOf(p);
  47110. }
  47111. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  47112. continue;
  47113. }
  47114. result[i] = cloneValue(desc.value);
  47115. }
  47116. return result;
  47117. }
  47118. if (!this._defer) {
  47119. this._listeners.forEach(function (listener) {
  47120. listener.call(this, { data: obj });
  47121. }, this);
  47122. return;
  47123. }
  47124. var cloned = new WeakMap();
  47125. var e = { data: cloneValue(obj) };
  47126. this._deferred.then(function () {
  47127. this._listeners.forEach(function (listener) {
  47128. listener.call(this, e);
  47129. }, this);
  47130. }.bind(this));
  47131. },
  47132. addEventListener: function (name, listener) {
  47133. this._listeners.push(listener);
  47134. },
  47135. removeEventListener: function (name, listener) {
  47136. var i = this._listeners.indexOf(listener);
  47137. this._listeners.splice(i, 1);
  47138. },
  47139. terminate: function () {
  47140. this._listeners = [];
  47141. }
  47142. };
  47143. function createCDNWrapper(url) {
  47144. var wrapper = 'importScripts(\'' + url + '\');';
  47145. return URL.createObjectURL(new Blob([wrapper]));
  47146. }
  47147. function PDFWorker(name) {
  47148. this.name = name;
  47149. this.destroyed = false;
  47150. this._readyCapability = createPromiseCapability();
  47151. this._port = null;
  47152. this._webWorker = null;
  47153. this._messageHandler = null;
  47154. this._initialize();
  47155. }
  47156. PDFWorker.prototype = {
  47157. get promise() {
  47158. return this._readyCapability.promise;
  47159. },
  47160. get port() {
  47161. return this._port;
  47162. },
  47163. get messageHandler() {
  47164. return this._messageHandler;
  47165. },
  47166. _initialize: function PDFWorker_initialize() {
  47167. this._setupFakeWorker();
  47168. },
  47169. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  47170. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  47171. warn('Setting up fake worker.');
  47172. isWorkerDisabled = true;
  47173. }
  47174. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  47175. if (this.destroyed) {
  47176. this._readyCapability.reject(new Error('Worker was destroyed'));
  47177. return;
  47178. }
  47179. var isTypedArraysPresent = Uint8Array !== Float32Array;
  47180. var port = new FakeWorkerPort(isTypedArraysPresent);
  47181. this._port = port;
  47182. var id = 'fake' + nextFakeWorkerId++;
  47183. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47184. WorkerMessageHandler.setup(workerHandler, port);
  47185. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47186. this._messageHandler = messageHandler;
  47187. this._readyCapability.resolve();
  47188. }.bind(this));
  47189. },
  47190. destroy: function PDFWorker_destroy() {
  47191. this.destroyed = true;
  47192. if (this._webWorker) {
  47193. this._webWorker.terminate();
  47194. this._webWorker = null;
  47195. }
  47196. this._port = null;
  47197. if (this._messageHandler) {
  47198. this._messageHandler.destroy();
  47199. this._messageHandler = null;
  47200. }
  47201. }
  47202. };
  47203. return PDFWorker;
  47204. }();
  47205. var WorkerTransport = function WorkerTransportClosure() {
  47206. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47207. this.messageHandler = messageHandler;
  47208. this.loadingTask = loadingTask;
  47209. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47210. this.commonObjs = new PDFObjects();
  47211. this.fontLoader = new FontLoader(loadingTask.docId);
  47212. this.destroyed = false;
  47213. this.destroyCapability = null;
  47214. this.pageCache = [];
  47215. this.pagePromises = [];
  47216. this.downloadInfoCapability = createPromiseCapability();
  47217. this.setupMessageHandler();
  47218. }
  47219. WorkerTransport.prototype = {
  47220. destroy: function WorkerTransport_destroy() {
  47221. if (this.destroyCapability) {
  47222. return this.destroyCapability.promise;
  47223. }
  47224. this.destroyed = true;
  47225. this.destroyCapability = createPromiseCapability();
  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. function updatePassword(password) {
  47254. messageHandler.send('UpdatePassword', password);
  47255. }
  47256. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47257. if (pdfDataRangeTransport) {
  47258. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47259. messageHandler.send('OnDataRange', {
  47260. begin: begin,
  47261. chunk: chunk
  47262. });
  47263. });
  47264. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47265. messageHandler.send('OnDataProgress', { loaded: loaded });
  47266. });
  47267. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47268. messageHandler.send('OnDataRange', { chunk: chunk });
  47269. });
  47270. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47271. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47272. }, this);
  47273. }
  47274. messageHandler.on('GetDoc', function transportDoc(data) {
  47275. var pdfInfo = data.pdfInfo;
  47276. this.numPages = data.pdfInfo.numPages;
  47277. var loadingTask = this.loadingTask;
  47278. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47279. this.pdfDocument = pdfDocument;
  47280. loadingTask._capability.resolve(pdfDocument);
  47281. }, this);
  47282. messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
  47283. var loadingTask = this.loadingTask;
  47284. if (loadingTask.onPassword) {
  47285. return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
  47286. }
  47287. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47288. }, this);
  47289. messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
  47290. var loadingTask = this.loadingTask;
  47291. if (loadingTask.onPassword) {
  47292. return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
  47293. }
  47294. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47295. }, this);
  47296. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47297. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47298. }, this);
  47299. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47300. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47301. }, this);
  47302. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47303. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47304. }, this);
  47305. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47306. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47307. }, this);
  47308. messageHandler.on('DataLoaded', function transportPage(data) {
  47309. this.downloadInfoCapability.resolve(data);
  47310. }, this);
  47311. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47312. if (this.pdfDataRangeTransport) {
  47313. this.pdfDataRangeTransport.transportReady();
  47314. }
  47315. }, this);
  47316. messageHandler.on('StartRenderPage', function transportRender(data) {
  47317. if (this.destroyed) {
  47318. return;
  47319. }
  47320. var page = this.pageCache[data.pageIndex];
  47321. page.stats.timeEnd('Page Request');
  47322. page._startRenderPage(data.transparency, data.intent);
  47323. }, this);
  47324. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47325. if (this.destroyed) {
  47326. return;
  47327. }
  47328. var page = this.pageCache[data.pageIndex];
  47329. page._renderPageChunk(data.operatorList, data.intent);
  47330. }, this);
  47331. messageHandler.on('commonobj', function transportObj(data) {
  47332. if (this.destroyed) {
  47333. return;
  47334. }
  47335. var id = data[0];
  47336. var type = data[1];
  47337. if (this.commonObjs.hasData(id)) {
  47338. return;
  47339. }
  47340. switch (type) {
  47341. case 'Font':
  47342. var exportedData = data[2];
  47343. if ('error' in exportedData) {
  47344. var exportedError = exportedData.error;
  47345. warn('Error during font loading: ' + exportedError);
  47346. this.commonObjs.resolve(id, exportedError);
  47347. break;
  47348. }
  47349. var fontRegistry = null;
  47350. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47351. fontRegistry = {
  47352. registerFont: function (font, url) {
  47353. globalScope['FontInspector'].fontAdded(font, url);
  47354. }
  47355. };
  47356. }
  47357. var font = new FontFaceObject(exportedData, {
  47358. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47359. disableFontFace: getDefaultSetting('disableFontFace'),
  47360. fontRegistry: fontRegistry
  47361. });
  47362. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47363. this.commonObjs.resolve(id, font);
  47364. }.bind(this));
  47365. break;
  47366. case 'FontPath':
  47367. this.commonObjs.resolve(id, data[2]);
  47368. break;
  47369. default:
  47370. error('Got unknown common object type ' + type);
  47371. }
  47372. }, this);
  47373. messageHandler.on('obj', function transportObj(data) {
  47374. if (this.destroyed) {
  47375. return;
  47376. }
  47377. var id = data[0];
  47378. var pageIndex = data[1];
  47379. var type = data[2];
  47380. var pageProxy = this.pageCache[pageIndex];
  47381. var imageData;
  47382. if (pageProxy.objs.hasData(id)) {
  47383. return;
  47384. }
  47385. switch (type) {
  47386. case 'JpegStream':
  47387. imageData = data[3];
  47388. loadJpegStream(id, imageData, pageProxy.objs);
  47389. break;
  47390. case 'Image':
  47391. imageData = data[3];
  47392. pageProxy.objs.resolve(id, imageData);
  47393. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47394. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47395. pageProxy.cleanupAfterRender = true;
  47396. }
  47397. break;
  47398. default:
  47399. error('Got unknown object type ' + type);
  47400. }
  47401. }, this);
  47402. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47403. if (this.destroyed) {
  47404. return;
  47405. }
  47406. var loadingTask = this.loadingTask;
  47407. if (loadingTask.onProgress) {
  47408. loadingTask.onProgress({
  47409. loaded: data.loaded,
  47410. total: data.total
  47411. });
  47412. }
  47413. }, this);
  47414. messageHandler.on('PageError', function transportError(data) {
  47415. if (this.destroyed) {
  47416. return;
  47417. }
  47418. var page = this.pageCache[data.pageNum - 1];
  47419. var intentState = page.intentStates[data.intent];
  47420. if (intentState.displayReadyCapability) {
  47421. intentState.displayReadyCapability.reject(data.error);
  47422. } else {
  47423. error(data.error);
  47424. }
  47425. if (intentState.operatorList) {
  47426. intentState.operatorList.lastChunk = true;
  47427. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47428. intentState.renderTasks[i].operatorListChanged();
  47429. }
  47430. }
  47431. }, this);
  47432. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47433. if (this.destroyed) {
  47434. return;
  47435. }
  47436. var featureId = data.featureId;
  47437. var loadingTask = this.loadingTask;
  47438. if (loadingTask.onUnsupportedFeature) {
  47439. loadingTask.onUnsupportedFeature(featureId);
  47440. }
  47441. _UnsupportedManager.notify(featureId);
  47442. }, this);
  47443. messageHandler.on('JpegDecode', function (data) {
  47444. if (this.destroyed) {
  47445. return Promise.reject(new Error('Worker was destroyed'));
  47446. }
  47447. var imageUrl = data[0];
  47448. var components = data[1];
  47449. if (components !== 3 && components !== 1) {
  47450. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47451. }
  47452. return new Promise(function (resolve, reject) {
  47453. var img = new Image();
  47454. img.onload = function () {
  47455. var width = img.width;
  47456. var height = img.height;
  47457. var size = width * height;
  47458. var rgbaLength = size * 4;
  47459. var buf = new Uint8Array(size * components);
  47460. var tmpCanvas = createScratchCanvas(width, height);
  47461. var tmpCtx = tmpCanvas.getContext('2d');
  47462. tmpCtx.drawImage(img, 0, 0);
  47463. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47464. var i, j;
  47465. if (components === 3) {
  47466. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47467. buf[j] = data[i];
  47468. buf[j + 1] = data[i + 1];
  47469. buf[j + 2] = data[i + 2];
  47470. }
  47471. } else if (components === 1) {
  47472. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47473. buf[j] = data[i];
  47474. }
  47475. }
  47476. resolve({
  47477. data: buf,
  47478. width: width,
  47479. height: height
  47480. });
  47481. };
  47482. img.onerror = function () {
  47483. reject(new Error('JpegDecode failed to load image'));
  47484. };
  47485. img.src = imageUrl;
  47486. });
  47487. }, this);
  47488. },
  47489. getData: function WorkerTransport_getData() {
  47490. return this.messageHandler.sendWithPromise('GetData', null);
  47491. },
  47492. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47493. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47494. return Promise.reject(new Error('Invalid page request'));
  47495. }
  47496. var pageIndex = pageNumber - 1;
  47497. if (pageIndex in this.pagePromises) {
  47498. return this.pagePromises[pageIndex];
  47499. }
  47500. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47501. if (this.destroyed) {
  47502. throw new Error('Transport destroyed');
  47503. }
  47504. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47505. this.pageCache[pageIndex] = page;
  47506. return page;
  47507. }.bind(this));
  47508. this.pagePromises[pageIndex] = promise;
  47509. return promise;
  47510. },
  47511. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47512. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47513. return Promise.reject(new Error(reason));
  47514. });
  47515. },
  47516. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47517. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47518. pageIndex: pageIndex,
  47519. intent: intent
  47520. });
  47521. },
  47522. getDestinations: function WorkerTransport_getDestinations() {
  47523. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47524. },
  47525. getDestination: function WorkerTransport_getDestination(id) {
  47526. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47527. },
  47528. getPageLabels: function WorkerTransport_getPageLabels() {
  47529. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47530. },
  47531. getAttachments: function WorkerTransport_getAttachments() {
  47532. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47533. },
  47534. getJavaScript: function WorkerTransport_getJavaScript() {
  47535. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47536. },
  47537. getOutline: function WorkerTransport_getOutline() {
  47538. return this.messageHandler.sendWithPromise('GetOutline', null);
  47539. },
  47540. getMetadata: function WorkerTransport_getMetadata() {
  47541. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47542. return {
  47543. info: results[0],
  47544. metadata: results[1] ? new Metadata(results[1]) : null
  47545. };
  47546. });
  47547. },
  47548. getStats: function WorkerTransport_getStats() {
  47549. return this.messageHandler.sendWithPromise('GetStats', null);
  47550. },
  47551. startCleanup: function WorkerTransport_startCleanup() {
  47552. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47553. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47554. var page = this.pageCache[i];
  47555. if (page) {
  47556. page.cleanup();
  47557. }
  47558. }
  47559. this.commonObjs.clear();
  47560. this.fontLoader.clear();
  47561. }.bind(this));
  47562. }
  47563. };
  47564. return WorkerTransport;
  47565. }();
  47566. var PDFObjects = function PDFObjectsClosure() {
  47567. function PDFObjects() {
  47568. this.objs = Object.create(null);
  47569. }
  47570. PDFObjects.prototype = {
  47571. ensureObj: function PDFObjects_ensureObj(objId) {
  47572. if (this.objs[objId]) {
  47573. return this.objs[objId];
  47574. }
  47575. var obj = {
  47576. capability: createPromiseCapability(),
  47577. data: null,
  47578. resolved: false
  47579. };
  47580. this.objs[objId] = obj;
  47581. return obj;
  47582. },
  47583. get: function PDFObjects_get(objId, callback) {
  47584. if (callback) {
  47585. this.ensureObj(objId).capability.promise.then(callback);
  47586. return null;
  47587. }
  47588. var obj = this.objs[objId];
  47589. if (!obj || !obj.resolved) {
  47590. error('Requesting object that isn\'t resolved yet ' + objId);
  47591. }
  47592. return obj.data;
  47593. },
  47594. resolve: function PDFObjects_resolve(objId, data) {
  47595. var obj = this.ensureObj(objId);
  47596. obj.resolved = true;
  47597. obj.data = data;
  47598. obj.capability.resolve(data);
  47599. },
  47600. isResolved: function PDFObjects_isResolved(objId) {
  47601. var objs = this.objs;
  47602. if (!objs[objId]) {
  47603. return false;
  47604. } else {
  47605. return objs[objId].resolved;
  47606. }
  47607. },
  47608. hasData: function PDFObjects_hasData(objId) {
  47609. return this.isResolved(objId);
  47610. },
  47611. getData: function PDFObjects_getData(objId) {
  47612. var objs = this.objs;
  47613. if (!objs[objId] || !objs[objId].resolved) {
  47614. return null;
  47615. } else {
  47616. return objs[objId].data;
  47617. }
  47618. },
  47619. clear: function PDFObjects_clear() {
  47620. this.objs = Object.create(null);
  47621. }
  47622. };
  47623. return PDFObjects;
  47624. }();
  47625. var RenderTask = function RenderTaskClosure() {
  47626. function RenderTask(internalRenderTask) {
  47627. this._internalRenderTask = internalRenderTask;
  47628. this.onContinue = null;
  47629. }
  47630. RenderTask.prototype = {
  47631. get promise() {
  47632. return this._internalRenderTask.capability.promise;
  47633. },
  47634. cancel: function RenderTask_cancel() {
  47635. this._internalRenderTask.cancel();
  47636. },
  47637. then: function RenderTask_then(onFulfilled, onRejected) {
  47638. return this.promise.then.apply(this.promise, arguments);
  47639. }
  47640. };
  47641. return RenderTask;
  47642. }();
  47643. var InternalRenderTask = function InternalRenderTaskClosure() {
  47644. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47645. this.callback = callback;
  47646. this.params = params;
  47647. this.objs = objs;
  47648. this.commonObjs = commonObjs;
  47649. this.operatorListIdx = null;
  47650. this.operatorList = operatorList;
  47651. this.pageNumber = pageNumber;
  47652. this.running = false;
  47653. this.graphicsReadyCallback = null;
  47654. this.graphicsReady = false;
  47655. this.useRequestAnimationFrame = false;
  47656. this.cancelled = false;
  47657. this.capability = createPromiseCapability();
  47658. this.task = new RenderTask(this);
  47659. this._continueBound = this._continue.bind(this);
  47660. this._scheduleNextBound = this._scheduleNext.bind(this);
  47661. this._nextBound = this._next.bind(this);
  47662. }
  47663. InternalRenderTask.prototype = {
  47664. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47665. if (this.cancelled) {
  47666. return;
  47667. }
  47668. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47669. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47670. this.stepper.init(this.operatorList);
  47671. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47672. }
  47673. var params = this.params;
  47674. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47675. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47676. this.operatorListIdx = 0;
  47677. this.graphicsReady = true;
  47678. if (this.graphicsReadyCallback) {
  47679. this.graphicsReadyCallback();
  47680. }
  47681. },
  47682. cancel: function InternalRenderTask_cancel() {
  47683. this.running = false;
  47684. this.cancelled = true;
  47685. this.callback('cancelled');
  47686. },
  47687. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47688. if (!this.graphicsReady) {
  47689. if (!this.graphicsReadyCallback) {
  47690. this.graphicsReadyCallback = this._continueBound;
  47691. }
  47692. return;
  47693. }
  47694. if (this.stepper) {
  47695. this.stepper.updateOperatorList(this.operatorList);
  47696. }
  47697. if (this.running) {
  47698. return;
  47699. }
  47700. this._continue();
  47701. },
  47702. _continue: function InternalRenderTask__continue() {
  47703. this.running = true;
  47704. if (this.cancelled) {
  47705. return;
  47706. }
  47707. if (this.task.onContinue) {
  47708. this.task.onContinue.call(this.task, this._scheduleNextBound);
  47709. } else {
  47710. this._scheduleNext();
  47711. }
  47712. },
  47713. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47714. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47715. window.requestAnimationFrame(this._nextBound);
  47716. } else {
  47717. Promise.resolve(undefined).then(this._nextBound);
  47718. }
  47719. },
  47720. _next: function InternalRenderTask__next() {
  47721. if (this.cancelled) {
  47722. return;
  47723. }
  47724. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47725. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47726. this.running = false;
  47727. if (this.operatorList.lastChunk) {
  47728. this.gfx.endDrawing();
  47729. this.callback();
  47730. }
  47731. }
  47732. }
  47733. };
  47734. return InternalRenderTask;
  47735. }();
  47736. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47737. var listeners = [];
  47738. return {
  47739. listen: function (cb) {
  47740. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47741. listeners.push(cb);
  47742. },
  47743. notify: function (featureId) {
  47744. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47745. listeners[i](featureId);
  47746. }
  47747. }
  47748. };
  47749. }();
  47750. if (typeof pdfjsVersion !== 'undefined') {
  47751. exports.version = pdfjsVersion;
  47752. }
  47753. if (typeof pdfjsBuild !== 'undefined') {
  47754. exports.build = pdfjsBuild;
  47755. }
  47756. exports.getDocument = getDocument;
  47757. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47758. exports.PDFWorker = PDFWorker;
  47759. exports.PDFDocumentProxy = PDFDocumentProxy;
  47760. exports.PDFPageProxy = PDFPageProxy;
  47761. exports._UnsupportedManager = _UnsupportedManager;
  47762. }));
  47763. (function (root, factory) {
  47764. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47765. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47766. var error = sharedUtil.error;
  47767. var info = sharedUtil.info;
  47768. var isArray = sharedUtil.isArray;
  47769. var isString = sharedUtil.isString;
  47770. var shadow = sharedUtil.shadow;
  47771. var warn = sharedUtil.warn;
  47772. var isDict = corePrimitives.isDict;
  47773. var isName = corePrimitives.isName;
  47774. var isStream = corePrimitives.isStream;
  47775. var PDFFunction = coreFunction.PDFFunction;
  47776. var ColorSpace = function ColorSpaceClosure() {
  47777. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47778. var COMPONENTS = 3;
  47779. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47780. var xRatio = w1 / w2;
  47781. var yRatio = h1 / h2;
  47782. var i, j, py, newIndex = 0, oldIndex;
  47783. var xScaled = new Uint16Array(w2);
  47784. var w1Scanline = w1 * COMPONENTS;
  47785. for (i = 0; i < w2; i++) {
  47786. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47787. }
  47788. for (i = 0; i < h2; i++) {
  47789. py = Math.floor(i * yRatio) * w1Scanline;
  47790. for (j = 0; j < w2; j++) {
  47791. oldIndex = py + xScaled[j];
  47792. dest[newIndex++] = src[oldIndex++];
  47793. dest[newIndex++] = src[oldIndex++];
  47794. dest[newIndex++] = src[oldIndex++];
  47795. newIndex += alpha01;
  47796. }
  47797. }
  47798. }
  47799. function ColorSpace() {
  47800. error('should not call ColorSpace constructor');
  47801. }
  47802. ColorSpace.prototype = {
  47803. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47804. var rgb = new Uint8Array(3);
  47805. this.getRgbItem(src, srcOffset, rgb, 0);
  47806. return rgb;
  47807. },
  47808. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47809. error('Should not call ColorSpace.getRgbItem');
  47810. },
  47811. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47812. error('Should not call ColorSpace.getRgbBuffer');
  47813. },
  47814. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47815. error('Should not call ColorSpace.getOutputLength');
  47816. },
  47817. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47818. return false;
  47819. },
  47820. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47821. var count = originalWidth * originalHeight;
  47822. var rgbBuf = null;
  47823. var numComponentColors = 1 << bpc;
  47824. var needsResizing = originalHeight !== height || originalWidth !== width;
  47825. var i, ii;
  47826. if (this.isPassthrough(bpc)) {
  47827. rgbBuf = comps;
  47828. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47829. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47830. var key;
  47831. for (i = 0; i < numComponentColors; i++) {
  47832. allColors[i] = i;
  47833. }
  47834. var colorMap = new Uint8Array(numComponentColors * 3);
  47835. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47836. var destPos, rgbPos;
  47837. if (!needsResizing) {
  47838. destPos = 0;
  47839. for (i = 0; i < count; ++i) {
  47840. key = comps[i] * 3;
  47841. dest[destPos++] = colorMap[key];
  47842. dest[destPos++] = colorMap[key + 1];
  47843. dest[destPos++] = colorMap[key + 2];
  47844. destPos += alpha01;
  47845. }
  47846. } else {
  47847. rgbBuf = new Uint8Array(count * 3);
  47848. rgbPos = 0;
  47849. for (i = 0; i < count; ++i) {
  47850. key = comps[i] * 3;
  47851. rgbBuf[rgbPos++] = colorMap[key];
  47852. rgbBuf[rgbPos++] = colorMap[key + 1];
  47853. rgbBuf[rgbPos++] = colorMap[key + 2];
  47854. }
  47855. }
  47856. } else {
  47857. if (!needsResizing) {
  47858. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47859. } else {
  47860. rgbBuf = new Uint8Array(count * 3);
  47861. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47862. }
  47863. }
  47864. if (rgbBuf) {
  47865. if (needsResizing) {
  47866. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47867. } else {
  47868. rgbPos = 0;
  47869. destPos = 0;
  47870. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47871. dest[destPos++] = rgbBuf[rgbPos++];
  47872. dest[destPos++] = rgbBuf[rgbPos++];
  47873. dest[destPos++] = rgbBuf[rgbPos++];
  47874. destPos += alpha01;
  47875. }
  47876. }
  47877. }
  47878. },
  47879. usesZeroToOneRange: true
  47880. };
  47881. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47882. var IR = ColorSpace.parseToIR(cs, xref, res);
  47883. if (IR instanceof AlternateCS) {
  47884. return IR;
  47885. }
  47886. return ColorSpace.fromIR(IR);
  47887. };
  47888. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47889. var name = isArray(IR) ? IR[0] : IR;
  47890. var whitePoint, blackPoint, gamma;
  47891. switch (name) {
  47892. case 'DeviceGrayCS':
  47893. return this.singletons.gray;
  47894. case 'DeviceRgbCS':
  47895. return this.singletons.rgb;
  47896. case 'DeviceCmykCS':
  47897. return this.singletons.cmyk;
  47898. case 'CalGrayCS':
  47899. whitePoint = IR[1];
  47900. blackPoint = IR[2];
  47901. gamma = IR[3];
  47902. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47903. case 'CalRGBCS':
  47904. whitePoint = IR[1];
  47905. blackPoint = IR[2];
  47906. gamma = IR[3];
  47907. var matrix = IR[4];
  47908. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47909. case 'PatternCS':
  47910. var basePatternCS = IR[1];
  47911. if (basePatternCS) {
  47912. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47913. }
  47914. return new PatternCS(basePatternCS);
  47915. case 'IndexedCS':
  47916. var baseIndexedCS = IR[1];
  47917. var hiVal = IR[2];
  47918. var lookup = IR[3];
  47919. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47920. case 'AlternateCS':
  47921. var numComps = IR[1];
  47922. var alt = IR[2];
  47923. var tintFnIR = IR[3];
  47924. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47925. case 'LabCS':
  47926. whitePoint = IR[1];
  47927. blackPoint = IR[2];
  47928. var range = IR[3];
  47929. return new LabCS(whitePoint, blackPoint, range);
  47930. default:
  47931. error('Unknown name ' + name);
  47932. }
  47933. return null;
  47934. };
  47935. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47936. if (isName(cs)) {
  47937. var colorSpaces = res.get('ColorSpace');
  47938. if (isDict(colorSpaces)) {
  47939. var refcs = colorSpaces.get(cs.name);
  47940. if (refcs) {
  47941. cs = refcs;
  47942. }
  47943. }
  47944. }
  47945. cs = xref.fetchIfRef(cs);
  47946. if (isName(cs)) {
  47947. switch (cs.name) {
  47948. case 'DeviceGray':
  47949. case 'G':
  47950. return 'DeviceGrayCS';
  47951. case 'DeviceRGB':
  47952. case 'RGB':
  47953. return 'DeviceRgbCS';
  47954. case 'DeviceCMYK':
  47955. case 'CMYK':
  47956. return 'DeviceCmykCS';
  47957. case 'Pattern':
  47958. return [
  47959. 'PatternCS',
  47960. null
  47961. ];
  47962. default:
  47963. error('unrecognized colorspace ' + cs.name);
  47964. }
  47965. } else if (isArray(cs)) {
  47966. var mode = xref.fetchIfRef(cs[0]).name;
  47967. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47968. switch (mode) {
  47969. case 'DeviceGray':
  47970. case 'G':
  47971. return 'DeviceGrayCS';
  47972. case 'DeviceRGB':
  47973. case 'RGB':
  47974. return 'DeviceRgbCS';
  47975. case 'DeviceCMYK':
  47976. case 'CMYK':
  47977. return 'DeviceCmykCS';
  47978. case 'CalGray':
  47979. params = xref.fetchIfRef(cs[1]);
  47980. whitePoint = params.getArray('WhitePoint');
  47981. blackPoint = params.getArray('BlackPoint');
  47982. gamma = params.get('Gamma');
  47983. return [
  47984. 'CalGrayCS',
  47985. whitePoint,
  47986. blackPoint,
  47987. gamma
  47988. ];
  47989. case 'CalRGB':
  47990. params = xref.fetchIfRef(cs[1]);
  47991. whitePoint = params.getArray('WhitePoint');
  47992. blackPoint = params.getArray('BlackPoint');
  47993. gamma = params.getArray('Gamma');
  47994. var matrix = params.getArray('Matrix');
  47995. return [
  47996. 'CalRGBCS',
  47997. whitePoint,
  47998. blackPoint,
  47999. gamma,
  48000. matrix
  48001. ];
  48002. case 'ICCBased':
  48003. var stream = xref.fetchIfRef(cs[1]);
  48004. var dict = stream.dict;
  48005. numComps = dict.get('N');
  48006. alt = dict.get('Alternate');
  48007. if (alt) {
  48008. var altIR = ColorSpace.parseToIR(alt, xref, res);
  48009. var altCS = ColorSpace.fromIR(altIR);
  48010. if (altCS.numComps === numComps) {
  48011. return altIR;
  48012. }
  48013. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  48014. }
  48015. if (numComps === 1) {
  48016. return 'DeviceGrayCS';
  48017. } else if (numComps === 3) {
  48018. return 'DeviceRgbCS';
  48019. } else if (numComps === 4) {
  48020. return 'DeviceCmykCS';
  48021. }
  48022. break;
  48023. case 'Pattern':
  48024. var basePatternCS = cs[1] || null;
  48025. if (basePatternCS) {
  48026. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  48027. }
  48028. return [
  48029. 'PatternCS',
  48030. basePatternCS
  48031. ];
  48032. case 'Indexed':
  48033. case 'I':
  48034. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  48035. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  48036. var lookup = xref.fetchIfRef(cs[3]);
  48037. if (isStream(lookup)) {
  48038. lookup = lookup.getBytes();
  48039. }
  48040. return [
  48041. 'IndexedCS',
  48042. baseIndexedCS,
  48043. hiVal,
  48044. lookup
  48045. ];
  48046. case 'Separation':
  48047. case 'DeviceN':
  48048. var name = xref.fetchIfRef(cs[1]);
  48049. numComps = isArray(name) ? name.length : 1;
  48050. alt = ColorSpace.parseToIR(cs[2], xref, res);
  48051. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  48052. return [
  48053. 'AlternateCS',
  48054. numComps,
  48055. alt,
  48056. tintFnIR
  48057. ];
  48058. case 'Lab':
  48059. params = xref.fetchIfRef(cs[1]);
  48060. whitePoint = params.getArray('WhitePoint');
  48061. blackPoint = params.getArray('BlackPoint');
  48062. var range = params.getArray('Range');
  48063. return [
  48064. 'LabCS',
  48065. whitePoint,
  48066. blackPoint,
  48067. range
  48068. ];
  48069. default:
  48070. error('unimplemented color space object "' + mode + '"');
  48071. }
  48072. } else {
  48073. error('unrecognized color space object: "' + cs + '"');
  48074. }
  48075. return null;
  48076. };
  48077. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  48078. if (!isArray(decode)) {
  48079. return true;
  48080. }
  48081. if (n * 2 !== decode.length) {
  48082. warn('The decode map is not the correct length');
  48083. return true;
  48084. }
  48085. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  48086. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  48087. return false;
  48088. }
  48089. }
  48090. return true;
  48091. };
  48092. ColorSpace.singletons = {
  48093. get gray() {
  48094. return shadow(this, 'gray', new DeviceGrayCS());
  48095. },
  48096. get rgb() {
  48097. return shadow(this, 'rgb', new DeviceRgbCS());
  48098. },
  48099. get cmyk() {
  48100. return shadow(this, 'cmyk', new DeviceCmykCS());
  48101. }
  48102. };
  48103. return ColorSpace;
  48104. }();
  48105. var AlternateCS = function AlternateCSClosure() {
  48106. function AlternateCS(numComps, base, tintFn) {
  48107. this.name = 'Alternate';
  48108. this.numComps = numComps;
  48109. this.defaultColor = new Float32Array(numComps);
  48110. for (var i = 0; i < numComps; ++i) {
  48111. this.defaultColor[i] = 1;
  48112. }
  48113. this.base = base;
  48114. this.tintFn = tintFn;
  48115. this.tmpBuf = new Float32Array(base.numComps);
  48116. }
  48117. AlternateCS.prototype = {
  48118. getRgb: ColorSpace.prototype.getRgb,
  48119. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48120. var tmpBuf = this.tmpBuf;
  48121. this.tintFn(src, srcOffset, tmpBuf, 0);
  48122. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  48123. },
  48124. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48125. var tintFn = this.tintFn;
  48126. var base = this.base;
  48127. var scale = 1 / ((1 << bits) - 1);
  48128. var baseNumComps = base.numComps;
  48129. var usesZeroToOneRange = base.usesZeroToOneRange;
  48130. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  48131. var pos = isPassthrough ? destOffset : 0;
  48132. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  48133. var numComps = this.numComps;
  48134. var scaled = new Float32Array(numComps);
  48135. var tinted = new Float32Array(baseNumComps);
  48136. var i, j;
  48137. for (i = 0; i < count; i++) {
  48138. for (j = 0; j < numComps; j++) {
  48139. scaled[j] = src[srcOffset++] * scale;
  48140. }
  48141. tintFn(scaled, 0, tinted, 0);
  48142. if (usesZeroToOneRange) {
  48143. for (j = 0; j < baseNumComps; j++) {
  48144. baseBuf[pos++] = tinted[j] * 255;
  48145. }
  48146. } else {
  48147. base.getRgbItem(tinted, 0, baseBuf, pos);
  48148. pos += baseNumComps;
  48149. }
  48150. }
  48151. if (!isPassthrough) {
  48152. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  48153. }
  48154. },
  48155. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  48156. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  48157. },
  48158. isPassthrough: ColorSpace.prototype.isPassthrough,
  48159. fillRgb: ColorSpace.prototype.fillRgb,
  48160. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  48161. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48162. },
  48163. usesZeroToOneRange: true
  48164. };
  48165. return AlternateCS;
  48166. }();
  48167. var PatternCS = function PatternCSClosure() {
  48168. function PatternCS(baseCS) {
  48169. this.name = 'Pattern';
  48170. this.base = baseCS;
  48171. }
  48172. PatternCS.prototype = {};
  48173. return PatternCS;
  48174. }();
  48175. var IndexedCS = function IndexedCSClosure() {
  48176. function IndexedCS(base, highVal, lookup) {
  48177. this.name = 'Indexed';
  48178. this.numComps = 1;
  48179. this.defaultColor = new Uint8Array(this.numComps);
  48180. this.base = base;
  48181. this.highVal = highVal;
  48182. var baseNumComps = base.numComps;
  48183. var length = baseNumComps * highVal;
  48184. if (isStream(lookup)) {
  48185. this.lookup = new Uint8Array(length);
  48186. var bytes = lookup.getBytes(length);
  48187. this.lookup.set(bytes);
  48188. } else if (isString(lookup)) {
  48189. this.lookup = new Uint8Array(length);
  48190. for (var i = 0; i < length; ++i) {
  48191. this.lookup[i] = lookup.charCodeAt(i);
  48192. }
  48193. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48194. this.lookup = lookup;
  48195. } else {
  48196. error('Unrecognized lookup table: ' + lookup);
  48197. }
  48198. }
  48199. IndexedCS.prototype = {
  48200. getRgb: ColorSpace.prototype.getRgb,
  48201. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48202. var numComps = this.base.numComps;
  48203. var start = src[srcOffset] * numComps;
  48204. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48205. },
  48206. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48207. var base = this.base;
  48208. var numComps = base.numComps;
  48209. var outputDelta = base.getOutputLength(numComps, alpha01);
  48210. var lookup = this.lookup;
  48211. for (var i = 0; i < count; ++i) {
  48212. var lookupPos = src[srcOffset++] * numComps;
  48213. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48214. destOffset += outputDelta;
  48215. }
  48216. },
  48217. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48218. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48219. },
  48220. isPassthrough: ColorSpace.prototype.isPassthrough,
  48221. fillRgb: ColorSpace.prototype.fillRgb,
  48222. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48223. return true;
  48224. },
  48225. usesZeroToOneRange: true
  48226. };
  48227. return IndexedCS;
  48228. }();
  48229. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48230. function DeviceGrayCS() {
  48231. this.name = 'DeviceGray';
  48232. this.numComps = 1;
  48233. this.defaultColor = new Float32Array(this.numComps);
  48234. }
  48235. DeviceGrayCS.prototype = {
  48236. getRgb: ColorSpace.prototype.getRgb,
  48237. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48238. var c = src[srcOffset] * 255 | 0;
  48239. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48240. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48241. },
  48242. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48243. var scale = 255 / ((1 << bits) - 1);
  48244. var j = srcOffset, q = destOffset;
  48245. for (var i = 0; i < count; ++i) {
  48246. var c = scale * src[j++] | 0;
  48247. dest[q++] = c;
  48248. dest[q++] = c;
  48249. dest[q++] = c;
  48250. q += alpha01;
  48251. }
  48252. },
  48253. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48254. return inputLength * (3 + alpha01);
  48255. },
  48256. isPassthrough: ColorSpace.prototype.isPassthrough,
  48257. fillRgb: ColorSpace.prototype.fillRgb,
  48258. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48259. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48260. },
  48261. usesZeroToOneRange: true
  48262. };
  48263. return DeviceGrayCS;
  48264. }();
  48265. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48266. function DeviceRgbCS() {
  48267. this.name = 'DeviceRGB';
  48268. this.numComps = 3;
  48269. this.defaultColor = new Float32Array(this.numComps);
  48270. }
  48271. DeviceRgbCS.prototype = {
  48272. getRgb: ColorSpace.prototype.getRgb,
  48273. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48274. var r = src[srcOffset] * 255 | 0;
  48275. var g = src[srcOffset + 1] * 255 | 0;
  48276. var b = src[srcOffset + 2] * 255 | 0;
  48277. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48278. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48279. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48280. },
  48281. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48282. if (bits === 8 && alpha01 === 0) {
  48283. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48284. return;
  48285. }
  48286. var scale = 255 / ((1 << bits) - 1);
  48287. var j = srcOffset, q = destOffset;
  48288. for (var i = 0; i < count; ++i) {
  48289. dest[q++] = scale * src[j++] | 0;
  48290. dest[q++] = scale * src[j++] | 0;
  48291. dest[q++] = scale * src[j++] | 0;
  48292. q += alpha01;
  48293. }
  48294. },
  48295. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48296. return inputLength * (3 + alpha01) / 3 | 0;
  48297. },
  48298. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48299. return bits === 8;
  48300. },
  48301. fillRgb: ColorSpace.prototype.fillRgb,
  48302. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48303. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48304. },
  48305. usesZeroToOneRange: true
  48306. };
  48307. return DeviceRgbCS;
  48308. }();
  48309. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48310. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48311. var c = src[srcOffset + 0] * srcScale;
  48312. var m = src[srcOffset + 1] * srcScale;
  48313. var y = src[srcOffset + 2] * srcScale;
  48314. var k = src[srcOffset + 3] * srcScale;
  48315. 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;
  48316. 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;
  48317. 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;
  48318. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48319. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48320. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48321. }
  48322. function DeviceCmykCS() {
  48323. this.name = 'DeviceCMYK';
  48324. this.numComps = 4;
  48325. this.defaultColor = new Float32Array(this.numComps);
  48326. this.defaultColor[3] = 1;
  48327. }
  48328. DeviceCmykCS.prototype = {
  48329. getRgb: ColorSpace.prototype.getRgb,
  48330. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48331. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48332. },
  48333. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48334. var scale = 1 / ((1 << bits) - 1);
  48335. for (var i = 0; i < count; i++) {
  48336. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48337. srcOffset += 4;
  48338. destOffset += 3 + alpha01;
  48339. }
  48340. },
  48341. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48342. return inputLength / 4 * (3 + alpha01) | 0;
  48343. },
  48344. isPassthrough: ColorSpace.prototype.isPassthrough,
  48345. fillRgb: ColorSpace.prototype.fillRgb,
  48346. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48347. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48348. },
  48349. usesZeroToOneRange: true
  48350. };
  48351. return DeviceCmykCS;
  48352. }();
  48353. var CalGrayCS = function CalGrayCSClosure() {
  48354. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48355. this.name = 'CalGray';
  48356. this.numComps = 1;
  48357. this.defaultColor = new Float32Array(this.numComps);
  48358. if (!whitePoint) {
  48359. error('WhitePoint missing - required for color space CalGray');
  48360. }
  48361. blackPoint = blackPoint || [
  48362. 0,
  48363. 0,
  48364. 0
  48365. ];
  48366. gamma = gamma || 1;
  48367. this.XW = whitePoint[0];
  48368. this.YW = whitePoint[1];
  48369. this.ZW = whitePoint[2];
  48370. this.XB = blackPoint[0];
  48371. this.YB = blackPoint[1];
  48372. this.ZB = blackPoint[2];
  48373. this.G = gamma;
  48374. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48375. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48376. }
  48377. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48378. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48379. this.XB = this.YB = this.ZB = 0;
  48380. }
  48381. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48382. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48383. }
  48384. if (this.G < 1) {
  48385. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48386. this.G = 1;
  48387. }
  48388. }
  48389. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48390. var A = src[srcOffset] * scale;
  48391. var AG = Math.pow(A, cs.G);
  48392. var L = cs.YW * AG;
  48393. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48394. dest[destOffset] = val;
  48395. dest[destOffset + 1] = val;
  48396. dest[destOffset + 2] = val;
  48397. }
  48398. CalGrayCS.prototype = {
  48399. getRgb: ColorSpace.prototype.getRgb,
  48400. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48401. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48402. },
  48403. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48404. var scale = 1 / ((1 << bits) - 1);
  48405. for (var i = 0; i < count; ++i) {
  48406. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48407. srcOffset += 1;
  48408. destOffset += 3 + alpha01;
  48409. }
  48410. },
  48411. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48412. return inputLength * (3 + alpha01);
  48413. },
  48414. isPassthrough: ColorSpace.prototype.isPassthrough,
  48415. fillRgb: ColorSpace.prototype.fillRgb,
  48416. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48417. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48418. },
  48419. usesZeroToOneRange: true
  48420. };
  48421. return CalGrayCS;
  48422. }();
  48423. var CalRGBCS = function CalRGBCSClosure() {
  48424. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48425. 0.8951,
  48426. 0.2664,
  48427. -0.1614,
  48428. -0.7502,
  48429. 1.7135,
  48430. 0.0367,
  48431. 0.0389,
  48432. -0.0685,
  48433. 1.0296
  48434. ]);
  48435. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48436. 0.9869929,
  48437. -0.1470543,
  48438. 0.1599627,
  48439. 0.4323053,
  48440. 0.5183603,
  48441. 0.0492912,
  48442. -0.0085287,
  48443. 0.0400428,
  48444. 0.9684867
  48445. ]);
  48446. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48447. 3.2404542,
  48448. -1.5371385,
  48449. -0.4985314,
  48450. -0.9692660,
  48451. 1.8760108,
  48452. 0.0415560,
  48453. 0.0556434,
  48454. -0.2040259,
  48455. 1.0572252
  48456. ]);
  48457. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48458. 1,
  48459. 1,
  48460. 1
  48461. ]);
  48462. var tempNormalizeMatrix = new Float32Array(3);
  48463. var tempConvertMatrix1 = new Float32Array(3);
  48464. var tempConvertMatrix2 = new Float32Array(3);
  48465. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48466. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48467. this.name = 'CalRGB';
  48468. this.numComps = 3;
  48469. this.defaultColor = new Float32Array(this.numComps);
  48470. if (!whitePoint) {
  48471. error('WhitePoint missing - required for color space CalRGB');
  48472. }
  48473. blackPoint = blackPoint || new Float32Array(3);
  48474. gamma = gamma || new Float32Array([
  48475. 1,
  48476. 1,
  48477. 1
  48478. ]);
  48479. matrix = matrix || new Float32Array([
  48480. 1,
  48481. 0,
  48482. 0,
  48483. 0,
  48484. 1,
  48485. 0,
  48486. 0,
  48487. 0,
  48488. 1
  48489. ]);
  48490. var XW = whitePoint[0];
  48491. var YW = whitePoint[1];
  48492. var ZW = whitePoint[2];
  48493. this.whitePoint = whitePoint;
  48494. var XB = blackPoint[0];
  48495. var YB = blackPoint[1];
  48496. var ZB = blackPoint[2];
  48497. this.blackPoint = blackPoint;
  48498. this.GR = gamma[0];
  48499. this.GG = gamma[1];
  48500. this.GB = gamma[2];
  48501. this.MXA = matrix[0];
  48502. this.MYA = matrix[1];
  48503. this.MZA = matrix[2];
  48504. this.MXB = matrix[3];
  48505. this.MYB = matrix[4];
  48506. this.MZB = matrix[5];
  48507. this.MXC = matrix[6];
  48508. this.MYC = matrix[7];
  48509. this.MZC = matrix[8];
  48510. if (XW < 0 || ZW < 0 || YW !== 1) {
  48511. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48512. }
  48513. if (XB < 0 || YB < 0 || ZB < 0) {
  48514. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48515. this.blackPoint = new Float32Array(3);
  48516. }
  48517. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48518. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48519. this.GR = this.GG = this.GB = 1;
  48520. }
  48521. 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) {
  48522. 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');
  48523. this.MXA = this.MYB = this.MZC = 1;
  48524. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48525. }
  48526. }
  48527. function matrixProduct(a, b, result) {
  48528. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48529. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48530. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48531. }
  48532. function convertToFlat(sourceWhitePoint, LMS, result) {
  48533. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48534. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48535. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48536. }
  48537. function convertToD65(sourceWhitePoint, LMS, result) {
  48538. var D65X = 0.95047;
  48539. var D65Y = 1;
  48540. var D65Z = 1.08883;
  48541. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48542. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48543. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48544. }
  48545. function sRGBTransferFunction(color) {
  48546. if (color <= 0.0031308) {
  48547. return adjustToRange(0, 1, 12.92 * color);
  48548. }
  48549. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48550. }
  48551. function adjustToRange(min, max, value) {
  48552. return Math.max(min, Math.min(max, value));
  48553. }
  48554. function decodeL(L) {
  48555. if (L < 0) {
  48556. return -decodeL(-L);
  48557. }
  48558. if (L > 8.0) {
  48559. return Math.pow((L + 16) / 116, 3);
  48560. }
  48561. return L * DECODE_L_CONSTANT;
  48562. }
  48563. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48564. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48565. result[0] = XYZ_Flat[0];
  48566. result[1] = XYZ_Flat[1];
  48567. result[2] = XYZ_Flat[2];
  48568. return;
  48569. }
  48570. var zeroDecodeL = decodeL(0);
  48571. var X_DST = zeroDecodeL;
  48572. var X_SRC = decodeL(sourceBlackPoint[0]);
  48573. var Y_DST = zeroDecodeL;
  48574. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48575. var Z_DST = zeroDecodeL;
  48576. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48577. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48578. var X_Offset = 1 - X_Scale;
  48579. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48580. var Y_Offset = 1 - Y_Scale;
  48581. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48582. var Z_Offset = 1 - Z_Scale;
  48583. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48584. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48585. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48586. }
  48587. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48588. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48589. result[0] = XYZ_In[0];
  48590. result[1] = XYZ_In[1];
  48591. result[2] = XYZ_In[2];
  48592. return;
  48593. }
  48594. var LMS = result;
  48595. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48596. var LMS_Flat = tempNormalizeMatrix;
  48597. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48598. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48599. }
  48600. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48601. var LMS = result;
  48602. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48603. var LMS_D65 = tempNormalizeMatrix;
  48604. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48605. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48606. }
  48607. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48608. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48609. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48610. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48611. var AGR = Math.pow(A, cs.GR);
  48612. var BGG = Math.pow(B, cs.GG);
  48613. var CGB = Math.pow(C, cs.GB);
  48614. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48615. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48616. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48617. var XYZ = tempConvertMatrix1;
  48618. XYZ[0] = X;
  48619. XYZ[1] = Y;
  48620. XYZ[2] = Z;
  48621. var XYZ_Flat = tempConvertMatrix2;
  48622. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48623. var XYZ_Black = tempConvertMatrix1;
  48624. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48625. var XYZ_D65 = tempConvertMatrix2;
  48626. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48627. var SRGB = tempConvertMatrix1;
  48628. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48629. var sR = sRGBTransferFunction(SRGB[0]);
  48630. var sG = sRGBTransferFunction(SRGB[1]);
  48631. var sB = sRGBTransferFunction(SRGB[2]);
  48632. dest[destOffset] = Math.round(sR * 255);
  48633. dest[destOffset + 1] = Math.round(sG * 255);
  48634. dest[destOffset + 2] = Math.round(sB * 255);
  48635. }
  48636. CalRGBCS.prototype = {
  48637. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48638. var rgb = new Uint8Array(3);
  48639. this.getRgbItem(src, srcOffset, rgb, 0);
  48640. return rgb;
  48641. },
  48642. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48643. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48644. },
  48645. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48646. var scale = 1 / ((1 << bits) - 1);
  48647. for (var i = 0; i < count; ++i) {
  48648. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48649. srcOffset += 3;
  48650. destOffset += 3 + alpha01;
  48651. }
  48652. },
  48653. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48654. return inputLength * (3 + alpha01) / 3 | 0;
  48655. },
  48656. isPassthrough: ColorSpace.prototype.isPassthrough,
  48657. fillRgb: ColorSpace.prototype.fillRgb,
  48658. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48659. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48660. },
  48661. usesZeroToOneRange: true
  48662. };
  48663. return CalRGBCS;
  48664. }();
  48665. var LabCS = function LabCSClosure() {
  48666. function LabCS(whitePoint, blackPoint, range) {
  48667. this.name = 'Lab';
  48668. this.numComps = 3;
  48669. this.defaultColor = new Float32Array(this.numComps);
  48670. if (!whitePoint) {
  48671. error('WhitePoint missing - required for color space Lab');
  48672. }
  48673. blackPoint = blackPoint || [
  48674. 0,
  48675. 0,
  48676. 0
  48677. ];
  48678. range = range || [
  48679. -100,
  48680. 100,
  48681. -100,
  48682. 100
  48683. ];
  48684. this.XW = whitePoint[0];
  48685. this.YW = whitePoint[1];
  48686. this.ZW = whitePoint[2];
  48687. this.amin = range[0];
  48688. this.amax = range[1];
  48689. this.bmin = range[2];
  48690. this.bmax = range[3];
  48691. this.XB = blackPoint[0];
  48692. this.YB = blackPoint[1];
  48693. this.ZB = blackPoint[2];
  48694. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48695. error('Invalid WhitePoint components, no fallback available');
  48696. }
  48697. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48698. info('Invalid BlackPoint, falling back to default');
  48699. this.XB = this.YB = this.ZB = 0;
  48700. }
  48701. if (this.amin > this.amax || this.bmin > this.bmax) {
  48702. info('Invalid Range, falling back to defaults');
  48703. this.amin = -100;
  48704. this.amax = 100;
  48705. this.bmin = -100;
  48706. this.bmax = 100;
  48707. }
  48708. }
  48709. function fn_g(x) {
  48710. if (x >= 6 / 29) {
  48711. return x * x * x;
  48712. } else {
  48713. return 108 / 841 * (x - 4 / 29);
  48714. }
  48715. }
  48716. function decode(value, high1, low2, high2) {
  48717. return low2 + value * (high2 - low2) / high1;
  48718. }
  48719. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48720. var Ls = src[srcOffset];
  48721. var as = src[srcOffset + 1];
  48722. var bs = src[srcOffset + 2];
  48723. if (maxVal !== false) {
  48724. Ls = decode(Ls, maxVal, 0, 100);
  48725. as = decode(as, maxVal, cs.amin, cs.amax);
  48726. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48727. }
  48728. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48729. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48730. var M = (Ls + 16) / 116;
  48731. var L = M + as / 500;
  48732. var N = M - bs / 200;
  48733. var X = cs.XW * fn_g(L);
  48734. var Y = cs.YW * fn_g(M);
  48735. var Z = cs.ZW * fn_g(N);
  48736. var r, g, b;
  48737. if (cs.ZW < 1) {
  48738. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48739. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48740. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48741. } else {
  48742. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48743. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48744. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48745. }
  48746. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48747. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48748. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48749. }
  48750. LabCS.prototype = {
  48751. getRgb: ColorSpace.prototype.getRgb,
  48752. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48753. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48754. },
  48755. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48756. var maxVal = (1 << bits) - 1;
  48757. for (var i = 0; i < count; i++) {
  48758. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48759. srcOffset += 3;
  48760. destOffset += 3 + alpha01;
  48761. }
  48762. },
  48763. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48764. return inputLength * (3 + alpha01) / 3 | 0;
  48765. },
  48766. isPassthrough: ColorSpace.prototype.isPassthrough,
  48767. fillRgb: ColorSpace.prototype.fillRgb,
  48768. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48769. return true;
  48770. },
  48771. usesZeroToOneRange: false
  48772. };
  48773. return LabCS;
  48774. }();
  48775. exports.ColorSpace = ColorSpace;
  48776. }));
  48777. (function (root, factory) {
  48778. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48779. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48780. var globalScope = sharedUtil.globalScope;
  48781. var deprecated = sharedUtil.deprecated;
  48782. var warn = sharedUtil.warn;
  48783. var LinkTarget = displayDOMUtils.LinkTarget;
  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 ? 'noreferrer' : 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. } else {
  48919. return Promise.resolve(image);
  48920. }
  48921. }
  48922. function decodeAndClamp(value, addend, coefficient, max) {
  48923. value = addend + value * coefficient;
  48924. return value < 0 ? 0 : value > max ? max : value;
  48925. }
  48926. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48927. var length = w2 * h2;
  48928. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48929. var xRatio = w1 / w2;
  48930. var yRatio = h1 / h2;
  48931. var i, j, py, newIndex = 0, oldIndex;
  48932. var xScaled = new Uint16Array(w2);
  48933. var w1Scanline = w1;
  48934. for (i = 0; i < w2; i++) {
  48935. xScaled[i] = Math.floor(i * xRatio);
  48936. }
  48937. for (i = 0; i < h2; i++) {
  48938. py = Math.floor(i * yRatio) * w1Scanline;
  48939. for (j = 0; j < w2; j++) {
  48940. oldIndex = py + xScaled[j];
  48941. dest[newIndex++] = src[oldIndex];
  48942. }
  48943. }
  48944. return dest;
  48945. }
  48946. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48947. this.image = image;
  48948. var dict = image.dict;
  48949. if (dict.has('Filter')) {
  48950. var filter = dict.get('Filter').name;
  48951. if (filter === 'JPXDecode') {
  48952. var jpxImage = new JpxImage();
  48953. jpxImage.parseImageProperties(image.stream);
  48954. image.stream.reset();
  48955. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48956. image.numComps = jpxImage.componentsCount;
  48957. } else if (filter === 'JBIG2Decode') {
  48958. image.bitsPerComponent = 1;
  48959. image.numComps = 1;
  48960. }
  48961. }
  48962. this.width = dict.get('Width', 'W');
  48963. this.height = dict.get('Height', 'H');
  48964. if (this.width < 1 || this.height < 1) {
  48965. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48966. }
  48967. this.interpolate = dict.get('Interpolate', 'I') || false;
  48968. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48969. this.matte = dict.get('Matte') || false;
  48970. var bitsPerComponent = image.bitsPerComponent;
  48971. if (!bitsPerComponent) {
  48972. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48973. if (!bitsPerComponent) {
  48974. if (this.imageMask) {
  48975. bitsPerComponent = 1;
  48976. } else {
  48977. error('Bits per component missing in image: ' + this.imageMask);
  48978. }
  48979. }
  48980. }
  48981. this.bpc = bitsPerComponent;
  48982. if (!this.imageMask) {
  48983. var colorSpace = dict.get('ColorSpace', 'CS');
  48984. if (!colorSpace) {
  48985. info('JPX images (which do not require color spaces)');
  48986. switch (image.numComps) {
  48987. case 1:
  48988. colorSpace = Name.get('DeviceGray');
  48989. break;
  48990. case 3:
  48991. colorSpace = Name.get('DeviceRGB');
  48992. break;
  48993. case 4:
  48994. colorSpace = Name.get('DeviceCMYK');
  48995. break;
  48996. default:
  48997. error('JPX images with ' + this.numComps + ' color components not supported.');
  48998. }
  48999. }
  49000. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  49001. this.numComps = this.colorSpace.numComps;
  49002. }
  49003. this.decode = dict.getArray('Decode', 'D');
  49004. this.needsDecode = false;
  49005. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  49006. this.needsDecode = true;
  49007. var max = (1 << bitsPerComponent) - 1;
  49008. this.decodeCoefficients = [];
  49009. this.decodeAddends = [];
  49010. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  49011. var dmin = this.decode[i];
  49012. var dmax = this.decode[i + 1];
  49013. this.decodeCoefficients[j] = dmax - dmin;
  49014. this.decodeAddends[j] = max * dmin;
  49015. }
  49016. }
  49017. if (smask) {
  49018. this.smask = new PDFImage(xref, res, smask, false);
  49019. } else if (mask) {
  49020. if (isStream(mask)) {
  49021. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  49022. if (!imageMask) {
  49023. warn('Ignoring /Mask in image without /ImageMask.');
  49024. } else {
  49025. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  49026. }
  49027. } else {
  49028. this.mask = mask;
  49029. }
  49030. }
  49031. }
  49032. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  49033. var imagePromise = handleImageData(image, nativeDecoder);
  49034. var smaskPromise;
  49035. var maskPromise;
  49036. var smask = image.dict.get('SMask');
  49037. var mask = image.dict.get('Mask');
  49038. if (smask) {
  49039. smaskPromise = handleImageData(smask, nativeDecoder);
  49040. maskPromise = Promise.resolve(null);
  49041. } else {
  49042. smaskPromise = Promise.resolve(null);
  49043. if (mask) {
  49044. if (isStream(mask)) {
  49045. maskPromise = handleImageData(mask, nativeDecoder);
  49046. } else if (isArray(mask)) {
  49047. maskPromise = Promise.resolve(mask);
  49048. } else {
  49049. warn('Unsupported mask format.');
  49050. maskPromise = Promise.resolve(null);
  49051. }
  49052. } else {
  49053. maskPromise = Promise.resolve(null);
  49054. }
  49055. }
  49056. return Promise.all([
  49057. imagePromise,
  49058. smaskPromise,
  49059. maskPromise
  49060. ]).then(function (results) {
  49061. var imageData = results[0];
  49062. var smaskData = results[1];
  49063. var maskData = results[2];
  49064. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  49065. });
  49066. };
  49067. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  49068. var computedLength = (width + 7 >> 3) * height;
  49069. var actualLength = imgArray.byteLength;
  49070. var haveFullData = computedLength === actualLength;
  49071. var data, i;
  49072. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  49073. data = imgArray;
  49074. } else if (!inverseDecode) {
  49075. data = new Uint8Array(actualLength);
  49076. data.set(imgArray);
  49077. } else {
  49078. data = new Uint8Array(computedLength);
  49079. data.set(imgArray);
  49080. for (i = actualLength; i < computedLength; i++) {
  49081. data[i] = 0xff;
  49082. }
  49083. }
  49084. if (inverseDecode) {
  49085. for (i = 0; i < actualLength; i++) {
  49086. data[i] = ~data[i];
  49087. }
  49088. }
  49089. return {
  49090. data: data,
  49091. width: width,
  49092. height: height
  49093. };
  49094. };
  49095. PDFImage.prototype = {
  49096. get drawWidth() {
  49097. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  49098. },
  49099. get drawHeight() {
  49100. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  49101. },
  49102. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  49103. var bpc = this.bpc;
  49104. var numComps = this.numComps;
  49105. var decodeAddends = this.decodeAddends;
  49106. var decodeCoefficients = this.decodeCoefficients;
  49107. var max = (1 << bpc) - 1;
  49108. var i, ii;
  49109. if (bpc === 1) {
  49110. for (i = 0, ii = buffer.length; i < ii; i++) {
  49111. buffer[i] = +!buffer[i];
  49112. }
  49113. return;
  49114. }
  49115. var index = 0;
  49116. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  49117. for (var j = 0; j < numComps; j++) {
  49118. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  49119. index++;
  49120. }
  49121. }
  49122. },
  49123. getComponents: function PDFImage_getComponents(buffer) {
  49124. var bpc = this.bpc;
  49125. if (bpc === 8) {
  49126. return buffer;
  49127. }
  49128. var width = this.width;
  49129. var height = this.height;
  49130. var numComps = this.numComps;
  49131. var length = width * height * numComps;
  49132. var bufferPos = 0;
  49133. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  49134. var rowComps = width * numComps;
  49135. var max = (1 << bpc) - 1;
  49136. var i = 0, ii, buf;
  49137. if (bpc === 1) {
  49138. var mask, loop1End, loop2End;
  49139. for (var j = 0; j < height; j++) {
  49140. loop1End = i + (rowComps & ~7);
  49141. loop2End = i + rowComps;
  49142. while (i < loop1End) {
  49143. buf = buffer[bufferPos++];
  49144. output[i] = buf >> 7 & 1;
  49145. output[i + 1] = buf >> 6 & 1;
  49146. output[i + 2] = buf >> 5 & 1;
  49147. output[i + 3] = buf >> 4 & 1;
  49148. output[i + 4] = buf >> 3 & 1;
  49149. output[i + 5] = buf >> 2 & 1;
  49150. output[i + 6] = buf >> 1 & 1;
  49151. output[i + 7] = buf & 1;
  49152. i += 8;
  49153. }
  49154. if (i < loop2End) {
  49155. buf = buffer[bufferPos++];
  49156. mask = 128;
  49157. while (i < loop2End) {
  49158. output[i++] = +!!(buf & mask);
  49159. mask >>= 1;
  49160. }
  49161. }
  49162. }
  49163. } else {
  49164. var bits = 0;
  49165. buf = 0;
  49166. for (i = 0, ii = length; i < ii; ++i) {
  49167. if (i % rowComps === 0) {
  49168. buf = 0;
  49169. bits = 0;
  49170. }
  49171. while (bits < bpc) {
  49172. buf = buf << 8 | buffer[bufferPos++];
  49173. bits += 8;
  49174. }
  49175. var remainingBits = bits - bpc;
  49176. var value = buf >> remainingBits;
  49177. output[i] = value < 0 ? 0 : value > max ? max : value;
  49178. buf = buf & (1 << remainingBits) - 1;
  49179. bits = remainingBits;
  49180. }
  49181. }
  49182. return output;
  49183. },
  49184. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49185. var smask = this.smask;
  49186. var mask = this.mask;
  49187. var alphaBuf, sw, sh, i, ii, j;
  49188. if (smask) {
  49189. sw = smask.width;
  49190. sh = smask.height;
  49191. alphaBuf = new Uint8Array(sw * sh);
  49192. smask.fillGrayBuffer(alphaBuf);
  49193. if (sw !== width || sh !== height) {
  49194. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49195. }
  49196. } else if (mask) {
  49197. if (mask instanceof PDFImage) {
  49198. sw = mask.width;
  49199. sh = mask.height;
  49200. alphaBuf = new Uint8Array(sw * sh);
  49201. mask.numComps = 1;
  49202. mask.fillGrayBuffer(alphaBuf);
  49203. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49204. alphaBuf[i] = 255 - alphaBuf[i];
  49205. }
  49206. if (sw !== width || sh !== height) {
  49207. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49208. }
  49209. } else if (isArray(mask)) {
  49210. alphaBuf = new Uint8Array(width * height);
  49211. var numComps = this.numComps;
  49212. for (i = 0, ii = width * height; i < ii; ++i) {
  49213. var opacity = 0;
  49214. var imageOffset = i * numComps;
  49215. for (j = 0; j < numComps; ++j) {
  49216. var color = image[imageOffset + j];
  49217. var maskOffset = j * 2;
  49218. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49219. opacity = 255;
  49220. break;
  49221. }
  49222. }
  49223. alphaBuf[i] = opacity;
  49224. }
  49225. } else {
  49226. error('Unknown mask format.');
  49227. }
  49228. }
  49229. if (alphaBuf) {
  49230. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49231. rgbaBuf[j] = alphaBuf[i];
  49232. }
  49233. } else {
  49234. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49235. rgbaBuf[j] = 255;
  49236. }
  49237. }
  49238. },
  49239. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49240. var matte = this.smask && this.smask.matte;
  49241. if (!matte) {
  49242. return;
  49243. }
  49244. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49245. var matteR = matteRgb[0];
  49246. var matteG = matteRgb[1];
  49247. var matteB = matteRgb[2];
  49248. var length = width * height * 4;
  49249. var r, g, b;
  49250. for (var i = 0; i < length; i += 4) {
  49251. var alpha = buffer[i + 3];
  49252. if (alpha === 0) {
  49253. buffer[i] = 255;
  49254. buffer[i + 1] = 255;
  49255. buffer[i + 2] = 255;
  49256. continue;
  49257. }
  49258. var k = 255 / alpha;
  49259. r = (buffer[i] - matteR) * k + matteR;
  49260. g = (buffer[i + 1] - matteG) * k + matteG;
  49261. b = (buffer[i + 2] - matteB) * k + matteB;
  49262. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49263. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49264. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49265. }
  49266. },
  49267. createImageData: function PDFImage_createImageData(forceRGBA) {
  49268. var drawWidth = this.drawWidth;
  49269. var drawHeight = this.drawHeight;
  49270. var imgData = {
  49271. width: drawWidth,
  49272. height: drawHeight
  49273. };
  49274. var numComps = this.numComps;
  49275. var originalWidth = this.width;
  49276. var originalHeight = this.height;
  49277. var bpc = this.bpc;
  49278. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49279. var imgArray;
  49280. if (!forceRGBA) {
  49281. var kind;
  49282. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49283. kind = ImageKind.GRAYSCALE_1BPP;
  49284. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49285. kind = ImageKind.RGB_24BPP;
  49286. }
  49287. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49288. imgData.kind = kind;
  49289. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49290. if (this.image instanceof DecodeStream) {
  49291. imgData.data = imgArray;
  49292. } else {
  49293. var newArray = new Uint8Array(imgArray.length);
  49294. newArray.set(imgArray);
  49295. imgData.data = newArray;
  49296. }
  49297. if (this.needsDecode) {
  49298. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49299. var buffer = imgData.data;
  49300. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49301. buffer[i] ^= 0xff;
  49302. }
  49303. }
  49304. return imgData;
  49305. }
  49306. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49307. imgData.kind = ImageKind.RGB_24BPP;
  49308. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49309. return imgData;
  49310. }
  49311. }
  49312. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49313. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49314. var comps = this.getComponents(imgArray);
  49315. var alpha01, maybeUndoPreblend;
  49316. if (!forceRGBA && !this.smask && !this.mask) {
  49317. imgData.kind = ImageKind.RGB_24BPP;
  49318. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49319. alpha01 = 0;
  49320. maybeUndoPreblend = false;
  49321. } else {
  49322. imgData.kind = ImageKind.RGBA_32BPP;
  49323. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49324. alpha01 = 1;
  49325. maybeUndoPreblend = true;
  49326. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49327. }
  49328. if (this.needsDecode) {
  49329. this.decodeBuffer(comps);
  49330. }
  49331. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49332. if (maybeUndoPreblend) {
  49333. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49334. }
  49335. return imgData;
  49336. },
  49337. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49338. var numComps = this.numComps;
  49339. if (numComps !== 1) {
  49340. error('Reading gray scale from a color image: ' + numComps);
  49341. }
  49342. var width = this.width;
  49343. var height = this.height;
  49344. var bpc = this.bpc;
  49345. var rowBytes = width * numComps * bpc + 7 >> 3;
  49346. var imgArray = this.getImageBytes(height * rowBytes);
  49347. var comps = this.getComponents(imgArray);
  49348. var i, length;
  49349. if (bpc === 1) {
  49350. length = width * height;
  49351. if (this.needsDecode) {
  49352. for (i = 0; i < length; ++i) {
  49353. buffer[i] = comps[i] - 1 & 255;
  49354. }
  49355. } else {
  49356. for (i = 0; i < length; ++i) {
  49357. buffer[i] = -comps[i] & 255;
  49358. }
  49359. }
  49360. return;
  49361. }
  49362. if (this.needsDecode) {
  49363. this.decodeBuffer(comps);
  49364. }
  49365. length = width * height;
  49366. var scale = 255 / ((1 << bpc) - 1);
  49367. for (i = 0; i < length; ++i) {
  49368. buffer[i] = scale * comps[i] | 0;
  49369. }
  49370. },
  49371. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49372. this.image.reset();
  49373. this.image.drawWidth = drawWidth || this.width;
  49374. this.image.drawHeight = drawHeight || this.height;
  49375. this.image.forceRGB = !!forceRGB;
  49376. return this.image.getBytes(length);
  49377. }
  49378. };
  49379. return PDFImage;
  49380. }();
  49381. exports.PDFImage = PDFImage;
  49382. }));
  49383. (function (root, factory) {
  49384. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49385. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49386. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49387. var MissingDataException = sharedUtil.MissingDataException;
  49388. var XRefParseException = sharedUtil.XRefParseException;
  49389. var assert = sharedUtil.assert;
  49390. var bytesToString = sharedUtil.bytesToString;
  49391. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49392. var error = sharedUtil.error;
  49393. var info = sharedUtil.info;
  49394. var isArray = sharedUtil.isArray;
  49395. var isBool = sharedUtil.isBool;
  49396. var isInt = sharedUtil.isInt;
  49397. var isString = sharedUtil.isString;
  49398. var shadow = sharedUtil.shadow;
  49399. var stringToPDFString = sharedUtil.stringToPDFString;
  49400. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49401. var warn = sharedUtil.warn;
  49402. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49403. var Util = sharedUtil.Util;
  49404. var Ref = corePrimitives.Ref;
  49405. var RefSet = corePrimitives.RefSet;
  49406. var RefSetCache = corePrimitives.RefSetCache;
  49407. var isName = corePrimitives.isName;
  49408. var isCmd = corePrimitives.isCmd;
  49409. var isDict = corePrimitives.isDict;
  49410. var isRef = corePrimitives.isRef;
  49411. var isRefsEqual = corePrimitives.isRefsEqual;
  49412. var isStream = corePrimitives.isStream;
  49413. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49414. var Lexer = coreParser.Lexer;
  49415. var Parser = coreParser.Parser;
  49416. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49417. var ColorSpace = coreColorSpace.ColorSpace;
  49418. var Catalog = function CatalogClosure() {
  49419. function Catalog(pdfManager, xref, pageFactory) {
  49420. this.pdfManager = pdfManager;
  49421. this.xref = xref;
  49422. this.catDict = xref.getCatalogObj();
  49423. this.fontCache = new RefSetCache();
  49424. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49425. this.pageFactory = pageFactory;
  49426. this.pagePromises = [];
  49427. }
  49428. Catalog.prototype = {
  49429. get metadata() {
  49430. var streamRef = this.catDict.getRaw('Metadata');
  49431. if (!isRef(streamRef)) {
  49432. return shadow(this, 'metadata', null);
  49433. }
  49434. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49435. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49436. var metadata;
  49437. if (stream && isDict(stream.dict)) {
  49438. var type = stream.dict.get('Type');
  49439. var subtype = stream.dict.get('Subtype');
  49440. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49441. try {
  49442. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49443. } catch (e) {
  49444. info('Skipping invalid metadata.');
  49445. }
  49446. }
  49447. }
  49448. return shadow(this, 'metadata', metadata);
  49449. },
  49450. get toplevelPagesDict() {
  49451. var pagesObj = this.catDict.get('Pages');
  49452. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49453. return shadow(this, 'toplevelPagesDict', pagesObj);
  49454. },
  49455. get documentOutline() {
  49456. var obj = null;
  49457. try {
  49458. obj = this.readDocumentOutline();
  49459. } catch (ex) {
  49460. if (ex instanceof MissingDataException) {
  49461. throw ex;
  49462. }
  49463. warn('Unable to read document outline');
  49464. }
  49465. return shadow(this, 'documentOutline', obj);
  49466. },
  49467. readDocumentOutline: function Catalog_readDocumentOutline() {
  49468. var obj = this.catDict.get('Outlines');
  49469. if (!isDict(obj)) {
  49470. return null;
  49471. }
  49472. obj = obj.getRaw('First');
  49473. if (!isRef(obj)) {
  49474. return null;
  49475. }
  49476. var root = { items: [] };
  49477. var queue = [{
  49478. obj: obj,
  49479. parent: root
  49480. }];
  49481. var processed = new RefSet();
  49482. processed.put(obj);
  49483. var xref = this.xref, blackColor = new Uint8Array(3);
  49484. while (queue.length > 0) {
  49485. var i = queue.shift();
  49486. var outlineDict = xref.fetchIfRef(i.obj);
  49487. if (outlineDict === null) {
  49488. continue;
  49489. }
  49490. assert(outlineDict.has('Title'), 'Invalid outline item');
  49491. var data = {
  49492. url: null,
  49493. dest: null
  49494. };
  49495. Catalog.parseDestDictionary({
  49496. destDict: outlineDict,
  49497. resultObj: data,
  49498. docBaseUrl: this.pdfManager.docBaseUrl
  49499. });
  49500. var title = outlineDict.get('Title');
  49501. var flags = outlineDict.get('F') || 0;
  49502. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49503. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49504. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49505. }
  49506. var outlineItem = {
  49507. dest: data.dest,
  49508. url: data.url,
  49509. unsafeUrl: data.unsafeUrl,
  49510. newWindow: data.newWindow,
  49511. title: stringToPDFString(title),
  49512. color: rgbColor,
  49513. count: outlineDict.get('Count'),
  49514. bold: !!(flags & 2),
  49515. italic: !!(flags & 1),
  49516. items: []
  49517. };
  49518. i.parent.items.push(outlineItem);
  49519. obj = outlineDict.getRaw('First');
  49520. if (isRef(obj) && !processed.has(obj)) {
  49521. queue.push({
  49522. obj: obj,
  49523. parent: outlineItem
  49524. });
  49525. processed.put(obj);
  49526. }
  49527. obj = outlineDict.getRaw('Next');
  49528. if (isRef(obj) && !processed.has(obj)) {
  49529. queue.push({
  49530. obj: obj,
  49531. parent: i.parent
  49532. });
  49533. processed.put(obj);
  49534. }
  49535. }
  49536. return root.items.length > 0 ? root.items : null;
  49537. },
  49538. get numPages() {
  49539. var obj = this.toplevelPagesDict.get('Count');
  49540. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49541. return shadow(this, 'num', obj);
  49542. },
  49543. get destinations() {
  49544. function fetchDestination(dest) {
  49545. return isDict(dest) ? dest.get('D') : dest;
  49546. }
  49547. var xref = this.xref;
  49548. var dests = {}, nameTreeRef, nameDictionaryRef;
  49549. var obj = this.catDict.get('Names');
  49550. if (obj && obj.has('Dests')) {
  49551. nameTreeRef = obj.getRaw('Dests');
  49552. } else if (this.catDict.has('Dests')) {
  49553. nameDictionaryRef = this.catDict.get('Dests');
  49554. }
  49555. if (nameDictionaryRef) {
  49556. obj = nameDictionaryRef;
  49557. obj.forEach(function catalogForEach(key, value) {
  49558. if (!value) {
  49559. return;
  49560. }
  49561. dests[key] = fetchDestination(value);
  49562. });
  49563. }
  49564. if (nameTreeRef) {
  49565. var nameTree = new NameTree(nameTreeRef, xref);
  49566. var names = nameTree.getAll();
  49567. for (var name in names) {
  49568. dests[name] = fetchDestination(names[name]);
  49569. }
  49570. }
  49571. return shadow(this, 'destinations', dests);
  49572. },
  49573. getDestination: function Catalog_getDestination(destinationId) {
  49574. function fetchDestination(dest) {
  49575. return isDict(dest) ? dest.get('D') : dest;
  49576. }
  49577. var xref = this.xref;
  49578. var dest = null, nameTreeRef, nameDictionaryRef;
  49579. var obj = this.catDict.get('Names');
  49580. if (obj && obj.has('Dests')) {
  49581. nameTreeRef = obj.getRaw('Dests');
  49582. } else if (this.catDict.has('Dests')) {
  49583. nameDictionaryRef = this.catDict.get('Dests');
  49584. }
  49585. if (nameDictionaryRef) {
  49586. var value = nameDictionaryRef.get(destinationId);
  49587. if (value) {
  49588. dest = fetchDestination(value);
  49589. }
  49590. }
  49591. if (nameTreeRef) {
  49592. var nameTree = new NameTree(nameTreeRef, xref);
  49593. dest = fetchDestination(nameTree.get(destinationId));
  49594. }
  49595. return dest;
  49596. },
  49597. get pageLabels() {
  49598. var obj = null;
  49599. try {
  49600. obj = this.readPageLabels();
  49601. } catch (ex) {
  49602. if (ex instanceof MissingDataException) {
  49603. throw ex;
  49604. }
  49605. warn('Unable to read page labels.');
  49606. }
  49607. return shadow(this, 'pageLabels', obj);
  49608. },
  49609. readPageLabels: function Catalog_readPageLabels() {
  49610. var obj = this.catDict.getRaw('PageLabels');
  49611. if (!obj) {
  49612. return null;
  49613. }
  49614. var pageLabels = new Array(this.numPages);
  49615. var style = null;
  49616. var prefix = '';
  49617. var numberTree = new NumberTree(obj, this.xref);
  49618. var nums = numberTree.getAll();
  49619. var currentLabel = '', currentIndex = 1;
  49620. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49621. if (i in nums) {
  49622. var labelDict = nums[i];
  49623. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49624. var type = labelDict.get('Type');
  49625. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49626. var s = labelDict.get('S');
  49627. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49628. style = s ? s.name : null;
  49629. var p = labelDict.get('P');
  49630. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49631. prefix = p ? stringToPDFString(p) : '';
  49632. var st = labelDict.get('St');
  49633. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49634. currentIndex = st || 1;
  49635. }
  49636. switch (style) {
  49637. case 'D':
  49638. currentLabel = currentIndex;
  49639. break;
  49640. case 'R':
  49641. case 'r':
  49642. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49643. break;
  49644. case 'A':
  49645. case 'a':
  49646. var LIMIT = 26;
  49647. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49648. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49649. var letterIndex = currentIndex - 1;
  49650. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49651. var charBuf = [];
  49652. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49653. charBuf.push(character);
  49654. }
  49655. currentLabel = charBuf.join('');
  49656. break;
  49657. default:
  49658. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49659. }
  49660. pageLabels[i] = prefix + currentLabel;
  49661. currentLabel = '';
  49662. currentIndex++;
  49663. }
  49664. return pageLabels;
  49665. },
  49666. get attachments() {
  49667. var xref = this.xref;
  49668. var attachments = null, nameTreeRef;
  49669. var obj = this.catDict.get('Names');
  49670. if (obj) {
  49671. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49672. }
  49673. if (nameTreeRef) {
  49674. var nameTree = new NameTree(nameTreeRef, xref);
  49675. var names = nameTree.getAll();
  49676. for (var name in names) {
  49677. var fs = new FileSpec(names[name], xref);
  49678. if (!attachments) {
  49679. attachments = Object.create(null);
  49680. }
  49681. attachments[stringToPDFString(name)] = fs.serializable;
  49682. }
  49683. }
  49684. return shadow(this, 'attachments', attachments);
  49685. },
  49686. get javaScript() {
  49687. var xref = this.xref;
  49688. var obj = this.catDict.get('Names');
  49689. var javaScript = [];
  49690. function appendIfJavaScriptDict(jsDict) {
  49691. var type = jsDict.get('S');
  49692. if (!isName(type, 'JavaScript')) {
  49693. return;
  49694. }
  49695. var js = jsDict.get('JS');
  49696. if (isStream(js)) {
  49697. js = bytesToString(js.getBytes());
  49698. } else if (!isString(js)) {
  49699. return;
  49700. }
  49701. javaScript.push(stringToPDFString(js));
  49702. }
  49703. if (obj && obj.has('JavaScript')) {
  49704. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49705. var names = nameTree.getAll();
  49706. for (var name in names) {
  49707. var jsDict = names[name];
  49708. if (isDict(jsDict)) {
  49709. appendIfJavaScriptDict(jsDict);
  49710. }
  49711. }
  49712. }
  49713. var openactionDict = this.catDict.get('OpenAction');
  49714. if (isDict(openactionDict, 'Action')) {
  49715. var actionType = openactionDict.get('S');
  49716. if (isName(actionType, 'Named')) {
  49717. var action = openactionDict.get('N');
  49718. if (isName(action, 'Print')) {
  49719. javaScript.push('print({});');
  49720. }
  49721. } else {
  49722. appendIfJavaScriptDict(openactionDict);
  49723. }
  49724. }
  49725. return shadow(this, 'javaScript', javaScript);
  49726. },
  49727. cleanup: function Catalog_cleanup() {
  49728. var promises = [];
  49729. this.fontCache.forEach(function (promise) {
  49730. promises.push(promise);
  49731. });
  49732. return Promise.all(promises).then(function (translatedFonts) {
  49733. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49734. var font = translatedFonts[i].dict;
  49735. delete font.translated;
  49736. }
  49737. this.fontCache.clear();
  49738. }.bind(this));
  49739. },
  49740. getPage: function Catalog_getPage(pageIndex) {
  49741. if (!(pageIndex in this.pagePromises)) {
  49742. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49743. var dict = a[0];
  49744. var ref = a[1];
  49745. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49746. }.bind(this));
  49747. }
  49748. return this.pagePromises[pageIndex];
  49749. },
  49750. getPageDict: function Catalog_getPageDict(pageIndex) {
  49751. var capability = createPromiseCapability();
  49752. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49753. var currentPageIndex = 0;
  49754. var xref = this.xref;
  49755. var checkAllKids = false;
  49756. function next() {
  49757. while (nodesToVisit.length) {
  49758. var currentNode = nodesToVisit.pop();
  49759. if (isRef(currentNode)) {
  49760. xref.fetchAsync(currentNode).then(function (obj) {
  49761. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49762. if (pageIndex === currentPageIndex) {
  49763. capability.resolve([
  49764. obj,
  49765. currentNode
  49766. ]);
  49767. } else {
  49768. currentPageIndex++;
  49769. next();
  49770. }
  49771. return;
  49772. }
  49773. nodesToVisit.push(obj);
  49774. next();
  49775. }, capability.reject);
  49776. return;
  49777. }
  49778. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49779. var count = currentNode.get('Count');
  49780. if (count === 0) {
  49781. checkAllKids = true;
  49782. }
  49783. if (currentPageIndex + count <= pageIndex) {
  49784. currentPageIndex += count;
  49785. continue;
  49786. }
  49787. var kids = currentNode.get('Kids');
  49788. assert(isArray(kids), 'page dictionary kids object is not an array');
  49789. if (!checkAllKids && count === kids.length) {
  49790. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49791. currentPageIndex = pageIndex;
  49792. continue;
  49793. } else {
  49794. for (var last = kids.length - 1; last >= 0; last--) {
  49795. nodesToVisit.push(kids[last]);
  49796. }
  49797. }
  49798. }
  49799. capability.reject('Page index ' + pageIndex + ' not found.');
  49800. }
  49801. next();
  49802. return capability.promise;
  49803. },
  49804. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49805. var xref = this.xref;
  49806. function pagesBeforeRef(kidRef) {
  49807. var total = 0;
  49808. var parentRef;
  49809. return xref.fetchAsync(kidRef).then(function (node) {
  49810. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49811. throw new Error('The reference does not point to a /Page Dict.');
  49812. }
  49813. if (!node) {
  49814. return null;
  49815. }
  49816. assert(isDict(node), 'node must be a Dict.');
  49817. parentRef = node.getRaw('Parent');
  49818. return node.getAsync('Parent');
  49819. }).then(function (parent) {
  49820. if (!parent) {
  49821. return null;
  49822. }
  49823. assert(isDict(parent), 'parent must be a Dict.');
  49824. return parent.getAsync('Kids');
  49825. }).then(function (kids) {
  49826. if (!kids) {
  49827. return null;
  49828. }
  49829. var kidPromises = [];
  49830. var found = false;
  49831. for (var i = 0; i < kids.length; i++) {
  49832. var kid = kids[i];
  49833. assert(isRef(kid), 'kid must be a Ref.');
  49834. if (kid.num === kidRef.num) {
  49835. found = true;
  49836. break;
  49837. }
  49838. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49839. if (kid.has('Count')) {
  49840. var count = kid.get('Count');
  49841. total += count;
  49842. } else {
  49843. total++;
  49844. }
  49845. }));
  49846. }
  49847. if (!found) {
  49848. error('kid ref not found in parents kids');
  49849. }
  49850. return Promise.all(kidPromises).then(function () {
  49851. return [
  49852. total,
  49853. parentRef
  49854. ];
  49855. });
  49856. });
  49857. }
  49858. var total = 0;
  49859. function next(ref) {
  49860. return pagesBeforeRef(ref).then(function (args) {
  49861. if (!args) {
  49862. return total;
  49863. }
  49864. var count = args[0];
  49865. var parentRef = args[1];
  49866. total += count;
  49867. return next(parentRef);
  49868. });
  49869. }
  49870. return next(pageRef);
  49871. }
  49872. };
  49873. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49874. function addDefaultProtocolToUrl(url) {
  49875. if (url.indexOf('www.') === 0) {
  49876. return 'http://' + url;
  49877. }
  49878. return url;
  49879. }
  49880. function tryConvertUrlEncoding(url) {
  49881. try {
  49882. return stringToUTF8String(url);
  49883. } catch (e) {
  49884. return url;
  49885. }
  49886. }
  49887. var destDict = params.destDict;
  49888. if (!isDict(destDict)) {
  49889. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49890. return;
  49891. }
  49892. var resultObj = params.resultObj;
  49893. if (typeof resultObj !== 'object') {
  49894. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49895. return;
  49896. }
  49897. var docBaseUrl = params.docBaseUrl || null;
  49898. var action = destDict.get('A'), url, dest;
  49899. if (isDict(action)) {
  49900. var linkType = action.get('S').name;
  49901. switch (linkType) {
  49902. case 'URI':
  49903. url = action.get('URI');
  49904. if (isName(url)) {
  49905. url = '/' + url.name;
  49906. } else if (isString(url)) {
  49907. url = addDefaultProtocolToUrl(url);
  49908. }
  49909. break;
  49910. case 'GoTo':
  49911. dest = action.get('D');
  49912. break;
  49913. case 'Launch':
  49914. case 'GoToR':
  49915. var urlDict = action.get('F');
  49916. if (isDict(urlDict)) {
  49917. url = urlDict.get('F') || null;
  49918. } else if (isString(urlDict)) {
  49919. url = urlDict;
  49920. }
  49921. var remoteDest = action.get('D');
  49922. if (remoteDest) {
  49923. if (isName(remoteDest)) {
  49924. remoteDest = remoteDest.name;
  49925. }
  49926. if (isString(url)) {
  49927. var baseUrl = url.split('#')[0];
  49928. if (isString(remoteDest)) {
  49929. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49930. } else if (isArray(remoteDest)) {
  49931. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49932. }
  49933. }
  49934. }
  49935. var newWindow = action.get('NewWindow');
  49936. if (isBool(newWindow)) {
  49937. resultObj.newWindow = newWindow;
  49938. }
  49939. break;
  49940. case 'Named':
  49941. var namedAction = action.get('N');
  49942. if (isName(namedAction)) {
  49943. resultObj.action = namedAction.name;
  49944. }
  49945. break;
  49946. case 'JavaScript':
  49947. var jsAction = action.get('JS'), js;
  49948. if (isStream(jsAction)) {
  49949. js = bytesToString(jsAction.getBytes());
  49950. } else if (isString(jsAction)) {
  49951. js = jsAction;
  49952. }
  49953. if (js) {
  49954. var URL_OPEN_METHODS = [
  49955. 'app.launchURL',
  49956. 'window.open'
  49957. ];
  49958. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49959. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49960. if (jsUrl && jsUrl[1]) {
  49961. url = jsUrl[1];
  49962. break;
  49963. }
  49964. }
  49965. default:
  49966. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49967. break;
  49968. }
  49969. } else if (destDict.has('Dest')) {
  49970. dest = destDict.get('Dest');
  49971. }
  49972. if (isString(url)) {
  49973. url = tryConvertUrlEncoding(url);
  49974. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49975. if (absoluteUrl) {
  49976. resultObj.url = absoluteUrl.href;
  49977. }
  49978. resultObj.unsafeUrl = url;
  49979. }
  49980. if (dest) {
  49981. if (isName(dest)) {
  49982. dest = dest.name;
  49983. }
  49984. if (isString(dest) || isArray(dest)) {
  49985. resultObj.dest = dest;
  49986. }
  49987. }
  49988. };
  49989. return Catalog;
  49990. }();
  49991. var XRef = function XRefClosure() {
  49992. function XRef(stream, password) {
  49993. this.stream = stream;
  49994. this.entries = [];
  49995. this.xrefstms = Object.create(null);
  49996. this.cache = [];
  49997. this.password = password;
  49998. this.stats = {
  49999. streamTypes: [],
  50000. fontTypes: []
  50001. };
  50002. }
  50003. XRef.prototype = {
  50004. setStartXRef: function XRef_setStartXRef(startXRef) {
  50005. this.startXRefQueue = [startXRef];
  50006. },
  50007. parse: function XRef_parse(recoveryMode) {
  50008. var trailerDict;
  50009. if (!recoveryMode) {
  50010. trailerDict = this.readXRef();
  50011. } else {
  50012. warn('Indexing all PDF objects');
  50013. trailerDict = this.indexObjects();
  50014. }
  50015. trailerDict.assignXref(this);
  50016. this.trailer = trailerDict;
  50017. var encrypt = trailerDict.get('Encrypt');
  50018. if (encrypt) {
  50019. var ids = trailerDict.get('ID');
  50020. var fileId = ids && ids.length ? ids[0] : '';
  50021. encrypt.suppressEncryption = true;
  50022. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  50023. }
  50024. if (!(this.root = trailerDict.get('Root'))) {
  50025. error('Invalid root reference');
  50026. }
  50027. },
  50028. processXRefTable: function XRef_processXRefTable(parser) {
  50029. if (!('tableState' in this)) {
  50030. this.tableState = {
  50031. entryNum: 0,
  50032. streamPos: parser.lexer.stream.pos,
  50033. parserBuf1: parser.buf1,
  50034. parserBuf2: parser.buf2
  50035. };
  50036. }
  50037. var obj = this.readXRefTable(parser);
  50038. if (!isCmd(obj, 'trailer')) {
  50039. error('Invalid XRef table: could not find trailer dictionary');
  50040. }
  50041. var dict = parser.getObj();
  50042. if (!isDict(dict) && dict.dict) {
  50043. dict = dict.dict;
  50044. }
  50045. if (!isDict(dict)) {
  50046. error('Invalid XRef table: could not parse trailer dictionary');
  50047. }
  50048. delete this.tableState;
  50049. return dict;
  50050. },
  50051. readXRefTable: function XRef_readXRefTable(parser) {
  50052. var stream = parser.lexer.stream;
  50053. var tableState = this.tableState;
  50054. stream.pos = tableState.streamPos;
  50055. parser.buf1 = tableState.parserBuf1;
  50056. parser.buf2 = tableState.parserBuf2;
  50057. var obj;
  50058. while (true) {
  50059. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  50060. if (isCmd(obj = parser.getObj(), 'trailer')) {
  50061. break;
  50062. }
  50063. tableState.firstEntryNum = obj;
  50064. tableState.entryCount = parser.getObj();
  50065. }
  50066. var first = tableState.firstEntryNum;
  50067. var count = tableState.entryCount;
  50068. if (!isInt(first) || !isInt(count)) {
  50069. error('Invalid XRef table: wrong types in subsection header');
  50070. }
  50071. for (var i = tableState.entryNum; i < count; i++) {
  50072. tableState.streamPos = stream.pos;
  50073. tableState.entryNum = i;
  50074. tableState.parserBuf1 = parser.buf1;
  50075. tableState.parserBuf2 = parser.buf2;
  50076. var entry = {};
  50077. entry.offset = parser.getObj();
  50078. entry.gen = parser.getObj();
  50079. var type = parser.getObj();
  50080. if (isCmd(type, 'f')) {
  50081. entry.free = true;
  50082. } else if (isCmd(type, 'n')) {
  50083. entry.uncompressed = true;
  50084. }
  50085. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  50086. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  50087. }
  50088. if (i === 0 && entry.free && first === 1) {
  50089. first = 0;
  50090. }
  50091. if (!this.entries[i + first]) {
  50092. this.entries[i + first] = entry;
  50093. }
  50094. }
  50095. tableState.entryNum = 0;
  50096. tableState.streamPos = stream.pos;
  50097. tableState.parserBuf1 = parser.buf1;
  50098. tableState.parserBuf2 = parser.buf2;
  50099. delete tableState.firstEntryNum;
  50100. delete tableState.entryCount;
  50101. }
  50102. if (this.entries[0] && !this.entries[0].free) {
  50103. error('Invalid XRef table: unexpected first object');
  50104. }
  50105. return obj;
  50106. },
  50107. processXRefStream: function XRef_processXRefStream(stream) {
  50108. if (!('streamState' in this)) {
  50109. var streamParameters = stream.dict;
  50110. var byteWidths = streamParameters.get('W');
  50111. var range = streamParameters.get('Index');
  50112. if (!range) {
  50113. range = [
  50114. 0,
  50115. streamParameters.get('Size')
  50116. ];
  50117. }
  50118. this.streamState = {
  50119. entryRanges: range,
  50120. byteWidths: byteWidths,
  50121. entryNum: 0,
  50122. streamPos: stream.pos
  50123. };
  50124. }
  50125. this.readXRefStream(stream);
  50126. delete this.streamState;
  50127. return stream.dict;
  50128. },
  50129. readXRefStream: function XRef_readXRefStream(stream) {
  50130. var i, j;
  50131. var streamState = this.streamState;
  50132. stream.pos = streamState.streamPos;
  50133. var byteWidths = streamState.byteWidths;
  50134. var typeFieldWidth = byteWidths[0];
  50135. var offsetFieldWidth = byteWidths[1];
  50136. var generationFieldWidth = byteWidths[2];
  50137. var entryRanges = streamState.entryRanges;
  50138. while (entryRanges.length > 0) {
  50139. var first = entryRanges[0];
  50140. var n = entryRanges[1];
  50141. if (!isInt(first) || !isInt(n)) {
  50142. error('Invalid XRef range fields: ' + first + ', ' + n);
  50143. }
  50144. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  50145. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  50146. }
  50147. for (i = streamState.entryNum; i < n; ++i) {
  50148. streamState.entryNum = i;
  50149. streamState.streamPos = stream.pos;
  50150. var type = 0, offset = 0, generation = 0;
  50151. for (j = 0; j < typeFieldWidth; ++j) {
  50152. type = type << 8 | stream.getByte();
  50153. }
  50154. if (typeFieldWidth === 0) {
  50155. type = 1;
  50156. }
  50157. for (j = 0; j < offsetFieldWidth; ++j) {
  50158. offset = offset << 8 | stream.getByte();
  50159. }
  50160. for (j = 0; j < generationFieldWidth; ++j) {
  50161. generation = generation << 8 | stream.getByte();
  50162. }
  50163. var entry = {};
  50164. entry.offset = offset;
  50165. entry.gen = generation;
  50166. switch (type) {
  50167. case 0:
  50168. entry.free = true;
  50169. break;
  50170. case 1:
  50171. entry.uncompressed = true;
  50172. break;
  50173. case 2:
  50174. break;
  50175. default:
  50176. error('Invalid XRef entry type: ' + type);
  50177. }
  50178. if (!this.entries[first + i]) {
  50179. this.entries[first + i] = entry;
  50180. }
  50181. }
  50182. streamState.entryNum = 0;
  50183. streamState.streamPos = stream.pos;
  50184. entryRanges.splice(0, 2);
  50185. }
  50186. },
  50187. indexObjects: function XRef_indexObjects() {
  50188. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50189. var PERCENT = 0x25, LT = 0x3C;
  50190. function readToken(data, offset) {
  50191. var token = '', ch = data[offset];
  50192. while (ch !== LF && ch !== CR && ch !== LT) {
  50193. if (++offset >= data.length) {
  50194. break;
  50195. }
  50196. token += String.fromCharCode(ch);
  50197. ch = data[offset];
  50198. }
  50199. return token;
  50200. }
  50201. function skipUntil(data, offset, what) {
  50202. var length = what.length, dataLength = data.length;
  50203. var skipped = 0;
  50204. while (offset < dataLength) {
  50205. var i = 0;
  50206. while (i < length && data[offset + i] === what[i]) {
  50207. ++i;
  50208. }
  50209. if (i >= length) {
  50210. break;
  50211. }
  50212. offset++;
  50213. skipped++;
  50214. }
  50215. return skipped;
  50216. }
  50217. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50218. var trailerBytes = new Uint8Array([
  50219. 116,
  50220. 114,
  50221. 97,
  50222. 105,
  50223. 108,
  50224. 101,
  50225. 114
  50226. ]);
  50227. var startxrefBytes = new Uint8Array([
  50228. 115,
  50229. 116,
  50230. 97,
  50231. 114,
  50232. 116,
  50233. 120,
  50234. 114,
  50235. 101,
  50236. 102
  50237. ]);
  50238. var endobjBytes = new Uint8Array([
  50239. 101,
  50240. 110,
  50241. 100,
  50242. 111,
  50243. 98,
  50244. 106
  50245. ]);
  50246. var xrefBytes = new Uint8Array([
  50247. 47,
  50248. 88,
  50249. 82,
  50250. 101,
  50251. 102
  50252. ]);
  50253. this.entries.length = 0;
  50254. var stream = this.stream;
  50255. stream.pos = 0;
  50256. var buffer = stream.getBytes();
  50257. var position = stream.start, length = buffer.length;
  50258. var trailers = [], xrefStms = [];
  50259. while (position < length) {
  50260. var ch = buffer[position];
  50261. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50262. ++position;
  50263. continue;
  50264. }
  50265. if (ch === PERCENT) {
  50266. do {
  50267. ++position;
  50268. if (position >= length) {
  50269. break;
  50270. }
  50271. ch = buffer[position];
  50272. } while (ch !== LF && ch !== CR);
  50273. continue;
  50274. }
  50275. var token = readToken(buffer, position);
  50276. var m;
  50277. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50278. position += skipUntil(buffer, position, trailerBytes);
  50279. trailers.push(position);
  50280. position += skipUntil(buffer, position, startxrefBytes);
  50281. } else if (m = objRegExp.exec(token)) {
  50282. if (typeof this.entries[m[1]] === 'undefined') {
  50283. this.entries[m[1]] = {
  50284. offset: position - stream.start,
  50285. gen: m[2] | 0,
  50286. uncompressed: true
  50287. };
  50288. }
  50289. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50290. var content = buffer.subarray(position, position + contentLength);
  50291. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50292. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50293. xrefStms.push(position - stream.start);
  50294. this.xrefstms[position - stream.start] = 1;
  50295. }
  50296. position += contentLength;
  50297. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50298. trailers.push(position);
  50299. position += skipUntil(buffer, position, startxrefBytes);
  50300. } else {
  50301. position += token.length + 1;
  50302. }
  50303. }
  50304. var i, ii;
  50305. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50306. this.startXRefQueue.push(xrefStms[i]);
  50307. this.readXRef(true);
  50308. }
  50309. var dict;
  50310. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50311. stream.pos = trailers[i];
  50312. var parser = new Parser(new Lexer(stream), true, this, true);
  50313. var obj = parser.getObj();
  50314. if (!isCmd(obj, 'trailer')) {
  50315. continue;
  50316. }
  50317. dict = parser.getObj();
  50318. if (!isDict(dict)) {
  50319. continue;
  50320. }
  50321. if (dict.has('ID')) {
  50322. return dict;
  50323. }
  50324. }
  50325. if (dict) {
  50326. return dict;
  50327. }
  50328. throw new InvalidPDFException('Invalid PDF structure');
  50329. },
  50330. readXRef: function XRef_readXRef(recoveryMode) {
  50331. var stream = this.stream;
  50332. try {
  50333. while (this.startXRefQueue.length) {
  50334. var startXRef = this.startXRefQueue[0];
  50335. stream.pos = startXRef + stream.start;
  50336. var parser = new Parser(new Lexer(stream), true, this);
  50337. var obj = parser.getObj();
  50338. var dict;
  50339. if (isCmd(obj, 'xref')) {
  50340. dict = this.processXRefTable(parser);
  50341. if (!this.topDict) {
  50342. this.topDict = dict;
  50343. }
  50344. obj = dict.get('XRefStm');
  50345. if (isInt(obj)) {
  50346. var pos = obj;
  50347. if (!(pos in this.xrefstms)) {
  50348. this.xrefstms[pos] = 1;
  50349. this.startXRefQueue.push(pos);
  50350. }
  50351. }
  50352. } else if (isInt(obj)) {
  50353. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50354. error('Invalid XRef stream');
  50355. }
  50356. dict = this.processXRefStream(obj);
  50357. if (!this.topDict) {
  50358. this.topDict = dict;
  50359. }
  50360. if (!dict) {
  50361. error('Failed to read XRef stream');
  50362. }
  50363. } else {
  50364. error('Invalid XRef stream header');
  50365. }
  50366. obj = dict.get('Prev');
  50367. if (isInt(obj)) {
  50368. this.startXRefQueue.push(obj);
  50369. } else if (isRef(obj)) {
  50370. this.startXRefQueue.push(obj.num);
  50371. }
  50372. this.startXRefQueue.shift();
  50373. }
  50374. return this.topDict;
  50375. } catch (e) {
  50376. if (e instanceof MissingDataException) {
  50377. throw e;
  50378. }
  50379. info('(while reading XRef): ' + e);
  50380. }
  50381. if (recoveryMode) {
  50382. return;
  50383. }
  50384. throw new XRefParseException();
  50385. },
  50386. getEntry: function XRef_getEntry(i) {
  50387. var xrefEntry = this.entries[i];
  50388. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50389. return xrefEntry;
  50390. }
  50391. return null;
  50392. },
  50393. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50394. if (!isRef(obj)) {
  50395. return obj;
  50396. }
  50397. return this.fetch(obj, suppressEncryption);
  50398. },
  50399. fetch: function XRef_fetch(ref, suppressEncryption) {
  50400. assert(isRef(ref), 'ref object is not a reference');
  50401. var num = ref.num;
  50402. if (num in this.cache) {
  50403. var cacheEntry = this.cache[num];
  50404. return cacheEntry;
  50405. }
  50406. var xrefEntry = this.getEntry(num);
  50407. if (xrefEntry === null) {
  50408. return this.cache[num] = null;
  50409. }
  50410. if (xrefEntry.uncompressed) {
  50411. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50412. } else {
  50413. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50414. }
  50415. if (isDict(xrefEntry)) {
  50416. xrefEntry.objId = ref.toString();
  50417. } else if (isStream(xrefEntry)) {
  50418. xrefEntry.dict.objId = ref.toString();
  50419. }
  50420. return xrefEntry;
  50421. },
  50422. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50423. var gen = ref.gen;
  50424. var num = ref.num;
  50425. if (xrefEntry.gen !== gen) {
  50426. error('inconsistent generation in XRef');
  50427. }
  50428. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50429. var parser = new Parser(new Lexer(stream), true, this);
  50430. var obj1 = parser.getObj();
  50431. var obj2 = parser.getObj();
  50432. var obj3 = parser.getObj();
  50433. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50434. error('bad XRef entry');
  50435. }
  50436. if (!isCmd(obj3, 'obj')) {
  50437. if (obj3.cmd.indexOf('obj') === 0) {
  50438. num = parseInt(obj3.cmd.substring(3), 10);
  50439. if (!isNaN(num)) {
  50440. return num;
  50441. }
  50442. }
  50443. error('bad XRef entry');
  50444. }
  50445. if (this.encrypt && !suppressEncryption) {
  50446. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50447. } else {
  50448. xrefEntry = parser.getObj();
  50449. }
  50450. if (!isStream(xrefEntry)) {
  50451. this.cache[num] = xrefEntry;
  50452. }
  50453. return xrefEntry;
  50454. },
  50455. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50456. var tableOffset = xrefEntry.offset;
  50457. var stream = this.fetch(new Ref(tableOffset, 0));
  50458. if (!isStream(stream)) {
  50459. error('bad ObjStm stream');
  50460. }
  50461. var first = stream.dict.get('First');
  50462. var n = stream.dict.get('N');
  50463. if (!isInt(first) || !isInt(n)) {
  50464. error('invalid first and n parameters for ObjStm stream');
  50465. }
  50466. var parser = new Parser(new Lexer(stream), false, this);
  50467. parser.allowStreams = true;
  50468. var i, entries = [], num, nums = [];
  50469. for (i = 0; i < n; ++i) {
  50470. num = parser.getObj();
  50471. if (!isInt(num)) {
  50472. error('invalid object number in the ObjStm stream: ' + num);
  50473. }
  50474. nums.push(num);
  50475. var offset = parser.getObj();
  50476. if (!isInt(offset)) {
  50477. error('invalid object offset in the ObjStm stream: ' + offset);
  50478. }
  50479. }
  50480. for (i = 0; i < n; ++i) {
  50481. entries.push(parser.getObj());
  50482. if (isCmd(parser.buf1, 'endobj')) {
  50483. parser.shift();
  50484. }
  50485. num = nums[i];
  50486. var entry = this.entries[num];
  50487. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50488. this.cache[num] = entries[i];
  50489. }
  50490. }
  50491. xrefEntry = entries[xrefEntry.gen];
  50492. if (xrefEntry === undefined) {
  50493. error('bad XRef entry for compressed object');
  50494. }
  50495. return xrefEntry;
  50496. },
  50497. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50498. if (!isRef(obj)) {
  50499. return Promise.resolve(obj);
  50500. }
  50501. return this.fetchAsync(obj, suppressEncryption);
  50502. },
  50503. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50504. var streamManager = this.stream.manager;
  50505. var xref = this;
  50506. return new Promise(function tryFetch(resolve, reject) {
  50507. try {
  50508. resolve(xref.fetch(ref, suppressEncryption));
  50509. } catch (e) {
  50510. if (e instanceof MissingDataException) {
  50511. streamManager.requestRange(e.begin, e.end).then(function () {
  50512. tryFetch(resolve, reject);
  50513. }, reject);
  50514. return;
  50515. }
  50516. reject(e);
  50517. }
  50518. });
  50519. },
  50520. getCatalogObj: function XRef_getCatalogObj() {
  50521. return this.root;
  50522. }
  50523. };
  50524. return XRef;
  50525. }();
  50526. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50527. function NameOrNumberTree(root, xref) {
  50528. throw new Error('Cannot initialize NameOrNumberTree.');
  50529. }
  50530. NameOrNumberTree.prototype = {
  50531. getAll: function NameOrNumberTree_getAll() {
  50532. var dict = Object.create(null);
  50533. if (!this.root) {
  50534. return dict;
  50535. }
  50536. var xref = this.xref;
  50537. var processed = new RefSet();
  50538. processed.put(this.root);
  50539. var queue = [this.root];
  50540. while (queue.length > 0) {
  50541. var i, n;
  50542. var obj = xref.fetchIfRef(queue.shift());
  50543. if (!isDict(obj)) {
  50544. continue;
  50545. }
  50546. if (obj.has('Kids')) {
  50547. var kids = obj.get('Kids');
  50548. for (i = 0, n = kids.length; i < n; i++) {
  50549. var kid = kids[i];
  50550. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50551. queue.push(kid);
  50552. processed.put(kid);
  50553. }
  50554. continue;
  50555. }
  50556. var entries = obj.get(this._type);
  50557. if (isArray(entries)) {
  50558. for (i = 0, n = entries.length; i < n; i += 2) {
  50559. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50560. }
  50561. }
  50562. }
  50563. return dict;
  50564. },
  50565. get: function NameOrNumberTree_get(key) {
  50566. if (!this.root) {
  50567. return null;
  50568. }
  50569. var xref = this.xref;
  50570. var kidsOrEntries = xref.fetchIfRef(this.root);
  50571. var loopCount = 0;
  50572. var MAX_LEVELS = 10;
  50573. var l, r, m;
  50574. while (kidsOrEntries.has('Kids')) {
  50575. if (++loopCount > MAX_LEVELS) {
  50576. warn('Search depth limit reached for "' + this._type + '" tree.');
  50577. return null;
  50578. }
  50579. var kids = kidsOrEntries.get('Kids');
  50580. if (!isArray(kids)) {
  50581. return null;
  50582. }
  50583. l = 0;
  50584. r = kids.length - 1;
  50585. while (l <= r) {
  50586. m = l + r >> 1;
  50587. var kid = xref.fetchIfRef(kids[m]);
  50588. var limits = kid.get('Limits');
  50589. if (key < xref.fetchIfRef(limits[0])) {
  50590. r = m - 1;
  50591. } else if (key > xref.fetchIfRef(limits[1])) {
  50592. l = m + 1;
  50593. } else {
  50594. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50595. break;
  50596. }
  50597. }
  50598. if (l > r) {
  50599. return null;
  50600. }
  50601. }
  50602. var entries = kidsOrEntries.get(this._type);
  50603. if (isArray(entries)) {
  50604. l = 0;
  50605. r = entries.length - 2;
  50606. while (l <= r) {
  50607. m = l + r & ~1;
  50608. var currentKey = xref.fetchIfRef(entries[m]);
  50609. if (key < currentKey) {
  50610. r = m - 2;
  50611. } else if (key > currentKey) {
  50612. l = m + 2;
  50613. } else {
  50614. return xref.fetchIfRef(entries[m + 1]);
  50615. }
  50616. }
  50617. }
  50618. return null;
  50619. }
  50620. };
  50621. return NameOrNumberTree;
  50622. }();
  50623. var NameTree = function NameTreeClosure() {
  50624. function NameTree(root, xref) {
  50625. this.root = root;
  50626. this.xref = xref;
  50627. this._type = 'Names';
  50628. }
  50629. Util.inherit(NameTree, NameOrNumberTree, {});
  50630. return NameTree;
  50631. }();
  50632. var NumberTree = function NumberTreeClosure() {
  50633. function NumberTree(root, xref) {
  50634. this.root = root;
  50635. this.xref = xref;
  50636. this._type = 'Nums';
  50637. }
  50638. Util.inherit(NumberTree, NameOrNumberTree, {});
  50639. return NumberTree;
  50640. }();
  50641. var FileSpec = function FileSpecClosure() {
  50642. function FileSpec(root, xref) {
  50643. if (!root || !isDict(root)) {
  50644. return;
  50645. }
  50646. this.xref = xref;
  50647. this.root = root;
  50648. if (root.has('FS')) {
  50649. this.fs = root.get('FS');
  50650. }
  50651. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50652. if (root.has('RF')) {
  50653. warn('Related file specifications are not supported');
  50654. }
  50655. this.contentAvailable = true;
  50656. if (!root.has('EF')) {
  50657. this.contentAvailable = false;
  50658. warn('Non-embedded file specifications are not supported');
  50659. }
  50660. }
  50661. function pickPlatformItem(dict) {
  50662. if (dict.has('UF')) {
  50663. return dict.get('UF');
  50664. } else if (dict.has('F')) {
  50665. return dict.get('F');
  50666. } else if (dict.has('Unix')) {
  50667. return dict.get('Unix');
  50668. } else if (dict.has('Mac')) {
  50669. return dict.get('Mac');
  50670. } else if (dict.has('DOS')) {
  50671. return dict.get('DOS');
  50672. } else {
  50673. return null;
  50674. }
  50675. }
  50676. FileSpec.prototype = {
  50677. get filename() {
  50678. if (!this._filename && this.root) {
  50679. var filename = pickPlatformItem(this.root) || 'unnamed';
  50680. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50681. }
  50682. return this._filename;
  50683. },
  50684. get content() {
  50685. if (!this.contentAvailable) {
  50686. return null;
  50687. }
  50688. if (!this.contentRef && this.root) {
  50689. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50690. }
  50691. var content = null;
  50692. if (this.contentRef) {
  50693. var xref = this.xref;
  50694. var fileObj = xref.fetchIfRef(this.contentRef);
  50695. if (fileObj && isStream(fileObj)) {
  50696. content = fileObj.getBytes();
  50697. } else {
  50698. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50699. }
  50700. } else {
  50701. warn('Embedded file specification does not have a content');
  50702. }
  50703. return content;
  50704. },
  50705. get serializable() {
  50706. return {
  50707. filename: this.filename,
  50708. content: this.content
  50709. };
  50710. }
  50711. };
  50712. return FileSpec;
  50713. }();
  50714. var ObjectLoader = function () {
  50715. function mayHaveChildren(value) {
  50716. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50717. }
  50718. function addChildren(node, nodesToVisit) {
  50719. var value;
  50720. if (isDict(node) || isStream(node)) {
  50721. var map;
  50722. if (isDict(node)) {
  50723. map = node.map;
  50724. } else {
  50725. map = node.dict.map;
  50726. }
  50727. for (var key in map) {
  50728. value = map[key];
  50729. if (mayHaveChildren(value)) {
  50730. nodesToVisit.push(value);
  50731. }
  50732. }
  50733. } else if (isArray(node)) {
  50734. for (var i = 0, ii = node.length; i < ii; i++) {
  50735. value = node[i];
  50736. if (mayHaveChildren(value)) {
  50737. nodesToVisit.push(value);
  50738. }
  50739. }
  50740. }
  50741. }
  50742. function ObjectLoader(obj, keys, xref) {
  50743. this.obj = obj;
  50744. this.keys = keys;
  50745. this.xref = xref;
  50746. this.refSet = null;
  50747. this.capability = null;
  50748. }
  50749. ObjectLoader.prototype = {
  50750. load: function ObjectLoader_load() {
  50751. var keys = this.keys;
  50752. this.capability = createPromiseCapability();
  50753. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50754. this.capability.resolve();
  50755. return this.capability.promise;
  50756. }
  50757. this.refSet = new RefSet();
  50758. var nodesToVisit = [];
  50759. for (var i = 0; i < keys.length; i++) {
  50760. nodesToVisit.push(this.obj[keys[i]]);
  50761. }
  50762. this._walk(nodesToVisit);
  50763. return this.capability.promise;
  50764. },
  50765. _walk: function ObjectLoader_walk(nodesToVisit) {
  50766. var nodesToRevisit = [];
  50767. var pendingRequests = [];
  50768. while (nodesToVisit.length) {
  50769. var currentNode = nodesToVisit.pop();
  50770. if (isRef(currentNode)) {
  50771. if (this.refSet.has(currentNode)) {
  50772. continue;
  50773. }
  50774. try {
  50775. var ref = currentNode;
  50776. this.refSet.put(ref);
  50777. currentNode = this.xref.fetch(currentNode);
  50778. } catch (e) {
  50779. if (!(e instanceof MissingDataException)) {
  50780. throw e;
  50781. }
  50782. nodesToRevisit.push(currentNode);
  50783. pendingRequests.push({
  50784. begin: e.begin,
  50785. end: e.end
  50786. });
  50787. }
  50788. }
  50789. if (currentNode && currentNode.getBaseStreams) {
  50790. var baseStreams = currentNode.getBaseStreams();
  50791. var foundMissingData = false;
  50792. for (var i = 0; i < baseStreams.length; i++) {
  50793. var stream = baseStreams[i];
  50794. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50795. foundMissingData = true;
  50796. pendingRequests.push({
  50797. begin: stream.start,
  50798. end: stream.end
  50799. });
  50800. }
  50801. }
  50802. if (foundMissingData) {
  50803. nodesToRevisit.push(currentNode);
  50804. }
  50805. }
  50806. addChildren(currentNode, nodesToVisit);
  50807. }
  50808. if (pendingRequests.length) {
  50809. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50810. nodesToVisit = nodesToRevisit;
  50811. for (var i = 0; i < nodesToRevisit.length; i++) {
  50812. var node = nodesToRevisit[i];
  50813. if (isRef(node)) {
  50814. this.refSet.remove(node);
  50815. }
  50816. }
  50817. this._walk(nodesToVisit);
  50818. }.bind(this), this.capability.reject);
  50819. return;
  50820. }
  50821. this.refSet = null;
  50822. this.capability.resolve();
  50823. }
  50824. };
  50825. return ObjectLoader;
  50826. }();
  50827. exports.Catalog = Catalog;
  50828. exports.ObjectLoader = ObjectLoader;
  50829. exports.XRef = XRef;
  50830. exports.FileSpec = FileSpec;
  50831. }));
  50832. (function (root, factory) {
  50833. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50834. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50835. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50836. var MissingDataException = sharedUtil.MissingDataException;
  50837. var Util = sharedUtil.Util;
  50838. var assert = sharedUtil.assert;
  50839. var error = sharedUtil.error;
  50840. var info = sharedUtil.info;
  50841. var warn = sharedUtil.warn;
  50842. var isStream = corePrimitives.isStream;
  50843. var PDFFunction = coreFunction.PDFFunction;
  50844. var ColorSpace = coreColorSpace.ColorSpace;
  50845. var ShadingType = {
  50846. FUNCTION_BASED: 1,
  50847. AXIAL: 2,
  50848. RADIAL: 3,
  50849. FREE_FORM_MESH: 4,
  50850. LATTICE_FORM_MESH: 5,
  50851. COONS_PATCH_MESH: 6,
  50852. TENSOR_PATCH_MESH: 7
  50853. };
  50854. var Pattern = function PatternClosure() {
  50855. function Pattern() {
  50856. error('should not call Pattern constructor');
  50857. }
  50858. Pattern.prototype = {
  50859. getPattern: function Pattern_getPattern(ctx) {
  50860. error('Should not call Pattern.getStyle: ' + ctx);
  50861. }
  50862. };
  50863. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50864. var dict = isStream(shading) ? shading.dict : shading;
  50865. var type = dict.get('ShadingType');
  50866. try {
  50867. switch (type) {
  50868. case ShadingType.AXIAL:
  50869. case ShadingType.RADIAL:
  50870. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50871. case ShadingType.FREE_FORM_MESH:
  50872. case ShadingType.LATTICE_FORM_MESH:
  50873. case ShadingType.COONS_PATCH_MESH:
  50874. case ShadingType.TENSOR_PATCH_MESH:
  50875. return new Shadings.Mesh(shading, matrix, xref, res);
  50876. default:
  50877. throw new Error('Unsupported ShadingType: ' + type);
  50878. }
  50879. } catch (ex) {
  50880. if (ex instanceof MissingDataException) {
  50881. throw ex;
  50882. }
  50883. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50884. warn(ex);
  50885. return new Shadings.Dummy();
  50886. }
  50887. };
  50888. return Pattern;
  50889. }();
  50890. var Shadings = {};
  50891. Shadings.SMALL_NUMBER = 1e-6;
  50892. Shadings.RadialAxial = function RadialAxialClosure() {
  50893. function RadialAxial(dict, matrix, xref, res) {
  50894. this.matrix = matrix;
  50895. this.coordsArr = dict.getArray('Coords');
  50896. this.shadingType = dict.get('ShadingType');
  50897. this.type = 'Pattern';
  50898. var cs = dict.get('ColorSpace', 'CS');
  50899. cs = ColorSpace.parse(cs, xref, res);
  50900. this.cs = cs;
  50901. var t0 = 0.0, t1 = 1.0;
  50902. if (dict.has('Domain')) {
  50903. var domainArr = dict.getArray('Domain');
  50904. t0 = domainArr[0];
  50905. t1 = domainArr[1];
  50906. }
  50907. var extendStart = false, extendEnd = false;
  50908. if (dict.has('Extend')) {
  50909. var extendArr = dict.getArray('Extend');
  50910. extendStart = extendArr[0];
  50911. extendEnd = extendArr[1];
  50912. }
  50913. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50914. var x1 = this.coordsArr[0];
  50915. var y1 = this.coordsArr[1];
  50916. var r1 = this.coordsArr[2];
  50917. var x2 = this.coordsArr[3];
  50918. var y2 = this.coordsArr[4];
  50919. var r2 = this.coordsArr[5];
  50920. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50921. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50922. warn('Unsupported radial gradient.');
  50923. }
  50924. }
  50925. this.extendStart = extendStart;
  50926. this.extendEnd = extendEnd;
  50927. var fnObj = dict.get('Function');
  50928. var fn = PDFFunction.parseArray(xref, fnObj);
  50929. var diff = t1 - t0;
  50930. var step = diff / 10;
  50931. var colorStops = this.colorStops = [];
  50932. if (t0 >= t1 || step <= 0) {
  50933. info('Bad shading domain.');
  50934. return;
  50935. }
  50936. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50937. var rgbColor;
  50938. for (var i = t0; i <= t1; i += step) {
  50939. ratio[0] = i;
  50940. fn(ratio, 0, color, 0);
  50941. rgbColor = cs.getRgb(color, 0);
  50942. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50943. colorStops.push([
  50944. (i - t0) / diff,
  50945. cssColor
  50946. ]);
  50947. }
  50948. var background = 'transparent';
  50949. if (dict.has('Background')) {
  50950. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50951. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50952. }
  50953. if (!extendStart) {
  50954. colorStops.unshift([
  50955. 0,
  50956. background
  50957. ]);
  50958. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50959. }
  50960. if (!extendEnd) {
  50961. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50962. colorStops.push([
  50963. 1,
  50964. background
  50965. ]);
  50966. }
  50967. this.colorStops = colorStops;
  50968. }
  50969. RadialAxial.prototype = {
  50970. getIR: function RadialAxial_getIR() {
  50971. var coordsArr = this.coordsArr;
  50972. var shadingType = this.shadingType;
  50973. var type, p0, p1, r0, r1;
  50974. if (shadingType === ShadingType.AXIAL) {
  50975. p0 = [
  50976. coordsArr[0],
  50977. coordsArr[1]
  50978. ];
  50979. p1 = [
  50980. coordsArr[2],
  50981. coordsArr[3]
  50982. ];
  50983. r0 = null;
  50984. r1 = null;
  50985. type = 'axial';
  50986. } else if (shadingType === ShadingType.RADIAL) {
  50987. p0 = [
  50988. coordsArr[0],
  50989. coordsArr[1]
  50990. ];
  50991. p1 = [
  50992. coordsArr[3],
  50993. coordsArr[4]
  50994. ];
  50995. r0 = coordsArr[2];
  50996. r1 = coordsArr[5];
  50997. type = 'radial';
  50998. } else {
  50999. error('getPattern type unknown: ' + shadingType);
  51000. }
  51001. var matrix = this.matrix;
  51002. if (matrix) {
  51003. p0 = Util.applyTransform(p0, matrix);
  51004. p1 = Util.applyTransform(p1, matrix);
  51005. if (shadingType === ShadingType.RADIAL) {
  51006. var scale = Util.singularValueDecompose2dScale(matrix);
  51007. r0 *= scale[0];
  51008. r1 *= scale[1];
  51009. }
  51010. }
  51011. return [
  51012. 'RadialAxial',
  51013. type,
  51014. this.colorStops,
  51015. p0,
  51016. p1,
  51017. r0,
  51018. r1
  51019. ];
  51020. }
  51021. };
  51022. return RadialAxial;
  51023. }();
  51024. Shadings.Mesh = function MeshClosure() {
  51025. function MeshStreamReader(stream, context) {
  51026. this.stream = stream;
  51027. this.context = context;
  51028. this.buffer = 0;
  51029. this.bufferLength = 0;
  51030. var numComps = context.numComps;
  51031. this.tmpCompsBuf = new Float32Array(numComps);
  51032. var csNumComps = context.colorSpace.numComps;
  51033. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  51034. }
  51035. MeshStreamReader.prototype = {
  51036. get hasData() {
  51037. if (this.stream.end) {
  51038. return this.stream.pos < this.stream.end;
  51039. }
  51040. if (this.bufferLength > 0) {
  51041. return true;
  51042. }
  51043. var nextByte = this.stream.getByte();
  51044. if (nextByte < 0) {
  51045. return false;
  51046. }
  51047. this.buffer = nextByte;
  51048. this.bufferLength = 8;
  51049. return true;
  51050. },
  51051. readBits: function MeshStreamReader_readBits(n) {
  51052. var buffer = this.buffer;
  51053. var bufferLength = this.bufferLength;
  51054. if (n === 32) {
  51055. if (bufferLength === 0) {
  51056. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  51057. }
  51058. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  51059. var nextByte = this.stream.getByte();
  51060. this.buffer = nextByte & (1 << bufferLength) - 1;
  51061. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  51062. }
  51063. if (n === 8 && bufferLength === 0) {
  51064. return this.stream.getByte();
  51065. }
  51066. while (bufferLength < n) {
  51067. buffer = buffer << 8 | this.stream.getByte();
  51068. bufferLength += 8;
  51069. }
  51070. bufferLength -= n;
  51071. this.bufferLength = bufferLength;
  51072. this.buffer = buffer & (1 << bufferLength) - 1;
  51073. return buffer >> bufferLength;
  51074. },
  51075. align: function MeshStreamReader_align() {
  51076. this.buffer = 0;
  51077. this.bufferLength = 0;
  51078. },
  51079. readFlag: function MeshStreamReader_readFlag() {
  51080. return this.readBits(this.context.bitsPerFlag);
  51081. },
  51082. readCoordinate: function MeshStreamReader_readCoordinate() {
  51083. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  51084. var xi = this.readBits(bitsPerCoordinate);
  51085. var yi = this.readBits(bitsPerCoordinate);
  51086. var decode = this.context.decode;
  51087. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  51088. return [
  51089. xi * scale * (decode[1] - decode[0]) + decode[0],
  51090. yi * scale * (decode[3] - decode[2]) + decode[2]
  51091. ];
  51092. },
  51093. readComponents: function MeshStreamReader_readComponents() {
  51094. var numComps = this.context.numComps;
  51095. var bitsPerComponent = this.context.bitsPerComponent;
  51096. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  51097. var decode = this.context.decode;
  51098. var components = this.tmpCompsBuf;
  51099. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  51100. var ci = this.readBits(bitsPerComponent);
  51101. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  51102. }
  51103. var color = this.tmpCsCompsBuf;
  51104. if (this.context.colorFn) {
  51105. this.context.colorFn(components, 0, color, 0);
  51106. }
  51107. return this.context.colorSpace.getRgb(color, 0);
  51108. }
  51109. };
  51110. function decodeType4Shading(mesh, reader) {
  51111. var coords = mesh.coords;
  51112. var colors = mesh.colors;
  51113. var operators = [];
  51114. var ps = [];
  51115. var verticesLeft = 0;
  51116. while (reader.hasData) {
  51117. var f = reader.readFlag();
  51118. var coord = reader.readCoordinate();
  51119. var color = reader.readComponents();
  51120. if (verticesLeft === 0) {
  51121. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  51122. switch (f) {
  51123. case 0:
  51124. verticesLeft = 3;
  51125. break;
  51126. case 1:
  51127. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  51128. verticesLeft = 1;
  51129. break;
  51130. case 2:
  51131. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  51132. verticesLeft = 1;
  51133. break;
  51134. }
  51135. operators.push(f);
  51136. }
  51137. ps.push(coords.length);
  51138. coords.push(coord);
  51139. colors.push(color);
  51140. verticesLeft--;
  51141. reader.align();
  51142. }
  51143. mesh.figures.push({
  51144. type: 'triangles',
  51145. coords: new Int32Array(ps),
  51146. colors: new Int32Array(ps)
  51147. });
  51148. }
  51149. function decodeType5Shading(mesh, reader, verticesPerRow) {
  51150. var coords = mesh.coords;
  51151. var colors = mesh.colors;
  51152. var ps = [];
  51153. while (reader.hasData) {
  51154. var coord = reader.readCoordinate();
  51155. var color = reader.readComponents();
  51156. ps.push(coords.length);
  51157. coords.push(coord);
  51158. colors.push(color);
  51159. }
  51160. mesh.figures.push({
  51161. type: 'lattice',
  51162. coords: new Int32Array(ps),
  51163. colors: new Int32Array(ps),
  51164. verticesPerRow: verticesPerRow
  51165. });
  51166. }
  51167. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51168. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51169. var TRIANGLE_DENSITY = 20;
  51170. var getB = function getBClosure() {
  51171. function buildB(count) {
  51172. var lut = [];
  51173. for (var i = 0; i <= count; i++) {
  51174. var t = i / count, t_ = 1 - t;
  51175. lut.push(new Float32Array([
  51176. t_ * t_ * t_,
  51177. 3 * t * t_ * t_,
  51178. 3 * t * t * t_,
  51179. t * t * t
  51180. ]));
  51181. }
  51182. return lut;
  51183. }
  51184. var cache = [];
  51185. return function getB(count) {
  51186. if (!cache[count]) {
  51187. cache[count] = buildB(count);
  51188. }
  51189. return cache[count];
  51190. };
  51191. }();
  51192. function buildFigureFromPatch(mesh, index) {
  51193. var figure = mesh.figures[index];
  51194. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51195. var coords = mesh.coords, colors = mesh.colors;
  51196. var pi = figure.coords;
  51197. var ci = figure.colors;
  51198. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51199. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51200. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51201. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51202. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51203. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51204. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51205. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51206. var verticesPerRow = splitXBy + 1;
  51207. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51208. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51209. var k = 0;
  51210. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51211. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51212. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51213. for (var row = 0; row <= splitYBy; row++) {
  51214. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51215. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51216. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51217. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51218. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51219. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51220. for (var col = 0; col <= splitXBy; col++, k++) {
  51221. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51222. continue;
  51223. }
  51224. var x = 0, y = 0;
  51225. var q = 0;
  51226. for (var i = 0; i <= 3; i++) {
  51227. for (var j = 0; j <= 3; j++, q++) {
  51228. var m = bRow[row][i] * bCol[col][j];
  51229. x += coords[pi[q]][0] * m;
  51230. y += coords[pi[q]][1] * m;
  51231. }
  51232. }
  51233. figureCoords[k] = coords.length;
  51234. coords.push([
  51235. x,
  51236. y
  51237. ]);
  51238. figureColors[k] = colors.length;
  51239. var newColor = new Uint8Array(3);
  51240. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51241. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51242. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51243. colors.push(newColor);
  51244. }
  51245. }
  51246. figureCoords[0] = pi[0];
  51247. figureColors[0] = ci[0];
  51248. figureCoords[splitXBy] = pi[3];
  51249. figureColors[splitXBy] = ci[1];
  51250. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51251. figureColors[verticesPerRow * splitYBy] = ci[2];
  51252. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51253. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51254. mesh.figures[index] = {
  51255. type: 'lattice',
  51256. coords: figureCoords,
  51257. colors: figureColors,
  51258. verticesPerRow: verticesPerRow
  51259. };
  51260. }
  51261. function decodeType6Shading(mesh, reader) {
  51262. var coords = mesh.coords;
  51263. var colors = mesh.colors;
  51264. var ps = new Int32Array(16);
  51265. var cs = new Int32Array(4);
  51266. while (reader.hasData) {
  51267. var f = reader.readFlag();
  51268. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51269. var i, ii;
  51270. var pi = coords.length;
  51271. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51272. coords.push(reader.readCoordinate());
  51273. }
  51274. var ci = colors.length;
  51275. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51276. colors.push(reader.readComponents());
  51277. }
  51278. var tmp1, tmp2, tmp3, tmp4;
  51279. switch (f) {
  51280. case 0:
  51281. ps[12] = pi + 3;
  51282. ps[13] = pi + 4;
  51283. ps[14] = pi + 5;
  51284. ps[15] = pi + 6;
  51285. ps[8] = pi + 2;
  51286. ps[11] = pi + 7;
  51287. ps[4] = pi + 1;
  51288. ps[7] = pi + 8;
  51289. ps[0] = pi;
  51290. ps[1] = pi + 11;
  51291. ps[2] = pi + 10;
  51292. ps[3] = pi + 9;
  51293. cs[2] = ci + 1;
  51294. cs[3] = ci + 2;
  51295. cs[0] = ci;
  51296. cs[1] = ci + 3;
  51297. break;
  51298. case 1:
  51299. tmp1 = ps[12];
  51300. tmp2 = ps[13];
  51301. tmp3 = ps[14];
  51302. tmp4 = ps[15];
  51303. ps[12] = tmp4;
  51304. ps[13] = pi + 0;
  51305. ps[14] = pi + 1;
  51306. ps[15] = pi + 2;
  51307. ps[8] = tmp3;
  51308. ps[11] = pi + 3;
  51309. ps[4] = tmp2;
  51310. ps[7] = pi + 4;
  51311. ps[0] = tmp1;
  51312. ps[1] = pi + 7;
  51313. ps[2] = pi + 6;
  51314. ps[3] = pi + 5;
  51315. tmp1 = cs[2];
  51316. tmp2 = cs[3];
  51317. cs[2] = tmp2;
  51318. cs[3] = ci;
  51319. cs[0] = tmp1;
  51320. cs[1] = ci + 1;
  51321. break;
  51322. case 2:
  51323. tmp1 = ps[15];
  51324. tmp2 = ps[11];
  51325. ps[12] = ps[3];
  51326. ps[13] = pi + 0;
  51327. ps[14] = pi + 1;
  51328. ps[15] = pi + 2;
  51329. ps[8] = ps[7];
  51330. ps[11] = pi + 3;
  51331. ps[4] = tmp2;
  51332. ps[7] = pi + 4;
  51333. ps[0] = tmp1;
  51334. ps[1] = pi + 7;
  51335. ps[2] = pi + 6;
  51336. ps[3] = pi + 5;
  51337. tmp1 = cs[3];
  51338. cs[2] = cs[1];
  51339. cs[3] = ci;
  51340. cs[0] = tmp1;
  51341. cs[1] = ci + 1;
  51342. break;
  51343. case 3:
  51344. ps[12] = ps[0];
  51345. ps[13] = pi + 0;
  51346. ps[14] = pi + 1;
  51347. ps[15] = pi + 2;
  51348. ps[8] = ps[1];
  51349. ps[11] = pi + 3;
  51350. ps[4] = ps[2];
  51351. ps[7] = pi + 4;
  51352. ps[0] = ps[3];
  51353. ps[1] = pi + 7;
  51354. ps[2] = pi + 6;
  51355. ps[3] = pi + 5;
  51356. cs[2] = cs[0];
  51357. cs[3] = ci;
  51358. cs[0] = cs[1];
  51359. cs[1] = ci + 1;
  51360. break;
  51361. }
  51362. ps[5] = coords.length;
  51363. coords.push([
  51364. (-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,
  51365. (-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
  51366. ]);
  51367. ps[6] = coords.length;
  51368. coords.push([
  51369. (-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,
  51370. (-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
  51371. ]);
  51372. ps[9] = coords.length;
  51373. coords.push([
  51374. (-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,
  51375. (-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
  51376. ]);
  51377. ps[10] = coords.length;
  51378. coords.push([
  51379. (-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,
  51380. (-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
  51381. ]);
  51382. mesh.figures.push({
  51383. type: 'patch',
  51384. coords: new Int32Array(ps),
  51385. colors: new Int32Array(cs)
  51386. });
  51387. }
  51388. }
  51389. function decodeType7Shading(mesh, reader) {
  51390. var coords = mesh.coords;
  51391. var colors = mesh.colors;
  51392. var ps = new Int32Array(16);
  51393. var cs = new Int32Array(4);
  51394. while (reader.hasData) {
  51395. var f = reader.readFlag();
  51396. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51397. var i, ii;
  51398. var pi = coords.length;
  51399. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51400. coords.push(reader.readCoordinate());
  51401. }
  51402. var ci = colors.length;
  51403. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51404. colors.push(reader.readComponents());
  51405. }
  51406. var tmp1, tmp2, tmp3, tmp4;
  51407. switch (f) {
  51408. case 0:
  51409. ps[12] = pi + 3;
  51410. ps[13] = pi + 4;
  51411. ps[14] = pi + 5;
  51412. ps[15] = pi + 6;
  51413. ps[8] = pi + 2;
  51414. ps[9] = pi + 13;
  51415. ps[10] = pi + 14;
  51416. ps[11] = pi + 7;
  51417. ps[4] = pi + 1;
  51418. ps[5] = pi + 12;
  51419. ps[6] = pi + 15;
  51420. ps[7] = pi + 8;
  51421. ps[0] = pi;
  51422. ps[1] = pi + 11;
  51423. ps[2] = pi + 10;
  51424. ps[3] = pi + 9;
  51425. cs[2] = ci + 1;
  51426. cs[3] = ci + 2;
  51427. cs[0] = ci;
  51428. cs[1] = ci + 3;
  51429. break;
  51430. case 1:
  51431. tmp1 = ps[12];
  51432. tmp2 = ps[13];
  51433. tmp3 = ps[14];
  51434. tmp4 = ps[15];
  51435. ps[12] = tmp4;
  51436. ps[13] = pi + 0;
  51437. ps[14] = pi + 1;
  51438. ps[15] = pi + 2;
  51439. ps[8] = tmp3;
  51440. ps[9] = pi + 9;
  51441. ps[10] = pi + 10;
  51442. ps[11] = pi + 3;
  51443. ps[4] = tmp2;
  51444. ps[5] = pi + 8;
  51445. ps[6] = pi + 11;
  51446. ps[7] = pi + 4;
  51447. ps[0] = tmp1;
  51448. ps[1] = pi + 7;
  51449. ps[2] = pi + 6;
  51450. ps[3] = pi + 5;
  51451. tmp1 = cs[2];
  51452. tmp2 = cs[3];
  51453. cs[2] = tmp2;
  51454. cs[3] = ci;
  51455. cs[0] = tmp1;
  51456. cs[1] = ci + 1;
  51457. break;
  51458. case 2:
  51459. tmp1 = ps[15];
  51460. tmp2 = ps[11];
  51461. ps[12] = ps[3];
  51462. ps[13] = pi + 0;
  51463. ps[14] = pi + 1;
  51464. ps[15] = pi + 2;
  51465. ps[8] = ps[7];
  51466. ps[9] = pi + 9;
  51467. ps[10] = pi + 10;
  51468. ps[11] = pi + 3;
  51469. ps[4] = tmp2;
  51470. ps[5] = pi + 8;
  51471. ps[6] = pi + 11;
  51472. ps[7] = pi + 4;
  51473. ps[0] = tmp1;
  51474. ps[1] = pi + 7;
  51475. ps[2] = pi + 6;
  51476. ps[3] = pi + 5;
  51477. tmp1 = cs[3];
  51478. cs[2] = cs[1];
  51479. cs[3] = ci;
  51480. cs[0] = tmp1;
  51481. cs[1] = ci + 1;
  51482. break;
  51483. case 3:
  51484. ps[12] = ps[0];
  51485. ps[13] = pi + 0;
  51486. ps[14] = pi + 1;
  51487. ps[15] = pi + 2;
  51488. ps[8] = ps[1];
  51489. ps[9] = pi + 9;
  51490. ps[10] = pi + 10;
  51491. ps[11] = pi + 3;
  51492. ps[4] = ps[2];
  51493. ps[5] = pi + 8;
  51494. ps[6] = pi + 11;
  51495. ps[7] = pi + 4;
  51496. ps[0] = ps[3];
  51497. ps[1] = pi + 7;
  51498. ps[2] = pi + 6;
  51499. ps[3] = pi + 5;
  51500. cs[2] = cs[0];
  51501. cs[3] = ci;
  51502. cs[0] = cs[1];
  51503. cs[1] = ci + 1;
  51504. break;
  51505. }
  51506. mesh.figures.push({
  51507. type: 'patch',
  51508. coords: new Int32Array(ps),
  51509. colors: new Int32Array(cs)
  51510. });
  51511. }
  51512. }
  51513. function updateBounds(mesh) {
  51514. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51515. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51516. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51517. minX = minX > x ? x : minX;
  51518. minY = minY > y ? y : minY;
  51519. maxX = maxX < x ? x : maxX;
  51520. maxY = maxY < y ? y : maxY;
  51521. }
  51522. mesh.bounds = [
  51523. minX,
  51524. minY,
  51525. maxX,
  51526. maxY
  51527. ];
  51528. }
  51529. function packData(mesh) {
  51530. var i, ii, j, jj;
  51531. var coords = mesh.coords;
  51532. var coordsPacked = new Float32Array(coords.length * 2);
  51533. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51534. var xy = coords[i];
  51535. coordsPacked[j++] = xy[0];
  51536. coordsPacked[j++] = xy[1];
  51537. }
  51538. mesh.coords = coordsPacked;
  51539. var colors = mesh.colors;
  51540. var colorsPacked = new Uint8Array(colors.length * 3);
  51541. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51542. var c = colors[i];
  51543. colorsPacked[j++] = c[0];
  51544. colorsPacked[j++] = c[1];
  51545. colorsPacked[j++] = c[2];
  51546. }
  51547. mesh.colors = colorsPacked;
  51548. var figures = mesh.figures;
  51549. for (i = 0, ii = figures.length; i < ii; i++) {
  51550. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51551. for (j = 0, jj = ps.length; j < jj; j++) {
  51552. ps[j] *= 2;
  51553. cs[j] *= 3;
  51554. }
  51555. }
  51556. }
  51557. function Mesh(stream, matrix, xref, res) {
  51558. assert(isStream(stream), 'Mesh data is not a stream');
  51559. var dict = stream.dict;
  51560. this.matrix = matrix;
  51561. this.shadingType = dict.get('ShadingType');
  51562. this.type = 'Pattern';
  51563. this.bbox = dict.getArray('BBox');
  51564. var cs = dict.get('ColorSpace', 'CS');
  51565. cs = ColorSpace.parse(cs, xref, res);
  51566. this.cs = cs;
  51567. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51568. var fnObj = dict.get('Function');
  51569. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51570. this.coords = [];
  51571. this.colors = [];
  51572. this.figures = [];
  51573. var decodeContext = {
  51574. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51575. bitsPerComponent: dict.get('BitsPerComponent'),
  51576. bitsPerFlag: dict.get('BitsPerFlag'),
  51577. decode: dict.getArray('Decode'),
  51578. colorFn: fn,
  51579. colorSpace: cs,
  51580. numComps: fn ? 1 : cs.numComps
  51581. };
  51582. var reader = new MeshStreamReader(stream, decodeContext);
  51583. var patchMesh = false;
  51584. switch (this.shadingType) {
  51585. case ShadingType.FREE_FORM_MESH:
  51586. decodeType4Shading(this, reader);
  51587. break;
  51588. case ShadingType.LATTICE_FORM_MESH:
  51589. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51590. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51591. decodeType5Shading(this, reader, verticesPerRow);
  51592. break;
  51593. case ShadingType.COONS_PATCH_MESH:
  51594. decodeType6Shading(this, reader);
  51595. patchMesh = true;
  51596. break;
  51597. case ShadingType.TENSOR_PATCH_MESH:
  51598. decodeType7Shading(this, reader);
  51599. patchMesh = true;
  51600. break;
  51601. default:
  51602. error('Unsupported mesh type.');
  51603. break;
  51604. }
  51605. if (patchMesh) {
  51606. updateBounds(this);
  51607. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51608. buildFigureFromPatch(this, i);
  51609. }
  51610. }
  51611. updateBounds(this);
  51612. packData(this);
  51613. }
  51614. Mesh.prototype = {
  51615. getIR: function Mesh_getIR() {
  51616. return [
  51617. 'Mesh',
  51618. this.shadingType,
  51619. this.coords,
  51620. this.colors,
  51621. this.figures,
  51622. this.bounds,
  51623. this.matrix,
  51624. this.bbox,
  51625. this.background
  51626. ];
  51627. }
  51628. };
  51629. return Mesh;
  51630. }();
  51631. Shadings.Dummy = function DummyClosure() {
  51632. function Dummy() {
  51633. this.type = 'Pattern';
  51634. }
  51635. Dummy.prototype = {
  51636. getIR: function Dummy_getIR() {
  51637. return ['Dummy'];
  51638. }
  51639. };
  51640. return Dummy;
  51641. }();
  51642. function getTilingPatternIR(operatorList, dict, args) {
  51643. var matrix = dict.getArray('Matrix');
  51644. var bbox = dict.getArray('BBox');
  51645. var xstep = dict.get('XStep');
  51646. var ystep = dict.get('YStep');
  51647. var paintType = dict.get('PaintType');
  51648. var tilingType = dict.get('TilingType');
  51649. return [
  51650. 'TilingPattern',
  51651. args,
  51652. operatorList,
  51653. matrix,
  51654. bbox,
  51655. xstep,
  51656. ystep,
  51657. paintType,
  51658. tilingType
  51659. ];
  51660. }
  51661. exports.Pattern = Pattern;
  51662. exports.getTilingPatternIR = getTilingPatternIR;
  51663. }));
  51664. (function (root, factory) {
  51665. 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);
  51666. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51667. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51668. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51669. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51670. var ImageKind = sharedUtil.ImageKind;
  51671. var OPS = sharedUtil.OPS;
  51672. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51673. var Util = sharedUtil.Util;
  51674. var assert = sharedUtil.assert;
  51675. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51676. var error = sharedUtil.error;
  51677. var info = sharedUtil.info;
  51678. var isArray = sharedUtil.isArray;
  51679. var isNum = sharedUtil.isNum;
  51680. var isString = sharedUtil.isString;
  51681. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51682. var warn = sharedUtil.warn;
  51683. var Dict = corePrimitives.Dict;
  51684. var Name = corePrimitives.Name;
  51685. var isCmd = corePrimitives.isCmd;
  51686. var isDict = corePrimitives.isDict;
  51687. var isName = corePrimitives.isName;
  51688. var isRef = corePrimitives.isRef;
  51689. var isStream = corePrimitives.isStream;
  51690. var DecodeStream = coreStream.DecodeStream;
  51691. var JpegStream = coreStream.JpegStream;
  51692. var Stream = coreStream.Stream;
  51693. var Lexer = coreParser.Lexer;
  51694. var Parser = coreParser.Parser;
  51695. var isEOF = coreParser.isEOF;
  51696. var PDFImage = coreImage.PDFImage;
  51697. var ColorSpace = coreColorSpace.ColorSpace;
  51698. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51699. var ErrorFont = coreFonts.ErrorFont;
  51700. var FontFlags = coreFonts.FontFlags;
  51701. var Font = coreFonts.Font;
  51702. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51703. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51704. var getFontType = coreFonts.getFontType;
  51705. var isPDFFunction = coreFunction.isPDFFunction;
  51706. var PDFFunction = coreFunction.PDFFunction;
  51707. var Pattern = corePattern.Pattern;
  51708. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51709. var CMapFactory = coreCMap.CMapFactory;
  51710. var IdentityCMap = coreCMap.IdentityCMap;
  51711. var getMetrics = coreMetrics.getMetrics;
  51712. var bidi = coreBidi.bidi;
  51713. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51714. var StandardEncoding = coreEncodings.StandardEncoding;
  51715. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51716. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51717. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51718. var getEncoding = coreEncodings.getEncoding;
  51719. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51720. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51721. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51722. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51723. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51724. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51725. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51726. var PartialEvaluator = function PartialEvaluatorClosure() {
  51727. var DefaultPartialEvaluatorOptions = {
  51728. forceDataSchema: false,
  51729. maxImageSize: -1,
  51730. disableFontFace: false,
  51731. cMapOptions: {
  51732. url: null,
  51733. packed: false
  51734. }
  51735. };
  51736. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51737. this.xref = xref;
  51738. this.resources = resources;
  51739. this.handler = handler;
  51740. this.forceDataSchema = forceDataSchema;
  51741. }
  51742. NativeImageDecoder.prototype = {
  51743. canDecode: function (image) {
  51744. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51745. },
  51746. decode: function (image) {
  51747. var dict = image.dict;
  51748. var colorSpace = dict.get('ColorSpace', 'CS');
  51749. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51750. var numComps = colorSpace.numComps;
  51751. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51752. image.getIR(this.forceDataSchema),
  51753. numComps
  51754. ]);
  51755. return decodePromise.then(function (message) {
  51756. var data = message.data;
  51757. return new Stream(data, 0, data.length, image.dict);
  51758. });
  51759. }
  51760. };
  51761. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51762. var dict = image.dict;
  51763. if (dict.has('DecodeParms') || dict.has('DP')) {
  51764. return false;
  51765. }
  51766. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51767. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51768. };
  51769. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51770. var dict = image.dict;
  51771. if (dict.has('DecodeParms') || dict.has('DP')) {
  51772. return false;
  51773. }
  51774. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51775. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51776. };
  51777. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  51778. this.pdfManager = pdfManager;
  51779. this.xref = xref;
  51780. this.handler = handler;
  51781. this.pageIndex = pageIndex;
  51782. this.uniquePrefix = uniquePrefix;
  51783. this.idCounters = idCounters;
  51784. this.fontCache = fontCache;
  51785. this.options = options || DefaultPartialEvaluatorOptions;
  51786. }
  51787. var TIME_SLOT_DURATION_MS = 20;
  51788. var CHECK_TIME_EVERY = 100;
  51789. function TimeSlotManager() {
  51790. this.reset();
  51791. }
  51792. TimeSlotManager.prototype = {
  51793. check: function TimeSlotManager_check() {
  51794. if (++this.checked < CHECK_TIME_EVERY) {
  51795. return false;
  51796. }
  51797. this.checked = 0;
  51798. return this.endTime <= Date.now();
  51799. },
  51800. reset: function TimeSlotManager_reset() {
  51801. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51802. this.checked = 0;
  51803. }
  51804. };
  51805. var deferred = Promise.resolve();
  51806. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51807. PartialEvaluator.prototype = {
  51808. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51809. if (!isDict(resources)) {
  51810. return false;
  51811. }
  51812. var processed = Object.create(null);
  51813. if (resources.objId) {
  51814. processed[resources.objId] = true;
  51815. }
  51816. var nodes = [resources], xref = this.xref;
  51817. while (nodes.length) {
  51818. var key, i, ii;
  51819. var node = nodes.shift();
  51820. var graphicStates = node.get('ExtGState');
  51821. if (isDict(graphicStates)) {
  51822. var graphicStatesKeys = graphicStates.getKeys();
  51823. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51824. key = graphicStatesKeys[i];
  51825. var graphicState = graphicStates.get(key);
  51826. var bm = graphicState.get('BM');
  51827. if (isName(bm) && bm.name !== 'Normal') {
  51828. return true;
  51829. }
  51830. }
  51831. }
  51832. var xObjects = node.get('XObject');
  51833. if (!isDict(xObjects)) {
  51834. continue;
  51835. }
  51836. var xObjectsKeys = xObjects.getKeys();
  51837. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51838. key = xObjectsKeys[i];
  51839. var xObject = xObjects.getRaw(key);
  51840. if (isRef(xObject)) {
  51841. if (processed[xObject.toString()]) {
  51842. continue;
  51843. }
  51844. xObject = xref.fetch(xObject);
  51845. }
  51846. if (!isStream(xObject)) {
  51847. continue;
  51848. }
  51849. if (xObject.dict.objId) {
  51850. if (processed[xObject.dict.objId]) {
  51851. continue;
  51852. }
  51853. processed[xObject.dict.objId] = true;
  51854. }
  51855. var xResources = xObject.dict.get('Resources');
  51856. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51857. nodes.push(xResources);
  51858. if (xResources.objId) {
  51859. processed[xResources.objId] = true;
  51860. }
  51861. }
  51862. }
  51863. }
  51864. return false;
  51865. },
  51866. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51867. var matrix = xobj.dict.getArray('Matrix');
  51868. var bbox = xobj.dict.getArray('BBox');
  51869. var group = xobj.dict.get('Group');
  51870. if (group) {
  51871. var groupOptions = {
  51872. matrix: matrix,
  51873. bbox: bbox,
  51874. smask: smask,
  51875. isolated: false,
  51876. knockout: false
  51877. };
  51878. var groupSubtype = group.get('S');
  51879. var colorSpace;
  51880. if (isName(groupSubtype, 'Transparency')) {
  51881. groupOptions.isolated = group.get('I') || false;
  51882. groupOptions.knockout = group.get('K') || false;
  51883. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51884. }
  51885. if (smask && smask.backdrop) {
  51886. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51887. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51888. }
  51889. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51890. }
  51891. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51892. matrix,
  51893. bbox
  51894. ]);
  51895. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51896. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51897. if (group) {
  51898. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51899. }
  51900. });
  51901. },
  51902. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51903. var self = this;
  51904. var dict = image.dict;
  51905. var w = dict.get('Width', 'W');
  51906. var h = dict.get('Height', 'H');
  51907. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51908. warn('Image dimensions are missing, or not numbers.');
  51909. return;
  51910. }
  51911. var maxImageSize = this.options.maxImageSize;
  51912. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51913. warn('Image exceeded maximum allowed size and was removed.');
  51914. return;
  51915. }
  51916. var imageMask = dict.get('ImageMask', 'IM') || false;
  51917. var imgData, args;
  51918. if (imageMask) {
  51919. var width = dict.get('Width', 'W');
  51920. var height = dict.get('Height', 'H');
  51921. var bitStrideLength = width + 7 >> 3;
  51922. var imgArray = image.getBytes(bitStrideLength * height);
  51923. var decode = dict.getArray('Decode', 'D');
  51924. var inverseDecode = !!decode && decode[0] > 0;
  51925. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51926. imgData.cached = true;
  51927. args = [imgData];
  51928. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51929. if (cacheKey) {
  51930. imageCache[cacheKey] = {
  51931. fn: OPS.paintImageMaskXObject,
  51932. args: args
  51933. };
  51934. }
  51935. return;
  51936. }
  51937. var softMask = dict.get('SMask', 'SM') || false;
  51938. var mask = dict.get('Mask') || false;
  51939. var SMALL_IMAGE_DIMENSIONS = 200;
  51940. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51941. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51942. imgData = imageObj.createImageData(true);
  51943. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51944. return;
  51945. }
  51946. var uniquePrefix = this.uniquePrefix || '';
  51947. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  51948. operatorList.addDependency(objId);
  51949. args = [
  51950. objId,
  51951. w,
  51952. h
  51953. ];
  51954. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51955. operatorList.addOp(OPS.paintJpegXObject, args);
  51956. this.handler.send('obj', [
  51957. objId,
  51958. this.pageIndex,
  51959. 'JpegStream',
  51960. image.getIR(this.options.forceDataSchema)
  51961. ]);
  51962. return;
  51963. }
  51964. var nativeImageDecoder = null;
  51965. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51966. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51967. }
  51968. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51969. var imgData = imageObj.createImageData(false);
  51970. self.handler.send('obj', [
  51971. objId,
  51972. self.pageIndex,
  51973. 'Image',
  51974. imgData
  51975. ], [imgData.data.buffer]);
  51976. }).then(undefined, function (reason) {
  51977. warn('Unable to decode image: ' + reason);
  51978. self.handler.send('obj', [
  51979. objId,
  51980. self.pageIndex,
  51981. 'Image',
  51982. null
  51983. ]);
  51984. });
  51985. operatorList.addOp(OPS.paintImageXObject, args);
  51986. if (cacheKey) {
  51987. imageCache[cacheKey] = {
  51988. fn: OPS.paintImageXObject,
  51989. args: args
  51990. };
  51991. }
  51992. },
  51993. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51994. var smaskContent = smask.get('G');
  51995. var smaskOptions = {
  51996. subtype: smask.get('S').name,
  51997. backdrop: smask.get('BC')
  51998. };
  51999. var transferObj = smask.get('TR');
  52000. if (isPDFFunction(transferObj)) {
  52001. var transferFn = PDFFunction.parse(this.xref, transferObj);
  52002. var transferMap = new Uint8Array(256);
  52003. var tmp = new Float32Array(1);
  52004. for (var i = 0; i < 256; i++) {
  52005. tmp[0] = i / 255;
  52006. transferFn(tmp, 0, tmp, 0);
  52007. transferMap[i] = tmp[0] * 255 | 0;
  52008. }
  52009. smaskOptions.transferMap = transferMap;
  52010. }
  52011. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  52012. },
  52013. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  52014. var tilingOpList = new OperatorList();
  52015. var resourcesArray = [
  52016. patternDict.get('Resources'),
  52017. resources
  52018. ];
  52019. var patternResources = Dict.merge(this.xref, resourcesArray);
  52020. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  52021. operatorList.addDependencies(tilingOpList.dependencies);
  52022. operatorList.addOp(fn, getTilingPatternIR({
  52023. fnArray: tilingOpList.fnArray,
  52024. argsArray: tilingOpList.argsArray
  52025. }, patternDict, args));
  52026. });
  52027. },
  52028. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  52029. var fontName;
  52030. if (fontArgs) {
  52031. fontArgs = fontArgs.slice();
  52032. fontName = fontArgs[0].name;
  52033. }
  52034. var self = this;
  52035. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  52036. if (!translated.font.isType3Font) {
  52037. return translated;
  52038. }
  52039. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  52040. return translated;
  52041. }, function (reason) {
  52042. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52043. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  52044. });
  52045. }).then(function (translated) {
  52046. state.font = translated.font;
  52047. translated.send(self.handler);
  52048. return translated.loadedName;
  52049. });
  52050. },
  52051. handleText: function PartialEvaluator_handleText(chars, state) {
  52052. var font = state.font;
  52053. var glyphs = font.charsToGlyphs(chars);
  52054. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  52055. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  52056. var buildPath = function (fontChar) {
  52057. if (!font.renderer.hasBuiltPath(fontChar)) {
  52058. var path = font.renderer.getPathJs(fontChar);
  52059. this.handler.send('commonobj', [
  52060. font.loadedName + '_path_' + fontChar,
  52061. 'FontPath',
  52062. path
  52063. ]);
  52064. }
  52065. }.bind(this);
  52066. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  52067. var glyph = glyphs[i];
  52068. buildPath(glyph.fontChar);
  52069. var accent = glyph.accent;
  52070. if (accent && accent.fontChar) {
  52071. buildPath(accent.fontChar);
  52072. }
  52073. }
  52074. }
  52075. return glyphs;
  52076. },
  52077. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  52078. var gStateObj = [];
  52079. var gStateKeys = gState.getKeys();
  52080. var self = this;
  52081. var promise = Promise.resolve();
  52082. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  52083. var key = gStateKeys[i];
  52084. var value = gState.get(key);
  52085. switch (key) {
  52086. case 'Type':
  52087. break;
  52088. case 'LW':
  52089. case 'LC':
  52090. case 'LJ':
  52091. case 'ML':
  52092. case 'D':
  52093. case 'RI':
  52094. case 'FL':
  52095. case 'CA':
  52096. case 'ca':
  52097. gStateObj.push([
  52098. key,
  52099. value
  52100. ]);
  52101. break;
  52102. case 'Font':
  52103. promise = promise.then(function () {
  52104. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  52105. operatorList.addDependency(loadedName);
  52106. gStateObj.push([
  52107. key,
  52108. [
  52109. loadedName,
  52110. value[1]
  52111. ]
  52112. ]);
  52113. });
  52114. });
  52115. break;
  52116. case 'BM':
  52117. gStateObj.push([
  52118. key,
  52119. value
  52120. ]);
  52121. break;
  52122. case 'SMask':
  52123. if (isName(value, 'None')) {
  52124. gStateObj.push([
  52125. key,
  52126. false
  52127. ]);
  52128. break;
  52129. }
  52130. if (isDict(value)) {
  52131. promise = promise.then(function (dict) {
  52132. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  52133. }.bind(this, value));
  52134. gStateObj.push([
  52135. key,
  52136. true
  52137. ]);
  52138. } else {
  52139. warn('Unsupported SMask type');
  52140. }
  52141. break;
  52142. case 'OP':
  52143. case 'op':
  52144. case 'OPM':
  52145. case 'BG':
  52146. case 'BG2':
  52147. case 'UCR':
  52148. case 'UCR2':
  52149. case 'TR':
  52150. case 'TR2':
  52151. case 'HT':
  52152. case 'SM':
  52153. case 'SA':
  52154. case 'AIS':
  52155. case 'TK':
  52156. info('graphic state operator ' + key);
  52157. break;
  52158. default:
  52159. info('Unknown graphic state operator ' + key);
  52160. break;
  52161. }
  52162. }
  52163. return promise.then(function () {
  52164. if (gStateObj.length > 0) {
  52165. operatorList.addOp(OPS.setGState, [gStateObj]);
  52166. }
  52167. });
  52168. },
  52169. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52170. function errorFont() {
  52171. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52172. }
  52173. var fontRef;
  52174. if (font) {
  52175. assert(isRef(font));
  52176. fontRef = font;
  52177. } else {
  52178. var fontRes = resources.get('Font');
  52179. if (fontRes) {
  52180. fontRef = fontRes.getRaw(fontName);
  52181. } else {
  52182. warn('fontRes not available');
  52183. return errorFont();
  52184. }
  52185. }
  52186. if (!fontRef) {
  52187. warn('fontRef not available');
  52188. return errorFont();
  52189. }
  52190. if (this.fontCache.has(fontRef)) {
  52191. return this.fontCache.get(fontRef);
  52192. }
  52193. font = xref.fetchIfRef(fontRef);
  52194. if (!isDict(font)) {
  52195. return errorFont();
  52196. }
  52197. if (font.translated) {
  52198. return font.translated;
  52199. }
  52200. var fontCapability = createPromiseCapability();
  52201. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52202. var descriptor = preEvaluatedFont.descriptor;
  52203. var fontRefIsRef = isRef(fontRef), fontID;
  52204. if (fontRefIsRef) {
  52205. fontID = fontRef.toString();
  52206. }
  52207. if (isDict(descriptor)) {
  52208. if (!descriptor.fontAliases) {
  52209. descriptor.fontAliases = Object.create(null);
  52210. }
  52211. var fontAliases = descriptor.fontAliases;
  52212. var hash = preEvaluatedFont.hash;
  52213. if (fontAliases[hash]) {
  52214. var aliasFontRef = fontAliases[hash].aliasRef;
  52215. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52216. this.fontCache.putAlias(fontRef, aliasFontRef);
  52217. return this.fontCache.get(fontRef);
  52218. }
  52219. } else {
  52220. fontAliases[hash] = { fontID: Font.getFontID() };
  52221. }
  52222. if (fontRefIsRef) {
  52223. fontAliases[hash].aliasRef = fontRef;
  52224. }
  52225. fontID = fontAliases[hash].fontID;
  52226. }
  52227. if (fontRefIsRef) {
  52228. this.fontCache.put(fontRef, fontCapability.promise);
  52229. } else {
  52230. if (!fontID) {
  52231. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  52232. }
  52233. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52234. }
  52235. assert(fontID, 'The "fontID" must be defined.');
  52236. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52237. font.translated = fontCapability.promise;
  52238. var translatedPromise;
  52239. try {
  52240. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52241. } catch (e) {
  52242. translatedPromise = Promise.reject(e);
  52243. }
  52244. var self = this;
  52245. translatedPromise.then(function (translatedFont) {
  52246. if (translatedFont.fontType !== undefined) {
  52247. var xrefFontStats = xref.stats.fontTypes;
  52248. xrefFontStats[translatedFont.fontType] = true;
  52249. }
  52250. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52251. }, function (reason) {
  52252. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52253. try {
  52254. var descriptor = preEvaluatedFont.descriptor;
  52255. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52256. var subtype = fontFile3 && fontFile3.get('Subtype');
  52257. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52258. var xrefFontStats = xref.stats.fontTypes;
  52259. xrefFontStats[fontType] = true;
  52260. } catch (ex) {
  52261. }
  52262. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52263. });
  52264. return fontCapability.promise;
  52265. },
  52266. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52267. var lastIndex = operatorList.length - 1;
  52268. if (!args) {
  52269. args = [];
  52270. }
  52271. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52272. operatorList.addOp(OPS.constructPath, [
  52273. [fn],
  52274. args
  52275. ]);
  52276. } else {
  52277. var opArgs = operatorList.argsArray[lastIndex];
  52278. opArgs[0].push(fn);
  52279. Array.prototype.push.apply(opArgs[1], args);
  52280. }
  52281. },
  52282. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52283. var patternName = args[args.length - 1];
  52284. var pattern;
  52285. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52286. var dict = isStream(pattern) ? pattern.dict : pattern;
  52287. var typeNum = dict.get('PatternType');
  52288. if (typeNum === TILING_PATTERN) {
  52289. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52290. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52291. } else if (typeNum === SHADING_PATTERN) {
  52292. var shading = dict.get('Shading');
  52293. var matrix = dict.getArray('Matrix');
  52294. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52295. operatorList.addOp(fn, pattern.getIR());
  52296. return Promise.resolve();
  52297. } else {
  52298. return Promise.reject('Unknown PatternType: ' + typeNum);
  52299. }
  52300. }
  52301. operatorList.addOp(fn, args);
  52302. return Promise.resolve();
  52303. },
  52304. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52305. var self = this;
  52306. var xref = this.xref;
  52307. var imageCache = Object.create(null);
  52308. assert(operatorList);
  52309. resources = resources || Dict.empty;
  52310. var xobjs = resources.get('XObject') || Dict.empty;
  52311. var patterns = resources.get('Pattern') || Dict.empty;
  52312. var stateManager = new StateManager(initialState || new EvalState());
  52313. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52314. var timeSlotManager = new TimeSlotManager();
  52315. return new Promise(function promiseBody(resolve, reject) {
  52316. var next = function (promise) {
  52317. promise.then(function () {
  52318. try {
  52319. promiseBody(resolve, reject);
  52320. } catch (ex) {
  52321. reject(ex);
  52322. }
  52323. }, reject);
  52324. };
  52325. task.ensureNotTerminated();
  52326. timeSlotManager.reset();
  52327. var stop, operation = {}, i, ii, cs;
  52328. while (!(stop = timeSlotManager.check())) {
  52329. operation.args = null;
  52330. if (!preprocessor.read(operation)) {
  52331. break;
  52332. }
  52333. var args = operation.args;
  52334. var fn = operation.fn;
  52335. switch (fn | 0) {
  52336. case OPS.paintXObject:
  52337. if (args[0].code) {
  52338. break;
  52339. }
  52340. var name = args[0].name;
  52341. if (!name) {
  52342. warn('XObject must be referred to by name.');
  52343. continue;
  52344. }
  52345. if (imageCache[name] !== undefined) {
  52346. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52347. args = null;
  52348. continue;
  52349. }
  52350. var xobj = xobjs.get(name);
  52351. if (xobj) {
  52352. assert(isStream(xobj), 'XObject should be a stream');
  52353. var type = xobj.dict.get('Subtype');
  52354. assert(isName(type), 'XObject should have a Name subtype');
  52355. if (type.name === 'Form') {
  52356. stateManager.save();
  52357. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52358. stateManager.restore();
  52359. }));
  52360. return;
  52361. } else if (type.name === 'Image') {
  52362. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52363. args = null;
  52364. continue;
  52365. } else if (type.name === 'PS') {
  52366. info('Ignored XObject subtype PS');
  52367. continue;
  52368. } else {
  52369. error('Unhandled XObject subtype ' + type.name);
  52370. }
  52371. }
  52372. break;
  52373. case OPS.setFont:
  52374. var fontSize = args[1];
  52375. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52376. operatorList.addDependency(loadedName);
  52377. operatorList.addOp(OPS.setFont, [
  52378. loadedName,
  52379. fontSize
  52380. ]);
  52381. }));
  52382. return;
  52383. case OPS.endInlineImage:
  52384. var cacheKey = args[0].cacheKey;
  52385. if (cacheKey) {
  52386. var cacheEntry = imageCache[cacheKey];
  52387. if (cacheEntry !== undefined) {
  52388. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52389. args = null;
  52390. continue;
  52391. }
  52392. }
  52393. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52394. args = null;
  52395. continue;
  52396. case OPS.showText:
  52397. args[0] = self.handleText(args[0], stateManager.state);
  52398. break;
  52399. case OPS.showSpacedText:
  52400. var arr = args[0];
  52401. var combinedGlyphs = [];
  52402. var arrLength = arr.length;
  52403. var state = stateManager.state;
  52404. for (i = 0; i < arrLength; ++i) {
  52405. var arrItem = arr[i];
  52406. if (isString(arrItem)) {
  52407. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52408. } else if (isNum(arrItem)) {
  52409. combinedGlyphs.push(arrItem);
  52410. }
  52411. }
  52412. args[0] = combinedGlyphs;
  52413. fn = OPS.showText;
  52414. break;
  52415. case OPS.nextLineShowText:
  52416. operatorList.addOp(OPS.nextLine);
  52417. args[0] = self.handleText(args[0], stateManager.state);
  52418. fn = OPS.showText;
  52419. break;
  52420. case OPS.nextLineSetSpacingShowText:
  52421. operatorList.addOp(OPS.nextLine);
  52422. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52423. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52424. args[0] = self.handleText(args[0], stateManager.state);
  52425. fn = OPS.showText;
  52426. break;
  52427. case OPS.setTextRenderingMode:
  52428. stateManager.state.textRenderingMode = args[0];
  52429. break;
  52430. case OPS.setFillColorSpace:
  52431. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52432. continue;
  52433. case OPS.setStrokeColorSpace:
  52434. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52435. continue;
  52436. case OPS.setFillColor:
  52437. cs = stateManager.state.fillColorSpace;
  52438. args = cs.getRgb(args, 0);
  52439. fn = OPS.setFillRGBColor;
  52440. break;
  52441. case OPS.setStrokeColor:
  52442. cs = stateManager.state.strokeColorSpace;
  52443. args = cs.getRgb(args, 0);
  52444. fn = OPS.setStrokeRGBColor;
  52445. break;
  52446. case OPS.setFillGray:
  52447. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52448. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52449. fn = OPS.setFillRGBColor;
  52450. break;
  52451. case OPS.setStrokeGray:
  52452. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52453. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52454. fn = OPS.setStrokeRGBColor;
  52455. break;
  52456. case OPS.setFillCMYKColor:
  52457. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52458. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52459. fn = OPS.setFillRGBColor;
  52460. break;
  52461. case OPS.setStrokeCMYKColor:
  52462. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52463. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52464. fn = OPS.setStrokeRGBColor;
  52465. break;
  52466. case OPS.setFillRGBColor:
  52467. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52468. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52469. break;
  52470. case OPS.setStrokeRGBColor:
  52471. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52472. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52473. break;
  52474. case OPS.setFillColorN:
  52475. cs = stateManager.state.fillColorSpace;
  52476. if (cs.name === 'Pattern') {
  52477. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52478. return;
  52479. }
  52480. args = cs.getRgb(args, 0);
  52481. fn = OPS.setFillRGBColor;
  52482. break;
  52483. case OPS.setStrokeColorN:
  52484. cs = stateManager.state.strokeColorSpace;
  52485. if (cs.name === 'Pattern') {
  52486. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52487. return;
  52488. }
  52489. args = cs.getRgb(args, 0);
  52490. fn = OPS.setStrokeRGBColor;
  52491. break;
  52492. case OPS.shadingFill:
  52493. var shadingRes = resources.get('Shading');
  52494. if (!shadingRes) {
  52495. error('No shading resource found');
  52496. }
  52497. var shading = shadingRes.get(args[0].name);
  52498. if (!shading) {
  52499. error('No shading object found');
  52500. }
  52501. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52502. var patternIR = shadingFill.getIR();
  52503. args = [patternIR];
  52504. fn = OPS.shadingFill;
  52505. break;
  52506. case OPS.setGState:
  52507. var dictName = args[0];
  52508. var extGState = resources.get('ExtGState');
  52509. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52510. break;
  52511. }
  52512. var gState = extGState.get(dictName.name);
  52513. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52514. return;
  52515. case OPS.moveTo:
  52516. case OPS.lineTo:
  52517. case OPS.curveTo:
  52518. case OPS.curveTo2:
  52519. case OPS.curveTo3:
  52520. case OPS.closePath:
  52521. self.buildPath(operatorList, fn, args);
  52522. continue;
  52523. case OPS.rectangle:
  52524. self.buildPath(operatorList, fn, args);
  52525. continue;
  52526. case OPS.markPoint:
  52527. case OPS.markPointProps:
  52528. case OPS.beginMarkedContent:
  52529. case OPS.beginMarkedContentProps:
  52530. case OPS.endMarkedContent:
  52531. case OPS.beginCompat:
  52532. case OPS.endCompat:
  52533. continue;
  52534. default:
  52535. if (args !== null) {
  52536. for (i = 0, ii = args.length; i < ii; i++) {
  52537. if (args[i] instanceof Dict) {
  52538. break;
  52539. }
  52540. }
  52541. if (i < ii) {
  52542. warn('getOperatorList - ignoring operator: ' + fn);
  52543. continue;
  52544. }
  52545. }
  52546. }
  52547. operatorList.addOp(fn, args);
  52548. }
  52549. if (stop) {
  52550. next(deferred);
  52551. return;
  52552. }
  52553. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52554. operatorList.addOp(OPS.restore, []);
  52555. }
  52556. resolve();
  52557. });
  52558. },
  52559. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52560. stateManager = stateManager || new StateManager(new TextState());
  52561. var WhitespaceRegexp = /\s/g;
  52562. var textContent = {
  52563. items: [],
  52564. styles: Object.create(null)
  52565. };
  52566. var textContentItem = {
  52567. initialized: false,
  52568. str: [],
  52569. width: 0,
  52570. height: 0,
  52571. vertical: false,
  52572. lastAdvanceWidth: 0,
  52573. lastAdvanceHeight: 0,
  52574. textAdvanceScale: 0,
  52575. spaceWidth: 0,
  52576. fakeSpaceMin: Infinity,
  52577. fakeMultiSpaceMin: Infinity,
  52578. fakeMultiSpaceMax: -0,
  52579. textRunBreakAllowed: false,
  52580. transform: null,
  52581. fontName: null
  52582. };
  52583. var SPACE_FACTOR = 0.3;
  52584. var MULTI_SPACE_FACTOR = 1.5;
  52585. var MULTI_SPACE_FACTOR_MAX = 4;
  52586. var self = this;
  52587. var xref = this.xref;
  52588. resources = xref.fetchIfRef(resources) || Dict.empty;
  52589. var xobjs = null;
  52590. var xobjsCache = Object.create(null);
  52591. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52592. var textState;
  52593. function ensureTextContentItem() {
  52594. if (textContentItem.initialized) {
  52595. return textContentItem;
  52596. }
  52597. var font = textState.font;
  52598. if (!(font.loadedName in textContent.styles)) {
  52599. textContent.styles[font.loadedName] = {
  52600. fontFamily: font.fallbackName,
  52601. ascent: font.ascent,
  52602. descent: font.descent,
  52603. vertical: font.vertical
  52604. };
  52605. }
  52606. textContentItem.fontName = font.loadedName;
  52607. var tsm = [
  52608. textState.fontSize * textState.textHScale,
  52609. 0,
  52610. 0,
  52611. textState.fontSize,
  52612. 0,
  52613. textState.textRise
  52614. ];
  52615. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52616. var glyphHeight = font.bbox[3] - font.bbox[1];
  52617. if (glyphHeight > 0) {
  52618. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52619. tsm[3] *= glyphHeight;
  52620. }
  52621. }
  52622. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52623. textContentItem.transform = trm;
  52624. if (!font.vertical) {
  52625. textContentItem.width = 0;
  52626. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52627. textContentItem.vertical = false;
  52628. } else {
  52629. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52630. textContentItem.height = 0;
  52631. textContentItem.vertical = true;
  52632. }
  52633. var a = textState.textLineMatrix[0];
  52634. var b = textState.textLineMatrix[1];
  52635. var scaleLineX = Math.sqrt(a * a + b * b);
  52636. a = textState.ctm[0];
  52637. b = textState.ctm[1];
  52638. var scaleCtmX = Math.sqrt(a * a + b * b);
  52639. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52640. textContentItem.lastAdvanceWidth = 0;
  52641. textContentItem.lastAdvanceHeight = 0;
  52642. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52643. if (spaceWidth) {
  52644. textContentItem.spaceWidth = spaceWidth;
  52645. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52646. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52647. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52648. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52649. } else {
  52650. textContentItem.spaceWidth = 0;
  52651. textContentItem.fakeSpaceMin = Infinity;
  52652. textContentItem.fakeMultiSpaceMin = Infinity;
  52653. textContentItem.fakeMultiSpaceMax = 0;
  52654. textContentItem.textRunBreakAllowed = false;
  52655. }
  52656. textContentItem.initialized = true;
  52657. return textContentItem;
  52658. }
  52659. function replaceWhitespace(str) {
  52660. var i = 0, ii = str.length, code;
  52661. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52662. i++;
  52663. }
  52664. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52665. }
  52666. function runBidiTransform(textChunk) {
  52667. var str = textChunk.str.join('');
  52668. var bidiResult = bidi(str, -1, textChunk.vertical);
  52669. return {
  52670. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52671. dir: bidiResult.dir,
  52672. width: textChunk.width,
  52673. height: textChunk.height,
  52674. transform: textChunk.transform,
  52675. fontName: textChunk.fontName
  52676. };
  52677. }
  52678. function handleSetFont(fontName, fontRef) {
  52679. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52680. textState.font = translated.font;
  52681. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52682. });
  52683. }
  52684. function buildTextContentItem(chars) {
  52685. var font = textState.font;
  52686. var textChunk = ensureTextContentItem();
  52687. var width = 0;
  52688. var height = 0;
  52689. var glyphs = font.charsToGlyphs(chars);
  52690. var defaultVMetrics = font.defaultVMetrics;
  52691. for (var i = 0; i < glyphs.length; i++) {
  52692. var glyph = glyphs[i];
  52693. var vMetricX = null;
  52694. var vMetricY = null;
  52695. var glyphWidth = null;
  52696. if (font.vertical) {
  52697. if (glyph.vmetric) {
  52698. glyphWidth = glyph.vmetric[0];
  52699. vMetricX = glyph.vmetric[1];
  52700. vMetricY = glyph.vmetric[2];
  52701. } else {
  52702. glyphWidth = glyph.width;
  52703. vMetricX = glyph.width * 0.5;
  52704. vMetricY = defaultVMetrics[2];
  52705. }
  52706. } else {
  52707. glyphWidth = glyph.width;
  52708. }
  52709. var glyphUnicode = glyph.unicode;
  52710. var NormalizedUnicodes = getNormalizedUnicodes();
  52711. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52712. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52713. }
  52714. glyphUnicode = reverseIfRtl(glyphUnicode);
  52715. var charSpacing = textState.charSpacing;
  52716. if (glyph.isSpace) {
  52717. var wordSpacing = textState.wordSpacing;
  52718. charSpacing += wordSpacing;
  52719. if (wordSpacing > 0) {
  52720. addFakeSpaces(wordSpacing, textChunk.str);
  52721. }
  52722. }
  52723. var tx = 0;
  52724. var ty = 0;
  52725. if (!font.vertical) {
  52726. var w0 = glyphWidth * textState.fontMatrix[0];
  52727. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52728. width += tx;
  52729. } else {
  52730. var w1 = glyphWidth * textState.fontMatrix[0];
  52731. ty = w1 * textState.fontSize + charSpacing;
  52732. height += ty;
  52733. }
  52734. textState.translateTextMatrix(tx, ty);
  52735. textChunk.str.push(glyphUnicode);
  52736. }
  52737. if (!font.vertical) {
  52738. textChunk.lastAdvanceWidth = width;
  52739. textChunk.width += width * textChunk.textAdvanceScale;
  52740. } else {
  52741. textChunk.lastAdvanceHeight = height;
  52742. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  52743. }
  52744. return textChunk;
  52745. }
  52746. function addFakeSpaces(width, strBuf) {
  52747. if (width < textContentItem.fakeSpaceMin) {
  52748. return;
  52749. }
  52750. if (width < textContentItem.fakeMultiSpaceMin) {
  52751. strBuf.push(' ');
  52752. return;
  52753. }
  52754. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52755. while (fakeSpaces-- > 0) {
  52756. strBuf.push(' ');
  52757. }
  52758. }
  52759. function flushTextContentItem() {
  52760. if (!textContentItem.initialized) {
  52761. return;
  52762. }
  52763. textContent.items.push(runBidiTransform(textContentItem));
  52764. textContentItem.initialized = false;
  52765. textContentItem.str.length = 0;
  52766. }
  52767. var timeSlotManager = new TimeSlotManager();
  52768. return new Promise(function promiseBody(resolve, reject) {
  52769. var next = function (promise) {
  52770. promise.then(function () {
  52771. try {
  52772. promiseBody(resolve, reject);
  52773. } catch (ex) {
  52774. reject(ex);
  52775. }
  52776. }, reject);
  52777. };
  52778. task.ensureNotTerminated();
  52779. timeSlotManager.reset();
  52780. var stop, operation = {}, args = [];
  52781. while (!(stop = timeSlotManager.check())) {
  52782. args.length = 0;
  52783. operation.args = args;
  52784. if (!preprocessor.read(operation)) {
  52785. break;
  52786. }
  52787. textState = stateManager.state;
  52788. var fn = operation.fn;
  52789. args = operation.args;
  52790. var advance, diff;
  52791. switch (fn | 0) {
  52792. case OPS.setFont:
  52793. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52794. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52795. break;
  52796. }
  52797. flushTextContentItem();
  52798. textState.fontName = fontNameArg;
  52799. textState.fontSize = fontSizeArg;
  52800. next(handleSetFont(fontNameArg, null));
  52801. return;
  52802. case OPS.setTextRise:
  52803. flushTextContentItem();
  52804. textState.textRise = args[0];
  52805. break;
  52806. case OPS.setHScale:
  52807. flushTextContentItem();
  52808. textState.textHScale = args[0] / 100;
  52809. break;
  52810. case OPS.setLeading:
  52811. flushTextContentItem();
  52812. textState.leading = args[0];
  52813. break;
  52814. case OPS.moveText:
  52815. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52816. advance = args[0] - args[1];
  52817. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52818. textState.translateTextLineMatrix(args[0], args[1]);
  52819. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52820. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52821. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52822. addFakeSpaces(diff, textContentItem.str);
  52823. break;
  52824. }
  52825. flushTextContentItem();
  52826. textState.translateTextLineMatrix(args[0], args[1]);
  52827. textState.textMatrix = textState.textLineMatrix.slice();
  52828. break;
  52829. case OPS.setLeadingMoveText:
  52830. flushTextContentItem();
  52831. textState.leading = -args[1];
  52832. textState.translateTextLineMatrix(args[0], args[1]);
  52833. textState.textMatrix = textState.textLineMatrix.slice();
  52834. break;
  52835. case OPS.nextLine:
  52836. flushTextContentItem();
  52837. textState.carriageReturn();
  52838. break;
  52839. case OPS.setTextMatrix:
  52840. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52841. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52842. textState.translateTextLineMatrix(advance.width, advance.height);
  52843. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52844. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52845. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52846. addFakeSpaces(diff, textContentItem.str);
  52847. break;
  52848. }
  52849. flushTextContentItem();
  52850. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52851. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52852. break;
  52853. case OPS.setCharSpacing:
  52854. textState.charSpacing = args[0];
  52855. break;
  52856. case OPS.setWordSpacing:
  52857. textState.wordSpacing = args[0];
  52858. break;
  52859. case OPS.beginText:
  52860. flushTextContentItem();
  52861. textState.textMatrix = IDENTITY_MATRIX.slice();
  52862. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52863. break;
  52864. case OPS.showSpacedText:
  52865. var items = args[0];
  52866. var offset;
  52867. for (var j = 0, jj = items.length; j < jj; j++) {
  52868. if (typeof items[j] === 'string') {
  52869. buildTextContentItem(items[j]);
  52870. } else if (isNum(items[j])) {
  52871. ensureTextContentItem();
  52872. advance = items[j] * textState.fontSize / 1000;
  52873. var breakTextRun = false;
  52874. if (textState.font.vertical) {
  52875. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  52876. textState.translateTextMatrix(0, advance);
  52877. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52878. if (!breakTextRun) {
  52879. textContentItem.height += offset;
  52880. }
  52881. } else {
  52882. advance = -advance;
  52883. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  52884. textState.translateTextMatrix(advance, 0);
  52885. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52886. if (!breakTextRun) {
  52887. textContentItem.width += offset;
  52888. }
  52889. }
  52890. if (breakTextRun) {
  52891. flushTextContentItem();
  52892. } else if (advance > 0) {
  52893. addFakeSpaces(advance, textContentItem.str);
  52894. }
  52895. }
  52896. }
  52897. break;
  52898. case OPS.showText:
  52899. buildTextContentItem(args[0]);
  52900. break;
  52901. case OPS.nextLineShowText:
  52902. flushTextContentItem();
  52903. textState.carriageReturn();
  52904. buildTextContentItem(args[0]);
  52905. break;
  52906. case OPS.nextLineSetSpacingShowText:
  52907. flushTextContentItem();
  52908. textState.wordSpacing = args[0];
  52909. textState.charSpacing = args[1];
  52910. textState.carriageReturn();
  52911. buildTextContentItem(args[2]);
  52912. break;
  52913. case OPS.paintXObject:
  52914. flushTextContentItem();
  52915. if (args[0].code) {
  52916. break;
  52917. }
  52918. if (!xobjs) {
  52919. xobjs = resources.get('XObject') || Dict.empty;
  52920. }
  52921. var name = args[0].name;
  52922. if (xobjsCache.key === name) {
  52923. if (xobjsCache.texts) {
  52924. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52925. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52926. }
  52927. break;
  52928. }
  52929. var xobj = xobjs.get(name);
  52930. if (!xobj) {
  52931. break;
  52932. }
  52933. assert(isStream(xobj), 'XObject should be a stream');
  52934. var type = xobj.dict.get('Subtype');
  52935. assert(isName(type), 'XObject should have a Name subtype');
  52936. if ('Form' !== type.name) {
  52937. xobjsCache.key = name;
  52938. xobjsCache.texts = null;
  52939. break;
  52940. }
  52941. stateManager.save();
  52942. var matrix = xobj.dict.getArray('Matrix');
  52943. if (isArray(matrix) && matrix.length === 6) {
  52944. stateManager.transform(matrix);
  52945. }
  52946. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52947. Util.appendToArray(textContent.items, formTextContent.items);
  52948. Util.extendObj(textContent.styles, formTextContent.styles);
  52949. stateManager.restore();
  52950. xobjsCache.key = name;
  52951. xobjsCache.texts = formTextContent;
  52952. }));
  52953. return;
  52954. case OPS.setGState:
  52955. flushTextContentItem();
  52956. var dictName = args[0];
  52957. var extGState = resources.get('ExtGState');
  52958. if (!isDict(extGState) || !isName(dictName)) {
  52959. break;
  52960. }
  52961. var gState = extGState.get(dictName.name);
  52962. if (!isDict(gState)) {
  52963. break;
  52964. }
  52965. var gStateFont = gState.get('Font');
  52966. if (gStateFont) {
  52967. textState.fontName = null;
  52968. textState.fontSize = gStateFont[1];
  52969. next(handleSetFont(null, gStateFont[0]));
  52970. return;
  52971. }
  52972. break;
  52973. }
  52974. }
  52975. if (stop) {
  52976. next(deferred);
  52977. return;
  52978. }
  52979. flushTextContentItem();
  52980. resolve(textContent);
  52981. });
  52982. },
  52983. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52984. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52985. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52986. if (properties.composite) {
  52987. var cidSystemInfo = dict.get('CIDSystemInfo');
  52988. if (isDict(cidSystemInfo)) {
  52989. properties.cidSystemInfo = {
  52990. registry: cidSystemInfo.get('Registry'),
  52991. ordering: cidSystemInfo.get('Ordering'),
  52992. supplement: cidSystemInfo.get('Supplement')
  52993. };
  52994. }
  52995. var cidToGidMap = dict.get('CIDToGIDMap');
  52996. if (isStream(cidToGidMap)) {
  52997. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52998. }
  52999. }
  53000. var differences = [];
  53001. var baseEncodingName = null;
  53002. var encoding;
  53003. if (dict.has('Encoding')) {
  53004. encoding = dict.get('Encoding');
  53005. if (isDict(encoding)) {
  53006. baseEncodingName = encoding.get('BaseEncoding');
  53007. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  53008. if (encoding.has('Differences')) {
  53009. var diffEncoding = encoding.get('Differences');
  53010. var index = 0;
  53011. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  53012. var data = xref.fetchIfRef(diffEncoding[j]);
  53013. if (isNum(data)) {
  53014. index = data;
  53015. } else if (isName(data)) {
  53016. differences[index++] = data.name;
  53017. } else {
  53018. error('Invalid entry in \'Differences\' array: ' + data);
  53019. }
  53020. }
  53021. }
  53022. } else if (isName(encoding)) {
  53023. baseEncodingName = encoding.name;
  53024. } else {
  53025. error('Encoding is not a Name nor a Dict');
  53026. }
  53027. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  53028. baseEncodingName = null;
  53029. }
  53030. }
  53031. if (baseEncodingName) {
  53032. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  53033. } else {
  53034. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  53035. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  53036. encoding = StandardEncoding;
  53037. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  53038. encoding = WinAnsiEncoding;
  53039. }
  53040. if (isSymbolicFont) {
  53041. encoding = MacRomanEncoding;
  53042. if (!properties.file) {
  53043. if (/Symbol/i.test(properties.name)) {
  53044. encoding = SymbolSetEncoding;
  53045. } else if (/Dingbats/i.test(properties.name)) {
  53046. encoding = ZapfDingbatsEncoding;
  53047. }
  53048. }
  53049. }
  53050. properties.defaultEncoding = encoding;
  53051. }
  53052. properties.differences = differences;
  53053. properties.baseEncodingName = baseEncodingName;
  53054. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  53055. properties.dict = dict;
  53056. return toUnicodePromise.then(function (toUnicode) {
  53057. properties.toUnicode = toUnicode;
  53058. return this.buildToUnicode(properties);
  53059. }.bind(this)).then(function (toUnicode) {
  53060. properties.toUnicode = toUnicode;
  53061. return properties;
  53062. });
  53063. },
  53064. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  53065. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  53066. if (properties.hasIncludedToUnicodeMap) {
  53067. return Promise.resolve(properties.toUnicode);
  53068. }
  53069. var toUnicode, charcode, glyphName;
  53070. if (!properties.composite)
  53071. {
  53072. toUnicode = [];
  53073. var encoding = properties.defaultEncoding.slice();
  53074. var baseEncodingName = properties.baseEncodingName;
  53075. var differences = properties.differences;
  53076. for (charcode in differences) {
  53077. glyphName = differences[charcode];
  53078. if (glyphName === '.notdef') {
  53079. continue;
  53080. }
  53081. encoding[charcode] = glyphName;
  53082. }
  53083. var glyphsUnicodeMap = getGlyphsUnicode();
  53084. for (charcode in encoding) {
  53085. glyphName = encoding[charcode];
  53086. if (glyphName === '') {
  53087. continue;
  53088. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  53089. var code = 0;
  53090. switch (glyphName[0]) {
  53091. case 'G':
  53092. if (glyphName.length === 3) {
  53093. code = parseInt(glyphName.substr(1), 16);
  53094. }
  53095. break;
  53096. case 'g':
  53097. if (glyphName.length === 5) {
  53098. code = parseInt(glyphName.substr(1), 16);
  53099. }
  53100. break;
  53101. case 'C':
  53102. case 'c':
  53103. if (glyphName.length >= 3) {
  53104. code = +glyphName.substr(1);
  53105. }
  53106. break;
  53107. default:
  53108. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  53109. if (unicode !== -1) {
  53110. code = unicode;
  53111. }
  53112. }
  53113. if (code) {
  53114. if (baseEncodingName && code === +charcode) {
  53115. var baseEncoding = getEncoding(baseEncodingName);
  53116. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  53117. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  53118. continue;
  53119. }
  53120. }
  53121. toUnicode[charcode] = String.fromCharCode(code);
  53122. }
  53123. continue;
  53124. }
  53125. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  53126. }
  53127. return Promise.resolve(new ToUnicodeMap(toUnicode));
  53128. }
  53129. 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'))) {
  53130. var registry = properties.cidSystemInfo.registry;
  53131. var ordering = properties.cidSystemInfo.ordering;
  53132. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  53133. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  53134. var cMap = properties.cMap;
  53135. toUnicode = [];
  53136. cMap.forEach(function (charcode, cid) {
  53137. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  53138. var ucs2 = ucs2CMap.lookup(cid);
  53139. if (ucs2) {
  53140. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  53141. }
  53142. });
  53143. return new ToUnicodeMap(toUnicode);
  53144. });
  53145. }
  53146. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  53147. },
  53148. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  53149. var cmapObj = toUnicode;
  53150. if (isName(cmapObj)) {
  53151. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53152. if (cmap instanceof IdentityCMap) {
  53153. return new IdentityToUnicodeMap(0, 0xFFFF);
  53154. }
  53155. return new ToUnicodeMap(cmap.getMap());
  53156. });
  53157. } else if (isStream(cmapObj)) {
  53158. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53159. if (cmap instanceof IdentityCMap) {
  53160. return new IdentityToUnicodeMap(0, 0xFFFF);
  53161. }
  53162. var map = new Array(cmap.length);
  53163. cmap.forEach(function (charCode, token) {
  53164. var str = [];
  53165. for (var k = 0; k < token.length; k += 2) {
  53166. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53167. if ((w1 & 0xF800) !== 0xD800) {
  53168. str.push(w1);
  53169. continue;
  53170. }
  53171. k += 2;
  53172. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53173. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53174. }
  53175. map[charCode] = String.fromCharCode.apply(String, str);
  53176. });
  53177. return new ToUnicodeMap(map);
  53178. });
  53179. }
  53180. return Promise.resolve(null);
  53181. },
  53182. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53183. var glyphsData = cidToGidStream.getBytes();
  53184. var result = [];
  53185. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53186. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53187. if (glyphID === 0) {
  53188. continue;
  53189. }
  53190. var code = j >> 1;
  53191. result[code] = glyphID;
  53192. }
  53193. return result;
  53194. },
  53195. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53196. var glyphsWidths = [];
  53197. var defaultWidth = 0;
  53198. var glyphsVMetrics = [];
  53199. var defaultVMetrics;
  53200. var i, ii, j, jj, start, code, widths;
  53201. if (properties.composite) {
  53202. defaultWidth = dict.get('DW') || 1000;
  53203. widths = dict.get('W');
  53204. if (widths) {
  53205. for (i = 0, ii = widths.length; i < ii; i++) {
  53206. start = xref.fetchIfRef(widths[i++]);
  53207. code = xref.fetchIfRef(widths[i]);
  53208. if (isArray(code)) {
  53209. for (j = 0, jj = code.length; j < jj; j++) {
  53210. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  53211. }
  53212. } else {
  53213. var width = xref.fetchIfRef(widths[++i]);
  53214. for (j = start; j <= code; j++) {
  53215. glyphsWidths[j] = width;
  53216. }
  53217. }
  53218. }
  53219. }
  53220. if (properties.vertical) {
  53221. var vmetrics = dict.getArray('DW2') || [
  53222. 880,
  53223. -1000
  53224. ];
  53225. defaultVMetrics = [
  53226. vmetrics[1],
  53227. defaultWidth * 0.5,
  53228. vmetrics[0]
  53229. ];
  53230. vmetrics = dict.get('W2');
  53231. if (vmetrics) {
  53232. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53233. start = xref.fetchIfRef(vmetrics[i++]);
  53234. code = xref.fetchIfRef(vmetrics[i]);
  53235. if (isArray(code)) {
  53236. for (j = 0, jj = code.length; j < jj; j++) {
  53237. glyphsVMetrics[start++] = [
  53238. xref.fetchIfRef(code[j++]),
  53239. xref.fetchIfRef(code[j++]),
  53240. xref.fetchIfRef(code[j])
  53241. ];
  53242. }
  53243. } else {
  53244. var vmetric = [
  53245. xref.fetchIfRef(vmetrics[++i]),
  53246. xref.fetchIfRef(vmetrics[++i]),
  53247. xref.fetchIfRef(vmetrics[++i])
  53248. ];
  53249. for (j = start; j <= code; j++) {
  53250. glyphsVMetrics[j] = vmetric;
  53251. }
  53252. }
  53253. }
  53254. }
  53255. }
  53256. } else {
  53257. var firstChar = properties.firstChar;
  53258. widths = dict.get('Widths');
  53259. if (widths) {
  53260. j = firstChar;
  53261. for (i = 0, ii = widths.length; i < ii; i++) {
  53262. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  53263. }
  53264. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53265. } else {
  53266. var baseFontName = dict.get('BaseFont');
  53267. if (isName(baseFontName)) {
  53268. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53269. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53270. defaultWidth = metrics.defaultWidth;
  53271. }
  53272. }
  53273. }
  53274. var isMonospace = true;
  53275. var firstWidth = defaultWidth;
  53276. for (var glyph in glyphsWidths) {
  53277. var glyphWidth = glyphsWidths[glyph];
  53278. if (!glyphWidth) {
  53279. continue;
  53280. }
  53281. if (!firstWidth) {
  53282. firstWidth = glyphWidth;
  53283. continue;
  53284. }
  53285. if (firstWidth !== glyphWidth) {
  53286. isMonospace = false;
  53287. break;
  53288. }
  53289. }
  53290. if (isMonospace) {
  53291. properties.flags |= FontFlags.FixedPitch;
  53292. }
  53293. properties.defaultWidth = defaultWidth;
  53294. properties.widths = glyphsWidths;
  53295. properties.defaultVMetrics = defaultVMetrics;
  53296. properties.vmetrics = glyphsVMetrics;
  53297. },
  53298. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53299. var fontNameWoStyle = baseFontName.split('-')[0];
  53300. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53301. },
  53302. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53303. var defaultWidth = 0;
  53304. var widths = [];
  53305. var monospace = false;
  53306. var stdFontMap = getStdFontMap();
  53307. var lookupName = stdFontMap[name] || name;
  53308. var Metrics = getMetrics();
  53309. if (!(lookupName in Metrics)) {
  53310. if (this.isSerifFont(name)) {
  53311. lookupName = 'Times-Roman';
  53312. } else {
  53313. lookupName = 'Helvetica';
  53314. }
  53315. }
  53316. var glyphWidths = Metrics[lookupName];
  53317. if (isNum(glyphWidths)) {
  53318. defaultWidth = glyphWidths;
  53319. monospace = true;
  53320. } else {
  53321. widths = glyphWidths();
  53322. }
  53323. return {
  53324. defaultWidth: defaultWidth,
  53325. monospace: monospace,
  53326. widths: widths
  53327. };
  53328. },
  53329. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53330. var widths = Object.create(null);
  53331. var differences = properties.differences;
  53332. var encoding = properties.defaultEncoding;
  53333. for (var charCode = 0; charCode < 256; charCode++) {
  53334. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53335. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53336. continue;
  53337. }
  53338. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53339. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53340. continue;
  53341. }
  53342. }
  53343. return widths;
  53344. },
  53345. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53346. var baseDict = dict;
  53347. var type = dict.get('Subtype');
  53348. assert(isName(type), 'invalid font Subtype');
  53349. var composite = false;
  53350. var uint8array;
  53351. if (type.name === 'Type0') {
  53352. var df = dict.get('DescendantFonts');
  53353. if (!df) {
  53354. error('Descendant fonts are not specified');
  53355. }
  53356. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53357. type = dict.get('Subtype');
  53358. assert(isName(type), 'invalid font Subtype');
  53359. composite = true;
  53360. }
  53361. var descriptor = dict.get('FontDescriptor');
  53362. if (descriptor) {
  53363. var hash = new MurmurHash3_64();
  53364. var encoding = baseDict.getRaw('Encoding');
  53365. if (isName(encoding)) {
  53366. hash.update(encoding.name);
  53367. } else if (isRef(encoding)) {
  53368. hash.update(encoding.toString());
  53369. } else if (isDict(encoding)) {
  53370. var keys = encoding.getKeys();
  53371. for (var i = 0, ii = keys.length; i < ii; i++) {
  53372. var entry = encoding.getRaw(keys[i]);
  53373. if (isName(entry)) {
  53374. hash.update(entry.name);
  53375. } else if (isRef(entry)) {
  53376. hash.update(entry.toString());
  53377. } else if (isArray(entry)) {
  53378. hash.update(entry.length.toString());
  53379. }
  53380. }
  53381. }
  53382. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53383. if (isStream(toUnicode)) {
  53384. var stream = toUnicode.str || toUnicode;
  53385. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53386. hash.update(uint8array);
  53387. } else if (isName(toUnicode)) {
  53388. hash.update(toUnicode.name);
  53389. }
  53390. var widths = dict.get('Widths') || baseDict.get('Widths');
  53391. if (widths) {
  53392. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53393. hash.update(uint8array);
  53394. }
  53395. }
  53396. return {
  53397. descriptor: descriptor,
  53398. dict: dict,
  53399. baseDict: baseDict,
  53400. composite: composite,
  53401. type: type.name,
  53402. hash: hash ? hash.hexdigest() : ''
  53403. };
  53404. },
  53405. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53406. var baseDict = preEvaluatedFont.baseDict;
  53407. var dict = preEvaluatedFont.dict;
  53408. var composite = preEvaluatedFont.composite;
  53409. var descriptor = preEvaluatedFont.descriptor;
  53410. var type = preEvaluatedFont.type;
  53411. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53412. var cMapOptions = this.options.cMapOptions;
  53413. var properties;
  53414. if (!descriptor) {
  53415. if (type === 'Type3') {
  53416. descriptor = new Dict(null);
  53417. descriptor.set('FontName', Name.get(type));
  53418. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53419. } else {
  53420. var baseFontName = dict.get('BaseFont');
  53421. if (!isName(baseFontName)) {
  53422. error('Base font is not specified');
  53423. }
  53424. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53425. var metrics = this.getBaseFontMetrics(baseFontName);
  53426. var fontNameWoStyle = baseFontName.split('-')[0];
  53427. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53428. properties = {
  53429. type: type,
  53430. name: baseFontName,
  53431. widths: metrics.widths,
  53432. defaultWidth: metrics.defaultWidth,
  53433. flags: flags,
  53434. firstChar: 0,
  53435. lastChar: maxCharIndex
  53436. };
  53437. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53438. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53439. return new Font(baseFontName, null, properties);
  53440. }.bind(this));
  53441. }
  53442. }
  53443. var firstChar = dict.get('FirstChar') || 0;
  53444. var lastChar = dict.get('LastChar') || maxCharIndex;
  53445. var fontName = descriptor.get('FontName');
  53446. var baseFont = dict.get('BaseFont');
  53447. if (isString(fontName)) {
  53448. fontName = Name.get(fontName);
  53449. }
  53450. if (isString(baseFont)) {
  53451. baseFont = Name.get(baseFont);
  53452. }
  53453. if (type !== 'Type3') {
  53454. var fontNameStr = fontName && fontName.name;
  53455. var baseFontStr = baseFont && baseFont.name;
  53456. if (fontNameStr !== baseFontStr) {
  53457. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53458. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53459. fontName = baseFont;
  53460. }
  53461. }
  53462. }
  53463. fontName = fontName || baseFont;
  53464. assert(isName(fontName), 'invalid font name');
  53465. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53466. if (fontFile) {
  53467. if (fontFile.dict) {
  53468. var subtype = fontFile.dict.get('Subtype');
  53469. if (subtype) {
  53470. subtype = subtype.name;
  53471. }
  53472. var length1 = fontFile.dict.get('Length1');
  53473. var length2 = fontFile.dict.get('Length2');
  53474. var length3 = fontFile.dict.get('Length3');
  53475. }
  53476. }
  53477. properties = {
  53478. type: type,
  53479. name: fontName.name,
  53480. subtype: subtype,
  53481. file: fontFile,
  53482. length1: length1,
  53483. length2: length2,
  53484. length3: length3,
  53485. loadedName: baseDict.loadedName,
  53486. composite: composite,
  53487. wideChars: composite,
  53488. fixedPitch: false,
  53489. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53490. firstChar: firstChar || 0,
  53491. lastChar: lastChar || maxCharIndex,
  53492. bbox: descriptor.getArray('FontBBox'),
  53493. ascent: descriptor.get('Ascent'),
  53494. descent: descriptor.get('Descent'),
  53495. xHeight: descriptor.get('XHeight'),
  53496. capHeight: descriptor.get('CapHeight'),
  53497. flags: descriptor.get('Flags'),
  53498. italicAngle: descriptor.get('ItalicAngle'),
  53499. coded: false
  53500. };
  53501. var cMapPromise;
  53502. if (composite) {
  53503. var cidEncoding = baseDict.get('Encoding');
  53504. if (isName(cidEncoding)) {
  53505. properties.cidEncoding = cidEncoding.name;
  53506. }
  53507. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53508. properties.cMap = cMap;
  53509. properties.vertical = properties.cMap.vertical;
  53510. });
  53511. } else {
  53512. cMapPromise = Promise.resolve(undefined);
  53513. }
  53514. return cMapPromise.then(function () {
  53515. return this.extractDataStructures(dict, baseDict, xref, properties);
  53516. }.bind(this)).then(function (properties) {
  53517. this.extractWidths(dict, xref, descriptor, properties);
  53518. if (type === 'Type3') {
  53519. properties.isType3Font = true;
  53520. }
  53521. return new Font(fontName.name, fontFile, properties);
  53522. }.bind(this));
  53523. }
  53524. };
  53525. return PartialEvaluator;
  53526. }();
  53527. var TranslatedFont = function TranslatedFontClosure() {
  53528. function TranslatedFont(loadedName, font, dict) {
  53529. this.loadedName = loadedName;
  53530. this.font = font;
  53531. this.dict = dict;
  53532. this.type3Loaded = null;
  53533. this.sent = false;
  53534. }
  53535. TranslatedFont.prototype = {
  53536. send: function (handler) {
  53537. if (this.sent) {
  53538. return;
  53539. }
  53540. var fontData = this.font.exportData();
  53541. handler.send('commonobj', [
  53542. this.loadedName,
  53543. 'Font',
  53544. fontData
  53545. ]);
  53546. this.sent = true;
  53547. },
  53548. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53549. assert(this.font.isType3Font);
  53550. if (this.type3Loaded) {
  53551. return this.type3Loaded;
  53552. }
  53553. var translatedFont = this.font;
  53554. var loadCharProcsPromise = Promise.resolve();
  53555. var charProcs = this.dict.get('CharProcs');
  53556. var fontResources = this.dict.get('Resources') || resources;
  53557. var charProcKeys = charProcs.getKeys();
  53558. var charProcOperatorList = Object.create(null);
  53559. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53560. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53561. var glyphStream = charProcs.get(key);
  53562. var operatorList = new OperatorList();
  53563. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53564. charProcOperatorList[key] = operatorList.getIR();
  53565. parentOperatorList.addDependencies(operatorList.dependencies);
  53566. }, function (reason) {
  53567. warn('Type3 font resource \"' + key + '\" is not available');
  53568. var operatorList = new OperatorList();
  53569. charProcOperatorList[key] = operatorList.getIR();
  53570. });
  53571. }.bind(this, charProcKeys[i]));
  53572. }
  53573. this.type3Loaded = loadCharProcsPromise.then(function () {
  53574. translatedFont.charProcOperatorList = charProcOperatorList;
  53575. });
  53576. return this.type3Loaded;
  53577. }
  53578. };
  53579. return TranslatedFont;
  53580. }();
  53581. var OperatorList = function OperatorListClosure() {
  53582. var CHUNK_SIZE = 1000;
  53583. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53584. function getTransfers(queue) {
  53585. var transfers = [];
  53586. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53587. for (var i = 0, ii = queue.length; i < ii; i++) {
  53588. switch (fnArray[i]) {
  53589. case OPS.paintInlineImageXObject:
  53590. case OPS.paintInlineImageXObjectGroup:
  53591. case OPS.paintImageMaskXObject:
  53592. var arg = argsArray[i][0];
  53593. if (!arg.cached) {
  53594. transfers.push(arg.data.buffer);
  53595. }
  53596. break;
  53597. }
  53598. }
  53599. return transfers;
  53600. }
  53601. function OperatorList(intent, messageHandler, pageIndex) {
  53602. this.messageHandler = messageHandler;
  53603. this.fnArray = [];
  53604. this.argsArray = [];
  53605. this.dependencies = Object.create(null);
  53606. this._totalLength = 0;
  53607. this.pageIndex = pageIndex;
  53608. this.intent = intent;
  53609. }
  53610. OperatorList.prototype = {
  53611. get length() {
  53612. return this.argsArray.length;
  53613. },
  53614. get totalLength() {
  53615. return this._totalLength + this.length;
  53616. },
  53617. addOp: function (fn, args) {
  53618. this.fnArray.push(fn);
  53619. this.argsArray.push(args);
  53620. if (this.messageHandler) {
  53621. if (this.fnArray.length >= CHUNK_SIZE) {
  53622. this.flush();
  53623. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53624. this.flush();
  53625. }
  53626. }
  53627. },
  53628. addDependency: function (dependency) {
  53629. if (dependency in this.dependencies) {
  53630. return;
  53631. }
  53632. this.dependencies[dependency] = true;
  53633. this.addOp(OPS.dependency, [dependency]);
  53634. },
  53635. addDependencies: function (dependencies) {
  53636. for (var key in dependencies) {
  53637. this.addDependency(key);
  53638. }
  53639. },
  53640. addOpList: function (opList) {
  53641. Util.extendObj(this.dependencies, opList.dependencies);
  53642. for (var i = 0, ii = opList.length; i < ii; i++) {
  53643. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53644. }
  53645. },
  53646. getIR: function () {
  53647. return {
  53648. fnArray: this.fnArray,
  53649. argsArray: this.argsArray,
  53650. length: this.length
  53651. };
  53652. },
  53653. flush: function (lastChunk) {
  53654. if (this.intent !== 'oplist') {
  53655. new QueueOptimizer().optimize(this);
  53656. }
  53657. var transfers = getTransfers(this);
  53658. var length = this.length;
  53659. this._totalLength += length;
  53660. this.messageHandler.send('RenderPageChunk', {
  53661. operatorList: {
  53662. fnArray: this.fnArray,
  53663. argsArray: this.argsArray,
  53664. lastChunk: lastChunk,
  53665. length: length
  53666. },
  53667. pageIndex: this.pageIndex,
  53668. intent: this.intent
  53669. }, transfers);
  53670. this.dependencies = Object.create(null);
  53671. this.fnArray.length = 0;
  53672. this.argsArray.length = 0;
  53673. }
  53674. };
  53675. return OperatorList;
  53676. }();
  53677. var StateManager = function StateManagerClosure() {
  53678. function StateManager(initialState) {
  53679. this.state = initialState;
  53680. this.stateStack = [];
  53681. }
  53682. StateManager.prototype = {
  53683. save: function () {
  53684. var old = this.state;
  53685. this.stateStack.push(this.state);
  53686. this.state = old.clone();
  53687. },
  53688. restore: function () {
  53689. var prev = this.stateStack.pop();
  53690. if (prev) {
  53691. this.state = prev;
  53692. }
  53693. },
  53694. transform: function (args) {
  53695. this.state.ctm = Util.transform(this.state.ctm, args);
  53696. }
  53697. };
  53698. return StateManager;
  53699. }();
  53700. var TextState = function TextStateClosure() {
  53701. function TextState() {
  53702. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53703. this.fontName = null;
  53704. this.fontSize = 0;
  53705. this.font = null;
  53706. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53707. this.textMatrix = IDENTITY_MATRIX.slice();
  53708. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53709. this.charSpacing = 0;
  53710. this.wordSpacing = 0;
  53711. this.leading = 0;
  53712. this.textHScale = 1;
  53713. this.textRise = 0;
  53714. }
  53715. TextState.prototype = {
  53716. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53717. var m = this.textMatrix;
  53718. m[0] = a;
  53719. m[1] = b;
  53720. m[2] = c;
  53721. m[3] = d;
  53722. m[4] = e;
  53723. m[5] = f;
  53724. },
  53725. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53726. var m = this.textLineMatrix;
  53727. m[0] = a;
  53728. m[1] = b;
  53729. m[2] = c;
  53730. m[3] = d;
  53731. m[4] = e;
  53732. m[5] = f;
  53733. },
  53734. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53735. var m = this.textMatrix;
  53736. m[4] = m[0] * x + m[2] * y + m[4];
  53737. m[5] = m[1] * x + m[3] * y + m[5];
  53738. },
  53739. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53740. var m = this.textLineMatrix;
  53741. m[4] = m[0] * x + m[2] * y + m[4];
  53742. m[5] = m[1] * x + m[3] * y + m[5];
  53743. },
  53744. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53745. var font = this.font;
  53746. if (!font) {
  53747. return null;
  53748. }
  53749. var m = this.textLineMatrix;
  53750. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53751. return null;
  53752. }
  53753. var txDiff = e - m[4], tyDiff = f - m[5];
  53754. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53755. return null;
  53756. }
  53757. var tx, ty, denominator = a * d - b * c;
  53758. if (font.vertical) {
  53759. tx = -tyDiff * c / denominator;
  53760. ty = tyDiff * a / denominator;
  53761. } else {
  53762. tx = txDiff * d / denominator;
  53763. ty = -txDiff * b / denominator;
  53764. }
  53765. return {
  53766. width: tx,
  53767. height: ty,
  53768. value: font.vertical ? ty : tx
  53769. };
  53770. },
  53771. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53772. var tsm = [
  53773. this.fontSize * this.textHScale,
  53774. 0,
  53775. 0,
  53776. this.fontSize,
  53777. 0,
  53778. this.textRise
  53779. ];
  53780. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53781. },
  53782. carriageReturn: function TextState_carriageReturn() {
  53783. this.translateTextLineMatrix(0, -this.leading);
  53784. this.textMatrix = this.textLineMatrix.slice();
  53785. },
  53786. clone: function TextState_clone() {
  53787. var clone = Object.create(this);
  53788. clone.textMatrix = this.textMatrix.slice();
  53789. clone.textLineMatrix = this.textLineMatrix.slice();
  53790. clone.fontMatrix = this.fontMatrix.slice();
  53791. return clone;
  53792. }
  53793. };
  53794. return TextState;
  53795. }();
  53796. var EvalState = function EvalStateClosure() {
  53797. function EvalState() {
  53798. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53799. this.font = null;
  53800. this.textRenderingMode = TextRenderingMode.FILL;
  53801. this.fillColorSpace = ColorSpace.singletons.gray;
  53802. this.strokeColorSpace = ColorSpace.singletons.gray;
  53803. }
  53804. EvalState.prototype = {
  53805. clone: function CanvasExtraState_clone() {
  53806. return Object.create(this);
  53807. }
  53808. };
  53809. return EvalState;
  53810. }();
  53811. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53812. var getOPMap = getLookupTableFactory(function (t) {
  53813. t['w'] = {
  53814. id: OPS.setLineWidth,
  53815. numArgs: 1,
  53816. variableArgs: false
  53817. };
  53818. t['J'] = {
  53819. id: OPS.setLineCap,
  53820. numArgs: 1,
  53821. variableArgs: false
  53822. };
  53823. t['j'] = {
  53824. id: OPS.setLineJoin,
  53825. numArgs: 1,
  53826. variableArgs: false
  53827. };
  53828. t['M'] = {
  53829. id: OPS.setMiterLimit,
  53830. numArgs: 1,
  53831. variableArgs: false
  53832. };
  53833. t['d'] = {
  53834. id: OPS.setDash,
  53835. numArgs: 2,
  53836. variableArgs: false
  53837. };
  53838. t['ri'] = {
  53839. id: OPS.setRenderingIntent,
  53840. numArgs: 1,
  53841. variableArgs: false
  53842. };
  53843. t['i'] = {
  53844. id: OPS.setFlatness,
  53845. numArgs: 1,
  53846. variableArgs: false
  53847. };
  53848. t['gs'] = {
  53849. id: OPS.setGState,
  53850. numArgs: 1,
  53851. variableArgs: false
  53852. };
  53853. t['q'] = {
  53854. id: OPS.save,
  53855. numArgs: 0,
  53856. variableArgs: false
  53857. };
  53858. t['Q'] = {
  53859. id: OPS.restore,
  53860. numArgs: 0,
  53861. variableArgs: false
  53862. };
  53863. t['cm'] = {
  53864. id: OPS.transform,
  53865. numArgs: 6,
  53866. variableArgs: false
  53867. };
  53868. t['m'] = {
  53869. id: OPS.moveTo,
  53870. numArgs: 2,
  53871. variableArgs: false
  53872. };
  53873. t['l'] = {
  53874. id: OPS.lineTo,
  53875. numArgs: 2,
  53876. variableArgs: false
  53877. };
  53878. t['c'] = {
  53879. id: OPS.curveTo,
  53880. numArgs: 6,
  53881. variableArgs: false
  53882. };
  53883. t['v'] = {
  53884. id: OPS.curveTo2,
  53885. numArgs: 4,
  53886. variableArgs: false
  53887. };
  53888. t['y'] = {
  53889. id: OPS.curveTo3,
  53890. numArgs: 4,
  53891. variableArgs: false
  53892. };
  53893. t['h'] = {
  53894. id: OPS.closePath,
  53895. numArgs: 0,
  53896. variableArgs: false
  53897. };
  53898. t['re'] = {
  53899. id: OPS.rectangle,
  53900. numArgs: 4,
  53901. variableArgs: false
  53902. };
  53903. t['S'] = {
  53904. id: OPS.stroke,
  53905. numArgs: 0,
  53906. variableArgs: false
  53907. };
  53908. t['s'] = {
  53909. id: OPS.closeStroke,
  53910. numArgs: 0,
  53911. variableArgs: false
  53912. };
  53913. t['f'] = {
  53914. id: OPS.fill,
  53915. numArgs: 0,
  53916. variableArgs: false
  53917. };
  53918. t['F'] = {
  53919. id: OPS.fill,
  53920. numArgs: 0,
  53921. variableArgs: false
  53922. };
  53923. t['f*'] = {
  53924. id: OPS.eoFill,
  53925. numArgs: 0,
  53926. variableArgs: false
  53927. };
  53928. t['B'] = {
  53929. id: OPS.fillStroke,
  53930. numArgs: 0,
  53931. variableArgs: false
  53932. };
  53933. t['B*'] = {
  53934. id: OPS.eoFillStroke,
  53935. numArgs: 0,
  53936. variableArgs: false
  53937. };
  53938. t['b'] = {
  53939. id: OPS.closeFillStroke,
  53940. numArgs: 0,
  53941. variableArgs: false
  53942. };
  53943. t['b*'] = {
  53944. id: OPS.closeEOFillStroke,
  53945. numArgs: 0,
  53946. variableArgs: false
  53947. };
  53948. t['n'] = {
  53949. id: OPS.endPath,
  53950. numArgs: 0,
  53951. variableArgs: false
  53952. };
  53953. t['W'] = {
  53954. id: OPS.clip,
  53955. numArgs: 0,
  53956. variableArgs: false
  53957. };
  53958. t['W*'] = {
  53959. id: OPS.eoClip,
  53960. numArgs: 0,
  53961. variableArgs: false
  53962. };
  53963. t['BT'] = {
  53964. id: OPS.beginText,
  53965. numArgs: 0,
  53966. variableArgs: false
  53967. };
  53968. t['ET'] = {
  53969. id: OPS.endText,
  53970. numArgs: 0,
  53971. variableArgs: false
  53972. };
  53973. t['Tc'] = {
  53974. id: OPS.setCharSpacing,
  53975. numArgs: 1,
  53976. variableArgs: false
  53977. };
  53978. t['Tw'] = {
  53979. id: OPS.setWordSpacing,
  53980. numArgs: 1,
  53981. variableArgs: false
  53982. };
  53983. t['Tz'] = {
  53984. id: OPS.setHScale,
  53985. numArgs: 1,
  53986. variableArgs: false
  53987. };
  53988. t['TL'] = {
  53989. id: OPS.setLeading,
  53990. numArgs: 1,
  53991. variableArgs: false
  53992. };
  53993. t['Tf'] = {
  53994. id: OPS.setFont,
  53995. numArgs: 2,
  53996. variableArgs: false
  53997. };
  53998. t['Tr'] = {
  53999. id: OPS.setTextRenderingMode,
  54000. numArgs: 1,
  54001. variableArgs: false
  54002. };
  54003. t['Ts'] = {
  54004. id: OPS.setTextRise,
  54005. numArgs: 1,
  54006. variableArgs: false
  54007. };
  54008. t['Td'] = {
  54009. id: OPS.moveText,
  54010. numArgs: 2,
  54011. variableArgs: false
  54012. };
  54013. t['TD'] = {
  54014. id: OPS.setLeadingMoveText,
  54015. numArgs: 2,
  54016. variableArgs: false
  54017. };
  54018. t['Tm'] = {
  54019. id: OPS.setTextMatrix,
  54020. numArgs: 6,
  54021. variableArgs: false
  54022. };
  54023. t['T*'] = {
  54024. id: OPS.nextLine,
  54025. numArgs: 0,
  54026. variableArgs: false
  54027. };
  54028. t['Tj'] = {
  54029. id: OPS.showText,
  54030. numArgs: 1,
  54031. variableArgs: false
  54032. };
  54033. t['TJ'] = {
  54034. id: OPS.showSpacedText,
  54035. numArgs: 1,
  54036. variableArgs: false
  54037. };
  54038. t['\''] = {
  54039. id: OPS.nextLineShowText,
  54040. numArgs: 1,
  54041. variableArgs: false
  54042. };
  54043. t['"'] = {
  54044. id: OPS.nextLineSetSpacingShowText,
  54045. numArgs: 3,
  54046. variableArgs: false
  54047. };
  54048. t['d0'] = {
  54049. id: OPS.setCharWidth,
  54050. numArgs: 2,
  54051. variableArgs: false
  54052. };
  54053. t['d1'] = {
  54054. id: OPS.setCharWidthAndBounds,
  54055. numArgs: 6,
  54056. variableArgs: false
  54057. };
  54058. t['CS'] = {
  54059. id: OPS.setStrokeColorSpace,
  54060. numArgs: 1,
  54061. variableArgs: false
  54062. };
  54063. t['cs'] = {
  54064. id: OPS.setFillColorSpace,
  54065. numArgs: 1,
  54066. variableArgs: false
  54067. };
  54068. t['SC'] = {
  54069. id: OPS.setStrokeColor,
  54070. numArgs: 4,
  54071. variableArgs: true
  54072. };
  54073. t['SCN'] = {
  54074. id: OPS.setStrokeColorN,
  54075. numArgs: 33,
  54076. variableArgs: true
  54077. };
  54078. t['sc'] = {
  54079. id: OPS.setFillColor,
  54080. numArgs: 4,
  54081. variableArgs: true
  54082. };
  54083. t['scn'] = {
  54084. id: OPS.setFillColorN,
  54085. numArgs: 33,
  54086. variableArgs: true
  54087. };
  54088. t['G'] = {
  54089. id: OPS.setStrokeGray,
  54090. numArgs: 1,
  54091. variableArgs: false
  54092. };
  54093. t['g'] = {
  54094. id: OPS.setFillGray,
  54095. numArgs: 1,
  54096. variableArgs: false
  54097. };
  54098. t['RG'] = {
  54099. id: OPS.setStrokeRGBColor,
  54100. numArgs: 3,
  54101. variableArgs: false
  54102. };
  54103. t['rg'] = {
  54104. id: OPS.setFillRGBColor,
  54105. numArgs: 3,
  54106. variableArgs: false
  54107. };
  54108. t['K'] = {
  54109. id: OPS.setStrokeCMYKColor,
  54110. numArgs: 4,
  54111. variableArgs: false
  54112. };
  54113. t['k'] = {
  54114. id: OPS.setFillCMYKColor,
  54115. numArgs: 4,
  54116. variableArgs: false
  54117. };
  54118. t['sh'] = {
  54119. id: OPS.shadingFill,
  54120. numArgs: 1,
  54121. variableArgs: false
  54122. };
  54123. t['BI'] = {
  54124. id: OPS.beginInlineImage,
  54125. numArgs: 0,
  54126. variableArgs: false
  54127. };
  54128. t['ID'] = {
  54129. id: OPS.beginImageData,
  54130. numArgs: 0,
  54131. variableArgs: false
  54132. };
  54133. t['EI'] = {
  54134. id: OPS.endInlineImage,
  54135. numArgs: 1,
  54136. variableArgs: false
  54137. };
  54138. t['Do'] = {
  54139. id: OPS.paintXObject,
  54140. numArgs: 1,
  54141. variableArgs: false
  54142. };
  54143. t['MP'] = {
  54144. id: OPS.markPoint,
  54145. numArgs: 1,
  54146. variableArgs: false
  54147. };
  54148. t['DP'] = {
  54149. id: OPS.markPointProps,
  54150. numArgs: 2,
  54151. variableArgs: false
  54152. };
  54153. t['BMC'] = {
  54154. id: OPS.beginMarkedContent,
  54155. numArgs: 1,
  54156. variableArgs: false
  54157. };
  54158. t['BDC'] = {
  54159. id: OPS.beginMarkedContentProps,
  54160. numArgs: 2,
  54161. variableArgs: false
  54162. };
  54163. t['EMC'] = {
  54164. id: OPS.endMarkedContent,
  54165. numArgs: 0,
  54166. variableArgs: false
  54167. };
  54168. t['BX'] = {
  54169. id: OPS.beginCompat,
  54170. numArgs: 0,
  54171. variableArgs: false
  54172. };
  54173. t['EX'] = {
  54174. id: OPS.endCompat,
  54175. numArgs: 0,
  54176. variableArgs: false
  54177. };
  54178. t['BM'] = null;
  54179. t['BD'] = null;
  54180. t['true'] = null;
  54181. t['fa'] = null;
  54182. t['fal'] = null;
  54183. t['fals'] = null;
  54184. t['false'] = null;
  54185. t['nu'] = null;
  54186. t['nul'] = null;
  54187. t['null'] = null;
  54188. });
  54189. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54190. this.opMap = getOPMap();
  54191. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54192. this.stateManager = stateManager;
  54193. this.nonProcessedArgs = [];
  54194. }
  54195. EvaluatorPreprocessor.prototype = {
  54196. get savedStatesDepth() {
  54197. return this.stateManager.stateStack.length;
  54198. },
  54199. read: function EvaluatorPreprocessor_read(operation) {
  54200. var args = operation.args;
  54201. while (true) {
  54202. var obj = this.parser.getObj();
  54203. if (isCmd(obj)) {
  54204. var cmd = obj.cmd;
  54205. var opSpec = this.opMap[cmd];
  54206. if (!opSpec) {
  54207. warn('Unknown command "' + cmd + '"');
  54208. continue;
  54209. }
  54210. var fn = opSpec.id;
  54211. var numArgs = opSpec.numArgs;
  54212. var argsLength = args !== null ? args.length : 0;
  54213. if (!opSpec.variableArgs) {
  54214. if (argsLength !== numArgs) {
  54215. var nonProcessedArgs = this.nonProcessedArgs;
  54216. while (argsLength > numArgs) {
  54217. nonProcessedArgs.push(args.shift());
  54218. argsLength--;
  54219. }
  54220. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54221. if (args === null) {
  54222. args = [];
  54223. }
  54224. args.unshift(nonProcessedArgs.pop());
  54225. argsLength++;
  54226. }
  54227. }
  54228. if (argsLength < numArgs) {
  54229. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54230. if (args !== null) {
  54231. args.length = 0;
  54232. }
  54233. continue;
  54234. }
  54235. } else if (argsLength > numArgs) {
  54236. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54237. }
  54238. this.preprocessCommand(fn, args);
  54239. operation.fn = fn;
  54240. operation.args = args;
  54241. return true;
  54242. } else {
  54243. if (isEOF(obj)) {
  54244. return false;
  54245. }
  54246. if (obj !== null) {
  54247. if (args === null) {
  54248. args = [];
  54249. }
  54250. args.push(obj);
  54251. assert(args.length <= 33, 'Too many arguments');
  54252. }
  54253. }
  54254. }
  54255. },
  54256. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54257. switch (fn | 0) {
  54258. case OPS.save:
  54259. this.stateManager.save();
  54260. break;
  54261. case OPS.restore:
  54262. this.stateManager.restore();
  54263. break;
  54264. case OPS.transform:
  54265. this.stateManager.transform(args);
  54266. break;
  54267. }
  54268. }
  54269. };
  54270. return EvaluatorPreprocessor;
  54271. }();
  54272. var QueueOptimizer = function QueueOptimizerClosure() {
  54273. function addState(parentState, pattern, fn) {
  54274. var state = parentState;
  54275. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54276. var item = pattern[i];
  54277. state = state[item] || (state[item] = []);
  54278. }
  54279. state[pattern[pattern.length - 1]] = fn;
  54280. }
  54281. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54282. var iFirstPIMXO = iFirstSave + 2;
  54283. for (var i = 0; i < count; i++) {
  54284. var arg = argsArray[iFirstPIMXO + 4 * i];
  54285. var imageMask = arg.length === 1 && arg[0];
  54286. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54287. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54288. continue;
  54289. }
  54290. break;
  54291. }
  54292. return count - i;
  54293. }
  54294. var InitialState = [];
  54295. addState(InitialState, [
  54296. OPS.save,
  54297. OPS.transform,
  54298. OPS.paintInlineImageXObject,
  54299. OPS.restore
  54300. ], function foundInlineImageGroup(context) {
  54301. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54302. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54303. var MAX_WIDTH = 1000;
  54304. var IMAGE_PADDING = 1;
  54305. var fnArray = context.fnArray, argsArray = context.argsArray;
  54306. var curr = context.iCurr;
  54307. var iFirstSave = curr - 3;
  54308. var iFirstTransform = curr - 2;
  54309. var iFirstPIIXO = curr - 1;
  54310. var i = iFirstSave + 4;
  54311. var ii = fnArray.length;
  54312. while (i + 3 < ii) {
  54313. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54314. break;
  54315. }
  54316. i += 4;
  54317. }
  54318. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54319. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54320. return i;
  54321. }
  54322. var maxX = 0;
  54323. var map = [], maxLineHeight = 0;
  54324. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54325. var q;
  54326. for (q = 0; q < count; q++) {
  54327. var transform = argsArray[iFirstTransform + (q << 2)];
  54328. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54329. if (currentX + img.width > MAX_WIDTH) {
  54330. maxX = Math.max(maxX, currentX);
  54331. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54332. currentX = 0;
  54333. maxLineHeight = 0;
  54334. }
  54335. map.push({
  54336. transform: transform,
  54337. x: currentX,
  54338. y: currentY,
  54339. w: img.width,
  54340. h: img.height
  54341. });
  54342. currentX += img.width + 2 * IMAGE_PADDING;
  54343. maxLineHeight = Math.max(maxLineHeight, img.height);
  54344. }
  54345. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54346. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54347. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54348. var imgRowSize = imgWidth << 2;
  54349. for (q = 0; q < count; q++) {
  54350. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54351. var rowSize = map[q].w << 2;
  54352. var dataOffset = 0;
  54353. var offset = map[q].x + map[q].y * imgWidth << 2;
  54354. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54355. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54356. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54357. dataOffset += rowSize;
  54358. offset += imgRowSize;
  54359. }
  54360. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54361. while (offset >= 0) {
  54362. data[offset - 4] = data[offset];
  54363. data[offset - 3] = data[offset + 1];
  54364. data[offset - 2] = data[offset + 2];
  54365. data[offset - 1] = data[offset + 3];
  54366. data[offset + rowSize] = data[offset + rowSize - 4];
  54367. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54368. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54369. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54370. offset -= imgRowSize;
  54371. }
  54372. }
  54373. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54374. argsArray.splice(iFirstSave, count * 4, [
  54375. {
  54376. width: imgWidth,
  54377. height: imgHeight,
  54378. kind: ImageKind.RGBA_32BPP,
  54379. data: imgData
  54380. },
  54381. map
  54382. ]);
  54383. return iFirstSave + 1;
  54384. });
  54385. addState(InitialState, [
  54386. OPS.save,
  54387. OPS.transform,
  54388. OPS.paintImageMaskXObject,
  54389. OPS.restore
  54390. ], function foundImageMaskGroup(context) {
  54391. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54392. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54393. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54394. var fnArray = context.fnArray, argsArray = context.argsArray;
  54395. var curr = context.iCurr;
  54396. var iFirstSave = curr - 3;
  54397. var iFirstTransform = curr - 2;
  54398. var iFirstPIMXO = curr - 1;
  54399. var i = iFirstSave + 4;
  54400. var ii = fnArray.length;
  54401. while (i + 3 < ii) {
  54402. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54403. break;
  54404. }
  54405. i += 4;
  54406. }
  54407. var count = (i - iFirstSave) / 4;
  54408. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54409. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54410. return i;
  54411. }
  54412. var q;
  54413. var isSameImage = false;
  54414. var iTransform, transformArgs;
  54415. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54416. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54417. isSameImage = true;
  54418. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54419. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54420. iTransform = iFirstTransform + 4;
  54421. var iPIMXO = iFirstPIMXO + 4;
  54422. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54423. transformArgs = argsArray[iTransform];
  54424. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54425. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54426. isSameImage = false;
  54427. } else {
  54428. count = q;
  54429. }
  54430. break;
  54431. }
  54432. }
  54433. }
  54434. if (isSameImage) {
  54435. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54436. var positions = new Float32Array(count * 2);
  54437. iTransform = iFirstTransform;
  54438. for (q = 0; q < count; q++, iTransform += 4) {
  54439. transformArgs = argsArray[iTransform];
  54440. positions[q << 1] = transformArgs[4];
  54441. positions[(q << 1) + 1] = transformArgs[5];
  54442. }
  54443. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54444. argsArray.splice(iFirstSave, count * 4, [
  54445. firstPIMXOArg0,
  54446. firstTransformArg0,
  54447. firstTransformArg3,
  54448. positions
  54449. ]);
  54450. } else {
  54451. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54452. var images = [];
  54453. for (q = 0; q < count; q++) {
  54454. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54455. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54456. images.push({
  54457. data: maskParams.data,
  54458. width: maskParams.width,
  54459. height: maskParams.height,
  54460. transform: transformArgs
  54461. });
  54462. }
  54463. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54464. argsArray.splice(iFirstSave, count * 4, [images]);
  54465. }
  54466. return iFirstSave + 1;
  54467. });
  54468. addState(InitialState, [
  54469. OPS.save,
  54470. OPS.transform,
  54471. OPS.paintImageXObject,
  54472. OPS.restore
  54473. ], function (context) {
  54474. var MIN_IMAGES_IN_BLOCK = 3;
  54475. var MAX_IMAGES_IN_BLOCK = 1000;
  54476. var fnArray = context.fnArray, argsArray = context.argsArray;
  54477. var curr = context.iCurr;
  54478. var iFirstSave = curr - 3;
  54479. var iFirstTransform = curr - 2;
  54480. var iFirstPIXO = curr - 1;
  54481. var iFirstRestore = curr;
  54482. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54483. return iFirstRestore + 1;
  54484. }
  54485. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54486. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54487. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54488. var i = iFirstSave + 4;
  54489. var ii = fnArray.length;
  54490. while (i + 3 < ii) {
  54491. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54492. break;
  54493. }
  54494. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54495. break;
  54496. }
  54497. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54498. break;
  54499. }
  54500. i += 4;
  54501. }
  54502. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54503. if (count < MIN_IMAGES_IN_BLOCK) {
  54504. return i;
  54505. }
  54506. var positions = new Float32Array(count * 2);
  54507. var iTransform = iFirstTransform;
  54508. for (var q = 0; q < count; q++, iTransform += 4) {
  54509. var transformArgs = argsArray[iTransform];
  54510. positions[q << 1] = transformArgs[4];
  54511. positions[(q << 1) + 1] = transformArgs[5];
  54512. }
  54513. var args = [
  54514. firstPIXOArg0,
  54515. firstTransformArg0,
  54516. firstTransformArg3,
  54517. positions
  54518. ];
  54519. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54520. argsArray.splice(iFirstSave, count * 4, args);
  54521. return iFirstSave + 1;
  54522. });
  54523. addState(InitialState, [
  54524. OPS.beginText,
  54525. OPS.setFont,
  54526. OPS.setTextMatrix,
  54527. OPS.showText,
  54528. OPS.endText
  54529. ], function (context) {
  54530. var MIN_CHARS_IN_BLOCK = 3;
  54531. var MAX_CHARS_IN_BLOCK = 1000;
  54532. var fnArray = context.fnArray, argsArray = context.argsArray;
  54533. var curr = context.iCurr;
  54534. var iFirstBeginText = curr - 4;
  54535. var iFirstSetFont = curr - 3;
  54536. var iFirstSetTextMatrix = curr - 2;
  54537. var iFirstShowText = curr - 1;
  54538. var iFirstEndText = curr;
  54539. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54540. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54541. var i = iFirstBeginText + 5;
  54542. var ii = fnArray.length;
  54543. while (i + 4 < ii) {
  54544. 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) {
  54545. break;
  54546. }
  54547. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54548. break;
  54549. }
  54550. i += 5;
  54551. }
  54552. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54553. if (count < MIN_CHARS_IN_BLOCK) {
  54554. return i;
  54555. }
  54556. var iFirst = iFirstBeginText;
  54557. 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) {
  54558. count++;
  54559. iFirst -= 5;
  54560. }
  54561. var iEndText = iFirst + 4;
  54562. for (var q = 1; q < count; q++) {
  54563. fnArray.splice(iEndText, 3);
  54564. argsArray.splice(iEndText, 3);
  54565. iEndText += 2;
  54566. }
  54567. return iEndText + 1;
  54568. });
  54569. function QueueOptimizer() {
  54570. }
  54571. QueueOptimizer.prototype = {
  54572. optimize: function QueueOptimizer_optimize(queue) {
  54573. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54574. var context = {
  54575. iCurr: 0,
  54576. fnArray: fnArray,
  54577. argsArray: argsArray
  54578. };
  54579. var state;
  54580. var i = 0, ii = fnArray.length;
  54581. while (i < ii) {
  54582. state = (state || InitialState)[fnArray[i]];
  54583. if (typeof state === 'function') {
  54584. context.iCurr = i;
  54585. i = state(context);
  54586. state = undefined;
  54587. ii = context.fnArray.length;
  54588. } else {
  54589. i++;
  54590. }
  54591. }
  54592. }
  54593. };
  54594. return QueueOptimizer;
  54595. }();
  54596. exports.OperatorList = OperatorList;
  54597. exports.PartialEvaluator = PartialEvaluator;
  54598. }));
  54599. (function (root, factory) {
  54600. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54601. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54602. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54603. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54604. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54605. var AnnotationType = sharedUtil.AnnotationType;
  54606. var OPS = sharedUtil.OPS;
  54607. var Util = sharedUtil.Util;
  54608. var isString = sharedUtil.isString;
  54609. var isArray = sharedUtil.isArray;
  54610. var isInt = sharedUtil.isInt;
  54611. var stringToBytes = sharedUtil.stringToBytes;
  54612. var stringToPDFString = sharedUtil.stringToPDFString;
  54613. var warn = sharedUtil.warn;
  54614. var Dict = corePrimitives.Dict;
  54615. var isDict = corePrimitives.isDict;
  54616. var isName = corePrimitives.isName;
  54617. var isRef = corePrimitives.isRef;
  54618. var Stream = coreStream.Stream;
  54619. var ColorSpace = coreColorSpace.ColorSpace;
  54620. var Catalog = coreObj.Catalog;
  54621. var ObjectLoader = coreObj.ObjectLoader;
  54622. var FileSpec = coreObj.FileSpec;
  54623. var OperatorList = coreEvaluator.OperatorList;
  54624. function AnnotationFactory() {
  54625. }
  54626. AnnotationFactory.prototype = {
  54627. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  54628. var dict = xref.fetchIfRef(ref);
  54629. if (!isDict(dict)) {
  54630. return;
  54631. }
  54632. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  54633. var subtype = dict.get('Subtype');
  54634. subtype = isName(subtype) ? subtype.name : null;
  54635. var parameters = {
  54636. xref: xref,
  54637. dict: dict,
  54638. ref: isRef(ref) ? ref : null,
  54639. subtype: subtype,
  54640. id: id,
  54641. pdfManager: pdfManager
  54642. };
  54643. switch (subtype) {
  54644. case 'Link':
  54645. return new LinkAnnotation(parameters);
  54646. case 'Text':
  54647. return new TextAnnotation(parameters);
  54648. case 'Widget':
  54649. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54650. fieldType = isName(fieldType) ? fieldType.name : null;
  54651. switch (fieldType) {
  54652. case 'Tx':
  54653. return new TextWidgetAnnotation(parameters);
  54654. case 'Btn':
  54655. return new ButtonWidgetAnnotation(parameters);
  54656. case 'Ch':
  54657. return new ChoiceWidgetAnnotation(parameters);
  54658. }
  54659. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54660. return new WidgetAnnotation(parameters);
  54661. case 'Popup':
  54662. return new PopupAnnotation(parameters);
  54663. case 'Highlight':
  54664. return new HighlightAnnotation(parameters);
  54665. case 'Underline':
  54666. return new UnderlineAnnotation(parameters);
  54667. case 'Squiggly':
  54668. return new SquigglyAnnotation(parameters);
  54669. case 'StrikeOut':
  54670. return new StrikeOutAnnotation(parameters);
  54671. case 'FileAttachment':
  54672. return new FileAttachmentAnnotation(parameters);
  54673. default:
  54674. if (!subtype) {
  54675. warn('Annotation is missing the required /Subtype.');
  54676. } else {
  54677. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54678. }
  54679. return new Annotation(parameters);
  54680. }
  54681. }
  54682. };
  54683. var Annotation = function AnnotationClosure() {
  54684. function getTransformMatrix(rect, bbox, matrix) {
  54685. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54686. var minX = bounds[0];
  54687. var minY = bounds[1];
  54688. var maxX = bounds[2];
  54689. var maxY = bounds[3];
  54690. if (minX === maxX || minY === maxY) {
  54691. return [
  54692. 1,
  54693. 0,
  54694. 0,
  54695. 1,
  54696. rect[0],
  54697. rect[1]
  54698. ];
  54699. }
  54700. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54701. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54702. return [
  54703. xRatio,
  54704. 0,
  54705. 0,
  54706. yRatio,
  54707. rect[0] - minX * xRatio,
  54708. rect[1] - minY * yRatio
  54709. ];
  54710. }
  54711. function getDefaultAppearance(dict) {
  54712. var appearanceState = dict.get('AP');
  54713. if (!isDict(appearanceState)) {
  54714. return;
  54715. }
  54716. var appearance;
  54717. var appearances = appearanceState.get('N');
  54718. if (isDict(appearances)) {
  54719. var as = dict.get('AS');
  54720. if (as && appearances.has(as.name)) {
  54721. appearance = appearances.get(as.name);
  54722. }
  54723. } else {
  54724. appearance = appearances;
  54725. }
  54726. return appearance;
  54727. }
  54728. function Annotation(params) {
  54729. var dict = params.dict;
  54730. this.setFlags(dict.get('F'));
  54731. this.setRectangle(dict.getArray('Rect'));
  54732. this.setColor(dict.getArray('C'));
  54733. this.setBorderStyle(dict);
  54734. this.appearance = getDefaultAppearance(dict);
  54735. this.data = {};
  54736. this.data.id = params.id;
  54737. this.data.subtype = params.subtype;
  54738. this.data.annotationFlags = this.flags;
  54739. this.data.rect = this.rectangle;
  54740. this.data.color = this.color;
  54741. this.data.borderStyle = this.borderStyle;
  54742. this.data.hasAppearance = !!this.appearance;
  54743. }
  54744. Annotation.prototype = {
  54745. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54746. return !!(flags & flag);
  54747. },
  54748. _isViewable: function Annotation_isViewable(flags) {
  54749. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54750. },
  54751. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54752. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54753. },
  54754. get viewable() {
  54755. if (this.flags === 0) {
  54756. return true;
  54757. }
  54758. return this._isViewable(this.flags);
  54759. },
  54760. get printable() {
  54761. if (this.flags === 0) {
  54762. return false;
  54763. }
  54764. return this._isPrintable(this.flags);
  54765. },
  54766. setFlags: function Annotation_setFlags(flags) {
  54767. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54768. },
  54769. hasFlag: function Annotation_hasFlag(flag) {
  54770. return this._hasFlag(this.flags, flag);
  54771. },
  54772. setRectangle: function Annotation_setRectangle(rectangle) {
  54773. if (isArray(rectangle) && rectangle.length === 4) {
  54774. this.rectangle = Util.normalizeRect(rectangle);
  54775. } else {
  54776. this.rectangle = [
  54777. 0,
  54778. 0,
  54779. 0,
  54780. 0
  54781. ];
  54782. }
  54783. },
  54784. setColor: function Annotation_setColor(color) {
  54785. var rgbColor = new Uint8Array(3);
  54786. if (!isArray(color)) {
  54787. this.color = rgbColor;
  54788. return;
  54789. }
  54790. switch (color.length) {
  54791. case 0:
  54792. this.color = null;
  54793. break;
  54794. case 1:
  54795. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54796. this.color = rgbColor;
  54797. break;
  54798. case 3:
  54799. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54800. this.color = rgbColor;
  54801. break;
  54802. case 4:
  54803. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54804. this.color = rgbColor;
  54805. break;
  54806. default:
  54807. this.color = rgbColor;
  54808. break;
  54809. }
  54810. },
  54811. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54812. this.borderStyle = new AnnotationBorderStyle();
  54813. if (!isDict(borderStyle)) {
  54814. return;
  54815. }
  54816. if (borderStyle.has('BS')) {
  54817. var dict = borderStyle.get('BS');
  54818. var dictType = dict.get('Type');
  54819. if (!dictType || isName(dictType, 'Border')) {
  54820. this.borderStyle.setWidth(dict.get('W'));
  54821. this.borderStyle.setStyle(dict.get('S'));
  54822. this.borderStyle.setDashArray(dict.getArray('D'));
  54823. }
  54824. } else if (borderStyle.has('Border')) {
  54825. var array = borderStyle.getArray('Border');
  54826. if (isArray(array) && array.length >= 3) {
  54827. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54828. this.borderStyle.setVerticalCornerRadius(array[1]);
  54829. this.borderStyle.setWidth(array[2]);
  54830. if (array.length === 4) {
  54831. this.borderStyle.setDashArray(array[3]);
  54832. }
  54833. }
  54834. } else {
  54835. this.borderStyle.setWidth(0);
  54836. }
  54837. },
  54838. _preparePopup: function Annotation_preparePopup(dict) {
  54839. if (!dict.has('C')) {
  54840. this.data.color = null;
  54841. }
  54842. this.data.hasPopup = dict.has('Popup');
  54843. this.data.title = stringToPDFString(dict.get('T') || '');
  54844. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54845. },
  54846. loadResources: function Annotation_loadResources(keys) {
  54847. return new Promise(function (resolve, reject) {
  54848. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54849. if (!resources) {
  54850. resolve();
  54851. return;
  54852. }
  54853. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54854. objectLoader.load().then(function () {
  54855. resolve(resources);
  54856. }, reject);
  54857. }, reject);
  54858. }.bind(this));
  54859. },
  54860. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54861. if (!this.appearance) {
  54862. return Promise.resolve(new OperatorList());
  54863. }
  54864. var data = this.data;
  54865. var appearanceDict = this.appearance.dict;
  54866. var resourcesPromise = this.loadResources([
  54867. 'ExtGState',
  54868. 'ColorSpace',
  54869. 'Pattern',
  54870. 'Shading',
  54871. 'XObject',
  54872. 'Font'
  54873. ]);
  54874. var bbox = appearanceDict.getArray('BBox') || [
  54875. 0,
  54876. 0,
  54877. 1,
  54878. 1
  54879. ];
  54880. var matrix = appearanceDict.getArray('Matrix') || [
  54881. 1,
  54882. 0,
  54883. 0,
  54884. 1,
  54885. 0,
  54886. 0
  54887. ];
  54888. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54889. var self = this;
  54890. return resourcesPromise.then(function (resources) {
  54891. var opList = new OperatorList();
  54892. opList.addOp(OPS.beginAnnotation, [
  54893. data.rect,
  54894. transform,
  54895. matrix
  54896. ]);
  54897. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54898. opList.addOp(OPS.endAnnotation, []);
  54899. self.appearance.reset();
  54900. return opList;
  54901. });
  54902. });
  54903. }
  54904. };
  54905. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54906. var annotationPromises = [];
  54907. for (var i = 0, n = annotations.length; i < n; ++i) {
  54908. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54909. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54910. }
  54911. }
  54912. return Promise.all(annotationPromises).then(function (operatorLists) {
  54913. opList.addOp(OPS.beginAnnotations, []);
  54914. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54915. opList.addOpList(operatorLists[i]);
  54916. }
  54917. opList.addOp(OPS.endAnnotations, []);
  54918. });
  54919. };
  54920. return Annotation;
  54921. }();
  54922. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54923. function AnnotationBorderStyle() {
  54924. this.width = 1;
  54925. this.style = AnnotationBorderStyleType.SOLID;
  54926. this.dashArray = [3];
  54927. this.horizontalCornerRadius = 0;
  54928. this.verticalCornerRadius = 0;
  54929. }
  54930. AnnotationBorderStyle.prototype = {
  54931. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54932. if (width === (width | 0)) {
  54933. this.width = width;
  54934. }
  54935. },
  54936. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54937. if (!style) {
  54938. return;
  54939. }
  54940. switch (style.name) {
  54941. case 'S':
  54942. this.style = AnnotationBorderStyleType.SOLID;
  54943. break;
  54944. case 'D':
  54945. this.style = AnnotationBorderStyleType.DASHED;
  54946. break;
  54947. case 'B':
  54948. this.style = AnnotationBorderStyleType.BEVELED;
  54949. break;
  54950. case 'I':
  54951. this.style = AnnotationBorderStyleType.INSET;
  54952. break;
  54953. case 'U':
  54954. this.style = AnnotationBorderStyleType.UNDERLINE;
  54955. break;
  54956. default:
  54957. break;
  54958. }
  54959. },
  54960. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54961. if (isArray(dashArray) && dashArray.length > 0) {
  54962. var isValid = true;
  54963. var allZeros = true;
  54964. for (var i = 0, len = dashArray.length; i < len; i++) {
  54965. var element = dashArray[i];
  54966. var validNumber = +element >= 0;
  54967. if (!validNumber) {
  54968. isValid = false;
  54969. break;
  54970. } else if (element > 0) {
  54971. allZeros = false;
  54972. }
  54973. }
  54974. if (isValid && !allZeros) {
  54975. this.dashArray = dashArray;
  54976. } else {
  54977. this.width = 0;
  54978. }
  54979. } else if (dashArray) {
  54980. this.width = 0;
  54981. }
  54982. },
  54983. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54984. if (radius === (radius | 0)) {
  54985. this.horizontalCornerRadius = radius;
  54986. }
  54987. },
  54988. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54989. if (radius === (radius | 0)) {
  54990. this.verticalCornerRadius = radius;
  54991. }
  54992. }
  54993. };
  54994. return AnnotationBorderStyle;
  54995. }();
  54996. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54997. function WidgetAnnotation(params) {
  54998. Annotation.call(this, params);
  54999. var dict = params.dict;
  55000. var data = this.data;
  55001. data.annotationType = AnnotationType.WIDGET;
  55002. data.fieldName = this._constructFieldName(dict);
  55003. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  55004. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  55005. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  55006. var fieldType = Util.getInheritableProperty(dict, 'FT');
  55007. data.fieldType = isName(fieldType) ? fieldType.name : null;
  55008. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  55009. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  55010. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  55011. data.fieldFlags = 0;
  55012. }
  55013. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  55014. if (data.fieldType === 'Sig') {
  55015. this.setFlags(AnnotationFlag.HIDDEN);
  55016. }
  55017. }
  55018. Util.inherit(WidgetAnnotation, Annotation, {
  55019. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  55020. if (!dict.has('T') && !dict.has('Parent')) {
  55021. warn('Unknown field name, falling back to empty field name.');
  55022. return '';
  55023. }
  55024. if (!dict.has('Parent')) {
  55025. return stringToPDFString(dict.get('T'));
  55026. }
  55027. var fieldName = [];
  55028. if (dict.has('T')) {
  55029. fieldName.unshift(stringToPDFString(dict.get('T')));
  55030. }
  55031. var loopDict = dict;
  55032. while (loopDict.has('Parent')) {
  55033. loopDict = loopDict.get('Parent');
  55034. if (loopDict.has('T')) {
  55035. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  55036. }
  55037. }
  55038. return fieldName.join('.');
  55039. },
  55040. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  55041. return !!(this.data.fieldFlags & flag);
  55042. }
  55043. });
  55044. return WidgetAnnotation;
  55045. }();
  55046. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  55047. function TextWidgetAnnotation(params) {
  55048. WidgetAnnotation.call(this, params);
  55049. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  55050. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  55051. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  55052. alignment = null;
  55053. }
  55054. this.data.textAlignment = alignment;
  55055. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  55056. if (!isInt(maximumLength) || maximumLength < 0) {
  55057. maximumLength = null;
  55058. }
  55059. this.data.maxLen = maximumLength;
  55060. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  55061. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  55062. }
  55063. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  55064. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  55065. var operatorList = new OperatorList();
  55066. if (renderForms) {
  55067. return Promise.resolve(operatorList);
  55068. }
  55069. if (this.appearance) {
  55070. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  55071. }
  55072. if (!this.data.defaultAppearance) {
  55073. return Promise.resolve(operatorList);
  55074. }
  55075. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  55076. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  55077. return operatorList;
  55078. });
  55079. }
  55080. });
  55081. return TextWidgetAnnotation;
  55082. }();
  55083. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  55084. function ButtonWidgetAnnotation(params) {
  55085. WidgetAnnotation.call(this, params);
  55086. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  55087. if (this.data.checkBox) {
  55088. if (!isName(this.data.fieldValue)) {
  55089. return;
  55090. }
  55091. this.data.fieldValue = this.data.fieldValue.name;
  55092. }
  55093. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  55094. if (this.data.radioButton) {
  55095. this.data.fieldValue = this.data.buttonValue = null;
  55096. var fieldParent = params.dict.get('Parent');
  55097. if (!isDict(fieldParent) || !fieldParent.has('V')) {
  55098. return;
  55099. }
  55100. var fieldParentValue = fieldParent.get('V');
  55101. if (!isName(fieldParentValue)) {
  55102. return;
  55103. }
  55104. this.data.fieldValue = fieldParentValue.name;
  55105. var appearanceStates = params.dict.get('AP');
  55106. if (!isDict(appearanceStates)) {
  55107. return;
  55108. }
  55109. var normalAppearanceState = appearanceStates.get('N');
  55110. if (!isDict(normalAppearanceState)) {
  55111. return;
  55112. }
  55113. var keys = normalAppearanceState.getKeys();
  55114. for (var i = 0, ii = keys.length; i < ii; i++) {
  55115. if (keys[i] !== 'Off') {
  55116. this.data.buttonValue = keys[i];
  55117. break;
  55118. }
  55119. }
  55120. }
  55121. }
  55122. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  55123. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  55124. var operatorList = new OperatorList();
  55125. if (renderForms) {
  55126. return Promise.resolve(operatorList);
  55127. }
  55128. if (this.appearance) {
  55129. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  55130. }
  55131. return Promise.resolve(operatorList);
  55132. }
  55133. });
  55134. return ButtonWidgetAnnotation;
  55135. }();
  55136. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  55137. function ChoiceWidgetAnnotation(params) {
  55138. WidgetAnnotation.call(this, params);
  55139. this.data.options = [];
  55140. var options = params.dict.get('Opt');
  55141. if (isArray(options)) {
  55142. var xref = params.xref;
  55143. for (var i = 0, ii = options.length; i < ii; i++) {
  55144. var option = xref.fetchIfRef(options[i]);
  55145. var isOptionArray = isArray(option);
  55146. this.data.options[i] = {
  55147. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  55148. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  55149. };
  55150. }
  55151. }
  55152. if (!isArray(this.data.fieldValue)) {
  55153. this.data.fieldValue = [this.data.fieldValue];
  55154. }
  55155. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  55156. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  55157. }
  55158. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  55159. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  55160. var operatorList = new OperatorList();
  55161. if (renderForms) {
  55162. return Promise.resolve(operatorList);
  55163. }
  55164. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  55165. }
  55166. });
  55167. return ChoiceWidgetAnnotation;
  55168. }();
  55169. var TextAnnotation = function TextAnnotationClosure() {
  55170. var DEFAULT_ICON_SIZE = 22;
  55171. function TextAnnotation(parameters) {
  55172. Annotation.call(this, parameters);
  55173. this.data.annotationType = AnnotationType.TEXT;
  55174. if (this.data.hasAppearance) {
  55175. this.data.name = 'NoIcon';
  55176. } else {
  55177. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  55178. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  55179. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  55180. }
  55181. this._preparePopup(parameters.dict);
  55182. }
  55183. Util.inherit(TextAnnotation, Annotation, {});
  55184. return TextAnnotation;
  55185. }();
  55186. var LinkAnnotation = function LinkAnnotationClosure() {
  55187. function LinkAnnotation(params) {
  55188. Annotation.call(this, params);
  55189. var data = this.data;
  55190. data.annotationType = AnnotationType.LINK;
  55191. Catalog.parseDestDictionary({
  55192. destDict: params.dict,
  55193. resultObj: data,
  55194. docBaseUrl: params.pdfManager.docBaseUrl
  55195. });
  55196. }
  55197. Util.inherit(LinkAnnotation, Annotation, {});
  55198. return LinkAnnotation;
  55199. }();
  55200. var PopupAnnotation = function PopupAnnotationClosure() {
  55201. function PopupAnnotation(parameters) {
  55202. Annotation.call(this, parameters);
  55203. this.data.annotationType = AnnotationType.POPUP;
  55204. var dict = parameters.dict;
  55205. var parentItem = dict.get('Parent');
  55206. if (!parentItem) {
  55207. warn('Popup annotation has a missing or invalid parent annotation.');
  55208. return;
  55209. }
  55210. this.data.parentId = dict.getRaw('Parent').toString();
  55211. this.data.title = stringToPDFString(parentItem.get('T') || '');
  55212. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  55213. if (!parentItem.has('C')) {
  55214. this.data.color = null;
  55215. } else {
  55216. this.setColor(parentItem.getArray('C'));
  55217. this.data.color = this.color;
  55218. }
  55219. if (!this.viewable) {
  55220. var parentFlags = parentItem.get('F');
  55221. if (this._isViewable(parentFlags)) {
  55222. this.setFlags(parentFlags);
  55223. }
  55224. }
  55225. }
  55226. Util.inherit(PopupAnnotation, Annotation, {});
  55227. return PopupAnnotation;
  55228. }();
  55229. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55230. function HighlightAnnotation(parameters) {
  55231. Annotation.call(this, parameters);
  55232. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55233. this._preparePopup(parameters.dict);
  55234. this.data.borderStyle.setWidth(0);
  55235. }
  55236. Util.inherit(HighlightAnnotation, Annotation, {});
  55237. return HighlightAnnotation;
  55238. }();
  55239. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55240. function UnderlineAnnotation(parameters) {
  55241. Annotation.call(this, parameters);
  55242. this.data.annotationType = AnnotationType.UNDERLINE;
  55243. this._preparePopup(parameters.dict);
  55244. this.data.borderStyle.setWidth(0);
  55245. }
  55246. Util.inherit(UnderlineAnnotation, Annotation, {});
  55247. return UnderlineAnnotation;
  55248. }();
  55249. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55250. function SquigglyAnnotation(parameters) {
  55251. Annotation.call(this, parameters);
  55252. this.data.annotationType = AnnotationType.SQUIGGLY;
  55253. this._preparePopup(parameters.dict);
  55254. this.data.borderStyle.setWidth(0);
  55255. }
  55256. Util.inherit(SquigglyAnnotation, Annotation, {});
  55257. return SquigglyAnnotation;
  55258. }();
  55259. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55260. function StrikeOutAnnotation(parameters) {
  55261. Annotation.call(this, parameters);
  55262. this.data.annotationType = AnnotationType.STRIKEOUT;
  55263. this._preparePopup(parameters.dict);
  55264. this.data.borderStyle.setWidth(0);
  55265. }
  55266. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55267. return StrikeOutAnnotation;
  55268. }();
  55269. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55270. function FileAttachmentAnnotation(parameters) {
  55271. Annotation.call(this, parameters);
  55272. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55273. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55274. this.data.file = file.serializable;
  55275. this._preparePopup(parameters.dict);
  55276. }
  55277. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55278. return FileAttachmentAnnotation;
  55279. }();
  55280. exports.Annotation = Annotation;
  55281. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55282. exports.AnnotationFactory = AnnotationFactory;
  55283. }));
  55284. (function (root, factory) {
  55285. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55286. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55287. var MissingDataException = sharedUtil.MissingDataException;
  55288. var Util = sharedUtil.Util;
  55289. var assert = sharedUtil.assert;
  55290. var error = sharedUtil.error;
  55291. var info = sharedUtil.info;
  55292. var isArray = sharedUtil.isArray;
  55293. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55294. var isNum = sharedUtil.isNum;
  55295. var isString = sharedUtil.isString;
  55296. var shadow = sharedUtil.shadow;
  55297. var stringToBytes = sharedUtil.stringToBytes;
  55298. var stringToPDFString = sharedUtil.stringToPDFString;
  55299. var warn = sharedUtil.warn;
  55300. var isSpace = sharedUtil.isSpace;
  55301. var Dict = corePrimitives.Dict;
  55302. var isDict = corePrimitives.isDict;
  55303. var isName = corePrimitives.isName;
  55304. var isStream = corePrimitives.isStream;
  55305. var NullStream = coreStream.NullStream;
  55306. var Stream = coreStream.Stream;
  55307. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55308. var Catalog = coreObj.Catalog;
  55309. var ObjectLoader = coreObj.ObjectLoader;
  55310. var XRef = coreObj.XRef;
  55311. var Linearization = coreParser.Linearization;
  55312. var calculateMD5 = coreCrypto.calculateMD5;
  55313. var OperatorList = coreEvaluator.OperatorList;
  55314. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55315. var Annotation = coreAnnotation.Annotation;
  55316. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55317. var Page = function PageClosure() {
  55318. var DEFAULT_USER_UNIT = 1.0;
  55319. var LETTER_SIZE_MEDIABOX = [
  55320. 0,
  55321. 0,
  55322. 612,
  55323. 792
  55324. ];
  55325. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55326. this.pdfManager = pdfManager;
  55327. this.pageIndex = pageIndex;
  55328. this.pageDict = pageDict;
  55329. this.xref = xref;
  55330. this.ref = ref;
  55331. this.fontCache = fontCache;
  55332. this.uniquePrefix = 'p' + this.pageIndex + '_';
  55333. this.idCounters = { obj: 0 };
  55334. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55335. this.resourcesPromise = null;
  55336. }
  55337. Page.prototype = {
  55338. getPageProp: function Page_getPageProp(key) {
  55339. return this.pageDict.get(key);
  55340. },
  55341. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  55342. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55343. var MAX_LOOP_COUNT = 100;
  55344. getArray = getArray || false;
  55345. while (dict) {
  55346. var value = getArray ? dict.getArray(key) : dict.get(key);
  55347. if (value) {
  55348. if (!valueArray) {
  55349. valueArray = [];
  55350. }
  55351. valueArray.push(value);
  55352. }
  55353. if (++loopCount > MAX_LOOP_COUNT) {
  55354. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55355. break;
  55356. }
  55357. dict = dict.get('Parent');
  55358. }
  55359. if (!valueArray) {
  55360. return Dict.empty;
  55361. }
  55362. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55363. return valueArray[0];
  55364. }
  55365. return Dict.merge(this.xref, valueArray);
  55366. },
  55367. get content() {
  55368. return this.getPageProp('Contents');
  55369. },
  55370. get resources() {
  55371. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55372. },
  55373. get mediaBox() {
  55374. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  55375. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  55376. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  55377. }
  55378. return shadow(this, 'mediaBox', mediaBox);
  55379. },
  55380. get cropBox() {
  55381. var cropBox = this.getInheritedPageProp('CropBox', true);
  55382. if (!isArray(cropBox) || cropBox.length !== 4) {
  55383. return shadow(this, 'cropBox', this.mediaBox);
  55384. }
  55385. return shadow(this, 'cropBox', cropBox);
  55386. },
  55387. get userUnit() {
  55388. var obj = this.getPageProp('UserUnit');
  55389. if (!isNum(obj) || obj <= 0) {
  55390. obj = DEFAULT_USER_UNIT;
  55391. }
  55392. return shadow(this, 'userUnit', obj);
  55393. },
  55394. get view() {
  55395. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  55396. if (mediaBox === cropBox) {
  55397. return shadow(this, 'view', mediaBox);
  55398. }
  55399. var intersection = Util.intersect(cropBox, mediaBox);
  55400. return shadow(this, 'view', intersection || mediaBox);
  55401. },
  55402. get rotate() {
  55403. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55404. if (rotate % 90 !== 0) {
  55405. rotate = 0;
  55406. } else if (rotate >= 360) {
  55407. rotate = rotate % 360;
  55408. } else if (rotate < 0) {
  55409. rotate = (rotate % 360 + 360) % 360;
  55410. }
  55411. return shadow(this, 'rotate', rotate);
  55412. },
  55413. getContentStream: function Page_getContentStream() {
  55414. var content = this.content;
  55415. var stream;
  55416. if (isArray(content)) {
  55417. var xref = this.xref;
  55418. var i, n = content.length;
  55419. var streams = [];
  55420. for (i = 0; i < n; ++i) {
  55421. streams.push(xref.fetchIfRef(content[i]));
  55422. }
  55423. stream = new StreamsSequenceStream(streams);
  55424. } else if (isStream(content)) {
  55425. stream = content;
  55426. } else {
  55427. stream = new NullStream();
  55428. }
  55429. return stream;
  55430. },
  55431. loadResources: function Page_loadResources(keys) {
  55432. if (!this.resourcesPromise) {
  55433. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55434. }
  55435. return this.resourcesPromise.then(function resourceSuccess() {
  55436. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55437. return objectLoader.load();
  55438. }.bind(this));
  55439. },
  55440. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55441. var self = this;
  55442. var pdfManager = this.pdfManager;
  55443. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55444. var resourcesPromise = this.loadResources([
  55445. 'ExtGState',
  55446. 'ColorSpace',
  55447. 'Pattern',
  55448. 'Shading',
  55449. 'XObject',
  55450. 'Font'
  55451. ]);
  55452. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  55453. var dataPromises = Promise.all([
  55454. contentStreamPromise,
  55455. resourcesPromise
  55456. ]);
  55457. var pageListPromise = dataPromises.then(function (data) {
  55458. var contentStream = data[0];
  55459. var opList = new OperatorList(intent, handler, self.pageIndex);
  55460. handler.send('StartRenderPage', {
  55461. transparency: partialEvaluator.hasBlendModes(self.resources),
  55462. pageIndex: self.pageIndex,
  55463. intent: intent
  55464. });
  55465. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55466. return opList;
  55467. });
  55468. });
  55469. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55470. return Promise.all([
  55471. pageListPromise,
  55472. annotationsPromise
  55473. ]).then(function (datas) {
  55474. var pageOpList = datas[0];
  55475. var annotations = datas[1];
  55476. if (annotations.length === 0) {
  55477. pageOpList.flush(true);
  55478. return pageOpList;
  55479. }
  55480. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55481. return annotationsReadyPromise.then(function () {
  55482. pageOpList.flush(true);
  55483. return pageOpList;
  55484. });
  55485. });
  55486. },
  55487. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55488. var handler = {
  55489. on: function nullHandlerOn() {
  55490. },
  55491. send: function nullHandlerSend() {
  55492. }
  55493. };
  55494. var self = this;
  55495. var pdfManager = this.pdfManager;
  55496. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55497. var resourcesPromise = this.loadResources([
  55498. 'ExtGState',
  55499. 'XObject',
  55500. 'Font'
  55501. ]);
  55502. var dataPromises = Promise.all([
  55503. contentStreamPromise,
  55504. resourcesPromise
  55505. ]);
  55506. return dataPromises.then(function (data) {
  55507. var contentStream = data[0];
  55508. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  55509. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55510. });
  55511. },
  55512. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55513. var annotations = this.annotations;
  55514. var annotationsData = [];
  55515. for (var i = 0, n = annotations.length; i < n; ++i) {
  55516. if (intent) {
  55517. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55518. continue;
  55519. }
  55520. }
  55521. annotationsData.push(annotations[i].data);
  55522. }
  55523. return annotationsData;
  55524. },
  55525. get annotations() {
  55526. var annotations = [];
  55527. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55528. var annotationFactory = new AnnotationFactory();
  55529. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55530. var annotationRef = annotationRefs[i];
  55531. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  55532. if (annotation) {
  55533. annotations.push(annotation);
  55534. }
  55535. }
  55536. return shadow(this, 'annotations', annotations);
  55537. }
  55538. };
  55539. return Page;
  55540. }();
  55541. var PDFDocument = function PDFDocumentClosure() {
  55542. var FINGERPRINT_FIRST_BYTES = 1024;
  55543. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55544. function PDFDocument(pdfManager, arg, password) {
  55545. if (isStream(arg)) {
  55546. init.call(this, pdfManager, arg, password);
  55547. } else if (isArrayBuffer(arg)) {
  55548. init.call(this, pdfManager, new Stream(arg), password);
  55549. } else {
  55550. error('PDFDocument: Unknown argument type');
  55551. }
  55552. }
  55553. function init(pdfManager, stream, password) {
  55554. assert(stream.length > 0, 'stream must have data');
  55555. this.pdfManager = pdfManager;
  55556. this.stream = stream;
  55557. var xref = new XRef(this.stream, password, pdfManager);
  55558. this.xref = xref;
  55559. }
  55560. function find(stream, needle, limit, backwards) {
  55561. var pos = stream.pos;
  55562. var end = stream.end;
  55563. var strBuf = [];
  55564. if (pos + limit > end) {
  55565. limit = end - pos;
  55566. }
  55567. for (var n = 0; n < limit; ++n) {
  55568. strBuf.push(String.fromCharCode(stream.getByte()));
  55569. }
  55570. var str = strBuf.join('');
  55571. stream.pos = pos;
  55572. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55573. if (index === -1) {
  55574. return false;
  55575. }
  55576. stream.pos += index;
  55577. return true;
  55578. }
  55579. var DocumentInfoValidators = {
  55580. get entries() {
  55581. return shadow(this, 'entries', {
  55582. Title: isString,
  55583. Author: isString,
  55584. Subject: isString,
  55585. Keywords: isString,
  55586. Creator: isString,
  55587. Producer: isString,
  55588. CreationDate: isString,
  55589. ModDate: isString,
  55590. Trapped: isName
  55591. });
  55592. }
  55593. };
  55594. PDFDocument.prototype = {
  55595. parse: function PDFDocument_parse(recoveryMode) {
  55596. this.setup(recoveryMode);
  55597. var version = this.catalog.catDict.get('Version');
  55598. if (isName(version)) {
  55599. this.pdfFormatVersion = version.name;
  55600. }
  55601. try {
  55602. this.acroForm = this.catalog.catDict.get('AcroForm');
  55603. if (this.acroForm) {
  55604. this.xfa = this.acroForm.get('XFA');
  55605. var fields = this.acroForm.get('Fields');
  55606. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55607. this.acroForm = null;
  55608. }
  55609. }
  55610. } catch (ex) {
  55611. info('Something wrong with AcroForm entry');
  55612. this.acroForm = null;
  55613. }
  55614. },
  55615. get linearization() {
  55616. var linearization = null;
  55617. if (this.stream.length) {
  55618. try {
  55619. linearization = Linearization.create(this.stream);
  55620. } catch (err) {
  55621. if (err instanceof MissingDataException) {
  55622. throw err;
  55623. }
  55624. info(err);
  55625. }
  55626. }
  55627. return shadow(this, 'linearization', linearization);
  55628. },
  55629. get startXRef() {
  55630. var stream = this.stream;
  55631. var startXRef = 0;
  55632. var linearization = this.linearization;
  55633. if (linearization) {
  55634. stream.reset();
  55635. if (find(stream, 'endobj', 1024)) {
  55636. startXRef = stream.pos + 6;
  55637. }
  55638. } else {
  55639. var step = 1024;
  55640. var found = false, pos = stream.end;
  55641. while (!found && pos > 0) {
  55642. pos -= step - 'startxref'.length;
  55643. if (pos < 0) {
  55644. pos = 0;
  55645. }
  55646. stream.pos = pos;
  55647. found = find(stream, 'startxref', step, true);
  55648. }
  55649. if (found) {
  55650. stream.skip(9);
  55651. var ch;
  55652. do {
  55653. ch = stream.getByte();
  55654. } while (isSpace(ch));
  55655. var str = '';
  55656. while (ch >= 0x20 && ch <= 0x39) {
  55657. str += String.fromCharCode(ch);
  55658. ch = stream.getByte();
  55659. }
  55660. startXRef = parseInt(str, 10);
  55661. if (isNaN(startXRef)) {
  55662. startXRef = 0;
  55663. }
  55664. }
  55665. }
  55666. return shadow(this, 'startXRef', startXRef);
  55667. },
  55668. get mainXRefEntriesOffset() {
  55669. var mainXRefEntriesOffset = 0;
  55670. var linearization = this.linearization;
  55671. if (linearization) {
  55672. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55673. }
  55674. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55675. },
  55676. checkHeader: function PDFDocument_checkHeader() {
  55677. var stream = this.stream;
  55678. stream.reset();
  55679. if (find(stream, '%PDF-', 1024)) {
  55680. stream.moveStart();
  55681. var MAX_VERSION_LENGTH = 12;
  55682. var version = '', ch;
  55683. while ((ch = stream.getByte()) > 0x20) {
  55684. if (version.length >= MAX_VERSION_LENGTH) {
  55685. break;
  55686. }
  55687. version += String.fromCharCode(ch);
  55688. }
  55689. if (!this.pdfFormatVersion) {
  55690. this.pdfFormatVersion = version.substring(5);
  55691. }
  55692. return;
  55693. }
  55694. },
  55695. parseStartXRef: function PDFDocument_parseStartXRef() {
  55696. var startXRef = this.startXRef;
  55697. this.xref.setStartXRef(startXRef);
  55698. },
  55699. setup: function PDFDocument_setup(recoveryMode) {
  55700. this.xref.parse(recoveryMode);
  55701. var self = this;
  55702. var pageFactory = {
  55703. createPage: function (pageIndex, dict, ref, fontCache) {
  55704. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55705. }
  55706. };
  55707. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55708. },
  55709. get numPages() {
  55710. var linearization = this.linearization;
  55711. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55712. return shadow(this, 'numPages', num);
  55713. },
  55714. get documentInfo() {
  55715. var docInfo = {
  55716. PDFFormatVersion: this.pdfFormatVersion,
  55717. IsAcroFormPresent: !!this.acroForm,
  55718. IsXFAPresent: !!this.xfa
  55719. };
  55720. var infoDict;
  55721. try {
  55722. infoDict = this.xref.trailer.get('Info');
  55723. } catch (err) {
  55724. info('The document information dictionary is invalid.');
  55725. }
  55726. if (infoDict) {
  55727. var validEntries = DocumentInfoValidators.entries;
  55728. for (var key in validEntries) {
  55729. if (infoDict.has(key)) {
  55730. var value = infoDict.get(key);
  55731. if (validEntries[key](value)) {
  55732. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55733. } else {
  55734. info('Bad value in document info for "' + key + '"');
  55735. }
  55736. }
  55737. }
  55738. }
  55739. return shadow(this, 'documentInfo', docInfo);
  55740. },
  55741. get fingerprint() {
  55742. var xref = this.xref, hash, fileID = '';
  55743. var idArray = xref.trailer.get('ID');
  55744. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55745. hash = stringToBytes(idArray[0]);
  55746. } else {
  55747. if (this.stream.ensureRange) {
  55748. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55749. }
  55750. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55751. }
  55752. for (var i = 0, n = hash.length; i < n; i++) {
  55753. var hex = hash[i].toString(16);
  55754. fileID += hex.length === 1 ? '0' + hex : hex;
  55755. }
  55756. return shadow(this, 'fingerprint', fileID);
  55757. },
  55758. getPage: function PDFDocument_getPage(pageIndex) {
  55759. return this.catalog.getPage(pageIndex);
  55760. },
  55761. cleanup: function PDFDocument_cleanup() {
  55762. return this.catalog.cleanup();
  55763. }
  55764. };
  55765. return PDFDocument;
  55766. }();
  55767. exports.Page = Page;
  55768. exports.PDFDocument = PDFDocument;
  55769. }));
  55770. (function (root, factory) {
  55771. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55772. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55773. var warn = sharedUtil.warn;
  55774. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55775. var shadow = sharedUtil.shadow;
  55776. var NotImplementedException = sharedUtil.NotImplementedException;
  55777. var MissingDataException = sharedUtil.MissingDataException;
  55778. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55779. var Util = sharedUtil.Util;
  55780. var Stream = coreStream.Stream;
  55781. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55782. var PDFDocument = coreDocument.PDFDocument;
  55783. var BasePdfManager = function BasePdfManagerClosure() {
  55784. function BasePdfManager() {
  55785. throw new Error('Cannot initialize BaseManagerManager');
  55786. }
  55787. BasePdfManager.prototype = {
  55788. get docId() {
  55789. return this._docId;
  55790. },
  55791. get docBaseUrl() {
  55792. var docBaseUrl = null;
  55793. if (this._docBaseUrl) {
  55794. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55795. if (absoluteUrl) {
  55796. docBaseUrl = absoluteUrl.href;
  55797. } else {
  55798. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55799. }
  55800. }
  55801. return shadow(this, 'docBaseUrl', docBaseUrl);
  55802. },
  55803. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55804. throw new NotImplementedException();
  55805. },
  55806. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55807. return this.ensure(this.pdfDocument, prop, args);
  55808. },
  55809. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55810. return this.ensure(this.pdfDocument.xref, prop, args);
  55811. },
  55812. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55813. return this.ensure(this.pdfDocument.catalog, prop, args);
  55814. },
  55815. getPage: function BasePdfManager_getPage(pageIndex) {
  55816. return this.pdfDocument.getPage(pageIndex);
  55817. },
  55818. cleanup: function BasePdfManager_cleanup() {
  55819. return this.pdfDocument.cleanup();
  55820. },
  55821. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55822. return new NotImplementedException();
  55823. },
  55824. requestRange: function BasePdfManager_requestRange(begin, end) {
  55825. return new NotImplementedException();
  55826. },
  55827. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55828. return new NotImplementedException();
  55829. },
  55830. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55831. return new NotImplementedException();
  55832. },
  55833. updatePassword: function BasePdfManager_updatePassword(password) {
  55834. this.pdfDocument.xref.password = this.password = password;
  55835. if (this._passwordChangedCapability) {
  55836. this._passwordChangedCapability.resolve();
  55837. }
  55838. },
  55839. passwordChanged: function BasePdfManager_passwordChanged() {
  55840. this._passwordChangedCapability = createPromiseCapability();
  55841. return this._passwordChangedCapability.promise;
  55842. },
  55843. terminate: function BasePdfManager_terminate() {
  55844. return new NotImplementedException();
  55845. }
  55846. };
  55847. return BasePdfManager;
  55848. }();
  55849. var LocalPdfManager = function LocalPdfManagerClosure() {
  55850. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55851. this._docId = docId;
  55852. this._docBaseUrl = docBaseUrl;
  55853. this.evaluatorOptions = evaluatorOptions;
  55854. var stream = new Stream(data);
  55855. this.pdfDocument = new PDFDocument(this, stream, password);
  55856. this._loadedStreamCapability = createPromiseCapability();
  55857. this._loadedStreamCapability.resolve(stream);
  55858. }
  55859. Util.inherit(LocalPdfManager, BasePdfManager, {
  55860. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55861. return new Promise(function (resolve, reject) {
  55862. try {
  55863. var value = obj[prop];
  55864. var result;
  55865. if (typeof value === 'function') {
  55866. result = value.apply(obj, args);
  55867. } else {
  55868. result = value;
  55869. }
  55870. resolve(result);
  55871. } catch (e) {
  55872. reject(e);
  55873. }
  55874. });
  55875. },
  55876. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55877. return Promise.resolve();
  55878. },
  55879. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55880. return;
  55881. },
  55882. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55883. return this._loadedStreamCapability.promise;
  55884. },
  55885. terminate: function LocalPdfManager_terminate() {
  55886. return;
  55887. }
  55888. });
  55889. return LocalPdfManager;
  55890. }();
  55891. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55892. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55893. this._docId = docId;
  55894. this._docBaseUrl = docBaseUrl;
  55895. this.msgHandler = args.msgHandler;
  55896. this.evaluatorOptions = evaluatorOptions;
  55897. var params = {
  55898. msgHandler: args.msgHandler,
  55899. url: args.url,
  55900. length: args.length,
  55901. disableAutoFetch: args.disableAutoFetch,
  55902. rangeChunkSize: args.rangeChunkSize
  55903. };
  55904. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55905. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  55906. }
  55907. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55908. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55909. var pdfManager = this;
  55910. return new Promise(function (resolve, reject) {
  55911. function ensureHelper() {
  55912. try {
  55913. var result;
  55914. var value = obj[prop];
  55915. if (typeof value === 'function') {
  55916. result = value.apply(obj, args);
  55917. } else {
  55918. result = value;
  55919. }
  55920. resolve(result);
  55921. } catch (e) {
  55922. if (!(e instanceof MissingDataException)) {
  55923. reject(e);
  55924. return;
  55925. }
  55926. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55927. }
  55928. }
  55929. ensureHelper();
  55930. });
  55931. },
  55932. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55933. return this.streamManager.requestRange(begin, end);
  55934. },
  55935. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55936. this.streamManager.requestAllChunks();
  55937. },
  55938. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55939. this.streamManager.onReceiveData({ chunk: chunk });
  55940. },
  55941. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55942. return this.streamManager.onLoadedStream();
  55943. },
  55944. terminate: function NetworkPdfManager_terminate() {
  55945. this.streamManager.abort();
  55946. }
  55947. });
  55948. return NetworkPdfManager;
  55949. }();
  55950. exports.LocalPdfManager = LocalPdfManager;
  55951. exports.NetworkPdfManager = NetworkPdfManager;
  55952. }));
  55953. (function (root, factory) {
  55954. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55955. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55956. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55957. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55958. var MessageHandler = sharedUtil.MessageHandler;
  55959. var MissingPDFException = sharedUtil.MissingPDFException;
  55960. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55961. var PasswordException = sharedUtil.PasswordException;
  55962. var PasswordResponses = sharedUtil.PasswordResponses;
  55963. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55964. var XRefParseException = sharedUtil.XRefParseException;
  55965. var arrayByteLength = sharedUtil.arrayByteLength;
  55966. var arraysToBytes = sharedUtil.arraysToBytes;
  55967. var assert = sharedUtil.assert;
  55968. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55969. var error = sharedUtil.error;
  55970. var info = sharedUtil.info;
  55971. var warn = sharedUtil.warn;
  55972. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55973. var Ref = corePrimitives.Ref;
  55974. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55975. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55976. var globalScope = sharedUtil.globalScope;
  55977. var WorkerTask = function WorkerTaskClosure() {
  55978. function WorkerTask(name) {
  55979. this.name = name;
  55980. this.terminated = false;
  55981. this._capability = createPromiseCapability();
  55982. }
  55983. WorkerTask.prototype = {
  55984. get finished() {
  55985. return this._capability.promise;
  55986. },
  55987. finish: function () {
  55988. this._capability.resolve();
  55989. },
  55990. terminate: function () {
  55991. this.terminated = true;
  55992. },
  55993. ensureNotTerminated: function () {
  55994. if (this.terminated) {
  55995. throw new Error('Worker task was terminated');
  55996. }
  55997. }
  55998. };
  55999. return WorkerTask;
  56000. }();
  56001. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  56002. function PDFWorkerStream(params, msgHandler) {
  56003. this._queuedChunks = [];
  56004. var initialData = params.initialData;
  56005. if (initialData && initialData.length > 0) {
  56006. this._queuedChunks.push(initialData);
  56007. }
  56008. this._msgHandler = msgHandler;
  56009. this._isRangeSupported = !params.disableRange;
  56010. this._isStreamingSupported = !params.disableStream;
  56011. this._contentLength = params.length;
  56012. this._fullRequestReader = null;
  56013. this._rangeReaders = [];
  56014. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  56015. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  56016. }
  56017. PDFWorkerStream.prototype = {
  56018. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  56019. if (args.begin === undefined) {
  56020. if (this._fullRequestReader) {
  56021. this._fullRequestReader._enqueue(args.chunk);
  56022. } else {
  56023. this._queuedChunks.push(args.chunk);
  56024. }
  56025. } else {
  56026. var found = this._rangeReaders.some(function (rangeReader) {
  56027. if (rangeReader._begin !== args.begin) {
  56028. return false;
  56029. }
  56030. rangeReader._enqueue(args.chunk);
  56031. return true;
  56032. });
  56033. assert(found);
  56034. }
  56035. },
  56036. _onProgress: function PDFWorkerStream_onProgress(evt) {
  56037. if (this._rangeReaders.length > 0) {
  56038. var firstReader = this._rangeReaders[0];
  56039. if (firstReader.onProgress) {
  56040. firstReader.onProgress({ loaded: evt.loaded });
  56041. }
  56042. }
  56043. },
  56044. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  56045. var i = this._rangeReaders.indexOf(reader);
  56046. if (i >= 0) {
  56047. this._rangeReaders.splice(i, 1);
  56048. }
  56049. },
  56050. getFullReader: function PDFWorkerStream_getFullReader() {
  56051. assert(!this._fullRequestReader);
  56052. var queuedChunks = this._queuedChunks;
  56053. this._queuedChunks = null;
  56054. return new PDFWorkerStreamReader(this, queuedChunks);
  56055. },
  56056. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  56057. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  56058. this._msgHandler.send('RequestDataRange', {
  56059. begin: begin,
  56060. end: end
  56061. });
  56062. this._rangeReaders.push(reader);
  56063. return reader;
  56064. },
  56065. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  56066. if (this._fullRequestReader) {
  56067. this._fullRequestReader.cancel(reason);
  56068. }
  56069. var readers = this._rangeReaders.slice(0);
  56070. readers.forEach(function (rangeReader) {
  56071. rangeReader.cancel(reason);
  56072. });
  56073. }
  56074. };
  56075. function PDFWorkerStreamReader(stream, queuedChunks) {
  56076. this._stream = stream;
  56077. this._done = false;
  56078. this._queuedChunks = queuedChunks || [];
  56079. this._requests = [];
  56080. this._headersReady = Promise.resolve();
  56081. stream._fullRequestReader = this;
  56082. this.onProgress = null;
  56083. }
  56084. PDFWorkerStreamReader.prototype = {
  56085. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  56086. if (this._done) {
  56087. return;
  56088. }
  56089. if (this._requests.length > 0) {
  56090. var requestCapability = this._requests.shift();
  56091. requestCapability.resolve({
  56092. value: chunk,
  56093. done: false
  56094. });
  56095. return;
  56096. }
  56097. this._queuedChunks.push(chunk);
  56098. },
  56099. get headersReady() {
  56100. return this._headersReady;
  56101. },
  56102. get isRangeSupported() {
  56103. return this._stream._isRangeSupported;
  56104. },
  56105. get isStreamingSupported() {
  56106. return this._stream._isStreamingSupported;
  56107. },
  56108. get contentLength() {
  56109. return this._stream._contentLength;
  56110. },
  56111. read: function PDFWorkerStreamReader_read() {
  56112. if (this._queuedChunks.length > 0) {
  56113. var chunk = this._queuedChunks.shift();
  56114. return Promise.resolve({
  56115. value: chunk,
  56116. done: false
  56117. });
  56118. }
  56119. if (this._done) {
  56120. return Promise.resolve({
  56121. value: undefined,
  56122. done: true
  56123. });
  56124. }
  56125. var requestCapability = createPromiseCapability();
  56126. this._requests.push(requestCapability);
  56127. return requestCapability.promise;
  56128. },
  56129. cancel: function PDFWorkerStreamReader_cancel(reason) {
  56130. this._done = true;
  56131. this._requests.forEach(function (requestCapability) {
  56132. requestCapability.resolve({
  56133. value: undefined,
  56134. done: true
  56135. });
  56136. });
  56137. this._requests = [];
  56138. }
  56139. };
  56140. function PDFWorkerStreamRangeReader(stream, begin, end) {
  56141. this._stream = stream;
  56142. this._begin = begin;
  56143. this._end = end;
  56144. this._queuedChunk = null;
  56145. this._requests = [];
  56146. this._done = false;
  56147. this.onProgress = null;
  56148. }
  56149. PDFWorkerStreamRangeReader.prototype = {
  56150. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  56151. if (this._done) {
  56152. return;
  56153. }
  56154. if (this._requests.length === 0) {
  56155. this._queuedChunk = chunk;
  56156. } else {
  56157. var requestsCapability = this._requests.shift();
  56158. requestsCapability.resolve({
  56159. value: chunk,
  56160. done: false
  56161. });
  56162. this._requests.forEach(function (requestCapability) {
  56163. requestCapability.resolve({
  56164. value: undefined,
  56165. done: true
  56166. });
  56167. });
  56168. this._requests = [];
  56169. }
  56170. this._done = true;
  56171. this._stream._removeRangeReader(this);
  56172. },
  56173. get isStreamingSupported() {
  56174. return false;
  56175. },
  56176. read: function PDFWorkerStreamRangeReader_read() {
  56177. if (this._queuedChunk) {
  56178. return Promise.resolve({
  56179. value: this._queuedChunk,
  56180. done: false
  56181. });
  56182. }
  56183. if (this._done) {
  56184. return Promise.resolve({
  56185. value: undefined,
  56186. done: true
  56187. });
  56188. }
  56189. var requestCapability = createPromiseCapability();
  56190. this._requests.push(requestCapability);
  56191. return requestCapability.promise;
  56192. },
  56193. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  56194. this._done = true;
  56195. this._requests.forEach(function (requestCapability) {
  56196. requestCapability.resolve({
  56197. value: undefined,
  56198. done: true
  56199. });
  56200. });
  56201. this._requests = [];
  56202. this._stream._removeRangeReader(this);
  56203. }
  56204. };
  56205. return PDFWorkerStream;
  56206. }();
  56207. var PDFNetworkStream;
  56208. function setPDFNetworkStreamClass(cls) {
  56209. PDFNetworkStream = cls;
  56210. }
  56211. var WorkerMessageHandler = {
  56212. setup: function wphSetup(handler, port) {
  56213. var testMessageProcessed = false;
  56214. handler.on('test', function wphSetupTest(data) {
  56215. if (testMessageProcessed) {
  56216. return;
  56217. }
  56218. testMessageProcessed = true;
  56219. if (!(data instanceof Uint8Array)) {
  56220. handler.send('test', 'main', false);
  56221. return;
  56222. }
  56223. var supportTransfers = data[0] === 255;
  56224. handler.postMessageTransfers = supportTransfers;
  56225. var xhr = new XMLHttpRequest();
  56226. var responseExists = 'response' in xhr;
  56227. try {
  56228. var dummy = xhr.responseType;
  56229. } catch (e) {
  56230. responseExists = false;
  56231. }
  56232. if (!responseExists) {
  56233. handler.send('test', false);
  56234. return;
  56235. }
  56236. handler.send('test', {
  56237. supportTypedArray: true,
  56238. supportTransfers: supportTransfers
  56239. });
  56240. });
  56241. handler.on('configure', function wphConfigure(data) {
  56242. setVerbosityLevel(data.verbosity);
  56243. });
  56244. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56245. return WorkerMessageHandler.createDocumentHandler(data, port);
  56246. });
  56247. },
  56248. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56249. var pdfManager;
  56250. var terminated = false;
  56251. var cancelXHRs = null;
  56252. var WorkerTasks = [];
  56253. var docId = docParams.docId;
  56254. var docBaseUrl = docParams.docBaseUrl;
  56255. var workerHandlerName = docParams.docId + '_worker';
  56256. var handler = new MessageHandler(workerHandlerName, docId, port);
  56257. handler.postMessageTransfers = docParams.postMessageTransfers;
  56258. function ensureNotTerminated() {
  56259. if (terminated) {
  56260. throw new Error('Worker was terminated');
  56261. }
  56262. }
  56263. function startWorkerTask(task) {
  56264. WorkerTasks.push(task);
  56265. }
  56266. function finishWorkerTask(task) {
  56267. task.finish();
  56268. var i = WorkerTasks.indexOf(task);
  56269. WorkerTasks.splice(i, 1);
  56270. }
  56271. function loadDocument(recoveryMode) {
  56272. var loadDocumentCapability = createPromiseCapability();
  56273. var parseSuccess = function parseSuccess() {
  56274. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56275. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56276. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56277. Promise.all([
  56278. numPagesPromise,
  56279. fingerprintPromise,
  56280. encryptedPromise
  56281. ]).then(function onDocReady(results) {
  56282. var doc = {
  56283. numPages: results[0],
  56284. fingerprint: results[1],
  56285. encrypted: !!results[2]
  56286. };
  56287. loadDocumentCapability.resolve(doc);
  56288. }, parseFailure);
  56289. };
  56290. var parseFailure = function parseFailure(e) {
  56291. loadDocumentCapability.reject(e);
  56292. };
  56293. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56294. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56295. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56296. }, parseFailure);
  56297. }, parseFailure);
  56298. return loadDocumentCapability.promise;
  56299. }
  56300. function getPdfManager(data, evaluatorOptions) {
  56301. var pdfManagerCapability = createPromiseCapability();
  56302. var pdfManager;
  56303. var source = data.source;
  56304. if (source.data) {
  56305. try {
  56306. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56307. pdfManagerCapability.resolve(pdfManager);
  56308. } catch (ex) {
  56309. pdfManagerCapability.reject(ex);
  56310. }
  56311. return pdfManagerCapability.promise;
  56312. }
  56313. var pdfStream;
  56314. try {
  56315. if (source.chunkedViewerLoading) {
  56316. pdfStream = new PDFWorkerStream(source, handler);
  56317. } else {
  56318. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56319. pdfStream = new PDFNetworkStream(data);
  56320. }
  56321. } catch (ex) {
  56322. pdfManagerCapability.reject(ex);
  56323. return pdfManagerCapability.promise;
  56324. }
  56325. var fullRequest = pdfStream.getFullReader();
  56326. fullRequest.headersReady.then(function () {
  56327. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56328. fullRequest.onProgress = function (evt) {
  56329. handler.send('DocProgress', {
  56330. loaded: evt.loaded,
  56331. total: evt.total
  56332. });
  56333. };
  56334. }
  56335. if (!fullRequest.isRangeSupported) {
  56336. return;
  56337. }
  56338. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56339. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56340. msgHandler: handler,
  56341. url: source.url,
  56342. password: source.password,
  56343. length: fullRequest.contentLength,
  56344. disableAutoFetch: disableAutoFetch,
  56345. rangeChunkSize: source.rangeChunkSize
  56346. }, evaluatorOptions, docBaseUrl);
  56347. pdfManagerCapability.resolve(pdfManager);
  56348. cancelXHRs = null;
  56349. }).catch(function (reason) {
  56350. pdfManagerCapability.reject(reason);
  56351. cancelXHRs = null;
  56352. });
  56353. var cachedChunks = [], loaded = 0;
  56354. var flushChunks = function () {
  56355. var pdfFile = arraysToBytes(cachedChunks);
  56356. if (source.length && pdfFile.length !== source.length) {
  56357. warn('reported HTTP length is different from actual');
  56358. }
  56359. try {
  56360. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56361. pdfManagerCapability.resolve(pdfManager);
  56362. } catch (ex) {
  56363. pdfManagerCapability.reject(ex);
  56364. }
  56365. cachedChunks = [];
  56366. };
  56367. var readPromise = new Promise(function (resolve, reject) {
  56368. var readChunk = function (chunk) {
  56369. try {
  56370. ensureNotTerminated();
  56371. if (chunk.done) {
  56372. if (!pdfManager) {
  56373. flushChunks();
  56374. }
  56375. cancelXHRs = null;
  56376. return;
  56377. }
  56378. var data = chunk.value;
  56379. loaded += arrayByteLength(data);
  56380. if (!fullRequest.isStreamingSupported) {
  56381. handler.send('DocProgress', {
  56382. loaded: loaded,
  56383. total: Math.max(loaded, fullRequest.contentLength || 0)
  56384. });
  56385. }
  56386. if (pdfManager) {
  56387. pdfManager.sendProgressiveData(data);
  56388. } else {
  56389. cachedChunks.push(data);
  56390. }
  56391. fullRequest.read().then(readChunk, reject);
  56392. } catch (e) {
  56393. reject(e);
  56394. }
  56395. };
  56396. fullRequest.read().then(readChunk, reject);
  56397. });
  56398. readPromise.catch(function (e) {
  56399. pdfManagerCapability.reject(e);
  56400. cancelXHRs = null;
  56401. });
  56402. cancelXHRs = function () {
  56403. pdfStream.cancelAllRequests('abort');
  56404. };
  56405. return pdfManagerCapability.promise;
  56406. }
  56407. var setupDoc = function (data) {
  56408. var onSuccess = function (doc) {
  56409. ensureNotTerminated();
  56410. handler.send('GetDoc', { pdfInfo: doc });
  56411. };
  56412. var onFailure = function (e) {
  56413. if (e instanceof PasswordException) {
  56414. if (e.code === PasswordResponses.NEED_PASSWORD) {
  56415. handler.send('NeedPassword', e);
  56416. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  56417. handler.send('IncorrectPassword', e);
  56418. }
  56419. } else if (e instanceof InvalidPDFException) {
  56420. handler.send('InvalidPDF', e);
  56421. } else if (e instanceof MissingPDFException) {
  56422. handler.send('MissingPDF', e);
  56423. } else if (e instanceof UnexpectedResponseException) {
  56424. handler.send('UnexpectedResponse', e);
  56425. } else {
  56426. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56427. }
  56428. };
  56429. ensureNotTerminated();
  56430. var cMapOptions = {
  56431. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56432. packed: data.cMapPacked === true
  56433. };
  56434. var evaluatorOptions = {
  56435. forceDataSchema: data.disableCreateObjectURL,
  56436. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56437. disableFontFace: data.disableFontFace,
  56438. cMapOptions: cMapOptions
  56439. };
  56440. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56441. if (terminated) {
  56442. newPdfManager.terminate();
  56443. throw new Error('Worker was terminated');
  56444. }
  56445. pdfManager = newPdfManager;
  56446. handler.send('PDFManagerReady', null);
  56447. pdfManager.onLoadedStream().then(function (stream) {
  56448. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56449. });
  56450. }).then(function pdfManagerReady() {
  56451. ensureNotTerminated();
  56452. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56453. ensureNotTerminated();
  56454. if (!(ex instanceof XRefParseException)) {
  56455. if (ex instanceof PasswordException) {
  56456. pdfManager.passwordChanged().then(pdfManagerReady);
  56457. }
  56458. onFailure(ex);
  56459. return;
  56460. }
  56461. pdfManager.requestLoadedStream();
  56462. pdfManager.onLoadedStream().then(function () {
  56463. ensureNotTerminated();
  56464. loadDocument(true).then(onSuccess, onFailure);
  56465. });
  56466. }, onFailure);
  56467. }, onFailure);
  56468. };
  56469. handler.on('GetPage', function wphSetupGetPage(data) {
  56470. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56471. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56472. var refPromise = pdfManager.ensure(page, 'ref');
  56473. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  56474. var viewPromise = pdfManager.ensure(page, 'view');
  56475. return Promise.all([
  56476. rotatePromise,
  56477. refPromise,
  56478. userUnitPromise,
  56479. viewPromise
  56480. ]).then(function (results) {
  56481. return {
  56482. rotate: results[0],
  56483. ref: results[1],
  56484. userUnit: results[2],
  56485. view: results[3]
  56486. };
  56487. });
  56488. });
  56489. });
  56490. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56491. var ref = new Ref(data.ref.num, data.ref.gen);
  56492. var catalog = pdfManager.pdfDocument.catalog;
  56493. return catalog.getPageIndex(ref);
  56494. });
  56495. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56496. return pdfManager.ensureCatalog('destinations');
  56497. });
  56498. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56499. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56500. });
  56501. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56502. return pdfManager.ensureCatalog('pageLabels');
  56503. });
  56504. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56505. return pdfManager.ensureCatalog('attachments');
  56506. });
  56507. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56508. return pdfManager.ensureCatalog('javaScript');
  56509. });
  56510. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56511. return pdfManager.ensureCatalog('documentOutline');
  56512. });
  56513. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56514. return Promise.all([
  56515. pdfManager.ensureDoc('documentInfo'),
  56516. pdfManager.ensureCatalog('metadata')
  56517. ]);
  56518. });
  56519. handler.on('GetData', function wphSetupGetData(data) {
  56520. pdfManager.requestLoadedStream();
  56521. return pdfManager.onLoadedStream().then(function (stream) {
  56522. return stream.bytes;
  56523. });
  56524. });
  56525. handler.on('GetStats', function wphSetupGetStats(data) {
  56526. return pdfManager.pdfDocument.xref.stats;
  56527. });
  56528. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  56529. pdfManager.updatePassword(data);
  56530. });
  56531. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56532. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56533. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56534. });
  56535. });
  56536. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56537. var pageIndex = data.pageIndex;
  56538. pdfManager.getPage(pageIndex).then(function (page) {
  56539. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56540. startWorkerTask(task);
  56541. var pageNum = pageIndex + 1;
  56542. var start = Date.now();
  56543. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56544. finishWorkerTask(task);
  56545. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56546. }, function (e) {
  56547. finishWorkerTask(task);
  56548. if (task.terminated) {
  56549. return;
  56550. }
  56551. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56552. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56553. var wrappedException;
  56554. if (typeof e === 'string') {
  56555. wrappedException = {
  56556. message: e,
  56557. stack: minimumStackMessage
  56558. };
  56559. } else if (typeof e === 'object') {
  56560. wrappedException = {
  56561. message: e.message || e.toString(),
  56562. stack: e.stack || minimumStackMessage
  56563. };
  56564. } else {
  56565. wrappedException = {
  56566. message: 'Unknown exception type: ' + typeof e,
  56567. stack: minimumStackMessage
  56568. };
  56569. }
  56570. handler.send('PageError', {
  56571. pageNum: pageNum,
  56572. error: wrappedException,
  56573. intent: data.intent
  56574. });
  56575. });
  56576. });
  56577. }, this);
  56578. handler.on('GetTextContent', function wphExtractText(data) {
  56579. var pageIndex = data.pageIndex;
  56580. var normalizeWhitespace = data.normalizeWhitespace;
  56581. var combineTextItems = data.combineTextItems;
  56582. return pdfManager.getPage(pageIndex).then(function (page) {
  56583. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56584. startWorkerTask(task);
  56585. var pageNum = pageIndex + 1;
  56586. var start = Date.now();
  56587. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56588. finishWorkerTask(task);
  56589. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56590. return textContent;
  56591. }, function (reason) {
  56592. finishWorkerTask(task);
  56593. if (task.terminated) {
  56594. return;
  56595. }
  56596. throw reason;
  56597. });
  56598. });
  56599. });
  56600. handler.on('Cleanup', function wphCleanup(data) {
  56601. return pdfManager.cleanup();
  56602. });
  56603. handler.on('Terminate', function wphTerminate(data) {
  56604. terminated = true;
  56605. if (pdfManager) {
  56606. pdfManager.terminate();
  56607. pdfManager = null;
  56608. }
  56609. if (cancelXHRs) {
  56610. cancelXHRs();
  56611. }
  56612. var waitOn = [];
  56613. WorkerTasks.forEach(function (task) {
  56614. waitOn.push(task.finished);
  56615. task.terminate();
  56616. });
  56617. return Promise.all(waitOn).then(function () {
  56618. handler.destroy();
  56619. handler = null;
  56620. });
  56621. });
  56622. handler.on('Ready', function wphReady(data) {
  56623. setupDoc(docParams);
  56624. docParams = null;
  56625. });
  56626. return workerHandlerName;
  56627. }
  56628. };
  56629. function initializeWorker() {
  56630. if (!('console' in globalScope)) {
  56631. var consoleTimer = {};
  56632. var workerConsole = {
  56633. log: function log() {
  56634. var args = Array.prototype.slice.call(arguments);
  56635. globalScope.postMessage({
  56636. targetName: 'main',
  56637. action: 'console_log',
  56638. data: args
  56639. });
  56640. },
  56641. error: function error() {
  56642. var args = Array.prototype.slice.call(arguments);
  56643. globalScope.postMessage({
  56644. targetName: 'main',
  56645. action: 'console_error',
  56646. data: args
  56647. });
  56648. throw 'pdf.js execution error';
  56649. },
  56650. time: function time(name) {
  56651. consoleTimer[name] = Date.now();
  56652. },
  56653. timeEnd: function timeEnd(name) {
  56654. var time = consoleTimer[name];
  56655. if (!time) {
  56656. error('Unknown timer name ' + name);
  56657. }
  56658. this.log('Timer:', name, Date.now() - time);
  56659. }
  56660. };
  56661. globalScope.console = workerConsole;
  56662. }
  56663. var handler = new MessageHandler('worker', 'main', self);
  56664. WorkerMessageHandler.setup(handler, self);
  56665. handler.send('ready', null);
  56666. }
  56667. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56668. initializeWorker();
  56669. }
  56670. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56671. exports.WorkerTask = WorkerTask;
  56672. exports.WorkerMessageHandler = WorkerMessageHandler;
  56673. }));
  56674. (function (root, factory) {
  56675. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56676. }(this, function (exports, sharedUtil, coreWorker) {
  56677. var OK_RESPONSE = 200;
  56678. var PARTIAL_CONTENT_RESPONSE = 206;
  56679. function NetworkManager(url, args) {
  56680. this.url = url;
  56681. args = args || {};
  56682. this.isHttp = /^https?:/i.test(url);
  56683. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56684. this.withCredentials = args.withCredentials || false;
  56685. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56686. return new XMLHttpRequest();
  56687. };
  56688. this.currXhrId = 0;
  56689. this.pendingRequests = Object.create(null);
  56690. this.loadedRequests = Object.create(null);
  56691. }
  56692. function getArrayBuffer(xhr) {
  56693. var data = xhr.response;
  56694. if (typeof data !== 'string') {
  56695. return data;
  56696. }
  56697. var length = data.length;
  56698. var array = new Uint8Array(length);
  56699. for (var i = 0; i < length; i++) {
  56700. array[i] = data.charCodeAt(i) & 0xFF;
  56701. }
  56702. return array.buffer;
  56703. }
  56704. var supportsMozChunked = function supportsMozChunkedClosure() {
  56705. try {
  56706. var x = new XMLHttpRequest();
  56707. x.open('GET', 'https://example.com');
  56708. x.responseType = 'moz-chunked-arraybuffer';
  56709. return x.responseType === 'moz-chunked-arraybuffer';
  56710. } catch (e) {
  56711. return false;
  56712. }
  56713. }();
  56714. NetworkManager.prototype = {
  56715. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56716. var args = {
  56717. begin: begin,
  56718. end: end
  56719. };
  56720. for (var prop in listeners) {
  56721. args[prop] = listeners[prop];
  56722. }
  56723. return this.request(args);
  56724. },
  56725. requestFull: function NetworkManager_requestFull(listeners) {
  56726. return this.request(listeners);
  56727. },
  56728. request: function NetworkManager_request(args) {
  56729. var xhr = this.getXhr();
  56730. var xhrId = this.currXhrId++;
  56731. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56732. xhr.open('GET', this.url);
  56733. xhr.withCredentials = this.withCredentials;
  56734. for (var property in this.httpHeaders) {
  56735. var value = this.httpHeaders[property];
  56736. if (typeof value === 'undefined') {
  56737. continue;
  56738. }
  56739. xhr.setRequestHeader(property, value);
  56740. }
  56741. if (this.isHttp && 'begin' in args && 'end' in args) {
  56742. var rangeStr = args.begin + '-' + (args.end - 1);
  56743. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56744. pendingRequest.expectedStatus = 206;
  56745. } else {
  56746. pendingRequest.expectedStatus = 200;
  56747. }
  56748. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56749. if (useMozChunkedLoading) {
  56750. xhr.responseType = 'moz-chunked-arraybuffer';
  56751. pendingRequest.onProgressiveData = args.onProgressiveData;
  56752. pendingRequest.mozChunked = true;
  56753. } else {
  56754. xhr.responseType = 'arraybuffer';
  56755. }
  56756. if (args.onError) {
  56757. xhr.onerror = function (evt) {
  56758. args.onError(xhr.status);
  56759. };
  56760. }
  56761. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56762. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56763. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56764. pendingRequest.onDone = args.onDone;
  56765. pendingRequest.onError = args.onError;
  56766. pendingRequest.onProgress = args.onProgress;
  56767. xhr.send(null);
  56768. return xhrId;
  56769. },
  56770. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56771. var pendingRequest = this.pendingRequests[xhrId];
  56772. if (!pendingRequest) {
  56773. return;
  56774. }
  56775. if (pendingRequest.mozChunked) {
  56776. var chunk = getArrayBuffer(pendingRequest.xhr);
  56777. pendingRequest.onProgressiveData(chunk);
  56778. }
  56779. var onProgress = pendingRequest.onProgress;
  56780. if (onProgress) {
  56781. onProgress(evt);
  56782. }
  56783. },
  56784. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56785. var pendingRequest = this.pendingRequests[xhrId];
  56786. if (!pendingRequest) {
  56787. return;
  56788. }
  56789. var xhr = pendingRequest.xhr;
  56790. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56791. pendingRequest.onHeadersReceived();
  56792. delete pendingRequest.onHeadersReceived;
  56793. }
  56794. if (xhr.readyState !== 4) {
  56795. return;
  56796. }
  56797. if (!(xhrId in this.pendingRequests)) {
  56798. return;
  56799. }
  56800. delete this.pendingRequests[xhrId];
  56801. if (xhr.status === 0 && this.isHttp) {
  56802. if (pendingRequest.onError) {
  56803. pendingRequest.onError(xhr.status);
  56804. }
  56805. return;
  56806. }
  56807. var xhrStatus = xhr.status || OK_RESPONSE;
  56808. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56809. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56810. if (pendingRequest.onError) {
  56811. pendingRequest.onError(xhr.status);
  56812. }
  56813. return;
  56814. }
  56815. this.loadedRequests[xhrId] = true;
  56816. var chunk = getArrayBuffer(xhr);
  56817. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56818. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56819. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56820. var begin = parseInt(matches[1], 10);
  56821. pendingRequest.onDone({
  56822. begin: begin,
  56823. chunk: chunk
  56824. });
  56825. } else if (pendingRequest.onProgressiveData) {
  56826. pendingRequest.onDone(null);
  56827. } else if (chunk) {
  56828. pendingRequest.onDone({
  56829. begin: 0,
  56830. chunk: chunk
  56831. });
  56832. } else if (pendingRequest.onError) {
  56833. pendingRequest.onError(xhr.status);
  56834. }
  56835. },
  56836. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56837. for (var xhrId in this.pendingRequests) {
  56838. return true;
  56839. }
  56840. return false;
  56841. },
  56842. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56843. return this.pendingRequests[xhrId].xhr;
  56844. },
  56845. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56846. return !!this.pendingRequests[xhrId].onProgressiveData;
  56847. },
  56848. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56849. return xhrId in this.pendingRequests;
  56850. },
  56851. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56852. return xhrId in this.loadedRequests;
  56853. },
  56854. abortAllRequests: function NetworkManager_abortAllRequests() {
  56855. for (var xhrId in this.pendingRequests) {
  56856. this.abortRequest(xhrId | 0);
  56857. }
  56858. },
  56859. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56860. var xhr = this.pendingRequests[xhrId].xhr;
  56861. delete this.pendingRequests[xhrId];
  56862. xhr.abort();
  56863. }
  56864. };
  56865. var assert = sharedUtil.assert;
  56866. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56867. var isInt = sharedUtil.isInt;
  56868. var MissingPDFException = sharedUtil.MissingPDFException;
  56869. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56870. function PDFNetworkStream(options) {
  56871. this._options = options;
  56872. var source = options.source;
  56873. this._manager = new NetworkManager(source.url, {
  56874. httpHeaders: source.httpHeaders,
  56875. withCredentials: source.withCredentials
  56876. });
  56877. this._rangeChunkSize = source.rangeChunkSize;
  56878. this._fullRequestReader = null;
  56879. this._rangeRequestReaders = [];
  56880. }
  56881. PDFNetworkStream.prototype = {
  56882. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56883. var i = this._rangeRequestReaders.indexOf(reader);
  56884. if (i >= 0) {
  56885. this._rangeRequestReaders.splice(i, 1);
  56886. }
  56887. },
  56888. getFullReader: function PDFNetworkStream_getFullReader() {
  56889. assert(!this._fullRequestReader);
  56890. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56891. return this._fullRequestReader;
  56892. },
  56893. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56894. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56895. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56896. this._rangeRequestReaders.push(reader);
  56897. return reader;
  56898. },
  56899. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56900. if (this._fullRequestReader) {
  56901. this._fullRequestReader.cancel(reason);
  56902. }
  56903. var readers = this._rangeRequestReaders.slice(0);
  56904. readers.forEach(function (reader) {
  56905. reader.cancel(reason);
  56906. });
  56907. }
  56908. };
  56909. function PDFNetworkStreamFullRequestReader(manager, options) {
  56910. this._manager = manager;
  56911. var source = options.source;
  56912. var args = {
  56913. onHeadersReceived: this._onHeadersReceived.bind(this),
  56914. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56915. onDone: this._onDone.bind(this),
  56916. onError: this._onError.bind(this),
  56917. onProgress: this._onProgress.bind(this)
  56918. };
  56919. this._url = source.url;
  56920. this._fullRequestId = manager.requestFull(args);
  56921. this._headersReceivedCapability = createPromiseCapability();
  56922. this._disableRange = options.disableRange || false;
  56923. this._contentLength = source.length;
  56924. this._rangeChunkSize = source.rangeChunkSize;
  56925. if (!this._rangeChunkSize && !this._disableRange) {
  56926. this._disableRange = true;
  56927. }
  56928. this._isStreamingSupported = false;
  56929. this._isRangeSupported = false;
  56930. this._cachedChunks = [];
  56931. this._requests = [];
  56932. this._done = false;
  56933. this._storedError = undefined;
  56934. this.onProgress = null;
  56935. }
  56936. PDFNetworkStreamFullRequestReader.prototype = {
  56937. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56938. if (this._disableRange) {
  56939. return false;
  56940. }
  56941. var networkManager = this._manager;
  56942. if (!networkManager.isHttp) {
  56943. return false;
  56944. }
  56945. var fullRequestXhrId = this._fullRequestId;
  56946. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56947. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56948. return false;
  56949. }
  56950. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56951. if (contentEncoding !== 'identity') {
  56952. return false;
  56953. }
  56954. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56955. length = parseInt(length, 10);
  56956. if (!isInt(length)) {
  56957. return false;
  56958. }
  56959. this._contentLength = length;
  56960. if (length <= 2 * this._rangeChunkSize) {
  56961. return false;
  56962. }
  56963. return true;
  56964. },
  56965. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56966. if (this._validateRangeRequestCapabilities()) {
  56967. this._isRangeSupported = true;
  56968. }
  56969. var networkManager = this._manager;
  56970. var fullRequestXhrId = this._fullRequestId;
  56971. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56972. this._isStreamingSupported = true;
  56973. } else if (this._isRangeSupported) {
  56974. networkManager.abortRequest(fullRequestXhrId);
  56975. }
  56976. this._headersReceivedCapability.resolve();
  56977. },
  56978. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56979. if (this._requests.length > 0) {
  56980. var requestCapability = this._requests.shift();
  56981. requestCapability.resolve({
  56982. value: chunk,
  56983. done: false
  56984. });
  56985. } else {
  56986. this._cachedChunks.push(chunk);
  56987. }
  56988. },
  56989. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56990. if (args) {
  56991. this._onProgressiveData(args.chunk);
  56992. }
  56993. this._done = true;
  56994. if (this._cachedChunks.length > 0) {
  56995. return;
  56996. }
  56997. this._requests.forEach(function (requestCapability) {
  56998. requestCapability.resolve({
  56999. value: undefined,
  57000. done: true
  57001. });
  57002. });
  57003. this._requests = [];
  57004. },
  57005. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  57006. var url = this._url;
  57007. var exception;
  57008. if (status === 404 || status === 0 && /^file:/.test(url)) {
  57009. exception = new MissingPDFException('Missing PDF "' + url + '".');
  57010. } else {
  57011. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  57012. }
  57013. this._storedError = exception;
  57014. this._headersReceivedCapability.reject(exception);
  57015. this._requests.forEach(function (requestCapability) {
  57016. requestCapability.reject(exception);
  57017. });
  57018. this._requests = [];
  57019. this._cachedChunks = [];
  57020. },
  57021. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  57022. if (this.onProgress) {
  57023. this.onProgress({
  57024. loaded: data.loaded,
  57025. total: data.lengthComputable ? data.total : this._contentLength
  57026. });
  57027. }
  57028. },
  57029. get isRangeSupported() {
  57030. return this._isRangeSupported;
  57031. },
  57032. get isStreamingSupported() {
  57033. return this._isStreamingSupported;
  57034. },
  57035. get contentLength() {
  57036. return this._contentLength;
  57037. },
  57038. get headersReady() {
  57039. return this._headersReceivedCapability.promise;
  57040. },
  57041. read: function PDFNetworkStreamFullRequestReader_read() {
  57042. if (this._storedError) {
  57043. return Promise.reject(this._storedError);
  57044. }
  57045. if (this._cachedChunks.length > 0) {
  57046. var chunk = this._cachedChunks.shift();
  57047. return Promise.resolve(chunk);
  57048. }
  57049. if (this._done) {
  57050. return Promise.resolve({
  57051. value: undefined,
  57052. done: true
  57053. });
  57054. }
  57055. var requestCapability = createPromiseCapability();
  57056. this._requests.push(requestCapability);
  57057. return requestCapability.promise;
  57058. },
  57059. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  57060. this._done = true;
  57061. this._headersReceivedCapability.reject(reason);
  57062. this._requests.forEach(function (requestCapability) {
  57063. requestCapability.resolve({
  57064. value: undefined,
  57065. done: true
  57066. });
  57067. });
  57068. this._requests = [];
  57069. if (this._manager.isPendingRequest(this._fullRequestId)) {
  57070. this._manager.abortRequest(this._fullRequestId);
  57071. }
  57072. this._fullRequestReader = null;
  57073. }
  57074. };
  57075. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  57076. this._manager = manager;
  57077. var args = {
  57078. onDone: this._onDone.bind(this),
  57079. onProgress: this._onProgress.bind(this)
  57080. };
  57081. this._requestId = manager.requestRange(begin, end, args);
  57082. this._requests = [];
  57083. this._queuedChunk = null;
  57084. this._done = false;
  57085. this.onProgress = null;
  57086. this.onClosed = null;
  57087. }
  57088. PDFNetworkStreamRangeRequestReader.prototype = {
  57089. _close: function PDFNetworkStreamRangeRequestReader_close() {
  57090. if (this.onClosed) {
  57091. this.onClosed(this);
  57092. }
  57093. },
  57094. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  57095. var chunk = data.chunk;
  57096. if (this._requests.length > 0) {
  57097. var requestCapability = this._requests.shift();
  57098. requestCapability.resolve({
  57099. value: chunk,
  57100. done: false
  57101. });
  57102. } else {
  57103. this._queuedChunk = chunk;
  57104. }
  57105. this._done = true;
  57106. this._requests.forEach(function (requestCapability) {
  57107. requestCapability.resolve({
  57108. value: undefined,
  57109. done: true
  57110. });
  57111. });
  57112. this._requests = [];
  57113. this._close();
  57114. },
  57115. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  57116. if (!this.isStreamingSupported && this.onProgress) {
  57117. this.onProgress({ loaded: evt.loaded });
  57118. }
  57119. },
  57120. get isStreamingSupported() {
  57121. return false;
  57122. },
  57123. read: function PDFNetworkStreamRangeRequestReader_read() {
  57124. if (this._queuedChunk !== null) {
  57125. var chunk = this._queuedChunk;
  57126. this._queuedChunk = null;
  57127. return Promise.resolve({
  57128. value: chunk,
  57129. done: false
  57130. });
  57131. }
  57132. if (this._done) {
  57133. return Promise.resolve({
  57134. value: undefined,
  57135. done: true
  57136. });
  57137. }
  57138. var requestCapability = createPromiseCapability();
  57139. this._requests.push(requestCapability);
  57140. return requestCapability.promise;
  57141. },
  57142. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  57143. this._done = true;
  57144. this._requests.forEach(function (requestCapability) {
  57145. requestCapability.resolve({
  57146. value: undefined,
  57147. done: true
  57148. });
  57149. });
  57150. this._requests = [];
  57151. if (this._manager.isPendingRequest(this._requestId)) {
  57152. this._manager.abortRequest(this._requestId);
  57153. }
  57154. this._close();
  57155. }
  57156. };
  57157. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  57158. exports.PDFNetworkStream = PDFNetworkStream;
  57159. exports.NetworkManager = NetworkManager;
  57160. }));
  57161. }.call(pdfjsLibs));
  57162. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  57163. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  57164. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  57165. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  57166. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  57167. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  57168. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  57169. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57170. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  57171. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  57172. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  57173. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  57174. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  57175. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  57176. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  57177. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57178. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  57179. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  57180. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  57181. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  57182. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  57183. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  57184. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57185. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  57186. }));