/[gnustep]/gnustep/core/back/Source/art/ftfont.m
ViewVC logotype

Diff of /gnustep/core/back/Source/art/ftfont.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.43 by alexm, Tue Nov 9 21:22:36 2004 UTC revision 1.44 by alexm, Tue Jan 11 15:02:29 2005 UTC
# Line 1  Line 1 
1  /*  /*
2     Copyright (C) 2002 Free Software Foundation, Inc.     Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3    
4     Author:  Alexander Malmberg <alexander@malmberg.org>     Author:  Alexander Malmberg <alexander@malmberg.org>
5    
# Line 20  Line 20 
20     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */  */
22    
23    
24    #include <ft2build.h>
25    #include FT_FREETYPE_H
26    
27    
28    #if (FREETYPE_MAJOR==2) && ((FREETYPE_MINOR<1) || ((FREETYPE_MINOR==1) && (FREETYPE_PATCH<8)))
29    
30    #include "ftfont-old.m"
31    
32    #else
33    
34    
35  #include <math.h>  #include <math.h>
36    
37  #include <Foundation/NSObject.h>  #include <Foundation/NSObject.h>
# Line 49  Line 61 
61    
62  /** font handling interface **/  /** font handling interface **/
63    
 #include <ft2build.h>  
 #include FT_FREETYPE_H  
64  #include FT_CACHE_H  #include FT_CACHE_H
65    
66  #include FT_CACHE_IMAGE_H  #include FT_CACHE_IMAGE_H
# Line 59  Line 69 
69    
70  #include FT_OUTLINE_H  #include FT_OUTLINE_H
71    
 #if (FREETYPE_MAJOR==2) && ((FREETYPE_MINOR<1) || ((FREETYPE_MINOR==1) && (FREETYPE_PATCH<=2)))  
 #define FT212_STUFF  
 #endif  
   
