12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656 |
- #define TMP_PRESENT
- using UnityEngine;
- using UnityEngine.TextCore;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using UnityEngine.EventSystems;
- using System;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- namespace TMPro
- {
- public interface ITextElement
- {
- Material sharedMaterial { get; }
- void Rebuild(CanvasUpdate update);
- int GetInstanceID();
- }
- public enum TextAlignmentOptions
- {
- TopLeft = HorizontalAlignmentOptions.Left | VerticalAlignmentOptions.Top,
- Top = HorizontalAlignmentOptions.Center | VerticalAlignmentOptions.Top,
- TopRight = HorizontalAlignmentOptions.Right | VerticalAlignmentOptions.Top,
- TopJustified = HorizontalAlignmentOptions.Justified | VerticalAlignmentOptions.Top,
- TopFlush = HorizontalAlignmentOptions.Flush | VerticalAlignmentOptions.Top,
- TopGeoAligned = HorizontalAlignmentOptions.Geometry | VerticalAlignmentOptions.Top,
- Left = HorizontalAlignmentOptions.Left | VerticalAlignmentOptions.Middle,
- Center = HorizontalAlignmentOptions.Center | VerticalAlignmentOptions.Middle,
- Right = HorizontalAlignmentOptions.Right | VerticalAlignmentOptions.Middle,
- Justified = HorizontalAlignmentOptions.Justified | VerticalAlignmentOptions.Middle,
- Flush = HorizontalAlignmentOptions.Flush | VerticalAlignmentOptions.Middle,
- CenterGeoAligned = HorizontalAlignmentOptions.Geometry | VerticalAlignmentOptions.Middle,
- BottomLeft = HorizontalAlignmentOptions.Left | VerticalAlignmentOptions.Bottom,
- Bottom = HorizontalAlignmentOptions.Center | VerticalAlignmentOptions.Bottom,
- BottomRight = HorizontalAlignmentOptions.Right | VerticalAlignmentOptions.Bottom,
- BottomJustified = HorizontalAlignmentOptions.Justified | VerticalAlignmentOptions.Bottom,
- BottomFlush = HorizontalAlignmentOptions.Flush | VerticalAlignmentOptions.Bottom,
- BottomGeoAligned = HorizontalAlignmentOptions.Geometry | VerticalAlignmentOptions.Bottom,
- BaselineLeft = HorizontalAlignmentOptions.Left | VerticalAlignmentOptions.Baseline,
- Baseline = HorizontalAlignmentOptions.Center | VerticalAlignmentOptions.Baseline,
- BaselineRight = HorizontalAlignmentOptions.Right | VerticalAlignmentOptions.Baseline,
- BaselineJustified = HorizontalAlignmentOptions.Justified | VerticalAlignmentOptions.Baseline,
- BaselineFlush = HorizontalAlignmentOptions.Flush | VerticalAlignmentOptions.Baseline,
- BaselineGeoAligned = HorizontalAlignmentOptions.Geometry | VerticalAlignmentOptions.Baseline,
- MidlineLeft = HorizontalAlignmentOptions.Left | VerticalAlignmentOptions.Geometry,
- Midline = HorizontalAlignmentOptions.Center | VerticalAlignmentOptions.Geometry,
- MidlineRight = HorizontalAlignmentOptions.Right | VerticalAlignmentOptions.Geometry,
- MidlineJustified = HorizontalAlignmentOptions.Justified | VerticalAlignmentOptions.Geometry,
- MidlineFlush = HorizontalAlignmentOptions.Flush | VerticalAlignmentOptions.Geometry,
- MidlineGeoAligned = HorizontalAlignmentOptions.Geometry | VerticalAlignmentOptions.Geometry,
- CaplineLeft = HorizontalAlignmentOptions.Left | VerticalAlignmentOptions.Capline,
- Capline = HorizontalAlignmentOptions.Center | VerticalAlignmentOptions.Capline,
- CaplineRight = HorizontalAlignmentOptions.Right | VerticalAlignmentOptions.Capline,
- CaplineJustified = HorizontalAlignmentOptions.Justified | VerticalAlignmentOptions.Capline,
- CaplineFlush = HorizontalAlignmentOptions.Flush | VerticalAlignmentOptions.Capline,
- CaplineGeoAligned = HorizontalAlignmentOptions.Geometry | VerticalAlignmentOptions.Capline,
- Converted = 0xFFFF
- };
-
-
-
- public enum HorizontalAlignmentOptions
- {
- Left = 0x1, Center = 0x2, Right = 0x4, Justified = 0x8, Flush = 0x10, Geometry = 0x20
- }
-
-
-
- public enum VerticalAlignmentOptions
- {
- Top = 0x100, Middle = 0x200, Bottom = 0x400, Baseline = 0x800, Geometry = 0x1000, Capline = 0x2000,
- }
-
-
-
- public enum TextRenderFlags
- {
- DontRender = 0x0,
- Render = 0xFF
- };
- public enum TMP_TextElementType { Character, Sprite };
- public enum MaskingTypes { MaskOff = 0, MaskHard = 1, MaskSoft = 2 };
- public enum TextOverflowModes { Overflow = 0, Ellipsis = 1, Masking = 2, Truncate = 3, ScrollRect = 4, Page = 5, Linked = 6 };
- public enum MaskingOffsetMode { Percentage = 0, Pixel = 1 };
- public enum TextureMappingOptions { Character = 0, Line = 1, Paragraph = 2, MatchAspect = 3 };
- [Flags]
- public enum FontStyles { Normal = 0x0, Bold = 0x1, Italic = 0x2, Underline = 0x4, LowerCase = 0x8, UpperCase = 0x10, SmallCaps = 0x20, Strikethrough = 0x40, Superscript = 0x80, Subscript = 0x100, Highlight = 0x200 };
- public enum FontWeight { Thin = 100, ExtraLight = 200, Light = 300, Regular = 400, Medium = 500, SemiBold = 600, Bold = 700, Heavy = 800, Black = 900 };
-
-
-
- public abstract class TMP_Text : MaskableGraphic
- {
-
-
-
- public virtual string text
- {
- get { return m_text; }
- set
- {
- if (m_text != null && value != null && m_text.Length == value.Length && m_text == value)
- return;
- m_text = value;
- m_inputSource = TextInputSources.String;
- m_havePropertiesChanged = true;
- m_isInputParsingRequired = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
- }
- [SerializeField]
- [TextArea(5, 10)]
- protected string m_text;
-
-
-
- public ITextPreprocessor textPreprocessor
- {
- get { return m_TextPreprocessor; }
- set { m_TextPreprocessor = value; }
- }
- [SerializeField]
- protected ITextPreprocessor m_TextPreprocessor;
-
-
-
- public bool isRightToLeftText
- {
- get { return m_isRightToLeft; }
- set { if (m_isRightToLeft == value) return; m_isRightToLeft = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_isRightToLeft = false;
-
-
-
- public TMP_FontAsset font
- {
- get { return m_fontAsset; }
- set { if (m_fontAsset == value) return; m_fontAsset = value; LoadFontAsset(); m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected TMP_FontAsset m_fontAsset;
- protected TMP_FontAsset m_currentFontAsset;
- protected bool m_isSDFShader;
-
-
-
- public virtual Material fontSharedMaterial
- {
- get { return m_sharedMaterial; }
- set { if (m_sharedMaterial == value) return; SetSharedMaterial(value); m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetMaterialDirty(); }
- }
- [SerializeField]
- protected Material m_sharedMaterial;
- protected Material m_currentMaterial;
- protected MaterialReference[] m_materialReferences = new MaterialReference[32];
- protected Dictionary<int, int> m_materialReferenceIndexLookup = new Dictionary<int, int>();
- protected TMP_TextProcessingStack<MaterialReference> m_materialReferenceStack = new TMP_TextProcessingStack<MaterialReference>(new MaterialReference[16]);
- protected int m_currentMaterialIndex;
-
-
-
- public virtual Material[] fontSharedMaterials
- {
- get { return GetSharedMaterials(); }
- set { SetSharedMaterials(value); m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetMaterialDirty(); }
- }
- [SerializeField]
- protected Material[] m_fontSharedMaterials;
-
-
-
- public Material fontMaterial
- {
-
- get { return GetMaterial(m_sharedMaterial); }
-
- set
- {
- if (m_sharedMaterial != null && m_sharedMaterial.GetInstanceID() == value.GetInstanceID()) return;
- m_sharedMaterial = value;
- m_padding = GetPaddingForMaterial();
- m_havePropertiesChanged = true;
- m_isInputParsingRequired = true;
- SetVerticesDirty();
- SetMaterialDirty();
- }
- }
- [SerializeField]
- protected Material m_fontMaterial;
-
-
-
- public virtual Material[] fontMaterials
- {
- get { return GetMaterials(m_fontSharedMaterials); }
- set { SetSharedMaterials(value); m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetMaterialDirty(); }
- }
- [SerializeField]
- protected Material[] m_fontMaterials;
- protected bool m_isMaterialDirty;
-
-
-
- public override Color color
- {
- get { return m_fontColor; }
- set { if (m_fontColor == value) return; m_havePropertiesChanged = true; m_fontColor = value; SetVerticesDirty(); }
- }
-
- [SerializeField]
- protected Color32 m_fontColor32 = Color.white;
- [SerializeField]
- protected Color m_fontColor = Color.white;
- protected static Color32 s_colorWhite = new Color32(255, 255, 255, 255);
- protected Color32 m_underlineColor = s_colorWhite;
- protected Color32 m_strikethroughColor = s_colorWhite;
-
-
-
- public float alpha
- {
- get { return m_fontColor.a; }
- set { if (m_fontColor.a == value) return; m_fontColor.a = value; m_havePropertiesChanged = true; SetVerticesDirty(); }
- }
-
-
-
-
- public bool enableVertexGradient
- {
- get { return m_enableVertexGradient; }
- set { if (m_enableVertexGradient == value) return; m_havePropertiesChanged = true; m_enableVertexGradient = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_enableVertexGradient;
- [SerializeField]
- protected ColorMode m_colorMode = ColorMode.FourCornersGradient;
-
-
-
-
- public VertexGradient colorGradient
- {
- get { return m_fontColorGradient; }
- set { m_havePropertiesChanged = true; m_fontColorGradient = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected VertexGradient m_fontColorGradient = new VertexGradient(Color.white);
-
-
-
- public TMP_ColorGradient colorGradientPreset
- {
- get { return m_fontColorGradientPreset; }
- set { m_havePropertiesChanged = true; m_fontColorGradientPreset = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected TMP_ColorGradient m_fontColorGradientPreset;
-
-
-
- public TMP_SpriteAsset spriteAsset
- {
- get { return m_spriteAsset; }
- set { m_spriteAsset = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected TMP_SpriteAsset m_spriteAsset;
-
-
-
- public bool tintAllSprites
- {
- get { return m_tintAllSprites; }
- set { if (m_tintAllSprites == value) return; m_tintAllSprites = value; m_havePropertiesChanged = true; SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_tintAllSprites;
- protected bool m_tintSprite;
- protected Color32 m_spriteColor;
-
-
-
- public TMP_StyleSheet styleSheet
- {
- get { return m_StyleSheet; }
- set { m_StyleSheet = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected TMP_StyleSheet m_StyleSheet;
-
-
-
- public TMP_Style textStyle
- {
- get
- {
- m_TextStyle = GetStyle(m_TextStyleHashCode);
- if (m_TextStyle == null)
- {
- m_TextStyle = TMP_Style.NormalStyle;
- m_TextStyleHashCode = m_TextStyle.hashCode;
- }
- return m_TextStyle;
- }
- set { m_TextStyle = value; m_TextStyleHashCode = m_TextStyle.hashCode; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- internal TMP_Style m_TextStyle;
- [SerializeField]
- protected int m_TextStyleHashCode;
-
-
-
- public bool overrideColorTags
- {
- get { return m_overrideHtmlColors; }
- set { if (m_overrideHtmlColors == value) return; m_havePropertiesChanged = true; m_overrideHtmlColors = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_overrideHtmlColors = false;
-
-
-
- public Color32 faceColor
- {
- get
- {
- if (m_sharedMaterial == null) return m_faceColor;
- m_faceColor = m_sharedMaterial.GetColor(ShaderUtilities.ID_FaceColor);
- return m_faceColor;
- }
- set { if (m_faceColor.Compare(value)) return; SetFaceColor(value); m_havePropertiesChanged = true; m_faceColor = value; SetVerticesDirty(); SetMaterialDirty(); }
- }
- [SerializeField]
- protected Color32 m_faceColor = Color.white;
-
-
-
- public Color32 outlineColor
- {
- get
- {
- if (m_sharedMaterial == null) return m_outlineColor;
- m_outlineColor = m_sharedMaterial.GetColor(ShaderUtilities.ID_OutlineColor);
- return m_outlineColor;
- }
- set { if (m_outlineColor.Compare(value)) return; SetOutlineColor(value); m_havePropertiesChanged = true; m_outlineColor = value; SetVerticesDirty(); }
- }
-
- protected Color32 m_outlineColor = Color.black;
-
-
-
- public float outlineWidth
- {
- get
- {
- if (m_sharedMaterial == null) return m_outlineWidth;
- m_outlineWidth = m_sharedMaterial.GetFloat(ShaderUtilities.ID_OutlineWidth);
- return m_outlineWidth;
- }
- set { if (m_outlineWidth == value) return; SetOutlineThickness(value); m_havePropertiesChanged = true; m_outlineWidth = value; SetVerticesDirty(); }
- }
- protected float m_outlineWidth = 0.0f;
-
-
-
- public float fontSize
- {
- get { return m_fontSize; }
- set { if (m_fontSize == value) return; m_havePropertiesChanged = true; m_fontSize = value; if (!m_enableAutoSizing) m_fontSizeBase = m_fontSize; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_fontSize = 36;
- protected float m_currentFontSize;
- [SerializeField]
- protected float m_fontSizeBase = 36;
- protected TMP_TextProcessingStack<float> m_sizeStack = new TMP_TextProcessingStack<float>(16);
-
-
-
- public float fontScale
- {
- get { return m_fontScale; }
- }
-
-
-
- public FontWeight fontWeight
- {
- get { return m_fontWeight; }
- set { if (m_fontWeight == value) return; m_fontWeight = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected FontWeight m_fontWeight = FontWeight.Regular;
- protected FontWeight m_FontWeightInternal = FontWeight.Regular;
- protected TMP_TextProcessingStack<FontWeight> m_FontWeightStack = new TMP_TextProcessingStack<FontWeight>(8);
-
-
-
- public float pixelsPerUnit
- {
- get
- {
- var localCanvas = canvas;
- if (!localCanvas)
- return 1;
-
- if (!font)
- return localCanvas.scaleFactor;
-
- if (m_currentFontAsset == null || m_currentFontAsset.faceInfo.pointSize <= 0 || m_fontSize <= 0)
- return 1;
- return m_fontSize / m_currentFontAsset.faceInfo.pointSize;
- }
- }
-
-
-
- public bool enableAutoSizing
- {
- get { return m_enableAutoSizing; }
- set { if (m_enableAutoSizing == value) return; m_enableAutoSizing = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_enableAutoSizing;
- protected float m_maxFontSize;
- protected float m_minFontSize;
- protected int m_AutoSizeIterationCount;
- protected int m_AutoSizeMaxIterationCount = 100;
- protected bool m_IsAutoSizePointSizeSet;
-
-
-
- public float fontSizeMin
- {
- get { return m_fontSizeMin; }
- set { if (m_fontSizeMin == value) return; m_fontSizeMin = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_fontSizeMin = 0;
-
-
-
- public float fontSizeMax
- {
- get { return m_fontSizeMax; }
- set { if (m_fontSizeMax == value) return; m_fontSizeMax = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_fontSizeMax = 0;
-
-
-
- public FontStyles fontStyle
- {
- get { return m_fontStyle; }
- set { if (m_fontStyle == value) return; m_fontStyle = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected FontStyles m_fontStyle = FontStyles.Normal;
- protected FontStyles m_FontStyleInternal = FontStyles.Normal;
- protected TMP_FontStyleStack m_fontStyleStack;
-
-
-
- public bool isUsingBold { get { return m_isUsingBold; } }
- protected bool m_isUsingBold = false;
-
-
-
- public HorizontalAlignmentOptions horizontalAlignment
- {
- get { return m_HorizontalAlignment; }
- set
- {
- if (m_HorizontalAlignment == value)
- return;
- m_HorizontalAlignment = value;
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- }
- }
- [SerializeField]
- protected HorizontalAlignmentOptions m_HorizontalAlignment = HorizontalAlignmentOptions.Left;
-
-
-
- public VerticalAlignmentOptions verticalAlignment
- {
- get { return m_VerticalAlignment; }
- set
- {
- if (m_VerticalAlignment == value)
- return;
- m_VerticalAlignment = value;
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- }
- }
- [SerializeField]
- protected VerticalAlignmentOptions m_VerticalAlignment = VerticalAlignmentOptions.Top;
-
-
-
- public TextAlignmentOptions alignment
- {
- get { return (TextAlignmentOptions)((int)m_HorizontalAlignment | (int)m_VerticalAlignment); }
- set
- {
- HorizontalAlignmentOptions horizontalAlignment = (HorizontalAlignmentOptions)((int)value & 0xFF);
- VerticalAlignmentOptions verticalAlignment = (VerticalAlignmentOptions)((int)value & 0xFF00);
- if (m_HorizontalAlignment == horizontalAlignment && m_VerticalAlignment == verticalAlignment)
- return;
- m_HorizontalAlignment = horizontalAlignment;
- m_VerticalAlignment = verticalAlignment;
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- }
- }
- [SerializeField]
- [UnityEngine.Serialization.FormerlySerializedAs("m_lineJustification")]
- protected TextAlignmentOptions m_textAlignment = TextAlignmentOptions.Converted;
- protected HorizontalAlignmentOptions m_lineJustification;
- protected TMP_TextProcessingStack<HorizontalAlignmentOptions> m_lineJustificationStack = new TMP_TextProcessingStack<HorizontalAlignmentOptions>(new HorizontalAlignmentOptions[16]);
- protected Vector3[] m_textContainerLocalCorners = new Vector3[4];
-
-
-
-
-
-
-
-
-
-
-
-
-
- public float characterSpacing
- {
- get { return m_characterSpacing; }
- set { if (m_characterSpacing == value) return; m_havePropertiesChanged = true; m_characterSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_characterSpacing = 0;
- protected float m_cSpacing = 0;
- protected float m_monoSpacing = 0;
-
-
-
- public float wordSpacing
- {
- get { return m_wordSpacing; }
- set { if (m_wordSpacing == value) return; m_havePropertiesChanged = true; m_wordSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_wordSpacing = 0;
-
-
-
- public float lineSpacing
- {
- get { return m_lineSpacing; }
- set { if (m_lineSpacing == value) return; m_havePropertiesChanged = true; m_lineSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_lineSpacing = 0;
- protected float m_lineSpacingDelta = 0;
- protected float m_lineHeight = TMP_Math.FLOAT_UNSET;
- protected bool m_IsDrivenLineSpacing;
-
-
-
- public float lineSpacingAdjustment
- {
- get { return m_lineSpacingMax; }
- set { if (m_lineSpacingMax == value) return; m_havePropertiesChanged = true; m_lineSpacingMax = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_lineSpacingMax = 0;
-
-
-
-
- public float paragraphSpacing
- {
- get { return m_paragraphSpacing; }
- set { if (m_paragraphSpacing == value) return; m_havePropertiesChanged = true; m_paragraphSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_paragraphSpacing = 0;
-
-
-
- public float characterWidthAdjustment
- {
- get { return m_charWidthMaxAdj; }
- set { if (m_charWidthMaxAdj == value) return; m_havePropertiesChanged = true; m_charWidthMaxAdj = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_charWidthMaxAdj = 0f;
- protected float m_charWidthAdjDelta = 0;
-
-
-
- public bool enableWordWrapping
- {
- get { return m_enableWordWrapping; }
- set { if (m_enableWordWrapping == value) return; m_havePropertiesChanged = true; m_isInputParsingRequired = true; m_enableWordWrapping = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_enableWordWrapping = false;
- protected bool m_isCharacterWrappingEnabled = false;
- protected bool m_isNonBreakingSpace = false;
- protected bool m_isIgnoringAlignment;
-
-
-
- public float wordWrappingRatios
- {
- get { return m_wordWrappingRatios; }
- set { if (m_wordWrappingRatios == value) return; m_wordWrappingRatios = value; m_havePropertiesChanged = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected float m_wordWrappingRatios = 0.4f;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public TextOverflowModes overflowMode
- {
- get { return m_overflowMode; }
- set { if (m_overflowMode == value) return; m_overflowMode = value; m_havePropertiesChanged = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected TextOverflowModes m_overflowMode = TextOverflowModes.Overflow;
-
-
-
- public bool isTextOverflowing
- {
- get { if (m_firstOverflowCharacterIndex != -1) return true; return false; }
- }
-
-
-
- public int firstOverflowCharacterIndex
- {
- get { return m_firstOverflowCharacterIndex; }
- }
-
- protected int m_firstOverflowCharacterIndex = -1;
-
-
-
- public TMP_Text linkedTextComponent
- {
- get { return m_linkedTextComponent; }
- set
- {
- if (value == null)
- {
-
- ReleaseLinkedTextComponent(m_linkedTextComponent);
- m_linkedTextComponent = value;
- }
- else if (IsSelfOrLinkedAncestor(value))
- {
-
- return;
- }
- else
- {
-
- ReleaseLinkedTextComponent(m_linkedTextComponent);
- m_linkedTextComponent = value;
- m_linkedTextComponent.parentLinkedComponent = this;
- }
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
- }
- [SerializeField]
- protected TMP_Text m_linkedTextComponent;
- [SerializeField]
- internal TMP_Text parentLinkedComponent;
-
-
-
- public bool isTextTruncated { get { return m_isTextTruncated; } }
-
- protected bool m_isTextTruncated;
-
-
-
- public bool enableKerning
- {
- get { return m_enableKerning; }
- set { if (m_enableKerning == value) return; m_havePropertiesChanged = true; m_enableKerning = value; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_enableKerning;
- protected float m_GlyphHorizontalAdvanceAdjustment;
-
-
-
- public bool extraPadding
- {
- get { return m_enableExtraPadding; }
- set { if (m_enableExtraPadding == value) return; m_havePropertiesChanged = true; m_enableExtraPadding = value; UpdateMeshPadding(); SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_enableExtraPadding = false;
- [SerializeField]
- protected bool checkPaddingRequired;
-
-
-
- public bool richText
- {
- get { return m_isRichText; }
- set { if (m_isRichText == value) return; m_isRichText = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_isRichText = true;
-
-
-
- public bool parseCtrlCharacters
- {
- get { return m_parseCtrlCharacters; }
- set { if (m_parseCtrlCharacters == value) return; m_parseCtrlCharacters = value; m_havePropertiesChanged = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_parseCtrlCharacters = true;
-
-
-
- public bool isOverlay
- {
- get { return m_isOverlay; }
- set { if (m_isOverlay == value) return; m_isOverlay = value; SetShaderDepth(); m_havePropertiesChanged = true; SetVerticesDirty(); }
- }
- protected bool m_isOverlay = false;
-
-
-
- public bool isOrthographic
- {
- get { return m_isOrthographic; }
- set { if (m_isOrthographic == value) return; m_havePropertiesChanged = true; m_isOrthographic = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_isOrthographic = false;
-
-
-
- public bool enableCulling
- {
- get { return m_isCullingEnabled; }
- set { if (m_isCullingEnabled == value) return; m_isCullingEnabled = value; SetCulling(); m_havePropertiesChanged = true; }
- }
- [SerializeField]
- protected bool m_isCullingEnabled = false;
-
- protected bool m_isMaskingEnabled;
- protected bool isMaskUpdateRequired;
-
-
-
- public bool ignoreVisibility
- {
- get { return m_ignoreCulling; }
- set { if (m_ignoreCulling == value) return; m_havePropertiesChanged = true; m_ignoreCulling = value; }
- }
-
- protected bool m_ignoreCulling = true;
-
-
-
- public TextureMappingOptions horizontalMapping
- {
- get { return m_horizontalMapping; }
- set { if (m_horizontalMapping == value) return; m_havePropertiesChanged = true; m_horizontalMapping = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected TextureMappingOptions m_horizontalMapping = TextureMappingOptions.Character;
-
-
-
- public TextureMappingOptions verticalMapping
- {
- get { return m_verticalMapping; }
- set { if (m_verticalMapping == value) return; m_havePropertiesChanged = true; m_verticalMapping = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected TextureMappingOptions m_verticalMapping = TextureMappingOptions.Character;
-
-
-
-
-
-
-
-
-
-
-
-
-
- public float mappingUvLineOffset
- {
- get { return m_uvLineOffset; }
- set { if (m_uvLineOffset == value) return; m_havePropertiesChanged = true; m_uvLineOffset = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected float m_uvLineOffset = 0.0f;
-
-
-
- public TextRenderFlags renderMode
- {
- get { return m_renderMode; }
- set { if (m_renderMode == value) return; m_renderMode = value; m_havePropertiesChanged = true; }
- }
- protected TextRenderFlags m_renderMode = TextRenderFlags.Render;
-
-
-
- public VertexSortingOrder geometrySortingOrder
- {
- get { return m_geometrySortingOrder; }
- set { m_geometrySortingOrder = value; m_havePropertiesChanged = true; SetVerticesDirty(); }
- }
- [SerializeField]
- protected VertexSortingOrder m_geometrySortingOrder;
-
-
-
- public bool isTextObjectScaleStatic
- {
- get { return m_IsTextObjectScaleStatic; }
- set
- {
- m_IsTextObjectScaleStatic = value;
- if (m_IsTextObjectScaleStatic)
- TMP_UpdateManager.UnRegisterTextObjectForUpdate(this);
- else
- TMP_UpdateManager.RegisterTextObjectForUpdate(this);
- }
- }
- [SerializeField]
- protected bool m_IsTextObjectScaleStatic;
-
-
-
-
- public bool vertexBufferAutoSizeReduction
- {
- get { return m_VertexBufferAutoSizeReduction; }
- set { m_VertexBufferAutoSizeReduction = value; m_havePropertiesChanged = true; SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_VertexBufferAutoSizeReduction = true;
-
-
-
- public int firstVisibleCharacter
- {
- get { return m_firstVisibleCharacter; }
- set { if (m_firstVisibleCharacter == value) return; m_havePropertiesChanged = true; m_firstVisibleCharacter = value; SetVerticesDirty(); }
- }
-
- protected int m_firstVisibleCharacter;
-
-
-
- public int maxVisibleCharacters
- {
- get { return m_maxVisibleCharacters; }
- set { if (m_maxVisibleCharacters == value) return; m_havePropertiesChanged = true; m_maxVisibleCharacters = value; SetVerticesDirty(); }
- }
- protected int m_maxVisibleCharacters = 99999;
-
-
-
- public int maxVisibleWords
- {
- get { return m_maxVisibleWords; }
- set { if (m_maxVisibleWords == value) return; m_havePropertiesChanged = true; m_maxVisibleWords = value; SetVerticesDirty(); }
- }
- protected int m_maxVisibleWords = 99999;
-
-
-
- public int maxVisibleLines
- {
- get { return m_maxVisibleLines; }
- set { if (m_maxVisibleLines == value) return; m_havePropertiesChanged = true; m_isInputParsingRequired = true; m_maxVisibleLines = value; SetVerticesDirty(); }
- }
- protected int m_maxVisibleLines = 99999;
-
-
-
- public bool useMaxVisibleDescender
- {
- get { return m_useMaxVisibleDescender; }
- set { if (m_useMaxVisibleDescender == value) return; m_havePropertiesChanged = true; m_isInputParsingRequired = true; m_useMaxVisibleDescender = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected bool m_useMaxVisibleDescender = true;
-
-
-
- public int pageToDisplay
- {
- get { return m_pageToDisplay; }
- set { if (m_pageToDisplay == value) return; m_havePropertiesChanged = true; m_pageToDisplay = value; SetVerticesDirty(); }
- }
- [SerializeField]
- protected int m_pageToDisplay = 1;
- protected bool m_isNewPage = false;
-
-
-
- public virtual Vector4 margin
- {
- get { return m_margin; }
- set { if (m_margin == value) return; m_margin = value; ComputeMarginSize(); m_havePropertiesChanged = true; SetVerticesDirty(); }
- }
- [SerializeField]
- protected Vector4 m_margin = new Vector4(0, 0, 0, 0);
- protected float m_marginLeft;
- protected float m_marginRight;
- protected float m_marginWidth;
- protected float m_marginHeight;
- protected float m_width = -1;
-
-
-
- public TMP_TextInfo textInfo
- {
- get { return m_textInfo; }
- }
-
- protected TMP_TextInfo m_textInfo;
-
-
-
- public bool havePropertiesChanged
- {
- get { return m_havePropertiesChanged; }
- set { if (m_havePropertiesChanged == value) return; m_havePropertiesChanged = value; m_isInputParsingRequired = true; SetAllDirty(); }
- }
-
- protected bool m_havePropertiesChanged;
-
-
-
- public bool isUsingLegacyAnimationComponent
- {
- get { return m_isUsingLegacyAnimationComponent; }
- set { m_isUsingLegacyAnimationComponent = value; }
- }
- [SerializeField]
- protected bool m_isUsingLegacyAnimationComponent;
-
-
-
- public new Transform transform
- {
- get
- {
- if (m_transform == null)
- m_transform = GetComponent<Transform>();
- return m_transform;
- }
- }
- protected Transform m_transform;
-
-
-
- public new RectTransform rectTransform
- {
- get
- {
- if (m_rectTransform == null)
- m_rectTransform = GetComponent<RectTransform>();
- return m_rectTransform;
- }
- }
- protected RectTransform m_rectTransform;
-
-
-
- protected Vector2 m_PreviousRectTransformSize;
-
-
-
- protected Vector2 m_PreviousPivotPosition;
-
-
-
- public virtual bool autoSizeTextContainer
- {
- get;
- set;
- }
- protected bool m_autoSizeTextContainer;
-
-
-
- public virtual Mesh mesh
- {
- get { return m_mesh; }
- }
- protected Mesh m_mesh;
-
-
-
- public bool isVolumetricText
- {
- get { return m_isVolumetricText; }
- set { if (m_isVolumetricText == value) return; m_havePropertiesChanged = value; m_textInfo.ResetVertexLayout(value); m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
- }
- [SerializeField]
- protected bool m_isVolumetricText;
-
-
-
- public Bounds bounds
- {
- get
- {
- if (m_mesh == null) return new Bounds();
- return GetCompoundBounds();
- }
- }
-
-
-
- public Bounds textBounds
- {
- get
- {
- if (m_textInfo == null) return new Bounds();
- return GetTextBounds();
- }
- }
-
-
-
-
- public static event Func<int, string, TMP_FontAsset> OnFontAssetRequest;
-
-
-
- public static event Func<int, string, TMP_SpriteAsset> OnSpriteAssetRequest;
-
-
-
- public virtual event Action<TMP_TextInfo> OnPreRenderText = delegate { };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- protected TMP_SpriteAnimator spriteAnimator
- {
- get
- {
- if (m_spriteAnimator == null)
- {
- m_spriteAnimator = GetComponent<TMP_SpriteAnimator>();
- if (m_spriteAnimator == null) m_spriteAnimator = gameObject.AddComponent<TMP_SpriteAnimator>();
- }
- return m_spriteAnimator;
- }
- }
-
- protected TMP_SpriteAnimator m_spriteAnimator;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public float flexibleHeight { get { return m_flexibleHeight; } }
- protected float m_flexibleHeight = -1f;
-
-
-
- public float flexibleWidth { get { return m_flexibleWidth; } }
- protected float m_flexibleWidth = -1f;
-
-
-
- public float minWidth { get { return m_minWidth; } }
- protected float m_minWidth;
-
-
-
- public float minHeight { get { return m_minHeight; } }
- protected float m_minHeight;
-
-
-
- public float maxWidth { get { return m_maxWidth; } }
- protected float m_maxWidth;
-
-
-
- public float maxHeight { get { return m_maxHeight; } }
- protected float m_maxHeight;
-
-
-
- protected LayoutElement layoutElement
- {
- get
- {
- if (m_LayoutElement == null)
- {
- m_LayoutElement = GetComponent<LayoutElement>();
- }
- return m_LayoutElement;
- }
- }
- protected LayoutElement m_LayoutElement;
-
-
-
- public virtual float preferredWidth { get { m_preferredWidth = GetPreferredWidth(); return m_preferredWidth; } }
- protected float m_preferredWidth;
- protected float m_renderedWidth;
- protected bool m_isPreferredWidthDirty;
-
-
-
- public virtual float preferredHeight { get { m_preferredHeight = GetPreferredHeight(); return m_preferredHeight; } }
- protected float m_preferredHeight;
- protected float m_renderedHeight;
- protected bool m_isPreferredHeightDirty;
- protected bool m_isCalculatingPreferredValues;
-
-
-
- public virtual float renderedWidth { get { return GetRenderedWidth(); } }
-
-
-
- public virtual float renderedHeight { get { return GetRenderedHeight(); } }
-
-
-
- public int layoutPriority { get { return m_layoutPriority; } }
- protected int m_layoutPriority = 0;
- protected bool m_isLayoutDirty;
- protected bool m_isAwake;
- internal bool m_isWaitingOnResourceLoad;
- internal bool m_isInputParsingRequired = false;
-
-
-
-
-
-
- protected struct CharacterSubstitution
- {
- public int index;
- public uint unicode;
- public CharacterSubstitution (int index, uint unicode)
- {
- this.index = index;
- this.unicode = unicode;
- }
- }
-
- internal enum TextInputSources { Text = 0, SetText = 1, SetCharArray = 2, String = 3 };
-
- internal TextInputSources m_inputSource;
- protected float m_fontScale;
- protected float m_fontScaleMultiplier;
- protected char[] m_htmlTag = new char[128];
- protected RichTextTagAttribute[] m_xmlAttribute = new RichTextTagAttribute[8];
- protected float[] m_attributeParameterValues = new float[16];
- protected float tag_LineIndent = 0;
- protected float tag_Indent = 0;
- protected TMP_TextProcessingStack<float> m_indentStack = new TMP_TextProcessingStack<float>(new float[16]);
- protected bool tag_NoParsing;
-
- protected bool m_isParsingText;
- protected Matrix4x4 m_FXMatrix;
- protected bool m_isFXMatrixSet;
-
-
-
- protected UnicodeChar[] m_InternalParsingBuffer = new UnicodeChar[8];
-
-
-
- protected int m_InternalParsingBufferSize;
- protected struct UnicodeChar
- {
- public int unicode;
- public int stringIndex;
- public int length;
- }
- protected struct SpecialCharacter
- {
- public TMP_Character character;
- public TMP_FontAsset fontAsset;
- public Material material;
- public int materialIndex;
- public SpecialCharacter(TMP_Character character, int materialIndex)
- {
- this.character = character;
- this.fontAsset = character.textAsset as TMP_FontAsset;
- this.material = this.fontAsset != null ? this.fontAsset.material : null;
- this.materialIndex = materialIndex;
- }
- }
- private TMP_CharacterInfo[] m_internalCharacterInfo;
- protected char[] m_input_CharArray = new char[256];
- private int m_charArray_Length = 0;
- protected int m_totalCharacterCount;
-
- protected WordWrapState m_SavedWordWrapState = new WordWrapState();
- protected WordWrapState m_SavedLineState = new WordWrapState();
- protected WordWrapState m_SavedEllipsisState = new WordWrapState();
- protected WordWrapState m_SavedLastValidState = new WordWrapState();
- protected WordWrapState m_SavedSoftLineBreakState = new WordWrapState();
-
- internal TMP_TextProcessingStack<WordWrapState> m_EllipsisInsertionCandidateStack = new TMP_TextProcessingStack<WordWrapState>(8, 8);
-
- protected int m_characterCount;
-
-
- protected int m_firstCharacterOfLine;
- protected int m_firstVisibleCharacterOfLine;
- protected int m_lastCharacterOfLine;
- protected int m_lastVisibleCharacterOfLine;
- protected int m_lineNumber;
- protected int m_lineVisibleCharacterCount;
- protected int m_pageNumber;
- protected float m_PageAscender;
- protected float m_maxTextAscender;
- protected float m_maxCapHeight;
- protected float m_ElementAscender;
- protected float m_ElementDescender;
- protected float m_maxLineAscender;
- protected float m_maxLineDescender;
- protected float m_startOfLineAscender;
- protected float m_startOfLineDescender;
-
- protected float m_lineOffset;
- protected Extents m_meshExtents;
-
- protected Color32 m_htmlColor = new Color(255, 255, 255, 128);
- protected TMP_TextProcessingStack<Color32> m_colorStack = new TMP_TextProcessingStack<Color32>(new Color32[16]);
- protected TMP_TextProcessingStack<Color32> m_underlineColorStack = new TMP_TextProcessingStack<Color32>(new Color32[16]);
- protected TMP_TextProcessingStack<Color32> m_strikethroughColorStack = new TMP_TextProcessingStack<Color32>(new Color32[16]);
- protected TMP_TextProcessingStack<HighlightState> m_HighlightStateStack = new TMP_TextProcessingStack<HighlightState>(new HighlightState[16]);
- protected TMP_ColorGradient m_colorGradientPreset;
- protected TMP_TextProcessingStack<TMP_ColorGradient> m_colorGradientStack = new TMP_TextProcessingStack<TMP_ColorGradient>(new TMP_ColorGradient[16]);
- protected bool m_colorGradientPresetIsTinted;
- protected float m_tabSpacing = 0;
- protected float m_spacing = 0;
-
- protected TMP_TextProcessingStack<int>[] m_TextStyleStacks = new TMP_TextProcessingStack<int>[8];
- protected int m_TextStyleStackDepth = 0;
- protected TMP_TextProcessingStack<int> m_ItalicAngleStack = new TMP_TextProcessingStack<int>(new int[16]);
- protected int m_ItalicAngle;
- protected TMP_TextProcessingStack<int> m_actionStack = new TMP_TextProcessingStack<int>(new int[16]);
- protected float m_padding = 0;
- protected float m_baselineOffset;
- protected TMP_TextProcessingStack<float> m_baselineOffsetStack = new TMP_TextProcessingStack<float>(new float[16]);
- protected float m_xAdvance;
- protected TMP_TextElementType m_textElementType;
- protected TMP_TextElement m_cached_TextElement;
- protected SpecialCharacter m_Ellipsis;
- protected SpecialCharacter m_Underline;
- protected TMP_SpriteAsset m_defaultSpriteAsset;
- protected TMP_SpriteAsset m_currentSpriteAsset;
- protected int m_spriteCount = 0;
- protected int m_spriteIndex;
- protected int m_spriteAnimationID;
-
-
-
-
- protected virtual void LoadFontAsset() { }
-
-
-
-
- protected virtual void SetSharedMaterial(Material mat) { }
-
-
-
- protected virtual Material GetMaterial(Material mat) { return null; }
-
-
-
-
- protected virtual void SetFontBaseMaterial(Material mat) { }
-
-
-
-
- protected virtual Material[] GetSharedMaterials() { return null; }
-
-
-
- protected virtual void SetSharedMaterials(Material[] materials) { }
-
-
-
-
- protected virtual Material[] GetMaterials(Material[] mats) { return null; }
-
-
-
-
-
-
-
-
-
-
- protected virtual Material CreateMaterialInstance(Material source)
- {
- Material mat = new Material(source);
- mat.shaderKeywords = source.shaderKeywords;
- mat.name += " (Instance)";
- return mat;
- }
- protected void SetVertexColorGradient(TMP_ColorGradient gradient)
- {
- if (gradient == null) return;
- m_fontColorGradient.bottomLeft = gradient.bottomLeft;
- m_fontColorGradient.bottomRight = gradient.bottomRight;
- m_fontColorGradient.topLeft = gradient.topLeft;
- m_fontColorGradient.topRight = gradient.topRight;
- SetVerticesDirty();
- }
-
-
-
- protected void SetTextSortingOrder(VertexSortingOrder order)
- {
- }
-
-
-
-
- protected void SetTextSortingOrder(int[] order)
- {
- }
-
-
-
-
- protected virtual void SetFaceColor(Color32 color) { }
-
-
-
-
- protected virtual void SetOutlineColor(Color32 color) { }
-
-
-
-
- protected virtual void SetOutlineThickness(float thickness) { }
-
-
-
- protected virtual void SetShaderDepth() { }
-
-
-
- protected virtual void SetCulling() { }
-
-
-
- internal virtual void UpdateCulling() {}
-
-
-
-
- protected virtual float GetPaddingForMaterial()
- {
- ShaderUtilities.GetShaderPropertyIDs();
- if (m_sharedMaterial == null) return 0;
- m_padding = ShaderUtilities.GetPadding(m_sharedMaterial, m_enableExtraPadding, m_isUsingBold);
- m_isMaskingEnabled = ShaderUtilities.IsMaskingEnabled(m_sharedMaterial);
- m_isSDFShader = m_sharedMaterial.HasProperty(ShaderUtilities.ID_WeightNormal);
- return m_padding;
- }
-
-
-
-
- protected virtual float GetPaddingForMaterial(Material mat)
- {
- if (mat == null)
- return 0;
- m_padding = ShaderUtilities.GetPadding(mat, m_enableExtraPadding, m_isUsingBold);
- m_isMaskingEnabled = ShaderUtilities.IsMaskingEnabled(m_sharedMaterial);
- m_isSDFShader = mat.HasProperty(ShaderUtilities.ID_WeightNormal);
- return m_padding;
- }
-
-
-
-
- protected virtual Vector3[] GetTextContainerLocalCorners() { return null; }
-
- protected bool m_ignoreActiveState;
-
-
-
-
-
- public virtual void ForceMeshUpdate(bool ignoreActiveState = false, bool forceTextReparsing = false) { }
-
-
-
-
-
-
-
-
- internal void SetTextInternal(string text)
- {
- m_text = text;
- m_renderMode = TextRenderFlags.DontRender;
- m_isInputParsingRequired = true;
- ForceMeshUpdate();
- m_renderMode = TextRenderFlags.Render;
- }
-
-
-
-
-
-
-
-
-
-
- public virtual void UpdateGeometry(Mesh mesh, int index) { }
-
-
-
- public virtual void UpdateVertexData(TMP_VertexDataUpdateFlags flags) { }
-
-
-
- public virtual void UpdateVertexData() { }
-
-
-
-
- public virtual void SetVertices(Vector3[] vertices) { }
-
-
-
- public virtual void UpdateMeshPadding() { }
-
-
-
-
-
-
-
-
-
-
-
- public override void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
- {
- base.CrossFadeColor(targetColor, duration, ignoreTimeScale, useAlpha);
- InternalCrossFadeColor(targetColor, duration, ignoreTimeScale, useAlpha);
- }
-
-
-
-
-
-
- public override void CrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
- {
- base.CrossFadeAlpha(alpha, duration, ignoreTimeScale);
- InternalCrossFadeAlpha(alpha, duration, ignoreTimeScale);
- }
-
-
-
-
-
-
-
-
- protected virtual void InternalCrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha) { }
-
-
-
-
-
-
- protected virtual void InternalCrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale) { }
-
-
-
- protected void ParseInputText()
- {
-
-
- m_isInputParsingRequired = false;
- switch (m_inputSource)
- {
- case TextInputSources.String:
- case TextInputSources.Text:
- if (m_TextPreprocessor != null)
- m_InternalParsingBufferSize = StringToInternalParsingBuffer(m_TextPreprocessor.PreprocessText(m_text), ref m_InternalParsingBuffer);
- else
- m_InternalParsingBufferSize = StringToInternalParsingBuffer(m_text, ref m_InternalParsingBuffer);
- break;
- case TextInputSources.SetText:
- m_InternalParsingBufferSize = CharArrayToInternalParsingBuffer(m_input_CharArray, ref m_InternalParsingBuffer);
- break;
- case TextInputSources.SetCharArray:
- break;
- }
- SetArraySizes(m_InternalParsingBuffer);
-
- }
-
-
-
-
- public void SetText(string text, bool syncTextInputBox = true)
- {
- this.text = text;
- }
-
-
-
-
-
-
-
- public void SetText(string text, float arg0)
- {
- SetText(text, arg0, 0, 0, 0, 0, 0, 0, 0);
- }
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1)
- {
- SetText(text, arg0, arg1, 0, 0, 0, 0, 0, 0);
- }
-
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1, float arg2)
- {
- SetText(text, arg0, arg1, arg2, 0, 0, 0, 0, 0);
- }
-
-
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1, float arg2, float arg3)
- {
- SetText(text, arg0, arg1, arg2, arg3, 0, 0, 0, 0);
- }
-
-
-
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1, float arg2, float arg3, float arg4)
- {
- SetText(text, arg0, arg1, arg2, arg3, arg4, 0, 0, 0);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1, float arg2, float arg3, float arg4, float arg5)
- {
- SetText(text, arg0, arg1, arg2, arg3, arg4, arg5, 0, 0);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1, float arg2, float arg3, float arg4, float arg5, float arg6)
- {
- SetText(text, arg0, arg1, arg2, arg3, arg4, arg5, arg6, 0);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public void SetText(string text, float arg0, float arg1, float arg2, float arg3, float arg4, float arg5, float arg6, float arg7)
- {
- int argIndex = 0;
- int padding = 0;
- int decimalPrecision = 0;
- int readFlag = 0;
- int readIndex = 0;
- int writeIndex = 0;
- for (; readIndex < text.Length; readIndex++)
- {
- char c = text[readIndex];
- if (c == '{')
- {
- readFlag = 1;
- continue;
- }
- if (c == '}')
- {
-
- switch (argIndex)
- {
- case 0:
- AddFloatToCharArray(arg0, padding, decimalPrecision, ref writeIndex);
- break;
- case 1:
- AddFloatToCharArray(arg1, padding, decimalPrecision, ref writeIndex);
- break;
- case 2:
- AddFloatToCharArray(arg2, padding, decimalPrecision, ref writeIndex);
- break;
- case 3:
- AddFloatToCharArray(arg3, padding, decimalPrecision, ref writeIndex);
- break;
- case 4:
- AddFloatToCharArray(arg4, padding, decimalPrecision, ref writeIndex);
- break;
- case 5:
- AddFloatToCharArray(arg5, padding, decimalPrecision, ref writeIndex);
- break;
- case 6:
- AddFloatToCharArray(arg6, padding, decimalPrecision, ref writeIndex);
- break;
- case 7:
- AddFloatToCharArray(arg7, padding, decimalPrecision, ref writeIndex);
- break;
- }
- argIndex = 0;
- readFlag = 0;
- padding = 0;
- decimalPrecision = 0;
- continue;
- }
-
- if (readFlag == 1)
- {
- if (c >= '0' && c <= '8')
- {
- argIndex = c - 48;
- readFlag = 2;
- continue;
- }
- }
-
- if (readFlag == 2)
- {
-
- if (c == ':')
- continue;
-
- if (c == '.')
- {
- readFlag = 3;
- continue;
- }
- if (c == '#')
- {
-
- continue;
- }
- if (c == '0')
- {
- padding += 1;
- continue;
- }
- if (c == ',')
- {
-
- continue;
- }
-
- if (c >= '1' && c <= '9')
- {
- decimalPrecision = c - 48;
- continue;
- }
- }
-
- if (readFlag == 3)
- {
- if (c == '0')
- {
- decimalPrecision += 1;
- continue;
- }
- }
-
- m_input_CharArray[writeIndex] = c;
- writeIndex += 1;
- }
- m_input_CharArray[writeIndex] = (char)0;
- m_charArray_Length = writeIndex;
- #if UNITY_EDITOR
-
- m_text = new string(m_input_CharArray, 0, writeIndex - 1);
- #endif
- m_inputSource = TextInputSources.SetText;
- m_isInputParsingRequired = true;
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
-
-
-
-
-
-
-
- public void SetText(StringBuilder text)
- {
- m_inputSource = TextInputSources.SetCharArray;
- #if UNITY_EDITOR
-
- m_text = text.ToString();
- #endif
- m_InternalParsingBufferSize = StringBuilderToInternalParsingBuffer(text, ref m_InternalParsingBuffer);
- m_isInputParsingRequired = true;
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
-
-
-
-
- public void SetText(char[] text)
- {
- SetCharArray(text);
- }
-
-
-
-
-
-
- public void SetText(char[] text, int start, int length)
- {
- SetCharArray(text, start, length);
- }
-
-
-
-
- public void SetCharArray(char[] sourceText)
- {
- int characterCount = sourceText == null ? 0 : sourceText.Length;
- #if UNITY_EDITOR
-
- if (characterCount == 0)
- m_text = string.Empty;
- else
- m_text = new string(sourceText);
- #endif
-
- if (characterCount == 0)
- {
- m_InternalParsingBuffer[0].unicode = 0;
- m_InternalParsingBufferSize = 0;
- return;
- }
-
- if (m_InternalParsingBuffer.Length < characterCount)
- ResizeInternalArray(ref m_InternalParsingBuffer, characterCount);
-
- for (int i = 0; i < m_TextStyleStacks.Length; i++)
- m_TextStyleStacks[i].SetDefault(0);
- m_TextStyleStackDepth = 0;
- int writeIndex = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertOpeningStyleTag(m_TextStyle, 0, ref m_InternalParsingBuffer, ref writeIndex);
- for (int i = 0; sourceText != null && i < sourceText.Length; i++)
- {
- if (sourceText[i] == 92 && i < sourceText.Length - 1)
- {
- switch ((int)sourceText[i + 1])
- {
- case 110:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 10;
- i += 1;
- writeIndex += 1;
- continue;
- case 114:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 13;
- i += 1;
- writeIndex += 1;
- continue;
- case 116:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 9;
- i += 1;
- writeIndex += 1;
- continue;
- case 118:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 11;
- i += 1;
- writeIndex += 1;
- continue;
- }
- }
-
- if (sourceText[i] == 60)
- {
- if (IsTagName(ref sourceText, "<BR>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref sourceText, "<NBSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<ZWSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<STYLE=", i))
- {
- int srcOffset;
- if (ReplaceOpeningStyleTag(ref sourceText, i, out srcOffset, ref m_InternalParsingBuffer, ref writeIndex))
- {
- i = srcOffset;
- continue;
- }
- }
- else if (IsTagName(ref sourceText, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref sourceText, i, ref m_InternalParsingBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = sourceText[i];
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertClosingStyleTag(ref m_InternalParsingBuffer, ref writeIndex);
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0;
- m_InternalParsingBufferSize = writeIndex;
- m_inputSource = TextInputSources.SetCharArray;
- m_isInputParsingRequired = true;
- m_havePropertiesChanged = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
-
-
-
-
- public void SetCharArray(char[] sourceText, int start, int length)
- {
- int characterCount = 0;
-
- if (sourceText != null)
- {
- start = Mathf.Clamp(start, 0, sourceText.Length);
- length = Mathf.Clamp(length, 0, start + length < sourceText.Length ? length : sourceText.Length - start);
- characterCount = length;
- }
- #if UNITY_EDITOR
-
- if (characterCount == 0)
- m_text = string.Empty;
- else
- m_text = new string(sourceText, start, length);
- #endif
-
- if (characterCount == 0)
- {
- m_InternalParsingBuffer[0].unicode = 0;
- m_InternalParsingBufferSize = 0;
- return;
- }
-
- if (m_InternalParsingBuffer.Length < characterCount)
- ResizeInternalArray(ref m_InternalParsingBuffer, characterCount);
-
- for (int j = 0; j < m_TextStyleStacks.Length; j++)
- m_TextStyleStacks[j].SetDefault(0);
- m_TextStyleStackDepth = 0;
- int writeIndex = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertOpeningStyleTag(m_TextStyle, 0, ref m_InternalParsingBuffer, ref writeIndex);
- int i = start;
- int end = start + length;
- for (; i < end; i++)
- {
- if (sourceText[i] == 92 && i < length - 1)
- {
- switch ((int)sourceText[i + 1])
- {
- case 110:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 10;
- i += 1;
- writeIndex += 1;
- continue;
- case 114:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 13;
- i += 1;
- writeIndex += 1;
- continue;
- case 116:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 9;
- i += 1;
- writeIndex += 1;
- continue;
- case 118:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 11;
- i += 1;
- writeIndex += 1;
- continue;
- }
- }
-
- if (sourceText[i] == 60)
- {
- if (IsTagName(ref sourceText, "<BR>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref sourceText, "<NBSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<ZWSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<STYLE=", i))
- {
- int srcOffset;
- if (ReplaceOpeningStyleTag(ref sourceText, i, out srcOffset, ref m_InternalParsingBuffer, ref writeIndex))
- {
- i = srcOffset;
- continue;
- }
- }
- else if (IsTagName(ref sourceText, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref sourceText, i, ref m_InternalParsingBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = sourceText[i];
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertClosingStyleTag(ref m_InternalParsingBuffer, ref writeIndex);
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0;
- m_inputSource = TextInputSources.SetCharArray;
- m_havePropertiesChanged = true;
- m_isInputParsingRequired = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
-
-
-
-
- public void SetCharArray(int[] sourceText, int start, int length)
- {
-
- if (m_InternalParsingBuffer == null) m_InternalParsingBuffer = new UnicodeChar[8];
- #if UNITY_EDITOR
-
- if (sourceText == null || sourceText.Length == 0 || length == 0)
- {
- m_text = string.Empty;
- start = 0;
- length = 0;
- }
- else
- {
- m_text = sourceText.IntToString(start, length);
- }
- #endif
-
- for (int j = 0; j < m_TextStyleStacks.Length; j++)
- m_TextStyleStacks[j].SetDefault(0);
- m_TextStyleStackDepth = 0;
- int writeIndex = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertOpeningStyleTag(m_TextStyle, 0, ref m_InternalParsingBuffer, ref writeIndex);
- int end = start + length;
- for (int i = start; i < end && i < sourceText.Length; i++)
- {
- if (sourceText[i] == 92 && i < length - 1)
- {
- switch ((int)sourceText[i + 1])
- {
- case 110:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 10;
- i += 1;
- writeIndex += 1;
- continue;
- case 114:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 13;
- i += 1;
- writeIndex += 1;
- continue;
- case 116:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 9;
- i += 1;
- writeIndex += 1;
- continue;
- case 118:
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 11;
- i += 1;
- writeIndex += 1;
- continue;
- }
- }
-
- if (sourceText[i] == 60)
- {
- if (IsTagName(ref sourceText, "<BR>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref sourceText, "<NBSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<ZWSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<STYLE=", i))
- {
- int srcOffset;
- if (ReplaceOpeningStyleTag(ref sourceText, i, out srcOffset, ref m_InternalParsingBuffer, ref writeIndex))
- {
- i = srcOffset;
- continue;
- }
- }
- else if (IsTagName(ref sourceText, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref sourceText, i, ref m_InternalParsingBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = sourceText[i];
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertClosingStyleTag(ref m_InternalParsingBuffer, ref writeIndex);
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0;
- m_inputSource = TextInputSources.SetCharArray;
- m_havePropertiesChanged = true;
- m_isInputParsingRequired = true;
- SetVerticesDirty();
- SetLayoutDirty();
- }
-
-
-
-
-
- protected int CharArrayToInternalParsingBuffer(char[] sourceText, ref UnicodeChar[] internalParsingArray)
- {
- int characterCount = sourceText == null ? 0 : sourceText.Length;
- #if UNITY_EDITOR
-
-
- if (characterCount == 0)
- m_text = string.Empty;
- else
- m_text = new string(sourceText);
- #endif
-
- if (characterCount == 0)
- {
- if (internalParsingArray != null)
- internalParsingArray[0].unicode = 0;
- return 0;
- }
-
- if (internalParsingArray == null)
- internalParsingArray = new UnicodeChar[characterCount];
- else if (internalParsingArray.Length < characterCount)
- ResizeInternalArray(ref internalParsingArray, characterCount);
-
- for (int j = 0; j < m_TextStyleStacks.Length; j++)
- m_TextStyleStacks[j].SetDefault(0);
- m_TextStyleStackDepth = 0;
- int writeIndex = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertOpeningStyleTag(m_TextStyle, 0, ref internalParsingArray, ref writeIndex);
- for (int i = 0; i < m_charArray_Length; i++)
- {
-
- if (char.IsHighSurrogate(sourceText[i]) && char.IsLowSurrogate(sourceText[i + 1]))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = char.ConvertToUtf32(sourceText[i], sourceText[i + 1]);
- i += 1;
- writeIndex += 1;
- continue;
- }
-
- if (sourceText[i] == 60)
- {
- if (IsTagName(ref sourceText, "<BR>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref sourceText, "<NBSP>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<ZWSP>", i))
- {
- if (writeIndex == m_InternalParsingBuffer.Length) ResizeInternalArray(ref m_InternalParsingBuffer);
- m_InternalParsingBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<STYLE=", i))
- {
- int srcOffset;
- if (ReplaceOpeningStyleTag(ref sourceText, i, out srcOffset, ref internalParsingArray, ref writeIndex))
- {
- i = srcOffset;
- continue;
- }
- }
- else if (IsTagName(ref sourceText, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref sourceText, i, ref internalParsingArray, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = sourceText[i];
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertClosingStyleTag(ref internalParsingArray, ref writeIndex);
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 0;
- return writeIndex;
- }
-
-
-
-
-
- protected int StringToInternalParsingBuffer(string sourceText, ref UnicodeChar[] internalParsingArray)
- {
- int characterCount = sourceText == null ? 0 : sourceText.Length;
-
- if (characterCount == 0)
- {
- if (internalParsingArray != null)
- internalParsingArray[0].unicode = 0;
- return 0;
- }
-
- if (internalParsingArray == null)
- internalParsingArray = new UnicodeChar[characterCount];
- else if (internalParsingArray.Length < characterCount)
- ResizeInternalArray(ref internalParsingArray, characterCount);
-
- for (int j = 0; j < m_TextStyleStacks.Length; j++)
- m_TextStyleStacks[j].SetDefault(0);
- m_TextStyleStackDepth = 0;
- int writeIndex = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertOpeningStyleTag(m_TextStyle, 0, ref internalParsingArray, ref writeIndex);
- for (int i = 0; i < sourceText.Length; i++)
- {
- if (m_inputSource == TextInputSources.Text && sourceText[i] == 92 && sourceText.Length > i + 1)
- {
- switch ((int)sourceText[i + 1])
- {
- case 85:
- if (sourceText.Length > i + 9)
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = GetUTF32(sourceText, i + 2);
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 10;
- i += 9;
- writeIndex += 1;
- continue;
- }
- break;
- case 92:
- if (!m_parseCtrlCharacters) break;
- if (sourceText.Length <= i + 2) break;
- if (writeIndex + 2 > internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = sourceText[i + 1];
- internalParsingArray[writeIndex + 1].unicode = sourceText[i + 2];
- i += 2;
- writeIndex += 2;
- continue;
- case 110:
- if (!m_parseCtrlCharacters) break;
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 10;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- i += 1;
- writeIndex += 1;
- continue;
- case 114:
- if (!m_parseCtrlCharacters) break;
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 13;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- i += 1;
- writeIndex += 1;
- continue;
- case 116:
- if (!m_parseCtrlCharacters) break;
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 9;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- i += 1;
- writeIndex += 1;
- continue;
- case 117:
- if (sourceText.Length > i + 5)
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = GetUTF16(sourceText, i + 2);
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 6;
- i += 5;
- writeIndex += 1;
- continue;
- }
- break;
- case 118:
- if (!m_parseCtrlCharacters) break;
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 11;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- i += 1;
- writeIndex += 1;
- continue;
- }
- }
-
- if (char.IsHighSurrogate(sourceText[i]) && char.IsLowSurrogate(sourceText[i + 1]))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = char.ConvertToUtf32(sourceText[i], sourceText[i + 1]);
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 2;
- i += 1;
- writeIndex += 1;
- continue;
- }
-
- if (sourceText[i] == 60 && m_isRichText)
- {
- if (IsTagName(ref sourceText, "<BR>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 10;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref sourceText, "<NBSP>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 160;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<ZWSP>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 0x200B;
- internalParsingArray[writeIndex].stringIndex = i;
- internalParsingArray[writeIndex].length = 1;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<STYLE=", i))
- {
- int srcOffset;
- if (ReplaceOpeningStyleTag(ref sourceText, i, out srcOffset, ref internalParsingArray, ref writeIndex))
- {
- i = srcOffset;
- continue;
- }
- }
- else if (IsTagName(ref sourceText, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref sourceText, i, ref internalParsingArray, ref writeIndex);
- i += 7;
- continue;
- }
- }
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = sourceText[i];
- internalParsingArray[writeIndex].stringIndex = writeIndex;
- internalParsingArray[writeIndex].length = 1;
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertClosingStyleTag(ref internalParsingArray, ref writeIndex);
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 0;
- return writeIndex;
- }
-
-
-
-
-
- protected int StringBuilderToInternalParsingBuffer(StringBuilder sourceText, ref UnicodeChar[] internalParsingArray)
- {
- int characterCount = sourceText == null ? 0 : sourceText.Length;
- #if UNITY_EDITOR
-
-
- if (characterCount == 0)
- m_text = string.Empty;
- else
- m_text = sourceText.ToString();
- #endif
-
- if (characterCount == 0)
- {
- if (internalParsingArray != null)
- internalParsingArray[0].unicode = 0;
- return 0;
- }
-
- if (internalParsingArray == null)
- internalParsingArray = new UnicodeChar[characterCount];
- else if (internalParsingArray.Length < characterCount)
- ResizeInternalArray(ref internalParsingArray, characterCount);
-
- for (int j = 0; j < m_TextStyleStacks.Length; j++)
- m_TextStyleStacks[j].SetDefault(0);
- m_TextStyleStackDepth = 0;
- int writeIndex = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertOpeningStyleTag(m_TextStyle, 0, ref internalParsingArray, ref writeIndex);
- for (int i = 0; i < sourceText.Length; i++)
- {
- if (m_parseCtrlCharacters && sourceText[i] == 92 && sourceText.Length > i + 1)
- {
- switch ((int)sourceText[i + 1])
- {
- case 85:
- if (sourceText.Length > i + 9)
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = GetUTF32(sourceText, i + 2);
- i += 9;
- writeIndex += 1;
- continue;
- }
- break;
- case 92:
- if (sourceText.Length <= i + 2) break;
- if (writeIndex + 2 > internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = sourceText[i + 1];
- internalParsingArray[writeIndex + 1].unicode = sourceText[i + 2];
- i += 2;
- writeIndex += 2;
- continue;
- case 110:
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 10;
- i += 1;
- writeIndex += 1;
- continue;
- case 114:
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 13;
- i += 1;
- writeIndex += 1;
- continue;
- case 116:
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 9;
- i += 1;
- writeIndex += 1;
- continue;
- case 117:
- if (sourceText.Length > i + 5)
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = GetUTF16(sourceText, i + 2);
- i += 5;
- writeIndex += 1;
- continue;
- }
- break;
- case 118:
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 11;
- i += 1;
- writeIndex += 1;
- continue;
- }
- }
-
- if (char.IsHighSurrogate(sourceText[i]) && char.IsLowSurrogate(sourceText[i + 1]))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = char.ConvertToUtf32(sourceText[i], sourceText[i + 1]);
- i += 1;
- writeIndex += 1;
- continue;
- }
-
- if (sourceText[i] == 60)
- {
- if (IsTagName(ref sourceText, "<BR>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref sourceText, "<NBSP>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<ZWSP>", i))
- {
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref sourceText, "<STYLE=", i))
- {
- int srcOffset;
- if (ReplaceOpeningStyleTag(ref sourceText, i, out srcOffset, ref internalParsingArray, ref writeIndex))
- {
- i = srcOffset;
- continue;
- }
- }
- else if (IsTagName(ref sourceText, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref sourceText, i, ref internalParsingArray, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = sourceText[i];
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
-
- if (textStyle.hashCode != (int)TagHashCode.NORMAL)
- InsertClosingStyleTag(ref internalParsingArray, ref writeIndex);
- if (writeIndex == internalParsingArray.Length) ResizeInternalArray(ref internalParsingArray);
- internalParsingArray[writeIndex].unicode = 0;
- return writeIndex;
- }
-
-
-
-
-
-
-
-
-
- bool ReplaceOpeningStyleTag(ref string sourceText, int srcIndex, out int srcOffset, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null || srcOffset == 0) return false;
-
- m_TextStyleStackDepth += 1;
-
- m_TextStyleStacks[m_TextStyleStackDepth].Push(style.hashCode);
- int styleLength = style.styleOpeningTagArray.Length;
-
- int[] tagDefinition = style.styleOpeningTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
-
-
-
-
- bool ReplaceOpeningStyleTag(ref int[] sourceText, int srcIndex, out int srcOffset, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null || srcOffset == 0) return false;
-
- m_TextStyleStackDepth += 1;
-
- m_TextStyleStacks[m_TextStyleStackDepth].Push(style.hashCode);
- int styleLength = style.styleOpeningTagArray.Length;
-
- int[] tagDefinition = style.styleOpeningTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
-
-
-
-
- bool ReplaceOpeningStyleTag(ref char[] sourceText, int srcIndex, out int srcOffset, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null || srcOffset == 0) return false;
-
- m_TextStyleStackDepth += 1;
-
- m_TextStyleStacks[m_TextStyleStackDepth].Push(style.hashCode);
- int styleLength = style.styleOpeningTagArray.Length;
-
- int[] tagDefinition = style.styleOpeningTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
-
-
-
-
- bool ReplaceOpeningStyleTag(ref StringBuilder sourceText, int srcIndex, out int srcOffset, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null || srcOffset == 0) return false;
-
- m_TextStyleStackDepth += 1;
-
- m_TextStyleStacks[m_TextStyleStackDepth].Push(style.hashCode);
- int styleLength = style.styleOpeningTagArray.Length;
-
- int[] tagDefinition = style.styleOpeningTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- return true;
- }
-
-
-
-
-
-
-
-
- bool ReplaceClosingStyleTag(ref string sourceText, int srcIndex, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = m_TextStyleStacks[m_TextStyleStackDepth + 1].Pop();
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null) return false;
-
- m_TextStyleStackDepth += 1;
- int styleLength = style.styleClosingTagArray.Length;
-
- int[] tagDefinition = style.styleClosingTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
-
-
-
- bool ReplaceClosingStyleTag(ref int[] sourceText, int srcIndex, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = m_TextStyleStacks[m_TextStyleStackDepth + 1].Pop();
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null) return false;
-
- m_TextStyleStackDepth += 1;
- int styleLength = style.styleClosingTagArray.Length;
-
- int[] tagDefinition = style.styleClosingTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset; ;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
-
-
-
- bool ReplaceClosingStyleTag(ref char[] sourceText, int srcIndex, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = m_TextStyleStacks[m_TextStyleStackDepth + 1].Pop();
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null) return false;
-
- m_TextStyleStackDepth += 1;
- int styleLength = style.styleClosingTagArray.Length;
-
- int[] tagDefinition = style.styleClosingTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
-
-
-
- bool ReplaceClosingStyleTag(ref StringBuilder sourceText, int srcIndex, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = m_TextStyleStacks[m_TextStyleStackDepth + 1].Pop();
- TMP_Style style = GetStyle(hashCode);
-
- if (style == null) return false;
-
- m_TextStyleStackDepth += 1;
- int styleLength = style.styleClosingTagArray.Length;
-
- int[] tagDefinition = style.styleClosingTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth -= 1;
- return true;
- }
-
-
-
-
-
- TMP_Style GetStyle(int hashCode)
- {
- TMP_Style style = null;
-
- if (m_StyleSheet != null)
- {
- style = m_StyleSheet.GetStyle(hashCode);
- if (style != null)
- return style;
- }
- if (TMP_Settings.defaultStyleSheet != null)
- style = TMP_Settings.defaultStyleSheet.GetStyle(hashCode);
- return style;
- }
- bool InsertOpeningStyleTag(TMP_Style style, int srcIndex, ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- if (style == null) return false;
- m_TextStyleStacks[0].Push(style.hashCode);
- int styleLength = style.styleOpeningTagArray.Length;
-
- int[] tagDefinition = style.styleOpeningTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
- return true;
- }
- bool InsertClosingStyleTag(ref UnicodeChar[] charBuffer, ref int writeIndex)
- {
-
- int hashCode = m_TextStyleStacks[0].Pop();
- TMP_Style style = GetStyle(hashCode);
- int styleLength = style.styleClosingTagArray.Length;
-
- int[] tagDefinition = style.styleClosingTagArray;
- for (int i = 0; i < styleLength; i++)
- {
- int c = tagDefinition[i];
- if (c == '\\' && i + 1 < styleLength)
- {
- switch (tagDefinition[i + 1])
- {
- case '\\':
- i += 1;
- break;
- case 'n':
- c = 10;
- i += 1;
- break;
- case 'r':
- break;
- case 't':
- break;
- case 'u':
-
- if (i + 5 < styleLength)
- {
- c = GetUTF16(tagDefinition, i + 2);
- i += 5;
- }
- break;
- case 'U':
-
- if (i + 9 < styleLength)
- {
- c = GetUTF32(tagDefinition, i + 2);
- i += 9;
- }
- break;
- }
- }
- if (c == 60)
- {
- if (IsTagName(ref tagDefinition, "<BR>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 10;
- writeIndex += 1;
- i += 3;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<NBSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 160;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<ZWSP>", i))
- {
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = 0x200B;
- writeIndex += 1;
- i += 5;
- continue;
- }
- else if (IsTagName(ref tagDefinition, "<STYLE=", i))
- {
- int offset;
- if (ReplaceOpeningStyleTag(ref tagDefinition, i, out offset, ref charBuffer, ref writeIndex))
- {
- i = offset;
- continue;
- }
- }
- else if (IsTagName(ref tagDefinition, "</STYLE>", i))
- {
- ReplaceClosingStyleTag(ref tagDefinition, i, ref charBuffer, ref writeIndex);
-
- i += 7;
- continue;
- }
- }
- if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
- charBuffer[writeIndex].unicode = c;
- writeIndex += 1;
- }
- m_TextStyleStackDepth = 0;
- return true;
- }
-
-
-
-
-
-
-
- bool IsTagName (ref string text, string tag, int index)
- {
- if (text.Length < index + tag.Length) return false;
- for (int i = 0; i < tag.Length; i++)
- {
- if (TMP_TextUtilities.ToUpperFast(text[index + i]) != tag[i]) return false;
- }
- return true;
- }
-
-
-
-
-
-
-
- bool IsTagName(ref char[] text, string tag, int index)
- {
- if (text.Length < index + tag.Length) return false;
- for (int i = 0; i < tag.Length; i++)
- {
- if (TMP_TextUtilities.ToUpperFast(text[index + i]) != tag[i]) return false;
- }
- return true;
- }
-
-
-
-
-
-
-
- bool IsTagName(ref int[] text, string tag, int index)
- {
- if (text.Length < index + tag.Length) return false;
- for (int i = 0; i < tag.Length; i++)
- {
- if (TMP_TextUtilities.ToUpperFast((char)text[index + i]) != tag[i]) return false;
- }
- return true;
- }
-
-
-
-
-
-
-
- bool IsTagName(ref StringBuilder text, string tag, int index)
- {
- if (text.Length < index + tag.Length) return false;
- for (int i = 0; i < tag.Length; i++)
- {
- if (TMP_TextUtilities.ToUpperFast(text[index + i]) != tag[i]) return false;
- }
- return true;
- }
-
-
-
-
-
-
-
- int GetTagHashCode(ref string text, int index, out int closeIndex)
- {
- int hashCode = 0;
- closeIndex = 0;
- for (int i = index; i < text.Length; i++)
- {
-
- if (text[i] == 34) continue;
-
- if (text[i] == 62) { closeIndex = i; break; }
- hashCode = (hashCode << 5) + hashCode ^ TMP_TextParsingUtilities.ToUpperASCIIFast(text[i]);
- }
- return hashCode;
- }
-
-
-
-
-
-
-
- int GetTagHashCode(ref char[] text, int index, out int closeIndex)
- {
- int hashCode = 0;
- closeIndex = 0;
- for (int i = index; i < text.Length; i++)
- {
-
- if (text[i] == 34) continue;
-
- if (text[i] == 62) { closeIndex = i; break; }
- hashCode = (hashCode << 5) + hashCode ^ TMP_TextParsingUtilities.ToUpperASCIIFast(text[i]);
- }
- return hashCode;
- }
-
-
-
-
-
-
-
- int GetTagHashCode(ref int[] text, int index, out int closeIndex)
- {
- int hashCode = 0;
- closeIndex = 0;
- for (int i = index; i < text.Length; i++)
- {
-
- if (text[i] == 34) continue;
-
- if (text[i] == 62) { closeIndex = i; break; }
- hashCode = (hashCode << 5) + hashCode ^ TMP_TextParsingUtilities.ToUpperASCIIFast((char)text[i]);
- }
- return hashCode;
- }
-
-
-
-
-
-
-
- int GetTagHashCode(ref StringBuilder text, int index, out int closeIndex)
- {
- int hashCode = 0;
- closeIndex = 0;
- for (int i = index; i < text.Length; i++)
- {
-
- if (text[i] == 34) continue;
-
- if (text[i] == 62) { closeIndex = i; break; }
- hashCode = (hashCode << 5) + hashCode ^ TMP_TextParsingUtilities.ToUpperASCIIFast(text[i]);
- }
- return hashCode;
- }
-
-
-
- void ResizeInternalArray <T>(ref T[] array)
- {
- int size = Mathf.NextPowerOfTwo(array.Length + 1);
- System.Array.Resize(ref array, size);
- }
- void ResizeInternalArray<T>(ref T[] array, int size)
- {
- size = Mathf.NextPowerOfTwo(size + 1);
- System.Array.Resize(ref array, size);
- }
- private readonly decimal[] k_Power = { 5e-1m, 5e-2m, 5e-3m, 5e-4m, 5e-5m, 5e-6m, 5e-7m, 5e-8m, 5e-9m, 5e-10m };
- void AddFloatToCharArray(float value, int padding, int precision, ref int writeIndex)
- {
- if (value < 0)
- {
- m_input_CharArray[writeIndex] = '-';
- writeIndex += 1;
- value = -value;
- }
-
- decimal valueD = (decimal)value;
-
- if (padding == 0 && precision == 0)
- precision = 9;
- else
- valueD += k_Power[Mathf.Min(9, precision)];
- long integer = (long)valueD;
- AddIntegerToCharArray(integer, padding, ref writeIndex);
- if (precision > 0)
- {
- valueD -= integer;
-
- if (valueD != 0)
- {
-
- m_input_CharArray[writeIndex++] = '.';
- for (int p = 0; p < precision; p++)
- {
- valueD *= 10;
- long d = (long)valueD;
- m_input_CharArray[writeIndex++] = (char)(d + 48);
- valueD -= d;
- if (valueD == 0)
- p = precision;
- }
- }
- }
- }
-
-
-
-
-
-
- void AddIntegerToCharArray(double number, int padding, ref int writeIndex)
- {
- int integralCount = 0;
- int i = writeIndex;
- do
- {
- m_input_CharArray[i++] = (char)(number % 10 + 48);
- number /= 10;
- integralCount += 1;
- } while (number > 0.999d || integralCount < padding);
- int lastIndex = i;
-
- while (writeIndex + 1 < i)
- {
- i -= 1;
- char t = m_input_CharArray[writeIndex];
- m_input_CharArray[writeIndex] = m_input_CharArray[i];
- m_input_CharArray[i] = t;
- writeIndex += 1;
- }
- writeIndex = lastIndex;
- }
-
-
-
-
-
- protected virtual int SetArraySizes(UnicodeChar[] unicodeChars) { return 0; }
-
-
-
- protected virtual void GenerateTextMesh() { }
-
-
-
-
- public Vector2 GetPreferredValues()
- {
- if (m_isInputParsingRequired || m_isTextTruncated)
- {
- m_isCalculatingPreferredValues = true;
- ParseInputText();
- }
-
- float preferredWidth = GetPreferredWidth();
-
- float preferredHeight = GetPreferredHeight();
- return new Vector2(preferredWidth, preferredHeight);
- }
-
-
-
-
- public Vector2 GetPreferredValues(float width, float height)
- {
- if (m_isInputParsingRequired || m_isTextTruncated)
- {
- m_isCalculatingPreferredValues = true;
- ParseInputText();
- }
- Vector2 margin = new Vector2(width, height);
-
- float preferredWidth = GetPreferredWidth(margin);
-
- float preferredHeight = GetPreferredHeight(margin);
- return new Vector2(preferredWidth, preferredHeight);
- }
-
-
-
-
-
- public Vector2 GetPreferredValues(string text)
- {
- m_isCalculatingPreferredValues = true;
- StringToInternalParsingBuffer(text, ref m_InternalParsingBuffer);
- SetArraySizes(m_InternalParsingBuffer);
- Vector2 margin = k_LargePositiveVector2;
-
- float preferredWidth = GetPreferredWidth(margin);
-
- float preferredHeight = GetPreferredHeight(margin);
- return new Vector2(preferredWidth, preferredHeight);
- }
-
-
-
-
-
- public Vector2 GetPreferredValues(string text, float width, float height)
- {
- m_isCalculatingPreferredValues = true;
- StringToInternalParsingBuffer(text, ref m_InternalParsingBuffer);
- SetArraySizes(m_InternalParsingBuffer);
- Vector2 margin = new Vector2(width, height);
-
- float preferredWidth = GetPreferredWidth(margin);
-
- float preferredHeight = GetPreferredHeight(margin);
- return new Vector2(preferredWidth, preferredHeight);
- }
-
-
-
-
- protected float GetPreferredWidth()
- {
- if (TMP_Settings.instance == null) return 0;
-
- if (!m_isPreferredWidthDirty)
- return m_preferredWidth;
- float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
-
- m_minFontSize = m_fontSizeMin;
- m_maxFontSize = m_fontSizeMax;
- m_charWidthAdjDelta = 0;
-
- Vector2 margin = k_LargePositiveVector2;
- if (m_isInputParsingRequired || m_isTextTruncated)
- {
- m_isCalculatingPreferredValues = true;
- ParseInputText();
- }
- m_AutoSizeIterationCount = 0;
- float preferredWidth = CalculatePreferredValues(ref fontSize, margin, false, false).x;
- m_isPreferredWidthDirty = false;
-
- return preferredWidth;
- }
-
-
-
-
-
- float GetPreferredWidth(Vector2 margin)
- {
- float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
-
- m_minFontSize = m_fontSizeMin;
- m_maxFontSize = m_fontSizeMax;
- m_charWidthAdjDelta = 0;
- m_AutoSizeIterationCount = 0;
- float preferredWidth = CalculatePreferredValues(ref fontSize, margin, false, false).x;
-
- return preferredWidth;
- }
-
-
-
-
- protected float GetPreferredHeight()
- {
- if (TMP_Settings.instance == null) return 0;
-
- if (!m_isPreferredHeightDirty)
- return m_preferredHeight;
- float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
-
- m_minFontSize = m_fontSizeMin;
- m_maxFontSize = m_fontSizeMax;
- m_charWidthAdjDelta = 0;
- Vector2 margin = new Vector2(m_marginWidth != 0 ? m_marginWidth : k_LargePositiveFloat, k_LargePositiveFloat);
- if (m_isInputParsingRequired || m_isTextTruncated)
- {
- m_isCalculatingPreferredValues = true;
- ParseInputText();
- }
-
- m_IsAutoSizePointSizeSet = false;
- m_AutoSizeIterationCount = 0;
-
-
- float preferredHeight = 0;
- while (m_IsAutoSizePointSizeSet == false)
- {
- preferredHeight = CalculatePreferredValues(ref fontSize, margin, m_enableAutoSizing, m_enableWordWrapping).y;
- m_AutoSizeIterationCount += 1;
- }
- m_isPreferredHeightDirty = false;
-
- return preferredHeight;
- }
-
-
-
-
-
- float GetPreferredHeight(Vector2 margin)
- {
- float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
-
- m_minFontSize = m_fontSizeMin;
- m_maxFontSize = m_fontSizeMax;
- m_charWidthAdjDelta = 0;
-
- m_IsAutoSizePointSizeSet = false;
- m_AutoSizeIterationCount = 0;
-
-
- float preferredHeight = 0;
- while (m_IsAutoSizePointSizeSet == false)
- {
- preferredHeight = CalculatePreferredValues(ref fontSize, margin, m_enableAutoSizing, m_enableWordWrapping).y;
- m_AutoSizeIterationCount += 1;
- }
-
- return preferredHeight;
- }
-
-
-
-
- public Vector2 GetRenderedValues()
- {
- return GetTextBounds().size;
- }
-
-
-
-
-
- public Vector2 GetRenderedValues(bool onlyVisibleCharacters)
- {
- return GetTextBounds(onlyVisibleCharacters).size;
- }
-
-
-
-
- float GetRenderedWidth()
- {
- return GetRenderedValues().x;
- }
-
-
-
-
- protected float GetRenderedWidth(bool onlyVisibleCharacters)
- {
- return GetRenderedValues(onlyVisibleCharacters).x;
- }
-
-
-
-
- float GetRenderedHeight()
- {
- return GetRenderedValues().y;
- }
-
-
-
-
- protected float GetRenderedHeight(bool onlyVisibleCharacters)
- {
- return GetRenderedValues(onlyVisibleCharacters).y;
- }
-
-
-
-
- protected virtual Vector2 CalculatePreferredValues(ref float fontSize, Vector2 marginSize, bool isTextAutoSizingEnabled, bool isWordWrappingEnabled)
- {
-
-
-
- if (m_fontAsset == null || m_fontAsset.characterLookupTable == null)
- {
- Debug.LogWarning("Can't Generate Mesh! No Font Asset has been assigned to Object ID: " + this.GetInstanceID());
- m_IsAutoSizePointSizeSet = true;
- return Vector2.zero;
- }
-
- if (m_InternalParsingBuffer == null || m_InternalParsingBuffer.Length == 0 || m_InternalParsingBuffer[0].unicode == (char)0)
- {
- m_IsAutoSizePointSizeSet = true;
- return Vector2.zero;
- }
- m_currentFontAsset = m_fontAsset;
- m_currentMaterial = m_sharedMaterial;
- m_currentMaterialIndex = 0;
- m_materialReferenceStack.SetDefault(new MaterialReference(0, m_currentFontAsset, null, m_currentMaterial, m_padding));
-
- int totalCharacterCount = m_totalCharacterCount;
- if (m_internalCharacterInfo == null || totalCharacterCount > m_internalCharacterInfo.Length)
- m_internalCharacterInfo = new TMP_CharacterInfo[totalCharacterCount > 1024 ? totalCharacterCount + 256 : Mathf.NextPowerOfTwo(totalCharacterCount)];
-
-
- float baseScale = m_fontScale = (fontSize / m_fontAsset.faceInfo.pointSize * m_fontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- float currentElementScale = baseScale;
- float currentEmScale = fontSize * 0.01f * (m_isOrthographic ? 1 : 0.1f);
- m_fontScaleMultiplier = 1;
- m_currentFontSize = fontSize;
- m_sizeStack.SetDefault(m_currentFontSize);
- float fontSizeDelta = 0;
- m_FontStyleInternal = m_fontStyle;
- m_lineJustification = m_HorizontalAlignment;
- m_lineJustificationStack.SetDefault(m_lineJustification);
- m_baselineOffset = 0;
- m_baselineOffsetStack.Clear();
- m_lineOffset = 0;
- m_lineHeight = TMP_Math.FLOAT_UNSET;
- float lineGap = m_currentFontAsset.faceInfo.lineHeight - (m_currentFontAsset.faceInfo.ascentLine - m_currentFontAsset.faceInfo.descentLine);
- m_cSpacing = 0;
- m_monoSpacing = 0;
-
- m_xAdvance = 0;
- float maxXAdvance = 0;
- tag_LineIndent = 0;
- tag_Indent = 0;
- m_indentStack.SetDefault(0);
- tag_NoParsing = false;
-
- m_characterCount = 0;
-
- m_firstCharacterOfLine = 0;
- m_maxLineAscender = k_LargeNegativeFloat;
- m_maxLineDescender = k_LargePositiveFloat;
- m_lineNumber = 0;
- m_startOfLineAscender = 0;
- m_IsDrivenLineSpacing = false;
- float marginWidth = marginSize.x;
- float marginHeight = marginSize.y;
- m_marginLeft = 0;
- m_marginRight = 0;
- float lineMarginLeft = 0;
- float lineMarginRight = 0;
- m_width = -1;
- float widthOfTextArea = marginWidth + 0.0001f - m_marginLeft - m_marginRight;
-
- float renderedWidth = 0;
- float renderedHeight = 0;
- float textWidth = 0;
- m_isCalculatingPreferredValues = true;
-
- m_maxCapHeight = 0;
- m_maxTextAscender = 0;
- m_ElementDescender = 0;
- float maxVisibleDescender = 0;
- bool isMaxVisibleDescenderSet = false;
-
- bool isFirstWordOfLine = true;
- m_isNonBreakingSpace = false;
-
- bool isLastCharacterCJK = false;
-
- CharacterSubstitution characterToSubstitute = new CharacterSubstitution(-1, 0);
- bool isSoftHyphenIgnored = false;
- WordWrapState internalWordWrapState = new WordWrapState();
- WordWrapState internalLineState = new WordWrapState();
- WordWrapState internalSoftLineBreak = new WordWrapState();
-
- m_AutoSizeIterationCount += 1;
-
- for (int i = 0; i < m_InternalParsingBuffer.Length && m_InternalParsingBuffer[i].unicode != 0; i++)
- {
- int charCode = m_InternalParsingBuffer[i].unicode;
-
- #region Parse Rich Text Tag
- if (m_isRichText && charCode == 60)
- {
- m_isParsingText = true;
- m_textElementType = TMP_TextElementType.Character;
- int endTagIndex;
-
- if (ValidateHtmlTag(m_InternalParsingBuffer, i + 1, out endTagIndex))
- {
- i = endTagIndex;
-
- if (m_textElementType == TMP_TextElementType.Character)
- continue;
- }
- }
- else
- {
- m_textElementType = m_textInfo.characterInfo[m_characterCount].elementType;
- m_currentMaterialIndex = m_textInfo.characterInfo[m_characterCount].materialReferenceIndex;
- m_currentFontAsset = m_textInfo.characterInfo[m_characterCount].fontAsset;
- }
- #endregion End Parse Rich Text Tag
- int prev_MaterialIndex = m_currentMaterialIndex;
- bool isUsingAltTypeface = m_textInfo.characterInfo[m_characterCount].isUsingAlternateTypeface;
- m_isParsingText = false;
-
- #region Character Substitutions
- bool isInjectingCharacter = false;
- if (characterToSubstitute.index == m_characterCount)
- {
- charCode = (int)characterToSubstitute.unicode;
- m_textElementType = TMP_TextElementType.Character;
- isInjectingCharacter = true;
- switch (charCode)
- {
- case 0x03:
- m_internalCharacterInfo[m_characterCount].textElement = m_currentFontAsset.characterLookupTable[0x03];
- m_isTextTruncated = true;
- break;
- case 0x2D:
-
- break;
- case 0x2026:
- m_internalCharacterInfo[m_characterCount].textElement = m_Ellipsis.character; ;
- m_internalCharacterInfo[m_characterCount].elementType = TMP_TextElementType.Character;
- m_internalCharacterInfo[m_characterCount].fontAsset = m_Ellipsis.fontAsset;
- m_internalCharacterInfo[m_characterCount].material = m_Ellipsis.material;
- m_internalCharacterInfo[m_characterCount].materialReferenceIndex = m_Ellipsis.materialIndex;
-
- m_isTextTruncated = true;
-
- characterToSubstitute.index = m_characterCount + 1;
- characterToSubstitute.unicode = 0x03;
- break;
- }
- }
- #endregion
-
- #region Linked Text
- if (m_characterCount < m_firstVisibleCharacter && charCode != 0x03)
- {
- m_internalCharacterInfo[m_characterCount].isVisible = false;
- m_internalCharacterInfo[m_characterCount].character = (char)0x200B;
- m_internalCharacterInfo[m_characterCount].lineNumber = 0;
- m_characterCount += 1;
- continue;
- }
- #endregion
-
- #region Handling of LowerCase, UpperCase and SmallCaps Font Styles
- float smallCapsMultiplier = 1.0f;
- if (m_textElementType == TMP_TextElementType.Character)
- {
- if ( (m_FontStyleInternal & FontStyles.UpperCase) == FontStyles.UpperCase)
- {
-
- if (char.IsLower((char)charCode))
- charCode = char.ToUpper((char)charCode);
- }
- else if ( (m_FontStyleInternal & FontStyles.LowerCase) == FontStyles.LowerCase)
- {
-
- if (char.IsUpper((char)charCode))
- charCode = char.ToLower((char)charCode);
- }
- else if ( (m_FontStyleInternal & FontStyles.SmallCaps) == FontStyles.SmallCaps)
- {
- if (char.IsLower((char)charCode))
- {
- smallCapsMultiplier = 0.8f;
- charCode = char.ToUpper((char)charCode);
- }
- }
- }
- #endregion
-
- #region Look up Character Data
-
- float elementAscentLine = 0;
- float elementDescentLine = 0;
- if (m_textElementType == TMP_TextElementType.Sprite)
- {
-
- m_currentSpriteAsset = m_textInfo.characterInfo[m_characterCount].spriteAsset;
- m_spriteIndex = m_textInfo.characterInfo[m_characterCount].spriteIndex;
- TMP_SpriteCharacter sprite = m_currentSpriteAsset.spriteCharacterTable[m_spriteIndex];
- if (sprite == null) continue;
-
- if (charCode == 60)
- charCode = 57344 + m_spriteIndex;
-
- if (m_currentSpriteAsset.faceInfo.pointSize > 0)
- {
- float spriteScale = (m_currentFontSize / m_currentSpriteAsset.faceInfo.pointSize * m_currentSpriteAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- currentElementScale = sprite.scale * sprite.glyph.scale * spriteScale;
- elementAscentLine = m_currentSpriteAsset.faceInfo.ascentLine;
-
- elementDescentLine = m_currentSpriteAsset.faceInfo.descentLine;
- }
- else
- {
- float spriteScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- currentElementScale = m_currentFontAsset.faceInfo.ascentLine / sprite.glyph.metrics.height * sprite.scale * sprite.glyph.scale * spriteScale;
- float scaleDelta = spriteScale / currentElementScale;
- elementAscentLine = m_currentFontAsset.faceInfo.ascentLine * scaleDelta;
-
- elementDescentLine = m_currentFontAsset.faceInfo.descentLine * scaleDelta;
- }
- m_cached_TextElement = sprite;
- m_internalCharacterInfo[m_characterCount].elementType = TMP_TextElementType.Sprite;
- m_internalCharacterInfo[m_characterCount].scale = currentElementScale;
- m_currentMaterialIndex = prev_MaterialIndex;
- }
- else if (m_textElementType == TMP_TextElementType.Character)
- {
- m_cached_TextElement = m_textInfo.characterInfo[m_characterCount].textElement;
- if (m_cached_TextElement == null) continue;
- m_currentMaterialIndex = m_textInfo.characterInfo[m_characterCount].materialReferenceIndex;
- float adjustedScale;
- if (isInjectingCharacter && m_InternalParsingBuffer[i].unicode == 0x0A && m_characterCount != m_firstCharacterOfLine)
- adjustedScale = m_textInfo.characterInfo[m_characterCount - 1].pointSize * smallCapsMultiplier / m_currentFontAsset.m_FaceInfo.pointSize * m_currentFontAsset.m_FaceInfo.scale * (m_isOrthographic ? 1 : 0.1f);
- else
- adjustedScale = m_currentFontSize * smallCapsMultiplier / m_currentFontAsset.m_FaceInfo.pointSize * m_currentFontAsset.m_FaceInfo.scale * (m_isOrthographic ? 1 : 0.1f);
- elementAscentLine = m_currentFontAsset.m_FaceInfo.ascentLine;
- elementDescentLine = m_currentFontAsset.m_FaceInfo.descentLine;
- currentElementScale = adjustedScale * m_fontScaleMultiplier * m_cached_TextElement.scale;
-
- m_internalCharacterInfo[m_characterCount].elementType = TMP_TextElementType.Character;
- }
- #endregion
-
- #region Handle Soft Hyphen
- float currentElementUnmodifiedScale = currentElementScale;
- if (charCode == 0xAD || charCode == 0x03)
- currentElementScale = 0;
- #endregion
-
- m_internalCharacterInfo[m_characterCount].character = (char)charCode;
-
- GlyphMetrics currentGlyphMetrics = m_cached_TextElement.m_Glyph.metrics;
-
- bool isWhiteSpace = char.IsWhiteSpace((char)charCode);
-
- #region Handle Kerning
- TMP_GlyphValueRecord glyphAdjustments = new TMP_GlyphValueRecord();
- float characterSpacingAdjustment = m_characterSpacing;
- m_GlyphHorizontalAdvanceAdjustment = 0;
- if (m_enableKerning)
- {
- TMP_GlyphPairAdjustmentRecord adjustmentPair;
- uint baseGlyphIndex = m_cached_TextElement.m_GlyphIndex;
- if (m_characterCount < totalCharacterCount - 1)
- {
- uint nextGlyphIndex = m_textInfo.characterInfo[m_characterCount + 1].textElement.m_GlyphIndex;
- uint key = nextGlyphIndex << 16 | baseGlyphIndex;
- if (m_currentFontAsset.m_FontFeatureTable.m_GlyphPairAdjustmentRecordLookupDictionary.TryGetValue(key, out adjustmentPair))
- {
- glyphAdjustments = adjustmentPair.m_FirstAdjustmentRecord.m_GlyphValueRecord;
- characterSpacingAdjustment = (adjustmentPair.m_FeatureLookupFlags & FontFeatureLookupFlags.IgnoreSpacingAdjustments) == FontFeatureLookupFlags.IgnoreSpacingAdjustments ? 0 : characterSpacingAdjustment;
- }
- }
- if (m_characterCount >= 1)
- {
- uint previousGlyphIndex = m_textInfo.characterInfo[m_characterCount - 1].textElement.m_GlyphIndex;
- uint key = baseGlyphIndex << 16 | previousGlyphIndex;
- if (m_currentFontAsset.m_FontFeatureTable.m_GlyphPairAdjustmentRecordLookupDictionary.TryGetValue(key, out adjustmentPair))
- {
- glyphAdjustments += adjustmentPair.m_SecondAdjustmentRecord.m_GlyphValueRecord;
- characterSpacingAdjustment = (adjustmentPair.m_FeatureLookupFlags & FontFeatureLookupFlags.IgnoreSpacingAdjustments) == FontFeatureLookupFlags.IgnoreSpacingAdjustments ? 0 : characterSpacingAdjustment;
- }
- }
- m_GlyphHorizontalAdvanceAdjustment = glyphAdjustments.m_XAdvance;
- }
- #endregion
-
- #region Handle Right-to-Left
-
-
-
-
-
-
- #endregion
-
- #region Handle Mono Spacing
- float monoAdvance = 0;
- if (m_monoSpacing != 0)
- {
- monoAdvance = (m_monoSpacing / 2 - (m_cached_TextElement.glyph.metrics.width / 2 + m_cached_TextElement.glyph.metrics.horizontalBearingX) * currentElementScale) * (1 - m_charWidthAdjDelta);
- m_xAdvance += monoAdvance;
- }
- #endregion
-
- #region Handle Style Padding
- float boldSpacingAdjustment = 0;
- if (m_textElementType == TMP_TextElementType.Character && !isUsingAltTypeface && ((m_FontStyleInternal & FontStyles.Bold) == FontStyles.Bold))
- boldSpacingAdjustment = m_currentFontAsset.boldSpacing;
- #endregion Handle Style Padding
- m_internalCharacterInfo[m_characterCount].baseLine = 0 - m_lineOffset + m_baselineOffset;
-
- #region Compute Ascender & Descender values
-
- float elementAscender = m_textElementType == TMP_TextElementType.Character
- ? elementAscentLine * currentElementScale / smallCapsMultiplier + m_baselineOffset
- : elementAscentLine * currentElementScale + m_baselineOffset;
-
- float elementDescender = m_textElementType == TMP_TextElementType.Character
- ? elementDescentLine * currentElementScale / smallCapsMultiplier + m_baselineOffset
- : elementDescentLine * currentElementScale + m_baselineOffset;
- float adjustedAscender = elementAscender;
- float adjustedDescender = elementDescender;
- bool isFirstCharacterOfLine = m_characterCount == m_firstCharacterOfLine;
-
- if (isFirstCharacterOfLine || isWhiteSpace == false)
- {
-
- if (m_baselineOffset != 0)
- {
- adjustedAscender = Mathf.Max((elementAscender - m_baselineOffset) / m_fontScaleMultiplier, adjustedAscender);
- adjustedDescender = Mathf.Min((elementDescender - m_baselineOffset) / m_fontScaleMultiplier, adjustedDescender);
- }
- m_maxLineAscender = Mathf.Max(adjustedAscender, m_maxLineAscender);
- m_maxLineDescender = Mathf.Min(adjustedDescender, m_maxLineDescender);
- }
-
- if (isFirstCharacterOfLine || isWhiteSpace == false)
- {
- m_internalCharacterInfo[m_characterCount].adjustedAscender = adjustedAscender;
- m_internalCharacterInfo[m_characterCount].adjustedDescender = adjustedDescender;
- m_ElementAscender = m_internalCharacterInfo[m_characterCount].ascender = elementAscender - m_lineOffset;
- m_ElementDescender = m_internalCharacterInfo[m_characterCount].descender = elementDescender - m_lineOffset;
- }
- else
- {
- m_internalCharacterInfo[m_characterCount].adjustedAscender = m_maxLineAscender;
- m_internalCharacterInfo[m_characterCount].adjustedDescender = m_maxLineDescender;
- m_ElementAscender = m_internalCharacterInfo[m_characterCount].ascender = m_maxLineAscender - m_lineOffset;
- m_ElementDescender = m_internalCharacterInfo[m_characterCount].descender = m_maxLineDescender - m_lineOffset;
- }
-
- if (m_lineNumber == 0 || m_isNewPage)
- {
- if (isFirstCharacterOfLine || isWhiteSpace == false)
- {
- m_maxTextAscender = m_maxLineAscender;
- m_maxCapHeight = Mathf.Max(m_maxCapHeight, m_currentFontAsset.m_FaceInfo.capLine * currentElementScale / smallCapsMultiplier);
- }
- }
-
- if (m_lineOffset == 0)
- {
- if (!isWhiteSpace || m_characterCount == m_firstCharacterOfLine)
- m_PageAscender = m_PageAscender > elementAscender ? m_PageAscender : elementAscender;
- }
- #endregion
- bool isJustifiedOrFlush = (m_lineJustification & HorizontalAlignmentOptions.Flush) == HorizontalAlignmentOptions.Flush || (m_lineJustification & HorizontalAlignmentOptions.Justified) == HorizontalAlignmentOptions.Justified;
-
- #region Handle Visible Characters
- if (charCode == 9 || (isWhiteSpace == false && charCode != 0x200B && charCode != 0xAD && charCode != 0x03) || (charCode == 0xAD && isSoftHyphenIgnored == false) || m_textElementType == TMP_TextElementType.Sprite)
- {
-
-
-
-
-
-
-
-
- widthOfTextArea = m_width != -1 ? Mathf.Min(marginWidth + 0.0001f - m_marginLeft - m_marginRight, m_width) : marginWidth + 0.0001f - m_marginLeft - m_marginRight;
-
- textWidth = Mathf.Abs(m_xAdvance) + currentGlyphMetrics.horizontalAdvance * (1 - m_charWidthAdjDelta) * (charCode == 0xAD ? currentElementUnmodifiedScale : currentElementScale);
- int testedCharacterCount = m_characterCount;
-
- #region Current Line Horizontal Bounds Check
- if (textWidth > widthOfTextArea * (isJustifiedOrFlush ? 1.05f : 1.0f))
- {
-
- if (isWordWrappingEnabled && m_characterCount != m_firstCharacterOfLine)
- {
-
- i = RestoreWordWrappingState(ref internalWordWrapState);
-
- #region Handle Soft Hyphenation
- if (m_internalCharacterInfo[m_characterCount - 1].character == 0xAD && isSoftHyphenIgnored == false && m_overflowMode == TextOverflowModes.Overflow)
- {
- characterToSubstitute.index = m_characterCount - 1;
- characterToSubstitute.unicode = 0x2D;
- i -= 1;
- m_characterCount -= 1;
- continue;
- }
- isSoftHyphenIgnored = false;
-
- if (m_internalCharacterInfo[m_characterCount].character == 0xAD)
- {
- isSoftHyphenIgnored = true;
- continue;
- }
- #endregion
-
- #region Handle Text Auto Size (if word wrapping is no longer possible)
- if (isTextAutoSizingEnabled && isFirstWordOfLine)
- {
-
- #region Character Width Adjustments
- if (m_charWidthAdjDelta < m_charWidthMaxAdj / 100 && m_AutoSizeIterationCount < m_AutoSizeMaxIterationCount)
- {
- float adjustedTextWidth = textWidth;
-
- if (m_charWidthAdjDelta > 0)
- adjustedTextWidth /= 1f - m_charWidthAdjDelta;
- float adjustmentDelta = textWidth - (widthOfTextArea - 0.0001f) * (isJustifiedOrFlush ? 1.05f : 1.0f);
- m_charWidthAdjDelta += adjustmentDelta / adjustedTextWidth;
- m_charWidthAdjDelta = Mathf.Min(m_charWidthAdjDelta, m_charWidthMaxAdj / 100);
-
- return Vector2.zero;
- }
- #endregion
-
- #region Text Auto-Sizing (Text greater than vertical bounds)
- if (fontSize > m_fontSizeMin && m_AutoSizeIterationCount < m_AutoSizeMaxIterationCount)
- {
- m_maxFontSize = fontSize;
- float sizeDelta = Mathf.Max((fontSize - m_minFontSize) / 2, 0.05f);
- fontSize -= sizeDelta;
- fontSize = Mathf.Max((int)(fontSize * 20 + 0.5f) / 20f, m_fontSizeMin);
-
- return Vector2.zero;
- }
- #endregion Text Auto-Sizing
- }
- #endregion
-
- float baselineAdjustmentDelta = m_maxLineAscender - m_startOfLineAscender;
- if (m_lineOffset > 0 && Math.Abs(baselineAdjustmentDelta) > 0.01f && m_IsDrivenLineSpacing == false && !m_isNewPage)
- {
-
- m_ElementDescender -= baselineAdjustmentDelta;
- m_lineOffset += baselineAdjustmentDelta;
- }
-
- float lineAscender = m_maxLineAscender - m_lineOffset;
- float lineDescender = m_maxLineDescender - m_lineOffset;
-
- m_ElementDescender = m_ElementDescender < lineDescender ? m_ElementDescender : lineDescender;
- if (!isMaxVisibleDescenderSet)
- maxVisibleDescender = m_ElementDescender;
- if (m_useMaxVisibleDescender && (m_characterCount >= m_maxVisibleCharacters || m_lineNumber >= m_maxVisibleLines))
- isMaxVisibleDescenderSet = true;
-
- m_firstCharacterOfLine = m_characterCount;
- m_lineVisibleCharacterCount = 0;
-
- renderedWidth += m_xAdvance;
- if (isWordWrappingEnabled)
- renderedHeight = m_maxTextAscender - m_ElementDescender;
- else
- renderedHeight = Mathf.Max(renderedHeight, lineAscender - lineDescender);
-
- SaveWordWrappingState(ref internalLineState, i, m_characterCount - 1);
- m_lineNumber += 1;
- float ascender = m_internalCharacterInfo[m_characterCount].adjustedAscender;
-
- if (m_lineHeight == TMP_Math.FLOAT_UNSET)
- {
- m_lineOffset += 0 - m_maxLineDescender + ascender + (lineGap + m_lineSpacingDelta) * baseScale + m_lineSpacing * currentEmScale;
- m_IsDrivenLineSpacing = false;
- }
- else
- {
- m_lineOffset += m_lineHeight + m_lineSpacing * currentEmScale;
- m_IsDrivenLineSpacing = true;
- }
- m_maxLineAscender = k_LargeNegativeFloat;
- m_maxLineDescender = k_LargePositiveFloat;
- m_startOfLineAscender = ascender;
- m_xAdvance = 0 + tag_Indent;
-
- isFirstWordOfLine = true;
- continue;
- }
- }
- #endregion
- lineMarginLeft = m_marginLeft;
- lineMarginRight = m_marginRight;
- }
- #endregion Handle Visible Characters
-
- #region Adjust Line Spacing
-
- #endregion
-
- #region XAdvance, Tabulation & Stops
- if (charCode == 9)
- {
- float tabSize = m_currentFontAsset.faceInfo.tabWidth * m_currentFontAsset.tabSize * currentElementScale;
- float tabs = Mathf.Ceil(m_xAdvance / tabSize) * tabSize;
- m_xAdvance = tabs > m_xAdvance ? tabs : m_xAdvance + tabSize;
- }
- else if (m_monoSpacing != 0)
- {
- m_xAdvance += (m_monoSpacing - monoAdvance + ((m_currentFontAsset.normalSpacingOffset + characterSpacingAdjustment) * currentEmScale) + m_cSpacing) * (1 - m_charWidthAdjDelta);
- if (isWhiteSpace || charCode == 0x200B)
- m_xAdvance += m_wordSpacing * currentEmScale;
- }
- else
- {
- m_xAdvance += ((currentGlyphMetrics.horizontalAdvance + glyphAdjustments.xAdvance + boldSpacingAdjustment) * currentElementScale + (m_currentFontAsset.normalSpacingOffset + characterSpacingAdjustment) * currentEmScale + m_cSpacing) * (1 - m_charWidthAdjDelta);
- if (isWhiteSpace || charCode == 0x200B)
- m_xAdvance += m_wordSpacing * currentEmScale;
- }
- #endregion Tabulation & Stops
-
- #region Carriage Return
- if (charCode == 13)
- {
- maxXAdvance = Mathf.Max(maxXAdvance, renderedWidth + m_xAdvance);
- renderedWidth = 0;
- m_xAdvance = 0 + tag_Indent;
- }
- #endregion Carriage Return
-
- #region Check for Line Feed and Last Character
- if (charCode == 10 || charCode == 11 || charCode == 0x03 || charCode == 0x2028 || charCode == 0x2029 || m_characterCount == totalCharacterCount - 1)
- {
-
- float baselineAdjustmentDelta = m_maxLineAscender - m_startOfLineAscender;
- if (m_lineOffset > 0 && Math.Abs(baselineAdjustmentDelta) > 0.01f && m_IsDrivenLineSpacing == false && !m_isNewPage)
- {
- m_ElementDescender -= baselineAdjustmentDelta;
- m_lineOffset += baselineAdjustmentDelta;
- }
- m_isNewPage = false;
-
-
- float lineDescender = m_maxLineDescender - m_lineOffset;
-
- m_ElementDescender = m_ElementDescender < lineDescender ? m_ElementDescender : lineDescender;
-
- if (m_characterCount == totalCharacterCount - 1)
- renderedWidth = Mathf.Max(maxXAdvance, renderedWidth + textWidth + lineMarginLeft + lineMarginRight);
- else
- {
- maxXAdvance = Mathf.Max(maxXAdvance, renderedWidth + textWidth + lineMarginLeft + lineMarginRight);
- renderedWidth = 0;
- }
- renderedHeight = m_maxTextAscender - m_ElementDescender;
-
- if (charCode == 10 || charCode == 11 || charCode == 0x2D || charCode == 0x2028 || charCode == 0x2029)
- {
-
- SaveWordWrappingState(ref internalLineState, i, m_characterCount);
-
- SaveWordWrappingState(ref internalWordWrapState, i, m_characterCount);
- m_lineNumber += 1;
- m_firstCharacterOfLine = m_characterCount + 1;
- float ascender = m_internalCharacterInfo[m_characterCount].adjustedAscender;
-
- if (m_lineHeight == TMP_Math.FLOAT_UNSET)
- {
- float lineOffsetDelta = 0 - m_maxLineDescender + ascender + (lineGap + m_lineSpacingDelta) * baseScale + (m_lineSpacing + (charCode == 10 || charCode == 0x2029 ? m_paragraphSpacing : 0)) * currentEmScale;
- m_lineOffset += lineOffsetDelta;
- m_IsDrivenLineSpacing = false;
- }
- else
- {
- m_lineOffset += m_lineHeight + (m_lineSpacing + (charCode == 10 || charCode == 0x2029 ? m_paragraphSpacing : 0)) * currentEmScale;
- m_IsDrivenLineSpacing = true;
- }
- m_maxLineAscender = k_LargeNegativeFloat;
- m_maxLineDescender = k_LargePositiveFloat;
- m_startOfLineAscender = ascender;
- m_xAdvance = 0 + tag_LineIndent + tag_Indent;
- m_characterCount += 1;
- continue;
- }
-
- if (charCode == 0x03)
- i = m_InternalParsingBuffer.Length;
- }
- #endregion Check for Linefeed or Last Character
-
- #region Save Word Wrapping State
- if (isWordWrappingEnabled || m_overflowMode == TextOverflowModes.Truncate || m_overflowMode == TextOverflowModes.Ellipsis)
- {
- if ((isWhiteSpace || charCode == 0x200B || charCode == 0x2D || charCode == 0xAD) && !m_isNonBreakingSpace && charCode != 0xA0 && charCode != 0x2007 && charCode != 0x2011 && charCode != 0x202F && charCode != 0x2060)
- {
-
-
- SaveWordWrappingState(ref internalWordWrapState, i, m_characterCount);
- isFirstWordOfLine = false;
- isLastCharacterCJK = false;
-
- internalSoftLineBreak.previous_WordBreak = -1;
- }
-
- else if (m_isNonBreakingSpace == false &&
- ((charCode > 0x1100 && charCode < 0x11ff ||
- charCode > 0xA960 && charCode < 0xA97F ||
- charCode > 0xAC00 && charCode < 0xD7FF)&&
- TMP_Settings.useModernHangulLineBreakingRules == false ||
- (charCode > 0x2E80 && charCode < 0x9FFF ||
- charCode > 0xF900 && charCode < 0xFAFF ||
- charCode > 0xFE30 && charCode < 0xFE4F ||
- charCode > 0xFF00 && charCode < 0xFFEF)))
- {
- bool isLeadingCharacter = TMP_Settings.linebreakingRules.leadingCharacters.ContainsKey(charCode);
- bool isFollowingCharacter = m_characterCount < totalCharacterCount - 1 && TMP_Settings.linebreakingRules.followingCharacters.ContainsKey(m_internalCharacterInfo[m_characterCount + 1].character);
- if (isFirstWordOfLine || isLeadingCharacter == false)
- {
- if (isFollowingCharacter == false)
- {
- SaveWordWrappingState(ref internalWordWrapState, i, m_characterCount);
- isFirstWordOfLine = false;
- }
- if (isFirstWordOfLine)
- {
-
- if (isWhiteSpace)
- SaveWordWrappingState(ref internalSoftLineBreak, i, m_characterCount);
- SaveWordWrappingState(ref internalWordWrapState, i, m_characterCount);
- }
- }
- isLastCharacterCJK = true;
- }
- else if (isLastCharacterCJK)
- {
- bool isLeadingCharacter = TMP_Settings.linebreakingRules.leadingCharacters.ContainsKey(charCode);
- if (isLeadingCharacter == false)
- SaveWordWrappingState(ref internalWordWrapState, i, m_characterCount);
- isLastCharacterCJK = false;
- }
- else if (isFirstWordOfLine)
- {
-
- if (isWhiteSpace || (charCode == 0xAD && isSoftHyphenIgnored == false))
- SaveWordWrappingState(ref internalSoftLineBreak, i, m_characterCount);
- SaveWordWrappingState(ref internalWordWrapState, i, m_characterCount);
- isLastCharacterCJK = false;
- }
- }
- #endregion Save Word Wrapping State
- m_characterCount += 1;
- }
-
- #region Check Auto-Sizing (Upper Font Size Bounds)
- fontSizeDelta = m_maxFontSize - m_minFontSize;
- if (isTextAutoSizingEnabled && fontSizeDelta > 0.051f && fontSize < m_fontSizeMax && m_AutoSizeIterationCount < m_AutoSizeMaxIterationCount)
- {
-
- if (m_charWidthAdjDelta < m_charWidthMaxAdj / 100)
- m_charWidthAdjDelta = 0;
- m_minFontSize = fontSize;
- float sizeDelta = Mathf.Max((m_maxFontSize - fontSize) / 2, 0.05f);
- fontSize += sizeDelta;
- fontSize = Mathf.Min((int)(fontSize * 20 + 0.5f) / 20f, m_fontSizeMax);
-
- return Vector2.zero;
- }
- #endregion End Auto-sizing Check
- m_IsAutoSizePointSizeSet = true;
- m_isCalculatingPreferredValues = false;
-
- renderedWidth += m_margin.x > 0 ? m_margin.x : 0;
- renderedWidth += m_margin.z > 0 ? m_margin.z : 0;
- renderedHeight += m_margin.y > 0 ? m_margin.y : 0;
- renderedHeight += m_margin.w > 0 ? m_margin.w : 0;
-
- renderedWidth = (int)(renderedWidth * 100 + 1f) / 100f;
- renderedHeight = (int)(renderedHeight * 100 + 1f) / 100f;
-
-
- return new Vector2(renderedWidth, renderedHeight);
- }
-
-
-
-
- protected virtual Bounds GetCompoundBounds() { return new Bounds(); }
- internal virtual Rect GetCanvasSpaceClippingRect() { return Rect.zero; }
-
-
-
-
- protected Bounds GetTextBounds()
- {
- if (m_textInfo == null || m_textInfo.characterCount > m_textInfo.characterInfo.Length) return new Bounds();
- Extents extent = new Extents(k_LargePositiveVector2, k_LargeNegativeVector2);
- for (int i = 0; i < m_textInfo.characterCount && i < m_textInfo.characterInfo.Length; i++)
- {
- if (!m_textInfo.characterInfo[i].isVisible) continue;
- extent.min.x = Mathf.Min(extent.min.x, m_textInfo.characterInfo[i].bottomLeft.x);
- extent.min.y = Mathf.Min(extent.min.y, m_textInfo.characterInfo[i].descender);
- extent.max.x = Mathf.Max(extent.max.x, m_textInfo.characterInfo[i].xAdvance);
- extent.max.y = Mathf.Max(extent.max.y, m_textInfo.characterInfo[i].ascender);
- }
- Vector2 size;
- size.x = extent.max.x - extent.min.x;
- size.y = extent.max.y - extent.min.y;
- Vector3 center = (extent.min + extent.max) / 2;
- return new Bounds(center, size);
- }
-
-
-
-
-
- protected Bounds GetTextBounds(bool onlyVisibleCharacters)
- {
- if (m_textInfo == null) return new Bounds();
- Extents extent = new Extents(k_LargePositiveVector2, k_LargeNegativeVector2);
- for (int i = 0; i < m_textInfo.characterCount; i++)
- {
- if ((i > maxVisibleCharacters || m_textInfo.characterInfo[i].lineNumber > m_maxVisibleLines) && onlyVisibleCharacters) break;
- if (onlyVisibleCharacters && !m_textInfo.characterInfo[i].isVisible) continue;
- extent.min.x = Mathf.Min(extent.min.x, m_textInfo.characterInfo[i].origin);
- extent.min.y = Mathf.Min(extent.min.y, m_textInfo.characterInfo[i].descender);
- extent.max.x = Mathf.Max(extent.max.x, m_textInfo.characterInfo[i].xAdvance);
- extent.max.y = Mathf.Max(extent.max.y, m_textInfo.characterInfo[i].ascender);
- }
- Vector2 size;
- size.x = extent.max.x - extent.min.x;
- size.y = extent.max.y - extent.min.y;
- Vector2 center = (extent.min + extent.max) / 2;
- return new Bounds(center, size);
- }
-
-
-
-
-
-
-
- protected void AdjustLineOffset(int startIndex, int endIndex, float offset)
- {
- Vector3 vertexOffset = new Vector3(0, offset, 0);
- for (int i = startIndex; i <= endIndex; i++)
- {
- m_textInfo.characterInfo[i].bottomLeft -= vertexOffset;
- m_textInfo.characterInfo[i].topLeft -= vertexOffset;
- m_textInfo.characterInfo[i].topRight -= vertexOffset;
- m_textInfo.characterInfo[i].bottomRight -= vertexOffset;
- m_textInfo.characterInfo[i].ascender -= vertexOffset.y;
- m_textInfo.characterInfo[i].baseLine -= vertexOffset.y;
- m_textInfo.characterInfo[i].descender -= vertexOffset.y;
- if (m_textInfo.characterInfo[i].isVisible)
- {
- m_textInfo.characterInfo[i].vertex_BL.position -= vertexOffset;
- m_textInfo.characterInfo[i].vertex_TL.position -= vertexOffset;
- m_textInfo.characterInfo[i].vertex_TR.position -= vertexOffset;
- m_textInfo.characterInfo[i].vertex_BR.position -= vertexOffset;
- }
- }
- }
-
-
-
-
- protected void ResizeLineExtents(int size)
- {
- size = size > 1024 ? size + 256 : Mathf.NextPowerOfTwo(size + 1);
- TMP_LineInfo[] temp_lineInfo = new TMP_LineInfo[size];
- for (int i = 0; i < size; i++)
- {
- if (i < m_textInfo.lineInfo.Length)
- temp_lineInfo[i] = m_textInfo.lineInfo[i];
- else
- {
- temp_lineInfo[i].lineExtents.min = k_LargePositiveVector2;
- temp_lineInfo[i].lineExtents.max = k_LargeNegativeVector2;
- temp_lineInfo[i].ascender = k_LargeNegativeFloat;
- temp_lineInfo[i].descender = k_LargePositiveFloat;
- }
- }
- m_textInfo.lineInfo = temp_lineInfo;
- }
- protected static Vector2 k_LargePositiveVector2 = new Vector2(TMP_Math.INT_MAX, TMP_Math.INT_MAX);
- protected static Vector2 k_LargeNegativeVector2 = new Vector2(TMP_Math.INT_MIN, TMP_Math.INT_MIN);
- protected static float k_LargePositiveFloat = TMP_Math.FLOAT_MAX;
- protected static float k_LargeNegativeFloat = TMP_Math.FLOAT_MIN;
- protected static int k_LargePositiveInt = TMP_Math.INT_MAX;
- protected static int k_LargeNegativeInt = TMP_Math.INT_MIN;
-
-
-
-
-
- public virtual TMP_TextInfo GetTextInfo(string text) { return null; }
-
-
-
- public virtual void ComputeMarginSize() { }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- protected void InsertNewLine(int i, float baseScale, float currentElementScale, float currentEmScale, float glyphAdjustment, float boldSpacingAdjustment, float characterSpacingAdjustment, float width, float lineGap, ref bool isMaxVisibleDescenderSet, ref float maxVisibleDescender)
- {
-
- float baselineAdjustmentDelta = m_maxLineAscender - m_startOfLineAscender;
- if (m_lineOffset > 0 && Math.Abs(baselineAdjustmentDelta) > 0.01f && m_IsDrivenLineSpacing == false && !m_isNewPage)
- {
- AdjustLineOffset(m_firstCharacterOfLine, m_characterCount, baselineAdjustmentDelta);
- m_ElementDescender -= baselineAdjustmentDelta;
- m_lineOffset += baselineAdjustmentDelta;
- }
-
- float lineAscender = m_maxLineAscender - m_lineOffset;
- float lineDescender = m_maxLineDescender - m_lineOffset;
-
- m_ElementDescender = m_ElementDescender < lineDescender ? m_ElementDescender : lineDescender;
- if (!isMaxVisibleDescenderSet)
- maxVisibleDescender = m_ElementDescender;
- if (m_useMaxVisibleDescender && (m_characterCount >= m_maxVisibleCharacters || m_lineNumber >= m_maxVisibleLines))
- isMaxVisibleDescenderSet = true;
-
- m_textInfo.lineInfo[m_lineNumber].firstCharacterIndex = m_firstCharacterOfLine;
- m_textInfo.lineInfo[m_lineNumber].firstVisibleCharacterIndex = m_firstVisibleCharacterOfLine = m_firstCharacterOfLine > m_firstVisibleCharacterOfLine ? m_firstCharacterOfLine : m_firstVisibleCharacterOfLine;
- int lastCharacterIndex = m_textInfo.lineInfo[m_lineNumber].lastCharacterIndex = m_lastCharacterOfLine = m_characterCount - 1 > 0 ? m_characterCount - 1 : 0;
- m_textInfo.lineInfo[m_lineNumber].lastVisibleCharacterIndex = m_lastVisibleCharacterOfLine = m_lastVisibleCharacterOfLine < m_firstVisibleCharacterOfLine ? m_firstVisibleCharacterOfLine : m_lastVisibleCharacterOfLine;
- m_textInfo.lineInfo[m_lineNumber].characterCount = m_textInfo.lineInfo[m_lineNumber].lastCharacterIndex - m_textInfo.lineInfo[m_lineNumber].firstCharacterIndex + 1;
- m_textInfo.lineInfo[m_lineNumber].visibleCharacterCount = m_lineVisibleCharacterCount;
- m_textInfo.lineInfo[m_lineNumber].lineExtents.min = new Vector2(m_textInfo.characterInfo[m_firstVisibleCharacterOfLine].bottomLeft.x, lineDescender);
- m_textInfo.lineInfo[m_lineNumber].lineExtents.max = new Vector2(m_textInfo.characterInfo[m_lastVisibleCharacterOfLine].topRight.x, lineAscender);
- m_textInfo.lineInfo[m_lineNumber].length = m_textInfo.lineInfo[m_lineNumber].lineExtents.max.x;
- m_textInfo.lineInfo[m_lineNumber].width = width;
- float maxAdvanceOffset = ((glyphAdjustment + boldSpacingAdjustment) * currentElementScale + (m_currentFontAsset.normalSpacingOffset + characterSpacingAdjustment) * currentEmScale - m_cSpacing) * (1 - m_charWidthAdjDelta);
- float adjustedHorizontalAdvance = m_textInfo.lineInfo[m_lineNumber].maxAdvance = m_textInfo.characterInfo[m_lastVisibleCharacterOfLine].xAdvance + (m_isRightToLeft ? maxAdvanceOffset : - maxAdvanceOffset);
- m_textInfo.characterInfo[lastCharacterIndex].xAdvance = adjustedHorizontalAdvance;
- m_textInfo.lineInfo[m_lineNumber].baseline = 0 - m_lineOffset;
- m_textInfo.lineInfo[m_lineNumber].ascender = lineAscender;
- m_textInfo.lineInfo[m_lineNumber].descender = lineDescender;
- m_textInfo.lineInfo[m_lineNumber].lineHeight = lineAscender - lineDescender + lineGap * baseScale;
- m_firstCharacterOfLine = m_characterCount;
- m_lineVisibleCharacterCount = 0;
-
- SaveWordWrappingState(ref m_SavedLineState, i, m_characterCount - 1);
- m_lineNumber += 1;
-
- if (m_lineNumber >= m_textInfo.lineInfo.Length)
- ResizeLineExtents(m_lineNumber);
-
- if (m_lineHeight == TMP_Math.FLOAT_UNSET)
- {
- float ascender = m_textInfo.characterInfo[m_characterCount].adjustedAscender;
- float lineOffsetDelta = 0 - m_maxLineDescender + ascender + (lineGap + m_lineSpacingDelta) * baseScale + m_lineSpacing * currentEmScale;
- m_lineOffset += lineOffsetDelta;
- m_startOfLineAscender = ascender;
- }
- else
- {
- m_lineOffset += m_lineHeight + m_lineSpacing * currentEmScale;
- }
- m_maxLineAscender = k_LargeNegativeFloat;
- m_maxLineDescender = k_LargePositiveFloat;
- m_xAdvance = 0 + tag_Indent;
- }
-
-
-
-
-
-
- protected void SaveWordWrappingState(ref WordWrapState state, int index, int count)
- {
-
- state.currentFontAsset = m_currentFontAsset;
- state.currentSpriteAsset = m_currentSpriteAsset;
- state.currentMaterial = m_currentMaterial;
- state.currentMaterialIndex = m_currentMaterialIndex;
- state.previous_WordBreak = index;
- state.total_CharacterCount = count;
- state.visible_CharacterCount = m_lineVisibleCharacterCount;
-
-
- state.visible_LinkCount = m_textInfo.linkCount;
- state.firstCharacterIndex = m_firstCharacterOfLine;
- state.firstVisibleCharacterIndex = m_firstVisibleCharacterOfLine;
- state.lastVisibleCharIndex = m_lastVisibleCharacterOfLine;
- state.fontStyle = m_FontStyleInternal;
- state.italicAngle = m_ItalicAngle;
- state.fontScale = m_fontScale;
-
- state.fontScaleMultiplier = m_fontScaleMultiplier;
- state.currentFontSize = m_currentFontSize;
- state.xAdvance = m_xAdvance;
- state.maxCapHeight = m_maxCapHeight;
- state.maxAscender = m_maxTextAscender;
- state.maxDescender = m_ElementDescender;
- state.startOfLineAscender = m_startOfLineAscender;
- state.maxLineAscender = m_maxLineAscender;
- state.maxLineDescender = m_maxLineDescender;
- state.pageAscender = m_PageAscender;
- state.preferredWidth = m_preferredWidth;
- state.preferredHeight = m_preferredHeight;
- state.meshExtents = m_meshExtents;
- state.lineNumber = m_lineNumber;
- state.lineOffset = m_lineOffset;
- state.baselineOffset = m_baselineOffset;
- state.isDrivenLineSpacing = m_IsDrivenLineSpacing;
- state.glyphHorizontalAdvanceAdjustment = m_GlyphHorizontalAdvanceAdjustment;
- state.cSpace = m_cSpacing;
- state.mSpace = m_monoSpacing;
- state.horizontalAlignment = m_lineJustification;
- state.marginLeft = m_marginLeft;
- state.marginRight = m_marginRight;
- state.vertexColor = m_htmlColor;
- state.underlineColor = m_underlineColor;
- state.strikethroughColor = m_strikethroughColor;
- state.isNonBreakingSpace = m_isNonBreakingSpace;
- state.tagNoParsing = tag_NoParsing;
-
- state.basicStyleStack = m_fontStyleStack;
- state.italicAngleStack = m_ItalicAngleStack;
- state.colorStack = m_colorStack;
- state.underlineColorStack = m_underlineColorStack;
- state.strikethroughColorStack = m_strikethroughColorStack;
- state.highlightStateStack = m_HighlightStateStack;
- state.colorGradientStack = m_colorGradientStack;
- state.sizeStack = m_sizeStack;
- state.indentStack = m_indentStack;
- state.fontWeightStack = m_FontWeightStack;
-
- state.baselineStack = m_baselineOffsetStack;
- state.actionStack = m_actionStack;
- state.materialReferenceStack = m_materialReferenceStack;
- state.lineJustificationStack = m_lineJustificationStack;
-
- state.spriteAnimationID = m_spriteAnimationID;
- if (m_lineNumber < m_textInfo.lineInfo.Length)
- state.lineInfo = m_textInfo.lineInfo[m_lineNumber];
- }
-
-
-
-
-
- protected int RestoreWordWrappingState(ref WordWrapState state)
- {
- int index = state.previous_WordBreak;
-
- m_currentFontAsset = state.currentFontAsset;
- m_currentSpriteAsset = state.currentSpriteAsset;
- m_currentMaterial = state.currentMaterial;
- m_currentMaterialIndex = state.currentMaterialIndex;
- m_characterCount = state.total_CharacterCount + 1;
- m_lineVisibleCharacterCount = state.visible_CharacterCount;
-
-
- m_textInfo.linkCount = state.visible_LinkCount;
- m_firstCharacterOfLine = state.firstCharacterIndex;
- m_firstVisibleCharacterOfLine = state.firstVisibleCharacterIndex;
- m_lastVisibleCharacterOfLine = state.lastVisibleCharIndex;
- m_FontStyleInternal = state.fontStyle;
- m_ItalicAngle = state.italicAngle;
- m_fontScale = state.fontScale;
- m_fontScaleMultiplier = state.fontScaleMultiplier;
-
- m_currentFontSize = state.currentFontSize;
- m_xAdvance = state.xAdvance;
- m_maxCapHeight = state.maxCapHeight;
- m_maxTextAscender = state.maxAscender;
- m_ElementDescender = state.maxDescender;
- m_startOfLineAscender = state.startOfLineAscender;
- m_maxLineAscender = state.maxLineAscender;
- m_maxLineDescender = state.maxLineDescender;
- m_PageAscender = state.pageAscender;
- m_preferredWidth = state.preferredWidth;
- m_preferredHeight = state.preferredHeight;
- m_meshExtents = state.meshExtents;
- m_lineNumber = state.lineNumber;
- m_lineOffset = state.lineOffset;
- m_baselineOffset = state.baselineOffset;
- m_IsDrivenLineSpacing = state.isDrivenLineSpacing;
- m_GlyphHorizontalAdvanceAdjustment = state.glyphHorizontalAdvanceAdjustment;
- m_cSpacing = state.cSpace;
- m_monoSpacing = state.mSpace;
- m_lineJustification = state.horizontalAlignment;
- m_marginLeft = state.marginLeft;
- m_marginRight = state.marginRight;
- m_htmlColor = state.vertexColor;
- m_underlineColor = state.underlineColor;
- m_strikethroughColor = state.strikethroughColor;
- m_isNonBreakingSpace = state.isNonBreakingSpace;
- tag_NoParsing = state.tagNoParsing;
-
- m_fontStyleStack = state.basicStyleStack;
- m_ItalicAngleStack = state.italicAngleStack;
- m_colorStack = state.colorStack;
- m_underlineColorStack = state.underlineColorStack;
- m_strikethroughColorStack = state.strikethroughColorStack;
- m_HighlightStateStack = state.highlightStateStack;
- m_colorGradientStack = state.colorGradientStack;
- m_sizeStack = state.sizeStack;
- m_indentStack = state.indentStack;
- m_FontWeightStack = state.fontWeightStack;
-
- m_baselineOffsetStack = state.baselineStack;
- m_actionStack = state.actionStack;
- m_materialReferenceStack = state.materialReferenceStack;
- m_lineJustificationStack = state.lineJustificationStack;
-
- m_spriteAnimationID = state.spriteAnimationID;
- if (m_lineNumber < m_textInfo.lineInfo.Length)
- m_textInfo.lineInfo[m_lineNumber] = state.lineInfo;
- return index;
- }
-
-
-
-
-
- protected virtual void SaveGlyphVertexInfo(float padding, float style_padding, Color32 vertexColor)
- {
-
- #region Setup Mesh Vertices
- m_textInfo.characterInfo[m_characterCount].vertex_BL.position = m_textInfo.characterInfo[m_characterCount].bottomLeft;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.position = m_textInfo.characterInfo[m_characterCount].topLeft;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.position = m_textInfo.characterInfo[m_characterCount].topRight;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.position = m_textInfo.characterInfo[m_characterCount].bottomRight;
- #endregion
- #region Setup Vertex Colors
-
- vertexColor.a = m_fontColor32.a < vertexColor.a ? m_fontColor32.a : vertexColor.a;
-
- if (!m_enableVertexGradient)
- {
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color = vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color = vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color = vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color = vertexColor;
- }
- else
- {
- if (!m_overrideHtmlColors && m_colorStack.index > 1)
- {
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color = vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color = vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color = vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color = vertexColor;
- }
- else
- {
-
- if (m_fontColorGradientPreset != null)
- {
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color = m_fontColorGradientPreset.bottomLeft * vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color = m_fontColorGradientPreset.topLeft * vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color = m_fontColorGradientPreset.topRight * vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color = m_fontColorGradientPreset.bottomRight * vertexColor;
- }
- else
- {
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color = m_fontColorGradient.bottomLeft * vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color = m_fontColorGradient.topLeft * vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color = m_fontColorGradient.topRight * vertexColor;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color = m_fontColorGradient.bottomRight * vertexColor;
- }
- }
- }
- if (m_colorGradientPreset != null)
- {
- if (m_colorGradientPresetIsTinted)
- {
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color *= m_colorGradientPreset.bottomLeft;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color *= m_colorGradientPreset.topLeft;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color *= m_colorGradientPreset.topRight;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color *= m_colorGradientPreset.bottomRight;
- }
- else
- {
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color = m_colorGradientPreset.bottomLeft.MinAlpha(vertexColor);
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color = m_colorGradientPreset.topLeft.MinAlpha(vertexColor);
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color = m_colorGradientPreset.topRight.MinAlpha(vertexColor);
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color = m_colorGradientPreset.bottomRight.MinAlpha(vertexColor);
- }
- }
- #endregion
-
- if (!m_isSDFShader)
- style_padding = 0f;
-
- #region Setup UVs
- GlyphRect glyphRect = m_cached_TextElement.m_Glyph.glyphRect;
- Vector2 uv0;
- uv0.x = (glyphRect.x - padding - style_padding) / m_currentFontAsset.m_AtlasWidth;
- uv0.y = (glyphRect.y - padding - style_padding) / m_currentFontAsset.m_AtlasHeight;
- Vector2 uv1;
- uv1.x = uv0.x;
- uv1.y = (glyphRect.y + padding + style_padding + glyphRect.height) / m_currentFontAsset.m_AtlasHeight;
- Vector2 uv2;
- uv2.x = (glyphRect.x + padding + style_padding + glyphRect.width) / m_currentFontAsset.m_AtlasWidth;
- uv2.y = uv1.y;
- Vector2 uv3;
- uv3.x = uv2.x;
- uv3.y = uv0.y;
-
- m_textInfo.characterInfo[m_characterCount].vertex_BL.uv = uv0;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.uv = uv1;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.uv = uv2;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.uv = uv3;
- #endregion Setup UVs
-
- #region Setup Normals & Tangents
-
-
-
-
-
-
-
-
-
-
-
- #endregion end Normals & Tangents
- }
-
-
-
-
-
-
- protected virtual void SaveSpriteVertexInfo(Color32 vertexColor)
- {
-
- #region Setup Mesh Vertices
- m_textInfo.characterInfo[m_characterCount].vertex_BL.position = m_textInfo.characterInfo[m_characterCount].bottomLeft;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.position = m_textInfo.characterInfo[m_characterCount].topLeft;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.position = m_textInfo.characterInfo[m_characterCount].topRight;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.position = m_textInfo.characterInfo[m_characterCount].bottomRight;
- #endregion
-
- if (m_tintAllSprites) m_tintSprite = true;
- Color32 spriteColor = m_tintSprite ? m_spriteColor.Multiply(vertexColor) : m_spriteColor;
- spriteColor.a = spriteColor.a < m_fontColor32.a ? spriteColor.a = spriteColor.a < vertexColor.a ? spriteColor.a : vertexColor.a : m_fontColor32.a;
- Color32 c0 = spriteColor;
- Color32 c1 = spriteColor;
- Color32 c2 = spriteColor;
- Color32 c3 = spriteColor;
- if (m_enableVertexGradient)
- {
- if (m_fontColorGradientPreset != null)
- {
- c0 = m_tintSprite ? c0.Multiply(m_fontColorGradientPreset.bottomLeft) : c0;
- c1 = m_tintSprite ? c1.Multiply(m_fontColorGradientPreset.topLeft) : c1;
- c2 = m_tintSprite ? c2.Multiply(m_fontColorGradientPreset.topRight) : c2;
- c3 = m_tintSprite ? c3.Multiply(m_fontColorGradientPreset.bottomRight) : c3;
- }
- else
- {
- c0 = m_tintSprite ? c0.Multiply(m_fontColorGradient.bottomLeft) : c0;
- c1 = m_tintSprite ? c1.Multiply(m_fontColorGradient.topLeft) : c1;
- c2 = m_tintSprite ? c2.Multiply(m_fontColorGradient.topRight) : c2;
- c3 = m_tintSprite ? c3.Multiply(m_fontColorGradient.bottomRight) : c3;
- }
- }
- if (m_colorGradientPreset != null)
- {
- c0 = m_tintSprite ? c0.Multiply(m_colorGradientPreset.bottomLeft) : c0;
- c1 = m_tintSprite ? c1.Multiply(m_colorGradientPreset.topLeft) : c1;
- c2 = m_tintSprite ? c2.Multiply(m_colorGradientPreset.topRight) : c2;
- c3 = m_tintSprite ? c3.Multiply(m_colorGradientPreset.bottomRight) : c3;
- }
- m_textInfo.characterInfo[m_characterCount].vertex_BL.color = c0;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.color = c1;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.color = c2;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.color = c3;
-
- #region Setup UVs
- GlyphRect glyphRect = m_cached_TextElement.m_Glyph.glyphRect;
- Vector2 uv0 = new Vector2((float)glyphRect.x / m_currentSpriteAsset.spriteSheet.width, (float)glyphRect.y / m_currentSpriteAsset.spriteSheet.height);
- Vector2 uv1 = new Vector2(uv0.x, (float)(glyphRect.y + glyphRect.height) / m_currentSpriteAsset.spriteSheet.height);
- Vector2 uv2 = new Vector2((float)(glyphRect.x + glyphRect.width) / m_currentSpriteAsset.spriteSheet.width, uv1.y);
- Vector2 uv3 = new Vector2(uv2.x, uv0.y);
-
- m_textInfo.characterInfo[m_characterCount].vertex_BL.uv = uv0;
- m_textInfo.characterInfo[m_characterCount].vertex_TL.uv = uv1;
- m_textInfo.characterInfo[m_characterCount].vertex_TR.uv = uv2;
- m_textInfo.characterInfo[m_characterCount].vertex_BR.uv = uv3;
- #endregion Setup UVs
-
- #region Setup Normals & Tangents
-
-
-
-
-
-
-
-
-
-
-
- #endregion end Normals & Tangents
- }
-
-
-
-
-
- protected virtual void FillCharacterVertexBuffers(int i, int index_X4)
- {
- int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
- index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
-
- if (index_X4 >= m_textInfo.meshInfo[materialIndex].vertices.Length)
- m_textInfo.meshInfo[materialIndex].ResizeMeshInfo(Mathf.NextPowerOfTwo((index_X4 + 4) / 4));
- TMP_CharacterInfo[] characterInfoArray = m_textInfo.characterInfo;
- m_textInfo.characterInfo[i].vertexIndex = index_X4;
-
- m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray[i].vertex_BL.position;
- m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray[i].vertex_TL.position;
- m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray[i].vertex_TR.position;
- m_textInfo.meshInfo[materialIndex].vertices[3 + index_X4] = characterInfoArray[i].vertex_BR.position;
-
- m_textInfo.meshInfo[materialIndex].uvs0[0 + index_X4] = characterInfoArray[i].vertex_BL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[1 + index_X4] = characterInfoArray[i].vertex_TL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[2 + index_X4] = characterInfoArray[i].vertex_TR.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[3 + index_X4] = characterInfoArray[i].vertex_BR.uv;
-
- m_textInfo.meshInfo[materialIndex].uvs2[0 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[1 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[2 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[3 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
-
-
-
-
-
-
- m_textInfo.meshInfo[materialIndex].colors32[0 + index_X4] = characterInfoArray[i].vertex_BL.color;
- m_textInfo.meshInfo[materialIndex].colors32[1 + index_X4] = characterInfoArray[i].vertex_TL.color;
- m_textInfo.meshInfo[materialIndex].colors32[2 + index_X4] = characterInfoArray[i].vertex_TR.color;
- m_textInfo.meshInfo[materialIndex].colors32[3 + index_X4] = characterInfoArray[i].vertex_BR.color;
- m_textInfo.meshInfo[materialIndex].vertexCount = index_X4 + 4;
- }
- protected virtual void FillCharacterVertexBuffers(int i, int index_X4, bool isVolumetric)
- {
- int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
- index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
-
- if (index_X4 >= m_textInfo.meshInfo[materialIndex].vertices.Length)
- m_textInfo.meshInfo[materialIndex].ResizeMeshInfo(Mathf.NextPowerOfTwo((index_X4 + (isVolumetric ? 8 : 4)) / 4));
- TMP_CharacterInfo[] characterInfoArray = m_textInfo.characterInfo;
- m_textInfo.characterInfo[i].vertexIndex = index_X4;
-
- m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray[i].vertex_BL.position;
- m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray[i].vertex_TL.position;
- m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray[i].vertex_TR.position;
- m_textInfo.meshInfo[materialIndex].vertices[3 + index_X4] = characterInfoArray[i].vertex_BR.position;
- if (isVolumetric)
- {
- Vector3 depth = new Vector3(0, 0, m_fontSize * m_fontScale);
- m_textInfo.meshInfo[materialIndex].vertices[4 + index_X4] = characterInfoArray[i].vertex_BL.position + depth;
- m_textInfo.meshInfo[materialIndex].vertices[5 + index_X4] = characterInfoArray[i].vertex_TL.position + depth;
- m_textInfo.meshInfo[materialIndex].vertices[6 + index_X4] = characterInfoArray[i].vertex_TR.position + depth;
- m_textInfo.meshInfo[materialIndex].vertices[7 + index_X4] = characterInfoArray[i].vertex_BR.position + depth;
- }
-
- m_textInfo.meshInfo[materialIndex].uvs0[0 + index_X4] = characterInfoArray[i].vertex_BL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[1 + index_X4] = characterInfoArray[i].vertex_TL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[2 + index_X4] = characterInfoArray[i].vertex_TR.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[3 + index_X4] = characterInfoArray[i].vertex_BR.uv;
- if (isVolumetric)
- {
- m_textInfo.meshInfo[materialIndex].uvs0[4 + index_X4] = characterInfoArray[i].vertex_BL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[5 + index_X4] = characterInfoArray[i].vertex_TL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[6 + index_X4] = characterInfoArray[i].vertex_TR.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[7 + index_X4] = characterInfoArray[i].vertex_BR.uv;
- }
-
- m_textInfo.meshInfo[materialIndex].uvs2[0 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[1 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[2 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[3 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
- if (isVolumetric)
- {
- m_textInfo.meshInfo[materialIndex].uvs2[4 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[5 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[6 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[7 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
- }
-
-
-
-
-
-
- m_textInfo.meshInfo[materialIndex].colors32[0 + index_X4] = characterInfoArray[i].vertex_BL.color;
- m_textInfo.meshInfo[materialIndex].colors32[1 + index_X4] = characterInfoArray[i].vertex_TL.color;
- m_textInfo.meshInfo[materialIndex].colors32[2 + index_X4] = characterInfoArray[i].vertex_TR.color;
- m_textInfo.meshInfo[materialIndex].colors32[3 + index_X4] = characterInfoArray[i].vertex_BR.color;
- if (isVolumetric)
- {
- Color32 backColor = new Color32(255, 255, 128, 255);
- m_textInfo.meshInfo[materialIndex].colors32[4 + index_X4] = backColor;
- m_textInfo.meshInfo[materialIndex].colors32[5 + index_X4] = backColor;
- m_textInfo.meshInfo[materialIndex].colors32[6 + index_X4] = backColor;
- m_textInfo.meshInfo[materialIndex].colors32[7 + index_X4] = backColor;
- }
- m_textInfo.meshInfo[materialIndex].vertexCount = index_X4 + (!isVolumetric ? 4 : 8);
- }
-
-
-
-
-
- protected virtual void FillSpriteVertexBuffers(int i, int index_X4)
- {
- int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
- index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
-
- if (index_X4 >= m_textInfo.meshInfo[materialIndex].vertices.Length)
- m_textInfo.meshInfo[materialIndex].ResizeMeshInfo(Mathf.NextPowerOfTwo((index_X4 + 4) / 4));
- TMP_CharacterInfo[] characterInfoArray = m_textInfo.characterInfo;
- m_textInfo.characterInfo[i].vertexIndex = index_X4;
-
- m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray[i].vertex_BL.position;
- m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray[i].vertex_TL.position;
- m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray[i].vertex_TR.position;
- m_textInfo.meshInfo[materialIndex].vertices[3 + index_X4] = characterInfoArray[i].vertex_BR.position;
-
- m_textInfo.meshInfo[materialIndex].uvs0[0 + index_X4] = characterInfoArray[i].vertex_BL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[1 + index_X4] = characterInfoArray[i].vertex_TL.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[2 + index_X4] = characterInfoArray[i].vertex_TR.uv;
- m_textInfo.meshInfo[materialIndex].uvs0[3 + index_X4] = characterInfoArray[i].vertex_BR.uv;
-
- m_textInfo.meshInfo[materialIndex].uvs2[0 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[1 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[2 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
- m_textInfo.meshInfo[materialIndex].uvs2[3 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
-
-
-
-
-
-
- m_textInfo.meshInfo[materialIndex].colors32[0 + index_X4] = characterInfoArray[i].vertex_BL.color;
- m_textInfo.meshInfo[materialIndex].colors32[1 + index_X4] = characterInfoArray[i].vertex_TL.color;
- m_textInfo.meshInfo[materialIndex].colors32[2 + index_X4] = characterInfoArray[i].vertex_TR.color;
- m_textInfo.meshInfo[materialIndex].colors32[3 + index_X4] = characterInfoArray[i].vertex_BR.color;
- m_textInfo.meshInfo[materialIndex].vertexCount = index_X4 + 4;
- }
-
-
-
-
-
-
-
-
-
- protected virtual void DrawUnderlineMesh(Vector3 start, Vector3 end, ref int index, float startScale, float endScale, float maxScale, float sdfScale, Color32 underlineColor)
- {
-
- GetUnderlineSpecialCharacter(m_fontAsset);
- if (m_Underline.character == null)
- {
- if (!TMP_Settings.warningsDisabled)
- Debug.LogWarning("Unable to add underline since the primary Font Asset doesn't contain the underline character.", this);
- return;
- }
- int underlineMaterialIndex = m_Underline.materialIndex;
- int verticesCount = index + 12;
-
- if (verticesCount > m_textInfo.meshInfo[underlineMaterialIndex].vertices.Length)
- {
-
- m_textInfo.meshInfo[underlineMaterialIndex].ResizeMeshInfo(verticesCount / 4);
- }
-
- start.y = Mathf.Min(start.y, end.y);
- end.y = Mathf.Min(start.y, end.y);
- GlyphMetrics underlineGlyphMetrics = m_Underline.character.glyph.metrics;
- GlyphRect underlineGlyphRect = m_Underline.character.glyph.glyphRect;
- float segmentWidth = underlineGlyphMetrics.width / 2 * maxScale;
- if (end.x - start.x < underlineGlyphMetrics.width * maxScale)
- {
- segmentWidth = (end.x - start.x) / 2f;
- }
- float startPadding = m_padding * startScale / maxScale;
- float endPadding = m_padding * endScale / maxScale;
- float underlineThickness = m_Underline.fontAsset.faceInfo.underlineThickness;
-
- #region UNDERLINE VERTICES
- Vector3[] vertices = m_textInfo.meshInfo[underlineMaterialIndex].vertices;
-
- vertices[index + 0] = start + new Vector3(0, 0 - (underlineThickness + m_padding) * maxScale, 0);
- vertices[index + 1] = start + new Vector3(0, m_padding * maxScale, 0);
- vertices[index + 2] = vertices[index + 1] + new Vector3(segmentWidth, 0, 0);
- vertices[index + 3] = vertices[index + 0] + new Vector3(segmentWidth, 0, 0);
-
- vertices[index + 4] = vertices[index + 3];
- vertices[index + 5] = vertices[index + 2];
- vertices[index + 6] = end + new Vector3(-segmentWidth, m_padding * maxScale, 0);
- vertices[index + 7] = end + new Vector3(-segmentWidth, -(underlineThickness + m_padding) * maxScale, 0);
-
- vertices[index + 8] = vertices[index + 7];
- vertices[index + 9] = vertices[index + 6];
- vertices[index + 10] = end + new Vector3(0, m_padding * maxScale, 0);
- vertices[index + 11] = end + new Vector3(0, -(underlineThickness + m_padding) * maxScale, 0);
- #endregion
-
- #region HANDLE UV0
- Vector2[] uvs0 = m_textInfo.meshInfo[underlineMaterialIndex].uvs0;
- int atlasWidth = m_Underline.fontAsset.atlasWidth;
- int atlasHeight = m_Underline.fontAsset.atlasHeight;
-
- Vector2 uv0 = new Vector2((underlineGlyphRect.x - startPadding) / atlasWidth, (underlineGlyphRect.y - m_padding) / atlasHeight);
- Vector2 uv1 = new Vector2(uv0.x, (underlineGlyphRect.y + underlineGlyphRect.height + m_padding) / atlasHeight);
- Vector2 uv2 = new Vector2((underlineGlyphRect.x - startPadding + (float)underlineGlyphRect.width / 2) / atlasWidth, uv1.y);
- Vector2 uv3 = new Vector2(uv2.x, uv0.y);
- Vector2 uv4 = new Vector2((underlineGlyphRect.x + endPadding + (float)underlineGlyphRect.width / 2) / atlasWidth, uv1.y);
- Vector2 uv5 = new Vector2(uv4.x, uv0.y);
- Vector2 uv6 = new Vector2((underlineGlyphRect.x + endPadding + underlineGlyphRect.width) / atlasWidth, uv1.y);
- Vector2 uv7 = new Vector2(uv6.x, uv0.y);
-
- uvs0[0 + index] = uv0;
- uvs0[1 + index] = uv1;
- uvs0[2 + index] = uv2;
- uvs0[3 + index] = uv3;
-
- uvs0[4 + index] = new Vector2(uv2.x - uv2.x * 0.001f, uv0.y);
- uvs0[5 + index] = new Vector2(uv2.x - uv2.x * 0.001f, uv1.y);
- uvs0[6 + index] = new Vector2(uv2.x + uv2.x * 0.001f, uv1.y);
- uvs0[7 + index] = new Vector2(uv2.x + uv2.x * 0.001f, uv0.y);
-
- uvs0[8 + index] = uv5;
- uvs0[9 + index] = uv4;
- uvs0[10 + index] = uv6;
- uvs0[11 + index] = uv7;
- #endregion
-
- #region HANDLE UV2 - SDF SCALE
-
- float min_UvX = 0;
- float max_UvX = (vertices[index + 2].x - start.x) / (end.x - start.x);
-
- float xScale = Mathf.Abs(sdfScale);
- Vector2[] uvs2 = m_textInfo.meshInfo[underlineMaterialIndex].uvs2;
- uvs2[0 + index] = PackUV(0, 0, xScale);
- uvs2[1 + index] = PackUV(0, 1, xScale);
- uvs2[2 + index] = PackUV(max_UvX, 1, xScale);
- uvs2[3 + index] = PackUV(max_UvX, 0, xScale);
- min_UvX = (vertices[index + 4].x - start.x) / (end.x - start.x);
- max_UvX = (vertices[index + 6].x - start.x) / (end.x - start.x);
- uvs2[4 + index] = PackUV(min_UvX, 0, xScale);
- uvs2[5 + index] = PackUV(min_UvX, 1, xScale);
- uvs2[6 + index] = PackUV(max_UvX, 1, xScale);
- uvs2[7 + index] = PackUV(max_UvX, 0, xScale);
- min_UvX = (vertices[index + 8].x - start.x) / (end.x - start.x);
- uvs2[8 + index] = PackUV(min_UvX, 0, xScale);
- uvs2[9 + index] = PackUV(min_UvX, 1, xScale);
- uvs2[10 + index] = PackUV(1, 1, xScale);
- uvs2[11 + index] = PackUV(1, 0, xScale);
- #endregion
-
- #region UNDERLINE VERTEX COLORS
-
- underlineColor.a = m_fontColor32.a < underlineColor.a ? m_fontColor32.a : underlineColor.a;
- Color32[] colors32 = m_textInfo.meshInfo[underlineMaterialIndex].colors32;
- colors32[0 + index] = underlineColor;
- colors32[1 + index] = underlineColor;
- colors32[2 + index] = underlineColor;
- colors32[3 + index] = underlineColor;
- colors32[4 + index] = underlineColor;
- colors32[5 + index] = underlineColor;
- colors32[6 + index] = underlineColor;
- colors32[7 + index] = underlineColor;
- colors32[8 + index] = underlineColor;
- colors32[9 + index] = underlineColor;
- colors32[10 + index] = underlineColor;
- colors32[11 + index] = underlineColor;
- #endregion
- index += 12;
- }
- protected virtual void DrawTextHighlight(Vector3 start, Vector3 end, ref int index, Color32 highlightColor)
- {
- if (m_Underline.character == null)
- {
- GetUnderlineSpecialCharacter(m_fontAsset);
- if (m_Underline.character == null)
- {
- if (!TMP_Settings.warningsDisabled)
- Debug.LogWarning("Unable to add highlight since the primary Font Asset doesn't contain the underline character.", this);
- return;
- }
- }
- int underlineMaterialIndex = m_Underline.materialIndex;
- int verticesCount = index + 4;
-
- if (verticesCount > m_textInfo.meshInfo[underlineMaterialIndex].vertices.Length)
- {
-
- m_textInfo.meshInfo[underlineMaterialIndex].ResizeMeshInfo(verticesCount / 4);
- }
-
- #region HIGHLIGHT VERTICES
- Vector3[] vertices = m_textInfo.meshInfo[underlineMaterialIndex].vertices;
-
- vertices[index + 0] = start;
- vertices[index + 1] = new Vector3(start.x, end.y, 0);
- vertices[index + 2] = end;
- vertices[index + 3] = new Vector3(end.x, start.y, 0);
- #endregion
-
- #region HANDLE UV0
- Vector2[] uvs0 = m_textInfo.meshInfo[underlineMaterialIndex].uvs0;
- int atlasWidth = m_Underline.fontAsset.atlasWidth;
- int atlasHeight = m_Underline.fontAsset.atlasHeight;
- GlyphRect glyphRect = m_Underline.character.glyph.glyphRect;
-
- Vector2 uv0 = new Vector2(((float)glyphRect.x + glyphRect.width / 2) / atlasWidth, (glyphRect.y + (float)glyphRect.height / 2) / atlasHeight);
-
- uvs0[0 + index] = uv0;
- uvs0[1 + index] = uv0;
- uvs0[2 + index] = uv0;
- uvs0[3 + index] = uv0;
- #endregion
-
- #region HANDLE UV2 - SDF SCALE
- Vector2[] uvs2 = m_textInfo.meshInfo[underlineMaterialIndex].uvs2;
- Vector2 customUV = new Vector2(0, 1);
- uvs2[0 + index] = customUV;
- uvs2[1 + index] = customUV;
- uvs2[2 + index] = customUV;
- uvs2[3 + index] = customUV;
- #endregion
-
- #region
-
- highlightColor.a = m_fontColor32.a < highlightColor.a ? m_fontColor32.a : highlightColor.a;
- Color32[] colors32 = m_textInfo.meshInfo[underlineMaterialIndex].colors32;
- colors32[0 + index] = highlightColor;
- colors32[1 + index] = highlightColor;
- colors32[2 + index] = highlightColor;
- colors32[3 + index] = highlightColor;
- #endregion
- index += 4;
- }
-
-
-
- protected void LoadDefaultSettings()
- {
- if (m_fontAsset == null || m_isWaitingOnResourceLoad)
- {
- m_rectTransform = this.rectTransform;
- if (TMP_Settings.autoSizeTextContainer)
- {
- autoSizeTextContainer = true;
- }
- else
- {
- if (GetType() == typeof(TextMeshPro))
- {
- if (m_rectTransform.sizeDelta == new Vector2(100, 100))
- m_rectTransform.sizeDelta = TMP_Settings.defaultTextMeshProTextContainerSize;
- }
- else
- {
- if (m_rectTransform.sizeDelta == new Vector2(100, 100))
- m_rectTransform.sizeDelta = TMP_Settings.defaultTextMeshProUITextContainerSize;
- }
- }
- m_enableWordWrapping = TMP_Settings.enableWordWrapping;
- m_enableKerning = TMP_Settings.enableKerning;
- m_enableExtraPadding = TMP_Settings.enableExtraPadding;
- m_tintAllSprites = TMP_Settings.enableTintAllSprites;
- m_parseCtrlCharacters = TMP_Settings.enableParseEscapeCharacters;
- m_fontSize = m_fontSizeBase = TMP_Settings.defaultFontSize;
- m_fontSizeMin = m_fontSize * TMP_Settings.defaultTextAutoSizingMinRatio;
- m_fontSizeMax = m_fontSize * TMP_Settings.defaultTextAutoSizingMaxRatio;
- m_isWaitingOnResourceLoad = false;
- raycastTarget = TMP_Settings.enableRaycastTarget;
- m_IsTextObjectScaleStatic = TMP_Settings.isTextObjectScaleStatic;
- }
- else if ((int)m_textAlignment < 0xFF)
- {
-
- m_textAlignment = TMP_Compatibility.ConvertTextAlignmentEnumValues(m_textAlignment);
- }
-
- if (m_textAlignment != TextAlignmentOptions.Converted)
- {
- m_HorizontalAlignment = (HorizontalAlignmentOptions)((int)m_textAlignment & 0xFF);
- m_VerticalAlignment = (VerticalAlignmentOptions)((int)m_textAlignment & 0xFF00);
- m_textAlignment = TextAlignmentOptions.Converted;
- }
- }
-
-
-
-
- protected void GetSpecialCharacters(TMP_FontAsset fontAsset)
- {
- GetEllipsisSpecialCharacter(fontAsset);
- GetUnderlineSpecialCharacter(fontAsset);
- }
- protected void GetEllipsisSpecialCharacter(TMP_FontAsset fontAsset)
- {
- bool isUsingAlternativeTypeface;
-
- TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x2026, fontAsset, false, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface);
- if (character == null)
- {
-
- if (fontAsset.m_FallbackFontAssetTable != null && fontAsset.m_FallbackFontAssetTable.Count > 0)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(0x2026, fontAsset, fontAsset.m_FallbackFontAssetTable, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface);
- }
-
- if (character == null)
- {
- if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(0x2026, fontAsset, TMP_Settings.fallbackFontAssets, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface);
- }
-
- if (character == null)
- {
- if (TMP_Settings.defaultFontAsset != null)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x2026, TMP_Settings.defaultFontAsset, true, m_FontStyleInternal, m_FontWeightInternal, out isUsingAlternativeTypeface);
- }
- if (character != null)
- m_Ellipsis = new SpecialCharacter(character, 0);
- }
- protected void GetUnderlineSpecialCharacter(TMP_FontAsset fontAsset)
- {
- bool isUsingAlternativeTypeface;
-
- TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(0x5F, fontAsset, false, FontStyles.Normal, FontWeight.Regular, out isUsingAlternativeTypeface);
-
- if (character != null)
- {
- m_Underline = new SpecialCharacter(character, 0);
- }
- else
- {
- if (!TMP_Settings.warningsDisabled)
- Debug.LogWarning("The character used for Underline is not available in font asset [" + fontAsset.name + "].", this);
- }
- }
-
-
-
-
-
-
-
- protected void ReplaceTagWithCharacter(int[] chars, int insertionIndex, int tagLength, char c)
- {
- chars[insertionIndex] = c;
- for (int i = insertionIndex + tagLength; i < chars.Length; i++)
- {
- chars[i - 3] = chars[i];
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- protected TMP_FontAsset GetFontAssetForWeight(int fontWeight)
- {
- bool isItalic = (m_FontStyleInternal & FontStyles.Italic) == FontStyles.Italic || (m_fontStyle & FontStyles.Italic) == FontStyles.Italic;
- TMP_FontAsset fontAsset = null;
- int weightIndex = fontWeight / 100;
- if (isItalic)
- fontAsset = m_currentFontAsset.fontWeightTable[weightIndex].italicTypeface;
- else
- fontAsset = m_currentFontAsset.fontWeightTable[weightIndex].regularTypeface;
- return fontAsset;
- }
- internal TMP_TextElement GetTextElement(uint unicode, TMP_FontAsset fontAsset, FontStyles fontStyle, FontWeight fontWeight, out bool isUsingAlternativeTypeface)
- {
- TMP_Character character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, fontAsset, false, fontStyle, fontWeight, out isUsingAlternativeTypeface);
- if (character != null)
- return character;
-
- if (fontAsset.m_FallbackFontAssetTable != null && fontAsset.m_FallbackFontAssetTable.Count > 0)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, fontAsset.m_FallbackFontAssetTable, true, fontStyle, fontWeight, out isUsingAlternativeTypeface);
- if (character != null)
- {
-
-
- return character;
- }
-
- if (fontAsset.instanceID != m_fontAsset.instanceID)
- {
-
- character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, m_fontAsset, false, fontStyle, fontWeight, out isUsingAlternativeTypeface);
-
- if (character != null)
- {
- m_currentMaterialIndex = 0;
- m_currentMaterial = m_materialReferences[0].material;
-
-
- return character;
- }
-
- if (m_fontAsset.m_FallbackFontAssetTable != null && m_fontAsset.m_FallbackFontAssetTable.Count > 0)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, m_fontAsset.m_FallbackFontAssetTable, true, fontStyle, fontWeight, out isUsingAlternativeTypeface);
- if (character != null)
- {
-
-
- return character;
- }
- }
-
- if (m_spriteAsset != null)
- {
- TMP_SpriteCharacter spriteCharacter = TMP_FontAssetUtilities.GetSpriteCharacterFromSpriteAsset(unicode, m_spriteAsset, true);
- if (spriteCharacter != null)
- return spriteCharacter;
- }
-
- if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAssets(unicode, fontAsset, TMP_Settings.fallbackFontAssets, true, fontStyle, fontWeight, out isUsingAlternativeTypeface);
- if (character != null)
- {
-
-
- return character;
- }
-
- if (TMP_Settings.defaultFontAsset != null)
- character = TMP_FontAssetUtilities.GetCharacterFromFontAsset(unicode, TMP_Settings.defaultFontAsset, true, fontStyle, fontWeight, out isUsingAlternativeTypeface);
- if (character != null)
- {
-
-
- return character;
- }
-
- if (TMP_Settings.defaultSpriteAsset != null)
- {
- TMP_SpriteCharacter spriteCharacter = TMP_FontAssetUtilities.GetSpriteCharacterFromSpriteAsset(unicode, TMP_Settings.defaultSpriteAsset, true);
- if (spriteCharacter != null)
- return spriteCharacter;
- }
- return null;
- }
-
-
-
-
- protected virtual void SetActiveSubMeshes(bool state) { }
-
-
-
- protected virtual void DestroySubMeshObjects() { }
-
-
-
- public virtual void ClearMesh() { }
-
-
-
- public virtual void ClearMesh(bool uploadGeometry) { }
-
-
-
-
- public virtual string GetParsedText()
- {
- if (m_textInfo == null)
- return string.Empty;
- int characterCount = m_textInfo.characterCount;
-
- char[] buffer = new char[characterCount];
- for (int i = 0; i < characterCount && i < m_textInfo.characterInfo.Length; i++)
- {
- buffer[i] = m_textInfo.characterInfo[i].character;
- }
- return new string(buffer);
- }
- internal bool IsSelfOrLinkedAncestor(TMP_Text targetTextComponent)
- {
- if (targetTextComponent == null)
- return true;
- if (parentLinkedComponent != null)
- {
- if (parentLinkedComponent.IsSelfOrLinkedAncestor(targetTextComponent))
- return true;
- }
- if (this.GetInstanceID() == targetTextComponent.GetInstanceID())
- return true;
- return false;
- }
- internal void ReleaseLinkedTextComponent(TMP_Text targetTextComponent)
- {
- if (targetTextComponent == null)
- return;
- TMP_Text childLinkedComponent = targetTextComponent.linkedTextComponent;
- if (childLinkedComponent != null)
- ReleaseLinkedTextComponent(childLinkedComponent);
- targetTextComponent.text = string.Empty;
- targetTextComponent.firstVisibleCharacter = 0;
- targetTextComponent.linkedTextComponent = null;
- targetTextComponent.parentLinkedComponent = null;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- protected Vector2 PackUV(float x, float y, float scale)
- {
- Vector2 output;
- output.x = (int)(x * 511);
- output.y = (int)(y * 511);
- output.x = (output.x * 4096) + output.y;
- output.y = scale;
- return output;
- }
-
-
-
-
-
-
- protected float PackUV(float x, float y)
- {
- double x0 = (int)(x * 511);
- double y0 = (int)(y * 511);
- return (float)((x0 * 4096) + y0);
- }
-
-
-
- internal virtual void InternalUpdate() { }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- protected int HexToInt(char hex)
- {
- switch (hex)
- {
- case '0': return 0;
- case '1': return 1;
- case '2': return 2;
- case '3': return 3;
- case '4': return 4;
- case '5': return 5;
- case '6': return 6;
- case '7': return 7;
- case '8': return 8;
- case '9': return 9;
- case 'A': return 10;
- case 'B': return 11;
- case 'C': return 12;
- case 'D': return 13;
- case 'E': return 14;
- case 'F': return 15;
- case 'a': return 10;
- case 'b': return 11;
- case 'c': return 12;
- case 'd': return 13;
- case 'e': return 14;
- case 'f': return 15;
- }
- return 15;
- }
-
-
-
-
-
- protected int GetUTF16(string text, int i)
- {
- int unicode = 0;
- unicode += HexToInt(text[i]) << 12;
- unicode += HexToInt(text[i + 1]) << 8;
- unicode += HexToInt(text[i + 2]) << 4;
- unicode += HexToInt(text[i + 3]);
- return unicode;
- }
- protected int GetUTF16(int[] text, int i)
- {
- int unicode = 0;
- unicode += HexToInt((char)text[i]) << 12;
- unicode += HexToInt((char)text[i + 1]) << 8;
- unicode += HexToInt((char)text[i + 2]) << 4;
- unicode += HexToInt((char)text[i + 3]);
- return unicode;
- }
-
-
-
-
-
- protected int GetUTF16(StringBuilder text, int i)
- {
- int unicode = 0;
- unicode += HexToInt(text[i]) << 12;
- unicode += HexToInt(text[i + 1]) << 8;
- unicode += HexToInt(text[i + 2]) << 4;
- unicode += HexToInt(text[i + 3]);
- return unicode;
- }
-
-
-
-
-
- protected int GetUTF32(string text, int i)
- {
- int unicode = 0;
- unicode += HexToInt(text[i]) << 28;
- unicode += HexToInt(text[i + 1]) << 24;
- unicode += HexToInt(text[i + 2]) << 20;
- unicode += HexToInt(text[i + 3]) << 16;
- unicode += HexToInt(text[i + 4]) << 12;
- unicode += HexToInt(text[i + 5]) << 8;
- unicode += HexToInt(text[i + 6]) << 4;
- unicode += HexToInt(text[i + 7]);
- return unicode;
- }
- protected int GetUTF32(int[] text, int i)
- {
- int unicode = 0;
- unicode += HexToInt((char)text[i]) << 28;
- unicode += HexToInt((char)text[i + 1]) << 24;
- unicode += HexToInt((char)text[i + 2]) << 20;
- unicode += HexToInt((char)text[i + 3]) << 16;
- unicode += HexToInt((char)text[i + 4]) << 12;
- unicode += HexToInt((char)text[i + 5]) << 8;
- unicode += HexToInt((char)text[i + 6]) << 4;
- unicode += HexToInt((char)text[i + 7]);
- return unicode;
- }
-
-
-
-
-
- protected int GetUTF32(StringBuilder text, int i)
- {
- int unicode = 0;
- unicode += HexToInt(text[i]) << 28;
- unicode += HexToInt(text[i + 1]) << 24;
- unicode += HexToInt(text[i + 2]) << 20;
- unicode += HexToInt(text[i + 3]) << 16;
- unicode += HexToInt(text[i + 4]) << 12;
- unicode += HexToInt(text[i + 5]) << 8;
- unicode += HexToInt(text[i + 6]) << 4;
- unicode += HexToInt(text[i + 7]);
- return unicode;
- }
-
-
-
-
-
-
- protected Color32 HexCharsToColor(char[] hexChars, int tagCount)
- {
- if (tagCount == 4)
- {
- byte r = (byte)(HexToInt(hexChars[1]) * 16 + HexToInt(hexChars[1]));
- byte g = (byte)(HexToInt(hexChars[2]) * 16 + HexToInt(hexChars[2]));
- byte b = (byte)(HexToInt(hexChars[3]) * 16 + HexToInt(hexChars[3]));
- return new Color32(r, g, b, 255);
- }
- else if (tagCount == 5)
- {
- byte r = (byte)(HexToInt(hexChars[1]) * 16 + HexToInt(hexChars[1]));
- byte g = (byte)(HexToInt(hexChars[2]) * 16 + HexToInt(hexChars[2]));
- byte b = (byte)(HexToInt(hexChars[3]) * 16 + HexToInt(hexChars[3]));
- byte a = (byte)(HexToInt(hexChars[4]) * 16 + HexToInt(hexChars[4]));
- return new Color32(r, g, b, a);
- }
- else if (tagCount == 7)
- {
- byte r = (byte)(HexToInt(hexChars[1]) * 16 + HexToInt(hexChars[2]));
- byte g = (byte)(HexToInt(hexChars[3]) * 16 + HexToInt(hexChars[4]));
- byte b = (byte)(HexToInt(hexChars[5]) * 16 + HexToInt(hexChars[6]));
- return new Color32(r, g, b, 255);
- }
- else if (tagCount == 9)
- {
- byte r = (byte)(HexToInt(hexChars[1]) * 16 + HexToInt(hexChars[2]));
- byte g = (byte)(HexToInt(hexChars[3]) * 16 + HexToInt(hexChars[4]));
- byte b = (byte)(HexToInt(hexChars[5]) * 16 + HexToInt(hexChars[6]));
- byte a = (byte)(HexToInt(hexChars[7]) * 16 + HexToInt(hexChars[8]));
- return new Color32(r, g, b, a);
- }
- else if (tagCount == 10)
- {
- byte r = (byte)(HexToInt(hexChars[7]) * 16 + HexToInt(hexChars[7]));
- byte g = (byte)(HexToInt(hexChars[8]) * 16 + HexToInt(hexChars[8]));
- byte b = (byte)(HexToInt(hexChars[9]) * 16 + HexToInt(hexChars[9]));
- return new Color32(r, g, b, 255);
- }
- else if (tagCount == 11)
- {
- byte r = (byte)(HexToInt(hexChars[7]) * 16 + HexToInt(hexChars[7]));
- byte g = (byte)(HexToInt(hexChars[8]) * 16 + HexToInt(hexChars[8]));
- byte b = (byte)(HexToInt(hexChars[9]) * 16 + HexToInt(hexChars[9]));
- byte a = (byte)(HexToInt(hexChars[10]) * 16 + HexToInt(hexChars[10]));
- return new Color32(r, g, b, a);
- }
- else if (tagCount == 13)
- {
- byte r = (byte)(HexToInt(hexChars[7]) * 16 + HexToInt(hexChars[8]));
- byte g = (byte)(HexToInt(hexChars[9]) * 16 + HexToInt(hexChars[10]));
- byte b = (byte)(HexToInt(hexChars[11]) * 16 + HexToInt(hexChars[12]));
- return new Color32(r, g, b, 255);
- }
- else if (tagCount == 15)
- {
- byte r = (byte)(HexToInt(hexChars[7]) * 16 + HexToInt(hexChars[8]));
- byte g = (byte)(HexToInt(hexChars[9]) * 16 + HexToInt(hexChars[10]));
- byte b = (byte)(HexToInt(hexChars[11]) * 16 + HexToInt(hexChars[12]));
- byte a = (byte)(HexToInt(hexChars[13]) * 16 + HexToInt(hexChars[14]));
- return new Color32(r, g, b, a);
- }
- return new Color32(255, 255, 255, 255);
- }
-
-
-
-
-
-
-
- protected Color32 HexCharsToColor(char[] hexChars, int startIndex, int length)
- {
- if (length == 7)
- {
- byte r = (byte)(HexToInt(hexChars[startIndex + 1]) * 16 + HexToInt(hexChars[startIndex + 2]));
- byte g = (byte)(HexToInt(hexChars[startIndex + 3]) * 16 + HexToInt(hexChars[startIndex + 4]));
- byte b = (byte)(HexToInt(hexChars[startIndex + 5]) * 16 + HexToInt(hexChars[startIndex + 6]));
- return new Color32(r, g, b, 255);
- }
- else if (length == 9)
- {
- byte r = (byte)(HexToInt(hexChars[startIndex + 1]) * 16 + HexToInt(hexChars[startIndex + 2]));
- byte g = (byte)(HexToInt(hexChars[startIndex + 3]) * 16 + HexToInt(hexChars[startIndex + 4]));
- byte b = (byte)(HexToInt(hexChars[startIndex + 5]) * 16 + HexToInt(hexChars[startIndex + 6]));
- byte a = (byte)(HexToInt(hexChars[startIndex + 7]) * 16 + HexToInt(hexChars[startIndex + 8]));
- return new Color32(r, g, b, a);
- }
- return s_colorWhite;
- }
-
-
-
-
-
-
-
-
- int GetAttributeParameters(char[] chars, int startIndex, int length, ref float[] parameters)
- {
- int endIndex = startIndex;
- int attributeCount = 0;
- while (endIndex < startIndex + length)
- {
- parameters[attributeCount] = ConvertToFloat(chars, startIndex, length, out endIndex);
- length -= (endIndex - startIndex) + 1;
- startIndex = endIndex + 1;
- attributeCount += 1;
- }
- return attributeCount;
- }
-
-
-
-
-
-
-
- protected float ConvertToFloat(char[] chars, int startIndex, int length)
- {
- int lastIndex;
- return ConvertToFloat(chars, startIndex, length, out lastIndex);
- }
-
-
-
-
-
-
-
-
- protected float ConvertToFloat(char[] chars, int startIndex, int length, out int lastIndex)
- {
- if (startIndex == 0)
- {
- lastIndex = 0;
- return Int16.MinValue;
- }
- int endIndex = startIndex + length;
- bool isIntegerValue = true;
- float decimalPointMultiplier = 0;
-
- int valueSignMultiplier = 1;
- if (chars[startIndex] == '+')
- {
- valueSignMultiplier = 1;
- startIndex += 1;
- }
- else if (chars[startIndex] == '-')
- {
- valueSignMultiplier = -1;
- startIndex += 1;
- }
- float value = 0;
- for (int i = startIndex; i < endIndex; i++)
- {
- uint c = chars[i];
- if (c >= '0' && c <= '9' || c == '.')
- {
- if (c == '.')
- {
- isIntegerValue = false;
- decimalPointMultiplier = 0.1f;
- continue;
- }
-
- if (isIntegerValue)
- value = value * 10 + (c - 48) * valueSignMultiplier;
- else
- {
- value = value + (c - 48) * decimalPointMultiplier * valueSignMultiplier;
- decimalPointMultiplier *= 0.1f;
- }
- continue;
- }
- else if (c == ',')
- {
- if (i + 1 < endIndex && chars[i + 1] == ' ')
- lastIndex = i + 1;
- else
- lastIndex = i;
-
- if (value > 32767)
- return Int16.MinValue;
- return value;
- }
- }
- lastIndex = endIndex;
-
- if (value > 32767)
- return Int16.MinValue;
- return value;
- }
-
-
-
-
-
-
-
- protected bool ValidateHtmlTag(UnicodeChar[] chars, int startIndex, out int endIndex)
- {
- int tagCharCount = 0;
- byte attributeFlag = 0;
- int attributeIndex = 0;
- m_xmlAttribute[attributeIndex].nameHashCode = 0;
- m_xmlAttribute[attributeIndex].valueHashCode = 0;
- m_xmlAttribute[attributeIndex].valueStartIndex = 0;
- m_xmlAttribute[attributeIndex].valueLength = 0;
- TagValueType tagValueType = m_xmlAttribute[attributeIndex].valueType = TagValueType.None;
- TagUnitType tagUnitType = m_xmlAttribute[attributeIndex].unitType = TagUnitType.Pixels;
-
- m_xmlAttribute[1].nameHashCode = 0;
- m_xmlAttribute[2].nameHashCode = 0;
- m_xmlAttribute[3].nameHashCode = 0;
- m_xmlAttribute[4].nameHashCode = 0;
- endIndex = startIndex;
- bool isTagSet = false;
- bool isValidHtmlTag = false;
- for (int i = startIndex; i < chars.Length && chars[i].unicode != 0 && tagCharCount < m_htmlTag.Length && chars[i].unicode != '<'; i++)
- {
- int unicode = chars[i].unicode;
- if (unicode == '>')
- {
- isValidHtmlTag = true;
- endIndex = i;
- m_htmlTag[tagCharCount] = (char)0;
- break;
- }
- m_htmlTag[tagCharCount] = (char)unicode;
- tagCharCount += 1;
- if (attributeFlag == 1)
- {
- if (tagValueType == TagValueType.None)
- {
-
- if (unicode == '+' || unicode == '-' || unicode == '.' || (unicode >= '0' && unicode <= '9'))
- {
- tagUnitType = TagUnitType.Pixels;
- tagValueType = m_xmlAttribute[attributeIndex].valueType = TagValueType.NumericalValue;
- m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1;
- m_xmlAttribute[attributeIndex].valueLength += 1;
- }
- else if (unicode == '#')
- {
- tagUnitType = TagUnitType.Pixels;
- tagValueType = m_xmlAttribute[attributeIndex].valueType = TagValueType.ColorValue;
- m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1;
- m_xmlAttribute[attributeIndex].valueLength += 1;
- }
- else if (unicode == '"')
- {
- tagUnitType = TagUnitType.Pixels;
- tagValueType = m_xmlAttribute[attributeIndex].valueType = TagValueType.StringValue;
- m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount;
- }
- else
- {
- tagUnitType = TagUnitType.Pixels;
- tagValueType = m_xmlAttribute[attributeIndex].valueType = TagValueType.StringValue;
- m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1;
- m_xmlAttribute[attributeIndex].valueHashCode = (m_xmlAttribute[attributeIndex].valueHashCode << 5) + m_xmlAttribute[attributeIndex].valueHashCode ^ unicode;
- m_xmlAttribute[attributeIndex].valueLength += 1;
- }
- }
- else
- {
- if (tagValueType == TagValueType.NumericalValue)
- {
-
- if (unicode == 'p' || unicode == 'e' || unicode == '%' || unicode == ' ')
- {
- attributeFlag = 2;
- tagValueType = TagValueType.None;
- switch (unicode)
- {
- case 'e':
- m_xmlAttribute[attributeIndex].unitType = tagUnitType = TagUnitType.FontUnits;
- break;
- case '%':
- m_xmlAttribute[attributeIndex].unitType = tagUnitType = TagUnitType.Percentage;
- break;
- default:
- m_xmlAttribute[attributeIndex].unitType = tagUnitType = TagUnitType.Pixels;
- break;
- }
- attributeIndex += 1;
- m_xmlAttribute[attributeIndex].nameHashCode = 0;
- m_xmlAttribute[attributeIndex].valueHashCode = 0;
- m_xmlAttribute[attributeIndex].valueType = TagValueType.None;
- m_xmlAttribute[attributeIndex].unitType = TagUnitType.Pixels;
- m_xmlAttribute[attributeIndex].valueStartIndex = 0;
- m_xmlAttribute[attributeIndex].valueLength = 0;
- }
- else if (attributeFlag != 2)
- {
- m_xmlAttribute[attributeIndex].valueLength += 1;
- }
- }
- else if (tagValueType == TagValueType.ColorValue)
- {
- if (unicode != ' ')
- {
- m_xmlAttribute[attributeIndex].valueLength += 1;
- }
- else
- {
- attributeFlag = 2;
- tagValueType = TagValueType.None;
- tagUnitType = TagUnitType.Pixels;
- attributeIndex += 1;
- m_xmlAttribute[attributeIndex].nameHashCode = 0;
- m_xmlAttribute[attributeIndex].valueType = TagValueType.None;
- m_xmlAttribute[attributeIndex].unitType = TagUnitType.Pixels;
- m_xmlAttribute[attributeIndex].valueHashCode = 0;
- m_xmlAttribute[attributeIndex].valueStartIndex = 0;
- m_xmlAttribute[attributeIndex].valueLength = 0;
- }
- }
- else if (tagValueType == TagValueType.StringValue)
- {
-
- if (unicode != '"')
- {
- m_xmlAttribute[attributeIndex].valueHashCode = (m_xmlAttribute[attributeIndex].valueHashCode << 5) + m_xmlAttribute[attributeIndex].valueHashCode ^ unicode;
- m_xmlAttribute[attributeIndex].valueLength += 1;
- }
- else
- {
- attributeFlag = 2;
- tagValueType = TagValueType.None;
- tagUnitType = TagUnitType.Pixels;
- attributeIndex += 1;
- m_xmlAttribute[attributeIndex].nameHashCode = 0;
- m_xmlAttribute[attributeIndex].valueType = TagValueType.None;
- m_xmlAttribute[attributeIndex].unitType = TagUnitType.Pixels;
- m_xmlAttribute[attributeIndex].valueHashCode = 0;
- m_xmlAttribute[attributeIndex].valueStartIndex = 0;
- m_xmlAttribute[attributeIndex].valueLength = 0;
- }
- }
- }
- }
- if (unicode == '=')
- attributeFlag = 1;
-
- if (attributeFlag == 0 && unicode == ' ')
- {
- if (isTagSet) return false;
- isTagSet = true;
- attributeFlag = 2;
- tagValueType = TagValueType.None;
- tagUnitType = TagUnitType.Pixels;
- attributeIndex += 1;
- m_xmlAttribute[attributeIndex].nameHashCode = 0;
- m_xmlAttribute[attributeIndex].valueType = TagValueType.None;
- m_xmlAttribute[attributeIndex].unitType = TagUnitType.Pixels;
- m_xmlAttribute[attributeIndex].valueHashCode = 0;
- m_xmlAttribute[attributeIndex].valueStartIndex = 0;
- m_xmlAttribute[attributeIndex].valueLength = 0;
- }
- if (attributeFlag == 0)
- m_xmlAttribute[attributeIndex].nameHashCode = (m_xmlAttribute[attributeIndex].nameHashCode << 3) - m_xmlAttribute[attributeIndex].nameHashCode + unicode;
- if (attributeFlag == 2 && unicode == ' ')
- attributeFlag = 0;
- }
- if (!isValidHtmlTag)
- {
- return false;
- }
-
-
-
- #region Rich Text Tag Processing
- #if !RICH_TEXT_ENABLED
-
- if (tag_NoParsing && (m_xmlAttribute[0].nameHashCode != 53822163 && m_xmlAttribute[0].nameHashCode != 49429939))
- return false;
- else if (m_xmlAttribute[0].nameHashCode == 53822163 || m_xmlAttribute[0].nameHashCode == 49429939)
- {
- tag_NoParsing = false;
- return true;
- }
-
- if (m_htmlTag[0] == 35 && tagCharCount == 4)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- else if (m_htmlTag[0] == 35 && tagCharCount == 5)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- else if (m_htmlTag[0] == 35 && tagCharCount == 7)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- else if (m_htmlTag[0] == 35 && tagCharCount == 9)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
- else
- {
- float value = 0;
- switch (m_xmlAttribute[0].nameHashCode)
- {
- case 98:
- case 66:
- m_FontStyleInternal |= FontStyles.Bold;
- m_fontStyleStack.Add(FontStyles.Bold);
- m_FontWeightInternal = FontWeight.Bold;
- return true;
- case 427:
- case 395:
- if ((m_fontStyle & FontStyles.Bold) != FontStyles.Bold)
- {
- if (m_fontStyleStack.Remove(FontStyles.Bold) == 0)
- {
- m_FontStyleInternal &= ~FontStyles.Bold;
- m_FontWeightInternal = m_FontWeightStack.Peek();
- }
- }
- return true;
- case 105:
- case 73:
- m_FontStyleInternal |= FontStyles.Italic;
- m_fontStyleStack.Add(FontStyles.Italic);
- if (m_xmlAttribute[1].nameHashCode == 276531 || m_xmlAttribute[1].nameHashCode == 186899)
- {
- m_ItalicAngle = (int)ConvertToFloat(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
-
- if (m_ItalicAngle < -180 || m_ItalicAngle > 180) return false;
- }
- else
- m_ItalicAngle = m_currentFontAsset.italicStyle;
- m_ItalicAngleStack.Add(m_ItalicAngle);
- return true;
- case 434:
- case 402:
- if ((m_fontStyle & FontStyles.Italic) != FontStyles.Italic)
- {
- m_ItalicAngle = m_ItalicAngleStack.Remove();
- if (m_fontStyleStack.Remove(FontStyles.Italic) == 0)
- m_FontStyleInternal &= ~FontStyles.Italic;
- }
- return true;
- case 115:
- case 83:
- m_FontStyleInternal |= FontStyles.Strikethrough;
- m_fontStyleStack.Add(FontStyles.Strikethrough);
- if (m_xmlAttribute[1].nameHashCode == 281955 || m_xmlAttribute[1].nameHashCode == 192323)
- {
- m_strikethroughColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
- m_strikethroughColor.a = m_htmlColor.a < m_strikethroughColor.a ? (byte)(m_htmlColor.a) : (byte)(m_strikethroughColor .a);
- }
- else
- m_strikethroughColor = m_htmlColor;
- m_strikethroughColorStack.Add(m_strikethroughColor);
- return true;
- case 444:
- case 412:
- if ((m_fontStyle & FontStyles.Strikethrough) != FontStyles.Strikethrough)
- {
- if (m_fontStyleStack.Remove(FontStyles.Strikethrough) == 0)
- m_FontStyleInternal &= ~FontStyles.Strikethrough;
- }
- m_strikethroughColor = m_strikethroughColorStack.Remove();
- return true;
- case 117:
- case 85:
- m_FontStyleInternal |= FontStyles.Underline;
- m_fontStyleStack.Add(FontStyles.Underline);
- if (m_xmlAttribute[1].nameHashCode == 281955 || m_xmlAttribute[1].nameHashCode == 192323)
- {
- m_underlineColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
- m_underlineColor.a = m_htmlColor.a < m_underlineColor.a ? (byte)(m_htmlColor.a) : (byte)(m_underlineColor.a);
- }
- else
- m_underlineColor = m_htmlColor;
- m_underlineColorStack.Add(m_underlineColor);
- return true;
- case 446:
- case 414:
- if ((m_fontStyle & FontStyles.Underline) != FontStyles.Underline)
- {
- m_underlineColor = m_underlineColorStack.Remove();
- if (m_fontStyleStack.Remove(FontStyles.Underline) == 0)
- m_FontStyleInternal &= ~FontStyles.Underline;
- }
- m_underlineColor = m_underlineColorStack.Remove();
- return true;
- case 43045:
- case 30245:
- m_FontStyleInternal |= FontStyles.Highlight;
- m_fontStyleStack.Add(FontStyles.Highlight);
- Color32 highlightColor = new Color32(255, 255, 0, 64);
- TMP_Offset highlightPadding = TMP_Offset.zero;
-
- for (int i = 0; i < m_xmlAttribute.Length && m_xmlAttribute[i].nameHashCode != 0; i++)
- {
- int nameHashCode = m_xmlAttribute[i].nameHashCode;
- switch (nameHashCode)
- {
-
- case 43045:
- case 30245:
- if (m_xmlAttribute[i].valueType == TagValueType.ColorValue)
- highlightColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
- break;
-
- case 281955:
- highlightColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength);
- break;
-
- case 15087385:
- int paramCount = GetAttributeParameters(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength, ref m_attributeParameterValues);
- if (paramCount != 4) return false;
- highlightPadding = new TMP_Offset(m_attributeParameterValues[0], m_attributeParameterValues[1], m_attributeParameterValues[2], m_attributeParameterValues[3]);
- highlightPadding *= m_fontSize * 0.01f * (m_isOrthographic ? 1 : 0.1f);
- break;
- }
- }
- highlightColor.a = m_htmlColor.a < highlightColor.a ? (byte)(m_htmlColor.a) : (byte)(highlightColor.a);
- HighlightState state = new HighlightState(highlightColor, highlightPadding);
- m_HighlightStateStack.Push(state);
- return true;
- case 155892:
- case 143092:
- if ((m_fontStyle & FontStyles.Highlight) != FontStyles.Highlight)
- {
- m_HighlightStateStack.Remove();
- if (m_fontStyleStack.Remove(FontStyles.Highlight) == 0)
- m_FontStyleInternal &= ~FontStyles.Highlight;
- }
- return true;
- case 6552:
- case 4728:
- m_fontScaleMultiplier *= m_currentFontAsset.faceInfo.subscriptSize > 0 ? m_currentFontAsset.faceInfo.subscriptSize : 1;
- m_baselineOffsetStack.Push(m_baselineOffset);
- m_baselineOffset += m_currentFontAsset.faceInfo.subscriptOffset * m_fontScale * m_fontScaleMultiplier;
- m_fontStyleStack.Add(FontStyles.Subscript);
- m_FontStyleInternal |= FontStyles.Subscript;
- return true;
- case 22673:
- case 20849:
- if ((m_FontStyleInternal & FontStyles.Subscript) == FontStyles.Subscript)
- {
- if (m_fontScaleMultiplier < 1)
- {
-
- m_baselineOffset = m_baselineOffsetStack.Pop();
- m_fontScaleMultiplier /= m_currentFontAsset.faceInfo.subscriptSize > 0 ? m_currentFontAsset.faceInfo.subscriptSize : 1;
- }
- if (m_fontStyleStack.Remove(FontStyles.Subscript) == 0)
- m_FontStyleInternal &= ~FontStyles.Subscript;
- }
- return true;
- case 6566:
- case 4742:
- m_fontScaleMultiplier *= m_currentFontAsset.faceInfo.superscriptSize > 0 ? m_currentFontAsset.faceInfo.superscriptSize : 1;
- m_baselineOffsetStack.Push(m_baselineOffset);
- m_baselineOffset += m_currentFontAsset.faceInfo.superscriptOffset * m_fontScale * m_fontScaleMultiplier;
- m_fontStyleStack.Add(FontStyles.Superscript);
- m_FontStyleInternal |= FontStyles.Superscript;
- return true;
- case 22687:
- case 20863:
- if ((m_FontStyleInternal & FontStyles.Superscript) == FontStyles.Superscript)
- {
- if (m_fontScaleMultiplier < 1)
- {
-
- m_baselineOffset = m_baselineOffsetStack.Pop();
- m_fontScaleMultiplier /= m_currentFontAsset.faceInfo.superscriptSize > 0 ? m_currentFontAsset.faceInfo.superscriptSize : 1;
- }
- if (m_fontStyleStack.Remove(FontStyles.Superscript) == 0)
- m_FontStyleInternal &= ~FontStyles.Superscript;
- }
- return true;
- case -330774850:
- case 2012149182:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch ((int)value)
- {
- case 100:
- m_FontWeightInternal = FontWeight.Thin;
- break;
- case 200:
- m_FontWeightInternal = FontWeight.ExtraLight;
- break;
- case 300:
- m_FontWeightInternal = FontWeight.Light;
- break;
- case 400:
- m_FontWeightInternal = FontWeight.Regular;
- break;
- case 500:
- m_FontWeightInternal = FontWeight.Medium;
- break;
- case 600:
- m_FontWeightInternal = FontWeight.SemiBold;
- break;
- case 700:
- m_FontWeightInternal = FontWeight.Bold;
- break;
- case 800:
- m_FontWeightInternal = FontWeight.Heavy;
- break;
- case 900:
- m_FontWeightInternal = FontWeight.Black;
- break;
- }
- m_FontWeightStack.Add(m_FontWeightInternal);
- return true;
- case -1885698441:
- case 457225591:
- m_FontWeightStack.Remove();
- if (m_FontStyleInternal == FontStyles.Bold)
- m_FontWeightInternal = FontWeight.Bold;
- else
- m_FontWeightInternal = m_FontWeightStack.Peek();
- return true;
- case 6380:
- case 4556:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_xAdvance = value * (m_isOrthographic ? 1.0f : 0.1f);
-
- return true;
- case TagUnitType.FontUnits:
- m_xAdvance = value * m_currentFontSize * (m_isOrthographic ? 1.0f : 0.1f);
-
- return true;
- case TagUnitType.Percentage:
- m_xAdvance = m_marginWidth * value / 100;
-
- return true;
- }
- return false;
- case 22501:
- case 20677:
- m_isIgnoringAlignment = false;
- return true;
- case 16034505:
- case 11642281:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_baselineOffset = value * (m_isOrthographic ? 1 : 0.1f);
- return true;
- case TagUnitType.FontUnits:
- m_baselineOffset = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- return true;
- case TagUnitType.Percentage:
-
- return false;
- }
- return false;
- case 54741026:
- case 50348802:
- m_baselineOffset = 0;
- return true;
- case 43991:
- case 31191:
-
- if (m_overflowMode == TextOverflowModes.Page)
- {
- m_xAdvance = 0 + tag_LineIndent + tag_Indent;
- m_lineOffset = 0;
- m_pageNumber += 1;
- m_isNewPage = true;
- }
- return true;
-
-
-
-
-
- case 43969:
- case 31169:
- m_isNonBreakingSpace = true;
- return true;
- case 156816:
- case 144016:
- m_isNonBreakingSpace = false;
- return true;
- case 45545:
- case 32745:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- if (m_htmlTag[5] == 43)
- {
- m_currentFontSize = m_fontSize + value;
- m_sizeStack.Add(m_currentFontSize);
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- }
- else if (m_htmlTag[5] == 45)
- {
- m_currentFontSize = m_fontSize + value;
- m_sizeStack.Add(m_currentFontSize);
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- }
- else
- {
- m_currentFontSize = value;
- m_sizeStack.Add(m_currentFontSize);
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- }
- case TagUnitType.FontUnits:
- m_currentFontSize = m_fontSize * value;
- m_sizeStack.Add(m_currentFontSize);
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- case TagUnitType.Percentage:
- m_currentFontSize = m_fontSize * value / 100;
- m_sizeStack.Add(m_currentFontSize);
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- }
- return false;
- case 158392:
- case 145592:
- m_currentFontSize = m_sizeStack.Remove();
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- case 41311:
- case 28511:
- int fontHashCode = m_xmlAttribute[0].valueHashCode;
- int materialAttributeHashCode = m_xmlAttribute[1].nameHashCode;
- int materialHashCode = m_xmlAttribute[1].valueHashCode;
-
- if (fontHashCode == 764638571 || fontHashCode == 523367755)
- {
- m_currentFontAsset = m_materialReferences[0].fontAsset;
- m_currentMaterial = m_materialReferences[0].material;
- m_currentMaterialIndex = 0;
-
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- m_materialReferenceStack.Add(m_materialReferences[0]);
- return true;
- }
- TMP_FontAsset tempFont;
- Material tempMaterial;
-
-
-
- MaterialReferenceManager.TryGetFontAsset(fontHashCode, out tempFont);
-
- if (tempFont == null)
- {
-
- tempFont = OnFontAssetRequest?.Invoke(fontHashCode, new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
- if (tempFont == null)
- {
-
- tempFont = Resources.Load<TMP_FontAsset>(TMP_Settings.defaultFontAssetPath + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
- }
- if (tempFont == null)
- return false;
-
- MaterialReferenceManager.AddFontAsset(tempFont);
- }
-
- if (materialAttributeHashCode == 0 && materialHashCode == 0)
- {
-
- m_currentMaterial = tempFont.material;
- m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, tempFont, m_materialReferences, m_materialReferenceIndexLookup);
- m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]);
- }
- else if (materialAttributeHashCode == 103415287 || materialAttributeHashCode == 72669687)
- {
- if (MaterialReferenceManager.TryGetMaterial(materialHashCode, out tempMaterial))
- {
- m_currentMaterial = tempMaterial;
- m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, tempFont, m_materialReferences, m_materialReferenceIndexLookup);
- m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]);
- }
- else
- {
-
- tempMaterial = Resources.Load<Material>(TMP_Settings.defaultFontAssetPath + new string(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength));
- if (tempMaterial == null)
- return false;
-
- MaterialReferenceManager.AddFontMaterial(materialHashCode, tempMaterial);
- m_currentMaterial = tempMaterial;
- m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, tempFont, m_materialReferences, m_materialReferenceIndexLookup);
- m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]);
- }
- }
- else
- return false;
- m_currentFontAsset = tempFont;
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- case 154158:
- case 141358:
- {
- MaterialReference materialReference = m_materialReferenceStack.Remove();
- m_currentFontAsset = materialReference.fontAsset;
- m_currentMaterial = materialReference.material;
- m_currentMaterialIndex = materialReference.index;
- m_fontScale = (m_currentFontSize / m_currentFontAsset.faceInfo.pointSize * m_currentFontAsset.faceInfo.scale * (m_isOrthographic ? 1 : 0.1f));
- return true;
- }
- case 103415287:
- case 72669687:
- materialHashCode = m_xmlAttribute[0].valueHashCode;
-
- if (materialHashCode == 764638571 || materialHashCode == 523367755)
- {
-
-
- m_currentMaterial = m_materialReferences[0].material;
- m_currentMaterialIndex = 0;
- m_materialReferenceStack.Add(m_materialReferences[0]);
- return true;
- }
-
- if (MaterialReferenceManager.TryGetMaterial(materialHashCode, out tempMaterial))
- {
-
-
- m_currentMaterial = tempMaterial;
- m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, m_currentFontAsset, m_materialReferences, m_materialReferenceIndexLookup);
- m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]);
- }
- else
- {
-
- tempMaterial = Resources.Load<Material>(TMP_Settings.defaultFontAssetPath + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
- if (tempMaterial == null)
- return false;
-
-
-
- MaterialReferenceManager.AddFontMaterial(materialHashCode, tempMaterial);
- m_currentMaterial = tempMaterial;
- m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, m_currentFontAsset , m_materialReferences, m_materialReferenceIndexLookup);
- m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]);
- }
- return true;
- case 374360934:
- case 343615334:
- {
-
-
- MaterialReference materialReference = m_materialReferenceStack.Remove();
- m_currentMaterial = materialReference.material;
- m_currentMaterialIndex = materialReference.index;
- return true;
- }
- case 320078:
- case 230446:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_xAdvance += value * (m_isOrthographic ? 1 : 0.1f);
- return true;
- case TagUnitType.FontUnits:
- m_xAdvance += value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- return true;
- case TagUnitType.Percentage:
-
- return false;
- }
- return false;
- case 276254:
- case 186622:
- if (m_xmlAttribute[0].valueLength != 3) return false;
- m_htmlColor.a = (byte)(HexToInt(m_htmlTag[7]) * 16 + HexToInt(m_htmlTag[8]));
- return true;
- case 1750458:
- return false;
- case 426:
- return true;
- case 43066:
- case 30266:
- if (m_isParsingText && !m_isCalculatingPreferredValues)
- {
- int index = m_textInfo.linkCount;
- if (index + 1 > m_textInfo.linkInfo.Length)
- TMP_TextInfo.Resize(ref m_textInfo.linkInfo, index + 1);
- m_textInfo.linkInfo[index].textComponent = this;
- m_textInfo.linkInfo[index].hashCode = m_xmlAttribute[0].valueHashCode;
- m_textInfo.linkInfo[index].linkTextfirstCharacterIndex = m_characterCount;
- m_textInfo.linkInfo[index].linkIdFirstCharacterIndex = startIndex + m_xmlAttribute[0].valueStartIndex;
- m_textInfo.linkInfo[index].linkIdLength = m_xmlAttribute[0].valueLength;
- m_textInfo.linkInfo[index].SetLinkID(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
- }
- return true;
- case 155913:
- case 143113:
- if (m_isParsingText && !m_isCalculatingPreferredValues)
- {
- if (m_textInfo.linkCount < m_textInfo.linkInfo.Length)
- {
- m_textInfo.linkInfo[m_textInfo.linkCount].linkTextLength = m_characterCount - m_textInfo.linkInfo[m_textInfo.linkCount].linkTextfirstCharacterIndex;
- m_textInfo.linkCount += 1;
- }
- }
- return true;
- case 275917:
- case 186285:
- switch (m_xmlAttribute[0].valueHashCode)
- {
- case 3774683:
- m_lineJustification = HorizontalAlignmentOptions.Left;
- m_lineJustificationStack.Add(m_lineJustification);
- return true;
- case 136703040:
- m_lineJustification = HorizontalAlignmentOptions.Right;
- m_lineJustificationStack.Add(m_lineJustification);
- return true;
- case -458210101:
- m_lineJustification = HorizontalAlignmentOptions.Center;
- m_lineJustificationStack.Add(m_lineJustification);
- return true;
- case -523808257:
- m_lineJustification = HorizontalAlignmentOptions.Justified;
- m_lineJustificationStack.Add(m_lineJustification);
- return true;
- case 122383428:
- m_lineJustification = HorizontalAlignmentOptions.Flush;
- m_lineJustificationStack.Add(m_lineJustification);
- return true;
- }
- return false;
- case 1065846:
- case 976214:
- m_lineJustification = m_lineJustificationStack.Remove();
- return true;
- case 327550:
- case 237918:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_width = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- return false;
-
- case TagUnitType.Percentage:
- m_width = m_marginWidth * value / 100;
- break;
- }
- return true;
- case 1117479:
- case 1027847:
- m_width = -1;
- return true;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- case 281955:
- case 192323:
-
- if (m_htmlTag[6] == 35 && tagCharCount == 10)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- else if (m_htmlTag[6] == 35 && tagCharCount == 11)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- if (m_htmlTag[6] == 35 && tagCharCount == 13)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- else if (m_htmlTag[6] == 35 && tagCharCount == 15)
- {
- m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount);
- m_colorStack.Add(m_htmlColor);
- return true;
- }
-
- switch (m_xmlAttribute[0].valueHashCode)
- {
- case 125395:
- m_htmlColor = Color.red;
- m_colorStack.Add(m_htmlColor);
- return true;
- case -992792864:
- m_htmlColor = new Color32(173, 216, 230, 255);
- m_colorStack.Add(m_htmlColor);
- return true;
- case 3573310:
- m_htmlColor = Color.blue;
- m_colorStack.Add(m_htmlColor);
- return true;
- case 3680713:
- m_htmlColor = new Color32(128, 128, 128, 255);
- m_colorStack.Add(m_htmlColor);
- return true;
- case 117905991:
- m_htmlColor = Color.black;
- m_colorStack.Add(m_htmlColor);
- return true;
- case 121463835:
- m_htmlColor = Color.green;
- m_colorStack.Add(m_htmlColor);
- return true;
- case 140357351:
- m_htmlColor = Color.white;
- m_colorStack.Add(m_htmlColor);
- return true;
- case 26556144:
- m_htmlColor = new Color32(255, 128, 0, 255);
- m_colorStack.Add(m_htmlColor);
- return true;
- case -36881330:
- m_htmlColor = new Color32(160, 32, 240, 255);
- m_colorStack.Add(m_htmlColor);
- return true;
- case 554054276:
- m_htmlColor = Color.yellow;
- m_colorStack.Add(m_htmlColor);
- return true;
- }
- return false;
- case 100149144:
- case 69403544:
- int gradientPresetHashCode = m_xmlAttribute[0].valueHashCode;
- TMP_ColorGradient tempColorGradientPreset;
-
- if (MaterialReferenceManager.TryGetColorGradientPreset(gradientPresetHashCode, out tempColorGradientPreset))
- {
- m_colorGradientPreset = tempColorGradientPreset;
- }
- else
- {
-
- if (tempColorGradientPreset == null)
- {
- tempColorGradientPreset = Resources.Load<TMP_ColorGradient>(TMP_Settings.defaultColorGradientPresetsPath + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
- }
- if (tempColorGradientPreset == null)
- return false;
- MaterialReferenceManager.AddColorGradientPreset(gradientPresetHashCode, tempColorGradientPreset);
- m_colorGradientPreset = tempColorGradientPreset;
- }
- m_colorGradientPresetIsTinted = false;
-
- for (int i = 1; i < m_xmlAttribute.Length && m_xmlAttribute[i].nameHashCode != 0; i++)
- {
-
- int nameHashCode = m_xmlAttribute[i].nameHashCode;
- switch (nameHashCode)
- {
- case 45819:
- case 33019:
- m_colorGradientPresetIsTinted = ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength) != 0;
- break;
- }
- }
- m_colorGradientStack.Add(m_colorGradientPreset);
-
- return true;
- case 371094791:
- case 340349191:
- m_colorGradientPreset = m_colorGradientStack.Remove();
- return true;
- case 1983971:
- case 1356515:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_cSpacing = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_cSpacing = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- return false;
- }
- return true;
- case 7513474:
- case 6886018:
- if (!m_isParsingText) return true;
-
- if (m_characterCount > 0)
- {
- m_xAdvance -= m_cSpacing;
- m_textInfo.characterInfo[m_characterCount - 1].xAdvance = m_xAdvance;
- }
- m_cSpacing = 0;
- return true;
- case 2152041:
- case 1524585:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_monoSpacing = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_monoSpacing = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- return false;
- }
- return true;
- case 7681544:
- case 7054088:
- m_monoSpacing = 0;
- return true;
- case 280416:
- return false;
- case 1071884:
- case 982252:
- m_htmlColor = m_colorStack.Remove();
- return true;
- case 2068980:
- case 1441524:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- tag_Indent = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- tag_Indent = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- tag_Indent = m_marginWidth * value / 100;
- break;
- }
- m_indentStack.Add(tag_Indent);
- m_xAdvance = tag_Indent;
- return true;
- case 7598483:
- case 6971027:
- tag_Indent = m_indentStack.Remove();
-
- return true;
- case 1109386397:
- case -842656867:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- tag_LineIndent = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- tag_LineIndent = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- tag_LineIndent = m_marginWidth * value / 100;
- break;
- }
- m_xAdvance += tag_LineIndent;
- return true;
- case -445537194:
- case 1897386838:
- tag_LineIndent = 0;
- return true;
- case 2246877:
- case 1619421:
- int spriteAssetHashCode = m_xmlAttribute[0].valueHashCode;
- TMP_SpriteAsset tempSpriteAsset;
- m_spriteIndex = -1;
-
- if (m_xmlAttribute[0].valueType == TagValueType.None || m_xmlAttribute[0].valueType == TagValueType.NumericalValue)
- {
-
- if (m_spriteAsset != null)
- {
- m_currentSpriteAsset = m_spriteAsset;
- }
- else if (m_defaultSpriteAsset != null)
- {
- m_currentSpriteAsset = m_defaultSpriteAsset;
- }
- else if (m_defaultSpriteAsset == null)
- {
- if (TMP_Settings.defaultSpriteAsset != null)
- m_defaultSpriteAsset = TMP_Settings.defaultSpriteAsset;
- else
- m_defaultSpriteAsset = Resources.Load<TMP_SpriteAsset>("Sprite Assets/Default Sprite Asset");
- m_currentSpriteAsset = m_defaultSpriteAsset;
- }
-
- if (m_currentSpriteAsset == null)
- return false;
- }
- else
- {
-
- if (MaterialReferenceManager.TryGetSpriteAsset(spriteAssetHashCode, out tempSpriteAsset))
- {
- m_currentSpriteAsset = tempSpriteAsset;
- }
- else
- {
-
- if (tempSpriteAsset == null)
- {
-
- tempSpriteAsset = OnSpriteAssetRequest?.Invoke(spriteAssetHashCode, new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
- if (tempSpriteAsset == null)
- tempSpriteAsset = Resources.Load<TMP_SpriteAsset>(TMP_Settings.defaultSpriteAssetPath + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
- }
- if (tempSpriteAsset == null)
- return false;
-
- MaterialReferenceManager.AddSpriteAsset(spriteAssetHashCode, tempSpriteAsset);
- m_currentSpriteAsset = tempSpriteAsset;
- }
- }
-
- if (m_xmlAttribute[0].valueType == TagValueType.NumericalValue)
- {
- int index = (int)ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (index == Int16.MinValue) return false;
-
- if (index > m_currentSpriteAsset.spriteCharacterTable.Count - 1) return false;
- m_spriteIndex = index;
- }
- m_spriteColor = s_colorWhite;
- m_tintSprite = false;
-
- for (int i = 0; i < m_xmlAttribute.Length && m_xmlAttribute[i].nameHashCode != 0; i++)
- {
-
- int nameHashCode = m_xmlAttribute[i].nameHashCode;
- int index = 0;
- switch (nameHashCode)
- {
- case 43347:
- case 30547:
- m_currentSpriteAsset = TMP_SpriteAsset.SearchForSpriteByHashCode(m_currentSpriteAsset, m_xmlAttribute[i].valueHashCode, true, out index);
- if (index == -1) return false;
- m_spriteIndex = index;
- break;
- case 295562:
- case 205930:
- index = (int)ConvertToFloat(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
-
- if (index == Int16.MinValue) return false;
-
- if (index > m_currentSpriteAsset.spriteCharacterTable.Count - 1) return false;
- m_spriteIndex = index;
- break;
- case 45819:
- case 33019:
- m_tintSprite = ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength) != 0;
- break;
- case 281955:
- case 192323:
- m_spriteColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength);
- break;
- case 39505:
- case 26705:
-
- int paramCount = GetAttributeParameters(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength, ref m_attributeParameterValues);
- if (paramCount != 3) return false;
- m_spriteIndex = (int)m_attributeParameterValues[0];
- if (m_isParsingText)
- {
-
-
-
- spriteAnimator.DoSpriteAnimation(m_characterCount, m_currentSpriteAsset, m_spriteIndex, (int)m_attributeParameterValues[1], (int)m_attributeParameterValues[2]);
- }
- break;
-
-
-
- default:
- if (nameHashCode != 2246877 && nameHashCode != 1619421)
- return false;
- break;
- }
- }
- if (m_spriteIndex == -1) return false;
-
- m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentSpriteAsset.material, m_currentSpriteAsset, m_materialReferences, m_materialReferenceIndexLookup);
- m_textElementType = TMP_TextElementType.Sprite;
- return true;
- case 730022849:
- case 514803617:
- m_FontStyleInternal |= FontStyles.LowerCase;
- m_fontStyleStack.Add(FontStyles.LowerCase);
- return true;
- case -1668324918:
- case -1883544150:
- if ((m_fontStyle & FontStyles.LowerCase) != FontStyles.LowerCase)
- {
- if (m_fontStyleStack.Remove(FontStyles.LowerCase) == 0)
- m_FontStyleInternal &= ~FontStyles.LowerCase;
- }
- return true;
- case 13526026:
- case 9133802:
- case 781906058:
- case 566686826:
- m_FontStyleInternal |= FontStyles.UpperCase;
- m_fontStyleStack.Add(FontStyles.UpperCase);
- return true;
- case 52232547:
- case 47840323:
- case -1616441709:
- case -1831660941:
- if ((m_fontStyle & FontStyles.UpperCase) != FontStyles.UpperCase)
- {
- if (m_fontStyleStack.Remove(FontStyles.UpperCase) == 0)
- m_FontStyleInternal &= ~FontStyles.UpperCase;
- }
- return true;
- case 766244328:
- case 551025096:
- m_FontStyleInternal |= FontStyles.SmallCaps;
- m_fontStyleStack.Add(FontStyles.SmallCaps);
- return true;
- case -1632103439:
- case -1847322671:
- if ((m_fontStyle & FontStyles.SmallCaps) != FontStyles.SmallCaps)
- {
- if (m_fontStyleStack.Remove(FontStyles.SmallCaps) == 0)
- m_FontStyleInternal &= ~FontStyles.SmallCaps;
- }
- return true;
- case 2109854:
- case 1482398:
-
- switch (m_xmlAttribute[0].valueType)
- {
- case TagValueType.NumericalValue:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
-
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_marginLeft = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_marginLeft = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * value / 100;
- break;
- }
- m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0;
- m_marginRight = m_marginLeft;
- return true;
- case TagValueType.None:
- for (int i = 1; i < m_xmlAttribute.Length && m_xmlAttribute[i].nameHashCode != 0; i++)
- {
-
- int nameHashCode = m_xmlAttribute[i].nameHashCode;
- switch (nameHashCode)
- {
- case 42823:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (m_xmlAttribute[i].unitType)
- {
- case TagUnitType.Pixels:
- m_marginLeft = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_marginLeft = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * value / 100;
- break;
- }
- m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0;
- break;
- case 315620:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (m_xmlAttribute[i].unitType)
- {
- case TagUnitType.Pixels:
- m_marginRight = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_marginRight = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- m_marginRight = (m_marginWidth - (m_width != -1 ? m_width : 0)) * value / 100;
- break;
- }
- m_marginRight = m_marginRight >= 0 ? m_marginRight : 0;
- break;
- }
- }
- return true;
- }
- return false;
- case 7639357:
- case 7011901:
- m_marginLeft = 0;
- m_marginRight = 0;
- return true;
- case 1100728678:
- case -855002522:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_marginLeft = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_marginLeft = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * value / 100;
- break;
- }
- m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0;
- return true;
- case -884817987:
- case -1690034531:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_marginRight = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_marginRight = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- m_marginRight = (m_marginWidth - (m_width != -1 ? m_width : 0)) * value / 100;
- break;
- }
- m_marginRight = m_marginRight >= 0 ? m_marginRight : 0;
- return true;
- case 1109349752:
- case -842693512:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- switch (tagUnitType)
- {
- case TagUnitType.Pixels:
- m_lineHeight = value * (m_isOrthographic ? 1 : 0.1f);
- break;
- case TagUnitType.FontUnits:
- m_lineHeight = value * (m_isOrthographic ? 1 : 0.1f) * m_currentFontSize;
- break;
- case TagUnitType.Percentage:
- m_lineHeight = m_fontAsset.faceInfo.lineHeight * value / 100 * m_fontScale;
- break;
- }
- return true;
- case -445573839:
- case 1897350193:
- m_lineHeight = TMP_Math.FLOAT_UNSET;
- return true;
- case 15115642:
- case 10723418:
- tag_NoParsing = true;
- return true;
- case 1913798:
- case 1286342:
- int actionID = m_xmlAttribute[0].valueHashCode;
- if (m_isParsingText)
- {
- m_actionStack.Add(actionID);
- Debug.Log("Action ID: [" + actionID + "] First character index: " + m_characterCount);
- }
-
-
-
-
- return true;
- case 7443301:
- case 6815845:
- if (m_isParsingText)
- {
- Debug.Log("Action ID: [" + m_actionStack.CurrentItem() + "] Last character index: " + (m_characterCount - 1));
- }
- m_actionStack.Remove();
- return true;
- case 315682:
- case 226050:
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- m_FXMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(value, 1, 1));
- m_isFXMatrixSet = true;
- return true;
- case 1105611:
- case 1015979:
- m_isFXMatrixSet = false;
- return true;
- case 2227963:
- case 1600507:
-
- value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
-
- if (value == Int16.MinValue) return false;
- m_FXMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, value), Vector3.one);
- m_isFXMatrixSet = true;
- return true;
- case 7757466:
- case 7130010:
- m_isFXMatrixSet = false;
- return true;
- case 317446:
- case 227814:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return false;
- case 1107375:
- case 1017743:
- return true;
- case 926:
- case 670:
- return true;
- case 3229:
- case 2973:
- return true;
- case 916:
- case 660:
-
- return true;
- case 3219:
- case 2963:
- return true;
- case 912:
- case 656:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return false;
- case 3215:
- case 2959:
- return false;
- }
- }
- #endif
- #endregion
- return false;
- }
- }
- }
|