PangoSharp: Difference between revisions

From Wiki Maui Linux NET
Jump to navigation Jump to search
Created page with "{{Infobox software | name = PangoSharp | logo = GTK_logo.svg | developer = GNOME Project, Xamarin, and community contributors | released = {{Start date|2002}} | programming_language = C# | operating_system = Cross-platform | platform = .NET, Mono | genre = Text layout and rendering library bindings | license = GNU Lesser General Public License | website = [https://github.com/GtkSharp/GtkSharp GitHub repository]..."
 
Line 80: Line 80:
* [[GLibSharp]]
* [[GLibSharp]]
* [[Mono (software)]]
* [[Mono (software)]]
* [[.NET (software framework)]]


== External links ==
== External links ==

Revision as of 13:06, 20 October 2025

PangoSharp
Developer(s) GNOME Project, Xamarin, and community contributors
Initial release

2002

Latest version
Programming language C#
Operating system Cross-platform
Platform .NET, Mono
Type Text layout and rendering library bindings
License GNU Lesser General Public License
Website GitHub repository


PangoSharp is a set of C# bindings for the Pango text layout and rendering library. It is part of the GtkSharp project and provides managed access to Pango’s advanced international text handling and font rendering capabilities for use in .NET and Mono applications.

Overview of Pango

Pango (short for "Portable Layout Engine") is a library designed for high-quality text layout and rendering. It forms the text subsystem of the GTK toolkit and is used for displaying complex, multilingual text with proper script shaping and font support.

Pango integrates with Cairo for rendering and supports multiple font backends, including FreeType, Xft, and DirectWrite.

Core features of Pango include:

  • Advanced text layout for multiple scripts and languages
  • Bidirectional text handling (e.g. Arabic, Hebrew)
  • Font management and metrics
  • Integration with Cairo for high-quality rendering
  • OpenType and TrueType font support
  • Line breaking, alignment, and markup text

PangoSharp

PangoSharp provides managed C# bindings for the native Pango library. It enables developers to render text, measure font metrics, and perform complex layout operations within .NET applications that use GtkSharp or CairoSharp.

Using PangoSharp, developers can:

  • Create and render richly formatted text layouts
  • Measure and align text precisely within drawing contexts
  • Integrate international and complex-script text support
  • Use Pango markup to render stylized text (colors, fonts, weights, etc.)
  • Combine with CairoSharp for custom 2D graphics rendering

PangoSharp mirrors Pango’s object-oriented design while exposing it through a type-safe, idiomatic C# API.

Relationship to other GtkSharp components

PangoSharp works closely with several other GtkSharp bindings:

  • CairoSharp – Used as the rendering backend for drawing Pango layouts.
  • GtkSharp – Uses Pango for all text rendering in GTK widgets.
  • GdkSharp – Provides integration with windows and surfaces where Pango text is drawn.
  • GLibSharp – Supplies the object and signal system used by PangoSharp’s bindings.

Version compatibility

PangoSharp tracks the corresponding GTK and Pango versions:

  • **PangoSharp 2.x** – For GTK 2 and older Mono environments
  • **PangoSharp 3.x** – For GTK 3 and modern .NET versions
  • **PangoSharp 4.x** – Planned for GTK 4 and .NET 6+ with improved introspection support

Example

A simple example of drawing text using PangoSharp and CairoSharp:

using Cairo;
using Pango;

public void DrawText(Context cr)
{
    using (Layout layout = Pango.CairoHelper.CreateLayout(cr))
    {
        layout.SetText("Hello, GtkSharp with Pango!", -1);
        layout.FontDescription = FontDescription.FromString("Sans Bold 16");
        cr.SetSourceRGB(0, 0, 0);
        Pango.CairoHelper.ShowLayout(cr, layout);
    }
}

See also