Android
For XE7 to 10.2.1 TokyoYou should be able to use any True Type Font in an android app.
Example using the font Script MT Bold. This font is in the Windows Font Folder. The font file name is SCRIPTBL.TTF.
1. copy SCRIPTBL.TTF to the project folder.
2. In Deployment window, add SCRIPTBL.TTF file. Set Remote Path to .\assets\internal\
Set Remote Name to .SCRIPTBL.ttf (make the ttf extension lower case so we can hard code it into the program)
3. Load FMX.FontGlyphs.Android.pas into the editor. ( the file is in C:\Program Files (x86)\Embarcadero\Studio\15.0\source\fmx)
If it is read only, right click in editor and turn off Read-Only.
Save the file to the project folder. Don't change the file name. Then you can edit it in the Delphi editor.
A. Add System.IOUtils to the uses clause.
B. Go to procedure TAndroidFontGlyphManager.LoadResource;
- Add a var FontFile: string;
- There is a line in the procedure that says:Typeface := TJTypeface.JavaClass.create(FamilyName, TypefaceFlag);
- Replace that line with:
This will make it look for a font file by that name first.FontFile := TPath.GetDocumentsPath + PathDelim + CurrentSettings.Family + '.ttf'; if FileExists(FontFile) then Typeface := TJTypeface.JavaClass.createFromFile(StringToJString(FontFile)) else Typeface := TJTypeface.JavaClass.Create(FamilyName, TypefaceFlag);
4. For each component you want to use this font on, set the TextSettings Font Family property to SCRIPTBL
This is the name of the font file without the file extension. Don't put "SCRIPTBL.ttf" and don't put "Script MT Bold".
You will have to type or paste it in to the property box.
Note: filenames in Android are case sensitive, so you have to get them all the same.
This is a form with label, textbox, memo, checkbox, radio button:
Note: an easier idea for the filename is:
If the font family name is not the same as the file name of the font, you can just make a copy of the font file and rename it to the Font FamilyName and use that. Then the font will show up at both design time and runtime.