Bug 442113 - Canvas text size depends on browser text zoom r=vlad

This commit is contained in:
Takeshi Kurosawa ext:(%2C%20Eric%20Butler%20%3Cebutler%40mozilla.com%3E) 2008-07-03 15:02:50 -07:00
Родитель 4b5c0b5b3f
Коммит ab5953d90b
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -1699,15 +1699,18 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
nsRefPtr<nsStyleContext> sc = styleSet->ResolveStyleForRules(parentContext, rules); nsRefPtr<nsStyleContext> sc = styleSet->ResolveStyleForRules(parentContext, rules);
if (!sc) if (!sc)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
const nsStyleFont *fontStyle = sc->GetStyleFont(); const nsStyleFont* fontStyle = sc->GetStyleFont();
NS_ASSERTION(fontStyle, "Could not obtain font style"); NS_ASSERTION(fontStyle, "Could not obtain font style");
PRUint32 aupdp = presShell->GetPresContext()->AppUnitsPerDevPixel(); // use CSS pixels instead of dev pixels to avoid being affected by page zoom
const PRUint32 aupcp = nsPresContext::AppUnitsPerCSSPixel();
// un-zoom the font size to avoid being affected by text-only zoom
const nscoord fontSize = nsStyleFont::UnZoomText(parentContext->PresContext(), fontStyle->mFont.size);
gfxFontStyle style(fontStyle->mFont.style, gfxFontStyle style(fontStyle->mFont.style,
fontStyle->mFont.weight, fontStyle->mFont.weight,
NSAppUnitsToFloatPixels(fontStyle->mFont.size,aupdp), NSAppUnitsToFloatPixels(fontSize, aupcp),
langGroup, langGroup,
fontStyle->mFont.sizeAdjust, fontStyle->mFont.sizeAdjust,
fontStyle->mFont.systemFont, fontStyle->mFont.systemFont,