| Category | Font substitution |
|---|---|
| Note | FontFile is never opened; only its filename is used as a system-font name lookup (see Remarks) |
Purpose — Nominally: replace a document font with the font file at FontFile.
Description — the file path is not actually loaded; read this before using it. The wrapper strips FontFile down to its base filename without extension (ChangeFileExt(ExtractFileName(FontFile), '')) and passes that string as a font name to the exact same ReplaceFontH used by pdfReplaceFont — which then searches installed system fonts for a match by that name. The bytes at FontFile are never read. If you point FontFile at "C:\CustomFonts\MyBrandFace.ttf" and that face is *not* separately installed as a system font named "MyBrandFace", this call falls through to the same rename-only fallback as pdfReplaceFont — an unembedded /BaseFont reference by that filename-derived string, with no actual font program swapped in, despite Embed=TRUE.
Declarations
int32_t __stdcall pdfReplaceFontExA(PPDF IPDF, void* PDFFont, const char* FontFile, BOOL32 Embed);
int32_t __stdcall pdfReplaceFontExW(PPDF IPDF, void* PDFFont, const wchar_t* FontFile, BOOL32 Embed);
function pdfReplaceFontExA(const IPDF: PPDF; const PDFFont: Pointer; const FontFile: PAnsiChar; Embed: LongBool): Integer; stdcall; external 'LumasPdf.dll';
function pdfReplaceFontExW(const IPDF: PPDF; const PDFFont: Pointer; const FontFile: PWideChar; Embed: LongBool): Integer; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
PDFFont | Pointer | A PFNT handle from pdfEnumDocFonts. |
FontFile | string | Only the filename (minus extension) is used, as a system-font-name lookup — the path and the file's actual bytes are never accessed. |
Embed | BOOL32 | Accepted for ABI compatibility; not read — embedding happens automatically if-and-only-if a matching system font is found by name, regardless of this flag. |
Return value — The entry's handle on success; 0 if PDFFont is unrecognized.
Remarks — if you need to embed an arbitrary font file the host doesn't have installed, this is not the API for it. There is no entry point in this cluster that loads arbitrary font bytes from a caller-supplied path for a *replacement*; FontFile here functions purely as a name hint into the system font catalog. (Contrast with the V05 font-*loading* cluster — pdfLoadFont/pdfLoadFontEx — which does load a file's bytes directly; not covered in this chapter.)
See also — pdfReplaceFont
C# (P/Invoke)
public static extern int pdfReplaceFontExA(IntPtr IPDF, IntPtr PDFFont, [MarshalAs(UnmanagedType.LPStr)] string FontFile, [MarshalAs(UnmanagedType.Bool)] bool Embed);
public static extern int pdfReplaceFontExW(IntPtr IPDF, IntPtr PDFFont, [MarshalAs(UnmanagedType.LPWStr)] string FontFile, [MarshalAs(UnmanagedType.Bool)] bool Embed);
Core
pdfReplaceFontExA
pdfReplaceFontExW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.