DelphiFM
DelphiFM

Reputation: 133

How to change globally the Fonts in FireMonkey?

I’m trying to find a way to globally change the font in a FireMonkey project. What is the easiest way to do it without having to change the font property for all the components? If there a way to set the font of an entire application or an entire form (like in VCL)?

Upvotes: 5

Views: 3633

Answers (3)

SunYu
SunYu

Reputation: 11

Just to set a new  TFont.FontService , you can change default font size and 
family 



unit ChangeDefaultFont; 

interface
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,FMX.graphics;

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

implementation

{ TDefaultFont }

function TDefaultFont.GetDefaultFontFamilyName: string;
begin
  Result := 'Tahoma';
end;

function TDefaultFont.GetDefaultFontSize: Single;
begin
  Result := 26.0;
end;
initialization
   TFont.FontService := TDefaultFont.Create;
end.

Upvotes: 1

Jason Southwell
Jason Southwell

Reputation: 361

You should be able to do this with Duck Duck Delphi...

This would change all of the fonts for components on a form:

Form1.duck.all.on('Font').setTo('Name','Arial').setTo('Color',TAlphaColors.Red);

And I haven't tried it, but either of these "should" work for doing the same application-wide:

Application.duck.all.each.on('Font').setTo('Name','Arial').setTo('Color',TAlphaColors.Red);
Screen.duck.all.each.on('Font').setTo('Name','Arial').setTo('Color',TAlphaColors.Red);

Duck Duck Delphi can be found here:

https://bitbucket.org/sivv/duckduckdelphi

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 612784

FireMonkey styles are the way to do this. Note that the VCL way of doing things with ParentXXX is not offered in FMX.

This article covers the topic in some detail.

Upvotes: 1

Related Questions