Post Reply 
Width of each character.
04-11-2022, 07:51 PM (This post was last modified: 04-11-2022 09:15 PM by matalog.)
Post: #1
Width of each character.
It seems that there is no way to select a fixed width font on the calculator, so is there a way to know the width of each used character, for example, so that they can be deleted if typed in error?

M for example, takes up more than 8 pixels wide and . takes up 8 or less. If I use 8 pixels wide to delete characters, it works most of the time, but it doesn't work properly with the likes of M and i'm sure there are others.
Find all posts by this user
Quote this message in a reply
04-11-2022, 09:16 PM
Post: #2
RE: Width of each character.
I can use string manipulation to amend the string by one character and then redraw the whole string, but would still be interested if there is a way to know the width of each character.
Find all posts by this user
Quote this message in a reply
04-12-2022, 05:13 AM
Post: #3
RE: Width of each character.
TEXTOUT_P() returns the X coordinate at which the next character of the string should be drawn if it had more characters (from the Help).

So with a bit of trial and error you could figure it out from that, here's a sample to get started:
Code:
EXPORT ChrWidth()
BEGIN
  LOCAL mychars:={"A","B","C","1","2","3"};
  LOCAL mylist:={}, k;
  FOR k FROM 1 TO SIZE(mychars) DO
    mylist:=CONCAT(mylist,{TEXTOUT_P(mychars(k),0,0)});
  END;
  MSGBOX(mylist);
END;
Visit this user's website Find all posts by this user
Quote this message in a reply
04-13-2022, 09:38 PM
Post: #4
RE: Width of each character.
Thanks, that's great.

Is there a way to return the pixel from TEXTOUT() with it not actually printing the text to screen?
Find all posts by this user
Quote this message in a reply
04-13-2022, 10:22 PM
Post: #5
RE: Width of each character.
I assume this will work:
TEXTOUT(text, [G]...
The optional G parameter (an integer) allows one of several screens to be specified (all but one of which will be off-screen).

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
04-14-2022, 04:40 AM (This post was last modified: 04-14-2022 04:41 AM by Tyann.)
Post: #6
RE: Width of each character.
(04-11-2022 07:51 PM)matalog Wrote:  It seems that there is no way to select a fixed width font on the calculator, so is there a way to know the width of each used character, for example, so that they can be deleted if typed in error?

M for example, takes up more than 8 pixels wide and . takes up 8 or less. If I use 8 pixels wide to delete characters, it works most of the time, but it doesn't work properly with the likes of M and i'm sure there are others.

Bonjour

Sur les dernières version du Firware il y a TEXTSIZE
[TEXTSIZE(chaîne,font) renvoie {largeur,hauteur}

Hello

On the latest version of Firware there is TEXTSIZE
[TEXTSIZE(string,font) returns {width,height}

Sorry for my english
Find all posts by this user
Quote this message in a reply
04-14-2022, 04:43 AM
Post: #7
RE: Width of each character.
All of this would be so unnecessary if they would just allow us to choose a fixed-width font for the terminal. Tabular output would be a lot neater, too.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)