CairoCanvas, for alignment, logical rect should be used instead of ink rect, fix alignment to the right

git-svn-id: trunk@40722 -
This commit is contained in:
jesus 2013-04-05 20:10:53 +00:00
parent 8fc6a8eb4b
commit a471e2d12c
2 changed files with 9 additions and 7 deletions

View File

@ -934,9 +934,9 @@ begin
pango_layout_set_text(layout, pchar(s1), -1);
pango_layout_get_extents(Layout, @ink, @logical);
case Style.Alignment of
taLeftJustify: x := StartLeft;
taCenter: x := BoxLeft + BoxWidth/2 - ink.width/PANGO_SCALE/2;
taRightJustify: x := BoxLeft+BoxWidth - ink.Width/PANGO_SCALE;
taLeftJustify: x := StartLeft;
taCenter: x := BoxLeft + BoxWidth/2 - logical.width/PANGO_SCALE/2;
taRightJustify: x := BoxLeft+BoxWidth - logical.Width/PANGO_SCALE;
end;
cairo_move_to(cr, x, y);
//DebugLn('TextRect ',S1);

View File

@ -233,9 +233,11 @@ procedure TForm1.DrawOther(cnv: TCanvas; XDPI, YDPI: Integer);
const
CTEXT='Hola';
Par =
'Uno' + LineEnding+
'noU' + LineEnding+
'oUn' + LineEnding+
'1.111' + LineEnding+
'0.000' + LineEnding+
'.101' + LineEnding+
'M.Unl' + LineEnding+
'.UnlM' + LineEnding+
'01.' + LineEnding+
'1.0' + LineEnding+
'.01';
@ -269,7 +271,7 @@ begin
cnv.TextOut(R.Left, R.Top, 'Line3'); OffsetRect(R, 0, sz.cy);
R := Rect(XDPI*4, YDPI*2, Round(XDPI*6), round(YDPI*6));
cnv.Font.Name := 'Arial';
cnv.Font.Name := 'Sans';
cnv.Font.Size := 40;
cnv.Font.Color := clGreen;
cnv.Brush.Style := bsClear;