更改默认TextSettings字体系列/大小(XE7)

Chr*_*ris 5 ide delphi firemonkey

我目前正在开发Windows 8.1和OSX Yosemite的应用程序.

Firemonkey使用Segoe UI(12)和Helvetica(13)作为默认字体系列和大小.

有人知道更改这些默认设置或完全取消它们的方法:

在此输入图像描述

由于默认字体具有不同的字体大小(12和13),因此很难获得相同的外观和感觉.

在此输入图像描述

正如你所看到的,除了默认值之外,其他大小看起来都相同.

如果要在OSX中显示文本大小为12的字体,则必须在运行时执行此操作.那是因为如果你在设计器中设置文本大小12,它将自动切换到(默认)并在编译mac时将其更改为13.

Arj*_*pek 5

您可以通过替换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.
Run Code Online (Sandbox Code Playgroud)

默认字体大小(在XE10中,不知道XE7)是

  • 对于Windows:12(请参阅FMX.Platform.Win.pas中的DefaultWindowsFontSize)
  • 对于iOS:14(参见FMX.Platform.iOS.pas中的DefaultiOSFontSize)
  • 对于OS X:13(请参阅FMX.Platform.Mac.pas中的DefaultMacFontSize)


Mik*_*ton 0

我希望默认意味着它正在使用样式中的设置。您可以在“工具”菜单上的“位图样式设计器”中打开该样式,进行任何更改并另存为 FireMonkey 样式。

不过,我不确定是否有一种简单的方法可以更改默认值。这可能意味着单独更改每种字体。