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

Platform-independent way to build path for fonts into the sample. Now… #371

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
24 changes: 12 additions & 12 deletions samples/DrawWithImageSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
{
var fonts = new FontCollection();
var woffFonts = new FontCollection();
FontFamily font = fonts.Add(@"Fonts\SixLaborsSampleAB.ttf");
FontFamily fontWoff = woffFonts.Add(@"Fonts\SixLaborsSampleAB.woff");
FontFamily fontWoff2 = woffFonts.Add(@"Fonts\OpenSans-Regular.woff2");
FontFamily carter = fonts.Add(@"Fonts\CarterOne.ttf");
FontFamily wendyOne = fonts.Add(@"Fonts\WendyOne-Regular.ttf");
FontFamily whitneyBook = fonts.Add(@"Fonts\whitney-book.ttf");
FontFamily colorEmoji = fonts.Add(@"Fonts\Twemoji Mozilla.ttf");
FontFamily font2 = fonts.Add(@"Fonts\OpenSans-Regular.ttf");
FontFamily sunflower = fonts.Add(@"Fonts\Sunflower-Medium.ttf");
FontFamily bugzilla = fonts.Add(@"Fonts\me_quran_volt_newmet.ttf");

FontFamily notoKR = fonts.Add(@"Fonts\NotoSansKR-Regular.otf");
FontFamily font = fonts.Add(IOPath.Combine("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, 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)
FontFamily fontWoff = woffFonts.Add(IOPath.Combine("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, 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)
FontFamily fontWoff2 = woffFonts.Add(IOPath.Combine("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, 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)
FontFamily carter = fonts.Add(IOPath.Combine("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, 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)
FontFamily wendyOne = fonts.Add(IOPath.Combine("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(IOPath.Combine("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, 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)
FontFamily colorEmoji = fonts.Add(IOPath.Combine("Fonts", "Twemoji Mozilla.ttf"));

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)
FontFamily font2 = fonts.Add(IOPath.Combine("Fonts", "OpenSans-Regular.ttf"));
FontFamily sunflower = fonts.Add(IOPath.Combine("Fonts", "Sunflower-Medium.ttf"));
FontFamily bugzilla = fonts.Add(IOPath.Combine("Fonts", "me_quran_volt_newmet.ttf"));

FontFamily notoKR = fonts.Add(IOPath.Combine("Fonts", "NotoSansKR-Regular.otf"));

RenderText(notoKR, "\uD734", pointSize: 72);
RenderText(notoKR, "Sphinx of black quartz, judge my vow!", pointSize: 72);
Expand All @@ -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, net7.0, 7.0.x, true, -x64, false)

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, net6.0, 6.0.x, -x64, true)

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 @@ -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, ubuntu-latest, net6.0, 6.0.x, -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,

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,

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,
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, ubuntu-latest, net6.0, 6.0.x, -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,

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,

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,

string fullPath = CreatePath(font.Name, text + "-" + h + "-" + v + ".png");
Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath));
Expand Down
Loading