diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d07a66..4edbdff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,4 +9,5 @@ All notable changes to this project will be documented in this file. - Depend on OxyPlot.Core 1.0.0 - Build OxyPlot.GtkSharp with GtkSharp 2.12.45 - Build OxyPlot.GtkSharp3 with GtkSharp 2.99.3 -- Fix application freeze on Linux/X11 when viewing "show tracker without clicking" example (#13) +- Mitigate memory issue with Pango.Layout #11 +- Fix application freeze on Linux/X11 when viewing "show tracker without clicking" example (#13) \ No newline at end of file diff --git a/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs b/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs index 0bf4fad..02cb6a0 100644 --- a/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs +++ b/Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs @@ -39,6 +39,11 @@ public class GraphicsRenderContext : RenderContextBase /// private Cairo.Context g; + /// + /// The text layout context + /// + private Pango.Context c; + /// /// Sets the graphics target. /// @@ -47,6 +52,7 @@ public void SetGraphicsTarget(Cairo.Context graphics) { this.g = graphics; this.g.Antialias = Antialias.Subpixel; // TODO .TextRenderingHint = TextRenderingHint.AntiAliasGridFit; + this.c = Pango.CairoHelper.CreateContext(this.g); } /// @@ -258,7 +264,7 @@ public override void DrawText( VerticalAlignment valign, OxySize? maxSize) { - Pango.Layout layout = Pango.CairoHelper.CreateLayout(this.g); + Pango.Layout layout = new Layout(this.c); Pango.FontDescription font = new Pango.FontDescription(); font.Family = fontFamily; font.Weight = (fontWeight >= 700) ? Pango.Weight.Bold : Pango.Weight.Normal; @@ -330,7 +336,7 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS return OxySize.Empty; } this.g.Save(); - Pango.Layout layout = Pango.CairoHelper.CreateLayout(this.g); + Pango.Layout layout = new Layout(this.c); Pango.FontDescription font = new Pango.FontDescription(); font.Family = fontFamily; font.Weight = (fontWeight >= 700) ? Pango.Weight.Bold : Pango.Weight.Normal;