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

Side by Side Diff: gfx/font_win.cc

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gfx/font_skia.cc ('k') | gfx/gfx.gyp » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "gfx/font.h" 5 #include "gfx/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>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/win_util.h" 14 #include "base/win_util.h"
15 #include "gfx/canvas_skia.h" 15 #include "gfx/canvas.h"
16 16
17 namespace gfx { 17 namespace gfx {
18 18
19 // static 19 // static
20 Font::HFontRef* Font::base_font_ref_; 20 Font::HFontRef* Font::base_font_ref_;
21 21
22 // static 22 // static
23 Font::AdjustFontCallback Font::adjust_font_callback = NULL; 23 Font::AdjustFontCallback Font::adjust_font_callback = NULL;
24 Font::GetMinimumFontSizeCallback Font::get_minimum_font_size_callback = NULL; 24 Font::GetMinimumFontSizeCallback Font::get_minimum_font_size_callback = NULL;
25 25
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 font_info.lfUnderline = ((style & UNDERLINED) == UNDERLINED); 164 font_info.lfUnderline = ((style & UNDERLINED) == UNDERLINED);
165 font_info.lfItalic = ((style & ITALIC) == ITALIC); 165 font_info.lfItalic = ((style & ITALIC) == ITALIC);
166 font_info.lfWeight = (style & BOLD) ? FW_BOLD : FW_NORMAL; 166 font_info.lfWeight = (style & BOLD) ? FW_BOLD : FW_NORMAL;
167 167
168 HFONT hfont = CreateFontIndirect(&font_info); 168 HFONT hfont = CreateFontIndirect(&font_info);
169 return Font(CreateHFontRef(hfont)); 169 return Font(CreateHFontRef(hfont));
170 } 170 }
171 171
172 int Font::GetStringWidth(const std::wstring& text) const { 172 int Font::GetStringWidth(const std::wstring& text) const {
173 int width = 0, height = 0; 173 int width = 0, height = 0;
174 CanvasSkia::SizeStringInt(text, *this, &width, &height, 174 Canvas::SizeStringInt(text, *this, &width, &height, gfx::Canvas::NO_ELLIPSIS);
175 gfx::Canvas::NO_ELLIPSIS);
176 return width; 175 return width;
177 } 176 }
178 177
179 Font::HFontRef* Font::CreateHFontRef(HFONT font) { 178 Font::HFontRef* Font::CreateHFontRef(HFONT font) {
180 TEXTMETRIC font_metrics; 179 TEXTMETRIC font_metrics;
181 HDC screen_dc = GetDC(NULL); 180 HDC screen_dc = GetDC(NULL);
182 HFONT previous_font = static_cast<HFONT>(SelectObject(screen_dc, font)); 181 HFONT previous_font = static_cast<HFONT>(SelectObject(screen_dc, font));
183 int last_map_mode = SetMapMode(screen_dc, MM_TEXT); 182 int last_map_mode = SetMapMode(screen_dc, MM_TEXT);
184 GetTextMetrics(screen_dc, &font_metrics); 183 GetTextMetrics(screen_dc, &font_metrics);
185 // Yes, this is how Microsoft recommends calculating the dialog unit 184 // Yes, this is how Microsoft recommends calculating the dialog unit
(...skipping 21 matching lines...) Expand all
207 } 206 }
208 if (font_metrics.tmWeight >= kTextMetricWeightBold) { 207 if (font_metrics.tmWeight >= kTextMetricWeightBold) {
209 style |= Font::BOLD; 208 style |= Font::BOLD;
210 } 209 }
211 210
212 return new HFontRef(font, height, baseline, ave_char_width, style, 211 return new HFontRef(font, height, baseline, ave_char_width, style,
213 dlu_base_x); 212 dlu_base_x);
214 } 213 }
215 214
216 } // namespace gfx 215 } // namespace gfx
OLDNEW
« no previous file with comments | « gfx/font_skia.cc ('k') | gfx/gfx.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698