Change the default font 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 its default font family and size.

Does anyone know a way to change these default settings or completely deactivate them:

enter image description here

Since fonts have different font sizes by default (12 and 13), itโ€™s hard to get the same look.

enter image description here

As you can see, all other sizes look pretty equal, except for the standard ones.

If you want to display a font with a text size of 12 on OSX, you will have to do this at run time. This is because if you set the text size to 12 in the designer, it will automatically switch to (default) and change it to 13 when compiling for mac.

+5
source share
4 answers

You can change the default font and size by replacing 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. 

Default font size (in XE10, I don't know for XE7)

  • 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)
+4
source

I would expect that by default this means that it uses style settings. You can open the style in the Bitmap Style Designer in the "Tools" menu, make any changes and the "Save as FireMonkey Style" style.

I'm not sure if there is an easy way to change the default settings. This may mean changing each font individually.

0
source

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; 
0
source

The real problem is the poor use of the default value for this property. This is Embarcadero's mistake. Of course!

My solution, inside TStyleBooks components, is set to a value close to 12, but not 12.

In particular, I use "11.9". This value is not considered the default value in the Delphi Property Editor. But when you run the program, the system converts it, right up to 12, to the font size. On Mac OS X and Windows too.

0
source

Source: https://habr.com/ru/post/1207240/


All Articles