| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the internal font implementation. | 2 * This file is part of the internal font implementation. |
| 3 * | 3 * |
| 4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2007-2008 Torch Mobile, Inc. | 5 * Copyright (C) 2007-2008 Torch Mobile, Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #ifndef SimpleFontData_h | 24 #ifndef SimpleFontData_h |
| 25 #define SimpleFontData_h | 25 #define SimpleFontData_h |
| 26 | 26 |
| 27 #include "platform/PlatformExport.h" | 27 #include "platform/PlatformExport.h" |
| 28 #include "platform/fonts/CustomFontData.h" | 28 #include "platform/fonts/CustomFontData.h" |
| 29 #include "platform/fonts/FontBaseline.h" | 29 #include "platform/fonts/FontBaseline.h" |
| 30 #include "platform/fonts/FontData.h" | 30 #include "platform/fonts/FontData.h" |
| 31 #include "platform/fonts/FontMetrics.h" | 31 #include "platform/fonts/FontMetrics.h" |
| 32 #include "platform/fonts/FontPlatformData.h" | 32 #include "platform/fonts/FontPlatformData.h" |
| 33 #include "platform/fonts/GlyphPageTreeNode.h" | |
| 34 #include "platform/fonts/TypesettingFeatures.h" | 33 #include "platform/fonts/TypesettingFeatures.h" |
| 35 #include "platform/fonts/opentype/OpenTypeVerticalData.h" | 34 #include "platform/fonts/opentype/OpenTypeVerticalData.h" |
| 36 #include "platform/geometry/FloatRect.h" | 35 #include "platform/geometry/FloatRect.h" |
| 37 #include "wtf/PtrUtil.h" | 36 #include "wtf/PtrUtil.h" |
| 38 #include "wtf/text/StringHash.h" | 37 #include "wtf/text/StringHash.h" |
| 39 #include <SkPaint.h> | 38 #include <SkPaint.h> |
| 40 #include <memory> | 39 #include <memory> |
| 41 | 40 |
| 42 #if OS(MACOSX) | 41 #if OS(MACOSX) |
| 43 #include "platform/fonts/GlyphMetricsMap.h" | 42 #include "platform/fonts/GlyphMetricsMap.h" |
| 44 #endif | 43 #endif |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 47 // Holds the glyph index and the corresponding SimpleFontData information for a |
| 48 // given |
| 49 // character. |
| 50 struct GlyphData { |
| 51 GlyphData(Glyph g = 0, const SimpleFontData* f = 0) : glyph(g), fontData(f) {} |
| 52 Glyph glyph; |
| 53 const SimpleFontData* fontData; |
| 54 }; |
| 55 |
| 48 class FontDescription; | 56 class FontDescription; |
| 49 | 57 |
| 50 enum FontDataVariant { | 58 enum FontDataVariant { |
| 51 AutoVariant, | 59 AutoVariant, |
| 52 NormalVariant, | 60 NormalVariant, |
| 53 SmallCapsVariant, | 61 SmallCapsVariant, |
| 54 EmphasisMarkVariant | 62 EmphasisMarkVariant |
| 55 }; | 63 }; |
| 56 | 64 |
| 57 class PLATFORM_EXPORT SimpleFontData : public FontData { | 65 class PLATFORM_EXPORT SimpleFontData : public FontData { |
| 58 public: | 66 public: |
| 59 // Used to create platform fonts. | 67 // Used to create platform fonts. |
| 60 static PassRefPtr<SimpleFontData> create( | 68 static PassRefPtr<SimpleFontData> create( |
| 61 const FontPlatformData& platformData, | 69 const FontPlatformData& platformData, |
| 62 PassRefPtr<CustomFontData> customData = nullptr, | 70 PassRefPtr<CustomFontData> customData = nullptr, |
| 63 bool isTextOrientationFallback = false, | 71 bool isTextOrientationFallback = false, |
| 64 bool subpixelAscentDescent = false) { | 72 bool subpixelAscentDescent = false) { |
| 65 return adoptRef(new SimpleFontData(platformData, std::move(customData), | 73 return adoptRef(new SimpleFontData(platformData, std::move(customData), |
| 66 isTextOrientationFallback, | 74 isTextOrientationFallback, |
| 67 subpixelAscentDescent)); | 75 subpixelAscentDescent)); |
| 68 } | 76 } |
| 69 | 77 |
| 70 ~SimpleFontData() override; | |
| 71 | |
| 72 const FontPlatformData& platformData() const { return m_platformData; } | 78 const FontPlatformData& platformData() const { return m_platformData; } |
| 73 const OpenTypeVerticalData* verticalData() const { | 79 const OpenTypeVerticalData* verticalData() const { |
| 74 return m_verticalData.get(); | 80 return m_verticalData.get(); |
| 75 } | 81 } |
| 76 | 82 |
| 77 PassRefPtr<SimpleFontData> smallCapsFontData(const FontDescription&) const; | 83 PassRefPtr<SimpleFontData> smallCapsFontData(const FontDescription&) const; |
| 78 PassRefPtr<SimpleFontData> emphasisMarkFontData(const FontDescription&) const; | 84 PassRefPtr<SimpleFontData> emphasisMarkFontData(const FontDescription&) const; |
| 79 | 85 |
| 80 PassRefPtr<SimpleFontData> variantFontData(const FontDescription& description, | 86 PassRefPtr<SimpleFontData> variantFontData(const FontDescription& description, |
| 81 FontDataVariant variant) const { | 87 FontDataVariant variant) const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 152 |
| 147 const GlyphData& missingGlyphData() const { return m_missingGlyphData; } | 153 const GlyphData& missingGlyphData() const { return m_missingGlyphData; } |
| 148 void setMissingGlyphData(const GlyphData& glyphData) { | 154 void setMissingGlyphData(const GlyphData& glyphData) { |
| 149 m_missingGlyphData = glyphData; | 155 m_missingGlyphData = glyphData; |
| 150 } | 156 } |
| 151 | 157 |
| 152 bool canRenderCombiningCharacterSequence(const UChar*, size_t) const; | 158 bool canRenderCombiningCharacterSequence(const UChar*, size_t) const; |
| 153 | 159 |
| 154 CustomFontData* customFontData() const { return m_customFontData.get(); } | 160 CustomFontData* customFontData() const { return m_customFontData.get(); } |
| 155 | 161 |
| 156 // Implemented by the platform. | |
| 157 virtual bool fillGlyphPage(GlyphPage* pageToFill, | |
| 158 unsigned offset, | |
| 159 unsigned length, | |
| 160 UChar* buffer, | |
| 161 unsigned bufferLength) const; | |
| 162 | |
| 163 protected: | 162 protected: |
| 164 SimpleFontData(const FontPlatformData&, | 163 SimpleFontData(const FontPlatformData&, |
| 165 PassRefPtr<CustomFontData> customData, | 164 PassRefPtr<CustomFontData> customData, |
| 166 bool isTextOrientationFallback = false, | 165 bool isTextOrientationFallback = false, |
| 167 bool subpixelAscentDescent = false); | 166 bool subpixelAscentDescent = false); |
| 168 | 167 |
| 169 SimpleFontData(PassRefPtr<CustomFontData> customData, | 168 SimpleFontData(PassRefPtr<CustomFontData> customData, |
| 170 float fontSize, | 169 float fontSize, |
| 171 bool syntheticBold, | 170 bool syntheticBold, |
| 172 bool syntheticItalic); | 171 bool syntheticItalic); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 193 float m_spaceWidth; | 192 float m_spaceWidth; |
| 194 Glyph m_zeroGlyph; | 193 Glyph m_zeroGlyph; |
| 195 | 194 |
| 196 GlyphData m_missingGlyphData; | 195 GlyphData m_missingGlyphData; |
| 197 | 196 |
| 198 struct DerivedFontData { | 197 struct DerivedFontData { |
| 199 USING_FAST_MALLOC(DerivedFontData); | 198 USING_FAST_MALLOC(DerivedFontData); |
| 200 WTF_MAKE_NONCOPYABLE(DerivedFontData); | 199 WTF_MAKE_NONCOPYABLE(DerivedFontData); |
| 201 | 200 |
| 202 public: | 201 public: |
| 203 static std::unique_ptr<DerivedFontData> create(bool forCustomFont); | 202 static std::unique_ptr<DerivedFontData> create(); |
| 204 ~DerivedFontData(); | |
| 205 | 203 |
| 206 bool forCustomFont; | |
| 207 RefPtr<SimpleFontData> smallCaps; | 204 RefPtr<SimpleFontData> smallCaps; |
| 208 RefPtr<SimpleFontData> emphasisMark; | 205 RefPtr<SimpleFontData> emphasisMark; |
| 209 RefPtr<SimpleFontData> verticalRightOrientation; | 206 RefPtr<SimpleFontData> verticalRightOrientation; |
| 210 RefPtr<SimpleFontData> uprightOrientation; | 207 RefPtr<SimpleFontData> uprightOrientation; |
| 211 | 208 |
| 212 private: | 209 private: |
| 213 DerivedFontData(bool custom) : forCustomFont(custom) {} | 210 DerivedFontData() {} |
| 214 }; | 211 }; |
| 215 | 212 |
| 216 mutable std::unique_ptr<DerivedFontData> m_derivedFontData; | 213 mutable std::unique_ptr<DerivedFontData> m_derivedFontData; |
| 217 | 214 |
| 218 RefPtr<CustomFontData> m_customFontData; | 215 RefPtr<CustomFontData> m_customFontData; |
| 219 | 216 |
| 220 // See discussion on crbug.com/631032 and Skiaissue | 217 // See discussion on crbug.com/631032 and Skiaissue |
| 221 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 : | 218 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 : |
| 222 // On Mac we're still using path based glyph metrics, and they seem to be | 219 // On Mac we're still using path based glyph metrics, and they seem to be |
| 223 // too slow to be able to remove the caching layer we have here. | 220 // too slow to be able to remove the caching layer we have here. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 256 |
| 260 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); | 257 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); |
| 261 return width; | 258 return width; |
| 262 #endif | 259 #endif |
| 263 } | 260 } |
| 264 | 261 |
| 265 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); | 262 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); |
| 266 | 263 |
| 267 } // namespace blink | 264 } // namespace blink |
| 268 #endif // SimpleFontData_h | 265 #endif // SimpleFontData_h |
| OLD | NEW |