I had thought that settextjustify is the right function. But I received so astonishing results that I prepared some simple tests. It seems an aligment and a justification are two different beasts.
The first example is a about horizontal aligment/justification. In SF the code is:
.....
CALL settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 18)
CALL settextjustify(LEFT_TEXT, BOTTOM_TEXT)
CALL outtextxy(50, 50, 'Abcd-l')
CALL settextjustify(CENTER_TEXT, BOTTOM_TEXT)
CALL outtextxy(50, 70, 'Abcd-c')
CALL settextjustify(RIGHT_TEXT, BOTTOM_TEXT)
CALL outtextxy(50, 90, 'Abcd-r')
CALL line(50, 0, 50, 299)
.....
In Delphi Pascal I call Windows API for aligning:
procedure TForm1.FormPaint(Sender: TObject);
var
h : THandle;
begin
h:=Form1.Canvas.Handle;
SetTextAlign(h, TA_LEFT);
TextOut(h, 50, 50, 'Abcd-l', 6);
SetTextAlign(h, TA_CENTER);
TextOut(h, 50, 70, 'Abcd-c', 6);
SetTextAlign(h, TA_RIGHT);
TextOut(h, 50, 90, 'Abcd-r', 6);
MoveToEx(h, 50, 1, NIL);
LineTo(h, 50, 299)
end;
The vertical line is for better orientation.
The second example is about a vertical aligment/justification.
SF code is as follows:
.....
CALL settextjustify(LEFT_TEXT, BOTTOM_TEXT)
CALL outtextxy(50, 50, 'Abcd-b')
CALL settextjustify(LEFT_TEXT, CENTER_TEXT)
CALL outtextxy(150, 50, 'Abcd-c')
CALL settextjustify(LEFT_TEXT, TOP_TEXT)
CALL outtextxy(250, 50, 'Abcd-t')
CALL line(0, 65, 399, 65)
.....
Delphi code is:
procedure TForm1.FormPaint(Sender: TObject);
var
h : THandle;
begin
h:=Form1.Canvas.Handle;
SetTextAlign(h, TA_BOTTOM);
TextOut(h, 50, 50, 'Abcd-b', 6);
SetTextAlign(h, TA_BASELINE);
TextOut(h, 150, 50, 'Abcd-c', 6);
SetTextAlign(h, TA_TOP);
TextOut(h, 250, 50, 'Abcd-t', 6);
MoveToEx(h, 1, 65, NIL);
LineTo(h, 399, 65)
end;
The horizontal line is for better orientation.
If you can't run the above examples I will send you screenshots or will try to drop here.
As you can see the results are quite different. My suggerstion concerns "aligment" when I can draw a text that the middle point matches the required one. For example the centre of a labal fits the center of the line.