Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions Source/OxyPlot.GtkSharp.Shared/GraphicsRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class GraphicsRenderContext : RenderContextBase
/// </summary>
private Cairo.Context g;

/// <summary>
/// The text layout context
/// </summary>
private Pango.Context c;

/// <summary>
/// Sets the graphics target.
/// </summary>
Expand All @@ -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);
}

/// <summary>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down