NGUIText.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968
  1. using System;
  2. using System.Diagnostics;
  3. using System.Text;
  4. using UnityEngine;
  5. public static class NGUIText
  6. {
  7. public static void Update()
  8. {
  9. NGUIText.Update(true);
  10. }
  11. public static void Update(bool request)
  12. {
  13. NGUIText.finalSize = Mathf.RoundToInt((float)NGUIText.fontSize / NGUIText.pixelDensity);
  14. NGUIText.finalSpacingX = NGUIText.spacingX * NGUIText.fontScale;
  15. NGUIText.finalLineHeight = ((float)NGUIText.fontSize + NGUIText.spacingY) * NGUIText.fontScale;
  16. NGUIText.useSymbols = (NGUIText.bitmapFont != null && NGUIText.bitmapFont.hasSymbols && NGUIText.encoding && NGUIText.symbolStyle != NGUIText.SymbolStyle.None);
  17. if (NGUIText.dynamicFont != null && request)
  18. {
  19. NGUIText.dynamicFont.RequestCharactersInTexture(")_-", NGUIText.finalSize, NGUIText.fontStyle);
  20. if (!NGUIText.dynamicFont.GetCharacterInfo(')', out NGUIText.mTempChar, NGUIText.finalSize, NGUIText.fontStyle) || NGUIText.mTempChar.vert.height == 0f)
  21. {
  22. NGUIText.dynamicFont.RequestCharactersInTexture("A", NGUIText.finalSize, NGUIText.fontStyle);
  23. if (!NGUIText.dynamicFont.GetCharacterInfo('A', out NGUIText.mTempChar, NGUIText.finalSize, NGUIText.fontStyle))
  24. {
  25. NGUIText.baseline = 0f;
  26. return;
  27. }
  28. }
  29. float yMax = NGUIText.mTempChar.vert.yMax;
  30. float yMin = NGUIText.mTempChar.vert.yMin;
  31. NGUIText.baseline = Mathf.Round(yMax + ((float)NGUIText.finalSize - yMax + yMin) * 0.5f);
  32. }
  33. }
  34. public static void Prepare(string text)
  35. {
  36. if (NGUIText.dynamicFont != null)
  37. {
  38. NGUIText.dynamicFont.RequestCharactersInTexture(text, NGUIText.finalSize, NGUIText.fontStyle);
  39. }
  40. }
  41. public static BMSymbol GetSymbol(string text, int index, int textLength)
  42. {
  43. return (!(NGUIText.bitmapFont != null)) ? null : NGUIText.bitmapFont.MatchSymbol(text, index, textLength);
  44. }
  45. public static float GetGlyphWidth(int ch, int prev)
  46. {
  47. if (NGUIText.bitmapFont != null)
  48. {
  49. bool flag = false;
  50. if (ch == 8201)
  51. {
  52. flag = true;
  53. ch = 32;
  54. }
  55. BMGlyph bmglyph = NGUIText.bitmapFont.bmFont.GetGlyph(ch);
  56. if (bmglyph != null)
  57. {
  58. int num = bmglyph.advance;
  59. if (flag)
  60. {
  61. num >>= 1;
  62. }
  63. return NGUIText.fontScale * (float)((prev == 0) ? bmglyph.advance : (num + bmglyph.GetKerning(prev)));
  64. }
  65. }
  66. else if (NGUIText.dynamicFont != null && NGUIText.dynamicFont.GetCharacterInfo((char)ch, out NGUIText.mTempChar, NGUIText.finalSize, NGUIText.fontStyle))
  67. {
  68. return NGUIText.mTempChar.width * NGUIText.fontScale * NGUIText.pixelDensity;
  69. }
  70. return 0f;
  71. }
  72. public static NGUIText.GlyphInfo GetGlyph(int ch, int prev)
  73. {
  74. if (NGUIText.bitmapFont != null)
  75. {
  76. bool flag = false;
  77. if (ch == 8201)
  78. {
  79. flag = true;
  80. ch = 32;
  81. }
  82. BMGlyph bmglyph = NGUIText.bitmapFont.bmFont.GetGlyph(ch);
  83. if (bmglyph != null)
  84. {
  85. int num = (prev == 0) ? 0 : bmglyph.GetKerning(prev);
  86. NGUIText.glyph.v0.x = (float)((prev == 0) ? bmglyph.offsetX : (bmglyph.offsetX + num));
  87. NGUIText.glyph.v1.y = (float)(-(float)bmglyph.offsetY);
  88. NGUIText.glyph.v1.x = NGUIText.glyph.v0.x + (float)bmglyph.width;
  89. NGUIText.glyph.v0.y = NGUIText.glyph.v1.y - (float)bmglyph.height;
  90. NGUIText.glyph.u0.x = (float)bmglyph.x;
  91. NGUIText.glyph.u0.y = (float)(bmglyph.y + bmglyph.height);
  92. NGUIText.glyph.u2.x = (float)(bmglyph.x + bmglyph.width);
  93. NGUIText.glyph.u2.y = (float)bmglyph.y;
  94. NGUIText.glyph.u1.x = NGUIText.glyph.u0.x;
  95. NGUIText.glyph.u1.y = NGUIText.glyph.u2.y;
  96. NGUIText.glyph.u3.x = NGUIText.glyph.u2.x;
  97. NGUIText.glyph.u3.y = NGUIText.glyph.u0.y;
  98. int num2 = bmglyph.advance;
  99. if (flag)
  100. {
  101. num2 >>= 1;
  102. }
  103. NGUIText.glyph.advance = (float)(num2 + num);
  104. NGUIText.glyph.channel = bmglyph.channel;
  105. if (NGUIText.fontScale != 1f)
  106. {
  107. NGUIText.glyph.v0 *= NGUIText.fontScale;
  108. NGUIText.glyph.v1 *= NGUIText.fontScale;
  109. NGUIText.glyph.advance *= NGUIText.fontScale;
  110. }
  111. return NGUIText.glyph;
  112. }
  113. }
  114. else if (NGUIText.dynamicFont != null && NGUIText.dynamicFont.GetCharacterInfo((char)ch, out NGUIText.mTempChar, NGUIText.finalSize, NGUIText.fontStyle))
  115. {
  116. NGUIText.glyph.v0.x = NGUIText.mTempChar.vert.xMin;
  117. NGUIText.glyph.v1.x = NGUIText.glyph.v0.x + NGUIText.mTempChar.vert.width;
  118. NGUIText.glyph.v0.y = NGUIText.mTempChar.vert.yMax - NGUIText.baseline;
  119. NGUIText.glyph.v1.y = NGUIText.glyph.v0.y - NGUIText.mTempChar.vert.height;
  120. NGUIText.glyph.u0.x = NGUIText.mTempChar.uv.xMin;
  121. NGUIText.glyph.u0.y = NGUIText.mTempChar.uv.yMin;
  122. NGUIText.glyph.u2.x = NGUIText.mTempChar.uv.xMax;
  123. NGUIText.glyph.u2.y = NGUIText.mTempChar.uv.yMax;
  124. if (NGUIText.mTempChar.flipped)
  125. {
  126. NGUIText.glyph.u1 = new Vector2(NGUIText.glyph.u2.x, NGUIText.glyph.u0.y);
  127. NGUIText.glyph.u3 = new Vector2(NGUIText.glyph.u0.x, NGUIText.glyph.u2.y);
  128. }
  129. else
  130. {
  131. NGUIText.glyph.u1 = new Vector2(NGUIText.glyph.u0.x, NGUIText.glyph.u2.y);
  132. NGUIText.glyph.u3 = new Vector2(NGUIText.glyph.u2.x, NGUIText.glyph.u0.y);
  133. }
  134. NGUIText.glyph.advance = NGUIText.mTempChar.width;
  135. NGUIText.glyph.channel = 0;
  136. NGUIText.glyph.v0.x = Mathf.Round(NGUIText.glyph.v0.x);
  137. NGUIText.glyph.v0.y = Mathf.Round(NGUIText.glyph.v0.y);
  138. NGUIText.glyph.v1.x = Mathf.Round(NGUIText.glyph.v1.x);
  139. NGUIText.glyph.v1.y = Mathf.Round(NGUIText.glyph.v1.y);
  140. float num3 = NGUIText.fontScale * NGUIText.pixelDensity;
  141. if (num3 != 1f)
  142. {
  143. NGUIText.glyph.v0 *= num3;
  144. NGUIText.glyph.v1 *= num3;
  145. NGUIText.glyph.advance *= num3;
  146. }
  147. return NGUIText.glyph;
  148. }
  149. return null;
  150. }
  151. [DebuggerHidden]
  152. [DebuggerStepThrough]
  153. public static float ParseAlpha(string text, int index)
  154. {
  155. int num = NGUIMath.HexToDecimal(text[index + 1]) << 4 | NGUIMath.HexToDecimal(text[index + 2]);
  156. return Mathf.Clamp01((float)num / 255f);
  157. }
  158. [DebuggerHidden]
  159. [DebuggerStepThrough]
  160. public static Color ParseColor(string text, int offset)
  161. {
  162. return NGUIText.ParseColor24(text, offset);
  163. }
  164. [DebuggerHidden]
  165. [DebuggerStepThrough]
  166. public static Color ParseColor24(string text, int offset)
  167. {
  168. int num = NGUIMath.HexToDecimal(text[offset]) << 4 | NGUIMath.HexToDecimal(text[offset + 1]);
  169. int num2 = NGUIMath.HexToDecimal(text[offset + 2]) << 4 | NGUIMath.HexToDecimal(text[offset + 3]);
  170. int num3 = NGUIMath.HexToDecimal(text[offset + 4]) << 4 | NGUIMath.HexToDecimal(text[offset + 5]);
  171. float num4 = 0.003921569f;
  172. return new Color(num4 * (float)num, num4 * (float)num2, num4 * (float)num3);
  173. }
  174. [DebuggerHidden]
  175. [DebuggerStepThrough]
  176. public static Color ParseColor32(string text, int offset)
  177. {
  178. int num = NGUIMath.HexToDecimal(text[offset]) << 4 | NGUIMath.HexToDecimal(text[offset + 1]);
  179. int num2 = NGUIMath.HexToDecimal(text[offset + 2]) << 4 | NGUIMath.HexToDecimal(text[offset + 3]);
  180. int num3 = NGUIMath.HexToDecimal(text[offset + 4]) << 4 | NGUIMath.HexToDecimal(text[offset + 5]);
  181. int num4 = NGUIMath.HexToDecimal(text[offset + 6]) << 4 | NGUIMath.HexToDecimal(text[offset + 7]);
  182. float num5 = 0.003921569f;
  183. return new Color(num5 * (float)num, num5 * (float)num2, num5 * (float)num3, num5 * (float)num4);
  184. }
  185. [DebuggerHidden]
  186. [DebuggerStepThrough]
  187. public static string EncodeColor(Color c)
  188. {
  189. return NGUIText.EncodeColor24(c);
  190. }
  191. [DebuggerHidden]
  192. [DebuggerStepThrough]
  193. public static string EncodeAlpha(float a)
  194. {
  195. int num = Mathf.Clamp(Mathf.RoundToInt(a * 255f), 0, 255);
  196. return NGUIMath.DecimalToHex8(num);
  197. }
  198. [DebuggerHidden]
  199. [DebuggerStepThrough]
  200. public static string EncodeColor24(Color c)
  201. {
  202. int num = 16777215 & NGUIMath.ColorToInt(c) >> 8;
  203. return NGUIMath.DecimalToHex24(num);
  204. }
  205. [DebuggerHidden]
  206. [DebuggerStepThrough]
  207. public static string EncodeColor32(Color c)
  208. {
  209. int num = NGUIMath.ColorToInt(c);
  210. return NGUIMath.DecimalToHex32(num);
  211. }
  212. public static bool ParseSymbol(string text, ref int index)
  213. {
  214. int num = 1;
  215. bool flag = false;
  216. bool flag2 = false;
  217. bool flag3 = false;
  218. bool flag4 = false;
  219. bool flag5 = false;
  220. return NGUIText.ParseSymbol(text, ref index, null, false, ref num, ref flag, ref flag2, ref flag3, ref flag4, ref flag5);
  221. }
  222. [DebuggerHidden]
  223. [DebuggerStepThrough]
  224. public static bool IsHex(char ch)
  225. {
  226. return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F');
  227. }
  228. public static bool ParseSymbol(string text, ref int index, BetterList<Color> colors, bool premultiply, ref int sub, ref bool bold, ref bool italic, ref bool underline, ref bool strike, ref bool ignoreColor)
  229. {
  230. int length = text.Length;
  231. if (index + 3 > length || text[index] != '[')
  232. {
  233. return false;
  234. }
  235. if (text[index + 2] == ']')
  236. {
  237. if (text[index + 1] == '-')
  238. {
  239. if (colors != null && colors.size > 1)
  240. {
  241. colors.RemoveAt(colors.size - 1);
  242. }
  243. index += 3;
  244. return true;
  245. }
  246. string text2 = text.Substring(index, 3);
  247. if (text2 != null)
  248. {
  249. if (text2 == "[b]")
  250. {
  251. bold = true;
  252. index += 3;
  253. return true;
  254. }
  255. if (text2 == "[i]")
  256. {
  257. italic = true;
  258. index += 3;
  259. return true;
  260. }
  261. if (text2 == "[u]")
  262. {
  263. underline = true;
  264. index += 3;
  265. return true;
  266. }
  267. if (text2 == "[s]")
  268. {
  269. strike = true;
  270. index += 3;
  271. return true;
  272. }
  273. if (text2 == "[c]")
  274. {
  275. ignoreColor = true;
  276. index += 3;
  277. return true;
  278. }
  279. }
  280. }
  281. if (index + 4 > length)
  282. {
  283. return false;
  284. }
  285. if (text[index + 3] == ']')
  286. {
  287. string text3 = text.Substring(index, 4);
  288. if (text3 != null)
  289. {
  290. if (text3 == "[/b]")
  291. {
  292. bold = false;
  293. index += 4;
  294. return true;
  295. }
  296. if (text3 == "[/i]")
  297. {
  298. italic = false;
  299. index += 4;
  300. return true;
  301. }
  302. if (text3 == "[/u]")
  303. {
  304. underline = false;
  305. index += 4;
  306. return true;
  307. }
  308. if (text3 == "[/s]")
  309. {
  310. strike = false;
  311. index += 4;
  312. return true;
  313. }
  314. if (text3 == "[/c]")
  315. {
  316. ignoreColor = false;
  317. index += 4;
  318. return true;
  319. }
  320. }
  321. char ch = text[index + 1];
  322. char ch2 = text[index + 2];
  323. if (NGUIText.IsHex(ch) && NGUIText.IsHex(ch2))
  324. {
  325. int num = NGUIMath.HexToDecimal(ch) << 4 | NGUIMath.HexToDecimal(ch2);
  326. NGUIText.mAlpha = (float)num / 255f;
  327. index += 4;
  328. return true;
  329. }
  330. }
  331. if (index + 5 > length)
  332. {
  333. return false;
  334. }
  335. if (text[index + 4] == ']')
  336. {
  337. string text4 = text.Substring(index, 5);
  338. if (text4 != null)
  339. {
  340. if (text4 == "[sub]")
  341. {
  342. sub = 1;
  343. index += 5;
  344. return true;
  345. }
  346. if (text4 == "[sup]")
  347. {
  348. sub = 2;
  349. index += 5;
  350. return true;
  351. }
  352. }
  353. }
  354. if (index + 6 > length)
  355. {
  356. return false;
  357. }
  358. if (text[index + 5] == ']')
  359. {
  360. string text5 = text.Substring(index, 6);
  361. if (text5 != null)
  362. {
  363. if (text5 == "[/sub]")
  364. {
  365. sub = 0;
  366. index += 6;
  367. return true;
  368. }
  369. if (text5 == "[/sup]")
  370. {
  371. sub = 0;
  372. index += 6;
  373. return true;
  374. }
  375. if (text5 == "[/url]")
  376. {
  377. index += 6;
  378. return true;
  379. }
  380. }
  381. }
  382. if (text[index + 1] == 'u' && text[index + 2] == 'r' && text[index + 3] == 'l' && text[index + 4] == '=')
  383. {
  384. int num2 = text.IndexOf(']', index + 4);
  385. if (num2 != -1)
  386. {
  387. index = num2 + 1;
  388. return true;
  389. }
  390. index = text.Length;
  391. return true;
  392. }
  393. else
  394. {
  395. if (index + 8 > length)
  396. {
  397. return false;
  398. }
  399. if (text[index + 7] == ']')
  400. {
  401. Color color = NGUIText.ParseColor24(text, index + 1);
  402. if (NGUIText.EncodeColor24(color) != text.Substring(index + 1, 6).ToUpper())
  403. {
  404. return false;
  405. }
  406. if (colors != null)
  407. {
  408. color.a = colors[colors.size - 1].a;
  409. if (premultiply && color.a != 1f)
  410. {
  411. color = Color.Lerp(NGUIText.mInvisible, color, color.a);
  412. }
  413. colors.Add(color);
  414. }
  415. index += 8;
  416. return true;
  417. }
  418. else
  419. {
  420. if (index + 10 > length)
  421. {
  422. return false;
  423. }
  424. if (text[index + 9] != ']')
  425. {
  426. return false;
  427. }
  428. Color color2 = NGUIText.ParseColor32(text, index + 1);
  429. if (NGUIText.EncodeColor32(color2) != text.Substring(index + 1, 8).ToUpper())
  430. {
  431. return false;
  432. }
  433. if (colors != null)
  434. {
  435. if (premultiply && color2.a != 1f)
  436. {
  437. color2 = Color.Lerp(NGUIText.mInvisible, color2, color2.a);
  438. }
  439. colors.Add(color2);
  440. }
  441. index += 10;
  442. return true;
  443. }
  444. }
  445. }
  446. public static string StripSymbols(string text)
  447. {
  448. if (text != null)
  449. {
  450. int i = 0;
  451. int length = text.Length;
  452. while (i < length)
  453. {
  454. char c = text[i];
  455. if (c == '[')
  456. {
  457. int num = 0;
  458. bool flag = false;
  459. bool flag2 = false;
  460. bool flag3 = false;
  461. bool flag4 = false;
  462. bool flag5 = false;
  463. int num2 = i;
  464. if (NGUIText.ParseSymbol(text, ref num2, null, false, ref num, ref flag, ref flag2, ref flag3, ref flag4, ref flag5))
  465. {
  466. text = text.Remove(i, num2 - i);
  467. length = text.Length;
  468. continue;
  469. }
  470. }
  471. i++;
  472. }
  473. }
  474. return text;
  475. }
  476. public static void Align(BetterList<Vector3> verts, int indexOffset, float printedWidth)
  477. {
  478. NGUIText.Alignment alignment = NGUIText.alignment;
  479. if (alignment != NGUIText.Alignment.Right)
  480. {
  481. if (alignment != NGUIText.Alignment.Center)
  482. {
  483. if (alignment == NGUIText.Alignment.Justified)
  484. {
  485. if (printedWidth < (float)NGUIText.rectWidth * 0.65f)
  486. {
  487. return;
  488. }
  489. float num = ((float)NGUIText.rectWidth - printedWidth) * 0.5f;
  490. if (num < 1f)
  491. {
  492. return;
  493. }
  494. int num2 = (verts.size - indexOffset) / 4;
  495. if (num2 < 1)
  496. {
  497. return;
  498. }
  499. float num3 = 1f / (float)(num2 - 1);
  500. float num4 = (float)NGUIText.rectWidth / printedWidth;
  501. int i = indexOffset + 4;
  502. int num5 = 1;
  503. while (i < verts.size)
  504. {
  505. float num6 = verts.buffer[i].x;
  506. float num7 = verts.buffer[i + 2].x;
  507. float num8 = num7 - num6;
  508. float num9 = num6 * num4;
  509. float a = num9 + num8;
  510. float num10 = num7 * num4;
  511. float b = num10 - num8;
  512. float t = (float)num5 * num3;
  513. num6 = Mathf.Lerp(num9, b, t);
  514. num7 = Mathf.Lerp(a, num10, t);
  515. num6 = Mathf.Round(num6);
  516. num7 = Mathf.Round(num7);
  517. verts.buffer[i++].x = num6;
  518. verts.buffer[i++].x = num6;
  519. verts.buffer[i++].x = num7;
  520. verts.buffer[i++].x = num7;
  521. num5++;
  522. }
  523. }
  524. }
  525. else
  526. {
  527. float num11 = ((float)NGUIText.rectWidth - printedWidth) * 0.5f;
  528. if (num11 < 0f)
  529. {
  530. return;
  531. }
  532. int num12 = Mathf.RoundToInt((float)NGUIText.rectWidth - printedWidth);
  533. int num13 = Mathf.RoundToInt((float)NGUIText.rectWidth);
  534. bool flag = (num12 & 1) == 1;
  535. bool flag2 = (num13 & 1) == 1;
  536. if ((flag && !flag2) || (!flag && flag2))
  537. {
  538. num11 += 0.5f * NGUIText.fontScale;
  539. }
  540. for (int j = indexOffset; j < verts.size; j++)
  541. {
  542. Vector3[] buffer = verts.buffer;
  543. int num14 = j;
  544. buffer[num14].x = buffer[num14].x + num11;
  545. }
  546. }
  547. }
  548. else
  549. {
  550. float num15 = (float)NGUIText.rectWidth - printedWidth;
  551. if (num15 < 0f)
  552. {
  553. return;
  554. }
  555. for (int k = indexOffset; k < verts.size; k++)
  556. {
  557. Vector3[] buffer2 = verts.buffer;
  558. int num16 = k;
  559. buffer2[num16].x = buffer2[num16].x + num15;
  560. }
  561. }
  562. }
  563. public static int GetExactCharacterIndex(BetterList<Vector3> verts, BetterList<int> indices, Vector2 pos)
  564. {
  565. for (int i = 0; i < indices.size; i++)
  566. {
  567. int num = i << 1;
  568. int i2 = num + 1;
  569. float x = verts[num].x;
  570. if (pos.x >= x)
  571. {
  572. float x2 = verts[i2].x;
  573. if (pos.x <= x2)
  574. {
  575. float y = verts[num].y;
  576. if (pos.y >= y)
  577. {
  578. float y2 = verts[i2].y;
  579. if (pos.y <= y2)
  580. {
  581. return indices[i];
  582. }
  583. }
  584. }
  585. }
  586. }
  587. return 0;
  588. }
  589. public static int GetApproximateCharacterIndex(BetterList<Vector3> verts, BetterList<int> indices, Vector2 pos)
  590. {
  591. float num = float.MaxValue;
  592. float num2 = float.MaxValue;
  593. int i = 0;
  594. for (int j = 0; j < verts.size; j++)
  595. {
  596. float num3 = Mathf.Abs(pos.y - verts[j].y);
  597. if (num3 <= num2)
  598. {
  599. float num4 = Mathf.Abs(pos.x - verts[j].x);
  600. if (num3 < num2)
  601. {
  602. num2 = num3;
  603. num = num4;
  604. i = j;
  605. }
  606. else if (num4 < num)
  607. {
  608. num = num4;
  609. i = j;
  610. }
  611. }
  612. }
  613. return indices[i];
  614. }
  615. [DebuggerHidden]
  616. [DebuggerStepThrough]
  617. private static bool IsSpace(int ch)
  618. {
  619. return ch == 32 || ch == 8202 || ch == 8203 || ch == 8201;
  620. }
  621. [DebuggerHidden]
  622. [DebuggerStepThrough]
  623. public static void EndLine(ref StringBuilder s)
  624. {
  625. int num = s.Length - 1;
  626. if (num > 0 && NGUIText.IsSpace((int)s[num]))
  627. {
  628. s[num] = '\n';
  629. }
  630. else
  631. {
  632. s.Append('\n');
  633. }
  634. }
  635. [DebuggerHidden]
  636. [DebuggerStepThrough]
  637. private static void ReplaceSpaceWithNewline(ref StringBuilder s)
  638. {
  639. int num = s.Length - 1;
  640. if (num > 0 && NGUIText.IsSpace((int)s[num]))
  641. {
  642. s[num] = '\n';
  643. }
  644. }
  645. public static Vector2 CalculatePrintedSize(string text)
  646. {
  647. Vector2 zero = Vector2.zero;
  648. if (!string.IsNullOrEmpty(text))
  649. {
  650. if (NGUIText.encoding)
  651. {
  652. text = NGUIText.StripSymbols(text);
  653. }
  654. NGUIText.Prepare(text);
  655. float num = 0f;
  656. float num2 = 0f;
  657. float num3 = 0f;
  658. int length = text.Length;
  659. int prev = 0;
  660. for (int i = 0; i < length; i++)
  661. {
  662. int num4 = (int)text[i];
  663. if (num4 == 10)
  664. {
  665. if (num > num3)
  666. {
  667. num3 = num;
  668. }
  669. num = 0f;
  670. num2 += NGUIText.finalLineHeight;
  671. }
  672. else if (num4 >= 32)
  673. {
  674. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  675. if (bmsymbol == null)
  676. {
  677. float num5 = NGUIText.GetGlyphWidth(num4, prev);
  678. if (num5 != 0f)
  679. {
  680. num5 += NGUIText.finalSpacingX;
  681. if (Mathf.RoundToInt(num + num5) > NGUIText.regionWidth)
  682. {
  683. if (num > num3)
  684. {
  685. num3 = num - NGUIText.finalSpacingX;
  686. }
  687. num = num5;
  688. num2 += NGUIText.finalLineHeight;
  689. }
  690. else
  691. {
  692. num += num5;
  693. }
  694. prev = num4;
  695. }
  696. }
  697. else
  698. {
  699. float num6 = NGUIText.finalSpacingX + (float)bmsymbol.advance * NGUIText.fontScale;
  700. if (Mathf.RoundToInt(num + num6) > NGUIText.regionWidth)
  701. {
  702. if (num > num3)
  703. {
  704. num3 = num - NGUIText.finalSpacingX;
  705. }
  706. num = num6;
  707. num2 += NGUIText.finalLineHeight;
  708. }
  709. else
  710. {
  711. num += num6;
  712. }
  713. i += bmsymbol.sequence.Length - 1;
  714. prev = 0;
  715. }
  716. }
  717. }
  718. zero.x = ((num <= num3) ? num3 : (num - NGUIText.finalSpacingX));
  719. zero.y = num2 + NGUIText.finalLineHeight;
  720. }
  721. return zero;
  722. }
  723. public static int CalculateOffsetToFit(string text)
  724. {
  725. if (string.IsNullOrEmpty(text) || NGUIText.regionWidth < 1)
  726. {
  727. return 0;
  728. }
  729. NGUIText.Prepare(text);
  730. int length = text.Length;
  731. int prev = 0;
  732. int i = 0;
  733. int length2 = text.Length;
  734. while (i < length2)
  735. {
  736. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  737. if (bmsymbol == null)
  738. {
  739. int num = (int)text[i];
  740. float glyphWidth = NGUIText.GetGlyphWidth(num, prev);
  741. if (glyphWidth != 0f)
  742. {
  743. NGUIText.mSizes.Add(NGUIText.finalSpacingX + glyphWidth);
  744. }
  745. prev = num;
  746. }
  747. else
  748. {
  749. NGUIText.mSizes.Add(NGUIText.finalSpacingX + (float)bmsymbol.advance * NGUIText.fontScale);
  750. int j = 0;
  751. int num2 = bmsymbol.sequence.Length - 1;
  752. while (j < num2)
  753. {
  754. NGUIText.mSizes.Add(0f);
  755. j++;
  756. }
  757. i += bmsymbol.sequence.Length - 1;
  758. prev = 0;
  759. }
  760. i++;
  761. }
  762. float num3 = (float)NGUIText.regionWidth;
  763. int num4 = NGUIText.mSizes.size;
  764. while (num4 > 0 && num3 > 0f)
  765. {
  766. num3 -= NGUIText.mSizes[--num4];
  767. }
  768. NGUIText.mSizes.Clear();
  769. if (num3 < 0f)
  770. {
  771. num4++;
  772. }
  773. return num4;
  774. }
  775. public static string GetEndOfLineThatFits(string text)
  776. {
  777. int length = text.Length;
  778. int num = NGUIText.CalculateOffsetToFit(text);
  779. return text.Substring(num, length - num);
  780. }
  781. public static bool WrapText(string text, out string finalText)
  782. {
  783. return NGUIText.WrapText(text, out finalText, false);
  784. }
  785. public static bool WrapText(string text, out string finalText, bool keepCharCount)
  786. {
  787. if (NGUIText.regionWidth < 1 || NGUIText.regionHeight < 1 || NGUIText.finalLineHeight < 1f)
  788. {
  789. finalText = string.Empty;
  790. return false;
  791. }
  792. float num = (NGUIText.maxLines <= 0) ? ((float)NGUIText.regionHeight) : Mathf.Min((float)NGUIText.regionHeight, NGUIText.finalLineHeight * (float)NGUIText.maxLines);
  793. int num2 = (NGUIText.maxLines <= 0) ? 1000000 : NGUIText.maxLines;
  794. num2 = Mathf.FloorToInt(Mathf.Min((float)num2, num / NGUIText.finalLineHeight) + 0.01f);
  795. if (num2 == 0)
  796. {
  797. finalText = string.Empty;
  798. return false;
  799. }
  800. if (string.IsNullOrEmpty(text))
  801. {
  802. text = " ";
  803. }
  804. NGUIText.Prepare(text);
  805. StringBuilder stringBuilder = new StringBuilder();
  806. int length = text.Length;
  807. float num3 = (float)NGUIText.regionWidth;
  808. int num4 = 0;
  809. int i = 0;
  810. int num5 = 1;
  811. int prev = 0;
  812. bool flag = true;
  813. bool flag2 = true;
  814. bool flag3 = false;
  815. while (i < length)
  816. {
  817. char c = text[i];
  818. if (Product.supportMultiLanguage)
  819. {
  820. flag3 = false;
  821. }
  822. if (c > '⿿')
  823. {
  824. flag3 = true;
  825. }
  826. if (c == '\n')
  827. {
  828. if (num5 == num2)
  829. {
  830. break;
  831. }
  832. num3 = (float)NGUIText.regionWidth;
  833. if (num4 < i)
  834. {
  835. stringBuilder.Append(text.Substring(num4, i - num4 + 1));
  836. }
  837. else
  838. {
  839. stringBuilder.Append(c);
  840. }
  841. flag = true;
  842. num5++;
  843. num4 = i + 1;
  844. prev = 0;
  845. }
  846. else if (NGUIText.encoding && NGUIText.ParseSymbol(text, ref i))
  847. {
  848. i--;
  849. }
  850. else
  851. {
  852. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  853. float num6;
  854. if (bmsymbol == null)
  855. {
  856. float glyphWidth = NGUIText.GetGlyphWidth((int)c, prev);
  857. if (glyphWidth == 0f)
  858. {
  859. goto IL_397;
  860. }
  861. num6 = NGUIText.finalSpacingX + glyphWidth;
  862. }
  863. else
  864. {
  865. num6 = NGUIText.finalSpacingX + (float)bmsymbol.advance * NGUIText.fontScale;
  866. }
  867. num3 -= num6;
  868. if (NGUIText.IsSpace((int)c) && !flag3 && num4 < i)
  869. {
  870. int num7 = i - num4 + 1;
  871. if (num5 == num2 && num3 <= 0f && i < length)
  872. {
  873. char c2 = text[i];
  874. if (c2 < ' ' || NGUIText.IsSpace((int)c2))
  875. {
  876. num7--;
  877. }
  878. }
  879. stringBuilder.Append(text.Substring(num4, num7));
  880. flag = false;
  881. num4 = i + 1;
  882. }
  883. if (Mathf.RoundToInt(num3) < 0)
  884. {
  885. if (flag || num5 == num2)
  886. {
  887. stringBuilder.Append(text.Substring(num4, Mathf.Max(0, i - num4)));
  888. bool flag4 = NGUIText.IsSpace((int)c);
  889. if (!flag4 && !flag3)
  890. {
  891. flag2 = false;
  892. }
  893. if (num5++ == num2)
  894. {
  895. num4 = i;
  896. break;
  897. }
  898. if (keepCharCount)
  899. {
  900. NGUIText.ReplaceSpaceWithNewline(ref stringBuilder);
  901. }
  902. else
  903. {
  904. NGUIText.EndLine(ref stringBuilder);
  905. }
  906. flag = true;
  907. if (flag4)
  908. {
  909. num4 = i + 1;
  910. num3 = (float)NGUIText.regionWidth;
  911. }
  912. else
  913. {
  914. num4 = i;
  915. num3 = (float)NGUIText.regionWidth - num6;
  916. }
  917. prev = 0;
  918. }
  919. else
  920. {
  921. flag = true;
  922. num3 = (float)NGUIText.regionWidth;
  923. i = num4 - 1;
  924. prev = 0;
  925. if (num5++ == num2)
  926. {
  927. break;
  928. }
  929. if (keepCharCount)
  930. {
  931. NGUIText.ReplaceSpaceWithNewline(ref stringBuilder);
  932. }
  933. else
  934. {
  935. NGUIText.EndLine(ref stringBuilder);
  936. }
  937. goto IL_397;
  938. }
  939. }
  940. else
  941. {
  942. prev = (int)c;
  943. }
  944. if (bmsymbol != null)
  945. {
  946. i += bmsymbol.length - 1;
  947. prev = 0;
  948. }
  949. }
  950. IL_397:
  951. i++;
  952. }
  953. if (num4 < i)
  954. {
  955. stringBuilder.Append(text.Substring(num4, i - num4));
  956. }
  957. finalText = stringBuilder.ToString();
  958. return flag2 && (i == length || num5 <= Mathf.Min(NGUIText.maxLines, num2));
  959. }
  960. public static void Print(string text, BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
  961. {
  962. if (string.IsNullOrEmpty(text))
  963. {
  964. return;
  965. }
  966. int size = verts.size;
  967. NGUIText.Prepare(text);
  968. NGUIText.mColors.Add(Color.white);
  969. NGUIText.mAlpha = 1f;
  970. int prev = 0;
  971. float num = 0f;
  972. float num2 = 0f;
  973. float num3 = 0f;
  974. float num4 = (float)NGUIText.finalSize;
  975. Color a = NGUIText.tint * NGUIText.gradientBottom;
  976. Color b = NGUIText.tint * NGUIText.gradientTop;
  977. Color32 color = NGUIText.tint;
  978. int length = text.Length;
  979. Rect rect = default(Rect);
  980. float num5 = 0f;
  981. float num6 = 0f;
  982. float num7 = num4 * NGUIText.pixelDensity;
  983. bool flag = false;
  984. int num8 = 0;
  985. bool flag2 = false;
  986. bool flag3 = false;
  987. bool flag4 = false;
  988. bool flag5 = false;
  989. bool flag6 = false;
  990. if (NGUIText.bitmapFont != null)
  991. {
  992. rect = NGUIText.bitmapFont.uvRect;
  993. num5 = rect.width / (float)NGUIText.bitmapFont.texWidth;
  994. num6 = rect.height / (float)NGUIText.bitmapFont.texHeight;
  995. }
  996. for (int i = 0; i < length; i++)
  997. {
  998. int num9 = (int)text[i];
  999. float num10 = num;
  1000. if (num9 == 10)
  1001. {
  1002. if (num > num3)
  1003. {
  1004. num3 = num;
  1005. }
  1006. if (NGUIText.alignment != NGUIText.Alignment.Left)
  1007. {
  1008. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1009. size = verts.size;
  1010. }
  1011. num = 0f;
  1012. num2 += NGUIText.finalLineHeight;
  1013. prev = 0;
  1014. }
  1015. else if (num9 < 32)
  1016. {
  1017. prev = num9;
  1018. }
  1019. else if (NGUIText.encoding && NGUIText.ParseSymbol(text, ref i, NGUIText.mColors, NGUIText.premultiply, ref num8, ref flag2, ref flag3, ref flag4, ref flag5, ref flag6))
  1020. {
  1021. Color color2;
  1022. if (flag6)
  1023. {
  1024. color2 = NGUIText.mColors[NGUIText.mColors.size - 1];
  1025. color2.a *= NGUIText.mAlpha * NGUIText.tint.a;
  1026. }
  1027. else
  1028. {
  1029. color2 = NGUIText.tint * NGUIText.mColors[NGUIText.mColors.size - 1];
  1030. color2.a *= NGUIText.mAlpha;
  1031. }
  1032. color = color2;
  1033. int j = 0;
  1034. int num11 = NGUIText.mColors.size - 2;
  1035. while (j < num11)
  1036. {
  1037. color2.a *= NGUIText.mColors[j].a;
  1038. j++;
  1039. }
  1040. if (NGUIText.gradient)
  1041. {
  1042. a = NGUIText.gradientBottom * color2;
  1043. b = NGUIText.gradientTop * color2;
  1044. }
  1045. i--;
  1046. }
  1047. else
  1048. {
  1049. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  1050. if (bmsymbol != null)
  1051. {
  1052. float num12 = num + (float)bmsymbol.offsetX * NGUIText.fontScale;
  1053. float num13 = num12 + (float)bmsymbol.width * NGUIText.fontScale;
  1054. float num14 = -(num2 + (float)bmsymbol.offsetY * NGUIText.fontScale);
  1055. float num15 = num14 - (float)bmsymbol.height * NGUIText.fontScale;
  1056. if (Mathf.RoundToInt(num + (float)bmsymbol.advance * NGUIText.fontScale) > NGUIText.regionWidth)
  1057. {
  1058. if (num == 0f)
  1059. {
  1060. return;
  1061. }
  1062. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1063. {
  1064. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1065. size = verts.size;
  1066. }
  1067. num12 -= num;
  1068. num13 -= num;
  1069. num15 -= NGUIText.finalLineHeight;
  1070. num14 -= NGUIText.finalLineHeight;
  1071. num = 0f;
  1072. num2 += NGUIText.finalLineHeight;
  1073. }
  1074. verts.Add(new Vector3(num12, num15));
  1075. verts.Add(new Vector3(num12, num14));
  1076. verts.Add(new Vector3(num13, num14));
  1077. verts.Add(new Vector3(num13, num15));
  1078. num += NGUIText.finalSpacingX + (float)bmsymbol.advance * NGUIText.fontScale;
  1079. i += bmsymbol.length - 1;
  1080. prev = 0;
  1081. if (uvs != null)
  1082. {
  1083. Rect uvRect = bmsymbol.uvRect;
  1084. float xMin = uvRect.xMin;
  1085. float yMin = uvRect.yMin;
  1086. float xMax = uvRect.xMax;
  1087. float yMax = uvRect.yMax;
  1088. uvs.Add(new Vector2(xMin, yMin));
  1089. uvs.Add(new Vector2(xMin, yMax));
  1090. uvs.Add(new Vector2(xMax, yMax));
  1091. uvs.Add(new Vector2(xMax, yMin));
  1092. }
  1093. if (cols != null)
  1094. {
  1095. if (NGUIText.symbolStyle == NGUIText.SymbolStyle.Colored)
  1096. {
  1097. for (int k = 0; k < 4; k++)
  1098. {
  1099. cols.Add(color);
  1100. }
  1101. }
  1102. else
  1103. {
  1104. Color32 item = Color.white;
  1105. item.a = color.a;
  1106. for (int l = 0; l < 4; l++)
  1107. {
  1108. cols.Add(item);
  1109. }
  1110. }
  1111. }
  1112. }
  1113. else
  1114. {
  1115. NGUIText.GlyphInfo glyphInfo = NGUIText.GetGlyph(num9, prev);
  1116. if (glyphInfo != null)
  1117. {
  1118. prev = num9;
  1119. if (num8 != 0)
  1120. {
  1121. NGUIText.GlyphInfo glyphInfo2 = glyphInfo;
  1122. glyphInfo2.v0.x = glyphInfo2.v0.x * 0.75f;
  1123. NGUIText.GlyphInfo glyphInfo3 = glyphInfo;
  1124. glyphInfo3.v0.y = glyphInfo3.v0.y * 0.75f;
  1125. NGUIText.GlyphInfo glyphInfo4 = glyphInfo;
  1126. glyphInfo4.v1.x = glyphInfo4.v1.x * 0.75f;
  1127. NGUIText.GlyphInfo glyphInfo5 = glyphInfo;
  1128. glyphInfo5.v1.y = glyphInfo5.v1.y * 0.75f;
  1129. if (num8 == 1)
  1130. {
  1131. NGUIText.GlyphInfo glyphInfo6 = glyphInfo;
  1132. glyphInfo6.v0.y = glyphInfo6.v0.y - NGUIText.fontScale * (float)NGUIText.fontSize * 0.4f;
  1133. NGUIText.GlyphInfo glyphInfo7 = glyphInfo;
  1134. glyphInfo7.v1.y = glyphInfo7.v1.y - NGUIText.fontScale * (float)NGUIText.fontSize * 0.4f;
  1135. }
  1136. else
  1137. {
  1138. NGUIText.GlyphInfo glyphInfo8 = glyphInfo;
  1139. glyphInfo8.v0.y = glyphInfo8.v0.y + NGUIText.fontScale * (float)NGUIText.fontSize * 0.05f;
  1140. NGUIText.GlyphInfo glyphInfo9 = glyphInfo;
  1141. glyphInfo9.v1.y = glyphInfo9.v1.y + NGUIText.fontScale * (float)NGUIText.fontSize * 0.05f;
  1142. }
  1143. }
  1144. float num12 = glyphInfo.v0.x + num;
  1145. float num15 = glyphInfo.v0.y - num2;
  1146. float num13 = glyphInfo.v1.x + num;
  1147. float num14 = glyphInfo.v1.y - num2;
  1148. float num16 = glyphInfo.advance;
  1149. if (NGUIText.finalSpacingX < 0f)
  1150. {
  1151. num16 += NGUIText.finalSpacingX;
  1152. }
  1153. if (Mathf.RoundToInt(num + num16) > NGUIText.regionWidth)
  1154. {
  1155. if (num == 0f)
  1156. {
  1157. return;
  1158. }
  1159. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1160. {
  1161. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1162. size = verts.size;
  1163. }
  1164. num12 -= num;
  1165. num13 -= num;
  1166. num15 -= NGUIText.finalLineHeight;
  1167. num14 -= NGUIText.finalLineHeight;
  1168. num = 0f;
  1169. num2 += NGUIText.finalLineHeight;
  1170. num10 = 0f;
  1171. }
  1172. if (NGUIText.IsSpace(num9))
  1173. {
  1174. if (flag4)
  1175. {
  1176. num9 = 95;
  1177. }
  1178. else if (flag5)
  1179. {
  1180. num9 = 45;
  1181. }
  1182. }
  1183. num += ((num8 != 0) ? ((NGUIText.finalSpacingX + glyphInfo.advance) * 0.75f) : (NGUIText.finalSpacingX + glyphInfo.advance));
  1184. if (!NGUIText.IsSpace(num9))
  1185. {
  1186. if (uvs != null)
  1187. {
  1188. if (NGUIText.bitmapFont != null)
  1189. {
  1190. glyphInfo.u0.x = rect.xMin + num5 * glyphInfo.u0.x;
  1191. glyphInfo.u2.x = rect.xMin + num5 * glyphInfo.u2.x;
  1192. glyphInfo.u0.y = rect.yMax - num6 * glyphInfo.u0.y;
  1193. glyphInfo.u2.y = rect.yMax - num6 * glyphInfo.u2.y;
  1194. glyphInfo.u1.x = glyphInfo.u0.x;
  1195. glyphInfo.u1.y = glyphInfo.u2.y;
  1196. glyphInfo.u3.x = glyphInfo.u2.x;
  1197. glyphInfo.u3.y = glyphInfo.u0.y;
  1198. }
  1199. int m = 0;
  1200. int num17 = (!flag2) ? 1 : 4;
  1201. while (m < num17)
  1202. {
  1203. uvs.Add(glyphInfo.u0);
  1204. uvs.Add(glyphInfo.u1);
  1205. uvs.Add(glyphInfo.u2);
  1206. uvs.Add(glyphInfo.u3);
  1207. m++;
  1208. }
  1209. }
  1210. if (cols != null)
  1211. {
  1212. if (glyphInfo.channel == 0 || glyphInfo.channel == 15)
  1213. {
  1214. if (NGUIText.gradient)
  1215. {
  1216. float num18 = num7 + glyphInfo.v0.y / NGUIText.fontScale;
  1217. float num19 = num7 + glyphInfo.v1.y / NGUIText.fontScale;
  1218. num18 /= num7;
  1219. num19 /= num7;
  1220. NGUIText.s_c0 = Color.Lerp(a, b, num18);
  1221. NGUIText.s_c1 = Color.Lerp(a, b, num19);
  1222. int n = 0;
  1223. int num20 = (!flag2) ? 1 : 4;
  1224. while (n < num20)
  1225. {
  1226. cols.Add(NGUIText.s_c0);
  1227. cols.Add(NGUIText.s_c1);
  1228. cols.Add(NGUIText.s_c1);
  1229. cols.Add(NGUIText.s_c0);
  1230. n++;
  1231. }
  1232. }
  1233. else
  1234. {
  1235. int num21 = 0;
  1236. int num22 = (!flag2) ? 4 : 16;
  1237. while (num21 < num22)
  1238. {
  1239. cols.Add(color);
  1240. num21++;
  1241. }
  1242. }
  1243. }
  1244. else
  1245. {
  1246. Color color3 = color;
  1247. color3 *= 0.49f;
  1248. switch (glyphInfo.channel)
  1249. {
  1250. case 1:
  1251. color3.b += 0.51f;
  1252. break;
  1253. case 2:
  1254. color3.g += 0.51f;
  1255. break;
  1256. case 4:
  1257. color3.r += 0.51f;
  1258. break;
  1259. case 8:
  1260. color3.a += 0.51f;
  1261. break;
  1262. }
  1263. Color32 item2 = color3;
  1264. int num23 = 0;
  1265. int num24 = (!flag2) ? 4 : 16;
  1266. while (num23 < num24)
  1267. {
  1268. cols.Add(item2);
  1269. num23++;
  1270. }
  1271. }
  1272. }
  1273. if (!flag2)
  1274. {
  1275. if (!flag3)
  1276. {
  1277. verts.Add(new Vector3(num12, num15));
  1278. verts.Add(new Vector3(num12, num14));
  1279. verts.Add(new Vector3(num13, num14));
  1280. verts.Add(new Vector3(num13, num15));
  1281. }
  1282. else
  1283. {
  1284. float num25 = (float)NGUIText.fontSize * 0.1f * ((num14 - num15) / (float)NGUIText.fontSize);
  1285. verts.Add(new Vector3(num12 - num25, num15));
  1286. verts.Add(new Vector3(num12 + num25, num14));
  1287. verts.Add(new Vector3(num13 + num25, num14));
  1288. verts.Add(new Vector3(num13 - num25, num15));
  1289. }
  1290. }
  1291. else
  1292. {
  1293. for (int num26 = 0; num26 < 4; num26++)
  1294. {
  1295. float num27 = NGUIText.mBoldOffset[num26 * 2];
  1296. float num28 = NGUIText.mBoldOffset[num26 * 2 + 1];
  1297. float num29 = (!flag3) ? 0f : ((float)NGUIText.fontSize * 0.1f * ((num14 - num15) / (float)NGUIText.fontSize));
  1298. verts.Add(new Vector3(num12 + num27 - num29, num15 + num28));
  1299. verts.Add(new Vector3(num12 + num27 + num29, num14 + num28));
  1300. verts.Add(new Vector3(num13 + num27 + num29, num14 + num28));
  1301. verts.Add(new Vector3(num13 + num27 - num29, num15 + num28));
  1302. }
  1303. }
  1304. if (flag4 || flag5)
  1305. {
  1306. NGUIText.GlyphInfo glyphInfo10 = NGUIText.GetGlyph((!flag5) ? 95 : 45, prev);
  1307. if (glyphInfo10 != null)
  1308. {
  1309. if (uvs != null)
  1310. {
  1311. if (NGUIText.bitmapFont != null)
  1312. {
  1313. glyphInfo10.u0.x = rect.xMin + num5 * glyphInfo10.u0.x;
  1314. glyphInfo10.u2.x = rect.xMin + num5 * glyphInfo10.u2.x;
  1315. glyphInfo10.u0.y = rect.yMax - num6 * glyphInfo10.u0.y;
  1316. glyphInfo10.u2.y = rect.yMax - num6 * glyphInfo10.u2.y;
  1317. }
  1318. float x = (glyphInfo10.u0.x + glyphInfo10.u2.x) * 0.5f;
  1319. int num30 = 0;
  1320. int num31 = (!flag2) ? 1 : 4;
  1321. while (num30 < num31)
  1322. {
  1323. uvs.Add(new Vector2(x, glyphInfo10.u0.y));
  1324. uvs.Add(new Vector2(x, glyphInfo10.u2.y));
  1325. uvs.Add(new Vector2(x, glyphInfo10.u2.y));
  1326. uvs.Add(new Vector2(x, glyphInfo10.u0.y));
  1327. num30++;
  1328. }
  1329. }
  1330. if (flag && flag5)
  1331. {
  1332. num15 = (-num2 + glyphInfo10.v0.y) * 0.75f;
  1333. num14 = (-num2 + glyphInfo10.v1.y) * 0.75f;
  1334. }
  1335. else
  1336. {
  1337. num15 = -num2 + glyphInfo10.v0.y;
  1338. num14 = -num2 + glyphInfo10.v1.y;
  1339. }
  1340. if (flag2)
  1341. {
  1342. for (int num32 = 0; num32 < 4; num32++)
  1343. {
  1344. float num33 = NGUIText.mBoldOffset[num32 * 2];
  1345. float num34 = NGUIText.mBoldOffset[num32 * 2 + 1];
  1346. verts.Add(new Vector3(num10 + num33, num15 + num34));
  1347. verts.Add(new Vector3(num10 + num33, num14 + num34));
  1348. verts.Add(new Vector3(num + num33, num14 + num34));
  1349. verts.Add(new Vector3(num + num33, num15 + num34));
  1350. }
  1351. }
  1352. else
  1353. {
  1354. verts.Add(new Vector3(num10, num15));
  1355. verts.Add(new Vector3(num10, num14));
  1356. verts.Add(new Vector3(num, num14));
  1357. verts.Add(new Vector3(num, num15));
  1358. }
  1359. if (NGUIText.gradient)
  1360. {
  1361. float num35 = num7 + glyphInfo10.v0.y / NGUIText.fontScale;
  1362. float num36 = num7 + glyphInfo10.v1.y / NGUIText.fontScale;
  1363. num35 /= num7;
  1364. num36 /= num7;
  1365. NGUIText.s_c0 = Color.Lerp(a, b, num35);
  1366. NGUIText.s_c1 = Color.Lerp(a, b, num36);
  1367. int num37 = 0;
  1368. int num38 = (!flag2) ? 1 : 4;
  1369. while (num37 < num38)
  1370. {
  1371. cols.Add(NGUIText.s_c0);
  1372. cols.Add(NGUIText.s_c1);
  1373. cols.Add(NGUIText.s_c1);
  1374. cols.Add(NGUIText.s_c0);
  1375. num37++;
  1376. }
  1377. }
  1378. else
  1379. {
  1380. int num39 = 0;
  1381. int num40 = (!flag2) ? 4 : 16;
  1382. while (num39 < num40)
  1383. {
  1384. cols.Add(color);
  1385. num39++;
  1386. }
  1387. }
  1388. }
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394. }
  1395. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1396. {
  1397. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1398. size = verts.size;
  1399. }
  1400. NGUIText.mColors.Clear();
  1401. }
  1402. public static void PrintApproximateCharacterPositions(string text, BetterList<Vector3> verts, BetterList<int> indices)
  1403. {
  1404. if (string.IsNullOrEmpty(text))
  1405. {
  1406. text = " ";
  1407. }
  1408. NGUIText.Prepare(text);
  1409. float num = 0f;
  1410. float num2 = 0f;
  1411. float num3 = 0f;
  1412. float num4 = (float)NGUIText.fontSize * NGUIText.fontScale * 0.5f;
  1413. int length = text.Length;
  1414. int size = verts.size;
  1415. int prev = 0;
  1416. for (int i = 0; i < length; i++)
  1417. {
  1418. int num5 = (int)text[i];
  1419. verts.Add(new Vector3(num, -num2 - num4));
  1420. indices.Add(i);
  1421. if (num5 == 10)
  1422. {
  1423. if (num > num3)
  1424. {
  1425. num3 = num;
  1426. }
  1427. if (NGUIText.alignment != NGUIText.Alignment.Left)
  1428. {
  1429. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1430. size = verts.size;
  1431. }
  1432. num = 0f;
  1433. num2 += NGUIText.finalLineHeight;
  1434. prev = 0;
  1435. }
  1436. else if (num5 < 32)
  1437. {
  1438. prev = 0;
  1439. }
  1440. else if (NGUIText.encoding && NGUIText.ParseSymbol(text, ref i))
  1441. {
  1442. i--;
  1443. }
  1444. else
  1445. {
  1446. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  1447. if (bmsymbol == null)
  1448. {
  1449. float num6 = NGUIText.GetGlyphWidth(num5, prev);
  1450. if (num6 != 0f)
  1451. {
  1452. num6 += NGUIText.finalSpacingX;
  1453. if (Mathf.RoundToInt(num + num6) > NGUIText.regionWidth)
  1454. {
  1455. if (num == 0f)
  1456. {
  1457. return;
  1458. }
  1459. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1460. {
  1461. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1462. size = verts.size;
  1463. }
  1464. num = num6;
  1465. num2 += NGUIText.finalLineHeight;
  1466. }
  1467. else
  1468. {
  1469. num += num6;
  1470. }
  1471. verts.Add(new Vector3(num, -num2 - num4));
  1472. indices.Add(i + 1);
  1473. prev = num5;
  1474. }
  1475. }
  1476. else
  1477. {
  1478. float num7 = (float)bmsymbol.advance * NGUIText.fontScale + NGUIText.finalSpacingX;
  1479. if (Mathf.RoundToInt(num + num7) > NGUIText.regionWidth)
  1480. {
  1481. if (num == 0f)
  1482. {
  1483. return;
  1484. }
  1485. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1486. {
  1487. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1488. size = verts.size;
  1489. }
  1490. num = num7;
  1491. num2 += NGUIText.finalLineHeight;
  1492. }
  1493. else
  1494. {
  1495. num += num7;
  1496. }
  1497. verts.Add(new Vector3(num, -num2 - num4));
  1498. indices.Add(i + 1);
  1499. i += bmsymbol.sequence.Length - 1;
  1500. prev = 0;
  1501. }
  1502. }
  1503. }
  1504. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1505. {
  1506. NGUIText.Align(verts, size, num - NGUIText.finalSpacingX);
  1507. }
  1508. }
  1509. public static void PrintExactCharacterPositions(string text, BetterList<Vector3> verts, BetterList<int> indices)
  1510. {
  1511. if (string.IsNullOrEmpty(text))
  1512. {
  1513. text = " ";
  1514. }
  1515. NGUIText.Prepare(text);
  1516. float num = (float)NGUIText.fontSize * NGUIText.fontScale;
  1517. float num2 = 0f;
  1518. float num3 = 0f;
  1519. float num4 = 0f;
  1520. int length = text.Length;
  1521. int size = verts.size;
  1522. int prev = 0;
  1523. for (int i = 0; i < length; i++)
  1524. {
  1525. int num5 = (int)text[i];
  1526. if (num5 == 10)
  1527. {
  1528. if (num2 > num4)
  1529. {
  1530. num4 = num2;
  1531. }
  1532. if (NGUIText.alignment != NGUIText.Alignment.Left)
  1533. {
  1534. NGUIText.Align(verts, size, num2 - NGUIText.finalSpacingX);
  1535. size = verts.size;
  1536. }
  1537. num2 = 0f;
  1538. num3 += NGUIText.finalLineHeight;
  1539. prev = 0;
  1540. }
  1541. else if (num5 < 32)
  1542. {
  1543. prev = 0;
  1544. }
  1545. else if (NGUIText.encoding && NGUIText.ParseSymbol(text, ref i))
  1546. {
  1547. i--;
  1548. }
  1549. else
  1550. {
  1551. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  1552. if (bmsymbol == null)
  1553. {
  1554. float glyphWidth = NGUIText.GetGlyphWidth(num5, prev);
  1555. if (glyphWidth != 0f)
  1556. {
  1557. float num6 = glyphWidth + NGUIText.finalSpacingX;
  1558. if (Mathf.RoundToInt(num2 + num6) > NGUIText.regionWidth)
  1559. {
  1560. if (num2 == 0f)
  1561. {
  1562. return;
  1563. }
  1564. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1565. {
  1566. NGUIText.Align(verts, size, num2 - NGUIText.finalSpacingX);
  1567. size = verts.size;
  1568. }
  1569. num2 = 0f;
  1570. num3 += NGUIText.finalLineHeight;
  1571. prev = 0;
  1572. i--;
  1573. }
  1574. else
  1575. {
  1576. indices.Add(i);
  1577. verts.Add(new Vector3(num2, -num3 - num));
  1578. verts.Add(new Vector3(num2 + num6, -num3));
  1579. prev = num5;
  1580. num2 += num6;
  1581. }
  1582. }
  1583. }
  1584. else
  1585. {
  1586. float num7 = (float)bmsymbol.advance * NGUIText.fontScale + NGUIText.finalSpacingX;
  1587. if (Mathf.RoundToInt(num2 + num7) > NGUIText.regionWidth)
  1588. {
  1589. if (num2 == 0f)
  1590. {
  1591. return;
  1592. }
  1593. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1594. {
  1595. NGUIText.Align(verts, size, num2 - NGUIText.finalSpacingX);
  1596. size = verts.size;
  1597. }
  1598. num2 = 0f;
  1599. num3 += NGUIText.finalLineHeight;
  1600. prev = 0;
  1601. i--;
  1602. }
  1603. else
  1604. {
  1605. indices.Add(i);
  1606. verts.Add(new Vector3(num2, -num3 - num));
  1607. verts.Add(new Vector3(num2 + num7, -num3));
  1608. i += bmsymbol.sequence.Length - 1;
  1609. num2 += num7;
  1610. prev = 0;
  1611. }
  1612. }
  1613. }
  1614. }
  1615. if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
  1616. {
  1617. NGUIText.Align(verts, size, num2 - NGUIText.finalSpacingX);
  1618. }
  1619. }
  1620. public static void PrintCaretAndSelection(string text, int start, int end, BetterList<Vector3> caret, BetterList<Vector3> highlight)
  1621. {
  1622. if (string.IsNullOrEmpty(text))
  1623. {
  1624. text = " ";
  1625. }
  1626. NGUIText.Prepare(text);
  1627. int num = end;
  1628. if (start > end)
  1629. {
  1630. end = start;
  1631. start = num;
  1632. }
  1633. float num2 = 0f;
  1634. float num3 = 0f;
  1635. float num4 = 0f;
  1636. float num5 = (float)NGUIText.fontSize * NGUIText.fontScale;
  1637. int indexOffset = (caret == null) ? 0 : caret.size;
  1638. int num6 = (highlight == null) ? 0 : highlight.size;
  1639. int length = text.Length;
  1640. int i = 0;
  1641. int prev = 0;
  1642. bool flag = false;
  1643. bool flag2 = false;
  1644. Vector2 zero = Vector2.zero;
  1645. Vector2 zero2 = Vector2.zero;
  1646. while (i < length)
  1647. {
  1648. if (caret != null && !flag2 && num <= i)
  1649. {
  1650. flag2 = true;
  1651. caret.Add(new Vector3(num2 - 1f, -num3 - num5));
  1652. caret.Add(new Vector3(num2 - 1f, -num3));
  1653. caret.Add(new Vector3(num2 + 1f, -num3));
  1654. caret.Add(new Vector3(num2 + 1f, -num3 - num5));
  1655. }
  1656. int num7 = (int)text[i];
  1657. if (num7 == 10)
  1658. {
  1659. if (num2 > num4)
  1660. {
  1661. num4 = num2;
  1662. }
  1663. if (caret != null && flag2)
  1664. {
  1665. if (NGUIText.alignment != NGUIText.Alignment.Left)
  1666. {
  1667. NGUIText.Align(caret, indexOffset, num2 - NGUIText.finalSpacingX);
  1668. }
  1669. caret = null;
  1670. }
  1671. if (highlight != null)
  1672. {
  1673. if (flag)
  1674. {
  1675. flag = false;
  1676. highlight.Add(zero2);
  1677. highlight.Add(zero);
  1678. }
  1679. else if (start <= i && end > i)
  1680. {
  1681. highlight.Add(new Vector3(num2, -num3 - num5));
  1682. highlight.Add(new Vector3(num2, -num3));
  1683. highlight.Add(new Vector3(num2 + 2f, -num3));
  1684. highlight.Add(new Vector3(num2 + 2f, -num3 - num5));
  1685. }
  1686. if (NGUIText.alignment != NGUIText.Alignment.Left && num6 < highlight.size)
  1687. {
  1688. NGUIText.Align(highlight, num6, num2 - NGUIText.finalSpacingX);
  1689. num6 = highlight.size;
  1690. }
  1691. }
  1692. num2 = 0f;
  1693. num3 += NGUIText.finalLineHeight;
  1694. prev = 0;
  1695. }
  1696. else if (num7 < 32)
  1697. {
  1698. prev = 0;
  1699. }
  1700. else if (NGUIText.encoding && NGUIText.ParseSymbol(text, ref i))
  1701. {
  1702. i--;
  1703. }
  1704. else
  1705. {
  1706. BMSymbol bmsymbol = (!NGUIText.useSymbols) ? null : NGUIText.GetSymbol(text, i, length);
  1707. float num8 = (bmsymbol == null) ? NGUIText.GetGlyphWidth(num7, prev) : ((float)bmsymbol.advance * NGUIText.fontScale);
  1708. if (num8 != 0f)
  1709. {
  1710. float num9 = num2;
  1711. float num10 = num2 + num8;
  1712. float num11 = -num3 - num5;
  1713. float num12 = -num3;
  1714. if (Mathf.RoundToInt(num10 + NGUIText.finalSpacingX) > NGUIText.regionWidth)
  1715. {
  1716. if (num2 == 0f)
  1717. {
  1718. return;
  1719. }
  1720. if (num2 > num4)
  1721. {
  1722. num4 = num2;
  1723. }
  1724. if (caret != null && flag2)
  1725. {
  1726. if (NGUIText.alignment != NGUIText.Alignment.Left)
  1727. {
  1728. NGUIText.Align(caret, indexOffset, num2 - NGUIText.finalSpacingX);
  1729. }
  1730. caret = null;
  1731. }
  1732. if (highlight != null)
  1733. {
  1734. if (flag)
  1735. {
  1736. flag = false;
  1737. highlight.Add(zero2);
  1738. highlight.Add(zero);
  1739. }
  1740. else if (start <= i && end > i)
  1741. {
  1742. highlight.Add(new Vector3(num2, -num3 - num5));
  1743. highlight.Add(new Vector3(num2, -num3));
  1744. highlight.Add(new Vector3(num2 + 2f, -num3));
  1745. highlight.Add(new Vector3(num2 + 2f, -num3 - num5));
  1746. }
  1747. if (NGUIText.alignment != NGUIText.Alignment.Left && num6 < highlight.size)
  1748. {
  1749. NGUIText.Align(highlight, num6, num2 - NGUIText.finalSpacingX);
  1750. num6 = highlight.size;
  1751. }
  1752. }
  1753. num9 -= num2;
  1754. num10 -= num2;
  1755. num11 -= NGUIText.finalLineHeight;
  1756. num12 -= NGUIText.finalLineHeight;
  1757. num2 = 0f;
  1758. num3 += NGUIText.finalLineHeight;
  1759. }
  1760. num2 += num8 + NGUIText.finalSpacingX;
  1761. if (highlight != null)
  1762. {
  1763. if (start > i || end <= i)
  1764. {
  1765. if (flag)
  1766. {
  1767. flag = false;
  1768. highlight.Add(zero2);
  1769. highlight.Add(zero);
  1770. }
  1771. }
  1772. else if (!flag)
  1773. {
  1774. flag = true;
  1775. highlight.Add(new Vector3(num9, num11));
  1776. highlight.Add(new Vector3(num9, num12));
  1777. }
  1778. }
  1779. zero = new Vector2(num10, num11);
  1780. zero2 = new Vector2(num10, num12);
  1781. prev = num7;
  1782. }
  1783. }
  1784. i++;
  1785. }
  1786. if (caret != null)
  1787. {
  1788. if (!flag2)
  1789. {
  1790. caret.Add(new Vector3(num2 - 1f, -num3 - num5));
  1791. caret.Add(new Vector3(num2 - 1f, -num3));
  1792. caret.Add(new Vector3(num2 + 1f, -num3));
  1793. caret.Add(new Vector3(num2 + 1f, -num3 - num5));
  1794. }
  1795. if (NGUIText.alignment != NGUIText.Alignment.Left)
  1796. {
  1797. NGUIText.Align(caret, indexOffset, num2 - NGUIText.finalSpacingX);
  1798. }
  1799. }
  1800. if (highlight != null)
  1801. {
  1802. if (flag)
  1803. {
  1804. highlight.Add(zero2);
  1805. highlight.Add(zero);
  1806. }
  1807. else if (start < i && end == i)
  1808. {
  1809. highlight.Add(new Vector3(num2, -num3 - num5));
  1810. highlight.Add(new Vector3(num2, -num3));
  1811. highlight.Add(new Vector3(num2 + 2f, -num3));
  1812. highlight.Add(new Vector3(num2 + 2f, -num3 - num5));
  1813. }
  1814. if (NGUIText.alignment != NGUIText.Alignment.Left && num6 < highlight.size)
  1815. {
  1816. NGUIText.Align(highlight, num6, num2 - NGUIText.finalSpacingX);
  1817. }
  1818. }
  1819. }
  1820. public static UIFont bitmapFont;
  1821. public static Font dynamicFont;
  1822. public static NGUIText.GlyphInfo glyph = new NGUIText.GlyphInfo();
  1823. public static int fontSize = 16;
  1824. public static float fontScale = 1f;
  1825. public static float pixelDensity = 1f;
  1826. public static FontStyle fontStyle = FontStyle.Normal;
  1827. public static NGUIText.Alignment alignment = NGUIText.Alignment.Left;
  1828. public static Color tint = Color.white;
  1829. public static int rectWidth = 1000000;
  1830. public static int rectHeight = 1000000;
  1831. public static int regionWidth = 1000000;
  1832. public static int regionHeight = 1000000;
  1833. public static int maxLines = 0;
  1834. public static bool gradient = false;
  1835. public static Color gradientBottom = Color.white;
  1836. public static Color gradientTop = Color.white;
  1837. public static bool encoding = false;
  1838. public static float spacingX = 0f;
  1839. public static float spacingY = 0f;
  1840. public static bool premultiply = false;
  1841. public static NGUIText.SymbolStyle symbolStyle;
  1842. public static int finalSize = 0;
  1843. public static float finalSpacingX = 0f;
  1844. public static float finalLineHeight = 0f;
  1845. public static float baseline = 0f;
  1846. public static bool useSymbols = false;
  1847. private static Color mInvisible = new Color(0f, 0f, 0f, 0f);
  1848. private static BetterList<Color> mColors = new BetterList<Color>();
  1849. private static float mAlpha = 1f;
  1850. private static CharacterInfo mTempChar;
  1851. private static BetterList<float> mSizes = new BetterList<float>();
  1852. private static Color32 s_c0;
  1853. private static Color32 s_c1;
  1854. private static float[] mBoldOffset = new float[]
  1855. {
  1856. -0.25f,
  1857. 0f,
  1858. 0.25f,
  1859. 0f,
  1860. 0f,
  1861. -0.25f,
  1862. 0f,
  1863. 0.25f
  1864. };
  1865. public enum Alignment
  1866. {
  1867. Automatic,
  1868. Left,
  1869. Center,
  1870. Right,
  1871. Justified
  1872. }
  1873. public enum SymbolStyle
  1874. {
  1875. None,
  1876. Normal,
  1877. Colored
  1878. }
  1879. public class GlyphInfo
  1880. {
  1881. public Vector2 v0;
  1882. public Vector2 v1;
  1883. public Vector2 u0;
  1884. public Vector2 u1;
  1885. public Vector2 u2;
  1886. public Vector2 u3;
  1887. public float advance;
  1888. public int channel;
  1889. }
  1890. }