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

Side by Side Diff: sky/engine/platform/fonts/FontPlatformData.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
1 /* 1 /*
2 * Copyright (C) 2011 Brent Fulgham 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * Redistribution and use in source and binary forms, with or without
5 * modify it under the terms of the GNU Library General Public 5 * modification, are permitted provided that the following conditions are
6 * License as published by the Free Software Foundation; either 6 * met:
7 * version 2 of the License, or (at your option) any later version.
8 * 7 *
9 * This library is distributed in the hope that it will be useful, 8 * * Redistributions of source code must retain the above copyright
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * notice, this list of conditions and the following disclaimer.
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 * * Redistributions in binary form must reproduce the above
12 * Library General Public License for more details. 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.
13 * 17 *
14 * You should have received a copy of the GNU Library General Public License 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * along with this library; see the file COPYING.LIB. If not, write to 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 * Boston, MA 02110-1301, USA. 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * 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.
19 */ 29 */
20 30
21 #include "config.h" 31 #include "config.h"
22 #include "platform/fonts/FontPlatformData.h" 32 #include "platform/fonts/FontPlatformData.h"
23 33
24 #include "wtf/HashMap.h" 34 #include "SkTypeface.h"
25 #include "wtf/text/StringHash.h" 35 #include "platform/fonts/harfbuzz/HarfBuzzFace.h"
26 #include "wtf/text/WTFString.h" 36 #include "wtf/text/WTFString.h"
27 37
28 #if OS(MACOSX)
29 #include "platform/fonts/harfbuzz/HarfBuzzFace.h"
30 #endif
31
32 namespace blink { 38 namespace blink {
33 39
34 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) 40 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
35 : m_syntheticBold(false) 41 : m_textSize(0)
36 , m_syntheticOblique(false) 42 , m_syntheticBold(false)
43 , m_syntheticItalic(false)
37 , m_orientation(Horizontal) 44 , m_orientation(Horizontal)
38 , m_size(0) 45 , m_isHashTableDeletedValue(true)
39 , m_widthVariant(RegularWidth)
40 #if OS(MACOSX)
41 , m_font(hashTableDeletedFontValue())
42 #endif
43 , m_isColorBitmapFont(false)
44 , m_isCompositeFontReference(false)
45 { 46 {
46 } 47 }
47 48
48 FontPlatformData::FontPlatformData() 49 FontPlatformData::FontPlatformData()
49 : m_syntheticBold(false) 50 : m_textSize(0)
50 , m_syntheticOblique(false) 51 , m_syntheticBold(false)
52 , m_syntheticItalic(false)
51 , m_orientation(Horizontal) 53 , m_orientation(Horizontal)
52 , m_size(0) 54 , m_isHashTableDeletedValue(false)
53 , m_widthVariant(RegularWidth)
54 #if OS(MACOSX)
55 , m_font(0)
56 #endif
57 , m_isColorBitmapFont(false)
58 , m_isCompositeFontReference(false)
59 { 55 {
60 } 56 }
61 57
62 FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheti cOblique, FontOrientation orientation, FontWidthVariant widthVariant) 58 FontPlatformData::FontPlatformData(float textSize, bool syntheticBold, bool synt heticItalic)
63 : m_syntheticBold(syntheticBold) 59 : m_textSize(textSize)
64 , m_syntheticOblique(syntheticOblique) 60 , m_syntheticBold(syntheticBold)
65 , m_orientation(orientation) 61 , m_syntheticItalic(syntheticItalic)
66 , m_size(size) 62 , m_orientation(Horizontal)
67 , m_widthVariant(widthVariant) 63 , m_isHashTableDeletedValue(false)
68 #if OS(MACOSX)
69 , m_font(0)
70 #endif
71 , m_isColorBitmapFont(false)
72 , m_isCompositeFontReference(false)
73 { 64 {
74 } 65 }
75 66
76 #if OS(MACOSX) 67 FontPlatformData::FontPlatformData(const FontPlatformData& src)
77 FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticB old, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthV ariant) 68 : m_typeface(src.m_typeface)
78 : m_syntheticBold(syntheticBold) 69 , m_family(src.m_family)
79 , m_syntheticOblique(syntheticOblique) 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)
80 , m_orientation(orientation) 86 , m_orientation(orientation)
81 , m_size(size) 87 , m_isHashTableDeletedValue(false)
82 , m_widthVariant(widthVariant)
83 , m_font(0)
84 , m_cgFont(cgFont)
85 , m_isColorBitmapFont(false)
86 , m_isCompositeFontReference(false)
87 { 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();
88 } 126 }
89 #endif 127 #endif
90 128
91 FontPlatformData::FontPlatformData(const FontPlatformData& source) 129 SkFontID FontPlatformData::uniqueID() const
92 : m_syntheticBold(source.m_syntheticBold)
93 , m_syntheticOblique(source.m_syntheticOblique)
94 , m_orientation(source.m_orientation)
95 , m_size(source.m_size)
96 , m_widthVariant(source.m_widthVariant)
97 , m_isColorBitmapFont(source.m_isColorBitmapFont)
98 , m_isCompositeFontReference(source.m_isCompositeFontReference)
99 { 130 {
100 platformDataInit(source); 131 return m_typeface->uniqueID();
101 } 132 }
102 133
103 const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe r) 134 String FontPlatformData::fontFamilyName() const
104 { 135 {
105 // Check for self-assignment. 136 // FIXME(crbug.com/326582): come up with a proper way of handling SVG.
106 if (this == &other) 137 if (!this->typeface())
107 return *this; 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 }
108 145
109 m_syntheticBold = other.m_syntheticBold; 146 bool FontPlatformData::operator==(const FontPlatformData& a) const
110 m_syntheticOblique = other.m_syntheticOblique; 147 {
111 m_orientation = other.m_orientation; 148 // If either of the typeface pointers are null then we test for pointer
112 m_size = other.m_size; 149 // equality. Otherwise, we call SkTypeface::Equal on the valid pointers.
113 m_widthVariant = other.m_widthVariant; 150 bool typefacesEqual;
114 m_isColorBitmapFont = other.m_isColorBitmapFont; 151 if (!m_typeface || !a.m_typeface)
115 m_isCompositeFontReference = other.m_isCompositeFontReference; 152 typefacesEqual = m_typeface == a.m_typeface;
153 else
154 typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get()) ;
116 155
117 return platformDataAssign(other); 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();
118 } 176 }
119 177
120 } // namespace blink 178 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/fonts/FontPlatformData.h ('k') | sky/engine/platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698