72    
73  /* TODO: finish screen font handling */  /* TODO: finish screen font handling */
74    
# Line 86  static BOOL anti_alias_by_default; Line 92  static BOOL anti_alias_by_default;
92  @interface FTFontInfo : GSFontInfo <FTFontInfo>  @interface FTFontInfo : GSFontInfo <FTFontInfo>
93  {  {
94  @public  @public
95  #ifdef FT212_STUFF    int pix_width, pix_height;
   FTC_ImageDesc imgd;  
96    
97    FTC_ImageDesc advancementImgd;    FTC_FaceID faceId;
98  #else    FTC_ImageTypeRec imageType;
99    FTC_ImageTypeRec imgd;    FTC_ScalerRec scaler;
100      int unicodeCmap;
   FTC_ImageTypeRec advancementImgd;  
 #endif  
   
   FTFaceInfo *face_info;  
101    
102    BOOL screenFont;    BOOL screenFont;
103    
104    
105      FTFaceInfo *face_info;
106    
107    /*    /*
108    Profiling (2003-11-14) shows that calls to -advancementForGlyph: accounted    Profiling (2003-11-14) shows that calls to -advancementForGlyph: accounted
109    for roughly 20% of layout time. This cache reduces it to (currently)    for roughly 20% of layout time. This cache reduces it to (currently)
# Line 426  static void add_face(NSString *family, i Line 429  static void add_face(NSString *family, i
429    fi->traits = traits;    fi->traits = traits;
430    
431    if ([d objectForKey: @"RenderHints_hack"])    if ([d objectForKey: @"RenderHints_hack"])
432      fi->render_hints_hack=strtol([[d objectForKey: @"RenderHints_hack"] cString],NULL,0);      fi->render_hints_hack
433          = strtol([[d objectForKey: @"RenderHints_hack"] cString], NULL, 0);
434    else    else
435      {      {
436        if (anti_alias_by_default)        if (anti_alias_by_default)
437          fi->render_hints_hack=0x10202;          fi->render_hints_hack = 0x10202;
438        else        else
439          fi->render_hints_hack=0x00202;          fi->render_hints_hack = 0x00202;
440      }      }
441    
442    NSDebugLLog(@"ftfont", @"adding '%@' '%@'", fontName, fi);    NSDebugLLog(@"ftfont", @"adding '%@' '%@'", fontName, fi);
# Line 670  static FT_Error ft_get_face(FTC_FaceID f Line 674  static FT_Error ft_get_face(FTC_FaceID f
674          matrix: (const float *)fmatrix          matrix: (const float *)fmatrix
675          screenFont: (BOOL)p_screenFont          screenFont: (BOOL)p_screenFont
676  {  {
   FT_Face face;  
677    FT_Size size;    FT_Size size;
678    NSArray *rfi;    NSArray *rfi;
679    FTFaceInfo *font_entry;    FTFaceInfo *font_entry;
# Line 710  static FT_Error ft_get_face(FTC_FaceID f Line 713  static FT_Error ft_get_face(FTC_FaceID f
713    familyName = [face_info->familyName copy];    familyName = [face_info->familyName copy];
714    memcpy(matrix, fmatrix, sizeof(matrix));    memcpy(matrix, fmatrix, sizeof(matrix));
715    
716    /* TODO: somehow make gnustep-gui send unicode our way. utf8? ugly, but it works */    /* Using utf8 is a bit ugly, but it works.  Besides, the bulk of the text
717         comes as glyphs anyway.  */
718    mostCompatibleStringEncoding = NSUTF8StringEncoding;    mostCompatibleStringEncoding = NSUTF8StringEncoding;
719    encodingScheme = @"iso10646-1";    encodingScheme = @"iso10646-1";
720    
721    if (screenFont)    if (screenFont)
722      {      {
723        /* Round up; makes the text more legible. */        /* Round up; makes the text more legible.  */
724        matrix[0] = ceil(matrix[0]);        matrix[0] = ceil(matrix[0]);
725        if (matrix[3] < 0.0)        if (matrix[3] < 0.0)
726          matrix[3] = floor(matrix[3]);          matrix[3] = floor(matrix[3]);
# Line 724  static FT_Error ft_get_face(FTC_FaceID f Line 728  static FT_Error ft_get_face(FTC_FaceID f
728          matrix[3] = ceil(matrix[3]);          matrix[3] = ceil(matrix[3]);
729      }      }
730    
731    imgd.font.pix_width = fabs(matrix[0]);    pix_width = fabs(matrix[0]);
732    imgd.font.pix_height = fabs(matrix[3]);    pix_height = fabs(matrix[3]);
733    
734    rfi = font_entry->files;    rfi = font_entry->files;
735    if (screenFont && font_entry->num_sizes &&    if (screenFont && font_entry->num_sizes &&
736        imgd.font.pix_width == imgd.font.pix_height)        pix_width == pix_height)
737      {      {
738        int i;        int i;
739        for (i = 0; i < font_entry->num_sizes; i++)        for (i = 0; i < font_entry->num_sizes; i++)
740          {          {
741            if (font_entry->sizes[i].pixel_size == imgd.font.pix_width)            if (font_entry->sizes[i].pixel_size == pix_width)
742              {              {
743                rfi = font_entry->sizes[i].files;                rfi = font_entry->sizes[i].files;
744                break;                break;
# Line 742  static FT_Error ft_get_face(FTC_FaceID f Line 746  static FT_Error ft_get_face(FTC_FaceID f
746          }          }
747      }      }
748    
749    imgd.font.face_id = (FTC_FaceID)rfi;    faceId = (FTC_FaceID)rfi;
750    
751    if ((error=FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, &size)))    imageType.face_id = faceId;
752      imageType.width = pix_width;
753      imageType.height = pix_height;
754      /* TODO: Flags? */
755    
756      scaler.face_id = faceId;
757      scaler.width = pix_width;
758      scaler.height = pix_height;
759      scaler.pixel = 1;
760      
761      if ((error = FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
762      {      {
763        NSLog(@"FTC_Manager_Lookup_Size() failed for '%@', error %08x!\n", name, error);        NSLog(@"FTC_Manager_LookupSize() failed for '%@', error %08x!\n", name, error);
764        return self;        return self;
765      }      }
766    
# Line 769  static FT_Error ft_get_face(FTC_FaceID f Line 783  static FT_Error ft_get_face(FTC_FaceID f
783                  fontBBox.size.width, fontBBox.size.height);*/                  fontBBox.size.width, fontBBox.size.height);*/
784    
785    {    {
786      FTC_CMapDescRec cmap;      int i;
787      cmap.face_id = imgd.font.face_id;      FT_Face face = size->face;
788      cmap.u.encoding = ft_encoding_unicode;      FT_CharMap cmap;
789      cmap.type = FTC_CMAP_BY_ENCODING;      FT_Encoding e;
790      ligature_ff = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb00);      unicodeCmap = 0;
791      ligature_fi = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb01);      for (i = 0; i < face->num_charmaps; i++)
792      ligature_fl = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb02);        {
793      ligature_ffi = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb03);          cmap = face->charmaps[i];
794      ligature_ffl = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb04);          e = cmap->encoding;
795            if (e == FT_ENCODING_UNICODE)
796              {
797                unicodeCmap = i;
798                break;
799              }
800          }
801      }
802      {
803        ligature_ff = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb00);
804        ligature_fi = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap,  0xfb01);
805        ligature_fl = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb02);
806        ligature_ffi = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb03);
807        ligature_ffl = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, 0xfb04);
808  /*    printf("ligatures %04x %04x %04x %04x %04x | %02x %02x %02x for |%@|\n",  /*    printf("ligatures %04x %04x %04x %04x %04x | %02x %02x %02x for |%@|\n",
809        ligature_ff,ligature_fi,ligature_fl,ligature_ffi,ligature_ffl,        ligature_ff,ligature_fi,ligature_fl,ligature_ffi,ligature_ffl,
810        FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 'f'),        FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 'f'),
# Line 786  static FT_Error ft_get_face(FTC_FaceID f Line 813  static FT_Error ft_get_face(FTC_FaceID f
813        fontName);*/        fontName);*/
814    }    }
815    
816      if (screenFont)
817      {      {
818        float xx, yy;        int flags;
819  #ifdef FT212_STUFF        if (pix_width == pix_height && pix_width < 16 && pix_height >= 8)
820        FTC_ImageDesc cur;          {
821  #else            int rh = face_info->render_hints_hack;
822        FTC_ImageTypeRec cur;            if (rh & 0x10000)
823  #endif              {
824                  flags = FT_LOAD_TARGET_NORMAL;
825        cur = imgd;                rh = (rh >> 8) & 0xff;
826                }
827        xx = matrix[0];            else
828        yy = matrix[3];              {
829                  flags = FT_LOAD_TARGET_MONO;
830          if (xx == yy && xx < 16 && xx >= 8)                rh = rh & 0xff;
831            {              }
832              int rh = face_info->render_hints_hack;            if (rh & 1)
833              if (rh & 0x10000)              flags |= FT_LOAD_FORCE_AUTOHINT;
834                {            if (!(rh & 2))
835  #ifdef FT212_STUFF              flags |= FT_LOAD_NO_HINTING;
836                  cur.type = ftc_image_grays;          }
837  #else        else if (pix_width < 8)
838                  cur.flags = FT_LOAD_TARGET_NORMAL;          flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;
839  #endif        else
840                  rh = (rh >> 8) & 0xff;          flags = FT_LOAD_TARGET_NORMAL;
841                }        imageType.flags = flags;
842              else      }
843                {    else
844  #ifdef FT212_STUFF      {
845                  cur.type = ftc_image_mono;        imageType.flags = FT_LOAD_NO_HINTING;
 #else  
                 cur.flags = FT_LOAD_TARGET_MONO;  
 #endif  
                 rh = rh & 0xff;  
               }  
             if (rh & 1)  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_autohinted;  
 #else  
               cur.flags |= FT_LOAD_FORCE_AUTOHINT;  
 #endif  
             if (!(rh & 2))  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_unhinted;  
 #else  
               cur.flags |= FT_LOAD_NO_HINTING;  
 #endif  
           }  
         else if (xx < 8)  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays | ftc_image_flag_unhinted;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;  
 #endif  
         else  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
       advancementImgd = cur;  
