function GetTextAlongPathOutine(image: TImage32; const text: string; const path: TArrayOfPointD; fontInfo: TFontInfo; textAlign: TTextAlign; vertOffset: integer = 0; charSpacing: double = 0): TArrayOfArrayOfPointD;
This function returns the polygons that outline the supplied text as the text flows along the specified path.
To avoid or minimize character spreading or bunching (outside convexities or inside concavities respectively), 'vertOffset' can be used to position the text vertically relative to the path. (When a path is curved in several directions, positioning the text vertically relatively to the path, as if it were striking through each character, generally produces the least character bunching and spreading.)
'charSpacing' can also be used to avoid or minimize character spreading or bunching, and is especially useful when the text needs to be position exactly on the line (ie when there's no vertical offset). To reduce character bunching when a path is concave, use a positive charSpacing value, and to reduce character spreading when the curve is convex use a negative value.
uses Image32, Image32_PNG, Image32_Vector, Image32_Text, Image32_Draw; ... var img: TImage32; lf: TLogFont; path: TArrayOfPointD; outline: TArrayOfArrayOfPointD; begin lf := DefaultLogfont; lf.lfHeight := -70; lf.lfFaceName := 'Impact'; path := FlattenCBezier(PointD(60,100), PointD(200,0), PointD(200,200), PointD(340,100)); img := TImage32.Create(400,200); //draw the path with a very faint line DrawLine(img, path, 1, $40000000, esRound); //get the text outline ... //(offsetting the text down 20px and spreading each char by 3px) outline := GetTextAlongPathOutine(img, 'this is a test', path, GetFontInfo(lf), taCenter, 20, 3); DrawShadow(designLayer.Image, outline, frEvenOdd, 3); DrawPolygon(designLayer.Image, outline, frEvenOdd, clLime32); Draw3D(designLayer.Image, outline, frEvenOdd, 2, 3); DrawLine(img, outline, 1, clBlack32, esClosed); img.SaveToFile('image32_text.png'); img.Free;
Copyright ©2019 Angus Johnson - Image32 ver. 1.44 - Documentation last updated on 1-March-2020