@@ -1042,8 +1042,8 @@ AddFallbackFonts(nsAString& aFontName, const nsAString& aFallbackFamilies)
1042
1042
1043
1043
// Update the font and rendering context if there is a family change
1044
1044
static void
1045
- SetFontFamily (nsPresContext * aPresContext ,
1046
- nsRenderingContext& aRenderingContext,
1045
+ SetFontFamily (nsStyleContext * aStyleContext ,
1046
+ nsRenderingContext& aRenderingContext,
1047
1047
nsFont& aFont,
1048
1048
const nsGlyphTable* aGlyphTable,
1049
1049
const nsGlyphCode& aGlyphCode,
@@ -1053,7 +1053,12 @@ SetFontFamily(nsPresContext* aPresContext,
1053
1053
aGlyphCode.font ? aGlyphTable->FontNameFor (aGlyphCode) : aDefaultFamily;
1054
1054
if (! family.Equals (aFont.name )) {
1055
1055
aFont.name = family;
1056
- aRenderingContext.SetFont (aFont, aPresContext->GetUserFontSet ());
1056
+ nsRefPtr fm;
1057
+ aRenderingContext.DeviceContext ()->GetMetricsFor (aFont,
1058
+ aStyleContext->GetStyleVisibility ()->mLanguage ,
1059
+ aStyleContext->PresContext ()->GetUserFontSet (),
1060
+ *getter_AddRefs (fm));
1061
+ aRenderingContext.SetFont (fm);
1057
1062
}
1058
1063
}
1059
1064
@@ -1119,7 +1124,8 @@ nsMathMLChar::StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
1119
1124
const nsAString& aFamily)
1120
1125
{
1121
1126
// Use our stretchy style context now that stretching is in progress
1122
- nsFont font = mChar ->mStyleContext ->GetStyleFont ()->mFont ;
1127
+ nsStyleContext *sc = mChar ->mStyleContext ;
1128
+ nsFont font = sc->GetStyleFont ()->mFont ;
1123
1129
// Ensure mRenderingContext.SetFont will be called:
1124
1130
font.name .Truncate ();
1125
1131
@@ -1144,8 +1150,7 @@ nsMathMLChar::StretchEnumContext::TryVariants(nsGlyphTable* aGlyphTable,
1144
1150
nsGlyphCode ch;
1145
1151
while ((ch = aGlyphTable->BigOf (mPresContext , mChar , size)).Exists ()) {
1146
1152
1147
- SetFontFamily (mChar ->mStyleContext ->PresContext (), mRenderingContext ,
1148
- font, aGlyphTable, ch, aFamily);
1153
+ SetFontFamily (sc, mRenderingContext , font, aGlyphTable, ch, aFamily);
1149
1154
1150
1155
NS_ASSERTION (maxWidth || ch.code[0 ] != mChar ->mGlyph .code[0 ] ||
1151
1156
ch.code[1 ] != mChar ->mGlyph .code[1 ] ||
@@ -1269,7 +1274,7 @@ nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable* aGlyphTable,
1269
1274
sizedata[i] = mTargetSize ;
1270
1275
}
1271
1276
else {
1272
- SetFontFamily (mChar ->mStyleContext -> PresContext () , mRenderingContext ,
1277
+ SetFontFamily (mChar ->mStyleContext , mRenderingContext ,
1273
1278
font, aGlyphTable, ch, aFamily);
1274
1279
nsBoundingMetrics bm = mRenderingContext .GetBoundingMetrics (ch.code ,
1275
1280
ch.Length ());
@@ -1460,7 +1465,11 @@ nsMathMLChar::StretchInternal(nsPresContext* aPresContext,
1460
1465
mFamily = families;
1461
1466
}
1462
1467
1463
- aRenderingContext.SetFont (font, aPresContext->GetUserFontSet ());
1468
+ nsRefPtr fm;
1469
+ aRenderingContext.DeviceContext ()->GetMetricsFor (font,
1470
+ mStyleContext ->GetStyleVisibility ()->mLanguage ,
1471
+ aPresContext->GetUserFontSet (), *getter_AddRefs (fm));
1472
+ aRenderingContext.SetFont (fm);
1464
1473
aDesiredStretchSize =
1465
1474
aRenderingContext.GetBoundingMetrics (mData .get (), PRUint32 (mData .Length ()));
1466
1475
@@ -2056,7 +2065,12 @@ nsMathMLChar::PaintForeground(nsPresContext* aPresContext,
2056
2065
if (! mFamily .IsEmpty ()) {
2057
2066
theFont.name = mFamily ;
2058
2067
}
2059
- aRenderingContext.SetFont (theFont, aPresContext->GetUserFontSet ());
2068
+ nsRefPtr fm;
2069
+ aRenderingContext.DeviceContext ()->GetMetricsFor (theFont,
2070
+ styleContext->GetStyleVisibility ()->mLanguage ,
2071
+ aPresContext->GetUserFontSet (),
2072
+ *getter_AddRefs (fm));
2073
+ aRenderingContext.SetFont (fm);
2060
2074
2061
2075
aRenderingContext.PushState ();
2062
2076
nsRect r = mRect + aPt;
@@ -2165,7 +2179,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
2165
2179
if (!ch.Exists ()) ch = chGlue;
2166
2180
// if (!ch.Exists()) glue is null, leave bounding metrics at 0
2167
2181
if (ch.Exists ()) {
2168
- SetFontFamily (aPresContext , aRenderingContext,
2182
+ SetFontFamily (aStyleContext , aRenderingContext,
2169
2183
aFont, aGlyphTable, ch, mFamily );
2170
2184
bmdata[i] = aRenderingContext.GetBoundingMetrics (ch.code , ch.Length ());
2171
2185
}
@@ -2250,7 +2264,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
2250
2264
}
2251
2265
if (!clipRect.IsEmpty ()) {
2252
2266
AutoPushClipRect clip (aRenderingContext, clipRect);
2253
- SetFontFamily (aPresContext , aRenderingContext,
2267
+ SetFontFamily (aStyleContext , aRenderingContext,
2254
2268
aFont, aGlyphTable, ch, mFamily );
2255
2269
aRenderingContext.DrawString (ch.code , ch.Length (), dx, dy);
2256
2270
}
@@ -2307,7 +2321,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
2307
2321
bm.descent -= oneDevPixel;
2308
2322
}
2309
2323
2310
- SetFontFamily (aPresContext , aRenderingContext,
2324
+ SetFontFamily (aStyleContext , aRenderingContext,
2311
2325
aFont, aGlyphTable, chGlue, mFamily );
2312
2326
nsRect clipRect = unionRect;
2313
2327
@@ -2393,7 +2407,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
2393
2407
if (!ch.Exists ()) ch = chGlue;
2394
2408
// if (!ch.Exists()) glue is null, leave bounding metrics at 0.
2395
2409
if (ch.Exists ()) {
2396
- SetFontFamily (aPresContext , aRenderingContext,
2410
+ SetFontFamily (aStyleContext , aRenderingContext,
2397
2411
aFont, aGlyphTable, ch, mFamily );
2398
2412
bmdata[i] = aRenderingContext.GetBoundingMetrics (ch.code , ch.Length ());
2399
2413
}
@@ -2473,7 +2487,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
2473
2487
}
2474
2488
if (!clipRect.IsEmpty ()) {
2475
2489
AutoPushClipRect clip (aRenderingContext, clipRect);
2476
- SetFontFamily (aPresContext , aRenderingContext,
2490
+ SetFontFamily (aStyleContext , aRenderingContext,
2477
2491
aFont, aGlyphTable, ch, mFamily );
2478
2492
aRenderingContext.DrawString (ch.code , ch.Length (), dx, dy);
2479
2493
}
@@ -2529,7 +2543,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
2529
2543
bm.rightBearing -= oneDevPixel;
2530
2544
}
2531
2545
2532
- SetFontFamily (aPresContext , aRenderingContext,
2546
+ SetFontFamily (aStyleContext , aRenderingContext,
2533
2547
aFont, aGlyphTable, chGlue, mFamily );
2534
2548
nsRect clipRect = unionRect;
2535
2549
0 commit comments