846      }      }
847    
848    /*    /*
# Line 896  static FT_Error ft_get_face(FTC_FaceID f Line 893  static FT_Error ft_get_face(FTC_FaceID f
893          transform: (NSAffineTransform *)transform          transform: (NSAffineTransform *)transform
894          drawinfo: (draw_info_t *)di          drawinfo: (draw_info_t *)di
895  {  {
 #if 0  
   NSLog(@"ignoring drawString");  
 #else  
896    const unsigned char *c;    const unsigned char *c;
897    unsigned char ch;    unsigned char ch;
898    unsigned int uch;    unsigned int uch;
899    
   FTC_CMapDescRec cmap;  
900    unsigned int glyph;    unsigned int glyph;
901    
902    int use_sbit;    int use_sbit;
903    
904    FTC_SBit sbit;    FTC_SBit sbit;
 #ifdef FT212_STUFF  
   FTC_ImageDesc cur;  
 #else  
   FTC_ImageTypeRec cur;  
 #endif  
905    
906    FT_Matrix ftmatrix;    FT_Matrix ftmatrix;
907    FT_Vector ftdelta;    FT_Vector ftdelta;
# Line 940  static FT_Error ft_get_face(FTC_FaceID f Line 928  static FT_Error ft_get_face(FTC_FaceID f
928                  transform                  transform
929                  );*/                  );*/
930    
   cur = imgd;  
931    {    {
932      float xx, xy, yx, yy;      float xx, xy, yx, yy;
933    
# Line 957  static FT_Error ft_get_face(FTC_FaceID f Line 944  static FT_Error ft_get_face(FTC_FaceID f
944          xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)          xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
945        {        {
946          use_sbit = 1;          use_sbit = 1;
         cur.font.pix_width = xx;  
         cur.font.pix_height = yy;  
   
         if (xx == yy && xx < 16 && xx >= 8)  
           {  
             int rh = face_info->render_hints_hack;  
             if (rh & 0x10000)  
               {  
 #ifdef FT212_STUFF  
                 cur.type = ftc_image_grays;  
 #else  
                 cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
                 rh = (rh >> 8) & 0xff;  
               }  
             else  
               {  
 #ifdef FT212_STUFF  
                 cur.type = ftc_image_mono;  
 #else  
                 cur.flags = FT_LOAD_TARGET_MONO;  
 #endif  
                 rh = rh & 0xff;  
               }  
             if (rh & 1)  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_autohinted;  
 #else  
               cur.flags |= FT_LOAD_FORCE_AUTOHINT;  
 #endif  
             if (!(rh & 2))  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_unhinted;  
 #else  
               cur.flags |= FT_LOAD_NO_HINTING;  
 #endif  
           }  
         else if (xx < 8)  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays | ftc_image_flag_unhinted;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;  
 #endif  
         else  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
947        }        }
948      else      else
949        {        {
950          float f;          float f;
951          use_sbit = 0;          use_sbit = 0;
952    
953          f = fabs(xx * yy - xy * yx);          /* TODO: Think hard about this.  Fancy truetype magic can
954               significantly change the outline, e.g. by adding fancy adornments
955               at large sizes.  If the font is then scaled down, we should
956               probably set the font size to the original size and scale down
957               using the matrix.  This ensures that adornments and such are
958               still present, just scaled down.
959    
960               This is somewhat complicated by the fact that we don't have any
961               real size, just a matrix.  Thus, we average pix_width and
962               pix_height; we'll get the right answer for normal cases, and
963               we can't really do anything about the weird cases.  */
964            f = fabs(pix_width) + fabs(pix_height);
965          if (f > 1)          if (f > 1)
966            f = sqrt(f);            f = f / 2.0;
967          else          else
968            f = 1.0;            f = 1.0;
   
969          f = (int)f;          f = (int)f;
970    
971          cur.font.pix_width = cur.font.pix_height = f;          scaler.width = scaler.height = f;
972          ftmatrix.xx = xx / f * 65536.0;          ftmatrix.xx = xx / f * 65536.0;
973          ftmatrix.xy = xy / f * 65536.0;          ftmatrix.xy = xy / f * 65536.0;
974          ftmatrix.yx = yx / f * 65536.0;          ftmatrix.yx = yx / f * 65536.0;
# Line 1033  static FT_Error ft_get_face(FTC_FaceID f Line 981  static FT_Error ft_get_face(FTC_FaceID f
981  /*      NSLog(@"drawString: '%s' at: %i:%i  to: %i:%i:%i:%i:%p\n",  /*      NSLog(@"drawString: '%s' at: %i:%i  to: %i:%i:%i:%i:%p\n",
982                  s, x, y, x0, y0, x1, y1, buf);*/                  s, x, y, x0, y0, x1, y1, buf);*/
983    
   cmap.face_id = imgd.font.face_id;  
   cmap.u.encoding = ft_encoding_unicode;  
   cmap.type = FTC_CMAP_BY_ENCODING;  
   
984    for (c = s; *c; c++)    for (c = s; *c; c++)
985      {      {
986  /* TODO: do the same thing in outlineString:... */  /* TODO: do the same thing in outlineString:... */
# Line 1091  static FT_Error ft_get_face(FTC_FaceID f Line 1035  static FT_Error ft_get_face(FTC_FaceID f
1035          uch = 0xfffd;          uch = 0xfffd;
1036  #undef ADD_UTF_BYTE  #undef ADD_UTF_BYTE
1037    
1038        glyph = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, uch);        glyph = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, uch);
       cur.font.face_id = imgd.font.face_id;  
1039    
1040        if (use_sbit)        if (use_sbit)
1041          {          {
1042            if ((error=FTC_SBitCache_Lookup(ftc_sbitcache, &cur, glyph, &sbit, NULL)))            if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
1043              {              {
1044                NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",                NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
1045                  error, glyph, cur.font.face_id, cur.font.pix_width, cur.font.pix_height,                  error, glyph, imageType.face_id, imageType.width, imageType.height,
1046  #ifdef FT212_STUFF                  imageType.flags);
                 cur.type  
 #else  
                 cur.flags  
 #endif  
                 );  
1047                continue;                continue;
1048              }              }
1049    
# Line 1226  static FT_Error ft_get_face(FTC_FaceID f Line 1164  static FT_Error ft_get_face(FTC_FaceID f
1164          {          {
1165            FT_Face face;            FT_Face face;
1166            FT_Glyph gl;            FT_Glyph gl;
1167              FT_Size size;
1168            FT_BitmapGlyph gb;            FT_BitmapGlyph gb;
1169    
1170            if ((error=FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0)))            if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
1171              {              {
1172                NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);                NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);
1173                continue;                continue;
1174              }              }
1175              face = size->face;
1176    
1177            /* TODO: for rotations of 90, 180, 270, and integer            /* TODO: for screen fonts we should probably still hint */
              scales hinting might still be a good idea. */  
1178            if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))            if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
1179              {              {
1180                NSLog(@"FT_Load_Glyph() failed with error %08x\n",error);                NSLog(@"FT_Load_Glyph() failed with error %08x\n",error);
# Line 1332  static FT_Error ft_get_face(FTC_FaceID f Line 1271  static FT_Error ft_get_face(FTC_FaceID f
1271            FT_Done_Glyph(gl);            FT_Done_Glyph(gl);
1272          }          }
1273      }      }
   
 #endif  
