I tried using the font from NSIS as shown below.
CreateFont $0 "Fonts installed on the system" 9 "500"
What I want to do is as follows:
.ttf
) are included in the setup.Windows Fonts
.)The reason is that there is a separate deletion program,
I only want to delete the font directory installed in the previous setup, and I do not want to delete the fonts on the user's system.
(2024-07-08) i was found font-info plugin However, the API users and examples do not explain in detail how they are using it.
RequestExecutionLevel User
!include LogicLib.nsh
!include WinMessages.nsh
#!define EXAMPLE_SETALL ; Uncomment to set the font for all controls
!define /IfNDef FR_PRIVATE 0x10
!define /IfNDef FR_NOT_ENUM 0x20
!macro LoadCustomFont path
System::Call 'GDI32::AddFontResourceEx(t "${path}", i ${FR_PRIVATE}|${FR_NOT_ENUM}, p0)i'
!macroend
!macro FreeCustomFont path
System::Call 'GDI32::RemoveFontResourceEx(t "${path}", i ${FR_PRIVATE}|${FR_NOT_ENUM}, p0)i'
!macroend
var FontPath
!ifdef EXAMPLE_SETALL
SetFont "Cascadia Code PL" 8
!else
var CustomFontHandle
Page InstFiles "" OnInstFilesShow
Function OnInstFilesShow
System::Call GDI32::DeleteObject(p$CustomFontHandle)
!insertmacro FreeCustomFont $FontPath
!insertmacro LoadCustomFont $FontPath
GetDlgItem $0 $hWndParent 1 ; The Next/Close button
CreateFont $CustomFontHandle "Cascadia Code PL" 8 400 /UNDERLINE
SendMessage $0 ${WM_SETFONT} $CustomFontHandle 1
FunctionEnd
!endif
Function .onInit
${IfNot} ${Silent}
InitPluginsDir
StrCpy $FontPath "$PluginsDir\CascadiaCodePL.ttf"
File "/oname=$FontPath" "CascadiaCodePL.ttf" #github.com/microsoft/cascadia-code/releases
!ifdef EXAMPLE_SETALL
!insertmacro LoadCustomFont $FontPath
!endif
${EndIf}
FunctionEnd
Function .onGUIEnd
!ifndef EXAMPLE_SETALL
System::Call GDI32::DeleteObject(p$CustomFontHandle)
!endif
!insertmacro FreeCustomFont $FontPath
FunctionEnd
Section
SectionEnd