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[, prepend_space=false]]]) Returns a substring of a given text that meets the maximum width (in pixels) restriction with ellipses (…) at the end if required.

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 int
  • bold bool 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 int maximum width in pixels
  • kerning bool whether the text should be measured with kerning (default false)
  • bold bool 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 int start position for a given text (within maximum width)
  • width int 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 bool whether the text should be measured with kerning (default false)
  • bold bool 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 int starting x coordinate position within dest_bb
  • baseline int 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 bool whether the text should be measured with kerning (default false)
  • bold bool whether the text should be measured as bold (default false)
  • fgcolor BlitBuffer.COLOR foreground color (default BlitBuffer.COLOR_BLACK)
  • width int 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[, prepend_space=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 int maximum width in pixels
  • kerning bool whether the text should be measured with kerning (default false)
  • bold bool whether the text should be measured as bold (default false)
  • prepend_space bool whether a space should be prepended to the text (default false)

Returns:

    string

See also:

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.4.6 Last updated 2017-10-08 14:57:40