diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index eb5d0448..fb1c8f1d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -64,26 +64,26 @@ jobs: - ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }} options: - os: ubuntu-latest - framework: net9.0 - sdk: 9.0.x + framework: net10.0 + sdk: 10.0.x sdk-preview: true runtime: -x64 codecov: false - os: macos-latest - framework: net9.0 - sdk: 9.0.x + framework: net10.0 + sdk: 10.0.x sdk-preview: true runtime: -x64 codecov: false - os: windows-latest - framework: net9.0 - sdk: 9.0.x + framework: net10.0 + sdk: 10.0.x sdk-preview: true runtime: -x64 codecov: false - os: buildjet-4vcpu-ubuntu-2204-arm - framework: net9.0 - sdk: 9.0.x + framework: net10.0 + sdk: 10.0.x sdk-preview: true runtime: -x64 codecov: false @@ -161,7 +161,7 @@ jobs: uses: actions/setup-dotnet@v5 with: dotnet-version: | - 9.0.x + 10.0.x - name: DotNet Build if: ${{ matrix.options.sdk-preview != true }} diff --git a/README.md b/README.md index ba0b629e..512e798d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ SixLabors.Fonts **SixLabors.Fonts** is a cross-platform library for loading, measuring, and laying out fonts and text. It supports TrueType and OpenType fonts (including CFF1 and CFF2 outlines), WOFF/WOFF2 web fonts, variable fonts, color fonts (COLR v0/v1 and SVG), and TrueType hinting. The library provides a full OpenType layout engine with GSUB/GPOS support, advanced text shaping for complex scripts, and bidirectional text rendering. +Fonts also exposes high-level text layout primitives for applications that need more than a single bounding box. Callers can measure advance, ink bounds, renderable bounds, lines, words, graphemes, and glyphs; reuse prepared text across multiple wrapping widths; inspect the resolved font used to shape and render fallback glyphs; and use built-in hit testing, caret placement, and selection geometry. + ## License - Fonts is licensed under the [Six Labors Split License, Version 1.0](https://github.com/SixLabors/Fonts/blob/main/LICENSE) @@ -106,6 +108,11 @@ git lfs pull - Support for ligatures and kerning. - Support for rendering left to right, right to left, and bidirectional text. - Support for line breaking based on [UAX 14](https://www.unicode.org/reports/tr14/). +- Support for reusable prepared text layout via `TextBlock`. +- Text measurement APIs for advance bounds, ink bounds, renderable bounds, line metrics, word metrics, grapheme metrics, and glyph metrics. +- Glyph and grapheme metrics expose the resolved font used to shape and render each entry, including fallback fonts. +- Text interaction helpers for hit testing, caret positioning, caret movement, and selection bounds. +- Support for wrapping, trimming, ellipsis, hyphenation, tab width, tracking, line height, and horizontal and vertical layout modes. ## API Examples diff --git a/shared-infrastructure b/shared-infrastructure index bed6f53b..7ac57034 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit bed6f53bea0239e4afa19e81c24a6fff421707e1 +Subproject commit 7ac5703452348d9295db31fc0912c2bd9e419dc9 diff --git a/src/SixLabors.Fonts/SixLabors.Fonts.csproj b/src/SixLabors.Fonts/SixLabors.Fonts.csproj index b9dca3b3..c71e6b25 100644 --- a/src/SixLabors.Fonts/SixLabors.Fonts.csproj +++ b/src/SixLabors.Fonts/SixLabors.Fonts.csproj @@ -1,4 +1,4 @@ - + SixLabors.Fonts @@ -32,7 +32,7 @@ - net8.0;net9.0 + net8.0;net10.0 true diff --git a/src/UnicodeTrieGenerator/Generator.UniversalShapingEngine.cs b/src/UnicodeTrieGenerator/Generator.UniversalShapingEngine.cs index 72cb1da2..a3fc8588 100644 --- a/src/UnicodeTrieGenerator/Generator.UniversalShapingEngine.cs +++ b/src/UnicodeTrieGenerator/Generator.UniversalShapingEngine.cs @@ -317,7 +317,7 @@ public static partial class Generator { 0x1cf9, IPC.Top } }; - private static bool Check(dynamic pattern, dynamic value) + private static bool Check(object pattern, object? value) { // TODO:This is nasty. Port to use the harfbuzz approach using Function if (pattern is Dictionary dictionary && dictionary.TryGetValue("not", out object? not)) @@ -326,12 +326,7 @@ private static bool Check(dynamic pattern, dynamic value) { foreach (object item in list) { - if (value is int i && item is int i2 && i == i2) - { - return false; - } - - if (value is GC gc && item is GC gc2 && gc == gc2) + if (object.Equals(value, item)) { return false; } @@ -341,35 +336,28 @@ private static bool Check(dynamic pattern, dynamic value) } else { - if (value is int i && not is int i2) - { - return i != i2; - } - - if (value is GC gc && not is GC gc2) - { - return gc != gc2; - } + return !object.Equals(value, not); } } - return value == pattern; + return object.Equals(value, pattern); } - private static bool Matches(dynamic pattern, Codepoint code) + private static bool Matches(object pattern, Codepoint code) { if (pattern is int i) { - pattern = new Dictionary { { "U", i } }; + pattern = new Dictionary { { "U", i } }; } else if (pattern is ISC isc) { - pattern = new Dictionary { { "UISC", isc } }; + pattern = new Dictionary { { "UISC", isc } }; } - foreach (string? key in pattern.Keys) + Dictionary dictionary = (Dictionary)pattern; + foreach (string key in dictionary.Keys) { - if (!Check(pattern[key], GetCodeValue(code, key))) + if (!Check(dictionary[key], GetCodeValue(code, key))) { return false; } diff --git a/src/UnicodeTrieGenerator/Program.cs b/src/UnicodeTrieGenerator/Program.cs index dba98bfd..0589ba02 100644 --- a/src/UnicodeTrieGenerator/Program.cs +++ b/src/UnicodeTrieGenerator/Program.cs @@ -1,15 +1,9 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -namespace UnicodeTrieGenerator; +using UnicodeTrieGenerator; -internal static class Program -{ - private static void Main() - { - Console.WriteLine("Generating Trie Data"); - Generator.GenerateUnicodeTries(); - Console.WriteLine("Done"); - Console.ReadLine(); - } -} +Console.WriteLine("Generating Trie Data"); +Generator.GenerateUnicodeTries(); +Console.WriteLine("Done"); +Console.ReadLine(); diff --git a/src/UnicodeTrieGenerator/UnicodeTrieGenerator.csproj b/src/UnicodeTrieGenerator/UnicodeTrieGenerator.csproj index 7968581c..aa356ad1 100644 --- a/src/UnicodeTrieGenerator/UnicodeTrieGenerator.csproj +++ b/src/UnicodeTrieGenerator/UnicodeTrieGenerator.csproj @@ -10,7 +10,7 @@ - net8.0;net9.0 + net8.0;net10.0 diff --git a/tests/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks.csproj b/tests/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks.csproj index 5300318f..139adf4d 100644 --- a/tests/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks.csproj +++ b/tests/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks/SixLabors.Fonts.Benchmarks.csproj @@ -19,7 +19,7 @@ - net8.0;net9.0 + net8.0;net10.0 diff --git a/tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj b/tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj index e239a798..d9d7b950 100644 --- a/tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj +++ b/tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj @@ -1,4 +1,4 @@ - + True @@ -13,7 +13,7 @@ - net8.0;net9.0 + net8.0;net10.0