| Category | Interactive text replacement (alt-font registry) |
|---|---|
| Exported names | psrSetAltFontA, psrSetAltFontW |
| Note | a real, functioning mechanism (unlike the document-level alt-font-list confusion in E03); Style/Size/Embed/CP accepted but unused |
Purpose — Register an alternate font name in a psr context (see [Interactive Text Search, Selection & Replacement](../V06_Text/E05_InteractiveTextSearchAndReplace.md) for the psr* workflow), for use when replacing selected text with characters the selection's own font can't represent.
Description — genuinely consumed, verified. Appends Name to Ctx.AltFontNames, returning its 1-based handle. This registry, together with psrChangeAltFont, is read by psrReplaceSelText: if an alt font is the current selection (via psrChangeAltFont) and the replacement text contains non-Latin-1 characters, that call currently fails (full alt-font re-encoding isn't implemented) rather than corrupting output — see that entry for the exact behavior. This is a separate, working mechanism from the confusingly-named, non-functional document-level pdfCreateAltFontList/ pdfActivateAltFontList/pdfSetAltFontsA family documented in E03 — don't confuse the two.
Declarations
int32_t __stdcall psrSetAltFontA(PPDF IPDF, IPSR Ctx, const char* Name, TFStyle Style, double Size, BOOL32 Embed, TCodepage CP);
int32_t __stdcall psrSetAltFontW(PPDF IPDF, IPSR Ctx, const wchar_t* Name, TFStyle Style, double Size, BOOL32 Embed, TCodepage CP);
function psrSetAltFontA(const IPDF: PPDF; const Ctx: IPSR; const Name: PAnsiChar; Style: TFStyle; Size: Double; Embed: LongBool; CP: TCodepage): Integer; stdcall; external 'LumasPdf.dll';
function psrSetAltFontW(const IPDF: PPDF; const Ctx: IPSR; const Name: PWideChar; Style: TFStyle; Size: Double; Embed: LongBool; CP: TCodepage): Integer; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Ctx | IPSR | A parsed psr context (from psrParsePage). |
Name | string | Alt font name to register. Only this parameter is actually used. |
Style, Size, Embed, CP | various | All accepted but not read by this implementation — the registry stores only the name. |
Return value — 1-based handle for the newly registered entry; 0 if Ctx is invalid.
See also — psrChangeAltFont, psrReplaceSelText
C# (P/Invoke)
public static extern int psrSetAltFontA(IntPtr IPDF, IntPtr Ctx, [MarshalAs(UnmanagedType.LPStr)] string Name, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed, TCodepage CP);
public static extern int psrSetAltFontW(IntPtr IPDF, IntPtr Ctx, [MarshalAs(UnmanagedType.LPWStr)] string Name, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed, TCodepage CP);
Misc
psrSetAltFontA
psrSetAltFontW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.