API referenceFonts

pdfSetCIDFont

Select a CID-keyed font for CJK/composite text, encoded

CategoryCID/CJK fonts

Purpose — Select a CID-keyed font for CJK/composite text, encoded through a predefined CMap (from pdfLoadCMap) or via Identity-H/V.

Description — Branches on CMapHandle: 0 (or any handle out of range) falls through to plain pdfSetFont (so this call degrades gracefully to a normal font selection if you didn't load a CMap first). A handle naming "Identity-H"/"Identity-V" also uses the ordinary embedded-TrueType path (CID = GID directly) — Identity-V additionally flags the resulting font entry as vertical-writing. Any other predefined CMap name (e.g. "UniGB-UCS2-H") builds a real CID font entry: looks up a matching system font for real glyph metrics/advances, and — when Embed=TRUE and that system font was found — embeds its /FontFile2 and builds a /CIDToGIDMap; if no matching system font exists, the CID font still works non-embedded, falling back to the CMap's declared /DW default width for all advances (less accurate than real per-glyph widths).

Declarations

C
int32_t __stdcall pdfSetCIDFontA(PPDF IPDF, uint32_t CMapHandle, const char* Name, int32_t Style, double Size, BOOL32 Embed);
int32_t __stdcall pdfSetCIDFontW(PPDF IPDF, uint32_t CMapHandle, const wchar_t* Name, int32_t Style, double Size, BOOL32 Embed);
Delphi
function pdfSetCIDFontA(const IPDF: PPDF; CMapHandle: Cardinal; const Name: PAnsiChar; Style: Integer; Size: Double; Embed: LongBool): Integer; stdcall; external 'LumasPdf.dll';
function pdfSetCIDFontW(const IPDF: PPDF; CMapHandle: Cardinal; const Name: PWideChar; Style: Integer; Size: Double; Embed: LongBool): Integer; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
CMapHandleCardinalHandle from pdfLoadCMap; 0/out-of-range falls back to plain pdfSetFont.
NamestringSystem font name to resolve for glyph metrics/embedding.
StyleIntegerPassed straight through to the underlying pdfSetFont fallback path where applicable — subject to the same bit-0=Bold/bit-1=Italic convention documented in E01.
SizeDoubleInitial point size.
EmbedBOOL32Genuinely honored here (unlike several Embed parameters elsewhere in this volume) — controls whether the resolved system font's program is actually embedded.

Return value — 1-based font handle on success; 0 if the predefined CMap couldn't be loaded (e.g. CMapHandle names a CMap this build doesn't bundle).

See alsopdfLoadCMap

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfSetCIDFontA(IntPtr IPDF, uint CMapHandle, [MarshalAs(UnmanagedType.LPStr)] string Name, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed);
public static extern int pdfSetCIDFontW(IntPtr IPDF, uint CMapHandle, [MarshalAs(UnmanagedType.LPWStr)] string Name, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed);
Area
Fonts
Category

Setters

Exported names

pdfSetCIDFontA pdfSetCIDFontW

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.