Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing default TextSettings Font Family / Size (XE7)

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.

like image 705
Chris Avatar asked Nov 19 '14 17:11

Chris


People also ask

How do I permanently change the font size?

Open any Word document. Right-click somewhere in the document and choose “Font”. In the Font dialog box, select your preferred typeface and any other settings you want to change (e.g., font size). Click the “Set As Default” button.


1 Answers

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)
like image 124
Arjen van der Spek Avatar answered Sep 29 '22 07:09

Arjen van der Spek