From 821e87b1ff4b35b888b1f759f806182e55f3a21f Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Mon, 1 Sep 2025 18:19:29 -0400 Subject: [PATCH] Remove some declare/define macros (pt 2). This removes the next set of macros remaining from the PIC support. * include/freetype/internal/ftobjs.h (FT_DECLARE_GLYPH, FT_DEFINE_GLYPH): Removed. * include/freetype/ftglyph.h (FT_Glyph_Class): Make const always. * src/*: Update all users. --- include/freetype/ftglyph.h | 10 +++---- include/freetype/internal/ftobjs.h | 37 ----------------------- src/base/ftbase.h | 7 +++-- src/base/ftglyph.c | 48 +++++++++++++++--------------- src/base/ftstroke.c | 3 +- 5 files changed, 35 insertions(+), 70 deletions(-) diff --git a/include/freetype/ftglyph.h b/include/freetype/ftglyph.h index dc1eb8873..ea7e9c141 100644 --- a/include/freetype/ftglyph.h +++ b/include/freetype/ftglyph.h @@ -66,7 +66,7 @@ FT_BEGIN_HEADER /* forward declaration to a private type */ - typedef struct FT_Glyph_Class_ FT_Glyph_Class; + typedef const struct FT_Glyph_Class_ FT_Glyph_Class; /************************************************************************** @@ -111,10 +111,10 @@ FT_BEGIN_HEADER */ typedef struct FT_GlyphRec_ { - FT_Library library; - const FT_Glyph_Class* clazz; - FT_Glyph_Format format; - FT_Vector advance; + FT_Library library; + FT_Glyph_Class* clazz; + FT_Glyph_Format format; + FT_Vector advance; } FT_GlyphRec; diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index edca62386..44a9c8f74 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -1064,43 +1064,6 @@ FT_BEGIN_HEADER }; - - /************************************************************************** - * - * @macro: - * FT_DEFINE_GLYPH - * - * @description: - * The struct will be allocated in the global scope (or the scope where - * the macro is used). - */ -#define FT_DECLARE_GLYPH( class_ ) \ - FT_CALLBACK_TABLE const FT_Glyph_Class class_; - -#define FT_DEFINE_GLYPH( \ - class_, \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_Glyph_Class class_ = \ - { \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ \ - }; - - FT_END_HEADER #endif /* FTOBJS_H_ */ diff --git a/src/base/ftbase.h b/src/base/ftbase.h index f216c1df1..210037843 100644 --- a/src/base/ftbase.h +++ b/src/base/ftbase.h @@ -26,9 +26,10 @@ FT_BEGIN_HEADER - FT_DECLARE_GLYPH( ft_bitmap_glyph_class ) - FT_DECLARE_GLYPH( ft_outline_glyph_class ) - FT_DECLARE_GLYPH( ft_svg_glyph_class ) + FT_CALLBACK_TABLE + FT_Glyph_Class ft_bitmap_glyph_class, + ft_outline_glyph_class, + ft_svg_glyph_class; #ifdef FT_CONFIG_OPTION_MAC_FONTS diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 1b5849f99..d8dd69676 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -133,9 +133,9 @@ } - FT_DEFINE_GLYPH( - ft_bitmap_glyph_class, - + FT_CALLBACK_TABLE_DEF + FT_Glyph_Class ft_bitmap_glyph_class = + { sizeof ( FT_BitmapGlyphRec ), FT_GLYPH_FORMAT_BITMAP, @@ -145,7 +145,7 @@ NULL, /* FT_Glyph_TransformFunc glyph_transform */ ft_bitmap_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */ NULL /* FT_Glyph_PrepareFunc glyph_prepare */ - ) + }; /*************************************************************************/ @@ -263,9 +263,9 @@ } - FT_DEFINE_GLYPH( - ft_outline_glyph_class, - + FT_CALLBACK_TABLE_DEF + FT_Glyph_Class ft_outline_glyph_class = + { sizeof ( FT_OutlineGlyphRec ), FT_GLYPH_FORMAT_OUTLINE, @@ -275,7 +275,7 @@ ft_outline_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */ ft_outline_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */ ft_outline_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */ - ) + }; #ifdef FT_CONFIG_OPTION_SVG @@ -495,9 +495,9 @@ } - FT_DEFINE_GLYPH( - ft_svg_glyph_class, - + FT_CALLBACK_TABLE_DEF + FT_Glyph_Class ft_svg_glyph_class = + { sizeof ( FT_SvgGlyphRec ), FT_GLYPH_FORMAT_SVG, @@ -507,7 +507,7 @@ ft_svg_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */ NULL, /* FT_Glyph_GetBBoxFunc glyph_bbox */ ft_svg_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */ - ) + }; #endif /* FT_CONFIG_OPTION_SVG */ @@ -521,9 +521,9 @@ /*************************************************************************/ static FT_Error - ft_new_glyph( FT_Library library, - const FT_Glyph_Class* clazz, - FT_Glyph* aglyph ) + ft_new_glyph( FT_Library library, + FT_Glyph_Class* clazz, + FT_Glyph* aglyph ) { FT_Memory memory = library->memory; FT_Error error; @@ -551,9 +551,9 @@ FT_Glyph_Copy( FT_Glyph source, FT_Glyph *target ) { - FT_Glyph copy; - FT_Error error; - const FT_Glyph_Class* clazz; + FT_Glyph copy; + FT_Error error; + FT_Glyph_Class* clazz; /* check arguments */ @@ -599,7 +599,7 @@ FT_Glyph_Format format, FT_Glyph *aglyph ) { - const FT_Glyph_Class* clazz = NULL; + FT_Glyph_Class* clazz = NULL; if ( !library || !aglyph ) return FT_THROW( Invalid_Argument ); @@ -708,7 +708,7 @@ error = FT_THROW( Invalid_Argument ); else { - const FT_Glyph_Class* clazz = glyph->clazz; + FT_Glyph_Class* clazz = glyph->clazz; if ( clazz->glyph_transform ) @@ -734,7 +734,7 @@ FT_UInt bbox_mode, FT_BBox *acbox ) { - const FT_Glyph_Class* clazz; + FT_Glyph_Class* clazz; if ( !acbox ) @@ -787,7 +787,7 @@ FT_Error error = FT_Err_Ok; FT_Glyph b, glyph; FT_BitmapGlyph bitmap = NULL; - const FT_Glyph_Class* clazz; + FT_Glyph_Class* clazz; FT_Library library; @@ -896,8 +896,8 @@ { if ( glyph ) { - FT_Memory memory = glyph->library->memory; - const FT_Glyph_Class* clazz = glyph->clazz; + FT_Memory memory = glyph->library->memory; + FT_Glyph_Class* clazz = glyph->clazz; if ( clazz->glyph_done ) diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c index 8fa5f6723..0b49a19d6 100644 --- a/src/base/ftstroke.c +++ b/src/base/ftstroke.c @@ -26,7 +26,8 @@ /* declare an extern to access `ft_outline_glyph_class' globally */ /* allocated in `ftglyph.c' */ - FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class; + FT_CALLBACK_TABLE + FT_Glyph_Class ft_outline_glyph_class; /* documentation is in ftstroke.h */