Different font design.

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Different font design.

Post by palikem »

Hi everybody

I use a custom font in the program

Code: Select all

#include "AdcApp.h"
#include "AdcFrm.h"

IMPLEMENT_APP(AdcFrmApp)

bool AdcFrmApp::OnInit()
{
//************************ NACITANIE VLASTNEHO PISMA DO WIN.... ****************
    wxString fontfile( "Files\\OpenReg.ttf" );
    AddFontResource( fontfile.wc_str() );
    
    AdcFrm* frame = new AdcFrm(NULL);
    SetTopWindow(frame);
    frame->Show();
    return true;
}
 
int AdcFrmApp::OnExit()
{
//************************ ZRUSENIE VLASTNEHO PISMA Z WIN ..... ****************
    wxString fontfile( "Files\\OpenReg.ttf" );
    RemoveFontResource( fontfile.wc_str() );
    
	return 0;
	
}
Why does the font look different in win XP. Program resolution is in both cases 800x600.
There is some solution ?

Win8
frame.jpg
Win XP
frame1.jpg
Thank you for the reactions.

Win8
wxDev-C++ 7.4.2.569
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Different font design.

Post by PB »

I do not see setting any font anywhere in the code you posted?
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: Different font design.

Post by palikem »

Code: Select all

void AdcFrm::AdcFrmPaint(wxPaintEvent& event)
{
     wxPaintDC dc(this);

    dc.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, false, _("Open Sans")));

    dc.SetPen(*wxBLACK);
    dc.DrawText(mfile[slo], file.x, file.y+5);
    dc.DrawText(moptions[slo], options.x, options.y+5);
    dc.DrawText(mcalibration[slo], calibration.x, calibration.y+5);
    dc.DrawText(mhelp[slo], help.x, help.y+5);
    
    dc.GetTextExtent(mmeasur[slo], &u1, &h1); poli=(meas.height-h1)/2; polt=(meas.width-u1)/2;
    dc.DrawText(mmeasur[slo], meas.x+polt, meas.y+poli);
    dc.GetTextExtent(mcali[slo], &u1, &h1); poli=(meas.height-h1)/2; polt=(meas.width-u1)/2;
    dc.DrawText(mcali[slo], cali.x+polt, cali.y+poli);
    
    dc.DrawText(wxT("\x03D1 = 45\x00B0"), u45.x+20, u45.y+poli);
    dc.DrawText(wxT("\x03D1 = 90\x00B0"), u90.x+20, u90.y+poli);
    dc.DrawText(wxT("\x03D1 = 135\x00B0"), u135.x+20, u135.y+poli);
    
    dc.DrawText(mangular[slo], u_cent.x+20, u_cent.y+poli);
    
    ..........
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Different font design.

Post by PB »

palikem wrote:

Code: Select all

dc.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, false, _("Open Sans")));
I believe this is wrong - the temporary wxFont is destroyed once SetFont() returns, although Windows may tolerate it and not destroy the selected underlying HFONT so it may not be relevant here, just like using wrong text macro (_()).

Anyway, create an instance of wxFont and then check if it was created successfully (wxFont::IsOk()) and therefore the default font is not used. I would also check the strings returned by wxFont::GetNativeFontInfoUserDesc() to see what font was actually created on both systems...
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: Different font design.

Post by palikem »

Win XP
wxFont::IsOk() = true.
wxFont::GetNativeFontInfoDesc() = 0;-13;0;0;0;400;0;0;0;1;0;0;2;32;Open Sans

win8
wxFont::IsOk() = true.
wxFont::GetNativeFontInfoDesc() = 0;-17;0;0;0;400;0;0;0;1;0;0;2;32;Open Sans
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Different font design.

Post by doublemax »

Is everything on the screen custom-drawn? If yes, can you add a wxButton with default size and some label in this font and check how it looks like?

What's the setting for Desktop Display Scaling on the Windows 8 machine? If it's not 100%, is your application marked as "dpi aware"?
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Different font design.

Post by PB »

In addition to what doublemax said, you can check if there is any difference in PPI on the two machines, using wxDC::GetPPI().
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: Different font design.

Post by palikem »

Win8
Desktop Display Scaling - 125%
wxDC::GetPPI()
Width = 1120
Height = 120

win XP
Desktop Display Scaling - I can not find
wxDC::GetPPI()
Width = 196
Height = 96
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Different font design.

Post by PB »

Well, the program works as it should then. By increasing Windows DPI setting to 125% (96 -> 120), the user requested that everything should be drawn bigger which your program happily obliges.

The actual issue may be that not all parts of the program respect the customized setting...
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: Different font design.

Post by palikem »

It's possible to do something about it.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Different font design.

Post by PB »

I guess that depends on what you mean by "something".

If you mean bringing the rest of the application up to the task of properly supporting high-DPI, it certainly could be possible but you may run into limitations stemming from using an obsolete wxWidgets - IIRC you are stuck with wxWidgets 2.8? You need to identify the problem areas and fix those. I.e., avoid using hardcoded values wherever possible (using sizers) and when impossible, use device independent points (DIPs) instead of pixels....

See generic information about high-DPI support on MSW
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
https://blogs.windows.com/buildingapps/ ... ktop-apps/
palikem
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sat Oct 28, 2017 9:33 am
Location: Slovensko

Re: Different font design.

Post by palikem »

Thank you PB and Doublemax
Post Reply