Remove special case for color fonts from Freetype font engine
When adding color font support to the Freetype engine, we added a special case to some functions based on the assumption that color fonts do not contain the latin alphabet. The reason for the assumption is that color fonts are currently most popular for emojis and the most popular ones on Linux did not contain the latin alphabet. But there is nothing special about color fonts making them less likely to contain latin characters than other fonts especially made for non-latin writing systems. If we want an additional fallback when the x character is not available, this should be implemented for all font engines and font types. Change-Id: I1c4aa28d49c38ba7a416c1cae50a1d1c09cbda41 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: jian liang <jianliang79@gmail.com>bb10
parent
5def42f783
commit
365a65da70
|
|
@ -1328,33 +1328,25 @@ QFixed QFontEngineFT::leading() const
|
|||
|
||||
QFixed QFontEngineFT::xHeight() const
|
||||
{
|
||||
if (!isScalableBitmap()) {
|
||||
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
|
||||
if (os2 && os2->sxHeight) {
|
||||
lockFace();
|
||||
QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize();
|
||||
unlockFace();
|
||||
return answer;
|
||||
}
|
||||
} else {
|
||||
return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor;
|
||||
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
|
||||
if (os2 && os2->sxHeight) {
|
||||
lockFace();
|
||||
QFixed answer = QFixed(os2->sxHeight * freetype->face->size->metrics.y_ppem) / emSquareSize();
|
||||
unlockFace();
|
||||
return answer;
|
||||
}
|
||||
|
||||
return QFontEngine::xHeight();
|
||||
}
|
||||
|
||||
QFixed QFontEngineFT::averageCharWidth() const
|
||||
{
|
||||
if (!isScalableBitmap()) {
|
||||
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
|
||||
if (os2 && os2->xAvgCharWidth) {
|
||||
lockFace();
|
||||
QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize();
|
||||
unlockFace();
|
||||
return answer;
|
||||
}
|
||||
} else {
|
||||
const qreal aspectRatio = (qreal)xsize / ysize;
|
||||
return QFixed::fromReal(fontDef.pixelSize * aspectRatio);
|
||||
TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(freetype->face, ft_sfnt_os2);
|
||||
if (os2 && os2->xAvgCharWidth) {
|
||||
lockFace();
|
||||
QFixed answer = QFixed(os2->xAvgCharWidth * freetype->face->size->metrics.x_ppem) / emSquareSize();
|
||||
unlockFace();
|
||||
return answer;
|
||||
}
|
||||
|
||||
return QFontEngine::averageCharWidth();
|
||||
|
|
|
|||
Loading…
Reference in New Issue