1274  }  }
1275    
1276    
# Line 1351  static FT_Error ft_get_face(FTC_FaceID f Line 1288  static FT_Error ft_get_face(FTC_FaceID f
1288    int use_sbit;    int use_sbit;
1289    
1290    FTC_SBit sbit;    FTC_SBit sbit;
 #ifdef FT212_STUFF  
   FTC_ImageDesc cur;  
 #else  
   FTC_ImageTypeRec cur;  
 #endif  
1291    
1292    FT_Matrix ftmatrix;    FT_Matrix ftmatrix;
1293    FT_Vector ftdelta;    FT_Vector ftdelta;
# Line 1382  static FT_Error ft_get_face(FTC_FaceID f Line 1314  static FT_Error ft_get_face(FTC_FaceID f
1314                  transform                  transform
1315                  );*/                  );*/
1316    
   cur = imgd;  
1317    {    {
1318      float xx, xy, yx, yy;      float xx, xy, yx, yy;
1319    
# Line 1399  static FT_Error ft_get_face(FTC_FaceID f Line 1330  static FT_Error ft_get_face(FTC_FaceID f
1330          xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)          xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
1331        {        {
1332          use_sbit = 1;          use_sbit = 1;
         cur.font.pix_width = xx;  
         cur.font.pix_height = yy;  
   
         if (xx == yy && xx < 16 && xx >= 8)  
           {  
             int rh = face_info->render_hints_hack;  
             if (rh & 0x10000)  
               {  
 #ifdef FT212_STUFF  
                 cur.type = ftc_image_grays;  
 #else  
                 cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
                 rh = (rh >> 8) & 0xff;  
               }  
             else  
               {  
 #ifdef FT212_STUFF  
                 cur.type = ftc_image_mono;  
 #else  
                 cur.flags = FT_LOAD_TARGET_MONO;  
 #endif  
                 rh = rh & 0xff;  
               }  
             if (rh & 1)  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_autohinted;  
 #else  
               cur.flags |= FT_LOAD_FORCE_AUTOHINT;  
 #endif  
             if (!(rh & 2))  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_unhinted;  
 #else  
               cur.flags |= FT_LOAD_NO_HINTING;  
 #endif  
           }  
         else if (xx < 8)  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays | ftc_image_flag_unhinted;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;  
 #endif  
         else  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
1333        }        }
1334      else      else
1335        {        {
1336          float f;          float f;
1337          use_sbit = 0;          use_sbit = 0;
1338    
1339          f = fabs(xx * yy - xy * yx);          f = fabs(pix_width) + fabs(pix_height);
1340          if (f > 1)          if (f > 1)
1341            f = sqrt(f);            f = f / 2.0;
1342          else          else
1343            f = 1.0;            f = 1.0;
   
1344          f = (int)f;          f = (int)f;
1345    
1346          cur.font.pix_width = cur.font.pix_height = f;          scaler.width = scaler.height = f;
1347          ftmatrix.xx = xx / f * 65536.0;          ftmatrix.xx = xx / f * 65536.0;
1348          ftmatrix.xy = xy / f * 65536.0;          ftmatrix.xy = xy / f * 65536.0;
1349          ftmatrix.yx = yx / f * 65536.0;          ftmatrix.yx = yx / f * 65536.0;
# Line 1471  static FT_Error ft_get_face(FTC_FaceID f Line 1352  static FT_Error ft_get_face(FTC_FaceID f
1352        }        }
1353    }    }
1354    
1355  /*      NSLog(@"drawString: '%s' at: %i:%i  to: %i:%i:%i:%i:%p\n",  /*      NSLog(@"drawGlyphs: '%p' at: %i:%i  to: %i:%i:%i:%i:%p\n",
1356                  s, x, y, x0, y0, x1, y1, buf);*/                  glyphs, x, y, x0, y0, x1, y1, buf);*/
1357    
1358    for (; length; length--, glyphs++)    for (; length; length--, glyphs++)
1359      {      {
# Line 1480  static FT_Error ft_get_face(FTC_FaceID f Line 1361  static FT_Error ft_get_face(FTC_FaceID f
1361    
1362        if (use_sbit)        if (use_sbit)
1363          {          {
1364            if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &cur, glyph, &sbit, NULL)))            if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
1365              {              {
1366                NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",                NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
1367                  error, glyph, cur.font.face_id, cur.font.pix_width, cur.font.pix_height,                  error, glyph, imageType.face_id, imageType.width, imageType.height,
1368  #ifdef FT212_STUFF                  imageType.flags
                 cur.type  
 #else  
                 cur.flags  
 #endif  
1369                  );                  );
1370                continue;                continue;
1371              }              }
# Line 1609  static FT_Error ft_get_face(FTC_FaceID f Line 1486  static FT_Error ft_get_face(FTC_FaceID f
1486        else        else
1487          {          {
1488            FT_Face face;            FT_Face face;
1489              FT_Size size;
1490            FT_Glyph gl;            FT_Glyph gl;
1491            FT_BitmapGlyph gb;            FT_BitmapGlyph gb;
1492    
1493            if ((error=FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0)))            if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
1494              {              {
1495                NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);                NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);
1496                continue;                continue;
1497              }              }
1498              face = size->face;
1499    
1500            /* TODO: for rotations of 90, 180, 270, and integer            /* TODO: for screen fonts ...see above... rotations of 90, 180, 270, and integer
1501               scales hinting might still be a good idea. */               scales hinting might still be a good idea. */
1502            if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))            if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
1503              {              {
# Line 1725  static FT_Error ft_get_face(FTC_FaceID f Line 1604  static FT_Error ft_get_face(FTC_FaceID f
1604    int use_sbit;    int use_sbit;
1605    
1606    FTC_SBit sbit;    FTC_SBit sbit;
 #ifdef FT212_STUFF  
   FTC_ImageDesc cur;  
 #else  
   FTC_ImageTypeRec cur;  
 #endif  
1607    
1608    FT_Matrix ftmatrix;    FT_Matrix ftmatrix;
1609    FT_Vector ftdelta;    FT_Vector ftdelta;
# Line 1756  static FT_Error ft_get_face(FTC_FaceID f Line 1630  static FT_Error ft_get_face(FTC_FaceID f
1630                  transform                  transform
1631                  );*/                  );*/
1632    
   cur = imgd;  
