Simulated fonts aren't TrueType fonts.
Some font back-ends provide simulated fonts such as fake bold or fake oblique. These fonts should not be reported as TrueType, since the font data isn't what is actually used to draw the glyphs. BUG=chromium:639198 BUG=chromium:614612 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2333423002 Review-Url: https://codereview.chromium.org/2333423002
This commit is contained in:
parent
ceb93abddc
commit
0b7758236c
@ -5,6 +5,7 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "SkAdvancedTypefaceMetrics.h"
|
||||||
#include "SkDataTable.h"
|
#include "SkDataTable.h"
|
||||||
#include "SkFixed.h"
|
#include "SkFixed.h"
|
||||||
#include "SkFontDescriptor.h"
|
#include "SkFontDescriptor.h"
|
||||||
@ -484,6 +485,20 @@ public:
|
|||||||
this->INHERITED::onFilterRec(rec);
|
this->INHERITED::onFilterRec(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(PerGlyphInfo perGlyphInfo,
|
||||||
|
const uint32_t* glyphIDs,
|
||||||
|
uint32_t glyphIDsCount) const override
|
||||||
|
{
|
||||||
|
SkAdvancedTypefaceMetrics* info =
|
||||||
|
this->INHERITED::onGetAdvancedTypefaceMetrics(perGlyphInfo, glyphIDs, glyphIDsCount);
|
||||||
|
|
||||||
|
// Simulated fonts shouldn't be considered to be of the type of their data.
|
||||||
|
if (get_matrix(fPattern, FC_MATRIX) || get_bool(fPattern, FC_EMBOLDEN)) {
|
||||||
|
info->fType = SkAdvancedTypefaceMetrics::kOther_Font;
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~SkTypeface_fontconfig() {
|
virtual ~SkTypeface_fontconfig() {
|
||||||
// Hold the lock while unrefing the pattern.
|
// Hold the lock while unrefing the pattern.
|
||||||
FCLocker lock;
|
FCLocker lock;
|
||||||
|
@ -331,6 +331,10 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
|
|||||||
info->fEmSize = dwfm.designUnitsPerEm;
|
info->fEmSize = dwfm.designUnitsPerEm;
|
||||||
info->fLastGlyphID = SkToU16(glyphCount - 1);
|
info->fLastGlyphID = SkToU16(glyphCount - 1);
|
||||||
|
|
||||||
|
info->fAscent = SkToS16(dwfm.ascent);
|
||||||
|
info->fDescent = SkToS16(dwfm.descent);
|
||||||
|
info->fCapHeight = SkToS16(dwfm.capHeight);
|
||||||
|
|
||||||
// SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be
|
// SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be
|
||||||
// the PostScript name of the font. However, due to the way it is currently
|
// the PostScript name of the font. However, due to the way it is currently
|
||||||
// used, it must actually be a family name.
|
// used, it must actually be a family name.
|
||||||
@ -350,24 +354,22 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
|
DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
|
||||||
if (fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE ||
|
if (fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE &&
|
||||||
fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION) {
|
fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)
|
||||||
info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
|
{
|
||||||
} else {
|
|
||||||
info->fAscent = dwfm.ascent;
|
|
||||||
info->fDescent = dwfm.descent;
|
|
||||||
info->fCapHeight = dwfm.capHeight;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Simulated fonts aren't really TrueType fonts.
|
||||||
|
if (fDWriteFontFace->GetSimulations() == DWRITE_FONT_SIMULATIONS_NONE) {
|
||||||
|
info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
|
||||||
|
}
|
||||||
|
|
||||||
AutoTDWriteTable<SkOTTableHead> headTable(fDWriteFontFace.get());
|
AutoTDWriteTable<SkOTTableHead> headTable(fDWriteFontFace.get());
|
||||||
AutoTDWriteTable<SkOTTablePostScript> postTable(fDWriteFontFace.get());
|
AutoTDWriteTable<SkOTTablePostScript> postTable(fDWriteFontFace.get());
|
||||||
AutoTDWriteTable<SkOTTableHorizontalHeader> hheaTable(fDWriteFontFace.get());
|
AutoTDWriteTable<SkOTTableHorizontalHeader> hheaTable(fDWriteFontFace.get());
|
||||||
AutoTDWriteTable<SkOTTableOS2> os2Table(fDWriteFontFace.get());
|
AutoTDWriteTable<SkOTTableOS2> os2Table(fDWriteFontFace.get());
|
||||||
if (!headTable.fExists || !postTable.fExists || !hheaTable.fExists || !os2Table.fExists) {
|
if (!headTable.fExists || !postTable.fExists || !hheaTable.fExists || !os2Table.fExists) {
|
||||||
info->fAscent = dwfm.ascent;
|
|
||||||
info->fDescent = dwfm.descent;
|
|
||||||
info->fCapHeight = dwfm.capHeight;
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,10 +408,6 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
|
|||||||
|
|
||||||
info->fItalicAngle = SkEndian_SwapBE32(postTable->italicAngle) >> 16;
|
info->fItalicAngle = SkEndian_SwapBE32(postTable->italicAngle) >> 16;
|
||||||
|
|
||||||
info->fAscent = SkToS16(dwfm.ascent);
|
|
||||||
info->fDescent = SkToS16(dwfm.descent);
|
|
||||||
info->fCapHeight = SkToS16(dwfm.capHeight);
|
|
||||||
|
|
||||||
info->fBBox = SkIRect::MakeLTRB((int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMin),
|
info->fBBox = SkIRect::MakeLTRB((int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMin),
|
||||||
(int32_t)SkEndian_SwapBE16((uint16_t)headTable->yMax),
|
(int32_t)SkEndian_SwapBE16((uint16_t)headTable->yMax),
|
||||||
(int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMax),
|
(int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMax),
|
||||||
|
Loading…
Reference in New Issue
Block a user