Jump to content

Font weight scaling problem


Mungo
 Share

Recommended Posts

I have encountered that the font weight does not seem to scale the way I would have expected. The degree of "bold" does not always increase with the weight value but even reverses e.g. 700 being less bold than 600 ?

Does anyone have an idea?

Code and screenshot below.

Cheers

#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example()

Func Example()
    Local $f_size = 9
    Local $h_win = GUICreate ( "TEST GUI ... FONT weight", 400, 350)
    GUISetBkColor(0xffffff, $h_win)
    GUISetFont(10, 400, 0, "Arial", $h_win, 2)
    GUICtrlCreateLabel("Test FONT weight ...", 10, 10)

    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 200)", 10, 60, 380, 20)
    GUICtrlSetFont(-1, $f_size, 200)
    GUICtrlSetColor(-1, 0x000099)
    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 400)", 10, 90, 380, 20)
    GUICtrlSetFont(-1, $f_size, 400)
    GUICtrlSetColor(-1, 0x000099)
    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 500)", 10, 120, 380, 20)
    GUICtrlSetFont(-1, $f_size, 500)
    GUICtrlSetColor(-1, 0x000099)
    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 600)", 10, 150, 380, 20)
    GUICtrlSetFont(-1, $f_size, 600)
    GUICtrlSetColor(-1, 0x000099)
    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 700)", 10, 180, 380, 20)
    GUICtrlSetFont(-1, $f_size, 700)
    GUICtrlSetColor(-1, 0x000099)
    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 800)", 10, 210, 380, 20)
    GUICtrlSetFont(-1, $f_size, 800)
    GUICtrlSetColor(-1, 0x000099)
    GUICtrlCreateLabel("The quick brown fox jumps over ... (weight = 900)", 10, 240, 380, 20)
    GUICtrlSetFont(-1, $f_size, 900)
    GUICtrlSetColor(-1, 0x000099)

    Local $button = GUICtrlCreateButton("Close", 160, 310, 80, 20)
    GUISetState(@SW_SHOW)

    While 1
    Local $msg_pop = GUIGetMsg()
        Select
            Case $msg_pop = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg_pop = $button
                ExitLoop
        EndSelect
     WEnd
    GUIDelete()
EndFunc

post-57589-0-45336800-1403965638_thumb.p

Edited by Mungo
Link to comment
Share on other sites

  • Moderators

Mungo,

The Help file explains that Windows will accept anything from 1 to 10 "hundreds" as a "weight" value, but as I understand it what is actually displayed depends on the number of "weight"s a particular font contains for a given size. Different fonts have different numbers of internal "weight"s for each font size, although it seems 400 (normal) and 700 (bold) are supported in the majority of fonts at most sizes. :)

So you cannot predict exactly what you will get at other values, as if a given "weight" is not supported in a font at the required size Windows will choose what it considers as "most suitable" - which, as you have just shown, might not be what you expect. :wacko:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks Melba23,

Yes, the help is actually very detailed and good. However, what confused me was the (for me) unexpected kinks when increasing the "weight" factor. I tried various "weight" settings in a 100 increment from 0 to 1000 also with different fonts and sizes. Different fonts behave slightly differently especially in relation to the increase / decrease of boldness when weight factor is increased.

E. g. Arial, Segoe UI, Tahoma and Times New Roman actually show two kinks (steps) first increasing the "boldness" drastically (with 600) but then decreasing again to a lesser extent (>=700).

The results are that boldness from 0 to 500 is "normal", 600 is "very bold" and 700 to 1000 is "bold" lower again (Example left). It actually looks like a MS bug to me ...  ;)

Other fonts such as MS Sans Serif and MS Serif only show one kink when increasing the boldness factor (Example righ)

I wonder whether these results could also be related to the font version or OS used ? I use Win 7. Any other experiences with XP and Win 8 and 8.1 ?

Cheers

Mungo

post-57589-0-85566700-1404033989_thumb.p

post-57589-0-89049700-1404034136_thumb.p

Edited by Mungo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...