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: sky/engine/platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.cpp

Issue 717343002: Replace (unused) FontPlatformData.* with harfbuzz variants. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
(Empty)
1 /*
2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h"
33
34 #include "SkTypeface.h"
35 #include "platform/fonts/harfbuzz/HarfBuzzFace.h"
36 #include "wtf/text/WTFString.h"
37
38 namespace blink {
39
40 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
41 : m_textSize(0)
42 , m_syntheticBold(false)
43 , m_syntheticItalic(false)
44 , m_orientation(Horizontal)
45 , m_isHashTableDeletedValue(true)
46 {
47 }
48
49 FontPlatformData::FontPlatformData()
50 : m_textSize(0)
51 , m_syntheticBold(false)
52 , m_syntheticItalic(false)
53 , m_orientation(Horizontal)
54 , m_isHashTableDeletedValue(false)
55 {
56 }
57
58 FontPlatformData::FontPlatformData(float textSize, bool syntheticBold, bool synt heticItalic)
59 : m_textSize(textSize)
60 , m_syntheticBold(syntheticBold)
61 , m_syntheticItalic(syntheticItalic)
62 , m_orientation(Horizontal)
63 , m_isHashTableDeletedValue(false)
64 {
65 }
66
67 FontPlatformData::FontPlatformData(const FontPlatformData& src)
68 : m_typeface(src.m_typeface)
69 , m_family(src.m_family)
70 , m_textSize(src.m_textSize)
71 , m_syntheticBold(src.m_syntheticBold)
72 , m_syntheticItalic(src.m_syntheticItalic)
73 , m_orientation(src.m_orientation)
74 , m_style(src.m_style)
75 , m_harfBuzzFace(nullptr)
76 , m_isHashTableDeletedValue(false)
77 {
78 }
79
80 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family , float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orie ntation, bool subpixelTextPosition)
81 : m_typeface(tf)
82 , m_family(family)
83 , m_textSize(textSize)
84 , m_syntheticBold(syntheticBold)
85 , m_syntheticItalic(syntheticItalic)
86 , m_orientation(orientation)
87 , m_isHashTableDeletedValue(false)
88 {
89 querySystemForRenderStyle(subpixelTextPosition);
90 }
91
92 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
93 : m_typeface(src.m_typeface)
94 , m_family(src.m_family)
95 , m_textSize(textSize)
96 , m_syntheticBold(src.m_syntheticBold)
97 , m_syntheticItalic(src.m_syntheticItalic)
98 , m_orientation(src.m_orientation)
99 , m_harfBuzzFace(nullptr)
100 , m_isHashTableDeletedValue(false)
101 {
102 querySystemForRenderStyle(FontDescription::subpixelPositioning());
103 }
104
105 FontPlatformData::~FontPlatformData()
106 {
107 }
108
109 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
110 {
111 m_typeface = src.m_typeface;
112 m_family = src.m_family;
113 m_textSize = src.m_textSize;
114 m_syntheticBold = src.m_syntheticBold;
115 m_syntheticItalic = src.m_syntheticItalic;
116 m_harfBuzzFace = nullptr;
117 m_orientation = src.m_orientation;
118 m_style = src.m_style;
119 return *this;
120 }
121
122 #ifndef NDEBUG
123 String FontPlatformData::description() const
124 {
125 return String();
126 }
127 #endif
128
129 SkFontID FontPlatformData::uniqueID() const
130 {
131 return m_typeface->uniqueID();
132 }
133
134 String FontPlatformData::fontFamilyName() const
135 {
136 // FIXME(crbug.com/326582): come up with a proper way of handling SVG.
137 if (!this->typeface())
138 return "";
139 SkTypeface::LocalizedStrings* fontFamilyIterator = this->typeface()->createF amilyNameIterator();
140 SkTypeface::LocalizedString localizedString;
141 while (fontFamilyIterator->next(&localizedString) && !localizedString.fStrin g.size()) { }
142 fontFamilyIterator->unref();
143 return String(localizedString.fString.c_str());
144 }
145
146 bool FontPlatformData::operator==(const FontPlatformData& a) const
147 {
148 // If either of the typeface pointers are null then we test for pointer
149 // equality. Otherwise, we call SkTypeface::Equal on the valid pointers.
150 bool typefacesEqual;
151 if (!m_typeface || !a.m_typeface)
152 typefacesEqual = m_typeface == a.m_typeface;
153 else
154 typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get()) ;
155
156 return typefacesEqual
157 && m_textSize == a.m_textSize
158 && m_syntheticBold == a.m_syntheticBold
159 && m_syntheticItalic == a.m_syntheticItalic
160 && m_orientation == a.m_orientation
161 && m_style == a.m_style
162 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue;
163 }
164
165 bool FontPlatformData::isFixedPitch() const
166 {
167 return typeface() && typeface()->isFixedPitch();
168 }
169
170 HarfBuzzFace* FontPlatformData::harfBuzzFace() const
171 {
172 if (!m_harfBuzzFace)
173 m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this ), uniqueID());
174
175 return m_harfBuzzFace.get();
176 }
177
178 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698