Bug 1065002 pt 1.1 - Rename gfxFont::GetMetrics to GetHorizontalMetrics, and add a GetMetrics wrapper to access it. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-09-30 07:37:40 +01:00
parent 3ff7b19ff8
commit 08e2504e53
8 changed files with 24 additions and 16 deletions

View File

@ -126,7 +126,7 @@ gfxDWriteFont::CopyWithAntialiasOption(AntialiasOption anAAOption)
}
const gfxFont::Metrics&
gfxDWriteFont::GetMetrics()
gfxDWriteFont::GetHorizontalMetrics()
{
return *mMetrics;
}

View File

@ -30,8 +30,6 @@ public:
virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption);
virtual const gfxFont::Metrics& GetMetrics();
virtual uint32_t GetSpaceGlyph();
virtual bool SetupCairoFont(gfxContext *aContext);
@ -71,6 +69,8 @@ public:
virtual cairo_scaled_font_t *GetCairoScaledFont();
protected:
virtual const Metrics& GetHorizontalMetrics();
bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics);
void ComputeMetrics(AntialiasOption anAAOption);
@ -87,7 +87,7 @@ protected:
nsRefPtr<IDWriteFontFace> mFontFace;
cairo_font_face_t *mCairoFontFace;
gfxFont::Metrics *mMetrics;
Metrics *mMetrics;
// cache of glyph widths in 16.16 fixed-point pixels
nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;

View File

@ -108,7 +108,7 @@ gfxFT2FontBase::GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents)
}
const gfxFont::Metrics&
gfxFT2FontBase::GetMetrics()
gfxFT2FontBase::GetHorizontalMetrics()
{
if (mHasMetrics)
return mMetrics;
@ -146,7 +146,7 @@ gfxFT2FontBase::GetSpaceGlyph()
{
NS_ASSERTION(GetStyle()->size != 0,
"forgot to short-circuit a text run with zero-sized font?");
GetMetrics();
GetHorizontalMetrics();
return mSpaceGlyph;
}

View File

@ -21,7 +21,6 @@ public:
uint32_t GetGlyph(uint32_t aCharCode);
void GetGlyphExtents(uint32_t aGlyph,
cairo_text_extents_t* aExtents);
virtual const gfxFont::Metrics& GetMetrics();
virtual uint32_t GetSpaceGlyph();
virtual bool ProvidesGetGlyph() const { return true; }
virtual uint32_t GetGlyph(uint32_t unicode, uint32_t variation_selector);
@ -34,7 +33,10 @@ public:
virtual FontType GetType() const { return FONT_TYPE_FT2; }
mozilla::gfx::FontOptions* GetFontOptions() { return &mFontOptions; }
protected:
virtual const Metrics& GetHorizontalMetrics();
uint32_t mSpaceGlyph;
bool mHasMetrics;
Metrics mMetrics;

View File

@ -1441,7 +1441,11 @@ public:
// no '0' glyph in this font,
// equal to .aveCharWidth
};
virtual const gfxFont::Metrics& GetMetrics() = 0;
const Metrics& GetMetrics()
{
return GetHorizontalMetrics();
}
/**
* We let layout specify spacing on either side of any
@ -1735,6 +1739,8 @@ public:
GetSubSuperscriptFont(int32_t aAppUnitsPerDevPixel);
protected:
virtual const Metrics& GetHorizontalMetrics() = 0;
// Output a single glyph at *aPt, which is updated by the glyph's advance.
// Normal glyphs are simply accumulated in aBuffer until it is full and
// gets flushed, but SVG or color-font glyphs will instead be rendered
@ -1988,7 +1994,7 @@ protected:
// some fonts have bad metrics, this method sanitize them.
// if this font has bad underline offset, aIsBadUnderlineFont should be true.
void SanitizeMetrics(gfxFont::Metrics *aMetrics, bool aIsBadUnderlineFont);
void SanitizeMetrics(Metrics *aMetrics, bool aIsBadUnderlineFont);
bool RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMode,
uint32_t aGlyphId, gfxTextContextPaint *aContextPaint) const;

View File

@ -106,7 +106,7 @@ gfxGDIFont::ShapeText(gfxContext *aContext,
}
const gfxFont::Metrics&
gfxGDIFont::GetMetrics()
gfxGDIFont::GetHorizontalMetrics()
{
if (!mMetrics) {
Initialize();

View File

@ -34,8 +34,6 @@ public:
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; }
/* overrides for the pure virtual methods in gfxFont */
virtual const gfxFont::Metrics& GetMetrics();
virtual uint32_t GetSpaceGlyph();
virtual bool SetupCairoFont(gfxContext *aContext);
@ -71,6 +69,8 @@ public:
virtual FontType GetType() const { return FONT_TYPE_GDI; }
protected:
virtual const Metrics& GetHorizontalMetrics();
/* override to ensure the cairo font is set up properly */
virtual bool ShapeText(gfxContext *aContext,
const char16_t *aText,

View File

@ -24,10 +24,6 @@ public:
CGFontRef GetCGFontRef() const { return mCGFont; }
/* overrides for the pure virtual methods in gfxFont */
virtual const gfxFont::Metrics& GetMetrics() {
return mMetrics;
}
virtual uint32_t GetSpaceGlyph() {
return mSpaceGlyph;
}
@ -51,6 +47,10 @@ public:
virtual FontType GetType() const { return FONT_TYPE_MAC; }
protected:
virtual const Metrics& GetHorizontalMetrics() {
return mMetrics;
}
// override to prefer CoreText shaping with fonts that depend on AAT
virtual bool ShapeText(gfxContext *aContext,
const char16_t *aText,