| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering) | 75 void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering) |
| 76 { | 76 { |
| 77 useSkiaSubpixelRendering = useSubpixelRendering; | 77 useSkiaSubpixelRendering = useSubpixelRendering; |
| 78 } | 78 } |
| 79 | 79 |
| 80 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) | 80 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) |
| 81 : m_textSize(0) | 81 : m_textSize(0) |
| 82 , m_emSizeInFontUnits(0) | 82 , m_emSizeInFontUnits(0) |
| 83 , m_fakeBold(false) | 83 , m_syntheticBold(false) |
| 84 , m_fakeItalic(false) | 84 , m_syntheticItalic(false) |
| 85 , m_orientation(Horizontal) | 85 , m_orientation(Horizontal) |
| 86 , m_isHashTableDeletedValue(true) | 86 , m_isHashTableDeletedValue(true) |
| 87 { | 87 { |
| 88 } | 88 } |
| 89 | 89 |
| 90 FontPlatformData::FontPlatformData() | 90 FontPlatformData::FontPlatformData() |
| 91 : m_textSize(0) | 91 : m_textSize(0) |
| 92 , m_emSizeInFontUnits(0) | 92 , m_emSizeInFontUnits(0) |
| 93 , m_fakeBold(false) | 93 , m_syntheticBold(false) |
| 94 , m_fakeItalic(false) | 94 , m_syntheticItalic(false) |
| 95 , m_orientation(Horizontal) | 95 , m_orientation(Horizontal) |
| 96 , m_isHashTableDeletedValue(false) | 96 , m_isHashTableDeletedValue(false) |
| 97 { | 97 { |
| 98 } | 98 } |
| 99 | 99 |
| 100 FontPlatformData::FontPlatformData(float textSize, bool fakeBold, bool fakeItali
c) | 100 FontPlatformData::FontPlatformData(float textSize, bool syntheticBold, bool synt
heticItalic) |
| 101 : m_textSize(textSize) | 101 : m_textSize(textSize) |
| 102 , m_emSizeInFontUnits(0) | 102 , m_emSizeInFontUnits(0) |
| 103 , m_fakeBold(fakeBold) | 103 , m_syntheticBold(syntheticBold) |
| 104 , m_fakeItalic(fakeItalic) | 104 , m_syntheticItalic(syntheticItalic) |
| 105 , m_orientation(Horizontal) | 105 , m_orientation(Horizontal) |
| 106 , m_isHashTableDeletedValue(false) | 106 , m_isHashTableDeletedValue(false) |
| 107 { | 107 { |
| 108 } | 108 } |
| 109 | 109 |
| 110 FontPlatformData::FontPlatformData(const FontPlatformData& src) | 110 FontPlatformData::FontPlatformData(const FontPlatformData& src) |
| 111 : m_typeface(src.m_typeface) | 111 : m_typeface(src.m_typeface) |
| 112 , m_family(src.m_family) | 112 , m_family(src.m_family) |
| 113 , m_textSize(src.m_textSize) | 113 , m_textSize(src.m_textSize) |
| 114 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) | 114 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) |
| 115 , m_fakeBold(src.m_fakeBold) | 115 , m_syntheticBold(src.m_syntheticBold) |
| 116 , m_fakeItalic(src.m_fakeItalic) | 116 , m_syntheticItalic(src.m_syntheticItalic) |
| 117 , m_orientation(src.m_orientation) | 117 , m_orientation(src.m_orientation) |
| 118 , m_style(src.m_style) | 118 , m_style(src.m_style) |
| 119 , m_harfBuzzFace(0) | 119 , m_harfBuzzFace(0) |
| 120 , m_isHashTableDeletedValue(false) | 120 , m_isHashTableDeletedValue(false) |
| 121 { | 121 { |
| 122 } | 122 } |
| 123 | 123 |
| 124 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
, float textSize, bool fakeBold, bool fakeItalic, FontOrientation orientation, b
ool subpixelTextPosition) | 124 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orie
ntation, bool subpixelTextPosition) |
| 125 : m_typeface(tf) | 125 : m_typeface(tf) |
| 126 , m_family(family) | 126 , m_family(family) |
| 127 , m_textSize(textSize) | 127 , m_textSize(textSize) |
| 128 , m_emSizeInFontUnits(0) | 128 , m_emSizeInFontUnits(0) |
| 129 , m_fakeBold(fakeBold) | 129 , m_syntheticBold(syntheticBold) |
| 130 , m_fakeItalic(fakeItalic) | 130 , m_syntheticItalic(syntheticItalic) |
| 131 , m_orientation(orientation) | 131 , m_orientation(orientation) |
| 132 , m_isHashTableDeletedValue(false) | 132 , m_isHashTableDeletedValue(false) |
| 133 { | 133 { |
| 134 querySystemForRenderStyle(subpixelTextPosition); | 134 querySystemForRenderStyle(subpixelTextPosition); |
| 135 } | 135 } |
| 136 | 136 |
| 137 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) | 137 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) |
| 138 : m_typeface(src.m_typeface) | 138 : m_typeface(src.m_typeface) |
| 139 , m_family(src.m_family) | 139 , m_family(src.m_family) |
| 140 , m_textSize(textSize) | 140 , m_textSize(textSize) |
| 141 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) | 141 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) |
| 142 , m_fakeBold(src.m_fakeBold) | 142 , m_syntheticBold(src.m_syntheticBold) |
| 143 , m_fakeItalic(src.m_fakeItalic) | 143 , m_syntheticItalic(src.m_syntheticItalic) |
| 144 , m_orientation(src.m_orientation) | 144 , m_orientation(src.m_orientation) |
| 145 , m_harfBuzzFace(0) | 145 , m_harfBuzzFace(0) |
| 146 , m_isHashTableDeletedValue(false) | 146 , m_isHashTableDeletedValue(false) |
| 147 { | 147 { |
| 148 querySystemForRenderStyle(FontDescription::subpixelPositioning()); | 148 querySystemForRenderStyle(FontDescription::subpixelPositioning()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 FontPlatformData::~FontPlatformData() | 151 FontPlatformData::~FontPlatformData() |
| 152 { | 152 { |
| 153 } | 153 } |
| 154 | 154 |
| 155 int FontPlatformData::emSizeInFontUnits() const | 155 int FontPlatformData::emSizeInFontUnits() const |
| 156 { | 156 { |
| 157 if (m_emSizeInFontUnits) | 157 if (m_emSizeInFontUnits) |
| 158 return m_emSizeInFontUnits; | 158 return m_emSizeInFontUnits; |
| 159 | 159 |
| 160 m_emSizeInFontUnits = m_typeface->getUnitsPerEm(); | 160 m_emSizeInFontUnits = m_typeface->getUnitsPerEm(); |
| 161 return m_emSizeInFontUnits; | 161 return m_emSizeInFontUnits; |
| 162 } | 162 } |
| 163 | 163 |
| 164 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src) | 164 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src) |
| 165 { | 165 { |
| 166 m_typeface = src.m_typeface; | 166 m_typeface = src.m_typeface; |
| 167 m_family = src.m_family; | 167 m_family = src.m_family; |
| 168 m_textSize = src.m_textSize; | 168 m_textSize = src.m_textSize; |
| 169 m_fakeBold = src.m_fakeBold; | 169 m_syntheticBold = src.m_syntheticBold; |
| 170 m_fakeItalic = src.m_fakeItalic; | 170 m_syntheticItalic = src.m_syntheticItalic; |
| 171 m_harfBuzzFace = 0; | 171 m_harfBuzzFace = 0; |
| 172 m_orientation = src.m_orientation; | 172 m_orientation = src.m_orientation; |
| 173 m_style = src.m_style; | 173 m_style = src.m_style; |
| 174 m_emSizeInFontUnits = src.m_emSizeInFontUnits; | 174 m_emSizeInFontUnits = src.m_emSizeInFontUnits; |
| 175 | 175 |
| 176 return *this; | 176 return *this; |
| 177 } | 177 } |
| 178 | 178 |
| 179 #ifndef NDEBUG | 179 #ifndef NDEBUG |
| 180 String FontPlatformData::description() const | 180 String FontPlatformData::description() const |
| (...skipping 13 matching lines...) Expand all Loading... |
| 194 | 194 |
| 195 // TestRunner specifically toggles the subpixel positioning flag. | 195 // TestRunner specifically toggles the subpixel positioning flag. |
| 196 if (RuntimeEnabledFeatures::subpixelFontScalingEnabled() && !isRunningLayout
Test()) | 196 if (RuntimeEnabledFeatures::subpixelFontScalingEnabled() && !isRunningLayout
Test()) |
| 197 paint->setSubpixelText(true); | 197 paint->setSubpixelText(true); |
| 198 else | 198 else |
| 199 paint->setSubpixelText(m_style.useSubpixelPositioning); | 199 paint->setSubpixelText(m_style.useSubpixelPositioning); |
| 200 | 200 |
| 201 const float ts = m_textSize >= 0 ? m_textSize : 12; | 201 const float ts = m_textSize >= 0 ? m_textSize : 12; |
| 202 paint->setTextSize(SkFloatToScalar(ts)); | 202 paint->setTextSize(SkFloatToScalar(ts)); |
| 203 paint->setTypeface(m_typeface.get()); | 203 paint->setTypeface(m_typeface.get()); |
| 204 paint->setFakeBoldText(m_fakeBold); | 204 paint->setFakeBoldText(m_syntheticBold); |
| 205 paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0); | 205 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0); |
| 206 } | 206 } |
| 207 | 207 |
| 208 SkFontID FontPlatformData::uniqueID() const | 208 SkFontID FontPlatformData::uniqueID() const |
| 209 { | 209 { |
| 210 return m_typeface->uniqueID(); | 210 return m_typeface->uniqueID(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 String FontPlatformData::fontFamilyName() const | 213 String FontPlatformData::fontFamilyName() const |
| 214 { | 214 { |
| 215 // FIXME(crbug.com/326582): come up with a proper way of handling SVG. | 215 // FIXME(crbug.com/326582): come up with a proper way of handling SVG. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 227 // If either of the typeface pointers are null then we test for pointer | 227 // If either of the typeface pointers are null then we test for pointer |
| 228 // equality. Otherwise, we call SkTypeface::Equal on the valid pointers. | 228 // equality. Otherwise, we call SkTypeface::Equal on the valid pointers. |
| 229 bool typefacesEqual; | 229 bool typefacesEqual; |
| 230 if (!m_typeface || !a.m_typeface) | 230 if (!m_typeface || !a.m_typeface) |
| 231 typefacesEqual = m_typeface == a.m_typeface; | 231 typefacesEqual = m_typeface == a.m_typeface; |
| 232 else | 232 else |
| 233 typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get())
; | 233 typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get())
; |
| 234 | 234 |
| 235 return typefacesEqual | 235 return typefacesEqual |
| 236 && m_textSize == a.m_textSize | 236 && m_textSize == a.m_textSize |
| 237 && m_fakeBold == a.m_fakeBold | 237 && m_syntheticBold == a.m_syntheticBold |
| 238 && m_fakeItalic == a.m_fakeItalic | 238 && m_syntheticItalic == a.m_syntheticItalic |
| 239 && m_orientation == a.m_orientation | 239 && m_orientation == a.m_orientation |
| 240 && m_style == a.m_style | 240 && m_style == a.m_style |
| 241 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue; | 241 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue; |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool FontPlatformData::isFixedPitch() const | 244 bool FontPlatformData::isFixedPitch() const |
| 245 { | 245 { |
| 246 notImplemented(); | 246 notImplemented(); |
| 247 return false; | 247 return false; |
| 248 } | 248 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) | 295 if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) |
| 296 m_style.useSubpixelRendering = useSkiaSubpixelRendering; | 296 m_style.useSubpixelRendering = useSkiaSubpixelRendering; |
| 297 | 297 |
| 298 // TestRunner specifically toggles the subpixel positioning flag. | 298 // TestRunner specifically toggles the subpixel positioning flag. |
| 299 if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference | 299 if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference |
| 300 || isRunningLayoutTest()) | 300 || isRunningLayoutTest()) |
| 301 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; | 301 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace WebCore | 304 } // namespace WebCore |
| OLD | NEW |