--- freetype.c.orig Thu Jun 6 14:56:09 2002 +++ freetype.c Fri Jun 7 19:22:21 2002 @@ -95,9 +95,13 @@ MAKE_FUNCPTR(FT_Vector_Rotate) #undef MAKE_FUNCPTR +#define USE_TTC typedef struct tagFace { WCHAR *StyleName; char *file; +#ifdef USE_TTC + int index; +#endif BOOL Italic; BOOL Bold; DWORD fsCsb[2]; /* codepage bitfield from FONTSIGNATURE */ @@ -161,6 +165,8 @@ static WCHAR TurkishW[] = {'T','u','r','k','i','s','h','\0'}; static WCHAR VietnameseW[] = {'V','i','e','t','n','a','m','e','s','e','\0'}; static WCHAR WesternW[] = {'W','e','s','t','e','r','n','\0'}; +static WCHAR JisJapanW[] = {'J','i','s','J','a','p','a','n','\0'}; +static WCHAR HangulW[] = {'H','a','n','g','u','l','\0'}; static WCHAR *ElfScriptsW[32] = { /* these are in the order of the fsCsb[0] bits */ WesternW, /*00*/ @@ -174,7 +180,7 @@ VietnameseW, /*08*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*15*/ ThaiW, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*23*/ + JisJapanW, NULL, HangulW, NULL, NULL, NULL, NULL, /*23*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, SymbolW /*31*/ }; @@ -198,22 +204,31 @@ TT_OS2 *pOS2; WCHAR *FamilyW, *StyleW; DWORD len; - Family *family = FontList; - Family **insert = &FontList; + Family *family;// = FontList; + Family **insert;// = &FontList; Face **insertface; FT_Error err; int i; + int j,fn; + + fn=1; + + for (j=0; jnum_faces; +#endif + if(ft_face->num_faces==1 && !FT_IS_SFNT(ft_face)) { /* for now we'll skip everything but TT/OT */ pFT_Done_Face(ft_face); return FALSE; } + family = FontList; + insert = &FontList; len = MultiByteToWideChar(CP_ACP, 0, ft_face->family_name, -1, NULL, 0); FamilyW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); @@ -253,6 +268,9 @@ (*insertface)->StyleName = StyleW; (*insertface)->file = HeapAlloc(GetProcessHeap(),0,strlen(file)+1); strcpy((*insertface)->file, file); +#ifdef USE_TTC + (*insertface)->index = j; +#endif (*insertface)->next = NULL; (*insertface)->Italic = (ft_face->style_flags & FT_STYLE_FLAG_ITALIC) ? 1 : 0; (*insertface)->Bold = (ft_face->style_flags & FT_STYLE_FLAG_BOLD) ? 1 : 0; @@ -281,11 +299,11 @@ } } } - - pFT_Done_Face(ft_face); - TRACE("Added font %s %s\n", debugstr_w(family->FamilyName), debugstr_w(StyleW)); + pFT_Done_Face(ft_face); + } + return TRUE; } @@ -574,13 +592,21 @@ static LONG load_VDMX(GdiFont, LONG); +#ifndef USE_TTC static FT_Face OpenFontFile(GdiFont font, char *file, LONG height) +#else +static FT_Face OpenFontFile(GdiFont font, Face *face, LONG height) +#endif { FT_Error err; FT_Face ft_face; LONG ppem; +#ifndef USE_TTC err = pFT_New_Face(library, file, 0, &ft_face); +#else + err = pFT_New_Face(library, face->file, face->index, &ft_face); +#endif if(err) { ERR("FT_New_Face rets %d\n", err); return 0; @@ -894,8 +920,13 @@ TRACE("Choosen %s %s\n", debugstr_w(family->FamilyName), debugstr_w(face->StyleName)); +#ifndef USE_TTC ret->ft_face = OpenFontFile(ret, face->file, INTERNAL_YWSTODS(dc,plf->lfHeight)); +#else + ret->ft_face = OpenFontFile(ret, face, + INTERNAL_YWSTODS(dc,plf->lfHeight)); +#endif if (!ret->ft_face) { GDI_ReleaseObj(hfont); @@ -967,7 +998,11 @@ UINT size; GdiFont font = alloc_font(); +#ifndef USE_TTC if (!(font->ft_face = OpenFontFile(font, face->file, 100))) +#else + if (!(font->ft_face = OpenFontFile(font, face, 100)) || !FT_IS_SFNT(font->ft_face) ) +#endif { free_font(font); return; @@ -1266,13 +1301,42 @@ if(format == GGO_METRICS) return 1; /* FIXME */ +#define ENABLE_EMBEDED_BITMAP +#ifndef ENABLE_EMBEDED_BITMAP if(ft_face->glyph->format != ft_glyph_format_outline) { FIXME("loaded a bitmap\n"); return GDI_ERROR; } +#endif switch(format) { case GGO_BITMAP: +#ifdef ENABLE_EMBEDED_BITMAP + /* TT embedded bitmap or .fon files bitmap */ + + if ( ft_face->glyph->format == ft_glyph_format_bitmap ) + { + width = ft_face->glyph->bitmap.width; + height = ft_face->glyph->bitmap.rows; + pitch = (width + 31) / 32 * 4; + needed = pitch * height; + if(!buf || !buflen) break; + if ( buf ) + { + int pitchf; + unsigned char *bbuf; + + memset(buf, 0, needed); + + pitchf = ft_face->glyph->bitmap.pitch; + bbuf = ft_face->glyph->bitmap.buffer; + for ( ; height ; height--, buf+=pitch, bbuf+=pitchf ) + memcpy( buf, bbuf, pitchf ); + } + } + else + { +#endif width = lpgm->gmBlackBoxX; height = lpgm->gmBlackBoxY; pitch = (width + 31) / 32 * 4; @@ -1299,6 +1363,9 @@ /* Note: FreeType will only set 'black' bits for us. */ memset(buf, 0, needed); pFT_Outline_Get_Bitmap(library, &ft_face->glyph->outline, &ft_bitmap); +#ifdef ENABLE_EMBEDED_BITMAP + } +#endif break; case GGO_GRAY2_BITMAP: