Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
41f66eb6
Unverified
Commit
41f66eb6
authored
Dec 27, 2018
by
mrbean-bremen
Browse files
Use DPI setting from system instead of using a hard-coded value
- see #384
parent
ec2c12ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Source/SvgDocument.cs
View file @
41f66eb6
...
...
@@ -14,6 +14,7 @@ using Svg.Css;
using
System.Threading
;
using
System.Globalization
;
using
Svg.Exceptions
;
using
System.Runtime.InteropServices
;
namespace
Svg
{
...
...
@@ -22,10 +23,29 @@ namespace Svg
/// </summary>
public
class
SvgDocument
:
SvgFragment
,
ITypeDescriptorContext
{
public
static
readonly
int
PointsPerInch
=
96
;
public
static
readonly
int
PointsPerInch
=
GetSystemDpi
()
;
private
SvgElementIdManager
_idManager
;
private
Dictionary
<
string
,
IEnumerable
<
SvgFontFace
>>
_fontDefns
=
null
;
private
static
int
GetSystemDpi
()
{
IntPtr
hDC
=
GetDC
(
IntPtr
.
Zero
);
const
int
LOGPIXELSY
=
90
;
int
result
=
GetDeviceCaps
(
hDC
,
LOGPIXELSY
);
ReleaseDC
(
IntPtr
.
Zero
,
hDC
);
return
result
;
}
[
DllImport
(
"gdi32.dll"
)]
private
static
extern
int
GetDeviceCaps
(
IntPtr
hdc
,
int
nIndex
);
[
DllImport
(
"user32.dll"
)]
private
static
extern
IntPtr
GetDC
(
IntPtr
hWnd
);
[
DllImport
(
"user32.dll"
)]
private
static
extern
int
ReleaseDC
(
IntPtr
hWnd
,
IntPtr
hDC
);
internal
Dictionary
<
string
,
IEnumerable
<
SvgFontFace
>>
FontDefns
()
{
if
(
_fontDefns
==
null
)
...
...
Write
Preview
Supports
Markdown
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