Added `FT_CONFIG_OPTION_SVG'.

This commit is contained in:
Moazin Khatti 2019-07-17 12:22:47 +05:00
parent c25304fa34
commit 3b62e9dc9d
13 changed files with 79 additions and 23 deletions

View File

@ -493,6 +493,15 @@ FT_BEGIN_HEADER
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
/**************************************************************************
*
* OpenType SVG Glyph Support
*
* If this macro is set, OpenType SVG glyphs will be supported.
*/
#define FT_CONFIG_OPTION_SVG
/**************************************************************************
*
* Error Strings

View File

@ -1227,7 +1227,9 @@ FT_BEGIN_HEADER
#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
#define FT_FACE_FLAG_COLOR ( 1L << 14 )
#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
#ifdef FT_CONFIG_OPTION_SVG
#define FT_FACE_FLAG_SVG ( 1L << 16 )
#endif
/**************************************************************************

View File

@ -223,6 +223,7 @@ FT_BEGIN_HEADER
} FT_OutlineGlyphRec;
#ifdef FT_CONFIG_OPTION_SVG
/**************************************************************************
*
* @type:
@ -292,6 +293,7 @@ FT_BEGIN_HEADER
/* TODO: (OT-SVG) Maybe put a transformation matrix here */
} FT_SvgGlyphRec;
#endif
/**************************************************************************
*

View File

@ -419,7 +419,9 @@ FT_BEGIN_HEADER
*/
#define FT_GLYPH_OWN_BITMAP 0x1U
#ifdef FT_CONFIG_OPTION_SVG
#define FT_GLYPH_OWN_GZIP_SVG 0x2U
#endif
typedef struct FT_Slot_InternalRec_
{
@ -921,8 +923,9 @@ FT_BEGIN_HEADER
FT_Int refcount;
#ifdef FT_CONFIG_OPTION_SVG
void* svg_renderer_state;
#endif
} FT_LibraryRec;

View File

@ -1645,8 +1645,10 @@ FT_BEGIN_HEADER
void* cpal;
void* colr;
#ifdef FT_CONFIG_OPTION_SVG
/* OpenType SVG Glyph Support */
void* svg;
#endif
} TT_FaceRec;

View File

@ -28,6 +28,7 @@
#error "so that freetype.h of FreeType 2 is found first."
#endif
#ifdef FT_CONFIG_OPTION_SVG
FT_BEGIN_HEADER
/**************************************************************************
@ -255,5 +256,5 @@ FT_BEGIN_HEADER
typedef struct FT_SVG_DocumentRec_* FT_SVG_Document;
FT_END_HEADER
#endif /* FT_CONFIG_OPTION_SVG */
#endif

View File

@ -276,6 +276,7 @@
ft_outline_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
)
#ifdef FT_CONFIG_OPTION_SVG
/*************************************************************************/
/*************************************************************************/
/**** ****/
@ -441,7 +442,7 @@
ft_svg_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
)
#endif
/*************************************************************************/
/*************************************************************************/
@ -543,9 +544,11 @@
else if ( format == FT_GLYPH_FORMAT_OUTLINE )
clazz = &ft_outline_glyph_class;
#ifdef FT_CONFIG_OPTION_SVG
/* if it is a SVG glyph */
else if ( format == FT_GLYPH_FORMAT_SVG )
clazz = &ft_svg_glyph_class;
#endif
else
{
@ -716,7 +719,6 @@
const FT_Glyph_Class* clazz;
FT_Library library;
FT_Memory memory;
/* check argument */
@ -728,7 +730,6 @@
clazz = glyph->clazz;
library = glyph->library;
memory = library->memory;
if ( !library || !clazz )
goto Bad;
@ -767,10 +768,13 @@
if ( !error )
{
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
#ifdef FT_CONFIG_OPTION_SVG
if ( clazz == &ft_svg_glyph_class )
{
FT_Memory memory = library->memory;
FT_FREE( dummy.other );
}
#endif
}
#if 1

View File

@ -318,6 +318,7 @@
if ( !error && clazz->init_slot )
error = clazz->init_slot( slot );
#ifdef FT_CONFIG_OPTION_SVG
/* check if SVG table exists allocate the space in slot->other */
if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
{
@ -326,6 +327,7 @@
goto Exit;
slot->other = document;
}
#endif
Exit:
return error;
@ -561,7 +563,9 @@
slot->subglyphs = NULL;
slot->control_data = NULL;
slot->control_len = 0;
#ifndef FT_CONFIG_OPTION_SVG
slot->other = NULL;
#else
if ( !( slot->face->face_flags & FT_FACE_FLAG_SVG ) )
slot->other = NULL;
else
@ -574,6 +578,7 @@
slot->internal->load_flags &= ~FT_GLYPH_OWN_GZIP_SVG;
}
}
#endif
slot->format = FT_GLYPH_FORMAT_NONE;
@ -592,6 +597,7 @@
FT_Memory memory = driver->root.memory;
#ifdef FT_CONFIG_OPTION_SVG
if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
{
/* free memory in case svg was there */
@ -603,6 +609,7 @@
}
FT_FREE( slot->other );
}
#endif
if ( clazz->done_slot )
clazz->done_slot( slot );
@ -873,11 +880,13 @@
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
load_flags &= ~FT_LOAD_RENDER;
#ifdef FT_CONFIG_OPTION_SVG
if ( ( load_flags & FT_LOAD_COLOR ) &&
( ttface->svg ) )
{
FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE);
}
#endif
/*
* Determine whether we need to auto-hint or not.
@ -4445,10 +4454,12 @@
render->render = clazz->render_glyph;
}
#ifdef FT_CONFIG_OPTION_SVG
if ( clazz->glyph_format == FT_GLYPH_FORMAT_SVG )
{
render->render = clazz->render_glyph;
}
#endif
/* add to list */
node->data = module;
@ -5592,6 +5603,7 @@
return 0;
}
#ifdef FT_CONFIG_OPTION_SVG
FT_EXPORT_DEF( FT_Error )
FT_Set_Svg_Hooks( FT_Library library,
SVG_Lib_Init_Func init_svg,
@ -5617,5 +5629,6 @@
get_buffer_size );
return FT_Err_Ok;
}
#endif
/* END */

View File

@ -347,6 +347,7 @@
if ( load_flags & FT_LOAD_SBITS_ONLY )
return FT_THROW( Invalid_Argument );
#ifdef FT_CONFIG_OPTION_SVG
/* check for OT-SVG */
if ( ( load_flags & FT_LOAD_COLOR ) &&
( ((TT_Face)glyph->root.face)->svg ) )
@ -359,6 +360,7 @@
return error;
}
}
#endif
/* if we have a CID subfont, use its matrix (which has already */
/* been multiplied with the root matrix) */

View File

@ -37,7 +37,9 @@
#include "ttcpal.h"
#endif
#ifdef FT_CONFIG_OPTION_SVG
#include "ttsvg.h" /* OpenType SVG support */
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.h"
@ -1210,6 +1212,12 @@
#define PUT_EMBEDDED_BITMAPS( a ) NULL
#endif
#ifdef FT_CONFIG_OPTION_SVG
#define PUT_SVG_SUPPORT( a ) a
#else
#define PUT_SVG_SUPPORT( a ) NULL
#endif
#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
#define PUT_COLOR_LAYERS( a ) a
#else
@ -1297,9 +1305,12 @@
tt_face_get_name, /* TT_Get_Name_Func get_name */
sfnt_get_name_id, /* TT_Get_Name_ID_Func get_name_id */
tt_face_load_svg, /* TT_Load_Table_Func load_svg */
tt_face_free_svg, /* TT_Free_Table_Func free_svg */
tt_face_load_svg_doc /* TT_Load_Svg_Doc_Func load_svg_doc */
PUT_SVG_SUPPORT( tt_face_load_svg ),
/* TT_Load_Table_Func load_svg */
PUT_SVG_SUPPORT( tt_face_free_svg ),
/* TT_Free_Table_Func free_svg */
PUT_SVG_SUPPORT( tt_face_load_svg_doc )
/* TT_Load_Svg_Doc_Func load_svg_doc */
)

View File

@ -751,7 +751,6 @@
FT_Bool is_apple_sbix;
FT_Bool has_CBLC;
FT_Bool has_CBDT;
FT_Bool has_SVG = FALSE; /* for OT-SVG */
FT_Bool ignore_typographic_family = FALSE;
FT_Bool ignore_typographic_subfamily = FALSE;
@ -954,12 +953,11 @@
LOAD_( colr );
}
/* opentype svg colored glyph support */
/* no If statement because the function always exists for now */
LOAD_( svg );
if( face->svg )
has_SVG = TRUE;
#ifdef FT_CONFIG_OPTION_SVG
/* opentype svg glyph support */
if ( sfnt->load_svg )
LOAD_( svg );
#endif
/* consider the pclt, kerning, and gasp tables as optional */
LOAD_( pclt );
@ -1380,9 +1378,11 @@
sfnt->free_cpal( face );
sfnt->free_colr( face );
}
#ifdef FT_CONFIG_OPTION_SVG
/* free svg data */
sfnt->free_svg( face );
if ( sfnt->free_svg )
sfnt->free_svg( face );
#endif
}
#ifdef TT_CONFIG_OPTION_BDF

View File

@ -31,6 +31,7 @@
#include FT_GZIP_H
#include FT_SVG_RENDER_H
#ifdef FT_CONFIG_OPTION_SVG
#include "ttsvg.h"
@ -187,8 +188,6 @@
FT_ULong uncomp_size;
FT_Byte* uncomp_buffer;
FT_Bool is_gzip_encoded = FALSE;
FT_Error error = FT_Err_Ok;
TT_Face face = (TT_Face)glyph->face;
FT_Memory memory = face->root.memory;
@ -212,8 +211,6 @@
if( ( doc_list[0] == 0x1F ) && ( doc_list[1] == 0x8B )
&& ( doc_list[2] == 0x08 ) )
{
is_gzip_encoded = TRUE;
/* get the size of the orignal document. This helps in alotting the
* buffer to accomodate the uncompressed version. The last 4 bytes
* of the compressed document are equal to orignal_size modulo 2^32.
@ -254,3 +251,10 @@
return FT_Err_Ok;
}
#else /* !FT_CONFIG_OPTION_SVG */
/* ANSI C doesn't like empty source files */
typedef int _tt_cpal_dummy;
#endif /* !FT_CONFIG_OPTION_SVG */

View File

@ -2796,7 +2796,7 @@
{
FT_Error error;
TT_LoaderRec loader;
SFNT_Service sfnt;
FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
@ -2907,9 +2907,11 @@
goto Exit;
}
#ifdef FT_CONFIG_OPTION_SVG
/* check for OT-SVG */
if ( ( load_flags & FT_LOAD_COLOR ) && ( ((TT_Face)glyph->face)->svg ) )
{
SFNT_Service sfnt;
sfnt = (SFNT_Service)((TT_Face)glyph->face)->sfnt;
error = sfnt->load_svg_doc( glyph, glyph_index );
if( error == FT_Err_Ok )
@ -2918,6 +2920,7 @@
return error;
}
}
#endif
if ( load_flags & FT_LOAD_SBITS_ONLY )
{