Commit 8da26fb2 authored by Huw D M Davies's avatar Huw D M Davies Committed by Alexandre Julliard

- Implement AddFontResource*, add stubs for RemoveFontResource*.

- Add support for GGO_BEZIER and a few bug fixes for GGO_NATIVE. - Much better support for non ansi charsets in font matching. - Proper implementation of GetTextFace for gdi font. - Load fonts that are listed in the registry but aren't in %WINDOWSDIR%\fonts. - Revert TranslateCharsetInfo to use codepage 1252 with ANSI_CHARSET. - Add support for VIETNAMESE_CHARSET and SYMBOL_CHARSET.
parent 09b4c500
......@@ -10,6 +10,8 @@ init MAIN_GdiInit
@ stdcall AbortDoc(long) AbortDoc
@ stdcall AbortPath(long) AbortPath
@ stdcall AddFontResourceA(str) AddFontResourceA
@ stdcall AddFontResourceExA(str long ptr) AddFontResourceExA
@ stdcall AddFontResourceExW(wstr long ptr) AddFontResourceExW
@ stub AddFontResourceTracking
@ stdcall AddFontResourceW(wstr) AddFontResourceW
@ stdcall AngleArc(long long long long long long) AngleArc
......@@ -319,6 +321,8 @@ init MAIN_GdiInit
@ stdcall RectVisible(long ptr) RectVisible
@ stdcall Rectangle(long long long long long) Rectangle
@ stdcall RemoveFontResourceA(str) RemoveFontResourceA
@ stdcall RemoveFontResourceExA(str long ptr) RemoveFontResourceExA
@ stdcall RemoveFontResourceExW(wstr long ptr) RemoveFontResourceExW
@ stub RemoveFontResourceTracking
@ stdcall RemoveFontResourceW(wstr) RemoveFontResourceW
@ stdcall ResetDCA(long ptr) ResetDCA
......
......@@ -38,6 +38,7 @@ extern void FONT_EnumLogFontEx16ToW(const ENUMLOGFONTEX16*, LPENUMLOGFONTEXW);
extern LPWSTR FONT_mbtowc(HDC, LPCSTR, INT, INT*, UINT*);
extern INT WineEngAddFontResourceEx(LPCWSTR, DWORD, PVOID);
extern GdiFont WineEngCreateFontInstance(DC*, HFONT);
extern BOOL WineEngDestroyFontInstance(HFONT handle);
extern DWORD WineEngEnumFonts(LPLOGFONTW, DEVICEFONTENUMPROC, LPARAM);
......@@ -51,7 +52,9 @@ extern DWORD WineEngGetGlyphOutline(GdiFont, UINT glyph, UINT format,
extern UINT WineEngGetOutlineTextMetrics(GdiFont, UINT, LPOUTLINETEXTMETRICW);
extern BOOL WineEngGetTextExtentPoint(GdiFont, LPCWSTR, INT, LPSIZE);
extern BOOL WineEngGetTextExtentPointI(GdiFont, const WORD *, INT, LPSIZE);
extern INT WineEngGetTextFace(GdiFont, INT, LPWSTR);
extern BOOL WineEngGetTextMetrics(GdiFont, LPTEXTMETRICW);
extern BOOL WineEngInit(void);
extern BOOL WineEngRemoveFontResourceEx(LPCWSTR, DWORD, PVOID);
#endif /* __WINE_FONT_H */
......@@ -684,6 +684,7 @@ typedef struct
#define HEBREW_CHARSET (BYTE)177 /* CP1255, -iso8859-8 */
#define ARABIC_CHARSET (BYTE)178 /* CP1256, -iso8859-6 */
#define BALTIC_CHARSET (BYTE)186 /* CP1257, -iso8859-13 */
#define VIETNAMESE_CHARSET (BYTE)163 /* CP1258 */
#define RUSSIAN_CHARSET (BYTE)204 /* CP1251, -iso8859-5 */
#define EE_CHARSET (BYTE)238 /* CP1250, -iso8859-2 */
#define EASTEUROPE_CHARSET EE_CHARSET
......@@ -1235,6 +1236,7 @@ typedef struct
#define GGO_METRICS 0
#define GGO_BITMAP 1
#define GGO_NATIVE 2
#define GGO_BEZIER 3
#define GGO_GRAY2_BITMAP 4
#define GGO_GRAY4_BITMAP 5
#define GGO_GRAY8_BITMAP 6
......@@ -1365,6 +1367,7 @@ typedef struct
#define TT_PRIM_LINE 1
#define TT_PRIM_QSPLINE 2
#define TT_PRIM_CSPLINE 3
#define TT_POLYGON_TYPE 24
/* Get/SetSystemPaletteUse() values */
......@@ -3046,11 +3049,19 @@ typedef struct _BLENDFUNCTION
#define GDI_ERROR (0xFFFFFFFFL)
#define HGDI_ERROR ((HANDLE)0xFFFFFFFFL)
/* AddFontResourceEx flags */
#define FR_PRIVATE 0x10
#define FR_NOT_ENUM 0x20
INT WINAPI AbortDoc(HDC);
BOOL WINAPI AbortPath(HDC);
INT WINAPI AddFontResourceA(LPCSTR);
INT WINAPI AddFontResourceW(LPCWSTR);
#define AddFontResource WINELIB_NAME_AW(AddFontResource)
INT WINAPI AddFontResourceExA(LPCSTR, DWORD, PVOID);
INT WINAPI AddFontResourceExW(LPCWSTR, DWORD, PVOID);
#define AddFontResourceEx WINELIB_NAME_AW(AddFontResourceEx)
BOOL WINAPI AlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
BOOL WINAPI AngleArc(HDC, INT, INT, DWORD, FLOAT, FLOAT);
BOOL WINAPI AnimatePalette(HPALETTE,UINT,UINT,const PALETTEENTRY*);
......@@ -3331,6 +3342,9 @@ BOOL WINAPI RectVisible(HDC,const RECT*);
BOOL WINAPI RemoveFontResourceA(LPCSTR);
BOOL WINAPI RemoveFontResourceW(LPCWSTR);
#define RemoveFontResource WINELIB_NAME_AW(RemoveFontResource)
BOOL WINAPI RemoveFontResourceExA(LPCSTR, DWORD, PVOID);
BOOL WINAPI RemoveFontResourceExW(LPCWSTR, DWORD, PVOID);
#define RemoveFontResourceEx WINELIB_NAME_AW(RemoveFontResourceEx)
HDC WINAPI ResetDCA(HDC,const DEVMODEA *);
HDC WINAPI ResetDCW(HDC,const DEVMODEW *);
#define ResetDC WINELIB_NAME_AW(ResetDC)
......
......@@ -98,6 +98,7 @@ static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
{ HEBREW_CHARSET, 1255, FS(5)},
{ ARABIC_CHARSET, 1256, FS(6)},
{ BALTIC_CHARSET, 1257, FS(7)},
{ VIETNAMESE_CHARSET, 1258, FS(8)},
/* reserved by ANSI */
{ DEFAULT_CHARSET, 0, FS(0)},
{ DEFAULT_CHARSET, 0, FS(0)},
......@@ -106,7 +107,6 @@ static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
{ DEFAULT_CHARSET, 0, FS(0)},
{ DEFAULT_CHARSET, 0, FS(0)},
{ DEFAULT_CHARSET, 0, FS(0)},
{ DEFAULT_CHARSET, 0, FS(0)},
/* ANSI and OEM */
{ THAI_CHARSET, 874, FS(16)},
{ SHIFTJIS_CHARSET, 932, FS(17)},
......@@ -125,7 +125,7 @@ static CHARSETINFO FONT_tci[MAXTCIINDEX] = {
{ DEFAULT_CHARSET, 0, FS(0)},
/* reserved for system */
{ DEFAULT_CHARSET, 0, FS(0)},
{ DEFAULT_CHARSET, 0, FS(0)},
{ SYMBOL_CHARSET, CP_SYMBOL, FS(31)},
};
/* ### start build ### */
......@@ -1104,7 +1104,9 @@ INT WINAPI GetTextFaceW( HDC hdc, INT count, LPWSTR name )
DC * dc = DC_GetDCPtr( hdc );
if (!dc) return 0;
if ((font = (FONTOBJ *) GDI_GetObjPtr( dc->hFont, FONT_MAGIC )))
if(dc->gdiFont)
ret = WineEngGetTextFace(dc->gdiFont, count, name);
else if ((font = (FONTOBJ *) GDI_GetObjPtr( dc->hFont, FONT_MAGIC )))
{
if (name)
{
......@@ -1393,11 +1395,11 @@ BOOL WINAPI GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
* therefore we have to convert them to logical */
#define WDPTOLP(x) ((x<0)? \
(-abs((x)*dc->wndExtX/dc->vportExtX)): \
(abs((x)*dc->wndExtX/dc->vportExtX)))
(-abs(INTERNAL_XDSTOWS(dc, (x)))): \
(abs(INTERNAL_XDSTOWS(dc, (x)))))
#define HDPTOLP(y) ((y<0)? \
(-abs((y)*dc->wndExtY/dc->vportExtY)): \
(abs((y)*dc->wndExtY/dc->vportExtY)))
(-abs(INTERNAL_YDSTOWS(dc, (y)))): \
(abs(INTERNAL_YDSTOWS(dc, (y)))))
metrics->tmHeight = HDPTOLP(metrics->tmHeight);
metrics->tmAscent = HDPTOLP(metrics->tmAscent);
......@@ -2242,7 +2244,7 @@ GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount,
DWORD dwFlags)
{
WCHAR *lpStringW;
INT uCountW;
INT uCountW, i;
GCP_RESULTSW resultsW;
DWORD ret;
UINT font_cp;
......@@ -2261,9 +2263,14 @@ GetCharacterPlacementA(HDC hdc, LPCSTR lpString, INT uCount,
ret = GetCharacterPlacementW(hdc, lpStringW, uCountW, nMaxExtent, &resultsW, dwFlags);
if(lpResults->lpOutString)
if(lpResults->lpOutString) {
if(font_cp != CP_SYMBOL)
WideCharToMultiByte(font_cp, 0, resultsW.lpOutString, uCountW,
lpResults->lpOutString, uCount, NULL, NULL );
else
for(i = 0; i < uCount; i++)
lpResults->lpOutString[i] = (CHAR)resultsW.lpOutString[i];
}
HeapFree(GetProcessHeap(), 0, lpStringW);
HeapFree(GetProcessHeap(), 0, resultsW.lpOutString);
......@@ -2482,38 +2489,50 @@ BOOL WINAPI GetCharWidthFloatW(HDC hdc, UINT iFirstChar,
*
* Can be either .FON, or .FNT, or .TTF, or .FOT font file.
*
* FIXME: Load header and find the best-matching font in the fontList;
* fixup dfPoints if all metrics are identical, otherwise create
* new fontAlias. When soft font support is ready this will
* simply create a new fontResource ('filename' will go into
* the pfr->resource field) with FR_SOFTFONT/FR_SOFTRESOURCE
* flag set.
*/
INT16 WINAPI AddFontResource16( LPCSTR filename )
{
return AddFontResourceA( filename );
}
/***********************************************************************
* AddFontResourceA (GDI32.@)
*/
INT WINAPI AddFontResourceA( LPCSTR str )
{
FIXME("(%s): stub! Read the Wine User Guide on how to install "
"this font manually.\n", debugstr_a(str));
return 1;
return AddFontResourceExA( str, 0, NULL);
}
/***********************************************************************
* AddFontResourceW (GDI32.@)
*/
INT WINAPI AddFontResourceW( LPCWSTR str )
{
FIXME("(%s): stub! Read the Wine User Guide on how to install "
"this font manually.\n", debugstr_w(str));
return 1;
return AddFontResourceExW(str, 0, NULL);
}
/***********************************************************************
* AddFontResourceExA (GDI32.@)
*/
INT WINAPI AddFontResourceExA( LPCSTR str, DWORD fl, PVOID pdv )
{
DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
LPWSTR strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
INT ret;
MultiByteToWideChar(CP_ACP, 0, str, -1, strW, len);
ret = AddFontResourceExW(strW, fl, pdv);
HeapFree(GetProcessHeap(), 0, strW);
return ret;
}
/***********************************************************************
* AddFontResourceExW (GDI32.@)
*/
INT WINAPI AddFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
{
return WineEngAddFontResourceEx(str, fl, pdv);
}
/***********************************************************************
......@@ -2521,48 +2540,44 @@ INT WINAPI AddFontResourceW( LPCWSTR str )
*/
BOOL16 WINAPI RemoveFontResource16( LPCSTR str )
{
FIXME("(%s): stub\n", debugstr_a(str));
return TRUE;
return RemoveFontResourceA(str);
}
/***********************************************************************
* RemoveFontResourceA (GDI32.@)
*/
BOOL WINAPI RemoveFontResourceA( LPCSTR str )
{
/* This is how it should look like */
/*
fontResource** ppfr;
BOOL32 retVal = FALSE;
return RemoveFontResourceExA(str, 0, 0);
}
EnterCriticalSection( &crtsc_fonts_X11 );
for( ppfr = &fontList; *ppfr; ppfr = &(*ppfr)->next )
if( !strcasecmp( (*ppfr)->lfFaceName, str ) )
{
if(((*ppfr)->fr_flags & (FR_SOFTFONT | FR_SOFTRESOURCE)) &&
(*ppfr)->hOwnerProcess == GetCurrentProcess() )
{
if( (*ppfr)->fo_count )
(*ppfr)->fr_flags |= FR_REMOVED;
else
XFONT_RemoveFontResource( ppfr );
}
retVal = TRUE;
}
LeaveCriticalSection( &crtsc_fonts_X11 );
return retVal;
/***********************************************************************
* RemoveFontResourceW (GDI32.@)
*/
FIXME("(%s): stub\n", debugstr_a(str));
return TRUE;
BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
{
return RemoveFontResourceExW(str, 0, 0);
}
/***********************************************************************
* RemoveFontResourceExA (GDI32.@)
*/
BOOL WINAPI RemoveFontResourceExA( LPCSTR str, DWORD fl, PVOID pdv )
{
DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
LPWSTR strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
INT ret;
MultiByteToWideChar(CP_ACP, 0, str, -1, strW, len);
ret = RemoveFontResourceExW(strW, fl, pdv);
HeapFree(GetProcessHeap(), 0, strW);
return ret;
}
/***********************************************************************
* RemoveFontResourceW (GDI32.@)
* RemoveFontResourceExW (GDI32.@)
*/
BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
{
FIXME("(%s): stub\n", debugstr_w(str) );
return TRUE;
return WineEngRemoveFontResourceEx(str, fl, pdv);
}
......@@ -40,13 +40,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(text);
* number of bytes to convert. If plenW is non-NULL, on return it
* will point to the number of WCHARs (excluding the '\0') that have
* been written. If pCP is non-NULL, on return it will point to the
* codepage used in the conversion. The caller should free the
* returned LPWSTR from the process heap itself.
* codepage used in the conversion (NB, this may be CP_SYMBOL so watch
* out). The caller should free the returned LPWSTR from the process
* heap itself.
*/
LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
{
UINT cp = CP_ACP;
INT lenW;
INT lenW, i;
LPWSTR strW;
CHARSETINFO csi;
int charset = GetTextCharset(hdc);
......@@ -56,9 +57,6 @@ LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
cp = csi.ciACP;
else {
switch(charset) {
case SYMBOL_CHARSET: /* We don't want any translation here */
cp = GetACP();
break;
case OEM_CHARSET:
cp = GetOEMCP();
break;
......@@ -90,10 +88,20 @@ LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
}
}
TRACE("cp == %d\n", cp);
if(count == -1) count = strlen(str);
if(cp != CP_SYMBOL) {
lenW = MultiByteToWideChar(cp, 0, str, count, NULL, 0);
strW = HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR));
MultiByteToWideChar(cp, 0, str, count, strW, lenW);
} else {
lenW = count;
strW = HeapAlloc(GetProcessHeap(), 0, (lenW + 1) * sizeof(WCHAR));
for(i = 0; i < count; i++) strW[i] = (BYTE)str[i];
}
strW[lenW] = '\0';
TRACE("mapped %s -> %s\n", debugstr_an(str, count), debugstr_wn(strW, lenW));
if(plenW) *plenW = lenW;
if(pCP) *pCP = cp;
return strW;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment