--- gnustep-back-0.9.3/Source/art/ftfont.m.orig 2004-05-13 17:14:46.000000000 +0200 +++ gnustep-back-0.9.3/Source/art/ftfont.m 2004-06-26 11:32:32.704296824 +0200 @@ -61,6 +61,8 @@ #if (FREETYPE_MAJOR==2) && ((FREETYPE_MINOR<1) || ((FREETYPE_MINOR==1) && (FREETYPE_PATCH<=2))) #define FT212_STUFF +#elif (FREETYPE_MAJOR==2) && ((FREETYPE_MINOR>1) || ((FREETYPE_MINOR==1) && (FREETYPE_PATCH>=8))) +#define FT_GE_218 #endif @@ -95,6 +97,9 @@ FTC_ImageTypeRec advancementImgd; #endif +#ifdef FT_GE_218 + FTC_ScalerRec scalerd; +#endif FTFaceInfo *face_info; @@ -718,17 +723,31 @@ matrix[3] = ceil(matrix[3]); } +#ifdef FT_GE_218 + scalerd.pixel = 1; + scalerd.width = imgd.width = fabs(matrix[0]); + scalerd.height = imgd.height = fabs(matrix[3]); +#else imgd.font.pix_width = fabs(matrix[0]); imgd.font.pix_height = fabs(matrix[3]); +#endif rfi = font_entry->files; if (screenFont && font_entry->num_sizes && +#ifdef FT_GE_218 + imgd.width == imgd.height) +#else imgd.font.pix_width == imgd.font.pix_height) +#endif { int i; for (i = 0; i < font_entry->num_sizes; i++) { +#ifdef FT_GE_218 + if (font_entry->sizes[i].pixel_size == imgd.width) +#else if (font_entry->sizes[i].pixel_size == imgd.font.pix_width) +#endif { rfi = font_entry->sizes[i].files; break; @@ -736,9 +755,18 @@ } } +#ifdef FT_GE_218 + scalerd.face_id = imgd.face_id = (FTC_FaceID)rfi; +#else imgd.font.face_id = (FTC_FaceID)rfi; +#endif +#ifdef FT_GE_218 + if ((error=FTC_Manager_LookupFace(ftc_manager, scalerd.face_id, &face)) || + (error=FTC_Manager_LookupSize(ftc_manager, &scalerd, &size))) +#else if ((error=FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, &size))) +#endif { NSLog(@"FTC_Manager_Lookup_Size() failed for '%@', error %08x!\n", name, error); return self; @@ -762,6 +790,19 @@ fontBBox.size.width, fontBBox.size.height);*/ { +#ifdef FT_GE_218 + FT_CharMapRec crec; + FT_Int cind; + crec.face = face; + crec.encoding = ft_encoding_unicode; + crec.platform_id = crec.encoding_id = 0; + cind = FT_Get_Charmap_Index( &crec ); + ligature_ff = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, 0xfb00); + ligature_fi = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, 0xfb01); + ligature_fl = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, 0xfb02); + ligature_ffi = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, 0xfb03); + ligature_ffl = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, 0xfb04); +#else FTC_CMapDescRec cmap; cmap.face_id = imgd.font.face_id; cmap.u.encoding = ft_encoding_unicode; @@ -771,6 +812,7 @@ ligature_fl = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb02); ligature_ffi = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb03); ligature_ffl = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 0xfb04); +#endif /* printf("ligatures %04x %04x %04x %04x %04x | %02x %02x %02x for |%@|\n", ligature_ff,ligature_fi,ligature_fl,ligature_ffi,ligature_ffl, FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, 'f'), @@ -881,7 +923,13 @@ unsigned char ch; unsigned int uch; +#ifdef FT_GE_218 + FT_CharMapRec crec; + FT_Int cind; + FT_Face face1; +#else FTC_CMapDescRec cmap; +#endif unsigned int glyph; int use_sbit; @@ -935,8 +983,13 @@ xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5) { use_sbit = 1; +#ifdef FT_GE_218 + cur.width = xx; + cur.height = yy; +#else cur.font.pix_width = xx; cur.font.pix_height = yy; +#endif if (xx == yy && xx < 16 && xx >= 8) { @@ -998,7 +1051,11 @@ f = (int)f; +#ifdef FT_GE_218 + cur.width = cur.height = f; +#else cur.font.pix_width = cur.font.pix_height = f; +#endif ftmatrix.xx = xx / f * 65536.0; ftmatrix.xy = xy / f * 65536.0; ftmatrix.yx = yx / f * 65536.0; @@ -1011,9 +1068,17 @@ /* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p\n", s, x, y, x0, y0, x1, y1, buf);*/ +#ifdef FT_GE_218 + FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face1); + crec.face = face1; + crec.encoding = ft_encoding_unicode; + crec.platform_id = crec.encoding_id = 0; + cind = FT_Get_Charmap_Index( &crec ); +#else cmap.face_id = imgd.font.face_id; cmap.u.encoding = ft_encoding_unicode; cmap.type = FTC_CMAP_BY_ENCODING; +#endif for (c = s; *c; c++) { @@ -1069,15 +1134,24 @@ uch = 0xfffd; #undef ADD_UTF_BYTE +#ifdef FT_GE_218 + glyph = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, uch); + cur.face_id = imgd.face_id; +#else glyph = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, uch); cur.font.face_id = imgd.font.face_id; +#endif if (use_sbit) { if ((error=FTC_SBitCache_Lookup(ftc_sbitcache, &cur, glyph, &sbit, NULL))) { NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n", +#ifdef FT_GE_218 + error, glyph, cur.face_id, cur.width, cur.height, +#else error, glyph, cur.font.face_id, cur.font.pix_width, cur.font.pix_height, +#endif #ifdef FT212_STUFF cur.type #else @@ -1206,12 +1280,19 @@ FT_Glyph gl; FT_BitmapGlyph gb; +#ifdef FT_GE_218 + if ((error=FTC_Manager_LookupFace(ftc_manager, cur.face_id, &face))) + { + NSLog(@"FTC_Manager_LookupFace() failed with error %08x\n",error); + continue; + } +#else if ((error=FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0))) { NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error); continue; } - +#endif /* TODO: for rotations of 90, 180, 270, and integer scales hinting might still be a good idea. */ if ((error=FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP))) @@ -1377,8 +1458,13 @@ xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5) { use_sbit = 1; +#ifdef FT_GE_218 + cur.width = xx; + cur.height = yy; +#else cur.font.pix_width = xx; cur.font.pix_height = yy; +#endif if (xx == yy && xx < 16 && xx >= 8) { @@ -1440,7 +1526,11 @@ f = (int)f; +#ifdef FT_GE_218 + cur.width = cur.height = f; +#else cur.font.pix_width = cur.font.pix_height = f; +#endif ftmatrix.xx = xx / f * 65536.0; ftmatrix.xy = xy / f * 65536.0; ftmatrix.yx = yx / f * 65536.0; @@ -1461,7 +1551,11 @@ if ((error = FTC_SBitCache_Lookup(ftc_sbitcache, &cur, glyph, &sbit, NULL))) { NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n", +#ifdef FT_GE_218 + error, glyph, cur.face_id, cur.width, cur.height, +#else error, glyph, cur.font.face_id, cur.font.pix_width, cur.font.pix_height, +#endif #ifdef FT212_STUFF cur.type #else @@ -1590,11 +1684,19 @@ FT_Glyph gl; FT_BitmapGlyph gb; +#ifdef FT_GE_218 + if ((error=FTC_Manager_LookupFace(ftc_manager, cur.face_id, &face))) + { + NSLog(@"FTC_Manager_LookupFace() failed with error %08x\n",error); + continue; + } +#else if ((error=FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0))) { NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error); continue; } +#endif /* TODO: for rotations of 90, 180, 270, and integer scales hinting might still be a good idea. */ @@ -1751,8 +1853,13 @@ xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5) { use_sbit = 1; +#ifdef FT_GE_218 + cur.width = xx; + cur.height = yy; +#else cur.font.pix_width = xx; cur.font.pix_height = yy; +#endif if (xx == yy && xx < 16 && xx >= 8) { @@ -1814,7 +1921,11 @@ f = (int)f; +#ifdef FT_GE_218 + cur.width = cur.height = f; +#else cur.font.pix_width = cur.font.pix_height = f; +#endif ftmatrix.xx = xx / f * 65536.0; ftmatrix.xy = xy / f * 65536.0; ftmatrix.yx = yx / f * 65536.0; @@ -1836,7 +1947,11 @@ { if (glyph != 0xffffffff) NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n", +#ifdef FT_GE_218 + error, glyph, cur.face_id, cur.width, cur.height, +#else error, glyph, cur.font.face_id, cur.font.pix_width, cur.font.pix_height, +#endif #ifdef FT212_STUFF cur.type #else @@ -1963,11 +2078,19 @@ FT_Glyph gl; FT_BitmapGlyph gb; +#ifdef FT_GE_218 + if ((error=FTC_Manager_LookupFace(ftc_manager, cur.face_id, &face))) + { + NSLog(@"FTC_Manager_LookupFace() failed with error %08x\n",error); + continue; + } +#else if ((error=FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0))) { NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x\n",error); continue; } +#endif /* TODO: for rotations of 90, 180, 270, and integer scales hinting might still be a good idea. */ @@ -2067,11 +2190,19 @@ FT_Error error; glyph--; +#ifdef FT_GE_218 + if ((error=FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face))) + { + NSLog(@"FTC_Manager_LookupFace() failed with error %08x",error); + return NO; + } +#else if ((error=FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0))) { NSLog(@"FTC_Manager_Lookup_Size() failed with error %08x",error); return NO; } +#endif if ((error=FT_Load_Glyph(face, glyph, 0))) { @@ -2104,8 +2235,13 @@ if ((error=FTC_SBitCache_Lookup(ftc_sbitcache, &advancementImgd, glyph, &sbit, NULL))) { NSLog(@"FTC_SBitCache_Lookup() failed with error %08x (%08x, %08x, %ix%i, %08x)\n", +#ifdef FT_GE_218 + error, glyph, advancementImgd.face_id, + advancementImgd.width, advancementImgd.height, +#else error, glyph, advancementImgd.font.face_id, advancementImgd.font.pix_width, advancementImgd.font.pix_height, +#endif #ifdef FT212_STUFF advancementImgd.type #else @@ -2142,7 +2278,11 @@ ftmatrix.yy = matrix[3] / f * 65536.0; ftdelta.x = ftdelta.y = 0; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0)) +#endif return NSZeroSize; if (FT_Load_Glyph(face, glyph, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)) @@ -2210,7 +2350,11 @@ g--; prev--; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0)) +#endif return NSZeroPoint; if (FT_Load_Glyph(face, prev, FT_LOAD_DEFAULT)) @@ -2240,7 +2384,13 @@ int i, c = [string length]; int total; +#ifdef FT_GE_218 + FT_CharMapRec crec; + FT_Int cind; + FT_Face face1; +#else FTC_CMapDescRec cmap; +#endif unsigned int glyph; FTC_SBit sbit; @@ -2251,17 +2401,28 @@ FTC_ImageTypeRec *cur; #endif - +#ifdef FT_GE_218 + FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face1); + crec.face = face1; + crec.encoding = ft_encoding_unicode; + crec.platform_id = crec.encoding_id = 0; + cind = FT_Get_Charmap_Index( &crec ); +#else cmap.face_id = imgd.font.face_id; cmap.u.encoding = ft_encoding_unicode; cmap.type = FTC_CMAP_BY_ENCODING; +#endif total = 0; for (i = 0; i < c; i++) { ch = [string characterAtIndex: i]; cur = &imgd; +#ifdef FT_GE_218 + glyph = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, ch); +#else glyph = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, ch); +#endif /* TODO: shouldn't use sbit cache for this */ if (1) @@ -2285,7 +2446,11 @@ FT_Face face; NSGlyph g; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0)) +#endif return NSNullGlyph; g = FT_Get_Name_Index(face, (FT_String *)[glyphName lossyCString]); @@ -2526,7 +2691,12 @@ { unichar *c; int i; +#ifdef FT_GE_218 + FT_CharMapRec crec; + FT_Int cind; +#else FTC_CMapDescRec cmap; +#endif unsigned int glyph; unichar *uch; @@ -2557,9 +2727,14 @@ cur = imgd; +#ifdef FT_GE_218 + crec.encoding = ft_encoding_unicode; + crec.platform_id = crec.encoding_id = 0; +#else cmap.face_id = imgd.font.face_id; cmap.u.encoding = ft_encoding_unicode; cmap.type = FTC_CMAP_BY_ENCODING; +#endif for (c = uch, i = 0; i < ulen; i++, c++) { @@ -2567,11 +2742,23 @@ FT_Glyph gl; FT_OutlineGlyph og; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, cur.face_id, &face)) +#else + if (FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0)) +#endif + continue; + +#ifdef FT_GE_218 + crec.face = face; + cind = FT_Get_Charmap_Index( &crec ); + glyph = FTC_CMapCache_Lookup(ftc_cmapcache, imgd.face_id, cind, *c); + cur.face_id = imgd.face_id; +#else glyph = FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, *c); cur.font.face_id = imgd.font.face_id; +#endif - if (FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0)) - continue; if (FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT)) continue; @@ -2630,7 +2817,11 @@ glyph = *glyphs - 1; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0)) +#endif continue; if (FT_Load_Glyph(face, glyph, FT_LOAD_DEFAULT)) continue; @@ -2757,7 +2948,6 @@ transform: (NSAffineTransform *)transform drawinfo: (struct draw_info_s *)di { - FTC_CMapDescRec cmap; unsigned int glyph; int use_sbit; @@ -2808,15 +2998,24 @@ xx < 72 && yy < 72 && xx > 0.5 && yy > 0.5) { use_sbit = 1; +#ifdef FT_GE_218 + cur.width = xx; + cur.height = yy; +#else cur.font.pix_width = xx; cur.font.pix_height = yy; +#endif /* if (cur.font.pix_width < 16 && cur.font.pix_height < 16 && cur.font.pix_width > 6 && cur.font.pix_height > 6) cur.type = ftc_image_mono; else*/ #ifdef FT212_STUFF +#ifdef FT_GE_218 + cur.type = ftc_image_grays, subpixel = YES, cur.width *= 3, x *= 3; +#else cur.type = ftc_image_grays, subpixel = YES, cur.font.pix_width *= 3, x *= 3; +#endif #else cur.flags = FT_LOAD_TARGET_LCD, subpixel = YES; #endif @@ -2835,7 +3034,11 @@ f = (int)f; +#ifdef FT_GE_218 + cur.width = cur.height = f; +#else cur.font.pix_width = cur.font.pix_height = f; +#endif ftmatrix.xx = xx / f * 65536.0; ftmatrix.xy = xy / f * 65536.0; ftmatrix.yx = yx / f * 65536.0; @@ -2848,10 +3051,6 @@ /* NSLog(@"drawString: '%s' at: %i:%i to: %i:%i:%i:%i:%p\n", s, x, y, x0, y0, x1, y1, buf);*/ - cmap.face_id = imgd.font.face_id; - cmap.u.encoding = ft_encoding_unicode; - cmap.type = FTC_CMAP_BY_ENCODING; - for (; length; length--, glyphs++) { glyph = *glyphs - 1; @@ -3033,7 +3232,11 @@ FT_Glyph gl; FT_BitmapGlyph gb; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, cur.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &cur.font, &face, 0)) +#endif continue; /* TODO: for rotations of 90, 180, 270, and integer @@ -3134,6 +3337,17 @@ { FTFontInfo *fi=fontInfo; +#ifdef FT_GE_218 + FT_CharMapRec crec; + FT_Int cind; + FT_Face face1; + FTC_Manager_LookupFace(ftc_manager, fi->imgd.face_id, &face1); + crec.face = face1; + crec.encoding = ft_encoding_unicode; + crec.platform_id = crec.encoding_id = 0; + cind = FT_Get_Charmap_Index( &crec ); + return FTC_CMapCache_Lookup(ftc_cmapcache, fi->imgd.face_id, cind, ch) + 1; +#else FTC_CMapDescRec cmap; cmap.face_id = fi->imgd.font.face_id; @@ -3141,6 +3355,7 @@ cmap.type = FTC_CMAP_BY_ENCODING; return FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, ch) + 1; +#endif } -(NSString *) nameOfGlyph: (NSGlyph)glyph @@ -3152,7 +3367,11 @@ glyph--; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, fi->imgd.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &fi->imgd.font, &face, 0)) +#endif return nil; if (FT_Get_Glyph_Name(face,glyph,buf,sizeof(buf))) @@ -3219,7 +3438,13 @@ unsigned int ch,ch2,ch3; FTFontInfo *fi=[run->font fontInfo]; +#ifdef FT_GE_218 + FT_CharMapRec crec; + FT_Int cind; + FT_Face face1; +#else FTC_CMapDescRec cmap; +#endif NSCharacterSet *cs=[NSCharacterSet controlCharacterSet]; IMP characterIsMember=[cs methodForSelector: @selector(characterIsMember:)]; @@ -3231,9 +3456,17 @@ [[_textStorage string] getCharacters: buf range: NSMakeRange(pos,c)]; +#ifdef FT_GE_218 + FTC_Manager_LookupFace(ftc_manager, fi->imgd.face_id, &face1); + crec.face = face1; + crec.encoding = ft_encoding_unicode; + crec.platform_id = crec.encoding_id = 0; + cind = FT_Get_Charmap_Index( &crec ); +#else cmap.face_id = fi->imgd.font.face_id; cmap.u.encoding = ft_encoding_unicode; cmap.type = FTC_CMAP_BY_ENCODING; +#endif /* first guess */ glyph_size=c; @@ -3309,7 +3542,11 @@ ch = 0xfffd; } +#ifdef FT_GE_218 + g->g=FTC_CMapCache_Lookup(ftc_cmapcache, fi->imgd.face_id, cind, ch) + 1; +#else g->g=FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, ch) + 1; +#endif if (g->g == 1 && ch<0x10000) { @@ -3325,7 +3562,11 @@ g=run->glyphs+j; memset(&run->glyphs[glyph_size-1],0,sizeof(glyph_t)); +#ifdef FT_GE_218 + g->g=FTC_CMapCache_Lookup(ftc_cmapcache, fi->imgd.face_id, cind, *decomp) + 1; +#else g->g=FTC_CMapCache_Lookup(ftc_cmapcache, &cmap, *decomp) + 1; +#endif if (g->g == 1) break; c++; @@ -3365,7 +3606,11 @@ FT_Face face; g--; +#ifdef FT_GE_218 + if (FTC_Manager_LookupFace(ftc_manager, imgd.face_id, &face)) +#else if (FTC_Manager_Lookup_Size(ftc_manager, &imgd.font, &face, 0)) +#endif return ".notdef"; if (FT_Get_Glyph_Name(face, g, buf, sizeof(buf)))