|
Joined: Jul 2006
Posts: 4,105
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,105 |
$width($chr(9),verdana,15) is 0, when $height() returns 19 When /drawtexting the tab character, it definitely takes some width, is this a bug?
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2002
Posts: 5,365
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,365 |
Thanks for your bug report. That is the length being returned by Windows APIs for the tab character. When I test this with /drawtext, eg. drawing the letters AB or the letters A $+ $chr(9) $+ B, using different fonts, the letters are spaced the same, ie. no space between the characters A and B. The same applies to several other non-printable characters.
|
|
|
|
Joined: Jul 2006
Posts: 4,105
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,105 |
Which font did you try? I tried both verdana and segoe ui symbol, width is 0 and there is a space between the two letters for me.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jul 2006
Posts: 4,105
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,105 |
Right, I mistested when triyng to replicate the issue outside of my big chunk of code. The issue only appears when using the drawtext -p switch to support control codes. //window -pdCBfo +l @test -1 -1 400 400 | drawrect -fr @test 16777215 0 0 0 400 400 | drawtext -rpn @test 0 "segoe ui symbol" 50 100 100 $+(A,$chr(9),B) | drawdot @test
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2002
Posts: 5,365
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,365 |
The -p switch in /drawtext makes it process control codes. You would need to use the same option in $width().
|
|
|
|
Joined: Jul 2006
Posts: 4,105
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,105 |
Even with $width($chr(9),verdana,25,0,1) or $width($chr(9),segoe ui symbol,25,1,1) I get 0, which should process control code
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Dec 2002
Posts: 5,365
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,365 |
Right, this is actually a little more complicated. $chr(9) is definitely zero length as returned by Windows APIs. However, some characters in custom @windows are processed slightly differently from normal windows, and this includes tab characters. $width() and $height() work independently of window type, since there is no window parameter. They currently default to the window type in which they are being called. If you call these from a custom @window, they will return the value you expect to match /drawtext. If you call them from any other window, they will return values for normal windows.
To make them match /drawtext, one solution would be to add a switch to $width() and $height() to make them use a custom @window type measurement.
Or, since they will usually be used with /drawtext, make them default to custom @window measurement. But this would break backward compatibility in measurement of text that includes tab characters in non-custom windows.
Last edited by Khaled; 17/03/20 10:56 AM.
|
|
|
|
Joined: Jul 2006
Posts: 4,105
Hoopy frood
|
OP
Hoopy frood
Joined: Jul 2006
Posts: 4,105 |
Indeed, indeed.
Where is that width coming from? Are you replacing the tab by some spaces in this case?
I'm fine with a new switch.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
|