API referenceFonts

fntTranslateRawCode

Decode raw show-string bytes (from a PFNT snapshot's font)

CategoryFont-object decoding

Purpose — Decode raw show-string bytes (from a PFNT snapshot's font) into Unicode text plus the advance width, in one call.

Description — For a 2-byte (Type0/CID) font, decodes big-endian code pairs; for a UCS2 font the code *is* the Unicode value directly. For a single-byte font, decodes via the snapshot's byte→width table (WinAnsi/ Latin-1 identity for codes 0–255).

Declarations

C
uint32_t __stdcall fntTranslateRawCode(PFNT IFont, const char* Text, uint32_t Len, double* Width, const wchar_t* OutText, int32_t* OutLen, BOOL32* Decoded, float CharSpacing, float WordSpacing, float TextScale);
Delphi
function fntTranslateRawCode(const IFont: PFNT; const Text: PAnsiChar; Len: Cardinal; var Width: Double; OutText: PWideChar; var OutLen: Integer; var Decoded: LongBool; CharSpacing, WordSpacing, TextScale: Single): Cardinal; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IFontPFNTSnapshot handle.
TextPAnsiCharRaw show-string bytes.
LenCardinalByte length.
WidthDouble*Receives the em-fraction advance (caller scales by point size).
OutTextPWideCharBuffer for decoded Unicode text — must be at least 32 wide characters, per the source's own parameter comment; this is not validated at runtime, so an undersized buffer overflows.
OutLenInteger*Receives the decoded character count.
DecodedBOOL32*Receives whether decoding succeeded.
CharSpacing, WordSpacing, TextScaleSingleSame as fntGetTextWidth.

Return value — The first decoded Unicode code point; 0 on failure.

Remarks — undersized-buffer risk. The 32-wide-character minimum for OutText is documented only in the source's inline parameter comment, not enforced by the function itself — passing a smaller buffer for text that decodes to 32+ characters overflows it.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern uint fntTranslateRawCode(IntPtr IFont, [MarshalAs(UnmanagedType.LPStr)] string Text, uint Len, ref double Width, IntPtr OutText, ref int OutLen, [MarshalAs(UnmanagedType.Bool)] ref bool Decoded, float CharSpacing, float WordSpacing, float TextScale);
Area
Fonts
Category

Font Services

Exported names

fntTranslateRawCode

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.