Bug 839956 - Choose SVG text font size scale factor without regard to devPixelsPerPx. r=longsonr
authorCameron McCormack <cam@mcc.id.au>
Wed, 10 Apr 2013 22:58:56 +1000
changeset 128317 0ff1755d6359bfbbb9585d7a041c57adfb06a6c7
parent 128316 dffb1a1c78737b1e9da04d9abab81030f389a5fd
child 128318 645b63111263268c87a74abc664a2311003e19c6
push idunknown
push userunknown
push dateunknown
reviewerslongsonr
bugs839956
milestone23.0a1
Bug 839956 - Choose SVG text font size scale factor without regard to devPixelsPerPx. r=longsonr
layout/svg/nsSVGTextFrame2.cpp
--- a/layout/svg/nsSVGTextFrame2.cpp
+++ b/layout/svg/nsSVGTextFrame2.cpp
@@ -4851,16 +4851,24 @@ nsSVGTextFrame2::UpdateFontSizeScaleFact
   double maxSize = presContext->AppUnitsToFloatCSSPixels(max) / textZoom;
 
   // The context scale is the ratio of the length of the transformed
   // diagonal vector (1,1) to the length of the untransformed diagonal
   // (which is sqrt(2)).
   gfxPoint p = m.Transform(gfxPoint(1, 1)) - m.Transform(gfxPoint(0, 0));
   double contextScale = SVGContentUtils::ComputeNormalizedHypotenuse(p.x, p.y);
 
+  // But we want to ignore any scaling required due to HiDPI displays, since
+  // regular CSS text frames will still create text runs using the font size
+  // in CSS pixels, and we want SVG text to have the same rendering as HTML
+  // text for regular font sizes.
+  float cssPxPerDevPx =
+    presContext->AppUnitsToFloatCSSPixels(presContext->AppUnitsPerDevPixel());
+  contextScale *= cssPxPerDevPx;
+
   double minTextRunSize = minSize * contextScale;
   double maxTextRunSize = maxSize * contextScale;
 
   if (minTextRunSize >= CLAMP_MIN_SIZE &&
       maxTextRunSize <= CLAMP_MAX_SIZE) {
     // We are already in the ideal font size range for all text frames,
     // so we only have to take into account the contextScale.
     mFontSizeScaleFactor = contextScale;