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

Side by Side Diff: Source/core/svg/SVGFontData.h

Issue 656913006: Remove SVG fonts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update tests for landing 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef SVGFontData_h
21 #define SVGFontData_h
22
23 #if ENABLE(SVG_FONTS)
24 #include "platform/fonts/CustomFontData.h"
25 #include "wtf/WeakPtr.h"
26 #include "wtf/text/WTFString.h"
27
28 namespace blink {
29
30 class SimpleFontData;
31 class SVGFontElement;
32 class SVGFontFaceElement;
33
34 class SVGFontData final : public CustomFontData {
35 public:
36 static PassRefPtr<SVGFontData> create(SVGFontFaceElement* element)
37 {
38 return adoptRef(new SVGFontData(element));
39 }
40
41 virtual ~SVGFontData();
42
43 virtual bool isSVGFont() const override { return true; };
44 virtual bool shouldSkipDrawing() const override;
45 virtual void initializeFontData(SimpleFontData*, float fontSize) override;
46 virtual float widthForSVGGlyph(Glyph, float fontSize) const override;
47 virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const override;
48 virtual bool applySVGGlyphSelection(SimpleShaper&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const override;
49
50 SVGFontFaceElement* svgFontFaceElement() const;
51
52 float horizontalOriginX() const { return m_horizontalOriginX; }
53 float horizontalOriginY() const { return m_horizontalOriginY; }
54 float horizontalAdvanceX() const { return m_horizontalAdvanceX; }
55
56 float verticalOriginX() const { return m_verticalOriginX; }
57 float verticalOriginY() const { return m_verticalOriginY; }
58 float verticalAdvanceY() const { return m_verticalAdvanceY; }
59
60 private:
61 SVGFontData(SVGFontFaceElement*);
62
63 bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned l ength, UChar* buffer, const SimpleFontData*) const;
64 bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigne d length, UChar* buffer, const SimpleFontData*) const;
65
66 String createStringWithMirroredCharacters(const String&) const;
67
68 // Ths SVGFontFaceElement is kept alive --
69 // 1) in the external font case: by the CSSFontFaceSource, which holds a ref erence to the external SVG document
70 // containing the element;
71 // 2) in the in-document font case: by virtue of being in the document tree and making sure that when it is removed
72 // from the document, it removes the @font-face rule it owns from the doc ument's mapped element sheet and forces
73 // a style update.
74 WeakPtr<SVGFontFaceElement> m_svgFontFaceElement;
75
76 float m_horizontalOriginX;
77 float m_horizontalOriginY;
78 float m_horizontalAdvanceX;
79
80 float m_verticalOriginX;
81 float m_verticalOriginY;
82 float m_verticalAdvanceY;
83 };
84
85 DEFINE_CUSTOM_FONT_DATA_TYPE_CASTS(SVGFontData, isSVGFont());
86
87 } // namespace blink
88
89 #endif
90 #endif // SVGFontData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698