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

Side by Side Diff: Source/core/platform/graphics/skia/FontCustomPlatformDataSkia.cpp

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2007 Apple Computer, Inc.
3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4 * Copyright (C) 2010 Company 100, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include "config.h"
34 #include "platform/fonts/FontCustomPlatformData.h"
35
36 #include "platform/LayoutTestSupport.h"
37 #include "platform/SharedBuffer.h"
38 #include "core/platform/graphics/FontPlatformData.h"
39 #include "core/platform/graphics/opentype/OpenTypeSanitizer.h"
40 #include "third_party/skia/include/core/SkStream.h"
41 #include "third_party/skia/include/core/SkTypeface.h"
42 #include "wtf/PassOwnPtr.h"
43
44 namespace WebCore {
45
46 FontCustomPlatformData::FontCustomPlatformData(PassRefPtr<SkTypeface> typeface)
47 : m_typeface(typeface)
48 {
49 }
50
51 FontCustomPlatformData::~FontCustomPlatformData()
52 {
53 }
54
55 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant)
56 {
57 ASSERT(m_typeface);
58 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB old(), italic && !m_typeface->isItalic(), orientation);
59 }
60
61 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer)
62 {
63 ASSERT_ARG(buffer, buffer);
64
65 OpenTypeSanitizer sanitizer(buffer);
66 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
67 if (!transcodeBuffer)
68 return nullptr; // validation failed.
69 buffer = transcodeBuffer.get();
70
71 RefPtr<SkMemoryStream> stream = adoptRef(new SkMemoryStream(buffer->getAsSkD ata().get()));
72 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream.g et()));
73 if (!typeface)
74 return nullptr;
75
76 return adoptPtr(new FontCustomPlatformData(typeface.release()));
77 }
78
79 bool FontCustomPlatformData::supportsFormat(const String& format)
80 {
81 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format);
82 }
83
84 }
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/skia/FontCacheSkiaWin.cpp ('k') | Source/core/platform/graphics/skia/FontPlatformDataSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698