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

Unified Diff: ui/gfx/pango_util.cc

Issue 377413002: linux: Round font sizes when going from points to pixels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « ui/gfx/pango_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/pango_util.cc
diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc
index d3f59c44474af3be574da475f96d57eceb342489..42dfc07f05600d17331692801c0385006edd62f1 100644
--- a/ui/gfx/pango_util.cc
+++ b/ui/gfx/pango_util.cc
@@ -230,17 +230,15 @@ void SetUpPangoLayout(
pango_layout_set_font_description(layout, desc.get());
}
-size_t GetPangoFontSizeInPixels(PangoFontDescription* pango_font) {
- size_t size_in_pixels = pango_font_description_get_size(pango_font);
- if (pango_font_description_get_size_is_absolute(pango_font)) {
- // If the size is absolute, then it's in Pango units rather than points.
- // There are PANGO_SCALE Pango units in a device unit (pixel).
- size_in_pixels /= PANGO_SCALE;
- } else {
- // Otherwise, we need to convert from points.
- size_in_pixels = size_in_pixels * GetPixelsInPoint() / PANGO_SCALE;
- }
- return size_in_pixels;
+int GetPangoFontSizeInPixels(PangoFontDescription* pango_font) {
+ // If the size is absolute, then it's in Pango units rather than points. There
+ // are PANGO_SCALE Pango units in a device unit (pixel).
+ if (pango_font_description_get_size_is_absolute(pango_font))
+ return pango_font_description_get_size(pango_font) / PANGO_SCALE;
+
+ // Otherwise, we need to convert from points.
+ return static_cast<int>(GetPixelsInPoint() *
+ pango_font_description_get_size(pango_font) / PANGO_SCALE + 0.5);
}
PangoFontMetrics* GetPangoFontMetrics(PangoFontDescription* desc) {
« no previous file with comments | « ui/gfx/pango_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698