View Issue Details

IDProjectCategoryView StatusLast Update
0025484LazarusPrinterpublic2014-11-06 12:25
ReporterPetr-KAssigned ToJesus Reyes 
PriorityhighSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.3 (SVN)Product Buildtrunk #43585 
Target Version1.4Fixed in Version1.3 (SVN) 
Summary0025484: CairoCanvas WordBreak implementation with pango_layout
DescriptionIn CairoCanvas was not implented WordBreak.
TagsNo tags attached.
Fixed in Revision44430
LazTarget1.4
WidgetsetGTK 2
Attached Files
  • cairocanvas.patch (1,661 bytes)
    Index: components/cairocanvas/cairocanvas.pas
    ===================================================================
    --- components/cairocanvas/cairocanvas.pas	(revision 43585)
    +++ components/cairocanvas/cairocanvas.pas	(working copy)
    @@ -1180,7 +1188,16 @@
         {$endif}
     
         {$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_get_extents(Layout, @ink, @logical);
         //Calc start 'box' relative positions
    @@ -1217,10 +1234,12 @@
           {$ifdef pangocairo}
           pango_layout_set_text(layout, pchar(s1), -1);
           pango_layout_get_extents(Layout, @ink, @logical);
    -      case Style.Alignment of
    -        taLeftJustify:  x := 0;
    -        taCenter:       x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
    -        taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
    +      x := 0;
    +      if not Style.Wordbreak then begin
    +        case Style.Alignment of
    +          taCenter:       x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
    +          taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
    +        end;
           end;
           cairo_move_to(cr, x, y);
           //DebugLn('TextRect ',S1);
    
    cairocanvas.patch (1,661 bytes)

Activities

Petr-K

2014-01-02 14:53

reporter  

cairocanvas.patch (1,661 bytes)
Index: components/cairocanvas/cairocanvas.pas
===================================================================
--- components/cairocanvas/cairocanvas.pas	(revision 43585)
+++ components/cairocanvas/cairocanvas.pas	(working copy)
@@ -1180,7 +1188,16 @@
     {$endif}
 
     {$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_get_extents(Layout, @ink, @logical);
     //Calc start 'box' relative positions
@@ -1217,10 +1234,12 @@
       {$ifdef pangocairo}
       pango_layout_set_text(layout, pchar(s1), -1);
       pango_layout_get_extents(Layout, @ink, @logical);
-      case Style.Alignment of
-        taLeftJustify:  x := 0;
-        taCenter:       x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
-        taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
+      x := 0;
+      if not Style.Wordbreak then begin
+        case Style.Alignment of
+          taCenter:       x := BoxWidth/2 - logical.width/PANGO_SCALE/2;
+          taRightJustify: x := BoxWidth - logical.Width/PANGO_SCALE;
+        end;
       end;
       cairo_move_to(cr, x, y);
       //DebugLn('TextRect ',S1);
cairocanvas.patch (1,661 bytes)

Jesus Reyes

2014-03-15 09:20

developer   ~0073709

Applied, thanks.

Issue History

Date Modified Username Field Change
2014-01-02 14:53 Petr-K New Issue
2014-01-02 14:53 Petr-K File Added: cairocanvas.patch
2014-01-25 06:12 Jesus Reyes Assigned To => Jesus Reyes
2014-01-25 06:12 Jesus Reyes Status new => assigned
2014-03-14 07:46 Jesus Reyes LazTarget => -
2014-03-14 07:46 Jesus Reyes Priority normal => high
2014-03-15 09:20 Jesus Reyes Fixed in Revision => 44430
2014-03-15 09:20 Jesus Reyes LazTarget - => 1.4
2014-03-15 09:20 Jesus Reyes Note Added: 0073709
2014-03-15 09:20 Jesus Reyes Status assigned => resolved
2014-03-15 09:20 Jesus Reyes Fixed in Version => 1.3 (SVN)
2014-03-15 09:20 Jesus Reyes Resolution open => fixed
2014-03-15 09:20 Jesus Reyes Target Version => 1.4
2014-11-06 12:25 Petr-K Status resolved => closed