mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Bug 364058 [cocoa-cairo] css length unit 'ex' doesn't work on 10.3.9 r=vald
This commit is contained in:
parent
0ea4e79fbc
commit
dfe6f6a6aa
@ -54,7 +54,8 @@ public:
|
||||
|
||||
virtual const gfxFont::Metrics& GetMetrics();
|
||||
|
||||
float GetCharWidth (PRUnichar c);
|
||||
float GetCharWidth(PRUnichar c);
|
||||
float GetCharHeight(PRUnichar c);
|
||||
|
||||
ATSUFontID GetATSUFontID() { return mATSUFontID; }
|
||||
|
||||
|
@ -136,7 +136,11 @@ gfxAtsuiFont::gfxAtsuiFont(ATSUFontID fontID,
|
||||
mMetrics.emDescent = mMetrics.emHeight - mMetrics.emAscent;
|
||||
|
||||
mMetrics.maxAdvance = atsMetrics.maxAdvanceWidth * size;
|
||||
mMetrics.xHeight = atsMetrics.xHeight * size;
|
||||
|
||||
if (atsMetrics.xHeight)
|
||||
mMetrics.xHeight = atsMetrics.xHeight * size;
|
||||
else
|
||||
mMetrics.xHeight = GetCharHeight('x');
|
||||
|
||||
if (atsMetrics.avgAdvanceWidth != 0.0)
|
||||
mMetrics.aveCharWidth =
|
||||
@ -201,6 +205,25 @@ gfxAtsuiFont::GetCharWidth(PRUnichar c)
|
||||
return f;
|
||||
}
|
||||
|
||||
float
|
||||
gfxAtsuiFont::GetCharHeight(PRUnichar c)
|
||||
{
|
||||
// this sucks. There is a faster way to go from a char -> glyphs, but it
|
||||
// requires using oodles of apple private interfaces. If we start caching
|
||||
// gfxAtsuiFonts, then it might make sense to do that.
|
||||
ATSUTextLayout layout;
|
||||
|
||||
UniCharCount one = 1;
|
||||
ATSUCreateTextLayoutWithTextPtr(&c, 0, 1, 1, 1, &one, &mATSUStyle, &layout);
|
||||
|
||||
Rect rect;
|
||||
ATSUMeasureTextImage(layout, 0, 1, 0, 0, &rect);
|
||||
|
||||
ATSUDisposeTextLayout(layout);
|
||||
|
||||
return rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
gfxAtsuiFont::~gfxAtsuiFont()
|
||||
{
|
||||
cairo_scaled_font_destroy(mScaledFont);
|
||||
|
Loading…
Reference in New Issue
Block a user