2001-09-12 22:21:06 +02:00
|
|
|
/*
|
|
|
|
* FreeType font engine interface
|
|
|
|
*
|
|
|
|
* Copyright 2001 Huw D M Davies for CodeWeavers.
|
2006-09-20 17:18:51 +02:00
|
|
|
* Copyright 2006 Dmitry Timoshkov for CodeWeavers.
|
2001-09-12 22:21:06 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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
|
2006-12-06 21:31:53 +01:00
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
|
|
|
# include <sys/mman.h>
|
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <string.h>
|
2008-10-19 18:55:13 +02:00
|
|
|
#ifdef HAVE_DIRENT_H
|
|
|
|
# include <dirent.h>
|
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2006-12-21 16:21:13 +01:00
|
|
|
#ifdef HAVE_CARBON_CARBON_H
|
|
|
|
#define LoadResource __carbon_LoadResource
|
|
|
|
#define CompareString __carbon_CompareString
|
|
|
|
#define GetCurrentThread __carbon_GetCurrentThread
|
|
|
|
#define GetCurrentProcess __carbon_GetCurrentProcess
|
|
|
|
#define AnimatePalette __carbon_AnimatePalette
|
|
|
|
#define EqualRgn __carbon_EqualRgn
|
|
|
|
#define FillRgn __carbon_FillRgn
|
|
|
|
#define FrameRgn __carbon_FrameRgn
|
|
|
|
#define GetPixel __carbon_GetPixel
|
|
|
|
#define InvertRgn __carbon_InvertRgn
|
|
|
|
#define LineTo __carbon_LineTo
|
|
|
|
#define OffsetRgn __carbon_OffsetRgn
|
|
|
|
#define PaintRgn __carbon_PaintRgn
|
|
|
|
#define Polygon __carbon_Polygon
|
|
|
|
#define ResizePalette __carbon_ResizePalette
|
|
|
|
#define SetRectRgn __carbon_SetRectRgn
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#undef LoadResource
|
|
|
|
#undef CompareString
|
|
|
|
#undef GetCurrentThread
|
|
|
|
#undef _CDECL
|
|
|
|
#undef DPRINTF
|
|
|
|
#undef GetCurrentProcess
|
|
|
|
#undef AnimatePalette
|
|
|
|
#undef EqualRgn
|
|
|
|
#undef FillRgn
|
|
|
|
#undef FrameRgn
|
|
|
|
#undef GetPixel
|
|
|
|
#undef InvertRgn
|
|
|
|
#undef LineTo
|
|
|
|
#undef OffsetRgn
|
|
|
|
#undef PaintRgn
|
|
|
|
#undef Polygon
|
|
|
|
#undef ResizePalette
|
|
|
|
#undef SetRectRgn
|
|
|
|
#endif /* HAVE_CARBON_CARBON_H */
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2006-04-04 13:12:41 +02:00
|
|
|
#include "winternl.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_private.h"
|
2009-12-05 11:45:31 +01:00
|
|
|
#include "wine/library.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
|
2007-09-20 12:10:31 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FTTYPES_H
|
|
|
|
#include <freetype/fttypes.h>
|
|
|
|
#endif
|
2001-09-12 22:21:06 +02:00
|
|
|
#ifdef HAVE_FREETYPE_FTSNAMES_H
|
|
|
|
#include <freetype/ftsnames.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_TTNAMEID_H
|
|
|
|
#include <freetype/ttnameid.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FREETYPE_FTOUTLN_H
|
|
|
|
#include <freetype/ftoutln.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
|
2006-01-24 10:57:35 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTMODAPI_H
|
|
|
|
#include <freetype/ftmodapi.h>
|
|
|
|
#endif
|
2008-12-10 15:50:44 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTLCDFIL_H
|
|
|
|
#include <freetype/ftlcdfil.h>
|
|
|
|
#endif
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2006-02-22 13:24:25 +01:00
|
|
|
#ifndef HAVE_FT_TRUETYPEENGINETYPE
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
|
|
|
|
FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
|
|
|
|
FT_TRUETYPE_ENGINE_TYPE_PATENTED
|
|
|
|
} FT_TrueTypeEngineType;
|
2006-01-24 11:04:20 +01:00
|
|
|
#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
|
|
|
|
MAKE_FUNCPTR(FT_Done_Face);
|
|
|
|
MAKE_FUNCPTR(FT_Get_Char_Index);
|
2011-10-11 11:14:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Get_First_Char);
|
2005-10-06 14:28:11 +02:00
|
|
|
MAKE_FUNCPTR(FT_Get_Module);
|
2011-10-11 11:14:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Get_Next_Char);
|
2006-04-05 13:45:25 +02:00
|
|
|
MAKE_FUNCPTR(FT_Get_Sfnt_Name);
|
|
|
|
MAKE_FUNCPTR(FT_Get_Sfnt_Name_Count);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Get_Sfnt_Table);
|
2011-10-11 11:14:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Get_WinFNT_Header);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Init_FreeType);
|
2011-10-11 11:14:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Library_Version);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Load_Glyph);
|
2011-10-10 15:15:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Load_Sfnt_Table);
|
2003-10-10 02:06:35 +02:00
|
|
|
MAKE_FUNCPTR(FT_Matrix_Multiply);
|
2008-09-03 13:14:17 +02:00
|
|
|
#ifdef FT_MULFIX_INLINED
|
|
|
|
#define pFT_MulFix FT_MULFIX_INLINED
|
|
|
|
#else
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_MulFix);
|
2008-09-03 13:14:17 +02:00
|
|
|
#endif
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_New_Face);
|
2006-12-06 21:31:53 +01:00
|
|
|
MAKE_FUNCPTR(FT_New_Memory_Face);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Outline_Get_Bitmap);
|
|
|
|
MAKE_FUNCPTR(FT_Outline_Transform);
|
|
|
|
MAKE_FUNCPTR(FT_Outline_Translate);
|
2011-10-10 15:15:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Render_Glyph);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Select_Charmap);
|
2007-10-02 05:04:25 +02:00
|
|
|
MAKE_FUNCPTR(FT_Set_Charmap);
|
2002-09-23 22:45:57 +02:00
|
|
|
MAKE_FUNCPTR(FT_Set_Pixel_Sizes);
|
2003-10-10 02:06:35 +02:00
|
|
|
MAKE_FUNCPTR(FT_Vector_Transform);
|
2011-10-10 15:15:56 +02:00
|
|
|
MAKE_FUNCPTR(FT_Vector_Unit);
|
2006-02-22 13:24:25 +01:00
|
|
|
static FT_TrueTypeEngineType (*pFT_Get_TrueType_Engine_Type)(FT_Library);
|
2008-12-23 12:34:01 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTLCDFIL_H
|
|
|
|
static FT_Error (*pFT_Library_SetLcdFilter)(FT_Library, FT_LcdFilter);
|
|
|
|
#endif
|
2002-04-03 22:02:39 +02:00
|
|
|
|
2007-07-02 17:31:48 +02:00
|
|
|
#ifdef SONAME_LIBFONTCONFIG
|
2003-11-09 01:30:13 +01:00
|
|
|
#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);
|
2006-12-19 22:21:27 +01:00
|
|
|
MAKE_FUNCPTR(FcPatternGetBool);
|
2006-04-28 13:51:36 +02:00
|
|
|
MAKE_FUNCPTR(FcPatternGetString);
|
2003-11-09 01:30:13 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
|
2007-09-20 12:10:31 +02:00
|
|
|
#ifndef FT_MAKE_TAG
|
|
|
|
#define FT_MAKE_TAG( ch0, ch1, ch2, ch3 ) \
|
|
|
|
( ((DWORD)(BYTE)(ch0) << 24) | ((DWORD)(BYTE)(ch1) << 16) | \
|
|
|
|
((DWORD)(BYTE)(ch2) << 8) | (DWORD)(BYTE)(ch3) )
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
2006-04-04 13:12:41 +02:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
#define GET_BE_WORD(x) (x)
|
|
|
|
#else
|
|
|
|
#define GET_BE_WORD(x) RtlUshortByteSwap(x)
|
|
|
|
#endif
|
2002-05-23 04:53:10 +02:00
|
|
|
|
2008-03-25 18:35:45 +01:00
|
|
|
/* This is basically a copy of FT_Bitmap_Size with an extra element added */
|
2004-06-16 22:06:26 +02:00
|
|
|
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;
|
|
|
|
|
2008-01-16 07:46:24 +01:00
|
|
|
struct enum_data
|
|
|
|
{
|
|
|
|
ENUMLOGFONTEXW elf;
|
|
|
|
NEWTEXTMETRICEXW ntm;
|
|
|
|
DWORD type;
|
|
|
|
};
|
|
|
|
|
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;
|
2011-05-17 01:20:09 +02:00
|
|
|
WCHAR *FullName;
|
2001-09-12 22:21:06 +02:00
|
|
|
char *file;
|
2007-09-13 19:42:55 +02:00
|
|
|
void *font_data_ptr;
|
|
|
|
DWORD font_data_size;
|
2002-06-22 03:19:29 +02:00
|
|
|
FT_Long face_index;
|
2003-06-23 22:51:06 +02:00
|
|
|
FONTSIGNATURE fs;
|
2005-09-06 11:24:07 +02:00
|
|
|
FONTSIGNATURE fs_links;
|
2008-04-07 09:11:42 +02:00
|
|
|
DWORD ntmFlags;
|
2003-06-23 22:51:06 +02:00
|
|
|
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;
|
2007-12-11 14:09:21 +01:00
|
|
|
/* Cached data for Enum */
|
2008-01-16 07:46:24 +01:00
|
|
|
struct enum_data *cached_enum_data;
|
2001-09-12 22:21:06 +02:00
|
|
|
} Face;
|
|
|
|
|
|
|
|
typedef struct tagFamily {
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list entry;
|
2006-05-26 06:34:50 +02:00
|
|
|
const WCHAR *FamilyName;
|
2011-10-06 23:26:04 +02:00
|
|
|
const WCHAR *EnglishName;
|
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;
|
2006-05-25 11:44:47 +02:00
|
|
|
BOOL can_use_bitmap;
|
2004-08-06 19:31:39 +02:00
|
|
|
} FONT_DESC;
|
|
|
|
|
|
|
|
typedef struct tagHFONTLIST {
|
|
|
|
struct list entry;
|
|
|
|
HFONT hfont;
|
|
|
|
} HFONTLIST;
|
|
|
|
|
2005-09-06 11:24:07 +02:00
|
|
|
typedef struct {
|
|
|
|
struct list entry;
|
2007-09-06 20:40:00 +02:00
|
|
|
Face *face;
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *font;
|
2005-09-06 11:24:07 +02:00
|
|
|
} CHILD_FONT;
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
struct tagGdiFont {
|
2004-08-04 20:16:13 +02:00
|
|
|
struct list entry;
|
2008-02-05 21:16:06 +01:00
|
|
|
GM **gm;
|
|
|
|
DWORD gmsize;
|
|
|
|
struct list hfontlist;
|
|
|
|
OUTLINETEXTMETRICW *potm;
|
|
|
|
DWORD total_kern_pairs;
|
|
|
|
KERNINGPAIR *kern_pairs;
|
|
|
|
struct list child_fonts;
|
|
|
|
|
|
|
|
/* the following members can be accessed without locking, they are never modified after creation */
|
2001-09-12 22:21:06 +02:00
|
|
|
FT_Face ft_face;
|
2006-12-06 21:31:53 +01:00
|
|
|
struct font_mapping *mapping;
|
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;
|
2004-08-06 19:31:39 +02:00
|
|
|
FONT_DESC font_desc;
|
2008-01-08 16:02:09 +01:00
|
|
|
LONG aveWidth, ppem;
|
2008-06-24 09:10:27 +02:00
|
|
|
double scale_y;
|
2002-01-29 04:02:50 +01:00
|
|
|
SHORT yMax;
|
|
|
|
SHORT yMin;
|
2007-09-07 23:30:40 +02:00
|
|
|
DWORD ntmFlags;
|
2003-06-23 22:51:06 +02:00
|
|
|
FONTSIGNATURE fs;
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *base_font;
|
2008-03-13 10:40:58 +01:00
|
|
|
VOID *GSUB_Table;
|
2008-07-31 17:47:22 +02:00
|
|
|
DWORD cache_num;
|
2001-09-12 22:21:06 +02:00
|
|
|
};
|
|
|
|
|
2005-09-06 11:24:07 +02:00
|
|
|
typedef struct {
|
|
|
|
struct list entry;
|
2006-05-26 06:34:50 +02:00
|
|
|
const WCHAR *font_name;
|
2005-09-06 11:24:07 +02:00
|
|
|
struct list links;
|
|
|
|
} SYSTEM_LINKS;
|
|
|
|
|
2011-04-01 14:20:00 +02:00
|
|
|
struct enum_charset_element {
|
|
|
|
DWORD mask;
|
|
|
|
DWORD charset;
|
|
|
|
LPCWSTR name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct enum_charset_list {
|
|
|
|
DWORD total;
|
|
|
|
struct enum_charset_element element[32];
|
|
|
|
};
|
|
|
|
|
2007-08-30 12:17:23 +02:00
|
|
|
#define GM_BLOCK_SIZE 128
|
|
|
|
#define FONT_GM(font,idx) (&(font)->gm[(idx) / GM_BLOCK_SIZE][(idx) % GM_BLOCK_SIZE])
|
2002-01-29 04:02:50 +01:00
|
|
|
|
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
|
2005-09-07 11:21:50 +02:00
|
|
|
static struct list child_font_list = LIST_INIT(child_font_list);
|
2005-09-06 11:24:07 +02:00
|
|
|
static struct list system_links = LIST_INIT(system_links);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2006-03-30 15:38:07 +02:00
|
|
|
static struct list font_subst_list = LIST_INIT(font_subst_list);
|
|
|
|
|
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
|
|
|
|
2007-01-08 21:38:12 +01:00
|
|
|
static const WCHAR defSerif[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n','\0'};
|
2007-07-05 16:27:20 +02:00
|
|
|
static const WCHAR defSans[] = {'A','r','i','a','l','\0'};
|
2003-11-11 21:39:34 +01:00
|
|
|
static const WCHAR defFixed[] = {'C','o','u','r','i','e','r',' ','N','e','w','\0'};
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2007-09-12 08:05:28 +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'};
|
|
|
|
|
2006-05-26 06:34:50 +02:00
|
|
|
static const WCHAR * const SystemFontValues[4] = {
|
2004-06-16 22:06:26 +02:00
|
|
|
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
|
|
|
|
2009-05-09 19:12:40 +02:00
|
|
|
/* Interesting and well-known (frequently-assumed!) font names */
|
|
|
|
static const WCHAR Lucida_Sans_Unicode[] = {'L','u','c','i','d','a',' ','S','a','n','s',' ','U','n','i','c','o','d','e',0};
|
|
|
|
static const WCHAR Microsoft_Sans_Serif[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f',0 };
|
|
|
|
static const WCHAR Tahoma[] = {'T','a','h','o','m','a',0};
|
|
|
|
static const WCHAR MS_UI_Gothic[] = {'M','S',' ','U','I',' ','G','o','t','h','i','c',0};
|
|
|
|
static const WCHAR SimSun[] = {'S','i','m','S','u','n',0};
|
|
|
|
static const WCHAR Gulim[] = {'G','u','l','i','m',0};
|
|
|
|
static const WCHAR PMingLiU[] = {'P','M','i','n','g','L','i','U',0};
|
|
|
|
static const WCHAR Batang[] = {'B','a','t','a','n','g',0};
|
|
|
|
|
2011-10-12 12:55:12 +02:00
|
|
|
static const WCHAR arial[] = {'A','r','i','a','l',0};
|
|
|
|
static const WCHAR bitstream_vera_sans[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','a','n','s',0};
|
|
|
|
static const WCHAR bitstream_vera_sans_mono[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','a','n','s',' ','M','o','n','o',0};
|
|
|
|
static const WCHAR bitstream_vera_serif[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','e','r','i','f',0};
|
|
|
|
static const WCHAR courier_new[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
|
2011-10-12 12:55:13 +02:00
|
|
|
static const WCHAR liberation_mono[] = {'L','i','b','e','r','a','t','i','o','n',' ','M','o','n','o',0};
|
|
|
|
static const WCHAR liberation_sans[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','a','n','s',0};
|
|
|
|
static const WCHAR liberation_serif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
|
2011-10-12 12:55:12 +02:00
|
|
|
static const WCHAR times_new_roman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
|
|
|
|
|
|
|
|
static const WCHAR *default_serif_list[] =
|
|
|
|
{
|
|
|
|
times_new_roman,
|
2011-10-12 12:55:13 +02:00
|
|
|
liberation_serif,
|
2011-10-12 12:55:12 +02:00
|
|
|
bitstream_vera_serif,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR *default_fixed_list[] =
|
|
|
|
{
|
|
|
|
courier_new,
|
2011-10-12 12:55:13 +02:00
|
|
|
liberation_mono,
|
2011-10-12 12:55:12 +02:00
|
|
|
bitstream_vera_sans_mono,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR *default_sans_list[] =
|
|
|
|
{
|
|
|
|
arial,
|
2011-10-12 12:55:13 +02:00
|
|
|
liberation_sans,
|
2011-10-12 12:55:12 +02:00
|
|
|
bitstream_vera_sans,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2006-05-26 06:34:50 +02:00
|
|
|
static const WCHAR * const 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 {
|
2006-03-30 15:38:07 +02:00
|
|
|
WCHAR *name;
|
|
|
|
INT charset;
|
2002-04-03 22:51:20 +02:00
|
|
|
} NameCs;
|
|
|
|
|
|
|
|
typedef struct tagFontSubst {
|
2006-03-30 15:38:07 +02:00
|
|
|
struct list entry;
|
|
|
|
NameCs from;
|
|
|
|
NameCs to;
|
2002-04-03 22:51:20 +02:00
|
|
|
} FontSubst;
|
|
|
|
|
2011-10-06 23:26:06 +02:00
|
|
|
/* Registry font cache key and value names */
|
|
|
|
static const WCHAR wine_fonts_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
|
|
|
|
'F','o','n','t','s',0};
|
|
|
|
static const WCHAR wine_fonts_cache_key[] = {'C','a','c','h','e',0};
|
|
|
|
static const WCHAR english_name_value[] = {'E','n','g','l','i','s','h',' ','N','a','m','e',0};
|
|
|
|
static const WCHAR face_index_value[] = {'I','n','d','e','x',0};
|
|
|
|
static const WCHAR face_italic_value[] = {'I','t','a','l','i','c',0};
|
|
|
|
static const WCHAR face_bold_value[] = {'B','o','l','d',0};
|
|
|
|
static const WCHAR face_version_value[] = {'V','e','r','s','i','o','n',0};
|
|
|
|
static const WCHAR face_external_value[] = {'E','x','t','e','r','n','a','l',0};
|
|
|
|
static const WCHAR face_height_value[] = {'H','e','i','g','h','t',0};
|
|
|
|
static const WCHAR face_width_value[] = {'W','i','d','t','h',0};
|
|
|
|
static const WCHAR face_size_value[] = {'S','i','z','e',0};
|
|
|
|
static const WCHAR face_x_ppem_value[] = {'X','p','p','e','m',0};
|
|
|
|
static const WCHAR face_y_ppem_value[] = {'Y','p','p','e','m',0};
|
|
|
|
static const WCHAR face_internal_leading_value[] = {'I','n','t','e','r','n','a','l',' ','L','e','a','d','i','n','g',0};
|
|
|
|
static const WCHAR face_font_sig_value[] = {'F','o','n','t',' ','S','i','g','n','a','t','u','r','e',0};
|
|
|
|
static const WCHAR face_full_name_value[] = {'F','u','l','l',' ','N','a','m','e','\0'};
|
|
|
|
|
|
|
|
|
2006-12-06 21:31:53 +01:00
|
|
|
struct font_mapping
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
int refcount;
|
|
|
|
dev_t dev;
|
|
|
|
ino_t ino;
|
|
|
|
void *data;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct list mappings_list = LIST_INIT( mappings_list );
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
static CRITICAL_SECTION freetype_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &freetype_cs,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": freetype_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION freetype_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
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'};
|
|
|
|
|
2008-02-18 16:49:07 +01:00
|
|
|
static const WCHAR szDefaultFallbackLink[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f',0};
|
|
|
|
static BOOL use_default_fallback = FALSE;
|
|
|
|
|
2007-05-02 18:15:12 +02:00
|
|
|
static BOOL get_glyph_index_linked(GdiFont *font, UINT c, GdiFont **linked_font, FT_UInt *glyph);
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2009-05-09 19:12:40 +02:00
|
|
|
static const WCHAR system_link[] = {'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','L','i','n','k','\\',
|
|
|
|
'S','y','s','t','e','m','L','i','n','k',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
|
2008-03-25 18:35:45 +01:00
|
|
|
* (HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\FontDPI
|
2004-06-16 22:06:26 +02:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2008-03-13 10:40:58 +01:00
|
|
|
/* These are all structures needed for the GSUB table */
|
|
|
|
|
|
|
|
#define GSUB_TAG MS_MAKE_TAG('G', 'S', 'U', 'B')
|
|
|
|
#define TATEGAKI_LOWER_BOUND 0x02F1
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DWORD version;
|
|
|
|
WORD ScriptList;
|
|
|
|
WORD FeatureList;
|
|
|
|
WORD LookupList;
|
|
|
|
} GSUB_Header;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
CHAR ScriptTag[4];
|
|
|
|
WORD Script;
|
|
|
|
} GSUB_ScriptRecord;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD ScriptCount;
|
|
|
|
GSUB_ScriptRecord ScriptRecord[1];
|
|
|
|
} GSUB_ScriptList;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
CHAR LangSysTag[4];
|
|
|
|
WORD LangSys;
|
|
|
|
} GSUB_LangSysRecord;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD DefaultLangSys;
|
|
|
|
WORD LangSysCount;
|
|
|
|
GSUB_LangSysRecord LangSysRecord[1];
|
|
|
|
} GSUB_Script;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD LookupOrder; /* Reserved */
|
|
|
|
WORD ReqFeatureIndex;
|
|
|
|
WORD FeatureCount;
|
|
|
|
WORD FeatureIndex[1];
|
|
|
|
} GSUB_LangSys;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
CHAR FeatureTag[4];
|
|
|
|
WORD Feature;
|
|
|
|
} GSUB_FeatureRecord;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD FeatureCount;
|
|
|
|
GSUB_FeatureRecord FeatureRecord[1];
|
|
|
|
} GSUB_FeatureList;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD FeatureParams; /* Reserved */
|
|
|
|
WORD LookupCount;
|
|
|
|
WORD LookupListIndex[1];
|
|
|
|
} GSUB_Feature;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD LookupCount;
|
|
|
|
WORD Lookup[1];
|
|
|
|
} GSUB_LookupList;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD LookupType;
|
|
|
|
WORD LookupFlag;
|
|
|
|
WORD SubTableCount;
|
|
|
|
WORD SubTable[1];
|
|
|
|
} GSUB_LookupTable;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD CoverageFormat;
|
|
|
|
WORD GlyphCount;
|
|
|
|
WORD GlyphArray[1];
|
|
|
|
} GSUB_CoverageFormat1;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD Start;
|
|
|
|
WORD End;
|
|
|
|
WORD StartCoverageIndex;
|
|
|
|
} GSUB_RangeRecord;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD CoverageFormat;
|
|
|
|
WORD RangeCount;
|
|
|
|
GSUB_RangeRecord RangeRecord[1];
|
|
|
|
} GSUB_CoverageFormat2;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD SubstFormat; /* = 1 */
|
|
|
|
WORD Coverage;
|
|
|
|
WORD DeltaGlyphID;
|
|
|
|
} GSUB_SingleSubstFormat1;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
WORD SubstFormat; /* = 2 */
|
|
|
|
WORD Coverage;
|
|
|
|
WORD GlyphCount;
|
|
|
|
WORD Substitute[1];
|
|
|
|
}GSUB_SingleSubstFormat2;
|
|
|
|
|
2006-12-21 16:21:13 +01:00
|
|
|
#ifdef HAVE_CARBON_CARBON_H
|
|
|
|
static char *find_cache_dir(void)
|
|
|
|
{
|
|
|
|
FSRef ref;
|
|
|
|
OSErr err;
|
|
|
|
static char cached_path[MAX_PATH];
|
|
|
|
static const char *wine = "/Wine", *fonts = "/Fonts";
|
|
|
|
|
|
|
|
if(*cached_path) return cached_path;
|
|
|
|
|
|
|
|
err = FSFindFolder(kUserDomain, kCachedDataFolderType, kCreateFolder, &ref);
|
|
|
|
if(err != noErr)
|
|
|
|
{
|
|
|
|
WARN("can't create cached data folder\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
err = FSRefMakePath(&ref, (unsigned char*)cached_path, sizeof(cached_path));
|
|
|
|
if(err != noErr)
|
|
|
|
{
|
|
|
|
WARN("can't create cached data path\n");
|
|
|
|
*cached_path = '\0';
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if(strlen(cached_path) + strlen(wine) + strlen(fonts) + 1 > sizeof(cached_path))
|
|
|
|
{
|
|
|
|
ERR("Could not create full path\n");
|
|
|
|
*cached_path = '\0';
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strcat(cached_path, wine);
|
|
|
|
|
|
|
|
if(mkdir(cached_path, 0700) == -1 && errno != EEXIST)
|
|
|
|
{
|
|
|
|
WARN("Couldn't mkdir %s\n", cached_path);
|
|
|
|
*cached_path = '\0';
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strcat(cached_path, fonts);
|
|
|
|
if(mkdir(cached_path, 0700) == -1 && errno != EEXIST)
|
|
|
|
{
|
|
|
|
WARN("Couldn't mkdir %s\n", cached_path);
|
|
|
|
*cached_path = '\0';
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return cached_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* expand_mac_font
|
|
|
|
*
|
|
|
|
* Extracts individual TrueType font files from a Mac suitcase font
|
|
|
|
* and saves them into the user's caches directory (see
|
|
|
|
* find_cache_dir()).
|
|
|
|
* Returns a NULL terminated array of filenames.
|
|
|
|
*
|
|
|
|
* We do this because they are apps that try to read ttf files
|
|
|
|
* themselves and they don't like Mac suitcase files.
|
|
|
|
*/
|
|
|
|
static char **expand_mac_font(const char *path)
|
|
|
|
{
|
|
|
|
FSRef ref;
|
|
|
|
SInt16 res_ref;
|
|
|
|
OSStatus s;
|
|
|
|
unsigned int idx;
|
|
|
|
const char *out_dir;
|
|
|
|
const char *filename;
|
|
|
|
int output_len;
|
|
|
|
struct {
|
|
|
|
char **array;
|
|
|
|
unsigned int size, max_size;
|
|
|
|
} ret;
|
|
|
|
|
|
|
|
TRACE("path %s\n", path);
|
|
|
|
|
|
|
|
s = FSPathMakeRef((unsigned char*)path, &ref, FALSE);
|
|
|
|
if(s != noErr)
|
|
|
|
{
|
|
|
|
WARN("failed to get ref\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = FSOpenResourceFile(&ref, 0, NULL, fsRdPerm, &res_ref);
|
|
|
|
if(s != noErr)
|
|
|
|
{
|
|
|
|
TRACE("no data fork, so trying resource fork\n");
|
|
|
|
res_ref = FSOpenResFile(&ref, fsRdPerm);
|
|
|
|
if(res_ref == -1)
|
|
|
|
{
|
|
|
|
TRACE("unable to open resource fork\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret.size = 0;
|
|
|
|
ret.max_size = 10;
|
|
|
|
ret.array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ret.max_size * sizeof(*ret.array));
|
|
|
|
if(!ret.array)
|
|
|
|
{
|
|
|
|
CloseResFile(res_ref);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
out_dir = find_cache_dir();
|
|
|
|
|
|
|
|
filename = strrchr(path, '/');
|
|
|
|
if(!filename) filename = path;
|
|
|
|
else filename++;
|
|
|
|
|
|
|
|
/* output filename has the form out_dir/filename_%04x.ttf */
|
|
|
|
output_len = strlen(out_dir) + 1 + strlen(filename) + 5 + 5;
|
|
|
|
|
|
|
|
UseResFile(res_ref);
|
|
|
|
idx = 1;
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
FamRec *fam_rec;
|
|
|
|
unsigned short *num_faces_ptr, num_faces, face;
|
|
|
|
AsscEntry *assoc;
|
|
|
|
Handle fond;
|
2007-09-20 12:10:31 +02:00
|
|
|
ResType fond_res = FT_MAKE_TAG('F','O','N','D');
|
2006-12-21 16:21:13 +01:00
|
|
|
|
2007-06-25 23:34:34 +02:00
|
|
|
fond = Get1IndResource(fond_res, idx);
|
2006-12-21 16:21:13 +01:00
|
|
|
if(!fond) break;
|
|
|
|
TRACE("got fond resource %d\n", idx);
|
|
|
|
HLock(fond);
|
|
|
|
|
|
|
|
fam_rec = *(FamRec**)fond;
|
|
|
|
num_faces_ptr = (unsigned short *)(fam_rec + 1);
|
|
|
|
num_faces = GET_BE_WORD(*num_faces_ptr);
|
|
|
|
num_faces++;
|
|
|
|
assoc = (AsscEntry*)(num_faces_ptr + 1);
|
|
|
|
TRACE("num faces %04x\n", num_faces);
|
|
|
|
for(face = 0; face < num_faces; face++, assoc++)
|
|
|
|
{
|
|
|
|
Handle sfnt;
|
2007-09-20 12:10:31 +02:00
|
|
|
ResType sfnt_res = FT_MAKE_TAG('s','f','n','t');
|
2006-12-21 16:21:13 +01:00
|
|
|
unsigned short size, font_id;
|
|
|
|
char *output;
|
|
|
|
|
|
|
|
size = GET_BE_WORD(assoc->fontSize);
|
|
|
|
font_id = GET_BE_WORD(assoc->fontID);
|
|
|
|
if(size != 0)
|
|
|
|
{
|
|
|
|
TRACE("skipping id %04x because it's not scalable (fixed size %d)\n", font_id, size);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("trying to load sfnt id %04x\n", font_id);
|
2007-06-25 23:34:34 +02:00
|
|
|
sfnt = GetResource(sfnt_res, font_id);
|
2006-12-21 16:21:13 +01:00
|
|
|
if(!sfnt)
|
|
|
|
{
|
|
|
|
TRACE("can't get sfnt resource %04x\n", font_id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
output = HeapAlloc(GetProcessHeap(), 0, output_len);
|
|
|
|
if(output)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
sprintf(output, "%s/%s_%04x.ttf", out_dir, filename, font_id);
|
|
|
|
|
|
|
|
fd = open(output, O_CREAT | O_EXCL | O_WRONLY, 0600);
|
|
|
|
if(fd != -1 || errno == EEXIST)
|
|
|
|
{
|
|
|
|
if(fd != -1)
|
|
|
|
{
|
|
|
|
unsigned char *sfnt_data;
|
|
|
|
|
|
|
|
HLock(sfnt);
|
|
|
|
sfnt_data = *(unsigned char**)sfnt;
|
|
|
|
write(fd, sfnt_data, GetHandleSize(sfnt));
|
|
|
|
HUnlock(sfnt);
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
if(ret.size >= ret.max_size - 1) /* Always want the last element to be NULL */
|
|
|
|
{
|
|
|
|
ret.max_size *= 2;
|
|
|
|
ret.array = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ret.array, ret.max_size * sizeof(*ret.array));
|
|
|
|
}
|
|
|
|
ret.array[ret.size++] = output;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("unable to create %s\n", output);
|
|
|
|
HeapFree(GetProcessHeap(), 0, output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ReleaseResource(sfnt);
|
|
|
|
}
|
|
|
|
HUnlock(fond);
|
|
|
|
ReleaseResource(fond);
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
CloseResFile(res_ref);
|
|
|
|
|
|
|
|
return ret.array;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_CARBON_CARBON_H */
|
2004-06-16 22:06:26 +02:00
|
|
|
|
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
|
|
|
/*
|
2008-06-30 00:23:07 +02:00
|
|
|
This function builds an FT_Fixed from a double. It fails if the absolute
|
|
|
|
value of the float number is greater than 32768.
|
2003-10-10 02:06:35 +02:00
|
|
|
*/
|
2008-06-24 09:10:27 +02:00
|
|
|
static inline FT_Fixed FT_FixedFromFloat(double f)
|
2003-10-10 02:06:35 +02:00
|
|
|
{
|
2008-06-30 00:23:07 +02:00
|
|
|
return f * 0x10000;
|
2003-10-10 02:06:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
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)
|
|
|
|
{
|
2009-06-02 10:16:38 +02:00
|
|
|
return (FT_Fixed)((int)f.value << 16 | (unsigned int)f.fract);
|
2003-10-10 02:06:35 +02:00
|
|
|
}
|
|
|
|
|
2006-04-05 13:41:49 +02:00
|
|
|
|
2006-04-10 13:35:23 +02:00
|
|
|
static Face *find_face_from_filename(const WCHAR *file_name, const WCHAR *face_name)
|
2006-04-05 13:41:49 +02:00
|
|
|
{
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2006-05-26 06:34:50 +02:00
|
|
|
const char *file;
|
2006-04-10 13:35:23 +02:00
|
|
|
DWORD len = WideCharToMultiByte(CP_UNIXCP, 0, file_name, -1, NULL, 0, NULL, NULL);
|
|
|
|
char *file_nameA = HeapAlloc(GetProcessHeap(), 0, len);
|
2006-04-05 13:41:49 +02:00
|
|
|
|
2006-04-10 13:35:23 +02:00
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, file_name, -1, file_nameA, len, NULL, NULL);
|
|
|
|
TRACE("looking for file %s name %s\n", debugstr_a(file_nameA), debugstr_w(face_name));
|
2006-04-05 13:41:49 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
|
|
|
{
|
2006-04-10 13:35:23 +02:00
|
|
|
if(face_name && strcmpiW(face_name, family->FamilyName))
|
|
|
|
continue;
|
2006-04-05 13:41:49 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(face, &family->faces, Face, entry)
|
|
|
|
{
|
2007-09-13 19:42:55 +02:00
|
|
|
if (!face->file)
|
|
|
|
continue;
|
2006-04-05 13:41:49 +02:00
|
|
|
file = strrchr(face->file, '/');
|
|
|
|
if(!file)
|
|
|
|
file = face->file;
|
|
|
|
else
|
|
|
|
file++;
|
2006-09-12 23:41:43 +02:00
|
|
|
if(!strcasecmp(file, file_nameA))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, file_nameA);
|
|
|
|
return face;
|
|
|
|
}
|
2006-04-05 13:41:49 +02:00
|
|
|
}
|
|
|
|
}
|
2006-04-10 13:35:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, file_nameA);
|
2006-09-12 23:41:43 +02:00
|
|
|
return NULL;
|
2006-04-05 13:41:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Family *find_family_from_name(const WCHAR *name)
|
|
|
|
{
|
|
|
|
Family *family;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
|
|
|
|
{
|
|
|
|
if(!strcmpiW(family->FamilyName, name))
|
|
|
|
return family;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-03-07 06:45:11 +01:00
|
|
|
|
2006-04-05 13:41:49 +02:00
|
|
|
static void DumpSubstList(void)
|
|
|
|
{
|
|
|
|
FontSubst *psub;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(psub, &font_subst_list, FontSubst, entry)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPWSTR strdupW(LPCWSTR p)
|
|
|
|
{
|
|
|
|
LPWSTR ret;
|
|
|
|
DWORD len = (strlenW(p) + 1) * sizeof(WCHAR);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
memcpy(ret, p, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPSTR strdupA(LPCSTR p)
|
|
|
|
{
|
|
|
|
LPSTR ret;
|
|
|
|
DWORD len = (strlen(p) + 1);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
memcpy(ret, p, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FontSubst *get_font_subst(const struct list *subst_list, const WCHAR *from_name,
|
|
|
|
INT from_charset)
|
|
|
|
{
|
|
|
|
FontSubst *element;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(element, subst_list, FontSubst, entry)
|
|
|
|
{
|
|
|
|
if(!strcmpiW(element->from.name, from_name) &&
|
|
|
|
(element->from.charset == from_charset ||
|
|
|
|
element->from.charset == -1))
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_FONT_SUBST_FORCE 1
|
|
|
|
|
|
|
|
static BOOL add_font_subst(struct list *subst_list, FontSubst *subst, INT flags)
|
|
|
|
{
|
|
|
|
FontSubst *from_exist, *to_exist;
|
|
|
|
|
|
|
|
from_exist = get_font_subst(subst_list, subst->from.name, subst->from.charset);
|
|
|
|
|
|
|
|
if(from_exist && (flags & ADD_FONT_SUBST_FORCE))
|
|
|
|
{
|
|
|
|
list_remove(&from_exist->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, &from_exist->from.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, &from_exist->to.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, from_exist);
|
|
|
|
from_exist = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!from_exist)
|
|
|
|
{
|
|
|
|
to_exist = get_font_subst(subst_list, subst->to.name, subst->to.charset);
|
|
|
|
|
|
|
|
if(to_exist)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, subst->to.name);
|
|
|
|
subst->to.name = strdupW(to_exist->to.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_add_tail(subst_list, &subst->entry);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-04-05 13:43:12 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, subst->from.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, subst->to.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, subst);
|
2006-04-05 13:41:49 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LoadSubstList(void)
|
|
|
|
{
|
|
|
|
FontSubst *psub;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
|
|
|
|
LPSTR value;
|
|
|
|
LPVOID data;
|
|
|
|
|
|
|
|
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;
|
|
|
|
while(RegEnumValueA(hkey, i++, value, &vlen, NULL, &type, data,
|
|
|
|
&dlen) == ERROR_SUCCESS) {
|
|
|
|
TRACE("Got %s=%s\n", debugstr_a(value), debugstr_a(data));
|
|
|
|
|
|
|
|
psub = HeapAlloc(GetProcessHeap(), 0, sizeof(*psub));
|
|
|
|
split_subst_info(&psub->from, value);
|
|
|
|
split_subst_info(&psub->to, data);
|
|
|
|
|
|
|
|
/* Win 2000 doesn't allow mapping between different charsets
|
|
|
|
or mapping of DEFAULT_CHARSET */
|
2008-06-22 15:41:47 +02:00
|
|
|
if ((psub->from.charset && psub->to.charset != psub->from.charset) ||
|
2006-04-05 13:41:49 +02:00
|
|
|
psub->to.charset == DEFAULT_CHARSET) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, psub->to.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, psub->from.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, psub);
|
|
|
|
} else {
|
|
|
|
add_font_subst(&font_subst_list, psub, 0);
|
|
|
|
}
|
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, value);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-18 13:23:08 +02:00
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* get_name_table_entry
|
|
|
|
*
|
|
|
|
* Supply the platform, encoding, language and name ids in req
|
|
|
|
* and if the name exists the function will fill in the string
|
|
|
|
* and string_len members. The string is owned by FreeType so
|
|
|
|
* don't free it. Returns TRUE if the name is found else FALSE.
|
|
|
|
*/
|
|
|
|
static BOOL get_name_table_entry(FT_Face ft_face, FT_SfntName *req)
|
2006-04-05 13:45:25 +02:00
|
|
|
{
|
|
|
|
FT_SfntName name;
|
2008-09-18 13:23:08 +02:00
|
|
|
FT_UInt num_names, name_index;
|
2006-04-05 13:45:25 +02:00
|
|
|
|
|
|
|
if(FT_IS_SFNT(ft_face))
|
|
|
|
{
|
|
|
|
num_names = pFT_Get_Sfnt_Name_Count(ft_face);
|
|
|
|
|
|
|
|
for(name_index = 0; name_index < num_names; name_index++)
|
|
|
|
{
|
|
|
|
if(!pFT_Get_Sfnt_Name(ft_face, name_index, &name))
|
|
|
|
{
|
2008-09-18 13:23:08 +02:00
|
|
|
if((name.platform_id == req->platform_id) &&
|
|
|
|
(name.encoding_id == req->encoding_id) &&
|
|
|
|
(name.language_id == req->language_id) &&
|
|
|
|
(name.name_id == req->name_id))
|
2006-04-05 13:45:25 +02:00
|
|
|
{
|
2008-09-18 13:23:08 +02:00
|
|
|
req->string = name.string;
|
|
|
|
req->string_len = name.string_len;
|
|
|
|
return TRUE;
|
2006-04-05 13:45:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-18 13:23:08 +02:00
|
|
|
req->string = NULL;
|
|
|
|
req->string_len = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-04-05 13:45:25 +02:00
|
|
|
|
2011-05-10 22:38:06 +02:00
|
|
|
static WCHAR *get_face_name(FT_Face ft_face, FT_UShort name_id, FT_UShort language_id)
|
2008-09-18 13:23:08 +02:00
|
|
|
{
|
2011-05-10 22:38:06 +02:00
|
|
|
WCHAR *ret = NULL;
|
2008-09-18 13:23:08 +02:00
|
|
|
FT_SfntName name;
|
|
|
|
|
|
|
|
name.platform_id = TT_PLATFORM_MICROSOFT;
|
|
|
|
name.encoding_id = TT_MS_ID_UNICODE_CS;
|
2011-05-10 22:38:06 +02:00
|
|
|
name.language_id = language_id;
|
|
|
|
name.name_id = name_id;
|
2008-09-18 13:23:08 +02:00
|
|
|
|
|
|
|
if(get_name_table_entry(ft_face, &name))
|
|
|
|
{
|
2008-10-10 21:00:41 +02:00
|
|
|
FT_UInt i;
|
2008-09-18 13:23:08 +02:00
|
|
|
|
|
|
|
/* String is not nul terminated and string_len is a byte length. */
|
2011-05-10 22:38:06 +02:00
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, name.string_len + 2);
|
2008-09-18 13:23:08 +02:00
|
|
|
for(i = 0; i < name.string_len / 2; i++)
|
|
|
|
{
|
|
|
|
WORD *tmp = (WORD *)&name.string[i * 2];
|
2011-05-10 22:38:06 +02:00
|
|
|
ret[i] = GET_BE_WORD(*tmp);
|
2008-09-18 13:23:08 +02:00
|
|
|
}
|
2011-05-10 22:38:06 +02:00
|
|
|
ret[i] = 0;
|
|
|
|
TRACE("Got localised name %s\n", debugstr_w(ret));
|
2008-09-18 13:23:08 +02:00
|
|
|
}
|
|
|
|
|
2011-05-10 22:38:06 +02:00
|
|
|
return ret;
|
2006-04-05 13:45:25 +02:00
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:07 +02:00
|
|
|
static LONG reg_load_dword(HKEY hkey, const WCHAR *value, DWORD *data)
|
|
|
|
{
|
|
|
|
DWORD type, needed;
|
|
|
|
LONG r = RegQueryValueExW(hkey, value, NULL, &type, NULL, &needed);
|
|
|
|
if(r != ERROR_SUCCESS) return r;
|
|
|
|
if(type != REG_DWORD || needed != sizeof(DWORD)) return ERROR_BAD_CONFIGURATION;
|
|
|
|
return RegQueryValueExW(hkey, value, NULL, &type, (BYTE*)data, &needed);
|
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:06 +02:00
|
|
|
static inline LONG reg_save_dword(HKEY hkey, const WCHAR *value, DWORD data)
|
|
|
|
{
|
|
|
|
return RegSetValueExW(hkey, value, 0, REG_DWORD, (BYTE*)&data, sizeof(DWORD));
|
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:07 +02:00
|
|
|
static void load_face(HKEY hkey_face, WCHAR *face_name, Family *family)
|
|
|
|
{
|
|
|
|
DWORD needed;
|
|
|
|
DWORD num_strikes, max_strike_key_len;
|
|
|
|
|
|
|
|
/* If we have a File Name key then this is a real font, not just the parent
|
|
|
|
key of a bunch of non-scalable strikes */
|
|
|
|
if(RegQueryValueExA(hkey_face, "File Name", NULL, NULL, NULL, &needed) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DWORD italic, bold;
|
|
|
|
Face *face;
|
|
|
|
face = HeapAlloc(GetProcessHeap(), 0, sizeof(*face));
|
|
|
|
face->cached_enum_data = NULL;
|
|
|
|
|
|
|
|
face->file = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
RegQueryValueExA(hkey_face, "File Name", NULL, NULL, (BYTE*)face->file, &needed);
|
|
|
|
|
|
|
|
face->StyleName = strdupW(face_name);
|
|
|
|
face->family = family;
|
|
|
|
|
|
|
|
if(RegQueryValueExW(hkey_face, face_full_name_value, NULL, NULL, NULL, &needed) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR *fullName = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
RegQueryValueExW(hkey_face, face_full_name_value, NULL, NULL, (BYTE*)fullName, &needed);
|
|
|
|
face->FullName = fullName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
face->FullName = NULL;
|
|
|
|
|
|
|
|
reg_load_dword(hkey_face, face_index_value, (DWORD*)&face->face_index);
|
|
|
|
reg_load_dword(hkey_face, face_italic_value, &italic);
|
|
|
|
reg_load_dword(hkey_face, face_bold_value, &bold);
|
|
|
|
reg_load_dword(hkey_face, face_version_value, (DWORD*)&face->font_version);
|
|
|
|
reg_load_dword(hkey_face, face_external_value, (DWORD*)&face->external);
|
|
|
|
|
|
|
|
needed = sizeof(face->fs);
|
|
|
|
RegQueryValueExW(hkey_face, face_font_sig_value, NULL, NULL, (BYTE*)&face->fs, &needed);
|
|
|
|
memset(&face->fs_links, 0, sizeof(face->fs_links));
|
|
|
|
|
|
|
|
if(reg_load_dword(hkey_face, face_height_value, (DWORD*)&face->size.height) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
face->scalable = TRUE;
|
|
|
|
memset(&face->size, 0, sizeof(face->size));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
face->scalable = FALSE;
|
|
|
|
reg_load_dword(hkey_face, face_width_value, (DWORD*)&face->size.width);
|
|
|
|
reg_load_dword(hkey_face, face_size_value, (DWORD*)&face->size.size);
|
|
|
|
reg_load_dword(hkey_face, face_x_ppem_value, (DWORD*)&face->size.x_ppem);
|
|
|
|
reg_load_dword(hkey_face, face_y_ppem_value, (DWORD*)&face->size.y_ppem);
|
|
|
|
reg_load_dword(hkey_face, face_internal_leading_value, (DWORD*)&face->size.internal_leading);
|
|
|
|
|
|
|
|
TRACE("Adding bitmap size h %d w %d size %ld x_ppem %ld y_ppem %ld\n",
|
|
|
|
face->size.height, face->size.width, face->size.size >> 6,
|
|
|
|
face->size.x_ppem >> 6, face->size.y_ppem >> 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
face->ntmFlags = 0;
|
|
|
|
if (italic) face->ntmFlags |= NTM_ITALIC;
|
|
|
|
if (bold) face->ntmFlags |= NTM_BOLD;
|
|
|
|
if (face->ntmFlags == 0) face->ntmFlags = NTM_REGULAR;
|
|
|
|
|
|
|
|
TRACE("fsCsb = %08x %08x/%08x %08x %08x %08x\n",
|
|
|
|
face->fs.fsCsb[0], face->fs.fsCsb[1],
|
|
|
|
face->fs.fsUsb[0], face->fs.fsUsb[1],
|
|
|
|
face->fs.fsUsb[2], face->fs.fsUsb[3]);
|
|
|
|
|
|
|
|
if(!italic && !bold)
|
|
|
|
list_add_head(&family->faces, &face->entry);
|
|
|
|
else
|
|
|
|
list_add_tail(&family->faces, &face->entry);
|
|
|
|
|
|
|
|
TRACE("Added font %s %s\n", debugstr_w(family->FamilyName), debugstr_w(face->StyleName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do we have any bitmap strikes? */
|
|
|
|
RegQueryInfoKeyW(hkey_face, NULL, NULL, NULL, &num_strikes, &max_strike_key_len, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if(num_strikes != 0)
|
|
|
|
{
|
|
|
|
WCHAR strike_name[10];
|
|
|
|
DWORD strike_index = 0;
|
|
|
|
|
|
|
|
needed = sizeof(strike_name) / sizeof(WCHAR);
|
|
|
|
while(RegEnumKeyExW(hkey_face, strike_index++, strike_name, &needed,
|
|
|
|
NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
HKEY hkey_strike;
|
|
|
|
RegOpenKeyExW(hkey_face, strike_name, 0, KEY_ALL_ACCESS, &hkey_strike);
|
|
|
|
load_face(hkey_strike, face_name, family);
|
|
|
|
RegCloseKey(hkey_strike);
|
|
|
|
needed = sizeof(strike_name) / sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void load_font_list_from_cache(HKEY hkey_font_cache)
|
|
|
|
{
|
|
|
|
DWORD max_family_key_len, size;
|
|
|
|
WCHAR *family_name;
|
|
|
|
DWORD family_index = 0;
|
|
|
|
Family *family;
|
|
|
|
HKEY hkey_family;
|
|
|
|
|
|
|
|
RegQueryInfoKeyW(hkey_font_cache, NULL, NULL, NULL, NULL, &max_family_key_len, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
family_name = HeapAlloc(GetProcessHeap(), 0, (max_family_key_len + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
size = max_family_key_len + 1;
|
|
|
|
while(RegEnumKeyExW(hkey_font_cache, family_index++, family_name, &size,
|
|
|
|
NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WCHAR *english_family = NULL;
|
|
|
|
DWORD face_index = 0;
|
|
|
|
WCHAR *face_name;
|
|
|
|
DWORD max_face_key_len;
|
|
|
|
|
|
|
|
RegOpenKeyExW(hkey_font_cache, family_name, 0, KEY_ALL_ACCESS, &hkey_family);
|
|
|
|
TRACE("opened family key %s\n", debugstr_w(family_name));
|
|
|
|
if(RegQueryValueExW(hkey_family, english_name_value, NULL, NULL, NULL, &size) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
english_family = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
RegQueryValueExW(hkey_family, english_name_value, NULL, NULL, (BYTE*)english_family, &size);
|
|
|
|
}
|
|
|
|
|
|
|
|
family = HeapAlloc(GetProcessHeap(), 0, sizeof(*family));
|
|
|
|
family->FamilyName = strdupW(family_name);
|
|
|
|
family->EnglishName = english_family;
|
|
|
|
list_init(&family->faces);
|
|
|
|
list_add_tail(&font_list, &family->entry);
|
|
|
|
|
|
|
|
if(english_family)
|
|
|
|
{
|
|
|
|
FontSubst *subst = HeapAlloc(GetProcessHeap(), 0, sizeof(*subst));
|
|
|
|
subst->from.name = strdupW(english_family);
|
|
|
|
subst->from.charset = -1;
|
|
|
|
subst->to.name = strdupW(family_name);
|
|
|
|
subst->to.charset = -1;
|
|
|
|
add_font_subst(&font_subst_list, subst, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegQueryInfoKeyW(hkey_family, NULL, NULL, NULL, NULL, &max_face_key_len, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
face_name = HeapAlloc(GetProcessHeap(), 0, (max_face_key_len + 1) * sizeof(WCHAR));
|
|
|
|
size = max_face_key_len + 1;
|
|
|
|
while(RegEnumKeyExW(hkey_family, face_index++, face_name, &size,
|
|
|
|
NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
HKEY hkey_face;
|
|
|
|
|
|
|
|
RegOpenKeyExW(hkey_family, face_name, 0, KEY_ALL_ACCESS, &hkey_face);
|
|
|
|
load_face(hkey_face, face_name, family);
|
|
|
|
RegCloseKey(hkey_face);
|
|
|
|
size = max_face_key_len + 1;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, face_name);
|
|
|
|
RegCloseKey(hkey_family);
|
|
|
|
size = max_family_key_len + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, family_name);
|
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:06 +02:00
|
|
|
static LONG create_font_cache_key(HKEY *hkey, DWORD *disposition)
|
|
|
|
{
|
|
|
|
LONG ret;
|
|
|
|
HKEY hkey_wine_fonts;
|
|
|
|
|
|
|
|
/* We don't want to create the fonts key as volatile, so open this first */
|
|
|
|
ret = RegCreateKeyExW(HKEY_CURRENT_USER, wine_fonts_key, 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &hkey_wine_fonts, NULL);
|
|
|
|
if(ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("Can't create %s\n", debugstr_w(wine_fonts_key));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegCreateKeyExW(hkey_wine_fonts, wine_fonts_cache_key, 0, NULL, REG_OPTION_VOLATILE,
|
|
|
|
KEY_ALL_ACCESS, NULL, hkey, disposition);
|
|
|
|
RegCloseKey(hkey_wine_fonts);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_face_to_cache(Face *face)
|
|
|
|
{
|
|
|
|
HKEY hkey_font_cache, hkey_family, hkey_face;
|
|
|
|
WCHAR *face_key_name;
|
|
|
|
|
|
|
|
create_font_cache_key(&hkey_font_cache, NULL);
|
|
|
|
|
|
|
|
RegCreateKeyExW(hkey_font_cache, face->family->FamilyName, 0,
|
|
|
|
NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey_family, NULL);
|
|
|
|
if(face->family->EnglishName)
|
|
|
|
RegSetValueExW(hkey_family, english_name_value, 0, REG_SZ, (BYTE*)face->family->EnglishName,
|
|
|
|
(strlenW(face->family->EnglishName) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
if(face->scalable)
|
|
|
|
face_key_name = face->StyleName;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static const WCHAR fmtW[] = {'%','s','\\','%','d',0};
|
|
|
|
face_key_name = HeapAlloc(GetProcessHeap(), 0, (strlenW(face->StyleName) + 10) * sizeof(WCHAR));
|
|
|
|
sprintfW(face_key_name, fmtW, face->StyleName, face->size.y_ppem);
|
|
|
|
}
|
|
|
|
RegCreateKeyExW(hkey_family, face_key_name, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL,
|
|
|
|
&hkey_face, NULL);
|
|
|
|
if(!face->scalable)
|
|
|
|
HeapFree(GetProcessHeap(), 0, face_key_name);
|
|
|
|
|
|
|
|
RegSetValueExA(hkey_face, "File Name", 0, REG_BINARY, (BYTE*)face->file, strlen(face->file) + 1);
|
|
|
|
if (face->FullName)
|
|
|
|
RegSetValueExW(hkey_face, face_full_name_value, 0, REG_SZ, (BYTE*)face->FullName,
|
|
|
|
(strlenW(face->FullName) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
reg_save_dword(hkey_face, face_index_value, face->face_index);
|
|
|
|
reg_save_dword(hkey_face, face_italic_value, (face->ntmFlags & NTM_ITALIC) != 0);
|
|
|
|
reg_save_dword(hkey_face, face_bold_value, (face->ntmFlags & NTM_BOLD) != 0);
|
|
|
|
reg_save_dword(hkey_face, face_version_value, face->font_version);
|
|
|
|
reg_save_dword(hkey_face, face_external_value, face->external);
|
|
|
|
|
|
|
|
RegSetValueExW(hkey_face, face_font_sig_value, 0, REG_BINARY, (BYTE*)&face->fs, sizeof(face->fs));
|
|
|
|
|
|
|
|
if(!face->scalable)
|
|
|
|
{
|
|
|
|
reg_save_dword(hkey_face, face_height_value, face->size.height);
|
|
|
|
reg_save_dword(hkey_face, face_width_value, face->size.width);
|
|
|
|
reg_save_dword(hkey_face, face_size_value, face->size.size);
|
|
|
|
reg_save_dword(hkey_face, face_x_ppem_value, face->size.x_ppem);
|
|
|
|
reg_save_dword(hkey_face, face_y_ppem_value, face->size.y_ppem);
|
|
|
|
reg_save_dword(hkey_face, face_internal_leading_value, face->size.internal_leading);
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey_face);
|
|
|
|
RegCloseKey(hkey_family);
|
|
|
|
RegCloseKey(hkey_font_cache);
|
|
|
|
}
|
2006-04-05 13:45:25 +02:00
|
|
|
|
2008-04-30 20:51:00 +02:00
|
|
|
static inline int TestStyles(DWORD flags, DWORD styles)
|
|
|
|
{
|
|
|
|
return (flags & styles) == styles;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int StyleOrdering(Face *face)
|
|
|
|
{
|
|
|
|
if (TestStyles(face->ntmFlags, NTM_BOLD | NTM_ITALIC))
|
|
|
|
return 3;
|
|
|
|
if (TestStyles(face->ntmFlags, NTM_ITALIC))
|
|
|
|
return 2;
|
|
|
|
if (TestStyles(face->ntmFlags, NTM_BOLD))
|
|
|
|
return 1;
|
|
|
|
if (TestStyles(face->ntmFlags, NTM_REGULAR))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
WARN("Don't know how to order font %s %s with flags 0x%08x\n",
|
|
|
|
debugstr_w(face->family->FamilyName),
|
|
|
|
debugstr_w(face->StyleName),
|
|
|
|
face->ntmFlags);
|
|
|
|
|
|
|
|
return 9999;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a style of face to a font family using an ordering of the list such
|
|
|
|
that regular fonts come before bold and italic, and single styles come
|
|
|
|
before compound styles. */
|
|
|
|
static void AddFaceToFamily(Face *face, Family *family)
|
|
|
|
{
|
|
|
|
struct list *entry;
|
|
|
|
|
|
|
|
LIST_FOR_EACH( entry, &family->faces )
|
|
|
|
{
|
|
|
|
Face *ent = LIST_ENTRY(entry, Face, entry);
|
|
|
|
if (StyleOrdering(face) < StyleOrdering(ent)) break;
|
|
|
|
}
|
|
|
|
list_add_before( entry, &face->entry );
|
|
|
|
}
|
2007-10-12 15:06:24 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
#define ADDFONT_EXTERNAL_FONT 0x01
|
|
|
|
#define ADDFONT_FORCE_BITMAP 0x02
|
2011-10-06 23:26:06 +02:00
|
|
|
#define ADDFONT_ADD_TO_CACHE 0x04
|
|
|
|
|
2010-11-05 12:48:54 +01:00
|
|
|
static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_size, char *fake_family, const WCHAR *target_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;
|
2006-04-05 13:45:25 +02:00
|
|
|
WCHAR *english_family, *localised_family, *StyleW;
|
2001-09-12 22:21:06 +02:00
|
|
|
DWORD len;
|
2010-11-05 12:48:54 +01:00
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2004-08-18 00:08:31 +02:00
|
|
|
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
|
|
|
FT_WinFNT_HeaderRec winfnt_header;
|
2005-08-19 11:58:32 +02:00
|
|
|
int i, bitmap_num, internal_leading;
|
|
|
|
FONTSIGNATURE fs;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
/* we always load external fonts from files - otherwise we would get a crash in update_reg_entries */
|
|
|
|
assert(file || !(flags & ADDFONT_EXTERNAL_FONT));
|
|
|
|
|
2006-12-21 16:21:13 +01:00
|
|
|
#ifdef HAVE_CARBON_CARBON_H
|
2007-09-13 19:42:55 +02:00
|
|
|
if(file && !fake_family)
|
2006-12-21 16:21:13 +01:00
|
|
|
{
|
|
|
|
char **mac_list = expand_mac_font(file);
|
|
|
|
if(mac_list)
|
|
|
|
{
|
|
|
|
BOOL had_one = FALSE;
|
|
|
|
char **cursor;
|
|
|
|
for(cursor = mac_list; *cursor; cursor++)
|
|
|
|
{
|
|
|
|
had_one = TRUE;
|
2010-11-05 12:48:54 +01:00
|
|
|
AddFontToList(*cursor, NULL, 0, NULL, NULL, flags);
|
2006-12-21 16:21:13 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, *cursor);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, mac_list);
|
|
|
|
if(had_one)
|
2007-05-04 09:26:06 +02:00
|
|
|
return 1;
|
2006-12-21 16:21:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_CARBON_CARBON_H */
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
do {
|
2003-06-23 22:51:06 +02:00
|
|
|
char *family_name = fake_family;
|
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
TRACE("Loading font file %s index %ld\n", debugstr_a(file), face_index);
|
|
|
|
err = pFT_New_Face(library, file, face_index, &ft_face);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
TRACE("Loading font from ptr %p size %d, index %ld\n", font_data_ptr, font_data_size, face_index);
|
|
|
|
err = pFT_New_Memory_Face(library, font_data_ptr, font_data_size, face_index, &ft_face);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(err != 0) {
|
|
|
|
WARN("Unable to load font %s/%p err = %x\n", debugstr_a(file), font_data_ptr, err);
|
2007-05-04 09:26:06 +02:00
|
|
|
return 0;
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
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*/
|
2007-09-13 19:42:55 +02:00
|
|
|
WARN("Ignoring font %s/%p\n", debugstr_a(file), font_data_ptr);
|
2004-06-16 22:06:26 +02:00
|
|
|
pFT_Done_Face(ft_face);
|
2007-05-04 09:26:06 +02:00
|
|
|
return 0;
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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))) {
|
2007-09-13 19:42:55 +02:00
|
|
|
WARN("FreeType version < 2.1.9, skipping bitmap font %s/%p\n", debugstr_a(file), font_data_ptr);
|
2002-06-22 03:19:29 +02:00
|
|
|
pFT_Done_Face(ft_face);
|
2007-05-04 09:26:06 +02:00
|
|
|
return 0;
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2007-10-12 15:35:44 +02:00
|
|
|
if(FT_IS_SFNT(ft_face))
|
|
|
|
{
|
|
|
|
if(!(pOS2 = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_os2)) ||
|
|
|
|
!pFT_Get_Sfnt_Table(ft_face, ft_sfnt_hhea) ||
|
|
|
|
!(pHeader = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_head)))
|
|
|
|
{
|
|
|
|
TRACE("Font %s/%p lacks either an OS2, HHEA or HEAD table.\n"
|
|
|
|
"Skipping this font.\n", debugstr_a(file), font_data_ptr);
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wine uses ttfs as an intermediate step in building its bitmap fonts;
|
|
|
|
we don't want to load these. */
|
|
|
|
if(!memcmp(pOS2->achVendID, "Wine", sizeof(pOS2->achVendID)))
|
|
|
|
{
|
|
|
|
FT_ULong len = 0;
|
|
|
|
|
2011-10-10 15:15:56 +02:00
|
|
|
if(!pFT_Load_Sfnt_Table(ft_face, FT_MAKE_TAG('E','B','S','C'), 0, NULL, &len))
|
2007-10-12 15:35:44 +02:00
|
|
|
{
|
|
|
|
TRACE("Skipping Wine bitmap-only TrueType font %s\n", debugstr_a(file));
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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) {
|
2007-09-13 19:42:55 +02:00
|
|
|
TRACE("Font %s/%p lacks either a family or style name\n", debugstr_a(file), font_data_ptr);
|
2003-06-23 22:51:06 +02:00
|
|
|
pFT_Done_Face(ft_face);
|
2007-05-04 09:26:06 +02:00
|
|
|
return 0;
|
2003-06-23 22:51:06 +02:00
|
|
|
}
|
|
|
|
|
2008-03-21 11:32:45 +01:00
|
|
|
if(ft_face->family_name[0] == '.') /* Ignore fonts with names beginning with a dot */
|
|
|
|
{
|
|
|
|
TRACE("Ignoring %s since its family name begins with a dot\n", debugstr_a(file));
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-02-26 06:25:27 +01:00
|
|
|
if (target_family)
|
|
|
|
{
|
2011-05-10 22:38:06 +02:00
|
|
|
localised_family = get_face_name(ft_face, TT_NAME_ID_FONT_FAMILY, GetUserDefaultLCID());
|
2007-04-19 16:00:02 +02:00
|
|
|
if (localised_family && strcmpiW(localised_family,target_family)!=0)
|
2007-02-26 06:25:27 +01:00
|
|
|
{
|
|
|
|
TRACE("Skipping Index %i: Incorrect Family name for replacement\n",(INT)face_index);
|
|
|
|
HeapFree(GetProcessHeap(), 0, localised_family);
|
|
|
|
num_faces = ft_face->num_faces;
|
2007-03-06 13:30:20 +01:00
|
|
|
pFT_Done_Face(ft_face);
|
2007-02-26 06:25:27 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, localised_family);
|
|
|
|
}
|
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
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;
|
2007-09-07 23:30:40 +02:00
|
|
|
FT_ULong tmp_size;
|
2004-07-14 23:42:35 +02:00
|
|
|
|
|
|
|
if(!FT_IS_SCALABLE(ft_face))
|
|
|
|
size = (My_FT_Bitmap_Size *)ft_face->available_sizes + bitmap_num;
|
|
|
|
|
2010-11-05 12:48:54 +01:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, family_name, -1, NULL, 0);
|
|
|
|
english_family = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, family_name, -1, english_family, len);
|
|
|
|
|
|
|
|
localised_family = NULL;
|
|
|
|
if(!fake_family) {
|
2011-05-10 22:38:06 +02:00
|
|
|
localised_family = get_face_name(ft_face, TT_NAME_ID_FONT_FAMILY, GetUserDefaultLCID());
|
2010-11-05 12:48:54 +01:00
|
|
|
if(localised_family && !strcmpiW(localised_family, english_family)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, localised_family);
|
|
|
|
localised_family = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
family = NULL;
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpiW(family->FamilyName, localised_family ? localised_family : english_family))
|
|
|
|
break;
|
|
|
|
family = NULL;
|
|
|
|
}
|
|
|
|
if(!family) {
|
|
|
|
family = HeapAlloc(GetProcessHeap(), 0, sizeof(*family));
|
|
|
|
family->FamilyName = strdupW(localised_family ? localised_family : english_family);
|
2011-10-06 23:26:04 +02:00
|
|
|
family->EnglishName = localised_family ? strdupW(english_family) : NULL;
|
2010-11-05 12:48:54 +01:00
|
|
|
list_init(&family->faces);
|
|
|
|
list_add_tail(&font_list, &family->entry);
|
|
|
|
|
|
|
|
if(localised_family) {
|
|
|
|
FontSubst *subst = HeapAlloc(GetProcessHeap(), 0, sizeof(*subst));
|
|
|
|
subst->from.name = strdupW(english_family);
|
|
|
|
subst->from.charset = -1;
|
|
|
|
subst->to.name = strdupW(localised_family);
|
|
|
|
subst->to.charset = -1;
|
|
|
|
add_font_subst(&font_subst_list, subst, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, localised_family);
|
|
|
|
HeapFree(GetProcessHeap(), 0, english_family);
|
|
|
|
|
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;
|
|
|
|
|
2011-10-11 11:14:56 +02:00
|
|
|
if(pFT_Get_First_Char( ft_face, &dummy ) < 0x100)
|
2008-01-14 12:38:59 +01:00
|
|
|
fs.fsCsb[0] |= FS_LATIN1;
|
2005-08-19 11:58:32 +02:00
|
|
|
else
|
2008-01-14 12:38:59 +01:00
|
|
|
fs.fsCsb[0] |= FS_SYMBOL;
|
2005-08-19 11:58:32 +02:00
|
|
|
}
|
|
|
|
}
|
2011-10-11 11:14:56 +02:00
|
|
|
else if(!pFT_Get_WinFNT_Header(ft_face, &winfnt_header)) {
|
2005-08-19 11:58:32 +02:00
|
|
|
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);
|
2006-07-19 09:17:49 +02:00
|
|
|
if(TranslateCharsetInfo((DWORD*)(UINT_PTR)winfnt_header.charset, &csi, TCI_SRCCHARSET))
|
2008-02-27 22:21:10 +01:00
|
|
|
fs = csi.fs;
|
2005-08-19 11:58:32 +02:00
|
|
|
internal_leading = winfnt_header.internal_leading;
|
|
|
|
}
|
|
|
|
|
2010-11-05 12:48:54 +01: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(!strcmpiW(face->StyleName, StyleW) &&
|
|
|
|
(FT_IS_SCALABLE(ft_face) || ((size->y_ppem == face->size.y_ppem) && !memcmp(&fs, &face->fs, sizeof(fs)) ))) {
|
|
|
|
TRACE("Already loaded font %s %s original version is %lx, this version is %lx\n",
|
|
|
|
debugstr_w(family->FamilyName), debugstr_w(StyleW),
|
|
|
|
face->font_version, pHeader ? pHeader->Font_Revision : 0);
|
|
|
|
|
|
|
|
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 1;
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
2010-11-05 12:48:54 +01:00
|
|
|
if(!pHeader || pHeader->Font_Revision <= face->font_version) {
|
|
|
|
TRACE("Original font is newer so skipping this one\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, StyleW);
|
|
|
|
pFT_Done_Face(ft_face);
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
TRACE("Replacing original with this one\n");
|
|
|
|
list_remove(&face->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, face->file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, face->StyleName);
|
2011-05-17 01:20:09 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, face->FullName);
|
2010-11-05 12:48:54 +01:00
|
|
|
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));
|
2008-01-16 07:46:24 +01:00
|
|
|
face->cached_enum_data = NULL;
|
2004-08-18 00:08:31 +02:00
|
|
|
face->StyleName = StyleW;
|
2011-05-10 22:38:07 +02:00
|
|
|
face->FullName = get_face_name(ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES);
|
2007-09-13 19:42:55 +02:00
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
face->file = strdupA(file);
|
|
|
|
face->font_data_ptr = NULL;
|
|
|
|
face->font_data_size = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
face->file = NULL;
|
|
|
|
face->font_data_ptr = font_data_ptr;
|
|
|
|
face->font_data_size = font_data_size;
|
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
face->face_index = face_index;
|
2008-04-07 09:11:42 +02:00
|
|
|
face->ntmFlags = 0;
|
|
|
|
if (ft_face->style_flags & FT_STYLE_FLAG_ITALIC)
|
|
|
|
face->ntmFlags |= NTM_ITALIC;
|
|
|
|
if (ft_face->style_flags & FT_STYLE_FLAG_BOLD)
|
|
|
|
face->ntmFlags |= NTM_BOLD;
|
|
|
|
if (face->ntmFlags == 0) face->ntmFlags = NTM_REGULAR;
|
2004-08-18 00:08:31 +02:00
|
|
|
face->font_version = pHeader ? pHeader->Font_Revision : 0;
|
|
|
|
face->family = family;
|
|
|
|
face->external = (flags & ADDFONT_EXTERNAL_FONT) ? TRUE : FALSE;
|
2008-02-27 22:21:10 +01:00
|
|
|
face->fs = fs;
|
2005-09-06 11:24:07 +02:00
|
|
|
memset(&face->fs_links, 0, sizeof(face->fs_links));
|
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
|
|
|
}
|
|
|
|
|
2007-09-07 23:30:40 +02:00
|
|
|
/* check for the presence of the 'CFF ' table to check if the font is Type1 */
|
|
|
|
tmp_size = 0;
|
2011-10-10 15:15:56 +02:00
|
|
|
if (!pFT_Load_Sfnt_Table(ft_face, FT_MAKE_TAG('C','F','F',' '), 0, NULL, &tmp_size))
|
2007-09-07 23:30:40 +02:00
|
|
|
{
|
|
|
|
TRACE("Font %s/%p is OTF Type1\n", wine_dbgstr_a(file), font_data_ptr);
|
2008-04-07 09:11:42 +02:00
|
|
|
face->ntmFlags |= NTM_PS_OPENTYPE;
|
2007-09-07 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("fsCsb = %08x %08x/%08x %08x %08x %08x\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:
|
2008-01-14 12:38:59 +01:00
|
|
|
face->fs.fsCsb[0] |= FS_LATIN1;
|
2004-06-16 22:06:26 +02:00
|
|
|
break;
|
2004-09-15 20:03:32 +02:00
|
|
|
case FT_ENCODING_MS_SYMBOL:
|
2008-01-14 12:38:59 +01:00
|
|
|
face->fs.fsCsb[0] |= FS_SYMBOL;
|
2004-06-16 22:06:26 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2011-10-06 23:26:06 +02:00
|
|
|
if(flags & ADDFONT_ADD_TO_CACHE)
|
|
|
|
add_face_to_cache(face);
|
|
|
|
|
2010-11-05 12:48:54 +01:00
|
|
|
AddFaceToFamily(face, family);
|
2008-04-30 20:51:00 +02:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
} 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);
|
2007-05-04 09:26:06 +02:00
|
|
|
return num_faces;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2010-11-05 12:48:54 +01:00
|
|
|
static INT AddFontFileToList(const char *file, char *fake_family, const WCHAR *target_family, DWORD flags)
|
2007-09-13 19:42:55 +02:00
|
|
|
{
|
2010-11-05 12:48:54 +01:00
|
|
|
return AddFontToList(file, NULL, 0, fake_family, target_family, flags);
|
2007-09-13 19:42:55 +02:00
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
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);
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("\t%s\t%08x", debugstr_w(face->StyleName), face->fs.fsCsb[0]);
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!face->scalable)
|
2006-06-01 16:12:30 +02:00
|
|
|
TRACE(" %d", face->size.height);
|
2004-06-16 22:06:26 +02:00
|
|
|
TRACE("\n");
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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;
|
2007-02-26 05:12:30 +01:00
|
|
|
LPWSTR value;
|
2003-06-23 22:51:06 +02:00
|
|
|
LPVOID data;
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2007-02-26 05:12:30 +01:00
|
|
|
CHAR familyA[400];
|
2003-06-23 22:51:06 +02:00
|
|
|
|
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)
|
|
|
|
{
|
2007-02-26 05:12:30 +01:00
|
|
|
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
2003-06-23 22:51:06 +02:00
|
|
|
&valuelen, &datalen, NULL, NULL);
|
|
|
|
|
|
|
|
valuelen++; /* returned value doesn't include room for '\0' */
|
2007-02-26 05:12:30 +01:00
|
|
|
value = HeapAlloc(GetProcessHeap(), 0, valuelen * sizeof(WCHAR));
|
2003-06-23 22:51:06 +02:00
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, datalen);
|
|
|
|
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
2007-02-26 05:12:30 +01:00
|
|
|
while(RegEnumValueW(hkey, i++, value, &vlen, NULL, &type, data,
|
2003-06-23 22:51:06 +02:00
|
|
|
&dlen) == ERROR_SUCCESS) {
|
2007-02-26 05:12:30 +01:00
|
|
|
TRACE("Got %s=%s\n", debugstr_w(value), debugstr_w(data));
|
2003-06-23 22:51:06 +02:00
|
|
|
/* "NewName"="Oldname" */
|
2007-02-26 05:12:30 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, value, -1, familyA, sizeof(familyA), NULL, NULL);
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2011-08-04 17:15:58 +02:00
|
|
|
if(!find_family_from_name(value))
|
|
|
|
{
|
|
|
|
/* Find the old family and hence all of the font files
|
|
|
|
in that family */
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
if(!strcmpiW(family->FamilyName, data)) {
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
TRACE("mapping %s %s to %s\n", debugstr_w(family->FamilyName),
|
|
|
|
debugstr_w(face->StyleName), familyA);
|
|
|
|
/* Now add a new entry with the new family name */
|
|
|
|
AddFontToList(face->file, face->font_data_ptr, face->font_data_size,
|
|
|
|
familyA, family->FamilyName,
|
|
|
|
ADDFONT_FORCE_BITMAP | (face->external ? ADDFONT_EXTERNAL_FONT : 0));
|
|
|
|
}
|
|
|
|
break;
|
2003-06-23 22:51:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, value);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-06 11:24:07 +02:00
|
|
|
/*************************************************************
|
|
|
|
* init_system_links
|
|
|
|
*/
|
|
|
|
static BOOL init_system_links(void)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD type, max_val, max_data, val_len, data_len, index;
|
|
|
|
WCHAR *value, *data;
|
|
|
|
WCHAR *entry, *next;
|
|
|
|
SYSTEM_LINKS *font_link, *system_font_link;
|
|
|
|
CHILD_FONT *child_font;
|
2005-09-14 21:17:00 +02:00
|
|
|
static const WCHAR tahoma_ttf[] = {'t','a','h','o','m','a','.','t','t','f',0};
|
2005-09-06 11:24:07 +02:00
|
|
|
static const WCHAR System[] = {'S','y','s','t','e','m',0};
|
|
|
|
FONTSIGNATURE fs;
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
2006-09-12 23:41:50 +02:00
|
|
|
FontSubst *psub;
|
2005-09-06 11:24:07 +02:00
|
|
|
|
|
|
|
if(RegOpenKeyW(HKEY_LOCAL_MACHINE, system_link, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &max_val, &max_data, NULL, NULL);
|
|
|
|
value = HeapAlloc(GetProcessHeap(), 0, (max_val + 1) * sizeof(WCHAR));
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0, max_data);
|
|
|
|
val_len = max_val + 1;
|
|
|
|
data_len = max_data;
|
|
|
|
index = 0;
|
|
|
|
while(RegEnumValueW(hkey, index++, value, &val_len, NULL, &type, (LPBYTE)data, &data_len) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
memset(&fs, 0, sizeof(fs));
|
2006-09-12 23:41:50 +02:00
|
|
|
psub = get_font_subst(&font_subst_list, value, -1);
|
2009-05-04 15:21:27 +02:00
|
|
|
/* Don't store fonts that are only substitutes for other fonts */
|
|
|
|
if(psub)
|
|
|
|
{
|
|
|
|
TRACE("%s: SystemLink entry for substituted font, ignoring\n", debugstr_w(value));
|
2009-07-15 21:31:17 +02:00
|
|
|
goto next;
|
2009-05-04 15:21:27 +02:00
|
|
|
}
|
|
|
|
font_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*font_link));
|
|
|
|
font_link->font_name = strdupW(value);
|
2005-09-06 11:24:07 +02:00
|
|
|
list_init(&font_link->links);
|
|
|
|
for(entry = data; (char*)entry < (char*)data + data_len && *entry != 0; entry = next)
|
|
|
|
{
|
|
|
|
WCHAR *face_name;
|
|
|
|
CHILD_FONT *child_font;
|
|
|
|
|
2009-04-15 16:33:14 +02:00
|
|
|
TRACE("%s: %s\n", debugstr_w(value), debugstr_w(entry));
|
2005-09-06 11:24:07 +02:00
|
|
|
|
|
|
|
next = entry + strlenW(entry) + 1;
|
|
|
|
|
|
|
|
face_name = strchrW(entry, ',');
|
2006-04-10 13:35:23 +02:00
|
|
|
if(face_name)
|
2005-09-06 11:24:07 +02:00
|
|
|
{
|
|
|
|
*face_name++ = 0;
|
|
|
|
while(isspaceW(*face_name))
|
|
|
|
face_name++;
|
2006-09-12 23:41:50 +02:00
|
|
|
|
|
|
|
psub = get_font_subst(&font_subst_list, face_name, -1);
|
|
|
|
if(psub)
|
|
|
|
face_name = psub->to.name;
|
2005-09-06 11:24:07 +02:00
|
|
|
}
|
2006-04-10 13:35:23 +02:00
|
|
|
face = find_face_from_filename(entry, face_name);
|
2005-09-06 11:24:07 +02:00
|
|
|
if(!face)
|
|
|
|
{
|
2006-04-10 13:35:23 +02:00
|
|
|
TRACE("Unable to find file %s face name %s\n", debugstr_w(entry), debugstr_w(face_name));
|
2005-09-06 11:24:07 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
child_font = HeapAlloc(GetProcessHeap(), 0, sizeof(*child_font));
|
2007-09-06 20:40:00 +02:00
|
|
|
child_font->face = face;
|
2005-09-06 11:24:07 +02:00
|
|
|
child_font->font = NULL;
|
|
|
|
fs.fsCsb[0] |= face->fs.fsCsb[0];
|
|
|
|
fs.fsCsb[1] |= face->fs.fsCsb[1];
|
2007-09-06 20:40:00 +02:00
|
|
|
TRACE("Adding file %s index %ld\n", child_font->face->file, child_font->face->face_index);
|
2005-09-06 11:24:07 +02:00
|
|
|
list_add_tail(&font_link->links, &child_font->entry);
|
|
|
|
}
|
|
|
|
family = find_family_from_name(font_link->font_name);
|
|
|
|
if(family)
|
|
|
|
{
|
|
|
|
LIST_FOR_EACH_ENTRY(face, &family->faces, Face, entry)
|
|
|
|
{
|
2008-02-27 22:21:10 +01:00
|
|
|
face->fs_links = fs;
|
2005-09-06 11:24:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
list_add_tail(&system_links, &font_link->entry);
|
2009-07-15 21:31:17 +02:00
|
|
|
next:
|
2005-09-06 11:24:07 +02:00
|
|
|
val_len = max_val + 1;
|
|
|
|
data_len = max_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, value);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Explicitly add an entry for the system font, this links to Tahoma and any links
|
|
|
|
that Tahoma has */
|
2005-09-14 21:17:00 +02:00
|
|
|
|
2005-09-06 11:24:07 +02:00
|
|
|
system_font_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*system_font_link));
|
|
|
|
system_font_link->font_name = strdupW(System);
|
|
|
|
list_init(&system_font_link->links);
|
2005-09-14 21:17:00 +02:00
|
|
|
|
2006-04-10 13:35:23 +02:00
|
|
|
face = find_face_from_filename(tahoma_ttf, Tahoma);
|
2005-09-14 21:17:00 +02:00
|
|
|
if(face)
|
|
|
|
{
|
|
|
|
child_font = HeapAlloc(GetProcessHeap(), 0, sizeof(*child_font));
|
2007-09-06 20:40:00 +02:00
|
|
|
child_font->face = face;
|
2005-09-14 21:17:00 +02:00
|
|
|
child_font->font = NULL;
|
2007-09-06 20:40:00 +02:00
|
|
|
TRACE("Found Tahoma in %s index %ld\n", child_font->face->file, child_font->face->face_index);
|
2005-09-14 21:17:00 +02:00
|
|
|
list_add_tail(&system_font_link->links, &child_font->entry);
|
|
|
|
}
|
2005-09-06 11:24:07 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
|
|
|
{
|
2005-09-14 21:17:00 +02:00
|
|
|
if(!strcmpiW(font_link->font_name, Tahoma))
|
2005-09-06 11:24:07 +02:00
|
|
|
{
|
|
|
|
CHILD_FONT *font_link_entry;
|
|
|
|
LIST_FOR_EACH_ENTRY(font_link_entry, &font_link->links, CHILD_FONT, entry)
|
|
|
|
{
|
|
|
|
CHILD_FONT *new_child;
|
|
|
|
new_child = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_child));
|
2007-09-06 20:40:00 +02:00
|
|
|
new_child->face = font_link_entry->face;
|
2005-09-06 11:24:07 +02:00
|
|
|
new_child->font = NULL;
|
|
|
|
list_add_tail(&system_font_link->links, &new_child->entry);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list_add_tail(&system_links, &system_font_link->entry);
|
|
|
|
return ret;
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
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) {
|
2006-04-04 11:54:14 +02:00
|
|
|
WARN("Can't open directory %s\n", debugstr_a(dirname));
|
2001-09-12 22:21:06 +02:00
|
|
|
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
|
2011-10-06 23:26:06 +02:00
|
|
|
{
|
|
|
|
DWORD addfont_flags = ADDFONT_ADD_TO_CACHE;
|
|
|
|
if(external_fonts) addfont_flags |= ADDFONT_EXTERNAL_FONT;
|
|
|
|
AddFontFileToList(path, NULL, NULL, addfont_flags);
|
|
|
|
}
|
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)
|
|
|
|
{
|
2007-07-02 17:31:48 +02:00
|
|
|
#ifdef SONAME_LIBFONTCONFIG
|
2003-11-09 01:30:13 +01:00
|
|
|
void *fc_handle = NULL;
|
|
|
|
FcConfig *config;
|
|
|
|
FcPattern *pat;
|
|
|
|
FcObjectSet *os;
|
|
|
|
FcFontSet *fontset;
|
|
|
|
int i, len;
|
2006-10-30 22:05:43 +01:00
|
|
|
char *file;
|
|
|
|
const char *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);
|
2006-12-19 22:21:27 +01:00
|
|
|
LOAD_FUNCPTR(FcPatternGetBool);
|
2006-04-28 13:51:36 +02:00
|
|
|
LOAD_FUNCPTR(FcPatternGetString);
|
2003-11-09 01:30:13 +01:00
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
if(!pFcInit()) return;
|
|
|
|
|
|
|
|
config = pFcConfigGetCurrent();
|
|
|
|
pat = pFcPatternCreate();
|
|
|
|
os = pFcObjectSetCreate();
|
|
|
|
pFcObjectSetAdd(os, FC_FILE);
|
2006-12-19 22:21:27 +01:00
|
|
|
pFcObjectSetAdd(os, FC_SCALABLE);
|
2003-11-09 01:30:13 +01:00
|
|
|
fontset = pFcFontList(config, pat, os);
|
|
|
|
if(!fontset) return;
|
|
|
|
for(i = 0; i < fontset->nfont; i++) {
|
2006-12-19 22:21:27 +01:00
|
|
|
FcBool scalable;
|
|
|
|
|
2006-04-28 13:51:36 +02:00
|
|
|
if(pFcPatternGetString(fontset->fonts[i], FC_FILE, 0, (FcChar8**)&file) != FcResultMatch)
|
2003-11-09 01:30:13 +01:00
|
|
|
continue;
|
2005-08-08 17:03:42 +02:00
|
|
|
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
|
2006-12-19 22:21:27 +01:00
|
|
|
picks up the scalable fonts without extensions .pf[ab] to save time
|
|
|
|
loading every other font */
|
|
|
|
|
|
|
|
if(pFcPatternGetBool(fontset->fonts[i], FC_SCALABLE, 0, &scalable) == FcResultMatch && !scalable)
|
|
|
|
{
|
|
|
|
TRACE("not scalable\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
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 ];
|
2006-12-19 22:21:27 +01:00
|
|
|
if(strcasecmp(ext, "pfa") && strcasecmp(ext, "pfb"))
|
2011-10-06 23:26:06 +02:00
|
|
|
AddFontFileToList(file, NULL, NULL, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE);
|
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
|
|
|
|
2006-03-09 08:13:08 +01:00
|
|
|
static BOOL load_font_from_data_dir(LPCWSTR file)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
const char *data_dir = wine_get_data_dir();
|
|
|
|
|
2006-03-17 13:10:09 +01:00
|
|
|
if (!data_dir) data_dir = wine_get_build_dir();
|
|
|
|
|
2006-03-09 08:13:08 +01:00
|
|
|
if (data_dir)
|
|
|
|
{
|
|
|
|
INT len;
|
|
|
|
char *unix_name;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_UNIXCP, 0, file, -1, NULL, 0, NULL, NULL);
|
|
|
|
|
|
|
|
unix_name = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + len + sizeof("/fonts/"));
|
|
|
|
|
|
|
|
strcpy(unix_name, data_dir);
|
|
|
|
strcat(unix_name, "/fonts/");
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, file, -1, unix_name + strlen(unix_name), len, NULL, NULL);
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2011-10-06 23:26:06 +02:00
|
|
|
ret = AddFontFileToList(unix_name, NULL, NULL, ADDFONT_FORCE_BITMAP | ADDFONT_ADD_TO_CACHE);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-03-09 08:13:08 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, unix_name);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2008-01-12 03:16:08 +01:00
|
|
|
static BOOL load_font_from_winfonts_dir(LPCWSTR file)
|
|
|
|
{
|
|
|
|
static const WCHAR slashW[] = {'\\','\0'};
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
WCHAR windowsdir[MAX_PATH];
|
|
|
|
char *unixname;
|
|
|
|
|
|
|
|
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
|
|
|
|
strcatW(windowsdir, fontsW);
|
|
|
|
strcatW(windowsdir, slashW);
|
|
|
|
strcatW(windowsdir, file);
|
|
|
|
if ((unixname = wine_get_unix_file_name(windowsdir))) {
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2010-11-05 12:48:54 +01:00
|
|
|
ret = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2008-01-12 03:16:08 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
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];
|
2006-05-26 06:34:50 +02:00
|
|
|
const WCHAR * const *value;
|
2004-06-16 22:06:26 +02:00
|
|
|
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) {
|
2006-03-09 08:13:08 +01:00
|
|
|
BOOL added = FALSE;
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
sprintfW(pathW, fmtW, windowsdir, data);
|
|
|
|
if((unixname = wine_get_unix_file_name(pathW))) {
|
2011-10-06 23:26:06 +02:00
|
|
|
added = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP | ADDFONT_ADD_TO_CACHE);
|
2004-06-16 22:06:26 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
2006-03-09 08:13:08 +01:00
|
|
|
if (!added)
|
|
|
|
load_font_from_data_dir(data);
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2008-03-07 18:02:32 +01:00
|
|
|
HKEY winnt_key = 0, win9x_key = 0, external_key = 0;
|
2004-03-09 04:43:54 +01:00
|
|
|
LPWSTR valueW;
|
2008-03-07 18:02:32 +01:00
|
|
|
DWORD len, len_fam;
|
2004-03-09 04:43:54 +01:00
|
|
|
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;
|
|
|
|
|
2008-03-07 18:02:32 +01:00
|
|
|
if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key,
|
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &winnt_key, NULL) != ERROR_SUCCESS) {
|
2004-03-09 04:43:54 +01:00
|
|
|
ERR("Can't create Windows font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2008-03-07 18:02:32 +01:00
|
|
|
if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, win9x_font_reg_key,
|
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &win9x_key, NULL) != ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Windows font reg key\n");
|
|
|
|
goto end;
|
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,
|
2008-03-07 18:02:32 +01:00
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &external_key, NULL) != ERROR_SUCCESS) {
|
2004-03-09 04:43:54 +01:00
|
|
|
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;
|
2008-06-19 23:57:46 +02:00
|
|
|
if (!(face->ntmFlags & NTM_REGULAR))
|
2004-03-09 04:43:54 +01:00
|
|
|
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);
|
2008-03-10 13:31:43 +01:00
|
|
|
|
|
|
|
file = wine_get_dos_file_name(face->file);
|
|
|
|
if(file)
|
|
|
|
len = strlenW(file) + 1;
|
2004-03-09 04:43:54 +01:00
|
|
|
else
|
2008-03-10 13:31:43 +01:00
|
|
|
{
|
|
|
|
if((path = strrchr(face->file, '/')) == NULL)
|
|
|
|
path = face->file;
|
|
|
|
else
|
|
|
|
path++;
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
2004-03-09 04:43:54 +01:00
|
|
|
|
2008-03-10 13:31:43 +01:00
|
|
|
file = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, path, -1, file, len);
|
|
|
|
}
|
2008-03-07 18:02:32 +01:00
|
|
|
RegSetValueExW(winnt_key, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));
|
|
|
|
RegSetValueExW(win9x_key, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));
|
|
|
|
RegSetValueExW(external_key, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));
|
2004-03-09 04:43:54 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, file);
|
|
|
|
HeapFree(GetProcessHeap(), 0, valueW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end:
|
2008-03-07 18:02:32 +01:00
|
|
|
if(external_key) RegCloseKey(external_key);
|
|
|
|
if(win9x_key) RegCloseKey(win9x_key);
|
|
|
|
if(winnt_key) RegCloseKey(winnt_key);
|
2004-03-09 04:43:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-07 18:02:32 +01:00
|
|
|
static void delete_external_font_keys(void)
|
|
|
|
{
|
|
|
|
HKEY winnt_key = 0, win9x_key = 0, external_key = 0;
|
|
|
|
DWORD dlen, vlen, datalen, valuelen, i, type;
|
|
|
|
LPWSTR valueW;
|
|
|
|
LPVOID data;
|
|
|
|
|
|
|
|
if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key,
|
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &winnt_key, NULL) != ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Windows font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, win9x_font_reg_key,
|
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &win9x_key, NULL) != ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Windows font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(RegCreateKeyW(HKEY_CURRENT_USER, external_fonts_reg_key, &external_key) != ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create external font reg key\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete all external fonts added last time */
|
|
|
|
|
|
|
|
RegQueryInfoKeyW(external_key, 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(external_key, i++, valueW, &vlen, NULL, &type, data,
|
|
|
|
&dlen) == ERROR_SUCCESS) {
|
|
|
|
|
|
|
|
RegDeleteValueW(winnt_key, valueW);
|
|
|
|
RegDeleteValueW(win9x_key, valueW);
|
|
|
|
/* reset dlen and vlen */
|
|
|
|
dlen = datalen;
|
|
|
|
vlen = valuelen;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
HeapFree(GetProcessHeap(), 0, valueW);
|
|
|
|
|
|
|
|
/* Delete the old external fonts key */
|
|
|
|
RegCloseKey(external_key);
|
|
|
|
RegDeleteKeyW(HKEY_CURRENT_USER, external_fonts_reg_key);
|
|
|
|
|
|
|
|
end:
|
|
|
|
if(win9x_key) RegCloseKey(win9x_key);
|
|
|
|
if(winnt_key) RegCloseKey(winnt_key);
|
|
|
|
}
|
2004-03-09 04:43:54 +01:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngAddFontResourceEx
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
2008-01-12 03:16:08 +01:00
|
|
|
INT ret = 0;
|
2009-01-28 19:38:15 +01:00
|
|
|
|
|
|
|
GDI_CheckNotLock();
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
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)
|
2006-10-12 22:56:56 +02:00
|
|
|
FIXME("Ignoring flags %x\n", flags);
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2004-04-14 21:40:53 +02:00
|
|
|
if((unixname = wine_get_unix_file_name(file)))
|
|
|
|
{
|
2011-10-06 23:26:06 +02:00
|
|
|
DWORD addfont_flags = ADDFONT_FORCE_BITMAP;
|
|
|
|
|
|
|
|
if(!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2011-10-06 23:26:06 +02:00
|
|
|
ret = AddFontFileToList(unixname, NULL, NULL, addfont_flags);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2004-04-14 21:40:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
2008-01-12 03:16:08 +01:00
|
|
|
}
|
|
|
|
if (!ret && !strchrW(file, '\\')) {
|
|
|
|
/* Try in %WINDIR%/fonts, needed for Fotobuch Designer */
|
|
|
|
ret = load_font_from_winfonts_dir(file);
|
|
|
|
if (!ret) {
|
|
|
|
/* Try in datadir/fonts (or builddir/fonts),
|
|
|
|
* needed for Magic the Gathering Online
|
|
|
|
*/
|
|
|
|
ret = load_font_from_data_dir(file);
|
|
|
|
}
|
2004-04-14 21:40:53 +02:00
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
2008-01-12 03:16:08 +01:00
|
|
|
return ret;
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngAddFontMemResourceEx
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HANDLE WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
|
|
|
|
{
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
if (ft_handle) /* do it only if we have freetype up and running */
|
|
|
|
{
|
|
|
|
PVOID pFontCopy = HeapAlloc(GetProcessHeap(), 0, cbFont);
|
|
|
|
|
|
|
|
TRACE("Copying %d bytes of data from %p to %p\n", cbFont, pbFont, pFontCopy);
|
|
|
|
memcpy(pFontCopy, pbFont, cbFont);
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2010-11-05 12:48:54 +01:00
|
|
|
*pcFonts = AddFontToList(NULL, pFontCopy, cbFont, NULL, NULL, ADDFONT_FORCE_BITMAP);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2007-09-13 19:42:55 +02:00
|
|
|
|
|
|
|
if (*pcFonts == 0)
|
|
|
|
{
|
|
|
|
TRACE("AddFontToList failed\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, pFontCopy);
|
2010-08-02 08:35:04 +02:00
|
|
|
return 0;
|
2007-09-13 19:42:55 +02:00
|
|
|
}
|
|
|
|
/* FIXME: is the handle only for use in RemoveFontMemResourceEx or should it be a true handle?
|
|
|
|
* For now return something unique but quite random
|
|
|
|
*/
|
|
|
|
TRACE("Returning handle %lx\n", ((INT_PTR)pFontCopy)^0x87654321);
|
|
|
|
return (HANDLE)(((INT_PTR)pFontCopy)^0x87654321);
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcFonts = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngRemoveFontResourceEx
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2010-01-20 09:18:59 +01:00
|
|
|
FIXME("(%s, %x, %p): stub\n", debugstr_w(file), flags, pdv);
|
2002-06-22 03:19:29 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2005-09-14 17:39:29 +02:00
|
|
|
static const struct nls_update_font_list
|
|
|
|
{
|
|
|
|
UINT ansi_cp, oem_cp;
|
|
|
|
const char *oem, *fixed, *system;
|
|
|
|
const char *courier, *serif, *small, *sserif;
|
2008-06-22 15:41:47 +02:00
|
|
|
/* these are for font substitutes */
|
2007-03-05 04:43:00 +01:00
|
|
|
const char *shelldlg, *tmsrmn;
|
2008-06-22 15:41:47 +02:00
|
|
|
const char *fixed_0, *system_0, *courier_0, *serif_0, *small_0, *sserif_0,
|
|
|
|
*helv_0, *tmsrmn_0;
|
|
|
|
const struct subst
|
|
|
|
{
|
|
|
|
const char *from, *to;
|
|
|
|
} arial_0, courier_new_0, times_new_roman_0;
|
2005-09-14 17:39:29 +02:00
|
|
|
} nls_update_font_list[] =
|
|
|
|
{
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Latin 1 (United States) */
|
|
|
|
{ 1252, 437, "vgaoem.fon", "vgafix.fon", "vgasys.fon",
|
2005-09-14 17:39:29 +02:00
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "sserife.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman",
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Latin 1 (Multilingual) */
|
|
|
|
{ 1252, 850, "vga850.fon", "vgafix.fon", "vgasys.fon",
|
2005-09-14 17:39:29 +02:00
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "sserife.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Eastern Europe */
|
2005-09-14 17:39:29 +02:00
|
|
|
{ 1250, 852, "vga852.fon", "vgafixe.fon", "vgasyse.fon",
|
|
|
|
"couree.fon", "serifee.fon", "smallee.fon", "sserifee.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,238", "System,238",
|
|
|
|
"Courier New,238", "MS Serif,238", "Small Fonts,238",
|
|
|
|
"MS Sans Serif,238", "MS Sans Serif,238", "MS Serif,238",
|
|
|
|
{ "Arial CE,0", "Arial,238" },
|
|
|
|
{ "Courier New CE,0", "Courier New,238" },
|
|
|
|
{ "Times New Roman CE,0", "Times New Roman,238" }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
|
|
|
/* Cyrillic */
|
|
|
|
{ 1251, 866, "vga866.fon", "vgafixr.fon", "vgasysr.fon",
|
|
|
|
"courer.fon", "serifer.fon", "smaller.fon", "sserifer.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,204", "System,204",
|
|
|
|
"Courier New,204", "MS Serif,204", "Small Fonts,204",
|
|
|
|
"MS Sans Serif,204", "MS Sans Serif,204", "MS Serif,204",
|
|
|
|
{ "Arial Cyr,0", "Arial,204" },
|
|
|
|
{ "Courier New Cyr,0", "Courier New,204" },
|
|
|
|
{ "Times New Roman Cyr,0", "Times New Roman,204" }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
|
|
|
/* Greek */
|
|
|
|
{ 1253, 737, "vga869.fon", "vgafixg.fon", "vgasysg.fon",
|
|
|
|
"coureg.fon", "serifeg.fon", "smalleg.fon", "sserifeg.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,161", "System,161",
|
|
|
|
"Courier New,161", "MS Serif,161", "Small Fonts,161",
|
|
|
|
"MS Sans Serif,161", "MS Sans Serif,161", "MS Serif,161",
|
|
|
|
{ "Arial Greek,0", "Arial,161" },
|
|
|
|
{ "Courier New Greek,0", "Courier New,161" },
|
|
|
|
{ "Times New Roman Greek,0", "Times New Roman,161" }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Turkish */
|
|
|
|
{ 1254, 857, "vga857.fon", "vgafixt.fon", "vgasyst.fon",
|
|
|
|
"couret.fon", "serifet.fon", "smallet.fon", "sserifet.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,162", "System,162",
|
|
|
|
"Courier New,162", "MS Serif,162", "Small Fonts,162",
|
|
|
|
"MS Sans Serif,162", "MS Sans Serif,162", "MS Serif,162",
|
|
|
|
{ "Arial Tur,0", "Arial,162" },
|
|
|
|
{ "Courier New Tur,0", "Courier New,162" },
|
|
|
|
{ "Times New Roman Tur,0", "Times New Roman,162" }
|
2005-09-16 20:46:54 +02:00
|
|
|
},
|
2005-09-14 17:39:29 +02:00
|
|
|
/* Hebrew */
|
|
|
|
{ 1255, 862, "vgaoem.fon", "vgaf1255.fon", "vgas1255.fon",
|
|
|
|
"coue1255.fon", "sere1255.fon", "smae1255.fon", "ssee1255.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,177", "System,177",
|
|
|
|
"Courier New,177", "MS Serif,177", "Small Fonts,177",
|
|
|
|
"MS Sans Serif,177", "MS Sans Serif,177", "MS Serif,177",
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Arabic */
|
|
|
|
{ 1256, 720, "vgaoem.fon", "vgaf1256.fon", "vgas1256.fon",
|
|
|
|
"coue1256.fon", "sere1256.fon", "smae1256.fon", "ssee1256.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,178", "System,178",
|
|
|
|
"Courier New,178", "MS Serif,178", "Small Fonts,178",
|
|
|
|
"MS Sans Serif,178", "MS Sans Serif,178", "MS Serif,178",
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Baltic */
|
|
|
|
{ 1257, 775, "vga775.fon", "vgaf1257.fon", "vgas1257.fon",
|
|
|
|
"coue1257.fon", "sere1257.fon", "smae1257.fon", "ssee1257.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
"Fixedsys,186", "System,186",
|
|
|
|
"Courier New,186", "MS Serif,186", "Small Fonts,186",
|
|
|
|
"MS Sans Serif,186", "MS Sans Serif,186", "MS Serif,186",
|
|
|
|
{ "Arial Baltic,0", "Arial,186" },
|
|
|
|
{ "Courier New Baltic,0", "Courier New,186" },
|
|
|
|
{ "Times New Roman Baltic,0", "Times New Roman,186" }
|
2005-09-16 20:46:54 +02:00
|
|
|
},
|
|
|
|
/* Vietnamese */
|
|
|
|
{ 1258, 1258, "vga850.fon", "vgafix.fon", "vgasys.fon",
|
2005-09-14 17:39:29 +02:00
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "sserife.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
|
|
|
/* Thai */
|
|
|
|
{ 874, 874, "vga850.fon", "vgaf874.fon", "vgas874.fon",
|
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "ssee874.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"Tahoma","Times New Roman", /* FIXME unverified */
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Japanese */
|
|
|
|
{ 932, 932, "vga932.fon", "jvgafix.fon", "jvgasys.fon",
|
|
|
|
"coure.fon", "serife.fon", "jsmalle.fon", "sserife.fon",
|
2007-03-05 04:43:00 +01:00
|
|
|
"MS UI Gothic","MS Serif",
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Chinese Simplified */
|
|
|
|
{ 936, 936, "vga936.fon", "svgafix.fon", "svgasys.fon",
|
2005-09-14 17:39:29 +02:00
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "sserife.fon",
|
2008-12-10 19:29:07 +01:00
|
|
|
"SimSun", "NSimSun",
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Korean */
|
|
|
|
{ 949, 949, "vga949.fon", "hvgafix.fon", "hvgasys.fon",
|
2005-09-14 17:39:29 +02:00
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "sserife.fon",
|
2007-03-06 14:06:33 +01:00
|
|
|
"Gulim", "Batang",
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
},
|
2005-09-16 20:46:54 +02:00
|
|
|
/* Chinese Traditional */
|
|
|
|
{ 950, 950, "vga950.fon", "cvgafix.fon", "cvgasys.fon",
|
2005-09-14 17:39:29 +02:00
|
|
|
"coure.fon", "serife.fon", "smalle.fon", "sserife.fon",
|
2008-01-10 20:05:41 +01:00
|
|
|
"PMingLiU", "MingLiU",
|
2008-06-22 15:41:47 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
{ 0 }, { 0 }, { 0 }
|
2005-09-14 17:39:29 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-05-09 19:12:40 +02:00
|
|
|
static const WCHAR *font_links_list[] =
|
|
|
|
{
|
|
|
|
Lucida_Sans_Unicode,
|
|
|
|
Microsoft_Sans_Serif,
|
|
|
|
Tahoma
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct font_links_defaults_list
|
|
|
|
{
|
|
|
|
/* Keyed off substitution for "MS Shell Dlg" */
|
|
|
|
const WCHAR *shelldlg;
|
|
|
|
/* Maximum of four substitutes, plus terminating NULL pointer */
|
|
|
|
const WCHAR *substitutes[5];
|
|
|
|
} font_links_defaults_list[] =
|
|
|
|
{
|
|
|
|
/* Non East-Asian */
|
|
|
|
{ Tahoma, /* FIXME unverified ordering */
|
|
|
|
{ MS_UI_Gothic, SimSun, Gulim, PMingLiU, NULL }
|
|
|
|
},
|
|
|
|
/* Below lists are courtesy of
|
|
|
|
* http://blogs.msdn.com/michkap/archive/2005/06/18/430507.aspx
|
|
|
|
*/
|
|
|
|
/* Japanese */
|
|
|
|
{ MS_UI_Gothic,
|
|
|
|
{ MS_UI_Gothic, PMingLiU, SimSun, Gulim, NULL }
|
|
|
|
},
|
|
|
|
/* Chinese Simplified */
|
|
|
|
{ SimSun,
|
|
|
|
{ SimSun, PMingLiU, MS_UI_Gothic, Batang, NULL }
|
|
|
|
},
|
|
|
|
/* Korean */
|
|
|
|
{ Gulim,
|
|
|
|
{ Gulim, PMingLiU, MS_UI_Gothic, SimSun, NULL }
|
|
|
|
},
|
|
|
|
/* Chinese Traditional */
|
|
|
|
{ PMingLiU,
|
|
|
|
{ PMingLiU, SimSun, MS_UI_Gothic, Batang, NULL }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-06-06 23:14:39 +02:00
|
|
|
static inline BOOL is_dbcs_ansi_cp(UINT ansi_cp)
|
|
|
|
{
|
|
|
|
return ( ansi_cp == 932 /* CP932 for Japanese */
|
|
|
|
|| ansi_cp == 936 /* CP936 for Chinese Simplified */
|
|
|
|
|| ansi_cp == 949 /* CP949 for Korean */
|
|
|
|
|| ansi_cp == 950 ); /* CP950 for Chinese Traditional */
|
|
|
|
}
|
|
|
|
|
2007-03-20 18:42:59 +01:00
|
|
|
static inline HKEY create_fonts_NT_registry_key(void)
|
2005-09-14 17:39:29 +02:00
|
|
|
{
|
|
|
|
HKEY hkey = 0;
|
|
|
|
|
|
|
|
RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key, 0, NULL,
|
|
|
|
0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
|
|
|
|
return hkey;
|
|
|
|
}
|
|
|
|
|
2007-03-20 18:42:59 +01:00
|
|
|
static inline HKEY create_fonts_9x_registry_key(void)
|
2005-09-14 17:39:29 +02:00
|
|
|
{
|
|
|
|
HKEY hkey = 0;
|
|
|
|
|
|
|
|
RegCreateKeyExW(HKEY_LOCAL_MACHINE, win9x_font_reg_key, 0, NULL,
|
|
|
|
0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
|
|
|
|
return hkey;
|
|
|
|
}
|
|
|
|
|
2007-03-20 18:42:59 +01:00
|
|
|
static inline HKEY create_config_fonts_registry_key(void)
|
2005-09-14 17:39:29 +02:00
|
|
|
{
|
|
|
|
HKEY hkey = 0;
|
|
|
|
|
|
|
|
RegCreateKeyExW(HKEY_CURRENT_CONFIG, system_fonts_reg_key, 0, NULL,
|
|
|
|
0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
|
|
|
|
return hkey;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_font_list(HKEY hkey, const struct nls_update_font_list *fl)
|
|
|
|
{
|
|
|
|
RegSetValueExA(hkey, "Courier", 0, REG_SZ, (const BYTE *)fl->courier, strlen(fl->courier)+1);
|
|
|
|
RegSetValueExA(hkey, "MS Serif", 0, REG_SZ, (const BYTE *)fl->serif, strlen(fl->serif)+1);
|
|
|
|
RegSetValueExA(hkey, "MS Sans Serif", 0, REG_SZ, (const BYTE *)fl->sserif, strlen(fl->sserif)+1);
|
|
|
|
RegSetValueExA(hkey, "Small Fonts", 0, REG_SZ, (const BYTE *)fl->small, strlen(fl->small)+1);
|
|
|
|
}
|
|
|
|
|
2008-06-22 15:41:47 +02:00
|
|
|
static void set_value_key(HKEY hkey, const char *name, const char *value)
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
RegSetValueExA(hkey, name, 0, REG_SZ, (const BYTE *)value, strlen(value) + 1);
|
|
|
|
else if (name)
|
|
|
|
RegDeleteValueA(hkey, name);
|
|
|
|
}
|
|
|
|
|
2005-09-14 17:39:29 +02:00
|
|
|
static void update_font_info(void)
|
|
|
|
{
|
2006-12-08 13:00:53 +01:00
|
|
|
char buf[40], cpbuf[40];
|
2005-09-14 17:39:29 +02:00
|
|
|
DWORD len, type;
|
|
|
|
HKEY hkey = 0;
|
|
|
|
UINT i, ansi_cp = 0, oem_cp = 0;
|
2008-06-22 15:41:47 +02:00
|
|
|
BOOL done = FALSE;
|
2005-09-14 17:39:29 +02:00
|
|
|
|
2006-12-20 23:33:28 +01:00
|
|
|
if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\Fonts", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL) != ERROR_SUCCESS)
|
2005-09-14 17:39:29 +02:00
|
|
|
return;
|
|
|
|
|
2006-12-08 13:00:53 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER|LOCALE_NOUSEROVERRIDE,
|
|
|
|
(WCHAR *)&ansi_cp, sizeof(ansi_cp)/sizeof(WCHAR));
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTCODEPAGE|LOCALE_RETURN_NUMBER|LOCALE_NOUSEROVERRIDE,
|
|
|
|
(WCHAR *)&oem_cp, sizeof(oem_cp)/sizeof(WCHAR));
|
|
|
|
sprintf( cpbuf, "%u,%u", ansi_cp, oem_cp );
|
|
|
|
|
2008-06-06 23:14:39 +02:00
|
|
|
/* Setup Default_Fallback usage for DBCS ANSI codepages */
|
|
|
|
if (is_dbcs_ansi_cp(ansi_cp))
|
2008-02-18 16:49:07 +01:00
|
|
|
use_default_fallback = TRUE;
|
|
|
|
|
2005-09-14 17:39:29 +02:00
|
|
|
len = sizeof(buf);
|
2006-12-08 13:00:53 +01:00
|
|
|
if (RegQueryValueExA(hkey, "Codepages", 0, &type, (BYTE *)buf, &len) == ERROR_SUCCESS && type == REG_SZ)
|
2005-09-14 17:39:29 +02:00
|
|
|
{
|
2006-12-08 13:00:53 +01:00
|
|
|
if (!strcmp( buf, cpbuf )) /* already set correctly */
|
2005-09-14 17:39:29 +02:00
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
2006-12-08 13:00:53 +01:00
|
|
|
TRACE("updating registry, codepages changed %s -> %u,%u\n", buf, ansi_cp, oem_cp);
|
2005-09-14 17:39:29 +02:00
|
|
|
}
|
2006-12-08 13:00:53 +01:00
|
|
|
else TRACE("updating registry, codepages changed none -> %u,%u\n", ansi_cp, oem_cp);
|
2005-09-14 17:39:29 +02:00
|
|
|
|
2006-12-08 13:00:53 +01:00
|
|
|
RegSetValueExA(hkey, "Codepages", 0, REG_SZ, (const BYTE *)cpbuf, strlen(cpbuf)+1);
|
2005-09-14 17:39:29 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(nls_update_font_list)/sizeof(nls_update_font_list[0]); i++)
|
|
|
|
{
|
2008-06-22 15:41:47 +02:00
|
|
|
HKEY hkey;
|
|
|
|
|
2005-09-14 17:39:29 +02:00
|
|
|
if (nls_update_font_list[i].ansi_cp == ansi_cp &&
|
|
|
|
nls_update_font_list[i].oem_cp == oem_cp)
|
|
|
|
{
|
|
|
|
hkey = create_config_fonts_registry_key();
|
|
|
|
RegSetValueExA(hkey, "OEMFONT.FON", 0, REG_SZ, (const BYTE *)nls_update_font_list[i].oem, strlen(nls_update_font_list[i].oem)+1);
|
2006-07-24 15:08:45 +02:00
|
|
|
RegSetValueExA(hkey, "FIXEDFON.FON", 0, REG_SZ, (const BYTE *)nls_update_font_list[i].fixed, strlen(nls_update_font_list[i].fixed)+1);
|
2005-09-14 17:39:29 +02:00
|
|
|
RegSetValueExA(hkey, "FONTS.FON", 0, REG_SZ, (const BYTE *)nls_update_font_list[i].system, strlen(nls_update_font_list[i].system)+1);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
hkey = create_fonts_NT_registry_key();
|
|
|
|
add_font_list(hkey, &nls_update_font_list[i]);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
hkey = create_fonts_9x_registry_key();
|
|
|
|
add_font_list(hkey, &nls_update_font_list[i]);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2007-03-05 04:43:00 +01:00
|
|
|
if (!RegCreateKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes", &hkey ))
|
|
|
|
{
|
|
|
|
RegSetValueExA(hkey, "MS Shell Dlg", 0, REG_SZ, (const BYTE *)nls_update_font_list[i].shelldlg,
|
|
|
|
strlen(nls_update_font_list[i].shelldlg)+1);
|
|
|
|
RegSetValueExA(hkey, "Tms Rmn", 0, REG_SZ, (const BYTE *)nls_update_font_list[i].tmsrmn,
|
|
|
|
strlen(nls_update_font_list[i].tmsrmn)+1);
|
2008-06-22 15:41:47 +02:00
|
|
|
|
|
|
|
set_value_key(hkey, "Fixedsys,0", nls_update_font_list[i].fixed_0);
|
|
|
|
set_value_key(hkey, "System,0", nls_update_font_list[i].system_0);
|
|
|
|
set_value_key(hkey, "Courier,0", nls_update_font_list[i].courier_0);
|
|
|
|
set_value_key(hkey, "MS Serif,0", nls_update_font_list[i].serif_0);
|
|
|
|
set_value_key(hkey, "Small Fonts,0", nls_update_font_list[i].small_0);
|
|
|
|
set_value_key(hkey, "MS Sans Serif,0", nls_update_font_list[i].sserif_0);
|
|
|
|
set_value_key(hkey, "Helv,0", nls_update_font_list[i].helv_0);
|
|
|
|
set_value_key(hkey, "Tms Rmn,0", nls_update_font_list[i].tmsrmn_0);
|
|
|
|
|
|
|
|
set_value_key(hkey, nls_update_font_list[i].arial_0.from, nls_update_font_list[i].arial_0.to);
|
|
|
|
set_value_key(hkey, nls_update_font_list[i].courier_new_0.from, nls_update_font_list[i].courier_new_0.to);
|
|
|
|
set_value_key(hkey, nls_update_font_list[i].times_new_roman_0.from, nls_update_font_list[i].times_new_roman_0.to);
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
done = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Delete the FontSubstitutes from other locales */
|
|
|
|
if (!RegCreateKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes", &hkey ))
|
|
|
|
{
|
|
|
|
set_value_key(hkey, nls_update_font_list[i].arial_0.from, NULL);
|
|
|
|
set_value_key(hkey, nls_update_font_list[i].courier_new_0.from, NULL);
|
|
|
|
set_value_key(hkey, nls_update_font_list[i].times_new_roman_0.from, NULL);
|
2007-03-05 04:43:00 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2005-09-14 17:39:29 +02:00
|
|
|
}
|
|
|
|
}
|
2008-06-22 15:41:47 +02:00
|
|
|
if (!done)
|
|
|
|
FIXME("there is no font defaults for codepages %u,%u\n", ansi_cp, oem_cp);
|
2009-05-09 19:12:40 +02:00
|
|
|
|
|
|
|
/* Clear out system links */
|
|
|
|
RegDeleteKeyW(HKEY_LOCAL_MACHINE, system_link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void populate_system_links(HKEY hkey, const WCHAR *name, const WCHAR *const *values)
|
|
|
|
{
|
|
|
|
const WCHAR *value;
|
|
|
|
int i;
|
|
|
|
FontSubst *psub;
|
|
|
|
Family *family;
|
|
|
|
Face *face;
|
|
|
|
const char *file;
|
|
|
|
WCHAR *fileW;
|
|
|
|
int fileLen;
|
|
|
|
WCHAR buff[MAX_PATH];
|
|
|
|
WCHAR *data;
|
|
|
|
int entryLen;
|
|
|
|
|
|
|
|
static const WCHAR comma[] = {',',0};
|
|
|
|
|
|
|
|
RegDeleteValueW(hkey, name);
|
|
|
|
if (values)
|
|
|
|
{
|
|
|
|
data = buff;
|
|
|
|
data[0] = '\0';
|
|
|
|
for (i = 0; values[i] != NULL; i++)
|
|
|
|
{
|
|
|
|
value = values[i];
|
|
|
|
if (!strcmpiW(name,value))
|
|
|
|
continue;
|
|
|
|
psub = get_font_subst(&font_subst_list, value, -1);
|
|
|
|
if(psub)
|
|
|
|
value = psub->to.name;
|
|
|
|
family = find_family_from_name(value);
|
|
|
|
if (!family)
|
|
|
|
continue;
|
|
|
|
file = NULL;
|
|
|
|
/* Use first extant filename for this Family */
|
|
|
|
LIST_FOR_EACH_ENTRY(face, &family->faces, Face, entry)
|
|
|
|
{
|
|
|
|
if (!face->file)
|
|
|
|
continue;
|
|
|
|
file = strrchr(face->file, '/');
|
|
|
|
if (!file)
|
|
|
|
file = face->file;
|
|
|
|
else
|
|
|
|
file++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!file)
|
|
|
|
continue;
|
|
|
|
fileLen = MultiByteToWideChar(CP_UNIXCP, 0, file, -1, NULL, 0);
|
|
|
|
fileW = HeapAlloc(GetProcessHeap(), 0, fileLen * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, file, -1, fileW, fileLen);
|
|
|
|
entryLen = strlenW(fileW) + 1 + strlenW(value) + 1;
|
|
|
|
if (sizeof(buff)-(data-buff) < entryLen + 1)
|
|
|
|
{
|
|
|
|
WARN("creating SystemLink for %s, ran out of buffer space\n", debugstr_w(name));
|
|
|
|
HeapFree(GetProcessHeap(), 0, fileW);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
strcpyW(data, fileW);
|
|
|
|
strcatW(data, comma);
|
|
|
|
strcatW(data, value);
|
|
|
|
data += entryLen;
|
|
|
|
TRACE("added SystemLink for %s to %s in %s\n", debugstr_w(name), debugstr_w(value),debugstr_w(fileW));
|
|
|
|
HeapFree(GetProcessHeap(), 0, fileW);
|
|
|
|
}
|
|
|
|
if (data != buff)
|
|
|
|
{
|
|
|
|
*data='\0';
|
|
|
|
data++;
|
|
|
|
RegSetValueExW(hkey, name, 0, REG_MULTI_SZ, (BYTE*)buff, (data-buff) * sizeof(WCHAR));
|
|
|
|
} else
|
|
|
|
TRACE("no SystemLink fonts found for %s\n", debugstr_w(name));
|
|
|
|
} else
|
|
|
|
TRACE("removed SystemLink for %s\n", debugstr_w(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_system_links(void)
|
|
|
|
{
|
|
|
|
HKEY hkey = 0;
|
|
|
|
UINT i, j;
|
|
|
|
BOOL done = FALSE;
|
|
|
|
DWORD disposition;
|
|
|
|
FontSubst *psub;
|
|
|
|
|
|
|
|
static const WCHAR MS_Shell_Dlg[] = {'M','S',' ','S','h','e','l','l',' ','D','l','g',0};
|
|
|
|
|
|
|
|
if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, system_link, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, &disposition))
|
|
|
|
{
|
|
|
|
if (disposition == REG_OPENED_EXISTING_KEY)
|
|
|
|
{
|
|
|
|
TRACE("SystemLink key already exists, doing nothing\n");
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
psub = get_font_subst(&font_subst_list, MS_Shell_Dlg, -1);
|
|
|
|
if (!psub) {
|
|
|
|
WARN("could not find FontSubstitute for MS Shell Dlg\n");
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(font_links_defaults_list)/sizeof(font_links_defaults_list[0]); i++)
|
|
|
|
{
|
|
|
|
if (!strcmpiW(font_links_defaults_list[i].shelldlg, psub->to.name))
|
|
|
|
{
|
|
|
|
for (j = 0; j < sizeof(font_links_list)/sizeof(font_links_list[0]); j++)
|
|
|
|
populate_system_links(hkey, font_links_list[j], font_links_defaults_list[i].substitutes);
|
|
|
|
|
|
|
|
if (!strcmpiW(psub->to.name, font_links_defaults_list[i].substitutes[0]))
|
|
|
|
populate_system_links(hkey, psub->to.name, font_links_defaults_list[i].substitutes);
|
|
|
|
done = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmpiW(psub->to.name, font_links_defaults_list[i].substitutes[0]))
|
|
|
|
{
|
|
|
|
populate_system_links(hkey, font_links_defaults_list[i].substitutes[0], NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if (!done)
|
|
|
|
WARN("there is no SystemLink default list for MS Shell Dlg %s\n", debugstr_w(psub->to.name));
|
|
|
|
} else
|
|
|
|
WARN("failed to create SystemLink key\n");
|
2005-09-14 17:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-12 14:45:13 +01:00
|
|
|
static BOOL init_freetype(void)
|
|
|
|
{
|
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;}
|
|
|
|
|
|
|
|
LOAD_FUNCPTR(FT_Done_Face)
|
|
|
|
LOAD_FUNCPTR(FT_Get_Char_Index)
|
2011-10-11 11:14:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Get_First_Char)
|
2005-10-06 14:28:11 +02:00
|
|
|
LOAD_FUNCPTR(FT_Get_Module)
|
2011-10-11 11:14:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Get_Next_Char)
|
2006-04-05 13:45:25 +02:00
|
|
|
LOAD_FUNCPTR(FT_Get_Sfnt_Name)
|
|
|
|
LOAD_FUNCPTR(FT_Get_Sfnt_Name_Count)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Get_Sfnt_Table)
|
2011-10-11 11:14:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Get_WinFNT_Header)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Init_FreeType)
|
2011-10-11 11:14:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Library_Version)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Load_Glyph)
|
2011-10-10 15:15:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Load_Sfnt_Table)
|
2003-10-10 02:06:35 +02:00
|
|
|
LOAD_FUNCPTR(FT_Matrix_Multiply)
|
2008-09-03 13:14:17 +02:00
|
|
|
#ifndef FT_MULFIX_INLINED
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_MulFix)
|
2008-09-03 13:14:17 +02:00
|
|
|
#endif
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_New_Face)
|
2006-12-06 21:31:53 +01:00
|
|
|
LOAD_FUNCPTR(FT_New_Memory_Face)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Outline_Get_Bitmap)
|
|
|
|
LOAD_FUNCPTR(FT_Outline_Transform)
|
|
|
|
LOAD_FUNCPTR(FT_Outline_Translate)
|
2011-10-10 15:15:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Render_Glyph)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Select_Charmap)
|
2007-10-02 05:04:25 +02:00
|
|
|
LOAD_FUNCPTR(FT_Set_Charmap)
|
2002-04-03 22:02:39 +02:00
|
|
|
LOAD_FUNCPTR(FT_Set_Pixel_Sizes)
|
2003-10-10 02:06:35 +02:00
|
|
|
LOAD_FUNCPTR(FT_Vector_Transform)
|
2011-10-10 15:15:56 +02:00
|
|
|
LOAD_FUNCPTR(FT_Vector_Unit)
|
2002-04-03 22:02:39 +02:00
|
|
|
#undef LOAD_FUNCPTR
|
2008-03-12 14:45:13 +01:00
|
|
|
/* Don't warn if these ones are missing */
|
2006-02-22 13:24:25 +01:00
|
|
|
pFT_Get_TrueType_Engine_Type = wine_dlsym(ft_handle, "FT_Get_TrueType_Engine_Type", NULL, 0);
|
2008-12-23 12:34:01 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTLCDFIL_H
|
|
|
|
pFT_Library_SetLcdFilter = wine_dlsym(ft_handle, "FT_Library_SetLcdFilter", NULL, 0);
|
|
|
|
#endif
|
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;
|
|
|
|
}
|
2011-10-11 11:14:56 +02:00
|
|
|
pFT_Library_Version(library,&FT_Version.major,&FT_Version.minor,&FT_Version.patch);
|
2008-03-12 14:45:13 +01:00
|
|
|
|
2002-08-17 20:34:34 +02:00
|
|
|
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
|
|
|
|
2008-03-12 14:45:13 +01:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
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"
|
2011-10-10 15:15:56 +02:00
|
|
|
"FreeType to at least version 2.1.4.\n"
|
2008-03-12 14:45:13 +01:00
|
|
|
"http://www.freetype.org\n");
|
|
|
|
wine_dlclose(ft_handle, NULL, 0);
|
|
|
|
ft_handle = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:05 +02:00
|
|
|
static void init_font_list(void)
|
2008-03-12 14:45:13 +01:00
|
|
|
{
|
|
|
|
static const WCHAR dot_fonW[] = {'.','f','o','n','\0'};
|
|
|
|
static const WCHAR pathW[] = {'P','a','t','h',0};
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD valuelen, datalen, i = 0, type, dlen, vlen;
|
|
|
|
WCHAR windowsdir[MAX_PATH];
|
|
|
|
char *unixname;
|
|
|
|
const char *data_dir;
|
|
|
|
|
2008-03-07 18:02:32 +01:00
|
|
|
delete_external_font_keys();
|
|
|
|
|
2006-03-17 16:36:11 +01:00
|
|
|
/* load the system bitmap fonts */
|
2004-07-14 23:42:35 +02:00
|
|
|
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
|
|
|
|
2006-03-17 16:36:11 +01:00
|
|
|
/* load the system truetype fonts */
|
|
|
|
data_dir = wine_get_data_dir();
|
2007-10-12 15:36:44 +02:00
|
|
|
if (!data_dir) data_dir = wine_get_build_dir();
|
2011-10-06 23:26:05 +02:00
|
|
|
if (data_dir && (unixname = HeapAlloc(GetProcessHeap(), 0, strlen(data_dir) + sizeof("/fonts/"))))
|
|
|
|
{
|
2006-03-17 16:36:11 +01:00
|
|
|
strcpy(unixname, data_dir);
|
|
|
|
strcat(unixname, "/fonts/");
|
2007-10-02 15:30:04 +02:00
|
|
|
ReadFontDir(unixname, TRUE);
|
2006-03-17 16:36:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
|
|
|
|
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,
|
2011-10-06 23:26:05 +02:00
|
|
|
&hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
2009-01-26 15:09:18 +01:00
|
|
|
LPWSTR data, valueW;
|
2004-01-06 00:42:09 +01:00
|
|
|
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
2011-10-06 23:26:05 +02:00
|
|
|
&valuelen, &datalen, NULL, NULL);
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2011-10-06 23:26:05 +02:00
|
|
|
valuelen++; /* returned value doesn't include room for '\0' */
|
|
|
|
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;
|
2009-01-26 15:09:18 +01:00
|
|
|
while(RegEnumValueW(hkey, i++, valueW, &vlen, NULL, &type, (LPBYTE)data,
|
2011-10-06 23:26:05 +02:00
|
|
|
&dlen) == ERROR_SUCCESS)
|
|
|
|
{
|
2009-01-26 15:09:18 +01:00
|
|
|
if(data[0] && (data[1] == ':'))
|
2004-06-16 22:06:26 +02:00
|
|
|
{
|
2009-01-26 15:09:18 +01:00
|
|
|
if((unixname = wine_get_unix_file_name(data)))
|
2004-04-14 21:40:53 +02:00
|
|
|
{
|
2011-10-06 23:26:06 +02:00
|
|
|
AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP | ADDFONT_ADD_TO_CACHE);
|
2004-06-16 22:06:26 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
|
|
|
}
|
2009-01-26 15:09:18 +01:00
|
|
|
else if(dlen / 2 >= 6 && !strcmpiW(data + dlen / 2 - 5, dot_fonW))
|
2004-06-16 22:06:26 +02:00
|
|
|
{
|
|
|
|
WCHAR pathW[MAX_PATH];
|
|
|
|
static const WCHAR fmtW[] = {'%','s','\\','%','s','\0'};
|
2006-03-09 08:13:08 +01:00
|
|
|
BOOL added = FALSE;
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
sprintfW(pathW, fmtW, windowsdir, data);
|
|
|
|
if((unixname = wine_get_unix_file_name(pathW)))
|
|
|
|
{
|
2011-10-06 23:26:06 +02:00
|
|
|
added = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP | ADDFONT_ADD_TO_CACHE);
|
2004-04-14 21:40:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
}
|
2006-03-09 08:13:08 +01:00
|
|
|
if (!added)
|
|
|
|
load_font_from_data_dir(data);
|
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);
|
2011-10-06 23:26:05 +02:00
|
|
|
RegCloseKey(hkey);
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2011-10-06 23:26:05 +02:00
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:08 +02:00
|
|
|
static BOOL move_to_front(const WCHAR *name)
|
|
|
|
{
|
|
|
|
Family *family, *cursor2;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(family, cursor2, &font_list, Family, entry)
|
|
|
|
{
|
|
|
|
if(!strcmpiW(family->FamilyName, name))
|
|
|
|
{
|
|
|
|
list_remove(&family->entry);
|
|
|
|
list_add_head(&font_list, &family->entry);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-10-12 12:55:12 +02:00
|
|
|
static BOOL set_default(const WCHAR **name_list)
|
2011-10-06 23:26:08 +02:00
|
|
|
{
|
2011-10-12 12:55:12 +02:00
|
|
|
while (*name_list)
|
|
|
|
{
|
|
|
|
if (move_to_front(*name_list)) return TRUE;
|
|
|
|
name_list++;
|
|
|
|
}
|
2011-10-06 23:26:08 +02:00
|
|
|
|
2011-10-12 12:55:12 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-10-06 23:26:08 +02:00
|
|
|
|
2011-10-12 12:55:12 +02:00
|
|
|
static void reorder_font_list(void)
|
|
|
|
{
|
|
|
|
set_default( default_serif_list );
|
|
|
|
set_default( default_fixed_list );
|
|
|
|
set_default( default_sans_list );
|
2011-10-06 23:26:08 +02:00
|
|
|
}
|
|
|
|
|
2011-10-06 23:26:05 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngInit
|
|
|
|
*
|
|
|
|
* Initialize FreeType library and create a list of available faces
|
|
|
|
*/
|
|
|
|
BOOL WineEngInit(void)
|
|
|
|
{
|
2011-10-06 23:26:06 +02:00
|
|
|
HKEY hkey_font_cache;
|
|
|
|
DWORD disposition;
|
2011-10-06 23:26:05 +02:00
|
|
|
HANDLE font_mutex;
|
|
|
|
|
|
|
|
/* update locale dependent font info in registry */
|
|
|
|
update_font_info();
|
|
|
|
|
|
|
|
if(!init_freetype()) return FALSE;
|
|
|
|
|
|
|
|
if((font_mutex = CreateMutexW(NULL, FALSE, font_mutex_nameW)) == NULL)
|
|
|
|
{
|
|
|
|
ERR("Failed to create font mutex\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
WaitForSingleObject(font_mutex, INFINITE);
|
|
|
|
|
2011-10-06 23:26:06 +02:00
|
|
|
create_font_cache_key(&hkey_font_cache, &disposition);
|
|
|
|
|
2011-10-06 23:26:07 +02:00
|
|
|
if(disposition == REG_CREATED_NEW_KEY)
|
|
|
|
init_font_list();
|
|
|
|
else
|
|
|
|
load_font_list_from_cache(hkey_font_cache);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2011-10-06 23:26:06 +02:00
|
|
|
RegCloseKey(hkey_font_cache);
|
|
|
|
|
2011-10-06 23:26:08 +02:00
|
|
|
reorder_font_list();
|
|
|
|
|
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();
|
2011-10-06 23:26:07 +02:00
|
|
|
|
|
|
|
if(disposition == REG_CREATED_NEW_KEY)
|
|
|
|
update_reg_entries();
|
2004-03-09 04:43:54 +01:00
|
|
|
|
2009-05-09 19:12:40 +02:00
|
|
|
update_system_links();
|
2005-09-06 11:24:07 +02:00
|
|
|
init_system_links();
|
|
|
|
|
2004-03-09 04:43:54 +01:00
|
|
|
ReleaseMutex(font_mutex);
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
2008-06-24 09:10:27 +02:00
|
|
|
ppem = MulDiv(ft_face->units_per_EM, height,
|
|
|
|
pHori->Ascender - pHori->Descender);
|
2003-12-08 22:53:15 +01:00
|
|
|
else
|
2008-06-24 09:10:27 +02:00
|
|
|
ppem = MulDiv(ft_face->units_per_EM, height,
|
|
|
|
pOS2->usWinAscent + pOS2->usWinDescent);
|
2003-12-08 22:53:15 +01:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
else
|
|
|
|
ppem = -height;
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
return ppem;
|
|
|
|
}
|
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
static struct font_mapping *map_font_file( const char *name )
|
2006-12-06 21:31:53 +01:00
|
|
|
{
|
|
|
|
struct font_mapping *mapping;
|
|
|
|
struct stat st;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if ((fd = open( name, O_RDONLY )) == -1) return NULL;
|
|
|
|
if (fstat( fd, &st ) == -1) goto error;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( mapping, &mappings_list, struct font_mapping, entry )
|
|
|
|
{
|
|
|
|
if (mapping->dev == st.st_dev && mapping->ino == st.st_ino)
|
|
|
|
{
|
|
|
|
mapping->refcount++;
|
|
|
|
close( fd );
|
|
|
|
return mapping;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(mapping = HeapAlloc( GetProcessHeap(), 0, sizeof(*mapping) )))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
mapping->data = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 );
|
|
|
|
close( fd );
|
|
|
|
|
|
|
|
if (mapping->data == MAP_FAILED)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, mapping );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
mapping->refcount = 1;
|
|
|
|
mapping->dev = st.st_dev;
|
|
|
|
mapping->ino = st.st_ino;
|
|
|
|
mapping->size = st.st_size;
|
|
|
|
list_add_tail( &mappings_list, &mapping->entry );
|
|
|
|
return mapping;
|
|
|
|
|
|
|
|
error:
|
|
|
|
close( fd );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
static void unmap_font_file( struct font_mapping *mapping )
|
2006-12-06 21:31:53 +01:00
|
|
|
{
|
|
|
|
if (!--mapping->refcount)
|
|
|
|
{
|
|
|
|
list_remove( &mapping->entry );
|
|
|
|
munmap( mapping->data, mapping->size );
|
|
|
|
HeapFree( GetProcessHeap(), 0, mapping );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static LONG load_VDMX(GdiFont*, LONG);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
static FT_Face OpenFontFace(GdiFont *font, Face *face, LONG width, LONG height)
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
|
|
|
FT_Error err;
|
|
|
|
FT_Face ft_face;
|
2007-09-13 19:42:55 +02:00
|
|
|
void *data_ptr;
|
|
|
|
DWORD data_size;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
TRACE("%s/%p, %ld, %d x %d\n", debugstr_a(face->file), face->font_data_ptr, face->face_index, width, height);
|
2006-12-06 21:31:53 +01:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
if (face->file)
|
2007-03-22 00:36:39 +01:00
|
|
|
{
|
2007-09-13 19:42:55 +02:00
|
|
|
if (!(font->mapping = map_font_file( face->file )))
|
|
|
|
{
|
|
|
|
WARN("failed to map %s\n", debugstr_a(face->file));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
data_ptr = font->mapping->data;
|
|
|
|
data_size = font->mapping->size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data_ptr = face->font_data_ptr;
|
|
|
|
data_size = face->font_data_size;
|
2007-03-22 00:36:39 +01:00
|
|
|
}
|
2006-12-06 21:31:53 +01:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
err = pFT_New_Memory_Face(library, data_ptr, data_size, face->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 */
|
2005-09-06 16:04:01 +02:00
|
|
|
font->ppem = load_VDMX(font, height);
|
|
|
|
if(font->ppem == 0)
|
|
|
|
font->ppem = calc_ppem_for_height(ft_face, height);
|
2008-06-24 09:10:27 +02:00
|
|
|
TRACE("height %d => ppem %d\n", height, font->ppem);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2005-09-06 16:04:01 +02:00
|
|
|
if((err = pFT_Set_Pixel_Sizes(ft_face, 0, font->ppem)) != 0)
|
2006-10-12 22:56:56 +02:00
|
|
|
WARN("FT_Set_Pixel_Sizes %d, %d rets %x\n", 0, font->ppem, err);
|
2004-06-16 22:06:26 +02:00
|
|
|
} else {
|
2008-01-20 14:21:45 +01:00
|
|
|
font->ppem = height;
|
2004-06-16 22:06:26 +02:00
|
|
|
if((err = pFT_Set_Pixel_Sizes(ft_face, width, height)) != 0)
|
2006-10-12 22:56:56 +02:00
|
|
|
WARN("FT_Set_Pixel_Sizes %d, %d rets %x\n", width, height, err);
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
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;
|
2006-07-19 09:17:49 +02:00
|
|
|
if(TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE))
|
2006-10-01 23:42:50 +02:00
|
|
|
if(csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.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
|
2006-10-12 22:56:56 +02:00
|
|
|
FIXME("TCI failing on %x\n", fs0);
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2006-10-12 22:56:56 +02:00
|
|
|
FIXME("returning DEFAULT_CHARSET face->fs.fsCsb[0] = %08x file = %s\n",
|
2003-06-23 22:51:06 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static GdiFont *alloc_font(void)
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
|
2007-08-30 12:17:23 +02:00
|
|
|
ret->gmsize = 1;
|
|
|
|
ret->gm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GM*));
|
|
|
|
ret->gm[0] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GM) * GM_BLOCK_SIZE);
|
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;
|
2006-09-20 17:18:51 +02:00
|
|
|
ret->total_kern_pairs = (DWORD)-1;
|
|
|
|
ret->kern_pairs = NULL;
|
2004-08-06 19:31:39 +02:00
|
|
|
list_init(&ret->hfontlist);
|
2005-09-07 11:21:50 +02:00
|
|
|
list_init(&ret->child_fonts);
|
2002-01-29 04:02:50 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static void free_font(GdiFont *font)
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
2005-09-07 11:21:50 +02:00
|
|
|
struct list *cursor, *cursor2;
|
2008-10-10 21:00:41 +02:00
|
|
|
DWORD i;
|
2005-09-07 11:21:50 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &font->child_fonts)
|
|
|
|
{
|
|
|
|
CHILD_FONT *child = LIST_ENTRY(cursor, CHILD_FONT, entry);
|
|
|
|
list_remove(cursor);
|
2005-09-14 13:15:05 +02:00
|
|
|
if(child->font)
|
|
|
|
free_font(child->font);
|
2005-09-07 11:21:50 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, child);
|
|
|
|
}
|
|
|
|
|
2011-02-21 11:21:46 +01:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &font->hfontlist)
|
|
|
|
{
|
|
|
|
HFONTLIST *hfontlist = LIST_ENTRY(cursor, HFONTLIST, entry);
|
|
|
|
DeleteObject(hfontlist->hfont);
|
|
|
|
list_remove(&hfontlist->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, hfontlist);
|
|
|
|
}
|
|
|
|
|
2002-04-03 22:02:39 +02:00
|
|
|
if (font->ft_face) pFT_Done_Face(font->ft_face);
|
2007-09-13 19:42:55 +02:00
|
|
|
if (font->mapping) unmap_font_file( font->mapping );
|
2006-09-20 17:18:51 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, font->kern_pairs);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, font->potm);
|
|
|
|
HeapFree(GetProcessHeap(), 0, font->name);
|
2007-08-30 12:17:23 +02:00
|
|
|
for (i = 0; i < font->gmsize; i++)
|
|
|
|
HeapFree(GetProcessHeap(),0,font->gm[i]);
|
2002-01-29 04:02:50 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, font->gm);
|
2008-03-13 10:40:58 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, font->GSUB_Table);
|
2002-01-29 04:02:50 +01:00
|
|
|
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;
|
|
|
|
|
2006-04-04 13:12:41 +02:00
|
|
|
typedef struct {
|
|
|
|
WORD recs;
|
|
|
|
BYTE startsz;
|
|
|
|
BYTE endsz;
|
|
|
|
} VDMX_group;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static LONG load_VDMX(GdiFont *font, LONG height)
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
2006-04-04 13:12:41 +02:00
|
|
|
WORD hdr[3], tmp;
|
|
|
|
VDMX_group group;
|
2002-01-29 04:02:50 +01:00
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
|
2006-04-04 13:12:41 +02:00
|
|
|
numRecs = GET_BE_WORD(hdr[1]);
|
|
|
|
numRatios = GET_BE_WORD(hdr[2]);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
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);
|
2006-04-04 13:12:41 +02:00
|
|
|
WineEngGetFontData(font, MS_VDMX_TAG, offset, &tmp, 2);
|
2002-01-29 04:02:50 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-04-04 13:12:41 +02:00
|
|
|
if(WineEngGetFontData(font, MS_VDMX_TAG, offset, &group, 4) != GDI_ERROR) {
|
2002-01-29 04:02:50 +01:00
|
|
|
USHORT recs;
|
|
|
|
BYTE startsz, endsz;
|
2006-04-04 13:12:41 +02:00
|
|
|
WORD *vTable;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2006-04-04 13:12:41 +02:00
|
|
|
recs = GET_BE_WORD(group.recs);
|
|
|
|
startsz = group.startsz;
|
|
|
|
endsz = group.endsz;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
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++) {
|
2006-04-04 13:12:41 +02:00
|
|
|
SHORT yMax = GET_BE_WORD(vTable[(i * 3) + 1]);
|
|
|
|
SHORT yMin = GET_BE_WORD(vTable[(i * 3) + 2]);
|
|
|
|
ppem = GET_BE_WORD(vTable[i * 3]);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
if(yMax + -yMin == height) {
|
|
|
|
font->yMax = yMax;
|
|
|
|
font->yMin = yMin;
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("ppem %d found; height=%d yMax=%d yMin=%d\n", ppem, height, font->yMax, font->yMin);
|
2002-01-29 04:02:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(yMax + -yMin > height) {
|
|
|
|
if(--i < 0) {
|
|
|
|
ppem = 0;
|
|
|
|
goto end; /* failed */
|
|
|
|
}
|
2006-04-04 13:12:41 +02:00
|
|
|
font->yMax = GET_BE_WORD(vTable[(i * 3) + 1]);
|
|
|
|
font->yMin = GET_BE_WORD(vTable[(i * 3) + 2]);
|
2006-09-20 12:53:06 +02:00
|
|
|
ppem = GET_BE_WORD(vTable[i * 3]);
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("ppem %d found; height=%d yMax=%d yMin=%d\n", ppem, height, font->yMax, font->yMin);
|
2002-01-29 04:02:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!font->yMax) {
|
|
|
|
ppem = 0;
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("ppem not found for height %d\n", height);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, vTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ppem;
|
|
|
|
}
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
static BOOL fontcmp(const GdiFont *font, FONT_DESC *fd)
|
2004-08-06 19:31:39 +02:00
|
|
|
{
|
|
|
|
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;
|
2006-05-25 11:44:47 +02:00
|
|
|
if(!font->font_desc.can_use_bitmap != !fd->can_use_bitmap) return TRUE;
|
2004-08-06 19:31:39 +02:00
|
|
|
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;
|
2008-07-11 00:08:49 +02:00
|
|
|
for(i = 0, ptr = (DWORD*)pfd->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
|
2004-08-06 19:31:39 +02:00
|
|
|
two_chars = *ptr;
|
|
|
|
pwc = (WCHAR *)&two_chars;
|
|
|
|
if(!*pwc) break;
|
|
|
|
*pwc = toupperW(*pwc);
|
|
|
|
pwc++;
|
|
|
|
*pwc = toupperW(*pwc);
|
|
|
|
hash ^= two_chars;
|
|
|
|
if(!*pwc) break;
|
|
|
|
}
|
2006-05-25 11:44:47 +02:00
|
|
|
hash ^= !pfd->can_use_bitmap;
|
2004-08-06 19:31:39 +02:00
|
|
|
pfd->hash = hash;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-07 17:18:10 +02:00
|
|
|
static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pmat, BOOL can_use_bitmap)
|
2004-08-06 19:31:39 +02:00
|
|
|
{
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *ret;
|
2004-08-06 19:31:39 +02:00
|
|
|
FONT_DESC fd;
|
|
|
|
HFONTLIST *hflist;
|
|
|
|
struct list *font_elem_ptr, *hfontlist_elem_ptr;
|
|
|
|
|
2008-02-27 22:21:10 +01:00
|
|
|
fd.lf = *plf;
|
2008-07-07 17:18:10 +02:00
|
|
|
fd.matrix = *pmat;
|
2006-05-25 11:44:47 +02:00
|
|
|
fd.can_use_bitmap = can_use_bitmap;
|
2004-08-06 19:31:39 +02:00
|
|
|
calc_hash(&fd);
|
|
|
|
|
2008-10-27 08:59:53 +01:00
|
|
|
/* try the child list */
|
|
|
|
LIST_FOR_EACH(font_elem_ptr, &child_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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-06 19:31:39 +02:00
|
|
|
/* 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
|
|
|
|
2008-07-31 17:47:22 +02:00
|
|
|
static void add_to_cache(GdiFont *font)
|
|
|
|
{
|
|
|
|
static DWORD cache_num = 1;
|
|
|
|
|
|
|
|
font->cache_num = cache_num++;
|
|
|
|
list_add_head(&gdi_font_list, &font->entry);
|
|
|
|
}
|
|
|
|
|
2005-09-07 11:21:50 +02:00
|
|
|
/*************************************************************
|
|
|
|
* create_child_font_list
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
static BOOL create_child_font_list(GdiFont *font)
|
2005-09-07 11:21:50 +02:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
SYSTEM_LINKS *font_link;
|
|
|
|
CHILD_FONT *font_link_entry, *new_child;
|
2009-04-14 14:20:55 +02:00
|
|
|
FontSubst *psub;
|
|
|
|
WCHAR* font_name;
|
2005-09-07 11:21:50 +02:00
|
|
|
|
2009-04-14 14:20:55 +02:00
|
|
|
psub = get_font_subst(&font_subst_list, font->name, -1);
|
|
|
|
font_name = psub ? psub->to.name : font->name;
|
2005-09-07 11:21:50 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
|
|
|
{
|
2009-04-14 14:20:55 +02:00
|
|
|
if(!strcmpiW(font_link->font_name, font_name))
|
2005-09-07 11:21:50 +02:00
|
|
|
{
|
|
|
|
TRACE("found entry in system list\n");
|
|
|
|
LIST_FOR_EACH_ENTRY(font_link_entry, &font_link->links, CHILD_FONT, entry)
|
|
|
|
{
|
|
|
|
new_child = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_child));
|
2007-09-06 20:40:00 +02:00
|
|
|
new_child->face = font_link_entry->face;
|
2005-09-07 11:21:50 +02:00
|
|
|
new_child->font = NULL;
|
|
|
|
list_add_tail(&font->child_fonts, &new_child->entry);
|
2007-09-06 20:40:00 +02:00
|
|
|
TRACE("font %s %ld\n", debugstr_a(new_child->face->file), new_child->face->face_index);
|
2005-09-07 11:21:50 +02:00
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-02-18 16:49:07 +01:00
|
|
|
/*
|
|
|
|
* if not SYMBOL or OEM then we also get all the fonts for Microsoft
|
|
|
|
* Sans Serif. This is how asian windows get default fallbacks for fonts
|
|
|
|
*/
|
|
|
|
if (use_default_fallback && font->charset != SYMBOL_CHARSET &&
|
|
|
|
font->charset != OEM_CHARSET &&
|
2009-04-14 14:20:55 +02:00
|
|
|
strcmpiW(font_name,szDefaultFallbackLink) != 0)
|
2008-02-18 16:49:07 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
|
|
|
{
|
2009-04-15 16:13:30 +02:00
|
|
|
if(!strcmpiW(font_link->font_name,szDefaultFallbackLink))
|
2008-02-18 16:49:07 +01:00
|
|
|
{
|
|
|
|
TRACE("found entry in default fallback list\n");
|
|
|
|
LIST_FOR_EACH_ENTRY(font_link_entry, &font_link->links, CHILD_FONT, entry)
|
|
|
|
{
|
|
|
|
new_child = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_child));
|
|
|
|
new_child->face = font_link_entry->face;
|
|
|
|
new_child->font = NULL;
|
|
|
|
list_add_tail(&font->child_fonts, &new_child->entry);
|
|
|
|
TRACE("font %s %ld\n", debugstr_a(new_child->face->file), new_child->face->face_index);
|
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-09-07 11:21:50 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-10-02 05:04:25 +02:00
|
|
|
static BOOL select_charmap(FT_Face ft_face, FT_Encoding encoding)
|
|
|
|
{
|
|
|
|
FT_Error ft_err = FT_Err_Invalid_CharMap_Handle;
|
|
|
|
|
|
|
|
if (pFT_Set_Charmap)
|
|
|
|
{
|
|
|
|
FT_Int i;
|
|
|
|
FT_CharMap cmap0, cmap1, cmap2, cmap3, cmap_def;
|
|
|
|
|
|
|
|
cmap0 = cmap1 = cmap2 = cmap3 = cmap_def = NULL;
|
|
|
|
|
|
|
|
for (i = 0; i < ft_face->num_charmaps; i++)
|
|
|
|
{
|
|
|
|
if (ft_face->charmaps[i]->encoding == encoding)
|
|
|
|
{
|
|
|
|
TRACE("found cmap with platform_id %u, encoding_id %u\n",
|
|
|
|
ft_face->charmaps[i]->platform_id, ft_face->charmaps[i]->encoding_id);
|
|
|
|
|
|
|
|
switch (ft_face->charmaps[i]->platform_id)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
cmap_def = ft_face->charmaps[i];
|
|
|
|
break;
|
|
|
|
case 0: /* Apple Unicode */
|
|
|
|
cmap0 = ft_face->charmaps[i];
|
|
|
|
break;
|
|
|
|
case 1: /* Macintosh */
|
|
|
|
cmap1 = ft_face->charmaps[i];
|
|
|
|
break;
|
|
|
|
case 2: /* ISO */
|
|
|
|
cmap2 = ft_face->charmaps[i];
|
|
|
|
break;
|
|
|
|
case 3: /* Microsoft */
|
|
|
|
cmap3 = ft_face->charmaps[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmap3) /* prefer Microsoft cmap table */
|
|
|
|
ft_err = pFT_Set_Charmap(ft_face, cmap3);
|
|
|
|
else if (cmap1)
|
|
|
|
ft_err = pFT_Set_Charmap(ft_face, cmap1);
|
|
|
|
else if (cmap2)
|
|
|
|
ft_err = pFT_Set_Charmap(ft_face, cmap2);
|
|
|
|
else if (cmap0)
|
|
|
|
ft_err = pFT_Set_Charmap(ft_face, cmap0);
|
|
|
|
else if (cmap_def)
|
|
|
|
ft_err = pFT_Set_Charmap(ft_face, cmap_def);
|
|
|
|
}
|
|
|
|
return ft_err == FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pFT_Select_Charmap(ft_face, encoding) == FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngCreateFontInstance
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *ret;
|
2006-08-29 08:21:52 +02:00
|
|
|
Face *face, *best, *best_bitmap;
|
2005-10-31 22:03:28 +01:00
|
|
|
Family *family, *last_resort_family;
|
2004-08-18 00:08:31 +02:00
|
|
|
struct list *family_elem_ptr, *face_elem_ptr;
|
2004-06-16 22:06:26 +02:00
|
|
|
INT height, width = 0;
|
2006-08-29 08:21:52 +02:00
|
|
|
unsigned int score = 0, new_score;
|
2004-06-16 22:06:26 +02:00
|
|
|
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;
|
2008-07-07 17:18:10 +02:00
|
|
|
FMAT2 dcmat;
|
2008-06-22 15:41:47 +02:00
|
|
|
FontSubst *psub = NULL;
|
2002-06-04 03:02:51 +02:00
|
|
|
|
2008-10-09 03:23:46 +02:00
|
|
|
if (!GetObjectW( hfont, sizeof(lf), &lf )) return NULL;
|
2008-04-07 14:23:55 +02:00
|
|
|
lf.lfWidth = abs(lf.lfWidth);
|
|
|
|
|
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
|
|
|
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("%s, h=%d, it=%d, weight=%d, PandF=%02x, charset=%d orient %d escapement %d\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
|
|
|
|
2008-07-07 17:18:10 +02:00
|
|
|
if(dc->GraphicsMode == GM_ADVANCED)
|
|
|
|
memcpy(&dcmat, &dc->xformWorld2Vport, sizeof(FMAT2));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Windows 3.1 compatibility mode GM_COMPATIBLE has only limited
|
|
|
|
font scaling abilities. */
|
2009-02-05 09:41:29 +01:00
|
|
|
dcmat.eM11 = dcmat.eM22 = dc->vport2WorldValid ? fabs(dc->xformWorld2Vport.eM22) : 1.0;
|
2008-07-07 17:18:10 +02:00
|
|
|
dcmat.eM21 = dcmat.eM12 = 0;
|
|
|
|
}
|
|
|
|
|
2008-11-01 10:44:05 +01:00
|
|
|
/* Try to avoid not necessary glyph transformations */
|
|
|
|
if (dcmat.eM21 == 0.0 && dcmat.eM12 == 0.0 && dcmat.eM11 == dcmat.eM22)
|
|
|
|
{
|
|
|
|
lf.lfHeight *= fabs(dcmat.eM11);
|
|
|
|
lf.lfWidth *= fabs(dcmat.eM11);
|
|
|
|
dcmat.eM11 = dcmat.eM22 = 1.0;
|
|
|
|
}
|
|
|
|
|
2008-07-07 17:18:10 +02:00
|
|
|
TRACE("DC transform %f %f %f %f\n", dcmat.eM11, dcmat.eM12,
|
|
|
|
dcmat.eM21, dcmat.eM22);
|
2008-06-24 09:10:27 +02:00
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-10-09 03:23:46 +02:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
/* check the cache first */
|
2008-07-07 17:18:10 +02:00
|
|
|
if((ret = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != NULL) {
|
2004-08-06 19:31:39 +02:00
|
|
|
TRACE("returning cached gdiFont(%p) for hFont %p\n", ret, hfont);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2004-08-06 19:31:39 +02:00
|
|
|
return ret;
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
|
2004-08-06 19:31:39 +02:00
|
|
|
TRACE("not in cache\n");
|
2005-09-14 17:39:29 +02:00
|
|
|
if(list_empty(&font_list)) /* No fonts installed */
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
|
|
|
TRACE("No fonts installed\n");
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-01-29 04:02:50 +01:00
|
|
|
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
|
|
|
|
2008-07-07 17:18:10 +02:00
|
|
|
ret->font_desc.matrix = dcmat;
|
2008-06-24 09:13:07 +02:00
|
|
|
ret->font_desc.lf = lf;
|
|
|
|
ret->font_desc.can_use_bitmap = can_use_bitmap;
|
|
|
|
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;
|
|
|
|
|
2006-07-19 09:17:49 +02:00
|
|
|
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)lf.lfCharSet, &csi, TCI_SRCCHARSET)) {
|
2002-06-22 03:19:29 +02:00
|
|
|
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') {
|
2007-03-07 06:45:11 +01:00
|
|
|
SYSTEM_LINKS *font_link;
|
|
|
|
CHILD_FONT *font_link_entry;
|
2008-03-11 11:34:48 +01:00
|
|
|
LPWSTR FaceName = lf.lfFaceName;
|
2007-03-07 06:45:11 +01:00
|
|
|
|
2008-03-11 11:34:48 +01:00
|
|
|
/*
|
|
|
|
* Check for a leading '@' this signals that the font is being
|
2008-03-25 18:35:45 +01:00
|
|
|
* requested in tategaki mode (vertical writing substitution) but
|
2008-03-11 11:34:48 +01:00
|
|
|
* does not affect the fontface that is to be selected.
|
|
|
|
*/
|
|
|
|
if (lf.lfFaceName[0]=='@')
|
|
|
|
FaceName = &lf.lfFaceName[1];
|
|
|
|
|
|
|
|
psub = get_font_subst(&font_subst_list, FaceName, lf.lfCharSet);
|
2006-03-30 15:38:07 +02:00
|
|
|
|
2002-04-03 22:51:20 +02:00
|
|
|
if(psub) {
|
2008-06-22 15:41:47 +02:00
|
|
|
TRACE("substituting %s,%d -> %s,%d\n", debugstr_w(FaceName), lf.lfCharSet,
|
|
|
|
debugstr_w(psub->to.name), (psub->to.charset != -1) ? psub->to.charset : lf.lfCharSet);
|
|
|
|
if (psub->to.charset != -1)
|
|
|
|
lf.lfCharSet = psub->to.charset;
|
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);
|
2008-06-22 15:41:47 +02:00
|
|
|
if (!strcmpiW(family->FamilyName, FaceName) ||
|
|
|
|
(psub && !strcmpiW(family->FamilyName, psub->to.name)))
|
|
|
|
{
|
2005-08-19 11:58:32 +02:00
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2005-09-07 11:21:50 +02:00
|
|
|
if((csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) || !csi.fs.fsCsb[0])
|
2005-08-19 11:58:32 +02:00
|
|
|
if(face->scalable || can_use_bitmap)
|
|
|
|
goto found;
|
|
|
|
}
|
2004-08-18 00:08:31 +02:00
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2007-03-07 06:45:11 +01:00
|
|
|
|
2011-05-10 22:38:07 +02:00
|
|
|
/* Search by full face name. */
|
|
|
|
LIST_FOR_EACH(family_elem_ptr, &font_list) {
|
|
|
|
family = LIST_ENTRY(family_elem_ptr, Family, entry);
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
if(face->FullName && !strcmpiW(face->FullName, FaceName) &&
|
|
|
|
((csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) || !csi.fs.fsCsb[0]))
|
|
|
|
{
|
|
|
|
if(face->scalable || can_use_bitmap)
|
|
|
|
goto found_face;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-07 06:45:11 +01:00
|
|
|
/*
|
|
|
|
* Try check the SystemLink list first for a replacement font.
|
|
|
|
* We may find good replacements there.
|
|
|
|
*/
|
|
|
|
LIST_FOR_EACH_ENTRY(font_link, &system_links, SYSTEM_LINKS, entry)
|
|
|
|
{
|
2008-12-02 15:51:05 +01:00
|
|
|
if(!strcmpiW(font_link->font_name, FaceName) ||
|
|
|
|
(psub && !strcmpiW(font_link->font_name,psub->to.name)))
|
2007-03-07 06:45:11 +01:00
|
|
|
{
|
|
|
|
TRACE("found entry in system list\n");
|
|
|
|
LIST_FOR_EACH_ENTRY(font_link_entry, &font_link->links, CHILD_FONT, entry)
|
|
|
|
{
|
2007-09-06 20:40:00 +02:00
|
|
|
face = font_link_entry->face;
|
|
|
|
family = face->family;
|
|
|
|
if(csi.fs.fsCsb[0] &
|
|
|
|
(face->fs.fsCsb[0] | face->fs_links.fsCsb[0]) || !csi.fs.fsCsb[0])
|
2007-03-07 06:45:11 +01:00
|
|
|
{
|
2007-09-06 20:40:00 +02:00
|
|
|
if(face->scalable || can_use_bitmap)
|
|
|
|
goto found;
|
2007-03-07 06:45:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
|
2008-06-22 15:41:47 +02:00
|
|
|
psub = NULL; /* substitution is no more relevant */
|
|
|
|
|
2005-08-19 11:58:32 +02:00
|
|
|
/* If requested charset was DEFAULT_CHARSET then try using charset
|
|
|
|
corresponding to the current ansi codepage */
|
2008-10-09 07:30:00 +02:00
|
|
|
if (!csi.fs.fsCsb[0])
|
2008-05-13 15:10:05 +02:00
|
|
|
{
|
2005-08-19 11:58:32 +02:00
|
|
|
INT acp = GetACP();
|
2006-07-19 09:17:49 +02:00
|
|
|
if(!TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE)) {
|
2005-08-19 11:58:32 +02:00
|
|
|
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);
|
2005-09-07 11:21:50 +02:00
|
|
|
if(csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.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;
|
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-10-31 22:03:28 +01:00
|
|
|
last_resort_family = NULL;
|
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-10-31 22:03:28 +01:00
|
|
|
if(csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) {
|
|
|
|
if(face->scalable)
|
2005-08-19 11:58:32 +02:00
|
|
|
goto found;
|
2005-10-31 22:03:28 +01:00
|
|
|
if(can_use_bitmap && !last_resort_family)
|
|
|
|
last_resort_family = family;
|
|
|
|
}
|
2005-08-19 11:58:32 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2005-10-31 22:03:28 +01:00
|
|
|
if(last_resort_family) {
|
|
|
|
family = last_resort_family;
|
|
|
|
csi.fs.fsCsb[0] = 0;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
|
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-10-31 22:03:28 +01:00
|
|
|
if(face->scalable) {
|
2004-08-11 20:49:34 +02:00
|
|
|
csi.fs.fsCsb[0] = 0;
|
2006-11-09 05:15:16 +01:00
|
|
|
WARN("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
|
|
|
}
|
2005-10-31 22:03:28 +01:00
|
|
|
if(can_use_bitmap && !last_resort_family)
|
|
|
|
last_resort_family = family;
|
2004-08-11 20:49:34 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2005-10-31 22:03:28 +01:00
|
|
|
if(!last_resort_family) {
|
|
|
|
FIXME("can't find a single appropriate font - bailing\n");
|
|
|
|
free_font(ret);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2005-10-31 22:03:28 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("could only find a bitmap font - this will probably look awful!\n");
|
|
|
|
family = last_resort_family;
|
|
|
|
csi.fs.fsCsb[0] = 0;
|
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
|
|
|
|
2008-06-24 09:11:40 +02:00
|
|
|
height = lf.lfHeight;
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2006-08-29 08:21:52 +02:00
|
|
|
face = best = best_bitmap = NULL;
|
|
|
|
LIST_FOR_EACH_ENTRY(face, &family->faces, Face, entry)
|
|
|
|
{
|
|
|
|
if((csi.fs.fsCsb[0] & (face->fs.fsCsb[0] | face->fs_links.fsCsb[0])) || !csi.fs.fsCsb[0])
|
|
|
|
{
|
2008-04-07 09:11:42 +02:00
|
|
|
BOOL italic, bold;
|
|
|
|
|
|
|
|
italic = (face->ntmFlags & NTM_ITALIC) ? 1 : 0;
|
|
|
|
bold = (face->ntmFlags & NTM_BOLD) ? 1 : 0;
|
|
|
|
new_score = (italic ^ it) + (bold ^ bd);
|
2006-08-29 08:21:52 +02:00
|
|
|
if(!best || new_score <= score)
|
|
|
|
{
|
|
|
|
TRACE("(it=%d, bd=%d) is selected for (it=%d, bd=%d)\n",
|
2008-04-07 09:11:42 +02:00
|
|
|
italic, bold, it, bd);
|
2006-08-29 08:21:52 +02:00
|
|
|
score = new_score;
|
2004-06-16 22:06:26 +02:00
|
|
|
best = face;
|
2006-08-29 08:21:52 +02:00
|
|
|
if(best->scalable && score == 0) break;
|
|
|
|
if(!best->scalable)
|
|
|
|
{
|
|
|
|
if(height > 0)
|
|
|
|
newdiff = height - (signed int)(best->size.height);
|
|
|
|
else
|
|
|
|
newdiff = -height - ((signed int)(best->size.height) - best->size.internal_leading);
|
|
|
|
if(!best_bitmap || new_score < score ||
|
|
|
|
(diff > 0 && newdiff < diff && newdiff >= 0) || (diff < 0 && newdiff > diff))
|
|
|
|
{
|
|
|
|
TRACE("%d is better for %d diff was %d\n", best->size.height, height, diff);
|
|
|
|
diff = newdiff;
|
|
|
|
best_bitmap = best;
|
|
|
|
if(score == 0 && diff == 0) break;
|
|
|
|
}
|
2005-08-19 11:58:32 +02:00
|
|
|
}
|
2004-08-10 00:54:33 +02:00
|
|
|
}
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2006-08-29 08:21:52 +02:00
|
|
|
if(best)
|
|
|
|
face = best->scalable ? best : best_bitmap;
|
2008-04-07 09:11:42 +02:00
|
|
|
ret->fake_italic = (it && !(face->ntmFlags & NTM_ITALIC));
|
|
|
|
ret->fake_bold = (bd && !(face->ntmFlags & NTM_BOLD));
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2011-05-10 22:38:07 +02:00
|
|
|
found_face:
|
|
|
|
height = lf.lfHeight;
|
|
|
|
|
2008-02-27 22:21:10 +01:00
|
|
|
ret->fs = face->fs;
|
2003-06-23 22:51:06 +02:00
|
|
|
|
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
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
TRACE("Chosen: %s %s (%s/%p:%ld)\n", debugstr_w(family->FamilyName),
|
|
|
|
debugstr_w(face->StyleName), face->file, face->font_data_ptr, face->face_index);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2008-04-07 14:23:55 +02:00
|
|
|
ret->aveWidth = height ? lf.lfWidth : 0;
|
2008-01-09 14:58:00 +01:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(!face->scalable) {
|
2008-01-20 14:21:45 +01:00
|
|
|
/* Windows uses integer scaling factors for bitmap fonts */
|
|
|
|
INT scale, scaled_height;
|
2010-07-20 00:17:10 +02:00
|
|
|
GdiFont *cachedfont;
|
2008-01-20 14:21:45 +01:00
|
|
|
|
2008-08-21 08:02:15 +02:00
|
|
|
/* FIXME: rotation of bitmap fonts is ignored */
|
|
|
|
height = abs(GDI_ROUND( (double)height * ret->font_desc.matrix.eM22 ));
|
|
|
|
if (ret->aveWidth)
|
|
|
|
ret->aveWidth = (double)ret->aveWidth * ret->font_desc.matrix.eM11;
|
|
|
|
ret->font_desc.matrix.eM11 = ret->font_desc.matrix.eM22 = 1.0;
|
2010-07-20 00:17:10 +02:00
|
|
|
dcmat.eM11 = dcmat.eM22 = 1.0;
|
|
|
|
/* As we changed the matrix, we need to search the cache for the font again,
|
|
|
|
* otherwise we might explode the cache. */
|
|
|
|
if((cachedfont = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != NULL) {
|
|
|
|
TRACE("Found cached font after non-scalable matrix rescale!\n");
|
|
|
|
free_font( ret );
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return cachedfont;
|
|
|
|
}
|
|
|
|
calc_hash(&ret->font_desc);
|
2008-08-21 08:02:15 +02:00
|
|
|
|
2008-01-20 14:21:45 +01:00
|
|
|
if (height != 0) height = diff;
|
|
|
|
height += face->size.height;
|
|
|
|
|
|
|
|
scale = (height + face->size.height - 1) / face->size.height;
|
|
|
|
scaled_height = scale * face->size.height;
|
2009-02-20 15:40:44 +01:00
|
|
|
/* Only jump to the next height if the difference <= 25% original height */
|
|
|
|
if (scale > 2 && scaled_height - height > face->size.height / 4) scale--;
|
|
|
|
/* The jump between unscaled and doubled is delayed by 1 */
|
|
|
|
else if (scale == 2 && scaled_height - height > (face->size.height / 4 - 1)) scale--;
|
2008-01-20 14:21:45 +01:00
|
|
|
ret->scale_y = scale;
|
2008-01-09 14:58:00 +01:00
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
width = face->size.x_ppem >> 6;
|
|
|
|
height = face->size.y_ppem >> 6;
|
|
|
|
}
|
2008-01-20 14:21:45 +01:00
|
|
|
else
|
|
|
|
ret->scale_y = 1.0;
|
|
|
|
TRACE("font scale y: %f\n", ret->scale_y);
|
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
ret->ft_face = OpenFontFace(ret, face, width, height);
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2002-04-03 23:06:09 +02:00
|
|
|
if (!ret->ft_face)
|
|
|
|
{
|
|
|
|
free_font( ret );
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-04-03 23:06:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2003-10-28 01:08:28 +01:00
|
|
|
|
2007-09-07 23:30:40 +02:00
|
|
|
ret->ntmFlags = face->ntmFlags;
|
|
|
|
|
2003-10-15 04:33:55 +02:00
|
|
|
if (ret->charset == SYMBOL_CHARSET &&
|
2007-10-02 05:04:25 +02:00
|
|
|
select_charmap(ret->ft_face, FT_ENCODING_MS_SYMBOL)) {
|
2003-10-15 04:33:55 +02:00
|
|
|
/* No ops */
|
|
|
|
}
|
2007-10-02 05:04:25 +02:00
|
|
|
else if (select_charmap(ret->ft_face, FT_ENCODING_UNICODE)) {
|
2003-10-15 04:33:55 +02:00
|
|
|
/* No ops */
|
|
|
|
}
|
|
|
|
else {
|
2007-10-02 05:04:25 +02:00
|
|
|
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;
|
2008-06-22 15:41:47 +02:00
|
|
|
ret->name = psub ? strdupW(psub->from.name) : strdupW(family->FamilyName);
|
2004-07-22 21:42:31 +02:00
|
|
|
ret->underline = lf.lfUnderline ? 0xff : 0;
|
|
|
|
ret->strikeout = lf.lfStrikeOut ? 0xff : 0;
|
2005-09-07 11:21:50 +02:00
|
|
|
create_child_font_list(ret);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2008-03-13 10:40:58 +01:00
|
|
|
if (lf.lfFaceName[0]=='@') /* We need to try to load the GSUB table */
|
|
|
|
{
|
|
|
|
int length = WineEngGetFontData (ret, GSUB_TAG , 0, NULL, 0);
|
|
|
|
if (length != GDI_ERROR)
|
|
|
|
{
|
|
|
|
ret->GSUB_Table = HeapAlloc(GetProcessHeap(),0,length);
|
|
|
|
WineEngGetFontData(ret, GSUB_TAG , 0, ret->GSUB_Table, length);
|
|
|
|
TRACE("Loaded GSUB table of %i bytes\n",length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2008-07-31 17:47:22 +02:00
|
|
|
add_to_cache(ret);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
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
|
|
|
{
|
2006-09-28 08:11:06 +02: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);
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("gdiFont=%p %s %d\n",
|
2004-08-06 19:31:39 +02:00
|
|
|
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);
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("gdiFont=%p %s %d\n",
|
2004-08-06 19:31:39 +02:00
|
|
|
gdiFont, debugstr_w(gdiFont->font_desc.lf.lfFaceName), gdiFont->font_desc.lf.lfHeight);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2011-02-21 11:20:01 +01:00
|
|
|
|
|
|
|
TRACE("---------- Child gdiFont Cache ----------\n");
|
|
|
|
LIST_FOR_EACH(elem_ptr, &child_font_list) {
|
|
|
|
gdiFont = LIST_ENTRY(elem_ptr, struct tagGdiFont, entry);
|
|
|
|
TRACE("gdiFont=%p %s %d\n",
|
|
|
|
gdiFont, debugstr_w(gdiFont->font_desc.lf.lfFaceName), gdiFont->font_desc.lf.lfHeight);
|
|
|
|
}
|
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
|
|
|
{
|
2006-09-28 08:11:06 +02: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
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2005-09-15 11:29:37 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(gdiFont, &child_font_list, struct tagGdiFont, entry)
|
|
|
|
{
|
2011-02-21 11:20:59 +01:00
|
|
|
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) {
|
|
|
|
TRACE("removing child font %p from child list\n", gdiFont);
|
|
|
|
list_remove(&gdiFont->entry);
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-09-15 11:29:37 +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);
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-11-14 00:54:50 +01:00
|
|
|
return ret;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2011-04-01 14:20:00 +02:00
|
|
|
/***************************************************
|
|
|
|
* create_enum_charset_list
|
|
|
|
*
|
|
|
|
* This function creates charset enumeration list because in DEFAULT_CHARSET
|
|
|
|
* case, the ANSI codepage's charset takes precedence over other charsets.
|
|
|
|
* This function works as a filter other than DEFAULT_CHARSET case.
|
|
|
|
*/
|
|
|
|
static DWORD create_enum_charset_list(DWORD charset, struct enum_charset_list *list)
|
|
|
|
{
|
|
|
|
CHARSETINFO csi;
|
|
|
|
DWORD n = 0;
|
|
|
|
|
2011-04-11 13:45:23 +02:00
|
|
|
if (TranslateCharsetInfo(ULongToPtr(charset), &csi, TCI_SRCCHARSET) &&
|
2011-04-01 14:20:00 +02:00
|
|
|
csi.fs.fsCsb[0] != 0) {
|
|
|
|
list->element[n].mask = csi.fs.fsCsb[0];
|
|
|
|
list->element[n].charset = csi.ciCharset;
|
|
|
|
list->element[n].name = ElfScriptsW[ffs(csi.fs.fsCsb[0]) - 1];
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
else { /* charset is DEFAULT_CHARSET or invalid. */
|
|
|
|
INT acp, i;
|
|
|
|
|
|
|
|
/* Set the current codepage's charset as the first element. */
|
|
|
|
acp = GetACP();
|
|
|
|
if (TranslateCharsetInfo((DWORD*)(INT_PTR)acp, &csi, TCI_SRCCODEPAGE) &&
|
|
|
|
csi.fs.fsCsb[0] != 0) {
|
|
|
|
list->element[n].mask = csi.fs.fsCsb[0];
|
|
|
|
list->element[n].charset = csi.ciCharset;
|
|
|
|
list->element[n].name = ElfScriptsW[ffs(csi.fs.fsCsb[0]) - 1];
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill out left elements. */
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
FONTSIGNATURE fs;
|
|
|
|
fs.fsCsb[0] = 1L << i;
|
|
|
|
fs.fsCsb[1] = 0;
|
|
|
|
if (n > 0 && fs.fsCsb[0] == list->element[0].mask)
|
|
|
|
continue; /* skip, already added. */
|
|
|
|
if (!TranslateCharsetInfo(fs.fsCsb, &csi, TCI_SRCFONTSIG))
|
|
|
|
continue; /* skip, this is an invalid fsCsb bit. */
|
|
|
|
|
|
|
|
list->element[n].mask = fs.fsCsb[0];
|
|
|
|
list->element[n].charset = csi.ciCharset;
|
|
|
|
list->element[n].name = ElfScriptsW[i];
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list->total = n;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-01-10 14:18:36 +01:00
|
|
|
GdiFont *font;
|
2004-06-16 22:06:26 +02:00
|
|
|
LONG width, height;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2008-01-16 07:46:24 +01:00
|
|
|
if (face->cached_enum_data)
|
2007-12-11 14:09:21 +01:00
|
|
|
{
|
|
|
|
TRACE("Cached\n");
|
2008-02-27 22:21:10 +01:00
|
|
|
*pelf = face->cached_enum_data->elf;
|
|
|
|
*pntm = face->cached_enum_data->ntm;
|
2008-01-16 07:46:24 +01:00
|
|
|
*ptype = face->cached_enum_data->type;
|
2007-12-11 14:09:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-10 14:18:36 +01:00
|
|
|
font = alloc_font();
|
|
|
|
|
2004-06-16 22:06:26 +02:00
|
|
|
if(face->scalable) {
|
2008-04-24 06:25:27 +02:00
|
|
|
height = -2048; /* 2048 is the most common em size */
|
2004-06-16 22:06:26 +02:00
|
|
|
width = 0;
|
|
|
|
} else {
|
|
|
|
height = face->size.y_ppem >> 6;
|
|
|
|
width = face->size.x_ppem >> 6;
|
|
|
|
}
|
2008-01-20 14:21:45 +01:00
|
|
|
font->scale_y = 1.0;
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
if (!(font->ft_face = OpenFontFace(font, face, 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);
|
2007-09-07 23:30:40 +02:00
|
|
|
font->ntmFlags = face->ntmFlags;
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2008-01-11 10:04:26 +01:00
|
|
|
if (WineEngGetOutlineTextMetrics(font, 0, NULL))
|
|
|
|
{
|
|
|
|
memcpy(&pntm->ntmTm, &font->potm->otmTextMetrics, sizeof(TEXTMETRICW));
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2008-01-11 10:04:26 +01:00
|
|
|
pntm->ntmTm.ntmSizeEM = font->potm->otmEMSquare;
|
2004-06-16 22:06:26 +02:00
|
|
|
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfLogFont.lfFaceName,
|
2008-01-11 10:04:26 +01:00
|
|
|
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFamilyName),
|
2004-06-16 22:06:26 +02:00
|
|
|
LF_FACESIZE);
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfFullName,
|
2011-08-23 22:11:57 +02:00
|
|
|
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFullName),
|
2004-06-16 22:06:26 +02:00
|
|
|
LF_FULLFACESIZE);
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW(pelf->elfStyle,
|
2008-01-11 10:04:26 +01:00
|
|
|
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpStyleName),
|
2004-06-16 22:06:26 +02:00
|
|
|
LF_FACESIZE);
|
2008-01-11 10:04:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WineEngGetTextMetrics(font, (TEXTMETRICW *)&pntm->ntmTm);
|
2004-06-16 22:06:26 +02:00
|
|
|
|
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);
|
2011-08-23 22:11:57 +02:00
|
|
|
if (face->FullName)
|
|
|
|
lstrcpynW(pelf->elfFullName, face->FullName, LF_FULLFACESIZE);
|
|
|
|
else
|
|
|
|
lstrcpynW(pelf->elfFullName, face->family->FamilyName, LF_FULLFACESIZE);
|
2008-01-14 12:39:33 +01:00
|
|
|
lstrcpynW(pelf->elfStyle, face->StyleName, LF_FACESIZE);
|
2004-06-16 22:06:26 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2008-01-11 10:04:26 +01:00
|
|
|
pntm->ntmTm.ntmFlags = face->ntmFlags;
|
|
|
|
pntm->ntmTm.ntmCellHeight = pntm->ntmTm.tmHeight;
|
|
|
|
pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
|
2008-02-27 22:21:10 +01:00
|
|
|
pntm->ntmFontSig = face->fs;
|
2008-01-11 10:04:26 +01: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
|
|
|
|
2008-01-14 12:39:33 +01:00
|
|
|
pelf->elfLogFont.lfEscapement = 0;
|
|
|
|
pelf->elfLogFont.lfOrientation = 0;
|
2008-01-11 10:04:26 +01:00
|
|
|
pelf->elfLogFont.lfHeight = pntm->ntmTm.tmHeight;
|
|
|
|
pelf->elfLogFont.lfWidth = pntm->ntmTm.tmAveCharWidth;
|
|
|
|
pelf->elfLogFont.lfWeight = pntm->ntmTm.tmWeight;
|
|
|
|
pelf->elfLogFont.lfItalic = pntm->ntmTm.tmItalic;
|
|
|
|
pelf->elfLogFont.lfUnderline = pntm->ntmTm.tmUnderlined;
|
|
|
|
pelf->elfLogFont.lfStrikeOut = pntm->ntmTm.tmStruckOut;
|
|
|
|
pelf->elfLogFont.lfCharSet = pntm->ntmTm.tmCharSet;
|
|
|
|
pelf->elfLogFont.lfOutPrecision = OUT_STROKE_PRECIS;
|
|
|
|
pelf->elfLogFont.lfClipPrecision = CLIP_STROKE_PRECIS;
|
|
|
|
pelf->elfLogFont.lfQuality = DRAFT_QUALITY;
|
|
|
|
pelf->elfLogFont.lfPitchAndFamily = (pntm->ntmTm.tmPitchAndFamily & 0xf1) + 1;
|
|
|
|
|
|
|
|
*ptype = 0;
|
|
|
|
if (pntm->ntmTm.tmPitchAndFamily & TMPF_TRUETYPE)
|
|
|
|
*ptype |= TRUETYPE_FONTTYPE;
|
|
|
|
if (pntm->ntmTm.tmPitchAndFamily & TMPF_DEVICE)
|
|
|
|
*ptype |= DEVICE_FONTTYPE;
|
|
|
|
if(!(pntm->ntmTm.tmPitchAndFamily & TMPF_VECTOR))
|
|
|
|
*ptype |= RASTER_FONTTYPE;
|
|
|
|
|
2008-01-16 07:46:24 +01:00
|
|
|
face->cached_enum_data = HeapAlloc(GetProcessHeap(), 0, sizeof(*face->cached_enum_data));
|
|
|
|
if (face->cached_enum_data)
|
|
|
|
{
|
2008-02-27 22:21:10 +01:00
|
|
|
face->cached_enum_data->elf = *pelf;
|
|
|
|
face->cached_enum_data->ntm = *pntm;
|
2008-01-16 07:46:24 +01:00
|
|
|
face->cached_enum_data->type = *ptype;
|
|
|
|
}
|
2007-12-11 14:09:21 +01:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
free_font(font);
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2011-02-14 10:54:25 +01:00
|
|
|
static BOOL family_matches(Family *family, const LOGFONTW *lf)
|
|
|
|
{
|
|
|
|
struct list *face_elem_ptr;
|
|
|
|
|
|
|
|
if (!strcmpiW(lf->lfFaceName, family->FamilyName)) return TRUE;
|
|
|
|
|
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces)
|
|
|
|
{
|
|
|
|
static const WCHAR spaceW[] = { ' ',0 };
|
|
|
|
WCHAR full_family_name[LF_FULLFACESIZE];
|
|
|
|
Face *face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
|
|
|
|
|
|
|
if (strlenW(family->FamilyName) + strlenW(face->StyleName) + 2 > LF_FULLFACESIZE)
|
|
|
|
{
|
|
|
|
FIXME("Length of %s + %s + 2 is longer than LF_FULLFACESIZE\n",
|
|
|
|
debugstr_w(family->FamilyName), debugstr_w(face->StyleName));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW(full_family_name, family->FamilyName);
|
|
|
|
strcatW(full_family_name, spaceW);
|
|
|
|
strcatW(full_family_name, face->StyleName);
|
|
|
|
if (!strcmpiW(lf->lfFaceName, full_family_name)) return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL face_matches(Face *face, const LOGFONTW *lf)
|
|
|
|
{
|
|
|
|
static const WCHAR spaceW[] = { ' ',0 };
|
|
|
|
WCHAR full_family_name[LF_FULLFACESIZE];
|
|
|
|
|
|
|
|
if (!strcmpiW(lf->lfFaceName, face->family->FamilyName)) return TRUE;
|
|
|
|
|
|
|
|
if (strlenW(face->family->FamilyName) + strlenW(face->StyleName) + 2 > LF_FULLFACESIZE)
|
|
|
|
{
|
|
|
|
FIXME("Length of %s + %s + 2 is longer than LF_FULLFACESIZE\n",
|
|
|
|
debugstr_w(face->family->FamilyName), debugstr_w(face->StyleName));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW(full_family_name, face->family->FamilyName);
|
|
|
|
strcatW(full_family_name, spaceW);
|
|
|
|
strcatW(full_family_name, face->StyleName);
|
|
|
|
return !strcmpiW(lf->lfFaceName, full_family_name);
|
|
|
|
}
|
|
|
|
|
2011-04-01 14:20:00 +02:00
|
|
|
static BOOL enum_face_charsets(Face *face, struct enum_charset_list *list,
|
|
|
|
FONTENUMPROCW proc, LPARAM lparam)
|
2011-04-01 14:19:54 +02:00
|
|
|
{
|
|
|
|
ENUMLOGFONTEXW elf;
|
|
|
|
NEWTEXTMETRICEXW ntm;
|
|
|
|
DWORD type = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
GetEnumStructs(face, &elf, &ntm, &type);
|
2011-04-01 14:20:00 +02:00
|
|
|
for(i = 0; i < list->total; i++) {
|
2011-04-01 14:19:54 +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 */
|
2011-04-01 14:20:00 +02:00
|
|
|
} else if(!(face->fs.fsCsb[0] & list->element[i].mask))
|
2011-04-01 14:19:54 +02:00
|
|
|
continue;
|
|
|
|
else {
|
2011-04-01 14:20:00 +02:00
|
|
|
elf.elfLogFont.lfCharSet = ntm.ntmTm.tmCharSet = list->element[i].charset;
|
|
|
|
if(list->element[i].name)
|
|
|
|
strcpyW(elf.elfScript, list->element[i].name);
|
|
|
|
else
|
|
|
|
FIXME("Unknown elfscript for bit %d\n", ffs(list->element[i].mask) - 1);
|
2011-04-01 14:19:54 +02:00
|
|
|
}
|
|
|
|
TRACE("enuming face %s full %s style %s charset = %d type %d script %s it %d weight %d ntmflags %08x\n",
|
|
|
|
debugstr_w(elf.elfLogFont.lfFaceName),
|
|
|
|
debugstr_w(elf.elfFullName), debugstr_w(elf.elfStyle),
|
2011-04-01 14:20:00 +02:00
|
|
|
list->element[i].charset, type, debugstr_w(elf.elfScript),
|
2011-04-01 14:19:54 +02:00
|
|
|
elf.elfLogFont.lfItalic, elf.elfLogFont.lfWeight,
|
|
|
|
ntm.ntmTm.ntmFlags);
|
|
|
|
/* release section before callback (FIXME) */
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
if (!proc(&elf.elfLogFont, (TEXTMETRICW *)&ntm, type, lparam)) return FALSE;
|
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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;
|
2003-06-23 22:51:06 +02:00
|
|
|
LOGFONTW lf;
|
2011-04-01 14:20:00 +02:00
|
|
|
struct enum_charset_list enum_charsets;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2008-01-15 09:02:29 +01:00
|
|
|
if (!plf)
|
|
|
|
{
|
|
|
|
lf.lfCharSet = DEFAULT_CHARSET;
|
|
|
|
lf.lfPitchAndFamily = 0;
|
|
|
|
lf.lfFaceName[0] = 0;
|
|
|
|
plf = &lf;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-04-01 14:20:00 +02:00
|
|
|
create_enum_charset_list(plf->lfCharSet, &enum_charsets);
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2001-09-12 22:21:06 +02:00
|
|
|
if(plf->lfFaceName[0]) {
|
2003-06-23 22:51:06 +02:00
|
|
|
FontSubst *psub;
|
2006-03-30 15:38:07 +02:00
|
|
|
psub = get_font_subst(&font_subst_list, plf->lfFaceName, plf->lfCharSet);
|
|
|
|
|
2003-06-23 22:51:06 +02:00
|
|
|
if(psub) {
|
|
|
|
TRACE("substituting %s -> %s\n", debugstr_w(plf->lfFaceName),
|
|
|
|
debugstr_w(psub->to.name));
|
2008-02-27 22:21:10 +01:00
|
|
|
lf = *plf;
|
2003-06-23 22:51:06 +02:00
|
|
|
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);
|
2011-02-14 10:54:25 +01:00
|
|
|
if(family_matches(family, plf)) {
|
2004-08-18 00:08:31 +02:00
|
|
|
LIST_FOR_EACH(face_elem_ptr, &family->faces) {
|
|
|
|
face = LIST_ENTRY(face_elem_ptr, Face, entry);
|
2011-02-14 10:54:25 +01:00
|
|
|
if (!face_matches(face, plf)) continue;
|
2011-04-01 14:20:00 +02:00
|
|
|
if (!enum_face_charsets(face, &enum_charsets, proc, lparam)) return 0;
|
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);
|
2011-04-01 14:20:00 +02:00
|
|
|
if (!enum_face_charsets(face, &enum_charsets, proc, lparam)) return 0;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return 1;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-01-13 14:25:16 +01:00
|
|
|
/***************************************************
|
|
|
|
* According to the MSDN documentation on WideCharToMultiByte,
|
|
|
|
* certain codepages cannot set the default_used parameter.
|
|
|
|
* This returns TRUE if the codepage can set that parameter, false else
|
|
|
|
* so that calls to WideCharToMultiByte don't fail with ERROR_INVALID_PARAMETER
|
|
|
|
*/
|
|
|
|
static BOOL codepage_sets_default_used(UINT codepage)
|
|
|
|
{
|
|
|
|
switch (codepage)
|
|
|
|
{
|
|
|
|
case CP_UTF7:
|
|
|
|
case CP_UTF8:
|
|
|
|
case CP_SYMBOL:
|
|
|
|
return FALSE;
|
|
|
|
default:
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-13 10:40:58 +01:00
|
|
|
/*
|
|
|
|
* GSUB Table handling functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static INT GSUB_is_glyph_covered(LPCVOID table , UINT glyph)
|
|
|
|
{
|
|
|
|
const GSUB_CoverageFormat1* cf1;
|
|
|
|
|
2009-01-26 11:01:12 +01:00
|
|
|
cf1 = table;
|
2008-03-13 10:40:58 +01:00
|
|
|
|
|
|
|
if (GET_BE_WORD(cf1->CoverageFormat) == 1)
|
|
|
|
{
|
|
|
|
int count = GET_BE_WORD(cf1->GlyphCount);
|
|
|
|
int i;
|
|
|
|
TRACE("Coverage Format 1, %i glyphs\n",count);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if (glyph == GET_BE_WORD(cf1->GlyphArray[i]))
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if (GET_BE_WORD(cf1->CoverageFormat) == 2)
|
|
|
|
{
|
|
|
|
const GSUB_CoverageFormat2* cf2;
|
|
|
|
int i;
|
|
|
|
int count;
|
2010-03-27 11:56:11 +01:00
|
|
|
cf2 = (const GSUB_CoverageFormat2*)cf1;
|
2008-03-13 10:40:58 +01:00
|
|
|
|
|
|
|
count = GET_BE_WORD(cf2->RangeCount);
|
|
|
|
TRACE("Coverage Format 2, %i ranges\n",count);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (glyph < GET_BE_WORD(cf2->RangeRecord[i].Start))
|
|
|
|
return -1;
|
|
|
|
if ((glyph >= GET_BE_WORD(cf2->RangeRecord[i].Start)) &&
|
|
|
|
(glyph <= GET_BE_WORD(cf2->RangeRecord[i].End)))
|
|
|
|
{
|
|
|
|
return (GET_BE_WORD(cf2->RangeRecord[i].StartCoverageIndex) +
|
|
|
|
glyph - GET_BE_WORD(cf2->RangeRecord[i].Start));
|
|
|
|
}
|
|
|
|
}
|
2008-03-19 05:29:21 +01:00
|
|
|
return -1;
|
2008-03-13 10:40:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Unknown CoverageFormat %i\n",GET_BE_WORD(cf1->CoverageFormat));
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GSUB_Script* GSUB_get_script_table( const GSUB_Header* header, const char* tag)
|
|
|
|
{
|
|
|
|
const GSUB_ScriptList *script;
|
|
|
|
const GSUB_Script *deflt = NULL;
|
|
|
|
int i;
|
2010-03-27 11:56:11 +01:00
|
|
|
script = (const GSUB_ScriptList*)((const BYTE*)header + GET_BE_WORD(header->ScriptList));
|
2008-03-13 10:40:58 +01:00
|
|
|
|
|
|
|
TRACE("%i scripts in this font\n",GET_BE_WORD(script->ScriptCount));
|
|
|
|
for (i = 0; i < GET_BE_WORD(script->ScriptCount); i++)
|
|
|
|
{
|
|
|
|
const GSUB_Script *scr;
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
offset = GET_BE_WORD(script->ScriptRecord[i].Script);
|
2010-03-27 11:56:11 +01:00
|
|
|
scr = (const GSUB_Script*)((const BYTE*)script + offset);
|
2008-03-13 10:40:58 +01:00
|
|
|
|
|
|
|
if (strncmp(script->ScriptRecord[i].ScriptTag, tag,4)==0)
|
|
|
|
return scr;
|
|
|
|
if (strncmp(script->ScriptRecord[i].ScriptTag, "dflt",4)==0)
|
|
|
|
deflt = scr;
|
|
|
|
}
|
|
|
|
return deflt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GSUB_LangSys* GSUB_get_lang_table( const GSUB_Script* script, const char* tag)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int offset;
|
|
|
|
const GSUB_LangSys *Lang;
|
|
|
|
|
|
|
|
TRACE("Deflang %x, LangCount %i\n",GET_BE_WORD(script->DefaultLangSys), GET_BE_WORD(script->LangSysCount));
|
|
|
|
|
|
|
|
for (i = 0; i < GET_BE_WORD(script->LangSysCount) ; i++)
|
|
|
|
{
|
|
|
|
offset = GET_BE_WORD(script->LangSysRecord[i].LangSys);
|
2010-03-27 11:56:11 +01:00
|
|
|
Lang = (const GSUB_LangSys*)((const BYTE*)script + offset);
|
2008-03-13 10:40:58 +01:00
|
|
|
|
|
|
|
if ( strncmp(script->LangSysRecord[i].LangSysTag,tag,4)==0)
|
|
|
|
return Lang;
|
|
|
|
}
|
|
|
|
offset = GET_BE_WORD(script->DefaultLangSys);
|
|
|
|
if (offset)
|
|
|
|
{
|
2010-03-27 11:56:11 +01:00
|
|
|
Lang = (const GSUB_LangSys*)((const BYTE*)script + offset);
|
2008-03-13 10:40:58 +01:00
|
|
|
return Lang;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GSUB_Feature * GSUB_get_feature(const GSUB_Header *header, const GSUB_LangSys *lang, const char* tag)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const GSUB_FeatureList *feature;
|
2010-03-27 11:56:11 +01:00
|
|
|
feature = (const GSUB_FeatureList*)((const BYTE*)header + GET_BE_WORD(header->FeatureList));
|
2008-03-13 10:40:58 +01:00
|
|
|
|
2008-03-18 15:20:34 +01:00
|
|
|
TRACE("%i features\n",GET_BE_WORD(lang->FeatureCount));
|
2008-03-13 10:40:58 +01:00
|
|
|
for (i = 0; i < GET_BE_WORD(lang->FeatureCount); i++)
|
|
|
|
{
|
|
|
|
int index = GET_BE_WORD(lang->FeatureIndex[i]);
|
|
|
|
if (strncmp(feature->FeatureRecord[index].FeatureTag,tag,4)==0)
|
|
|
|
{
|
|
|
|
const GSUB_Feature *feat;
|
2010-03-27 11:56:11 +01:00
|
|
|
feat = (const GSUB_Feature*)((const BYTE*)feature + GET_BE_WORD(feature->FeatureRecord[index].Feature));
|
2008-03-13 10:40:58 +01:00
|
|
|
return feat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FT_UInt GSUB_apply_feature(const GSUB_Header * header, const GSUB_Feature* feature, UINT glyph)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int offset;
|
|
|
|
const GSUB_LookupList *lookup;
|
2010-03-27 11:56:11 +01:00
|
|
|
lookup = (const GSUB_LookupList*)((const BYTE*)header + GET_BE_WORD(header->LookupList));
|
2008-03-13 10:40:58 +01:00
|
|
|
|
|
|
|
TRACE("%i lookups\n", GET_BE_WORD(feature->LookupCount));
|
|
|
|
for (i = 0; i < GET_BE_WORD(feature->LookupCount); i++)
|
|
|
|
{
|
|
|
|
const GSUB_LookupTable *look;
|
|
|
|
offset = GET_BE_WORD(lookup->Lookup[GET_BE_WORD(feature->LookupListIndex[i])]);
|
2010-03-27 11:56:11 +01:00
|
|
|
look = (const GSUB_LookupTable*)((const BYTE*)lookup + offset);
|
2008-03-13 10:40:58 +01:00
|
|
|
TRACE("type %i, flag %x, subtables %i\n",GET_BE_WORD(look->LookupType),GET_BE_WORD(look->LookupFlag),GET_BE_WORD(look->SubTableCount));
|
|
|
|
if (GET_BE_WORD(look->LookupType) != 1)
|
|
|
|
FIXME("We only handle SubType 1\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < GET_BE_WORD(look->SubTableCount); j++)
|
|
|
|
{
|
|
|
|
const GSUB_SingleSubstFormat1 *ssf1;
|
|
|
|
offset = GET_BE_WORD(look->SubTable[j]);
|
2010-03-27 11:56:11 +01:00
|
|
|
ssf1 = (const GSUB_SingleSubstFormat1*)((const BYTE*)look+offset);
|
2008-03-13 10:40:58 +01:00
|
|
|
if (GET_BE_WORD(ssf1->SubstFormat) == 1)
|
|
|
|
{
|
|
|
|
int offset = GET_BE_WORD(ssf1->Coverage);
|
|
|
|
TRACE(" subtype 1, delta %i\n", GET_BE_WORD(ssf1->DeltaGlyphID));
|
2010-03-27 11:56:11 +01:00
|
|
|
if (GSUB_is_glyph_covered((const BYTE*)ssf1+offset, glyph) != -1)
|
2008-03-13 10:40:58 +01:00
|
|
|
{
|
|
|
|
TRACE(" Glyph 0x%x ->",glyph);
|
|
|
|
glyph += GET_BE_WORD(ssf1->DeltaGlyphID);
|
|
|
|
TRACE(" 0x%x\n",glyph);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const GSUB_SingleSubstFormat2 *ssf2;
|
|
|
|
INT index;
|
|
|
|
INT offset;
|
|
|
|
|
2010-03-27 11:56:11 +01:00
|
|
|
ssf2 = (const GSUB_SingleSubstFormat2 *)ssf1;
|
2008-03-13 10:40:58 +01:00
|
|
|
offset = GET_BE_WORD(ssf1->Coverage);
|
|
|
|
TRACE(" subtype 2, glyph count %i\n", GET_BE_WORD(ssf2->GlyphCount));
|
2010-03-27 11:56:11 +01:00
|
|
|
index = GSUB_is_glyph_covered((const BYTE*)ssf2+offset, glyph);
|
2008-03-13 10:40:58 +01:00
|
|
|
TRACE(" Coverage index %i\n",index);
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
TRACE(" Glyph is 0x%x ->",glyph);
|
|
|
|
glyph = GET_BE_WORD(ssf2->Substitute[index]);
|
|
|
|
TRACE("0x%x\n",glyph);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return glyph;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* get_opentype_script(const GdiFont *font)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* I am not sure if this is the correct way to generate our script tag
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (font->charset)
|
|
|
|
{
|
|
|
|
case ANSI_CHARSET: return "latn";
|
|
|
|
case BALTIC_CHARSET: return "latn"; /* ?? */
|
|
|
|
case CHINESEBIG5_CHARSET: return "hani";
|
|
|
|
case EASTEUROPE_CHARSET: return "latn"; /* ?? */
|
|
|
|
case GB2312_CHARSET: return "hani";
|
|
|
|
case GREEK_CHARSET: return "grek";
|
|
|
|
case HANGUL_CHARSET: return "hang";
|
|
|
|
case RUSSIAN_CHARSET: return "cyrl";
|
|
|
|
case SHIFTJIS_CHARSET: return "kana";
|
|
|
|
case TURKISH_CHARSET: return "latn"; /* ?? */
|
|
|
|
case VIETNAMESE_CHARSET: return "latn";
|
|
|
|
case JOHAB_CHARSET: return "latn"; /* ?? */
|
|
|
|
case ARABIC_CHARSET: return "arab";
|
|
|
|
case HEBREW_CHARSET: return "hebr";
|
|
|
|
case THAI_CHARSET: return "thai";
|
|
|
|
default: return "latn";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static FT_UInt get_GSUB_vert_glyph(const GdiFont *font, UINT glyph)
|
|
|
|
{
|
|
|
|
const GSUB_Header *header;
|
|
|
|
const GSUB_Script *script;
|
|
|
|
const GSUB_LangSys *language;
|
|
|
|
const GSUB_Feature *feature;
|
|
|
|
|
|
|
|
if (!font->GSUB_Table)
|
|
|
|
return glyph;
|
|
|
|
|
|
|
|
header = font->GSUB_Table;
|
|
|
|
|
|
|
|
script = GSUB_get_script_table(header, get_opentype_script(font));
|
|
|
|
if (!script)
|
|
|
|
{
|
|
|
|
TRACE("Script not found\n");
|
|
|
|
return glyph;
|
|
|
|
}
|
|
|
|
language = GSUB_get_lang_table(script, "xxxx"); /* Need to get Lang tag */
|
|
|
|
if (!language)
|
|
|
|
{
|
|
|
|
TRACE("Language not found\n");
|
|
|
|
return glyph;
|
|
|
|
}
|
|
|
|
feature = GSUB_get_feature(header, language, "vrt2");
|
|
|
|
if (!feature)
|
|
|
|
feature = GSUB_get_feature(header, language, "vert");
|
|
|
|
if (!feature)
|
|
|
|
{
|
|
|
|
TRACE("vrt2/vert feature not found\n");
|
|
|
|
return glyph;
|
|
|
|
}
|
|
|
|
return GSUB_apply_feature(header, feature, glyph);
|
|
|
|
}
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
static FT_UInt get_glyph_index(const GdiFont *font, UINT glyph)
|
2002-01-29 04:02:50 +01:00
|
|
|
{
|
2008-03-13 10:40:58 +01:00
|
|
|
FT_UInt glyphId;
|
|
|
|
|
2004-08-26 20:24:03 +02:00
|
|
|
if(font->ft_face->charmap->encoding == FT_ENCODING_NONE) {
|
|
|
|
WCHAR wc = (WCHAR)glyph;
|
2005-09-07 13:27:05 +02:00
|
|
|
BOOL default_used;
|
2006-01-13 14:25:16 +01:00
|
|
|
BOOL *default_used_pointer;
|
2005-09-07 13:27:05 +02:00
|
|
|
FT_UInt ret;
|
2005-07-05 13:02:37 +02:00
|
|
|
char buf;
|
2006-01-13 14:25:16 +01:00
|
|
|
default_used_pointer = NULL;
|
|
|
|
default_used = FALSE;
|
|
|
|
if (codepage_sets_default_used(font->codepage))
|
|
|
|
default_used_pointer = &default_used;
|
|
|
|
if(!WideCharToMultiByte(font->codepage, 0, &wc, 1, &buf, sizeof(buf), NULL, default_used_pointer) || default_used)
|
2005-09-07 13:27:05 +02:00
|
|
|
ret = 0;
|
|
|
|
else
|
|
|
|
ret = pFT_Get_Char_Index(font->ft_face, (unsigned char)buf);
|
|
|
|
TRACE("%04x (%02x) -> ret %d def_used %d\n", glyph, buf, ret, default_used);
|
2008-03-13 10:40:58 +01:00
|
|
|
return get_GSUB_vert_glyph(font,ret);
|
2004-08-26 20:24:03 +02:00
|
|
|
}
|
|
|
|
|
2011-05-11 18:01:59 +02:00
|
|
|
if(font->ft_face->charmap->encoding == FT_ENCODING_MS_SYMBOL)
|
2011-05-06 19:32:03 +02:00
|
|
|
{
|
2011-05-11 18:01:59 +02:00
|
|
|
if (glyph < 0x100) glyph += 0xf000;
|
2011-05-06 19:32:03 +02:00
|
|
|
/* there is a number of old pre-Unicode "broken" TTFs, which
|
|
|
|
do have symbols at U+00XX instead of U+f0XX */
|
2011-05-11 18:01:59 +02:00
|
|
|
if (!(glyphId = pFT_Get_Char_Index(font->ft_face, glyph)))
|
|
|
|
glyphId = pFT_Get_Char_Index(font->ft_face, glyph-0xf000);
|
2011-05-06 19:32:03 +02:00
|
|
|
}
|
|
|
|
else glyphId = pFT_Get_Char_Index(font->ft_face, glyph);
|
|
|
|
|
2008-03-13 10:40:58 +01:00
|
|
|
return get_GSUB_vert_glyph(font,glyphId);
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
|
|
|
|
2002-04-03 22:41:14 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetGlyphIndices
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
|
2002-04-03 22:41:14 +02:00
|
|
|
LPWORD pgi, DWORD flags)
|
|
|
|
{
|
2006-08-23 16:49:13 +02:00
|
|
|
int i;
|
2011-09-28 14:46:48 +02:00
|
|
|
WORD default_char;
|
|
|
|
BOOL got_default = FALSE;
|
2006-08-23 16:49:13 +02:00
|
|
|
|
2011-09-28 14:46:48 +02:00
|
|
|
if (flags & GGI_MARK_NONEXISTING_GLYPHS)
|
|
|
|
{
|
|
|
|
default_char = 0xffff; /* XP would use 0x1f for bitmap fonts */
|
|
|
|
got_default = TRUE;
|
|
|
|
}
|
2002-04-03 22:41:14 +02:00
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
2006-08-23 16:49:13 +02:00
|
|
|
{
|
2002-04-03 22:41:14 +02:00
|
|
|
pgi[i] = get_glyph_index(font, lpstr[i]);
|
2006-08-23 16:49:13 +02:00
|
|
|
if (pgi[i] == 0)
|
|
|
|
{
|
2011-09-28 14:46:48 +02:00
|
|
|
if (!got_default)
|
2006-08-23 16:49:13 +02:00
|
|
|
{
|
2008-03-30 21:43:15 +02:00
|
|
|
if (FT_IS_SFNT(font->ft_face))
|
|
|
|
{
|
|
|
|
TT_OS2 *pOS2 = pFT_Get_Sfnt_Table(font->ft_face, ft_sfnt_os2);
|
|
|
|
default_char = (pOS2->usDefaultChar ? get_glyph_index(font, pOS2->usDefaultChar) : 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TEXTMETRICW textm;
|
|
|
|
WineEngGetTextMetrics(font, &textm);
|
|
|
|
default_char = textm.tmDefaultChar;
|
|
|
|
}
|
2011-09-28 14:46:48 +02:00
|
|
|
got_default = TRUE;
|
2006-08-23 16:49:13 +02:00
|
|
|
}
|
|
|
|
pgi[i] = default_char;
|
|
|
|
}
|
|
|
|
}
|
2002-04-03 22:41:14 +02:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2008-06-24 09:11:40 +02:00
|
|
|
static inline BOOL is_identity_FMAT2(const FMAT2 *matrix)
|
|
|
|
{
|
|
|
|
static const FMAT2 identity = { 1.0, 0.0, 0.0, 1.0 };
|
|
|
|
return !memcmp(matrix, &identity, sizeof(FMAT2));
|
|
|
|
}
|
|
|
|
|
2008-06-24 09:11:57 +02:00
|
|
|
static inline BOOL is_identity_MAT2(const MAT2 *matrix)
|
|
|
|
{
|
|
|
|
static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
|
|
|
|
return !memcmp(matrix, &identity, sizeof(MAT2));
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
*/
|
2007-05-02 18:15:12 +02:00
|
|
|
DWORD WineEngGetGlyphOutline(GdiFont *incoming_font, UINT glyph, UINT format,
|
2001-09-12 22:21:06 +02:00
|
|
|
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)};
|
2007-05-02 18:15:12 +02:00
|
|
|
FT_Face ft_face = incoming_font->ft_face;
|
|
|
|
GdiFont *font = incoming_font;
|
2001-09-12 22:21:06 +02:00
|
|
|
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;
|
2007-10-02 12:56:54 +02:00
|
|
|
INT left, right, top = 0, bottom = 0, adv, lsb, bbx;
|
2002-01-29 04:02:50 +01:00
|
|
|
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;
|
2008-06-24 09:10:27 +02:00
|
|
|
double widthRatio = 1.0;
|
2003-10-10 02:06:35 +02:00
|
|
|
FT_Matrix transMat = identityMat;
|
2008-07-22 02:54:42 +02:00
|
|
|
FT_Matrix transMatUnrotated;
|
2003-10-10 02:06:35 +02:00
|
|
|
BOOL needsTransform = FALSE;
|
2008-03-13 10:40:58 +01:00
|
|
|
BOOL tategaki = (font->GSUB_Table != NULL);
|
|
|
|
UINT original_index;
|
2003-10-10 02:06:35 +02:00
|
|
|
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("%p, %04x, %08x, %p, %08x, %p, %p\n", font, glyph, format, lpgm,
|
2001-09-12 22:21:06 +02:00
|
|
|
buflen, buf, lpmat);
|
|
|
|
|
2008-06-24 09:10:27 +02:00
|
|
|
TRACE("font transform %f %f %f %f\n",
|
|
|
|
font->font_desc.matrix.eM11, font->font_desc.matrix.eM12,
|
|
|
|
font->font_desc.matrix.eM21, font->font_desc.matrix.eM22);
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
if(format & GGO_GLYPH_INDEX) {
|
2008-03-13 10:40:58 +01:00
|
|
|
glyph_index = get_GSUB_vert_glyph(incoming_font,glyph);
|
|
|
|
original_index = glyph;
|
2002-01-29 04:02:50 +01:00
|
|
|
format &= ~GGO_GLYPH_INDEX;
|
2007-05-02 18:15:12 +02:00
|
|
|
} else {
|
|
|
|
get_glyph_index_linked(incoming_font, glyph, &font, &glyph_index);
|
|
|
|
ft_face = font->ft_face;
|
2008-03-13 10:40:58 +01:00
|
|
|
original_index = glyph_index;
|
2007-05-02 18:15:12 +02:00
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2008-10-26 23:20:13 +01:00
|
|
|
if(format & GGO_UNHINTED) {
|
|
|
|
load_flags |= FT_LOAD_NO_HINTING;
|
|
|
|
format &= ~GGO_UNHINTED;
|
|
|
|
}
|
|
|
|
|
2008-03-13 10:40:58 +01:00
|
|
|
/* tategaki never appears to happen to lower glyph index */
|
|
|
|
if (glyph_index < TATEGAKI_LOWER_BOUND )
|
|
|
|
tategaki = FALSE;
|
|
|
|
|
|
|
|
if(original_index >= font->gmsize * GM_BLOCK_SIZE) {
|
|
|
|
font->gmsize = (original_index / GM_BLOCK_SIZE + 1);
|
2002-01-29 04:02:50 +01:00
|
|
|
font->gm = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, font->gm,
|
2007-08-30 12:17:23 +02:00
|
|
|
font->gmsize * sizeof(GM*));
|
2002-01-29 04:02:50 +01:00
|
|
|
} else {
|
2008-06-24 09:12:32 +02:00
|
|
|
if (format == GGO_METRICS && font->gm[original_index / GM_BLOCK_SIZE] != NULL &&
|
2009-02-03 10:55:19 +01:00
|
|
|
FONT_GM(font,original_index)->init && is_identity_MAT2(lpmat))
|
2008-06-24 09:12:32 +02:00
|
|
|
{
|
2008-03-13 10:40:58 +01:00
|
|
|
*lpgm = FONT_GM(font,original_index)->gm;
|
2008-06-24 09:12:32 +02:00
|
|
|
TRACE("cached: %u,%u,%s,%d,%d\n", lpgm->gmBlackBoxX, lpgm->gmBlackBoxY,
|
|
|
|
wine_dbgstr_point(&lpgm->gmptGlyphOrigin),
|
|
|
|
lpgm->gmCellIncX, lpgm->gmCellIncY);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-01-29 04:02:50 +01:00
|
|
|
return 1; /* FIXME */
|
|
|
|
}
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2008-03-13 10:40:58 +01:00
|
|
|
if (!font->gm[original_index / GM_BLOCK_SIZE])
|
|
|
|
font->gm[original_index / GM_BLOCK_SIZE] = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, sizeof(GM) * GM_BLOCK_SIZE);
|
2007-08-30 12:17:23 +02:00
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
/* Scaling factor */
|
2008-06-24 09:15:48 +02:00
|
|
|
if (font->aveWidth)
|
2008-01-08 16:02:09 +01:00
|
|
|
{
|
2008-06-24 09:15:48 +02:00
|
|
|
TEXTMETRICW tm;
|
|
|
|
|
|
|
|
WineEngGetTextMetrics(font, &tm);
|
|
|
|
|
2008-06-24 09:11:40 +02:00
|
|
|
widthRatio = (double)font->aveWidth;
|
2008-06-24 09:10:27 +02:00
|
|
|
widthRatio /= (double)font->potm->otmTextMetrics.tmAveCharWidth;
|
2003-10-10 02:06:35 +02:00
|
|
|
}
|
2008-01-20 14:21:45 +01:00
|
|
|
else
|
|
|
|
widthRatio = font->scale_y;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
/* Scaling transform */
|
2008-06-24 09:11:21 +02:00
|
|
|
if (widthRatio != 1.0 || font->scale_y != 1.0)
|
|
|
|
{
|
2003-10-10 02:06:35 +02:00
|
|
|
FT_Matrix scaleMat;
|
|
|
|
scaleMat.xx = FT_FixedFromFloat(widthRatio);
|
|
|
|
scaleMat.xy = 0;
|
|
|
|
scaleMat.yx = 0;
|
2008-01-20 14:21:45 +01:00
|
|
|
scaleMat.yy = FT_FixedFromFloat(font->scale_y);
|
2003-10-10 02:06:35 +02:00
|
|
|
|
|
|
|
pFT_Matrix_Multiply(&scaleMat, &transMat);
|
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-02 13:41:54 +01:00
|
|
|
/* Slant transform */
|
|
|
|
if (font->fake_italic) {
|
|
|
|
FT_Matrix slantMat;
|
|
|
|
|
|
|
|
slantMat.xx = (1 << 16);
|
|
|
|
slantMat.xy = ((1 << 16) >> 2);
|
|
|
|
slantMat.yx = 0;
|
|
|
|
slantMat.yy = (1 << 16);
|
|
|
|
pFT_Matrix_Multiply(&slantMat, &transMat);
|
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
/* Rotation transform */
|
2008-07-22 02:54:42 +02:00
|
|
|
transMatUnrotated = transMat;
|
2008-03-13 10:40:58 +01:00
|
|
|
if(font->orientation && !tategaki) {
|
2003-10-10 02:06:35 +02:00
|
|
|
FT_Matrix rotationMat;
|
|
|
|
FT_Vector vecAngle;
|
2008-06-24 09:10:27 +02:00
|
|
|
angle = FT_FixedFromFloat((double)font->orientation / 10.0);
|
2003-10-10 02:06:35 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-06-24 09:11:40 +02:00
|
|
|
/* World transform */
|
|
|
|
if (!is_identity_FMAT2(&font->font_desc.matrix))
|
|
|
|
{
|
|
|
|
FT_Matrix worldMat;
|
|
|
|
worldMat.xx = FT_FixedFromFloat(font->font_desc.matrix.eM11);
|
2009-03-02 10:23:31 +01:00
|
|
|
worldMat.xy = FT_FixedFromFloat(font->font_desc.matrix.eM12);
|
|
|
|
worldMat.yx = FT_FixedFromFloat(font->font_desc.matrix.eM21);
|
2008-06-24 09:11:40 +02:00
|
|
|
worldMat.yy = FT_FixedFromFloat(font->font_desc.matrix.eM22);
|
|
|
|
pFT_Matrix_Multiply(&worldMat, &transMat);
|
2008-07-22 02:54:42 +02:00
|
|
|
pFT_Matrix_Multiply(&worldMat, &transMatUnrotated);
|
2008-06-24 09:11:40 +02:00
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
/* Extra transformation specified by caller */
|
2009-02-03 10:55:19 +01:00
|
|
|
if (!is_identity_MAT2(lpmat))
|
2008-06-24 09:11:57 +02:00
|
|
|
{
|
2003-10-10 02:06:35 +02:00
|
|
|
FT_Matrix extraMat;
|
|
|
|
extraMat.xx = FT_FixedFromFIXED(lpmat->eM11);
|
2009-03-02 10:23:31 +01:00
|
|
|
extraMat.xy = FT_FixedFromFIXED(lpmat->eM12);
|
|
|
|
extraMat.yx = FT_FixedFromFIXED(lpmat->eM21);
|
2003-10-10 02:06:35 +02:00
|
|
|
extraMat.yy = FT_FixedFromFIXED(lpmat->eM22);
|
|
|
|
pFT_Matrix_Multiply(&extraMat, &transMat);
|
2008-07-22 02:54:42 +02:00
|
|
|
pFT_Matrix_Multiply(&extraMat, &transMatUnrotated);
|
2003-10-10 02:06:35 +02:00
|
|
|
needsTransform = TRUE;
|
|
|
|
}
|
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
if (needsTransform || (format == GGO_NATIVE || format == GGO_BEZIER ||
|
|
|
|
format == GGO_GRAY2_BITMAP || format == GGO_GRAY4_BITMAP ||
|
|
|
|
format == GGO_GRAY8_BITMAP))
|
|
|
|
{
|
2008-08-21 08:01:05 +02:00
|
|
|
load_flags |= FT_LOAD_NO_BITMAP;
|
2008-12-10 15:50:44 +01:00
|
|
|
}
|
2008-08-21 08:01:05 +02:00
|
|
|
|
|
|
|
err = pFT_Load_Glyph(ft_face, glyph_index, load_flags);
|
|
|
|
|
|
|
|
if(err) {
|
|
|
|
WARN("FT_Load_Glyph on index %x returns %d\n", glyph_index, err);
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
2003-10-10 02:06:35 +02:00
|
|
|
if(!needsTransform) {
|
2010-07-28 10:07:09 +02:00
|
|
|
left = (INT)(ft_face->glyph->metrics.horiBearingX) & -64;
|
|
|
|
right = (INT)((ft_face->glyph->metrics.horiBearingX + ft_face->glyph->metrics.width) + 63) & -64;
|
|
|
|
adv = (INT)(ft_face->glyph->metrics.horiAdvance + 63) >> 6;
|
|
|
|
|
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;
|
2007-10-02 12:56:54 +02:00
|
|
|
lpgm->gmCellIncX = adv;
|
2002-01-29 04:02:50 +01:00
|
|
|
lpgm->gmCellIncY = 0;
|
|
|
|
} else {
|
|
|
|
INT xc, yc;
|
|
|
|
FT_Vector vec;
|
2010-07-28 10:07:09 +02:00
|
|
|
|
|
|
|
left = right = 0;
|
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
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);
|
2008-07-22 02:54:42 +02:00
|
|
|
lpgm->gmCellIncX = (vec.x+63) >> 6;
|
2003-10-10 02:06:35 +02:00
|
|
|
lpgm->gmCellIncY = -((vec.y+63) >> 6);
|
2008-07-22 02:54:42 +02:00
|
|
|
|
|
|
|
vec.x = ft_face->glyph->metrics.horiAdvance;
|
|
|
|
vec.y = 0;
|
|
|
|
pFT_Vector_Transform(&vec, &transMatUnrotated);
|
|
|
|
adv = (vec.x+63) >> 6;
|
2002-01-29 04:02:50 +01:00
|
|
|
}
|
2010-07-28 10:07:09 +02:00
|
|
|
|
|
|
|
lsb = left >> 6;
|
|
|
|
bbx = (right - left) >> 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;
|
|
|
|
|
2008-06-24 09:12:14 +02:00
|
|
|
TRACE("%u,%u,%s,%d,%d\n", lpgm->gmBlackBoxX, lpgm->gmBlackBoxY,
|
|
|
|
wine_dbgstr_point(&lpgm->gmptGlyphOrigin),
|
|
|
|
lpgm->gmCellIncX, lpgm->gmCellIncY);
|
|
|
|
|
2008-12-24 03:16:04 +01:00
|
|
|
if ((format == GGO_METRICS || format == GGO_BITMAP || format == WINE_GGO_GRAY16_BITMAP) &&
|
2009-02-03 10:55:19 +01:00
|
|
|
is_identity_MAT2(lpmat)) /* don't cache custom transforms */
|
2007-10-02 12:56:54 +02:00
|
|
|
{
|
2008-03-13 10:40:58 +01:00
|
|
|
FONT_GM(font,original_index)->gm = *lpgm;
|
|
|
|
FONT_GM(font,original_index)->adv = adv;
|
|
|
|
FONT_GM(font,original_index)->lsb = lsb;
|
|
|
|
FONT_GM(font,original_index)->bbx = bbx;
|
|
|
|
FONT_GM(font,original_index)->init = TRUE;
|
2007-10-02 12:56:54 +02:00
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
if(format == GGO_METRICS)
|
2008-02-05 21:16:06 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-01-29 04:02:50 +01:00
|
|
|
return 1; /* FIXME */
|
2008-02-05 21:16:06 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
if(ft_face->glyph->format != ft_glyph_format_outline &&
|
2009-02-27 10:57:39 +01:00
|
|
|
(format == GGO_NATIVE || format == GGO_BEZIER ||
|
|
|
|
format == GGO_GRAY2_BITMAP || format == GGO_GRAY4_BITMAP ||
|
|
|
|
format == GGO_GRAY8_BITMAP))
|
2008-12-10 15:50:44 +01:00
|
|
|
{
|
2004-06-16 22:06:26 +02:00
|
|
|
TRACE("loaded a bitmap\n");
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
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;
|
|
|
|
|
2008-11-01 10:44:05 +01:00
|
|
|
if(needsTransform)
|
|
|
|
pFT_Outline_Transform(&ft_face->glyph->outline, &transMat);
|
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);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-06-22 03:19:29 +02:00
|
|
|
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;
|
|
|
|
|
2007-10-02 15:24:34 +02:00
|
|
|
switch(ft_face->glyph->format) {
|
|
|
|
case ft_glyph_format_bitmap:
|
|
|
|
{
|
|
|
|
BYTE *src = ft_face->glyph->bitmap.buffer, *dst = buf;
|
|
|
|
INT h = ft_face->glyph->bitmap.rows;
|
|
|
|
INT x;
|
2011-04-08 12:38:32 +02:00
|
|
|
memset( buf, 0, needed );
|
2007-10-02 15:24:34 +02:00
|
|
|
while(h--) {
|
2011-04-08 12:38:32 +02:00
|
|
|
for(x = 0; x < pitch && x < ft_face->glyph->bitmap.width; x++)
|
|
|
|
if (src[x / 8] & (1 << ( (7 - (x % 8))))) dst[x] = 0xff;
|
2007-10-02 15:24:34 +02:00
|
|
|
src += ft_face->glyph->bitmap.pitch;
|
|
|
|
dst += pitch;
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2007-10-02 15:24:34 +02:00
|
|
|
return needed;
|
|
|
|
}
|
|
|
|
case ft_glyph_format_outline:
|
|
|
|
{
|
|
|
|
ft_bitmap.width = width;
|
|
|
|
ft_bitmap.rows = height;
|
|
|
|
ft_bitmap.pitch = pitch;
|
|
|
|
ft_bitmap.pixel_mode = ft_pixel_mode_grays;
|
|
|
|
ft_bitmap.buffer = buf;
|
|
|
|
|
|
|
|
if(needsTransform)
|
|
|
|
pFT_Outline_Transform(&ft_face->glyph->outline, &transMat);
|
|
|
|
|
|
|
|
pFT_Outline_Translate(&ft_face->glyph->outline, -left, -bottom );
|
|
|
|
|
|
|
|
memset(ft_bitmap.buffer, 0, buflen);
|
|
|
|
|
|
|
|
pFT_Outline_Get_Bitmap(library, &ft_face->glyph->outline, &ft_bitmap);
|
|
|
|
|
|
|
|
if(format == GGO_GRAY2_BITMAP)
|
|
|
|
mult = 4;
|
|
|
|
else if(format == GGO_GRAY4_BITMAP)
|
|
|
|
mult = 16;
|
|
|
|
else if(format == GGO_GRAY8_BITMAP)
|
|
|
|
mult = 64;
|
2007-10-14 13:52:00 +02:00
|
|
|
else /* format == WINE_GGO_GRAY16_BITMAP */
|
2008-02-05 21:16:06 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2007-10-02 15:24:34 +02:00
|
|
|
return needed;
|
2008-02-05 21:16:06 +01:00
|
|
|
}
|
2007-10-04 13:22:37 +02:00
|
|
|
break;
|
2007-10-02 15:24:34 +02:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("loaded glyph format %x\n", ft_face->glyph->format);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2007-10-02 15:24:34 +02:00
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2002-01-29 04:02:50 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
case WINE_GGO_HRGB_BITMAP:
|
|
|
|
case WINE_GGO_HBGR_BITMAP:
|
|
|
|
case WINE_GGO_VRGB_BITMAP:
|
|
|
|
case WINE_GGO_VBGR_BITMAP:
|
2008-12-23 12:34:01 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTLCDFIL_H
|
2008-12-10 15:50:44 +01:00
|
|
|
{
|
|
|
|
switch (ft_face->glyph->format)
|
|
|
|
{
|
|
|
|
case FT_GLYPH_FORMAT_BITMAP:
|
|
|
|
{
|
2008-12-24 03:16:04 +01:00
|
|
|
BYTE *src, *dst;
|
|
|
|
INT src_pitch, x;
|
|
|
|
|
|
|
|
width = lpgm->gmBlackBoxX;
|
|
|
|
height = lpgm->gmBlackBoxY;
|
|
|
|
pitch = width * 4;
|
|
|
|
needed = pitch * height;
|
|
|
|
|
|
|
|
if (!buf || !buflen) break;
|
|
|
|
|
|
|
|
memset(buf, 0, buflen);
|
|
|
|
dst = buf;
|
|
|
|
src = ft_face->glyph->bitmap.buffer;
|
|
|
|
src_pitch = ft_face->glyph->bitmap.pitch;
|
2008-12-10 15:50:44 +01:00
|
|
|
|
2011-04-08 12:38:32 +02:00
|
|
|
height = min( height, ft_face->glyph->bitmap.rows );
|
2008-12-10 15:50:44 +01:00
|
|
|
while ( height-- )
|
|
|
|
{
|
2011-04-08 12:38:32 +02:00
|
|
|
for (x = 0; x < width && x < ft_face->glyph->bitmap.width; x++)
|
2008-12-10 15:50:44 +01:00
|
|
|
{
|
|
|
|
if ( src[x / 8] & (1 << ( (7 - (x % 8)))) )
|
|
|
|
((unsigned int *)dst)[x] = ~0u;
|
|
|
|
}
|
|
|
|
src += src_pitch;
|
|
|
|
dst += pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FT_GLYPH_FORMAT_OUTLINE:
|
|
|
|
{
|
2008-12-24 03:16:04 +01:00
|
|
|
unsigned int *dst;
|
2008-12-10 15:50:44 +01:00
|
|
|
BYTE *src;
|
2008-12-27 09:56:32 +01:00
|
|
|
INT x, src_pitch, src_width, src_height, rgb_interval, hmul, vmul;
|
|
|
|
INT x_shift, y_shift;
|
2008-12-24 03:16:04 +01:00
|
|
|
BOOL rgb;
|
2008-12-10 15:50:44 +01:00
|
|
|
FT_LcdFilter lcdfilter = FT_LCD_FILTER_DEFAULT;
|
|
|
|
FT_Render_Mode render_mode =
|
|
|
|
(format == WINE_GGO_HRGB_BITMAP || format == WINE_GGO_HBGR_BITMAP)?
|
|
|
|
FT_RENDER_MODE_LCD: FT_RENDER_MODE_LCD_V;
|
|
|
|
|
2008-12-24 03:16:04 +01:00
|
|
|
if ( lcdfilter == FT_LCD_FILTER_DEFAULT || lcdfilter == FT_LCD_FILTER_LIGHT )
|
|
|
|
{
|
|
|
|
if ( render_mode == FT_RENDER_MODE_LCD)
|
|
|
|
{
|
|
|
|
lpgm->gmBlackBoxX += 2;
|
|
|
|
lpgm->gmptGlyphOrigin.x -= 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lpgm->gmBlackBoxY += 2;
|
|
|
|
lpgm->gmptGlyphOrigin.y += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
width = lpgm->gmBlackBoxX;
|
|
|
|
height = lpgm->gmBlackBoxY;
|
|
|
|
pitch = width * 4;
|
|
|
|
needed = pitch * height;
|
|
|
|
|
|
|
|
if (!buf || !buflen) break;
|
|
|
|
|
|
|
|
memset(buf, 0, buflen);
|
2009-01-26 11:01:12 +01:00
|
|
|
dst = buf;
|
2008-12-24 03:16:04 +01:00
|
|
|
rgb = (format == WINE_GGO_HRGB_BITMAP || format == WINE_GGO_VRGB_BITMAP);
|
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
if ( needsTransform )
|
|
|
|
pFT_Outline_Transform (&ft_face->glyph->outline, &transMat);
|
2008-12-27 09:56:32 +01:00
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
if ( pFT_Library_SetLcdFilter )
|
|
|
|
pFT_Library_SetLcdFilter( library, lcdfilter );
|
|
|
|
pFT_Render_Glyph (ft_face->glyph, render_mode);
|
|
|
|
|
|
|
|
src = ft_face->glyph->bitmap.buffer;
|
|
|
|
src_pitch = ft_face->glyph->bitmap.pitch;
|
2008-12-27 09:56:32 +01:00
|
|
|
src_width = ft_face->glyph->bitmap.width;
|
|
|
|
src_height = ft_face->glyph->bitmap.rows;
|
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
if ( render_mode == FT_RENDER_MODE_LCD)
|
|
|
|
{
|
|
|
|
rgb_interval = 1;
|
|
|
|
hmul = 3;
|
|
|
|
vmul = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rgb_interval = src_pitch;
|
|
|
|
hmul = 1;
|
|
|
|
vmul = 3;
|
|
|
|
}
|
|
|
|
|
2008-12-27 09:56:32 +01:00
|
|
|
x_shift = ft_face->glyph->bitmap_left - lpgm->gmptGlyphOrigin.x;
|
|
|
|
if ( x_shift < 0 ) x_shift = 0;
|
|
|
|
if ( x_shift + (src_width / hmul) > width )
|
|
|
|
x_shift = width - (src_width / hmul);
|
|
|
|
|
|
|
|
y_shift = lpgm->gmptGlyphOrigin.y - ft_face->glyph->bitmap_top;
|
|
|
|
if ( y_shift < 0 ) y_shift = 0;
|
|
|
|
if ( y_shift + (src_height / vmul) > height )
|
|
|
|
y_shift = height - (src_height / vmul);
|
|
|
|
|
|
|
|
dst += x_shift + y_shift * ( pitch / 4 );
|
|
|
|
while ( src_height )
|
2008-12-10 15:50:44 +01:00
|
|
|
{
|
2008-12-27 09:56:32 +01:00
|
|
|
for ( x = 0; x < src_width / hmul; x++ )
|
2008-12-10 15:50:44 +01:00
|
|
|
{
|
|
|
|
if ( rgb )
|
|
|
|
{
|
2010-05-28 00:09:21 +02:00
|
|
|
dst[x] = ((unsigned int)src[hmul * x + rgb_interval * 0] << 16) |
|
|
|
|
((unsigned int)src[hmul * x + rgb_interval * 1] << 8) |
|
|
|
|
((unsigned int)src[hmul * x + rgb_interval * 2] << 0) |
|
|
|
|
((unsigned int)src[hmul * x + rgb_interval * 1] << 24) ;
|
2008-12-10 15:50:44 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-28 00:09:21 +02:00
|
|
|
dst[x] = ((unsigned int)src[hmul * x + rgb_interval * 2] << 16) |
|
|
|
|
((unsigned int)src[hmul * x + rgb_interval * 1] << 8) |
|
|
|
|
((unsigned int)src[hmul * x + rgb_interval * 0] << 0) |
|
|
|
|
((unsigned int)src[hmul * x + rgb_interval * 1] << 24) ;
|
2008-12-10 15:50:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
src += src_pitch * vmul;
|
|
|
|
dst += pitch / 4;
|
2008-12-27 09:56:32 +01:00
|
|
|
src_height -= vmul;
|
2008-12-10 15:50:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME ("loaded glyph format %x\n", ft_face->glyph->format);
|
|
|
|
LeaveCriticalSection ( &freetype_cs );
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2008-12-23 12:34:01 +01:00
|
|
|
#else
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return GDI_ERROR;
|
|
|
|
#endif
|
2008-12-10 15:50:44 +01:00
|
|
|
|
2002-01-29 04:02:50 +01:00
|
|
|
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
|
|
|
|
|
2011-07-27 13:38:43 +02:00
|
|
|
A quadratic Bezier has the form:
|
2002-06-22 03:19:29 +02:00
|
|
|
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);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2001-09-12 22:21:06 +02:00
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-01-29 04:02:50 +01:00
|
|
|
return needed;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static BOOL get_bitmap_text_metrics(GdiFont *font)
|
2004-06-16 22:06:26 +02:00
|
|
|
{
|
|
|
|
FT_Face ft_face = font->ft_face;
|
|
|
|
FT_WinFNT_HeaderRec winfnt_header;
|
|
|
|
const DWORD size = offsetof(OUTLINETEXTMETRICW, otmFiller);
|
|
|
|
font->potm = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
font->potm->otmSize = size;
|
|
|
|
|
|
|
|
#define TM font->potm->otmTextMetrics
|
2011-10-11 11:14:56 +02:00
|
|
|
if(!pFT_Get_WinFNT_Header(ft_face, &winfnt_header))
|
2004-06-16 22:06:26 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-01-08 16:02:09 +01:00
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
static void scale_font_metrics(const GdiFont *font, LPTEXTMETRICW ptm)
|
2008-01-08 16:02:09 +01:00
|
|
|
{
|
2008-06-24 09:11:40 +02:00
|
|
|
double scale_x, scale_y;
|
2008-01-08 16:02:09 +01:00
|
|
|
|
2008-01-20 14:21:45 +01:00
|
|
|
if (font->aveWidth)
|
|
|
|
{
|
2008-06-24 09:11:40 +02:00
|
|
|
scale_x = (double)font->aveWidth;
|
2008-06-24 09:10:27 +02:00
|
|
|
scale_x /= (double)font->potm->otmTextMetrics.tmAveCharWidth;
|
2008-01-08 16:02:09 +01:00
|
|
|
}
|
2008-01-20 14:21:45 +01:00
|
|
|
else
|
|
|
|
scale_x = font->scale_y;
|
|
|
|
|
2008-06-24 09:11:40 +02:00
|
|
|
scale_x *= fabs(font->font_desc.matrix.eM11);
|
|
|
|
scale_y = font->scale_y * fabs(font->font_desc.matrix.eM22);
|
|
|
|
|
|
|
|
#define SCALE_X(x) (x) = GDI_ROUND((double)(x) * (scale_x))
|
|
|
|
#define SCALE_Y(y) (y) = GDI_ROUND((double)(y) * (scale_y))
|
|
|
|
|
|
|
|
SCALE_Y(ptm->tmHeight);
|
|
|
|
SCALE_Y(ptm->tmAscent);
|
|
|
|
SCALE_Y(ptm->tmDescent);
|
|
|
|
SCALE_Y(ptm->tmInternalLeading);
|
|
|
|
SCALE_Y(ptm->tmExternalLeading);
|
|
|
|
SCALE_Y(ptm->tmOverhang);
|
|
|
|
|
|
|
|
SCALE_X(ptm->tmAveCharWidth);
|
|
|
|
SCALE_X(ptm->tmMaxCharWidth);
|
2008-01-08 16:02:09 +01:00
|
|
|
|
2008-06-24 09:11:40 +02:00
|
|
|
#undef SCALE_X
|
|
|
|
#undef SCALE_Y
|
2008-01-08 16:02:09 +01:00
|
|
|
}
|
|
|
|
|
2008-06-24 09:12:50 +02:00
|
|
|
static void scale_outline_font_metrics(const GdiFont *font, OUTLINETEXTMETRICW *potm)
|
|
|
|
{
|
|
|
|
double scale_x, scale_y;
|
|
|
|
|
|
|
|
if (font->aveWidth)
|
|
|
|
{
|
|
|
|
scale_x = (double)font->aveWidth;
|
|
|
|
scale_x /= (double)font->potm->otmTextMetrics.tmAveCharWidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scale_x = font->scale_y;
|
|
|
|
|
|
|
|
scale_x *= fabs(font->font_desc.matrix.eM11);
|
|
|
|
scale_y = font->scale_y * fabs(font->font_desc.matrix.eM22);
|
|
|
|
|
|
|
|
scale_font_metrics(font, &potm->otmTextMetrics);
|
|
|
|
|
|
|
|
#define SCALE_X(x) (x) = GDI_ROUND((double)(x) * (scale_x))
|
|
|
|
#define SCALE_Y(y) (y) = GDI_ROUND((double)(y) * (scale_y))
|
|
|
|
|
|
|
|
SCALE_Y(potm->otmAscent);
|
|
|
|
SCALE_Y(potm->otmDescent);
|
|
|
|
SCALE_Y(potm->otmLineGap);
|
|
|
|
SCALE_Y(potm->otmsCapEmHeight);
|
|
|
|
SCALE_Y(potm->otmsXHeight);
|
|
|
|
SCALE_Y(potm->otmrcFontBox.top);
|
|
|
|
SCALE_Y(potm->otmrcFontBox.bottom);
|
|
|
|
SCALE_X(potm->otmrcFontBox.left);
|
|
|
|
SCALE_X(potm->otmrcFontBox.right);
|
|
|
|
SCALE_Y(potm->otmMacAscent);
|
|
|
|
SCALE_Y(potm->otmMacDescent);
|
|
|
|
SCALE_Y(potm->otmMacLineGap);
|
|
|
|
SCALE_X(potm->otmptSubscriptSize.x);
|
|
|
|
SCALE_Y(potm->otmptSubscriptSize.y);
|
|
|
|
SCALE_X(potm->otmptSubscriptOffset.x);
|
|
|
|
SCALE_Y(potm->otmptSubscriptOffset.y);
|
|
|
|
SCALE_X(potm->otmptSuperscriptSize.x);
|
|
|
|
SCALE_Y(potm->otmptSuperscriptSize.y);
|
|
|
|
SCALE_X(potm->otmptSuperscriptOffset.x);
|
|
|
|
SCALE_Y(potm->otmptSuperscriptOffset.y);
|
|
|
|
SCALE_Y(potm->otmsStrikeoutSize);
|
|
|
|
SCALE_Y(potm->otmsStrikeoutPosition);
|
|
|
|
SCALE_Y(potm->otmsUnderscoreSize);
|
|
|
|
SCALE_Y(potm->otmsUnderscorePosition);
|
|
|
|
|
|
|
|
#undef SCALE_X
|
|
|
|
#undef SCALE_Y
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetTextMetrics
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetTextMetrics(GdiFont *font, LPTEXTMETRICW ptm)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
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))
|
2008-02-05 21:16:06 +01:00
|
|
|
{
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2004-06-16 22:06:26 +02:00
|
|
|
return FALSE;
|
2008-02-05 21:16:06 +01:00
|
|
|
}
|
2009-10-07 10:50:32 +02:00
|
|
|
|
|
|
|
/* Make sure that the font has sane width/height ratio */
|
|
|
|
if (font->aveWidth)
|
|
|
|
{
|
|
|
|
if ((font->aveWidth + font->potm->otmTextMetrics.tmHeight - 1) / font->potm->otmTextMetrics.tmHeight > 100)
|
|
|
|
{
|
|
|
|
WARN("Ignoring too large font->aveWidth %d\n", font->aveWidth);
|
|
|
|
font->aveWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
}
|
2009-10-07 10:50:32 +02:00
|
|
|
|
2008-02-27 22:21:10 +01:00
|
|
|
*ptm = font->potm->otmTextMetrics;
|
2008-01-08 16:02:09 +01:00
|
|
|
scale_font_metrics(font, ptm);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2009-02-18 11:33:12 +01:00
|
|
|
static BOOL face_has_symbol_charmap(FT_Face ft_face)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < ft_face->num_charmaps; i++)
|
|
|
|
{
|
|
|
|
if(ft_face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetOutlineTextMetrics
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
|
2001-09-12 22:21:06 +02:00
|
|
|
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;
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
if(font->potm) {
|
|
|
|
if(cbSize >= font->potm->otmSize)
|
2008-01-08 16:02:09 +01:00
|
|
|
{
|
2002-06-22 03:19:29 +02:00
|
|
|
memcpy(potm, font->potm, font->potm->otmSize);
|
2008-06-24 09:12:50 +02:00
|
|
|
scale_outline_font_metrics(font, potm);
|
2008-01-08 16:02:09 +01:00
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2002-06-22 03:19:29 +02:00
|
|
|
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,
|
2005-09-13 00:07:53 +02:00
|
|
|
style_nameW, lensty/sizeof(WCHAR));
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
/* These names should be read from the TT name table */
|
|
|
|
|
|
|
|
/* length of otmpFamilyName */
|
|
|
|
needed += lenfam;
|
|
|
|
|
|
|
|
/* length of otmpFaceName */
|
2008-06-19 23:57:46 +02:00
|
|
|
if ((ft_face->style_flags & (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD)) == 0) {
|
2001-09-12 22:21:06 +02:00
|
|
|
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;
|
2009-07-31 15:21:51 +02:00
|
|
|
TM.tmWeight = FW_REGULAR;
|
|
|
|
if (font->fake_bold)
|
|
|
|
TM.tmWeight = FW_BOLD;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ft_face->style_flags & FT_STYLE_FLAG_BOLD)
|
|
|
|
{
|
|
|
|
if (pOS2->usWeightClass > FW_MEDIUM)
|
|
|
|
TM.tmWeight = pOS2->usWeightClass;
|
|
|
|
}
|
|
|
|
else if (pOS2->usWeightClass <= FW_MEDIUM)
|
|
|
|
TM.tmWeight = pOS2->usWeightClass;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
TM.tmOverhang = 0;
|
|
|
|
TM.tmDigitizedAspectX = 300;
|
|
|
|
TM.tmDigitizedAspectY = 300;
|
2007-03-15 07:12:09 +01:00
|
|
|
/* It appears that for fonts with SYMBOL_CHARSET Windows always sets
|
|
|
|
* symbol range to 0 - f0ff
|
|
|
|
*/
|
2009-02-18 11:33:12 +01:00
|
|
|
|
|
|
|
if (face_has_symbol_charmap(ft_face) || (pOS2->usFirstCharIndex >= 0xf000 && pOS2->usFirstCharIndex < 0xf100))
|
2008-06-18 05:35:58 +02:00
|
|
|
{
|
2007-03-15 07:12:09 +01:00
|
|
|
TM.tmFirstChar = 0;
|
2009-02-17 12:49:02 +01:00
|
|
|
switch(GetACP())
|
|
|
|
{
|
|
|
|
case 1257: /* Baltic */
|
|
|
|
TM.tmLastChar = 0xf8fd;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
TM.tmLastChar = 0xf0ff;
|
|
|
|
}
|
2009-02-16 13:39:15 +01:00
|
|
|
TM.tmBreakChar = 0x20;
|
|
|
|
TM.tmDefaultChar = 0x1f;
|
2008-06-18 05:35:58 +02:00
|
|
|
}
|
2007-03-15 07:12:09 +01:00
|
|
|
else
|
2008-06-18 05:35:58 +02:00
|
|
|
{
|
2009-02-16 13:39:15 +01:00
|
|
|
TM.tmFirstChar = pOS2->usFirstCharIndex; /* Should be the first char in the cmap */
|
|
|
|
TM.tmLastChar = pOS2->usLastCharIndex; /* Should be min(cmap_last, os2_last) */
|
|
|
|
|
|
|
|
if(pOS2->usFirstCharIndex <= 1)
|
|
|
|
TM.tmBreakChar = pOS2->usFirstCharIndex + 2;
|
|
|
|
else if (pOS2->usFirstCharIndex > 0xff)
|
|
|
|
TM.tmBreakChar = 0x20;
|
|
|
|
else
|
|
|
|
TM.tmBreakChar = pOS2->usFirstCharIndex;
|
|
|
|
TM.tmDefaultChar = TM.tmBreakChar - 1;
|
2008-06-18 05:35:58 +02:00
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
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;
|
|
|
|
|
2009-02-11 14:49:52 +01:00
|
|
|
switch(pOS2->panose[PAN_FAMILYTYPE_INDEX])
|
|
|
|
{
|
2002-06-22 03:19:29 +02:00
|
|
|
case PAN_FAMILY_SCRIPT:
|
|
|
|
TM.tmPitchAndFamily |= FF_SCRIPT;
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
case PAN_FAMILY_DECORATIVE:
|
|
|
|
TM.tmPitchAndFamily |= FF_DECORATIVE;
|
2009-02-11 14:49:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_ANY:
|
|
|
|
case PAN_NO_FIT:
|
2002-06-22 03:19:29 +02:00
|
|
|
case PAN_FAMILY_TEXT_DISPLAY:
|
2009-02-11 14:49:52 +01:00
|
|
|
case PAN_FAMILY_PICTORIAL: /* symbol fonts get treated as if they were text */
|
|
|
|
/* which is clearly not what the panose spec says. */
|
|
|
|
default:
|
2009-02-19 11:41:34 +01:00
|
|
|
if(TM.tmPitchAndFamily == 0 || /* fixed */
|
|
|
|
pOS2->panose[PAN_PROPORTION_INDEX] == PAN_PROP_MONOSPACED)
|
2002-06-22 03:19:29 +02:00
|
|
|
TM.tmPitchAndFamily = FF_MODERN;
|
2009-02-11 14:49:52 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(pOS2->panose[PAN_SERIFSTYLE_INDEX])
|
|
|
|
{
|
|
|
|
case PAN_ANY:
|
|
|
|
case PAN_NO_FIT:
|
|
|
|
default:
|
|
|
|
TM.tmPitchAndFamily |= FF_DONTCARE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_SERIF_COVE:
|
|
|
|
case PAN_SERIF_OBTUSE_COVE:
|
|
|
|
case PAN_SERIF_SQUARE_COVE:
|
|
|
|
case PAN_SERIF_OBTUSE_SQUARE_COVE:
|
|
|
|
case PAN_SERIF_SQUARE:
|
|
|
|
case PAN_SERIF_THIN:
|
|
|
|
case PAN_SERIF_BONE:
|
|
|
|
case PAN_SERIF_EXAGGERATED:
|
|
|
|
case PAN_SERIF_TRIANGLE:
|
|
|
|
TM.tmPitchAndFamily |= FF_ROMAN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAN_SERIF_NORMAL_SANS:
|
|
|
|
case PAN_SERIF_OBTUSE_SANS:
|
|
|
|
case PAN_SERIF_PERP_SANS:
|
2009-02-12 13:23:01 +01:00
|
|
|
case PAN_SERIF_FLARED:
|
|
|
|
case PAN_SERIF_ROUNDED:
|
2009-02-11 14:49:52 +01:00
|
|
|
TM.tmPitchAndFamily |= FF_SWISS;
|
|
|
|
break;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FT_IS_SCALABLE(ft_face))
|
|
|
|
TM.tmPitchAndFamily |= TMPF_VECTOR;
|
2007-09-07 23:30:40 +02:00
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
if(FT_IS_SFNT(ft_face))
|
2007-09-07 23:30:40 +02:00
|
|
|
{
|
|
|
|
if (font->ntmFlags & NTM_PS_OPENTYPE)
|
|
|
|
TM.tmPitchAndFamily |= TMPF_DEVICE;
|
|
|
|
else
|
|
|
|
TM.tmPitchAndFamily |= TMPF_TRUETYPE;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
|
|
|
TM.tmCharSet = font->charset;
|
|
|
|
|
|
|
|
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;
|
2008-06-24 09:10:47 +02:00
|
|
|
font->potm->otmMacAscent = TM.tmAscent;
|
|
|
|
font->potm->otmMacDescent = -TM.tmDescent;
|
|
|
|
font->potm->otmMacLineGap = font->potm->otmLineGap;
|
2002-06-22 03:19:29 +02:00
|
|
|
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;
|
|
|
|
}
|
2008-06-24 09:10:47 +02:00
|
|
|
#undef TM
|
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);
|
2008-06-19 23:57:46 +02:00
|
|
|
if (ft_face->style_flags & (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD)) {
|
2001-09-12 22:21:06 +02:00
|
|
|
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)
|
2008-01-08 16:02:09 +01:00
|
|
|
{
|
2002-06-22 03:19:29 +02:00
|
|
|
memcpy(potm, font->potm, font->potm->otmSize);
|
2008-06-24 09:12:50 +02:00
|
|
|
scale_outline_font_metrics(font, potm);
|
2008-01-08 16:02:09 +01:00
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
|
|
|
end:
|
2001-09-12 22:21:06 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, style_nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, family_nameW);
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2001-09-12 22:21:06 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static BOOL load_child_font(GdiFont *font, CHILD_FONT *child)
|
2005-09-07 11:21:50 +02:00
|
|
|
{
|
|
|
|
HFONTLIST *hfontlist;
|
|
|
|
child->font = alloc_font();
|
2007-09-13 19:42:55 +02:00
|
|
|
child->font->ft_face = OpenFontFace(child->font, child->face, 0, -font->ppem);
|
2005-09-07 11:21:50 +02:00
|
|
|
if(!child->font->ft_face)
|
2005-09-14 13:15:05 +02:00
|
|
|
{
|
|
|
|
free_font(child->font);
|
|
|
|
child->font = NULL;
|
2005-09-07 11:21:50 +02:00
|
|
|
return FALSE;
|
2005-09-14 13:15:05 +02:00
|
|
|
}
|
2005-09-07 11:21:50 +02:00
|
|
|
|
2008-10-27 08:59:53 +01:00
|
|
|
child->font->font_desc = font->font_desc;
|
2007-09-07 23:30:40 +02:00
|
|
|
child->font->ntmFlags = child->face->ntmFlags;
|
2005-09-07 11:21:50 +02:00
|
|
|
child->font->orientation = font->orientation;
|
2008-01-30 14:26:02 +01:00
|
|
|
child->font->scale_y = font->scale_y;
|
2005-09-07 11:21:50 +02:00
|
|
|
hfontlist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hfontlist));
|
|
|
|
hfontlist->hfont = CreateFontIndirectW(&font->font_desc.lf);
|
2009-07-31 17:44:20 +02:00
|
|
|
child->font->name = strdupW(child->face->family->FamilyName);
|
2005-09-07 11:21:50 +02:00
|
|
|
list_add_head(&child->font->hfontlist, &hfontlist->entry);
|
|
|
|
child->font->base_font = font;
|
|
|
|
list_add_head(&child_font_list, &child->font->entry);
|
|
|
|
TRACE("created child font hfont %p for base %p child %p\n", hfontlist->hfont, font, child->font);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static BOOL get_glyph_index_linked(GdiFont *font, UINT c, GdiFont **linked_font, FT_UInt *glyph)
|
2005-09-07 11:21:50 +02:00
|
|
|
{
|
|
|
|
FT_UInt g;
|
|
|
|
CHILD_FONT *child_font;
|
|
|
|
|
|
|
|
if(font->base_font)
|
|
|
|
font = font->base_font;
|
|
|
|
|
|
|
|
*linked_font = font;
|
|
|
|
|
|
|
|
if((*glyph = get_glyph_index(font, c)))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(child_font, &font->child_fonts, CHILD_FONT, entry)
|
|
|
|
{
|
|
|
|
if(!child_font->font)
|
|
|
|
if(!load_child_font(font, child_font))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(!child_font->font->ft_face)
|
|
|
|
continue;
|
|
|
|
g = get_glyph_index(child_font->font, c);
|
|
|
|
if(g)
|
|
|
|
{
|
|
|
|
*glyph = g;
|
|
|
|
*linked_font = child_font->font;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetCharWidth
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetCharWidth(GdiFont *font, UINT firstChar, UINT lastChar,
|
2001-09-12 22:21:06 +02:00
|
|
|
LPINT buffer)
|
|
|
|
{
|
2009-02-03 10:55:19 +01:00
|
|
|
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
|
2001-09-12 22:21:06 +02:00
|
|
|
UINT c;
|
|
|
|
GLYPHMETRICS gm;
|
2002-01-29 04:02:50 +01:00
|
|
|
FT_UInt glyph_index;
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *linked_font;
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2001-09-12 22:21:06 +02:00
|
|
|
for(c = firstChar; c <= lastChar; c++) {
|
2005-09-08 14:40:20 +02:00
|
|
|
get_glyph_index_linked(font, c, &linked_font, &glyph_index);
|
|
|
|
WineEngGetGlyphOutline(linked_font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
2009-02-03 10:55:19 +01:00
|
|
|
&gm, 0, NULL, &identity);
|
2007-08-30 12:17:23 +02:00
|
|
|
buffer[c - firstChar] = FONT_GM(linked_font,glyph_index)->adv;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-02-12 21:05:47 +01:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetCharABCWidths
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetCharABCWidths(GdiFont *font, UINT firstChar, UINT lastChar,
|
2004-02-12 21:05:47 +01:00
|
|
|
LPABC buffer)
|
|
|
|
{
|
2009-02-03 10:55:19 +01:00
|
|
|
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
|
2004-02-12 21:05:47 +01:00
|
|
|
UINT c;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
FT_UInt glyph_index;
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *linked_font;
|
2004-02-12 21:05:47 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2004-02-12 21:05:47 +01:00
|
|
|
for(c = firstChar; c <= lastChar; c++) {
|
2005-09-08 14:40:20 +02:00
|
|
|
get_glyph_index_linked(font, c, &linked_font, &glyph_index);
|
|
|
|
WineEngGetGlyphOutline(linked_font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
2009-02-03 10:55:19 +01:00
|
|
|
&gm, 0, NULL, &identity);
|
2007-08-30 12:17:23 +02:00
|
|
|
buffer[c - firstChar].abcA = FONT_GM(linked_font,glyph_index)->lsb;
|
|
|
|
buffer[c - firstChar].abcB = FONT_GM(linked_font,glyph_index)->bbx;
|
|
|
|
buffer[c - firstChar].abcC = FONT_GM(linked_font,glyph_index)->adv - FONT_GM(linked_font,glyph_index)->lsb -
|
|
|
|
FONT_GM(linked_font,glyph_index)->bbx;
|
2004-02-12 21:05:47 +01:00
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2004-02-12 21:05:47 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-12-11 11:38:24 +01:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetCharABCWidthsFloat
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WineEngGetCharABCWidthsFloat(GdiFont *font, UINT first, UINT last, LPABCFLOAT buffer)
|
|
|
|
{
|
|
|
|
static const MAT2 identity = {{0,1}, {0,0}, {0,0}, {0,1}};
|
|
|
|
UINT c;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
FT_UInt glyph_index;
|
|
|
|
GdiFont *linked_font;
|
|
|
|
|
|
|
|
TRACE("%p, %d, %d, %p\n", font, first, last, buffer);
|
|
|
|
|
|
|
|
GDI_CheckNotLock();
|
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
|
|
|
for (c = first; c <= last; c++)
|
|
|
|
{
|
|
|
|
get_glyph_index_linked(font, c, &linked_font, &glyph_index);
|
|
|
|
WineEngGetGlyphOutline(linked_font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
|
|
|
&gm, 0, NULL, &identity);
|
|
|
|
buffer[c - first].abcfA = FONT_GM(linked_font, glyph_index)->lsb;
|
|
|
|
buffer[c - first].abcfB = FONT_GM(linked_font, glyph_index)->bbx;
|
|
|
|
buffer[c - first].abcfC = FONT_GM(linked_font, glyph_index)->adv -
|
|
|
|
FONT_GM(linked_font, glyph_index)->lsb -
|
|
|
|
FONT_GM(linked_font, glyph_index)->bbx;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-04-19 11:20:50 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetCharABCWidthsI
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetCharABCWidthsI(GdiFont *font, UINT firstChar, UINT count, LPWORD pgi,
|
2006-04-19 11:20:50 +02:00
|
|
|
LPABC buffer)
|
|
|
|
{
|
2009-02-03 10:55:19 +01:00
|
|
|
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
|
2006-04-19 11:20:50 +02:00
|
|
|
UINT c;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
FT_UInt glyph_index;
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *linked_font;
|
2006-04-19 11:20:50 +02:00
|
|
|
|
2007-12-08 22:55:01 +01:00
|
|
|
if(!FT_HAS_HORIZONTAL(font->ft_face))
|
2006-04-19 11:20:50 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2006-04-19 11:20:50 +02:00
|
|
|
get_glyph_index_linked(font, 'a', &linked_font, &glyph_index);
|
|
|
|
if (!pgi)
|
|
|
|
for(c = firstChar; c < firstChar+count; c++) {
|
|
|
|
WineEngGetGlyphOutline(linked_font, c, GGO_METRICS | GGO_GLYPH_INDEX,
|
2009-02-03 10:55:19 +01:00
|
|
|
&gm, 0, NULL, &identity);
|
2007-08-30 12:17:23 +02:00
|
|
|
buffer[c - firstChar].abcA = FONT_GM(linked_font,c)->lsb;
|
|
|
|
buffer[c - firstChar].abcB = FONT_GM(linked_font,c)->bbx;
|
|
|
|
buffer[c - firstChar].abcC = FONT_GM(linked_font,c)->adv - FONT_GM(linked_font,c)->lsb
|
|
|
|
- FONT_GM(linked_font,c)->bbx;
|
2006-04-19 11:20:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
for(c = 0; c < count; c++) {
|
|
|
|
WineEngGetGlyphOutline(linked_font, pgi[c], GGO_METRICS | GGO_GLYPH_INDEX,
|
2009-02-03 10:55:19 +01:00
|
|
|
&gm, 0, NULL, &identity);
|
2007-08-30 12:17:23 +02:00
|
|
|
buffer[c].abcA = FONT_GM(linked_font,pgi[c])->lsb;
|
|
|
|
buffer[c].abcB = FONT_GM(linked_font,pgi[c])->bbx;
|
|
|
|
buffer[c].abcC = FONT_GM(linked_font,pgi[c])->adv
|
|
|
|
- FONT_GM(linked_font,pgi[c])->lsb - FONT_GM(linked_font,pgi[c])->bbx;
|
2006-04-19 11:20:50 +02:00
|
|
|
}
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-04-19 11:20:50 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
/*************************************************************
|
2006-07-12 02:58:35 +02:00
|
|
|
* WineEngGetTextExtentExPoint
|
2001-09-12 22:21:06 +02:00
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetTextExtentExPoint(GdiFont *font, LPCWSTR wstr, INT count,
|
2006-07-12 02:58:35 +02:00
|
|
|
INT max_ext, LPINT pnfit, LPINT dxs, LPSIZE size)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
2009-02-03 10:55:19 +01:00
|
|
|
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
|
2003-03-17 05:42:30 +01:00
|
|
|
INT idx;
|
2006-07-12 02:58:35 +02:00
|
|
|
INT nfit = 0, ext;
|
2001-09-12 22:21:06 +02:00
|
|
|
GLYPHMETRICS gm;
|
|
|
|
TEXTMETRICW tm;
|
2002-01-29 04:02:50 +01:00
|
|
|
FT_UInt glyph_index;
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *linked_font;
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2006-07-12 02:58:35 +02:00
|
|
|
TRACE("%p, %s, %d, %d, %p\n", font, debugstr_wn(wstr, count), count,
|
|
|
|
max_ext, size);
|
2001-09-12 22:21:06 +02:00
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
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++) {
|
2005-09-08 14:40:20 +02:00
|
|
|
get_glyph_index_linked(font, wstr[idx], &linked_font, &glyph_index);
|
|
|
|
WineEngGetGlyphOutline(linked_font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
|
2009-02-03 10:55:19 +01:00
|
|
|
&gm, 0, NULL, &identity);
|
2007-08-30 12:17:23 +02:00
|
|
|
size->cx += FONT_GM(linked_font,glyph_index)->adv;
|
2006-07-12 02:58:35 +02:00
|
|
|
ext = size->cx;
|
|
|
|
if (! pnfit || ext <= max_ext) {
|
|
|
|
++nfit;
|
|
|
|
if (dxs)
|
|
|
|
dxs[idx] = ext;
|
|
|
|
}
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
2006-07-12 02:58:35 +02:00
|
|
|
|
|
|
|
if (pnfit)
|
|
|
|
*pnfit = nfit;
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("return %d, %d, %d\n", size->cx, size->cy, nfit);
|
2001-09-12 22:21:06 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-04-04 00:08:27 +02:00
|
|
|
/*************************************************************
|
2007-12-02 21:06:01 +01:00
|
|
|
* WineEngGetTextExtentExPointI
|
2002-04-04 00:08:27 +02:00
|
|
|
*
|
|
|
|
*/
|
2007-12-02 21:06:01 +01:00
|
|
|
BOOL WineEngGetTextExtentExPointI(GdiFont *font, const WORD *indices, INT count,
|
|
|
|
INT max_ext, LPINT pnfit, LPINT dxs, LPSIZE size)
|
2002-04-04 00:08:27 +02:00
|
|
|
{
|
2009-02-03 10:55:19 +01:00
|
|
|
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
|
2003-03-17 05:42:30 +01:00
|
|
|
INT idx;
|
2007-12-02 21:06:01 +01:00
|
|
|
INT nfit = 0, ext;
|
2002-04-04 00:08:27 +02:00
|
|
|
GLYPHMETRICS gm;
|
|
|
|
TEXTMETRICW tm;
|
|
|
|
|
2007-12-02 21:06:01 +01:00
|
|
|
TRACE("%p, %p, %d, %d, %p\n", font, indices, count, max_ext, size);
|
2002-04-04 00:08:27 +02:00
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
|
2002-04-04 00:08:27 +02:00
|
|
|
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,
|
2009-02-03 10:55:19 +01:00
|
|
|
&identity);
|
2007-12-02 21:06:01 +01:00
|
|
|
size->cx += FONT_GM(font,indices[idx])->adv;
|
|
|
|
ext = size->cx;
|
|
|
|
if (! pnfit || ext <= max_ext) {
|
|
|
|
++nfit;
|
|
|
|
if (dxs)
|
|
|
|
dxs[idx] = ext;
|
|
|
|
}
|
2002-04-04 00:08:27 +02:00
|
|
|
}
|
2007-12-02 21:06:01 +01:00
|
|
|
|
|
|
|
if (pnfit)
|
|
|
|
*pnfit = nfit;
|
|
|
|
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2007-12-02 21:06:01 +01:00
|
|
|
TRACE("return %d, %d, %d\n", size->cx, size->cy, nfit);
|
2002-04-04 00:08:27 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-10-23 22:06:32 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetFontData
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetFontData(GdiFont *font, DWORD table, DWORD offset, LPVOID buf,
|
2001-10-23 22:06:32 +02:00
|
|
|
DWORD cbData)
|
|
|
|
{
|
|
|
|
FT_Face ft_face = font->ft_face;
|
2006-07-19 09:17:49 +02:00
|
|
|
FT_ULong len;
|
2001-10-23 22:06:32 +02:00
|
|
|
FT_Error err;
|
|
|
|
|
2007-07-31 12:42:27 +02:00
|
|
|
TRACE("font=%p, table=%c%c%c%c, offset=0x%x, buf=%p, cbData=0x%x\n",
|
|
|
|
font, LOBYTE(LOWORD(table)), HIBYTE(LOWORD(table)),
|
|
|
|
LOBYTE(HIWORD(table)), HIBYTE(HIWORD(table)), offset, buf, cbData);
|
2002-01-29 04:02:50 +01:00
|
|
|
|
2001-10-23 22:06:32 +02:00
|
|
|
if(!FT_IS_SFNT(ft_face))
|
|
|
|
return GDI_ERROR;
|
|
|
|
|
2011-09-09 23:19:12 +02:00
|
|
|
if(!buf)
|
2001-10-23 22:06:32 +02:00
|
|
|
len = 0;
|
|
|
|
else
|
|
|
|
len = cbData;
|
|
|
|
|
2008-03-25 18:35:45 +01:00
|
|
|
if(table) { /* MS tags differ in endianness from FT ones */
|
2001-10-23 22:06:32 +02:00
|
|
|
table = table >> 24 | table << 24 |
|
|
|
|
(table >> 8 & 0xff00) | (table << 8 & 0xff0000);
|
|
|
|
}
|
|
|
|
|
2007-10-12 15:06:24 +02:00
|
|
|
/* make sure value of len is the value freetype says it needs */
|
|
|
|
if(buf && len)
|
|
|
|
{
|
|
|
|
FT_ULong needed = 0;
|
2011-10-10 15:15:56 +02:00
|
|
|
err = pFT_Load_Sfnt_Table(ft_face, table, offset, NULL, &needed);
|
2007-10-12 15:06:24 +02:00
|
|
|
if( !err && needed < len) len = needed;
|
2006-01-24 11:04:20 +01:00
|
|
|
}
|
2011-10-10 15:15:56 +02:00
|
|
|
err = pFT_Load_Sfnt_Table(ft_face, table, offset, buf, &len);
|
2007-10-12 15:06:24 +02:00
|
|
|
|
2001-10-23 22:06:32 +02:00
|
|
|
if(err) {
|
2007-08-02 06:47:57 +02:00
|
|
|
TRACE("Can't find table %c%c%c%c\n",
|
|
|
|
/* bytes were reversed */
|
|
|
|
HIBYTE(HIWORD(table)), LOBYTE(HIWORD(table)),
|
|
|
|
HIBYTE(LOWORD(table)), LOBYTE(LOWORD(table)));
|
2001-10-23 22:06:32 +02:00
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2002-06-22 03:19:29 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngGetTextFace
|
|
|
|
*
|
|
|
|
*/
|
2006-09-28 08:11:06 +02:00
|
|
|
INT WineEngGetTextFace(GdiFont *font, INT count, LPWSTR str)
|
2002-06-22 03:19:29 +02:00
|
|
|
{
|
2008-06-23 21:04:48 +02:00
|
|
|
INT n = strlenW(font->name) + 1;
|
2002-06-22 03:19:29 +02:00
|
|
|
if(str) {
|
|
|
|
lstrcpynW(str, font->name, count);
|
2008-06-23 21:04:48 +02:00
|
|
|
return min(count, n);
|
2002-06-22 03:19:29 +02:00
|
|
|
} else
|
2008-06-23 21:04:48 +02:00
|
|
|
return n;
|
2002-06-22 03:19:29 +02:00
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
UINT WineEngGetTextCharsetInfo(GdiFont *font, LPFONTSIGNATURE fs, DWORD flags)
|
2003-06-23 22:51:06 +02:00
|
|
|
{
|
2008-02-27 22:21:10 +01:00
|
|
|
if (fs) *fs = font->fs;
|
2003-06-23 22:51:06 +02:00
|
|
|
return font->charset;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2005-09-07 11:21:50 +02:00
|
|
|
BOOL WineEngGetLinkedHFont(DC *dc, WCHAR c, HFONT *new_hfont, UINT *glyph)
|
|
|
|
{
|
2006-09-28 08:11:06 +02:00
|
|
|
GdiFont *font = dc->gdiFont, *linked_font;
|
2005-09-07 11:21:50 +02:00
|
|
|
struct list *first_hfont;
|
|
|
|
BOOL ret;
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2005-09-07 11:21:50 +02:00
|
|
|
ret = get_glyph_index_linked(font, c, &linked_font, glyph);
|
|
|
|
TRACE("get_glyph_index_linked glyph %d font %p\n", *glyph, linked_font);
|
|
|
|
if(font == linked_font)
|
|
|
|
*new_hfont = dc->hFont;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
first_hfont = list_head(&linked_font->hfontlist);
|
|
|
|
*new_hfont = LIST_ENTRY(first_hfont, struct tagHFONTLIST, entry)->hfont;
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2005-09-07 11:21:50 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2005-09-07 15:26:49 +02:00
|
|
|
|
2007-03-01 20:30:12 +01:00
|
|
|
/* Retrieve a list of supported Unicode ranges for a given font.
|
|
|
|
* Can be called with NULL gs to calculate the buffer size. Returns
|
|
|
|
* the number of ranges found.
|
|
|
|
*/
|
|
|
|
static DWORD get_font_unicode_ranges(FT_Face face, GLYPHSET *gs)
|
|
|
|
{
|
|
|
|
DWORD num_ranges = 0;
|
|
|
|
|
2011-10-11 11:14:56 +02:00
|
|
|
if (face->charmap->encoding == FT_ENCODING_UNICODE)
|
2007-03-01 20:30:12 +01:00
|
|
|
{
|
|
|
|
FT_UInt glyph_code;
|
|
|
|
FT_ULong char_code, char_code_prev;
|
|
|
|
|
|
|
|
glyph_code = 0;
|
|
|
|
char_code_prev = char_code = pFT_Get_First_Char(face, &glyph_code);
|
|
|
|
|
|
|
|
TRACE("face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %04lx\n",
|
|
|
|
face->num_glyphs, glyph_code, char_code);
|
|
|
|
|
|
|
|
if (!glyph_code) return 0;
|
|
|
|
|
|
|
|
if (gs)
|
|
|
|
{
|
|
|
|
gs->ranges[0].wcLow = (USHORT)char_code;
|
|
|
|
gs->ranges[0].cGlyphs = 0;
|
|
|
|
gs->cGlyphsSupported = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_ranges = 1;
|
|
|
|
while (glyph_code)
|
|
|
|
{
|
|
|
|
if (char_code < char_code_prev)
|
|
|
|
{
|
|
|
|
ERR("expected increasing char code from FT_Get_Next_Char\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (char_code - char_code_prev > 1)
|
|
|
|
{
|
|
|
|
num_ranges++;
|
|
|
|
if (gs)
|
|
|
|
{
|
|
|
|
gs->ranges[num_ranges - 1].wcLow = (USHORT)char_code;
|
|
|
|
gs->ranges[num_ranges - 1].cGlyphs = 1;
|
|
|
|
gs->cGlyphsSupported++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gs)
|
|
|
|
{
|
|
|
|
gs->ranges[num_ranges - 1].cGlyphs++;
|
|
|
|
gs->cGlyphsSupported++;
|
|
|
|
}
|
|
|
|
char_code_prev = char_code;
|
|
|
|
char_code = pFT_Get_Next_Char(face, char_code, &glyph_code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FIXME("encoding %u not supported\n", face->charmap->encoding);
|
|
|
|
|
|
|
|
return num_ranges;
|
|
|
|
}
|
|
|
|
|
2007-09-26 20:17:13 +02:00
|
|
|
DWORD WineEngGetFontUnicodeRanges(GdiFont *font, LPGLYPHSET glyphset)
|
2007-03-01 20:30:12 +01:00
|
|
|
{
|
|
|
|
DWORD size = 0;
|
2007-09-26 20:17:13 +02:00
|
|
|
DWORD num_ranges = get_font_unicode_ranges(font->ft_face, glyphset);
|
2007-03-01 20:30:12 +01:00
|
|
|
|
2007-09-26 20:17:13 +02:00
|
|
|
size = sizeof(GLYPHSET) + sizeof(WCRANGE) * (num_ranges - 1);
|
|
|
|
if (glyphset)
|
2007-03-01 20:30:12 +01:00
|
|
|
{
|
2007-09-26 20:17:13 +02:00
|
|
|
glyphset->cbThis = size;
|
|
|
|
glyphset->cRanges = num_ranges;
|
2010-12-07 12:37:14 +01:00
|
|
|
glyphset->flAccel = 0;
|
2007-03-01 20:30:12 +01:00
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
2005-09-07 15:26:49 +02:00
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* FontIsLinked
|
|
|
|
*/
|
2007-09-26 20:21:34 +02:00
|
|
|
BOOL WineEngFontIsLinked(GdiFont *font)
|
2005-09-07 15:26:49 +02:00
|
|
|
{
|
2008-02-05 21:16:06 +01:00
|
|
|
BOOL ret;
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
|
|
|
ret = !list_empty(&font->child_fonts);
|
|
|
|
LeaveCriticalSection( &freetype_cs );
|
|
|
|
return ret;
|
2005-09-07 15:26:49 +02:00
|
|
|
}
|
2005-09-07 11:21:50 +02:00
|
|
|
|
2005-10-06 14:28:11 +02:00
|
|
|
static BOOL is_hinting_enabled(void)
|
|
|
|
{
|
2006-01-24 11:04:20 +01:00
|
|
|
/* Use the >= 2.2.0 function if available */
|
2006-02-22 13:24:25 +01:00
|
|
|
if(pFT_Get_TrueType_Engine_Type)
|
2006-01-24 11:04:20 +01:00
|
|
|
{
|
2006-02-22 13:24:25 +01:00
|
|
|
FT_TrueTypeEngineType type = pFT_Get_TrueType_Engine_Type(library);
|
|
|
|
return type == FT_TRUETYPE_ENGINE_TYPE_PATENTED;
|
2006-01-24 11:04:20 +01:00
|
|
|
}
|
|
|
|
#ifdef FT_DRIVER_HAS_HINTER
|
2006-05-29 12:38:49 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_Module mod;
|
|
|
|
|
|
|
|
/* otherwise if we've been compiled with < 2.2.0 headers
|
|
|
|
use the internal macro */
|
|
|
|
mod = pFT_Get_Module(library, "truetype");
|
|
|
|
if(mod && FT_DRIVER_HAS_HINTER(mod))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-01-24 11:04:20 +01:00
|
|
|
#endif
|
2005-10-06 14:28:11 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
static BOOL is_subpixel_rendering_enabled( void )
|
|
|
|
{
|
2008-12-23 12:34:01 +01:00
|
|
|
#ifdef HAVE_FREETYPE_FTLCDFIL_H
|
|
|
|
return pFT_Library_SetLcdFilter &&
|
|
|
|
pFT_Library_SetLcdFilter( NULL, 0 ) != FT_Err_Unimplemented_Feature;
|
|
|
|
#else
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
2008-12-10 15:50:44 +01:00
|
|
|
}
|
|
|
|
|
2005-10-06 14:28:11 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* GetRasterizerCaps (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
|
|
|
|
{
|
|
|
|
static int hinting = -1;
|
2008-12-10 15:50:44 +01:00
|
|
|
static int subpixel = -1;
|
2005-10-06 14:28:11 +02:00
|
|
|
|
|
|
|
if(hinting == -1)
|
2007-01-11 09:42:06 +01:00
|
|
|
{
|
2005-10-06 14:28:11 +02:00
|
|
|
hinting = is_hinting_enabled();
|
2007-01-11 09:42:06 +01:00
|
|
|
TRACE("hinting is %senabled\n", hinting ? "" : "NOT ");
|
|
|
|
}
|
2005-10-06 14:28:11 +02:00
|
|
|
|
2008-12-10 15:50:44 +01:00
|
|
|
if ( subpixel == -1 )
|
|
|
|
{
|
|
|
|
subpixel = is_subpixel_rendering_enabled();
|
|
|
|
TRACE("subpixel rendering is %senabled\n", subpixel ? "" : "NOT ");
|
|
|
|
}
|
|
|
|
|
2005-10-06 14:28:11 +02:00
|
|
|
lprs->nSize = sizeof(RASTERIZER_STATUS);
|
|
|
|
lprs->wFlags = TT_AVAILABLE | TT_ENABLED | (hinting ? WINE_TT_HINTER_ENABLED : 0);
|
2008-12-10 15:50:44 +01:00
|
|
|
if ( subpixel )
|
|
|
|
lprs->wFlags |= WINE_TT_SUBPIXEL_RENDERING_ENABLED;
|
2005-10-06 14:28:11 +02:00
|
|
|
lprs->nLanguageID = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-07-31 17:47:22 +02:00
|
|
|
/*************************************************************
|
|
|
|
* WineEngRealizationInfo
|
|
|
|
*/
|
|
|
|
BOOL WineEngRealizationInfo(GdiFont *font, realization_info_t *info)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub!\n", font, info);
|
|
|
|
|
|
|
|
info->flags = 1;
|
|
|
|
if(FT_IS_SCALABLE(font->ft_face))
|
|
|
|
info->flags |= 2;
|
|
|
|
|
|
|
|
info->cache_num = font->cache_num;
|
|
|
|
info->unknown2 = -1;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-20 17:18:51 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* Kerning support for TrueType fonts
|
|
|
|
*/
|
|
|
|
#define MS_KERN_TAG MS_MAKE_TAG('k', 'e', 'r', 'n')
|
|
|
|
|
|
|
|
struct TT_kern_table
|
|
|
|
{
|
|
|
|
USHORT version;
|
|
|
|
USHORT nTables;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TT_kern_subtable
|
|
|
|
{
|
|
|
|
USHORT version;
|
|
|
|
USHORT length;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
USHORT word;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
USHORT horizontal : 1;
|
|
|
|
USHORT minimum : 1;
|
|
|
|
USHORT cross_stream: 1;
|
|
|
|
USHORT override : 1;
|
|
|
|
USHORT reserved1 : 4;
|
|
|
|
USHORT format : 8;
|
|
|
|
} bits;
|
|
|
|
} coverage;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TT_format0_kern_subtable
|
|
|
|
{
|
|
|
|
USHORT nPairs;
|
|
|
|
USHORT searchRange;
|
|
|
|
USHORT entrySelector;
|
|
|
|
USHORT rangeShift;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TT_kern_pair
|
|
|
|
{
|
|
|
|
USHORT left;
|
|
|
|
USHORT right;
|
|
|
|
short value;
|
|
|
|
};
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
static DWORD parse_format0_kern_subtable(GdiFont *font,
|
2006-09-20 17:18:51 +02:00
|
|
|
const struct TT_format0_kern_subtable *tt_f0_ks,
|
|
|
|
const USHORT *glyph_to_char,
|
|
|
|
KERNINGPAIR *kern_pair, DWORD cPairs)
|
|
|
|
{
|
|
|
|
USHORT i, nPairs;
|
|
|
|
const struct TT_kern_pair *tt_kern_pair;
|
|
|
|
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("font height %d, units_per_EM %d\n", font->ppem, font->ft_face->units_per_EM);
|
2006-09-20 17:18:51 +02:00
|
|
|
|
|
|
|
nPairs = GET_BE_WORD(tt_f0_ks->nPairs);
|
|
|
|
|
|
|
|
TRACE("nPairs %u, searchRange %u, entrySelector %u, rangeShift %u\n",
|
|
|
|
nPairs, GET_BE_WORD(tt_f0_ks->searchRange),
|
|
|
|
GET_BE_WORD(tt_f0_ks->entrySelector), GET_BE_WORD(tt_f0_ks->rangeShift));
|
|
|
|
|
|
|
|
if (!kern_pair || !cPairs)
|
|
|
|
return nPairs;
|
|
|
|
|
|
|
|
tt_kern_pair = (const struct TT_kern_pair *)(tt_f0_ks + 1);
|
|
|
|
|
|
|
|
nPairs = min(nPairs, cPairs);
|
|
|
|
|
|
|
|
for (i = 0; i < nPairs; i++)
|
|
|
|
{
|
|
|
|
kern_pair->wFirst = glyph_to_char[GET_BE_WORD(tt_kern_pair[i].left)];
|
|
|
|
kern_pair->wSecond = glyph_to_char[GET_BE_WORD(tt_kern_pair[i].right)];
|
2006-09-27 16:43:23 +02:00
|
|
|
/* this algorithm appears to better match what Windows does */
|
|
|
|
kern_pair->iKernAmount = (short)GET_BE_WORD(tt_kern_pair[i].value) * font->ppem;
|
|
|
|
if (kern_pair->iKernAmount < 0)
|
|
|
|
{
|
|
|
|
kern_pair->iKernAmount -= font->ft_face->units_per_EM / 2;
|
|
|
|
kern_pair->iKernAmount -= font->ppem;
|
|
|
|
}
|
|
|
|
else if (kern_pair->iKernAmount > 0)
|
|
|
|
{
|
|
|
|
kern_pair->iKernAmount += font->ft_face->units_per_EM / 2;
|
|
|
|
kern_pair->iKernAmount += font->ppem;
|
|
|
|
}
|
|
|
|
kern_pair->iKernAmount /= font->ft_face->units_per_EM;
|
2006-09-20 17:18:51 +02:00
|
|
|
|
|
|
|
TRACE("left %u right %u value %d\n",
|
|
|
|
kern_pair->wFirst, kern_pair->wSecond, kern_pair->iKernAmount);
|
|
|
|
|
|
|
|
kern_pair++;
|
|
|
|
}
|
|
|
|
TRACE("copied %u entries\n", nPairs);
|
|
|
|
return nPairs;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair)
|
2006-09-20 17:18:51 +02:00
|
|
|
{
|
|
|
|
DWORD length;
|
|
|
|
void *buf;
|
|
|
|
const struct TT_kern_table *tt_kern_table;
|
|
|
|
const struct TT_kern_subtable *tt_kern_subtable;
|
|
|
|
USHORT i, nTables;
|
|
|
|
USHORT *glyph_to_char;
|
|
|
|
|
2009-01-28 19:38:15 +01:00
|
|
|
GDI_CheckNotLock();
|
2008-02-05 21:16:06 +01:00
|
|
|
EnterCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
if (font->total_kern_pairs != (DWORD)-1)
|
|
|
|
{
|
|
|
|
if (cPairs && kern_pair)
|
|
|
|
{
|
|
|
|
cPairs = min(cPairs, font->total_kern_pairs);
|
|
|
|
memcpy(kern_pair, font->kern_pairs, cPairs * sizeof(*kern_pair));
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return cPairs;
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return font->total_kern_pairs;
|
|
|
|
}
|
|
|
|
|
|
|
|
font->total_kern_pairs = 0;
|
|
|
|
|
|
|
|
length = WineEngGetFontData(font, MS_KERN_TAG, 0, NULL, 0);
|
|
|
|
|
|
|
|
if (length == GDI_ERROR)
|
|
|
|
{
|
|
|
|
TRACE("no kerning data in the font\n");
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, length);
|
|
|
|
if (!buf)
|
|
|
|
{
|
|
|
|
WARN("Out of memory\n");
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
WineEngGetFontData(font, MS_KERN_TAG, 0, buf, length);
|
|
|
|
|
|
|
|
/* build a glyph index to char code map */
|
|
|
|
glyph_to_char = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(USHORT) * 65536);
|
|
|
|
if (!glyph_to_char)
|
|
|
|
{
|
|
|
|
WARN("Out of memory allocating a glyph index to char code map\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-11 11:14:56 +02:00
|
|
|
if (font->ft_face->charmap->encoding == FT_ENCODING_UNICODE)
|
2006-09-20 17:18:51 +02:00
|
|
|
{
|
|
|
|
FT_UInt glyph_code;
|
|
|
|
FT_ULong char_code;
|
|
|
|
|
|
|
|
glyph_code = 0;
|
|
|
|
char_code = pFT_Get_First_Char(font->ft_face, &glyph_code);
|
|
|
|
|
|
|
|
TRACE("face encoding FT_ENCODING_UNICODE, number of glyphs %ld, first glyph %u, first char %lu\n",
|
|
|
|
font->ft_face->num_glyphs, glyph_code, char_code);
|
|
|
|
|
|
|
|
while (glyph_code)
|
|
|
|
{
|
|
|
|
/*TRACE("Char %04lX -> Index %u%s\n", char_code, glyph_code, glyph_to_char[glyph_code] ? " !" : "" );*/
|
|
|
|
|
|
|
|
/* FIXME: This doesn't match what Windows does: it does some fancy
|
|
|
|
* things with duplicate glyph index to char code mappings, while
|
|
|
|
* we just avoid overriding existing entries.
|
|
|
|
*/
|
|
|
|
if (glyph_code <= 65535 && !glyph_to_char[glyph_code])
|
|
|
|
glyph_to_char[glyph_code] = (USHORT)char_code;
|
|
|
|
|
|
|
|
char_code = pFT_Get_Next_Char(font->ft_face, char_code, &glyph_code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ULONG n;
|
|
|
|
|
|
|
|
FIXME("encoding %u not supported\n", font->ft_face->charmap->encoding);
|
|
|
|
for (n = 0; n <= 65535; n++)
|
|
|
|
glyph_to_char[n] = (USHORT)n;
|
|
|
|
}
|
|
|
|
|
|
|
|
tt_kern_table = buf;
|
|
|
|
nTables = GET_BE_WORD(tt_kern_table->nTables);
|
|
|
|
TRACE("version %u, nTables %u\n",
|
|
|
|
GET_BE_WORD(tt_kern_table->version), nTables);
|
|
|
|
|
|
|
|
tt_kern_subtable = (const struct TT_kern_subtable *)(tt_kern_table + 1);
|
|
|
|
|
|
|
|
for (i = 0; i < nTables; i++)
|
|
|
|
{
|
|
|
|
struct TT_kern_subtable tt_kern_subtable_copy;
|
|
|
|
|
|
|
|
tt_kern_subtable_copy.version = GET_BE_WORD(tt_kern_subtable->version);
|
|
|
|
tt_kern_subtable_copy.length = GET_BE_WORD(tt_kern_subtable->length);
|
|
|
|
tt_kern_subtable_copy.coverage.word = GET_BE_WORD(tt_kern_subtable->coverage.word);
|
|
|
|
|
|
|
|
TRACE("version %u, length %u, coverage %u, subtable format %u\n",
|
|
|
|
tt_kern_subtable_copy.version, tt_kern_subtable_copy.length,
|
|
|
|
tt_kern_subtable_copy.coverage.word, tt_kern_subtable_copy.coverage.bits.format);
|
|
|
|
|
|
|
|
/* According to the TrueType specification this is the only format
|
|
|
|
* that will be properly interpreted by Windows and OS/2
|
|
|
|
*/
|
|
|
|
if (tt_kern_subtable_copy.coverage.bits.format == 0)
|
|
|
|
{
|
|
|
|
DWORD new_chunk, old_total = font->total_kern_pairs;
|
|
|
|
|
|
|
|
new_chunk = parse_format0_kern_subtable(font, (const struct TT_format0_kern_subtable *)(tt_kern_subtable + 1),
|
|
|
|
glyph_to_char, NULL, 0);
|
|
|
|
font->total_kern_pairs += new_chunk;
|
|
|
|
|
|
|
|
if (!font->kern_pairs)
|
|
|
|
font->kern_pairs = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
font->total_kern_pairs * sizeof(*font->kern_pairs));
|
|
|
|
else
|
|
|
|
font->kern_pairs = HeapReAlloc(GetProcessHeap(), 0, font->kern_pairs,
|
|
|
|
font->total_kern_pairs * sizeof(*font->kern_pairs));
|
|
|
|
|
|
|
|
parse_format0_kern_subtable(font, (const struct TT_format0_kern_subtable *)(tt_kern_subtable + 1),
|
|
|
|
glyph_to_char, font->kern_pairs + old_total, new_chunk);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TRACE("skipping kerning table format %u\n", tt_kern_subtable_copy.coverage.bits.format);
|
|
|
|
|
|
|
|
tt_kern_subtable = (const struct TT_kern_subtable *)((const char *)tt_kern_subtable + tt_kern_subtable_copy.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, glyph_to_char);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
|
|
|
if (cPairs && kern_pair)
|
|
|
|
{
|
|
|
|
cPairs = min(cPairs, font->total_kern_pairs);
|
|
|
|
memcpy(kern_pair, font->kern_pairs, cPairs * sizeof(*kern_pair));
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return cPairs;
|
|
|
|
}
|
2008-02-05 21:16:06 +01:00
|
|
|
LeaveCriticalSection( &freetype_cs );
|
2006-09-20 17:18:51 +02:00
|
|
|
return font->total_kern_pairs;
|
|
|
|
}
|
2005-10-06 14:28:11 +02:00
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
#else /* HAVE_FREETYPE */
|
|
|
|
|
2006-05-12 00:34:55 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
BOOL WineEngInit(void)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-09-28 08:11:06 +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;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetGlyphIndices(GdiFont *font, LPCWSTR lpstr, INT count,
|
2002-04-03 22:41:14 +02:00
|
|
|
LPWORD pgi, DWORD flags)
|
|
|
|
{
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetGlyphOutline(GdiFont *font, UINT glyph, UINT format,
|
2001-09-12 22:21:06 +02:00
|
|
|
LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf,
|
|
|
|
const MAT2* lpmat)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetTextMetrics(GdiFont *font, LPTEXTMETRICW ptm)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
|
2001-09-12 22:21:06 +02:00
|
|
|
OUTLINETEXTMETRICW *potm)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetCharWidth(GdiFont *font, UINT firstChar, UINT lastChar,
|
2001-09-12 22:21:06 +02:00
|
|
|
LPINT buffer)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
2004-02-12 21:05:47 +01:00
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetCharABCWidths(GdiFont *font, UINT firstChar, UINT lastChar,
|
2004-02-12 21:05:47 +01:00
|
|
|
LPABC buffer)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
2001-09-12 22:21:06 +02:00
|
|
|
}
|
|
|
|
|
2009-12-11 11:38:24 +01:00
|
|
|
BOOL WineEngGetCharABCWidthsFloat(GdiFont *font, UINT first, UINT last, LPABCFLOAT buffer)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetCharABCWidthsI(GdiFont *font, UINT firstChar, UINT count, LPWORD pgi,
|
2006-04-21 11:27:38 +02:00
|
|
|
LPABC buffer)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
BOOL WineEngGetTextExtentExPoint(GdiFont *font, LPCWSTR wstr, INT count,
|
2006-07-12 02:58:35 +02:00
|
|
|
INT max_ext, LPINT nfit, LPINT dx, LPSIZE size)
|
2001-09-12 22:21:06 +02:00
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-12-02 21:06:01 +01:00
|
|
|
BOOL WineEngGetTextExtentExPointI(GdiFont *font, const WORD *indices, INT count,
|
|
|
|
INT max_ext, LPINT nfit, LPINT dx, LPSIZE size)
|
2002-04-04 00:08:27 +02:00
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetFontData(GdiFont *font, DWORD table, DWORD offset, LPVOID buf,
|
2001-10-23 22:06:32 +02:00
|
|
|
DWORD cbData)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return GDI_ERROR;
|
|
|
|
}
|
2002-06-22 03:19:29 +02:00
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
INT WineEngGetTextFace(GdiFont *font, INT count, LPWSTR str)
|
2002-06-22 03:19:29 +02:00
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
2010-01-20 09:18:59 +01:00
|
|
|
FIXME("(%s, %x, %p): stub\n", debugstr_w(file), flags, pdv);
|
2002-06-22 03:19:29 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
|
|
|
|
{
|
2010-01-20 09:18:59 +01:00
|
|
|
FIXME("(%s, %x, %p): stub\n", debugstr_w(file), flags, pdv);
|
2002-06-22 03:19:29 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2003-06-23 22:51:06 +02:00
|
|
|
|
2007-09-13 19:42:55 +02:00
|
|
|
HANDLE WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
|
|
|
|
{
|
2010-01-20 09:18:59 +01:00
|
|
|
FIXME("(%p, %u, %p, %p): stub\n", pbFont, cbFont, pdv, pcFonts);
|
2007-09-13 19:42:55 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
UINT WineEngGetTextCharsetInfo(GdiFont *font, LPFONTSIGNATURE fs, DWORD flags)
|
2003-06-23 22:51:06 +02:00
|
|
|
{
|
2010-01-20 09:18:59 +01:00
|
|
|
FIXME("(%p, %p, %u): stub\n", font, fs, flags);
|
2003-06-23 22:51:06 +02:00
|
|
|
return DEFAULT_CHARSET;
|
|
|
|
}
|
|
|
|
|
2005-09-07 11:21:50 +02:00
|
|
|
BOOL WineEngGetLinkedHFont(DC *dc, WCHAR c, HFONT *new_hfont, UINT *glyph)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-09-07 15:26:49 +02:00
|
|
|
|
2007-09-26 20:17:13 +02:00
|
|
|
DWORD WineEngGetFontUnicodeRanges(GdiFont *font, LPGLYPHSET glyphset)
|
2007-03-01 20:30:12 +01:00
|
|
|
{
|
2007-09-27 18:05:57 +02:00
|
|
|
FIXME("(%p, %p): stub\n", font, glyphset);
|
2007-03-01 20:30:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-26 20:21:34 +02:00
|
|
|
BOOL WineEngFontIsLinked(GdiFont *font)
|
2005-09-07 15:26:49 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-10-06 14:28:11 +02:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* GetRasterizerCaps (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
|
|
|
|
{
|
|
|
|
lprs->nSize = sizeof(RASTERIZER_STATUS);
|
|
|
|
lprs->wFlags = 0;
|
|
|
|
lprs->nLanguageID = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 08:11:06 +02:00
|
|
|
DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair)
|
2006-09-20 17:18:51 +02:00
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-25 15:38:27 +02:00
|
|
|
BOOL WineEngRealizationInfo(GdiFont *font, realization_info_t *info)
|
|
|
|
{
|
|
|
|
ERR("called but we don't have FreeType\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-12 22:21:06 +02:00
|
|
|
#endif /* HAVE_FREETYPE */
|