Hi all,
By recent discussions in poppler mailing list (poppler
is an open source PDF rendering library forked from xpdf),
I found a typical scenario that the tricky font list
cannot force the hinting for tricky fonts like MingLiU.
http://lists.freedesktop.org/archives/poppler/2010-August/006295.html
By my analysis(*1), it is hard for FT2 decide if hinting
should be forced for a font extracted from a PDF. The
information available at higher layer is important to
decide.
FT2 already provides an API to switch the hinting after
the creation of FT_Face object (FT_Face_SetUnpatentedHinting).
The FT2 clients with their own tricky font list can use
this API to force the hinting.
But, it seems that some developers don't want to maintain
their own external tricky font list.
Thus, I sketched an interface to configure the tricky font
list from FT2 client. The mechanism is quite simple:
1) Substitute the array of the string for tricky font family
name list (stored in TrueType driver) by FT_List object in
FT_Library (FT_Library-tricky_fonts).
1-a) tricky_fonts is allocated when FT_Library is created.
1-b) tricky_fonts is freed when FT_Library is destroyed.
2) Add 3 public functions to configure FT_Library-tricky_fonts
FT_Library_TrickyFontList_Add( library, condition )
FT_Library_TrickyFontList_Remove( library, condition )
FT_Face_Get_TrickyLevel( face, tricky_level )
2-a) at present, condition is a string FAMILYNAME=XXX.
other properties(*2) can be supported in future.
2-b) the condition string is duplicated to the buffer
allocated during the insertion, and the buffer
is freed during the removal.
3) Substitute tt_check_trickyness() by public function
FT_Face_Get_TrickyLevel().
4) Register known tricky fonts to FT_Library when TrueType
driver is initialized.
The following patch is a rough sketch. I'm wondering if
I should provide a simple function to check the list by
passing the family name string. In current sketch, FT2
clients should pass FT_Face object - if they want to check
before FT_Face creation, they have to make a fake FT_Face
object including family_name. Having a fake FT_Face object
and a genuine FT_Face object in one program might make
the maintainer confused.
--
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 7799b70..846385c 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1081,6 +1081,40 @@ FT_BEGIN_HEADER
#define FT_FACE_FLAG_TRICKY( 1L 13 )
+ /*/
+ /* */
+ /* Enum*/
+ /*FT_Face_Tricky_Level */
+ /* */
+ /* Description */
+ /*An enumeration type to indicate the tricky level of the face. */
+ /* */
+ /* Values */
+ /*FT_FACE_TRICKY_NO: nothing in blacklist matches*/
+ /* */
+ /*FT_FACE_TRICKY_EXACT: partial match in blacklisted fonts. */
+ /* */
+ /*FT_FACE_TRICKY_PARTIAL: partial match in blacklisted fonts.*/
+ /* */
+ typedef enum FT_Face_Tricky_Level_
+ {
+FT_FACE_TRICKY_NO, /* match nothing in blacklist */
+FT_FACE_TRICKY_EXACT,/* exact match in blacklist */
+FT_FACE_TRICKY_PARTIAL /* partial match in blacklist */
+ } FT_Face_Tricky_Level;
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Library_TrickyFontList_Add( FT_Library library,
+ FT_String* condition );
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Library_TrickyFontList_Remove( FT_Library library,
+FT_String* condition );
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Face_Get_TrickyLevel( FT_Faceface,
+ FT_Face_Tricky_Level* level );
+
/*
*
* @macro:
diff --git a/include/freetype/internal/ftobjs.h
b/include/freetype/internal/ftobjs.h
index 670eb78..c47ffe5 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -850,6 +850,7 @@ FT_BEGIN_HEADER
FT_ListRec renderers;/* list of renderers*/
FT_Renderercur_renderer; /* current outline renderer */
FT_Module auto_hinter;
+FT_List