forked from minhngoc25a/freetype2
* include/freetype/internal/ftobjs.h, src/base/ftobjs.c,
src/truetype/ttobjs.c: fixes related to the unpatented hinter
This commit is contained in:
parent
9884faed9d
commit
df430e1a20
|
@ -1,5 +1,7 @@
|
||||||
2006-09-30 Werner Lemberg <wl@gnu.org>
|
2006-09-30 Werner Lemberg <wl@gnu.org>
|
||||||
|
* include/freetype/internal/ftobjs.h, src/base/ftobjs.c,
|
||||||
|
src/truetype/ttobjs.c: fixes related to the unpatented hinter
|
||||||
|
|
||||||
* src/base/rules.mk (BASE_SRC): Remove `ftapi.c' (which is no longer
|
* src/base/rules.mk (BASE_SRC): Remove `ftapi.c' (which is no longer
|
||||||
in use).
|
in use).
|
||||||
|
|
||||||
|
|
|
@ -211,11 +211,11 @@ FT_BEGIN_HEADER
|
||||||
/* this data when first opened. This field exists only if */
|
/* this data when first opened. This field exists only if */
|
||||||
/* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
|
/* @FT_CONFIG_OPTION_INCREMENTAL is defined. */
|
||||||
/* */
|
/* */
|
||||||
/* unpatented_hinting :: */
|
/* ignore_unpatented_hinter :: */
|
||||||
/* This boolean flag instructs the glyph loader that this font */
|
/* This boolean flag instructs the glyph loader to ignore */
|
||||||
/* can only be loaded through the unpatented bytecode interpreter. */
|
/* the native font hinter, if one is found. This is exclusively */
|
||||||
/* In that case, the auto-hinter is never called for it, except if */
|
/* used in the case when the unpatented hinter is compiled within */
|
||||||
/* you use FT_LOAD_FORCE_AUTOHINT. */
|
/* the library. */
|
||||||
/* */
|
/* */
|
||||||
typedef struct FT_Face_InternalRec_
|
typedef struct FT_Face_InternalRec_
|
||||||
{
|
{
|
||||||
|
@ -233,7 +233,7 @@ FT_BEGIN_HEADER
|
||||||
FT_Incremental_InterfaceRec* incremental_interface;
|
FT_Incremental_InterfaceRec* incremental_interface;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FT_Bool unpatented_hinting;
|
FT_Bool ignore_unpatented_hinter;
|
||||||
|
|
||||||
} FT_Face_InternalRec;
|
} FT_Face_InternalRec;
|
||||||
|
|
||||||
|
|
|
@ -573,23 +573,45 @@
|
||||||
load_flags &= ~FT_LOAD_RENDER;
|
load_flags &= ~FT_LOAD_RENDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( FT_LOAD_TARGET_MODE( load_flags ) == FT_RENDER_MODE_LIGHT )
|
/* determine wether we need to auto-hint or not
|
||||||
load_flags |= FT_LOAD_FORCE_AUTOHINT;
|
* the general rules are:
|
||||||
|
*
|
||||||
|
* - only auto-hint if we have a hinter module, a
|
||||||
|
* scalable font format dealing with outlines,
|
||||||
|
* no transforms except simple slants
|
||||||
|
*
|
||||||
|
* - then, autohint if FT_LOAD_FORCE_AUTOHINT is set
|
||||||
|
* or if we don't have a native font hinter
|
||||||
|
*
|
||||||
|
* - otherwise, autohint for LIGHT hinting mode
|
||||||
|
*
|
||||||
|
* - except if the font requires the unpatented
|
||||||
|
* bytecode interpreter to load properly
|
||||||
|
*/
|
||||||
|
|
||||||
/* auto-hinter is preferred and should be used */
|
autohint = 0;
|
||||||
if ( ( !FT_DRIVER_HAS_HINTER( driver ) ||
|
if ( hinter &&
|
||||||
( load_flags & FT_LOAD_FORCE_AUTOHINT ) ) &&
|
(load_flags & FT_LOAD_NO_HINTING) == 0 &&
|
||||||
!( load_flags & FT_LOAD_NO_HINTING ) &&
|
(load_flags & FT_LOAD_NO_AUTOHINT) == 0 &&
|
||||||
!( load_flags & FT_LOAD_NO_AUTOHINT ) )
|
FT_DRIVER_IS_SCALABLE( driver ) &&
|
||||||
|
FT_DRIVER_USES_OUTLINES( driver ) &&
|
||||||
|
face->internal->transform_matrix.yy > 0 &&
|
||||||
|
face->internal->transform_matrix.yx == 0 )
|
||||||
{
|
{
|
||||||
/* check whether it works for this face */
|
if ( (load_flags & FT_LOAD_FORCE_AUTOHINT) != 0 ||
|
||||||
autohint =
|
!FT_DRIVER_HAS_HINTER( driver ) )
|
||||||
FT_BOOL( hinter &&
|
autohint = 1;
|
||||||
FT_DRIVER_IS_SCALABLE( driver ) &&
|
|
||||||
FT_DRIVER_USES_OUTLINES( driver ) &&
|
else
|
||||||
face->internal->transform_matrix.yy > 0 &&
|
{
|
||||||
face->internal->transform_matrix.yx == 0 &&
|
FT_Render_Mode mode = FT_LOAD_TARGET_MODE(load_flags);
|
||||||
!face->internal->unpatented_hinting );
|
|
||||||
|
if ( mode == FT_RENDER_MODE_LIGHT ||
|
||||||
|
face->internal->ignore_unpatented_hinter )
|
||||||
|
{
|
||||||
|
autohint = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( autohint )
|
if ( autohint )
|
||||||
|
|
|
@ -246,51 +246,53 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
|
#if defined(TT_CONFIG_OPTION_UNPATENTED_HINTING) && \
|
||||||
|
!defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
|
||||||
/* Determine whether unpatented hinting is to be used for this face. */
|
|
||||||
face->unpatented_hinting = FT_BOOL
|
|
||||||
( library->debug_hooks[ FT_DEBUG_HOOK_UNPATENTED_HINTING ] != NULL );
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
FT_Bool unpatented_hinting;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Determine whether unpatented hinting is to be used for this face. */
|
||||||
|
unpatented_hinting = FT_BOOL
|
||||||
|
( library->debug_hooks[ FT_DEBUG_HOOK_UNPATENTED_HINTING ] != NULL );
|
||||||
|
|
||||||
for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
|
for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
|
||||||
if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
|
if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
|
||||||
face->unpatented_hinting = TRUE;
|
unpatented_hinting = TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
/* Compare the face with a list of well-known `tricky' fonts. */
|
/* Compare the face with a list of well-known `tricky' fonts. */
|
||||||
/* This list shall be expanded as we find more of them. */
|
/* This list shall be expanded as we find more of them. */
|
||||||
if ( !face->unpatented_hinting )
|
if ( !unpatented_hinting )
|
||||||
{
|
|
||||||
static const char* const trick_names[] =
|
|
||||||
{
|
{
|
||||||
"DFKaiSho-SB", /* dfkaisb.ttf */
|
static const char* const trick_names[] =
|
||||||
"DFKai-SB", /* kaiu.ttf */
|
|
||||||
"HuaTianSongTi?", /* htst3.ttf */
|
|
||||||
"MingLiU", /* mingliu.ttf & mingliu.ttc */
|
|
||||||
"PMingLiU", /* mingliu.ttc */
|
|
||||||
"MingLi43", /* mingli.ttf */
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
int nn;
|
|
||||||
|
|
||||||
|
|
||||||
/* Note that we only check the face name at the moment; it might */
|
|
||||||
/* be worth to do more checks for a few special cases. */
|
|
||||||
for ( nn = 0; trick_names[nn] != NULL; nn++ )
|
|
||||||
{
|
|
||||||
if ( ft_strcmp( ttface->family_name, trick_names[nn] ) == 0 )
|
|
||||||
{
|
{
|
||||||
face->unpatented_hinting = 1;
|
"DFKaiSho-SB", /* dfkaisb.ttf */
|
||||||
break;
|
"DFKai-SB", /* kaiu.ttf */
|
||||||
|
"HuaTianSongTi?", /* htst3.ttf */
|
||||||
|
"MingLiU", /* mingliu.ttf & mingliu.ttc */
|
||||||
|
"PMingLiU", /* mingliu.ttc */
|
||||||
|
"MingLi43", /* mingli.ttf */
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
int nn;
|
||||||
|
|
||||||
|
|
||||||
|
/* Note that we only check the face name at the moment; it might */
|
||||||
|
/* be worth to do more checks for a few special cases. */
|
||||||
|
for ( nn = 0; trick_names[nn] != NULL; nn++ )
|
||||||
|
{
|
||||||
|
if ( ft_strcmp( ttface->family_name, trick_names[nn] ) == 0 )
|
||||||
|
{
|
||||||
|
unpatented_hinting = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ttface->internal->ignore_unpatented_hinter = !unpatented_hinting;
|
||||||
}
|
}
|
||||||
|
|
||||||
ttface->internal->unpatented_hinting = face->unpatented_hinting;
|
|
||||||
#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */
|
#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */
|
||||||
|
|
||||||
/* initialize standard glyph loading routines */
|
/* initialize standard glyph loading routines */
|
||||||
|
|
Loading…
Reference in New Issue