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

Side by Side Diff: Source/platform/fonts/FontCustomPlatformData.cpp

Issue 983973004: Provide user friendly messages for OTS parsing of fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Comment fixes Created 5 years, 7 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) 2007 Apple Computer, Inc. 2 * Copyright (C) 2007 Apple Computer, Inc.
3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved. 3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4 * Copyright (C) 2010 Company 100, Inc. 4 * Copyright (C) 2010 Company 100, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontM anager()->legacyCreateTypeface(name.c_str(), static_cast<SkTypeface::Style>(styl e))); 78 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontM anager()->legacyCreateTypeface(name.c_str(), static_cast<SkTypeface::Style>(styl e)));
79 syntheticBold = false; 79 syntheticBold = false;
80 syntheticItalic = false; 80 syntheticItalic = false;
81 return FontPlatformData(typeface.release(), "", size, syntheticBold, syntheticItalic, orientation); 81 return FontPlatformData(typeface.release(), "", size, syntheticBold, syntheticItalic, orientation);
82 } 82 }
83 } 83 }
84 #endif 84 #endif
85 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB old(), italic && !m_typeface->isItalic(), orientation); 85 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB old(), italic && !m_typeface->isItalic(), orientation);
86 } 86 }
87 87
88 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer) 88 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer, String& otsParseMessage)
89 { 89 {
90 ASSERT_ARG(buffer, buffer); 90 ASSERT_ARG(buffer, buffer);
91 91
92 OpenTypeSanitizer sanitizer(buffer); 92 OpenTypeSanitizer sanitizer(buffer);
93 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize(); 93 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
94 if (!transcodeBuffer) 94
95 if (!transcodeBuffer) {
jungshik at Google 2015/05/15 19:17:20 I took a look at sanitize() to find that there are
h.joshi 2015/05/18 05:58:28 Method "setParsingError" was not called at right p
96 otsParseMessage = sanitizer.getErrorString();
95 return nullptr; // validation failed. 97 return nullptr; // validation failed.
98 }
96 buffer = transcodeBuffer.get(); 99 buffer = transcodeBuffer.get();
97 100
98 SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get()); 101 SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get());
99 #if OS(WIN) 102 #if OS(WIN)
100 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager() ->createFromStream(stream)); 103 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager() ->createFromStream(stream));
101 #else 104 #else
102 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream)) ; 105 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream)) ;
103 #endif 106 #endif
104 if (!typeface) 107 if (!typeface)
105 return nullptr; 108 return nullptr;
106 109
107 return adoptPtr(new FontCustomPlatformData(typeface.release())); 110 return adoptPtr(new FontCustomPlatformData(typeface.release()));
108 } 111 }
109 112
110 bool FontCustomPlatformData::supportsFormat(const String& format) 113 bool FontCustomPlatformData::supportsFormat(const String& format)
111 { 114 {
112 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format); 115 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format);
113 } 116 }
114 117
115 } // namespace blink 118 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698