Font.measureText

Calculates the byte length which can be included within the specified width.

class Font
uint
measureText
(
string text
,
uint len
,
float width
,
float fontSize
,
float charSpace
,
float wordSpace
,,
float* realWidth
)

Parameters

text string

The text to use for calculation.

len uint

The length of the text.

width float

The width of the area to put the text.

fontSize float

The size of the font.

charSpace float

The character spacing.

wordSpace float

The word spacing.

wordWrap bool

Suppose there are three words: "ABCDE", "FGH", and "IJKL". Also, suppose the substring until "J" can be included within the width (12 bytes). If word_wrap is HPDF_FALSE the function returns 12. If word_wrap parameter is HPDF_TRUE, it returns 10 (the end of the previous word).

realWidth float*

If not NULL, parameter is set to the real width of the text. If NULL, parameter is ignored.

Return Value

Type: uint

On success, returns byte length which can be included within specified width. Otherwise, returns 0.

Meta