mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-21 15:00:42 +02:00
CairoCanvas, support for wordbreak text style, from Petr-K, issue #25484
git-svn-id: trunk@44430 -
This commit is contained in:
parent
53f8732b32
commit
585b1dd06a
@ -1180,7 +1180,16 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$ifdef pangocairo}
|
{$ifdef pangocairo}
|
||||||
// TODO: missing breaklines
|
if Style.Wordbreak then begin
|
||||||
|
pango_layout_set_width(layout, Round(BoxWidth*PANGO_SCALE));
|
||||||
|
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
|
||||||
|
case Style.Alignment of //Works only with pango_layout_set_width
|
||||||
|
taLeftJustify: pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
|
||||||
|
taCenter: pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
|
||||||
|
taRightJustify: pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
pango_layout_set_text(layout, pchar(s), -1);
|
pango_layout_set_text(layout, pchar(s), -1);
|
||||||
pango_layout_get_extents(Layout, @ink, @logical);
|
pango_layout_get_extents(Layout, @ink, @logical);
|
||||||
//Calc start 'box' relative positions
|
//Calc start 'box' relative positions
|
||||||
@ -1217,10 +1226,12 @@ begin
|
|||||||
{$ifdef pangocairo}
|
{$ifdef pangocairo}
|
||||||
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
|
x := 0;
|
||||||
taLeftJustify: x := 0;
|
if not Style.Wordbreak then begin
|
||||||
taCenter: x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
|
case Style.Alignment of
|
||||||
taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
|
taCenter: x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
|
||||||
|
taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
|
||||||
|
end;
|
||||||
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