![]() |
Locate command on the ttf graphical screens - 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: Locate command on the ttf graphical screens (/showthread.php?tid=3524) |
Locate command on the ttf graphical screens - Helium5793 - 03-09-2025 I have been learning to use the graphical screen 12 along with a ttf font. I have noticed that the locate command behaves differently here. if you have locate 5,1 that works and it calculates for the given font where line 5 would be, but the x =1 moves it over 1 pixel. Seems like it should move over a space. It does work in that if I say locate 5, 35 it moves over 35 pixels, It would be more intuitive if it got the width of a space in the font and moved it over that much. Anyway comments and criticism welcome. If there is a reason for it working this way I would be interested in knowing it. Thanks, John RE: Locate command on the ttf graphical screens - bplus - 03-09-2025 Locate command moves character cell: lines/rows and columns, according to font you use, 8x16 pixels character cell size in pixels for default. If your font is 15X20 the screen will be divided by 20 pixels going down for row and width divided by 15 for columnns numbers (assuming a graphics <> 0 screen). To go pinpoint pixel by pixel use _PrintString(x_pix, y_pix), text$ in graphics screen =non 0 for top left location of first print cell. Code: (Select All) Screen 12 LOCATE came from original BASIC back in days where everything was printed on paper so locating a print item made sense to find print row first then tab over to print column, in graphics all is x, y pixels and that came when screens were being used in place of paper for output. RE: Locate command on the ttf graphical screens - SMcNeill - 03-09-2025 @bplus has misdiagnosed your problem as you have left out several important pieces of information for him and no working code to run to showcase the issue in discussion. The issue you are seeing stems down to this: LOCATE has two separate methods to move text to a certain position on the screen. 1) With a monospaced font, text will locate by column and row according to _FontWidth and _FontHeight. 2) With a variable-width font, there is no set _FontWidth so you can't just move X characters to the right. Instead, it moves by PIXELS for positioning to the right. The up/down row position is the same as always, as you still have a _FontHeight, but there is no valid _FontWidth for left/right position so pixels are used instead. Solution? 1) Load a monospace font: _LOADFONT(fontname$, fontsize, "monospace") <-- This will give you a valid _FontWidth and allow proper LOCATE positioning based on the width. 2) Swap over to using pixel coordinates for the left/right. Instead of moving 1 pixel, move.. 8 or so per character, for your font (or whatever you choose to be a reasonable guesstimate for a midpoint of your font sizes) Anywho... that's the issue you're seeing in a nutshell. ![]() RE: Locate command on the ttf graphical screens - bplus - 03-09-2025 True, I missed how Locate works with variable width font @SMcNeill I did not diagnose any problem, merely stated facts. RE: Locate command on the ttf graphical screens - SMcNeill - 03-09-2025 A quick example of the issue: Code: (Select All)
RE: Locate command on the ttf graphical screens - SMcNeill - 03-09-2025 As I mentioned, it all steps back to this: Code: (Select All)
Variable width fonts have no set fontwidth, so you can't just move character width left/right, so it moves by pixels instead. |