Harden CI-sensitive recording and taskbar tests
PR and Push Build/Test / build-and-test (push) Failing after 9m57s

This commit is contained in:
2026-06-05 11:15:46 +02:00
parent 1a89382f02
commit ed2eb36d07
2 changed files with 65 additions and 5 deletions
@@ -52,10 +52,11 @@ internal static class TaskbarIconRenderer
{
using var path = new GraphicsPath();
using var format = StringFormat.GenericTypographic;
using var fontFamily = CreateGlyphFontFamily(out var fontStyle);
path.AddString(
text,
FontFamily.GenericSansSerif,
(int)FontStyle.Bold,
fontFamily,
(int)fontStyle,
9,
Point.Empty,
format);
@@ -69,6 +70,65 @@ internal static class TaskbarIconRenderer
graphics.FillPath(textBrush, path);
}
private static FontFamily CreateGlyphFontFamily(out FontStyle fontStyle)
{
foreach (var name in new[] { "Segoe UI", "Arial", "DejaVu Sans", "Liberation Sans", "Noto Sans" })
{
try
{
var family = new FontFamily(name);
if (TryGetUsableStyle(family, out fontStyle))
{
return family;
}
family.Dispose();
}
catch (ArgumentException)
{
}
}
using var installedFonts = new InstalledFontCollection();
foreach (var installedFamily in installedFonts.Families)
{
try
{
var family = new FontFamily(installedFamily.Name);
if (TryGetUsableStyle(family, out fontStyle))
{
return family;
}
family.Dispose();
}
catch (ArgumentException)
{
}
}
fontStyle = FontStyle.Bold;
return FontFamily.GenericSansSerif;
}
private static bool TryGetUsableStyle(FontFamily family, out FontStyle fontStyle)
{
if (family.IsStyleAvailable(FontStyle.Bold))
{
fontStyle = FontStyle.Bold;
return true;
}
if (family.IsStyleAvailable(FontStyle.Regular))
{
fontStyle = FontStyle.Regular;
return true;
}
fontStyle = FontStyle.Regular;
return false;
}
[DllImport("user32.dll", SetLastError = true)]
private static extern bool DestroyIcon(IntPtr hIcon);
}