Re: freetype module sometimes gets font height (descent?)
Chisato Yamauchi <[email protected]>
| Newsgroups | gmane.comp.xfree86.fonts |
|---|---|
| Message-ID | <[email protected]> |
From: Michael Lampe <[email protected]> Subject: Re: [Fonts] freetype module sometimes gets font height (descent?) Date: Sat, 21 Feb 2004 18:54:14 +0100 > > I cannot reprodeuce them using xedit... Why? How is your > > "resolution" of xdpyinfo. 100x100 dots per inch? > > Manually set to 75 dpi, real value is almost exactly 96 dpi. But this is > not the problem. If I replace '...-100-100-...' in the LFD with > '...-75-75-...' or enforce any other dpi value on the X server or let it > choose its own, it's exactly the same. > > fontpropdump with freetype: Thanks. I've fixed the problem: --- xc/lib/font/FreeType.orig/ftfuncs.c 2004-02-17 16:44:59.000000000 +0900 +++ xc/lib/font/FreeType/ftfuncs.c 2004-02-22 18:06:54.000000000 +0900 @@ -3319,8 +3341,12 @@ /* set info */ if( info ){ + /* info->fontAscent = ascent; info->fontDescent = descent; + */ + info->fontAscent = info->maxbounds.ascent; + info->fontDescent = info->maxbounds.descent; /* Glyph metrics are accurate */ info->inkMetrics=1; > PIXEL_SIZE : 12 > POINT_SIZE : 87 > RESOLUTION_X : 100 > RESOLUTION_Y : 100 > AVERAGE_WIDTH : 70 > RAW_AVERAGE_WIDTH : 6001 > FONT_ASCENT : 12 <<==== > RAW_ASCENT : (none) > FONT_DESCENT : 8 <<==== > RAW_DESCENT : (none) RAW_ASCENT and RAW_DESCENT have disappeared. There are simple bugs in the backend, so I've fixed in attached new patch. > RAW_PIXEL_SIZE : (none) > RAW_POINT_SIZE : (none) The Type1 backend also returns these values. I've added them in the patch. Additionally, in the new patch, "fp=n" TTCap option makes FreeType backend behave like X-TT backend about font properties. ------------------------------------------------------------ Chisato Yamauchi
XFree86-4.3.99.903-libfreetype-xtt2-font-prop.patch
(text/plain, 7.1 KB)
--- xc/lib/font/FreeType.orig/ftfuncs.c 2004-02-17 16:44:59.000000000 +0900
+++ xc/lib/font/FreeType/ftfuncs.c 2004-02-22 18:38:57.000000000 +0900
@@ -1327,7 +1327,7 @@
static int
FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
- char *fontname, int rawAverageWidth)
+ char *fontname, int rawAverageWidth, Bool font_properties)
{
int i, j, maxprops;
char *sp, *ep, val[MAXFONTNAMELEN], *vp;
@@ -1376,9 +1376,11 @@
maxprops=
1 + /* NAME */
(xlfdProps ? 14 : 0) + /* from XLFD */
- 8 +
- (os2 ? 6 : 0) +
- (post || t1info? 3 : 0) +
+ 5 +
+ ( !face->bitmap ? 3 : 0 ) + /* raw_av,raw_asc,raw_dec */
+ ( font_properties ? 2 : 0 ) + /* asc,dec */
+ ( (font_properties && os2) ? 6 : 0 ) +
+ ( (font_properties && (post || t1info)) ? 3 : 0 ) +
2; /* type */
info->props = (FontPropPtr)xalloc(maxprops * sizeof(FontPropRec));
@@ -1444,29 +1446,41 @@
}
}
+ info->props[i].name = MakeAtom("RAW_PIXEL_SIZE", 14, TRUE);
+ info->props[i].value = 1000;
+ i++;
+
+ info->props[i].name = MakeAtom("RAW_POINT_SIZE", 14, TRUE);
+ info->props[i].value = (long)(72270.0 / (double)vals->y + .5);
+ i++;
+
if(!face->bitmap) {
info->props[i].name = MakeAtom("RAW_AVERAGE_WIDTH", 17, TRUE);
info->props[i].value = rawAverageWidth;
i++;
}
- info->props[i].name = MakeAtom("FONT_ASCENT", 11, TRUE);
- info->props[i].value = info->fontAscent;
- i++;
+ if ( font_properties ) {
+ info->props[i].name = MakeAtom("FONT_ASCENT", 11, TRUE);
+ info->props[i].value = info->fontAscent;
+ i++;
+ }
if(!face->bitmap) {
- info->props[i].name = MakeAtom("RAW_ASCENT", 15, TRUE);
+ info->props[i].name = MakeAtom("RAW_ASCENT", 10, TRUE);
info->props[i].value =
((double)face->face->ascender/(double)upm*1000.0);
i++;
}
- info->props[i].name = MakeAtom("FONT_DESCENT", 12, TRUE);
- info->props[i].value = info->fontDescent;
- i++;
+ if ( font_properties ) {
+ info->props[i].name = MakeAtom("FONT_DESCENT", 12, TRUE);
+ info->props[i].value = info->fontDescent;
+ i++;
+ }
if(!face->bitmap) {
- info->props[i].name = MakeAtom("RAW_DESCENT", 16, TRUE);
+ info->props[i].name = MakeAtom("RAW_DESCENT", 11, TRUE);
info->props[i].value =
-((double)face->face->descender/(double)upm*1000.0);
i++;
@@ -1541,7 +1555,7 @@
/* In what follows, we assume the matrix is diagonal. In the rare
case when it is not, the values will be somewhat wrong. */
- if(os2) {
+ if( font_properties && os2 ) {
info->props[i].name = MakeAtom("SUBSCRIPT_SIZE",14,TRUE);
info->props[i].value =
TRANSFORM_FUNITS_Y(os2->ySubscriptYSize);
@@ -1568,7 +1582,7 @@
i++;
}
- if(post || t1info) {
+ if( font_properties && (post || t1info) ) {
int underlinePosition, underlineThickness;
/* Raw underlineposition counts upwards,
@@ -1909,8 +1923,8 @@
static int
FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
char **dynStrRealFileName, char **dynStrFTFileName,
- struct TTCapInfo *ret, int *face_number,
- FT_Int32 *load_flags, int *spacing, char **dynStrTTCapCodeRange )
+ struct TTCapInfo *ret, int *face_number, FT_Int32 *load_flags,
+ int *spacing, Bool *font_properties, char **dynStrTTCapCodeRange )
{
int result = Successful;
SDynPropRecValList listPropRecVal;
@@ -1920,6 +1934,7 @@
Bool alwaysEmbeddedBitmap = False;
int pixel = vals->pixel;
+ *font_properties=True;
*dynStrRealFileName=NULL;
*dynStrFTFileName=NULL;
*dynStrTTCapCodeRange=NULL;
@@ -2404,6 +2419,13 @@
}
}
+ if (SPropRecValList_search_record(&listPropRecVal,
+ &contRecValue,
+ "FontProperties")) {
+ /* Set or Reset the Flag of FontProperties */
+ *font_properties=SPropContainer_value_bool(contRecValue);
+ }
+
ret->force_c_scale_b_box_width *= ret->scaleBBoxWidth;
ret->force_c_scale_b_box_height *= ret->scaleBBoxHeight;
@@ -2870,7 +2892,7 @@
long rawWidth = 0, rawAverageWidth = 0;
int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
double scale, base_width, base_height;
- Bool orig_is_matrix_unit;
+ Bool orig_is_matrix_unit, font_properties;
int face_number, ttcap_spacing;
struct TTCapInfo tmp_ttcap;
struct TTCapInfo *ins_ttcap;
@@ -2890,7 +2912,7 @@
&dynStrRealFileName, &dynStrFTFileName,
&tmp_ttcap, &face_number,
&load_flags, &ttcap_spacing,
- &dynStrTTCapCodeRange);
+ &font_properties, &dynStrTTCapCodeRange);
if ( xrc != Successful ) {
goto quit;
}
@@ -3319,8 +3341,12 @@
/* set info */
if( info ){
+ /*
info->fontAscent = ascent;
info->fontDescent = descent;
+ */
+ info->fontAscent = info->maxbounds.ascent;
+ info->fontDescent = info->maxbounds.descent;
/* Glyph metrics are accurate */
info->inkMetrics=1;
@@ -3349,7 +3375,7 @@
if(info) {
xrc = FreeTypeAddProperties(font, vals, info, entry->name.name,
- rawAverageWidth);
+ rawAverageWidth, font_properties);
if (xrc != Successful) {
goto quit;
}
--- xc/lib/font/FreeType.orig/ftfuncs.h 2004-02-05 18:11:21.000000000 +0900
+++ xc/lib/font/FreeType/ftfuncs.h 2004-02-22 17:14:26.000000000 +0900
@@ -174,8 +174,7 @@
static void FreeTypeUnloadXFont(FontPtr pFont);
static int
FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
- char *fontname,
- int rawAverageWidth);
+ char *fontname, int rawAverageWidth, Bool font_properties);
static int FreeTypeFontGetGlyph(unsigned code, int flags, CharInfoPtr *g, FTFontPtr font);
static int
FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
--- xc/lib/font/FreeType.orig/xttcap.c 2003-10-20 03:53:50.000000000 +0900
+++ xc/lib/font/FreeType/xttcap.c 2004-02-17 17:07:43.000000000 +0900
@@ -102,7 +102,7 @@
{ "FaceNumber", eRecTypeString },
{ "AutoItalic", eRecTypeDouble },
{ "DoubleStrike", eRecTypeString },
- { "ForceProportional", eRecTypeBool },
+ { "FontProperties", eRecTypeBool },
{ "ForceSpacing", eRecTypeString },
{ "ScaleBBoxWidth", eRecTypeString },
{ "ScaleWidth", eRecTypeDouble },
@@ -126,13 +126,8 @@
} const correspondRelations[] = {
{ "fn", "FaceNumber" },
{ "ai", "AutoItalic" },
-#if True /* obsoleted - pointed out by mrt ->->-> */
- { "ab", "DoubleStrike" },
-#endif /* <-<-<- obsoleted */
{ "ds", "DoubleStrike" },
-#if True /* obsoleted ->->-> */
- { "fp", "ForceProportional" },
-#endif /* <-<-<- obsoleted */
+ { "fp", "FontProperties" },
{ "fs", "ForceSpacing" },
{ "bw", "ScaleBBoxWidth" },
{ "sw", "ScaleWidth" },