MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _fillText

Method _fillText

src/common/overlay/levelRenderer/Shape.js:833–862  ·  view source on GitHub ↗

* @function LevelRenderer.Shape.prototype._fillText * @description 填充文本

(ctx, text, x, y, textFont, textAlign, textBaseline)

Source from the content-addressed store, hash-verified

831 * @description 填充文本
832 */
833 static _fillText(ctx, text, x, y, textFont, textAlign, textBaseline) {
834 if (textFont) {
835 ctx.font = textFont;
836 }
837 ctx.textAlign = textAlign;
838 ctx.textBaseline = textBaseline;
839 var rect = Shape._getTextRect(
840 text, x, y, textFont, textAlign, textBaseline
841 );
842
843 text = (text + '').split('\n');
844
845 var lineHeight = SUtil.Util_area.getTextHeight('ZH', textFont);
846
847 switch (textBaseline) {
848 case 'top':
849 y = rect.y;
850 break;
851 case 'bottom':
852 y = rect.y + lineHeight;
853 break;
854 default:
855 y = rect.y + lineHeight / 2;
856 }
857
858 for (var i = 0, l = text.length; i < l; i++) {
859 ctx.fillText(text[i], x, y);
860 y += lineHeight;
861 }
862 }
863
864 /**
865 * @function LevelRenderer.Shape._getTextRect

Callers 1

drawTextMethod · 0.80

Calls 2

_getTextRectMethod · 0.80
getTextHeightMethod · 0.80

Tested by

no test coverage detected