Posts: 663
Threads: 96
Joined: Apr 2022
Reputation:
22
10-31-2024, 11:28 PM
(This post was last modified: 10-31-2024, 11:29 PM by PhilOfPerth.)
I'm looking for a font that's monospace, and occupies the same horizontal as vertical space.
for example:
FOX
FOX
FOX
will ocucupy a square space on screen.
All the Wide fonts I've found still take extra vertical space.
Posts: 2,713
Threads: 329
Joined: Apr 2022
Reputation:
222
Posts: 2,219
Threads: 225
Joined: Apr 2022
Reputation:
110
_Font 8. Better known as SCREEN 0's fat ASCII characters.
Hey is it just me, or did something go haywire and caused the forum icon buttons, for post formatting, to go blank?
Pete
Posts: 4,020
Threads: 181
Joined: Apr 2022
Reputation:
225
10-31-2024, 11:52 PM
(This post was last modified: 10-31-2024, 11:53 PM by bplus.)
Let me expand on Steve's amazing reply:
Code: (Select All) Screen _NewImage(600, 600, 32)
For i = 1 To 3
Text8 120, i * 120, 120, &HFFFF8844, "FOX"
Next
Print "OK?"
Sleep
Sub Text8 (x, y, textHeight, K As _Unsigned Long, txt$)
Dim fg As _Unsigned Long, cur&, I&, multi, xlen
fg = _DefaultColor
f = _Font
'screen snapshot
cur& = _Dest
I& = _NewImage(8 * Len(txt$), 8, 32)
_Dest I&
_Font 8
Color K, _RGBA32(0, 0, 0, 0)
_PrintString (0, 0), txt$
multi = textHeight / 8
xlen = Len(txt$) * 8 * multi
_PutImage (x, y)-Step(xlen, textHeight), I&, cur&
Color fg
_FreeImage I&
_Dest cur&
_Font f
End Sub
(10-31-2024, 11:48 PM)Pete Wrote: _Font 8. Better known as SCREEN 0's fat ASCII characters.
Hey is it just me, or did something go haywire and caused the forum icon buttons, for post formatting, to go blank?
Pete
Maybe my reply collided with your reply
b = b + ...
Posts: 663
Threads: 96
Joined: Apr 2022
Reputation:
22
(10-31-2024, 11:34 PM)SMcNeill Wrote: _FONT 8
Thanks Steve. and Bplus. Steve's suggestion does what I wanted. But can I create larger characters? I tried changing the _Font number, which, obviously, can't work.
Bplus, sorrry if i'm sounding dense, but can the essence of your Sub be put at top of the code, to declare the size font I need for the rest of the page? The sub works fine, but I don't want to call the sub every time I Print a piece of text.
Posts: 4,020
Threads: 181
Joined: Apr 2022
Reputation:
225
11-01-2024, 01:29 AM
(This post was last modified: 11-01-2024, 01:42 AM by bplus.)
@PhilOfPerth unlike with Fonts you can make the text any size you want when you call Text8
Sub Text8 (x, y, textHeight, K As _Unsigned Long, txt$)
This substitutes for a _Print String(x, y), txt$ only it does more!
You can say whatever size you want with textHeight and you can specify whatever color you want.
x, y is top left corner of the text put onto screen at the color and height you specify for txt$
If you want to say make every line a height of 20 then y = 20 * row, and use something less than 20 like 18 or 16 for text height so letters aren't sitting right on top of one another. Like the 3 FOX example.
Code: (Select All) Screen _NewImage(600, 600, 32)
For i = 0 To 29
Text8 20, i * 20, 18, &HFF00FF88, "This is line" + Str$(i)
Next
Sleep
Sub Text8 (x, y, textHeight, K As _Unsigned Long, txt$)
Dim fg As _Unsigned Long, cur&, I&, multi, xlen
fg = _DefaultColor
f = _Font
'screen snapshot
cur& = _Dest
I& = _NewImage(8 * Len(txt$), 8, 32)
_Dest I&
_Font 8
Color K, _RGBA32(0, 0, 0, 0)
_PrintString (0, 0), txt$
multi = textHeight / 8
xlen = Len(txt$) * 8 * multi
_PutImage (x, y)-Step(xlen, textHeight), I&, cur&
Color fg
_FreeImage I&
_Dest cur&
_Font f
End Sub
Update: Actually you can make the above example text height at 20! There is still a tiny little space between each row. I just checked.
b = b + ...
Posts: 4,020
Threads: 181
Joined: Apr 2022
Reputation:
225
11-01-2024, 02:17 AM
(This post was last modified: 11-01-2024, 02:17 AM by bplus.)
Here is cool example you can't do easily with a Font!
Code: (Select All) Screen _NewImage(1000, 600, 32)
size = 64
For i = 0 To 20
Text8 20, row, size, &HFF00FF88, "This is line" + Str$(i)
row = row + size + 1
size = size * .9
Next
Sleep
Sub Text8 (x, y, textHeight, K As _Unsigned Long, txt$)
Dim fg As _Unsigned Long, cur&, I&, multi, xlen
fg = _DefaultColor
f = _Font
'screen snapshot
cur& = _Dest
I& = _NewImage(8 * Len(txt$), 8, 32)
_Dest I&
_Font 8
Color K, _RGBA32(0, 0, 0, 0)
_PrintString (0, 0), txt$
multi = textHeight / 8
xlen = Len(txt$) * 8 * multi
_PutImage (x, y)-Step(xlen, textHeight), I&, cur&
Color fg
_FreeImage I&
_Dest cur&
_Font f
End Sub
b = b + ...
Posts: 2,713
Threads: 329
Joined: Apr 2022
Reputation:
222
(11-01-2024, 12:42 AM)PhilOfPerth Wrote: (10-31-2024, 11:34 PM)SMcNeill Wrote: _FONT 8
Steve's suggestion does what I wanted. But can I create larger characters?
Try this simple little SquarePrint routine: https://qb64phoenix.com/forum/showthread.php?tid=3183
Posts: 663
Threads: 96
Joined: Apr 2022
Reputation:
22
Thanks Steve. That's a very versatile print formating routine. I like how it lets me place text at pixel-position. I'll have a play with that and see if I can apply it in my prog..
|