Index: ui/gfx/render_text_win.cc |
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc |
index e76e6db39e8a55af31a8b1a0a1e0ad349bd86953..f7d5ce96ec66f985b8b97ebd973fd878024ead65 100644 |
--- a/ui/gfx/render_text_win.cc |
+++ b/ui/gfx/render_text_win.cc |
@@ -38,29 +38,13 @@ const size_t kMaxRuns = 10000; |
// The maximum number of glyphs per run; ScriptShape fails on larger values. |
const size_t kMaxGlyphs = 65535; |
-// Changes |font| to have the specified |font_size| (or |font_height| on Windows |
-// XP) and |font_style| if it is not the case already. Only considers bold and |
-// italic styles, since the underlined style has no effect on glyph shaping. |
-void DeriveFontIfNecessary(int font_size, |
- int font_height, |
- int font_style, |
- Font* font) { |
+// Changes |font| to the specified |font_height| and bold/italic |font_style|. |
+// Underlined styling is not considered, as it has no effect on glyph shaping. |
+void DeriveFontIfNecessary(int height, int style, Font* font) { |
const int kStyleMask = (Font::BOLD | Font::ITALIC); |
- const int target_style = (font_style & kStyleMask); |
- |
- // On Windows XP, the font must be resized using |font_height| instead of |
- // |font_size| to match GDI behavior. |
- if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
- PlatformFontWin* platform_font = |
- static_cast<PlatformFontWin*>(font->platform_font()); |
- *font = platform_font->DeriveFontWithHeight(font_height, target_style); |
- return; |
- } |
- |
- const int current_style = (font->GetStyle() & kStyleMask); |
- const int current_size = font->GetFontSize(); |
- if (current_style != target_style || current_size != font_size) |
- *font = font->Derive(font_size - current_size, target_style); |
+ PlatformFontWin* platform_font = |
+ static_cast<PlatformFontWin*>(font->platform_font()); |
+ *font = platform_font->DeriveFontWithHeight(height, style & kStyleMask); |
} |
// Returns true if |c| is a Unicode BiDi control character. |
@@ -891,8 +875,7 @@ void RenderTextWin::ItemizeLogicalText() { |
run->font = font_list().GetPrimaryFont(); |
run->font_style = (style.style(BOLD) ? Font::BOLD : 0) | |
(style.style(ITALIC) ? Font::ITALIC : 0); |
- DeriveFontIfNecessary(run->font.GetFontSize(), run->font.GetHeight(), |
- run->font_style, &run->font); |
+ DeriveFontIfNecessary(run->font.GetHeight(), run->font_style, &run->font); |
run->strike = style.style(STRIKE); |
run->diagonal_strike = style.style(DIAGONAL_STRIKE); |
run->underline = style.style(UNDERLINE); |
@@ -1119,10 +1102,9 @@ HRESULT RenderTextWin::ShapeTextRunWithFont(internal::TextRun* run, |
// Update the run's font only if necessary. If the two fonts wrap the same |
// PlatformFontWin object, their native fonts will have the same value. |
if (run->font.GetNativeFont() != font.GetNativeFont()) { |
- const int font_size = run->font.GetFontSize(); |
- const int font_height = run->font.GetHeight(); |
+ const int original_height = run->font.GetHeight(); |
run->font = font; |
- DeriveFontIfNecessary(font_size, font_height, run->font_style, &run->font); |
+ DeriveFontIfNecessary(original_height, run->font_style, &run->font); |
ScriptFreeCache(&run->script_cache); |
} |