2

Using Delphi XE8.1, how can I select a fixed (monospaced) font in Android?

I tried setting the font.family to Droid Sans Mono, but that didn't help.

4
  • I imagine you've seen this:raize.com/Articles/FmxStringGridCellFonts.asp, which it the time seemed to me to throw a bit of light on the FMX way of doing things. Commented Aug 15, 2015 at 21:47
  • @MartynA, changing the font family actually has an effect, so the mechanism seems to work. I just have thought that I have to select an existing Android font to get the desired results. The solution I just found is much simpler: setting the font family to Courier New already does the trick. Commented Aug 15, 2015 at 22:26
  • 1
    Glad you found something that works. Would be good if you would post that as an answer, so others could see how you were trying to do it, and what the eventual solution was. Commented Aug 15, 2015 at 22:29
  • the article mentioned at comment above can be found at web.archive.org/web/20180812155134/http://raize.com/Articles/… and basically says you have to adjust StyledSettings. See example on clearing just the font family flag (so that Style doesn't affect it) here: stackoverflow.com/a/44413546/903783 Commented Aug 5, 2022 at 13:31

2 Answers 2

3

When everything else fails the only answer, even if most unlikely, must be correct.

My understanding was, that I can only select a font installed on the target system. If that one is not found the system falls back to the default font. After running out of logical approaches, I found that simply setting the font family to Courier New does the trick.

Sign up to request clarification or add additional context in comments.

1 Comment

While this seems to work in older Android versions, I am still out of luck with lollipop.
2
.Canvas.Font.Family:='monospace'; 

works pefect for me.

1 Comment

This doesn't work on Windows 11. "Courier New" does work on Win11 though, so if comment above mentioning "Courier New" as working on Android is correct, it is probably better choice. Not sure about OS-X and iOS or Linux. Another comment was mentioning issues with "Android lollipop" however and at stackoverflow.com/questions/44366050/… I see conditional compilation being used to pick "monospace" for Android and "Courier New" for Windows. Other was suggesting "serif-monospace" (also not working on Win11)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.