mIRC Home    About    Download    Register    News    Help

Print Thread
#266960 12/03/20 06:57 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
$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
Wims #266972 14/03/20 03:25 PM
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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.

Khaled #266973 14/03/20 04:33 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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
Khaled #266974 14/03/20 05:39 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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.

Quote
//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
Wims #266985 15/03/20 09:22 PM
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
The -p switch in /drawtext makes it process control codes. You would need to use the same option in $width().

Khaled #266987 15/03/20 10:37 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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
Wims #266998 17/03/20 09:28 AM
Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
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.
Khaled #266999 17/03/20 06:04 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
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

Link Copied to Clipboard