Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for invalid ClassDefinitionTable offset handling #360

Merged
merged 3 commits into from
Sep 25, 2023
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
2 changes: 1 addition & 1 deletion samples/DrawWithImageSharp/DrawWithImageSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta15.14" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion samples/DrawWithImageSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
{
var fonts = new FontCollection();
var woffFonts = new FontCollection();
FontFamily font = fonts.Add(@"Fonts\SixLaborsSampleAB.ttf");

Check warning on line 24 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 24 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily fontWoff = woffFonts.Add(@"Fonts\SixLaborsSampleAB.woff");

Check warning on line 25 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 25 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 25 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 25 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 25 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 25 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily fontWoff2 = woffFonts.Add(@"Fonts\OpenSans-Regular.woff2");

Check warning on line 26 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 26 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 26 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 26 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 26 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 26 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily carter = fonts.Add(@"Fonts\CarterOne.ttf");

Check warning on line 27 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 27 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 27 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 27 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 27 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 27 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily wendyOne = fonts.Add(@"Fonts\WendyOne-Regular.ttf");

Check warning on line 28 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 28 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 28 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 28 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 28 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily whitneyBook = fonts.Add(@"Fonts\whitney-book.ttf");

Check warning on line 29 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 29 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 29 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 29 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 29 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily colorEmoji = fonts.Add(@"Fonts\Twemoji Mozilla.ttf");

Check warning on line 30 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 30 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 30 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 30 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily font2 = fonts.Add(@"Fonts\OpenSans-Regular.ttf");

Check warning on line 31 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 31 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 31 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 31 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, macos-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily sunflower = fonts.Add(@"Fonts\Sunflower-Medium.ttf");

Check warning on line 32 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net7.0, 7.0.x, true, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)

Check warning on line 32 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

GitHub Actions / Build (false, ubuntu-latest, net6.0, 6.0.x, -x64, false)

The behavior of 'FontCollection.Add(string)' could vary based on the current user's locale settings. Replace this call in 'Program.Main(string[])' with a call to 'FontCollection.Add(string, CultureInfo)'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1304)
FontFamily bugzilla = fonts.Add(@"Fonts\me_quran_volt_newmet.ttf");

FontFamily notoKR = fonts.Add(@"Fonts\NotoSansKR-Regular.otf");
Expand Down Expand Up @@ -58,7 +58,7 @@
RenderText(SystemFonts.Get("Arial"), "abcdef ghijk lmnopq rstuvwxyz", pointSize: 30);
return;

var textRuns = new List<RichTextRun>

Check warning on line 61 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

Unreachable code detected

Check warning on line 61 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

