API referenceFonts

fntTranslateString2

Decode raw bytes to Unicode using a PFNT snapshot's encoding

CategoryText 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

C
int32_t __stdcall fntTranslateString2(PFNT IFont, const char* Text, uint32_t Len, const wchar_t* OutBuf, uint32_t Size, uint32_t Flags);
Delphi
function fntTranslateString2(const IFont: PFNT; const Text: PAnsiChar; Len: Cardinal; OutBuf: PWideChar; Size, Flags: Cardinal): Integer; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IFontPFNTSnapshot handle.
TextPAnsiCharRaw show-string bytes.
LenCardinalByte length.
OutBufPWideCharDestination buffer.
SizeCardinalBuffer capacity.
FlagsCardinalAccepted for ABI compatibility; not read.

Return value — Number of characters decoded; 0 on a NULL snapshot/text/buffer.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int fntTranslateString2(IntPtr IFont, [MarshalAs(UnmanagedType.LPStr)] string Text, uint Len, IntPtr OutBuf, uint Size, uint Flags);
Area
Fonts
Category

Font Services

Exported names

fntTranslateString2

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.