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

Side by Side Diff: ui/base/l10n/l10n_util_win.cc

Issue 2695523002: Fix font sizes being incorrect when using --force-device-scale-factor. (Closed)
Patch Set: adjust comments Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/base/l10n/l10n_util_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/l10n/l10n_util_win.h" 5 #include "ui/base/l10n/l10n_util_win.h"
6 6
7 #include <windowsx.h> 7 #include <windowsx.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <iterator> 9 #include <iterator>
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ui_font_family.empty()) 148 ui_font_family.empty())
149 return false; 149 return false;
150 if (override_font_family && font_size_scaler) { 150 if (override_font_family && font_size_scaler) {
151 override_font_family->swap(ui_font_family); 151 override_font_family->swap(ui_font_family);
152 *font_size_scaler = scaler100 / 100.0; 152 *font_size_scaler = scaler100 / 100.0;
153 } 153 }
154 return true; 154 return true;
155 } 155 }
156 156
157 void AdjustUIFont(LOGFONT* logfont) { 157 void AdjustUIFont(LOGFONT* logfont) {
158 float dpi_scale = display::win::GetDPIScale(); 158 // Use the unforced scale so the font will be normalized to the correct DIP
159 if (display::Display::HasForceDeviceScaleFactor()) { 159 // value. That way it'll appear the right size when the forced scale is
160 // If the scale is forced, we don't need to adjust it here. 160 // applied later (when coverting to pixels).
161 dpi_scale = 1.0f; 161 AdjustUIFontForDIP(display::win::GetUnforcedDeviceScaleFactor(), logfont);
robliao 2017/02/13 17:57:33 Just to make sure I understand this correctly, the
Bret 2017/02/14 20:29:20 Our font system works in DIPs, as expected. This v
robliao 2017/02/14 20:43:09 That's fun. I think what I meant to say is let's p
162 }
163 AdjustUIFontForDIP(dpi_scale, logfont);
164 } 162 }
165 163
166 void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont) { 164 void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont) {
167 base::string16 ui_font_family = L"default"; 165 base::string16 ui_font_family = L"default";
168 double ui_font_size_scaler = 1; 166 double ui_font_size_scaler = 1;
169 if (NeedOverrideDefaultUIFont(&ui_font_family, &ui_font_size_scaler) || 167 if (NeedOverrideDefaultUIFont(&ui_font_family, &ui_font_size_scaler) ||
170 dpi_scale != 1) { 168 dpi_scale != 1) {
171 AdjustLogFont(ui_font_family, ui_font_size_scaler, dpi_scale, logfont); 169 AdjustLogFont(ui_font_family, ui_font_size_scaler, dpi_scale, logfont);
172 } 170 }
173 } 171 }
(...skipping 24 matching lines...) Expand all
198 } else { 196 } else {
199 NOTREACHED() << "Failed to determine the UI language for locale override."; 197 NOTREACHED() << "Failed to determine the UI language for locale override.";
200 } 198 }
201 } 199 }
202 200
203 const std::vector<std::string>& GetLocaleOverrides() { 201 const std::vector<std::string>& GetLocaleOverrides() {
204 return override_locale_holder.Get().value(); 202 return override_locale_holder.Get().value();
205 } 203 }
206 204
207 } // namespace l10n_util 205 } // namespace l10n_util
OLDNEW
« no previous file with comments | « no previous file | ui/base/l10n/l10n_util_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698