HP Forums

Full Version: Width of each character.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.
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;
Thanks, that's great.

Is there a way to return the pixel from TEXTOUT() with it not actually printing the text to screen?
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).
(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}
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.
Reference URL's