Home  Contents

Font Size

Graphics Core4 Lua Commands

SYNOPSIS

  1. x = fnt:ascent()
  2. x = fnt:descent()
  3. x = fnt:height()
  4. x = fnt:lbearing(ch)
  5. x = fnt:rbearing(ch)
  6. x = fnt:maxwidth()
  7. x = fnt:minwidth()
  8. x = fnt:width(arg)
  9. x = fnt:cwidth(arg)

DESCRIPTION

A group of methods for querying various text size properties.
fnt:ascent() Number of pixels above the baseline.
fnt:descent() Number of pixels below the baseline.
fnt:height() The total height of the font. fnt:height() equals fnt:ascent() + fnt:descent() + 1.
fnt:lbearing(ch)
fnt:rbearing(ch)
Returns the size of the left/right bearing of the glyph with the character code ch. If a bearing is positive, this is the number of blank pixel columns on the respective side of the glyph. If a bearing is negative, the glyph overlaps the neighboring glyph by that many pixels. If the character is not defined in the font, returns nil.
fnt:maxwidth()
fnt:minwidth()
Returns the size of the widest/narrowest glyph in the font. For fixed width fonts, both values are the same.
fnt:width(str) Returns the width of the rendered text interpreted as UTF8. Note that the text renderer replaces characters that are not defined in the font with a replacement glyph. This replacement also happens for the width calculation.
fnt:cwidth(ch) Returns the width of the glyph with character code ch. For fixed width fonts, this is the same for all glyphs. If the character is not defined in the font, returns nil.

ERRORS

Raises an error if fnt is not a font handle.

EXAMPLE

>  > 
fnt = gfx.default_font() print (fnt:minwidth(), fnt:maxwidth(), fnt:height(), fnt:ascent(), fnt:descent())
8 8 16 12 3

SEE ALSO