仅用于INNO设置的运行时添加OTF字体资源



我正在尝试将一些其他字体类型添加到资源中,然后在我的Inno Setup Installer中使用它,仅用于运行时,但它不适用于OTF字体类型,但适用于TTF字体类型我使用的代码是这样的:

[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}My Application
[Files]
Source: SetupUbuntu.otf;  DestDir: {tmp}; Flags: dontcopy
[code]
const
  FR_PRIVATE = $10;
function AddFontResourceEx(lpszFilename:string;fl:dword;pdv:integer): LongInt; external 'AddFontResourceExW@gdi32.dll stdcall';
function RemoveFontResourceEx(lpszFilename:string;fl:dword;pdv:integer): Boolean; external 'RemoveFontResourceExW@gdi32.dll stdcall';
function InitializeSetup(): Boolean;
begin
  ExtractTemporaryFile('Ubuntu.otf');
  if (AddFontResourceEx(ExpandConstant('{tmp}Ubuntu.otf'),FR_PRIVATE,0) = 0) then
    MsgBox('failed adding font - Ubuntu.otf',mbInformation,MB_OK);
  result := true;
end;
procedure InitializeWizard();
begin
  WizardForm.WelcomeLabel1.Font.Name := 'Ubuntu';
end;
procedure DeinitializeSetup();
begin
  RemoveFontResourceEx(ExpandConstant('{tmp}Ubuntu.otf'),FR_PRIVATE,0);
end;

AddFontresourceex函数始终成功,但对字体没有影响,它使用Fail Safe默认字体而是

我认为您需要添加标志参数'fontisnttruetype'。

最新更新