Post Reply 
TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
08-23-2023, 01:08 AM (This post was last modified: 08-23-2023 01:23 AM by Insoft.)
Post: #1
TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
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));
Find all posts by this user
Quote this message in a reply
08-23-2023, 05:20 AM
Post: #2
RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
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.

Sorry for my english
Find all posts by this user
Quote this message in a reply
08-23-2023, 09:38 AM
Post: #3
RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
(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.
Find all posts by this user
Quote this message in a reply
08-23-2023, 11:11 AM
Post: #4
RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
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.
Find all posts by this user
Quote this message in a reply
08-23-2023, 11:18 AM (This post was last modified: 08-23-2023 11:21 AM by Insoft.)
Post: #5
RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
(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.
Find all posts by this user
Quote this message in a reply
08-23-2023, 02:42 PM
Post: #6
RE: TEXTOUT_P & TEXTOUT with Left, Right & Centre Justification
(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
Find all posts by this user
Quote this message in a reply
Post Reply 




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