Commit b7d0bab5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Pass NT paths to ntgdi functions.

parent ab5664a5
...@@ -5446,6 +5446,7 @@ BOOL get_file_outline_text_metric( const WCHAR *path, OUTLINETEXTMETRICW *otm ) ...@@ -5446,6 +5446,7 @@ BOOL get_file_outline_text_metric( const WCHAR *path, OUTLINETEXTMETRICW *otm )
if (!path || !font_funcs) return FALSE; if (!path || !font_funcs) return FALSE;
if (*path == '\\') path += 4; /* skip NT prefix */
if (!(font = alloc_gdi_font( path, NULL, 0 ))) goto done; if (!(font = alloc_gdi_font( path, NULL, 0 ))) goto done;
font->lf.lfHeight = 100; font->lf.lfHeight = 100;
if (!font_funcs->load_font( font )) goto done; if (!font_funcs->load_font( font )) goto done;
...@@ -5600,6 +5601,7 @@ static int add_font_resource( LPCWSTR file, DWORD flags ) ...@@ -5600,6 +5601,7 @@ static int add_font_resource( LPCWSTR file, DWORD flags )
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
int ret = 0; int ret = 0;
if (*file == '\\') file += 4; /* skip NT prefix */
if (GetFullPathNameW( file, MAX_PATH, path, NULL )) if (GetFullPathNameW( file, MAX_PATH, path, NULL ))
{ {
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE; DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
...@@ -5621,6 +5623,7 @@ static BOOL remove_font_resource( LPCWSTR file, DWORD flags ) ...@@ -5621,6 +5623,7 @@ static BOOL remove_font_resource( LPCWSTR file, DWORD flags )
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
BOOL ret = FALSE; BOOL ret = FALSE;
if (*file == '\\') file += 4; /* skip NT prefix */
if (GetFullPathNameW( file, MAX_PATH, path, NULL )) if (GetFullPathNameW( file, MAX_PATH, path, NULL ))
{ {
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE; DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
......
...@@ -2385,6 +2385,23 @@ fail: ...@@ -2385,6 +2385,23 @@ fail:
return name; return name;
} }
static int add_font_resource( const WCHAR *str, DWORD flags, void *dv )
{
UNICODE_STRING nt_name;
int ret;
if (!RtlDosPathNameToNtPathName_U( str, &nt_name, NULL, NULL )) return 0;
ret = NtGdiAddFontResourceW( nt_name.Buffer, nt_name.Length / sizeof(WCHAR) + 1,
1, flags, 0, dv );
RtlFreeUnicodeString( &nt_name );
if (!ret && !wcschr( str, '\\' ))
{
/* try as system font */
ret = NtGdiAddFontResourceW( str, lstrlenW( str ) + 1, 1, flags, 0, dv );
}
return ret;
}
/*********************************************************************** /***********************************************************************
* AddFontResourceExW (GDI32.@) * AddFontResourceExW (GDI32.@)
*/ */
...@@ -2394,15 +2411,32 @@ INT WINAPI AddFontResourceExW( const WCHAR *str, DWORD flags, void *dv ) ...@@ -2394,15 +2411,32 @@ INT WINAPI AddFontResourceExW( const WCHAR *str, DWORD flags, void *dv )
BOOL hidden; BOOL hidden;
INT ret; INT ret;
if ((ret = NtGdiAddFontResourceW( str, 0, 1, flags, 0, dv ))) return ret; if ((ret = add_font_resource( str, flags, dv ))) return ret;
if (!(filename = get_scalable_filename( str, &hidden ))) return 0; if (!(filename = get_scalable_filename( str, &hidden ))) return 0;
if (hidden) flags |= FR_PRIVATE | FR_NOT_ENUM; if (hidden) flags |= FR_PRIVATE | FR_NOT_ENUM;
ret = NtGdiAddFontResourceW( filename, 0, 1, flags, 0, dv ); ret = add_font_resource( filename, flags, dv );
HeapFree( GetProcessHeap(), 0, filename ); HeapFree( GetProcessHeap(), 0, filename );
return ret; return ret;
} }
static int remove_font_resource( const WCHAR *str, DWORD flags, void *dv )
{
UNICODE_STRING nt_name;
int ret;
if (!RtlDosPathNameToNtPathName_U( str, &nt_name, NULL, NULL )) return 0;
ret = NtGdiRemoveFontResourceW( nt_name.Buffer, nt_name.Length / sizeof(WCHAR) + 1,
1, flags, 0, dv );
RtlFreeUnicodeString( &nt_name );
if (!ret && !wcschr( str, '\\' ))
{
/* try as system font */
ret = NtGdiRemoveFontResourceW( str, lstrlenW( str ) + 1, 1, flags, 0, dv );
}
return ret;
}
/*********************************************************************** /***********************************************************************
* RemoveFontResourceExW (GDI32.@) * RemoveFontResourceExW (GDI32.@)
*/ */
...@@ -2412,11 +2446,11 @@ BOOL WINAPI RemoveFontResourceExW( const WCHAR *str, DWORD flags, void *dv ) ...@@ -2412,11 +2446,11 @@ BOOL WINAPI RemoveFontResourceExW( const WCHAR *str, DWORD flags, void *dv )
BOOL hidden; BOOL hidden;
INT ret; INT ret;
if ((ret = NtGdiRemoveFontResourceW( str, 0, 1, flags, 0, dv ))) return ret; if ((ret = remove_font_resource( str, flags, dv ))) return ret;
if (!(filename = get_scalable_filename( str, &hidden ))) return 0; if (!(filename = get_scalable_filename( str, &hidden ))) return 0;
if (hidden) flags |= FR_PRIVATE | FR_NOT_ENUM; if (hidden) flags |= FR_PRIVATE | FR_NOT_ENUM;
ret = NtGdiRemoveFontResourceW( filename, 0, 1, flags, 0, dv ); ret = remove_font_resource( filename, flags, dv );
HeapFree( GetProcessHeap(), 0, filename ); HeapFree( GetProcessHeap(), 0, filename );
return ret; return ret;
} }
...@@ -2629,8 +2663,10 @@ BOOL WINAPI CreateScalableFontResourceW( DWORD hidden, const WCHAR *resource_fil ...@@ -2629,8 +2663,10 @@ BOOL WINAPI CreateScalableFontResourceW( DWORD hidden, const WCHAR *resource_fil
const WCHAR *font_file, const WCHAR *font_path ) const WCHAR *font_file, const WCHAR *font_path )
{ {
struct fontdir fontdir = { 0 }; struct fontdir fontdir = { 0 };
UNICODE_STRING nt_name;
OUTLINETEXTMETRICW otm; OUTLINETEXTMETRICW otm;
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
BOOL ret;
TRACE("(%d, %s, %s, %s)\n", hidden, debugstr_w(resource_file), TRACE("(%d, %s, %s, %s)\n", hidden, debugstr_w(resource_file),
debugstr_w(font_file), debugstr_w(font_path) ); debugstr_w(font_file), debugstr_w(font_path) );
...@@ -2643,9 +2679,12 @@ BOOL WINAPI CreateScalableFontResourceW( DWORD hidden, const WCHAR *resource_fil ...@@ -2643,9 +2679,12 @@ BOOL WINAPI CreateScalableFontResourceW( DWORD hidden, const WCHAR *resource_fil
lstrcpynW( path, font_path, MAX_PATH ); lstrcpynW( path, font_path, MAX_PATH );
lstrcatW( path, L"\\" ); lstrcatW( path, L"\\" );
lstrcatW( path, font_file ); lstrcatW( path, font_file );
if (!RtlDosPathNameToNtPathName_U( path, &nt_name, NULL, NULL )) goto done;
} }
else if (!GetFullPathNameW( font_file, MAX_PATH, path, NULL )) goto done; else if (!RtlDosPathNameToNtPathName_U( font_file, &nt_name, NULL, NULL )) goto done;
if (!get_file_outline_text_metric( path, &otm )) goto done; ret = get_file_outline_text_metric( nt_name.Buffer, &otm );
RtlFreeUnicodeString( &nt_name );
if (!ret) goto done;
if (!(otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) goto done; if (!(otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) goto done;
fontdir.num_of_resources = 1; fontdir.num_of_resources = 1;
......
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