AvaloniaUI / Avalonia.HtmlRenderer

Avalonia front-end for the HtmlRenderer project.
MIT License
119 stars 34 forks source link

custom font not work #21

Closed Gilfoylex closed 1 year ago

Gilfoylex commented 1 year ago

I use the demo to set custom fonts, like this:

var f = new FontFamily(
            new Uri("avares://AvaloniaPreviewApp/Assets/Fonts/CustomFont.ttf"),
            "1 Smoothy DNA");

HtmlRender.AddFontFamily(f);

HtmlLabel and HtmlControl Unable to use custom font rendering, but the same code works fine in WPF

Gilfoylex commented 1 year ago

Sorry. I found out that there was a problem with the way I loaded the font。

right way is:

var f = new FontFamily(
            new Uri("avares://AvaloniaPreviewApp/Assets/Fonts"),
            "#1 Smoothy DNA");

"#" is very important!!!