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

Side by Side Diff: Source/core/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp

Issue 17080004: Move windows specific isFixedPitch to FontPlatformData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All Rights Reserved.
3 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. 3 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 bool SimpleFontData::containsCharacters(const UChar* characters, int length) con st 121 bool SimpleFontData::containsCharacters(const UChar* characters, int length) con st
122 { 122 {
123 // This used to be implemented with IMLangFontLink2, but since that code has 123 // This used to be implemented with IMLangFontLink2, but since that code has
124 // been disabled, this would always return false anyway. 124 // been disabled, this would always return false anyway.
125 return false; 125 return false;
126 } 126 }
127 127
128 void SimpleFontData::determinePitch() 128 void SimpleFontData::determinePitch()
129 { 129 {
130 // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that. 130 m_treatAsFixedPitch = platformData().isFixedPitch();
131 HWndDC dc(0);
132 HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
133
134 // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
135 // is *not* fixed pitch. Unbelievable but true.
136 TEXTMETRIC textMetric = {0};
137 if (!GetTextMetrics(dc, &textMetric)) {
138 if (FontPlatformData::ensureFontLoaded(m_platformData.hfont())) {
139 // Retry GetTextMetrics.
140 // FIXME: Handle gracefully the error if this call also fails.
141 // See http://crbug.com/6401.
142 if (!GetTextMetrics(dc, &textMetric))
143 LOG_ERROR("Unable to get the text metrics after second attempt") ;
144 }
145 }
146
147 m_treatAsFixedPitch = ((textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0 );
148
149 SelectObject(dc, oldFont);
150 } 131 }
151 132
152 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const 133 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
153 { 134 {
154 HWndDC hdc(0); 135 HWndDC hdc(0);
155 SetGraphicsMode(hdc, GM_ADVANCED); 136 SetGraphicsMode(hdc, GM_ADVANCED);
156 HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont()); 137 HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
157 138
158 GLYPHMETRICS gdiMetrics; 139 GLYPHMETRICS gdiMetrics;
159 static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 }; 140 static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 LOG_ERROR("Unable to get the char width after second attempt"); 172 LOG_ERROR("Unable to get the char width after second attempt");
192 } 173 }
193 } 174 }
194 175
195 SelectObject(dc, oldFont); 176 SelectObject(dc, oldFont);
196 177
197 return static_cast<float>(width); 178 return static_cast<float>(width);
198 } 179 }
199 180
200 } // namespace WebCore 181 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698