the text that was measured
the style that was measured
the measured width of the text
the measured height of the text
an array of the lines of text broken by new lines and wrapping if specified in style
an array of the line widths for each line matched to lines
the measured line height for this style
the maximum line width for all measured lines
the font properties object from TextMetrics.measureFont
The font properties object from TextMetrics.measureFont
测量出的高度。
The measured line height for this style
An array of the line widths for each line matched to lines
根据样式分割成的多行文本。
The maximum line width for all measured lines
被测量的样式。
被测量的文本。
测量出的宽度。
Static
BASELINE_Baseline multiplier for calculate font metrics.
Static
BASELINE_Baseline symbol for calculate font metrics.
Static
METRICS_String used for calculate font metrics. These characters are all tall to help calculate the height required for text.
Static
_breakingCache of breaking spaces.
Static
_canvasCached canvas element for measuring text
Static
_contextCache for context to use.
Static
_fontsCache of {@see PIXI.TextMetrics.FontMetrics} objects.
Static
_newlinesCache of new line chars.
Static
Private
addStatic
canOverridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
It allows one to determine whether a pair of characters should be broken by newlines For example certain characters in CJK langs or numbers. It must return a boolean.
whether to break word or not
The character
The next character
The token/word the characters are from
The index in the token of the char
The style attr break words
Static
canOverridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
It allows one to customise which words should break Examples are if the token is CJK or numbers. It must return a boolean.
whether to break word or not
The token
The style attr break words
Static
clearStatic
Private
collapseStatic
Private
collapseStatic
Private
getPrivate
Gets & sets the widths of calculated characters in a cache object
The from cache.
The key
The letter spacing
The cache
The canvas context
Static
Private
isStatic
Private
isStatic
measureCalculates the ascent, descent and fontSize of a given font-style
Font properties object
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textBaseline
String representing the style of the font
Static
measureMeasures the supplied string of text and returns a Rectangle.
measured width and height of the text.
the text to measure.
the text style to use for measuring
optional override for if word-wrap should be applied to the text.
optional specification of the canvas to use for measuring.
Static
Private
tokenizeStatic
Private
trimStatic
Private
wordPrivate
Applies newlines to a string to have it optimally fit into the horizontal bounds set by the Text object's wordWrapWidth property.
New string with new lines applied where required
String to apply word wrapping to
the style to use when wrapping
optional specification of the canvas to use for measuring.
Static
wordOverridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
It is called when a token (usually a word) has to be split into separate pieces in order to determine the point to break a word. It must return an array of characters.
// Correctly splits emojis, eg "🤪🤪" will result in two element array, each with one emoji.
TextMetrics.wordWrapSplit = (token) => [...token];
The characters of the token
The token to split
Generated using TypeDoc
文本度量
用于度量指定样式的文本的宽度。
从pixi.js移植
See
https://github.com/pixijs/pixi.js/blob/dev/packages/text/src/TextMetrics.js