HP Forums
TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification (/thread-20364.html)



TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - Insoft - 08-23-2023 01:08 AM

I have encountered an issue concerning text alignment. I would appreciate it if anyone has insights into the proper handling of left, right, and center justification. Despite my efforts, I have been unable to locate comprehensive information on this topic. At present, I have resorted to using a makeshift solution, but I am eager to explore a more refined approach. Your assistance is greatly valued.

eg.
Code:
X:=TEXTOUT_P("Center my TEXT", 0, 240, RGB(255,0,0));
TEXTOUT_P("Center my TEXT", 160-X/2, 120, RGB(255,0,0));



RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - Tyann - 08-23-2023 05:20 AM

Bonjour

Il y a peut être 'TEXTSIZE' qui peux vous être utile, mais qui n'est pas documenté dans l'aide intégrée de la dernière version (cela affiche l'aide de TEXTOUT).
TEXTSIZE(s,p) où 's' est la chaîne que vous souhaitez afficher et 'p' la police que vous souhaitez
utiliser, elle vous renvoie une liste de 2 valeurs : la largeur et la hauteur en pixels nécessaires à cette affichage.

Hello

You may find 'TEXTSIZE' useful, but it is not documented in the integrated help of the latest version (it displays the TEXTOUT help).
TEXTSIZE(s,p) where 's' is the string you want to display and 'p' is the font you want to use.
returns a list of 2 values: the width and height in pixels required for this display.


RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - Insoft - 08-23-2023 09:38 AM

(08-23-2023 05:20 AM)Tyann Wrote:  Bonjour

Il y a peut être 'TEXTSIZE' qui peux vous être utile, mais qui n'est pas documenté dans l'aide intégrée de la dernière version (cela affiche l'aide de TEXTOUT).
TEXTSIZE(s,p) où 's' est la chaîne que vous souhaitez afficher et 'p' la police que vous souhaitez
utiliser, elle vous renvoie une liste de 2 valeurs : la largeur et la hauteur en pixels nécessaires à cette affichage.

Hello

You may find 'TEXTSIZE' useful, but it is not documented in the integrated help of the latest version (it displays the TEXTOUT help).
TEXTSIZE(s,p) where 's' is the string you want to display and 'p' is the font you want to use.
returns a list of 2 values: the width and height in pixels required for this display.

Thanks for that info on TEXTSIZE, it’s exactly what I was needing.


RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - matalog - 08-23-2023 11:11 AM

TEXTOUT_P("String",X,Y) Returns the X coordinate at which the next character of the string should be drawn if the string had more characters (from the calculators built in help).

That will work with the same text on a different correctly defined GROB if you don't want it to be printed on the current GROB and it will work with the different font sizes.


RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - Insoft - 08-23-2023 11:18 AM

(08-23-2023 11:11 AM)matalog Wrote:  TEXTOUT_P("String",X,Y) Returns the X coordinate at which the next character of the string should be drawn if the string had more characters (from the calculators built in help).

That will work with the same text on a different correctly defined GROB if you don't want it to be printed on the current GROB and it will work with the different font sizes.

That’s what I was previously doing, I found that I could actually just draw off screen and still return the X coordinate and I was using that as a workaround tho TEXTSIZE seems what I should be using from what I can tell and it gives me the height which I may require one day tho with fixed font sizes I don’t see height being any real benefit in reality.


RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification - HPCarnace - 08-23-2023 02:42 PM

(08-23-2023 11:18 AM)Insoft Wrote:  
(08-23-2023 11:11 AM)matalog Wrote:  TEXTOUT_P("String",X,Y) Returns the X coordinate at which the next character of the string should be drawn if the string had more characters (from the calculators built in help).

That will work with the same text on a different correctly defined GROB if you don't want it to be printed on the current GROB and it will work with the different font sizes.

That’s what I was previously doing, I found that I could actually just draw off screen and still return the X coordinate and I was using that as a workaround tho TEXTSIZE seems what I should be using from what I can tell and it gives me the height which I may require one day tho with fixed font sizes I don’t see height being any real benefit in reality.
Me too:

Code:

GetWidthPix(Cadena, Fuente) //Obtiene el ancho en pixeles de una cadena Font=1
BEGIN
  LOCAL xAncho; 
  DIMGROB_P(G7,319,239,RGB(255,255,255)); 
  RECT_P(G7);
  xAncho := TEXTOUT_P(Cadena,G7,0,0,Fuente, RGB(0,0,255));
  RETURN xAncho;
END