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

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

Issue 28181: A fix for Issue 4400 (or maybe 4222).... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 25 matching lines...) Expand all
36 36
37 int ChromeFont::baseline() const { 37 int ChromeFont::baseline() const {
38 return font_ref_->baseline(); 38 return font_ref_->baseline();
39 } 39 }
40 40
41 int ChromeFont::ave_char_width() const { 41 int ChromeFont::ave_char_width() const {
42 return font_ref_->ave_char_width(); 42 return font_ref_->ave_char_width();
43 } 43 }
44 44
45 int ChromeFont::GetExpectedTextWidth(int length) const { 45 int ChromeFont::GetExpectedTextWidth(int length) const {
46 return length * font_ref_->dlu_base_x(); 46 return length * std::min(font_ref_->dlu_base_x(), ave_char_width());
47 } 47 }
48 48
49 int ChromeFont::style() const { 49 int ChromeFont::style() const {
50 return font_ref_->style(); 50 return font_ref_->style();
51 } 51 }
52 52
53 NativeFont ChromeFont::nativeFont() const { 53 NativeFont ChromeFont::nativeFont() const {
54 return hfont(); 54 return hfont();
55 } 55 }
56 56
(...skipping 11 matching lines...) Expand all
68 long lf_height = -MulDiv(font_size, GetDeviceCaps(hdc, LOGPIXELSY), 72); 68 long lf_height = -MulDiv(font_size, GetDeviceCaps(hdc, LOGPIXELSY), 72);
69 ReleaseDC(NULL, hdc); 69 ReleaseDC(NULL, hdc);
70 HFONT hf = ::CreateFont(lf_height, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70 HFONT hf = ::CreateFont(lf_height, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 font_name.c_str()); 71 font_name.c_str());
72 return ChromeFont::CreateFont(hf); 72 return ChromeFont::CreateFont(hf);
73 } 73 }
74 74
75 // static 75 // static
76 ChromeFont::HFontRef* ChromeFont::GetBaseFontRef() { 76 ChromeFont::HFontRef* ChromeFont::GetBaseFontRef() {
77 if (base_font_ref_ == NULL) { 77 if (base_font_ref_ == NULL) {
78 » » NONCLIENTMETRICS metrics; 78 NONCLIENTMETRICS metrics;
79 win_util::GetNonClientMetrics(&metrics); 79 win_util::GetNonClientMetrics(&metrics);
80 80
81 // See comment in ChromeFont::DeriveFont() about font size. 81 // See comment in ChromeFont::DeriveFont() about font size.
82 DCHECK_GE(abs(metrics.lfMessageFont.lfHeight), 5); 82 DCHECK_GE(abs(metrics.lfMessageFont.lfHeight), 5);
83 HFONT font = CreateFontIndirect(&metrics.lfMessageFont); 83 HFONT font = CreateFontIndirect(&metrics.lfMessageFont);
84 DLOG_ASSERT(font); 84 DLOG_ASSERT(font);
85 base_font_ref_ = ChromeFont::CreateHFontRef(font); 85 base_font_ref_ = ChromeFont::CreateHFontRef(font);
86 // base_font_ref_ is global, up the ref count so it's never deleted. 86 // base_font_ref_ is global, up the ref count so it's never deleted.
87 base_font_ref_->AddRef(); 87 base_font_ref_->AddRef();
88 } 88 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 if (font_metrics.tmWeight >= kTextMetricWeightBold) { 206 if (font_metrics.tmWeight >= kTextMetricWeightBold) {
207 style |= ChromeFont::BOLD; 207 style |= ChromeFont::BOLD;
208 } 208 }
209 209
210 return new HFontRef(font, height, baseline, ave_char_width, style, 210 return new HFontRef(font, height, baseline, ave_char_width, style,
211 dlu_base_x); 211 dlu_base_x);
212 } 212 }
213 213
214 214
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698