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

Side by Side Diff: src/ports/SkTypeface_win_dw.cpp

Issue 1218043004: Add check that Dwrite glyph fits in unicode table. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: code review 2 Created 5 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
« 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 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTypes.h" 8 #include "SkTypes.h"
9 // SkTypes will include Windows.h, which will pull in all of the GDI defines. 9 // SkTypes will include Windows.h, which will pull in all of the GDI defines.
10 // GDI #defines GetGlyphIndices to GetGlyphIndicesA or GetGlyphIndicesW, but 10 // GDI #defines GetGlyphIndices to GetGlyphIndicesA or GetGlyphIndicesW, but
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 using namespace skia_advanced_typeface_metrics_utils; 279 using namespace skia_advanced_typeface_metrics_utils;
280 280
281 // Construct Glyph to Unicode table. 281 // Construct Glyph to Unicode table.
282 // Unicode code points that require conjugate pairs in utf16 are not 282 // Unicode code points that require conjugate pairs in utf16 are not
283 // supported. 283 // supported.
284 // TODO(bungeman): This never does what anyone wants. 284 // TODO(bungeman): This never does what anyone wants.
285 // What is really wanted is the text to glyphs mapping 285 // What is really wanted is the text to glyphs mapping
286 static void populate_glyph_to_unicode(IDWriteFontFace* fontFace, 286 static void populate_glyph_to_unicode(IDWriteFontFace* fontFace,
287 const unsigned glyphCount, 287 const unsigned glyphCount,
288 SkTDArray<SkUnichar>* glyphToUnicode) { 288 SkTDArray<SkUnichar>* glyphToUnicode) {
289 HRESULT hr = S_OK;
290
291 //Do this like free type instead 289 //Do this like free type instead
292 SkAutoTMalloc<SkUnichar> glyphToUni(glyphCount); 290 SkAutoTMalloc<SkUnichar> glyphToUni(glyphCount);
293 int maxGlyph = -1; 291 int maxGlyph = -1;
294 for (UINT32 c = 0; c < 0x10FFFF; ++c) { 292 for (UINT32 c = 0; c < 0x10FFFF; ++c) {
295 UINT16 glyph; 293 UINT16 glyph = 0;
296 hr = fontFace->GetGlyphIndices(&c, 1, &glyph); 294 HRVM(fontFace->GetGlyphIndices(&c, 1, &glyph),
297 SkASSERT(glyph < glyphCount); 295 "Failed to get glyph index.");
296 // Intermittent DW bug on Windows 10. See crbug.com/470146.
297 if (glyph >= glyphCount) {
298 return;
299 }
298 if (0 < glyph) { 300 if (0 < glyph) {
299 maxGlyph = SkTMax(static_cast<int>(glyph), maxGlyph); 301 maxGlyph = SkTMax(static_cast<int>(glyph), maxGlyph);
300 glyphToUni[glyph] = c; 302 glyphToUni[glyph] = c;
301 } 303 }
302 } 304 }
303 305
304 SkTDArray<SkUnichar>(glyphToUni, maxGlyph + 1).swap(*glyphToUnicode); 306 SkTDArray<SkUnichar>(glyphToUni, maxGlyph + 1).swap(*glyphToUnicode);
305 } 307 }
306 308
307 static bool getWidthAdvance(IDWriteFontFace* fontFace, int gId, int16_t* advance ) { 309 static bool getWidthAdvance(IDWriteFontFace* fontFace, int gId, int16_t* advance ) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 getAdvanceData(fDWriteFontFace.get(), 456 getAdvanceData(fDWriteFontFace.get(),
455 glyphCount, 457 glyphCount,
456 glyphIDs, 458 glyphIDs,
457 glyphIDsCount, 459 glyphIDsCount,
458 getWidthAdvance)); 460 getWidthAdvance));
459 } 461 }
460 } 462 }
461 463
462 return info; 464 return info;
463 } 465 }
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