Hi!
There are situations where you want to control the kerning of some text as you now it from all the Desktop Publishers.
This means: Make the distance between the letters smaller or wider.
BGRAbitmap has not a straight solution. Only a diffused trick:
TextOutCurved has the parameter
ALetterSpacing: singleWe "missuse" that. The Path wich is needed by TextOutCurved is only made of 2 points:
Beginning and ending of the text.
Example in the attachment
Here we go:
Procedure TextOutKerning(dest : TBGRABitmap; x,y: single; txt: string;
col: TBGRAPixel; align: TAlignment; space : single);
var P1,P2 : TPointF;
UtfLen : Integer;
len : single;
path : TBGRAPath;
begin
len := Dest.TextSize(txt).cx;
UtfLen := UTF8Length(txt);
case align of
taLeftJustify : begin P1 := PointF(x,y);P2 := PointF(x+len +(UTFlen-1)*space,y); end;
taRightJustify: begin P2 := PointF(x,y);P1 := PointF(x-len -(UTFlen-1)*space,y); end;
taCenter : begin P1 := PointF(x-(len +(UTFlen-1)*space)/2,y);
P2 := PointF(x+(len +(UTFlen-1)*space)/2,y); end;
end; //case
path := TBGRAPath.Create(PointsF([P1,P2]));
dest.TextOutCurved(path,txt,col,align,space);
path.Free;
end;
There is definitly a quicker way to do that.
Perhaps @circular can insert it in one of the next versions.
Winni