Unreachable code detected
{
new RichTextRun { Start = 4, End = 10, Font = uiFont.CreateFont(72, FontStyle.Bold), TextAttributes = TextAttributes.Superscript, TextDecorations = TextDecorations.Underline | TextDecorations.Strikeout | TextDecorations.Overline },
new RichTextRun { Start = 26, End = 30, Font = uiFont.CreateFont(72, FontStyle.Italic), TextAttributes = TextAttributes.Subscript, TextDecorations = TextDecorations.Strikeout | TextDecorations.Underline | TextDecorations.Overline }
Expand Down Expand Up @@ -289,7 +289,7 @@

FontRectangle textSize = TextMeasurer.MeasureSize(text, textOptions);
using var img = new Image<Rgba32>(((int)textSize.Width * 2) + 20, ((int)textSize.Height * 2) + 20);
Size size = img.Size();
Size size = img.Size;
textOptions.Origin = new PointF(size.Width / 2F, size.Height / 2F);

img.Mutate(x => x.Fill(Color.Black).ApplyProcessor(
Expand All @@ -302,8 +302,8 @@

img[size.Width / 2, size.Height / 2] = Color.White;

string h = ha.ToString().Replace(nameof(HorizontalAlignment), string.Empty).ToLower();

Check warning on line 305 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Program.RenderTextProcessorWithAlignment(FontFamily, string,

Check warning on line 305 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

Specify a culture or use an invariant version to avoid implicit dependency on current culture (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1311)

Check warning on line 305 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Program.RenderTextProcessorWithAlignment(FontFamily, string,
string v = va.ToString().Replace(nameof(VerticalAlignment), string.Empty).ToLower();

Check warning on line 306 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Program.RenderTextProcessorWithAlignment(FontFamily, string,

Check warning on line 306 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

Specify a culture or use an invariant version to avoid implicit dependency on current culture (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1311)

Check warning on line 306 in samples/DrawWithImageSharp/Program.cs

View workflow job for this annotation

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

The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Program.RenderTextProcessorWithAlignment(FontFamily, string,

string fullPath = CreatePath(font.Name, text + "-" + h + "-" + v + ".png");
Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static AttachmentListTable Load(BigEndianBinaryReader reader, long offset
Span<ushort> attachPointOffsets = attachPointOffsetsBuffer.GetSpan();
reader.ReadUInt16Array(attachPointOffsets);

var attachmentListTable = new AttachmentListTable
AttachmentListTable attachmentListTable = new()
{
CoverageTable = CoverageTable.Load(reader, offset + coverageOffset),
AttachPoints = new AttachPoint[glyphCount]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using System.Diagnostics.CodeAnalysis;

namespace SixLabors.Fonts.Tables.AdvancedTypographic;

/// <summary>
Expand All @@ -20,6 +22,26 @@ internal abstract class ClassDefinitionTable
/// <returns>The class id.</returns>
public abstract int ClassIndexOf(ushort glyphId);

public static bool TryLoad(BigEndianBinaryReader reader, long offset, [NotNullWhen(true)] out ClassDefinitionTable? table)
{
if (offset == 0)
{
table = null;
return false;
}

reader.Seek(offset, SeekOrigin.Begin);
ushort classFormat = reader.ReadUInt16();
table = classFormat switch
{
1 => ClassDefinitionFormat1Table.Load(reader),
2 => ClassDefinitionFormat2Table.Load(reader),
_ => null
};

return table is not null;
}

public static ClassDefinitionTable Load(BigEndianBinaryReader reader, long offset)
{
reader.Seek(offset, SeekOrigin.Begin);
Expand Down Expand Up @@ -97,7 +119,7 @@ public static ClassDefinitionFormat2Table Load(BigEndianBinaryReader reader)
// | | | startGlyphID |
// +------------------+------------------------------------+-----------------------------------------+
ushort classRangeCount = reader.ReadUInt16();
var records = new ClassRangeRecord[classRangeCount];
ClassRangeRecord[] records = new ClassRangeRecord[classRangeCount];
for (int i = 0; i < records.Length; ++i)
{
// +--------+--------------+------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,20 @@ public static GlyphDefinitionTable Load(BigEndianBinaryReader reader)
throw new InvalidFontFileException($"Invalid value for 'minor version' {minorVersion} of GDEF table. Should be '0', '2' or '3'.");
}

ClassDefinitionTable? classDefinitionTable = glyphClassDefOffset is 0 ? null : ClassDefinitionTable.Load(reader, glyphClassDefOffset);
ClassDefinitionTable.TryLoad(reader, glyphClassDefOffset, out ClassDefinitionTable? classDefinitionTable);
AttachmentListTable? attachmentListTable = attachListOffset is 0 ? null : AttachmentListTable.Load(reader, attachListOffset);
LigatureCaretList? ligatureCaretList = ligatureCaretListOffset is 0 ? null : LigatureCaretList.Load(reader, ligatureCaretListOffset);
ClassDefinitionTable? markAttachmentClassDef = markAttachClassDefOffset is 0 ? null : ClassDefinitionTable.Load(reader, markAttachClassDefOffset);
ClassDefinitionTable.TryLoad(reader, markAttachClassDefOffset, out ClassDefinitionTable? markAttachmentClassDef);
MarkGlyphSetsTable? markGlyphSetsTable = markGlyphSetsDefOffset is 0 ? null : MarkGlyphSetsTable.Load(reader, markGlyphSetsDefOffset);

var glyphDefinitionTable = new GlyphDefinitionTable()
// TODO: read itemVarStore.
return new GlyphDefinitionTable()
{
GlyphClassDefinition = classDefinitionTable,
AttachmentListTable = attachmentListTable,
LigatureCaretList = ligatureCaretList,
MarkAttachmentClassDef = markAttachmentClassDef,
MarkGlyphSetsTable = markGlyphSetsTable
};

// TODO: read itemVarStore.
return glyphDefinitionTable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static MarkGlyphSetsTable Load(BigEndianBinaryReader reader, long offset)
{
reader.Seek(offset, SeekOrigin.Begin);

var markGlyphSetsTable = new MarkGlyphSetsTable
MarkGlyphSetsTable markGlyphSetsTable = new()
{
Format = reader.ReadUInt16()
};
Expand Down
12 changes: 12 additions & 0 deletions tests/SixLabors.Fonts.Tests/FontLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,16 @@ public void LoadFontWoff()
// the test font only has characters .notdef, 'a' & 'b' defined
Assert.Equal(6, r.ControlPoints.Distinct().Count());
}

[Fact]
public void LoadFontWithIncorrectClassDefinitionTableOffset()
{
// The following font contains a ClassDefinitionTable with an invalid offset.
// See https://forum.stimulsoft.com/viewtopic.php?t=60972
Font font = new FontCollection().Add(TestFonts.THSarabunFile).CreateFont(12);

FontRectangle advance = TextMeasurer.MeasureAdvance("เราใช้คุกกี้เพื่อพัฒนาประสิทธิภาพ และประสบการณ์ที่ดีในการใช้เว็บไซต์ของคุณ คุณสามารถศึกษารายละเอียดได้ที่", new(font));

Assert.NotEqual(default, advance);
}
}
Binary file added tests/SixLabors.Fonts.Tests/Fonts/THSarabun.ttf
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/SixLabors.Fonts.Tests/TestFonts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@

public static string DFKaiSBFile => GetFullPath("kaiu.ttf");

public static string THSarabunFile => GetFullPath("THSarabun.ttf");

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

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

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

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

View workflow job for this annotation

GitHub Actions / Build (false, windows-latest, net6.0, 6.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