mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 624310 - get glyph widths via directwrite rather than font tables when using simulated bold. r=bas a=joe
This commit is contained in:
parent
38c8e658e0
commit
97b96b98fb
@ -481,27 +481,37 @@ gfxDWriteFont::GetFontTable(PRUint32 aTag)
|
||||
}
|
||||
|
||||
PRInt32
|
||||
gfxDWriteFont::GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
|
||||
gfxDWriteFont::GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
|
||||
{
|
||||
if (!mGlyphWidths.IsInitialized()) {
|
||||
mGlyphWidths.Init(200);
|
||||
}
|
||||
|
||||
PRInt32 width;
|
||||
PRInt32 width = -1;
|
||||
if (mGlyphWidths.Get(aGID, &width)) {
|
||||
return width;
|
||||
}
|
||||
|
||||
DWRITE_GLYPH_METRICS glyphMetrics;
|
||||
HRESULT hr = mFontFace->GetGdiCompatibleGlyphMetrics(
|
||||
HRESULT hr;
|
||||
if (mUsingClearType) {
|
||||
hr = mFontFace->GetDesignGlyphMetrics(
|
||||
&aGID, 1, &glyphMetrics, FALSE);
|
||||
if (SUCCEEDED(hr)) {
|
||||
width =
|
||||
NS_lround(glyphMetrics.advanceWidth * mFUnitsConvFactor *
|
||||
65536.0);
|
||||
}
|
||||
} else {
|
||||
hr = mFontFace->GetGdiCompatibleGlyphMetrics(
|
||||
GetAdjustedSize(), 1.0f, nsnull, FALSE,
|
||||
&aGID, 1, &glyphMetrics, FALSE);
|
||||
|
||||
if (NS_SUCCEEDED(hr)) {
|
||||
width = NS_lround(glyphMetrics.advanceWidth * mFUnitsConvFactor) << 16;
|
||||
mGlyphWidths.Put(aGID, width);
|
||||
return width;
|
||||
if (SUCCEEDED(hr)) {
|
||||
width =
|
||||
NS_lround(glyphMetrics.advanceWidth * mFUnitsConvFactor) << 16;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
mGlyphWidths.Put(aGID, width);
|
||||
return width;
|
||||
}
|
||||
|
@ -79,13 +79,16 @@ public:
|
||||
// use DWrite API to get direct access to system font data
|
||||
virtual hb_blob_t *GetFontTable(PRUint32 aTag);
|
||||
|
||||
virtual PRBool ProvidesHintedWidths() const {
|
||||
return !mUsingClearType;
|
||||
virtual PRBool ProvidesGlyphWidths() const {
|
||||
return !mUsingClearType ||
|
||||
(mFontFace->GetSimulations() & DWRITE_FONT_SIMULATIONS_BOLD);
|
||||
}
|
||||
|
||||
virtual PRInt32 GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
||||
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
||||
|
||||
protected:
|
||||
friend class gfxDWriteShaper;
|
||||
|
||||
virtual void CreatePlatformShaper();
|
||||
|
||||
void ComputeMetrics();
|
||||
|
@ -175,7 +175,7 @@ trymoreglyphs:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mFont->ProvidesHintedWidths()) {
|
||||
if (!static_cast<gfxDWriteFont*>(mFont)->mUsingClearType) {
|
||||
hr = analyzer->GetGdiCompatibleGlyphPlacements(
|
||||
aString + range.start,
|
||||
clusters.Elements(),
|
||||
|
@ -216,7 +216,7 @@ gfxFT2FontBase::GetGlyph(PRUint32 unicode, PRUint32 variation_selector)
|
||||
}
|
||||
|
||||
PRInt32
|
||||
gfxFT2FontBase::GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
|
||||
gfxFT2FontBase::GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
|
||||
{
|
||||
cairo_text_extents_t extents;
|
||||
GetGlyphExtents(aGID, &extents);
|
||||
|
@ -63,8 +63,8 @@ public:
|
||||
virtual hb_blob_t *GetFontTable(PRUint32 aTag);
|
||||
virtual PRBool ProvidesGetGlyph() const { return PR_TRUE; }
|
||||
virtual PRUint32 GetGlyph(PRUint32 unicode, PRUint32 variation_selector);
|
||||
virtual PRBool ProvidesHintedWidths() const { return PR_TRUE; }
|
||||
virtual PRInt32 GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
||||
virtual PRBool ProvidesGlyphWidths() const { return PR_TRUE; }
|
||||
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
||||
|
||||
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; };
|
||||
virtual PRBool SetupCairoFont(gfxContext *aContext);
|
||||
|
@ -1009,16 +1009,16 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
// subclasses may provide hinted glyph widths (in font units);
|
||||
// subclasses may provide (possibly hinted) glyph widths (in font units);
|
||||
// if they do not override this, harfbuzz will use unhinted widths
|
||||
// derived from the font tables
|
||||
virtual PRBool ProvidesHintedWidths() const {
|
||||
virtual PRBool ProvidesGlyphWidths() const {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// The return value is interpreted as a horizontal advance in 16.16 fixed
|
||||
// point format.
|
||||
virtual PRInt32 GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID) {
|
||||
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize)
|
||||
}
|
||||
|
||||
PRInt32
|
||||
gfxGDIFont::GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
|
||||
gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID)
|
||||
{
|
||||
if (!mGlyphWidths.IsInitialized()) {
|
||||
mGlyphWidths.Init(200);
|
||||
|
@ -76,10 +76,10 @@ public:
|
||||
/* required for MathML to suppress effects of ClearType "padding" */
|
||||
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
|
||||
|
||||
virtual PRBool ProvidesHintedWidths() const { return PR_TRUE; }
|
||||
virtual PRBool ProvidesGlyphWidths() const { return PR_TRUE; }
|
||||
|
||||
// get hinted glyph width in pixels as 16.16 fixed-point value
|
||||
virtual PRInt32 GetHintedGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
||||
virtual PRInt32 GetGlyphWidth(gfxContext *aCtx, PRUint16 aGID);
|
||||
|
||||
protected:
|
||||
virtual void CreatePlatformShaper();
|
||||
|
@ -83,7 +83,7 @@ gfxHarfBuzzShaper::gfxHarfBuzzShaper(gfxFont *aFont)
|
||||
mSubtableOffset(0),
|
||||
mUVSTableOffset(0),
|
||||
mUseFontGetGlyph(aFont->ProvidesGetGlyph()),
|
||||
mUseHintedWidths(aFont->ProvidesHintedWidths())
|
||||
mUseFontGlyphWidths(aFont->ProvidesGlyphWidths())
|
||||
{
|
||||
}
|
||||
|
||||
@ -215,8 +215,8 @@ gfxHarfBuzzShaper::GetGlyphAdvance(gfxContext *aContext,
|
||||
hb_position_t *x_advance,
|
||||
hb_position_t *y_advance) const
|
||||
{
|
||||
if (mUseHintedWidths) {
|
||||
*x_advance = mFont->GetHintedGlyphWidth(aContext, glyph);
|
||||
if (mUseFontGlyphWidths) {
|
||||
*x_advance = mFont->GetGlyphWidth(aContext, glyph);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -752,8 +752,8 @@ gfxHarfBuzzShaper::InitTextRun(gfxContext *aContext,
|
||||
hb_blob_unlock(mCmapTable);
|
||||
}
|
||||
|
||||
if (!mUseHintedWidths) {
|
||||
// if font doesn't implement hinted widths, we will be reading
|
||||
if (!mUseFontGlyphWidths) {
|
||||
// if font doesn't implement GetGlyphWidth, we will be reading
|
||||
// the hmtx table directly;
|
||||
// read mNumLongMetrics from hhea table without caching its blob,
|
||||
// and preload/cache the hmtx table
|
||||
@ -788,7 +788,7 @@ gfxHarfBuzzShaper::InitTextRun(gfxContext *aContext,
|
||||
}
|
||||
|
||||
if ((!mUseFontGetGlyph && mCmapFormat <= 0) ||
|
||||
(!mUseHintedWidths && !mHmtxTable)) {
|
||||
(!mUseFontGlyphWidths && !mHmtxTable)) {
|
||||
// unable to shape with this font
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ protected:
|
||||
// Whether the font implements GetGlyph, or we should read tables
|
||||
// directly
|
||||
PRPackedBool mUseFontGetGlyph;
|
||||
// Whether the font implements hinted widths, or we should read tables
|
||||
// Whether the font implements GetGlyphWidth, or we should read tables
|
||||
// directly to get ideal widths
|
||||
PRPackedBool mUseHintedWidths;
|
||||
PRPackedBool mUseFontGlyphWidths;
|
||||
};
|
||||
|
||||
#endif /* GFX_HARFBUZZSHAPER_H */
|
||||
|
@ -41,9 +41,7 @@ skip-if(!(d2d||cocoaWidget)) != subpixel-glyphs-x-2a.html subpixel-glyphs-x-2b.h
|
||||
== subpixel-glyphs-y-1a.html subpixel-glyphs-y-1b.html
|
||||
== subpixel-lineheight-1a.html subpixel-lineheight-1b.html
|
||||
== swash-1.html swash-1-ref.html
|
||||
# Test for bug 593564, synthetic bold should cause glyph metrics to increase
|
||||
# Random on Windows - fails on tinderbox Opt reftest, passes elsewhere - see bug 597300
|
||||
random-if(winWidget) HTTP(..) != synthetic-bold-metrics-01.html synthetic-bold-metrics-01-notref.html
|
||||
HTTP(..) != synthetic-bold-metrics-01.html synthetic-bold-metrics-01-notref.html
|
||||
== variation-selector-unsupported-1.html variation-selector-unsupported-1-ref.html
|
||||
== white-space-1a.html white-space-1-ref.html
|
||||
== white-space-1b.html white-space-1-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user