What size fonts does your Windows PC use?

Everything else that doesn't fall into one of the other PB categories.

What size fonts does your Windows PC use?

Small fonts (the default), or don't know
64
91%
Large fonts
4
6%
Custom size fonts
2
3%
 
Total votes: 70

PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

What size fonts does your Windows PC use?

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post 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 :)
Last edited by tinman on Wed Jun 01, 2005 4:52 pm, edited 2 times in total.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

misses finfo structure.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: What size fonts does your Windows PC use?

Post 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]
Last edited by PB on Sat Jul 19, 2014 2:15 am, edited 2 times in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: What size fonts does your Windows PC use?

Post 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?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: What size fonts does your Windows PC use?

Post 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. ;)
Last edited by PB on Sat Jul 19, 2014 2:14 am, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: What size fonts does your Windows PC use?

Post 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.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

I'm sad i can't vote again :(
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
klaver
Enthusiast
Enthusiast
Posts: 147
Joined: Wed Jun 28, 2006 6:55 pm
Location: Schröttersburg

Post 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() ?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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...
C64
Enthusiast
Enthusiast
Posts: 151
Joined: Sat Dec 18, 2010 4:40 am

Re:

Post by C64 »

Small fonts here. Large fonts makes most apps look ugly since most people don't code for them.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: What size fonts does your Windows PC use?

Post 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).
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply