mirror of
https://gitlab.freedesktop.org/freetype/freetype.git
synced 2026-05-02 20:18:03 +02:00
[autofit] Some preparations for loading HarfBuzz dynamically. (2/4)
Pass `AF_FaceGlobals` to many functions, or provide it, tagged with `FT_UNUSED`. We need this later on to access a dynamically linked HarfBuzz library. * src/autofit/ft-hb-ft.h (ft_hb_ft_font_create): Use `globals` argument. Drop unused `destroy` argument. * src/autofit/ft-hb-ft.c (ft_hb_ft_face_create, ft_hb_ft_font_create): Use `globals` argument. Drop unused `destroy` argument. (ft_hb_ft_face_create, ft_hb_ft_reference_table): Cast `user_data` to `AF_FaceGlobals`. * src/autofit/afadjust.c (af_get_glyph_alternates_helper, af_get_glyph_alternates): Add `globals` argument. Update callers. * src/autofit/afshaper.c, src/autofit/afshaper.h (af_shaper_buf_create, af_shaper_buf_destroy): Use `globals` argument. * src/autofit/afglobal.c (af_face_globals_new): Updated. * src/autofit/afcjk.c (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_metrics_check_digits): Updated. * src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_check_digits): Updated.
This commit is contained in:
parent
8b443d70fe
commit
e9d030720c
8 changed files with 59 additions and 40 deletions
|
|
@ -1036,13 +1036,16 @@
|
|||
|
||||
/* Get all alternates for a given glyph index. */
|
||||
static void
|
||||
af_get_glyph_alternates_helper( hb_face_t *hb_face,
|
||||
af_get_glyph_alternates_helper( AF_FaceGlobals globals,
|
||||
hb_face_t *hb_face,
|
||||
hb_codepoint_t glyph,
|
||||
hb_set_t *gsub_lookups,
|
||||
hb_set_t *result )
|
||||
{
|
||||
hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID;
|
||||
|
||||
FT_UNUSED( globals );
|
||||
|
||||
|
||||
/* Iterate over all lookups. */
|
||||
while ( hb( set_next )( gsub_lookups, &lookup_index ) )
|
||||
|
|
@ -1080,7 +1083,8 @@
|
|||
/* Get all alternates (including alternates of alternates) */
|
||||
/* for a given glyph index. */
|
||||
static void
|
||||
af_get_glyph_alternates( hb_font_t *hb_font,
|
||||
af_get_glyph_alternates( AF_FaceGlobals globals,
|
||||
hb_font_t *hb_font,
|
||||
hb_codepoint_t glyph,
|
||||
hb_set_t *gsub_lookups,
|
||||
hb_set_t *result )
|
||||
|
|
@ -1106,7 +1110,8 @@
|
|||
if ( !hb( set_has )( result, elem ) )
|
||||
{
|
||||
/* This call updates the glyph set in `helper_result`. */
|
||||
af_get_glyph_alternates_helper( hb_face,
|
||||
af_get_glyph_alternates_helper( globals,
|
||||
hb_face,
|
||||
elem,
|
||||
gsub_lookups,
|
||||
helper_result );
|
||||
|
|
@ -1200,7 +1205,8 @@
|
|||
codepoint = adjustment_database[i].codepoint;
|
||||
cmap_glyph = FT_Get_Char_Index( face, codepoint );
|
||||
|
||||
af_get_glyph_alternates( hb_font,
|
||||
af_get_glyph_alternates( globals,
|
||||
hb_font,
|
||||
cmap_glyph,
|
||||
gsub_lookups,
|
||||
result_set );
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
p = script_class->standard_charstring;
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
shaper_buf = af_shaper_buf_create( face );
|
||||
shaper_buf = af_shaper_buf_create( metrics->root.globals );
|
||||
#endif
|
||||
|
||||
/* We check a list of standard characters. The first match wins. */
|
||||
|
|
@ -144,7 +144,7 @@
|
|||
break;
|
||||
}
|
||||
|
||||
af_shaper_buf_destroy( face, shaper_buf );
|
||||
af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
|
||||
|
||||
if ( !glyph_index )
|
||||
goto Exit;
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
FT_TRACE5(( "\n" ));
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
shaper_buf = af_shaper_buf_create( face );
|
||||
shaper_buf = af_shaper_buf_create( metrics->root.globals );
|
||||
#endif
|
||||
|
||||
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
|
||||
|
|
@ -553,7 +553,7 @@
|
|||
|
||||
} /* end for loop */
|
||||
|
||||
af_shaper_buf_destroy( face, shaper_buf );
|
||||
af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
|
||||
|
||||
FT_TRACE5(( "\n" ));
|
||||
|
||||
|
|
@ -583,11 +583,13 @@
|
|||
const char digits[] = "0 1 2 3 4 5 6 7 8 9";
|
||||
const char* p;
|
||||
|
||||
FT_UNUSED( face );
|
||||
|
||||
|
||||
p = digits;
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
shaper_buf = af_shaper_buf_create( face );
|
||||
shaper_buf = af_shaper_buf_create( metrics->root.globals );
|
||||
#endif
|
||||
|
||||
while ( *p )
|
||||
|
|
@ -624,7 +626,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
af_shaper_buf_destroy( face, shaper_buf );
|
||||
af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
|
||||
|
||||
metrics->root.digits_have_same_width = same_width;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@
|
|||
globals->scale_down_factor = 0;
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
globals->hb_font = ft_hb_ft_font_create( face, NULL );
|
||||
globals->hb_font = ft_hb_ft_font_create( globals );
|
||||
globals->hb_buf = hb( buffer_create )();
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
p = script_class->standard_charstring;
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
shaper_buf = af_shaper_buf_create( face );
|
||||
shaper_buf = af_shaper_buf_create( metrics->root.globals );
|
||||
#endif
|
||||
/*
|
||||
* We check a list of standard characters to catch features like
|
||||
|
|
@ -141,7 +141,7 @@
|
|||
break;
|
||||
}
|
||||
|
||||
af_shaper_buf_destroy( face, shaper_buf );
|
||||
af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
|
||||
|
||||
if ( !glyph_index )
|
||||
{
|
||||
|
|
@ -351,7 +351,7 @@
|
|||
FT_TRACE5(( "\n" ));
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
shaper_buf = af_shaper_buf_create( face );
|
||||
shaper_buf = af_shaper_buf_create( metrics->root.globals );
|
||||
#endif
|
||||
|
||||
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
|
||||
|
|
@ -974,7 +974,7 @@
|
|||
|
||||
} /* end for loop */
|
||||
|
||||
af_shaper_buf_destroy( face, shaper_buf );
|
||||
af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
|
||||
|
||||
if ( axis->blue_count )
|
||||
{
|
||||
|
|
@ -1082,11 +1082,13 @@
|
|||
const char digits[] = "0 1 2 3 4 5 6 7 8 9";
|
||||
const char* p;
|
||||
|
||||
FT_UNUSED( face );
|
||||
|
||||
|
||||
p = digits;
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
|
||||
shaper_buf = af_shaper_buf_create( face );
|
||||
shaper_buf = af_shaper_buf_create( metrics->root.globals );
|
||||
#endif
|
||||
|
||||
while ( *p )
|
||||
|
|
@ -1123,7 +1125,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
af_shaper_buf_destroy( face, shaper_buf );
|
||||
af_shaper_buf_destroy( metrics->root.globals, shaper_buf );
|
||||
|
||||
metrics->root.digits_have_same_width = same_width;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -438,19 +438,19 @@
|
|||
|
||||
|
||||
void*
|
||||
af_shaper_buf_create( FT_Face face )
|
||||
af_shaper_buf_create( AF_FaceGlobals globals )
|
||||
{
|
||||
FT_UNUSED( face );
|
||||
FT_UNUSED( globals );
|
||||
|
||||
return (void*)hb( buffer_create )();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
af_shaper_buf_destroy( FT_Face face,
|
||||
void* buf )
|
||||
af_shaper_buf_destroy( AF_FaceGlobals globals,
|
||||
void* buf )
|
||||
{
|
||||
FT_UNUSED( face );
|
||||
FT_UNUSED( globals );
|
||||
|
||||
hb( buffer_destroy )( (hb_buffer_t*)buf );
|
||||
}
|
||||
|
|
@ -462,6 +462,8 @@
|
|||
void* buf_,
|
||||
unsigned int* count )
|
||||
{
|
||||
AF_FaceGlobals globals = metrics->globals;
|
||||
|
||||
AF_StyleClass style_class;
|
||||
const hb_feature_t* feature;
|
||||
FT_Int upem;
|
||||
|
|
@ -472,6 +474,8 @@
|
|||
hb_font_t* font;
|
||||
hb_codepoint_t dummy;
|
||||
|
||||
FT_UNUSED( globals );
|
||||
|
||||
|
||||
upem = (FT_Int)metrics->globals->face->units_per_EM;
|
||||
style_class = metrics->style_class;
|
||||
|
|
@ -561,12 +565,14 @@
|
|||
FT_Long* advance,
|
||||
FT_Long* y_offset )
|
||||
{
|
||||
AF_FaceGlobals globals = metrics->globals;
|
||||
|
||||
hb_buffer_t* buf = (hb_buffer_t*)buf_;
|
||||
hb_glyph_info_t* ginfo;
|
||||
hb_glyph_position_t* gpos;
|
||||
unsigned int gcount;
|
||||
|
||||
FT_UNUSED( metrics );
|
||||
FT_UNUSED( globals );
|
||||
|
||||
|
||||
ginfo = hb( buffer_get_glyph_infos )( buf, &gcount );
|
||||
|
|
@ -603,19 +609,19 @@
|
|||
|
||||
|
||||
void*
|
||||
af_shaper_buf_create( FT_Face face )
|
||||
af_shaper_buf_create( AF_FaceGlobals globals )
|
||||
{
|
||||
FT_UNUSED( face );
|
||||
FT_UNUSED( globals );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
af_shaper_buf_destroy( FT_Face face,
|
||||
af_shaper_buf_destroy( AF_FaceGlobals globals,
|
||||
void* buf )
|
||||
{
|
||||
FT_UNUSED( face );
|
||||
FT_UNUSED( globals );
|
||||
FT_UNUSED( buf );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ FT_BEGIN_HEADER
|
|||
|
||||
|
||||
void*
|
||||
af_shaper_buf_create( FT_Face face );
|
||||
af_shaper_buf_create( AF_FaceGlobals globals );
|
||||
|
||||
void
|
||||
af_shaper_buf_destroy( FT_Face face,
|
||||
void* buf );
|
||||
af_shaper_buf_destroy( AF_FaceGlobals globals,
|
||||
void* buf );
|
||||
|
||||
const char*
|
||||
af_shaper_get_cluster( const char* p,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@
|
|||
static hb_blob_t *
|
||||
ft_hb_ft_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data)
|
||||
{
|
||||
FT_Face ft_face = (FT_Face) user_data;
|
||||
AF_FaceGlobals globals = (AF_FaceGlobals) user_data;
|
||||
|
||||
FT_Face ft_face = globals->face;
|
||||
FT_Byte *buffer;
|
||||
FT_ULong length = 0;
|
||||
FT_Error error;
|
||||
|
|
@ -68,9 +70,10 @@ ft_hb_ft_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data)
|
|||
}
|
||||
|
||||
static hb_face_t *
|
||||
ft_hb_ft_face_create (FT_Face ft_face,
|
||||
hb_destroy_func_t destroy)
|
||||
ft_hb_ft_face_create (AF_FaceGlobals globals)
|
||||
{
|
||||
FT_Face ft_face = globals->face;
|
||||
|
||||
hb_face_t *face;
|
||||
|
||||
if (!ft_face->stream->read) {
|
||||
|
|
@ -79,11 +82,11 @@ ft_hb_ft_face_create (FT_Face ft_face,
|
|||
blob = hb(blob_create) ((const char *) ft_face->stream->base,
|
||||
(unsigned int) ft_face->stream->size,
|
||||
HB_MEMORY_MODE_READONLY,
|
||||
ft_face, destroy);
|
||||
ft_face, NULL);
|
||||
face = hb(face_create) (blob, ft_face->face_index);
|
||||
hb(blob_destroy) (blob);
|
||||
} else {
|
||||
face = hb(face_create_for_tables) (ft_hb_ft_reference_table, ft_face, destroy);
|
||||
face = hb(face_create_for_tables) (ft_hb_ft_reference_table, globals, NULL);
|
||||
}
|
||||
|
||||
hb(face_set_index) (face, ft_face->face_index);
|
||||
|
|
@ -93,13 +96,12 @@ ft_hb_ft_face_create (FT_Face ft_face,
|
|||
}
|
||||
|
||||
FT_LOCAL_DEF(hb_font_t *)
|
||||
ft_hb_ft_font_create (FT_Face ft_face,
|
||||
hb_destroy_func_t destroy)
|
||||
ft_hb_ft_font_create (AF_FaceGlobals globals)
|
||||
{
|
||||
hb_font_t *font;
|
||||
hb_face_t *face;
|
||||
|
||||
face = ft_hb_ft_face_create (ft_face, destroy);
|
||||
face = ft_hb_ft_face_create (globals);
|
||||
font = hb(font_create) (face);
|
||||
hb(face_destroy) (face);
|
||||
return font;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,13 @@
|
|||
|
||||
#include "ft-hb.h"
|
||||
|
||||
#include "afglobal.h"
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
FT_LOCAL(hb_font_t *)
|
||||
ft_hb_ft_font_create (FT_Face ft_face,
|
||||
hb_destroy_func_t destroy);
|
||||
ft_hb_ft_font_create (AF_FaceGlobals globals);
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue