Skip to content

Commit bf90c9c

Browse files
committed
WIP
1 parent 9eb9169 commit bf90c9c

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Build
33
on:
44
push:
55
branches:
6-
- main
7-
- ci
6+
- *
87
jobs:
98
# Prime a single LFS cache and expose the exact key for the matrix
109
WarmLFS:
@@ -247,7 +246,7 @@ jobs:
247246
run: |
248247
$date = Get-Date -Format "yyyy.MM.dd"
249248
$buildNumber = "${{ github.run_number }}"
250-
$version = "$date-mc.$buildNumber"
249+
$version = if ($env:GITHUB_REF -eq 'refs/heads/main') { "$date-mc.$buildNumber" } else { $branchName = $env:GITHUB_REF -replace 'refs/heads/', ''; "$date-$branchName.$buildNumber" }
251250
echo "version=$version" >> $env:GITHUB_OUTPUT
252251
echo "Computed version: $version"
253252

src/SixLabors.Fonts/TextLayout.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,8 @@ VerticalOrientationType.Rotate or
10371037
glyphAdvance = glyph.AdvanceHeight;
10381038
}
10391039

1040+
glyphAdvance += options.Tracking * glyph.FontMetrics.UnitsPerEm;
1041+
10401042
decomposedAdvances[0] = glyphAdvance;
10411043

10421044
if (CodePoint.IsTabulation(codePoint))

src/SixLabors.Fonts/TextOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ public float LineSpacing
170170
/// </summary>
171171
public KerningMode KerningMode { get; set; }
172172

173+
/// <summary>
174+
/// Gets or sets the tracking value for uniform letter-spacing adjustment.
175+
/// Tracking adjusts the spacing between all characters uniformly and is measured in em.
176+
/// Positive values increase spacing, negative values decrease spacing, and zero applies no adjustment.
177+
/// </summary>
178+
public float Tracking { get; set; }
179+
173180
/// <summary>
174181
/// Gets or sets the positioning mode used for rendering decorations.
175182
/// </summary>

tests/SixLabors.Fonts.Tests/TextLayoutTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Six Labors Split License.
33

44
using System.Globalization;
5+
using System.Net.Mime;
56
using System.Numerics;
67
using SixLabors.Fonts.Rendering;
78
using SixLabors.Fonts.Tests.Fakes;
@@ -968,6 +969,24 @@ public void TrueTypeHinting_CanHintSmallOpenSans(char c, FontRectangle expected)
968969
Assert.Equal(expected, actual, Comparer);
969970
}
970971

972+
/*
973+
[Theory]
974+
[InlineData("aaaa", 0, 20.952148)]
975+
[InlineData("aaaa", 1, 35.600586)]
976+
[InlineData("awwa", 1, 35.600586)]
977+
[InlineData("aaaa", 0.1, 22.416994)]
978+
public void FontTracking_SpaceCharacters(string text, float tracking, float width)
979+
{
980+
TextOptions options = new(OpenSansTTFLarge)
981+
{
982+
Tracking = tracking,
983+
};
984+
985+
FontRectangle actual = TextMeasurer.MeasureSize(text, options);
986+
Assert.Equal(new FontRectangle(0, 0, width, 5.5371094f), actual, Comparer);
987+
}
988+
*/
989+
971990
[Fact]
972991
public void CanMeasureTextAdvance()
973992
{
@@ -1299,6 +1318,7 @@ public void EndLayer()
12991318
}
13001319

13011320
private static readonly Font OpenSansTTF = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(10);
1321+
private static readonly Font OpenSansTTFLarge = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(64);
13021322
private static readonly Font OpenSansWoff = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(10);
13031323

13041324
#if OS_WINDOWS

0 commit comments

Comments
 (0)