Package ro.sync.exml.view.graphics
Interface FontMetrics
@API(type=NOT_EXTENDABLE,
src=PRIVATE)
public interface FontMetrics
Common font metrics
-
Method Summary
Modifier and TypeMethodDescriptionintcharsWidth(char[] chars, int off, int len) Returns the total advance width for showing the specified array of characters in thisFont.intcharWidth(char c) Get the char widthintThe font ascent is the distance from the font's baseline to the top of most alphanumeric characters.intgetCorrectedBreakYForWrappedString(AttributedString aStr, int wrappingWidth, int initialBreak) Gets the y coordinate where the given wrapped string bounds can be split without cutting off a text line.intThe font descent is the distance from the font's baseline to the bottom of most alphanumeric characters with descenders.intintDetermines the standard leading of theFontdescribed by thisFontMetricsobject.default intGet the maximum character width, -1 if not implemented.getWrappedStringBounds(AttributedString aStr, int wrappingWidth) Gets the bounds of a string that is wrapped at the wrappingWidth.limitAttributedString(AttributedString aStr, int wrappingWidth, int maxLineCount) Limit the given attributed string at a maximum number of lines.intstringWidth(String text) Returns the total advance width for showing the specifiedStringin thisFont.
-
Method Details
-
charsWidth
int charsWidth(char[] chars, int off, int len) Returns the total advance width for showing the specified array of characters in thisFont.- Parameters:
chars- the array of characters to be measuredoff- the start offset of the characters in the arraylen- the number of characters to be measured from the array- Returns:
- the advance width of the subarray of the specified
chararray in the font described by thisFontMetricsobject.
-
getAscent
int getAscent()The font ascent is the distance from the font's baseline to the top of most alphanumeric characters.- Returns:
- The font ascent.
-
getDescent
int getDescent()The font descent is the distance from the font's baseline to the bottom of most alphanumeric characters with descenders.- Returns:
- The ont descent.
-
stringWidth
Returns the total advance width for showing the specifiedStringin thisFont.- Parameters:
text- The text.- Returns:
- The width of the text.
-
getHeight
int getHeight()- Returns:
- The font height
-
charWidth
int charWidth(char c) Get the char width- Parameters:
c- The char- Returns:
- The char width
-
getLeading
int getLeading()Determines the standard leading of theFontdescribed by thisFontMetricsobject. The standard leading, or interline spacing, is the logical amount of space to be reserved between the descent of one line of text and the ascent of the next line. The height metric is calculated to include this extra space.- Returns:
- the standard leading of the
Font.
-
getWrappedStringBounds
Gets the bounds of a string that is wrapped at the wrappingWidth. Takes into account newlines. -
limitAttributedString
AttributedString[] limitAttributedString(AttributedString aStr, int wrappingWidth, int maxLineCount) Limit the given attributed string at a maximum number of lines.- Parameters:
aStr- The text, as an attributed string. The {TextAttribute#FONT} and {TextAttribute#FOREGROUND} contain values that are instances ofFontandColor.wrappingWidth- The maximum width of the text.maxLineCount- The maximum number of lines.- Returns:
- The array of attributed strings, one for each line of text (if the given attributed string overflows the maximum number of lines) or the initial attributed string (if there is no overflow)
-
getCorrectedBreakYForWrappedString
Gets the y coordinate where the given wrapped string bounds can be split without cutting off a text line. If the given initial break Y is inside a text line, the resulting break will point to the top of the text line. Otherwise-1is returned.- Parameters:
aStr- The text, as an attributed string. The {TextAttribute#FONT} and {TextAttribute#FOREGROUND} contain values that are instances ofFontandColor.wrappingWidth- The maximum width of the text.initialBreak- The initial break Y coordinate.- Returns:
- The corrected Y break coordinate or
-1if the initial break is not placed inside a text line.
-
getMaxCharWidth
default int getMaxCharWidth()Get the maximum character width, -1 if not implemented.- Returns:
- the maximum character width, -1 if not implemented.
-