mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 16:38:15 +02:00
CairoCanvas, fix textrect rotation
git-svn-id: trunk@40724 -
This commit is contained in:
parent
2b3ef514e9
commit
5fc932cc76
@ -809,6 +809,12 @@ begin
|
|||||||
cairo_clip(cr);
|
cairo_clip(cr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if (Font.Orientation=900) or (Font.Orientation=2700) then begin
|
||||||
|
x := BoxWidth;
|
||||||
|
BoxWidth := BoxHeight;
|
||||||
|
BoxHeight := x;
|
||||||
|
end;
|
||||||
|
|
||||||
if Style.ExpandTabs then
|
if Style.ExpandTabs then
|
||||||
s := StringReplace(s, #9, ' ', [rfReplaceAll])
|
s := StringReplace(s, #9, ' ', [rfReplaceAll])
|
||||||
else
|
else
|
||||||
@ -911,12 +917,29 @@ begin
|
|||||||
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{$ifdef pangocairo}
|
||||||
|
// TODO: missing breaklines
|
||||||
|
pango_layout_set_text(layout, pchar(s), -1);
|
||||||
|
pango_layout_get_extents(Layout, @ink, @logical);
|
||||||
|
//Calc start 'box' relative positions
|
||||||
|
case Style.Layout of
|
||||||
|
tlTop: y := 0;
|
||||||
|
tlCenter: y := BoxHeight/2 - logical.Height/PANGO_SCALE/2;
|
||||||
|
tlBottom: y := BoxHeight - logical.height/PANGO_SCALE;
|
||||||
|
end;
|
||||||
|
{$else}
|
||||||
//Calc start positions
|
//Calc start positions
|
||||||
case Style.Layout of
|
case Style.Layout of
|
||||||
tlTop: y := StartTop;
|
tlTop: y := 0;
|
||||||
tlCenter: y := boxTop + BoxHeight/2 - fe.height*Lines.Count/2;
|
tlCenter: y := BoxHeight/2 - fe.height*Lines.Count/2;
|
||||||
tlBottom: y := BoxTop+BoxHeight - fe.height*Lines.Count;
|
tlBottom: y := BoxHeight - fe.height*Lines.Count;
|
||||||
end;
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
// translate origin
|
||||||
|
cairo_translate(cr, StartLeft, StartTop);
|
||||||
|
// rotate
|
||||||
|
cairo_rotate(cr, -DegToRad(Font.Orientation/10));
|
||||||
|
|
||||||
//Text output
|
//Text output
|
||||||
for i := 0 to Lines.Count-1 do begin
|
for i := 0 to Lines.Count-1 do begin
|
||||||
@ -930,13 +953,12 @@ begin
|
|||||||
|
|
||||||
//DebugLn('i=%i y=%f s1=%s',[i,y,s1]);
|
//DebugLn('i=%i y=%f s1=%s',[i,y,s1]);
|
||||||
{$ifdef pangocairo}
|
{$ifdef pangocairo}
|
||||||
//cairo_text_extents(cr, PChar(s1), @te);
|
|
||||||
pango_layout_set_text(layout, pchar(s1), -1);
|
pango_layout_set_text(layout, pchar(s1), -1);
|
||||||
pango_layout_get_extents(Layout, @ink, @logical);
|
pango_layout_get_extents(Layout, @ink, @logical);
|
||||||
case Style.Alignment of
|
case Style.Alignment of
|
||||||
taLeftJustify: x := StartLeft;
|
taLeftJustify: x := 0;
|
||||||
taCenter: x := BoxLeft + BoxWidth/2 - logical.width/PANGO_SCALE/2;
|
taCenter: x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
|
||||||
taRightJustify: x := BoxLeft+BoxWidth - logical.Width/PANGO_SCALE;
|
taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
|
||||||
end;
|
end;
|
||||||
cairo_move_to(cr, x, y);
|
cairo_move_to(cr, x, y);
|
||||||
//DebugLn('TextRect ',S1);
|
//DebugLn('TextRect ',S1);
|
||||||
|
Loading…
Reference in New Issue
Block a user