Recent

Author Topic: Draw Curved Text  (Read 26116 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #45 on: April 24, 2015, 03:18:40 pm »
BezierTextOut does not fail with that "é", it is UTF-8 compatible.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Draw Curved Text
« Reply #46 on: April 24, 2015, 03:54:55 pm »
BezierTextOut does not fail with that "é", it is UTF-8 compatible.
sorry I don't think so, unless canvas.textout is unicode and I do not know.
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

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #47 on: April 24, 2015, 03:56:34 pm »
Screenshot and demo attached.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Draw Curved Text
« Reply #48 on: April 24, 2015, 04:23:07 pm »
my ansi locale does not support the é look at my previous posted screen shots
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

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #49 on: April 24, 2015, 04:35:35 pm »
Chinese chars (attached).

circular

  • Hero Member
  • *****
  • Posts: 4462
    • Personal webpage
Re: Draw Curved Text
« Reply #50 on: April 29, 2015, 06:36:50 pm »
Hello there!

With version 8.4, it is possible to do curved text in BGRABitmap. Note that the letters themselves are not bent, they are rotated and placed at a specific location.

Sample code:
Code: [Select]
uses BGRABitmap, BGRABitmapTypes, BGRAPath, BGRAVectorize;

{ TForm1 }

procedure TForm1.FormPaint(Sender: TObject);
var bmp: TBGRABitmap;
  path: TBGRAPath;
  step,y1,y2: single;
begin
  bmp := TBGRABitmap.Create(ClientWidth,ClientHeight,CSSLightSteelBlue);
  path := TBGRAPath.Create;
  y1 := bmp.Height/6;
  y2 := 5*bmp.Height/6;
  step := bmp.Width/6;
  path.moveTo(0,(y1+y2)/2);
  path.quadraticCurveTo(0,y1,1*step,y1);
  path.smoothQuadraticCurveTo(2*step,(y1+y2)/2);
  path.smoothQuadraticCurveTo(3*step,y2);
  path.smoothQuadraticCurveTo(4*step,(y1+y2)/2);
  path.smoothQuadraticCurveTo(5*step,y1);
  path.smoothQuadraticCurveTo(6*step,(y1+y2)/2);
  bmp.FontHeight := round(bmp.Height/15);
  bmp.FontVerticalAnchor := fvaXCenter;
  bmp.FontRenderer := TBGRAVectorizedFontRenderer.Create;
  bmp.FontQuality := fqFineAntialiasing;
  bmp.TextOutCurved(path, 'One can taste the flavor of days only by shying away from the duty to have a destiny', BGRABlack, taCenter, 0);
  bmp.Draw(Canvas,0,0);
  bmp.Free;
end;
« Last Edit: April 29, 2015, 06:43:04 pm by circular »
Conscience is the debugger of the mind

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #51 on: April 29, 2015, 10:40:00 pm »
As I have said in BugTracker:

"This code is fast, light and cross-platform. Of course this code is not some kind of new technology, but could be very useful to those who don't want to use a large library to perform a single task."

circular

  • Hero Member
  • *****
  • Posts: 4462
    • Personal webpage
Re: Draw Curved Text
« Reply #52 on: April 30, 2015, 01:31:52 am »
Yes, the code provided is small and can be easily embedded in the LCL.

The principle that you use is more or less the same that I used in BGRABitmap. To make a polygon and to go through and output the characters.
Conscience is the debugger of the mind

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Draw Curved Text
« Reply #53 on: April 30, 2015, 05:17:52 pm »

 

TinyPortal © 2005-2018