[Interest] cross-language matching of QStrings: partial success only?
René J.V. Bertin
rjvbertin at gmail.com
Mon May 11 23:40:51 CEST 2015
On Monday May 11 2015 20:37:16 Allan Sandfeld Jensen wrote:
> I think the problem is that fonts not always named in English and often uses
> strings instead of defined enums. This means they can have their style names
Indeed, it's very variable what you find in a font file, but most of the time truetype and opentype files do seem to provide at least the English names for styles and weights.
I presume that with "defined enums" you refer to numerical weights and style classifications in (IIRC) the OS2 and Panose definitions?
> in the language of the font origin or the language of the operating system. So
> if you load a French font, and want it in semi-bold, you may need to look for
In this case, I'm not loading a French font, as can be seen from the styles list. I'm not sure why the font selection dialog shows only the english names provided by the font files while in the code I'm seeing French translations; that may be part of the problem.
I think that it really ought to be the reverse: the code should only work with the originals, and only translate the strings only when/where interaction with the user is required.
> the demibold or demi-gras style. This is a big mess. Look for how we find the
> weight of a font in qfontdatabase.cpp getFontWeight.
That's actually what I'm working on ... and yes, it's a bit of a mess. It's been improving though, from what I saw in 5.5, but I still have a feeling that there's something of a combinatorial explosion going on that could have been avoided.
> I have neither understood your objective nor your solution. I read your
> email three times and I can't get either.
Sorry. The objective is (or seems...) simple: improve support for less common font weights/styles, notably creating a QFont from the various ways Qt can represent a font. Simply put: when I configure an app (like the Qt Assistant) to use Segoe UI Semibold or Novarese Bk Bt Medium and reopen the app or even reopen the preferences dialog, I want that particular typeface to be used and show up in the dialog.
I didn't want to mention all that in my original message, trying to focus instead on the particular problem at hand: determining if 2 terms (strings) are equal taking into account the different known/supported synonyms for those terms. I have a solution (check if both terms are each contained in the same list of synonyms) that works well enough as long as only a single language (=English) is used.
> But my suggestion is that you restrict yourself to exact string matches.
> Don't do partials. Either you have the complete translation to be matched
> or you don't.
Indeed, there is no guarantee that a translation will preserve word order ("Bold Italic" really ought to be "Italique Gras" in French as it's the Bold version of an Italic font). But disallowing partial comparisons is going to increase the number of things to compare even more (as well as the likelihood that certain combinations will be omitted).
> Better yet, don't compare translations. Compare originals only.
I'd love to. Yet Qt itself doesn't (cf. getFontWeight in qfontdatabase.cpp) ... and apparently isn't too systematic about it either.
R.
More information about the Interest
mailing list