forked from minhngoc25a/freetype2
Created Svg type and the load/free funcs inside sfnt interface
This commit is contained in:
parent
0729a65165
commit
9b7c3d1df9
|
@ -778,6 +778,9 @@ FT_BEGIN_HEADER
|
|||
TT_Get_Name_Func get_name;
|
||||
TT_Get_Name_ID_Func get_name_id;
|
||||
|
||||
/* Open Type SVG Support */
|
||||
TT_Load_Table_Func load_svg;
|
||||
TT_Free_Table_Func free_svg;
|
||||
} SFNT_Interface;
|
||||
|
||||
|
||||
|
@ -824,7 +827,9 @@ FT_BEGIN_HEADER
|
|||
colr_blend_, \
|
||||
get_metrics_, \
|
||||
get_name_, \
|
||||
get_name_id_ ) \
|
||||
get_name_id_, \
|
||||
load_svg_, \
|
||||
free_svg_ ) \
|
||||
static const SFNT_Interface class_ = \
|
||||
{ \
|
||||
goto_table_, \
|
||||
|
@ -864,7 +869,9 @@ FT_BEGIN_HEADER
|
|||
colr_blend_, \
|
||||
get_metrics_, \
|
||||
get_name_, \
|
||||
get_name_id_ \
|
||||
get_name_id_, \
|
||||
load_svg_, \
|
||||
free_svg_ \
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1645,6 +1645,8 @@ FT_BEGIN_HEADER
|
|||
void* cpal;
|
||||
void* colr;
|
||||
|
||||
/* OpenType SVG Glyph Support */
|
||||
void* svg;
|
||||
} TT_FaceRec;
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "ttcpal.h"
|
||||
#endif
|
||||
|
||||
#include "ttsvg.h" /* OpenType SVG support */
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
#include "ttpost.h"
|
||||
#endif
|
||||
|
@ -1294,7 +1296,9 @@
|
|||
tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */
|
||||
|
||||
tt_face_get_name, /* TT_Get_Name_Func get_name */
|
||||
sfnt_get_name_id /* TT_Get_Name_ID_Func get_name_id */
|
||||
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 */
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "ttcmap.c"
|
||||
#include "ttcolr.c"
|
||||
#include "ttcpal.c"
|
||||
#include "ttsvg.c"
|
||||
|
||||
#include "ttkern.c"
|
||||
#include "ttload.c"
|
||||
|
|
|
@ -751,6 +751,7 @@
|
|||
FT_Bool is_apple_sbix;
|
||||
FT_Bool has_CBLC;
|
||||
FT_Bool has_CBDT;
|
||||
FT_Bool has_SVG = FALSE; /* For OpenType SVG fonts */
|
||||
FT_Bool ignore_typographic_family = FALSE;
|
||||
FT_Bool ignore_typographic_subfamily = FALSE;
|
||||
|
||||
|
@ -953,6 +954,13 @@
|
|||
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;
|
||||
|
||||
/* consider the pclt, kerning, and gasp tables as optional */
|
||||
LOAD_( pclt );
|
||||
LOAD_( gasp );
|
||||
|
@ -1372,6 +1380,9 @@
|
|||
sfnt->free_cpal( face );
|
||||
sfnt->free_colr( face );
|
||||
}
|
||||
|
||||
/* free svg data */
|
||||
sfnt->free_svg( face );
|
||||
}
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_BDF
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ttsvg.h
|
||||
*
|
||||
* OpenType SVG Color (specification).
|
||||
*
|
||||
* Copyright (C) 2018-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' table specification:
|
||||
*
|
||||
* https://docs.microsoft.com/en-us/typography/opentype/spec/svg
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_INTERNAL_STREAM_H
|
||||
#include FT_TRUETYPE_TAGS_H
|
||||
|
||||
|
||||
#include "ttsvg.h"
|
||||
|
||||
typedef struct Svg_
|
||||
{
|
||||
FT_UShort version; /* Table version (starting at 0) */
|
||||
FT_UShort num_entries; /* Number of SVG document records */
|
||||
/* Pointer to the starting of SVG Document List */
|
||||
FT_Byte* svg_doc_list;
|
||||
/* Memory that backs up SVG */
|
||||
void* table;
|
||||
FT_ULong table_size;
|
||||
} Svg;
|
||||
|
||||
|
||||
FT_LOCAL_DEF( FT_Error )
|
||||
tt_face_load_svg( TT_Face face,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Memory memory = face->root.memory;
|
||||
|
||||
FT_ULong table_size;
|
||||
FT_Byte* table = NULL;
|
||||
FT_Byte* p = NULL;
|
||||
|
||||
Svg* svg = NULL;
|
||||
|
||||
FT_ULong offsetToSVGDocumentList;
|
||||
|
||||
|
||||
error = face->goto_table( face, TTAG_SVG, stream, &table_size );
|
||||
if( error )
|
||||
goto NoSVG;
|
||||
|
||||
if( FT_FRAME_EXTRACT( table_size, table ))
|
||||
goto NoSVG;
|
||||
|
||||
/* Allocate the memory for the Svg object */
|
||||
if( FT_NEW( svg ) )
|
||||
goto NoSVG;
|
||||
|
||||
p = table;
|
||||
svg->version = FT_NEXT_USHORT( p );
|
||||
offsetToSVGDocumentList = FT_NEXT_ULONG( p );
|
||||
|
||||
if( offsetToSVGDocumentList == 0 )
|
||||
goto InvalidTable;
|
||||
|
||||
svg->svg_doc_list = (FT_Byte*)( table + offsetToSVGDocumentList );
|
||||
|
||||
p = svg->svg_doc_list;
|
||||
svg->num_entries = FT_NEXT_USHORT( p );
|
||||
|
||||
svg->table = table;
|
||||
svg->table_size = table_size;
|
||||
|
||||
face->svg = svg;
|
||||
|
||||
return FT_Err_Ok;
|
||||
|
||||
InvalidTable:
|
||||
error = FT_THROW( Invalid_Table );
|
||||
|
||||
NoSVG:
|
||||
FT_FRAME_RELEASE( table );
|
||||
FT_FREE( svg );
|
||||
face->svg = NULL;
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
FT_LOCAL_DEF( void )
|
||||
tt_face_free_svg( TT_Face face )
|
||||
{
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_Stream stream = face->root.stream;
|
||||
|
||||
Svg* svg = (Svg*) face->svg;
|
||||
if( svg )
|
||||
{
|
||||
FT_FRAME_RELEASE( svg->table );
|
||||
FT_FREE( svg );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* ttsvg.h
|
||||
*
|
||||
* OpenType SVG Color (specification).
|
||||
*
|
||||
* Copyright (C) 2018-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 __TTSVG_H__
|
||||
#define __TTSVG_H__
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
FT_LOCAL( FT_Error )
|
||||
tt_face_load_svg( TT_Face face,
|
||||
FT_Stream stream );
|
||||
|
||||
FT_LOCAL( void )
|
||||
tt_face_free_svg( TT_Face face );
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* __TTSVG_H__ */
|
||||
/* END */
|
Loading…
Reference in New Issue