// Generated API outline. Implementation bodies omitted.
#nullable enable
using G16 = ushort;
using RGBA = uint;
using System.ComponentModel;
using System.Diagnostics;
using nfloat = System.Runtime.InteropServices.NFloat;
namespace Xui.GPU.Software
{
using System;
using Xui.GPU.Shaders.Types;
///
/// Defines blend modes for color blending operations.
///
public enum BlendMode
{
///
/// Standard alpha blending (source over destination).
/// result = src.rgb * src.a + dst.rgb * (1 - src.a)
///
Alpha,
///
/// Additive blending - colors are added together.
/// result = src.rgb + dst.rgb
///
Add,
///
/// Multiplicative blending - colors are multiplied.
/// result = src.rgb * dst.rgb
///
Multiply,
///
/// Screen blending - inverted multiplicative.
/// result = 1 - (1 - src.rgb) * (1 - dst.rgb)
///
Screen,
///
/// Overlay blending - combination of multiply and screen.
/// Darkens dark colors, lightens light colors.
///
Overlay,
///
/// Replace mode - source completely replaces destination.
/// result = src.rgb
///
Replace
}
///
/// Represents a color attachment target for rendering operations.
///
///
/// Provides conversion utilities between shader Color4 types and RGBA32 packed format.
///
public static class ColorTarget
{
///
/// Converts a Color4 value to packed RGBA32 format (0xRRGGBBAA).
///
/// Color4 value with components in range [0.0, 1.0].
/// Packed RGBA32 color value.
///
/// Color components are clamped to [0.0, 1.0] and converted to 8-bit values.
///
public static uint ToRgba32(Color4 color);
///
/// Converts packed RGBA32 format to a Color4 value.
///
/// Packed RGBA32 color value (0xRRGGBBAA).
/// Color4 value with components in range [0.0, 1.0].
public static Color4 FromRgba32(uint rgba32);
///
/// Blends two colors using alpha blending (source over destination).
///
/// Source color with premultiplied alpha.
/// Destination color.
/// Blended color.
///
/// Uses standard alpha blending formula:
/// result = src.rgb * src.a + dst.rgb * (1 - src.a)
///
public static Color4 Blend(Color4 src, Color4 dst);
///
/// Blends a source color onto a destination using packed RGBA32 format.
///
/// Source RGBA32 color.
/// Destination RGBA32 color.
/// Blended RGBA32 color.
public static uint BlendRgba32(uint src, uint dst);
///
/// Blends two colors using the specified blend mode.
///
/// Source color.
/// Destination color.
/// The blend mode to use.
/// Blended color.
public static Color4 BlendWith(Color4 src, Color4 dst, BlendMode mode);
///
/// Additive blending - adds source and destination colors.
///
/// Source color.
/// Destination color.
/// Added color (clamped to [0, 1]).
public static Color4 Add(Color4 src, Color4 dst);
///
/// Multiplicative blending - multiplies source and destination colors.
///
/// Source color.
/// Destination color.
/// Multiplied color.
public static Color4 Multiply(Color4 src, Color4 dst);
///
/// Screen blending - inverted multiplicative blending.
///
/// Source color.
/// Destination color.
/// Screen-blended color.
public static Color4 Screen(Color4 src, Color4 dst);
///
/// Overlay blending - combination of multiply and screen based on destination luminance.
///
/// Source color.
/// Destination color.
/// Overlay-blended color.
public static Color4 Overlay(Color4 src, Color4 dst);
}
}
namespace Xui.GPU.Software
{
using System;
using Xui.GPU.Shaders.Types;
using Xui.GPU.Shaders;
///
/// Specifies which triangle faces to cull during software rasterization.
///
public enum CullMode
{
/// No culling — all triangles are rendered.
None = 0,
/// Back-facing triangles are culled (default).
Back = 1,
/// Front-facing triangles are culled.
Front = 2,
}
///
/// Orchestrates the software rendering pipeline.
///
///
/// RenderContext manages the rendering state and executes vertex and fragment shaders
/// to produce pixels in a framebuffer.
///
public unsafe class RenderContext
{
/// Uses premultiplied source-over when blending is enabled.
public bool PremultipliedAlpha { get; set; }
///
/// Gets the framebuffer associated with this render context.
///
public Framebuffer Framebuffer { get; }
///
/// Gets or sets the viewport for coordinate transformation.
///
public Viewport Viewport { get; set; }
///
/// Gets or sets the primitive topology.
///
public PrimitiveTopology Topology { get; set; }
///
/// Gets or sets whether depth testing is enabled.
///
public bool DepthTestEnabled { get; set; }
///
/// Gets or sets whether blending is enabled.
///
public bool BlendEnabled { get; set; }
///
/// Gets or sets the triangle cull mode (default is Back).
///
public CullMode CullMode { get; set; }
///
/// Creates a new render context with the specified framebuffer.
///
/// The framebuffer to render into.
public RenderContext(Framebuffer framebuffer);
///
/// Clears the framebuffer color to the specified value.
///
/// Color to clear to.
public void ClearColor(Color4 color);
///
/// Clears the framebuffer depth to the specified value.
///
/// Depth value to clear to (default 1.0).
public void ClearDepth(float depth = 1.0f);
///
/// Renders vertices through the specified vertex and fragment shaders.
///
/// The vertex input type.
/// The varying data type (vertex output / fragment input).
/// The shader bindings type.
/// Source of vertex data.
/// Vertex shader implementation.
/// Fragment shader implementation.
/// Shader bindings (uniforms, textures, etc.).
public void Draw(VertexSource vertices, IVertexShader vertexShader, IFragmentShader fragmentShader, TBindings bindings)
where TVertex : unmanaged where TVarying : unmanaged where TBindings : struct;
}
}
namespace Xui.GPU.Software
{
using System.Runtime.InteropServices;
using System;
///
/// Represents a framebuffer with RGBA32 color data and optional depth buffer.
///
///
/// The framebuffer stores pixel data in RGBA format with 8 bits per channel.
/// Coordinates are in screen space with origin at top-left (0,0).
///
public unsafe struct Framebuffer : IDisposable
{
///
/// Gets the width of the framebuffer in pixels.
///
public readonly int Width { get; }
///
/// Gets the height of the framebuffer in pixels.
///
public readonly int Height { get; }
///
/// Gets a pointer to the RGBA32 color data.
///
///
/// Color data is stored as packed RGBA with 8 bits per channel.
/// Format: 0xRRGGBBAA
///
public readonly uint* ColorData { get; }
///
/// Gets a pointer to the depth buffer data, or null if no depth buffer.
///
///
/// Depth values are stored as normalized floats in range [0.0, 1.0].
/// 0.0 represents the near plane, 1.0 represents the far plane.
///
public readonly float* DepthData { get; }
///
/// Gets whether this framebuffer has a depth buffer.
///
public readonly bool HasDepthBuffer { get; }
///
/// Creates a new framebuffer with the specified dimensions.
///
/// Width in pixels. Must be greater than 0.
/// Height in pixels. Must be greater than 0.
/// Whether to allocate a depth buffer.
///
/// Thrown when width or height is less than or equal to 0.
///
public Framebuffer(int width, int height, bool withDepthBuffer = true);
///
/// Creates a framebuffer wrapping existing memory buffers.
///
/// Width in pixels.
/// Height in pixels.
/// Pointer to RGBA32 color data.
/// Optional pointer to depth buffer data.
///
/// This constructor does not take ownership of the memory buffers.
/// The caller is responsible for managing the lifetime of the buffers.
///
public Framebuffer(int width, int height, uint* colorData, float* depthData = null);
///
/// Clears the color buffer to the specified color.
///
/// RGBA32 color value (0xRRGGBBAA).
public readonly void ClearColor(uint color);
///
/// Clears the depth buffer to the specified depth value.
///
/// Depth value in range [0.0, 1.0]. Default is 1.0 (far plane).
///
/// Thrown when the framebuffer has no depth buffer.
///
public readonly void ClearDepth(float depth = 1.0f);
///
/// Sets the color at the specified pixel coordinate.
///
/// X coordinate in pixels.
/// Y coordinate in pixels.
/// RGBA32 color value.
public readonly void SetColor(int x, int y, uint color);
///
/// Gets the color at the specified pixel coordinate.
///
/// X coordinate in pixels.
/// Y coordinate in pixels.
/// RGBA32 color value, or 0 if coordinates are out of bounds.
public readonly uint GetColor(int x, int y);
///
/// Sets the depth at the specified pixel coordinate.
///
/// X coordinate in pixels.
/// Y coordinate in pixels.
/// Depth value in range [0.0, 1.0].
public readonly void SetDepth(int x, int y, float depth);
///
/// Gets the depth at the specified pixel coordinate.
///
/// X coordinate in pixels.
/// Y coordinate in pixels.
/// Depth value in range [0.0, 1.0], or 1.0 if coordinates are out of bounds or no depth buffer.
public readonly float GetDepth(int x, int y);
///
/// Copies the color data to a managed byte array in RGBA format.
///
/// Byte array containing RGBA color data.
public readonly byte[] ToByteArray();
///
/// Releases the framebuffer memory if owned by this instance.
///
public void Dispose();
}
///
/// Represents a source of vertex data for rendering.
///
/// The vertex structure type.
///
/// VertexSource provides a view over a contiguous array of vertex data.
/// The vertex type T must be a value type with sequential layout.
///
public unsafe struct VertexSource
where T : unmanaged
{
///
/// Gets the number of vertices in this source.
///
public readonly int Count { get; }
///
/// Gets a pointer to the vertex data.
///
public readonly T* Data { get; }
///
/// Creates a vertex source from a managed array.
///
/// Array of vertex data.
/// A pinned vertex source.
///
/// IMPORTANT: This method is unsafe and should not be used in production code.
/// The returned VertexSource contains a pointer to memory that will become invalid
/// once the fixed block exits. The array can be moved by the garbage collector.
///
/// Instead, use the constructor directly within a fixed block:
///
/// fixed (TVertex* ptr = vertices)
/// {
/// var source = new VertexSource<TVertex>(ptr, vertices.Length);
/// // Use source here
/// }
///
///
/// This method is deprecated and will be removed in a future version.
///
[Obsolete("Use constructor within a fixed block instead. This method creates dangling pointers.", error: true)]
public static VertexSource FromArray(T[] vertices);
///
/// Creates a vertex source from a memory pointer.
///
/// Pointer to vertex data.
/// Number of vertices.
public VertexSource(T* data, int count);
///
/// Gets the vertex at the specified index.
///
/// Zero-based vertex index.
/// The vertex at the specified index.
///
/// Thrown when index is out of bounds.
///
public readonly T this[int index] { get; }
///
/// Gets a read-only span over the vertex data.
///
/// A read-only span of vertices.
public readonly ReadOnlySpan AsSpan();
}
}
namespace Xui.GPU.Software
{
///
/// Defines the primitive topology for vertex assembly.
///
public enum PrimitiveTopology
{
///
/// Vertices are assembled into triangles.
/// Each group of 3 vertices forms a triangle.
///
TriangleList = 0,
///
/// Vertices form a strip of triangles where each vertex (after the first two)
/// forms a triangle with the two preceding vertices.
///
TriangleStrip = 1,
///
/// Individual line segments. Each group of 2 vertices forms a line.
///
LineList = 2,
///
/// Connected line segments where each vertex (after the first)
/// forms a line with the preceding vertex.
///
LineStrip = 3,
///
/// Individual points. Each vertex is rendered as a point.
///
PointList = 4,
}
}
namespace Xui.GPU.Software
{
using System.Collections.Generic;
using System.Linq;
using System;
using Xui.GPU.Hardware;
using Xui.GPU.Shaders.Types;
/// Deterministic RGBA8 sampling with bilinear filtering and trilinear mip selection.
public sealed class SampledTexture : ISampledTexture
{
/// Copies validated premultiplied RGBA levels, largest first.
public SampledTexture(int width, int height, IReadOnlyList mipLevels);
/// Samples normalized coordinates at an explicit mip level.
public Color4 Sample(Sampler sampler, Float2 uv, F32 level);
}
}
namespace Xui.GPU.Software
{
using System;
///
/// Defines the viewport transformation from normalized device coordinates to screen space.
///
///
/// The viewport maps coordinates from NDC space [-1, 1] to screen space [x, x+width] and [y, y+height].
/// The depth range maps from NDC space [0, 1] to [minDepth, maxDepth].
///
public readonly struct Viewport
{
///
/// Gets the X coordinate of the viewport's upper-left corner in pixels.
///
public readonly float X;
///
/// Gets the Y coordinate of the viewport's upper-left corner in pixels.
///
public readonly float Y;
///
/// Gets the width of the viewport in pixels.
///
public readonly float Width;
///
/// Gets the height of the viewport in pixels.
///
public readonly float Height;
///
/// Gets the minimum depth value (default 0.0).
///
public readonly float MinDepth;
///
/// Gets the maximum depth value (default 1.0).
///
public readonly float MaxDepth;
/// Maps positive NDC Y upward, matching Metal and Direct3D.
public readonly bool YUp;
///
/// Creates a new viewport.
///
/// X coordinate of upper-left corner.
/// Y coordinate of upper-left corner.
/// Width in pixels. Must be greater than 0.
/// Height in pixels. Must be greater than 0.
/// Minimum depth value (default 0.0).
/// Maximum depth value (default 1.0).
/// Use native GPU NDC orientation (+1 at the top).
///
/// Thrown when width or height is less than or equal to 0.
///
public Viewport(float x, float y, float width, float height, float minDepth = 0.0f, float maxDepth = 1.0f, bool yUp = false);
///
/// Creates a viewport that covers the entire framebuffer.
///
/// The framebuffer to create a viewport for.
/// A viewport covering the entire framebuffer.
public static Viewport FromFramebuffer(Framebuffer framebuffer);
///
/// Transforms a position from normalized device coordinates to screen space.
///
/// X coordinate in NDC space [-1, 1].
/// Y coordinate in NDC space [-1, 1].
/// Z coordinate in NDC space [0, 1].
/// Output X coordinate in screen space.
/// Output Y coordinate in screen space.
/// Output depth value.
///
/// NDC coordinates map as follows:
/// - X: -1 (left) to +1 (right)
/// - Y: -1 (top) to +1 (bottom) [Note: Y is inverted from standard GL convention]
/// - Z: 0 (near) to 1 (far)
///
public readonly void Transform(float ndcX, float ndcY, float ndcZ, out float screenX, out float screenY, out float depth);
}
}
namespace Xui.Runtime.Software
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System;
///
/// Represents a grayscale 16-bit stencil buffer for supersampled shape coverage.
///
public class G16Stencil
{
public uint Width { get; }
public uint Height { get; }
public readonly _G16[] Alpha;
public G16Stencil(uint width, uint height);
public _G16 this[uint x, uint y] {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; [MethodImpl(MethodImplOptions.AggressiveInlining)]
set; }
public ReadOnlySpan AsBytes();
public void Clear();
public void Clear(uint startX, uint startY, uint w, uint h);
///
/// Adds the specified coverage amount to a stencil pixel at (x,y), saturating at 65535.
///
public void Add(uint x, uint y, ushort amount = 1);
}
public class RGBABitmap
{
public uint Width { get; }
public uint Height { get; }
public readonly _RGBA[] Pixels;
public RGBABitmap(uint width, uint height);
public _RGBA this[uint x, uint y] {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; [MethodImpl(MethodImplOptions.AggressiveInlining)]
set; }
public ReadOnlySpan AsBytes();
public void Blend(uint x, uint y, _RGBA src);
}
}
namespace Xui.Runtime.Software
{
using System.Buffers.Binary;
using System.IO.Compression;
using System.IO;
using System;
public class PngDecoder
{
public static byte[] LoadRGBA(string path, out int width, out int height);
public static byte[] LoadRGBA(Stream stream, out int width, out int height);
}
public class PngEncoder
{
public static void SaveRGBA(string path, byte[] rgbaPixels, int width, int height);
/// Encodes PNG data without closing the caller's stream.
public static void SaveRGBA(Stream stream, byte[] rgbaPixels, int width, int height);
public static void SaveRGBA(string path, RGBABitmap bitmap);
}
}
namespace Xui.Runtime.Software
{
using System.Collections.Generic;
using System.IO;
using System.Text;
using System;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
using Xui.Core.UI;
using Xui.Runtime.Software.Actual;
using Xui.Runtime.Software.Font;
///
/// Renders a view tree to a standalone SVG document without creating a window or accepting input.
///
///
///
/// This is intended for documentation, static web graphics, and deterministic component rendering.
/// It performs the same measure, arrange, and render passes that a root view receives during a
/// window render. is supplied to the layout pass, but no animation or input
/// events are generated.
///
///
/// Supply whenever layout depends on a bundled font. The optional
/// controls whether those fonts are treated as installed, linked from
/// the web, or embedded in the resulting SVG.
///
///
public sealed class SVGDocument
{
/// The view tree to lay out and render.
public View? Content { get; set; }
/// The SVG viewport size. Defaults to 800 by 600 logical pixels.
public Size Size { get; set; }
/// The deterministic time supplied as the current layout time. Defaults to zero.
public TimeSpan Time { get; set; }
///
/// Font sources used for text measurement and optional SVG font emission. Defaults to no fonts.
///
public IEnumerable FontUris { get; set; }
/// Optional descriptor-first font source used in preference to .
public IFontSource? FontSource { get; set; }
/// Controls how resolved font faces are represented in the SVG.
public SvgDrawingContext.SvgFontResolver FontResolver { get; set; }
/// Controls deterministic numeric formatting in the generated SVG.
public SvgDrawingContext.NumericFormat NumericFormat { get; set; }
///
/// Lays out and returns a complete SVG document.
///
public string ToSVG();
}
}
namespace Xui.Runtime.Software
{
using System.Runtime.InteropServices;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
public partial class SoftwareContext : IPathBuilder
{
protected Xui.Core.Canvas.Path2D path { get; }
public void Arc(Point center, NFloat radius, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise);
public void ArcTo(Point cp1, Point cp2, NFloat radius);
public void BeginPath();
public void ClosePath();
public void CurveTo(Point cp1, Point to);
public void CurveTo(Point cp1, Point cp2, Point to);
public void Ellipse(Point center, NFloat radiusX, NFloat radiusY, NFloat rotation, NFloat startAngle, NFloat endAngle, Winding winding = Winding.ClockWise);
public void LineTo(Point to);
public void MoveTo(Point to);
public void Rect(Rect rect);
public void RoundRect(Rect rect, NFloat radius);
public void RoundRect(Rect rect, CornerRadius radius);
}
}
namespace Xui.Runtime.Software
{
using System;
using Xui.Core.Canvas;
using Xui.Runtime.Software.Rasterization;
public partial class SoftwareContext : IPathDrawing
{
public void Fill(FillRule rule = FillRule.NonZero);
public void Stroke();
}
}
namespace Xui.Runtime.Software
{
using Xui.Core.Canvas;
public partial class SoftwareContext
{
public RGBABitmap bitmap { get; }
public G16Stencil stencil { get; }
public SoftwareContext(uint width, uint height);
}
}
namespace Xui.Runtime.Software
{
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct _G16
{
public ushort Gray;
public _G16(ushort gray);
}
}
namespace Xui.Runtime.Software
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct _RGBA
{
public byte Red;
public byte Green;
public byte Blue;
public byte Alpha;
public _RGBA(byte r, byte g, byte b, byte a);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static byte BlendByte(byte dst, byte src, float alpha);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static _RGBA Blend(_RGBA dst, _RGBA src, float alphaFactor);
}
}
namespace Xui.Runtime.Software.Actual
{
using System.Buffers.Binary;
using System.Collections.Concurrent;
using System.IO;
using System.Threading.Tasks;
using System;
using Xui.Core.Actual;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
/// An image handle retaining the original PNG bytes for SVG embedding.
public sealed class SoftwareImage : IImage
{
public Size Size { get; }
public void Load(string uri);
public async Task LoadAsync(string uri);
public void LoadPixels(int width, int height, ReadOnlySpan bgra32Data);
}
/// Cached packaged PNG resources for deterministic, self-contained SVG rendering.
public sealed class SoftwareImagePipeline : IImagePipeline
{
public SoftwareImagePipeline(string? baseDirectory = null);
public IImage CreateImage();
}
}
namespace Xui.Runtime.Software.Actual
{
using Catalog = Xui.Runtime.Software.Font.Catalog;
using Xui.Core.Canvas;
///
/// A lightweight backed by the software font
/// . Used to provide text hit-testing for pointer events
/// without needing a full drawing context.
///
public sealed class SoftwareTextMeasureContext : ITextMeasureContext
{
public SoftwareTextMeasureContext(Catalog catalog);
public TextMetrics MeasureText(string text);
public void SetFont(Xui.Core.Canvas.Font font);
}
}
namespace Xui.Runtime.Software.Actual
{
using System.Collections.Generic;
using System;
using Xui.Core.Canvas.Composition.Graphics;
using Xui.Core.Canvas;
public sealed partial class SvgDrawingContext
{
///
/// Emits an explicit SVG group, even with no transform or drawing. A new export always
/// needs content, independently of HasUpdates and any other context's native cache.
///
public CompositionGroup Group(scoped in GroupOptions options);
///
/// Closes the innermost group. Called by ;
/// prefer disposing the returned scope over calling this directly.
///
public void EndGroup();
}
}
namespace Xui.Runtime.Software.Actual
{
using System.Collections.Generic;
using System;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
public sealed partial class SvgDrawingContext
{
}
}
namespace Xui.Runtime.Software.Actual
{
using System.Collections.Generic;
using System.IO;
using System.Text;
using System;
using Xui.Core.Canvas.Symbols;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
public sealed partial class SvgDrawingContext
{
/// Writes one vector definition and a use element for each placement.
public void DrawSymbol(SymbolContent content);
}
}
namespace Xui.Runtime.Software.Actual
{
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.Marshalling;
using System.Runtime.InteropServices;
using System.Text;
using System;
using Xui.Core.Canvas.Filter;
using Xui.Core.Canvas;
using Xui.Core.Curves2D;
using Xui.Core.Math2D;
using Xui.Runtime.Software.Font;
public sealed partial class SvgDrawingContext : IContext, IDisposable
{
public void SetFilter();
public void SetFilter(Brightness brightness);
public nfloat GlobalAlpha { get; set; }
public LineCap LineCap { get; set; }
public LineJoin LineJoin { get; set; }
public nfloat LineWidth { get; set; }
public nfloat MiterLimit { get; set; }
public nfloat LineDashOffset { get; set; }
public TextAlign TextAlign { get; set; }
public TextBaseline TextBaseline { get; set; }
/// Characters and adjacent pairs rendered for each resolved font face.
public IReadOnlyDictionary FontUsage { get; }
public SvgDrawingContext(Size canvasSize, Stream output, IEnumerable fontUris, SvgFontResolver? resolver = null, NumericFormat? numericFormat = null, bool keepOpen = false);
/// Creates an SVG context with lazily loaded application font resources.
public SvgDrawingContext(Size canvasSize, Stream output, IFontSource fontSource, SvgFontResolver? resolver = null, NumericFormat? numericFormat = null, bool keepOpen = false);
public SvgDrawingContext(Size canvasSize, Stream output, bool keepOpen = false);
public SvgDrawingContext(Size canvasSize, Stream output, Catalog? catalog, SvgFontResolver? resolver = null, NumericFormat? numericFormat = null, bool keepOpen = false);
public void Dispose();
public abstract class NumericFormat
{
public abstract string Format(nfloat number);
public static NumericFormat Default { get; }
}
///
/// Delegate-based resolver that provides how a specific font should be handled in an SVG.
///
public class SvgFontResolver
{
public static readonly SvgFontResolver Default;
/// Embed only used glyphs and kerning pairs from each resolved font face.
public static readonly SvgFontResolver Embedded;
public virtual Resolved Resolve(FontFace face, Uri? uri);
}
public record struct Resolved(SvgFontMode Mode, Uri? WebUri);
///
/// Determines how to emit fonts inside an SVG.
///
public enum SvgFontMode
{
/// Assume the font is installed in the system; only use font-family="...".
System,
/// Emit a link to an external font using @font-face with a resolved URI.
WebLink,
/// Embed the font data as base64 using a data URI inside @font-face.
Embedded
}
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
public class CMapTable
{
public CMapTable(ReadOnlySpan data);
public int? GetGlyphIndex(int unicode);
public int? GetGlyphIndex(Rune rune);
/// Creates a Windows Unicode cmap for the retained Unicode scalar values.
public static byte[] CreateSubset(IReadOnlyList mappings);
public readonly record struct GlyphMapping(Rune Character, ushort GlyphId);
}
public sealed class KernTable
{
public readonly Dictionary<(ushort Left, ushort Right), short> Pairs;
public CMapTable CMap { get; }
public KernTable(ReadOnlySpan data, CMapTable cmap);
public short GetKerningAdjustment(ushort left, ushort right);
public TrueTypeFont.ValueRecord this[Rune left, Rune right] { get; }
/// Creates a horizontal format-0 kern table from the retained pairs.
public static byte[] CreateSubset(IEnumerable pairs);
public readonly record struct Pair(ushort Left, ushort Right, short Value);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using Xui.Core.Canvas;
public class Catalog
{
public Catalog(params IEnumerable[] sources);
/// Creates a catalog backed by descriptor-first, lazily loaded font resources.
public Catalog(IFontSource fontSource);
public virtual IEnumerable Fonts();
public virtual ReadOnlyMemory LoadFromUri(Uri uri);
///
/// Loads embedded font data from a URI in the format: embedded://Assembly.Name/Folder/File.ttf
///
/// The embedded URI, e.g. embedded://Xui.Core.Fonts/Inter/Inter-Bold.ttf
/// A byte array containing the font file contents.
/// Thrown when the resource or assembly cannot be found.
public static ReadOnlyMemory LoadEmbedded(Uri uri);
public IEnumerable AStar(FontFace font);
public TextMetrics MeasureText(in Core.Canvas.Font font, string text, TextAlign textAlign = TextAlign.Left, TextBaseline textBaseline = TextBaseline.Alphabetic);
public TrueTypeFont? FontForFace(in FontFace face);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Collections.Generic;
using System;
using Xui.Core.Canvas;
public readonly struct FontFace
{
///
/// A struct comparer for that avoids boxing and uses case-insensitive family comparison.
///
public static readonly IEqualityComparer Comparer;
public string Family { get; }
public FontWeight Weight { get; }
public FontStyle Style { get; }
public FontStretch Stretch { get; }
public FontFace(string family, FontWeight weight, FontStyle style, FontStretch stretch);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Collections.Generic;
using System.Text;
using System;
///
/// The characters and adjacent character pairs rendered with one font face.
///
///
/// This deliberately records source characters rather than only glyph IDs. A compact font needs
/// a cmap for the SVG text, while pairs allow the subsetter to retain the kerning actually used.
/// Complex OpenType shaping is outside the first subset format and will add richer usage records.
///
public sealed class FontUsage
{
public IReadOnlySet Characters { get; }
public IReadOnlySet Pairs { get; }
public void Add(string text);
public readonly record struct RunePair(Rune Left, Rune Right);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System;
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public abstract partial class ClassDefTable
{
public sealed class Format1 : ClassDefTable
{
public Format1(ReadOnlySpan span);
///
/// Returns the class ID for the given glyph ID.
/// If the glyph is not in the defined range, returns 0 (default class).
///
public override ushort this[ushort glyphId] { get; }
}
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public abstract partial class PairAdjustmentSubtable
{
///
/// Represents a GPOS LookupType 2 subtable: Pair Adjustment Format 2 (class-based kerning).
///
public sealed class Format2 : PairAdjustmentSubtable
{
public ushort ValueFormat1 { get; }
public ushort ValueFormat2 { get; }
public ClassDefTable ClassDef1 { get; }
public ClassDefTable ClassDef2 { get; }
public PairValueRecord[, ] Matrix { get; }
public CoverageTable Coverage { get; }
public ushort Class1Count { get; }
public ushort Class2Count { get; }
public Format2(ReadOnlySpan span);
public sealed record PairValueRecord(TrueTypeFont.ValueRecord Value1, TrueTypeFont.ValueRecord Value2);
public override TrueTypeFont.ValueRecordTuple this[ushort leftGlyph, ushort rightGlyph] { get; }
}
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public abstract partial class PairAdjustmentSubtable
{
public static PairAdjustmentSubtable Parse(ReadOnlySpan span);
public abstract TrueTypeFont.ValueRecordTuple this[ushort leftGlyph, ushort rightGlyph] { get; }
}
}
public class HeaderTable
{
public ushort FontRevisionMajor { get; }
public ushort FontRevisionMinor { get; }
public ushort UnitsPerEm { get; }
public DateTime Created { get; }
public DateTime Modified { get; }
public short XMin { get; }
public short YMin { get; }
public short XMax { get; }
public short YMax { get; }
public ushort MacStyle { get; }
public ushort LowestRecPPEM { get; }
public ushort IndexToLocFormat { get; }
public bool IsBold { get; }
public bool IsItalic { get; }
public bool IsUnderline { get; }
public bool IsOutline { get; }
public bool IsShadow { get; }
public bool IsCondensed { get; }
public bool IsExtended { get; }
public HeaderTable(ReadOnlySpan data);
/// Copies a head table configured for long loca offsets and a new checksum.
public static byte[] CreateSubset(ReadOnlySpan source);
}
public class HorizontalHeaderTable
{
public short Ascender { get; }
public short Descender { get; }
public short LineGap { get; }
public ushort AdvanceWidthMax { get; }
public short MinLeftSideBearing { get; }
public short MinRightSideBearing { get; }
public short XMaxExtent { get; }
public short CaretSlopeRise { get; }
public short CaretSlopeRun { get; }
public short CaretOffset { get; }
public short MetricDataFormat { get; }
public ushort NumberOfHMetrics { get; }
public HorizontalHeaderTable(ReadOnlySpan data);
/// Copies an hhea table for a compact hmtx table with one metric per glyph.
public static byte[] CreateSubset(ReadOnlySpan source, ushort numberOfHMetrics);
}
public class MaxProfileTable
{
public ushort NumGlyphs { get; }
public MaxProfileTable(ReadOnlySpan data);
/// Copies a maxp table with the compact glyph count.
public static byte[] CreateSubset(ReadOnlySpan source, ushort numGlyphs);
}
public class OS2Table
{
public ushort WeightClass { get; }
public ushort WidthClass { get; }
public short TypoAscender { get; }
public short TypoDescender { get; }
public short TypoLineGap { get; }
public OS2Table(ReadOnlySpan data);
}
public partial class TrueTypeFont
{
public record struct ValueRecord(short? XPlacement, short? YPlacement, short? XAdvance, short? YAdvance)
{
public static ValueRecord Parse(ReadOnlySpan span, ushort format, out int size);
}
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Collections.Generic;
using System;
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public abstract partial class ClassDefTable
{
public sealed class Format2 : ClassDefTable
{
public Format2(ReadOnlySpan span);
public override ushort this[ushort glyphId] { get; }
}
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public abstract partial class ClassDefTable
{
///
/// Parses a ClassDefTable (Format 1 or 2).
///
public static ClassDefTable Parse(ReadOnlySpan span);
public abstract ushort this[ushort glyphId] { get; }
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
///
/// Represents a GPOS Coverage Table used in subtables to identify glyphs affected.
///
///
/// Represents a GPOS Coverage Table used in subtables to identify glyphs affected.
///
public abstract partial class CoverageTable : IReadOnlyDictionary
{
public sealed class Format1 : CoverageTable
{
public Format1(ReadOnlySpan span);
public override int Count { get; }
public override IEnumerable Keys { get; }
public override IEnumerable Values { get; }
public override bool ContainsKey(ushort key);
public override bool TryGetValue(ushort key, out int value);
public override int this[ushort key] { get; }
public override IEnumerator> GetEnumerator();
}
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
///
/// Represents a GPOS Coverage Table used in subtables to identify glyphs affected.
///
///
/// Represents a GPOS Coverage Table used in subtables to identify glyphs affected.
///
public abstract partial class CoverageTable : IReadOnlyDictionary
{
public sealed class Format2 : CoverageTable
{
public Format2(ReadOnlySpan span);
public override int Count { get; }
public override IEnumerable Keys { get; }
public override IEnumerable Values { get; }
public override bool ContainsKey(ushort key);
public override bool TryGetValue(ushort key, out int value);
public override int this[ushort key] { get; }
public override IEnumerator> GetEnumerator();
}
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
///
/// Represents a GPOS Coverage Table used in subtables to identify glyphs affected.
///
///
/// Represents a GPOS Coverage Table used in subtables to identify glyphs affected.
///
public abstract partial class CoverageTable : IReadOnlyDictionary
{
public static CoverageTable Parse(ReadOnlySpan span);
public abstract int Count { get; }
public abstract IEnumerable Keys { get; }
public abstract IEnumerable Values { get; }
public abstract bool ContainsKey(ushort key);
public abstract bool TryGetValue(ushort key, out int value);
public abstract int this[ushort key] { get; }
public abstract IEnumerator> GetEnumerator();
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public abstract partial class PairAdjustmentSubtable
{
public class Format1 : PairAdjustmentSubtable
{
public ushort ValueFormat1 { get; }
public ushort ValueFormat2 { get; }
public List PairSets { get; }
public CoverageTable Coverage { get; }
public Format1(ReadOnlySpan span);
public sealed record PairSet(List Pairs);
public sealed record PairValueRecord(ushort SecondGlyphID, TrueTypeFont.ValueRecord Value1, TrueTypeFont.ValueRecord Value2);
public override TrueTypeFont.ValueRecordTuple this[ushort leftGlyph, ushort rightGlyph] { get; }
}
}
}
public class GlyfTable
{
public GlyfTable(ReadOnlyMemory data, LocaTable loca);
///
/// Returns a glyph shape by slicing the raw memory using loca table offsets.
///
public bool TryGetGlyph(int glyphIndex, out GlyphShape shape);
/// Adds every component needed by retained composite glyphs.
public void ExpandCompositeDependencies(SortedSet glyphs);
/// Creates compact glyf and long-format loca tables for retained glyphs.
public Subset CreateSubset(IReadOnlyList glyphs, IReadOnlyDictionary glyphMap);
public readonly record struct Subset(byte[] Glyf, byte[] Loca);
}
public class HorizontalMetricsTable
{
public HorizontalMetricsTable(ReadOnlySpan data, ushort numberOfHMetrics);
public HorizontalMetric GetMetric(int glyphIndex);
/// Creates a compact hmtx table with one full metric per retained glyph.
public byte[] CreateSubset(IEnumerable glyphIndices);
public record struct HorizontalMetric(ushort AdvanceWidth, short LeftSideBearing);
}
public class LocaTable
{
public LocaTable(ReadOnlySpan data, int numGlyphs, ushort indexToLocFormat);
public (int Offset, int Length) GetGlyphBounds(int glyphIndex);
/// Creates a long-format loca table from glyph offsets.
public static byte[] CreateLong(IReadOnlyList offsets);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System;
using static Xui.Runtime.Software.Font.GPosTable.LookupTable;
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public sealed class ExtensionPositioningSubtable
{
public GPosLookupType ExtensionLookupType { get; }
public PairAdjustmentSubtable? WrappedPairSubtable { get; }
public ExtensionPositioningSubtable(ReadOnlySpan span);
public TrueTypeFont.ValueRecordTuple this[ushort leftGlyph, ushort rightGlyph] { get; }
}
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Collections;
using System;
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public sealed class FeatureListTable : IReadOnlyDictionary
{
public FeatureListTable(ReadOnlySpan span);
public FeatureTable this[string key] { get; }
public IEnumerable Keys { get; }
public IEnumerable Values { get; }
public int Count { get; }
public bool ContainsKey(string key);
public bool TryGetValue(string key, out FeatureTable value);
public IEnumerator> GetEnumerator();
}
public sealed class FeatureTable
{
public List LookupIndices { get; }
public FeatureTable(ReadOnlySpan span);
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public sealed class LookupListTable : IReadOnlyList
{
public LookupListTable(ReadOnlySpan span);
public LookupTable this[int index] { get; }
public int Count { get; }
public IEnumerator GetEnumerator();
}
public sealed class LookupTable
{
public GPosLookupType LookupType { get; }
public ushort LookupFlag { get; }
public List SubTableOffsets { get; }
public List? PairAdjustmentSubtables { get; }
public List? ExtensionPositioningSubtables { get; }
public LookupTable(ReadOnlySpan span);
public TrueTypeFont.ValueRecordTuple this[ushort leftGlyph, ushort rightGlyph] { get; }
public enum GPosLookupType : ushort
{
SingleAdjustment = 1,
PairAdjustment = 2,
CursiveAttachment = 3,
MarkToBase = 4,
MarkToLigature = 5,
MarkToMark = 6,
ContextPositioning = 7,
ChainedContextPositioning = 8,
ExtensionPositioning = 9
}
}
}
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public sealed class ScriptListTable : IReadOnlyDictionary
{
public ScriptListTable(ReadOnlySpan span);
public ScriptTable this[string key] { get; }
public IEnumerable Keys { get; }
public IEnumerable Values { get; }
public int Count { get; }
public bool ContainsKey(string key);
public bool TryGetValue(string key, out ScriptTable value);
public IEnumerator> GetEnumerator();
}
public sealed class ScriptTable : IReadOnlyDictionary
{
public ScriptTable(ReadOnlySpan span);
public LangSysTable this[string key] { get; }
public IEnumerable Keys { get; }
public IEnumerable Values { get; }
public int Count { get; }
public bool ContainsKey(string key);
public bool TryGetValue(string key, out LangSysTable value);
public IEnumerator> GetEnumerator();
}
public sealed class LangSysTable
{
public ushort RequiredFeatureIndex { get; }
public List FeatureIndices { get; }
public LangSysTable(ReadOnlySpan span);
}
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Text;
using System;
///
/// Parses the 'GPOS' (Glyph Positioning) table from an OpenType font.
/// This table handles kerning, mark positioning, and other glyph adjustments.
///
public sealed partial class GPosTable
{
public ushort MajorVersion { get; }
public ushort MinorVersion { get; }
public ushort ScriptListOffset { get; }
public ushort FeatureListOffset { get; }
public ushort LookupListOffset { get; }
public uint? FeatureVariationsOffset { get; }
public ScriptListTable? ScriptList { get; }
public FeatureListTable? FeatureList { get; }
public LookupListTable? LookupList { get; }
public CMapTable CMap { get; }
public GPosTable(ReadOnlySpan span, CMapTable cMap);
///
/// Gets the kerning adjustment between two characters using GPOS LookupType 2 or ExtensionPositioning.
/// Returns a default ValueRecord if no adjustment is defined.
///
public TrueTypeFont.ValueRecord this[Rune left, Rune right] { get; }
}
}
namespace Xui.Runtime.Software.Font
{
public readonly record struct GlyphPosition(int GlyphId, float X, float Y);
public readonly record struct TableRecord(string Tag, uint Offset, uint Length, uint Checksum);
public partial class TrueTypeFont
{
public record struct ValueRecordTuple(ValueRecord Left, ValueRecord Right);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
///
/// A parsed TrueType glyph. This is a lightweight, stack-only view into raw glyph data.
///
public ref struct GlyphShape
{
///
/// Gets the unscaled bounding box of the glyph in font units.
///
public GlyphBound Bounds { get; }
public GlyphShape(ReadOnlySpan data);
public void Visit(IGlyphPathBuilder builder);
public struct GlyphBound
{
public short XMin;
public short YMin;
public short XMax;
public short YMax;
public GlyphBound(short xMin, short yMin, short xMax, short yMax);
}
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Text;
using System;
public partial class NameTable
{
/// Copyright notice (Name ID 0)
public string? Copyright { get; }
/// Font family name (Name ID 1)
public string? FamilyName { get; }
/// Font subfamily name (e.g. Regular, Bold) (Name ID 2)
public string? SubfamilyName { get; }
/// Unique font identifier (Name ID 3)
public string? UniqueIdentifier { get; }
/// Full font name (Name ID 4)
public string? FullName { get; }
/// Version string (Name ID 5)
public string? Version { get; }
/// PostScript name (Name ID 6)
public string? PostScriptName { get; }
/// Trademark notice (Name ID 7)
public string? Trademark { get; }
/// Manufacturer name (Name ID 8)
public string? Manufacturer { get; }
/// Designer name (Name ID 9)
public string? Designer { get; }
/// Description of the font (Name ID 10)
public string? Description { get; }
/// URL of the vendor (Name ID 11)
public string? VendorURL { get; }
/// URL of the designer (Name ID 12)
public string? DesignerURL { get; }
/// License description (Name ID 13)
public string? License { get; }
/// License info URL (Name ID 14)
public string? LicenseURL { get; }
/// Preferred family (Name ID 16) — used for name linking and fallback grouping
public string? PreferredFamily { get; }
/// Preferred subfamily (Name ID 17) — used with PreferredFamily
public string? PreferredSubfamily { get; }
public IReadOnlyList Names { get; }
public NameTable(ReadOnlySpan data);
public string? GetNameById(int id);
public record struct NameRecord(ushort NameID, string Value);
}
public class PostTable
{
public PostTable(ReadOnlySpan data);
public string? GetGlyphName(int glyphIndex);
/// Creates a post format-3 table, retaining metrics but dropping glyph names.
public static byte[] CreateSubset(ReadOnlySpan source);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
///
/// Lays out a string of text using a TrueType font.
/// Produces positioned glyphs and bounding metrics for rendering and measurement.
///
public class TextLayout
{
public IReadOnlyList Glyphs { get; }
///
/// The horizontal and vertical bounding metrics of the laid-out text.
///
public readonly LineMetrics LineMetrics;
public TextLayout(TrueTypeFont font, string text);
public TextLayout(TrueTypeFont font, string text, nfloat fontSize, TextAlign textAlign = TextAlign.Left, TextBaseline textBaseline = TextBaseline.Alphabetic);
///
/// Visits each glyph path, offset and scaled to its layout position.
///
public void Visit(IGlyphPathBuilder builder);
public readonly record struct GlyphPosition(int GlyphId, NFloat X, NFloat Y);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Text;
using System;
using Xui.Core.Canvas;
public partial class TrueTypeFont
{
public readonly ReadOnlyMemory Blob;
public readonly Uri? SourceUri;
public IReadOnlyDictionary Tables { get; }
public HeaderTable? Head { get; }
public MaxProfileTable? Maxp { get; }
public CMapTable? Cmap { get; }
public PostTable? Post { get; }
public LocaTable? Loca { get; }
public GlyfTable? Glyf { get; }
public OS2Table? OS2 { get; }
public NameTable? Name { get; }
public HorizontalHeaderTable? Hhea { get; }
public HorizontalMetricsTable? Hmtx { get; }
public KernTable? Kern { get; }
public GPosTable? GPos { get; }
public FontFace Face { get; }
public KerningQuery Kerning { get; }
public TrueTypeFont(ReadOnlyMemory blob, Uri? SourceUri = null);
public TextMetrics MeasureText(string text, Xui.Core.Canvas.Font font, TextAlign textAlign = TextAlign.Left, TextBaseline textBaseline = TextBaseline.Alphabetic);
/// Measures metrics which depend on the text's glyphs and shaping.
public LineMetrics MeasureLine(string text, Xui.Core.Canvas.Font font, TextAlign textAlign = TextAlign.Left, TextBaseline textBaseline = TextBaseline.Alphabetic);
public FontMetrics Metrics(Xui.Core.Canvas.Font font);
public bool TryGetGlyph(int glyphId, out GlyphShape shape);
public int? GetGlyphIndex(Rune rune);
public string? GetGlyphName(int glyphId);
public readonly record struct TableRecord(string Tag, uint Offset, uint Length, uint Checksum);
public readonly struct KerningQuery
{
public KerningQuery(TrueTypeFont font);
public ValueRecord this[Rune left, Rune right] { get; }
}
///
/// Extracts a from minimal parsed font tables.
///
/// The containing font naming information.
/// The containing weight and width data.
/// The used to determine italic style (via macStyle flags).
/// A constructed .
public static FontFace FontFace(HeaderTable? head, NameTable? name, OS2Table? os2);
public static FontFace FontFace(ReadOnlySpan fontData);
}
}
namespace Xui.Runtime.Software.Font
{
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Linq;
using System;
/// Builds a compact TrueType sfnt containing the rendered simple glyphs and kerning pairs.
public static class TrueTypeFontSubset
{
///
/// Creates a deterministic TrueType subset. The initial format supports BMP characters and
/// simple and composite glyf outlines; its callers must retain the original font for unsupported scripts.
///
public static ReadOnlyMemory Create(TrueTypeFont font, FontUsage usage);
}
}
namespace Xui.Runtime.Software.Raster
{
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System;
public unsafe sealed class RGBABitmap : IDisposable
{
public readonly int Width;
public readonly int Height;
public readonly int Stride;
public RGBA* Pixels { get; }
public Span Span { get; }
public Span> VectorSpan { get; }
public RGBABitmap(int width, int height);
public RGBA this[int x, int y] { get; set; }
public void Fill(RGBA value = 0);
public void FillRect(in Rect rect, RGBA value);
///
/// Initializes a rectangular region of the bitmap using SIMD, aligned outward to the nearest vector boundary.
/// This method may overdraw slightly beyond the specified rectangle for performance.
/// Suitable for fast clearing of bounds when rendering shapes or tiles.
///
/// The region to initialize.
/// The fill color (default is transparent black).
public void InitRect(in Rect rect, RGBA value = 0);
public void Dispose();
}
public unsafe sealed class StencilBitmap : IDisposable
{
public readonly int Width;
public readonly int Height;
public readonly int Stride;
public G16* Pixels { get; }
public Span Span { get; }
public StencilBitmap(int width, int height);
public G16 this[int x, int y] { get; set; }
public void Fill(G16 value = 0);
public void FillRect(in Rect rect, G16 value);
///
/// Initializes a rectangular region of the stencil buffer using SIMD, aligned outward to the nearest vector boundary.
/// This method may overdraw slightly beyond the specified rectangle for performance.
/// Suitable for fast clearing of bounds when preparing coverage masks.
///
/// The region to initialize.
/// The fill value (default is 0, meaning no coverage).
public void InitRect(in Rect rect, G16 value = 0);
public void Dispose();
}
}
namespace Xui.Runtime.Software.Raster
{
using System.Runtime.CompilerServices;
using System;
public struct Rect
{
public uint Left;
public uint Top;
public uint Right;
public uint Bottom;
public static readonly Rect Empty;
public bool IsEmpty { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void UnionWith(in Rect other);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void IntersectWith(in Rect other);
///
/// Returns a new rectangle expanded outward and aligned to a SIMD boundary.
/// This is used for conservative region initialization where vectorization is preferred.
///
/// The number of pixels per vector (e.g., Vector<T>.Count).
public static Rect AlignOutward(Rect rect, int simdWidth);
}
}
namespace Xui.Runtime.Software.Rasterization
{
using Xui.Core.Math2D;
public readonly struct Edge
{
public readonly nfloat X0, Y0;
public readonly nfloat X1, Y1;
public readonly nfloat DxDy;
public Edge(Point start, Point end);
}
}
namespace Xui.Runtime.Software.Rasterization
{
using System.Collections.Generic;
public sealed class EdgeList
{
public void Add(Edge edge);
public void Clear();
public void SortByY();
public IReadOnlyList Edges { get; }
}
}
namespace Xui.Runtime.Software.Rasterization
{
using System.Collections.Generic;
using System;
using Xui.Core.Canvas;
using Xui.Core.Curves2D;
using Xui.Core.Math2D;
public sealed class Rasterizer : IPathBuilder
{
public Rasterizer();
public void BeginPath();
public void MoveTo(Point to);
public void LineTo(Point to);
public void ClosePath();
public void CurveTo(Point cp1, Point to);
public void CurveTo(Point cp1, Point cp2, Point to);
public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
public void ArcTo(Point cp1, Point cp2, nfloat radius);
public void Ellipse(Point center, nfloat radiusX, nfloat radiusY, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
public void Rect(Rect rect);
public void RoundRect(Rect rect, nfloat radius);
public void RoundRect(Rect rect, CornerRadius radius);
public void Rasterize(G16Stencil stencil, FillRule rule);
}
}
namespace Xui.Runtime.Software.Tessellate
{
using System.Collections.Generic;
using Xui.Core.Math2D;
///
/// Represents a full tessellation pipeline result, including intermediate geometric representations.
/// Used for visual debugging, documentation, and rendering filled polygons from vector paths.
///
public partial class PathTesselator
{
///
/// Represents a closed contour — a sequence of connected points forming a polygon loop.
///
public readonly struct ClosedContour
{
///
/// Ordered list of points forming the closed contour path.
///
public readonly IReadOnlyList Points;
///
/// Initializes a new closed contour from a sequence of points.
///
public ClosedContour(IReadOnlyList points);
///
/// Returns the number of points in this contour.
///
public int Count { get; }
///
/// Indexer access to individual points.
///
public Point this[int index] { get; }
public enum WindingDirection
{
Clockwise,
CounterClockwise
}
public WindingDirection Winding { get; }
public Rect Bounds { get; }
public nfloat SignedArea { get; }
}
}
}
namespace Xui.Runtime.Software.Tessellate
{
using System.Collections.Generic;
using Xui.Core.Canvas;
using Xui.Core.Curves2D;
using Xui.Core.Math2D;
///
/// Represents a full tessellation pipeline result, including intermediate geometric representations.
/// Used for visual debugging, documentation, and rendering filled polygons from vector paths.
///
public partial class PathTesselator
{
public class Contouring : IPathBuilder
{
public IReadOnlyList Contours { get; }
public Contouring();
public Contouring(nfloat precision);
public List Result { get; }
public static IReadOnlyList ContourPath(Path2D path, nfloat precision);
public void BeginPath();
public void MoveTo(Point to);
public void LineTo(Point to);
public void CurveTo(Point cp1, Point cp2, Point to);
public void CurveTo(Point control, Point to);
public void Arc(Point center, nfloat radius, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
public void Ellipse(Point center, nfloat rx, nfloat ry, nfloat rotation, nfloat startAngle, nfloat endAngle, Winding winding = Winding.ClockWise);
public void ArcTo(Point cp1, Point cp2, nfloat radius);
public void Rect(Rect rect);
public void RoundRect(Rect rect, nfloat radius);
public void RoundRect(Rect rect, CornerRadius radius);
public void ClosePath();
}
}
}
namespace Xui.Runtime.Software.Tessellate
{
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
///
/// Represents a full tessellation pipeline result, including intermediate geometric representations.
/// Used for visual debugging, documentation, and rendering filled polygons from vector paths.
///
public partial class PathTesselator
{
public partial class ScanlineSweep
{
public static List Fill(IReadOnlyList contours, FillRule fillRule);
public static void SweepAndEmitTrapezoids(IReadOnlyList contours, FillRule fillRule, List outputTriangles);
///
/// Extracts all closed, non-intersecting loops from a set of directed edges.
/// Each loop is returned as a ClosedContour.
///
public static List ExtractLoops(List edges);
public readonly struct Edge
{
public readonly Point Start;
public readonly Point End;
public readonly nfloat XAtYMin;
public readonly nfloat SlopeInv;
public readonly nfloat YMin;
public readonly nfloat YMax;
public readonly int Winding;
public Edge(Point a, Point b);
public nfloat XAt(nfloat y);
}
}
}
}
namespace Xui.Runtime.Software.Tessellate
{
using System.Collections.Generic;
using Xui.Core.Canvas;
///
/// Represents a full tessellation pipeline result, including intermediate geometric representations.
/// Used for visual debugging, documentation, and rendering filled polygons from vector paths.
///
public partial class PathTesselator
{
public PathTesselator(IReadOnlyList contours, List polygons);
///
/// Gets the list of closed contours reconstructed from the segments.
/// Each contour represents a loop used in fill evaluation.
///
public IReadOnlyList Contours { get; }
///
/// Gets the final list of filled triangle polygons that represent the tessellated shape.
///
public List Polygons { get; }
///
/// Performs full tessellation of a vector path into filled triangle polygons using a specified fill rule.
/// Intermediate data including segments, contours, and trapezoids is retained for debugging or visualization.
///
/// The vector path to tessellate.
/// The fill rule (EvenOdd or NonZero) to apply during sweep.
/// The curve flattening tolerance. Smaller values yield more segments.
/// A instance containing all stages of the tessellation pipeline.
public static PathTesselator Fill(Path2D path, FillRule fillRule, nfloat flatness);
public static PathTesselator Fill(Path2D path, FillRule fillRule);
}
}
namespace Xui.Runtime.Software.Tessellate
{
using System.Collections.Generic;
using System.Collections;
using Xui.Core.Math2D;
///
/// Represents a triangle polygon used during path tessellation.
///
public readonly struct Polygon : IEnumerable
{
public readonly Point A;
public readonly Point B;
public readonly Point C;
public Polygon(Point a, Point b, Point c);
public IEnumerator GetEnumerator();
}
public readonly struct Trapezoid : IEnumerable
{
public readonly Point A;
public readonly Point B;
public readonly Point C;
public readonly Point D;
public Trapezoid(Point a, Point b, Point c, Point d);
public Polygon Polygon1 { get; }
public Polygon Polygon2 { get; }
public IEnumerator GetEnumerator();
}
}