cancel
Showing results for 
Search instead for 
Did you mean: 

Font caching : default font not displaying certain characters size correctly

GMeur
Senior

Hi,

In this image (taken from the touchgfx documentation)

0693W00000WIf5GQAT.png 

Can the 'font2' and the font in the cache (fontcache) be different? I'm asking cuz when I'm using a chinese font, I'd like to still be able to draw standard ascii chars from the default font (verdana) located in flash. I started doubting it could be done this way when I saw that some chars aren't drawn properly (curiously only chars like p,q,g):

0693W00000WIf5zQAD.pngSee the 'g' that's missing the bottom part?

Thanks in advance for your answer, and if it's the case, then what's the proper way to do what I want to do?

5 REPLIES 5
MM..1
Chief II

I mean isnt font problem. Try change position or order for up and bottom textareas

I don't know. It has indeed to do with the resizeHeight() of the textArea that doesn't seem to be able to calculate the height properly when I use the 'cachedfont'. Indeed, refering to the above diagram, if the font points directly to font2, it works fine, but if the font points to a cachedFont that points to font2 and an empty fontCache or a fontCache using a different font, it doesn't work correctly (don't know what happens if fontCache uses the same font2 but doesn't hold the drawn chars (ascii in that case)).

This cached stuf isnt i mean very used and maybe is buggy. Report here versions and code to replicate.

Other question is why you resize, but i mean you use other height with chinese...

Try set height size fix and invalidate.

GMeur
Senior

The thing is, I don't believe it's a bug, just the way it was designed to work. I work with touchgfx V16. The resizeHeightToCurrentText() calls the getMinimumTextHeight() from the font.hpp which returns the fontHeight + pixelsBelowBaseline. But even though the 'normal' (Verdana) and chinese (microsoft_jhenghei) fonts have the same height (22px in that case), their pixelsBelowBaseline is different (4 and 2 respectively). Therefore, if I try to draw a verdana letter that goes well under the baseline (like g, q, p,…) with the config of the microsoft_jheinghei the bottomest part is missing… The thing is, the cacheFont object is only set up to use one font, so I assume there is no real way to do what I'm trying to do (that is, support both fonts) besides modifying the cacheFont configuration and increasing manually the pixelsBelowBaseline to use the biggest value, which is obviously a quite ugly way to do it.

Unless there is something I'm missing (and the whole point of my original question is precisely to know whether something is escaping me or not :p) ?

Edit : and to make clear why my having resizeHeight() work is important is because I use a lot the resizeToCurrentText() which resizes both the widget width and height

GMeur
Senior

Hello,

I'd really appreciate if a developper from touchGFX could confirm this and indicate how I should go about working around this problem.

Thanks.