I was working in C++ with the SDL Library for access to the framebuffer, and i needed to implement a text drawing routine, so I was making a series of bitmaps to make fixed width fonts. I came up with this nice little alias that should have worked great.
alias textchart {
if (!$window(@Chart)) { window -dfp @Chart -1 -1 320 240 }
var %font = $window(@Chart).font , %size = $window(@Chart).fontsize
var %fw = $width(A,%font,%size,0,0) , %fh = $height(A,%font,%size)
var %x = 0
while (%x < 255) {
inc %x
var %fw = $iif($width($chr(%x),%font,%size,0,0) > %fw,$v1,$v2)
var %fh = $iif($height($chr(%x),%font,%size) > %fh,$v1,$v2)
}
window -dfp @Chart -1 -1 $calc(%fw * 16) $calc(%fh * 16)
drawrect -f @Chart 0 0 0 0 640 480
var %x = 0
while (%x < 16) {
var %y = 0
while (%y < 16) {
var %chr = $chr($calc((%x * 16) + %y))
drawtext @Chart 15 $calc(%fw * %y) $calc(%fh * %x) $iif(%chr != $chr(32) && %chr != $null,$v1,$chr(160))
inc %y
}
inc %x
}
}
it finds the widest and tallest character, and resizes the @window according to that to fit all 256 characters into the window, so each letter has the exact same size box which i needed for fonts, while this alias works flawlessly, when I used the titlebar of the @window and changed the font, and did another /textchart to build a new font map, when I did a /drawsave I noticed the bitmap from the drawsave was NOT the same size as the windows .dw and .dh, only the very first time I issued the command was this correct.. To reproduce this error with drawsave here is what i did...
my default font is Fixedsys, i did /textchart, then did a /drawsave @chart Fixedsys.bmp, then I clicked the icon in the titlebar, went to fonts, changed it to Terminal (font size 9, default) and did another /textchart, so far so good looks right... did a /drawsave @chart Terminal.bmp and BAM, Terminal.bmp was way too big on JUST The height. I had to crop the picture for my bmp chart of the font which was no big deal, but it was an annoying step and figured it deserved a bug report
![smile smile](/images/graemlins/mirc/smile.gif)