Skip to content

Commit

Permalink
[Fixes bug #1305701] Fix some incorrect behaviour on Ubuntu 14.04.
Browse files Browse the repository at this point in the history
It appears that the StrokeExtents() bug was fixed, so we now need to
manually call into cairo_stroke_extents to ensure that we get consistent
behaviour everywhere.

This was causing many issues, such as incorrect invalidation rectangles.
  • Loading branch information
cameronwhite committed Apr 24, 2014
1 parent 7b83f76 commit 636e354
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Pinta.Core/Extensions/CairoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using System;
using Cairo;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace Pinta.Core
{
Expand Down Expand Up @@ -485,17 +486,23 @@ public static Rectangle DrawLine (this Context g, PointD p1, PointD p2, Color co
/// bottom-right corner of the Rectangle in the width and
/// height members. This method corrects the rectangle to
/// contain the width and height in the width and height members.
///
/// This can be removed once we port to GTK3.
/// </summary>
/// <returns>
/// The rectangle describing the area that would be
/// affected.
/// </returns>
public static Rectangle FixedStrokeExtents (this Context g)
{
Rectangle r = g.StrokeExtents();
return new Rectangle (r.X, r.Y, r.Width - r.X, r.Height - r.Y);
double x1, y1, x2, y2;
cairo_stroke_extents (g.Handle, out x1, out y1, out x2, out y2);
return new Rectangle (x1, y1, x2 - x1, y2 - y1);
}

[DllImport ("libcairo-2.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern void cairo_stroke_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2);

private static Pango.Style CairoToPangoSlant (FontSlant slant)
{
switch (slant) {
Expand Down

0 comments on commit 636e354

Please sign in to comment.