Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is it so? (again)
#1
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?
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#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
#3
Simple as that!  Thanks bplus.

I'll leave you in peace now (for a while).  Big Grin
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply




Users browsing this thread: 1 Guest(s)