fntTranslateString2
Decode raw bytes to Unicode using a PFNT snapshot's encoding
| Category | Text decoding |
|---|
Purpose — Decode raw bytes to Unicode using a PFNT snapshot's encoding info directly (the standalone counterpart to fntTranslateString, which requires a pre-built TPDFStack).
Description — For a 2-byte (Type0/CID) font: decodes big-endian code pairs, resolving through the snapshot's CMap + CID-to-Unicode tables when present (Uni2Direct fonts use the code as Unicode directly). For a single-byte font: WinAnsi/Latin-1 identity mapping.
Declarations
int32_t __stdcall fntTranslateString2(PFNT IFont, const char* Text, uint32_t Len, const wchar_t* OutBuf, uint32_t Size, uint32_t Flags);
function fntTranslateString2(const IFont: PFNT; const Text: PAnsiChar; Len: Cardinal; OutBuf: PWideChar; Size, Flags: Cardinal): Integer; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IFont | PFNT | Snapshot handle. |
Text | PAnsiChar | Raw show-string bytes. |
Len | Cardinal | Byte length. |
OutBuf | PWideChar | Destination buffer. |
Size | Cardinal | Buffer capacity. |
Flags | Cardinal | Accepted for ABI compatibility; not read. |
Return value — Number of characters decoded; 0 on a NULL snapshot/text/buffer.
C# (P/Invoke)
public static extern int fntTranslateString2(IntPtr IFont, [MarshalAs(UnmanagedType.LPStr)] string Text, uint Len, IntPtr OutBuf, uint Size, uint Flags);
Font Services
fntTranslateString2
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.