Werner Lemberg pushed to branch wl/freetype-ot-svg-from-scratch-new at FreeType / FreeType
Commits:
-
ad76c448
by Moazin Khatti at 2022-01-11T22:23:20+01:00
-
f6e66215
by Werner Lemberg at 2022-01-11T22:23:23+01:00
19 changed files:
- CMakeLists.txt
- builds/meson/parse_modules_cfg.py
- builds/unix/configure.raw
- builds/unix/unix-cc.in
- include/freetype/config/ftmodule.h
- include/freetype/fterrdef.h
- include/freetype/internal/fttrace.h
- + include/freetype/internal/svginterface.h
- include/freetype/otsvg.h
- meson.build
- modules.cfg
- src/base/ftobjs.c
- src/sfnt/ttsvg.c
- + src/svg/ftsvg.c
- + src/svg/ftsvg.h
- + src/svg/module.mk
- + src/svg/rules.mk
- + src/svg/svg.c
- + src/svg/svgtypes.h
Changes:
... | ... | @@ -400,6 +400,7 @@ set(BASE_SRCS |
400 | 400 |
src/sdf/sdf.c
|
401 | 401 |
src/sfnt/sfnt.c
|
402 | 402 |
src/smooth/smooth.c
|
403 |
+ src/svg/svg.c
|
|
403 | 404 |
src/truetype/truetype.c
|
404 | 405 |
src/type1/type1.c
|
405 | 406 |
src/type42/type42.c
|
... | ... | @@ -87,6 +87,7 @@ def generate_ftmodule(lists): |
87 | 87 |
name = {
|
88 | 88 |
"raster": "ft_raster1",
|
89 | 89 |
"smooth": "ft_smooth",
|
90 |
+ "svg": "ft_svg",
|
|
90 | 91 |
}.get(module)
|
91 | 92 |
result += (
|
92 | 93 |
"FT_USE_MODULE( FT_Renderer_Class, %s_renderer_class )\n" % name
|
... | ... | @@ -514,19 +514,36 @@ if test x"$with_brotli" = xyes -a "$have_brotli" = no; then |
514 | 514 |
fi
|
515 | 515 |
|
516 | 516 |
|
517 |
-# check for librt
|
|
517 |
+# Checks for the demo programs.
|
|
518 | 518 |
#
|
519 |
-# We need `clock_gettime' for the `ftbench' demo program.
|
|
519 |
+# FreeType doesn't need this. However, since the demo program repository
|
|
520 |
+# doesn't come with a `configure` script of its own, we integrate the tests
|
|
521 |
+# here for simplicity.
|
|
522 |
+ |
|
523 |
+# We need `clock_gettime` from 'librt' for the `ftbench' demo program.
|
|
520 | 524 |
#
|
521 |
-# The code is modeled after gnulib's file `clock_time.m4', ignoring
|
|
525 |
+# The code is modeled after gnulib's file `clock_time.m4`, ignoring
|
|
522 | 526 |
# very old Solaris systems.
|
523 |
- |
|
524 | 527 |
LIB_CLOCK_GETTIME=
|
525 | 528 |
AC_SEARCH_LIBS([clock_gettime],
|
526 | 529 |
[rt],
|
527 | 530 |
[test "$ac_cv_search_clock_gettime" = "none required" \
|
528 | 531 |
|| LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
|
529 |
-AC_SUBST([LIB_CLOCK_GETTIME])
|
|
532 |
+ |
|
533 |
+# librsvg is needed to demonstrate SVG support.
|
|
534 |
+PKG_CHECK_MODULES([LIBRSVG], [librsvg-2.0],
|
|
535 |
+ [have_librsvg="yes (pkg-config)"], [have_librsvg=no])
|
|
536 |
+ |
|
537 |
+FT_DEMO_CFLAGS=""
|
|
538 |
+FT_DEMO_LDFLAGS="$LIB_CLOCK_GETTIME"
|
|
539 |
+ |
|
540 |
+if test "$have_librsvg" != no; then
|
|
541 |
+ FT_DEMO_CFLAGS="$FT_DEMO_CFLAGS $LIBRSVG_CFLAGS"
|
|
542 |
+ FT_DEMO_LDFLAGS="$FT_DEMO_LDFLAGS $LIBRSVG_LIBS"
|
|
543 |
+fi
|
|
544 |
+ |
|
545 |
+AC_SUBST([FT_DEMO_CFLAGS])
|
|
546 |
+AC_SUBST([FT_DEMO_LDFLAGS])
|
|
530 | 547 |
|
531 | 548 |
|
532 | 549 |
# Some options handling SDKs/archs in CFLAGS should be copied
|
... | ... | @@ -106,9 +106,7 @@ endif |
106 | 106 |
|
107 | 107 |
# Linker flags.
|
108 | 108 |
#
|
109 |
-LDFLAGS := @LDFLAGS@
|
|
110 |
-LIB_CLOCK_GETTIME := @LIB_CLOCK_GETTIME@ # for ftbench
|
|
111 |
- |
|
109 |
+LDFLAGS := @LDFLAGS@
|
|
112 | 110 |
|
113 | 111 |
# export symbols
|
114 | 112 |
#
|
... | ... | @@ -118,11 +116,15 @@ EXPORTS_LIST := $(OBJ_DIR)/ftexport.sym |
118 | 116 |
CCexe := $(CCraw_build) # used to compile `apinames' only
|
119 | 117 |
|
120 | 118 |
|
121 |
-# Library linking
|
|
119 |
+# Library linking.
|
|
122 | 120 |
#
|
123 | 121 |
LINK_LIBRARY = $(LIBTOOL) --mode=link $(CCraw) -o $@ $(OBJECTS_LIST) \
|
124 | 122 |
-rpath $(libdir) -version-info $(version_info) \
|
125 | 123 |
$(LDFLAGS) -no-undefined \
|
126 | 124 |
-export-symbols $(EXPORTS_LIST)
|
127 | 125 |
|
126 |
+# For the demo programs.
|
|
127 |
+FT_DEMO_CFLAGS := @FT_DEMO_CFLAGS@
|
|
128 |
+FT_DEMO_LDFLAGS := @FT_DEMO_LDFLAGS@
|
|
129 |
+ |
|
128 | 130 |
# EOF
|
... | ... | @@ -28,5 +28,6 @@ FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) |
28 | 28 |
FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
|
29 | 29 |
FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
|
30 | 30 |
FT_USE_MODULE( FT_Renderer_Class, ft_bitmap_sdf_renderer_class )
|
31 |
+FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class )
|
|
31 | 32 |
|
32 | 33 |
/* EOF */
|
... | ... | @@ -101,6 +101,8 @@ |
101 | 101 |
"too many hints" )
|
102 | 102 |
FT_ERRORDEF_( Invalid_Pixel_Size, 0x17,
|
103 | 103 |
"invalid pixel size" )
|
104 |
+ FT_ERRORDEF_( Invalid_SVG_Document, 0x18,
|
|
105 |
+ "invalid SVG document" )
|
|
104 | 106 |
|
105 | 107 |
/* handle errors */
|
106 | 108 |
|
... | ... | @@ -234,6 +236,8 @@ |
234 | 236 |
"found FDEF or IDEF opcode in glyf bytecode" )
|
235 | 237 |
FT_ERRORDEF_( Missing_Bitmap, 0x9D,
|
236 | 238 |
"missing bitmap in strike" )
|
239 |
+ FT_ERRORDEF_( Missing_SVG_Hooks, 0x9E,
|
|
240 |
+ "SVG hooks have not been set" )
|
|
237 | 241 |
|
238 | 242 |
/* CFF, CID, and Type 1 errors */
|
239 | 243 |
|
... | ... | @@ -49,6 +49,9 @@ FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ |
49 | 49 |
FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */
|
50 | 50 |
FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
|
51 | 51 |
|
52 |
+ /* ot-svg module */
|
|
53 |
+FT_TRACE_DEF( otsvg ) /* OT-SVG renderer (ftsvg.c) */
|
|
54 |
+ |
|
52 | 55 |
/* cache sub-system */
|
53 | 56 |
FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */
|
54 | 57 |
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * svginterface.h
|
|
4 |
+ *
|
|
5 |
+ * Interface of ot-svg module (specification only)
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 |
+ |
|
18 |
+ |
|
19 |
+#ifndef SVGINTERFACE_H_
|
|
20 |
+#define SVGINTERFACE_H_
|
|
21 |
+ |
|
22 |
+#include <ft2build.h>
|
|
23 |
+#include <freetype/otsvg.h>
|
|
24 |
+ |
|
25 |
+ |
|
26 |
+FT_BEGIN_HEADER
|
|
27 |
+ |
|
28 |
+ typedef FT_Error
|
|
29 |
+ (*Preset_Bitmap_Func)( FT_Module module,
|
|
30 |
+ FT_GlyphSlot slot,
|
|
31 |
+ FT_Bool cache );
|
|
32 |
+ |
|
33 |
+ typedef struct SVG_Interface_
|
|
34 |
+ {
|
|
35 |
+ Preset_Bitmap_Func preset_slot;
|
|
36 |
+ |
|
37 |
+ } SVG_Interface;
|
|
38 |
+ |
|
39 |
+ typedef SVG_Interface* SVG_Service;
|
|
40 |
+ |
|
41 |
+FT_END_HEADER
|
|
42 |
+ |
|
43 |
+#endif /* SVGINTERFACE_H_ */
|
|
44 |
+ |
|
45 |
+ |
|
46 |
+/* END */
|
... | ... | @@ -30,6 +30,217 @@ |
30 | 30 |
|
31 | 31 |
FT_BEGIN_HEADER
|
32 | 32 |
|
33 |
+ |
|
34 |
+ /**************************************************************************
|
|
35 |
+ *
|
|
36 |
+ * @functype:
|
|
37 |
+ * SVG_Lib_Init_Func
|
|
38 |
+ *
|
|
39 |
+ * @description:
|
|
40 |
+ * A callback that is called when the first OT-SVG glyph is rendered in
|
|
41 |
+ * the lifetime of an @FT_Library object. In a typical implementation,
|
|
42 |
+ * one would want to allocate a structure and point the `data_pointer`
|
|
43 |
+ * to it and perform any library initializations that might be needed.
|
|
44 |
+ *
|
|
45 |
+ * For more information on the implementation, see our standard hooks
|
|
46 |
+ * based on Librsvg in the 'FreeType Demo Programs' repository.
|
|
47 |
+ *
|
|
48 |
+ * @inout:
|
|
49 |
+ * data_pointer ::
|
|
50 |
+ * The SVG rendering module stores a pointer variable that can be used
|
|
51 |
+ * by clients to store any data that needs to be shared across
|
|
52 |
+ * different hooks. `data_pointer` is essentially a pointer to that
|
|
53 |
+ * pointer such that it can be written to as well as read from.
|
|
54 |
+ *
|
|
55 |
+ * @return:
|
|
56 |
+ * FreeType error code. 0 means success.
|
|
57 |
+ *
|
|
58 |
+ * @since:
|
|
59 |
+ * 2.12
|
|
60 |
+ */
|
|
61 |
+ typedef FT_Error
|
|
62 |
+ (*SVG_Lib_Init_Func)( FT_Pointer *data_pointer );
|
|
63 |
+ |
|
64 |
+ |
|
65 |
+ /**************************************************************************
|
|
66 |
+ *
|
|
67 |
+ * @functype:
|
|
68 |
+ * SVG_Lib_Free_Func
|
|
69 |
+ *
|
|
70 |
+ * @description:
|
|
71 |
+ * A callback that is called when the `ot-svg` module is being freed.
|
|
72 |
+ * It is only called if the init hook was called earlier. This means
|
|
73 |
+ * that neither the init nor the free hook is called if no OT-SVG glyph
|
|
74 |
+ * is rendered.
|
|
75 |
+ *
|
|
76 |
+ * In a typical implementation, one would want to free any state
|
|
77 |
+ * structure that was allocated in the init hook and perform any
|
|
78 |
+ * library-related closure that might be needed.
|
|
79 |
+ *
|
|
80 |
+ * For more information on the implementation, see our standard hooks
|
|
81 |
+ * based on Librsvg in the 'FreeType Demo Programs' repository.
|
|
82 |
+ *
|
|
83 |
+ * @inout:
|
|
84 |
+ * data_pointer ::
|
|
85 |
+ * The SVG rendering module stores a pointer variable that can be used
|
|
86 |
+ * by clients to store any data that needs to be shared across
|
|
87 |
+ * different hooks. `data_pointer` is essentially a pointer to that
|
|
88 |
+ * pointer such that it can be written to as well as read from.
|
|
89 |
+ *
|
|
90 |
+ * @since:
|
|
91 |
+ * 2.12
|
|
92 |
+ */
|
|
93 |
+ typedef void
|
|
94 |
+ (*SVG_Lib_Free_Func)( FT_Pointer *data_pointer );
|
|
95 |
+ |
|
96 |
+ |
|
97 |
+ /**************************************************************************
|
|
98 |
+ *
|
|
99 |
+ * @functype:
|
|
100 |
+ * SVG_Lib_Render_Func
|
|
101 |
+ *
|
|
102 |
+ * @description:
|
|
103 |
+ * A callback that is called to render an OT-SVG glyph. This callback
|
|
104 |
+ * hook is called right after the preset hook @SVG_Lib_Preset_SlotFunc
|
|
105 |
+ * has been called with `cache` set to `TRUE`. The data necessary to
|
|
106 |
+ * render is available through the handle @FT_SVG_Document, which is set
|
|
107 |
+ * in the `other` field of @FT_GlyphSlotRec.
|
|
108 |
+ *
|
|
109 |
+ * The render hook is expected to render the SVG glyph to the bitmap
|
|
110 |
+ * buffer that is allocated already at `slot->bitmap.buffer`. It also
|
|
111 |
+ * sets the `num_grays` value as well as `slot->format`.
|
|
112 |
+ *
|
|
113 |
+ * For more information on the implementation, see our standard hooks
|
|
114 |
+ * based on Librsvg in the 'FreeType Demo Programs' repository.
|
|
115 |
+ *
|
|
116 |
+ * @input:
|
|
117 |
+ * slot ::
|
|
118 |
+ * The slot to render.
|
|
119 |
+ *
|
|
120 |
+ * @inout:
|
|
121 |
+ * data_pointer ::
|
|
122 |
+ * The SVG rendering module stores a pointer variable that can be used
|
|
123 |
+ * by clients to store any data that needs to be shared across
|
|
124 |
+ * different hooks. `data_pointer` is essentially a pointer to that
|
|
125 |
+ * pointer such that it can be written to as well as read from.
|
|
126 |
+ *
|
|
127 |
+ * @return:
|
|
128 |
+ * FreeType error code. 0 means success.
|
|
129 |
+ *
|
|
130 |
+ * @since:
|
|
131 |
+ * 2.12
|
|
132 |
+ */
|
|
133 |
+ typedef FT_Error
|
|
134 |
+ (*SVG_Lib_Render_Func)( FT_GlyphSlot slot,
|
|
135 |
+ FT_Pointer *data_pointer );
|
|
136 |
+ |
|
137 |
+ |
|
138 |
+ /**************************************************************************
|
|
139 |
+ *
|
|
140 |
+ * @functype:
|
|
141 |
+ * SVG_Lib_Preset_Slot_Func
|
|
142 |
+ *
|
|
143 |
+ * @description:
|
|
144 |
+ * A callback that is called to preset the glyph slot. It is called from
|
|
145 |
+ * two places.
|
|
146 |
+ *
|
|
147 |
+ * 1. When `FT_Load_Glyph` needs to preset the glyph slot.
|
|
148 |
+ * 2. Right before the `svg` module calls the render callback hook.
|
|
149 |
+ *
|
|
150 |
+ * When it is the former, the argument `cache` is set to `FALSE`. When
|
|
151 |
+ * it is the latter, the argument `cache` is set to `TRUE`. This
|
|
152 |
+ * distinction has been made because many calculations that are necessary
|
|
153 |
+ * for presetting a glyph slot are the same needed later for the render
|
|
154 |
+ * callback hook. Thus, if `cache` is `TRUE`, the hook can _cache_ those
|
|
155 |
+ * calculations in a memory block referenced by the state pointer.
|
|
156 |
+ *
|
|
157 |
+ * This hook is expected to preset the slot by setting parameters such as
|
|
158 |
+ * `bitmap_left`, `bitmap_top`, `width`, `rows`, `pitch`, and
|
|
159 |
+ * `pixel_mode`. It is also expected to set all the metrics for the slot
|
|
160 |
+ * including the vertical advance if it is not already set. Typically,
|
|
161 |
+ * fonts have horizontal advances but not vertical ones. If those are
|
|
162 |
+ * available, they had already been set, otherwise they have to be
|
|
163 |
+ * estimated and set manually. The hook must take into account the
|
|
164 |
+ * transformations that have been set, and translate the transformation
|
|
165 |
+ * matrices into the SVG coordinate system, as the original matrix is
|
|
166 |
+ * intended for the TTF/CFF coordinate system.
|
|
167 |
+ *
|
|
168 |
+ * For more information on the implementation, see our standard hooks
|
|
169 |
+ * based on Librsvg in the 'FreeType Demo Programs' repository.
|
|
170 |
+ *
|
|
171 |
+ * @input:
|
|
172 |
+ * slot ::
|
|
173 |
+ * The glyph slot that has the SVG document loaded.
|
|
174 |
+ *
|
|
175 |
+ * cache ::
|
|
176 |
+ * See description.
|
|
177 |
+ *
|
|
178 |
+ * @inout:
|
|
179 |
+ * data_pointer ::
|
|
180 |
+ * The SVG rendering module stores a pointer variable that can be used
|
|
181 |
+ * by clients to store any data that needs to be shared across
|
|
182 |
+ * different hooks. `data_pointer` is essentially a pointer to that
|
|
183 |
+ * pointer such that it can be written to as well as read from.
|
|
184 |
+ *
|
|
185 |
+ * @return:
|
|
186 |
+ * FreeType error code. 0 means success.
|
|
187 |
+ *
|
|
188 |
+ * @since:
|
|
189 |
+ * 2.12
|
|
190 |
+ */
|
|
191 |
+ typedef FT_Error
|
|
192 |
+ (*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot,
|
|
193 |
+ FT_Bool cache,
|
|
194 |
+ FT_Pointer *state );
|
|
195 |
+ |
|
196 |
+ |
|
197 |
+ /**************************************************************************
|
|
198 |
+ *
|
|
199 |
+ * @struct:
|
|
200 |
+ * SVG_RendererHooks
|
|
201 |
+ *
|
|
202 |
+ * @description:
|
|
203 |
+ * A structure that stores the four hooks needed to render OT-SVG glyphs
|
|
204 |
+ * properly. The structure is publicly used to set the hooks via driver
|
|
205 |
+ * properties.
|
|
206 |
+ *
|
|
207 |
+ * The behavior of each hook is described in its documentation. One
|
|
208 |
+ * thing to note is that the preset hook and the render hook often need
|
|
209 |
+ * to do the same operations; therefore, it's better to cache the
|
|
210 |
+ * intermediate data in a state structure to avoid calculating it twice.
|
|
211 |
+ * For example, in the preset hook one can draw the glyph on a recorder
|
|
212 |
+ * surface and later create a bitmap surface from it in the render hook.
|
|
213 |
+ *
|
|
214 |
+ * For more information on the implementation, see our standard hooks
|
|
215 |
+ * based on Librsvg in the 'FreeType Demo Programs' repository.
|
|
216 |
+ *
|
|
217 |
+ * @fields:
|
|
218 |
+ * init_svg ::
|
|
219 |
+ * The initialization hook.
|
|
220 |
+ *
|
|
221 |
+ * free_svg ::
|
|
222 |
+ * The cleanup hook.
|
|
223 |
+ *
|
|
224 |
+ * render_hook ::
|
|
225 |
+ * The render hook.
|
|
226 |
+ *
|
|
227 |
+ * preset_slot ::
|
|
228 |
+ * The preset hook.
|
|
229 |
+ *
|
|
230 |
+ * @since:
|
|
231 |
+ * 2.12
|
|
232 |
+ */
|
|
233 |
+ typedef struct SVG_RendererHooks_
|
|
234 |
+ {
|
|
235 |
+ SVG_Lib_Init_Func init_svg;
|
|
236 |
+ SVG_Lib_Free_Func free_svg;
|
|
237 |
+ SVG_Lib_Render_Func render_svg;
|
|
238 |
+ |
|
239 |
+ SVG_Lib_Preset_Slot_Func preset_slot;
|
|
240 |
+ |
|
241 |
+ } SVG_RendererHooks;
|
|
242 |
+ |
|
243 |
+ |
|
33 | 244 |
/**************************************************************************
|
34 | 245 |
*
|
35 | 246 |
* @struct:
|
... | ... | @@ -172,6 +172,7 @@ ft2_public_headers = files([ |
172 | 172 |
'include/freetype/fttrigon.h',
|
173 | 173 |
'include/freetype/fttypes.h',
|
174 | 174 |
'include/freetype/ftwinfnt.h',
|
175 |
+ 'include/freetype/otsvg.h',
|
|
175 | 176 |
'include/freetype/t1tables.h',
|
176 | 177 |
'include/freetype/ttnameid.h',
|
177 | 178 |
'include/freetype/tttables.h',
|
... | ... | @@ -99,6 +99,9 @@ RASTER_MODULES += smooth |
99 | 99 |
# Monochrome rasterizer.
|
100 | 100 |
RASTER_MODULES += raster
|
101 | 101 |
|
102 |
+# OT-SVG.
|
|
103 |
+RASTER_MODULES += svg
|
|
104 |
+ |
|
102 | 105 |
# Signed distance field rasterizer.
|
103 | 106 |
RASTER_MODULES += sdf
|
104 | 107 |
|
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 |
#include <freetype/internal/ftstream.h>
|
29 | 29 |
#include <freetype/internal/sfnt.h> /* for SFNT_Load_Table_Func */
|
30 | 30 |
#include <freetype/internal/psaux.h> /* for PS_Driver */
|
31 |
+#include <freetype/internal/svginterface.h>
|
|
31 | 32 |
|
32 | 33 |
#include <freetype/tttables.h>
|
33 | 34 |
#include <freetype/tttags.h>
|
... | ... | @@ -386,7 +387,18 @@ |
386 | 387 |
FT_Pos width, height, pitch;
|
387 | 388 |
|
388 | 389 |
|
389 |
- if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
|
|
390 |
+ if ( slot->format == FT_GLYPH_FORMAT_SVG )
|
|
391 |
+ {
|
|
392 |
+ FT_Module module;
|
|
393 |
+ SVG_Service svg_service;
|
|
394 |
+ |
|
395 |
+ |
|
396 |
+ module = FT_Get_Module( slot->library, "ot-svg" );
|
|
397 |
+ svg_service = (SVG_Service)module->clazz->module_interface;
|
|
398 |
+ |
|
399 |
+ return (FT_Bool)svg_service->preset_slot( module, slot, FALSE );
|
|
400 |
+ }
|
|
401 |
+ else if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
|
|
390 | 402 |
return 1;
|
391 | 403 |
|
392 | 404 |
if ( origin )
|
... | ... | @@ -4524,7 +4536,7 @@ |
4524 | 4536 |
render->glyph_format = clazz->glyph_format;
|
4525 | 4537 |
|
4526 | 4538 |
/* allocate raster object if needed */
|
4527 |
- if ( clazz->raster_class->raster_new )
|
|
4539 |
+ if ( clazz->raster_class && clazz->raster_class->raster_new )
|
|
4528 | 4540 |
{
|
4529 | 4541 |
error = clazz->raster_class->raster_new( memory, &render->raster );
|
4530 | 4542 |
if ( error )
|
... | ... | @@ -4534,6 +4546,11 @@ |
4534 | 4546 |
render->render = clazz->render_glyph;
|
4535 | 4547 |
}
|
4536 | 4548 |
|
4549 |
+#ifdef FT_CONFIG_OPTION_SVG
|
|
4550 |
+ if ( clazz->glyph_format == FT_GLYPH_FORMAT_SVG )
|
|
4551 |
+ render->render = clazz->render_glyph;
|
|
4552 |
+#endif
|
|
4553 |
+ |
|
4537 | 4554 |
/* add to list */
|
4538 | 4555 |
node->data = module;
|
4539 | 4556 |
FT_List_Add( &library->renderers, node );
|
... | ... | @@ -299,7 +299,7 @@ |
299 | 299 |
if ( ( doc_list[0] == 0x1F ) && ( doc_list[1] == 0x8B )
|
300 | 300 |
&& ( doc_list[2] == 0x08 ) )
|
301 | 301 |
{
|
302 |
-#ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB
|
|
302 |
+#ifdef FT_CONFIG_OPTION_USE_ZLIB
|
|
303 | 303 |
|
304 | 304 |
FT_ULong uncomp_size;
|
305 | 305 |
FT_Byte* uncomp_buffer;
|
... | ... | @@ -338,12 +338,12 @@ |
338 | 338 |
doc_list = uncomp_buffer;
|
339 | 339 |
doc_length = uncomp_size;
|
340 | 340 |
|
341 |
-#else /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
|
|
341 |
+#else /* !FT_CONFIG_OPTION_USE_ZLIB */
|
|
342 | 342 |
|
343 | 343 |
error = FT_THROW( Unimplemented_Feature );
|
344 | 344 |
goto Exit;
|
345 | 345 |
|
346 |
-#endif /* !FT_CONFIG_OPTION_SYSTEM_ZLIB */
|
|
346 |
+#endif /* !FT_CONFIG_OPTION_USE_ZLIB */
|
|
347 | 347 |
}
|
348 | 348 |
|
349 | 349 |
svg_document->svg_document = doc_list;
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * ftsvg.c
|
|
4 |
+ *
|
|
5 |
+ * The FreeType SVG renderer interface (body).
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 |
+ |
|
18 |
+#include <freetype/internal/ftdebug.h>
|
|
19 |
+#include <freetype/internal/ftserv.h>
|
|
20 |
+#include <freetype/internal/services/svprop.h>
|
|
21 |
+#include <freetype/otsvg.h>
|
|
22 |
+#include <freetype/internal/svginterface.h>
|
|
23 |
+#include <freetype/ftbbox.h>
|
|
24 |
+ |
|
25 |
+#include "ftsvg.h"
|
|
26 |
+#include "svgtypes.h"
|
|
27 |
+ |
|
28 |
+ |
|
29 |
+ /**************************************************************************
|
|
30 |
+ *
|
|
31 |
+ * The macro FT_COMPONENT is used in trace mode. It is an implicit
|
|
32 |
+ * parameter of the FT_TRACE() and FT_ERROR() macros, usued to print/log
|
|
33 |
+ * messages during execution.
|
|
34 |
+ */
|
|
35 |
+#undef FT_COMPONENT
|
|
36 |
+#define FT_COMPONENT otsvg
|
|
37 |
+ |
|
38 |
+ |
|
39 |
+#ifdef FT_CONFIG_OPTION_SVG
|
|
40 |
+ |
|
41 |
+ /* ft_svg_init */
|
|
42 |
+ static FT_Error
|
|
43 |
+ ft_svg_init( SVG_Renderer svg_module )
|
|
44 |
+ {
|
|
45 |
+ FT_Error error = FT_Err_Ok;
|
|
46 |
+ |
|
47 |
+ |
|
48 |
+ svg_module->loaded = FALSE;
|
|
49 |
+ svg_module->hooks_set = FALSE;
|
|
50 |
+ |
|
51 |
+ return error;
|
|
52 |
+ }
|
|
53 |
+ |
|
54 |
+ |
|
55 |
+ static void
|
|
56 |
+ ft_svg_done( SVG_Renderer svg_module )
|
|
57 |
+ {
|
|
58 |
+ if ( svg_module->loaded == TRUE &&
|
|
59 |
+ svg_module->hooks_set == TRUE )
|
|
60 |
+ svg_module->hooks.free_svg( &svg_module->state );
|
|
61 |
+ |
|
62 |
+ svg_module->loaded = FALSE;
|
|
63 |
+ }
|
|
64 |
+ |
|
65 |
+ |
|
66 |
+ static FT_Error
|
|
67 |
+ ft_svg_preset_slot( FT_Module module,
|
|
68 |
+ FT_GlyphSlot slot,
|
|
69 |
+ FT_Bool cache )
|
|
70 |
+ {
|
|
71 |
+ SVG_Renderer svg_renderer = (SVG_Renderer)module;
|
|
72 |
+ SVG_RendererHooks hooks = svg_renderer->hooks;
|
|
73 |
+ |
|
74 |
+ |
|
75 |
+ if ( svg_renderer->hooks_set == FALSE )
|
|
76 |
+ {
|
|
77 |
+ FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" ));
|
|
78 |
+ return FT_THROW( Missing_SVG_Hooks );
|
|
79 |
+ }
|
|
80 |
+ |
|
81 |
+ if ( svg_renderer->loaded == FALSE )
|
|
82 |
+ {
|
|
83 |
+ FT_TRACE3(( "ft_svg_preset_slot: first presetting call,"
|
|
84 |
+ " calling init hook\n" ));
|
|
85 |
+ hooks.init_svg( &svg_renderer->state );
|
|
86 |
+ |
|
87 |
+ svg_renderer->loaded = TRUE;
|
|
88 |
+ }
|
|
89 |
+ |
|
90 |
+ return hooks.preset_slot( slot, cache, &svg_renderer->state );
|
|
91 |
+ }
|
|
92 |
+ |
|
93 |
+ |
|
94 |
+ static FT_Error
|
|
95 |
+ ft_svg_render( FT_Renderer renderer,
|
|
96 |
+ FT_GlyphSlot slot,
|
|
97 |
+ FT_Render_Mode mode,
|
|
98 |
+ const FT_Vector* origin )
|
|
99 |
+ {
|
|
100 |
+ SVG_Renderer svg_renderer = (SVG_Renderer)renderer;
|
|
101 |
+ |
|
102 |
+ FT_Library library = renderer->root.library;
|
|
103 |
+ FT_Memory memory = library->memory;
|
|
104 |
+ FT_Error error;
|
|
105 |
+ |
|
106 |
+ FT_ULong size_image_buffer;
|
|
107 |
+ |
|
108 |
+ SVG_RendererHooks hooks = svg_renderer->hooks;
|
|
109 |
+ |
|
110 |
+ |
|
111 |
+ FT_UNUSED( mode );
|
|
112 |
+ FT_UNUSED( origin );
|
|
113 |
+ |
|
114 |
+ if ( mode != FT_RENDER_MODE_NORMAL )
|
|
115 |
+ return FT_THROW( Bad_Argument );
|
|
116 |
+ |
|
117 |
+ if ( svg_renderer->hooks_set == FALSE )
|
|
118 |
+ {
|
|
119 |
+ FT_TRACE1(( "Hooks are NOT set. Can't render OT-SVG glyphs\n" ));
|
|
120 |
+ return FT_THROW( Missing_SVG_Hooks );
|
|
121 |
+ }
|
|
122 |
+ |
|
123 |
+ if ( svg_renderer->loaded == FALSE )
|
|
124 |
+ {
|
|
125 |
+ FT_TRACE3(( "ft_svg_render: first rendering, calling init hook\n" ));
|
|
126 |
+ error = hooks.init_svg( &svg_renderer->state );
|
|
127 |
+ |
|
128 |
+ svg_renderer->loaded = TRUE;
|
|
129 |
+ }
|
|
130 |
+ |
|
131 |
+ ft_svg_preset_slot( (FT_Module)renderer, slot, TRUE );
|
|
132 |
+ |
|
133 |
+ size_image_buffer = (FT_ULong)slot->bitmap.pitch * slot->bitmap.rows;
|
|
134 |
+ /* No `FT_QALLOC` here since we need a clean, empty canvas */
|
|
135 |
+ /* to start with. */
|
|
136 |
+ if ( FT_ALLOC( slot->bitmap.buffer, size_image_buffer ) )
|
|
137 |
+ return error;
|
|
138 |
+ |
|
139 |
+ error = hooks.render_svg( slot, &svg_renderer->state );
|
|
140 |
+ if ( error )
|
|
141 |
+ FT_FREE( slot->bitmap.buffer );
|
|
142 |
+ else
|
|
143 |
+ slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
|
|
144 |
+ |
|
145 |
+ return error;
|
|
146 |
+ }
|
|
147 |
+ |
|
148 |
+ |
|
149 |
+ static const SVG_Interface svg_interface =
|
|
150 |
+ {
|
|
151 |
+ (Preset_Bitmap_Func)ft_svg_preset_slot
|
|
152 |
+ };
|
|
153 |
+ |
|
154 |
+ |
|
155 |
+ static FT_Error
|
|
156 |
+ ft_svg_property_set( FT_Module module,
|
|
157 |
+ const char* property_name,
|
|
158 |
+ const void* value,
|
|
159 |
+ FT_Bool value_is_string )
|
|
160 |
+ {
|
|
161 |
+ FT_Error error = FT_Err_Ok;
|
|
162 |
+ SVG_Renderer renderer = (SVG_Renderer)module;
|
|
163 |
+ |
|
164 |
+ |
|
165 |
+ if ( !ft_strcmp( property_name, "svg_hooks" ) )
|
|
166 |
+ {
|
|
167 |
+ SVG_RendererHooks* hooks;
|
|
168 |
+ |
|
169 |
+ |
|
170 |
+ if ( value_is_string == TRUE )
|
|
171 |
+ return FT_THROW( Invalid_Argument );
|
|
172 |
+ |
|
173 |
+ hooks = (SVG_RendererHooks*)value;
|
|
174 |
+ |
|
175 |
+ renderer->hooks = *hooks;
|
|
176 |
+ renderer->hooks_set = TRUE;
|
|
177 |
+ }
|
|
178 |
+ else
|
|
179 |
+ error = FT_THROW( Missing_Property );
|
|
180 |
+ |
|
181 |
+ return error;
|
|
182 |
+ }
|
|
183 |
+ |
|
184 |
+ |
|
185 |
+ static FT_Error
|
|
186 |
+ ft_svg_property_get( FT_Module module,
|
|
187 |
+ const char* property_name,
|
|
188 |
+ const void* value )
|
|
189 |
+ {
|
|
190 |
+ FT_Error error = FT_Err_Ok;
|
|
191 |
+ SVG_Renderer renderer = (SVG_Renderer)module;
|
|
192 |
+ |
|
193 |
+ |
|
194 |
+ if ( !ft_strcmp( property_name, "svg_hooks" ) )
|
|
195 |
+ {
|
|
196 |
+ SVG_RendererHooks* hooks = (SVG_RendererHooks*)value;
|
|
197 |
+ |
|
198 |
+ |
|
199 |
+ *hooks = renderer->hooks;
|
|
200 |
+ }
|
|
201 |
+ else
|
|
202 |
+ error = FT_THROW( Missing_Property );
|
|
203 |
+ |
|
204 |
+ return error;
|
|
205 |
+ }
|
|
206 |
+ |
|
207 |
+ |
|
208 |
+ FT_DEFINE_SERVICE_PROPERTIESREC(
|
|
209 |
+ ft_svg_service_properties,
|
|
210 |
+ |
|
211 |
+ (FT_Properties_SetFunc)ft_svg_property_set, /* set_property */
|
|
212 |
+ (FT_Properties_GetFunc)ft_svg_property_get /* get_property */
|
|
213 |
+ )
|
|
214 |
+ |
|
215 |
+ |
|
216 |
+ FT_DEFINE_SERVICEDESCREC1(
|
|
217 |
+ ft_svg_services,
|
|
218 |
+ FT_SERVICE_ID_PROPERTIES, &ft_svg_service_properties )
|
|
219 |
+ |
|
220 |
+ |
|
221 |
+ FT_CALLBACK_DEF( FT_Module_Interface )
|
|
222 |
+ ft_svg_get_interface( FT_Module module,
|
|
223 |
+ const char* ft_svg_interface )
|
|
224 |
+ {
|
|
225 |
+ FT_Module_Interface result;
|
|
226 |
+ |
|
227 |
+ |
|
228 |
+ FT_UNUSED( module );
|
|
229 |
+ |
|
230 |
+ result = ft_service_list_lookup( ft_svg_services, ft_svg_interface );
|
|
231 |
+ if ( result )
|
|
232 |
+ return result;
|
|
233 |
+ |
|
234 |
+ return 0;
|
|
235 |
+ }
|
|
236 |
+ |
|
237 |
+ |
|
238 |
+ static FT_Error
|
|
239 |
+ ft_svg_transform( FT_Renderer renderer,
|
|
240 |
+ FT_GlyphSlot slot,
|
|
241 |
+ const FT_Matrix* _matrix,
|
|
242 |
+ const FT_Vector* _delta )
|
|
243 |
+ {
|
|
244 |
+ FT_SVG_Document doc = (FT_SVG_Document)slot->other;
|
|
245 |
+ FT_Matrix* matrix = (FT_Matrix*)_matrix;
|
|
246 |
+ FT_Vector* delta = (FT_Vector*)_delta;
|
|
247 |
+ |
|
248 |
+ FT_Matrix tmp_matrix;
|
|
249 |
+ FT_Vector tmp_delta;
|
|
250 |
+ |
|
251 |
+ FT_Matrix a, b;
|
|
252 |
+ FT_Pos x, y;
|
|
253 |
+ |
|
254 |
+ |
|
255 |
+ FT_UNUSED( renderer );
|
|
256 |
+ |
|
257 |
+ if ( !matrix )
|
|
258 |
+ {
|
|
259 |
+ tmp_matrix.xx = 0x10000;
|
|
260 |
+ tmp_matrix.xy = 0;
|
|
261 |
+ tmp_matrix.yx = 0;
|
|
262 |
+ tmp_matrix.yy = 0x10000;
|
|
263 |
+ |
|
264 |
+ matrix = &tmp_matrix;
|
|
265 |
+ }
|
|
266 |
+ |
|
267 |
+ if ( !delta )
|
|
268 |
+ {
|
|
269 |
+ tmp_delta.x = 0;
|
|
270 |
+ tmp_delta.y = 0;
|
|
271 |
+ |
|
272 |
+ delta = &tmp_delta;
|
|
273 |
+ }
|
|
274 |
+ |
|
275 |
+ a = doc->transform;
|
|
276 |
+ b = *matrix;
|
|
277 |
+ FT_Matrix_Multiply( &b, &a );
|
|
278 |
+ |
|
279 |
+ |
|
280 |
+ x = ADD_LONG( ADD_LONG( FT_MulFix( matrix->xx, doc->delta.x ),
|
|
281 |
+ FT_MulFix( matrix->xy, doc->delta.y ) ),
|
|
282 |
+ delta->x );
|
|
283 |
+ y = ADD_LONG( ADD_LONG( FT_MulFix( matrix->yx, doc->delta.x ),
|
|
284 |
+ FT_MulFix( matrix->yy, doc->delta.y ) ),
|
|
285 |
+ delta->y );
|
|
286 |
+ |
|
287 |
+ doc->delta.x = x;
|
|
288 |
+ doc->delta.y = y;
|
|
289 |
+ doc->transform = a;
|
|
290 |
+ |
|
291 |
+ return FT_Err_Ok;
|
|
292 |
+ }
|
|
293 |
+ |
|
294 |
+#endif /* FT_CONFIG_OPTION_SVG */
|
|
295 |
+ |
|
296 |
+ |
|
297 |
+#ifdef FT_CONFIG_OPTION_SVG
|
|
298 |
+#define PUT_SVG_MODULE( a ) a
|
|
299 |
+#define SVG_GLYPH_FORMAT FT_GLYPH_FORMAT_SVG
|
|
300 |
+#else
|
|
301 |
+#define PUT_SVG_MODULE( a ) NULL
|
|
302 |
+#define SVG_GLYPH_FORMAT FT_GLYPH_FORMAT_NONE
|
|
303 |
+#endif
|
|
304 |
+ |
|
305 |
+ |
|
306 |
+ FT_DEFINE_RENDERER(
|
|
307 |
+ ft_svg_renderer_class,
|
|
308 |
+ |
|
309 |
+ FT_MODULE_RENDERER,
|
|
310 |
+ sizeof ( SVG_RendererRec ),
|
|
311 |
+ |
|
312 |
+ "ot-svg",
|
|
313 |
+ 0x10000L,
|
|
314 |
+ 0x20000L,
|
|
315 |
+ |
|
316 |
+ (const void*)PUT_SVG_MODULE( &svg_interface ), /* module specific interface */
|
|
317 |
+ |
|
318 |
+ (FT_Module_Constructor)PUT_SVG_MODULE( ft_svg_init ), /* module_init */
|
|
319 |
+ (FT_Module_Destructor)PUT_SVG_MODULE( ft_svg_done ), /* module_done */
|
|
320 |
+ PUT_SVG_MODULE( ft_svg_get_interface ), /* get_interface */
|
|
321 |
+ |
|
322 |
+ SVG_GLYPH_FORMAT,
|
|
323 |
+ |
|
324 |
+ (FT_Renderer_RenderFunc) PUT_SVG_MODULE( ft_svg_render ), /* render_glyph */
|
|
325 |
+ (FT_Renderer_TransformFunc)PUT_SVG_MODULE( ft_svg_transform ), /* transform_glyph */
|
|
326 |
+ NULL, /* get_glyph_cbox */
|
|
327 |
+ NULL, /* set_mode */
|
|
328 |
+ NULL /* raster_class */
|
|
329 |
+ )
|
|
330 |
+ |
|
331 |
+ |
|
332 |
+/* END */
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * ftsvg.h
|
|
4 |
+ *
|
|
5 |
+ * The FreeType SVG renderer interface (specification).
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 |
+ |
|
18 |
+#ifndef FTSVG_H_
|
|
19 |
+#define FTSVG_H_
|
|
20 |
+ |
|
21 |
+#include <ft2build.h>
|
|
22 |
+#include <freetype/ftrender.h>
|
|
23 |
+#include <freetype/internal/ftobjs.h>
|
|
24 |
+ |
|
25 |
+ |
|
26 |
+FT_BEGIN_HEADER
|
|
27 |
+ |
|
28 |
+ FT_DECLARE_RENDERER( ft_svg_renderer_class )
|
|
29 |
+ |
|
30 |
+FT_END_HEADER
|
|
31 |
+ |
|
32 |
+#endif /* FTSVG_H_ */
|
|
33 |
+ |
|
34 |
+ |
|
35 |
+/* END */
|
1 |
+#
|
|
2 |
+# FreeType 2 SVG renderer module definition
|
|
3 |
+#
|
|
4 |
+ |
|
5 |
+ |
|
6 |
+# Copyright (C) 2021 by
|
|
7 |
+# David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
8 |
+#
|
|
9 |
+# This file is part of the FreeType project, and may only be used, modified,
|
|
10 |
+# and distributed under the terms of the FreeType project license,
|
|
11 |
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
|
12 |
+# indicate that you have read the license and understand and accept it
|
|
13 |
+# fully.
|
|
14 |
+ |
|
15 |
+ |
|
16 |
+FTMODULE_H_COMMANDS += SVG_MODULE
|
|
17 |
+ |
|
18 |
+define SVG_MODULE
|
|
19 |
+$(OPEN_DRIVER) FT_Renderer_Class, ft_svg_renderer_class $(CLOSE_DRIVER)
|
|
20 |
+$(ECHO_DRIVER)ot-svg $(ECHO_DRIVER_DESC)OT-SVG glyph renderer module$(ECHO_DRIVER_DONE)
|
|
21 |
+endef
|
|
22 |
+ |
|
23 |
+# EOF
|
1 |
+#
|
|
2 |
+# FreeType 2 SVG renderer module build rules
|
|
3 |
+#
|
|
4 |
+ |
|
5 |
+ |
|
6 |
+# Copyright (C) 2021 by
|
|
7 |
+# David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
8 |
+#
|
|
9 |
+# This file is part of the FreeType project, and may only be used, modified,
|
|
10 |
+# and distributed under the terms of the FreeType project license,
|
|
11 |
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
|
12 |
+# indicate that you have read the license and understand and accept it
|
|
13 |
+# fully.
|
|
14 |
+ |
|
15 |
+ |
|
16 |
+# SVG renderer driver directory
|
|
17 |
+#
|
|
18 |
+SVG_DIR := $(SRC_DIR)/svg
|
|
19 |
+ |
|
20 |
+# compilation flags for the driver
|
|
21 |
+#
|
|
22 |
+SVG_COMPILE := $(CC) $(ANSIFLAGS) \
|
|
23 |
+ $I$(subst /,$(COMPILER_SEP),$(SVG_DIR)) \
|
|
24 |
+ $(INCLUDE_FLAGS) \
|
|
25 |
+ $(FT_CFLAGS)
|
|
26 |
+ |
|
27 |
+# SVG renderer sources (i.e., C files)
|
|
28 |
+#
|
|
29 |
+SVG_DRV_SRC := $(SVG_DIR)/ftsvg.c
|
|
30 |
+ |
|
31 |
+ |
|
32 |
+# SVG renderer headers
|
|
33 |
+#
|
|
34 |
+SVG_DRV_H := $(SVG_DIR)/ftsvg.h \
|
|
35 |
+ $(SVG_DIR)/svgtypes.h
|
|
36 |
+ |
|
37 |
+ |
|
38 |
+# SVG renderer object(s)
|
|
39 |
+#
|
|
40 |
+# SVG_DRV_OBJ_M is used during `multi' builds.
|
|
41 |
+# SVG_DRV_OBJ_S is used during `single' builds.
|
|
42 |
+#
|
|
43 |
+SVG_DRV_OBJ_M := $(SVG_DRV_SRC:$(SVG_DIR)/%.c=$(OBJ_DIR)/%.$O)
|
|
44 |
+SVG_DRV_OBJ_S := $(OBJ_DIR)/svg.$O
|
|
45 |
+ |
|
46 |
+# SVG renderer source file for single build
|
|
47 |
+#
|
|
48 |
+SVG_DRV_SRC_S := $(SVG_DIR)/svg.c
|
|
49 |
+ |
|
50 |
+ |
|
51 |
+# SVG renderer - single object
|
|
52 |
+#
|
|
53 |
+$(SVG_DRV_OBJ_S): $(SVG_DRV_SRC_S) $(SVG_DRV_SRC) \
|
|
54 |
+ $(FREETYPE_H) $(SVG_DRV_H)
|
|
55 |
+ $(SVG_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SVG_DRV_SRC_S))
|
|
56 |
+ |
|
57 |
+ |
|
58 |
+# SVG renderer - multiple objects
|
|
59 |
+#
|
|
60 |
+$(OBJ_DIR)/%.$O: $(SVG_DIR)/%.c $(FREETYPE_H) $(SVG_DRV_H)
|
|
61 |
+ $(SVG_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
|
62 |
+ |
|
63 |
+ |
|
64 |
+# update main driver object lists
|
|
65 |
+#
|
|
66 |
+DRV_OBJS_S += $(SVG_DRV_OBJ_S)
|
|
67 |
+DRV_OBJS_M += $(SVG_DRV_OBJ_M)
|
|
68 |
+ |
|
69 |
+ |
|
70 |
+# EOF
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * svg.c
|
|
4 |
+ *
|
|
5 |
+ * FreeType SVG renderer module component (body only).
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 |
+ |
|
18 |
+#define FT_MAKE_OPTION_SINGLE_OBJECT
|
|
19 |
+ |
|
20 |
+#include "svgtypes.h"
|
|
21 |
+#include "ftsvg.c"
|
|
22 |
+ |
|
23 |
+ |
|
24 |
+/* END */
|
1 |
+/****************************************************************************
|
|
2 |
+ *
|
|
3 |
+ * svgtypes.h
|
|
4 |
+ *
|
|
5 |
+ * The FreeType SVG renderer internal types (specification).
|
|
6 |
+ *
|
|
7 |
+ * Copyright (C) 2021 by
|
|
8 |
+ * David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
|
|
9 |
+ *
|
|
10 |
+ * This file is part of the FreeType project, and may only be used,
|
|
11 |
+ * modified, and distributed under the terms of the FreeType project
|
|
12 |
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
13 |
+ * this file you indicate that you have read the license and
|
|
14 |
+ * understand and accept it fully.
|
|
15 |
+ *
|
|
16 |
+ */
|
|
17 |
+ |
|
18 |
+#ifndef SVGTYPES_H_
|
|
19 |
+#define SVGTYPES_H_
|
|
20 |
+ |
|
21 |
+#include <ft2build.h>
|
|
22 |
+#include <freetype/internal/ftobjs.h>
|
|
23 |
+#include <freetype/ftrender.h>
|
|
24 |
+#include <freetype/otsvg.h>
|
|
25 |
+ |
|
26 |
+ |
|
27 |
+ typedef struct SVG_RendererRec_
|
|
28 |
+ {
|
|
29 |
+ FT_RendererRec root; /* this inherits FT_RendererRec */
|
|
30 |
+ FT_Bool loaded;
|
|
31 |
+ FT_Bool hooks_set;
|
|
32 |
+ SVG_RendererHooks hooks; /* this holds hooks for SVG rendering */
|
|
33 |
+ FT_Pointer state; /* a place for hooks to store state, if needed */
|
|
34 |
+ |
|
35 |
+ } SVG_RendererRec;
|
|
36 |
+ |
|
37 |
+ typedef struct SVG_RendererRec_* SVG_Renderer;
|
|
38 |
+ |
|
39 |
+#endif /* SVGTYPES_H_ */
|
|
40 |
+ |
|
41 |
+ |
|
42 |
+/* EOF */
|