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

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: Code update for test expectation 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 || sanitizer.isParsingError()) {
96 if (sanitizer.isParsingError())
jungshik at Google 2015/05/12 20:22:48 I wonder if there's a case when transcodeBuffer==0
h.joshi 2015/05/14 04:52:15 Yes, two checks are not required. thank you. Made
97 otsParseMessage = sanitizer.getErrorString();
98
95 return nullptr; // validation failed. 99 return nullptr; // validation failed.
100 }
96 buffer = transcodeBuffer.get(); 101 buffer = transcodeBuffer.get();
97 102
98 SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get()); 103 SkMemoryStream* stream = new SkMemoryStream(buffer->getAsSkData().get());
99 #if OS(WIN) 104 #if OS(WIN)
100 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager() ->createFromStream(stream)); 105 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager() ->createFromStream(stream));
101 #else 106 #else
102 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream)) ; 107 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream)) ;
103 #endif 108 #endif
104 if (!typeface) 109 if (!typeface)
105 return nullptr; 110 return nullptr;
106 111
107 return adoptPtr(new FontCustomPlatformData(typeface.release())); 112 return adoptPtr(new FontCustomPlatformData(typeface.release()));
108 } 113 }
109 114
110 bool FontCustomPlatformData::supportsFormat(const String& format) 115 bool FontCustomPlatformData::supportsFormat(const String& format)
111 { 116 {
112 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format); 117 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format);
113 } 118 }
114 119
115 } // namespace blink 120 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698