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

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

Issue 660173002: Type conversion fixes, ui/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 | « ui/base/ime/remote_input_method_win.cc ('k') | ui/base/resource/data_pack.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 bool IsFontPresent(const wchar_t* font_name) { 49 bool IsFontPresent(const wchar_t* font_name) {
50 HFONT hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50 HFONT hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51 font_name); 51 font_name);
52 if (hfont == NULL) 52 if (hfont == NULL)
53 return false; 53 return false;
54 HDC dc = GetDC(0); 54 HDC dc = GetDC(0);
55 HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont)); 55 HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
56 WCHAR actual_font_name[LF_FACESIZE]; 56 WCHAR actual_font_name[LF_FACESIZE];
57 DWORD size_ret = GetTextFace(dc, LF_FACESIZE, actual_font_name); 57 int size_ret = GetTextFace(dc, LF_FACESIZE, actual_font_name);
58 actual_font_name[LF_FACESIZE - 1] = 0;
59 SelectObject(dc, oldFont); 58 SelectObject(dc, oldFont);
60 DeleteObject(hfont); 59 DeleteObject(hfont);
61 ReleaseDC(0, dc); 60 ReleaseDC(0, dc);
62 // We don't have to worry about East Asian fonts with locale-dependent 61 // We don't have to worry about East Asian fonts with locale-dependent
63 // names here. 62 // names here.
64 return wcscmp(font_name, actual_font_name) == 0; 63 return (size_ret != 0) && wcscmp(font_name, actual_font_name) == 0;
65 } 64 }
66 65
67 class OverrideLocaleHolder { 66 class OverrideLocaleHolder {
68 public: 67 public:
69 OverrideLocaleHolder() {} 68 OverrideLocaleHolder() {}
70 const std::vector<std::string>& value() const { return value_; } 69 const std::vector<std::string>& value() const { return value_; }
71 void swap_value(std::vector<std::string>* override_value) { 70 void swap_value(std::vector<std::string>* override_value) {
72 value_.swap(*override_value); 71 value_.swap(*override_value);
73 } 72 }
74 private: 73 private:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ui_font_family.empty()) 146 ui_font_family.empty())
148 return false; 147 return false;
149 if (override_font_family && font_size_scaler) { 148 if (override_font_family && font_size_scaler) {
150 override_font_family->swap(ui_font_family); 149 override_font_family->swap(ui_font_family);
151 *font_size_scaler = scaler100 / 100.0; 150 *font_size_scaler = scaler100 / 100.0;
152 } 151 }
153 return true; 152 return true;
154 } 153 }
155 154
156 void AdjustUIFont(LOGFONT* logfont) { 155 void AdjustUIFont(LOGFONT* logfont) {
157 double dpi_scale = gfx::GetDPIScale(); 156 float dpi_scale = gfx::GetDPIScale();
158 if (gfx::Display::HasForceDeviceScaleFactor()) { 157 if (gfx::Display::HasForceDeviceScaleFactor()) {
159 // If the scale is forced, we don't need to adjust it here. 158 // If the scale is forced, we don't need to adjust it here.
160 dpi_scale = 1.0; 159 dpi_scale = 1.0f;
161 } 160 }
162 AdjustUIFontForDIP(dpi_scale, logfont); 161 AdjustUIFontForDIP(dpi_scale, logfont);
163 } 162 }
164 163
165 void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont) { 164 void AdjustUIFontForDIP(float dpi_scale, LOGFONT* logfont) {
166 base::string16 ui_font_family = L"default"; 165 base::string16 ui_font_family = L"default";
167 double ui_font_size_scaler = 1; 166 double ui_font_size_scaler = 1;
168 if (NeedOverrideDefaultUIFont(&ui_font_family, &ui_font_size_scaler) || 167 if (NeedOverrideDefaultUIFont(&ui_font_family, &ui_font_size_scaler) ||
169 dpi_scale != 1) { 168 dpi_scale != 1) {
170 AdjustLogFont(ui_font_family, ui_font_size_scaler, dpi_scale, logfont); 169 AdjustLogFont(ui_font_family, ui_font_size_scaler, dpi_scale, logfont);
(...skipping 26 matching lines...) Expand all
197 } else { 196 } else {
198 NOTREACHED() << "Failed to determine the UI language for locale override."; 197 NOTREACHED() << "Failed to determine the UI language for locale override.";
199 } 198 }
200 } 199 }
201 200
202 const std::vector<std::string>& GetLocaleOverrides() { 201 const std::vector<std::string>& GetLocaleOverrides() {
203 return override_locale_holder.Get().value(); 202 return override_locale_holder.Get().value();
204 } 203 }
205 204
206 } // namespace l10n_util 205 } // namespace l10n_util
OLDNEW
« no previous file with comments | « ui/base/ime/remote_input_method_win.cc ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698