Barebones of an SVG rendering module and making it part of the build system
This commit is contained in:
parent
1ab8251ff1
commit
7915e5e102
|
@ -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, psaux_module_class )
|
||||||
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
|
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
|
||||||
FT_USE_MODULE( FT_Module_Class, pshinter_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_Module_Class, sfnt_module_class )
|
||||||
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
|
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
|
||||||
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
|
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
|
||||||
|
|
|
@ -99,6 +99,9 @@ RASTER_MODULES += raster
|
||||||
# Anti-aliasing rasterizer.
|
# Anti-aliasing rasterizer.
|
||||||
RASTER_MODULES += smooth
|
RASTER_MODULES += smooth
|
||||||
|
|
||||||
|
# OT-SVG
|
||||||
|
RASTER_MODULES += svg
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#### auxiliary modules
|
#### auxiliary modules
|
||||||
|
|
|
@ -4538,7 +4538,10 @@
|
||||||
{
|
{
|
||||||
case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
|
case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */
|
||||||
break;
|
break;
|
||||||
|
case FT_GLYPH_FORMAT_SVG: /* handle svg rendering */
|
||||||
|
renderer = FT_Lookup_Renderer( library, slot->format, NULL );
|
||||||
|
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if ( slot->internal->load_flags & FT_LOAD_COLOR )
|
if ( slot->internal->load_flags & FT_LOAD_COLOR )
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
|
)
|
|
@ -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 */
|
|
@ -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
|
|
@ -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
|
|
@ -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 */
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue