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
ed8a3304
Commit
ed8a3304
authored
Jul 16, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Factor out units_to_pixels() helper.
parent
9da37c76
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
63 deletions
+34
-63
font.c
dlls/gdiplus/font.c
+7
-63
gdiplus.c
dlls/gdiplus/gdiplus.c
+26
-0
gdiplus_private.h
dlls/gdiplus/gdiplus_private.h
+1
-0
No files found.
dlls/gdiplus/font.c
View file @
ed8a3304
...
...
@@ -118,41 +118,8 @@ typedef struct
static
GpStatus
clone_font_family
(
const
GpFontFamily
*
,
GpFontFamily
**
);
static
const
REAL
mm_per_inch
=
25
.
4
;
static
const
REAL
inch_per_point
=
1
.
0
/
72
.
0
;
static
GpFontCollection
installedFontCollection
=
{
0
};
static
LONG
em_size_to_pixel
(
REAL
em_size
,
Unit
unit
,
LONG
dpi
)
{
switch
(
unit
)
{
default:
FIXME
(
"Unhandled unit type: %d
\n
"
,
unit
);
return
0
;
case
UnitPixel
:
case
UnitWorld
:
/* FIXME: Figure out when World != Pixel */
return
em_size
;
case
UnitDisplay
:
FIXME
(
"Unknown behavior for UnitDisplay! Please report!
\n
"
);
/* FIXME: Figure out how this works...
* MSDN says that if "DISPLAY" is a monitor, then pixel should be
* used. That's not what I got. Tests on Windows revealed no output,
* and the tests in tests/font crash windows */
return
0
;
case
UnitPoint
:
return
em_size
*
dpi
*
inch_per_point
;
case
UnitInch
:
return
em_size
*
dpi
;
case
UnitDocument
:
return
em_size
*
dpi
/
300
.
0
;
/* Per MSDN */
case
UnitMillimeter
:
return
em_size
*
dpi
/
mm_per_inch
;
}
}
/*******************************************************************************
* GdipCreateFont [GDIPLUS.@]
*
...
...
@@ -195,7 +162,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
stat
=
GdipGetFamilyName
(
fontFamily
,
lfw
.
lfFaceName
,
LANG_NEUTRAL
);
if
(
stat
!=
Ok
)
return
stat
;
lfw
.
lfHeight
=
-
em_size_to_pixel
(
emSize
,
unit
,
fontFamily
->
dpi
);
lfw
.
lfHeight
=
-
units_to_pixels
(
emSize
,
unit
,
fontFamily
->
dpi
);
lfw
.
lfWeight
=
style
&
FontStyleBold
?
FW_BOLD
:
FW_REGULAR
;
lfw
.
lfItalic
=
style
&
FontStyleItalic
;
lfw
.
lfUnderline
=
style
&
FontStyleUnderline
;
...
...
@@ -483,7 +450,7 @@ GpStatus WINGDIPAPI GdipGetLogFontA(GpFont *font, GpGraphics *graphics,
void
get_log_fontW
(
const
GpFont
*
font
,
GpGraphics
*
graphics
,
LOGFONTW
*
lf
)
{
/* FIXME: use graphics */
lf
->
lfHeight
=
-
em_size_to_pixel
(
font
->
emSize
,
font
->
unit
,
font
->
family
->
dpi
);
lf
->
lfHeight
=
-
units_to_pixels
(
font
->
emSize
,
font
->
unit
,
font
->
family
->
dpi
);
lf
->
lfWidth
=
0
;
lf
->
lfEscapement
=
0
;
lf
->
lfOrientation
=
0
;
...
...
@@ -590,47 +557,24 @@ GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi,
GpStatus
stat
;
INT
style
;
UINT16
line_spacing
,
em_height
;
REAL
font_
height
,
font_
size
;
REAL
font_size
;
if
(
!
font
||
!
height
)
return
InvalidParameter
;
TRACE
(
"%p (%s), %f, %p
\n
"
,
font
,
debugstr_w
(
font
->
family
->
FamilyName
),
dpi
,
height
);
font_size
=
get_font_size
(
font
);
font_size
=
units_to_pixels
(
get_font_size
(
font
),
font
->
unit
,
dpi
);
style
=
get_font_style
(
font
);
stat
=
GdipGetLineSpacing
(
font
->
family
,
style
,
&
line_spacing
);
if
(
stat
!=
Ok
)
return
stat
;
stat
=
GdipGetEmHeight
(
font
->
family
,
style
,
&
em_height
);
if
(
stat
!=
Ok
)
return
stat
;
font_height
=
(
REAL
)
line_spacing
*
font_size
/
(
REAL
)
em_height
;
switch
(
font
->
unit
)
{
case
UnitPixel
:
case
UnitWorld
:
*
height
=
font_height
;
break
;
case
UnitPoint
:
*
height
=
font_height
*
dpi
*
inch_per_point
;
break
;
case
UnitInch
:
*
height
=
font_height
*
dpi
;
break
;
case
UnitDocument
:
*
height
=
font_height
*
(
dpi
/
300
.
0
);
break
;
case
UnitMillimeter
:
*
height
=
font_height
*
(
dpi
/
mm_per_inch
);
break
;
default:
FIXME
(
"Unhandled unit type: %d
\n
"
,
font
->
unit
);
return
NotImplemented
;
}
*
height
=
(
REAL
)
line_spacing
*
font_size
/
(
REAL
)
em_height
;
TRACE
(
"%s,%d
(unit %d)
=> %f
\n
"
,
debugstr_w
(
font
->
family
->
FamilyName
),
font
->
otm
.
otmTextMetrics
.
tmHeight
,
font
->
unit
,
*
height
);
TRACE
(
"%s,%d => %f
\n
"
,
debugstr_w
(
font
->
family
->
FamilyName
),
font
->
otm
.
otmTextMetrics
.
tmHeight
,
*
height
);
return
Ok
;
}
...
...
dlls/gdiplus/gdiplus.c
View file @
ed8a3304
...
...
@@ -35,6 +35,9 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
gdiplus
);
static
const
REAL
mm_per_inch
=
25
.
4
;
static
const
REAL
inch_per_point
=
1
.
0
/
72
.
0
;
static
Status
WINAPI
NotificationHook
(
ULONG_PTR
*
token
)
{
TRACE
(
"%p
\n
"
,
token
);
...
...
@@ -340,6 +343,29 @@ REAL convert_unit(REAL logpixels, GpUnit unit)
}
}
/* converts a given unit to its value in pixels */
REAL
units_to_pixels
(
REAL
units
,
GpUnit
unit
,
REAL
dpi
)
{
switch
(
unit
)
{
case
UnitPixel
:
case
UnitWorld
:
case
UnitDisplay
:
return
units
;
case
UnitPoint
:
return
units
*
dpi
*
inch_per_point
;
case
UnitInch
:
return
units
*
dpi
;
case
UnitDocument
:
return
units
*
dpi
/
300
.
0
;
/* Per MSDN */
case
UnitMillimeter
:
return
units
*
dpi
/
mm_per_inch
;
default:
FIXME
(
"Unhandled unit type: %d
\n
"
,
unit
);
return
0
;
}
}
/* Calculates Bezier points from cardinal spline points. */
void
calc_curve_bezier
(
CONST
GpPointF
*
pts
,
REAL
tension
,
REAL
*
x1
,
REAL
*
y1
,
REAL
*
x2
,
REAL
*
y2
)
...
...
dlls/gdiplus/gdiplus_private.h
View file @
ed8a3304
...
...
@@ -49,6 +49,7 @@ extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
extern
REAL
gdiplus_atan2
(
REAL
dy
,
REAL
dx
)
DECLSPEC_HIDDEN
;
extern
GpStatus
hresult_to_status
(
HRESULT
res
)
DECLSPEC_HIDDEN
;
extern
REAL
convert_unit
(
REAL
logpixels
,
GpUnit
unit
)
DECLSPEC_HIDDEN
;
extern
REAL
units_to_pixels
(
REAL
units
,
GpUnit
unit
,
REAL
dpi
)
DECLSPEC_HIDDEN
;
extern
GpStatus
graphics_from_image
(
GpImage
*
image
,
GpGraphics
**
graphics
)
DECLSPEC_HIDDEN
;
...
...
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