Getting the styled font size of a memo to resize it to its contents’ size in Firemonkey on Android


I’ve tried multiple things that are all present in answers to this question:
Can I make a TMemo size itself to the text it contains? – Firemonkey

The top answer with ContentBounds.Height works… on Windows. But it does not work on Android. It’s always one key press behind. Every time I press a key (be it Enter or ‘f’ or ‘a’, etc), the height is fitted to the content that was in the memo before that key was pressed.
Filipe.Fonseca’s answer straight up doesn’t work because there is no TTextLayout hiding in the object attachment of a line. Not sure what I’m missing here.
get_memo_height: This works to the extent that it’s not one key press behind. But the TTextLayout uses a different Font size:

If I remove the Size setting from the StyledSettings property of the Memo then get_memo_height will produce the right height. When I do that on my phone then the Font size (as in Memo1.Font.Size, Memo1.Canvas.Font.Size and Memo1.TextSettings.Font.Size) is reported as 14.

If I add Size back in, the Font size is still reported as 14. But the Text is printed at a size of something like 16 or so.

Does anyone know where this discrepancy is coming from?

Is there a way to get the actual Font size the Memo is using while the StyledSettings are active?

Comments are closed.