libgpac
Documentation of the core library of GPAC
Text Interface Reference

import"evg.idl";

Public Member Functions

 Text ()
 
void set_text (...)
 
TextMeasure measure ()
 
Path get_path (optional bool centered_coords=true)
 

Data Fields

attribute Array font
 
attribute double fontsize
 
attribute unsigned long align
 
attribute unsigned long baseline
 
attribute boolean horizontal
 
attribute boolean flip
 
attribute boolean underline
 
attribute boolean bold
 
attribute boolean italic
 
attribute double maxWidth
 
attribute double lineSpacing
 

Detailed Description

Text object

Constructor & Destructor Documentation

◆ Text()

Text::Text ( )

constructor. The default text is created with a font size of 12, horizontal drawing, start alignment and alphabetic baseline.

Member Function Documentation

◆ set_text()

void Text::set_text (   ...)

sets text. Each argument is processed as follows:

  • if the argument is an Array, process each item of the array as an element
  • otherwise process argument as an element

Each element is treated as follows:

  • transformed to string, whether it is a string, number, object / array
  • split in one or several text lines, scanning new line character 'CR'
  • each line of text is then transformed into a graphics path with the current text settings.

◆ measure()

TextMeasure Text::measure ( )

gets metrics for the text lines

Returns
text metrics

◆ get_path()

Path Text::get_path ( optional bool  centered_coords = true)

gets a copy of the path data of the text. Usually only needed to do some path outlining of glyphs

Parameters
centered_coordsindicate of the path will be drawn on a centered coords surface. This is needed to perform final layout of text
Returns
copy of text path data

Field Documentation

◆ font

attribute Array Text::font

font name - array or single string value. If array, fonts in array will be checked until one is found The text must be set again whenever the font is changing !

◆ fontsize

attribute double Text::fontsize

font name

◆ align

attribute unsigned long Text::align

align flag for horizontal positioning (see Canvas2D). Alignment is computed on maximum text line width after application of maxWidth if any/needed

  • GF_TEXT_ALIGN_START: left if text is left to right, right otherwise
  • GF_TEXT_ALIGN_END: right if text is left to right, left otherwise
  • GF_TEXT_ALIGN_LEFT: left
  • GF_TEXT_ALIGN_RIGHT: right
  • GF_TEXT_ALIGN_CENTER: center

◆ baseline

attribute unsigned long Text::baseline

baseline flag for vertical positioning (see Canvas2D):

  • GF_TEXT_BASELINE_TOP: top of EM box
  • GF_TEXT_BASELINE_HANGING: hanging (usually not available in fonts)
  • GF_TEXT_BASELINE_MIDDLE: middle of EM box
  • GF_TEXT_BASELINE_ALPHABETIC: baseline of font (default value)
  • GF_TEXT_BASELINE_IDEOGRAPHIC: not supported, same as GF_TEXT_BASELINE_ALPHABETIC.
  • GF_TEXT_BASELINE_BOTTOM: bottom of EM box

◆ horizontal

attribute boolean Text::horizontal

text is horizontal

◆ flip

attribute boolean Text::flip

text shoud be filpped while drawing

◆ underline

attribute boolean Text::underline

text shoud be underlined while drawing (not supported)

◆ bold

attribute boolean Text::bold

text shoud be bold (used when checking for font alternates)

◆ italic

attribute boolean Text::italic

text shoud be italic (used when checking for font alternates)

◆ maxWidth

attribute double Text::maxWidth

maximum width of text in local coordinate system (with no matrix transformations)

◆ lineSpacing

attribute double Text::lineSpacing

line spacing. If 0, the font's default line spacing is used