summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoazin Khatti <moazinkhatri@gmail.com>2019-06-13 16:18:09 +0500
committerMoazin Khatti <moazinkhatri@gmail.com>2019-07-11 14:09:42 +0500
commit7915e5e102e1c2b77f786c87bc0b43fbc93ac359 (patch)
tree3590e8e64a93981debae0d24b0dba40d6893b818
parent1ab8251ff12103fdd1adf91b792082a4275aaba5 (diff)
downloadfreetype2-7915e5e102e1c2b77f786c87bc0b43fbc93ac359.tar.gz
Barebones of an SVG rendering module and making it part of the build system
-rw-r--r--include/freetype/config/ftmodule.h3
-rw-r--r--modules.cfg3
-rw-r--r--src/base/ftobjs.c3
-rw-r--r--src/svg/ftsvg.c79
-rw-r--r--src/svg/ftsvg.h32
-rw-r--r--src/svg/module.mk23
-rw-r--r--src/svg/rules.mk72
-rw-r--r--src/svg/svg.c25
-rw-r--r--src/svg/svgtypes.c43
9 files changed, 282 insertions, 1 deletions
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index 7c603e532..0f37d07cb 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -22,7 +22,8 @@ FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
FT_USE_MODULE( FT_Module_Class, psaux_module_class )
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
-FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
+FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class )
+/*FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )*/
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
diff --git a/modules.cfg b/modules.cfg
index dc6c8d42d..14ac1e5bc 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -99,6 +99,9 @@ RASTER_MODULES += raster
# Anti-aliasing rasterizer.
RASTER_MODULES += smooth
+# OT-SVG
+RASTER_MODULES += svg
+
####
#### auxiliary modules
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index e301f8f11..697066b41 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4538,7 +4538,10 @@
{
case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
break;
+ case FT_GLYPH_FORMAT_SVG: /* handle svg rendering */
+ renderer = FT_Lookup_Renderer( library, slot->format, NULL );
+ break;
default:
if ( slot->internal->load_flags & FT_LOAD_COLOR )
{
diff --git a/src/svg/ftsvg.c b/src/svg/ftsvg.c
new file mode 100644
index 000000000..2f1570aaf
--- /dev/null
+++ b/src/svg/ftsvg.c
@@ -0,0 +1,79 @@
+/****************************************************************************
+ *
+ * ftsvg.c
+ *
+ * The FreeType svg renderer interface (body).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+#include <ft2build.h>
+#include <stdio.h>
+
+#include "ftsvg.h"
+
+ /* tmp hook injection */
+ FT_Error
+ tmp_svg_lib_init()
+ {
+ FT_Error error = FT_Err_Ok;
+ printf("Init svg\n");
+ return error;
+ }
+
+ /* ft_svg_init */
+ static FT_Error
+ ft_svg_init( SVG_Renderer svg_module )
+ {
+ FT_Error error = FT_Err_Ok;
+ SVG_RendererHooks hooks;
+
+ hooks.svg_lib_init = tmp_svg_lib_init;
+ svg_module->hooks = hooks;
+ svg_module->loaded = FALSE;
+
+ return error;
+ }
+
+ static FT_Error
+ ft_svg_render( FT_Renderer renderer,
+ FT_GlyphSlot slot,
+ FT_Render_Mode mode,
+ const FT_Vector* origin )
+ {
+ SVG_Renderer renderer_ = (SVG_Renderer)renderer;
+ if( renderer_->loaded == FALSE )
+ renderer_->loaded = TRUE;
+ renderer_->hooks.svg_lib_init();
+ }
+
+
+
+ FT_DEFINE_RENDERER(
+ ft_svg_renderer_class,
+
+ FT_MODULE_RENDERER,
+ sizeof( SVG_RendererRec ),
+
+ "ot-svg",
+ 0x10000L,
+ 0x20000L,
+ NULL, /* module specific interface */
+ (FT_Module_Constructor)ft_svg_init, /* module_init */
+ NULL,
+ NULL,
+ FT_GLYPH_FORMAT_SVG,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ )
diff --git a/src/svg/ftsvg.h b/src/svg/ftsvg.h
new file mode 100644
index 000000000..3c996775f
--- /dev/null
+++ b/src/svg/ftsvg.h
@@ -0,0 +1,32 @@
+/****************************************************************************
+ *
+ * ftsvg.h
+ *
+ * The FreeType svg renderer interface (specification).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+#ifndef FTSVG_H_
+#define FTSVG_H_
+
+#include <ft2build.h>
+#include FT_RENDER_H
+
+FT_BEGIN_HEADER
+
+ FT_DECLARE_RENDERER( ft_svg_renderer_class )
+
+FT_END_HEADER
+
+#endif /* FTSVG_H_ */
+
+/* END */
diff --git a/src/svg/module.mk b/src/svg/module.mk
new file mode 100644
index 000000000..b6efa174e
--- /dev/null
+++ b/src/svg/module.mk
@@ -0,0 +1,23 @@
+#
+# FreeType 2 svg renderer module definition
+#
+
+
+# Copyright (C) 1996-2019 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
+FTMODULE_H_COMMANDS += SVG_MODULE
+
+define SVG_MODULE
+$(OPEN_DRIVER) FT_Renderer_Class, ft_svg_renderer_class $(CLOSE_DRIVER)
+$(ECHO_DRIVER)svg $(ECHO_DRIVER_DESC)svg renderer module$(ECHO_DRIVER_DONE)
+endef
+
+# EOF
diff --git a/src/svg/rules.mk b/src/svg/rules.mk
new file mode 100644
index 000000000..0f14de443
--- /dev/null
+++ b/src/svg/rules.mk
@@ -0,0 +1,72 @@
+#
+# FreeType 2 svg renderer module build rules
+#
+
+
+# Copyright (C) 1996-2019 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+
+# svg renderer driver directory
+#
+SVG_DIR := $(SRC_DIR)/svg
+
+# compilation flags for the driver
+#
+SVG_COMPILE := $(CC) $(ANSIFLAGS) \
+ $I$(subst /,$(COMPILER_SEP),$(SVG_DIR)) \
+ $(INCLUDE_FLAGS) \
+ $(FT_CFLAGS)
+
+
+# raster driver sources (i.e., C files)
+#
+SVG_DRV_SRC := $(SVG_DIR)/ftsvg.c \
+ $(SVG_DIR)/svgtypes.c
+
+
+# raster driver headers
+#
+SVG_DRV_H := $(SVG_DIR)/ftsvg.h
+
+
+# raster driver object(s)
+#
+# RASTER_DRV_OBJ_M is used during `multi' builds.
+# RASTER_DRV_OBJ_S is used during `single' builds.
+#
+#RASTER_DRV_OBJ_M := $(RASTER_DRV_SRC:$(RASTER_DIR)/%.c=$(OBJ_DIR)/%.$O)
+SVG_DRV_OBJ_M := $(SVG_DRV_SRC:$(SVG_DIR)/%.c=$(OBJ_DIR)/%.$O)
+SVG_DRV_OBJ_S := $(OBJ_DIR)/svg.$O
+
+# raster driver source file for single build
+#
+SVG_DRV_SRC_S := $(SVG_DIR)/svg.c
+
+
+# raster driver - single object
+#
+$(SVG_DRV_OBJ_S): $(SVG_DRV_SRC_S) $(SVG_DRV_SRC) \
+ $(FREETYPE_H) $(SVG_DRV_H)
+ $(SVG_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SVG_DRV_SRC_S))
+
+
+# raster driver - multiple objects
+#
+$(OBJ_DIR)/%.$O: $(SVG_DIR)/%.c $(FREETYPE_H) $(SVG_DRV_H)
+ $(SVG_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
+
+
+# update main driver object lists
+#
+DRV_OBJS_S += $(SVG_DRV_OBJ_S)
+DRV_OBJS_M += $(SVG_DRV_OBJ_M)
+
+
+# EOF
diff --git a/src/svg/svg.c b/src/svg/svg.c
new file mode 100644
index 000000000..660bb1c04
--- /dev/null
+++ b/src/svg/svg.c
@@ -0,0 +1,25 @@
+/****************************************************************************
+ *
+ * svg.c
+ *
+ * FreeType svg renderer module component (body only).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+#define FT_MAKE_OPTION_SINGLE_OBJECT
+#include <ft2build.h>
+
+#include "svgtypes.c"
+#include "ftsvg.c"
+
+
+/* END */
diff --git a/src/svg/svgtypes.c b/src/svg/svgtypes.c
new file mode 100644
index 000000000..f3f70105e
--- /dev/null
+++ b/src/svg/svgtypes.c
@@ -0,0 +1,43 @@
+/****************************************************************************
+ *
+ * svgtypes.h
+ *
+ * TODO:
+ * The FreeType svg renderer internal types (specification).
+ *
+ * Copyright (C) 1996-2019 by
+ * David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT. By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
+
+#include <ft2build.h>
+#include FT_INTERNAL_OBJECTS_H
+#include FT_RENDER_H
+
+
+ /* Function Pointer definitions for SVG_RendererHooks */
+ typedef FT_Error (*SVG_Lib_Init)(); /* initialize the external lib */
+ typedef FT_Error (*SVG_Lib_Free)(); /* destroy the external lib */
+
+ typedef struct SVG_RendererHooks_
+ {
+ /* Api Hooks for OT-SVG Rendering */
+ SVG_Lib_Init svg_lib_init;
+ SVG_Lib_Free svg_lib_free;
+ } SVG_RendererHooks;
+
+ typedef struct SVG_RendererRec_
+ {
+ FT_RendererRec root; /* This inherits FT_RendererRec */
+ FT_Bool loaded;
+ SVG_RendererHooks hooks; /* Holds out hooks to the outside library */
+ } SVG_RendererRec;
+
+ typedef struct SVG_RendererRec_* SVG_Renderer;
+