【问题标题】:How to change globally the Fonts in FireMonkey?如何全局更改 FireMonkey 中的字体?
【发布时间】:2011-12-18 14:43:51
【问题描述】:

我正在尝试找到一种方法来全局更改 FireMonkey 项目中的字体。 无需更改所有组件的字体属性的最简单方法是什么? 如果有办法设置整个应用程序或整个表单的字体(如在 VCL 中)?

【问题讨论】:

  • 你试过什么?似乎新的 XE2“实时绑定”系统可能对做这样的事情有用。

标签: delphi delphi-xe2 firemonkey


【解决方案1】:

FireMonkey styles 是执行此操作的方法。请注意,VCL 处理 ParentXXX 的方式在 FMX 中不提供。

article 详细介绍了该主题。

【讨论】:

    【解决方案2】:

    你应该可以用 Duck Duck Delphi 做到这一点......

    这将更改表单上组件的所有字体:

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

    我还没有尝试过,但是这些“应该”中的任何一个都可以在整个应用程序范围内执行相同的操作:

    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 可以在这里找到:

    https://bitbucket.org/sivv/duckduckdelphi

    【讨论】:

    【解决方案3】:
    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.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多