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
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public static GlyphDefinitionTable Load(BigEndianBinaryReader reader)

ushort glyphClassDefOffset = reader.ReadUInt16();
ushort attachListOffset = reader.ReadUInt16();
ushort ligatureCaretListOffset = reader.ReadUInt16();
ushort markAttachClassDefOffset = reader.ReadUInt16();
ushort ligatureCaretListOffset = reader.ReadOffset16();
ushort markAttachClassDefOffset = reader.ReadOffset16();
ushort markGlyphSetsDefOffset = 0;
uint itemVarStoreOffset = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ public static LigatureCaretList Load(BigEndianBinaryReader reader, long offset)
// ----------|--------------------------------|--------------------------------------------------------------------------------------------------------
reader.Seek(offset, SeekOrigin.Begin);

ushort coverageOffset = reader.ReadUInt16();
ushort coverageOffset = reader.ReadOffset16();
ushort ligGlyphCount = reader.ReadUInt16();

using Buffer<ushort> ligGlyphOffsetsBuffer = new(ligGlyphCount);
Span<ushort> ligGlyphOffsets = ligGlyphOffsetsBuffer.GetSpan();
reader.ReadUInt16Array(ligGlyphOffsets);

var ligatureCaretList = new LigatureCaretList()
LigatureCaretList ligatureCaretList = new()
{
CoverageTable = CoverageTable.Load(reader, offset + coverageOffset)
CoverageTable = CoverageTable.Load(reader, offset + coverageOffset),
LigatureGlyphs = new LigatureGlyph[ligGlyphCount]
};

ligatureCaretList.LigatureGlyphs = new LigatureGlyph[ligGlyphCount];
for (int i = 0; i < ligatureCaretList.LigatureGlyphs.Length; i++)
{
ligatureCaretList.LigatureGlyphs[i] = LigatureGlyph.Load(reader, ligGlyphOffsets[i]);
ligatureCaretList.LigatureGlyphs[i] = LigatureGlyph.Load(reader, offset + ligGlyphOffsets[i]);
}

return ligatureCaretList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ public static LigatureGlyph Load(BigEndianBinaryReader reader, long offset)
reader.Seek(offset, SeekOrigin.Begin);

ushort caretCount = reader.ReadUInt16();
var ligatureGlyph = new LigatureGlyph()
return new LigatureGlyph()
{
CaretValueOffsets = reader.ReadUInt16Array(caretCount)
};

return ligatureGlyph;
}
}
3 changes: 3 additions & 0 deletions tests/Images/ReferenceOutput/Test_Issue_474-.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
30 changes: 30 additions & 0 deletions tests/SixLabors.Fonts.Tests/Issues/Issues_474.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using System.Text;

namespace SixLabors.Fonts.Tests.Issues;

public class Issues_474
{
[Fact]
public void Test_Issue_474()
{
StringBuilder stringBuilder = new();
stringBuilder.AppendLine("Latin: The quick brown fox jumps over the lazy dog.");
string text = stringBuilder.ToString();

FontCollection fontCollection = new();
string serviceNow = fontCollection.Add(TestFonts.ServiceNowWoff2).Name;

FontFamily mainFontFamily = fontCollection.Get(serviceNow);
Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular);

// There are too many metrics to validate here so we just ensure no exceptions are thrown
// and the rendering looks correct by inspecting the snapshot.
TextLayoutTestUtilities.TestLayout(
text,
new TextOptions(mainFont),
includeGeometry: false);
}
}
2 changes: 2 additions & 0 deletions tests/SixLabors.Fonts.Tests/TestFonts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@

public static string SofiaSansCondensedLight => GetFullPath("SofiaSansCondensed-ExtraLight-Regular.ttf");

public static string ServiceNowWoff2 => GetFullPath("ServiceNow-Sans-Text-Bold-unmastered-1.1.woff");

public static Stream TwemojiMozillaData() => OpenStream(TwemojiMozillaFile);

public static Stream SegoeuiEmojiData() => OpenStream(SegoeuiEmojiFile);
Expand Down Expand Up @@ -342,7 +344,7 @@

public static string GetFullPath(string path)
{
string root = Path.GetDirectoryName(new Uri(typeof(TestFonts).GetTypeInfo().Assembly.CodeBase).LocalPath);

Check warning on line 347 in tests/SixLabors.Fonts.Tests/TestFonts.cs

View workflow job for this annotation

GitHub Actions / Build (false, windows-latest, net8.0, 8.0.x, -x64, true)

'Assembly.CodeBase' is obsolete: 'Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.' (https://aka.ms/dotnet-warnings/SYSLIB0012)

string[] paths = new[]
{
Expand Down
Loading