On Fri, Dec 09, 2005 at 09:30:27AM +0800, Chia-I Wu wrote:
> To remedy this, the definition of FT_Set_Pixel_Sizes is changed to set
> the real height, not the nominal height. BDF/PCF drivers are also
> updated to reflect this change.
>
> As you can see, the problem is that other drivers are not updated. The
> scaling I mentioned in my another mail should be used for scalable font
> drivers. Sbit needs update too.
Ok, back on this issue :)
Since FT_Set_Pixel_Sizes might set the nominal size or the real
dimension in a unpredictable way, this is the first thing to fix. I
chose to make it always set the nominal size.
This effectively undo one of the changes between 2.1.9 and 2.1.10, which
says:
- The method how BDF and PCF bitmap fonts are accessed has been
refined. Formerly, FT_Set_Pixel_Sizes and FT_Set_Char_Size
were synonyms in FreeType's BDF and PCF interface. This has
changed now. FT_Set_Pixel_Sizes should be used to select the
actual font dimensions (the `strike', which is the sum of the
`FONT_ASCENT' and `FONT_DESCENT' properties), while
FT_Set_Char_Size selects the `nominal' size (the `PIXELSIZE'
property). In both functions, the width parameter is ignored.
Then what if the user wants to set the real dimension? To meet this
need, I changed the driver interface and combined the `set_char_sizes'
and `set_pixel_sizes' to `request_size', which takes FT_Size_RequestRec
as its argument, which is prototyped by
typedef struct FT_Size_RequestRec_
{
FT_Size_Request_Type type;
FT_F26Dot6 width;
FT_F26Dot6 height;
FT_UInt horiResolution;
FT_UInt vertResolution;
} FT_Size_RequestRec, *FT_Size_Request;
The field `type' can be NOMINAL, REAL_DIMENSION, or more.
Further, I added `select_size' to the driver interface, which selects a
fixed size by its index in available_sizes. If you imagine how clients
choose a fixed size from the available ones, you will find it useful.
In spite of this, `request_size' still looks into avaiable sizes and
selects one of them if it matches the request, as we had always done.
You can find the detail from the attached file, which is a diff of the
headers. If everyone agrees on these changes, I'll commit them.
--
Regards,
olv
=== include/freetype/freetype.h
==================================================================
--- include/freetype/freetype.h (/freetype2/trunk) (revision 3035)
+++ include/freetype/freetype.h (/freetype2/branches/size_selection) (local)
@@ -147,6 +147,7 @@
/* FT_Attach_File */
/* FT_Attach_Stream */
/* */
+ /* FT_Select_Size */
/* FT_Set_Char_Size */
/* FT_Set_Pixel_Sizes */
/* FT_Set_Transform */
@@ -293,10 +294,10 @@
/* where `size' is in points. */
/* */
/* Windows FNT: */
- /* The `size' parameter is not reliable: There exist fonts (e.g., */
- /* app850.fon) which have a wrong size for some subfonts; x_ppem */
- /* and y_ppem are thus set equal to pixel width and height given in */
- /* in the Windows FNT header. */
+ /* The nominal size given in a FNT font is not reliable. Thus when */
+ /* it is obviously incorrect, we set `size' to some calculated */
+ /* values and set `x_ppem' and `y_ppem' to pixel width and height */
+ /* given in the font, respectively. */
/* */
/* TrueType embedded bitmaps: */
/* `size', `width', and `height' values are not contained in the */
@@ -2071,16 +2072,40 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Select_Size */
+ /* */
+ /* <Description> */
+ /* Selects a fixed size. */
+ /* */
+ /* <InOut> */
+ /* face :: A handle to a target face object. */
+ /* */
+ /* <Input> */
+ /* index :: The index of the fixed size in the `available_sizes' */
+ /* field of @FT_FaceRec structure. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Select_Size( FT_Face face,
+ FT_Int index );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Set_Char_Size */
/* */
/* <Description> */
- /* Sets the character dimensions of a given face object. The */
- /* `char_width' and `char_height' values are used for the width and */
- /* height, respectively, expressed in 26.6 fractional points. */
+ /* Sets the character dimensions of a given face object. The width */
+ /* and height are expressed in 26.6 fractional points. */
/* */
+ /* If one of the character dimensions is zero, its value is set equal */
+ /* to the other. */
+ /* */
/* If the horizontal or vertical resolution values are zero, a */
- /* default value of 72dpi is used. Similarly, if one of the */
- /* character dimensions is zero, its value is set equal to the other. */
+ /* default value of 72dpi is used. */
/* */
/* <InOut> */
/* face :: A handle to a target face object. */
@@ -2099,9 +2124,8 @@
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
- /* For BDF and PCF formats, this function uses the `PIXEL_SIZE' */
- /* property of the bitmap font; the `char_width' parameter is */
- /* ignored. */
+ /* You should use @FT_Select_Size if you are intended to select some */
+ /* fixed size from the `available_sizes' field. */
/* */
FT_EXPORT( FT_Error )
FT_Set_Char_Size( FT_Face face,
@@ -2135,27 +2159,9 @@
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
- /* The values of `pixel_width' and `pixel_height' correspond to the */
- /* pixel values of the _typographic_ character size, which are NOT */
- /* necessarily the same as the dimensions of the glyph `bitmap */
- /* cells'. */
+ /* You should use @FT_Select_Size if you are intended to select some */
+ /* fixed size from the `available_sizes' field. */
/* */
- /* The `character size' is really the size of an abstract square */
- /* called the `EM', used to design the font. However, depending */
- /* on the font design, glyphs is smaller or greater than the EM. */
- /* */
- /* This means that setting the pixel size to, say, 8x8 doesn't */
- /* guarantee in any way that you get glyph bitmaps that all fit */
- /* within an 8x8 cell (sometimes even far from it). */
- /* */
- /* For bitmap fonts, `pixel_height' usually is a reliable value for */
- /* the height of the bitmap cell. Drivers for bitmap font formats */
- /* which contain a single bitmap strike only (BDF, PCF, FNT) ignore */
- /* `pixel_width'. */
- /* */
- /* For BDF and PCF formats, this function uses the sum of the */
- /* `FONT_ASCENT' and `FONT_DESCENT' properties of the bitmap font. */
- /* */
FT_EXPORT( FT_Error )
FT_Set_Pixel_Sizes( FT_Face face,
FT_UInt pixel_width,
=== include/freetype/internal/ftdriver.h
==================================================================
--- include/freetype/internal/ftdriver.h (/freetype2/trunk)
(revision 3035)
+++ include/freetype/internal/ftdriver.h
(/freetype2/branches/size_selection) (local)
@@ -52,17 +52,84 @@
(*FT_Slot_DoneFunc)( FT_GlyphSlot slot );
+ /*************************************************************************/
+ /* */
+ /* @enum: */
+ /* FT_SIZE_REQUEST_TYPE_XXX */
+ /* */
+ /* @description: */
+ /* The meaning of width and height in @FT_Size_Request. */
+ /* */
+ /* @values: */
+ /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
+ /* The nominal size. That is, the ppems. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
+ /* The real dimension. That is, ascenter + descender. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_BBOX :: */
+ /* The glyph bounding box. */
+ /* */
+ /* FT_SIZE_REQUEST_TYPE_CELL :: */
+ /* This type is a little different from the others, in that both */
+ /* axes will always be scaled by the same factor. The factor is */
+ /* chosen so that max_advance_width <= width and */
+ /* ascender + descender <= height. */
+ /* */
+
+ typedef enum FT_Size_Request_Type_
+ {
+ FT_SIZE_REQUEST_TYPE_NOMINAL,
+ FT_SIZE_REQUEST_TYPE_REAL_DIM,
+ FT_SIZE_REQUEST_TYPE_BBOX,
+ FT_SIZE_REQUEST_TYPE_CELL
+
+ } FT_Size_Request_Type;
+
+
+ /*************************************************************************/
+ /* */
+ /* <Struct> */
+ /* FT_Size_Request */
+ /* */
+ /* <Description> */
+ /* A structure used for size request. */
+ /* */
+ /* <Fields> */
+ /* type :: */
+ /* See @FT_Size_Request_Type. */
+ /* */
+ /* width :: */
+ /* The desired width. Can be zero if height is non-zero. */
+ /* */
+ /* height :: */
+ /* The desired height. Can be zero if width is non-zero. */
+ /* */
+ /* horiResolution :: */
+ /* The horizontal resolution. If it is zero, then width is treated */
+ /* as in pixels. */
+ /* */
+ /* vertResolution :: */
+ /* The vertical resolution. If it is zero, then height is treated */
+ /* as in pixels. */
+ /* */
+ typedef struct FT_Size_RequestRec_
+ {
+ FT_Size_Request_Type type;
+ FT_F26Dot6 width;
+ FT_F26Dot6 height;
+ FT_UInt horiResolution;
+ FT_UInt vertResolution;
+ } FT_Size_RequestRec, *FT_Size_Request;
+
+
typedef FT_Error
- (*FT_Size_ResetPointsFunc)( FT_Size size,
- FT_F26Dot6 char_width,
- FT_F26Dot6 char_height,
- FT_UInt horz_resolution,
- FT_UInt vert_resolution );
+ (*FT_Size_RequestFunc)( FT_Size size,
+ FT_Size_Request req );
typedef FT_Error
- (*FT_Size_ResetPixelsFunc)( FT_Size size,
- FT_UInt pixel_width,
- FT_UInt pixel_height );
+ (*FT_Size_SelectFunc)( FT_Size size,
+ FT_ULong index );
typedef FT_Error
(*FT_Slot_LoadFunc)( FT_GlyphSlot slot,
@@ -129,16 +196,18 @@
/* */
/* done_slot :: The format-specific slot destructor. */
/* */
- /* set_char_sizes :: A handle to a function used to set the new */
- /* character size in points + resolution. Can be */
- /* set to 0 to indicate default behaviour. */
+ /* request_size :: A handle to a function used to request the new */
+ /* character size. Can be set to 0 if the */
+ /* scaling done in the base layer suffices. */
/* */
- /* set_pixel_sizes :: A handle to a function used to set the new */
- /* character size in pixels. Can be set to 0 to */
- /* indicate default behaviour. */
+ /* select_size :: A handle to a function used to select a new */
+ /* fixed size. It is used only when */
+ /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */
+ /* to 0 if the scaling done in the base layer */
+ /* suffices. */
/* */
- /* load_glyph :: A function handle to load a given glyph image */
- /* in a slot. This field is mandatory! */
+ /* load_glyph :: A function handle to load a glyph to a slot. */
+ /* This field is mandatory! */
/* */
/* get_char_index :: A function handle to return the glyph index of */
/* a given character for a given charmap. This */
@@ -186,8 +255,8 @@
FT_Slot_InitFunc init_slot;
FT_Slot_DoneFunc done_slot;
- FT_Size_ResetPointsFunc set_char_sizes;
- FT_Size_ResetPixelsFunc set_pixel_sizes;
+ FT_Size_RequestFunc request_size;
+ FT_Size_SelectFunc select_size;
FT_Slot_LoadFunc load_glyph;
=== include/freetype/internal/ftobjs.h
==================================================================
--- include/freetype/internal/ftobjs.h (/freetype2/trunk) (revision 3035)
+++ include/freetype/internal/ftobjs.h (/freetype2/branches/size_selection)
(local)
@@ -451,6 +451,16 @@
/* */
+ /*
+ * Match the size request against `available_sizes'.
+ */
+ FT_BASE( FT_Error )
+ FT_Match_Size( FT_Face face,
+ FT_Size_Request req,
+ FT_Bool ignore_width,
+ FT_ULong* index );
+
+
/*
* Free the bitmap of a given glyphslot when needed
* (i.e., only when it was allocated with ft_glyphslot_alloc_bitmap).
_______________________________________________
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel