Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dpi_rev'
Browse files Browse the repository at this point in the history
  • Loading branch information
prepare committed Jul 3, 2020
2 parents 053e328 + 36130dd commit 69f741e
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 80 deletions.
5 changes: 2 additions & 3 deletions Demo/Windows/PixelFarmSample.WinForms/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using PixelFarm.Contours;

using Typography.OpenFont;
using Typography.OpenFont.Trimmable;
using Typography.TextLayout;
using Typography.Contours;
using Typography.WebFont;
Expand Down Expand Up @@ -817,8 +816,8 @@ private void button3_Click(object sender, EventArgs e)
OpenFontReader openFontReader = new OpenFontReader();
PreviewFontInfo previewFontInfo = openFontReader.ReadPreview(fs);
}
}
}


private void cmdTestReloadGlyphs_Click(object sender, EventArgs e)
{
Expand Down
34 changes: 33 additions & 1 deletion Demo/Windows/PixelFarmSample.WinForms/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//MIT, 2016-2017, WinterDev
//MIT, 2016-present, WinterDev
using System;
using System.Windows.Forms;
using Typography.OpenFont;

namespace SampleWinForms
{
static class Program
Expand All @@ -11,10 +13,40 @@ static class Program
[STAThread]
static void Main()
{
//---------
//user can skip this, and set it by app-manifest
//but here I, set DPI-aware by API :)
//-------


bool dpi_result = SetProcessDPIAware();
Typeface.DefaultDpi = GetDpiForSystem();


Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}


//-------
//https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware?redirectedfrom=MSDN
[System.Runtime.InteropServices.DllImport("user32")]
static extern bool SetProcessDPIAware();

//UINT GetDpiForWindow(
// HWND hwnd
//);
//https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow

[System.Runtime.InteropServices.DllImport("user32")]
static extern uint GetDpiForWindow(IntPtr ptr);

//UINT GetDpiForSystem();
//https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforsystem
[System.Runtime.InteropServices.DllImport("user32")]
static extern uint GetDpiForSystem();
//-------
}

}
2 changes: 1 addition & 1 deletion Demo/Windows/PixelFarmTextBox.WinForms/SampleTextBox.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//MIT, 2016-2017, WinterDev
//MIT, 2016-present, WinterDev
using System;
using System.Windows.Forms;
namespace SampleWinForms
Expand Down
Loading

0 comments on commit 69f741e

Please sign in to comment.