Page 1 of 2
What size fonts does your Windows PC use?
Posted: Wed Jun 01, 2005 12:02 pm
by PB
What size fonts does your Windows PC use? I've known for some time that
anything created with a Small Fonts system looks ugly on a Large Fonts
system, and I'm tired of double-coding my gadgets to support both.
Or, does anyone know of a simple calculation so I could use vars to create
my gadget sizes? I know how to determine whether the system is using
Small or Large fonts, by using this small procedure which returns 1 (#True)
if Small fonts are in use, and anything else if not:
Code: Select all
Procedure SmallFonts()
a=GetDesktopWindow_() : b=GetDC_(a) : c=GetDeviceCaps_(b,#LOGPIXELSX)
ReleaseDC_(a,b) : ProcedureReturn 97-c ; Returns 1 (c=96) for small.
EndProcedure
Posted: Wed Jun 01, 2005 1:54 pm
by tinman
Try this, works for me (it's a cut and paste from one of my PB sources but it should work as-is):
Code: Select all
DefType.LOGFONT finfo
font = GetStockObject_(#DEFAULT_GUI_FONT)
If font
GetObject_(font, SizeOf(LOGFONT), @finfo)
fname = PeekS(@finfo\lfFaceName[0])
fsize = finfo\lfHeight
If fsize < 0
; Negative height represents actual device units height (pixels)
fsize = -fsize
loadsize = 8 ; fallback in case we cannot get the DPI
ElseIf fsize = 0
; Uses a default height
fsize = 0
loadsize = 8
Else
; Positive height uses character cell height (ems) - which is the height we actually load
loadsize = fsize
fsize = 0
EndIf
; Try to find out font size and size we should load based on DPI settings
desktop_window = GetDesktopWindow_()
If desktop_window
im_hdc = GetDC_(desktop_window)
If im_hdc
vdpi.l=GetDeviceCaps_(im_hdc, #LOGPIXELSY)
ReleaseDC_(desktop_window, im_hdc)
; Figure out size to load or pixel height
If fsize=0
fsize = Round(loadsize * vdpi / 72 + 0.5, 0)
Else
loadsize = Round(fsize * 72 / vdpi + 0.5, 0)
EndIf
EndIf
EndIf
EndIf
DeleteObject_(font)
Debug "Font height in pixels = "+Str(fsize)
Debug "Font size to load = "+Str(loadsize)
So you can multiply or set your gadget heights based on the pixel font size, and also load it using LoadFont() so that you can use TextLength() or whatever the command is to get the length of a string in that font.
Edit: Added definition of finfo variable, thanks thefool.
Edit: Changed guess at pixel length function :)
Posted: Wed Jun 01, 2005 2:23 pm
by thefool
misses finfo structure.
Posted: Wed Jun 01, 2005 4:40 pm
by Trond
I don't think you should bother. Or you can have a routine to scale everything (buttons, etc...) so that the user can make them fit their fonts.
Re: What size fonts does your Windows PC use?
Posted: Sat Jun 11, 2005 5:13 am
by PB
I did some testing and this is the best I can come up with for now... it detects
if the system is using Large Fonts, and simply reduces the font size for each
gadget to fit (and yes, I'm aware of the irony of reducing the fonts when the
user has specifically set his PC to use Large Fonts).
[Code removed; dumb idea]
Re: What size fonts does your Windows PC use?
Posted: Sat Jun 11, 2005 7:28 pm
by tinman
People have large fonts for a reason, making your app use smaller fonts just because you don't want to go to the effort (and yes, it is something I hate having to do) of coding size calculations into your app is something I would find incredibly annoying.
I think Fred was planning on having some GUI layout functionality in newer versions of PB (something he mentioned on IRC once, he was looking at the Java ways at the time). Perhaps handling sizes could be incorporated there?
Re: What size fonts does your Windows PC use?
Posted: Sun Jun 12, 2005 2:02 am
by PB
> making your app use smaller fonts just because you don't want to go to
> the effort (and yes, it is something I hate having to do) of coding size
> calculations into your app is something I would find incredibly annoying
I fully understand and agree, which is why I said it was ironic.

Re: What size fonts does your Windows PC use?
Posted: Sat Dec 01, 2007 1:58 am
by PB
Just bumping this topic in case anybody new here hasn't voted yet.

It's been 2 years since the last post so it might be good to get some
fresh votes in.
Posted: Sat Dec 01, 2007 2:04 am
by thefool
I'm sad i can't vote again

Posted: Thu Aug 06, 2009 11:47 pm
by PB
Bumping this topic again to generate a few more votes from the newbies,
since a superior tip was posted by freak a few days ago. The poll here is
still nice to answer, though.
Posted: Sat Aug 08, 2009 10:02 am
by Trond
I now use a custom setting (dpi 103). You shouldn't hard-code for large/small fonts. Make the gadget sizes dependent on the actual font size.
Posted: Sat Aug 08, 2009 12:25 pm
by klaver
Code: Select all
If LoadFont(1, "Tahoma", 12)
SetGadgetFont(#PB_Default, FontID(1))
EndIf
In my opinion it's the best solution. Enlarging gadgets for bigger fonts is way too complicated. What if the GUI is very complex and there's no enough space between controls? ScrollAreaGadget() ?
Posted: Sat Aug 08, 2009 12:40 pm
by Trond
klaver wrote:Code: Select all
If LoadFont(1, "Tahoma", 12)
SetGadgetFont(#PB_Default, FontID(1))
EndIf
In my opinion it's the best solution.
No, it is absolutely silly. Because when someone uses the large font option, font size 12 gets larger...
Re:
Posted: Sun Jan 02, 2011 1:31 am
by C64
Small fonts here. Large fonts makes most apps look ugly since most people don't code for them.
Re: What size fonts does your Windows PC use?
Posted: Sun Jan 02, 2011 2:42 am
by IdeasVacuum
...The scaling efforts fall on a hard place once your app is released for several languages. Strings in some languages are relatively short compared to English (e.g. Mandarin) whilst others are often much much longer (e.g. German).