fmx Android 字体列表
时间: 2023-08-07 08:40:17 浏览: 204
在 FireMonkey 应用程序中,您可以使用 TFontDialog 来选择字体,TLabel 和 TEdit 等控件的 Font 属性来设置字体。以下是一些在 Android 上可用的系统字体:
- Droid Sans
- Droid Sans Mono
- Droid Serif
- Roboto
- Roboto Condensed
- Roboto Light
- Roboto Medium
- Roboto Thin
您也可以将自定义字体文件添加到您的应用程序中,然后使用 TFont.FromFile() 方法来加载它们。例如:
```
MyLabel.Font := TFont.FromFile('/sdcard/myfont.ttf');
```
请注意,在 Android 上,您需要在应用程序清单文件中声明读取外部存储器的权限,以便访问您的字体文件。例如:
```
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
```
希望这些信息对您有所帮助。如果您有任何其他问题,请随时提出。
相关问题
fmx Android获取系统字体列表
在 FireMonkey 应用程序中,您可以使用 TFontDialog 组件来选择字体,但是它不提供获取系统字体列表的方法。不过,您可以通过调用 Java 代码来获取 Android 系统中的字体列表。以下是获取系统字体列表的示例代码:
```
uses
Androidapi.Helpers,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.JavaTypes;
function GetSystemFontList: TArray<string>;
var
TypefaceClass: JNIClass;
FontManager: JNIClass;
FontList: JArrayList;
i: Integer;
begin
TypefaceClass := TJTypeface.JavaClass;
FontManager := TJTypeface.JavaClass.getDeclaredField('sSystemFontMap').getType;
FontList := TJArrayList.Wrap(FontManager.getDeclaredMethod('values').invoke(nil, nil));
SetLength(Result, FontList.size);
for i := 0 to FontList.size - 1 do
Result[i] := JStringToString(FontList.get(i).toString);
end;
```
这个函数返回一个字符串数组,其中包含系统中可用的字体名称。请注意,此代码需要使用 Androidapi.JNI 单元和 Androidapi.JNI.GraphicsContentViewText 单元中的类和方法。您可能需要在项目选项中添加这些单元。
希望这些信息对您有所帮助。如果您有任何其他问题,请随时提出。
Delphi Android 字体列表
您可以使用TFontManager来获取Android设备上已安装的字体列表。
以下是一个示例代码,它显示了如何使用TFontManager来获取Android设备上已安装的字体列表,并将其添加到一个下拉列表框中:
```delphi
uses
FMX.Fonts, FMX.Platform.Android;
procedure TForm1.FormCreate(Sender: TObject);
var
FontList: TStrings;
I: Integer;
FontService: IFMXFontService;
begin
FontList := TStringList.Create;
try
// Get the font service
FontService := TPlatformServices.Current.GetPlatformService(IFMXFontService) as IFMXFontService;
// Get the list of installed fonts
FontService.GetInstalledFonts(FontList);
// Add the fonts to the combo box
for I := 0 to FontList.Count - 1 do
ComboBox1.Items.Add(FontList[I]);
finally
FontList.Free;
end;
end;
```
请注意,上面的代码是用于FireMonkey框架的。如果您使用的是VCL框架,则需要使用不同的代码。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)