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

Side by Side Diff: app/gfx/font_win.cc

Issue 341045: Fix up extension badge text drawing.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « app/gfx/font_skia.cc ('k') | app/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 "app/gfx/font.h" 5 #include "app/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>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 AdjustFontSize(metrics.lfMessageFont.lfHeight, 0); 104 AdjustFontSize(metrics.lfMessageFont.lfHeight, 0);
105 HFONT font = CreateFontIndirect(&metrics.lfMessageFont); 105 HFONT font = CreateFontIndirect(&metrics.lfMessageFont);
106 DLOG_ASSERT(font); 106 DLOG_ASSERT(font);
107 base_font_ref_ = Font::CreateHFontRef(font); 107 base_font_ref_ = Font::CreateHFontRef(font);
108 // base_font_ref_ is global, up the ref count so it's never deleted. 108 // base_font_ref_ is global, up the ref count so it's never deleted.
109 base_font_ref_->AddRef(); 109 base_font_ref_->AddRef();
110 } 110 }
111 return base_font_ref_; 111 return base_font_ref_;
112 } 112 }
113 113
114 std::wstring Font::FontName() { 114 const std::wstring& Font::FontName() const {
115 LOGFONT font_info; 115 return font_name();
116 GetObject(hfont(), sizeof(LOGFONT), &font_info);
117 return (std::wstring(font_info.lfFaceName));
118 } 116 }
119 117
120 int Font::FontSize() { 118 int Font::FontSize() {
121 LOGFONT font_info; 119 LOGFONT font_info;
122 GetObject(hfont(), sizeof(LOGFONT), &font_info); 120 GetObject(hfont(), sizeof(LOGFONT), &font_info);
123 long lf_height = font_info.lfHeight; 121 long lf_height = font_info.lfHeight;
124 HDC hdc = GetDC(NULL); 122 HDC hdc = GetDC(NULL);
125 int device_caps = GetDeviceCaps(hdc, LOGPIXELSY); 123 int device_caps = GetDeviceCaps(hdc, LOGPIXELSY);
126 int font_size = 0; 124 int font_size = 0;
127 if (device_caps != 0) { 125 if (device_caps != 0) {
(...skipping 10 matching lines...) Expand all
138 int ave_char_width, 136 int ave_char_width,
139 int style, 137 int style,
140 int dlu_base_x) 138 int dlu_base_x)
141 : hfont_(hfont), 139 : hfont_(hfont),
142 height_(height), 140 height_(height),
143 baseline_(baseline), 141 baseline_(baseline),
144 ave_char_width_(ave_char_width), 142 ave_char_width_(ave_char_width),
145 style_(style), 143 style_(style),
146 dlu_base_x_(dlu_base_x) { 144 dlu_base_x_(dlu_base_x) {
147 DLOG_ASSERT(hfont); 145 DLOG_ASSERT(hfont);
146
147 LOGFONT font_info;
148 GetObject(hfont(), sizeof(LOGFONT), &font_info);
149 font_name_ = std::wstring(font_info.lfFaceName);
148 } 150 }
149 151
150 Font::HFontRef::~HFontRef() { 152 Font::HFontRef::~HFontRef() {
151 DeleteObject(hfont_); 153 DeleteObject(hfont_);
152 } 154 }
153 155
154 Font Font::DeriveFont(int size_delta, int style) const { 156 Font Font::DeriveFont(int size_delta, int style) const {
155 LOGFONT font_info; 157 LOGFONT font_info;
156 GetObject(hfont(), sizeof(LOGFONT), &font_info); 158 GetObject(hfont(), sizeof(LOGFONT), &font_info);
157 font_info.lfHeight = AdjustFontSize(font_info.lfHeight, size_delta); 159 font_info.lfHeight = AdjustFontSize(font_info.lfHeight, size_delta);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 212 }
211 if (font_metrics.tmWeight >= kTextMetricWeightBold) { 213 if (font_metrics.tmWeight >= kTextMetricWeightBold) {
212 style |= Font::BOLD; 214 style |= Font::BOLD;
213 } 215 }
214 216
215 return new HFontRef(font, height, baseline, ave_char_width, style, 217 return new HFontRef(font, height, baseline, ave_char_width, style,
216 dlu_base_x); 218 dlu_base_x);
217 } 219 }
218 220
219 } // namespace gfx 221 } // namespace gfx
OLDNEW
« no previous file with comments | « app/gfx/font_skia.cc ('k') | app/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698