summaryrefslogtreecommitdiffstats
path: root/src/autofit/afglobal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/autofit/afglobal.c')
-rw-r--r--src/autofit/afglobal.c107
1 files changed, 78 insertions, 29 deletions
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 64b9293..3223358 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -18,7 +18,7 @@
#include "afglobal.h"
#include "afranges.h"
-#include "hbshim.h"
+#include "afshaper.h"
#include FT_INTERNAL_DEBUG_H
@@ -42,12 +42,13 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
AF_DEFINE_SCRIPT_CLASS( \
af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \
af_ ## s ## _uniranges, \
- sc1, sc2, sc3 )
+ af_ ## s ## _nonbase_uniranges, \
+ ss )
#include "afscript.h"
@@ -82,7 +83,7 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
&af_ ## s ## _script_class,
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
@@ -135,16 +136,15 @@
FT_Error error;
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
- FT_Byte* gstyles = globals->glyph_styles;
+ FT_UShort* gstyles = globals->glyph_styles;
FT_UInt ss;
FT_UInt i;
FT_UInt dflt = ~0U; /* a non-valid value */
/* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
- FT_MEM_SET( globals->glyph_styles,
- AF_STYLE_UNASSIGNED,
- globals->glyph_count );
+ for ( i = 0; i < (FT_UInt)globals->glyph_count; i++ )
+ gstyles[i] = AF_STYLE_UNASSIGNED;
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
if ( error )
@@ -190,10 +190,10 @@
gindex = FT_Get_Char_Index( face, charcode );
- if ( gindex != 0 &&
- gindex < (FT_ULong)globals->glyph_count &&
- gstyles[gindex] == AF_STYLE_UNASSIGNED )
- gstyles[gindex] = (FT_Byte)ss;
+ if ( gindex != 0 &&
+ gindex < (FT_ULong)globals->glyph_count &&
+ ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
+ gstyles[gindex] = (FT_UShort)ss;
for (;;)
{
@@ -202,21 +202,50 @@
if ( gindex == 0 || charcode > range->last )
break;
- if ( gindex < (FT_ULong)globals->glyph_count &&
- gstyles[gindex] == AF_STYLE_UNASSIGNED )
- gstyles[gindex] = (FT_Byte)ss;
+ if ( gindex < (FT_ULong)globals->glyph_count &&
+ ( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
+ gstyles[gindex] = (FT_UShort)ss;
+ }
+ }
+
+ /* do the same for the script's non-base characters */
+ for ( range = script_class->script_uni_nonbase_ranges;
+ range->first != 0;
+ range++ )
+ {
+ FT_ULong charcode = range->first;
+ FT_UInt gindex;
+
+
+ gindex = FT_Get_Char_Index( face, charcode );
+
+ if ( gindex != 0 &&
+ gindex < (FT_ULong)globals->glyph_count &&
+ ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
+ gstyles[gindex] |= AF_NONBASE;
+
+ for (;;)
+ {
+ charcode = FT_Get_Next_Char( face, charcode, &gindex );
+
+ if ( gindex == 0 || charcode > range->last )
+ break;
+
+ if ( gindex < (FT_ULong)globals->glyph_count &&
+ ( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
+ gstyles[gindex] |= AF_NONBASE;
}
}
}
else
{
/* get glyphs not directly addressable by cmap */
- af_get_coverage( globals, style_class, gstyles );
+ af_shaper_get_coverage( globals, style_class, gstyles );
}
}
/* handle the default OpenType features of the default script ... */
- af_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles );
+ af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles );
/* ... and the remaining default OpenType features */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
@@ -225,7 +254,7 @@
if ( ss != dflt && style_class->coverage == AF_COVERAGE_DEFAULT )
- af_get_coverage( globals, style_class, gstyles );
+ af_shaper_get_coverage( globals, style_class, gstyles );
}
/* mark ASCII digits */
@@ -250,9 +279,9 @@
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
- if ( ( gstyles[nn] & ~AF_DIGIT ) == AF_STYLE_UNASSIGNED )
+ if ( ( gstyles[nn] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
{
- gstyles[nn] &= ~AF_STYLE_UNASSIGNED;
+ gstyles[nn] &= ~AF_STYLE_MASK;
gstyles[nn] |= globals->module->fallback_style;
}
}
@@ -276,7 +305,7 @@
for ( idx = 0; idx < globals->glyph_count; idx++ )
{
- if ( ( gstyles[idx] & ~AF_DIGIT ) == style_class->style )
+ if ( ( gstyles[idx] & AF_STYLE_MASK ) == style_class->style )
{
if ( !( count % 10 ) )
FT_TRACE4(( " " ));
@@ -314,18 +343,28 @@
memory = face->memory;
+ /* we allocate an AF_FaceGlobals structure together */
+ /* with the glyph_styles array */
if ( FT_ALLOC( globals,
sizeof ( *globals ) +
- (FT_ULong)face->num_glyphs * sizeof ( FT_Byte ) ) )
+ (FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
goto Exit;
- globals->face = face;
- globals->glyph_count = face->num_glyphs;
- globals->glyph_styles = (FT_Byte*)( globals + 1 );
- globals->module = module;
+ globals->face = face;
+ globals->glyph_count = face->num_glyphs;
+ /* right after the globals structure come the glyph styles */
+ globals->glyph_styles = (FT_UShort*)( globals + 1 );
+ globals->module = module;
+ globals->stem_darkening_for_ppem = 0;
+ globals->darken_x = 0;
+ globals->darken_y = 0;
+ globals->standard_vertical_width = 0;
+ globals->standard_horizontal_width = 0;
+ globals->scale_down_factor = 0;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
globals->hb_font = hb_ft_font_create( face, NULL );
+ globals->hb_buf = hb_buffer_create();
#endif
error = af_face_globals_compute_style_coverage( globals );
@@ -372,11 +411,21 @@
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_destroy( globals->hb_font );
globals->hb_font = NULL;
+
+ hb_buffer_destroy( globals->hb_buf );
+ globals->hb_buf = NULL;
#endif
- globals->glyph_count = 0;
- globals->glyph_styles = NULL; /* no need to free this one! */
- globals->face = NULL;
+ globals->glyph_count = 0;
+ globals->stem_darkening_for_ppem = 0;
+ globals->darken_x = 0;
+ globals->darken_y = 0;
+ globals->standard_vertical_width = 0;
+ globals->standard_horizontal_width = 0;
+ globals->scale_down_factor = 0;
+ /* no need to free this one! */
+ globals->glyph_styles = NULL;
+ globals->face = NULL;
FT_FREE( globals );
}