Hi Werner and Toshiya, Please find the report for week 3 here: https://hackmd.io/@xAHoMwB3QOSJR5L2HGzXGg/Hyk1JtC1S
The report has three sections. The first one is a brief summary of the work I have done the past week. The second and third sections discuss the way I designed the new structures and the technique I used to free memory. These sections were probably not necessary to write in a report but I still did it for two reasons: 1. It will allow you to quickly understand the code I have written when you'll be reviewing it in depth. 2. It presents a good chance for the community to discuss and suggest better ideas. *A demo of `ftview' working with OT-SVG fonts* This demo has 3 files. The larger one of the three can be grabbed from: https://drive.google.com/open?id=1Nl0mtExvXXzuCdUvURAPzqGS0Ed-5K7J The rest of the two are attached. The demo only runs on a Linux machine with the latest version of Rust installed. You'll also need to have cairo installed. As well as FreeType's usual dependencies installed. To run it, create a new folder and put all of the three files in it. From your terminal run `sh script.sh'. Hopefully, it'll run. I have tried to use `pkg-config' calls in the Makefiles so that they work on all machines. In case things go wrong, please feel free to let me know. Thank you, Moazin
diff --git a/Makefile b/Makefile
index 4c91e17..da2df77 100644
--- a/Makefile
+++ b/Makefile
@@ -121,11 +121,16 @@ else
SRC_DIR := $(TOP_DIR_2)/src
endif
+ CAIRO_INC = $(shell pkg-config cairo --cflags | sed "s/\/freetype2//g" | sed "s/-I//g" | sed "s/ / \n/g")
+
FT_INCLUDES := $(OBJ_BUILD) \
$(BUILD_DIR) \
$(DEVEL_DIR) \
$(TOP_DIR)/include \
- $(SRC_DIR)
+ $(SRC_DIR) \
+ ../resvg_rendering_port/port \
+ ../resvg_rendering_port/port/resvg/capi/include \
+ $(CAIRO_INC)
COMPILE = $(CC) $(CPPFLAGS) \
$(CFLAGS) \
@@ -179,6 +184,10 @@ else
endif
endif
+LINK_LIBS += -L../resvg_rendering_port/port/resvg/target/debug
+LINK_LIBS += -lresvg
+LINK_LIBS += $(shell pkg-config cairo --libs)
+
LINK = $(LINK_CMD) \
$(LINK_ITEMS) \
$(LINK_LIBS)
@@ -193,6 +202,14 @@ else
$(LINK_LIBS) $(subst /,$(COMPILER_SEP),$(GRAPH_LIB)) \
$(GRAPH_LINK) $(MATH)
+ resvg = ../resvg_rendering_port/port/build/resvg_port.o
+
+ LINK_NEW_VIEW = $(LINK_CMD) \
+ $(LINK_ITEMS) $(subst /,$(COMPILER_SEP),$(COMMON_OBJ) \
+ $(FTCOMMON_OBJ)) \
+ $(LINK_LIBS) $(subst /,$(COMPILER_SEP),$(GRAPH_LIB)) \
+ $(GRAPH_LINK) $(MATH) $(resvg)
+
.PHONY: exes clean distclean
@@ -519,9 +536,10 @@ else
$(LINK)
- $(BIN_DIR_2)/ftview$E: $(OBJ_DIR_2)/ftview.$(SO) $(FTLIB) \
- $(GRAPH_LIB) $(COMMON_OBJ) $(FTCOMMON_OBJ)
- $(LINK_NEW)
+
+ $(BIN_DIR_2)/ftview$E: $(OBJ_DIR_2)/ftview.$(SO) $(FTLIB) \
+ $(GRAPH_LIB) $(COMMON_OBJ) $(FTCOMMON_OBJ)
+ $(LINK_NEW_VIEW)
$(BIN_DIR_2)/ftgrid$E: $(OBJ_DIR_2)/ftgrid.$(SO) $(FTLIB) \
$(GRAPH_LIB) $(COMMON_OBJ) $(FTCOMMON_OBJ)
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 89c69d0..0cb7c73 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -1118,6 +1118,17 @@
*aglyf = glyf;
}
+ if ( glyf->format == FT_GLYPH_FORMAT_SVG )
+ {
+
+ /* render the glyph to a bitmap, don't destroy original */
+ error = FT_Glyph_To_Bitmap( &glyf, FT_RENDER_MODE_NORMAL, NULL, 0 );
+ if ( error )
+ return error;
+
+ *aglyf = glyf;
+ }
+
if ( glyf->format != FT_GLYPH_FORMAT_BITMAP )
PanicZ( "invalid glyph format returned!" );
diff --git a/src/ftview.c b/src/ftview.c
index 60fc2dc..662e12a 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -37,6 +37,9 @@
#include FT_COLOR_H
#include FT_BITMAP_H
+#include FT_SVG_RENDERER_H
+
+#include <resvg_port.h>
#define MAXPTSIZE 500 /* dtp */
@@ -2007,6 +2010,11 @@
for ( ; argc > 0; argc--, argv++ )
FTDemo_Install_Font( handle, argv[0], 0, 0 );
+ /* inject the hooks for SVG */
+ FT_Set_Svg_Hooks( handle->library, resvg_port_init, resvg_port_free,
+ resvg_port_render );
+
+
if ( handle->num_fonts == 0 )
Fatal( "could not find/open any font file" );
script.sh
Description: application/shellscript
_______________________________________________ Freetype-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype-devel
