2001-09-12 22:21:06 +02:00
|
|
|
/*
|
|
|
|
* FreeType font engine interface
|
|
|
|
*
|
|
|
|
* Copyright 2001 Huw D M Davies for CodeWeavers.
|
|
|
|
*
|
|
|
|
* This file contains the WineEng* functions.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-09-12 22:21:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2004-01-15 01:35:38 +01:00
|
|
|
#include "wine/port.h"
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
2005-05-06 18:22:54 +02:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2001-09-12 22:21:06 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wingdi.h"
|
2004-01-15 01:35:38 +01:00
|
|
|
#include "gdi.h"
|
|
|
|
#include "gdi_private.h"
|
2001-09-12 22:21:06 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-04-03 22:02:39 +02:00
|
|
|
#include "wine/debug.h"
|
2004-08-04 20:16:13 +02:00
|
|
|
#include "wine/list.h"
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(font);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
|
2003-11-19 03:18:13 +01:00
|
|
|
#ifdef HAVE_FT2BUILD_H
|
|
|
|
#include <ft2build.h>
|
|
|
|
#endif
|
2001-09-12 22:21:06 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FREETYPE_H
|
|
|
|
#include <freetype/freetype.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_FTGLYPH_H
|
|
|
|
#include <freetype/ftglyph.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_TTTABLES_H
|
|
|
|
#include <freetype/tttables.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_FTSNAMES_H
|
|
|
|
#include <freetype/ftsnames.h>
|
2001-12-24 22:10:31 +01:00
|
|
|
#else
|
|
|
|
# ifdef HAVE_FREETYPE_FTNAMES_H
|
|
|
|
# include <freetype/ftnames.h>
|
|
|
|
# endif
|
2001-09-12 22:21:06 +02:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_TTNAMEID_H
|
|
|
|
#include <freetype/ttnameid.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_FTOUTLN_H
|
|
|
|
#include <freetype/ftoutln.h>
|
|
|
|
#endif
|
2001-10-23 22:06:32 +02:00
|
|
|
#ifdef HAVE_FREETYPE_INTERNAL_SFNT_H
|
|
|
|
#include <freetype/internal/sfnt.h>
|
|
|
|
#endif
|
2002-01-29 04:02:50 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTTRIGON_H
|
|
|
|
#include <freetype/fttrigon.h>
|
|
|
|
#endif
|
2004-06-16 22:06:26 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
#include <freetype/ftwinfnt.h>
|
|
|
|
#endif
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-05-20 20:29:58 +02:00
|
|
|
#ifndef SONAME_LIBFREETYPE
|
|
|
|
#define SONAME_LIBFREETYPE "libfreetype.so"
|
|
|
|
#endif
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
static FT_Library library = 0;
|
2002-08-17 20:34:34 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
FT_Int major;
|
|
|
|
FT_Int minor;
|
|
|
|
FT_Int patch;
|
|
|
|
} FT_Version_t;
|
|
|
|
static FT_Version_t FT_Version;
|
2004-06-16 22:06:26 +02:00
|
|
|
static DWORD FT_SimpleVersion;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
static void *ft_handle = NULL;
|
|
|
|
|
2002-09-23 22:45:57 +02:00
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
|
2003-10-10 02:06:35 +02:00
|
|
|
MAKE_FUNCPTR(FT_Vector_Unit);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Done_Face);
|
|
|
|
MAKE_FUNCPTR(FT_Get_Char_Index);
|
|
|
|
MAKE_FUNCPTR(FT_Get_Sfnt_Table);
|
|
|
|
MAKE_FUNCPTR(FT_Init_FreeType);
|
|
|
|
MAKE_FUNCPTR(FT_Load_Glyph);
|
2003-10-10 02:06:35 +02:00
|
|
|
MAKE_FUNCPTR(FT_Matrix_Multiply);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_MulFix);
|
|
|
|
MAKE_FUNCPTR(FT_New_Face);
|
|
|
|
MAKE_FUNCPTR(FT_Outline_Get_Bitmap);
|
|
|
|
MAKE_FUNCPTR(FT_Outline_Transform);
|
|
|
|
MAKE_FUNCPTR(FT_Outline_Translate);
|
|
|
|
MAKE_FUNCPTR(FT_Select_Charmap);
|
|
|
|
MAKE_FUNCPTR(FT_Set_Pixel_Sizes);
|
2003-10-10 02:06:35 +02:00
|
|
|
MAKE_FUNCPTR(FT_Vector_Transform);
|
2002-08-17 20:34:34 +02:00
|
|
|
static void (*pFT_Library_Version)(FT_Library,FT_Int*,FT_Int*,FT_Int*);
|
2003-06-23 22:51:06 +02:00
|
|
|
static FT_Error (*pFT_Load_Sfnt_Table)(FT_Face,FT_ULong,FT_Long,FT_Byte*,FT_ULong*);
|
2003-12-15 20:50:59 +01:00
|
|
|
static FT_ULong (*pFT_Get_First_Char)(FT_Face,FT_UInt*);
|
2004-06-16 22:06:26 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
MAKE_FUNCPTR(FT_Get_WinFNT_Header);
|
|
|
|
#endif
|
2002-04-03 22:02:39 +02:00
|
|
|
|
2003-11-09 01:30:13 +01:00
|
|
|
#ifdef HAVE_FONTCONFIG_FONTCONFIG_H
|
|
|
|
#include <fontconfig/fontconfig.h>
|
|
|
|
MAKE_FUNCPTR(FcConfigGetCurrent);
|
|
|
|
MAKE_FUNCPTR(FcFontList);
|
|
|
|
MAKE_FUNCPTR(FcFontSetDestroy);
|
|
|
|
MAKE_FUNCPTR(FcInit);
|
|
|
|
MAKE_FUNCPTR(FcObjectSetAdd);
|
|
|
|
MAKE_FUNCPTR(FcObjectSetCreate);
|
|
|
|
MAKE_FUNCPTR(FcObjectSetDestroy);
|
|
|
|
MAKE_FUNCPTR(FcPatternCreate);
|
|
|
|
MAKE_FUNCPTR(FcPatternDestroy);
|
|
|
|
MAKE_FUNCPTR(FcPatternGet);
|
|
|
|
#ifndef SONAME_LIBFONTCONFIG
|
|
|
|
#define SONAME_LIBFONTCONFIG "libfontconfig.so"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
|
2004-10-18 21:38:30 +02:00
|
|
|
#ifndef ft_encoding_none
|
2004-09-15 20:03:32 +02:00
|
|
|
#define FT_ENCODING_NONE ft_encoding_none
|
|
|
|
#endif
|
2004-10-18 21:38:30 +02:00
|
|
|
#ifndef ft_encoding_ms_symbol
|
2004-09-15 20:03:32 +02:00
|
|
|
#define FT_ENCODING_MS_SYMBOL ft_encoding_symbol
|
|
|
|
#endif
|
2004-10-18 21:38:30 +02:00
|
|
|
#ifndef ft_encoding_unicode
|
2004-09-15 20:03:32 +02:00
|
|
|
#define FT_ENCODING_UNICODE ft_encoding_unicode
|
|
|
|
#endif
|
2004-10-18 21:38:30 +02:00
|
|
|
#ifndef ft_encoding_apple_roman
|
2004-09-15 20:03:32 +02:00
|
|
|
#define FT_ENCODING_APPLE_ROMAN ft_encoding_apple_roman
|
|
|
|
#endif
|
2003-11-09 01:30:13 +01:00
|
|
|
|
2002-05-23 04:53:10 +02:00
|
|
|
#define GET_BE_WORD(ptr) MAKEWORD( ((BYTE *)(ptr))[1], ((BYTE *)(ptr))[0] )
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
/* This is bascially a copy of FT_Bitmap_Size with an extra element added */
|
|
|
|
typedef struct {
|
|
|
|
FT_Short height;
|
|
|
|
FT_Short width;
|
2004-08-18 00:08:31 +02:00
|
|
|
FT_Pos size;
|
2004-06-16 22:06:26 +02:00
|
|
|
FT_Pos x_ppem;
|
|
|
|
FT_Pos y_ppem;
|
|
|
|
FT_Short internal_leading;
|
|
|
|
} Bitmap_Size;
|
|
|
|
|
2004-07-14 23:42:35 +02:00
|
|
|
/* FT_Bitmap_Size gained 3 new elements between FreeType 2.1.4 and 2.1.5
|
|
|
|
So to let this compile on older versions of FreeType we'll define the
|
|
|
|
new structure here. */
|
|
|
|
typedef struct {
|
|
|
|
FT_Short height, width;
|
|
|
|
FT_Pos size, x_ppem, y_ppem;
|
|
|
|
} My_FT_Bitmap_Size;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
typedef struct tagFace {
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list entry;
|
2001-09-12 22:21:06 +02:00
|
|
|
WCHAR *StyleName;
|
|
|
|
char *file;
|
2002-06-22 03:19:29 +02:00
|
|
|
FT_Long face_index;
|
2001-09-12 22:21:06 +02:00
|
|
|
BOOL Italic;
|
|
|
|
BOOL Bold;
|
2003-06-23 22:51:06 +02:00
|
|
|
FONTSIGNATURE fs;
|
|
|
|
FT_Fixed font_version;
|
2004-06-16 22:06:26 +02:00
|
|
|
BOOL scalable;
|
|
|
|
Bitmap_Size size; /* set if face is a bitmap */
|
2004-03-09 04:43:54 +01:00
|
|
|
BOOL external; /* TRUE if we should manually add this font to the registry */
|
2003-06-23 22:51:06 +02:00
|
|
|
struct tagFamily *family;
|
2001-09-12 22:21:06 +02:00
|
|
|
} Face;
|
|
|
|
|
|
|
|
typedef struct tagFamily {
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list entry;
|
2001-09-12 22:21:06 +02:00
|
|
|
WCHAR *FamilyName;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list faces;
|
2001-09-12 22:21:06 +02:00
|
|
|
} Family;
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
typedef struct {
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
INT adv; /* These three hold to widths of the unrotated chars */
|
|
|
|
INT lsb;
|
|
|
|
INT bbx;
|
|
|
|
BOOL init;
|
|
|
|
} GM;
|
|
|
|
|
2004-08-06 19:31:39 +02:00
|
|
|
typedef struct {
|
|
|
|
FLOAT eM11, eM12;
|
|
|
|
FLOAT eM21, eM22;
|
|
|
|
} FMAT2;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DWORD hash;
|
|
|
|
LOGFONTW lf;
|
|
|
|
FMAT2 matrix;
|
|
|
|
} FONT_DESC;
|
|
|
|
|
|
|
|
typedef struct tagHFONTLIST {
|
|
|
|
struct list entry;
|
|
|
|
HFONT hfont;
|
|
|
|
} HFONTLIST;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
struct tagGdiFont {
|
2004-08-04 20:16:13 +02:00
|
|
|
struct list entry;
|
2001-09-12 22:21:06 +02:00
|
|
|
FT_Face ft_face;
|
2002-06-22 03:19:29 +02:00
|
|
|
LPWSTR name;
|
2002-01-29 04:02:50 +01:00
|
|
|
int charset;
|
2004-08-26 20:24:03 +02:00
|
|
|
int codepage;
|
2002-01-29 04:02:50 +01:00
|
|
|
BOOL fake_italic;
|
|
|
|
BOOL fake_bold;
|
2004-07-22 21:42:31 +02:00
|
|
|
BYTE underline;
|
|
|
|
BYTE strikeout;
|
2002-01-29 04:02:50 +01:00
|
|
|
INT orientation;
|
|
|
|
GM *gm;
|
|
|
|
DWORD gmsize;
|
2004-08-06 19:31:39 +02:00
|
|
|
struct list hfontlist;
|
|
|
|
FONT_DESC font_desc;
|
2003-10-10 02:06:35 +02:00
|
|
|
LONG aveWidth;
|
2002-01-29 04:02:50 +01:00
|
|
|
SHORT yMax;
|
|
|
|
SHORT yMin;
|
2002-06-22 03:19:29 +02:00
|
|
|
OUTLINETEXTMETRICW *potm;
|
2003-06-23 22:51:06 +02:00
|
|
|
FONTSIGNATURE fs;
|
2001-09-12 22:21:06 +02:00
|
|
|
};
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
#define INIT_GM_SIZE 128
|
|
|
|
|
2004-08-04 20:16:13 +02:00
|
|
|
static struct list gdi_font_list = LIST_INIT(gdi_font_list);
|
2004-08-06 19:31:39 +02:00
|
|
|
static struct list unused_gdi_font_list = LIST_INIT(unused_gdi_font_list);
|
|
|
|
#define UNUSED_CACHE_SIZE 10
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
static struct list font_list = LIST_INIT(font_list);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR defSerif[] = {'T','i','m','e','s',' ','N','e','w',' ',
|
2002-01-29 04:02:50 +01:00
|
|
|
'R','o','m','a','n','\0'};
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR defSans[] = {'A','r','i','a','l','\0'};
|
|
|
|
static const WCHAR defFixed[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR defSystem[] = {'A','r','i','a','l','\0'};
|
|
|
|
static const WCHAR SystemW[] = {'S','y','s','t','e','m','\0'};
|
|
|
|
static const WCHAR MSSansSerifW[] = {'M','S',' ','S','a','n','s',' ',
|
2002-01-29 04:02:50 +01:00
|
|
|
'S','e','r','i','f','\0'};
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR HelvW[] = {'H','e','l','v','\0'};
|
2004-03-09 04:43:54 +01:00
|
|
|
static const WCHAR RegularW[] = {'R','e','g','u','l','a','r','\0'};
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
static const WCHAR fontsW[] = {'\\','F','o','n','t','s','\0'};
|
2004-03-09 04:43:54 +01:00
|
|
|
static const WCHAR win9x_font_reg_key[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'F','o','n','t','s','\0'};
|
|
|
|
|
|
|
|
static const WCHAR winnt_font_reg_key[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'F','o','n','t','s','\0'};
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
static const WCHAR system_fonts_reg_key[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
|
|
|
|
static const WCHAR FixedSys_Value[] = {'F','I','X','E','D','F','O','N','.','F','O','N','\0'};
|
|
|
|
static const WCHAR System_Value[] = {'F','O','N','T','S','.','F','O','N','\0'};
|
|
|
|
static const WCHAR OEMFont_Value[] = {'O','E','M','F','O','N','T','.','F','O','N','\0'};
|
|
|
|
|
|
|
|
static const WCHAR *SystemFontValues[4] = {
|
|
|
|
System_Value,
|
|
|
|
OEMFont_Value,
|
2004-07-14 23:42:35 +02:00
|
|
|
FixedSys_Value,
|
2004-06-16 22:06:26 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2005-06-14 14:33:19 +02:00
|
|
|
static const WCHAR external_fonts_reg_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
|
2004-03-09 04:43:54 +01:00
|
|
|
'F','o','n','t','s','\\','E','x','t','e','r','n','a','l',' ','F','o','n','t','s','\0'};
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR ArabicW[] = {'A','r','a','b','i','c','\0'};
|
|
|
|
static const WCHAR BalticW[] = {'B','a','l','t','i','c','\0'};
|
|
|
|
static const WCHAR CHINESE_BIG5W[] = {'C','H','I','N','E','S','E','_','B','I','G','5','\0'};
|
|
|
|
static const WCHAR CHINESE_GB2312W[] = {'C','H','I','N','E','S','E','_','G','B','2','3','1','2','\0'};
|
|
|
|
static const WCHAR Central_EuropeanW[] = {'C','e','n','t','r','a','l',' ',
|
2002-01-29 04:02:50 +01:00
|
|
|
'E','u','r','o','p','e','a','n','\0'};
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR CyrillicW[] = {'C','y','r','i','l','l','i','c','\0'};
|
|
|
|
static const WCHAR GreekW[] = {'G','r','e','e','k','\0'};
|
|
|
|
static const WCHAR HangulW[] = {'H','a','n','g','u','l','\0'};
|
|
|
|
static const WCHAR Hangul_Johab_W[] = {'H','a','n','g','u','l','(','J','o','h','a','b',')','\0'};
|
|
|
|
static const WCHAR HebrewW[] = {'H','e','b','r','e','w','\0'};
|
|
|
|
static const WCHAR JapaneseW[] = {'J','a','p','a','n','e','s','e','\0'};
|
|
|
|
static const WCHAR SymbolW[] = {'S','y','m','b','o','l','\0'};
|
|
|
|
static const WCHAR ThaiW[] = {'T','h','a','i','\0'};
|
|
|
|
static const WCHAR TurkishW[] = {'T','u','r','k','i','s','h','\0'};
|
|
|
|
static const WCHAR VietnameseW[] = {'V','i','e','t','n','a','m','e','s','e','\0'};
|
|
|
|
static const WCHAR WesternW[] = {'W','e','s','t','e','r','n','\0'};
|
2004-06-16 22:06:26 +02:00
|
|
|
static const WCHAR OEM_DOSW[] = {'O','E','M','/','D','O','S','\0'};
|
2003-11-11 21:39:34 +01:00
|
|
|
|
|
|
|
static const WCHAR *ElfScriptsW[32] = { /* these are in the order of the fsCsb[0] bits */
|
2002-01-29 04:02:50 +01:00
|
|
|
WesternW, /*00*/
|
|
|
|
Central_EuropeanW,
|
|
|
|
CyrillicW,
|
|
|
|
GreekW,
|
|
|
|
TurkishW,
|
|
|
|
HebrewW,
|
|
|
|
ArabicW,
|
|
|
|
BalticW,
|
|
|
|
VietnameseW, /*08*/
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*15*/
|
|
|
|
ThaiW,
|
2002-06-22 03:19:29 +02:00
|
|
|
JapaneseW,
|
|
|
|
CHINESE_GB2312W,
|
|
|
|
HangulW,
|
|
|
|
CHINESE_BIG5W,
|
|
|
|
Hangul_Johab_W,
|
|
|
|
NULL, NULL, /*23*/
|
2002-01-29 04:02:50 +01:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
SymbolW /*31*/
|
|
|
|
};
|
|
|
|
|
2002-04-03 22:51:20 +02:00
|
|
|
typedef struct {
|
|
|
|
WCHAR *name;
|
|
|
|
INT charset;
|
|
|
|
} NameCs;
|
|
|
|
|
|
|
|
typedef struct tagFontSubst {
|
|
|
|
NameCs from;
|
|
|
|
NameCs to;
|
|
|
|
struct tagFontSubst *next;
|
|
|
|
} FontSubst;
|
|
|
|
|
|
|
|
static FontSubst *substlist = NULL;
|
2003-06-23 22:51:06 +02:00
|
|
|
static BOOL have_installed_roman_font = FALSE; /* CreateFontInstance will fail if this is still FALSE */
|
2002-04-03 22:51:20 +02:00
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
static const WCHAR font_mutex_nameW[] = {'_','_','W','I','N','E','_','F','O','N','T','_','M','U','T','E','X','_','_','\0'};
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
|
|
|
|
/****************************************
|
|
|
|
* Notes on .fon files
|
|
|
|
*
|
|
|
|
* The fonts System, FixedSys and Terminal are special. There are typically multiple
|
|
|
|
* versions installed for different resolutions and codepages. Windows stores which one to use
|
|
|
|
* in HKEY_CURRENT_CONFIG\\Software\\Fonts.
|
|
|
|
* Key Meaning
|
|
|
|
* FIXEDFON.FON FixedSys
|
|
|
|
* FONTS.FON System
|
2005-01-05 18:12:07 +01:00
|
|
|
* OEMFONT.FON Terminal
|
2004-06-16 22:06:26 +02:00
|
|
|
* LogPixels Current dpi set by the display control panel applet
|
|
|
|
* (HKLM\\Software\\Microsft\\Windows NT\\CurrentVersion\\FontDPI
|
|
|
|
* also has a LogPixels value that appears to mirror this)
|
|
|
|
*
|
|
|
|
* On my system these values have data: vgafix.fon, vgasys.fon, vga850.fon and 96 respectively
|
|
|
|
* (vgaoem.fon would be your oemfont.fon if you have a US setup).
|
|
|
|
* If the resolution is changed to be >= 109dpi then the fonts goto 8514fix, 8514sys and 8514oem
|
|
|
|
* (not sure what's happening to the oem codepage here). 109 is nicely halfway between 96 and 120dpi,
|
|
|
|
* so that makes sense.
|
|
|
|
*
|
|
|
|
* Additionally Windows also loads the fonts listed in the [386enh] section of system.ini (this doesn't appear
|
|
|
|
* to be mapped into the registry on Windows 2000 at least).
|
|
|
|
* I have
|
|
|
|
* woafont=app850.fon
|
|
|
|
* ega80woa.fon=ega80850.fon
|
|
|
|
* ega40woa.fon=ega40850.fon
|
|
|
|
* cga80woa.fon=cga80850.fon
|
|
|
|
* cga40woa.fon=cga40850.fon
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
static inline BOOL is_win9x(void)
|
|
|
|
{
|
|
|
|
return GetVersion() & 0x80000000;
|
|
|
|
}
|
2003-10-10 02:06:35 +02:00
|
|
|
/*
|
|
|
|
This function builds an FT_Fixed from a float. It puts the integer part
|
|
|
|
in the highest 16 bits and the decimal part in the lowest 16 bits of the FT_Fixed.
|
|
|
|
It fails if the integer part of the float number is greater than SHORT_MAX.
|
|
|
|
*/
|
|
|
|
static inline FT_Fixed FT_FixedFromFloat(float f)
|
|
|
|
{
|
|
|
|
short value = f;
|
|
|
|
unsigned short fract = (f - value) * 0xFFFF;
|
|
|
|
return (FT_Fixed)((long)value << 16 | (unsigned long)fract);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function builds an FT_Fixed from a FIXED. It simply put f.value
|
|
|
|
in the highest 16 bits and f.fract in the lowest 16 bits of the FT_Fixed.
|
|
|
|
*/
|
|
|
|
static inline FT_Fixed FT_FixedFromFIXED(FIXED f)
|
|
|
|
{
|
|
|
|
return (FT_Fixed)((long)f.value << 16 | (unsigned long)f.fract);
|
|
|
|
}
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
#define ADDFONT_EXTERNAL_FONT 0x01
|
|
|
|
#define ADDFONT_FORCE_BITMAP 0x02
|
|
|
|
static BOOL AddFontFileToList(const char *file, char *fake_family, DWORD flags)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
FT_Face ft_face;
|
2002-01-29 04:02:50 +01:00
|
|
|
TT_OS2 *pOS2;
|
2004-06-16 22:06:26 +02:00
|
|
|
TT_Header *pHeader = NULL;
|
2001-09-12 22:21:06 +02:00
|
|
|
WCHAR *FamilyW, *StyleW;
|
|
|
|
DWORD len;
|
2004-08-18 00:08:31 +02:00
|
|
|
Family *family;
|
|
|
|
Face *face;
|
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2002-01-29 04:02:50 +01:00
|
|
|
FT_Error err;
|
2002-06-22 03:19:29 +02:00
|
|
|
FT_Long face_index = 0, num_faces;
|
2004-06-16 22:06:26 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
FT_WinFNT_HeaderRec winfnt_header;
|
|
|
|
#endif
|
2005-08-19 11:58:32 +02:00
|
|
|
int i, bitmap_num, internal_leading;
|
|
|
|
FONTSIGNATURE fs;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
do {
|
2003-06-23 22:51:06 +02:00
|
|
|
char *family_name = fake_family;
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
TRACE("Loading font file %s index %ld\n", debugstr_a(file), face_index);
|
|
|
|
if((err = pFT_New_Face(library, file, face_index, &ft_face)) != 0) {
|
2002-07-11 01:16:40 +02:00
|
|
|
WARN("Unable to load font file %s err = %x\n", debugstr_a(file), err);
|
2002-06-22 03:19:29 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!FT_IS_SFNT(ft_face) && (FT_IS_SCALABLE(ft_face) || !(flags & ADDFONT_FORCE_BITMAP))) { /* for now we'll accept TT/OT or bitmap fonts*/
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There are too many bugs in FreeType < 2.1.9 for bitmap font support */
|
|
|
|
if(!FT_IS_SCALABLE(ft_face) && FT_SimpleVersion < ((2 << 16) | (1 << 8) | (9 << 0))) {
|
2002-06-22 03:19:29 +02:00
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-06-16 22:06:26 +02:00
|
|
|
|
|
|
|
if(FT_IS_SFNT(ft_face) && (!pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2) ||
|
2003-06-23 22:51:06 +02:00
|
|
|
!pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea) ||
|
2004-06-16 22:06:26 +02:00
|
|
|
!(pHeader = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_head)))) {
|
2003-06-23 22:51:06 +02:00
|
|
|
TRACE("Font file %s lacks either an OS2, HHEA or HEAD table.\n"
|
2002-06-22 03:19:29 +02:00
|
|
|
"Skipping this font.\n", debugstr_a(file));
|
2002-04-03 22:02:39 +02:00
|
|
|
pFT_Done_Face(ft_face);
|
2001-09-12 22:21:06 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
if(!ft_face->family_name || !ft_face->style_name) {
|
|
|
|
TRACE("Font file %s lacks either a family or style name\n", debugstr_a(file));
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!family_name)
|
|
|
|
family_name = ft_face->family_name;
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
bitmap_num = 0;
|
|
|
|
do {
|
2004-07-14 23:42:35 +02:00
|
|
|
My_FT_Bitmap_Size *size = NULL;
|
|
|
|
|
|
|
|
if(!FT_IS_SCALABLE(ft_face))
|
|
|
|
size = (My_FT_Bitmap_Size *)ft_face->available_sizes + bitmap_num;
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, family_name, -1, NULL, 0);
|
|
|
|
FamilyW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, family_name, -1, FamilyW, len);
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
family = NULL;
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpW(family->FamilyName, FamilyW))
|
2004-06-16 22:06:26 +02:00
|
|
|
break;
|
2004-08-18 00:08:31 +02:00
|
|
|
family = NULL;
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
if(!family) {
|
|
|
|
family = HeapAlloc(GetProcessHeap(), 0, sizeof(*family));
|
|
|
|
family->FamilyName = FamilyW;
|
|
|
|
list_init(&family->faces);
|
|
|
|
list_add_tail(&font_list, &family->entry);
|
2004-06-16 22:06:26 +02:00
|
|
|
} else {
|
|
|
|
HeapFree(GetProcessHeap(), 0, FamilyW);
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1, NULL, 0);
|
|
|
|
StyleW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1, StyleW, len);
|
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
internal_leading = 0;
|
|
|
|
memset(&fs, 0, sizeof(fs));
|
|
|
|
|
|
|
|
pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);
|
|
|
|
if(pOS2) {
|
|
|
|
fs.fsCsb[0] = pOS2->ulCodePageRange1;
|
|
|
|
fs.fsCsb[1] = pOS2->ulCodePageRange2;
|
|
|
|
fs.fsUsb[0] = pOS2->ulUnicodeRange1;
|
|
|
|
fs.fsUsb[1] = pOS2->ulUnicodeRange2;
|
|
|
|
fs.fsUsb[2] = pOS2->ulUnicodeRange3;
|
|
|
|
fs.fsUsb[3] = pOS2->ulUnicodeRange4;
|
|
|
|
if(pOS2->version == 0) {
|
|
|
|
FT_UInt dummy;
|
|
|
|
|
|
|
|
if(!pFT_Get_First_Char || (pFT_Get_First_Char( ft_face, &dummy ) < 0x100))
|
|
|
|
fs.fsCsb[0] |= 1;
|
|
|
|
else
|
|
|
|
fs.fsCsb[0] |= 1L << 31;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
else if(pFT_Get_WinFNT_Header && !pFT_Get_WinFNT_Header(ft_face, &winfnt_header)) {
|
|
|
|
CHARSETINFO csi;
|
|
|
|
TRACE("pix_h %d charset %d dpi %dx%d pt %d\n", winfnt_header.pixel_height, winfnt_header.charset,
|
|
|
|
winfnt_header.vertical_resolution,winfnt_header.horizontal_resolution, winfnt_header.nominal_point_size);
|
|
|
|
if(TranslateCharsetInfo((DWORD*)(UINT)winfnt_header.charset, &csi, TCI_SRCCHARSET))
|
|
|
|
memcpy(&fs, &csi.fs, sizeof(csi.fs));
|
|
|
|
internal_leading = winfnt_header.internal_leading;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
face_elem_ptr = list_head(&family->faces);
|
|
|
|
while(face_elem_ptr) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
face_elem_ptr = list_next(&family->faces, face_elem_ptr);
|
|
|
|
if(!strcmpW(face->StyleName, StyleW) &&
|
2005-08-19 11:58:32 +02:00
|
|
|
(FT_IS_SCALABLE(ft_face) || ((size->y_ppem == face->size.y_ppem) && !memcmp(&fs, &face->fs, sizeof(fs)) ))) {
|
2004-06-16 22:06:26 +02:00
|
|
|
TRACE("Already loaded font %s %s original version is %lx, this version is %lx\n",
|
2004-08-18 00:08:31 +02:00
|
|
|
debugstr_w(family->FamilyName), debugstr_w(StyleW),
|
|
|
|
face->font_version, pHeader ? pHeader->Font_Revision : 0);
|
2004-06-16 22:06:26 +02:00
|
|
|
|
|
|
|
if(fake_family) {
|
|
|
|
TRACE("This font is a replacement but the original really exists, so we'll skip the replacement\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, StyleW);
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
if(!pHeader || pHeader->Font_Revision <= face->font_version) {
|
2004-06-16 22:06:26 +02:00
|
|
|
TRACE("Original font is newer so skipping this one\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, StyleW);
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
TRACE("Replacing original with this one\n");
|
2004-08-18 00:08:31 +02:00
|
|
|
list_remove(&face->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, face->file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, face->StyleName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, face);
|
2004-06-16 22:06:26 +02:00
|
|
|
break;
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
}
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
face = HeapAlloc(GetProcessHeap(), 0, sizeof(*face));
|
|
|
|
list_add_tail(&family->faces, &face->entry);
|
|
|
|
face->StyleName = StyleW;
|
|
|
|
face->file = HeapAlloc(GetProcessHeap(),0,strlen(file)+1);
|
|
|
|
strcpy(face->file, file);
|
|
|
|
face->face_index = face_index;
|
|
|
|
face->Italic = (ft_face->style_flags & FT_STYLE_FLAG_ITALIC) ? 1 : 0;
|
|
|
|
face->Bold = (ft_face->style_flags & FT_STYLE_FLAG_BOLD) ? 1 : 0;
|
|
|
|
face->font_version = pHeader ? pHeader->Font_Revision : 0;
|
|
|
|
face->family = family;
|
|
|
|
face->external = (flags & ADDFONT_EXTERNAL_FONT) ? TRUE : FALSE;
|
2005-08-19 11:58:32 +02:00
|
|
|
memcpy(&face->fs, &fs, sizeof(face->fs));
|
2004-06-16 22:06:26 +02:00
|
|
|
|
|
|
|
if(FT_IS_SCALABLE(ft_face)) {
|
2004-08-18 00:08:31 +02:00
|
|
|
memset(&face->size, 0, sizeof(face->size));
|
|
|
|
face->scalable = TRUE;
|
2004-06-16 22:06:26 +02:00
|
|
|
} else {
|
|
|
|
TRACE("Adding bitmap size h %d w %d size %ld x_ppem %ld y_ppem %ld\n",
|
|
|
|
size->height, size->width, size->size >> 6,
|
|
|
|
size->x_ppem >> 6, size->y_ppem >> 6);
|
2004-08-18 00:08:31 +02:00
|
|
|
face->size.height = size->height;
|
|
|
|
face->size.width = size->width;
|
|
|
|
face->size.size = size->size;
|
|
|
|
face->size.x_ppem = size->x_ppem;
|
|
|
|
face->size.y_ppem = size->y_ppem;
|
2005-08-19 11:58:32 +02:00
|
|
|
face->size.internal_leading = internal_leading;
|
2004-08-18 00:08:31 +02:00
|
|
|
face->scalable = FALSE;
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("fsCsb = %08lx %08lx/%08lx %08lx %08lx %08lx\n",
|
2004-08-18 00:08:31 +02:00
|
|
|
face->fs.fsCsb[0], face->fs.fsCsb[1],
|
|
|
|
face->fs.fsUsb[0], face->fs.fsUsb[1],
|
|
|
|
face->fs.fsUsb[2], face->fs.fsUsb[3]);
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2003-12-10 01:36:22 +01:00
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
if(face->fs.fsCsb[0] == 0) { /* let's see if we can find any interesting cmaps */
|
2004-06-16 22:06:26 +02:00
|
|
|
for(i = 0; i < ft_face->num_charmaps; i++) {
|
|
|
|
switch(ft_face->charmaps[i]->encoding) {
|
2004-09-15 20:03:32 +02:00
|
|
|
case FT_ENCODING_UNICODE:
|
|
|
|
case FT_ENCODING_APPLE_ROMAN:
|
2004-08-18 00:08:31 +02:00
|
|
|
face->fs.fsCsb[0] |= 1;
|
2004-06-16 22:06:26 +02:00
|
|
|
break;
|
2004-09-15 20:03:32 +02:00
|
|
|
case FT_ENCODING_MS_SYMBOL:
|
2004-08-18 00:08:31 +02:00
|
|
|
face->fs.fsCsb[0] |= 1L << 31;
|
2004-06-16 22:06:26 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
if(face->fs.fsCsb[0] & ~(1L << 31))
|
2004-06-16 22:06:26 +02:00
|
|
|
have_installed_roman_font = TRUE;
|
|
|
|
} while(!FT_IS_SCALABLE(ft_face) && ++bitmap_num < ft_face->num_fixed_sizes);
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
num_faces = ft_face->num_faces;
|
|
|
|
pFT_Done_Face(ft_face);
|
2004-08-18 00:08:31 +02:00
|
|
|
TRACE("Added font %s %s\n", debugstr_w(family->FamilyName),
|
2002-06-22 03:19:29 +02:00
|
|
|
debugstr_w(StyleW));
|
|
|
|
} while(num_faces > ++face_index);
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DumpFontList(void)
|
|
|
|
{
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
2001-09-12 22:21:06 +02:00
|
|
|
TRACE("Family: %s\n", debugstr_w(family->FamilyName));
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2005-08-19 11:58:32 +02:00
|
|
|
TRACE("\t%s\t%08lx", debugstr_w(face->StyleName), face->fs.fsCsb[0]);
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!face->scalable)
|
|
|
|
TRACE(" %ld", face->size.y_ppem >> 6);
|
|
|
|
TRACE("\n");
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-03 22:51:20 +02:00
|
|
|
static void DumpSubstList(void)
|
|
|
|
{
|
|
|
|
FontSubst *psub;
|
|
|
|
|
|
|
|
for(psub = substlist; psub; psub = psub->next)
|
|
|
|
if(psub->from.charset != -1 || psub->to.charset != -1)
|
|
|
|
TRACE("%s:%d -> %s:%d\n", debugstr_w(psub->from.name),
|
|
|
|
psub->from.charset, debugstr_w(psub->to.name), psub->to.charset);
|
|
|
|
else
|
|
|
|
TRACE("%s -> %s\n", debugstr_w(psub->from.name),
|
|
|
|
debugstr_w(psub->to.name));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
static LPWSTR strdupW(LPWSTR p)
|
|
|
|
{
|
|
|
|
LPWSTR ret;
|
|
|
|
DWORD len = (strlenW(p) + 1) * sizeof(WCHAR);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
memcpy(ret, p, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-04-03 22:51:20 +02:00
|
|
|
static void split_subst_info(NameCs *nc, LPSTR str)
|
|
|
|
{
|
|
|
|
CHAR *p = strrchr(str, ',');
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
nc->charset = -1;
|
|
|
|
if(p && *(p+1)) {
|
|
|
|
nc->charset = strtol(p+1, NULL, 10);
|
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
|
|
|
nc->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, nc->name, len);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-03 22:51:20 +02:00
|
|
|
static void LoadSubstList(void)
|
|
|
|
{
|
|
|
|
FontSubst *psub, **ppsub;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
|
|
|
|
LPSTR value;
|
|
|
|
LPVOID data;
|
|
|
|
|
|
|
|
if(substlist) {
|
|
|
|
for(psub = substlist; psub;) {
|
|
|
|
FontSubst *ptmp;
|
|
|
|
HeapFree(GetProcessHeap(), 0, psub->to.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, psub->from.name);
|
|
|
|
ptmp = psub;
|
|
|
|
psub = psub->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptmp);
|
|
|
|
}
|
|
|
|
substlist = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(RegOpenKeyA(HKEY_LOCAL_MACHINE,
|
|
|
|
"Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes",
|
|
|
|
&hkey) == ERROR_SUCCESS) {
|
|
|
|
|
|
|
|
RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
&valuelen, &datalen, NULL, NULL);
|
|
|
|
|
|
|
|
valuelen++; /* returned value doesn't include room for '\0' */
|
|
|
|
value = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(CHAR));
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, datalen);
|
|
|
|
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
ppsub = &substlist;
|
|
|
|
while(RegEnumValueA(hkey, i++, value, &vlen, NULL, &type, data,
|
|
|
|
&dlen) == ERROR_SUCCESS) {
|
|
|
|
TRACE("Got %s=%s\n", debugstr_a(value), debugstr_a(data));
|
|
|
|
|
|
|
|
*ppsub = HeapAlloc(GetProcessHeap(), 0, sizeof(**ppsub));
|
|
|
|
(*ppsub)->next = NULL;
|
|
|
|
split_subst_info(&((*ppsub)->from), value);
|
|
|
|
split_subst_info(&((*ppsub)->to), data);
|
|
|
|
|
|
|
|
/* Win 2000 doesn't allow mapping between different charsets
|
|
|
|
or mapping of DEFAULT_CHARSET */
|
|
|
|
if(((*ppsub)->to.charset != (*ppsub)->from.charset) ||
|
|
|
|
(*ppsub)->to.charset == DEFAULT_CHARSET) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, (*ppsub)->to.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (*ppsub)->from.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, *ppsub);
|
2002-08-17 03:38:48 +02:00
|
|
|
*ppsub = NULL;
|
2002-04-03 22:51:20 +02:00
|
|
|
} else {
|
|
|
|
ppsub = &((*ppsub)->next);
|
|
|
|
}
|
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, value);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
/***********************************************************
|
|
|
|
* The replacement list is a way to map an entire font
|
|
|
|
* family onto another family. For example adding
|
|
|
|
*
|
2005-06-14 14:33:19 +02:00
|
|
|
* [HKCU\Software\Wine\Fonts\Replacements]
|
2003-06-23 22:51:06 +02:00
|
|
|
* "Wingdings"="Winedings"
|
|
|
|
*
|
|
|
|
* would enumerate the Winedings font both as Winedings and
|
|
|
|
* Wingdings. However if a real Wingdings font is present the
|
|
|
|
* replacement does not take place.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void LoadReplaceList(void)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
|
|
|
|
LPSTR value;
|
|
|
|
LPVOID data;
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2003-06-23 22:51:06 +02:00
|
|
|
WCHAR old_nameW[200];
|
|
|
|
|
2005-06-14 14:33:19 +02:00
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Fonts\Replacements */
|
|
|
|
if(RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts\\Replacements", &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
2003-06-23 22:51:06 +02:00
|
|
|
RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
&valuelen, &datalen, NULL, NULL);
|
|
|
|
|
|
|
|
valuelen++; /* returned value doesn't include room for '\0' */
|
|
|
|
value = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(CHAR));
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, datalen);
|
|
|
|
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
while(RegEnumValueA(hkey, i++, value, &vlen, NULL, &type, data,
|
|
|
|
&dlen) == ERROR_SUCCESS) {
|
|
|
|
TRACE("Got %s=%s\n", debugstr_a(value), debugstr_a(data));
|
|
|
|
/* "NewName"="Oldname" */
|
|
|
|
if(!MultiByteToWideChar(CP_ACP, 0, data, -1, old_nameW, sizeof(old_nameW)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Find the old family and hence all of the font files
|
|
|
|
in that family */
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpiW(family->FamilyName, old_nameW)) {
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2003-06-23 22:51:06 +02:00
|
|
|
TRACE("mapping %s %s to %s\n", debugstr_w(family->FamilyName),
|
|
|
|
debugstr_w(face->StyleName), value);
|
|
|
|
/* Now add a new entry with the new family name */
|
2004-07-14 23:42:35 +02:00
|
|
|
AddFontFileToList(face->file, value, ADDFONT_FORCE_BITMAP | (face->external ? ADDFONT_EXTERNAL_FONT : 0));
|
2003-06-23 22:51:06 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, value);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
static BOOL ReadFontDir(const char *dirname, BOOL external_fonts)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dent;
|
|
|
|
char path[MAX_PATH];
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
TRACE("Loading fonts from %s\n", debugstr_a(dirname));
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
dir = opendir(dirname);
|
|
|
|
if(!dir) {
|
|
|
|
ERR("Can't open directory %s\n", debugstr_a(dirname));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
while((dent = readdir(dir)) != NULL) {
|
2002-01-29 04:02:50 +01:00
|
|
|
struct stat statbuf;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
if(!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
|
|
|
|
continue;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
TRACE("Found %s in %s\n", debugstr_a(dent->d_name), debugstr_a(dirname));
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
sprintf(path, "%s/%s", dirname, dent->d_name);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
if(stat(path, &statbuf) == -1)
|
|
|
|
{
|
|
|
|
WARN("Can't stat %s\n", debugstr_a(path));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(S_ISDIR(statbuf.st_mode))
|
2004-03-09 04:43:54 +01:00
|
|
|
ReadFontDir(path, external_fonts);
|
2002-01-29 04:02:50 +01:00
|
|
|
else
|
2004-06-16 22:06:26 +02:00
|
|
|
AddFontFileToList(path, NULL, external_fonts ? ADDFONT_EXTERNAL_FONT : 0);
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2002-11-14 00:54:50 +01:00
|
|
|
closedir(dir);
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-09 01:30:13 +01:00
|
|
|
static void load_fontconfig_fonts(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_FONTCONFIG_FONTCONFIG_H
|
|
|
|
void *fc_handle = NULL;
|
|
|
|
FcConfig *config;
|
|
|
|
FcPattern *pat;
|
|
|
|
FcObjectSet *os;
|
|
|
|
FcFontSet *fontset;
|
|
|
|
FcValue v;
|
|
|
|
int i, len;
|
2005-08-08 17:03:42 +02:00
|
|
|
const char *file, *ext;
|
2003-11-09 01:30:13 +01:00
|
|
|
|
|
|
|
fc_handle = wine_dlopen(SONAME_LIBFONTCONFIG, RTLD_NOW, NULL, 0);
|
|
|
|
if(!fc_handle) {
|
|
|
|
TRACE("Wine cannot find the fontconfig library (%s).\n",
|
|
|
|
SONAME_LIBFONTCONFIG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(fc_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
|
|
|
|
LOAD_FUNCPTR(FcConfigGetCurrent);
|
|
|
|
LOAD_FUNCPTR(FcFontList);
|
|
|
|
LOAD_FUNCPTR(FcFontSetDestroy);
|
|
|
|
LOAD_FUNCPTR(FcInit);
|
|
|
|
LOAD_FUNCPTR(FcObjectSetAdd);
|
|
|
|
LOAD_FUNCPTR(FcObjectSetCreate);
|
|
|
|
LOAD_FUNCPTR(FcObjectSetDestroy);
|
|
|
|
LOAD_FUNCPTR(FcPatternCreate);
|
|
|
|
LOAD_FUNCPTR(FcPatternDestroy);
|
|
|
|
LOAD_FUNCPTR(FcPatternGet);
|
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
if(!pFcInit()) return;
|
|
|
|
|
|
|
|
config = pFcConfigGetCurrent();
|
|
|
|
pat = pFcPatternCreate();
|
|
|
|
os = pFcObjectSetCreate();
|
|
|
|
pFcObjectSetAdd(os, FC_FILE);
|
|
|
|
fontset = pFcFontList(config, pat, os);
|
|
|
|
if(!fontset) return;
|
|
|
|
for(i = 0; i < fontset->nfont; i++) {
|
|
|
|
if(pFcPatternGet(fontset->fonts[i], FC_FILE, 0, &v) != FcResultMatch)
|
|
|
|
continue;
|
|
|
|
if(v.type != FcTypeString) continue;
|
2005-08-08 17:03:42 +02:00
|
|
|
file = (LPCSTR) v.u.s;
|
|
|
|
TRACE("fontconfig: %s\n", file);
|
2003-11-09 01:30:13 +01:00
|
|
|
|
|
|
|
/* We're just interested in OT/TT fonts for now, so this hack just
|
|
|
|
picks up the standard extensions to save time loading every other
|
|
|
|
font */
|
2005-08-08 17:03:42 +02:00
|
|
|
len = strlen( file );
|
2003-11-09 01:30:13 +01:00
|
|
|
if(len < 4) continue;
|
2005-08-08 17:03:42 +02:00
|
|
|
ext = &file[ len - 3 ];
|
2003-11-09 01:30:13 +01:00
|
|
|
if(!strcasecmp(ext, "ttf") || !strcasecmp(ext, "ttc") || !strcasecmp(ext, "otf"))
|
2005-08-08 17:03:42 +02:00
|
|
|
AddFontFileToList(file, NULL, ADDFONT_EXTERNAL_FONT);
|
2003-11-09 01:30:13 +01:00
|
|
|
}
|
|
|
|
pFcFontSetDestroy(fontset);
|
|
|
|
pFcObjectSetDestroy(os);
|
|
|
|
pFcPatternDestroy(pat);
|
|
|
|
sym_not_found:
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2004-03-09 04:43:54 +01:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2005-04-11 15:00:28 +02:00
|
|
|
static void load_system_fonts(void)
|
2004-06-16 22:06:26 +02:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
WCHAR data[MAX_PATH], windowsdir[MAX_PATH], pathW[MAX_PATH];
|
|
|
|
const WCHAR **value;
|
|
|
|
DWORD dlen, type;
|
|
|
|
static const WCHAR fmtW[] = {'%','s','\\','%','s','\0'};
|
|
|
|
char *unixname;
|
|
|
|
|
|
|
|
if(RegOpenKeyW(HKEY_CURRENT_CONFIG, system_fonts_reg_key, &hkey) == ERROR_SUCCESS) {
|
|
|
|
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
|
|
|
|
strcatW(windowsdir, fontsW);
|
|
|
|
for(value = SystemFontValues; *value; value++) {
|
|
|
|
dlen = sizeof(data);
|
|
|
|
if(RegQueryValueExW(hkey, *value, 0, &type, (void*)data, &dlen) == ERROR_SUCCESS &&
|
|
|
|
type == REG_SZ) {
|
|
|
|
sprintfW(pathW, fmtW, windowsdir, data);
|
|
|
|
if((unixname = wine_get_unix_file_name(pathW))) {
|
|
|
|
AddFontFileToList(unixname, NULL, ADDFONT_FORCE_BITMAP);
|
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
/*************************************************************
|
|
|
|
*
|
|
|
|
* This adds registry entries for any externally loaded fonts
|
|
|
|
* (fonts from fontconfig or FontDirs). It also deletes entries
|
|
|
|
* of no longer existing fonts.
|
|
|
|
*
|
|
|
|
*/
|
2005-04-11 15:00:28 +02:00
|
|
|
static void update_reg_entries(void)
|
2004-03-09 04:43:54 +01:00
|
|
|
{
|
|
|
|
HKEY winkey = 0, externalkey = 0;
|
|
|
|
LPWSTR valueW;
|
|
|
|
LPVOID data;
|
|
|
|
DWORD dlen, vlen, datalen, valuelen, i, type, len, len_fam;
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2004-03-09 04:43:54 +01:00
|
|
|
WCHAR *file;
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR TrueType[] = {' ','(','T','r','u','e','T','y','p','e',')','\0'};
|
|
|
|
static const WCHAR spaceW[] = {' ', '\0'};
|
2004-03-09 04:43:54 +01:00
|
|
|
char *path;
|
|
|
|
|
|
|
|
if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, is_win9x() ? win9x_font_reg_key : winnt_font_reg_key,
|
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &winkey, NULL) != ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Windows font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
2005-06-14 14:33:19 +02:00
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Fonts\ExternalFonts */
|
|
|
|
if(RegCreateKeyW(HKEY_CURRENT_USER, external_fonts_reg_key, &externalkey) != ERROR_SUCCESS) {
|
2004-03-09 04:43:54 +01:00
|
|
|
ERR("Can't create external font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete all external fonts added last time */
|
|
|
|
|
|
|
|
RegQueryInfoKeyW(externalkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
&valuelen, &datalen, NULL, NULL);
|
|
|
|
valuelen++; /* returned value doesn't include room for '\0' */
|
|
|
|
valueW = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(WCHAR));
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, datalen * sizeof(WCHAR));
|
|
|
|
|
|
|
|
dlen = datalen * sizeof(WCHAR);
|
|
|
|
vlen = valuelen;
|
|
|
|
i = 0;
|
|
|
|
while(RegEnumValueW(externalkey, i++, valueW, &vlen, NULL, &type, data,
|
|
|
|
&dlen) == ERROR_SUCCESS) {
|
|
|
|
|
|
|
|
RegDeleteValueW(winkey, valueW);
|
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, valueW);
|
|
|
|
|
|
|
|
/* Delete the old external fonts key */
|
|
|
|
RegCloseKey(externalkey);
|
|
|
|
externalkey = 0;
|
2005-06-28 21:15:17 +02:00
|
|
|
RegDeleteKeyW(HKEY_CURRENT_USER, external_fonts_reg_key);
|
2004-03-09 04:43:54 +01:00
|
|
|
|
2005-06-28 21:15:17 +02:00
|
|
|
if(RegCreateKeyExW(HKEY_CURRENT_USER, external_fonts_reg_key,
|
2004-03-09 04:43:54 +01:00
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &externalkey, NULL) != ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create external font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enumerate the fonts and add external ones to the two keys */
|
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
2004-03-09 04:43:54 +01:00
|
|
|
len_fam = strlenW(family->FamilyName) + sizeof(TrueType) / sizeof(WCHAR) + 1;
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2004-03-09 04:43:54 +01:00
|
|
|
if(!face->external) continue;
|
|
|
|
len = len_fam;
|
|
|
|
if(strcmpiW(face->StyleName, RegularW))
|
|
|
|
len = len_fam + strlenW(face->StyleName) + 1;
|
|
|
|
valueW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
strcpyW(valueW, family->FamilyName);
|
|
|
|
if(len != len_fam) {
|
|
|
|
strcatW(valueW, spaceW);
|
|
|
|
strcatW(valueW, face->StyleName);
|
|
|
|
}
|
|
|
|
strcatW(valueW, TrueType);
|
|
|
|
if((path = strrchr(face->file, '/')) == NULL)
|
|
|
|
path = face->file;
|
|
|
|
else
|
|
|
|
path++;
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
|
|
|
|
|
|
|
file = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, path, -1, file, len);
|
|
|
|
RegSetValueExW(winkey, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));
|
|
|
|
RegSetValueExW(externalkey, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, valueW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end:
|
|
|
|
if(externalkey)
|
|
|
|
RegCloseKey(externalkey);
|
|
|
|
if(winkey)
|
|
|
|
RegCloseKey(winkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngAddFontResourceEx
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
|
|
|
if (ft_handle) /* do it only if we have freetype up and running */
|
|
|
|
{
|
2004-04-14 21:40:53 +02:00
|
|
|
char *unixname;
|
2002-06-22 03:19:29 +02:00
|
|
|
|
|
|
|
if(flags)
|
|
|
|
FIXME("Ignoring flags %lx\n", flags);
|
|
|
|
|
2004-04-14 21:40:53 +02:00
|
|
|
if((unixname = wine_get_unix_file_name(file)))
|
|
|
|
{
|
2004-06-16 22:06:26 +02:00
|
|
|
AddFontFileToList(unixname, NULL, ADDFONT_FORCE_BITMAP);
|
2004-04-14 21:40:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngRemoveFontResourceEx
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
|
|
|
FIXME(":stub\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngInit
|
|
|
|
*
|
|
|
|
* Initialize FreeType library and create a list of available faces
|
|
|
|
*/
|
|
|
|
BOOL WineEngInit(void)
|
|
|
|
{
|
2004-06-16 22:06:26 +02:00
|
|
|
static const WCHAR dot_fonW[] = {'.','f','o','n','\0'};
|
2005-06-14 14:33:19 +02:00
|
|
|
static const WCHAR pathW[] = {'P','a','t','h',0};
|
2001-09-12 22:21:06 +02:00
|
|
|
HKEY hkey;
|
|
|
|
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
|
|
|
|
LPVOID data;
|
2004-01-06 00:42:09 +01:00
|
|
|
WCHAR windowsdir[MAX_PATH];
|
2004-04-14 21:40:53 +02:00
|
|
|
char *unixname;
|
2004-03-09 04:43:54 +01:00
|
|
|
HANDLE font_mutex;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
TRACE("\n");
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-05-20 20:29:58 +02:00
|
|
|
ft_handle = wine_dlopen(SONAME_LIBFREETYPE, RTLD_NOW, NULL, 0);
|
2002-04-03 22:02:39 +02:00
|
|
|
if(!ft_handle) {
|
|
|
|
WINE_MESSAGE(
|
|
|
|
"Wine cannot find the FreeType font library. To enable Wine to\n"
|
|
|
|
"use TrueType fonts please install a version of FreeType greater than\n"
|
|
|
|
"or equal to 2.0.5.\n"
|
|
|
|
"http://www.freetype.org\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ft_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
LOAD_FUNCPTR(FT_Vector_Unit)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Done_Face)
|
|
|
|
LOAD_FUNCPTR(FT_Get_Char_Index)
|
|
|
|
LOAD_FUNCPTR(FT_Get_Sfnt_Table)
|
|
|
|
LOAD_FUNCPTR(FT_Init_FreeType)
|
|
|
|
LOAD_FUNCPTR(FT_Load_Glyph)
|
2003-10-10 02:06:35 +02:00
|
|
|
LOAD_FUNCPTR(FT_Matrix_Multiply)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_MulFix)
|
|
|
|
LOAD_FUNCPTR(FT_New_Face)
|
|
|
|
LOAD_FUNCPTR(FT_Outline_Get_Bitmap)
|
|
|
|
LOAD_FUNCPTR(FT_Outline_Transform)
|
|
|
|
LOAD_FUNCPTR(FT_Outline_Translate)
|
|
|
|
LOAD_FUNCPTR(FT_Select_Charmap)
|
|
|
|
LOAD_FUNCPTR(FT_Set_Pixel_Sizes)
|
2003-10-10 02:06:35 +02:00
|
|
|
LOAD_FUNCPTR(FT_Vector_Transform)
|
2002-04-03 22:02:39 +02:00
|
|
|
|
|
|
|
#undef LOAD_FUNCPTR
|
2002-08-17 20:34:34 +02:00
|
|
|
/* Don't warn if this one is missing */
|
|
|
|
pFT_Library_Version = wine_dlsym(ft_handle, "FT_Library_Version", NULL, 0);
|
2003-06-23 22:51:06 +02:00
|
|
|
pFT_Load_Sfnt_Table = wine_dlsym(ft_handle, "FT_Load_Sfnt_Table", NULL, 0);
|
2003-12-15 20:50:59 +01:00
|
|
|
pFT_Get_First_Char = wine_dlsym(ft_handle, "FT_Get_First_Char", NULL, 0);
|
2004-06-16 22:06:26 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
pFT_Get_WinFNT_Header = wine_dlsym(ft_handle, "FT_Get_WinFNT_Header", NULL, 0);
|
|
|
|
#endif
|
2002-04-03 22:02:39 +02:00
|
|
|
if(!wine_dlsym(ft_handle, "FT_Get_Postscript_Name", NULL, 0) &&
|
|
|
|
!wine_dlsym(ft_handle, "FT_Sqrt64", NULL, 0)) {
|
|
|
|
/* try to avoid 2.0.4: >= 2.0.5 has FT_Get_Postscript_Name and
|
|
|
|
<= 2.0.3 has FT_Sqrt64 */
|
|
|
|
goto sym_not_found;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
if(pFT_Init_FreeType(&library) != 0) {
|
2001-09-12 22:21:06 +02:00
|
|
|
ERR("Can't init FreeType library\n");
|
2002-04-03 22:02:39 +02:00
|
|
|
wine_dlclose(ft_handle, NULL, 0);
|
2002-06-22 03:19:29 +02:00
|
|
|
ft_handle = NULL;
|
2001-09-12 22:21:06 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-08-17 20:34:34 +02:00
|
|
|
FT_Version.major=FT_Version.minor=FT_Version.patch=-1;
|
|
|
|
if (pFT_Library_Version)
|
|
|
|
{
|
|
|
|
pFT_Library_Version(library,&FT_Version.major,&FT_Version.minor,&FT_Version.patch);
|
|
|
|
}
|
|
|
|
if (FT_Version.major<=0)
|
|
|
|
{
|
|
|
|
FT_Version.major=2;
|
|
|
|
FT_Version.minor=0;
|
|
|
|
FT_Version.patch=5;
|
|
|
|
}
|
|
|
|
TRACE("FreeType version is %d.%d.%d\n",FT_Version.major,FT_Version.minor,FT_Version.patch);
|
2004-06-16 22:06:26 +02:00
|
|
|
FT_SimpleVersion = ((FT_Version.major << 16) & 0xff0000) |
|
|
|
|
((FT_Version.minor << 8) & 0x00ff00) |
|
|
|
|
((FT_Version.patch ) & 0x0000ff);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
if((font_mutex = CreateMutexW(NULL, FALSE, font_mutex_nameW)) == NULL) {
|
|
|
|
ERR("Failed to create font mutex\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
WaitForSingleObject(font_mutex, INFINITE);
|
|
|
|
|
2004-07-14 23:42:35 +02:00
|
|
|
/* load the system fonts */
|
|
|
|
load_system_fonts();
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
/* load in the fonts from %WINDOWSDIR%\\Fonts first of all */
|
2004-01-06 00:42:09 +01:00
|
|
|
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
|
|
|
|
strcatW(windowsdir, fontsW);
|
2004-04-14 21:40:53 +02:00
|
|
|
if((unixname = wine_get_unix_file_name(windowsdir)))
|
|
|
|
{
|
2004-03-09 04:43:54 +01:00
|
|
|
ReadFontDir(unixname, FALSE);
|
2004-04-14 21:40:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
/* now look under HKLM\Software\Microsoft\Windows[ NT]\CurrentVersion\Fonts
|
2002-06-22 03:19:29 +02:00
|
|
|
for any fonts not installed in %WINDOWSDIR%\Fonts. They will have their
|
2004-06-16 22:06:26 +02:00
|
|
|
full path as the entry. Also look for any .fon fonts, since ReadFontDir
|
|
|
|
will skip these. */
|
2004-03-09 04:43:54 +01:00
|
|
|
if(RegOpenKeyW(HKEY_LOCAL_MACHINE,
|
|
|
|
is_win9x() ? win9x_font_reg_key : winnt_font_reg_key,
|
2002-06-22 03:19:29 +02:00
|
|
|
&hkey) == ERROR_SUCCESS) {
|
2004-01-06 00:42:09 +01:00
|
|
|
LPWSTR valueW;
|
|
|
|
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
2002-06-22 03:19:29 +02:00
|
|
|
&valuelen, &datalen, NULL, NULL);
|
|
|
|
|
|
|
|
valuelen++; /* returned value doesn't include room for '\0' */
|
2004-01-06 00:42:09 +01:00
|
|
|
valueW = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(WCHAR));
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, datalen * sizeof(WCHAR));
|
2004-03-09 20:19:12 +01:00
|
|
|
if (valueW && data)
|
|
|
|
{
|
|
|
|
dlen = datalen * sizeof(WCHAR);
|
|
|
|
vlen = valuelen;
|
|
|
|
while(RegEnumValueW(hkey, i++, valueW, &vlen, NULL, &type, data,
|
|
|
|
&dlen) == ERROR_SUCCESS) {
|
|
|
|
if(((LPWSTR)data)[0] && ((LPWSTR)data)[1] == ':')
|
2004-06-16 22:06:26 +02:00
|
|
|
{
|
2004-04-14 21:40:53 +02:00
|
|
|
if((unixname = wine_get_unix_file_name((LPWSTR)data)))
|
|
|
|
{
|
2004-06-16 22:06:26 +02:00
|
|
|
AddFontFileToList(unixname, NULL, ADDFONT_FORCE_BITMAP);
|
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(dlen / 2 >= 6 && !strcmpiW(((LPWSTR)data) + dlen / 2 - 5, dot_fonW))
|
|
|
|
{
|
|
|
|
WCHAR pathW[MAX_PATH];
|
|
|
|
static const WCHAR fmtW[] = {'%','s','\\','%','s','\0'};
|
|
|
|
sprintfW(pathW, fmtW, windowsdir, data);
|
|
|
|
if((unixname = wine_get_unix_file_name(pathW)))
|
|
|
|
{
|
|
|
|
AddFontFileToList(unixname, NULL, ADDFONT_FORCE_BITMAP);
|
2004-04-14 21:40:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
2004-03-09 20:19:12 +01:00
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
}
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, valueW);
|
2002-06-22 03:19:29 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
2003-11-09 01:30:13 +01:00
|
|
|
load_fontconfig_fonts();
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
/* then look in any directories that we've specified in the config file */
|
2005-06-14 14:33:19 +02:00
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Fonts */
|
|
|
|
if(RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts", &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
LPWSTR valueW;
|
|
|
|
LPSTR valueA, ptr;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2005-06-14 14:33:19 +02:00
|
|
|
if (RegQueryValueExW( hkey, pathW, NULL, NULL, NULL, &len ) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
len += sizeof(WCHAR);
|
|
|
|
valueW = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
if (RegQueryValueExW( hkey, pathW, NULL, NULL, (LPBYTE)valueW, &len ) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, NULL, 0, NULL, NULL );
|
|
|
|
valueA = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
WideCharToMultiByte( CP_UNIXCP, 0, valueW, -1, valueA, len, NULL, NULL );
|
|
|
|
TRACE( "got font path %s\n", debugstr_a(valueA) );
|
|
|
|
ptr = valueA;
|
|
|
|
while (ptr)
|
|
|
|
{
|
|
|
|
LPSTR next = strchr( ptr, ':' );
|
|
|
|
if (next) *next++ = 0;
|
|
|
|
ReadFontDir( ptr, TRUE );
|
|
|
|
ptr = next;
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, valueA );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, valueW );
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
DumpFontList();
|
2002-04-03 22:51:20 +02:00
|
|
|
LoadSubstList();
|
|
|
|
DumpSubstList();
|
2003-06-23 22:51:06 +02:00
|
|
|
LoadReplaceList();
|
2004-03-09 04:43:54 +01:00
|
|
|
update_reg_entries();
|
|
|
|
|
|
|
|
ReleaseMutex(font_mutex);
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
2002-04-03 22:02:39 +02:00
|
|
|
sym_not_found:
|
|
|
|
WINE_MESSAGE(
|
|
|
|
"Wine cannot find certain functions that it needs inside the FreeType\n"
|
|
|
|
"font library. To enable Wine to use TrueType fonts please upgrade\n"
|
|
|
|
"FreeType to at least version 2.0.5.\n"
|
|
|
|
"http://www.freetype.org\n");
|
|
|
|
wine_dlclose(ft_handle, NULL, 0);
|
2002-06-22 03:19:29 +02:00
|
|
|
ft_handle = NULL;
|
2002-04-03 22:02:39 +02:00
|
|
|
return FALSE;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
static LONG calc_ppem_for_height(FT_Face ft_face, LONG height)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
TT_OS2 *pOS2;
|
2003-12-08 22:53:15 +01:00
|
|
|
TT_HoriHeader *pHori;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
LONG ppem;
|
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);
|
2003-12-08 22:53:15 +01:00
|
|
|
pHori = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
if(height == 0) height = 16;
|
|
|
|
|
|
|
|
/* Calc. height of EM square:
|
|
|
|
*
|
|
|
|
* For +ve lfHeight we have
|
|
|
|
* lfHeight = (winAscent + winDescent) * ppem / units_per_em
|
|
|
|
* Re-arranging gives:
|
|
|
|
* ppem = units_per_em * lfheight / (winAscent + winDescent)
|
|
|
|
*
|
|
|
|
* For -ve lfHeight we have
|
|
|
|
* |lfHeight| = ppem
|
|
|
|
* [i.e. |lfHeight| = (winAscent + winDescent - il) * ppem / units_per_em
|
|
|
|
* with il = winAscent + winDescent - units_per_em]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-12-08 22:53:15 +01:00
|
|
|
if(height > 0) {
|
|
|
|
if(pOS2->usWinAscent + pOS2->usWinDescent == 0)
|
|
|
|
ppem = ft_face->units_per_EM * height /
|
|
|
|
(pHori->Ascender - pHori->Descender);
|
|
|
|
else
|
|
|
|
ppem = ft_face->units_per_EM * height /
|
|
|
|
(pOS2->usWinAscent + pOS2->usWinDescent);
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
else
|
|
|
|
ppem = -height;
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
return ppem;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG load_VDMX(GdiFont, LONG);
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
static FT_Face OpenFontFile(GdiFont font, char *file, FT_Long face_index, LONG width, LONG height)
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
|
|
|
FT_Error err;
|
|
|
|
FT_Face ft_face;
|
|
|
|
LONG ppem;
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
err = pFT_New_Face(library, file, face_index, &ft_face);
|
2002-01-29 04:02:50 +01:00
|
|
|
if(err) {
|
|
|
|
ERR("FT_New_Face rets %d\n", err);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set it here, as load_VDMX needs it */
|
|
|
|
font->ft_face = ft_face;
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(FT_IS_SCALABLE(ft_face)) {
|
|
|
|
/* load the VDMX table if we have one */
|
|
|
|
ppem = load_VDMX(font, height);
|
|
|
|
if(ppem == 0)
|
|
|
|
ppem = calc_ppem_for_height(ft_face, height);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if((err = pFT_Set_Pixel_Sizes(ft_face, 0, ppem)) != 0)
|
|
|
|
WARN("FT_Set_Pixel_Sizes %d, %ld rets %x\n", 0, ppem, err);
|
|
|
|
} else {
|
|
|
|
if((err = pFT_Set_Pixel_Sizes(ft_face, width, height)) != 0)
|
|
|
|
WARN("FT_Set_Pixel_Sizes %ld, %ld rets %x\n", width, height, err);
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
return ft_face;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2004-08-26 20:24:03 +02:00
|
|
|
static int get_nearest_charset(Face *face, int *cp)
|
2002-06-22 03:19:29 +02:00
|
|
|
{
|
|
|
|
/* Only get here if lfCharSet == DEFAULT_CHARSET or we couldn't find
|
|
|
|
a single face with the requested charset. The idea is to check if
|
|
|
|
the selected font supports the current ANSI codepage, if it does
|
|
|
|
return the corresponding charset, else return the first charset */
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
CHARSETINFO csi;
|
|
|
|
int acp = GetACP(), i;
|
|
|
|
DWORD fs0;
|
|
|
|
|
2004-08-26 20:24:03 +02:00
|
|
|
*cp = acp;
|
2002-06-22 03:19:29 +02:00
|
|
|
if(TranslateCharsetInfo((DWORD*)acp, &csi, TCI_SRCCODEPAGE))
|
2003-06-23 22:51:06 +02:00
|
|
|
if(csi.fs.fsCsb[0] & face->fs.fsCsb[0])
|
2002-06-22 03:19:29 +02:00
|
|
|
return csi.ciCharset;
|
|
|
|
|
|
|
|
for(i = 0; i < 32; i++) {
|
|
|
|
fs0 = 1L << i;
|
2003-06-23 22:51:06 +02:00
|
|
|
if(face->fs.fsCsb[0] & fs0) {
|
2004-08-26 20:24:03 +02:00
|
|
|
if(TranslateCharsetInfo(&fs0, &csi, TCI_SRCFONTSIG)) {
|
|
|
|
*cp = csi.ciACP;
|
2002-06-22 03:19:29 +02:00
|
|
|
return csi.ciCharset;
|
2004-08-26 20:24:03 +02:00
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
else
|
|
|
|
FIXME("TCI failing on %lx\n", fs0);
|
|
|
|
}
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
FIXME("returning DEFAULT_CHARSET face->fs.fsCsb[0] = %08lx file = %s\n",
|
|
|
|
face->fs.fsCsb[0], face->file);
|
2004-08-26 20:24:03 +02:00
|
|
|
*cp = acp;
|
2002-01-29 04:02:50 +01:00
|
|
|
return DEFAULT_CHARSET;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdiFont alloc_font(void)
|
|
|
|
{
|
|
|
|
GdiFont ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
|
|
|
|
ret->gmsize = INIT_GM_SIZE;
|
|
|
|
ret->gm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
ret->gmsize * sizeof(*ret->gm));
|
2002-06-22 03:19:29 +02:00
|
|
|
ret->potm = NULL;
|
2004-08-06 19:31:39 +02:00
|
|
|
ret->font_desc.matrix.eM11 = ret->font_desc.matrix.eM22 = 1.0;
|
|
|
|
list_init(&ret->hfontlist);
|
2002-01-29 04:02:50 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_font(GdiFont font)
|
|
|
|
{
|
2002-04-03 22:02:39 +02:00
|
|
|
if (font->ft_face) pFT_Done_Face(font->ft_face);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, font->potm);
|
|
|
|
HeapFree(GetProcessHeap(), 0, font->name);
|
2002-01-29 04:02:50 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, font->gm);
|
|
|
|
HeapFree(GetProcessHeap(), 0, font);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* load_VDMX
|
|
|
|
*
|
|
|
|
* load the vdmx entry for the specified height
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
|
|
|
|
( ( (FT_ULong)_x4 << 24 ) | \
|
|
|
|
( (FT_ULong)_x3 << 16 ) | \
|
|
|
|
( (FT_ULong)_x2 << 8 ) | \
|
|
|
|
(FT_ULong)_x1 )
|
|
|
|
|
|
|
|
#define MS_VDMX_TAG MS_MAKE_TAG('V', 'D', 'M', 'X')
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
BYTE bCharSet;
|
|
|
|
BYTE xRatio;
|
|
|
|
BYTE yStartRatio;
|
|
|
|
BYTE yEndRatio;
|
|
|
|
} Ratios;
|
|
|
|
|
|
|
|
|
|
|
|
static LONG load_VDMX(GdiFont font, LONG height)
|
|
|
|
{
|
|
|
|
BYTE hdr[6], tmp[2], group[4];
|
|
|
|
BYTE devXRatio, devYRatio;
|
|
|
|
USHORT numRecs, numRatios;
|
2004-09-08 03:23:57 +02:00
|
|
|
DWORD result, offset = -1;
|
2002-01-29 04:02:50 +01:00
|
|
|
LONG ppem = 0;
|
2004-09-08 03:23:57 +02:00
|
|
|
int i;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2005-01-24 20:00:10 +01:00
|
|
|
/* For documentation on VDMX records, see
|
|
|
|
* http://www.microsoft.com/OpenType/OTSpec/vdmx.htm
|
|
|
|
*/
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
result = WineEngGetFontData(font, MS_VDMX_TAG, 0, hdr, 6);
|
|
|
|
|
|
|
|
if(result == GDI_ERROR) /* no vdmx table present, use linear scaling */
|
|
|
|
return ppem;
|
|
|
|
|
|
|
|
/* FIXME: need the real device aspect ratio */
|
|
|
|
devXRatio = 1;
|
|
|
|
devYRatio = 1;
|
|
|
|
|
|
|
|
numRecs = GET_BE_WORD(&hdr[2]);
|
|
|
|
numRatios = GET_BE_WORD(&hdr[4]);
|
|
|
|
|
2002-04-03 23:06:09 +02:00
|
|
|
TRACE("numRecs = %d numRatios = %d\n", numRecs, numRatios);
|
2002-01-29 04:02:50 +01:00
|
|
|
for(i = 0; i < numRatios; i++) {
|
|
|
|
Ratios ratio;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
offset = (3 * 2) + (i * sizeof(Ratios));
|
|
|
|
WineEngGetFontData(font, MS_VDMX_TAG, offset, &ratio, sizeof(Ratios));
|
|
|
|
offset = -1;
|
|
|
|
|
|
|
|
TRACE("Ratios[%d] %d %d : %d -> %d\n", i, ratio.bCharSet, ratio.xRatio, ratio.yStartRatio, ratio.yEndRatio);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if((ratio.xRatio == 0 &&
|
2002-01-29 04:02:50 +01:00
|
|
|
ratio.yStartRatio == 0 &&
|
|
|
|
ratio.yEndRatio == 0) ||
|
2002-06-01 01:06:46 +02:00
|
|
|
(devXRatio == ratio.xRatio &&
|
2002-01-29 04:02:50 +01:00
|
|
|
devYRatio >= ratio.yStartRatio &&
|
2002-06-01 01:06:46 +02:00
|
|
|
devYRatio <= ratio.yEndRatio))
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
|
|
|
offset = (3 * 2) + (numRatios * 4) + (i * 2);
|
|
|
|
WineEngGetFontData(font, MS_VDMX_TAG, offset, tmp, 2);
|
|
|
|
offset = GET_BE_WORD(tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-13 14:14:36 +01:00
|
|
|
if(offset == -1) {
|
2002-05-24 23:17:59 +02:00
|
|
|
FIXME("No suitable ratio found\n");
|
2002-01-29 04:02:50 +01:00
|
|
|
return ppem;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(WineEngGetFontData(font, MS_VDMX_TAG, offset, group, 4) != GDI_ERROR) {
|
|
|
|
USHORT recs;
|
|
|
|
BYTE startsz, endsz;
|
|
|
|
BYTE *vTable;
|
|
|
|
|
|
|
|
recs = GET_BE_WORD(group);
|
|
|
|
startsz = group[2];
|
|
|
|
endsz = group[3];
|
|
|
|
|
|
|
|
TRACE("recs=%d startsz=%d endsz=%d\n", recs, startsz, endsz);
|
|
|
|
|
|
|
|
vTable = HeapAlloc(GetProcessHeap(), 0, recs * 6);
|
|
|
|
result = WineEngGetFontData(font, MS_VDMX_TAG, offset + 4, vTable, recs * 6);
|
|
|
|
if(result == GDI_ERROR) {
|
|
|
|
FIXME("Failed to retrieve vTable\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(height > 0) {
|
|
|
|
for(i = 0; i < recs; i++) {
|
|
|
|
SHORT yMax = GET_BE_WORD(&vTable[(i * 6) + 2]);
|
|
|
|
SHORT yMin = GET_BE_WORD(&vTable[(i * 6) + 4]);
|
|
|
|
ppem = GET_BE_WORD(&vTable[i * 6]);
|
|
|
|
|
|
|
|
if(yMax + -yMin == height) {
|
|
|
|
font->yMax = yMax;
|
|
|
|
font->yMin = yMin;
|
|
|
|
TRACE("ppem %ld found; height=%ld yMax=%d yMin=%d\n", ppem, height, font->yMax, font->yMin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(yMax + -yMin > height) {
|
|
|
|
if(--i < 0) {
|
|
|
|
ppem = 0;
|
|
|
|
goto end; /* failed */
|
|
|
|
}
|
|
|
|
font->yMax = GET_BE_WORD(&vTable[(i * 6) + 2]);
|
|
|
|
font->yMin = GET_BE_WORD(&vTable[(i * 6) + 4]);
|
|
|
|
TRACE("ppem %ld found; height=%ld yMax=%d yMin=%d\n", ppem, height, font->yMax, font->yMin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!font->yMax) {
|
|
|
|
ppem = 0;
|
|
|
|
TRACE("ppem not found for height %ld\n", height);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ppem = -height;
|
|
|
|
if(ppem < startsz || ppem > endsz)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
for(i = 0; i < recs; i++) {
|
|
|
|
USHORT yPelHeight;
|
|
|
|
yPelHeight = GET_BE_WORD(&vTable[i * 6]);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(yPelHeight > ppem)
|
|
|
|
break; /* failed */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(yPelHeight == ppem) {
|
|
|
|
font->yMax = GET_BE_WORD(&vTable[(i * 6) + 2]);
|
|
|
|
font->yMin = GET_BE_WORD(&vTable[(i * 6) + 4]);
|
|
|
|
TRACE("ppem %ld found; yMax=%d yMin=%d\n", ppem, font->yMax, font->yMin);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, vTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ppem;
|
|
|
|
}
|
|
|
|
|
2004-08-06 19:31:39 +02:00
|
|
|
static BOOL fontcmp(GdiFont font, FONT_DESC *fd)
|
|
|
|
{
|
|
|
|
if(font->font_desc.hash != fd->hash) return TRUE;
|
|
|
|
if(memcmp(&font->font_desc.matrix, &fd->matrix, sizeof(fd->matrix))) return TRUE;
|
|
|
|
if(memcmp(&font->font_desc.lf, &fd->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
|
|
|
|
return strcmpiW(font->font_desc.lf.lfFaceName, fd->lf.lfFaceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void calc_hash(FONT_DESC *pfd)
|
|
|
|
{
|
|
|
|
DWORD hash = 0, *ptr, two_chars;
|
|
|
|
WORD *pwc;
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int i;
|
2004-08-06 19:31:39 +02:00
|
|
|
|
|
|
|
for(i = 0, ptr = (DWORD*)&pfd->matrix; i < sizeof(FMAT2)/sizeof(DWORD); i++, ptr++)
|
|
|
|
hash ^= *ptr;
|
|
|
|
for(i = 0, ptr = (DWORD*)&pfd->lf; i < 7; i++, ptr++)
|
|
|
|
hash ^= *ptr;
|
|
|
|
for(i = 0, ptr = (DWORD*)&pfd->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
|
|
|
|
two_chars = *ptr;
|
|
|
|
pwc = (WCHAR *)&two_chars;
|
|
|
|
if(!*pwc) break;
|
|
|
|
*pwc = toupperW(*pwc);
|
|
|
|
pwc++;
|
|
|
|
*pwc = toupperW(*pwc);
|
|
|
|
hash ^= two_chars;
|
|
|
|
if(!*pwc) break;
|
|
|
|
}
|
|
|
|
pfd->hash = hash;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdiFont find_in_cache(HFONT hfont, LOGFONTW *plf, XFORM *pxf, BOOL can_use_bitmap)
|
|
|
|
{
|
|
|
|
GdiFont ret;
|
|
|
|
FONT_DESC fd;
|
|
|
|
HFONTLIST *hflist;
|
|
|
|
struct list *font_elem_ptr, *hfontlist_elem_ptr;
|
|
|
|
|
|
|
|
memcpy(&fd.lf, plf, sizeof(LOGFONTW));
|
|
|
|
memcpy(&fd.matrix, pxf, sizeof(FMAT2));
|
|
|
|
calc_hash(&fd);
|
|
|
|
|
|
|
|
/* try the in-use list */
|
|
|
|
LIST_FOR_EACH(font_elem_ptr, &gdi_font_list) {
|
|
|
|
ret = LIST_ENTRY(font_elem_ptr, struct tagGdiFont, entry);
|
|
|
|
if(!fontcmp(ret, &fd)) {
|
|
|
|
if(!can_use_bitmap && !FT_IS_SCALABLE(ret->ft_face)) continue;
|
|
|
|
LIST_FOR_EACH(hfontlist_elem_ptr, &ret->hfontlist) {
|
|
|
|
hflist = LIST_ENTRY(hfontlist_elem_ptr, struct tagHFONTLIST, entry);
|
|
|
|
if(hflist->hfont == hfont)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
hflist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hflist));
|
|
|
|
hflist->hfont = hfont;
|
|
|
|
list_add_head(&ret->hfontlist, &hflist->entry);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then the unused list */
|
|
|
|
font_elem_ptr = list_head(&unused_gdi_font_list);
|
|
|
|
while(font_elem_ptr) {
|
|
|
|
ret = LIST_ENTRY(font_elem_ptr, struct tagGdiFont, entry);
|
|
|
|
font_elem_ptr = list_next(&unused_gdi_font_list, font_elem_ptr);
|
|
|
|
if(!fontcmp(ret, &fd)) {
|
|
|
|
if(!can_use_bitmap && !FT_IS_SCALABLE(ret->ft_face)) continue;
|
|
|
|
assert(list_empty(&ret->hfontlist));
|
|
|
|
TRACE("Found %p in unused list\n", ret);
|
|
|
|
list_remove(&ret->entry);
|
|
|
|
list_add_head(&gdi_font_list, &ret->entry);
|
|
|
|
hflist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hflist));
|
|
|
|
hflist->hfont = hfont;
|
|
|
|
list_add_head(&ret->hfontlist, &hflist->entry);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngCreateFontInstance
|
|
|
|
*
|
|
|
|
*/
|
2002-04-03 23:06:09 +02:00
|
|
|
GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
GdiFont ret;
|
2004-06-16 22:06:26 +02:00
|
|
|
Face *face, *best;
|
2004-08-18 00:08:31 +02:00
|
|
|
Family *family;
|
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2004-06-16 22:06:26 +02:00
|
|
|
INT height, width = 0;
|
|
|
|
signed int diff = 0, newdiff;
|
|
|
|
BOOL bd, it, can_use_bitmap;
|
2002-06-04 03:02:51 +02:00
|
|
|
LOGFONTW lf;
|
2002-06-22 03:19:29 +02:00
|
|
|
CHARSETINFO csi;
|
2004-08-06 19:31:39 +02:00
|
|
|
HFONTLIST *hflist;
|
2002-06-04 03:02:51 +02:00
|
|
|
|
|
|
|
if (!GetObjectW( hfont, sizeof(lf), &lf )) return NULL;
|
2004-06-16 22:06:26 +02:00
|
|
|
can_use_bitmap = GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_RA_ABLE;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
TRACE("%s, h=%ld, it=%d, weight=%ld, PandF=%02x, charset=%d orient %ld escapement %ld\n",
|
2002-06-04 03:02:51 +02:00
|
|
|
debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
|
|
|
|
lf.lfWeight, lf.lfPitchAndFamily, lf.lfCharSet, lf.lfOrientation,
|
|
|
|
lf.lfEscapement);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
/* check the cache first */
|
2004-08-06 19:31:39 +02:00
|
|
|
if((ret = find_in_cache(hfont, &lf, &dc->xformWorld2Vport, can_use_bitmap)) != NULL) {
|
|
|
|
TRACE("returning cached gdiFont(%p) for hFont %p\n", ret, hfont);
|
|
|
|
return ret;
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
|
2004-08-06 19:31:39 +02:00
|
|
|
TRACE("not in cache\n");
|
2004-08-18 00:08:31 +02:00
|
|
|
if(list_empty(&font_list) || !have_installed_roman_font) /* No fonts installed */
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
|
|
|
TRACE("No fonts installed\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
ret = alloc_font();
|
2004-08-06 19:31:39 +02:00
|
|
|
|
|
|
|
memcpy(&ret->font_desc.matrix, &dc->xformWorld2Vport, sizeof(FMAT2));
|
|
|
|
memcpy(&ret->font_desc.lf, &lf, sizeof(LOGFONTW));
|
|
|
|
calc_hash(&ret->font_desc);
|
|
|
|
hflist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hflist));
|
|
|
|
hflist->hfont = hfont;
|
|
|
|
list_add_head(&ret->hfontlist, &hflist->entry);
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/* If lfFaceName is "Symbol" then Windows fixes up lfCharSet to
|
|
|
|
SYMBOL_CHARSET so that Symbol gets picked irrespective of the
|
|
|
|
original value lfCharSet. Note this is a special case for
|
|
|
|
Symbol and doesn't happen at least for "Wingdings*" */
|
|
|
|
|
|
|
|
if(!strcmpiW(lf.lfFaceName, SymbolW))
|
|
|
|
lf.lfCharSet = SYMBOL_CHARSET;
|
|
|
|
|
|
|
|
if(!TranslateCharsetInfo((DWORD*)(INT)lf.lfCharSet, &csi, TCI_SRCCHARSET)) {
|
|
|
|
switch(lf.lfCharSet) {
|
|
|
|
case DEFAULT_CHARSET:
|
|
|
|
csi.fs.fsCsb[0] = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Untranslated charset %d\n", lf.lfCharSet);
|
|
|
|
csi.fs.fsCsb[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
family = NULL;
|
2002-06-04 03:02:51 +02:00
|
|
|
if(lf.lfFaceName[0] != '\0') {
|
2002-04-03 22:51:20 +02:00
|
|
|
FontSubst *psub;
|
|
|
|
for(psub = substlist; psub; psub = psub->next)
|
2002-06-04 03:02:51 +02:00
|
|
|
if(!strcmpiW(lf.lfFaceName, psub->from.name) &&
|
2002-04-03 22:51:20 +02:00
|
|
|
(psub->from.charset == -1 ||
|
2002-06-04 03:02:51 +02:00
|
|
|
psub->from.charset == lf.lfCharSet))
|
2002-04-03 22:51:20 +02:00
|
|
|
break;
|
|
|
|
if(psub) {
|
2002-06-04 03:02:51 +02:00
|
|
|
TRACE("substituting %s -> %s\n", debugstr_w(lf.lfFaceName),
|
2002-04-03 22:51:20 +02:00
|
|
|
debugstr_w(psub->to.name));
|
2002-06-04 03:02:51 +02:00
|
|
|
strcpyW(lf.lfFaceName, psub->to.name);
|
2002-04-03 22:51:20 +02:00
|
|
|
}
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/* We want a match on name and charset or just name if
|
|
|
|
charset was DEFAULT_CHARSET. If the latter then
|
|
|
|
we fixup the returned charset later in get_nearest_charset
|
|
|
|
where we'll either use the charset of the current ansi codepage
|
|
|
|
or if that's unavailable the first charset that the font supports.
|
|
|
|
*/
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpiW(family->FamilyName, lf.lfFaceName)) {
|
2005-08-19 11:58:32 +02:00
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
if((csi.fs.fsCsb[0] & face->fs.fsCsb[0]) || !csi.fs.fsCsb[0])
|
|
|
|
if(face->scalable || can_use_bitmap)
|
|
|
|
goto found;
|
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
/* If requested charset was DEFAULT_CHARSET then try using charset
|
|
|
|
corresponding to the current ansi codepage */
|
|
|
|
if(!csi.fs.fsCsb[0]) {
|
|
|
|
INT acp = GetACP();
|
|
|
|
if(!TranslateCharsetInfo((DWORD*)acp, &csi, TCI_SRCCODEPAGE)) {
|
|
|
|
FIXME("TCI failed on codepage %d\n", acp);
|
|
|
|
csi.fs.fsCsb[0] = 0;
|
|
|
|
} else
|
|
|
|
lf.lfCharSet = csi.ciCharset;
|
|
|
|
}
|
2003-10-04 06:00:08 +02:00
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
/* Face families are in the top 4 bits of lfPitchAndFamily,
|
|
|
|
so mask with 0xF0 before testing */
|
2003-10-04 06:00:08 +02:00
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
if((lf.lfPitchAndFamily & FIXED_PITCH) ||
|
|
|
|
(lf.lfPitchAndFamily & 0xF0) == FF_MODERN)
|
|
|
|
strcpyW(lf.lfFaceName, defFixed);
|
|
|
|
else if((lf.lfPitchAndFamily & 0xF0) == FF_ROMAN)
|
|
|
|
strcpyW(lf.lfFaceName, defSerif);
|
|
|
|
else if((lf.lfPitchAndFamily & 0xF0) == FF_SWISS)
|
|
|
|
strcpyW(lf.lfFaceName, defSans);
|
|
|
|
else
|
|
|
|
strcpyW(lf.lfFaceName, defSans);
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpiW(family->FamilyName, lf.lfFaceName)) {
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
2004-08-18 00:08:31 +02:00
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
if(csi.fs.fsCsb[0] & face->fs.fsCsb[0])
|
|
|
|
if(face->scalable || can_use_bitmap)
|
2005-08-19 11:58:32 +02:00
|
|
|
goto found;
|
2004-08-18 00:08:31 +02:00
|
|
|
}
|
2005-08-19 11:58:32 +02:00
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
2004-08-18 00:08:31 +02:00
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2005-08-19 11:58:32 +02:00
|
|
|
if(csi.fs.fsCsb[0] & face->fs.fsCsb[0])
|
2004-08-18 00:08:31 +02:00
|
|
|
if(face->scalable || can_use_bitmap)
|
2005-08-19 11:58:32 +02:00
|
|
|
goto found;
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
2004-08-18 00:08:31 +02:00
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
if(face->scalable || can_use_bitmap) {
|
2004-08-11 20:49:34 +02:00
|
|
|
csi.fs.fsCsb[0] = 0;
|
|
|
|
FIXME("just using first face for now\n");
|
2005-08-19 11:58:32 +02:00
|
|
|
goto found;
|
2004-08-11 20:49:34 +02:00
|
|
|
}
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2005-08-19 11:58:32 +02:00
|
|
|
FIXME("can't find a single appropriate font - bailing\n");
|
|
|
|
free_font(ret);
|
|
|
|
return NULL;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
found:
|
2002-06-04 03:02:51 +02:00
|
|
|
it = lf.lfItalic ? 1 : 0;
|
|
|
|
bd = lf.lfWeight > 550 ? 1 : 0;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
height = GDI_ROUND( (FLOAT)lf.lfHeight * dc->xformWorld2Vport.eM22 );
|
|
|
|
height = lf.lfHeight < 0 ? -abs(height) : abs(height);
|
|
|
|
|
2004-08-18 00:08:31 +02:00
|
|
|
face = best = NULL;
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2005-08-19 11:58:32 +02:00
|
|
|
if(!(face->Italic ^ it) && !(face->Bold ^ bd) &&
|
|
|
|
((csi.fs.fsCsb[0] & face->fs.fsCsb[0]) || !csi.fs.fsCsb[0])) {
|
2004-06-16 22:06:26 +02:00
|
|
|
if(face->scalable)
|
|
|
|
break;
|
|
|
|
if(height > 0)
|
|
|
|
newdiff = height - (signed int)(face->size.y_ppem >> 6);
|
|
|
|
else
|
|
|
|
newdiff = -height - ((signed int)(face->size.y_ppem >> 6) - face->size.internal_leading);
|
|
|
|
if(!best || (diff > 0 && newdiff < diff && newdiff >= 0) ||
|
|
|
|
(diff < 0 && newdiff > diff)) {
|
|
|
|
TRACE("%ld is better for %d diff was %d\n", face->size.y_ppem >> 6, height, diff);
|
|
|
|
diff = newdiff;
|
|
|
|
best = face;
|
|
|
|
if(diff == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
face = NULL;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!face && best)
|
|
|
|
face = best;
|
|
|
|
else if(!face) {
|
2004-08-10 00:54:33 +02:00
|
|
|
best = NULL;
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2005-08-19 11:58:32 +02:00
|
|
|
if((csi.fs.fsCsb[0] & face->fs.fsCsb[0]) || !csi.fs.fsCsb[0]) {
|
|
|
|
if(face->scalable)
|
2004-08-10 00:54:33 +02:00
|
|
|
break;
|
2005-08-19 11:58:32 +02:00
|
|
|
if(height > 0)
|
|
|
|
newdiff = height - (signed int)(face->size.y_ppem >> 6);
|
|
|
|
else
|
|
|
|
newdiff = -height - ((signed int)(face->size.y_ppem >> 6) - face->size.internal_leading);
|
|
|
|
if(!best || (diff > 0 && newdiff < diff && newdiff >= 0) ||
|
|
|
|
(diff < 0 && newdiff > diff)) {
|
|
|
|
TRACE("%ld is better for %d diff was %d\n", face->size.y_ppem >> 6, height, diff);
|
|
|
|
diff = newdiff;
|
|
|
|
best = face;
|
|
|
|
if(diff == 0)
|
|
|
|
break;
|
|
|
|
}
|
2004-08-10 00:54:33 +02:00
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
face = NULL;
|
2004-08-10 00:54:33 +02:00
|
|
|
}
|
|
|
|
if(!face && best)
|
|
|
|
face = best;
|
2002-01-29 04:02:50 +01:00
|
|
|
if(it && !face->Italic) ret->fake_italic = TRUE;
|
|
|
|
if(bd && !face->Bold) ret->fake_bold = TRUE;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
memcpy(&ret->fs, &face->fs, sizeof(FONTSIGNATURE));
|
|
|
|
|
2004-08-26 20:24:03 +02:00
|
|
|
if(csi.fs.fsCsb[0]) {
|
2002-06-22 03:19:29 +02:00
|
|
|
ret->charset = lf.lfCharSet;
|
2004-08-26 20:24:03 +02:00
|
|
|
ret->codepage = csi.ciACP;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
else
|
2004-08-26 20:24:03 +02:00
|
|
|
ret->charset = get_nearest_charset(face, &ret->codepage);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
TRACE("Chosen: %s %s (%s:%ld)\n", debugstr_w(family->FamilyName),
|
|
|
|
debugstr_w(face->StyleName), face->file, face->face_index);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!face->scalable) {
|
|
|
|
width = face->size.x_ppem >> 6;
|
|
|
|
height = face->size.y_ppem >> 6;
|
|
|
|
}
|
|
|
|
ret->ft_face = OpenFontFile(ret, face->file, face->face_index, width, height);
|
|
|
|
|
2002-04-03 23:06:09 +02:00
|
|
|
if (!ret->ft_face)
|
|
|
|
{
|
|
|
|
free_font( ret );
|
|
|
|
return 0;
|
|
|
|
}
|
2003-10-28 01:08:28 +01:00
|
|
|
|
2003-10-15 04:33:55 +02:00
|
|
|
if (ret->charset == SYMBOL_CHARSET &&
|
2004-09-15 20:03:32 +02:00
|
|
|
!pFT_Select_Charmap(ret->ft_face, FT_ENCODING_MS_SYMBOL)) {
|
2003-10-15 04:33:55 +02:00
|
|
|
/* No ops */
|
|
|
|
}
|
2004-09-15 20:03:32 +02:00
|
|
|
else if (!pFT_Select_Charmap(ret->ft_face, FT_ENCODING_UNICODE)) {
|
2003-10-15 04:33:55 +02:00
|
|
|
/* No ops */
|
|
|
|
}
|
|
|
|
else {
|
2004-09-15 20:03:32 +02:00
|
|
|
pFT_Select_Charmap(ret->ft_face, FT_ENCODING_APPLE_ROMAN);
|
2003-10-15 04:33:55 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-08-11 21:34:20 +02:00
|
|
|
ret->orientation = FT_IS_SCALABLE(ret->ft_face) ? lf.lfOrientation : 0;
|
2002-06-22 03:19:29 +02:00
|
|
|
ret->name = strdupW(family->FamilyName);
|
2004-07-22 21:42:31 +02:00
|
|
|
ret->underline = lf.lfUnderline ? 0xff : 0;
|
|
|
|
ret->strikeout = lf.lfStrikeOut ? 0xff : 0;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2002-11-22 23:16:53 +01:00
|
|
|
TRACE("caching: gdiFont=%p hfont=%p\n", ret, hfont);
|
2004-08-11 01:42:18 +02:00
|
|
|
|
|
|
|
ret->aveWidth = FT_IS_SCALABLE(ret->ft_face) ? lf.lfWidth : 0;
|
2004-08-04 20:16:13 +02:00
|
|
|
list_add_head(&gdi_font_list, &ret->entry);
|
2001-09-12 22:21:06 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-08-04 20:16:13 +02:00
|
|
|
static void dump_gdi_font_list(void)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2002-01-29 04:02:50 +01:00
|
|
|
GdiFont gdiFont;
|
2004-08-04 20:16:13 +02:00
|
|
|
struct list *elem_ptr;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
TRACE("---------- gdiFont Cache ----------\n");
|
2004-08-04 20:16:13 +02:00
|
|
|
LIST_FOR_EACH(elem_ptr, &gdi_font_list) {
|
|
|
|
gdiFont = LIST_ENTRY(elem_ptr, struct tagGdiFont, entry);
|
2004-08-06 19:31:39 +02:00
|
|
|
TRACE("gdiFont=%p %s %ld\n",
|
|
|
|
gdiFont, debugstr_w(gdiFont->font_desc.lf.lfFaceName), gdiFont->font_desc.lf.lfHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("---------- Unused gdiFont Cache ----------\n");
|
|
|
|
LIST_FOR_EACH(elem_ptr, &unused_gdi_font_list) {
|
|
|
|
gdiFont = LIST_ENTRY(elem_ptr, struct tagGdiFont, entry);
|
|
|
|
TRACE("gdiFont=%p %s %ld\n",
|
|
|
|
gdiFont, debugstr_w(gdiFont->font_desc.lf.lfFaceName), gdiFont->font_desc.lf.lfHeight);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
2002-01-29 04:02:50 +01:00
|
|
|
* WineEngDestroyFontInstance
|
|
|
|
*
|
|
|
|
* free the gdiFont associated with this handle
|
2001-09-12 22:21:06 +02:00
|
|
|
*
|
|
|
|
*/
|
2002-01-29 04:02:50 +01:00
|
|
|
BOOL WineEngDestroyFontInstance(HFONT handle)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2002-01-29 04:02:50 +01:00
|
|
|
GdiFont gdiFont;
|
2004-08-06 19:31:39 +02:00
|
|
|
HFONTLIST *hflist;
|
2002-11-14 00:54:50 +01:00
|
|
|
BOOL ret = FALSE;
|
2004-08-06 19:31:39 +02:00
|
|
|
struct list *font_elem_ptr, *hfontlist_elem_ptr;
|
|
|
|
int i = 0;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-11-22 23:16:53 +01:00
|
|
|
TRACE("destroying hfont=%p\n", handle);
|
2002-01-29 04:02:50 +01:00
|
|
|
if(TRACE_ON(font))
|
2004-08-04 20:16:13 +02:00
|
|
|
dump_gdi_font_list();
|
|
|
|
|
2004-08-06 19:31:39 +02:00
|
|
|
font_elem_ptr = list_head(&gdi_font_list);
|
|
|
|
while(font_elem_ptr) {
|
|
|
|
gdiFont = LIST_ENTRY(font_elem_ptr, struct tagGdiFont, entry);
|
|
|
|
font_elem_ptr = list_next(&gdi_font_list, font_elem_ptr);
|
|
|
|
|
|
|
|
hfontlist_elem_ptr = list_head(&gdiFont->hfontlist);
|
|
|
|
while(hfontlist_elem_ptr) {
|
|
|
|
hflist = LIST_ENTRY(hfontlist_elem_ptr, struct tagHFONTLIST, entry);
|
|
|
|
hfontlist_elem_ptr = list_next(&gdiFont->hfontlist, hfontlist_elem_ptr);
|
|
|
|
if(hflist->hfont == handle) {
|
|
|
|
list_remove(&hflist->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, hflist);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(list_empty(&gdiFont->hfontlist)) {
|
|
|
|
TRACE("Moving to Unused list\n");
|
2004-08-04 20:16:13 +02:00
|
|
|
list_remove(&gdiFont->entry);
|
2004-08-06 19:31:39 +02:00
|
|
|
list_add_head(&unused_gdi_font_list, &gdiFont->entry);
|
2004-08-04 20:16:13 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2004-08-06 19:31:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
font_elem_ptr = list_head(&unused_gdi_font_list);
|
|
|
|
while(font_elem_ptr && i++ < UNUSED_CACHE_SIZE)
|
|
|
|
font_elem_ptr = list_next(&unused_gdi_font_list, font_elem_ptr);
|
|
|
|
while(font_elem_ptr) {
|
|
|
|
gdiFont = LIST_ENTRY(font_elem_ptr, struct tagGdiFont, entry);
|
|
|
|
font_elem_ptr = list_next(&unused_gdi_font_list, font_elem_ptr);
|
|
|
|
TRACE("freeing %p\n", gdiFont);
|
|
|
|
list_remove(&gdiFont->entry);
|
|
|
|
free_font(gdiFont);
|
|
|
|
}
|
2002-11-14 00:54:50 +01:00
|
|
|
return ret;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
|
2002-11-04 23:43:24 +01:00
|
|
|
NEWTEXTMETRICEXW *pntm, LPDWORD ptype)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2004-06-16 22:06:26 +02:00
|
|
|
OUTLINETEXTMETRICW *potm = NULL;
|
2001-09-12 22:21:06 +02:00
|
|
|
UINT size;
|
2004-06-16 22:06:26 +02:00
|
|
|
TEXTMETRICW tm, *ptm;
|
2002-01-29 04:02:50 +01:00
|
|
|
GdiFont font = alloc_font();
|
2004-06-16 22:06:26 +02:00
|
|
|
LONG width, height;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(face->scalable) {
|
|
|
|
height = 100;
|
|
|
|
width = 0;
|
|
|
|
} else {
|
|
|
|
height = face->size.y_ppem >> 6;
|
|
|
|
width = face->size.x_ppem >> 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(font->ft_face = OpenFontFile(font, face->file, face->face_index, width, height)))
|
2002-04-03 23:06:09 +02:00
|
|
|
{
|
|
|
|
free_font(font);
|
|
|
|
return;
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
font->name = strdupW(face->family->FamilyName);
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
memset(&pelf->elfLogFont, 0, sizeof(LOGFONTW));
|
|
|
|
|
|
|
|
size = WineEngGetOutlineTextMetrics(font, 0, NULL);
|
2004-06-16 22:06:26 +02:00
|
|
|
if(size) {
|
|
|
|
potm = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
WineEngGetOutlineTextMetrics(font, size, potm);
|
|
|
|
ptm = (TEXTMETRICW*)&potm->otmTextMetrics;
|
|
|
|
} else {
|
|
|
|
WineEngGetTextMetrics(font, &tm);
|
|
|
|
ptm = &tm;
|
|
|
|
}
|
|
|
|
|
|
|
|
pntm->ntmTm.tmHeight = pelf->elfLogFont.lfHeight = ptm->tmHeight;
|
|
|
|
pntm->ntmTm.tmAscent = ptm->tmAscent;
|
|
|
|
pntm->ntmTm.tmDescent = ptm->tmDescent;
|
|
|
|
pntm->ntmTm.tmInternalLeading = ptm->tmInternalLeading;
|
|
|
|
pntm->ntmTm.tmExternalLeading = ptm->tmExternalLeading;
|
|
|
|
pntm->ntmTm.tmAveCharWidth = pelf->elfLogFont.lfWidth = ptm->tmAveCharWidth;
|
|
|
|
pntm->ntmTm.tmMaxCharWidth = ptm->tmMaxCharWidth;
|
|
|
|
pntm->ntmTm.tmWeight = pelf->elfLogFont.lfWeight = ptm->tmWeight;
|
|
|
|
pntm->ntmTm.tmOverhang = ptm->tmOverhang;
|
|
|
|
pntm->ntmTm.tmDigitizedAspectX = ptm->tmDigitizedAspectX;
|
|
|
|
pntm->ntmTm.tmDigitizedAspectY = ptm->tmDigitizedAspectY;
|
|
|
|
pntm->ntmTm.tmFirstChar = ptm->tmFirstChar;
|
|
|
|
pntm->ntmTm.tmLastChar = ptm->tmLastChar;
|
|
|
|
pntm->ntmTm.tmDefaultChar = ptm->tmDefaultChar;
|
|
|
|
pntm->ntmTm.tmBreakChar = ptm->tmBreakChar;
|
|
|
|
pntm->ntmTm.tmItalic = pelf->elfLogFont.lfItalic = ptm->tmItalic;
|
|
|
|
pntm->ntmTm.tmUnderlined = pelf->elfLogFont.lfUnderline = ptm->tmUnderlined;
|
|
|
|
pntm->ntmTm.tmStruckOut = pelf->elfLogFont.lfStrikeOut = ptm->tmStruckOut;
|
|
|
|
pntm->ntmTm.tmPitchAndFamily = ptm->tmPitchAndFamily;
|
|
|
|
pelf->elfLogFont.lfPitchAndFamily = (ptm->tmPitchAndFamily & 0xf1) + 1;
|
|
|
|
pntm->ntmTm.tmCharSet = pelf->elfLogFont.lfCharSet = ptm->tmCharSet;
|
2002-01-29 04:02:50 +01:00
|
|
|
pelf->elfLogFont.lfOutPrecision = OUT_STROKE_PRECIS;
|
|
|
|
pelf->elfLogFont.lfClipPrecision = CLIP_STROKE_PRECIS;
|
|
|
|
pelf->elfLogFont.lfQuality = DRAFT_QUALITY;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
*ptype = ptm->tmPitchAndFamily & TMPF_TRUETYPE ? TRUETYPE_FONTTYPE : 0;
|
|
|
|
if(!(ptm->tmPitchAndFamily & TMPF_VECTOR))
|
|
|
|
*ptype |= RASTER_FONTTYPE;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-12-21 15:45:38 +01:00
|
|
|
pntm->ntmTm.ntmFlags = ptm->tmItalic ? NTM_ITALIC : 0;
|
|
|
|
if(ptm->tmWeight > 550) pntm->ntmTm.ntmFlags |= NTM_BOLD;
|
|
|
|
if(pntm->ntmTm.ntmFlags == 0) pntm->ntmTm.ntmFlags = NTM_REGULAR;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2004-12-21 15:45:38 +01:00
|
|
|
pntm->ntmTm.ntmCellHeight = pntm->ntmTm.tmHeight;
|
|
|
|
pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
|
|
|
|
memset(&pntm->ntmFontSig, 0, sizeof(FONTSIGNATURE));
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2004-12-21 15:45:38 +01:00
|
|
|
if(potm) {
|
|
|
|
pntm->ntmTm.ntmSizeEM = potm->otmEMSquare;
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfLogFont.lfFaceName,
|
2004-06-16 22:06:26 +02:00
|
|
|
(WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFamilyName),
|
|
|
|
LF_FACESIZE);
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfFullName,
|
2004-06-16 22:06:26 +02:00
|
|
|
(WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFaceName),
|
|
|
|
LF_FULLFACESIZE);
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfStyle,
|
2004-06-16 22:06:26 +02:00
|
|
|
(WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpStyleName),
|
|
|
|
LF_FACESIZE);
|
|
|
|
|
2004-12-21 15:45:38 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, potm);
|
2004-06-16 22:06:26 +02:00
|
|
|
} else {
|
2004-12-21 15:45:38 +01:00
|
|
|
pntm->ntmTm.ntmSizeEM = pntm->ntmTm.tmHeight - pntm->ntmTm.tmInternalLeading;
|
|
|
|
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
|
|
|
|
lstrcpynW(pelf->elfFullName, face->family->FamilyName, LF_FACESIZE);
|
2004-06-16 22:06:26 +02:00
|
|
|
pelf->elfStyle[0] = '\0';
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
pelf->elfScript[0] = '\0'; /* This will get set in WineEngEnumFonts */
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
free_font(font);
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* WineEngEnumFonts
|
|
|
|
*
|
|
|
|
*/
|
2004-01-19 00:35:12 +01:00
|
|
|
DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2001-09-12 22:21:06 +02:00
|
|
|
ENUMLOGFONTEXW elf;
|
|
|
|
NEWTEXTMETRICEXW ntm;
|
|
|
|
DWORD type, ret = 1;
|
2002-01-29 04:02:50 +01:00
|
|
|
FONTSIGNATURE fs;
|
|
|
|
CHARSETINFO csi;
|
2003-06-23 22:51:06 +02:00
|
|
|
LOGFONTW lf;
|
2002-01-29 04:02:50 +01:00
|
|
|
int i;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
TRACE("facename = %s charset %d\n", debugstr_w(plf->lfFaceName), plf->lfCharSet);
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
if(plf->lfFaceName[0]) {
|
2003-06-23 22:51:06 +02:00
|
|
|
FontSubst *psub;
|
|
|
|
for(psub = substlist; psub; psub = psub->next)
|
|
|
|
if(!strcmpiW(plf->lfFaceName, psub->from.name) &&
|
|
|
|
(psub->from.charset == -1 ||
|
|
|
|
psub->from.charset == plf->lfCharSet))
|
|
|
|
break;
|
|
|
|
if(psub) {
|
|
|
|
TRACE("substituting %s -> %s\n", debugstr_w(plf->lfFaceName),
|
|
|
|
debugstr_w(psub->to.name));
|
|
|
|
memcpy(&lf, plf, sizeof(lf));
|
|
|
|
strcpyW(lf.lfFaceName, psub->to.name);
|
|
|
|
plf = &lf;
|
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpiW(plf->lfFaceName, family->FamilyName)) {
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
GetEnumStructs(face, &elf, &ntm, &type);
|
|
|
|
for(i = 0; i < 32; i++) {
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!face->scalable && face->fs.fsCsb[0] == 0) { /* OEM bitmap */
|
|
|
|
elf.elfLogFont.lfCharSet = ntm.ntmTm.tmCharSet = OEM_CHARSET;
|
|
|
|
strcpyW(elf.elfScript, OEM_DOSW);
|
|
|
|
i = 32; /* break out of loop */
|
|
|
|
} else if(!(face->fs.fsCsb[0] & (1L << i)))
|
|
|
|
continue;
|
|
|
|
else {
|
|
|
|
fs.fsCsb[0] = 1L << i;
|
|
|
|
fs.fsCsb[1] = 0;
|
|
|
|
if(!TranslateCharsetInfo(fs.fsCsb, &csi,
|
|
|
|
TCI_SRCFONTSIG))
|
|
|
|
csi.ciCharset = DEFAULT_CHARSET;
|
|
|
|
if(i == 31) csi.ciCharset = SYMBOL_CHARSET;
|
|
|
|
if(csi.ciCharset != DEFAULT_CHARSET) {
|
|
|
|
elf.elfLogFont.lfCharSet =
|
|
|
|
ntm.ntmTm.tmCharSet = csi.ciCharset;
|
|
|
|
if(ElfScriptsW[i])
|
|
|
|
strcpyW(elf.elfScript, ElfScriptsW[i]);
|
|
|
|
else
|
|
|
|
FIXME("Unknown elfscript for bit %d\n", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("enuming face %s full %s style %s charset %d type %ld script %s it %d weight %ld ntmflags %08lx\n",
|
|
|
|
debugstr_w(elf.elfLogFont.lfFaceName),
|
|
|
|
debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle),
|
|
|
|
csi.ciCharset, type, debugstr_w(elf.elfScript),
|
|
|
|
elf.elfLogFont.lfItalic, elf.elfLogFont.lfWeight,
|
|
|
|
ntm.ntmTm.ntmFlags);
|
|
|
|
ret = proc(&elf.elfLogFont, (TEXTMETRICW *)&ntm, type, lparam);
|
|
|
|
if(!ret) goto end;
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
face_elem_ptr = list_head(&family->faces);
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
GetEnumStructs(face, &elf, &ntm, &type);
|
|
|
|
for(i = 0; i < 32; i++) {
|
|
|
|
if(!face->scalable && face->fs.fsCsb[0] == 0) { /* OEM bitmap */
|
2004-06-16 22:06:26 +02:00
|
|
|
elf.elfLogFont.lfCharSet = ntm.ntmTm.tmCharSet = OEM_CHARSET;
|
|
|
|
strcpyW(elf.elfScript, OEM_DOSW);
|
|
|
|
i = 32; /* break out of loop */
|
2004-08-18 00:08:31 +02:00
|
|
|
} else if(!(face->fs.fsCsb[0] & (1L << i)))
|
2004-06-16 22:06:26 +02:00
|
|
|
continue;
|
|
|
|
else {
|
2002-01-29 04:02:50 +01:00
|
|
|
fs.fsCsb[0] = 1L << i;
|
|
|
|
fs.fsCsb[1] = 0;
|
|
|
|
if(!TranslateCharsetInfo(fs.fsCsb, &csi,
|
|
|
|
TCI_SRCFONTSIG))
|
|
|
|
csi.ciCharset = DEFAULT_CHARSET;
|
|
|
|
if(i == 31) csi.ciCharset = SYMBOL_CHARSET;
|
|
|
|
if(csi.ciCharset != DEFAULT_CHARSET) {
|
2002-06-01 01:06:46 +02:00
|
|
|
elf.elfLogFont.lfCharSet = ntm.ntmTm.tmCharSet =
|
2002-01-29 04:02:50 +01:00
|
|
|
csi.ciCharset;
|
|
|
|
if(ElfScriptsW[i])
|
|
|
|
strcpyW(elf.elfScript, ElfScriptsW[i]);
|
|
|
|
else
|
|
|
|
FIXME("Unknown elfscript for bit %d\n", i);
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("enuming face %s full %s style %s charset = %d type %ld script %s it %d weight %ld ntmflags %08lx\n",
|
|
|
|
debugstr_w(elf.elfLogFont.lfFaceName),
|
|
|
|
debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle),
|
|
|
|
csi.ciCharset, type, debugstr_w(elf.elfScript),
|
|
|
|
elf.elfLogFont.lfItalic, elf.elfLogFont.lfWeight,
|
|
|
|
ntm.ntmTm.ntmFlags);
|
|
|
|
ret = proc(&elf.elfLogFont, (TEXTMETRICW *)&ntm, type, lparam);
|
|
|
|
if(!ret) goto end;
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
end:
|
2001-09-12 22:21:06 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
static void FTVectorToPOINTFX(FT_Vector *vec, POINTFX *pt)
|
|
|
|
{
|
|
|
|
pt->x.value = vec->x >> 6;
|
|
|
|
pt->x.fract = (vec->x & 0x3f) << 10;
|
|
|
|
pt->x.fract |= ((pt->x.fract >> 6) | (pt->x.fract >> 12));
|
|
|
|
pt->y.value = vec->y >> 6;
|
|
|
|
pt->y.fract = (vec->y & 0x3f) << 10;
|
|
|
|
pt->y.fract |= ((pt->y.fract >> 6) | (pt->y.fract >> 12));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FT_UInt get_glyph_index(GdiFont font, UINT glyph)
|
|
|
|
{
|
2004-08-26 20:24:03 +02:00
|
|
|
if(font->ft_face->charmap->encoding == FT_ENCODING_NONE) {
|
|
|
|
WCHAR wc = (WCHAR)glyph;
|
2005-07-05 13:02:37 +02:00
|
|
|
char buf;
|
2004-08-26 20:24:03 +02:00
|
|
|
WideCharToMultiByte(font->codepage, 0, &wc, 1, &buf, sizeof(buf), 0, 0);
|
2005-08-15 16:50:36 +02:00
|
|
|
return pFT_Get_Char_Index(font->ft_face, (unsigned char)buf);
|
2004-08-26 20:24:03 +02:00
|
|
|
}
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(font->charset == SYMBOL_CHARSET && glyph < 0x100)
|
|
|
|
glyph = glyph + 0xf000;
|
2002-04-03 22:02:39 +02:00
|
|
|
return pFT_Get_Char_Index(font->ft_face, glyph);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
|
2002-04-03 22:41:14 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetGlyphIndices
|
|
|
|
*
|
|
|
|
* FIXME: add support for GGI_MARK_NONEXISTING_GLYPHS
|
|
|
|
*/
|
|
|
|
DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count,
|
|
|
|
LPWORD pgi, DWORD flags)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
pgi[i] = get_glyph_index(font, lpstr[i]);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetGlyphOutline
|
|
|
|
*
|
|
|
|
* Behaves in exactly the same way as the win32 api GetGlyphOutline
|
|
|
|
* except that the first parameter is the HWINEENGFONT of the font in
|
|
|
|
* question rather than an HDC.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format,
|
|
|
|
LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf,
|
|
|
|
const MAT2* lpmat)
|
|
|
|
{
|
2003-10-10 02:06:35 +02:00
|
|
|
static const FT_Matrix identityMat = {(1 << 16), 0, 0, (1 << 16)};
|
2001-09-12 22:21:06 +02:00
|
|
|
FT_Face ft_face = font->ft_face;
|
|
|
|
FT_UInt glyph_index;
|
2002-01-29 04:02:50 +01:00
|
|
|
DWORD width, height, pitch, needed = 0;
|
2001-09-12 22:21:06 +02:00
|
|
|
FT_Bitmap ft_bitmap;
|
2002-01-29 04:02:50 +01:00
|
|
|
FT_Error err;
|
|
|
|
INT left, right, top = 0, bottom = 0;
|
|
|
|
FT_Angle angle = 0;
|
2004-02-03 00:03:54 +01:00
|
|
|
FT_Int load_flags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
|
|
|
|
float widthRatio = 1.0;
|
2003-10-10 02:06:35 +02:00
|
|
|
FT_Matrix transMat = identityMat;
|
|
|
|
BOOL needsTransform = FALSE;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
TRACE("%p, %04x, %08x, %p, %08lx, %p, %p\n", font, glyph, format, lpgm,
|
|
|
|
buflen, buf, lpmat);
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(format & GGO_GLYPH_INDEX) {
|
2001-09-12 22:21:06 +02:00
|
|
|
glyph_index = glyph;
|
2002-01-29 04:02:50 +01:00
|
|
|
format &= ~GGO_GLYPH_INDEX;
|
|
|
|
} else
|
|
|
|
glyph_index = get_glyph_index(font, glyph);
|
|
|
|
|
|
|
|
if(glyph_index >= font->gmsize) {
|
|
|
|
font->gmsize = (glyph_index / INIT_GM_SIZE + 1) * INIT_GM_SIZE;
|
|
|
|
font->gm = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, font->gm,
|
|
|
|
font->gmsize * sizeof(*font->gm));
|
|
|
|
} else {
|
|
|
|
if(format == GGO_METRICS && font->gm[glyph_index].init) {
|
|
|
|
memcpy(lpgm, &font->gm[glyph_index].gm, sizeof(*lpgm));
|
|
|
|
return 1; /* FIXME */
|
|
|
|
}
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
if(font->orientation || (format != GGO_METRICS && format != GGO_BITMAP) || font->aveWidth || lpmat)
|
2002-06-22 03:19:29 +02:00
|
|
|
load_flags |= FT_LOAD_NO_BITMAP;
|
|
|
|
|
|
|
|
err = pFT_Load_Glyph(ft_face, glyph_index, load_flags);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(err) {
|
|
|
|
FIXME("FT_Load_Glyph on index %x returns %d\n", glyph_index, err);
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2003-10-10 02:06:35 +02:00
|
|
|
|
|
|
|
/* Scaling factor */
|
|
|
|
if (font->aveWidth && font->potm) {
|
2004-08-06 19:31:39 +02:00
|
|
|
widthRatio = (float)font->aveWidth * font->font_desc.matrix.eM11 / (float) font->potm->otmTextMetrics.tmAveCharWidth;
|
2003-10-10 02:06:35 +02:00
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
left = (INT)(ft_face->glyph->metrics.horiBearingX * widthRatio) & -64;
|
|
|
|
right = (INT)((ft_face->glyph->metrics.horiBearingX + ft_face->glyph->metrics.width) * widthRatio + 63) & -64;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
font->gm[glyph_index].adv = (INT)((ft_face->glyph->metrics.horiAdvance * widthRatio) + 63) >> 6;
|
2002-01-29 04:02:50 +01:00
|
|
|
font->gm[glyph_index].lsb = left >> 6;
|
|
|
|
font->gm[glyph_index].bbx = (right - left) >> 6;
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
/* Scaling transform */
|
|
|
|
if(font->aveWidth) {
|
|
|
|
FT_Matrix scaleMat;
|
|
|
|
scaleMat.xx = FT_FixedFromFloat(widthRatio);
|
|
|
|
scaleMat.xy = 0;
|
|
|
|
scaleMat.yx = 0;
|
|
|
|
scaleMat.yy = (1 << 16);
|
|
|
|
|
|
|
|
pFT_Matrix_Multiply(&scaleMat, &transMat);
|
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Rotation transform */
|
|
|
|
if(font->orientation) {
|
|
|
|
FT_Matrix rotationMat;
|
|
|
|
FT_Vector vecAngle;
|
|
|
|
angle = FT_FixedFromFloat((float)font->orientation / 10.0);
|
|
|
|
pFT_Vector_Unit(&vecAngle, angle);
|
|
|
|
rotationMat.xx = vecAngle.x;
|
|
|
|
rotationMat.xy = -vecAngle.y;
|
|
|
|
rotationMat.yx = -rotationMat.xy;
|
|
|
|
rotationMat.yy = rotationMat.xx;
|
|
|
|
|
|
|
|
pFT_Matrix_Multiply(&rotationMat, &transMat);
|
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extra transformation specified by caller */
|
|
|
|
if (lpmat) {
|
|
|
|
FT_Matrix extraMat;
|
|
|
|
extraMat.xx = FT_FixedFromFIXED(lpmat->eM11);
|
|
|
|
extraMat.xy = FT_FixedFromFIXED(lpmat->eM21);
|
|
|
|
extraMat.yx = FT_FixedFromFIXED(lpmat->eM12);
|
|
|
|
extraMat.yy = FT_FixedFromFIXED(lpmat->eM22);
|
|
|
|
pFT_Matrix_Multiply(&extraMat, &transMat);
|
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!needsTransform) {
|
2002-06-01 01:06:46 +02:00
|
|
|
top = (ft_face->glyph->metrics.horiBearingY + 63) & -64;
|
2002-01-29 04:02:50 +01:00
|
|
|
bottom = (ft_face->glyph->metrics.horiBearingY -
|
|
|
|
ft_face->glyph->metrics.height) & -64;
|
|
|
|
lpgm->gmCellIncX = font->gm[glyph_index].adv;
|
|
|
|
lpgm->gmCellIncY = 0;
|
|
|
|
} else {
|
|
|
|
INT xc, yc;
|
|
|
|
FT_Vector vec;
|
|
|
|
for(xc = 0; xc < 2; xc++) {
|
|
|
|
for(yc = 0; yc < 2; yc++) {
|
2003-10-10 02:06:35 +02:00
|
|
|
vec.x = (ft_face->glyph->metrics.horiBearingX +
|
|
|
|
xc * ft_face->glyph->metrics.width);
|
2002-01-29 04:02:50 +01:00
|
|
|
vec.y = ft_face->glyph->metrics.horiBearingY -
|
|
|
|
yc * ft_face->glyph->metrics.height;
|
|
|
|
TRACE("Vec %ld,%ld\n", vec.x, vec.y);
|
2003-10-10 02:06:35 +02:00
|
|
|
pFT_Vector_Transform(&vec, &transMat);
|
2002-01-29 04:02:50 +01:00
|
|
|
if(xc == 0 && yc == 0) {
|
|
|
|
left = right = vec.x;
|
|
|
|
top = bottom = vec.y;
|
|
|
|
} else {
|
|
|
|
if(vec.x < left) left = vec.x;
|
|
|
|
else if(vec.x > right) right = vec.x;
|
|
|
|
if(vec.y < bottom) bottom = vec.y;
|
|
|
|
else if(vec.y > top) top = vec.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
left = left & -64;
|
|
|
|
right = (right + 63) & -64;
|
|
|
|
bottom = bottom & -64;
|
|
|
|
top = (top + 63) & -64;
|
|
|
|
|
|
|
|
TRACE("transformed box: (%d,%d - %d,%d)\n", left, top, right, bottom);
|
|
|
|
vec.x = ft_face->glyph->metrics.horiAdvance;
|
|
|
|
vec.y = 0;
|
2003-10-10 02:06:35 +02:00
|
|
|
pFT_Vector_Transform(&vec, &transMat);
|
2002-01-29 04:02:50 +01:00
|
|
|
lpgm->gmCellIncX = (vec.x+63) >> 6;
|
2003-10-10 02:06:35 +02:00
|
|
|
lpgm->gmCellIncY = -((vec.y+63) >> 6);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
lpgm->gmBlackBoxX = (right - left) >> 6;
|
|
|
|
lpgm->gmBlackBoxY = (top - bottom) >> 6;
|
|
|
|
lpgm->gmptGlyphOrigin.x = left >> 6;
|
|
|
|
lpgm->gmptGlyphOrigin.y = top >> 6;
|
|
|
|
|
|
|
|
memcpy(&font->gm[glyph_index].gm, lpgm, sizeof(*lpgm));
|
|
|
|
font->gm[glyph_index].init = TRUE;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
if(format == GGO_METRICS)
|
2002-01-29 04:02:50 +01:00
|
|
|
return 1; /* FIXME */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
if(ft_face->glyph->format != ft_glyph_format_outline && format != GGO_BITMAP) {
|
2004-06-16 22:06:26 +02:00
|
|
|
TRACE("loaded a bitmap\n");
|
2001-09-12 22:21:06 +02:00
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
switch(format) {
|
|
|
|
case GGO_BITMAP:
|
2001-09-12 22:21:06 +02:00
|
|
|
width = lpgm->gmBlackBoxX;
|
|
|
|
height = lpgm->gmBlackBoxY;
|
2003-10-10 02:06:35 +02:00
|
|
|
pitch = ((width + 31) >> 5) << 2;
|
2001-09-12 22:21:06 +02:00
|
|
|
needed = pitch * height;
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(!buf || !buflen) break;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
switch(ft_face->glyph->format) {
|
|
|
|
case ft_glyph_format_bitmap:
|
|
|
|
{
|
|
|
|
BYTE *src = ft_face->glyph->bitmap.buffer, *dst = buf;
|
|
|
|
INT w = (ft_face->glyph->bitmap.width + 7) >> 3;
|
|
|
|
INT h = ft_face->glyph->bitmap.rows;
|
|
|
|
while(h--) {
|
|
|
|
memcpy(dst, src, w);
|
|
|
|
src += ft_face->glyph->bitmap.pitch;
|
|
|
|
dst += pitch;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ft_glyph_format_outline:
|
|
|
|
ft_bitmap.width = width;
|
|
|
|
ft_bitmap.rows = height;
|
|
|
|
ft_bitmap.pitch = pitch;
|
|
|
|
ft_bitmap.pixel_mode = ft_pixel_mode_mono;
|
|
|
|
ft_bitmap.buffer = buf;
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
if(needsTransform) {
|
|
|
|
pFT_Outline_Transform(&ft_face->glyph->outline, &transMat);
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
pFT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/* Note: FreeType will only set 'black' bits for us. */
|
|
|
|
memset(buf, 0, needed);
|
|
|
|
pFT_Outline_Get_Bitmap(library, &ft_face->glyph->outline, &ft_bitmap);
|
|
|
|
break;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
default:
|
|
|
|
FIXME("loaded glyph format %x\n", ft_face->glyph->format);
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GGO_GRAY2_BITMAP:
|
|
|
|
case GGO_GRAY4_BITMAP:
|
|
|
|
case GGO_GRAY8_BITMAP:
|
|
|
|
case WINE_GGO_GRAY16_BITMAP:
|
|
|
|
{
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int mult, row, col;
|
2002-01-29 04:02:50 +01:00
|
|
|
BYTE *start, *ptr;
|
|
|
|
|
|
|
|
width = lpgm->gmBlackBoxX;
|
|
|
|
height = lpgm->gmBlackBoxY;
|
|
|
|
pitch = (width + 3) / 4 * 4;
|
|
|
|
needed = pitch * height;
|
|
|
|
|
|
|
|
if(!buf || !buflen) break;
|
|
|
|
ft_bitmap.width = width;
|
|
|
|
ft_bitmap.rows = height;
|
|
|
|
ft_bitmap.pitch = pitch;
|
|
|
|
ft_bitmap.pixel_mode = ft_pixel_mode_grays;
|
|
|
|
ft_bitmap.buffer = buf;
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
if(needsTransform) {
|
|
|
|
pFT_Outline_Transform(&ft_face->glyph->outline, &transMat);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
pFT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2005-02-25 14:59:22 +01:00
|
|
|
memset(ft_bitmap.buffer, 0, buflen);
|
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
pFT_Outline_Get_Bitmap(library, &ft_face->glyph->outline, &ft_bitmap);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
if(format == GGO_GRAY2_BITMAP)
|
2005-02-25 14:59:22 +01:00
|
|
|
mult = 4;
|
2002-01-29 04:02:50 +01:00
|
|
|
else if(format == GGO_GRAY4_BITMAP)
|
2005-02-25 14:59:22 +01:00
|
|
|
mult = 16;
|
2002-01-29 04:02:50 +01:00
|
|
|
else if(format == GGO_GRAY8_BITMAP)
|
2005-02-25 14:59:22 +01:00
|
|
|
mult = 64;
|
2002-01-29 04:02:50 +01:00
|
|
|
else if(format == WINE_GGO_GRAY16_BITMAP)
|
|
|
|
break;
|
|
|
|
else {
|
|
|
|
assert(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
start = buf;
|
|
|
|
for(row = 0; row < height; row++) {
|
|
|
|
ptr = start;
|
|
|
|
for(col = 0; col < width; col++, ptr++) {
|
2005-02-25 14:59:22 +01:00
|
|
|
*ptr = (((int)*ptr) * mult + 128) / 256;
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
start += pitch;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GGO_NATIVE:
|
|
|
|
{
|
|
|
|
int contour, point = 0, first_pt;
|
|
|
|
FT_Outline *outline = &ft_face->glyph->outline;
|
|
|
|
TTPOLYGONHEADER *pph;
|
|
|
|
TTPOLYCURVE *ppc;
|
|
|
|
DWORD pph_start, cpfx, type;
|
|
|
|
|
|
|
|
if(buflen == 0) buf = NULL;
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
if (needsTransform && buf) {
|
|
|
|
pFT_Outline_Transform(outline, &transMat);
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
for(contour = 0; contour < outline->n_contours; contour++) {
|
|
|
|
pph_start = needed;
|
2003-01-23 22:32:35 +01:00
|
|
|
pph = (TTPOLYGONHEADER *)((char *)buf + needed);
|
2002-01-29 04:02:50 +01:00
|
|
|
first_pt = point;
|
|
|
|
if(buf) {
|
|
|
|
pph->dwType = TT_POLYGON_TYPE;
|
|
|
|
FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
|
|
|
|
}
|
|
|
|
needed += sizeof(*pph);
|
|
|
|
point++;
|
|
|
|
while(point <= outline->contours[contour]) {
|
2003-01-23 22:32:35 +01:00
|
|
|
ppc = (TTPOLYCURVE *)((char *)buf + needed);
|
2002-06-22 03:19:29 +02:00
|
|
|
type = (outline->tags[point] & FT_Curve_Tag_On) ?
|
2002-01-29 04:02:50 +01:00
|
|
|
TT_PRIM_LINE : TT_PRIM_QSPLINE;
|
|
|
|
cpfx = 0;
|
|
|
|
do {
|
|
|
|
if(buf)
|
|
|
|
FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
|
|
|
|
cpfx++;
|
|
|
|
point++;
|
|
|
|
} while(point <= outline->contours[contour] &&
|
2002-06-22 03:19:29 +02:00
|
|
|
(outline->tags[point] & FT_Curve_Tag_On) ==
|
|
|
|
(outline->tags[point-1] & FT_Curve_Tag_On));
|
|
|
|
/* At the end of a contour Windows adds the start point, but
|
|
|
|
only for Beziers */
|
|
|
|
if(point > outline->contours[contour] &&
|
|
|
|
!(outline->tags[point-1] & FT_Curve_Tag_On)) {
|
2002-01-29 04:02:50 +01:00
|
|
|
if(buf)
|
|
|
|
FTVectorToPOINTFX(&outline->points[first_pt], &ppc->apfx[cpfx]);
|
|
|
|
cpfx++;
|
2002-08-17 02:23:42 +02:00
|
|
|
} else if(point <= outline->contours[contour] &&
|
|
|
|
outline->tags[point] & FT_Curve_Tag_On) {
|
2002-01-29 04:02:50 +01:00
|
|
|
/* add closing pt for bezier */
|
|
|
|
if(buf)
|
|
|
|
FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
|
|
|
|
cpfx++;
|
|
|
|
point++;
|
|
|
|
}
|
|
|
|
if(buf) {
|
|
|
|
ppc->wType = type;
|
|
|
|
ppc->cpfx = cpfx;
|
|
|
|
}
|
|
|
|
needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
|
|
|
|
}
|
|
|
|
if(buf)
|
|
|
|
pph->cb = needed - pph_start;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
case GGO_BEZIER:
|
|
|
|
{
|
|
|
|
/* Convert the quadratic Beziers to cubic Beziers.
|
|
|
|
The parametric eqn for a cubic Bezier is, from PLRM:
|
|
|
|
r(t) = at^3 + bt^2 + ct + r0
|
|
|
|
with the control points:
|
|
|
|
r1 = r0 + c/3
|
|
|
|
r2 = r1 + (c + b)/3
|
|
|
|
r3 = r0 + c + b + a
|
|
|
|
|
|
|
|
A quadratic Beizer has the form:
|
|
|
|
p(t) = (1-t)^2 p0 + 2(1-t)t p1 + t^2 p2
|
|
|
|
|
|
|
|
So equating powers of t leads to:
|
|
|
|
r1 = 2/3 p1 + 1/3 p0
|
|
|
|
r2 = 2/3 p1 + 1/3 p2
|
|
|
|
and of course r0 = p0, r3 = p2
|
|
|
|
*/
|
|
|
|
|
|
|
|
int contour, point = 0, first_pt;
|
|
|
|
FT_Outline *outline = &ft_face->glyph->outline;
|
|
|
|
TTPOLYGONHEADER *pph;
|
|
|
|
TTPOLYCURVE *ppc;
|
|
|
|
DWORD pph_start, cpfx, type;
|
|
|
|
FT_Vector cubic_control[4];
|
|
|
|
if(buflen == 0) buf = NULL;
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
if (needsTransform && buf) {
|
|
|
|
pFT_Outline_Transform(outline, &transMat);
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
for(contour = 0; contour < outline->n_contours; contour++) {
|
|
|
|
pph_start = needed;
|
2003-01-23 22:32:35 +01:00
|
|
|
pph = (TTPOLYGONHEADER *)((char *)buf + needed);
|
2002-06-22 03:19:29 +02:00
|
|
|
first_pt = point;
|
|
|
|
if(buf) {
|
|
|
|
pph->dwType = TT_POLYGON_TYPE;
|
|
|
|
FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
|
|
|
|
}
|
|
|
|
needed += sizeof(*pph);
|
|
|
|
point++;
|
|
|
|
while(point <= outline->contours[contour]) {
|
2003-01-23 22:32:35 +01:00
|
|
|
ppc = (TTPOLYCURVE *)((char *)buf + needed);
|
2002-06-22 03:19:29 +02:00
|
|
|
type = (outline->tags[point] & FT_Curve_Tag_On) ?
|
|
|
|
TT_PRIM_LINE : TT_PRIM_CSPLINE;
|
|
|
|
cpfx = 0;
|
|
|
|
do {
|
|
|
|
if(type == TT_PRIM_LINE) {
|
|
|
|
if(buf)
|
|
|
|
FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
|
|
|
|
cpfx++;
|
|
|
|
point++;
|
|
|
|
} else {
|
|
|
|
/* Unlike QSPLINEs, CSPLINEs always have their endpoint
|
|
|
|
so cpfx = 3n */
|
|
|
|
|
|
|
|
/* FIXME: Possible optimization in endpoint calculation
|
|
|
|
if there are two consecutive curves */
|
|
|
|
cubic_control[0] = outline->points[point-1];
|
|
|
|
if(!(outline->tags[point-1] & FT_Curve_Tag_On)) {
|
|
|
|
cubic_control[0].x += outline->points[point].x + 1;
|
|
|
|
cubic_control[0].y += outline->points[point].y + 1;
|
|
|
|
cubic_control[0].x >>= 1;
|
|
|
|
cubic_control[0].y >>= 1;
|
|
|
|
}
|
|
|
|
if(point+1 > outline->contours[contour])
|
|
|
|
cubic_control[3] = outline->points[first_pt];
|
|
|
|
else {
|
|
|
|
cubic_control[3] = outline->points[point+1];
|
|
|
|
if(!(outline->tags[point+1] & FT_Curve_Tag_On)) {
|
|
|
|
cubic_control[3].x += outline->points[point].x + 1;
|
|
|
|
cubic_control[3].y += outline->points[point].y + 1;
|
|
|
|
cubic_control[3].x >>= 1;
|
|
|
|
cubic_control[3].y >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* r1 = 1/3 p0 + 2/3 p1
|
|
|
|
r2 = 1/3 p2 + 2/3 p1 */
|
|
|
|
cubic_control[1].x = (2 * outline->points[point].x + 1) / 3;
|
|
|
|
cubic_control[1].y = (2 * outline->points[point].y + 1) / 3;
|
|
|
|
cubic_control[2] = cubic_control[1];
|
|
|
|
cubic_control[1].x += (cubic_control[0].x + 1) / 3;
|
|
|
|
cubic_control[1].y += (cubic_control[0].y + 1) / 3;
|
|
|
|
cubic_control[2].x += (cubic_control[3].x + 1) / 3;
|
|
|
|
cubic_control[2].y += (cubic_control[3].y + 1) / 3;
|
|
|
|
if(buf) {
|
|
|
|
FTVectorToPOINTFX(&cubic_control[1], &ppc->apfx[cpfx]);
|
|
|
|
FTVectorToPOINTFX(&cubic_control[2], &ppc->apfx[cpfx+1]);
|
|
|
|
FTVectorToPOINTFX(&cubic_control[3], &ppc->apfx[cpfx+2]);
|
|
|
|
}
|
|
|
|
cpfx += 3;
|
|
|
|
point++;
|
|
|
|
}
|
|
|
|
} while(point <= outline->contours[contour] &&
|
|
|
|
(outline->tags[point] & FT_Curve_Tag_On) ==
|
|
|
|
(outline->tags[point-1] & FT_Curve_Tag_On));
|
|
|
|
/* At the end of a contour Windows adds the start point,
|
|
|
|
but only for Beziers and we've already done that.
|
|
|
|
*/
|
|
|
|
if(point <= outline->contours[contour] &&
|
|
|
|
outline->tags[point] & FT_Curve_Tag_On) {
|
|
|
|
/* This is the closing pt of a bezier, but we've already
|
|
|
|
added it, so just inc point and carry on */
|
|
|
|
point++;
|
|
|
|
}
|
|
|
|
if(buf) {
|
|
|
|
ppc->wType = type;
|
|
|
|
ppc->cpfx = cpfx;
|
|
|
|
}
|
|
|
|
needed += sizeof(*ppc) + (cpfx - 1) * sizeof(POINTFX);
|
|
|
|
}
|
|
|
|
if(buf)
|
|
|
|
pph->cb = needed - pph_start;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
default:
|
2001-09-12 22:21:06 +02:00
|
|
|
FIXME("Unsupported format %d\n", format);
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
return needed;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
static BOOL get_bitmap_text_metrics(GdiFont font)
|
|
|
|
{
|
|
|
|
FT_Face ft_face = font->ft_face;
|
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
FT_WinFNT_HeaderRec winfnt_header;
|
|
|
|
#endif
|
|
|
|
const DWORD size = offsetof(OUTLINETEXTMETRICW, otmFiller);
|
|
|
|
font->potm = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
font->potm->otmSize = size;
|
|
|
|
|
|
|
|
#define TM font->potm->otmTextMetrics
|
|
|
|
#ifdef HAVE_FREETYPE_FTWINFNT_H
|
|
|
|
if(pFT_Get_WinFNT_Header && !pFT_Get_WinFNT_Header(ft_face, &winfnt_header))
|
|
|
|
{
|
|
|
|
TM.tmHeight = winfnt_header.pixel_height;
|
|
|
|
TM.tmAscent = winfnt_header.ascent;
|
|
|
|
TM.tmDescent = TM.tmHeight - TM.tmAscent;
|
|
|
|
TM.tmInternalLeading = winfnt_header.internal_leading;
|
|
|
|
TM.tmExternalLeading = winfnt_header.external_leading;
|
|
|
|
TM.tmAveCharWidth = winfnt_header.avg_width;
|
|
|
|
TM.tmMaxCharWidth = winfnt_header.max_width;
|
|
|
|
TM.tmWeight = winfnt_header.weight;
|
|
|
|
TM.tmOverhang = 0;
|
|
|
|
TM.tmDigitizedAspectX = winfnt_header.horizontal_resolution;
|
|
|
|
TM.tmDigitizedAspectY = winfnt_header.vertical_resolution;
|
|
|
|
TM.tmFirstChar = winfnt_header.first_char;
|
|
|
|
TM.tmLastChar = winfnt_header.last_char;
|
2004-08-09 20:52:51 +02:00
|
|
|
TM.tmDefaultChar = winfnt_header.default_char + winfnt_header.first_char;
|
|
|
|
TM.tmBreakChar = winfnt_header.break_char + winfnt_header.first_char;
|
2004-06-16 22:06:26 +02:00
|
|
|
TM.tmItalic = winfnt_header.italic;
|
2004-07-22 21:42:31 +02:00
|
|
|
TM.tmUnderlined = font->underline;
|
|
|
|
TM.tmStruckOut = font->strikeout;
|
2004-06-16 22:06:26 +02:00
|
|
|
TM.tmPitchAndFamily = winfnt_header.pitch_and_family;
|
|
|
|
TM.tmCharSet = winfnt_header.charset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TM.tmAscent = ft_face->size->metrics.ascender >> 6;
|
|
|
|
TM.tmDescent = -ft_face->size->metrics.descender >> 6;
|
|
|
|
TM.tmHeight = TM.tmAscent + TM.tmDescent;
|
|
|
|
TM.tmInternalLeading = TM.tmHeight - ft_face->size->metrics.y_ppem;
|
|
|
|
TM.tmExternalLeading = (ft_face->size->metrics.height >> 6) - TM.tmHeight;
|
|
|
|
TM.tmMaxCharWidth = ft_face->size->metrics.max_advance >> 6;
|
|
|
|
TM.tmAveCharWidth = TM.tmMaxCharWidth * 2 / 3; /* FIXME */
|
|
|
|
TM.tmWeight = ft_face->style_flags & FT_STYLE_FLAG_BOLD ? FW_BOLD : FW_NORMAL;
|
|
|
|
TM.tmOverhang = 0;
|
|
|
|
TM.tmDigitizedAspectX = 96; /* FIXME */
|
|
|
|
TM.tmDigitizedAspectY = 96; /* FIXME */
|
|
|
|
TM.tmFirstChar = 1;
|
|
|
|
TM.tmLastChar = 255;
|
|
|
|
TM.tmDefaultChar = 32;
|
|
|
|
TM.tmBreakChar = 32;
|
|
|
|
TM.tmItalic = ft_face->style_flags & FT_STYLE_FLAG_ITALIC ? 1 : 0;
|
2004-07-22 21:42:31 +02:00
|
|
|
TM.tmUnderlined = font->underline;
|
|
|
|
TM.tmStruckOut = font->strikeout;
|
2004-06-16 22:06:26 +02:00
|
|
|
/* NB inverted meaning of TMPF_FIXED_PITCH */
|
|
|
|
TM.tmPitchAndFamily = ft_face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ? 0 : TMPF_FIXED_PITCH;
|
|
|
|
TM.tmCharSet = font->charset;
|
|
|
|
}
|
|
|
|
#undef TM
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetTextMetrics
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngGetTextMetrics(GdiFont font, LPTEXTMETRICW ptm)
|
|
|
|
{
|
2002-06-22 03:19:29 +02:00
|
|
|
if(!font->potm) {
|
|
|
|
if(!WineEngGetOutlineTextMetrics(font, 0, NULL))
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!get_bitmap_text_metrics(font))
|
|
|
|
return FALSE;
|
2002-04-03 23:06:09 +02:00
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
if(!font->potm) return FALSE;
|
|
|
|
memcpy(ptm, &font->potm->otmTextMetrics, sizeof(*ptm));
|
2003-10-10 02:06:35 +02:00
|
|
|
|
|
|
|
if (font->aveWidth) {
|
2004-08-06 19:31:39 +02:00
|
|
|
ptm->tmAveCharWidth = font->aveWidth * font->font_desc.matrix.eM11;
|
2003-10-10 02:06:35 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetOutlineTextMetrics
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
UINT WineEngGetOutlineTextMetrics(GdiFont font, UINT cbSize,
|
|
|
|
OUTLINETEXTMETRICW *potm)
|
|
|
|
{
|
|
|
|
FT_Face ft_face = font->ft_face;
|
|
|
|
UINT needed, lenfam, lensty, ret;
|
|
|
|
TT_OS2 *pOS2;
|
|
|
|
TT_HoriHeader *pHori;
|
2002-11-14 00:54:50 +01:00
|
|
|
TT_Postscript *pPost;
|
2001-09-12 22:21:06 +02:00
|
|
|
FT_Fixed x_scale, y_scale;
|
|
|
|
WCHAR *family_nameW, *style_nameW;
|
2004-04-20 03:12:17 +02:00
|
|
|
static const WCHAR spaceW[] = {' ', '\0'};
|
2001-09-12 22:21:06 +02:00
|
|
|
char *cp;
|
2003-12-08 22:53:15 +01:00
|
|
|
INT ascent, descent;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
TRACE("font=%p\n", font);
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!FT_IS_SCALABLE(ft_face))
|
|
|
|
return 0;
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
if(font->potm) {
|
|
|
|
if(cbSize >= font->potm->otmSize)
|
|
|
|
memcpy(potm, font->potm, font->potm->otmSize);
|
|
|
|
return font->potm->otmSize;
|
|
|
|
}
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
needed = sizeof(*potm);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
lenfam = (strlenW(font->name) + 1) * sizeof(WCHAR);
|
|
|
|
family_nameW = strdupW(font->name);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
lensty = MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1, NULL, 0)
|
|
|
|
* sizeof(WCHAR);
|
|
|
|
style_nameW = HeapAlloc(GetProcessHeap(), 0, lensty);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1,
|
|
|
|
style_nameW, lensty);
|
|
|
|
|
|
|
|
/* These names should be read from the TT name table */
|
|
|
|
|
|
|
|
/* length of otmpFamilyName */
|
|
|
|
needed += lenfam;
|
|
|
|
|
|
|
|
/* length of otmpFaceName */
|
|
|
|
if(!strcasecmp(ft_face->style_name, "regular")) {
|
|
|
|
needed += lenfam; /* just the family name */
|
|
|
|
} else {
|
|
|
|
needed += lenfam + lensty; /* family + " " + style */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* length of otmpStyleName */
|
|
|
|
needed += lensty;
|
|
|
|
|
|
|
|
/* length of otmpFullName */
|
|
|
|
needed += lenfam + lensty;
|
|
|
|
|
|
|
|
|
|
|
|
x_scale = ft_face->size->metrics.x_scale;
|
|
|
|
y_scale = ft_face->size->metrics.y_scale;
|
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2);
|
2001-09-12 22:21:06 +02:00
|
|
|
if(!pOS2) {
|
|
|
|
FIXME("Can't find OS/2 table - not TT font?\n");
|
|
|
|
ret = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
pHori = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea);
|
2001-09-12 22:21:06 +02:00
|
|
|
if(!pHori) {
|
|
|
|
FIXME("Can't find HHEA table - not TT font?\n");
|
|
|
|
ret = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2002-11-14 00:54:50 +01:00
|
|
|
pPost = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_post); /* we can live with this failing */
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
TRACE("OS/2 winA = %d winD = %d typoA = %d typoD = %d typoLG = %d FT_Face a = %d, d = %d, h = %d: HORZ a = %d, d = %d lg = %d maxY = %ld minY = %ld\n",
|
|
|
|
pOS2->usWinAscent, pOS2->usWinDescent,
|
|
|
|
pOS2->sTypoAscender, pOS2->sTypoDescender, pOS2->sTypoLineGap,
|
|
|
|
ft_face->ascender, ft_face->descender, ft_face->height,
|
|
|
|
pHori->Ascender, pHori->Descender, pHori->Line_Gap,
|
|
|
|
ft_face->bbox.yMax, ft_face->bbox.yMin);
|
|
|
|
|
|
|
|
font->potm = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
font->potm->otmSize = needed;
|
|
|
|
|
|
|
|
#define TM font->potm->otmTextMetrics
|
|
|
|
|
2003-12-08 22:53:15 +01:00
|
|
|
if(pOS2->usWinAscent + pOS2->usWinDescent == 0) {
|
|
|
|
ascent = pHori->Ascender;
|
|
|
|
descent = -pHori->Descender;
|
|
|
|
} else {
|
|
|
|
ascent = pOS2->usWinAscent;
|
|
|
|
descent = pOS2->usWinDescent;
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
if(font->yMax) {
|
|
|
|
TM.tmAscent = font->yMax;
|
|
|
|
TM.tmDescent = -font->yMin;
|
|
|
|
TM.tmInternalLeading = (TM.tmAscent + TM.tmDescent) - ft_face->size->metrics.y_ppem;
|
|
|
|
} else {
|
2003-12-08 22:53:15 +01:00
|
|
|
TM.tmAscent = (pFT_MulFix(ascent, y_scale) + 32) >> 6;
|
|
|
|
TM.tmDescent = (pFT_MulFix(descent, y_scale) + 32) >> 6;
|
|
|
|
TM.tmInternalLeading = (pFT_MulFix(ascent + descent
|
2002-06-22 03:19:29 +02:00
|
|
|
- ft_face->units_per_EM, y_scale) + 32) >> 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
TM.tmHeight = TM.tmAscent + TM.tmDescent;
|
|
|
|
|
|
|
|
/* MSDN says:
|
|
|
|
el = MAX(0, LineGap - ((WinAscent + WinDescent) - (Ascender - Descender)))
|
|
|
|
*/
|
|
|
|
TM.tmExternalLeading = max(0, (pFT_MulFix(pHori->Line_Gap -
|
2003-12-08 22:53:15 +01:00
|
|
|
((ascent + descent) -
|
2002-06-22 03:19:29 +02:00
|
|
|
(pHori->Ascender - pHori->Descender)), y_scale) + 32) >> 6);
|
|
|
|
|
|
|
|
TM.tmAveCharWidth = (pFT_MulFix(pOS2->xAvgCharWidth, x_scale) + 32) >> 6;
|
2003-10-10 02:06:35 +02:00
|
|
|
if (TM.tmAveCharWidth == 0) {
|
|
|
|
TM.tmAveCharWidth = 1;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
TM.tmMaxCharWidth = (pFT_MulFix(ft_face->bbox.xMax - ft_face->bbox.xMin, x_scale) + 32) >> 6;
|
|
|
|
TM.tmWeight = font->fake_bold ? FW_BOLD : pOS2->usWeightClass;
|
|
|
|
TM.tmOverhang = 0;
|
|
|
|
TM.tmDigitizedAspectX = 300;
|
|
|
|
TM.tmDigitizedAspectY = 300;
|
|
|
|
TM.tmFirstChar = pOS2->usFirstCharIndex;
|
|
|
|
TM.tmLastChar = pOS2->usLastCharIndex;
|
|
|
|
TM.tmDefaultChar = pOS2->usDefaultChar;
|
|
|
|
TM.tmBreakChar = pOS2->usBreakChar ? pOS2->usBreakChar : ' ';
|
|
|
|
TM.tmItalic = font->fake_italic ? 255 : ((ft_face->style_flags & FT_STYLE_FLAG_ITALIC) ? 255 : 0);
|
2004-07-22 21:42:31 +02:00
|
|
|
TM.tmUnderlined = font->underline;
|
|
|
|
TM.tmStruckOut = font->strikeout;
|
2002-06-22 03:19:29 +02:00
|
|
|
|
|
|
|
/* Yes TPMF_FIXED_PITCH is correct; braindead api */
|
2005-02-25 14:59:22 +01:00
|
|
|
if(!FT_IS_FIXED_WIDTH(ft_face) &&
|
|
|
|
(pOS2->version == 0xFFFFU ||
|
|
|
|
pOS2->panose[PAN_PROPORTION_INDEX] != PAN_PROP_MONOSPACED))
|
2002-06-22 03:19:29 +02:00
|
|
|
TM.tmPitchAndFamily = TMPF_FIXED_PITCH;
|
|
|
|
else
|
|
|
|
TM.tmPitchAndFamily = 0;
|
|
|
|
|
|
|
|
switch(pOS2->panose[PAN_FAMILYTYPE_INDEX]) {
|
|
|
|
case PAN_FAMILY_SCRIPT:
|
|
|
|
TM.tmPitchAndFamily |= FF_SCRIPT;
|
|
|
|
break;
|
|
|
|
case PAN_FAMILY_DECORATIVE:
|
|
|
|
case PAN_FAMILY_PICTORIAL:
|
|
|
|
TM.tmPitchAndFamily |= FF_DECORATIVE;
|
|
|
|
break;
|
|
|
|
case PAN_FAMILY_TEXT_DISPLAY:
|
|
|
|
if(TM.tmPitchAndFamily == 0) /* fixed */
|
|
|
|
TM.tmPitchAndFamily = FF_MODERN;
|
|
|
|
else {
|
|
|
|
switch(pOS2->panose[PAN_SERIFSTYLE_INDEX]) {
|
|
|
|
case PAN_SERIF_NORMAL_SANS:
|
|
|
|
case PAN_SERIF_OBTUSE_SANS:
|
|
|
|
case PAN_SERIF_PERP_SANS:
|
|
|
|
TM.tmPitchAndFamily |= FF_SWISS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
TM.tmPitchAndFamily |= FF_ROMAN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
TM.tmPitchAndFamily |= FF_DONTCARE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FT_IS_SCALABLE(ft_face))
|
|
|
|
TM.tmPitchAndFamily |= TMPF_VECTOR;
|
|
|
|
if(FT_IS_SFNT(ft_face))
|
|
|
|
TM.tmPitchAndFamily |= TMPF_TRUETYPE;
|
|
|
|
|
|
|
|
TM.tmCharSet = font->charset;
|
|
|
|
#undef TM
|
|
|
|
|
|
|
|
font->potm->otmFiller = 0;
|
|
|
|
memcpy(&font->potm->otmPanoseNumber, pOS2->panose, PANOSE_COUNT);
|
|
|
|
font->potm->otmfsSelection = pOS2->fsSelection;
|
|
|
|
font->potm->otmfsType = pOS2->fsType;
|
|
|
|
font->potm->otmsCharSlopeRise = pHori->caret_Slope_Rise;
|
|
|
|
font->potm->otmsCharSlopeRun = pHori->caret_Slope_Run;
|
|
|
|
font->potm->otmItalicAngle = 0; /* POST table */
|
|
|
|
font->potm->otmEMSquare = ft_face->units_per_EM;
|
|
|
|
font->potm->otmAscent = (pFT_MulFix(pOS2->sTypoAscender, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmDescent = (pFT_MulFix(pOS2->sTypoDescender, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmLineGap = (pFT_MulFix(pOS2->sTypoLineGap, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmsCapEmHeight = (pFT_MulFix(pOS2->sCapHeight, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmsXHeight = (pFT_MulFix(pOS2->sxHeight, y_scale) + 32) >> 6;
|
2003-11-12 23:42:55 +01:00
|
|
|
font->potm->otmrcFontBox.left = (pFT_MulFix(ft_face->bbox.xMin, x_scale) + 32) >> 6;
|
|
|
|
font->potm->otmrcFontBox.right = (pFT_MulFix(ft_face->bbox.xMax, x_scale) + 32) >> 6;
|
|
|
|
font->potm->otmrcFontBox.top = (pFT_MulFix(ft_face->bbox.yMax, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmrcFontBox.bottom = (pFT_MulFix(ft_face->bbox.yMin, y_scale) + 32) >> 6;
|
2002-06-22 03:19:29 +02:00
|
|
|
font->potm->otmMacAscent = 0; /* where do these come from ? */
|
|
|
|
font->potm->otmMacDescent = 0;
|
|
|
|
font->potm->otmMacLineGap = 0;
|
|
|
|
font->potm->otmusMinimumPPEM = 0; /* TT Header */
|
|
|
|
font->potm->otmptSubscriptSize.x = (pFT_MulFix(pOS2->ySubscriptXSize, x_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSubscriptSize.y = (pFT_MulFix(pOS2->ySubscriptYSize, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSubscriptOffset.x = (pFT_MulFix(pOS2->ySubscriptXOffset, x_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSubscriptOffset.y = (pFT_MulFix(pOS2->ySubscriptYOffset, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSuperscriptSize.x = (pFT_MulFix(pOS2->ySuperscriptXSize, x_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSuperscriptSize.y = (pFT_MulFix(pOS2->ySuperscriptYSize, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSuperscriptOffset.x = (pFT_MulFix(pOS2->ySuperscriptXOffset, x_scale) + 32) >> 6;
|
|
|
|
font->potm->otmptSuperscriptOffset.y = (pFT_MulFix(pOS2->ySuperscriptYOffset, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmsStrikeoutSize = (pFT_MulFix(pOS2->yStrikeoutSize, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmsStrikeoutPosition = (pFT_MulFix(pOS2->yStrikeoutPosition, y_scale) + 32) >> 6;
|
2002-11-14 00:54:50 +01:00
|
|
|
if(!pPost) {
|
|
|
|
font->potm->otmsUnderscoreSize = 0;
|
|
|
|
font->potm->otmsUnderscorePosition = 0;
|
|
|
|
} else {
|
|
|
|
font->potm->otmsUnderscoreSize = (pFT_MulFix(pPost->underlineThickness, y_scale) + 32) >> 6;
|
|
|
|
font->potm->otmsUnderscorePosition = (pFT_MulFix(pPost->underlinePosition, y_scale) + 32) >> 6;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/* otmp* members should clearly have type ptrdiff_t, but M$ knows best */
|
2002-06-22 03:19:29 +02:00
|
|
|
cp = (char*)font->potm + sizeof(*font->potm);
|
|
|
|
font->potm->otmpFamilyName = (LPSTR)(cp - (char*)font->potm);
|
2001-09-12 22:21:06 +02:00
|
|
|
strcpyW((WCHAR*)cp, family_nameW);
|
|
|
|
cp += lenfam;
|
2002-06-22 03:19:29 +02:00
|
|
|
font->potm->otmpStyleName = (LPSTR)(cp - (char*)font->potm);
|
2001-09-12 22:21:06 +02:00
|
|
|
strcpyW((WCHAR*)cp, style_nameW);
|
|
|
|
cp += lensty;
|
2002-06-22 03:19:29 +02:00
|
|
|
font->potm->otmpFaceName = (LPSTR)(cp - (char*)font->potm);
|
2001-09-12 22:21:06 +02:00
|
|
|
strcpyW((WCHAR*)cp, family_nameW);
|
|
|
|
if(strcasecmp(ft_face->style_name, "regular")) {
|
|
|
|
strcatW((WCHAR*)cp, spaceW);
|
|
|
|
strcatW((WCHAR*)cp, style_nameW);
|
|
|
|
cp += lenfam + lensty;
|
2002-06-01 01:06:46 +02:00
|
|
|
} else
|
2001-09-12 22:21:06 +02:00
|
|
|
cp += lenfam;
|
2002-06-22 03:19:29 +02:00
|
|
|
font->potm->otmpFullName = (LPSTR)(cp - (char*)font->potm);
|
2001-09-12 22:21:06 +02:00
|
|
|
strcpyW((WCHAR*)cp, family_nameW);
|
|
|
|
strcatW((WCHAR*)cp, spaceW);
|
|
|
|
strcatW((WCHAR*)cp, style_nameW);
|
|
|
|
ret = needed;
|
|
|
|
|
2003-10-11 07:24:22 +02:00
|
|
|
if(potm && needed <= cbSize)
|
2002-06-22 03:19:29 +02:00
|
|
|
memcpy(potm, font->potm, font->potm->otmSize);
|
|
|
|
|
|
|
|
end:
|
2001-09-12 22:21:06 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, style_nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, family_nameW);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetCharWidth
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngGetCharWidth(GdiFont font, UINT firstChar, UINT lastChar,
|
|
|
|
LPINT buffer)
|
|
|
|
{
|
|
|
|
UINT c;
|
|
|
|
GLYPHMETRICS gm;
|
2002-01-29 04:02:50 +01:00
|
|
|
FT_UInt glyph_index;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
|
|
|
|
|
|
|
|
for(c = firstChar; c <= lastChar; c++) {
|
2003-06-23 22:51:06 +02:00
|
|
|
glyph_index = get_glyph_index(font, c);
|
|
|
|
WineEngGetGlyphOutline(font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
|
|
|
&gm, 0, NULL, NULL);
|
2002-01-29 04:02:50 +01:00
|
|
|
buffer[c - firstChar] = font->gm[glyph_index].adv;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-02-12 21:05:47 +01:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetCharABCWidths
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngGetCharABCWidths(GdiFont font, UINT firstChar, UINT lastChar,
|
|
|
|
LPABC buffer)
|
|
|
|
{
|
|
|
|
UINT c;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
FT_UInt glyph_index;
|
|
|
|
|
|
|
|
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
|
|
|
|
|
2004-08-10 01:38:10 +02:00
|
|
|
if(!FT_IS_SCALABLE(font->ft_face))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-02-12 21:05:47 +01:00
|
|
|
for(c = firstChar; c <= lastChar; c++) {
|
|
|
|
glyph_index = get_glyph_index(font, c);
|
|
|
|
WineEngGetGlyphOutline(font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
|
|
|
&gm, 0, NULL, NULL);
|
|
|
|
buffer[c - firstChar].abcA = font->gm[glyph_index].lsb;
|
|
|
|
buffer[c - firstChar].abcB = font->gm[glyph_index].bbx;
|
|
|
|
buffer[c - firstChar].abcC = font->gm[glyph_index].adv - font->gm[glyph_index].lsb -
|
|
|
|
font->gm[glyph_index].bbx;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetTextExtentPoint
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngGetTextExtentPoint(GdiFont font, LPCWSTR wstr, INT count,
|
|
|
|
LPSIZE size)
|
|
|
|
{
|
2003-03-17 05:42:30 +01:00
|
|
|
INT idx;
|
2001-09-12 22:21:06 +02:00
|
|
|
GLYPHMETRICS gm;
|
|
|
|
TEXTMETRICW tm;
|
2002-01-29 04:02:50 +01:00
|
|
|
FT_UInt glyph_index;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
TRACE("%p, %s, %d, %p\n", font, debugstr_wn(wstr, count), count,
|
|
|
|
size);
|
|
|
|
|
|
|
|
size->cx = 0;
|
|
|
|
WineEngGetTextMetrics(font, &tm);
|
|
|
|
size->cy = tm.tmHeight;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
for(idx = 0; idx < count; idx++) {
|
2002-01-29 04:02:50 +01:00
|
|
|
glyph_index = get_glyph_index(font, wstr[idx]);
|
2003-06-23 22:51:06 +02:00
|
|
|
WineEngGetGlyphOutline(font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
|
|
|
&gm, 0, NULL, NULL);
|
2002-01-29 04:02:50 +01:00
|
|
|
size->cx += font->gm[glyph_index].adv;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
TRACE("return %ld,%ld\n", size->cx, size->cy);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-04-04 00:08:27 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetTextExtentPointI
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngGetTextExtentPointI(GdiFont font, const WORD *indices, INT count,
|
|
|
|
LPSIZE size)
|
|
|
|
{
|
2003-03-17 05:42:30 +01:00
|
|
|
INT idx;
|
2002-04-04 00:08:27 +02:00
|
|
|
GLYPHMETRICS gm;
|
|
|
|
TEXTMETRICW tm;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %d, %p\n", font, indices, count, size);
|
|
|
|
|
|
|
|
size->cx = 0;
|
|
|
|
WineEngGetTextMetrics(font, &tm);
|
|
|
|
size->cy = tm.tmHeight;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
for(idx = 0; idx < count; idx++) {
|
2002-04-04 00:08:27 +02:00
|
|
|
WineEngGetGlyphOutline(font, indices[idx],
|
|
|
|
GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, NULL,
|
|
|
|
NULL);
|
|
|
|
size->cx += font->gm[indices[idx]].adv;
|
|
|
|
}
|
|
|
|
TRACE("return %ld,%ld\n", size->cx, size->cy);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-10-23 22:06:32 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetFontData
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf,
|
|
|
|
DWORD cbData)
|
|
|
|
{
|
|
|
|
FT_Face ft_face = font->ft_face;
|
|
|
|
DWORD len;
|
|
|
|
FT_Error err;
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
TRACE("font=%p, table=%08lx, offset=%08lx, buf=%p, cbData=%lx\n",
|
|
|
|
font, table, offset, buf, cbData);
|
|
|
|
|
2001-10-23 22:06:32 +02:00
|
|
|
if(!FT_IS_SFNT(ft_face))
|
|
|
|
return GDI_ERROR;
|
|
|
|
|
|
|
|
if(!buf || !cbData)
|
|
|
|
len = 0;
|
|
|
|
else
|
|
|
|
len = cbData;
|
|
|
|
|
|
|
|
if(table) { /* MS tags differ in endidness from FT ones */
|
|
|
|
table = table >> 24 | table << 24 |
|
|
|
|
(table >> 8 & 0xff00) | (table << 8 & 0xff0000);
|
|
|
|
}
|
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
/* If the FT_Load_Sfnt_Table function is there we'll use it */
|
|
|
|
if(pFT_Load_Sfnt_Table)
|
|
|
|
err = pFT_Load_Sfnt_Table(ft_face, table, offset, buf, &len);
|
|
|
|
else { /* Do it the hard way */
|
|
|
|
TT_Face tt_face = (TT_Face) ft_face;
|
|
|
|
SFNT_Interface *sfnt;
|
|
|
|
if (FT_Version.major==2 && FT_Version.minor==0)
|
|
|
|
{
|
|
|
|
/* 2.0.x */
|
|
|
|
sfnt = *(SFNT_Interface**)((char*)tt_face + 528);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* A field was added in the middle of the structure in 2.1.x */
|
|
|
|
sfnt = *(SFNT_Interface**)((char*)tt_face + 532);
|
|
|
|
}
|
|
|
|
err = sfnt->load_any(tt_face, table, offset, buf, &len);
|
|
|
|
}
|
2001-10-23 22:06:32 +02:00
|
|
|
if(err) {
|
2002-01-29 04:02:50 +01:00
|
|
|
TRACE("Can't find table %08lx.\n", table);
|
2001-10-23 22:06:32 +02:00
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetTextFace
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT WineEngGetTextFace(GdiFont font, INT count, LPWSTR str)
|
|
|
|
{
|
|
|
|
if(str) {
|
|
|
|
lstrcpynW(str, font->name, count);
|
|
|
|
return strlenW(font->name);
|
|
|
|
} else
|
|
|
|
return strlenW(font->name) + 1;
|
|
|
|
}
|
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
UINT WineEngGetTextCharsetInfo(GdiFont font, LPFONTSIGNATURE fs, DWORD flags)
|
|
|
|
{
|
|
|
|
if (fs) memcpy(fs, &font->fs, sizeof(FONTSIGNATURE));
|
|
|
|
return font->charset;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
#else /* HAVE_FREETYPE */
|
|
|
|
|
|
|
|
BOOL WineEngInit(void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-04-03 23:06:09 +02:00
|
|
|
GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
BOOL WineEngDestroyFontInstance(HFONT hfont)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2002-01-29 04:02:50 +01:00
|
|
|
return FALSE;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2004-01-19 22:51:45 +01:00
|
|
|
DWORD WineEngEnumFonts(LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM lparam)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-04-03 22:41:14 +02:00
|
|
|
DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count,
|
|
|
|
LPWORD pgi, DWORD flags)
|
|
|
|
{
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
DWORD WineEngGetGlyphOutline(GdiFont font, UINT glyph, UINT format,
|
|
|
|
LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf,
|
|
|
|
const MAT2* lpmat)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WineEngGetTextMetrics(GdiFont font, LPTEXTMETRICW ptm)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WineEngGetOutlineTextMetrics(GdiFont font, UINT cbSize,
|
|
|
|
OUTLINETEXTMETRICW *potm)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WineEngGetCharWidth(GdiFont font, UINT firstChar, UINT lastChar,
|
|
|
|
LPINT buffer)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
2004-02-12 21:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WineEngGetCharABCWidths(GdiFont font, UINT firstChar, UINT lastChar,
|
|
|
|
LPABC buffer)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WineEngGetTextExtentPoint(GdiFont font, LPCWSTR wstr, INT count,
|
|
|
|
LPSIZE size)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-04-04 17:30:29 +02:00
|
|
|
BOOL WineEngGetTextExtentPointI(GdiFont font, const WORD *indices, INT count,
|
2002-04-04 00:08:27 +02:00
|
|
|
LPSIZE size)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-10-23 22:06:32 +02:00
|
|
|
DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf,
|
|
|
|
DWORD cbData)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
|
|
|
INT WineEngGetTextFace(GdiFont font, INT count, LPWSTR str)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
|
|
|
FIXME(":stub\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
|
|
|
FIXME(":stub\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
|
|
|
UINT WineEngGetTextCharsetInfo(GdiFont font, LPFONTSIGNATURE fs, DWORD flags)
|
|
|
|
{
|
|
|
|
FIXME(":stub\n");
|
|
|
|
return DEFAULT_CHARSET;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
#endif /* HAVE_FREETYPE */
|