Recent

Author Topic: Draw Curved Text  (Read 23827 times)

wcleyton

  • Jr. Member
  • **
  • Posts: 80
Draw Curved Text
« on: April 16, 2015, 04:38:30 pm »
Hello!

How to draw curved text in Lazarus?


felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Draw Curved Text
« Reply #1 on: April 16, 2015, 04:51:32 pm »
I'm not sure if it is supported. We support Font.Orientation to draw text at an angle (but in a streight line, not a curve). Using Font.Orientation and some geometry it should be possible to implement a function that draws each char at the right angle and position. Each char should be positioned in the curve in the line that tangents the curve in the point where the char is.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #2 on: April 16, 2015, 04:55:17 pm »
I have just tested this example and it works fine.

http://www.angusj.com/delphitips/beziertext.php

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Draw Curved Text
« Reply #3 on: April 16, 2015, 04:57:13 pm »
ahaha, yes, exactly, it implements what I was talking about... by "not supported" I meant that there is no pre-made function in the LCL for it, but yet, you can just grab a function in the internet and it works =) good idea.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #4 on: April 17, 2015, 01:01:35 pm »
Indeed, the basis of the linked example is changing the orientation.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Draw Curved Text
« Reply #5 on: April 17, 2015, 01:55:28 pm »
Not all solutions are made equal. I prefer Jay Clegg's "Warping Text to a Bézier curves"

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Draw Curved Text
« Reply #6 on: April 17, 2015, 02:23:40 pm »
Yeah me too! Lost the link a couple of years back though thank you for supplying it ;). Have you converted the article to pascal code?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Draw Curved Text
« Reply #7 on: April 17, 2015, 02:37:37 pm »
I think I did convert most of it using GDI+, let me dig and see if I can find it.

Edit:
I found the executable file. Check the attachment. Still need to find the source code.
« Last Edit: April 17, 2015, 02:54:34 pm by engkin »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #8 on: April 17, 2015, 03:24:17 pm »
Any cross-platform solution?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Draw Curved Text
« Reply #9 on: April 17, 2015, 03:33:21 pm »
Any cross-platform solution?
if engkin posts the source I'll convert it to cross platform otherwise you would have to wait until I convert the article to pascal my self.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

finalpatch

  • New Member
  • *
  • Posts: 12
Re: Draw Curved Text
« Reply #10 on: April 17, 2015, 04:24:24 pm »
guys you are sitting on this gold mine called aggpas without realizing it.
http://www.crossgl.com/aggpas/aggpas-demo.htm
scroll down to the example trans_curve1 and trans_curve2

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #11 on: April 17, 2015, 06:11:59 pm »
Any example of using this in Lazarus? The EXE demo does not help so much.
« Last Edit: April 17, 2015, 06:14:09 pm by typo »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Draw Curved Text
« Reply #12 on: April 17, 2015, 07:13:05 pm »
When I was working on it I was trying to solve a specific issue before I lost my interest. I wanted to merge the curves in cursive fonts when drawing the outline of text. Check the attached image. I found some version of the source code. Compiling it does not display proper results and the code looks horrible.

finalpatch

  • New Member
  • *
  • Posts: 12
Re: Draw Curved Text
« Reply #13 on: April 18, 2015, 07:37:07 am »
Any example of using this in Lazarus? The EXE demo does not help so much.

download aggpas from their website, the zip archive contains the full source code to all examples.
for programming you could just use the aggpas package shipped with lazarus.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #14 on: April 18, 2015, 07:45:49 pm »
Attached a project with a simple cross-platform curved text demo.

 

TinyPortal © 2005-2018