QB64 Phoenix Edition
Why is it so? (again) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Why is it so? (again) (/showthread.php?tid=2012)



Why is it so? (again) - PhilOfPerth - 09-18-2023

Sorry to be a pain (again), but
I'm trying to come to grips with "Fonty" stuff, and am a bit (a lot) puzzled by the results of this code:
Code: (Select All)
Screen _NewImage(1024, 820, 32) '                                                                  Screen Width is 1024 pixels
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 24, "monospace")
_Font f&
'                                                                                                  width of "X" on current screen
CpL = _DesktopWidth \ _PrintWidth("X") '                                                           chars per line on current screen
Print "Width of X is"; _PrintWidth("X"); ", and Chars per Line is"; CpL
Locate 10, 10

Print String$(CpL, "X");
Sleep
I would expect it to print a single, full line of X's. But it doesn't. I think it's to do with the font I've selected,
but I thought _PrintWidth considered that. Does it?


RE: Why is it so? (again) - bplus - 09-19-2023

(09-18-2023, 11:57 PM)PhilOfPerth Wrote: Sorry to be a pain (again), but
I'm trying to come to grips with "Fonty" stuff, and am a bit (a lot) puzzled by the results of this code:
Code: (Select All)
Screen _NewImage(1024, 820, 32) '                                                                  Screen Width is 1024 pixels
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 24, "monospace")
_Font f&
'                                                                                                  width of "X" on current screen
CpL = _DesktopWidth \ _PrintWidth("X") '                                                           chars per line on current screen
Print "Width of X is"; _PrintWidth("X"); ", and Chars per Line is"; CpL
Locate 10, 10

Print String$(CpL, "X");
Sleep
I would expect it to print a single, full line of X's. But it doesn't. I think it's to do with the font I've selected,
but I thought _PrintWidth considered that. Does it?

Divide screen Width by _PrintWidth not your whole DeskTopWidth
Code: (Select All)
Screen _NewImage(1024, 620, 32) '                                                                  Screen Width is 1024 pixels
SetFont: f& = _LoadFont("C:\WINDOWS\fonts\courbd.ttf", 24, "monospace")
_Font f&
'                                                                                                  width of "X" on current screen
CpL = _DesktopWidth \ _PrintWidth("X") '                                                           chars per line on current screen
Print "Width of X is"; _PrintWidth("X"); ", and Chars per Line is"; CpL
Locate 10, 10

Print String$(CpL, "X");
Sleep
CpL = _Width / _PrintWidth("W")
Print String$(CpL, "W");



RE: Why is it so? (again) - PhilOfPerth - 09-19-2023

Simple as that!  Thanks bplus.

I'll leave you in peace now (for a while).  Big Grin