Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3228)

Unified Diff: app/gfx/font_skia.cc

Issue 1095004: Clamp the max size of fonts used by skia/chrome canvas. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« app/gfx/font_gtk.cc ('K') | « app/gfx/font_gtk.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/font_skia.cc
diff --git a/app/gfx/font_skia.cc b/app/gfx/font_skia.cc
index eee1238c7263a4edb251fbce7030849c1cada895..3499caaf802b118cc57355aca3c7293cd9ddb1ab 100644
--- a/app/gfx/font_skia.cc
+++ b/app/gfx/font_skia.cc
@@ -22,28 +22,6 @@ namespace {
// IsFallbackFontAllowed function in skia/ext/SkFontHost_fontconfig_direct.cpp.
const char* kFallbackFontFamilyName = "sans";
-// Pango scales font sizes. This returns the scale factor. See
-// pango_cairo_context_set_resolution for details.
-// NOTE: this isn't entirely accurate, in that Pango also consults the
-// FC_PIXEL_SIZE first (see get_font_size in pangocairo-fcfont), but this
-// seems to give us the same sizes as used by Pango for all our fonts in both
-// English and Thia.
-static double GetPangoScaleFactor() {
- static float scale_factor = 0;
- static bool determined_scale = false;
- if (!determined_scale) {
- PangoContext* context = gdk_pango_context_get();
- scale_factor = pango_cairo_context_get_resolution(context);
- g_object_unref(context);
- if (scale_factor <= 0)
- scale_factor = 1;
- else
- scale_factor /= 72.0;
- determined_scale = true;
- }
- return scale_factor;
-}
-
// Retrieves the pango metrics for a pango font description. Caches the metrics
// and never frees them. The metrics objects are relatively small and
// very expensive to look up.
@@ -190,7 +168,7 @@ Font Font::DeriveFont(int size_delta, int style) const {
void Font::PaintSetup(SkPaint* paint) const {
paint->setAntiAlias(false);
paint->setSubpixelText(false);
- paint->setTextSize(SkFloatToScalar(font_size_ * GetPangoScaleFactor()));
+ paint->setTextSize(SkFloatToScalar(font_size_ * Font::GetPangoScaleFactor()));
paint->setTypeface(typeface_);
paint->setFakeBoldText((BOLD & style_) && !typeface_->isBold());
paint->setTextSkewX((ITALIC & style_) && !typeface_->isItalic() ?
« app/gfx/font_gtk.cc ('K') | « app/gfx/font_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698