API referenceFonts

pdfLoadFont

Load a font directly from an in-memory buffer (TrueType data).

CategoryFont loading
NoteEmbed/CP accepted but unused (see Remarks)

Purpose — Load a font directly from an in-memory buffer (TrueType data).

Description — Unlike pdfSetFont's multi-tier name-resolution chain, this loads the font bytes you supply directly — no system/alt-font/bundled-fallback search. Always registers as an embedded TrueType entry (embedding is not optional through this call regardless of the Embed parameter — see Remarks) and makes it the active font.

Declarations

C
int32_t __stdcall pdfLoadFont(PPDF IPDF, void* Buffer, uint32_t BufSize, int32_t Style, double Size, BOOL32 Embed, int32_t CP);
Delphi
function pdfLoadFont(const IPDF: PPDF; const Buffer: Pointer; BufSize: Cardinal; Style: Integer; Size: Double; Embed: LongBool; CP: Integer): Integer; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle with an open document.
BufferPointerRaw font file bytes (TrueType).
BufSizeCardinalByte length of Buffer.
StyleIntegerAccepted for ABI compatibility; the loaded font program dictates its own actual style — this does not select among style variants within the buffer (there is only one font in the buffer).
SizeDoubleInitial point size, becomes the current font size.
EmbedBOOL32Accepted but not read — loading from a buffer always results in an embedded font; there is no non-embedded path through this call.
CPIntegerAccepted but not read.

Return value — 1-based font handle on success; 0 if the buffer can't be parsed as a supported font or no document is open.

See alsopdfLoadFontEx

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfLoadFont(IntPtr IPDF, IntPtr Buffer, uint BufSize, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed, int CP);
Area
Fonts
Category

Core

Exported names

pdfLoadFont

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.