Some fonts (like Cascadia Code and Bahnschrift) seem to ignore Bold style. These are default windows fonts. Weirdly enough, it doesn't ignore italic style.
using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
using var document = new PdfDocument();
var page = document.AddPage();
page.Width = new XUnit
{
Millimeter = 100
};
page.Height = new XUnit
{
Millimeter = 100
};
using var gfx = XGraphics.FromPdfPage(page);
var cascadiaBold = new XFont("Cascadia Code", 40, XFontStyle.Bold, XPdfFontOptions.UnicodeDefault);
var rect = new XRect(10, 120, page.Width, 0);
gfx.DrawString("Hello world", cascadiaBold, new XSolidBrush(new XColor() { R = 0, G = 0, B = 0}), rect,
XStringFormats.BaseLineLeft);
var cascadiaRegular = new XFont("Cascadia Code", 40, XFontStyle.Regular, XPdfFontOptions.UnicodeDefault);
var rect2 = new XRect(10, 240, page.Width, 0);
gfx.DrawString("Hello world", cascadiaRegular, new XSolidBrush(new XColor() { R = 0, G = 0, B = 0 }), rect2,
XStringFormats.BaseLineLeft);
document.Save(@"C:\Users\Public\Documents\HelloWorld.pdf");
Some fonts (like Cascadia Code and Bahnschrift) seem to ignore Bold style. These are default windows fonts. Weirdly enough, it doesn't ignore italic style.
OS: Win 11
PdfSharpCore Version: 1.3.67
Below is the code for the sample code demonstrating this issue:
And here's the output where both texts seem identical:
HelloWorld.pdf
Here's the archive with the fonts:
fonts.zip