Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is _NEWIMAGE just a nicer way of saying, "Special needs?"
#11
Okay, I found one I like...

Code: (Select All)
Screen _NewImage(860, 300, 32)
_Delay .1
_ScreenMove _Middle
_Delay .1
nof = 4
ReDim fh(nof) As Long
fh(0) = _LoadFont("c:\windows\fonts\lucon.ttf", 16)
fh(1) = _LoadFont("RobotoMono-regular.ttf", 21, "monospace")
fh(2) = _LoadFont("RobotoMono-regular.ttf", 21)

For i = 0 To 2
    If fh(i) <= 0 Then
        Print "Failed to load font."
        End
    End If
Next

_PrintString (16, 21), " Test for a monospaced font. a and b will align if mono..."
_Font fh(1)
_PrintString (16, 21 * 3), "mmmmmmmmmmmmmmmmmmmma"
_Font fh(2)
Locate 4, 16
_PrintString (16, 21 * 4), "mmmmmmmmmmmmmmmmmmmmb"
_Font fh(0)

fh(0) = _LoadFont("c:\windows\fonts\lucon.ttf", 16)
fh(1) = _LoadFont("RobotoMono-regular.ttf", 21)
fh(2) = _LoadFont("RobotoMono-bold.ttf", 21)
fh(3) = _LoadFont("RobotoMono-italic.ttf", 21)
fh(4) = _LoadFont("RobotoMono-bolditalic.ttf", 21)

For i = 0 To nof
    If fh(i) <= 0 Then
        Print "Failed to load font."
        End
    End If
Next

Locate 9, 16: Print " Here's how they look...";

If print0 Then
    x = 16: y = 8: a = 0: k = 0
    For i = 1 To 26 * 4
        a = a + 1
        _Font fh(a)
        Locate y, x: Print Chr$(97 + k);
        x = x + 16
        If i = 26 * 2 Then y = y + 1: x = 16
        If i Mod 4 = 0 Then a = 0: k = k + 1
    Next
Else
    x = 15: y = 21 * 8
    For i = 1 To 26 * 4
        a = a + 1
        _Font fh(a)
        _PrintString (x, y), Chr$(97 + k)
        x = x + 16
        If i = 26 * 2 Then y = y + 21: x = 15
        If i Mod 4 = 0 Then a = 0: k = k + 1
    Next
End If

_Font fh(0)
End

What's interesting is the "monospace" handle is essentially useless if you try to use it with  non-monospaced font. Too many display problems, and forget about using the PRINT statement in graphics mode if you do try and go that way. It will throw the character positioning waaaaaay off. _PrintString works, but, again, the fonts will probably display poorly. My advice, stick with monospaced fonts or make a routine with _PrintWidth to improve the presentation of non-monospaced fonts if you are trying to preserve a fixed number of character spaces per line.

Pete


Attached Files
.zip   roboto-mono.zip (Size: 697.56 KB / Downloads: 17)
Reply


Messages In This Thread
RE: Is _NEWIMAGE just a nicer way of saying, "Special needs?" - by Pete - 03-12-2024, 12:15 AM



Users browsing this thread: 4 Guest(s)