Possible bug: Word-wrap oddity
#7
@Pete:  The glitch here is in the sheer fact that you start printing at pixel 1, instead of pixel 0, which is wrong when dealing with non-monospaced fonts.

Code: (Select All)
handle& = _NewImage(800, 600, 256)
Screen handle&

fontpath$ = Environ$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
font& = _LoadFont(fontpath$, 16)
_Font font&

Sleep

Cls
Print "Demo with monospace added.": Print
For i = 0 To 79
    ' With monospace added, this will print as one line.
    Color 4
    Locate 2, 10 * i: Print "*";
    Color 3
    _PrintString (10 * i, _FontHeight * 3), "*"
Next

When you run, LOCATE gives you an error on line 15 for the first character, as it refuses to print at pixel #0.  (Printstring doesn't care about this and is happy to print to such a point.)

Since you start printing characters from pixel 1 to 10...11 to 20...21 to 30...31 to 40....  you'll end up with the last pixel going on 791 to 800.... but the screen is dimensioned from 0 to 799, so you're off-screen and have to move down to the next line to print.

Adjust your print position to account for that single pixel offset (which is goofy), and then you're golden!

Code: (Select All)
handle& = _NewImage(800, 600, 256)
Screen handle&

fontpath$ = Environ$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
font& = _LoadFont(fontpath$, 16)
_Font font&

'Sleep

Cls
Print "Demo with monospace added.": Print
For i = 0 To 79
    ' With monospace added, this will print as one line.
    Color 4
    If i = 0 Then
        Locate 2, 1: Print "*" 'shift forward one pixel to print at LOC 1, not LOC 0.
    Else
        Locate 2, 10 * i: Print "*";
    End If
    Color 3
    _PrintString (10 * i, _FontHeight * 3), "*"
Next

It's not the lack of monospace which is screwing things up, it's the restriction that PRINT has to start on the 1st pixel, and not the 0th one when dealing with non-monsopaced fonts.
Reply


Messages In This Thread
Possible bug: Word-wrap oddity - by hanness - 05-04-2022, 06:41 AM
RE: Possible bug: Word-wrap oddity - by Pete - 05-04-2022, 08:38 AM
RE: Possible bug: Word-wrap oddity - by Pete - 05-04-2022, 09:50 AM
RE: Possible bug: Word-wrap oddity - by SMcNeill - 05-04-2022, 10:35 AM
RE: Possible bug: Word-wrap oddity - by hanness - 05-04-2022, 04:35 PM
RE: Possible bug: Word-wrap oddity - by Pete - 05-04-2022, 05:06 PM
RE: Possible bug: Word-wrap oddity - by SMcNeill - 05-04-2022, 05:50 PM
RE: Possible bug: Word-wrap oddity - by hanness - 05-04-2022, 06:15 PM
RE: Possible bug: Word-wrap oddity - by SMcNeill - 05-04-2022, 06:18 PM
RE: Possible bug: Word-wrap oddity - by Pete - 05-04-2022, 06:29 PM
RE: Possible bug: Word-wrap oddity - by SMcNeill - 05-04-2022, 06:50 PM
RE: Possible bug: Word-wrap oddity - by Pete - 05-04-2022, 09:57 PM



Users browsing this thread: 6 Guest(s)