Skip to content

Navigation Menu

Sign in
Sign up

Bold style is not applied for some windows fonts #374

Open
Labels
enhancementNew feature or request

Description

Some fonts (like Cascadia Code and Bahnschrift) seem to ignore Bold style. These are default windows fonts.

OS: Win 11
PdfSharp-WPF Version: 6.2.4
Below is the code for the sample app demonstrating this issue:

using PdfSharp.Drawing;
using PdfSharp.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 cascadiaRegular = new XFont("Cascadia Code", 40, XFontStyleEx.Regular);
var rect2 = new XRect(10, 120, page.Width, 0);
gfx.DrawString("Hello world", cascadiaRegular, new XSolidBrush(new XColor() { R = 0, G = 0, B = 0 }), rect2,
 XStringFormats.BaseLineLeft);
var cascadiaBold = new XFont("Cascadia Code", 40, XFontStyleEx.Bold);
var rect = new XRect(10, 240, page.Width, 0);
gfx.DrawString("Hello world", cascadiaBold, new XSolidBrush(new XColor() { R = 0, G = 0, B = 0}), rect,
 XStringFormats.BaseLineLeft);
document.Save(@"C:\Users\Public\Documents\HelloWorld.pdf");

And here's the output where both texts seem identical:
HelloWorld.pdf

Here's the archive with the fonts (just in case):
fonts.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /