Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there an inconsistency in the Locate function?
#1
Brick 
The result of running the small snippet of code below confuses me! I would expect Locate to use the first two arguments to set the column and row for text position, 
but it uses the first for the vertical row position, and the second, not as the column but as a number to be determined from the font size. 
I know, I'm easily confused, but can someone explain this to me?

PHP Code:
Screen _NewImage(128096032)
f& = _LoadFont("c:\WINDOWS\Fonts\arial.ttf"28)
_Font f&
 
                                                                                                     
Locate 31, 400
I would expect this to be an invalid horizontal position
Print "This text location is row 31, column 400";
' but it uses the pixel position, and prints it there!
Sleep 
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#2
You're not using a monospaced font.  With variable width fonts, locate positions by pixel -- not column.

Add "monospace" to the loadfont statement and see the difference.
Reply
#3
I think I get it. Thanks Steve.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#4
Great Steve, you uniformizes the dimensions of the characters of a font file!

@PhiloFPerth
you can get the reason here in the wiki

Quote:
  • In _NEWIMAGE graphic screen the number of text rows are calculated as _HEIGHT \ 16 except when a _FONT is used. Use _FONTHEIGHT to calculate font rows.
  • _NEWIMAGE graphic screen text columns are calculated as _WIDTH \ 8 except when a _FONT is used. Use _PRINTWIDTH to measure a line of font text.


LOCATE in _Newimage

Good study!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Star Suggestion for new REPLACE$() function zaadstra 3 239 01-26-2026, 05:11 PM
Last Post: grymmjack
  Is there a menu function? Mad Axeman 17 1,023 12-17-2025, 04:43 AM
Last Post: SMcNeill
  SCREEN Function CletusSnow 8 807 11-16-2025, 05:09 PM
Last Post: TempodiBasic
  Locate command on the ttf graphical screens Helium5793 5 702 03-09-2025, 05:47 PM
Last Post: SMcNeill
  Using the Screen function PhilOfPerth 19 3,047 04-16-2024, 05:23 PM
Last Post: bobalooie

Forum Jump:


Users browsing this thread: 1 Guest(s)