1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef SEEN_SP_FONTFACE_H
3 #define SEEN_SP_FONTFACE_H
4 
5 #include <vector>
6 
7 /*
8  * SVG <font-face> element implementation
9  *
10  * Section 20.8.3 of the W3C SVG 1.1 spec
11  * available at:
12  * http://www.w3.org/TR/SVG/fonts.html#FontFaceElement
13  *
14  * Authors:
15  *    Felipe C. da S. Sanches <juca@members.fsf.org>
16  *
17  * Copyright (C) 2008 Felipe C. da S. Sanches
18  *
19  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
20  */
21 
22 #include "sp-object.h"
23 
24 #define SP_FONTFACE(obj) (dynamic_cast<SPFontFace*>((SPObject*)obj))
25 #define SP_IS_FONTFACE(obj) (dynamic_cast<const SPFontFace*>((SPObject*)obj) != NULL)
26 
27 enum FontFaceStyleType{
28 	SP_FONTFACE_STYLE_ALL,
29 	SP_FONTFACE_STYLE_NORMAL,
30 	SP_FONTFACE_STYLE_ITALIC,
31 	SP_FONTFACE_STYLE_OBLIQUE
32 };
33 
34 enum FontFaceVariantType{
35 	SP_FONTFACE_VARIANT_NORMAL,
36 	SP_FONTFACE_VARIANT_SMALL_CAPS
37 };
38 
39 enum FontFaceWeightType{
40 	SP_FONTFACE_WEIGHT_ALL,
41 	SP_FONTFACE_WEIGHT_NORMAL,
42 	SP_FONTFACE_WEIGHT_BOLD,
43 	SP_FONTFACE_WEIGHT_100,
44 	SP_FONTFACE_WEIGHT_200,
45 	SP_FONTFACE_WEIGHT_300,
46 	SP_FONTFACE_WEIGHT_400,
47 	SP_FONTFACE_WEIGHT_500,
48 	SP_FONTFACE_WEIGHT_600,
49 	SP_FONTFACE_WEIGHT_700,
50 	SP_FONTFACE_WEIGHT_800,
51 	SP_FONTFACE_WEIGHT_900
52 };
53 
54 enum FontFaceStretchType{
55 	SP_FONTFACE_STRETCH_ALL,
56 	SP_FONTFACE_STRETCH_NORMAL,
57 	SP_FONTFACE_STRETCH_ULTRA_CONDENSED,
58 	SP_FONTFACE_STRETCH_EXTRA_CONDENSED,
59 	SP_FONTFACE_STRETCH_CONDENSED,
60 	SP_FONTFACE_STRETCH_SEMI_CONDENSED,
61 	SP_FONTFACE_STRETCH_SEMI_EXPANDED,
62 	SP_FONTFACE_STRETCH_EXPANDED,
63 	SP_FONTFACE_STRETCH_EXTRA_EXPANDED,
64 	SP_FONTFACE_STRETCH_ULTRA_EXPANDED
65 };
66 
67 enum FontFaceUnicodeRangeType{
68 	FONTFACE_UNICODERANGE_FIXME_HERE,
69 };
70 
71 class SPFontFace : public SPObject {
72 public:
73 	SPFontFace();
74 	~SPFontFace() override;
75 
76     char* font_family;
77     std::vector<FontFaceStyleType> font_style;
78     std::vector<FontFaceVariantType> font_variant;
79     std::vector<FontFaceWeightType> font_weight;
80     std::vector<FontFaceStretchType> font_stretch;
81     char* font_size;
82     std::vector<FontFaceUnicodeRangeType> unicode_range;
83     double units_per_em;
84     std::vector<int> panose_1;
85     double stemv;
86     double stemh;
87     double slope;
88     double cap_height;
89     double x_height;
90     double accent_height;
91     double ascent;
92     double descent;
93     char* widths;
94     char* bbox;
95     double ideographic;
96     double alphabetic;
97     double mathematical;
98     double hanging;
99     double v_ideographic;
100     double v_alphabetic;
101     double v_mathematical;
102     double v_hanging;
103     double underline_position;
104     double underline_thickness;
105     double strikethrough_position;
106     double strikethrough_thickness;
107     double overline_position;
108     double overline_thickness;
109 
110 protected:
111 	void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
112 	void release() override;
113 
114 	void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) override;
115 	void remove_child(Inkscape::XML::Node* child) override;
116 
117 	void set(SPAttr key, const char* value) override;
118 
119 	void update(SPCtx* ctx, unsigned int flags) override;
120 
121 	Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags) override;
122 };
123 
124 #endif //#ifndef __SP_FONTFACE_H__
125