Page 1 of 1

Default font under Win 8 and 10

Posted: Sun Aug 14, 2016 3:38 pm
by James Bott
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

Re: Default font under Win 8 and 10

Posted: Sun Aug 14, 2016 4:53 pm
by nageswaragunupudi
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

Re: Default font under Win 8 and 10

Posted: Sun Aug 14, 2016 5:08 pm
by Antonio Linares
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: Select all | Expand

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:oFont:cFaceName )

the same works for dialogs and controls too

Re: Default font under Win 8 and 10

Posted: Sun Aug 14, 2016 5:21 pm
by Enrico Maria Giordano
Unfortunately the system font is not using for resource dialogs, if I'm not wrong.

EMG

Re: Default font under Win 8 and 10

Posted: Sun Aug 14, 2016 5:29 pm
by nageswaragunupudi
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.

Re: Default font under Win 8 and 10

Posted: Wed Aug 17, 2016 10:17 pm
by James Bott
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

Re: Default font under Win 8 and 10

Posted: Wed Aug 17, 2016 10:22 pm
by cnavarro
Function GetSysFont(), has been modified

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

Re: Default font under Win 8 and 10

Posted: Wed Aug 17, 2016 11:28 pm
by nageswaragunupudi
Mr James

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

Re: Default font under Win 8 and 10

Posted: Wed Aug 17, 2016 11:32 pm
by James Bott
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

Re: Default font under Win 8 and 10

Posted: Wed Aug 17, 2016 11:34 pm
by James Bott
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

Re: Default font under Win 8 and 10

Posted: Thu Aug 18, 2016 8:30 am
by Enrico Maria Giordano
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

Re: Default font under Win 8 and 10

Posted: Thu Aug 18, 2016 8:31 am
by Enrico Maria Giordano
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