Lars Fosdal 1792 Posted February 4, 2020 We use a font named Code128.ttf to generate bar codes on Windows. Can that font be loaded for on-screen rendering in an FMX app on Android and/or iOS? Does anyone have an example for loading a custom font and rendering text with it in FMX? Share this post Link to post
Dave Nottage 557 Posted February 4, 2020 There's a number of examples if you Google for: custom fonts delphi android Share this post Link to post
Lars Fosdal 1792 Posted February 5, 2020 12 hours ago, Dave Nottage said: There's a number of examples if you Google for: custom fonts delphi android Do all of them involve creating a modified FMX.FontGlyphs.Android.pas !? Is there a QP I can vote for to improve this somehow? Share this post Link to post
Dave Nottage 557 Posted February 5, 2020 12 hours ago, Lars Fosdal said: Do all of them involve creating a modified FMX.FontGlyphs.Android.pas !? That's the only way of doing it, and it's very trivial to do. 12 hours ago, Lars Fosdal said: Is there a QP I can vote for to improve this somehow? https://quality.embarcadero.com/browse/RSP-16741 1 1 Share this post Link to post
Aamgian 2 Posted March 25, 2020 hi, I have followed the method carried out by Landerson Gomes like in the video on youtube . but on Android 10 it doesn't work, while on Android <10 it works fine. is there a newest way to do it? Share this post Link to post
Dave Nottage 557 Posted March 25, 2020 8 hours ago, Aamgian said: on Android 10 it doesn't work, The same method works OK on mine with Font Awesome. Which font(s) are you using? Share this post Link to post
Aamgian 2 Posted March 25, 2020 (edited) 3 hours ago, Dave Nottage said: Metode yang sama berfungsi baik pada saya dengan Font Awesome. Font apa yang Anda gunakan? I use nunito sans font from Google font. I made an application using the third party taltext component alcinoe so that the method could not worked but in android 9 that work fine, after I tried it with the default TText component it worked fine. but the next problem if I use the bold font style then it doesn't work. The following sample file that I made true_font.zip Edited March 25, 2020 by Aamgian Share this post Link to post
Dave Nottage 557 Posted March 26, 2020 You'll need to modify the patch in FMX.FontGlyphs.Android.pas to look like this: NameFont := TPath.Combine(TPath.GetDocumentsPath, CurrentSettings.Family); if not CurrentSettings.Style.Weight.IsRegular and TFile.Exists(NameFont + '-Bold.ttf') then NameFont := NameFont + '-Bold.ttf' else if CurrentSettings.Style.Weight.IsRegular and TFile.Exists(NameFont + '-Regular.ttf') then NameFont := NameFont + '-Regular.ttf' else NameFont := NameFont + '.ttf'; Share this post Link to post
Aamgian 2 Posted March 27, 2020 18 hours ago, Dave Nottage said: You'll need to modify the patch in FMX.FontGlyphs.Android.pas to look like this: NameFont := TPath.Combine(TPath.GetDocumentsPath, CurrentSettings.Family); if not CurrentSettings.Style.Weight.IsRegular and TFile.Exists(NameFont + '-Bold.ttf') then NameFont := NameFont + '-Bold.ttf' else if CurrentSettings.Style.Weight.IsRegular and TFile.Exists(NameFont + '-Regular.ttf') then NameFont := NameFont + '-Regular.ttf' else NameFont := NameFont + '.ttf'; thanks you for you help, but still not work. I decided to leave this font problem in the application that I made. Share this post Link to post
Dave Nottage 557 Posted March 27, 2020 Your example doesn't work on Android < 10 without those changes. I'm wondering how it ever would have, unless it included a font file without -Bold or -Regular on the end (which is not in the example). I've attached an update to the example that works on my Android 5.0.1 and Android 10 devices. true_font_b.zip Share this post Link to post
Mauro Botta 1 Posted January 9 Hi, @Dave Nottage i have update to Delphi 12, this patch don't work ( FMX.FontGlyphs.Android.pas is different ). Do you have any update for font problem ? Share this post Link to post
Dave Nottage 557 Posted January 9 9 hours ago, Mauro Botta said: Do you have any update for font problem ? For Delphi 12, starting from line 98 in the source: FontFile := TPath.Combine(TPath.GetDocumentsPath, CurrentSettings.Family); if not CurrentSettings.Style.Weight.IsRegular and TFile.Exists(FontFile + '-Bold.ttf') then FontFile := FontFile + '-Bold.ttf' else if CurrentSettings.Style.Weight.IsRegular and TFile.Exists(FontFile + '-Regular.ttf') then FontFile := FontFile + '-Regular.ttf' else FontFile := FontFile + '.ttf'; i.e. the changed parts start from the line starting with: if not CurrentSettings.Style.Weight.IsRegular Share this post Link to post