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
e800158a
Commit
e800158a
authored
Aug 21, 2011
by
Nikolay Sivov
Committed by
Alexandre Julliard
Aug 22, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Get rid of duplicated condition check.
parent
c69be3bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
80 deletions
+77
-80
olefont.c
dlls/oleaut32/olefont.c
+77
-80
No files found.
dlls/oleaut32/olefont.c
View file @
e800158a
...
...
@@ -584,88 +584,85 @@ static int CALLBACK font_enum_proc(const LOGFONTW *elf, const TEXTMETRICW *ntm,
static
void
realize_font
(
OLEFontImpl
*
This
)
{
if
(
This
->
dirty
)
{
LOGFONTW
logFont
;
INT
fontHeight
;
WCHAR
text_face
[
LF_FACESIZE
];
HDC
hdc
=
get_dc
();
HFONT
old_font
;
TEXTMETRICW
tm
;
LOGFONTW
logFont
;
INT
fontHeight
;
WCHAR
text_face
[
LF_FACESIZE
];
HDC
hdc
=
get_dc
();
HFONT
old_font
;
TEXTMETRICW
tm
;
text_face
[
0
]
=
0
;
if
(
!
This
->
dirty
)
return
;
if
(
This
->
gdiFont
)
{
old_font
=
SelectObject
(
hdc
,
This
->
gdiFont
);
GetTextFaceW
(
hdc
,
sizeof
(
text_face
)
/
sizeof
(
text_face
[
0
]),
text_face
);
SelectObject
(
hdc
,
old_font
);
dec_int_ref
(
This
->
gdiFont
);
This
->
gdiFont
=
0
;
}
text_face
[
0
]
=
0
;
memset
(
&
logFont
,
0
,
sizeof
(
LOGFONTW
));
if
(
This
->
gdiFont
)
{
old_font
=
SelectObject
(
hdc
,
This
->
gdiFont
);
GetTextFaceW
(
hdc
,
sizeof
(
text_face
)
/
sizeof
(
text_face
[
0
]),
text_face
);
SelectObject
(
hdc
,
old_font
);
dec_int_ref
(
This
->
gdiFont
);
This
->
gdiFont
=
0
;
}
lstrcpynW
(
logFont
.
lfFaceName
,
This
->
description
.
lpstrName
,
LF_FACESIZE
);
logFont
.
lfCharSet
=
This
->
description
.
sCharset
;
memset
(
&
logFont
,
0
,
sizeof
(
LOGFONTW
));
/* If the font name has been changed then enumerate all charsets
and pick one that'll result in the font specified being selected */
if
(
text_face
[
0
]
&&
lstrcmpiW
(
text_face
,
This
->
description
.
lpstrName
))
{
enum_data
data
;
data
.
orig_cs
=
This
->
description
.
sCharset
;
data
.
avail_cs
=
-
1
;
logFont
.
lfCharSet
=
DEFAULT_CHARSET
;
EnumFontFamiliesExW
(
get_dc
(),
&
logFont
,
font_enum_proc
,
(
LPARAM
)
&
data
,
0
);
if
(
data
.
avail_cs
!=
-
1
)
logFont
.
lfCharSet
=
data
.
avail_cs
;
}
lstrcpynW
(
logFont
.
lfFaceName
,
This
->
description
.
lpstrName
,
LF_FACESIZE
);
logFont
.
lfCharSet
=
This
->
description
.
sCharset
;
/* If the font name has been changed then enumerate all charsets
and pick one that'll result in the font specified being selected */
if
(
text_face
[
0
]
&&
lstrcmpiW
(
text_face
,
This
->
description
.
lpstrName
))
{
enum_data
data
;
data
.
orig_cs
=
This
->
description
.
sCharset
;
data
.
avail_cs
=
-
1
;
logFont
.
lfCharSet
=
DEFAULT_CHARSET
;
EnumFontFamiliesExW
(
get_dc
(),
&
logFont
,
font_enum_proc
,
(
LPARAM
)
&
data
,
0
);
if
(
data
.
avail_cs
!=
-
1
)
logFont
.
lfCharSet
=
data
.
avail_cs
;
}
/*
* The height of the font returned by the get_Size property is the
* height of the font in points multiplied by 10000... Using some
* simple conversions and the ratio given by the application, it can
* be converted to a height in pixels.
*
* Standard ratio is 72 / 2540, or 18 / 635 in lowest terms.
* Ratio is applied here relative to the standard.
*/
fontHeight
=
MulDiv
(
This
->
description
.
cySize
.
s
.
Lo
,
This
->
cyLogical
*
635
,
This
->
cyHimetric
*
18
);
/*
* The height of the font returned by the get_Size property is the
* height of the font in points multiplied by 10000... Using some
* simple conversions and the ratio given by the application, it can
* be converted to a height in pixels.
*
* Standard ratio is 72 / 2540, or 18 / 635 in lowest terms.
* Ratio is applied here relative to the standard.
*/
fontHeight
=
MulDiv
(
This
->
description
.
cySize
.
s
.
Lo
,
This
->
cyLogical
*
635
,
This
->
cyHimetric
*
18
);
logFont
.
lfHeight
=
((
fontHeight
%
10000L
)
>
5000L
)
?
(
-
fontHeight
/
10000L
)
-
1
:
logFont
.
lfHeight
=
((
fontHeight
%
10000L
)
>
5000L
)
?
(
-
fontHeight
/
10000L
)
-
1
:
(
-
fontHeight
/
10000L
);
logFont
.
lfItalic
=
This
->
description
.
fItalic
;
logFont
.
lfUnderline
=
This
->
description
.
fUnderline
;
logFont
.
lfStrikeOut
=
This
->
description
.
fStrikethrough
;
logFont
.
lfWeight
=
This
->
description
.
sWeight
;
logFont
.
lfOutPrecision
=
OUT_CHARACTER_PRECIS
;
logFont
.
lfClipPrecision
=
CLIP_DEFAULT_PRECIS
;
logFont
.
lfQuality
=
DEFAULT_QUALITY
;
logFont
.
lfPitchAndFamily
=
DEFAULT_PITCH
;
This
->
gdiFont
=
CreateFontIndirectW
(
&
logFont
);
This
->
dirty
=
FALSE
;
add_hfontitem
(
This
->
gdiFont
);
/* Fixup the name and charset properties so that they match the
selected font */
old_font
=
SelectObject
(
get_dc
(),
This
->
gdiFont
);
GetTextFaceW
(
hdc
,
sizeof
(
text_face
)
/
sizeof
(
text_face
[
0
]),
text_face
);
if
(
lstrcmpiW
(
text_face
,
This
->
description
.
lpstrName
))
{
HeapFree
(
GetProcessHeap
(),
0
,
This
->
description
.
lpstrName
);
This
->
description
.
lpstrName
=
strdupW
(
text_face
);
}
GetTextMetricsW
(
hdc
,
&
tm
);
This
->
description
.
sCharset
=
tm
.
tmCharSet
;
/* While we have it handy, stash the realized font height for use by get_Size() */
This
->
nRealHeight
=
tm
.
tmHeight
-
tm
.
tmInternalLeading
;
/* corresponds to LOGFONT lfHeight */
SelectObject
(
hdc
,
old_font
);
logFont
.
lfItalic
=
This
->
description
.
fItalic
;
logFont
.
lfUnderline
=
This
->
description
.
fUnderline
;
logFont
.
lfStrikeOut
=
This
->
description
.
fStrikethrough
;
logFont
.
lfWeight
=
This
->
description
.
sWeight
;
logFont
.
lfOutPrecision
=
OUT_CHARACTER_PRECIS
;
logFont
.
lfClipPrecision
=
CLIP_DEFAULT_PRECIS
;
logFont
.
lfQuality
=
DEFAULT_QUALITY
;
logFont
.
lfPitchAndFamily
=
DEFAULT_PITCH
;
This
->
gdiFont
=
CreateFontIndirectW
(
&
logFont
);
This
->
dirty
=
FALSE
;
add_hfontitem
(
This
->
gdiFont
);
/* Fixup the name and charset properties so that they match the
selected font */
old_font
=
SelectObject
(
get_dc
(),
This
->
gdiFont
);
GetTextFaceW
(
hdc
,
sizeof
(
text_face
)
/
sizeof
(
text_face
[
0
]),
text_face
);
if
(
lstrcmpiW
(
text_face
,
This
->
description
.
lpstrName
))
{
HeapFree
(
GetProcessHeap
(),
0
,
This
->
description
.
lpstrName
);
This
->
description
.
lpstrName
=
strdupW
(
text_face
);
}
GetTextMetricsW
(
hdc
,
&
tm
);
This
->
description
.
sCharset
=
tm
.
tmCharSet
;
/* While we have it handy, stash the realized font height for use by get_Size() */
This
->
nRealHeight
=
tm
.
tmHeight
-
tm
.
tmInternalLeading
;
/* corresponds to LOGFONT lfHeight */
SelectObject
(
hdc
,
old_font
);
}
/************************************************************************
...
...
@@ -683,7 +680,7 @@ static HRESULT WINAPI OLEFontImpl_get_Name(
if
(
pname
==
0
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
if
(
this
->
description
.
lpstrName
!=
0
)
*
pname
=
SysAllocString
(
this
->
description
.
lpstrName
);
...
...
@@ -741,7 +738,7 @@ static HRESULT WINAPI OLEFontImpl_get_Size(
if
(
!
psize
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
/*
* Convert realized font height in pixels to points descaled by current
...
...
@@ -785,7 +782,7 @@ static HRESULT WINAPI OLEFontImpl_get_Bold(
if
(
!
pbold
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
pbold
=
this
->
description
.
sWeight
>
550
;
...
...
@@ -820,7 +817,7 @@ static HRESULT WINAPI OLEFontImpl_get_Italic(
if
(
pitalic
==
0
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
pitalic
=
this
->
description
.
fItalic
;
...
...
@@ -856,7 +853,7 @@ static HRESULT WINAPI OLEFontImpl_get_Underline(
if
(
punderline
==
0
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
punderline
=
this
->
description
.
fUnderline
;
...
...
@@ -892,7 +889,7 @@ static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
if
(
pstrikethrough
==
0
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
pstrikethrough
=
this
->
description
.
fStrikethrough
;
...
...
@@ -928,7 +925,7 @@ static HRESULT WINAPI OLEFontImpl_get_Weight(
if
(
pweight
==
0
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
pweight
=
this
->
description
.
sWeight
;
...
...
@@ -964,7 +961,7 @@ static HRESULT WINAPI OLEFontImpl_get_Charset(
if
(
pcharset
==
0
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
pcharset
=
this
->
description
.
sCharset
;
...
...
@@ -999,7 +996,7 @@ static HRESULT WINAPI OLEFontImpl_get_hFont(
if
(
phfont
==
NULL
)
return
E_POINTER
;
if
(
this
->
dirty
)
realize_font
(
this
);
realize_font
(
this
);
*
phfont
=
this
->
gdiFont
;
TRACE
(
"Returning %p
\n
"
,
*
phfont
);
...
...
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