Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 727

Previous Page 726   Index   Next Page 728

Function Reference
Page 727 of 750
TranslateRawCode (Font API)
UI32 fntTranslateRawCode(
const void* IFont,
// Pointer of the active font
const BYTE* Text,
// Raw text to be converted
UI32 Len,
// Text length in bytes
double ADDR Width,
// The width of the character
UI16 OutText[32],
// Static Unicode output buffer
SI32 ADDR OutLen,
// Number of characters copied to OutText
LBOOL ADDR Decoded, // If false, Width, OutText, OutLen must be ignored
float CharSpacing,
// Current character spacing
float WordSpacing,
// Current word spacing
float TextScale)
// Current text scaling
The function converts a source character to Unicode. The code length of a character depends on the
font's encoding. PDF supports encodings with fixed and variable code lengths from one through four
bytes per character. The return value is the number of bytes which were consumed to convert the
character to Unicode; this value must be used to increment the text pointer and to decrement the
remaining text length.
The resulting Unicode character or sequence is stored in the parameter OutText, as well as the
corresponding output text length and the character width.
The parameter Decoded is set to true if the source character could be sucsessfully converted to
Unicode. If Decode is false the output string and character width contain no meaningful values.
The function can only fail when processing strings of CID fonts, e.g. if the font depends on an
external CMap that could not be loaded, or if the font uses a damaged CMap. The search path(s) to
external CMaps should always be set before extracting text from PDF files with SetCMapDir().
Passing an invalid or undefined code sequence to the function does not result in an error. In this case
the notdef character is added to the output string (this is usually 0 or 0xFFFD if the font contains a
ToUnicode CMap).
To improve processing speed the function does not check whether the parameters are valid.
This function was designed to convert raw strings on a per character basis to Unicode which were
returned by ParseContent() or GetPageText(). The parameters CharSpacing, WordSpacing, and
TextScale must be taken from the current graphics state or from the structure TPDFStack.
Return values:
The return value of this function is always greater or equal to one. Check the parameter Decoded to
determine whether the function succeed.

Previous topic: TranslateCoords

Next topic: TranslateString (obsolete)