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: Mon, 16 Feb 2004 19:38:40 +0100

> > Monotype Courier New from M$'s webfonts, cour.ttf, 302688 bytes, most probably the same font you get from a WindowsNT installation.
> > 
> 
> Hmmm... Seems you need emacs 20.7 to reproduce. Emacs 21.x makes no 
> difference to me, too.
> 
> Another way to see the same problem is to change the font for the 
> playlist in xmms to Monotype Arial (arial.ttf).

  I think that this problem is related to FreeType's additional
"font properties".  Try xfd command,

  xfd -fn "-monotype-courier new-medium-r-normal--13-0-100-100-m-0-iso8859-1"

and check the differences of ascent and descent between "xtt" and 
"freetype".  Perhaps no difference will be seen.  If so, try the
attached patch and set "fp=n" option to fonts.dir:

  fp=n:cour.ttf -monotype-courier new-medium-r-normal--0-0-0-0-m-0-iso8859-1

and would you tell the result?  If "fp=n" is set, the "freetype"
backend does not add the font properties.

------------------------------------------------------------
    Chisato Yamauchi
XFree86-4.3.99.903-libfreetype-xtt2-font-prop.patch (text/plain, 5 KB)
*** xc/lib/font/FreeType.orig/ftfuncs.c	2004-02-17 16:44:59.000000000 +0900
--- xc/lib/font/FreeType/ftfuncs.c	2004-02-17 17:29:33.000000000 +0900
***************
*** 1909,1916 ****
  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 )
  {
      int result = Successful;
      SDynPropRecValList listPropRecVal;
--- 1909,1916 ----
  static int 
  FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
  		    char **dynStrRealFileName, char **dynStrFTFileName,
! 		    struct TTCapInfo *ret, int *face_number, FT_Int32 *load_flags,
! 		    int *spacing, Bool *font_properties, char **dynStrTTCapCodeRange )
  {
      int result = Successful;
      SDynPropRecValList listPropRecVal;
***************
*** 1920,1925 ****
--- 1920,1926 ----
      Bool alwaysEmbeddedBitmap = False;
      int pixel = vals->pixel;
  
+     *font_properties=True;
      *dynStrRealFileName=NULL;
      *dynStrFTFileName=NULL;
      *dynStrTTCapCodeRange=NULL;
***************
*** 2404,2409 ****
--- 2405,2417 ----
          }
      }
  
+     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,2876 ****
      long rawWidth = 0, rawAverageWidth = 0;
      int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
      double scale, base_width, base_height;
!     Bool orig_is_matrix_unit;
      int face_number, ttcap_spacing;
      struct TTCapInfo tmp_ttcap;
      struct TTCapInfo *ins_ttcap;
--- 2878,2884 ----
      long rawWidth = 0, rawAverageWidth = 0;
      int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
      double scale, base_width, base_height;
!     Bool orig_is_matrix_unit, font_properties;
      int face_number, ttcap_spacing;
      struct TTCapInfo tmp_ttcap;
      struct TTCapInfo *ins_ttcap;
***************
*** 2890,2896 ****
  			     &dynStrRealFileName, &dynStrFTFileName,
  			     &tmp_ttcap, &face_number, 
  			     &load_flags, &ttcap_spacing,
! 			     &dynStrTTCapCodeRange);
      if ( xrc != Successful ) {
  	goto quit;
      }
--- 2898,2904 ----
  			     &dynStrRealFileName, &dynStrFTFileName,
  			     &tmp_ttcap, &face_number, 
  			     &load_flags, &ttcap_spacing,
! 			     &font_properties, &dynStrTTCapCodeRange);
      if ( xrc != Successful ) {
  	goto quit;
      }
***************
*** 3347,3353 ****
      if(xf)
          xf->fontPrivate = (void*)font;
    
!     if(info) {
          xrc = FreeTypeAddProperties(font, vals, info, entry->name.name, 
                                      rawAverageWidth);
          if (xrc != Successful) {
--- 3355,3361 ----
      if(xf)
          xf->fontPrivate = (void*)font;
    
!     if(info && font_properties) {
          xrc = FreeTypeAddProperties(font, vals, info, entry->name.name, 
                                      rawAverageWidth);
          if (xrc != Successful) {
*** 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,108 ****
      { "FaceNumber",             eRecTypeString },
      { "AutoItalic",             eRecTypeDouble  },
      { "DoubleStrike",           eRecTypeString  },
!     { "ForceProportional",      eRecTypeBool    },
      { "ForceSpacing",           eRecTypeString  },
      { "ScaleBBoxWidth",         eRecTypeString  },
      { "ScaleWidth",             eRecTypeDouble  },
--- 102,108 ----
      { "FaceNumber",             eRecTypeString },
      { "AutoItalic",             eRecTypeDouble  },
      { "DoubleStrike",           eRecTypeString  },
!     { "FontProperties",         eRecTypeBool    },
      { "ForceSpacing",           eRecTypeString  },
      { "ScaleBBoxWidth",         eRecTypeString  },
      { "ScaleWidth",             eRecTypeDouble  },
***************
*** 126,138 ****
  } 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 */
      { "fs", "ForceSpacing" },
      { "bw", "ScaleBBoxWidth" },
      { "sw", "ScaleWidth" },
--- 126,133 ----
  } const correspondRelations[] = {
      { "fn", "FaceNumber" },
      { "ai", "AutoItalic" },
      { "ds", "DoubleStrike" },
!     { "fp", "FontProperties" },
      { "fs", "ForceSpacing" },
      { "bw", "ScaleBBoxWidth" },
      { "sw", "ScaleWidth" },
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.