API referenceFonts

pdfSetFieldFont

Set a form field's /DA (Default Appearance) font name and

CategoryForm field fonts
Exported namespdfSetFieldFontA, pdfSetFieldFontW
NoteStyle/Embed/CP accepted but unused (see Remarks)

Purpose — Set a form field's /DA (Default Appearance) font name and size directly.

Description — Rewrites the field's /DA string as /<Name> <Size> Tf <existing color ops>, preserving whatever color operators were already present. Name is written as a bare resource name reference — it is not validated against the field's /DR (default resources) font dictionary, so if Name doesn't correspond to a real resource entry, rendering falls to viewer-specific substitution.

Declarations

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

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
FieldCardinalTarget field handle.
NamestringFont resource name written verbatim into /DA. Size <= 0 keeps the field's existing /DA size instead of clearing it.
StyleIntegerAccepted but not read.
SizeDoubleNew font size, or <= 0 to keep the existing size.
EmbedBOOL32Accepted but not read — this call never touches font embedding, only the /DA string.
CPTCodepageAccepted but not read.

Return value1 on success; 0 if Field doesn't resolve to a known field.

See alsopdfSetFieldFontSize

C# (P/Invoke)

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

Forms

Exported names

pdfSetFieldFontA pdfSetFieldFontW

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.