forked from minhngoc25a/freetype2
added the structure of new `sdf' module
This commit is contained in:
parent
986a340dd5
commit
185d07b0cd
|
@ -347,6 +347,7 @@ set(BASE_SRCS
|
|||
src/pshinter/pshinter.c
|
||||
src/psnames/psnames.c
|
||||
src/raster/raster.c
|
||||
src/sdf/sdf.c
|
||||
src/sfnt/sfnt.c
|
||||
src/smooth/smooth.c
|
||||
src/truetype/truetype.c
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
2020-06-18 Anuj Verma <anujv@iitbhilai.ac.in>
|
||||
|
||||
[sdf] Added the structure of a new module to render
|
||||
signed distance fields.
|
||||
|
||||
* src/sdf/sdf.c, src/sdf/ftsdfrend.c, src/sdf/ftsdf.c,
|
||||
src/sdf/ftsdfrend.h, src/sdf/ftsdf.h, src/sdf/ftsdferrs.h:
|
||||
Added files required by the `sdf' renderer module and added
|
||||
the basic structure and functions required.
|
||||
|
||||
* src/sdf/rules.mk, src/sdf/module.mk: Added files required to
|
||||
build the `sdf' module using the default build system.
|
||||
|
||||
* CMakeLists.txt (`BASE_SRCS'): Add `src/sdf/sdf.c' to the variable.
|
||||
|
||||
* include/freetype/config/ftmodule.h: Added `sdf' module
|
||||
declaration so that the module can be added when not compiling
|
||||
with GNU make.
|
||||
|
||||
* modules.cfg (RASTER_MODULES): Include `sdf' module to the default
|
||||
rasterizer module list.
|
||||
|
||||
* include/freetype/ftmoderr.h: sdf module error define
|
|
@ -26,5 +26,6 @@ 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_Driver_ClassRec, bdf_driver_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -171,6 +171,7 @@
|
|||
FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
|
||||
FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
|
||||
FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
|
||||
FT_MODERRDEF( Sdf, 0x1700, "signed distance field raster module" )
|
||||
|
||||
|
||||
#ifdef FT_MODERR_END_LIST
|
||||
|
|
|
@ -99,6 +99,8 @@ RASTER_MODULES += raster
|
|||
# Anti-aliasing rasterizer.
|
||||
RASTER_MODULES += smooth
|
||||
|
||||
# Signed distance field rasterizer.
|
||||
RASTER_MODULES += sdf
|
||||
|
||||
####
|
||||
#### auxiliary modules
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include "ftsdf.h"
|
||||
|
||||
#include "ftsdferrs.h"
|
||||
|
||||
static int
|
||||
sdf_raster_new( FT_Memory memory,
|
||||
FT_Raster* araster)
|
||||
{
|
||||
FT_Error error = FT_THROW( Unimplemented_Feature );
|
||||
|
||||
|
||||
FT_UNUSED( memory );
|
||||
FT_UNUSED( araster );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
sdf_raster_reset( FT_Raster raster,
|
||||
unsigned char* pool_base,
|
||||
unsigned long pool_size )
|
||||
{
|
||||
FT_UNUSED( raster );
|
||||
FT_UNUSED( pool_base );
|
||||
FT_UNUSED( pool_size );
|
||||
}
|
||||
|
||||
static int
|
||||
sdf_raster_set_mode( FT_Raster raster,
|
||||
unsigned long mode,
|
||||
void* args )
|
||||
{
|
||||
FT_UNUSED( raster );
|
||||
FT_UNUSED( mode );
|
||||
FT_UNUSED( args );
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sdf_raster_render( FT_Raster raster,
|
||||
const FT_Raster_Params* params )
|
||||
{
|
||||
FT_UNUSED( raster );
|
||||
FT_UNUSED( params );
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sdf_raster_done( FT_Raster raster )
|
||||
{
|
||||
FT_UNUSED( raster );
|
||||
}
|
||||
|
||||
FT_DEFINE_RASTER_FUNCS(
|
||||
ft_sdf_raster,
|
||||
|
||||
FT_GLYPH_FORMAT_OUTLINE,
|
||||
|
||||
(FT_Raster_New_Func) sdf_raster_new, /* raster_new */
|
||||
(FT_Raster_Reset_Func) sdf_raster_reset, /* raster_reset */
|
||||
(FT_Raster_Set_Mode_Func) sdf_raster_set_mode, /* raster_set_mode */
|
||||
(FT_Raster_Render_Func) sdf_raster_render, /* raster_render */
|
||||
(FT_Raster_Done_Func) sdf_raster_done /* raster_done */
|
||||
)
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
#ifndef FTSDF_H_
|
||||
#define FTSDF_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_CONFIG_H
|
||||
#include <freetype/ftimage.h>
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_sdf_raster;
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSDF_H_ */
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#ifndef FTSDFERRS_H_
|
||||
#define FTSDFERRS_H_
|
||||
|
||||
#include <freetype/ftmoderr.h>
|
||||
|
||||
#undef FTERRORS_H_
|
||||
|
||||
#undef FT_ERR_PREFIX
|
||||
#define FT_ERR_PREFIX Sdf_Err_
|
||||
#define FT_ERR_BASE FT_Mod_Err_Sdf
|
||||
|
||||
#include <freetype/fterrors.h>
|
||||
|
||||
#endif /* FTSDFERRS_H_ */
|
||||
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include "ftsdfrend.h"
|
||||
#include "ftsdf.h"
|
||||
|
||||
#include "ftsdferrs.h"
|
||||
|
||||
|
||||
static FT_Error
|
||||
ft_sdf_render( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Render_Mode mode,
|
||||
const FT_Vector* origin )
|
||||
{
|
||||
FT_Error error = FT_THROW( Unimplemented_Feature );
|
||||
|
||||
|
||||
FT_UNUSED( render );
|
||||
FT_UNUSED( slot );
|
||||
FT_UNUSED( mode );
|
||||
FT_UNUSED( origin );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static FT_Error
|
||||
ft_sdf_transform( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
const FT_Matrix* matrix,
|
||||
const FT_Vector* delta )
|
||||
{
|
||||
FT_Error error = FT_THROW( Unimplemented_Feature );
|
||||
|
||||
|
||||
FT_UNUSED( render );
|
||||
FT_UNUSED( slot );
|
||||
FT_UNUSED( matrix );
|
||||
FT_UNUSED( delta );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
ft_sdf_get_cbox( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox* cbox )
|
||||
{
|
||||
FT_UNUSED( render );
|
||||
FT_UNUSED( slot );
|
||||
FT_UNUSED( cbox );
|
||||
}
|
||||
|
||||
static FT_Error
|
||||
ft_sdf_set_mode( FT_Renderer render,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer data )
|
||||
{
|
||||
FT_Error error = FT_THROW( Unimplemented_Feature );
|
||||
|
||||
|
||||
FT_UNUSED( render );
|
||||
FT_UNUSED( mode_tag );
|
||||
FT_UNUSED( data );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
FT_DEFINE_RENDERER(
|
||||
ft_sdf_renderer_class,
|
||||
|
||||
FT_MODULE_RENDERER,
|
||||
sizeof( FT_RendererRec ),
|
||||
|
||||
"sdf",
|
||||
0x10000L,
|
||||
0x20000L,
|
||||
|
||||
NULL,
|
||||
|
||||
(FT_Module_Constructor) NULL,
|
||||
(FT_Module_Destructor) NULL,
|
||||
(FT_Module_Requester) NULL,
|
||||
|
||||
FT_GLYPH_FORMAT_OUTLINE,
|
||||
|
||||
(FT_Renderer_RenderFunc) ft_sdf_render, /* render_glyph */
|
||||
(FT_Renderer_TransformFunc)ft_sdf_transform, /* transform_glyph */
|
||||
(FT_Renderer_GetCBoxFunc) ft_sdf_get_cbox, /* get_glyph_cbox */
|
||||
(FT_Renderer_SetModeFunc) ft_sdf_set_mode, /* set_mode */
|
||||
|
||||
(FT_Raster_Funcs*)&ft_sdf_raster /* raster_class */
|
||||
)
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#ifndef FTSDFREND_H_
|
||||
#define FTSDFREND_H_
|
||||
|
||||
|
||||
#include <freetype/ftrender.h>
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
FT_DECLARE_RENDERER( ft_sdf_renderer_class )
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSDFREND_H_ */
|
||||
|
||||
|
||||
/* END */
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
|
||||
FTMODULE_H_COMMANDS += SDF_RENDERER
|
||||
|
||||
define SDF_RENDERER
|
||||
$(OPEN_DRIVER) FT_Renderer_Class, ft_sdf_renderer_class $(CLOSE_DRIVER)
|
||||
$(ECHO_DRIVER)sdf $(ECHO_DRIVER_DESC) signed distance field renderer $(ECHO_DRIVER_DONE)
|
||||
endef
|
||||
|
||||
#EOF
|
|
@ -0,0 +1,58 @@
|
|||
|
||||
|
||||
# sdf driver directory
|
||||
#
|
||||
SDF_DIR := $(SRC_DIR)/sdf
|
||||
|
||||
|
||||
# compilation flags for the driver
|
||||
#
|
||||
SDF_COMPILE := $(CC) $(ANSIFLAGS) \
|
||||
$I$(subst /,$(COMPILER_SEP),$(SDF_DIR)) \
|
||||
$(INCLUDE_FLAGS) \
|
||||
$(FT_CFLAGS)
|
||||
|
||||
|
||||
# sdf driver sources (i.e., C files)
|
||||
#
|
||||
SDF_DRV_SRC := $(SDF_DIR)/ftsdfrend.c \
|
||||
$(SDF_DIR)/ftsdf.c
|
||||
|
||||
|
||||
# sdf driver headers
|
||||
#
|
||||
SDF_DRV_H := $(SDF_DRV_SRC:%.c=%.h) \
|
||||
$(SDF_DIR)/ftsdferrs.h
|
||||
|
||||
|
||||
# sdf driver object(s)
|
||||
#
|
||||
# SDF_DRV_OBJ_M is used during `multi' builds.
|
||||
# SDF_DRV_OBJ_S is used during `single' builds.
|
||||
#
|
||||
SDF_DRV_OBJ_M := $(SDF_DRV_SRC:$(SDF_DIR)/%.c=$(OBJ_DIR)/%.$O)
|
||||
SDF_DRV_OBJ_S := $(OBJ_DIR)/sdf.$O
|
||||
|
||||
|
||||
# sdf driver source file for single build
|
||||
#
|
||||
SDF_DRV_SRC_S := $(SDF_DIR)/sdf.c
|
||||
|
||||
|
||||
# sdf driver - single object
|
||||
#
|
||||
$(SDF_DRV_OBJ_S): $(SDF_DRV_SRC_S) $(SDF_DRV_SRC) \
|
||||
$(FREETYPE_H) $(SDF_DRV_H)
|
||||
$(SDF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SDF_DRV_SRC_S))
|
||||
|
||||
|
||||
# sdf driver - multiple objects
|
||||
#
|
||||
$(OBJ_DIR)/%.$O: $(SDF_DIR)/%.c $(FREETYPE_H) $(SDF_DRV_H)
|
||||
$(SDF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
|
||||
|
||||
|
||||
# update main driver list
|
||||
#
|
||||
DRV_OBJ_S += $(SDF_DRV_OBJ_S)
|
||||
DRV_OBJ_M += $(SDF_DRV_OBJ_M)
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#include "ftsdfrend.c"
|
||||
#include "ftsdf.c"
|
||||
|
||||
|
||||
/* END */
|
Loading…
Reference in New Issue