1633    {    {
1634      float xx, xy, yx, yy;      float xx, xy, yx, yy;
1635    
# Line 1773  static FT_Error ft_get_face(FTC_FaceID f Line 1646  static FT_Error ft_get_face(FTC_FaceID f
1646          xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)          xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5)
1647        {        {
1648          use_sbit = 1;          use_sbit = 1;
         cur.font.pix_width = xx;  
         cur.font.pix_height = yy;  
   
         if (xx == yy && xx < 16 && xx >= 8)  
           {  
             int rh = face_info->render_hints_hack;  
             if (rh & 0x10000)  
               {  
 #ifdef FT212_STUFF  
                 cur.type = ftc_image_grays;  
 #else  
                 cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
                 rh = (rh >> 8) & 0xff;  
               }  
             else  
               {  
 #ifdef FT212_STUFF  
                 cur.type = ftc_image_mono;  
 #else  
                 cur.flags = FT_LOAD_TARGET_MONO;  
 #endif  
                 rh = rh & 0xff;  
               }  
             if (rh & 1)  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_autohinted;  
 #else  
               cur.flags |= FT_LOAD_FORCE_AUTOHINT;  
 #endif  
             if (!(rh & 2))  
 #ifdef FT212_STUFF  
               cur.type |= ftc_image_flag_unhinted;  
 #else  
               cur.flags |= FT_LOAD_NO_HINTING;  
 #endif  
           }  
         else if (xx < 8)  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays | ftc_image_flag_unhinted;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;  
 #endif  
         else  
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays;  
 #else  
           cur.flags = FT_LOAD_TARGET_NORMAL;  
 #endif  
1649        }        }
1650      else      else
1651        {        {
1652          float f;          float f;
1653          use_sbit = 0;          use_sbit = 0;
1654    
1655          f = fabs(xx * yy - xy * yx);          f = fabs(pix_width) + fabs(pix_height);
1656          if (f > 1)          if (f > 1)
1657            f = sqrt(f);            f = f / 2.0;
1658          else          else
1659            f = 1.0;            f = 1.0;
   
1660          f = (int)f;          f = (int)f;
1661    
1662          cur.font.pix_width = cur.font.pix_height = f;          scaler.width = scaler.height = f;
1663          ftmatrix.xx = xx / f * 65536.0;          ftmatrix.xx = xx / f * 65536.0;
1664          ftmatrix.xy = xy / f * 65536.0;          ftmatrix.xy = xy / f * 65536.0;
1665          ftmatrix.yx = yx / f * 65536.0;          ftmatrix.yx = yx / f * 65536.0;
# Line 1854  static FT_Error ft_get_face(FTC_FaceID f Line 1677  static FT_Error ft_get_face(FTC_FaceID f
1677    
1678        if (use_sbit)        if (use_sbit)
1679          {          {
1680            if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &cur, glyph, &sbit, NULL)))            if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
1681              {              {
1682                if (glyph != 0xffffffff)                if (glyph != 0xffffffff)
1683                  NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",                  NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
1684                    error, glyph, cur.font.face_id, cur.font.pix_width, cur.font.pix_height,                    error, glyph, imageType.face_id, imageType.width, imageType.height,
1685  #ifdef FT212_STUFF                    imageType.flags
                   cur.type  
 #else  
                   cur.flags  
 #endif  
1686                    );                    );
1687                continue;                continue;
1688              }              }
# Line 1982  static FT_Error ft_get_face(FTC_FaceID f Line 1801  static FT_Error ft_get_face(FTC_FaceID f
1801        else        else
1802          {          {
1803            FT_Face face;            FT_Face face;
1804              FT_Size size;
1805            FT_Glyph gl;            FT_Glyph gl;
1806            FT_BitmapGlyph gb;            FT_BitmapGlyph gb;
1807    
1808            if ((error=FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0)))            if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
1809              {              {
1810                NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);                NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error);
1811                continue;                continue;
1812              }              }
1813              face = size->face;
1814    
1815            /* TODO: for rotations of 90, 180, 270, and integer            /* TODO: for screen fonts, see above, etc., rotations of 90, 180, 270, and integer
1816               scales hinting might still be a good idea. */               scales hinting might still be a good idea. */
1817            if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))            if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)))
1818              {              {
# Line 2086  static FT_Error ft_get_face(FTC_FaceID f Line 1907  static FT_Error ft_get_face(FTC_FaceID f
1907  -(BOOL) glyphIsEncoded: (NSGlyph)glyph  -(BOOL) glyphIsEncoded: (NSGlyph)glyph
1908  {  {
1909    FT_Face face;    FT_Face face;
1910      FT_Size size;
1911    FT_Error error;    FT_Error error;
1912    
1913    glyph--;    glyph--;
1914    if ((error=FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0)))    if ((error=FTC_Manager_LookupSize(ftc_manager, &scaler, &size)))
1915      {      {
1916        NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x",error);        NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x",error);
1917        return NO;        return NO;
1918      }      }
1919      face = size->face;
1920    
1921    if ((error=FT_Load_Glyph(face, glyph, 0)))    if ((error=FT_Load_Glyph(face, glyph, 0)))
1922      {      {
# Line 2123  static FT_Error ft_get_face(FTC_FaceID f Line 1946  static FT_Error ft_get_face(FTC_FaceID f
1946        if (cachedGlyph[entry] == glyph)        if (cachedGlyph[entry] == glyph)
1947          return cachedSize[entry];          return cachedSize[entry];
1948    
1949        if ((error=FTC_SBitCache_Lookup(ftc_sbitcache, &advancementImgd, glyph, &sbit, NULL)))        if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL)))
1950          {          {
1951            NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",            NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n",
1952              error, glyph, advancementImgd.font.face_id,              error, glyph, imageType.face_id,
1953              advancementImgd.font.pix_width, advancementImgd.font.pix_height,              imageType.width, imageType.height,
1954  #ifdef FT212_STUFF              imageType.flags
             advancementImgd.type  
 #else  
             advancementImgd.flags  
 #endif  
1955              );              );
1956            return NSZeroSize;            return NSZeroSize;
1957          }          }
# Line 2144  static FT_Error ft_get_face(FTC_FaceID f Line 1963  static FT_Error ft_get_face(FTC_FaceID f
1963    else    else
1964      {      {
1965        FT_Face face;        FT_Face face;
1966          FT_Size size;
1967        FT_Glyph gl;        FT_Glyph gl;
1968        FT_Matrix ftmatrix;        FT_Matrix ftmatrix;
1969        FT_Vector ftdelta;        FT_Vector ftdelta;
# Line 2158  static FT_Error ft_get_face(FTC_FaceID f Line 1978  static FT_Error ft_get_face(FTC_FaceID f
1978    
1979        f = (int)f;        f = (int)f;
1980    
1981          /* TODO? scalers and stuff, need to review */
1982        ftmatrix.xx = matrix[0] / f * 65536.0;        ftmatrix.xx = matrix[0] / f * 65536.0;
1983        ftmatrix.xy = matrix[1] / f * 65536.0;        ftmatrix.xy = matrix[1] / f * 65536.0;
1984        ftmatrix.yx = matrix[2] / f * 65536.0;        ftmatrix.yx = matrix[2] / f * 65536.0;
1985        ftmatrix.yy = matrix[3] / f * 65536.0;        ftmatrix.yy = matrix[3] / f * 65536.0;
1986        ftdelta.x = ftdelta.y = 0;        ftdelta.x = ftdelta.y = 0;
1987    
1988        if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0))        if (FTC_Manager_LookupSize(ftc_manager, &scaler, &size))
1989          return NSZeroSize;          return NSZeroSize;
1990          face = size->face;
1991    
1992        if (FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP))        if (FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP))
1993          return NSZeroSize;          return NSZeroSize;
# Line 2186  static FT_Error ft_get_face(FTC_FaceID f Line 2008  static FT_Error ft_get_face(FTC_FaceID f
2008    
2009  - (NSRect) boundingRectForGlyph: (NSGlyph)glyph  - (NSRect) boundingRectForGlyph: (NSGlyph)glyph
2010  {  {
 #ifdef FT212_STUFF  
   FTC_ImageDesc *cur;  
 #else  
   FTC_ImageTypeRec *cur;  
 #endif  
2011    FT_BBox bbox;    FT_BBox bbox;
2012    FT_Glyph g;    FT_Glyph g;
2013    FT_Error error;    FT_Error error;
2014    
2015    glyph--;    glyph--;
2016  /* TODO: this is ugly */  /* TODO: this is ugly */
2017    cur = &imgd;    if ((error=FTC_ImageCache_Lookup(ftc_imagecache, &imageType, glyph, &g, NULL)))
   if ((error=FTC_ImageCache_Lookup(ftc_imagecache, cur, glyph, &g, NULL)))  
2018      {      {
2019        NSLog(@"FTC_ImageCache_Lookup() failed with error %08x",error);        NSLog(@"FTC_ImageCache_Lookup() failed with error %08x",error);
2020  //              NSLog(@"boundingRectForGlyph: %04x -> %i\n", aGlyph, glyph);  //              NSLog(@"boundingRectForGlyph: %04x -> %i\n", aGlyph, glyph);
# Line 2220  static FT_Error ft_get_face(FTC_FaceID f Line 2036  static FT_Error ft_get_face(FTC_FaceID f
2036  {  {
2037    NSPoint a;    NSPoint a;
2038    FT_Face face;    FT_Face face;
2039      FT_Size size;
2040    FT_Vector vec;    FT_Vector vec;
2041    FT_GlyphSlot glyph;    FT_GlyphSlot glyph;
2042    
# Line 2232  static FT_Error ft_get_face(FTC_FaceID f Line 2049  static FT_Error ft_get_face(FTC_FaceID f
2049    g--;    g--;
2050    prev--;    prev--;
2051    
2052    if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0))    if (FTC_Manager_LookupSize(ftc_manager, &scaler, &size))
2053      return NSZeroPoint;      return NSZeroPoint;
2054      face = size->face;
2055    
2056    if (FT_Load_Glyph(face, prev, FT_LOAD_DEFAULT))    if (FT_Load_Glyph(face, prev, FT_LOAD_DEFAULT))
2057      return NSZeroPoint;      return NSZeroPoint;
# Line 2262  static FT_Error ft_get_face(FTC_FaceID f Line 2080  static FT_Error ft_get_face(FTC_FaceID f
2080    int i, c = [string length];    int i, c = [string length];
2081    int total;    int total;
2082    
   FTC_CMapDescRec cmap;  
2083    unsigned int glyph;    unsigned int glyph;
2084    
2085    FTC_SBit sbit;    FTC_SBit sbit;
2086    
 #ifdef FT212_STUFF  
   FTC_ImageDesc *cur;  
 #else  
   FTC_ImageTypeRec *cur;  
 #endif  
   
   
   cmap.face_id = imgd.font.face_id;  
   cmap.u.encoding = ft_encoding_unicode;  
   cmap.type = FTC_CMAP_BY_ENCODING;  
2087    
2088    total = 0;    total = 0;
2089    for (i = 0; i < c; i++)    for (i = 0; i < c; i++)
2090      {      {
2091        ch = [string characterAtIndex: i];        ch = [string characterAtIndex: i];
2092        cur = &imgd;        glyph = FTC_CMapCache_Lookup(ftc_cmapcache, faceId, unicodeCmap, ch);
       glyph = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, ch);  
2093    
2094        /* TODO: shouldn't use sbit cache for this */        /* TODO: shouldn't use sbit cache for this */
2095        if (1)        if (1)
2096          {          {
2097            if (FTC_SBitCache_Lookup(ftc_sbitcache, cur, glyph, &sbit, NULL))            if (FTC_SBitCache_Lookup(ftc_sbitcache, &imageType, glyph, &sbit, NULL))
2098              continue;              continue;
2099    
2100            total += sbit->xadvance;            total += sbit->xadvance;
# Line 2305  static FT_Error ft_get_face(FTC_FaceID f Line 2111  static FT_Error ft_get_face(FTC_FaceID f
2111  -(NSGlyph) glyphWithName: (NSString *)glyphName  -(NSGlyph) glyphWithName: (NSString *)glyphName
2112  {  {
2113    FT_Face face;    FT_Face face;
2114      FT_Size size;
2115    NSGlyph g;    NSGlyph g;
2116    
2117    if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0))    if (FTC_Manager_LookupSize(ftc_manager, &scaler, &size))
2118      return NSNullGlyph;      return NSNullGlyph;
2119      face = size->face;
2120    
2121    g = FT_Get_Name_Index(face, (FT_String *)[glyphName lossyCString]);    g = FT_Get_Name_Index(face, (FT_String *)[glyphName lossyCString]);
2122    if (g)    if (g)
# Line 2546  add code to avoid loading bitmaps for gl Line 2354  add code to avoid loading bitmaps for gl
2354                     at: (float)x : (float)y                     at: (float)x : (float)y
2355                 gstate: (void *)func_param                 gstate: (void *)func_param
2356  {  {
2357    #if 0
2358    unichar *c;    unichar *c;
2359    int i;    int i;
2360    FTC_CMapDescRec cmap;    FTC_CMapDescRec cmap;
# Line 2554  add code to avoid loading bitmaps for gl Line 2363  add code to avoid loading bitmaps for gl
2363    unichar *uch;    unichar *uch;
2364    int ulen;    int ulen;
2365    
 #ifdef FT212_STUFF  
   FTC_ImageDesc cur;  
 #else  
2366    FTC_ImageTypeRec cur;    FTC_ImageTypeRec cur;
 #endif  
2367    
2368    
2369    FT_Matrix ftmatrix;    FT_Matrix ftmatrix;
# Line 2622  add code to avoid loading bitmaps for gl Line 2427  add code to avoid loading bitmaps for gl
2427      }      }
2428    
2429    free(uch);    free(uch);
2430    #endif
2431  }  }
2432    
2433    
# Line 2629  add code to avoid loading bitmaps for gl Line 2435  add code to avoid loading bitmaps for gl
2435                               count: (int)count                               count: (int)count
2436                        toBezierPath: (NSBezierPath *)path                        toBezierPath: (NSBezierPath *)path
2437  {  {
2438    #if 0
2439    int i;    int i;
2440    NSGlyph glyph;    NSGlyph glyph;
2441    
# Line 2679  add code to avoid loading bitmaps for gl Line 2486  add code to avoid loading bitmaps for gl
2486      {      {
2487        [path moveToPoint: NSMakePoint(ftdelta.x / 64.0, ftdelta.y / 64.0)];        [path moveToPoint: NSMakePoint(ftdelta.x / 64.0, ftdelta.y / 64.0)];
2488      }      }
2489    #endif
2490  }  }
2491    
2492    
# Line 2770  static int filters[3][7]= Line 2578  static int filters[3][7]=
2578  /* TODO: this whole thing needs cleaning up */  /* TODO: this whole thing needs cleaning up */
2579  @implementation FTFontInfo_subpixel  @implementation FTFontInfo_subpixel
2580    
2581    #if 0
2582  -(void) drawGlyphs: (const NSGlyph *)glyphs : (int)length  -(void) drawGlyphs: (const NSGlyph *)glyphs : (int)length
2583          at: (int)x : (int)y          at: (int)x : (int)y
2584          to: (int)x0 : (int)y0 : (int)x1 : (int)y1          to: (int)x0 : (int)y0 : (int)x1 : (int)y1
# Line 2785  static int filters[3][7]= Line 2594  static int filters[3][7]=
2594    int use_sbit;    int use_sbit;
2595    
2596    FTC_SBit sbit;    FTC_SBit sbit;
 #ifdef FT212_STUFF  
   FTC_ImageDesc cur;  
 #else  
2597    FTC_ImageTypeRec cur;    FTC_ImageTypeRec cur;
 #endif  
2598    
2599    FT_Matrix ftmatrix;    FT_Matrix ftmatrix;
2600    FT_Vector ftdelta;    FT_Vector ftdelta;
# Line 2837  static int filters[3][7]= Line 2642  static int filters[3][7]=
2642              cur.font.pix_width > 6 && cur.font.pix_height > 6)              cur.font.pix_width > 6 && cur.font.pix_height > 6)
2643            cur.type = ftc_image_mono;            cur.type = ftc_image_mono;
2644          else*/          else*/
 #ifdef FT212_STUFF  
           cur.type = ftc_image_grays, subpixel = YES, cur.font.pix_width *= 3, x *= 3;  
 #else  
2645            cur.flags = FT_LOAD_TARGET_LCD, subpixel = YES;            cur.flags = FT_LOAD_TARGET_LCD, subpixel = YES;
 #endif  
2646  //                      imgd.type|=|ftc_image_flag_unhinted; /* TODO? when? */  //                      imgd.type|=|ftc_image_flag_unhinted; /* TODO? when? */
2647        }        }
2648      else      else
# Line 2889  static int filters[3][7]= Line 2690  static int filters[3][7]=
2690                continue;                continue;
2691              }              }
2692    
 #ifdef FT212_STUFF  
           if (sbit->format == ft_pixel_mode_grays)  
 #else  
