FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Default font under Win 8 and 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Default font under Win 8 and 10
Posted: Sun Aug 14, 2016 03:38 PM

Microsoft's guidelines for apps running under Windows 8 and 10 state that they should be using the font Segoe UI.

I am wondering how we can do this with FW without conditionally assigning a new font to every window and dialog.

I am interested to know how font inheritance works. If, for instance, we assign a new font to an app's main window, then do all other windows and dialogs inherit this font? Or, do we have to assign a new font to every window and dialog?

Would it help if the Window class had the font assigned as CLASSDATA? Wouldn't then all other windows inherit the newly assigned font? Dialogs? How would this affect existing apps?

One other concern is that if the font is dynamically changed depending on the Windows version, is this going to affect the formatting design?

Other thoughts on this welcome.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Default font under Win 8 and 10
Posted: Sun Aug 14, 2016 04:53 PM

This is the present implementation.

A window/dialog/control having a parent ( clause OF oWnd or OF oDlg specifies the parent) inherits font of that parent unless another font is assigned to it.
A window or dialog (from source) not having a parent, by default is assigned with GetSysFont() size -12.

Function GetSysFont() is in getsysin.prg

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Default font under Win 8 and 10
Posted: Sun Aug 14, 2016 05:08 PM
James,

FWH uses function GetSysFont() to retrieve the font name to use.

Currently we are returning "Ms Sans Serif", so in order to follow Microsoft guidelines we are going to modify it
this way:
Code (fw): Select all Collapse
function GetSysFont()

   do case
      case ! IsWinNt() .and. ! IsWin95()  // Win 3.1
           return "System"
   endcase

return If( IsWindows10() .or. IsWin8(), "Segoe UI", "Ms Sans Serif" )


FWH reuses fonts in order to reduce the GDI consume. Class TFont has the DATAs nCount, lDestroy
to know in how many different places the font is being used. lDestroy becomes true to know when
the font has to be destroyed finally.

You can check the used font doing this:

MsgInfo( oWnd:cFaceName )

the same works for dialogs and controls too
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Default font under Win 8 and 10
Posted: Sun Aug 14, 2016 05:21 PM

Unfortunately the system font is not using for resource dialogs, if I'm not wrong.

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Default font under Win 8 and 10
Posted: Sun Aug 14, 2016 05:29 PM

When a dialog is created from resource and no font is assigned, the GetFont() method tries to created a font object based on the font-metrics of the font contained in the resource. Theoretically the created font object should be identical to the font defined in the resource. But there is a bug and it is different. I could not find how to solve it.

This bug is same / similar to the bug in choosefont(). The font finally created differs in the specs we choose in the font dialog.

Only experts like Mr Antonio and Mr EMG can fix it.

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Default font under Win 8 and 10
Posted: Wed Aug 17, 2016 10:17 PM

Sorry for my late reply.

Thanks everyone for their input.

Antonio, that would be great if you can make those changes so we don't have to define and assign fonts all the time.

I am concerned about the dialog font issue. It limits our ability to conform to Win8-10 specs. It sounds like the only solution right now would be to not use dialogs from resources? That would be a big pain.

Nages or Enrico, are you saying that this is problem with Windows or with FWH or xHarbour or Harbour?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Default font under Win 8 and 10
Posted: Wed Aug 17, 2016 10:22 PM

Function GetSysFont(), has been modified

viewtopic.php?f=16t=32792#p193101

&

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Default font under Win 8 and 10
Posted: Wed Aug 17, 2016 11:28 PM
Mr James

There is absolutely no problem with dialogs from resources as long as you assign a font to the dialog.
Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Default font under Win 8 and 10
Posted: Wed Aug 17, 2016 11:32 PM
Nages,

There is absolutely no problem with dialogs from resources as long as you assign a font to the dialog.


Ok, but wouldn't it be better to use the getSysFont() to assign it automatically in FWH's dialog class? This would still allow us to override the default by defining a new font.

Otherwise, we have to define the font for every dialog.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Default font under Win 8 and 10
Posted: Wed Aug 17, 2016 11:34 PM

Nages,

Of course, we would need to test this out to see if the Segoe font might not work with existing dialogs without messing up the layout. That may be an issue.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Default font under Win 8 and 10
Posted: Thu Aug 18, 2016 08:30 AM
James Bott wrote:Nages,

There is absolutely no problem with dialogs from resources as long as you assign a font to the dialog.


Ok, but wouldn't it be better to use the getSysFont() to assign it automatically in FWH's dialog class? This would still allow us to override the default by defining a new font.

Otherwise, we have to define the font for every dialog.

James


Yes, absolutely impractical. I vote for auto assign font too, if it's a viable solution.

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Default font under Win 8 and 10
Posted: Thu Aug 18, 2016 08:31 AM
James Bott wrote:Nages,

Of course, we would need to test this out to see if the Segoe font might not work with existing dialogs without messing up the layout. That may be an issue.

James


Of course.

EMG

Continue the discussion