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

Custom typeface in Avalonia.Svg #260

Closed
tkefauver opened this issue Feb 6, 2025 · 2 comments
Closed

Custom typeface in Avalonia.Svg #260

tkefauver opened this issue Feb 6, 2025 · 2 comments

Comments

@tkefauver
Copy link

I'm trying to use a custom typeface in Avalonia.Svg but its not working.

I'm loading the font like this:
var font_stream = AssetLoader.Open(new Uri("avares://AvaloniaSvgSkiaSample/Assets/Fonts/Garamond/EBGaramond-VariableFont_wght.ttf")); var result = SKFontManager.Default.CreateTypeface(font_stream);

Which works (it creates the SKTypeFace at least) but is not the approach described in the Wiki article because SvgTextExtensions doesn't seem to exist anymore so that might be part of my problem.

Then I'm using the sample app AvaloniaSvgSkiaSample and just adding a text element below the circle (in the string tab) like this:
<text x="40" y="40" font-family="EB Garamond">yoo</text>

But the family name isn't being recognized by SkiaAssetLoader.FindTypefaces. Its the right family name (I verified it from result of the CreateTypeFace call).

How do I add the SKTypeFace I created to be recognized?

@wieslawsoltes
Copy link
Owner

Avalonia.Svg is not using skia at all you need to provide Avalonia typeface type loader. Sorry no example available.

@tkefauver
Copy link
Author

Hmm ok thanks. I just decided to use a default fixed width font which pretty much fixes my issue (drawing centered text).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants