6

I am currently developing an application for Windows 8.1 and OSX Yosemite.

Firemonkey uses Segoe UI (12) and Helvetica (13) as the default font family and size.

Does someone know a way to change those default settings or completely deactive them:

enter image description here

Because the default fonts have different font sizes (12 and 13) it's hard to get an equal look and feel.

enter image description here

As you can see the other sizes all look pretty equal except default.

If you want to display a font with text size 12 in OSX you would have to do that by runtime. That's because if you set text size 12 in designer it would automatically switch to (Default) and change it to 13 when compiling for mac.

Chris
  • 81
  • 1
  • 4

4 Answers4

7

You can change the default font and size by replacing the IFMXSystemFontService:

unit My.FontService;

interface

uses
  FMX.Platform;

type
  TmyFMXSystemFontService = class(TInterfacedObject, IFMXSystemFontService)
  public
    function GetDefaultFontFamilyName: string;
    function GetDefaultFontSize: Single;
  end;

implementation  

function TmyFMXSystemFontService.GetDefaultFontFamilyName: string;
begin
  Result := 'Lato';
end;

function TmyFMXSystemFontService.GetDefaultFontSize: Single;
begin
  Result := 12;
end;

procedure InitFont;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXSystemFontService) then
    TPlatformServices.Current.RemovePlatformService(IFMXSystemFontService);

  TPlatformServices.Current.AddPlatformService(IFMXSystemFontService, TmyFMXSystemFontService.Create);
end;

initialization

InitFont;

end.

The default font size (in XE10, don't know for XE7) is

  • for Windows: 12 (see DefaultWindowsFontSize in FMX.Platform.Win.pas)
  • for iOS: 14 (see DefaultiOSFontSize in FMX.Platform.iOS.pas)
  • for OS X: 13 (see DefaultMacFontSize in FMX.Platform.Mac.pas)
Arjen van der Spek
  • 2,630
  • 16
  • 20
1

Workaround:

var
  Settings: ITextSettings;
  Instance: TComponent;
  i: integer;
begin

  for i := 0 to ComponentCount - 1 do
  begin
    Instance := Components[i];

    if IInterface(Instance).QueryInterface(ITextSettings, Settings) = S_OK then
    begin
      Settings.TextSettings.BeginUpdate;
      try
        Settings.DefaultTextSettings.Font.Size := 12;
        Settings.DefaultTextSettings.Font.Family := 'Comic Sans MS';
      finally
        Settings.TextSettings.EndUpdate;
      end;
    end;
  end;
Chris
  • 81
  • 1
  • 4
  • The problem for this solution are the TStyleBook components in wich, at run time, his property ComponentCount always is zero. Apart, the program shall to do the same thing (for i := 0 to StyleBook.ComponentCount - 1 do...) for each TStyleBook Component found. Please see my proposal of solution. I think that a combination the two, can solve this handicap. – Juan C.Cilleruelo May 06 '15 at 09:29
1

The real problem is, a bad use of the default value for this property. It's a mistake of Embarcadero. Sure!

My solution, inside TStyleBooks components, is put a value, near to 12, but not 12.

Specifically I use "11.9". This value is not assumed as Default Value by the Delphi property editor. But when you run the program, the system converts it, correctly to 12, in the size of the font. In Mac OS X and in Windows too.

0

I would expect that default means it's using the settings in the style. You can open the style in the Bitmap Style Designer on the Tools menu, make any changes and the Save As a FireMonkey style.

I'm not sure if there's an easy way to change the defaults, though. It may mean changing every font individually.

Mike Sutton
  • 4,191
  • 4
  • 29
  • 42