2693            if (sbit->format == FT_PIXEL_MODE_LCD)            if (sbit->format == FT_PIXEL_MODE_LCD)
 #endif  
2694              {              {
 #ifdef FT212_STUFF  
               int gx = x + sbit->left, gy = y - sbit->top;  
 #else  
2695                int gx = 3 * x + sbit->left, gy = y - sbit->top;                int gx = 3 * x + sbit->left, gy = y - sbit->top;
 #endif  
2696                int px0 = (gx - 2 < 0? gx - 4 : gx - 2) / 3;                int px0 = (gx - 2 < 0? gx - 4 : gx - 2) / 3;
2697                int px1 = (gx + sbit->width + 2 < 0? gx + sbit->width + 2: gx + sbit->width + 4) / 3;                int px1 = (gx + sbit->width + 2 < 0? gx + sbit->width + 2: gx + sbit->width + 4) / 3;
2698                int llip = gx - px0 * 3;                int llip = gx - px0 * 3;
# Line 3142  static int filters[3][7]= Line 2935  static int filters[3][7]=
2935          }          }
2936      }      }
2937  }  }
2938    #endif
2939    
2940  @end  @end
2941    
# Line 3157  static int filters[3][7]= Line 2951  static int filters[3][7]=
2951    FTFontInfo *fi=fontInfo;    FTFontInfo *fi=fontInfo;
2952    NSGlyph g;    NSGlyph g;
2953    
2954    FTC_CMapDescRec cmap;    g = FTC_CMapCache_Lookup(ftc_cmapcache, fi->faceId, fi->unicodeCmap, ch);
   
   cmap.face_id = fi->imgd.font.face_id;  
   cmap.u.encoding = ft_encoding_unicode;  
   cmap.type = FTC_CMAP_BY_ENCODING;  
   
   g = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, ch);  
