fntTranslateRawCode
Decode raw show-string bytes (from a PFNT snapshot's font)
| Category | Font-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
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);
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
| Parameter | Type | Description |
|---|---|---|
IFont | PFNT | Snapshot handle. |
Text | PAnsiChar | Raw show-string bytes. |
Len | Cardinal | Byte length. |
Width | Double* | Receives the em-fraction advance (caller scales by point size). |
OutText | PWideChar | Buffer 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. |
OutLen | Integer* | Receives the decoded character count. |
Decoded | BOOL32* | Receives whether decoding succeeded. |
CharSpacing, WordSpacing, TextScale | Single | Same 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)
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);
Font Services
fntTranslateRawCode
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.