Skip to content

Deploy VCL

Carlo Barazzetta edited this page May 3, 2024 · 6 revisions

Deploy VCL application (on Windows)

You must deploy the Icon Fonts used in your application to the target machine, in two way:

  1. Install the font into machine during setup process, so the Font is always available.

  2. Install the font on-the-fly, when the application need to use it.

To do this, look at the Demo Project into the event handler "OnFontMissing" of the IconFontsImageList:

procedure TMainForm.IconFontsImageListFontMissing(const AFontName: string);
var
  LFontFileName: string;
begin
  inherited;
  //The "material desktop font is not installed into system: load and install now from disk
  LFontFileName := ExtractFilePath(Application.ExeName)+'..\Fonts\Material Design Icons.ttf';
  if FileExists(LFontFileName) then
  begin
    {$IFNDEF D2010+}
    AddFontResource(PChar(LFontFileName));
    {$ELSE}
    AddFontResource(PWideChar(LFontFileName));
    {$ENDIF}
    SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
  end
  else
  begin
    //If the font file is not available
    MessageDlg(Format('Warning: "%s" font is not present in your system!'+sLineBreak+
      'Please download at https://github.com/Templarian/MaterialDesign-Webfont and install it, because this demo is based on this font.',
        [AFontName]), mtError, [mbOK], 0);
  end;
end;
Clone this wiki locally