Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ed9114c1
Commit
ed9114c1
authored
Oct 27, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Move the CreateScalableFontResource() implementation out of freetype.c.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5772b064
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
249 additions
and
3 deletions
+249
-3
font.c
dlls/gdi32/font.c
+248
-1
freetype.c
dlls/gdi32/freetype.c
+0
-0
gdi_private.h
dlls/gdi32/gdi_private.h
+1
-2
No files found.
dlls/gdi32/font.c
View file @
ed9114c1
...
...
@@ -4496,17 +4496,264 @@ BOOL WINAPI CreateScalableFontResourceA( DWORD fHidden,
return
ret
;
}
#define NE_FFLAGS_LIBMODULE 0x8000
#define NE_OSFLAGS_WINDOWS 0x02
static
const
char
dos_string
[
0x40
]
=
"This is a TrueType resource file"
;
static
const
char
FONTRES
[]
=
{
'F'
,
'O'
,
'N'
,
'T'
,
'R'
,
'E'
,
'S'
,
':'
};
#include <pshpack1.h>
struct
fontdir
{
WORD
num_of_resources
;
WORD
res_id
;
WORD
dfVersion
;
DWORD
dfSize
;
CHAR
dfCopyright
[
60
];
WORD
dfType
;
WORD
dfPoints
;
WORD
dfVertRes
;
WORD
dfHorizRes
;
WORD
dfAscent
;
WORD
dfInternalLeading
;
WORD
dfExternalLeading
;
BYTE
dfItalic
;
BYTE
dfUnderline
;
BYTE
dfStrikeOut
;
WORD
dfWeight
;
BYTE
dfCharSet
;
WORD
dfPixWidth
;
WORD
dfPixHeight
;
BYTE
dfPitchAndFamily
;
WORD
dfAvgWidth
;
WORD
dfMaxWidth
;
BYTE
dfFirstChar
;
BYTE
dfLastChar
;
BYTE
dfDefaultChar
;
BYTE
dfBreakChar
;
WORD
dfWidthBytes
;
DWORD
dfDevice
;
DWORD
dfFace
;
DWORD
dfReserved
;
CHAR
szFaceName
[
LF_FACESIZE
];
};
#include <poppack.h>
#include <pshpack2.h>
struct
ne_typeinfo
{
WORD
type_id
;
WORD
count
;
DWORD
res
;
};
struct
ne_nameinfo
{
WORD
off
;
WORD
len
;
WORD
flags
;
WORD
id
;
DWORD
res
;
};
struct
rsrc_tab
{
WORD
align
;
struct
ne_typeinfo
fontdir_type
;
struct
ne_nameinfo
fontdir_name
;
struct
ne_typeinfo
scalable_type
;
struct
ne_nameinfo
scalable_name
;
WORD
end_of_rsrc
;
BYTE
fontdir_res_name
[
8
];
};
#include <poppack.h>
static
BOOL
create_fot
(
const
WCHAR
*
resource
,
const
WCHAR
*
font_file
,
const
struct
fontdir
*
fontdir
)
{
BOOL
ret
=
FALSE
;
HANDLE
file
;
DWORD
size
,
written
;
BYTE
*
ptr
,
*
start
;
BYTE
import_name_len
,
res_name_len
,
non_res_name_len
,
font_file_len
;
char
*
font_fileA
,
*
last_part
,
*
ext
;
IMAGE_DOS_HEADER
dos
;
IMAGE_OS2_HEADER
ne
=
{
IMAGE_OS2_SIGNATURE
,
5
,
1
,
0
,
0
,
0
,
NE_FFLAGS_LIBMODULE
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
sizeof
(
ne
),
sizeof
(
ne
),
0
,
0
,
0
,
0
,
0
,
4
,
2
,
NE_OSFLAGS_WINDOWS
,
0
,
0
,
0
,
0
,
0x300
};
struct
rsrc_tab
rsrc_tab
=
{
4
,
{
0x8007
,
1
,
0
},
{
0
,
0
,
0x0c50
,
0x2c
,
0
},
{
0x80cc
,
1
,
0
},
{
0
,
0
,
0x0c50
,
0x8001
,
0
},
0
,
{
7
,
'F'
,
'O'
,
'N'
,
'T'
,
'D'
,
'I'
,
'R'
}
};
memset
(
&
dos
,
0
,
sizeof
(
dos
)
);
dos
.
e_magic
=
IMAGE_DOS_SIGNATURE
;
dos
.
e_lfanew
=
sizeof
(
dos
)
+
sizeof
(
dos_string
);
/* import name is last part\0, resident name is last part without extension
non-resident name is "FONTRES:" + lfFaceName */
font_file_len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
font_file
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
font_fileA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
font_file_len
);
WideCharToMultiByte
(
CP_ACP
,
0
,
font_file
,
-
1
,
font_fileA
,
font_file_len
,
NULL
,
NULL
);
last_part
=
strrchr
(
font_fileA
,
'\\'
);
if
(
last_part
)
last_part
++
;
else
last_part
=
font_fileA
;
import_name_len
=
strlen
(
last_part
)
+
1
;
ext
=
strchr
(
last_part
,
'.'
);
if
(
ext
)
res_name_len
=
ext
-
last_part
;
else
res_name_len
=
import_name_len
-
1
;
non_res_name_len
=
sizeof
(
FONTRES
)
+
strlen
(
fontdir
->
szFaceName
);
ne
.
ne_cbnrestab
=
1
+
non_res_name_len
+
2
+
1
;
/* len + string + (WORD) ord_num + 1 byte eod */
ne
.
ne_restab
=
ne
.
ne_rsrctab
+
sizeof
(
rsrc_tab
);
ne
.
ne_modtab
=
ne
.
ne_imptab
=
ne
.
ne_restab
+
1
+
res_name_len
+
2
+
3
;
/* len + string + (WORD) ord_num + 3 bytes eod */
ne
.
ne_enttab
=
ne
.
ne_imptab
+
1
+
import_name_len
;
/* len + string */
ne
.
ne_cbenttab
=
2
;
ne
.
ne_nrestab
=
ne
.
ne_enttab
+
ne
.
ne_cbenttab
+
2
+
dos
.
e_lfanew
;
/* there are 2 bytes of 0 after entry tab */
rsrc_tab
.
scalable_name
.
off
=
(
ne
.
ne_nrestab
+
ne
.
ne_cbnrestab
+
0xf
)
>>
4
;
rsrc_tab
.
scalable_name
.
len
=
(
font_file_len
+
0xf
)
>>
4
;
rsrc_tab
.
fontdir_name
.
off
=
rsrc_tab
.
scalable_name
.
off
+
rsrc_tab
.
scalable_name
.
len
;
rsrc_tab
.
fontdir_name
.
len
=
(
fontdir
->
dfSize
+
0xf
)
>>
4
;
size
=
(
rsrc_tab
.
fontdir_name
.
off
+
rsrc_tab
.
fontdir_name
.
len
)
<<
4
;
start
=
ptr
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
if
(
!
ptr
)
{
HeapFree
(
GetProcessHeap
(),
0
,
font_fileA
);
return
FALSE
;
}
memcpy
(
ptr
,
&
dos
,
sizeof
(
dos
)
);
memcpy
(
ptr
+
sizeof
(
dos
),
dos_string
,
sizeof
(
dos_string
)
);
memcpy
(
ptr
+
dos
.
e_lfanew
,
&
ne
,
sizeof
(
ne
)
);
ptr
=
start
+
dos
.
e_lfanew
+
ne
.
ne_rsrctab
;
memcpy
(
ptr
,
&
rsrc_tab
,
sizeof
(
rsrc_tab
)
);
ptr
=
start
+
dos
.
e_lfanew
+
ne
.
ne_restab
;
*
ptr
++
=
res_name_len
;
memcpy
(
ptr
,
last_part
,
res_name_len
);
ptr
=
start
+
dos
.
e_lfanew
+
ne
.
ne_imptab
;
*
ptr
++
=
import_name_len
;
memcpy
(
ptr
,
last_part
,
import_name_len
);
ptr
=
start
+
ne
.
ne_nrestab
;
*
ptr
++
=
non_res_name_len
;
memcpy
(
ptr
,
FONTRES
,
sizeof
(
FONTRES
)
);
memcpy
(
ptr
+
sizeof
(
FONTRES
),
fontdir
->
szFaceName
,
strlen
(
fontdir
->
szFaceName
)
);
ptr
=
start
+
(
rsrc_tab
.
scalable_name
.
off
<<
4
);
memcpy
(
ptr
,
font_fileA
,
font_file_len
);
ptr
=
start
+
(
rsrc_tab
.
fontdir_name
.
off
<<
4
);
memcpy
(
ptr
,
fontdir
,
fontdir
->
dfSize
);
file
=
CreateFileW
(
resource
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_NEW
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
file
!=
INVALID_HANDLE_VALUE
)
{
if
(
WriteFile
(
file
,
start
,
size
,
&
written
,
NULL
)
&&
written
==
size
)
ret
=
TRUE
;
CloseHandle
(
file
);
}
HeapFree
(
GetProcessHeap
(),
0
,
start
);
HeapFree
(
GetProcessHeap
(),
0
,
font_fileA
);
return
ret
;
}
/***********************************************************************
* CreateScalableFontResourceW (GDI32.@)
*/
BOOL
WINAPI
CreateScalableFontResourceW
(
DWORD
hidden
,
LPCWSTR
resource_file
,
LPCWSTR
font_file
,
LPCWSTR
font_path
)
{
static
const
WCHAR
backslashW
[]
=
{
'\\'
,
0
};
struct
fontdir
fontdir
=
{
0
};
struct
gdi_font
*
font
=
NULL
;
WCHAR
path
[
MAX_PATH
];
TRACE
(
"(%d, %s, %s, %s)
\n
"
,
hidden
,
debugstr_w
(
resource_file
),
debugstr_w
(
font_file
),
debugstr_w
(
font_path
)
);
if
(
!
font_funcs
)
return
FALSE
;
return
font_funcs
->
pCreateScalableFontResource
(
hidden
,
resource_file
,
font_file
,
font_path
);
if
(
!
font_file
)
goto
done
;
if
(
font_path
&&
font_path
[
0
])
{
int
len
=
strlenW
(
font_path
)
+
strlenW
(
font_file
)
+
2
;
if
(
len
>
MAX_PATH
)
goto
done
;
lstrcpynW
(
path
,
font_path
,
MAX_PATH
);
strcatW
(
path
,
backslashW
);
strcatW
(
path
,
font_file
);
}
else
if
(
!
GetFullPathNameW
(
font_file
,
MAX_PATH
,
path
,
NULL
))
goto
done
;
if
(
!
(
font
=
alloc_gdi_font
(
path
,
NULL
,
0
)))
goto
done
;
font
->
lf
.
lfHeight
=
100
;
if
(
!
font_funcs
->
load_font
(
font
))
goto
done
;
if
(
!
font_funcs
->
set_outline_text_metrics
(
font
))
goto
done
;
if
(
!
(
font
->
otm
.
otmTextMetrics
.
tmPitchAndFamily
&
TMPF_TRUETYPE
))
goto
done
;
fontdir
.
num_of_resources
=
1
;
fontdir
.
res_id
=
0
;
fontdir
.
dfVersion
=
0x200
;
fontdir
.
dfSize
=
sizeof
(
fontdir
);
strcpy
(
fontdir
.
dfCopyright
,
"Wine fontdir"
);
fontdir
.
dfType
=
0x4003
;
/* 0x0080 set if private */
fontdir
.
dfPoints
=
font
->
otm
.
otmEMSquare
;
fontdir
.
dfVertRes
=
72
;
fontdir
.
dfHorizRes
=
72
;
fontdir
.
dfAscent
=
font
->
otm
.
otmTextMetrics
.
tmAscent
;
fontdir
.
dfInternalLeading
=
font
->
otm
.
otmTextMetrics
.
tmInternalLeading
;
fontdir
.
dfExternalLeading
=
font
->
otm
.
otmTextMetrics
.
tmExternalLeading
;
fontdir
.
dfItalic
=
font
->
otm
.
otmTextMetrics
.
tmItalic
;
fontdir
.
dfUnderline
=
font
->
otm
.
otmTextMetrics
.
tmUnderlined
;
fontdir
.
dfStrikeOut
=
font
->
otm
.
otmTextMetrics
.
tmStruckOut
;
fontdir
.
dfWeight
=
font
->
otm
.
otmTextMetrics
.
tmWeight
;
fontdir
.
dfCharSet
=
font
->
otm
.
otmTextMetrics
.
tmCharSet
;
fontdir
.
dfPixWidth
=
0
;
fontdir
.
dfPixHeight
=
font
->
otm
.
otmTextMetrics
.
tmHeight
;
fontdir
.
dfPitchAndFamily
=
font
->
otm
.
otmTextMetrics
.
tmPitchAndFamily
;
fontdir
.
dfAvgWidth
=
font
->
otm
.
otmTextMetrics
.
tmAveCharWidth
;
fontdir
.
dfMaxWidth
=
font
->
otm
.
otmTextMetrics
.
tmMaxCharWidth
;
fontdir
.
dfFirstChar
=
font
->
otm
.
otmTextMetrics
.
tmFirstChar
;
fontdir
.
dfLastChar
=
font
->
otm
.
otmTextMetrics
.
tmLastChar
;
fontdir
.
dfDefaultChar
=
font
->
otm
.
otmTextMetrics
.
tmDefaultChar
;
fontdir
.
dfBreakChar
=
font
->
otm
.
otmTextMetrics
.
tmBreakChar
;
fontdir
.
dfWidthBytes
=
0
;
fontdir
.
dfDevice
=
0
;
fontdir
.
dfFace
=
FIELD_OFFSET
(
struct
fontdir
,
szFaceName
);
fontdir
.
dfReserved
=
0
;
WideCharToMultiByte
(
CP_ACP
,
0
,
(
WCHAR
*
)
font
->
otm
.
otmpFamilyName
,
-
1
,
fontdir
.
szFaceName
,
LF_FACESIZE
,
NULL
,
NULL
);
if
(
hidden
)
fontdir
.
dfType
|=
0x80
;
return
create_fot
(
resource_file
,
font_file
,
&
fontdir
);
done:
if
(
font
)
free_gdi_font
(
font
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
/*************************************************************************
...
...
dlls/gdi32/freetype.c
View file @
ed9114c1
This diff is collapsed.
Click to expand it.
dlls/gdi32/gdi_private.h
View file @
ed9114c1
...
...
@@ -370,12 +370,11 @@ struct font_backend_funcs
DWORD
(
CDECL
*
pGetFontUnicodeRanges
)(
struct
gdi_font
*
font
,
GLYPHSET
*
glyphset
);
struct
gdi_font
*
(
CDECL
*
pSelectFont
)(
DC
*
dc
,
HFONT
hfont
,
UINT
*
aa_flags
,
UINT
default_aa_flags
);
BOOL
(
CDECL
*
pCreateScalableFontResource
)(
DWORD
hidden
,
LPCWSTR
resource
,
LPCWSTR
font_file
,
LPCWSTR
font_path
);
INT
(
CDECL
*
add_font
)(
const
WCHAR
*
file
,
DWORD
flags
);
INT
(
CDECL
*
add_mem_font
)(
void
*
ptr
,
SIZE_T
size
,
DWORD
flags
);
BOOL
(
CDECL
*
remove_font
)(
const
WCHAR
*
file
,
DWORD
flags
);
BOOL
(
CDECL
*
load_font
)(
struct
gdi_font
*
gdi_font
);
DWORD
(
CDECL
*
get_font_data
)(
struct
gdi_font
*
gdi_font
,
DWORD
table
,
DWORD
offset
,
void
*
buf
,
DWORD
count
);
BOOL
(
CDECL
*
get_glyph_index
)(
struct
gdi_font
*
gdi_font
,
UINT
*
glyph
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment