cairo-fsm: Implement dashed lines.
[pspp] / src / output / cairo-fsm.c
index 6988d3f76cebe523cca41cbde82cbb239f3430a4..16cf47dec43883b711da0d14cf4fd371f7a1e22a 100644 (file)
@@ -185,8 +185,6 @@ xr_draw_line (struct xr_fsm *xr, int x0, int y0, int x1, int y1, int style,
               const struct cell_color *color)
 {
   cairo_new_path (xr->cairo);
-  if (!xr->style->use_system_colors)
-    xr_set_source_rgba (xr->cairo, color);
   cairo_set_line_width (
     xr->cairo,
     xr_to_pt (style == RENDER_LINE_THICK ? XR_LINE_WIDTH * 2
@@ -194,7 +192,14 @@ xr_draw_line (struct xr_fsm *xr, int x0, int y0, int x1, int y1, int style,
               : XR_LINE_WIDTH));
   cairo_move_to (xr->cairo, xr_to_pt (x0), xr_to_pt (y0));
   cairo_line_to (xr->cairo, xr_to_pt (x1), xr_to_pt (y1));
+
+  if (!xr->style->use_system_colors)
+    xr_set_source_rgba (xr->cairo, color);
+  if (style == RENDER_LINE_DASHED)
+    cairo_set_dash (xr->cairo, (double[]) { 2 }, 1, 0);
   cairo_stroke (xr->cairo);
+  if (style == RENDER_LINE_DASHED)
+    cairo_set_dash (xr->cairo, NULL, 0, 0);
 }
 
 static void UNUSED
@@ -817,6 +822,9 @@ xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
     bb[X][1] == INT_MAX ? -1 : xr_to_pango (bb[X][1] - bb[X][0]));
   pango_layout_set_wrap (layout, PANGO_WRAP_WORD);
 
+  int size[TABLE_N_AXES];
+  pango_layout_get_size (layout, &size[H], &size[V]);
+
   if (clip[H][0] != clip[H][1])
     {
       cairo_save (xr->cairo);
@@ -824,8 +832,10 @@ xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
         xr_clip (xr, clip);
       if (options & TAB_ROTATE)
         {
+          int extra = bb[H][1] - bb[H][0] - size[V];
+          int halign_offset = extra > 0 ? extra / 2 : 0;
           cairo_translate (xr->cairo,
-                           xr_to_pt (bb[H][0]),
+                           xr_to_pt (bb[H][0] + halign_offset),
                            xr_to_pt (bb[V][1]));
           cairo_rotate (xr->cairo, -M_PI_2);
         }
@@ -864,8 +874,6 @@ xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
       cairo_restore (xr->cairo);
     }
 
-  int size[TABLE_N_AXES];
-  pango_layout_get_size (layout, &size[H], &size[V]);
   int w = pango_to_xr (size[X]);
   int h = pango_to_xr (size[Y]);
   if (w > *widthp)