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

Side by Side Diff: chrome/common/gfx/chrome_font_win.cc

Issue 71005: Merge 13114 - Make the font family and the font size used in dom UI localizab... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: '' Created 11 years, 8 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 | « chrome/common/gfx/chrome_font.h ('k') | chrome/common/resource_bundle.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/common/gfx/chrome_font.h" 5 #include "chrome/common/gfx/chrome_font.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <math.h> 8 #include <math.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 font_info.lfHeight += size_delta; 141 font_info.lfHeight += size_delta;
142 } 142 }
143 // Even with "Small Fonts", the smallest readable font size is 5. It is easy 143 // Even with "Small Fonts", the smallest readable font size is 5. It is easy
144 // to create a non-drawing font and forget about the fact that text should be 144 // to create a non-drawing font and forget about the fact that text should be
145 // drawn in the UI. This test ensures that the font will be readable. 145 // drawn in the UI. This test ensures that the font will be readable.
146 DCHECK_GE(abs(font_info.lfHeight), 5); 146 DCHECK_GE(abs(font_info.lfHeight), 5);
147 font_info.lfUnderline = ((style & UNDERLINED) == UNDERLINED); 147 font_info.lfUnderline = ((style & UNDERLINED) == UNDERLINED);
148 font_info.lfItalic = ((style & ITALIC) == ITALIC); 148 font_info.lfItalic = ((style & ITALIC) == ITALIC);
149 font_info.lfWeight = (style & BOLD) ? FW_BOLD : FW_NORMAL; 149 font_info.lfWeight = (style & BOLD) ? FW_BOLD : FW_NORMAL;
150 150
151 if (style & WEB) {
152 font_info.lfPitchAndFamily = FF_SWISS;
153 wcscpy_s(font_info.lfFaceName,
154 l10n_util::GetString(IDS_WEB_FONT_FAMILY).c_str());
155 }
156
157 HFONT hfont = CreateFontIndirect(&font_info); 151 HFONT hfont = CreateFontIndirect(&font_info);
158 return ChromeFont(CreateHFontRef(hfont)); 152 return ChromeFont(CreateHFontRef(hfont));
159 } 153 }
160 154
161 int ChromeFont::GetStringWidth(const std::wstring& text) const { 155 int ChromeFont::GetStringWidth(const std::wstring& text) const {
162 int width = 0; 156 int width = 0;
163 HDC dc = GetDC(NULL); 157 HDC dc = GetDC(NULL);
164 HFONT previous_font = static_cast<HFONT>(SelectObject(dc, hfont())); 158 HFONT previous_font = static_cast<HFONT>(SelectObject(dc, hfont()));
165 SIZE size; 159 SIZE size;
166 if (GetTextExtentPoint32(dc, text.c_str(), static_cast<int>(text.size()), 160 if (GetTextExtentPoint32(dc, text.c_str(), static_cast<int>(text.size()),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (font_metrics.tmUnderlined) { 197 if (font_metrics.tmUnderlined) {
204 style |= ChromeFont::UNDERLINED; 198 style |= ChromeFont::UNDERLINED;
205 } 199 }
206 if (font_metrics.tmWeight >= kTextMetricWeightBold) { 200 if (font_metrics.tmWeight >= kTextMetricWeightBold) {
207 style |= ChromeFont::BOLD; 201 style |= ChromeFont::BOLD;
208 } 202 }
209 203
210 return new HFontRef(font, height, baseline, ave_char_width, style, 204 return new HFontRef(font, height, baseline, ave_char_width, style,
211 dlu_base_x); 205 dlu_base_x);
212 } 206 }
OLDNEW
« no previous file with comments | « chrome/common/gfx/chrome_font.h ('k') | chrome/common/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698