Recent

Author Topic: Graphical text  (Read 5794 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Graphical text
« on: June 02, 2021, 02:33:48 pm »
هل هناكـ أداة من أدوات الـ graphics ما يجعلني أعرض النّص التالي كأحرف رسوميّة وليس كنص عادي؟

google translate:

"Is there a graphics tool that will allow me to display the following text as graphic characters and not as plain text?"

Quote
El pan con la carne es el maestro de la comida.
La chose par la chose est rappelé.

speter

  • Sr. Member
  • ****
  • Posts: 349
Re: Graphical text
« Reply #1 on: June 02, 2021, 03:09:18 pm »
If you mean can you "draw" text, yes!

Code: Pascal  [Select][+][-]
  1. canvas.textout(10,10,'foo');

The code above will draw the specified phrase on a canvas. If you start a new project and put that code in the form.create function, the phrase will be drawn on the form's canvas.

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Graphical text
« Reply #2 on: June 02, 2021, 03:31:48 pm »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Graphical text
« Reply #3 on: June 02, 2021, 08:59:14 pm »
Hi!

You can rotate the text on the canvas.
Font.Orientation  are 0.1  degrees, so 900 means 90 degrees.

Code: Pascal  [Select][+][-]
  1.  Canvas.Font.Orientation := 900;
  2.  Canvas.TextOut( 200, 200,  "Upside Down");

Winni

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Graphical text
« Reply #4 on: June 02, 2021, 09:21:28 pm »
Hi!

You can rotate the text on the canvas.
Font.Orientation  are 0.1  degrees, so 900 means 90 degrees.

Code: Pascal  [Select][+][-]
  1.  Canvas.Font.Orientation := 900;
  2.  Canvas.TextOut( 200, 200,  "Upside Down");

Winni

جميل "es hermoso"

google translate:

"Beautiful "es hermoso""
La chose par la chose est rappelé.

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Graphical text
« Reply #5 on: June 02, 2021, 09:23:43 pm »
أشكُرُكُما @speter وَ@VTwin.

google translate:

"Thank you @speter and @VTwin."
La chose par la chose est rappelé.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Graphical text
« Reply #6 on: June 02, 2021, 11:04:00 pm »
Hi!

And the shading of a text is done with a simple trick:

Code: Pascal  [Select][+][-]
  1. const  myText = 'Some Text';
  2. ...
  3. Canvas.Font.color := clSilver;
  4. Canvas,TextOut (10,10,myText);
  5.  
  6. Canvas.Font.color := clBlack;
  7. Canvas,TextOut (11,11,myText);
  8. ...
  9.  


Winni

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Graphical text
« Reply #7 on: June 02, 2021, 11:48:33 pm »
Hi!

And the shading of a text is done with a simple trick:

Code: Pascal  [Select][+][-]
  1. const  myText = 'Some Text';
  2. ...
  3. Canvas.Font.color := clSilver;
  4. Canvas,TextOut (10,10,myText);
  5.  
  6. Canvas.Font.color := clBlack;
  7. Canvas,TextOut (11,11,myText);
  8. ...
  9.  


Winni

جرّبتُ ذلكـ ولكن هذا الذي خرج معي كما في الصورة:

google translate:

"I tried it but this is what came out with me as in the picture:"

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2.  
  3. const
  4.  
  5.   mytext='El pan con la carne es el maestro de la comida.';
  6.  
  7. begin
  8.  
  9.   Canvas.Font.Orientation := 400;
  10.  
  11.   Canvas.Font.color := clblue;
  12.   canvas.textout(100,250,mytext);
  13.  
  14.  
  15.   Canvas.Font.color := clBlack;
  16.   canvas.textout(102,252,mytext);
  17. end;
  18.  
  19.  
La chose par la chose est rappelé.

speter

  • Sr. Member
  • ****
  • Posts: 349
Re: Graphical text
« Reply #8 on: June 03, 2021, 03:49:46 am »
try adding
Code: Pascal  [Select][+][-]
  1. canvas.brush.style := bsClear;
before the first textout.

You may need to tweak the offset to get the effect you want. At present you have (+2,+2) which may be too much (with small text).

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Graphical text
« Reply #9 on: June 03, 2021, 01:57:32 pm »
try adding
Code: Pascal  [Select][+][-]
  1. canvas.brush.style := bsClear;
before the first textout.

You may need to tweak the offset to get the effect you want. At present you have (+2,+2) which may be too much (with small text).

cheers
S.

كلامُكـ صحيح! والآن أصبح ما قاله @winni ممكن التنفيذ.

google translate:

"You are right! Now what @winni said can be done."

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2.  
  3. const
  4.  
  5.   mytext='El pan con la carne es el maestro de la comida.';
  6.  
  7. begin
  8.  
  9.   Canvas.Font.Orientation := 400;
  10.  
  11.   Canvas.Font.color := clSilver;
  12.   canvas.brush.style := bsClear;
  13.   canvas.textout(100,250,mytext);
  14.  
  15.  
  16.   Canvas.Font.color := clBlack;
  17.   canvas.textout(101,251,mytext);
  18.  
  19. end;        
  20.  
La chose par la chose est rappelé.

 

TinyPortal © 2005-2018