• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 Apple Computer, Inc.
3  * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef FontCustomPlatformData_h
33 #define FontCustomPlatformData_h
34 
35 #include "FontOrientation.h"
36 #include "FontRenderingMode.h"
37 #include "FontWidthVariant.h"
38 #include "TextOrientation.h"
39 #include <wtf/Forward.h>
40 #include <wtf/Noncopyable.h>
41 
42 #if OS(WINDOWS)
43 #include "PlatformString.h"
44 #include <windows.h>
45 #elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP)
46 #include "SkTypeface.h"
47 #endif
48 
49 namespace WebCore {
50 
51 class FontPlatformData;
52 class SharedBuffer;
53 
54 struct FontCustomPlatformData {
55     WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
56 public:
57 #if OS(WINDOWS)
FontCustomPlatformDataFontCustomPlatformData58     FontCustomPlatformData(HANDLE fontReference, const String& name)
59         : m_fontReference(fontReference)
60         , m_name(name)
61     {}
62 #elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP)
63     explicit FontCustomPlatformData(SkTypeface* typeface)
64         : m_fontReference(typeface)
65     {}
66 #endif
67 
68     ~FontCustomPlatformData();
69 
70     FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight,
71                                       FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
72 
73     static bool supportsFormat(const String&);
74 
75 #if OS(WINDOWS)
76     HANDLE m_fontReference;
77     String m_name;
78 #elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP)
79     SkTypeface* m_fontReference;
80 #endif
81 };
82 
83 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
84 }
85 
86 #endif // FontCustomPlatformData_h
87