Module ui.rendertext

Text rendering module.

Functions

RenderText:getGlyph (face, charcode[, bold=false]) Returns a rendered glyph
RenderText:getSubTextByWidth (text, face, width[, kerning=false[, bold=false]]) Returns a substring of a given text that meets the maximum width (in pixels) restriction.
RenderText:sizeUtf8Text (x, width, face, text[, kerning=false[, bold=false]]) Measure rendered size for a given text.
RenderText:renderUtf8Text (dest_bb, x, baseline, face, text[, kerning=false[, bold=false[, fgcolor=Blitbuffer.COLOR_BLACK[, width=nil[, char_pads]]]]]) Render a given text into a given BlitBuffer
RenderText:truncateTextByWidth (text, face, width[, kerning=false[, bold=false]]) Returns a substring of a given text that meets the maximum width (in pixels) restriction with ellipses (…) at the end if required.
RenderText:getGlyphByIndex (face, glyph[, bold=false[, bolder=false]]) Returns a rendered glyph by glyph index xtext/Harfbuzz, after shaping, gives glyph indexes in the font, which is usually different from the unicode codepoint of the original char)

Tables

RenderTextSize RenderText size information


Functions

RenderText:getGlyph (face, charcode[, bold=false])
Returns a rendered glyph

Parameters:

  • face ui.font.FontFaceObj font face for the text
  • charcode integer
  • bold boolean whether the text should be measured as bold (default false)

Returns:

    glyph
RenderText:getSubTextByWidth (text, face, width[, kerning=false[, bold=false]])
Returns a substring of a given text that meets the maximum width (in pixels) restriction.

Parameters:

  • text string text to truncate
  • face ui.font.FontFaceObj font face for the text
  • width integer maximum width in pixels
  • kerning boolean whether the text should be measured with kerning (default false)
  • bold boolean whether the text should be measured as bold (default false)

Returns:

    string

See also:

RenderText:sizeUtf8Text (x, width, face, text[, kerning=false[, bold=false]])
Measure rendered size for a given text.

Note this function does not render the text into a bitmap. Use it if you only need the estimated size information.

Parameters:

  • x integer start position for a given text (within maximum width)
  • width integer maximum rendering width in pixels (think of it as size of the bitmap)
  • face ui.font.FontFaceObj font face that will be used for rendering
  • text string text to measure
  • kerning boolean whether the text should be measured with kerning (default false)
  • bold boolean whether the text should be measured as bold (default false)

Returns:

    RenderTextSize
RenderText:renderUtf8Text (dest_bb, x, baseline, face, text[, kerning=false[, bold=false[, fgcolor=Blitbuffer.COLOR_BLACK[, width=nil[, char_pads]]]]])
Render a given text into a given BlitBuffer

Parameters:

  • dest_bb BlitBuffer Buffer to blit into
  • x integer starting x coordinate position within dest_bb
  • baseline integer y coordinate for baseline, within dest_bb
  • face ui.font.FontFaceObj font face that will be used for rendering
  • text string text to render
  • kerning boolean whether the text should be measured with kerning (default false)
  • bold boolean whether the text should be measured as bold (default false)
  • fgcolor Blitbuffer.COLOR foreground color (default Blitbuffer.COLOR_BLACK)
  • width integer maximum rendering width (default nil)
  • char_pads table array of integers, nb of pixels to add, one for each utf8 char in text (optional)

Returns:

    int width of rendered bitmap
RenderText:truncateTextByWidth (text, face, width[, kerning=false[, bold=false]])
Returns a substring of a given text that meets the maximum width (in pixels) restriction with ellipses (…) at the end if required.

Parameters:

  • text string text to truncate
  • face ui.font.FontFaceObj font face for the text
  • width integer maximum width in pixels
  • kerning boolean whether the text should be measured with kerning (default false)
  • bold boolean whether the text should be measured as bold (default false)

Returns:

    string

See also:

RenderText:getGlyphByIndex (face, glyph[, bold=false[, bolder=false]])
Returns a rendered glyph by glyph index xtext/Harfbuzz, after shaping, gives glyph indexes in the font, which is usually different from the unicode codepoint of the original char)

Parameters:

  • face ui.font.FontFaceObj font face for the text
  • glyph integer index
  • bold boolean whether the glyph should be artificially boldened (default false)
  • bolder boolean whether the glyph should be even more artificially boldened (can stack with bold, but can also be used solo) (default false)

Returns:

    glyph

Tables

RenderTextSize
RenderText size information

Fields:

  • x length of the text on x coordinate
  • y_top distance between top-most pixel (scanline) and baseline (bearingY)
  • y_bottom distance between bottom-most pixel (scanline) and baseline (height - y_top)
generated by LDoc 1.5.0 Last updated 2024-11-21 07:57:34