| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2  * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 
| 3  * | 3  * | 
| 4  * Redistribution and use in source and binary forms, with or without | 4  * Redistribution and use in source and binary forms, with or without | 
| 5  * modification, are permitted provided that the following conditions are | 5  * modification, are permitted provided that the following conditions are | 
| 6  * met: | 6  * met: | 
| 7  * | 7  * | 
| 8  *     * Redistributions of source code must retain the above copyright | 8  *     * Redistributions of source code must retain the above copyright | 
| 9  * notice, this list of conditions and the following disclaimer. | 9  * notice, this list of conditions and the following disclaimer. | 
| 10  *     * Redistributions in binary form must reproduce the above | 10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 214 | 214 | 
| 215         characters += n; | 215         characters += n; | 
| 216         length -= n; | 216         length -= n; | 
| 217     } | 217     } | 
| 218 | 218 | 
| 219     return true; | 219     return true; | 
| 220 } | 220 } | 
| 221 | 221 | 
| 222 void SimpleFontData::determinePitch() | 222 void SimpleFontData::determinePitch() | 
| 223 { | 223 { | 
| 224 #if OS(WINDOWS) |  | 
| 225     // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that. |  | 
| 226     HWndDC dc(0); |  | 
| 227     HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont()); |  | 
| 228 |  | 
| 229     // Yes, this looks backwards, but the fixed pitch bit is actually set if the
      font |  | 
| 230     // is *not* fixed pitch. Unbelievable but true. |  | 
| 231     TEXTMETRIC textMetric = { 0 }; |  | 
| 232     if (!GetTextMetrics(dc, &textMetric)) { |  | 
| 233         if (FontPlatformData::ensureFontLoaded(m_platformData.hfont())) { |  | 
| 234             // Retry GetTextMetrics. |  | 
| 235             // FIXME: Handle gracefully the error if this call also fails. |  | 
| 236             // See http://crbug.com/6401. |  | 
| 237             if (!GetTextMetrics(dc, &textMetric)) |  | 
| 238                 LOG_ERROR("Unable to get the text metrics after second attempt")
     ; |  | 
| 239         } |  | 
| 240     } |  | 
| 241 |  | 
| 242     m_treatAsFixedPitch = !(textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH); |  | 
| 243 |  | 
| 244     SelectObject(dc, oldFont); |  | 
| 245 #else |  | 
| 246     m_treatAsFixedPitch = platformData().isFixedPitch(); | 224     m_treatAsFixedPitch = platformData().isFixedPitch(); | 
| 247 #endif |  | 
| 248 } | 225 } | 
| 249 | 226 | 
| 250 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const | 227 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const | 
| 251 { | 228 { | 
| 252     if (!m_platformData.size()) | 229     if (!m_platformData.size()) | 
| 253         return FloatRect(); | 230         return FloatRect(); | 
| 254 | 231 | 
| 255     SkASSERT(sizeof(glyph) == 2); // compile-time assert | 232     SkASSERT(sizeof(glyph) == 2); // compile-time assert | 
| 256 | 233 | 
| 257     SkPaint paint; | 234     SkPaint paint; | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 309     paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 286     paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 
| 310     if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { | 287     if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { | 
| 311         addResult.iterator->value = true; | 288         addResult.iterator->value = true; | 
| 312         return true; | 289         return true; | 
| 313     } | 290     } | 
| 314     return false; | 291     return false; | 
| 315 } | 292 } | 
| 316 #endif | 293 #endif | 
| 317 | 294 | 
| 318 } // namespace WebCore | 295 } // namespace WebCore | 
| OLD | NEW | 
|---|