Using 0x0200 to vertically center text

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Using 0x0200 to vertically center text

14 Nov 2014, 07:40

What determines exactly how text is vertically centered? I've found that some fonts tend to center more accurately than others. I've also seen slight differences in the positioning of words such as pig, hat,and dog - as if the absence or presence of ascenderers/descenders makes a difference. How to ensure everything is dead center? Thanks.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Using 0x0200 to vertically center text

14 Nov 2014, 08:13

Can you show an example?

Code: Select all

Gui, Margin, 5, 5
Gui, Add, Text, xm ym  w100 h22 0x0000 0x00800000, % "0x0000"
Gui, Add, Text, xm y+5 w100 h22 0x0001 0x00800000, % "0x0001"
Gui, Add, Text, xm y+5 w100 h22 0x0002 0x00800000, % "0x0002"
Gui, Add, Text, xm y+5 w100 h22 0x0200 0x00800000, % "0x0200"
Gui, Add, Text, xm y+5 w100 h22 0x0201 0x00800000, % "0x0201"
Gui, Add, Text, xm y+5 w100 h22 0x0202 0x00800000, % "0x0202"
Gui, Show, AutoSize
return


GuiEscape:
GuiClose:
ExitApp
Image
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
PuzzledGreatly
Posts: 1303
Joined: 29 Sep 2013, 22:18

Re: Using 0x0200 to vertically center text

14 Nov 2014, 22:02

Thanks, the problem shows up with larger text sizes. Try this example:

Code: Select all

Gui, Margin, 5, 5
Gui, font, s50, Arial
Gui, Add, text, w300 h100 center 0x0200 0x00800000, dog
Gui, font, s50, Comic Sans MS
Gui, Add, text, w300 h100 center 0x0200 0x00800000, dog
Gui, font, s50, Courier
Gui, Add, text, w300 h100 center 0x0200 0x00800000, dog
Gui, font, s50, Times New Roman
Gui, Add, text, w300 h100 center 0x0200 0x00800000, dog
Gui, Show, AutoSize
return

GuiEscape:
GuiClose:
ExitApp
I think all of them are slightly nearer the bottom - very evident with Comic Sans. I wondered if there might be a formula to shift them back up towards true center. I'm thinking of when text is overlayed over a picture or progress control.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: fiaztv1, Pianist and 176 guests