text.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. var BoundingRect = require("../core/BoundingRect");
  2. var imageHelper = require("../graphic/helper/image");
  3. var _util = require("../core/util");
  4. var getContext = _util.getContext;
  5. var extend = _util.extend;
  6. var retrieve2 = _util.retrieve2;
  7. var retrieve3 = _util.retrieve3;
  8. var textWidthCache = {};
  9. var textWidthCacheCounter = 0;
  10. var TEXT_CACHE_MAX = 5000;
  11. var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
  12. var DEFAULT_FONT = '12px sans-serif'; // Avoid assign to an exported variable, for transforming to cjs.
  13. var methods = {};
  14. function $override(name, fn) {
  15. methods[name] = fn;
  16. }
  17. /**
  18. * @public
  19. * @param {string} text
  20. * @param {string} font
  21. * @return {number} width
  22. */
  23. function getWidth(text, font) {
  24. font = font || DEFAULT_FONT;
  25. var key = text + ':' + font;
  26. if (textWidthCache[key]) {
  27. return textWidthCache[key];
  28. }
  29. var textLines = (text + '').split('\n');
  30. var width = 0;
  31. for (var i = 0, l = textLines.length; i < l; i++) {
  32. // textContain.measureText may be overrided in SVG or VML
  33. width = Math.max(measureText(textLines[i], font).width, width);
  34. }
  35. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  36. textWidthCacheCounter = 0;
  37. textWidthCache = {};
  38. }
  39. textWidthCacheCounter++;
  40. textWidthCache[key] = width;
  41. return width;
  42. }
  43. /**
  44. * @public
  45. * @param {string} text
  46. * @param {string} font
  47. * @param {string} [textAlign='left']
  48. * @param {string} [textVerticalAlign='top']
  49. * @param {Array.<number>} [textPadding]
  50. * @param {Object} [rich]
  51. * @param {Object} [truncate]
  52. * @return {Object} {x, y, width, height, lineHeight}
  53. */
  54. function getBoundingRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) {
  55. return rich ? getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) : getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, truncate);
  56. }
  57. function getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, truncate) {
  58. var contentBlock = parsePlainText(text, font, textPadding, truncate);
  59. var outerWidth = getWidth(text, font);
  60. if (textPadding) {
  61. outerWidth += textPadding[1] + textPadding[3];
  62. }
  63. var outerHeight = contentBlock.outerHeight;
  64. var x = adjustTextX(0, outerWidth, textAlign);
  65. var y = adjustTextY(0, outerHeight, textVerticalAlign);
  66. var rect = new BoundingRect(x, y, outerWidth, outerHeight);
  67. rect.lineHeight = contentBlock.lineHeight;
  68. return rect;
  69. }
  70. function getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) {
  71. var contentBlock = parseRichText(text, {
  72. rich: rich,
  73. truncate: truncate,
  74. font: font,
  75. textAlign: textAlign,
  76. textPadding: textPadding
  77. });
  78. var outerWidth = contentBlock.outerWidth;
  79. var outerHeight = contentBlock.outerHeight;
  80. var x = adjustTextX(0, outerWidth, textAlign);
  81. var y = adjustTextY(0, outerHeight, textVerticalAlign);
  82. return new BoundingRect(x, y, outerWidth, outerHeight);
  83. }
  84. /**
  85. * @public
  86. * @param {number} x
  87. * @param {number} width
  88. * @param {string} [textAlign='left']
  89. * @return {number} Adjusted x.
  90. */
  91. function adjustTextX(x, width, textAlign) {
  92. // FIXME Right to left language
  93. if (textAlign === 'right') {
  94. x -= width;
  95. } else if (textAlign === 'center') {
  96. x -= width / 2;
  97. }
  98. return x;
  99. }
  100. /**
  101. * @public
  102. * @param {number} y
  103. * @param {number} height
  104. * @param {string} [textVerticalAlign='top']
  105. * @return {number} Adjusted y.
  106. */
  107. function adjustTextY(y, height, textVerticalAlign) {
  108. if (textVerticalAlign === 'middle') {
  109. y -= height / 2;
  110. } else if (textVerticalAlign === 'bottom') {
  111. y -= height;
  112. }
  113. return y;
  114. }
  115. /**
  116. * @public
  117. * @param {stirng} textPosition
  118. * @param {Object} rect {x, y, width, height}
  119. * @param {number} distance
  120. * @return {Object} {x, y, textAlign, textVerticalAlign}
  121. */
  122. function adjustTextPositionOnRect(textPosition, rect, distance) {
  123. var x = rect.x;
  124. var y = rect.y;
  125. var height = rect.height;
  126. var width = rect.width;
  127. var halfHeight = height / 2;
  128. var textAlign = 'left';
  129. var textVerticalAlign = 'top';
  130. switch (textPosition) {
  131. case 'left':
  132. x -= distance;
  133. y += halfHeight;
  134. textAlign = 'right';
  135. textVerticalAlign = 'middle';
  136. break;
  137. case 'right':
  138. x += distance + width;
  139. y += halfHeight;
  140. textVerticalAlign = 'middle';
  141. break;
  142. case 'top':
  143. x += width / 2;
  144. y -= distance;
  145. textAlign = 'center';
  146. textVerticalAlign = 'bottom';
  147. break;
  148. case 'bottom':
  149. x += width / 2;
  150. y += height + distance;
  151. textAlign = 'center';
  152. break;
  153. case 'inside':
  154. x += width / 2;
  155. y += halfHeight;
  156. textAlign = 'center';
  157. textVerticalAlign = 'middle';
  158. break;
  159. case 'insideLeft':
  160. x += distance;
  161. y += halfHeight;
  162. textVerticalAlign = 'middle';
  163. break;
  164. case 'insideRight':
  165. x += width - distance;
  166. y += halfHeight;
  167. textAlign = 'right';
  168. textVerticalAlign = 'middle';
  169. break;
  170. case 'insideTop':
  171. x += width / 2;
  172. y += distance;
  173. textAlign = 'center';
  174. break;
  175. case 'insideBottom':
  176. x += width / 2;
  177. y += height - distance;
  178. textAlign = 'center';
  179. textVerticalAlign = 'bottom';
  180. break;
  181. case 'insideTopLeft':
  182. x += distance;
  183. y += distance;
  184. break;
  185. case 'insideTopRight':
  186. x += width - distance;
  187. y += distance;
  188. textAlign = 'right';
  189. break;
  190. case 'insideBottomLeft':
  191. x += distance;
  192. y += height - distance;
  193. textVerticalAlign = 'bottom';
  194. break;
  195. case 'insideBottomRight':
  196. x += width - distance;
  197. y += height - distance;
  198. textAlign = 'right';
  199. textVerticalAlign = 'bottom';
  200. break;
  201. }
  202. return {
  203. x: x,
  204. y: y,
  205. textAlign: textAlign,
  206. textVerticalAlign: textVerticalAlign
  207. };
  208. }
  209. /**
  210. * Show ellipsis if overflow.
  211. *
  212. * @public
  213. * @param {string} text
  214. * @param {string} containerWidth
  215. * @param {string} font
  216. * @param {number} [ellipsis='...']
  217. * @param {Object} [options]
  218. * @param {number} [options.maxIterations=3]
  219. * @param {number} [options.minChar=0] If truncate result are less
  220. * then minChar, ellipsis will not show, which is
  221. * better for user hint in some cases.
  222. * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
  223. * @return {string}
  224. */
  225. function truncateText(text, containerWidth, font, ellipsis, options) {
  226. if (!containerWidth) {
  227. return '';
  228. }
  229. var textLines = (text + '').split('\n');
  230. options = prepareTruncateOptions(containerWidth, font, ellipsis, options); // FIXME
  231. // It is not appropriate that every line has '...' when truncate multiple lines.
  232. for (var i = 0, len = textLines.length; i < len; i++) {
  233. textLines[i] = truncateSingleLine(textLines[i], options);
  234. }
  235. return textLines.join('\n');
  236. }
  237. function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
  238. options = extend({}, options);
  239. options.font = font;
  240. var ellipsis = retrieve2(ellipsis, '...');
  241. options.maxIterations = retrieve2(options.maxIterations, 2);
  242. var minChar = options.minChar = retrieve2(options.minChar, 0); // FIXME
  243. // Other languages?
  244. options.cnCharWidth = getWidth('国', font); // FIXME
  245. // Consider proportional font?
  246. var ascCharWidth = options.ascCharWidth = getWidth('a', font);
  247. options.placeholder = retrieve2(options.placeholder, ''); // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
  248. // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
  249. var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
  250. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  251. contentWidth -= ascCharWidth;
  252. }
  253. var ellipsisWidth = getWidth(ellipsis);
  254. if (ellipsisWidth > contentWidth) {
  255. ellipsis = '';
  256. ellipsisWidth = 0;
  257. }
  258. contentWidth = containerWidth - ellipsisWidth;
  259. options.ellipsis = ellipsis;
  260. options.ellipsisWidth = ellipsisWidth;
  261. options.contentWidth = contentWidth;
  262. options.containerWidth = containerWidth;
  263. return options;
  264. }
  265. function truncateSingleLine(textLine, options) {
  266. var containerWidth = options.containerWidth;
  267. var font = options.font;
  268. var contentWidth = options.contentWidth;
  269. if (!containerWidth) {
  270. return '';
  271. }
  272. var lineWidth = getWidth(textLine, font);
  273. if (lineWidth <= containerWidth) {
  274. return textLine;
  275. }
  276. for (var j = 0;; j++) {
  277. if (lineWidth <= contentWidth || j >= options.maxIterations) {
  278. textLine += options.ellipsis;
  279. break;
  280. }
  281. var subLength = j === 0 ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth) : lineWidth > 0 ? Math.floor(textLine.length * contentWidth / lineWidth) : 0;
  282. textLine = textLine.substr(0, subLength);
  283. lineWidth = getWidth(textLine, font);
  284. }
  285. if (textLine === '') {
  286. textLine = options.placeholder;
  287. }
  288. return textLine;
  289. }
  290. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  291. var width = 0;
  292. var i = 0;
  293. for (var len = text.length; i < len && width < contentWidth; i++) {
  294. var charCode = text.charCodeAt(i);
  295. width += 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth;
  296. }
  297. return i;
  298. }
  299. /**
  300. * @public
  301. * @param {string} font
  302. * @return {number} line height
  303. */
  304. function getLineHeight(font) {
  305. // FIXME A rough approach.
  306. return getWidth('国', font);
  307. }
  308. /**
  309. * @public
  310. * @param {string} text
  311. * @param {string} font
  312. * @return {Object} width
  313. */
  314. function measureText(text, font) {
  315. return methods.measureText(text, font);
  316. } // Avoid assign to an exported variable, for transforming to cjs.
  317. methods.measureText = function (text, font) {
  318. var ctx = getContext();
  319. ctx.font = font || DEFAULT_FONT;
  320. return ctx.measureText(text);
  321. };
  322. /**
  323. * @public
  324. * @param {string} text
  325. * @param {string} font
  326. * @param {Object} [truncate]
  327. * @return {Object} block: {lineHeight, lines, height, outerHeight}
  328. * Notice: for performance, do not calculate outerWidth util needed.
  329. */
  330. function parsePlainText(text, font, padding, truncate) {
  331. text != null && (text += '');
  332. var lineHeight = getLineHeight(font);
  333. var lines = text ? text.split('\n') : [];
  334. var height = lines.length * lineHeight;
  335. var outerHeight = height;
  336. if (padding) {
  337. outerHeight += padding[0] + padding[2];
  338. }
  339. if (text && truncate) {
  340. var truncOuterHeight = truncate.outerHeight;
  341. var truncOuterWidth = truncate.outerWidth;
  342. if (truncOuterHeight != null && outerHeight > truncOuterHeight) {
  343. text = '';
  344. lines = [];
  345. } else if (truncOuterWidth != null) {
  346. var options = prepareTruncateOptions(truncOuterWidth - (padding ? padding[1] + padding[3] : 0), font, truncate.ellipsis, {
  347. minChar: truncate.minChar,
  348. placeholder: truncate.placeholder
  349. }); // FIXME
  350. // It is not appropriate that every line has '...' when truncate multiple lines.
  351. for (var i = 0, len = lines.length; i < len; i++) {
  352. lines[i] = truncateSingleLine(lines[i], options);
  353. }
  354. }
  355. }
  356. return {
  357. lines: lines,
  358. height: height,
  359. outerHeight: outerHeight,
  360. lineHeight: lineHeight
  361. };
  362. }
  363. /**
  364. * For example: 'some text {a|some text}other text{b|some text}xxx{c|}xxx'
  365. * Also consider 'bbbb{a|xxx\nzzz}xxxx\naaaa'.
  366. *
  367. * @public
  368. * @param {string} text
  369. * @param {Object} style
  370. * @return {Object} block
  371. * {
  372. * width,
  373. * height,
  374. * lines: [{
  375. * lineHeight,
  376. * width,
  377. * tokens: [[{
  378. * styleName,
  379. * text,
  380. * width, // include textPadding
  381. * height, // include textPadding
  382. * textWidth, // pure text width
  383. * textHeight, // pure text height
  384. * lineHeihgt,
  385. * font,
  386. * textAlign,
  387. * textVerticalAlign
  388. * }], [...], ...]
  389. * }, ...]
  390. * }
  391. * If styleName is undefined, it is plain text.
  392. */
  393. function parseRichText(text, style) {
  394. var contentBlock = {
  395. lines: [],
  396. width: 0,
  397. height: 0
  398. };
  399. text != null && (text += '');
  400. if (!text) {
  401. return contentBlock;
  402. }
  403. var lastIndex = STYLE_REG.lastIndex = 0;
  404. var result;
  405. while ((result = STYLE_REG.exec(text)) != null) {
  406. var matchedIndex = result.index;
  407. if (matchedIndex > lastIndex) {
  408. pushTokens(contentBlock, text.substring(lastIndex, matchedIndex));
  409. }
  410. pushTokens(contentBlock, result[2], result[1]);
  411. lastIndex = STYLE_REG.lastIndex;
  412. }
  413. if (lastIndex < text.length) {
  414. pushTokens(contentBlock, text.substring(lastIndex, text.length));
  415. }
  416. var lines = contentBlock.lines;
  417. var contentHeight = 0;
  418. var contentWidth = 0; // For `textWidth: 100%`
  419. var pendingList = [];
  420. var stlPadding = style.textPadding;
  421. var truncate = style.truncate;
  422. var truncateWidth = truncate && truncate.outerWidth;
  423. var truncateHeight = truncate && truncate.outerHeight;
  424. if (stlPadding) {
  425. truncateWidth != null && (truncateWidth -= stlPadding[1] + stlPadding[3]);
  426. truncateHeight != null && (truncateHeight -= stlPadding[0] + stlPadding[2]);
  427. } // Calculate layout info of tokens.
  428. for (var i = 0; i < lines.length; i++) {
  429. var line = lines[i];
  430. var lineHeight = 0;
  431. var lineWidth = 0;
  432. for (var j = 0; j < line.tokens.length; j++) {
  433. var token = line.tokens[j];
  434. var tokenStyle = token.styleName && style.rich[token.styleName] || {}; // textPadding should not inherit from style.
  435. var textPadding = token.textPadding = tokenStyle.textPadding; // textFont has been asigned to font by `normalizeStyle`.
  436. var font = token.font = tokenStyle.font || style.font; // textHeight can be used when textVerticalAlign is specified in token.
  437. var tokenHeight = token.textHeight = retrieve2( // textHeight should not be inherited, consider it can be specified
  438. // as box height of the block.
  439. tokenStyle.textHeight, getLineHeight(font));
  440. textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
  441. token.height = tokenHeight;
  442. token.lineHeight = retrieve3(tokenStyle.textLineHeight, style.textLineHeight, tokenHeight);
  443. token.textAlign = tokenStyle && tokenStyle.textAlign || style.textAlign;
  444. token.textVerticalAlign = tokenStyle && tokenStyle.textVerticalAlign || 'middle';
  445. if (truncateHeight != null && contentHeight + token.lineHeight > truncateHeight) {
  446. return {
  447. lines: [],
  448. width: 0,
  449. height: 0
  450. };
  451. }
  452. token.textWidth = getWidth(token.text, font);
  453. var tokenWidth = tokenStyle.textWidth;
  454. var tokenWidthNotSpecified = tokenWidth == null || tokenWidth === 'auto'; // Percent width, can be `100%`, can be used in drawing separate
  455. // line when box width is needed to be auto.
  456. if (typeof tokenWidth === 'string' && tokenWidth.charAt(tokenWidth.length - 1) === '%') {
  457. token.percentWidth = tokenWidth;
  458. pendingList.push(token);
  459. tokenWidth = 0; // Do not truncate in this case, because there is no user case
  460. // and it is too complicated.
  461. } else {
  462. if (tokenWidthNotSpecified) {
  463. tokenWidth = token.textWidth; // FIXME: If image is not loaded and textWidth is not specified, calling
  464. // `getBoundingRect()` will not get correct result.
  465. var textBackgroundColor = tokenStyle.textBackgroundColor;
  466. var bgImg = textBackgroundColor && textBackgroundColor.image; // Use cases:
  467. // (1) If image is not loaded, it will be loaded at render phase and call
  468. // `dirty()` and `textBackgroundColor.image` will be replaced with the loaded
  469. // image, and then the right size will be calculated here at the next tick.
  470. // See `graphic/helper/text.js`.
  471. // (2) If image loaded, and `textBackgroundColor.image` is image src string,
  472. // use `imageHelper.findExistImage` to find cached image.
  473. // `imageHelper.findExistImage` will always be called here before
  474. // `imageHelper.createOrUpdateImage` in `graphic/helper/text.js#renderRichText`
  475. // which ensures that image will not be rendered before correct size calcualted.
  476. if (bgImg) {
  477. bgImg = imageHelper.findExistImage(bgImg);
  478. if (imageHelper.isImageReady(bgImg)) {
  479. tokenWidth = Math.max(tokenWidth, bgImg.width * tokenHeight / bgImg.height);
  480. }
  481. }
  482. }
  483. var paddingW = textPadding ? textPadding[1] + textPadding[3] : 0;
  484. tokenWidth += paddingW;
  485. var remianTruncWidth = truncateWidth != null ? truncateWidth - lineWidth : null;
  486. if (remianTruncWidth != null && remianTruncWidth < tokenWidth) {
  487. if (!tokenWidthNotSpecified || remianTruncWidth < paddingW) {
  488. token.text = '';
  489. token.textWidth = tokenWidth = 0;
  490. } else {
  491. token.text = truncateText(token.text, remianTruncWidth - paddingW, font, truncate.ellipsis, {
  492. minChar: truncate.minChar
  493. });
  494. token.textWidth = getWidth(token.text, font);
  495. tokenWidth = token.textWidth + paddingW;
  496. }
  497. }
  498. }
  499. lineWidth += token.width = tokenWidth;
  500. tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));
  501. }
  502. line.width = lineWidth;
  503. line.lineHeight = lineHeight;
  504. contentHeight += lineHeight;
  505. contentWidth = Math.max(contentWidth, lineWidth);
  506. }
  507. contentBlock.outerWidth = contentBlock.width = retrieve2(style.textWidth, contentWidth);
  508. contentBlock.outerHeight = contentBlock.height = retrieve2(style.textHeight, contentHeight);
  509. if (stlPadding) {
  510. contentBlock.outerWidth += stlPadding[1] + stlPadding[3];
  511. contentBlock.outerHeight += stlPadding[0] + stlPadding[2];
  512. }
  513. for (var i = 0; i < pendingList.length; i++) {
  514. var token = pendingList[i];
  515. var percentWidth = token.percentWidth; // Should not base on outerWidth, because token can not be placed out of padding.
  516. token.width = parseInt(percentWidth, 10) / 100 * contentWidth;
  517. }
  518. return contentBlock;
  519. }
  520. function pushTokens(block, str, styleName) {
  521. var isEmptyStr = str === '';
  522. var strs = str.split('\n');
  523. var lines = block.lines;
  524. for (var i = 0; i < strs.length; i++) {
  525. var text = strs[i];
  526. var token = {
  527. styleName: styleName,
  528. text: text,
  529. isLineHolder: !text && !isEmptyStr
  530. }; // The first token should be appended to the last line.
  531. if (!i) {
  532. var tokens = (lines[lines.length - 1] || (lines[0] = {
  533. tokens: []
  534. })).tokens; // Consider cases:
  535. // (1) ''.split('\n') => ['', '\n', ''], the '' at the first item
  536. // (which is a placeholder) should be replaced by new token.
  537. // (2) A image backage, where token likes {a|}.
  538. // (3) A redundant '' will affect textAlign in line.
  539. // (4) tokens with the same tplName should not be merged, because
  540. // they should be displayed in different box (with border and padding).
  541. var tokensLen = tokens.length;
  542. tokensLen === 1 && tokens[0].isLineHolder ? tokens[0] = token : // Consider text is '', only insert when it is the "lineHolder" or
  543. // "emptyStr". Otherwise a redundant '' will affect textAlign in line.
  544. (text || !tokensLen || isEmptyStr) && tokens.push(token);
  545. } // Other tokens always start a new line.
  546. else {
  547. // If there is '', insert it as a placeholder.
  548. lines.push({
  549. tokens: [token]
  550. });
  551. }
  552. }
  553. }
  554. function makeFont(style) {
  555. // FIXME in node-canvas fontWeight is before fontStyle
  556. // Use `fontSize` `fontFamily` to check whether font properties are defined.
  557. return (style.fontSize || style.fontFamily) && [style.fontStyle, style.fontWeight, (style.fontSize || 12) + 'px', // If font properties are defined, `fontFamily` should not be ignored.
  558. style.fontFamily || 'sans-serif'].join(' ') || style.textFont || style.font;
  559. }
  560. exports.DEFAULT_FONT = DEFAULT_FONT;
  561. exports.$override = $override;
  562. exports.getWidth = getWidth;
  563. exports.getBoundingRect = getBoundingRect;
  564. exports.adjustTextX = adjustTextX;
  565. exports.adjustTextY = adjustTextY;
  566. exports.adjustTextPositionOnRect = adjustTextPositionOnRect;
  567. exports.truncateText = truncateText;
  568. exports.getLineHeight = getLineHeight;
  569. exports.measureText = measureText;
  570. exports.parsePlainText = parsePlainText;
  571. exports.parseRichText = parseRichText;
  572. exports.makeFont = makeFont;