Why is my QML CJK text displayed with corrupted glyphs?

My application allows the user to switch languages ​​on the fly. I see that in about 10% of cases the user switches to Chinese or Japanese, the glyphs for the user interface text are not processed properly.

This application is running Linux on the iMX6 platform. Qt 5.5.0 is used. QML is used to visualize the user interface. Corrupt text is processed using a QML text control.

An example of processing damaged fonts

The font used is Source Hans Sans Regular. I tried loading this using QML FontLoader and loading it on the C ++ side into the font database of the application (both methods identified a problem). I tried using (admittedly very strongly related) Noto fonts; same problem.

I have never seen a text rendering distortion when using Roboto for text other than CJK, and as already mentioned, this works more often than not for CJK / Source Hans Sans.

Corruption is interesting in that it is similar to the level of the displayed bitmap, and not to the level of definition of the glyph (note that some glyphs have a lower half of correctness, but the upper half is damaged).

Corruption sometimes progresses. This makes me think that the cache of glyph glyph maps is rewritten further (just a theory, since I'm not sure how Qt renders fonts). I thought it might be a QML garbage collection doing something strange, but loading the font on the C ++ side did not help.

I will try to use "native rendering" for the following QML text controls.

Has anyone seen this before? Can anyone confirm that FreeType is used for font management / rendering in Qt 5.5.0? Are there ways to influence the management of this bitmap cache?

Thanks!

Update : using 'renderType: Text.NativeRendering' did not fix the problem (although corruption appeared a little differently). And, given the limitations of this mode, I just finished with the usually poorly displayed text (soft, poor scaling, etc. - as documented ).

Update 2 : I built Qt with (to my knowledge) all glyph caches disabled - shouldDrawCachedGlyphs () returns false in my local assembly for four instances of this call, I was able to find, but still encounters glyph corruption.

Update 3 : I tried switching to using Qt Quick 2 software (not OpenGL) by setting QMLSCENE_DEVICE = softwarecontext on each document ; Glyph damage did happen.

+6
source share
1 answer

In this particular case, there is an error in the OpenGL driver in the working platform I'm working with. This affects the reverse FBO requests. Setting QML_USE_GLYPHCACHE_WORKAROUND = 1 in the environment forces Qt to store an additional copy of the glyph cache in RAM (since it cannot be read from graphics equipment when adding new glyphs).

The consequence of this is that as long as the rendering is correct (since we are using a second cache that is not corrupt), performance will be slightly reduced, as there is an additional copy on the CPU, and the glyph cache will use twice as much memory. Rendering quality does not change.

Qt support was able to point me in the right direction and qualify the consequences associated with QML_USE_GLYPHCACHE_WORKAROUND.

+4
source

All Articles