Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is it so? (again)
#2
(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");
b = b + ...
Reply


Messages In This Thread
Why is it so? (again) - by PhilOfPerth - 09-18-2023, 11:57 PM
RE: Why is it so? (again) - by bplus - 09-19-2023, 12:38 AM
RE: Why is it so? (again) - by PhilOfPerth - 09-19-2023, 12:53 AM



Users browsing this thread: 1 Guest(s)