2955    if (g)    if (g)
2956      return g + 1;      return g + 1;
2957    else    else
# Line 3174  static int filters[3][7]= Line 2962  static int filters[3][7]=
2962  {  {
2963    FTFontInfo *fi=fontInfo;    FTFontInfo *fi=fontInfo;
2964    FT_Face face;    FT_Face face;
2965      FT_Size size;
2966    
2967    char buf[256];    char buf[256];
2968    
2969    glyph--;    glyph--;
2970    
2971    if (FTC_Manager_Lookup_Size(ftc_manager, &fi->imgd.font, &face, 0))    if (FTC_Manager_LookupSize(ftc_manager, &fi->scaler, &size))
2972      return nil;      return nil;
2973      face = size->face;
2974    
2975    if (FT_Get_Glyph_Name(face,glyph,buf,sizeof(buf)))    if (FT_Get_Glyph_Name(face,glyph,buf,sizeof(buf)))
2976      return nil;      return nil;
# Line 3246  fb04 'ffl' Line 3036  fb04 'ffl'
3036          unsigned int ch,ch2,ch3;          unsigned int ch,ch2,ch3;
3037    
3038          FTFontInfo *fi=[run->font fontInfo];          FTFontInfo *fi=[run->font fontInfo];
         FTC_CMapDescRec cmap;  
3039    
3040          NSCharacterSet *cs=[NSCharacterSet controlCharacterSet];          NSCharacterSet *cs=[NSCharacterSet controlCharacterSet];
3041          IMP characterIsMember=[cs methodForSelector: @selector(characterIsMember:)];          IMP characterIsMember=[cs methodForSelector: @selector(characterIsMember:)];
# Line 3258  fb04 'ffl' Line 3047  fb04 'ffl'
3047          [[_textStorage string] getCharacters: buf          [[_textStorage string] getCharacters: buf
3048                  range: NSMakeRange(pos,c)];                  range: NSMakeRange(pos,c)];
3049    
         cmap.face_id = fi->imgd.font.face_id;  
         cmap.u.encoding = ft_encoding_unicode;  
         cmap.type = FTC_CMAP_BY_ENCODING;  
   
3050          /* first guess */          /* first guess */
3051          glyph_size=c;          glyph_size=c;
3052          g=run->glyphs=malloc(sizeof(glyph_t)*glyph_size);          g=run->glyphs=malloc(sizeof(glyph_t)*glyph_size);
# Line 3336  fb04 'ffl' Line 3121  fb04 'ffl'
3121                                  ch = 0xfffd;                                  ch = 0xfffd;
3122                  }                  }
3123    
3124                  g->g=FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, ch) + 1;                  g->g=FTC_CMapCache_Lookup(ftc_cmapcache, fi->faceId, fi->unicodeCmap, ch) + 1;
3125    
3126                  if (g->g == 1 && ch<0x10000)                  if (g->g == 1 && ch<0x10000)
3127                  {                  {
# Line 3352  fb04 'ffl' Line 3137  fb04 'ffl'
3137                                          g=run->glyphs+j;                                          g=run->glyphs+j;
3138                                          memset(&run->glyphs[glyph_size-1],0,sizeof(glyph_t));                                          memset(&run->glyphs[glyph_size-1],0,sizeof(glyph_t));
3139    
3140                                          g->g=FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, *decomp) + 1;                                          g->g=FTC_CMapCache_Lookup(ftc_cmapcache, fi->faceId, fi->unicodeCmap, *decomp) + 1;
3141                                          if (g->g == 1)                                          if (g->g == 1)
3142                                                  break;                                                  break;
3143                                          c++;                                          c++;
# Line 3389  fb04 'ffl' Line 3174  fb04 'ffl'
3174  -(const char *) nameOfGlyph: (NSGlyph)g  -(const char *) nameOfGlyph: (NSGlyph)g
3175  {  {
3176  static char buf[1024]; /* !!TODO!! */  static char buf[1024]; /* !!TODO!! */
3177      FT_Size size;
3178    FT_Face face;    FT_Face face;
3179    
3180    g--;    g--;
3181    if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0))    if (FTC_Manager_LookupSize(ftc_manager, &scaler, &size))
3182      return ".notdef";      return ".notdef";
3183      face = size->face;
3184    
3185    if (FT_Get_Glyph_Name(face, g, buf, sizeof(buf)))    if (FT_Get_Glyph_Name(face, g, buf, sizeof(buf)))
3186      return ".notdef";      return ".notdef";
# Line 3402  static char buf[1024]; /* !!TODO!! */ Line 3189  static char buf[1024]; /* !!TODO!! */
3189  }  }
3190  @end  @end
3191    
3192    #endif /* freetype version check, >=2.1.8 */
3193    

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26