[Interest] Multi language/font display in qt4

Till Oliver Knoll till.oliver.knoll at gmail.com
Sun Jan 26 13:43:23 CET 2014


Am 26.01.2014 um 12:57 schrieb Simone <cjb.sw.nospam at gmail.com>:

> ...
> Are you sure of that?
> I read some article about fontconfig and seems that there is a solution, but i have not understood how it work.

Basically your problem is the following:

* If the character to be displayed is in the "Latin 1" Unicode range, then use font A

* Else (character is in "Asian language" Unicode range): use font B

I am pretty sure that there is no Qt API which would let you define such a "Unicode range"-dependent font.

So either you could try to get hold of some underlying (fontconfig) API which might (?) provide such a feature, or you would pre-process each text before you pass it to Qt to render it as (HTML) text.

That is, you would iterate over each character and whenever the Unicode range changes, you would set the font accordingly. Something like the following could work:

<span font="A">Latin 1 text followed by </span><span font="B">asian characters.</span>

Depending on the Qt API used to display text (e.g. QLabel::setText) that  HTML formatting is then evaluated/considered.

Cheers,
  Oliver


More information about the Interest mailing list