Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix SetFontFace method to be inline with LoadFontFace#76

Open
harture wants to merge 37 commits intofogleman:master from
cloudtrust:master
Open

Fix SetFontFace method to be inline with LoadFontFace #76
harture wants to merge 37 commits intofogleman:master from
cloudtrust:master

Conversation

@harture
Copy link

@harture harture commented Jun 11, 2019

No description provided.

Copy link
Owner

I'd like to merge this but I need to be careful with changing API behavior. Thoughts?

imamfzn reacted with rocket emoji

Copy link

remeh commented Mar 5, 2020

No solution for the API but I just want to +1 the fix, I've been bitten by this recently.

I was loading each time the font using dc.LoadFontface(string, float64) when I needed to render in a given size (at this time performances were not in the scope).
Later, for performances improvements, I've added a font cache: caching the font with
gg.LoadFontFace(string, float64) and using the font with dc.SetFontFace(font.Face). I've been surprised that the rendering result was not quite the same.

zpl-zak reacted with thumbs up emoji

Copy link

mufty commented Mar 12, 2020
edited
Loading

Yes this is fixing/unifying the SetFontFace method. I'm also trying to do the same thing as @remeh did with different results. Thus we have a fork at the moment with this PR included and it seems to work fine.

However one thing I don't understand is what the hell are these numbers in LoadFontface supposed to mean? What's " * 72 / 96"? 72 of what? and 96 of what?

I had a similar issue with font sizing in the past. Working with a different library in a different language but the root cause is the same I think. The issue was that the font description almost never has correct values for width and height of the font. What I had to do is to use glyphs to get a real text size just before "rendering" it. This is significantly slower because I had to basically render the whole text and get a real height after that but it works every time. You can remove these magic numbers doing that completely at the cost of speed tho.

zpl-zak reacted with thumbs up emoji

Copy link

kirides commented Jan 5, 2021
edited
Loading

iirc, 72 is Pixels per Inch and 96 is the assumed DPI for any monitor.

Though i only know this because of working with C# Winforms & WPF. Winforms assumes everything is in PPI (72px) and WPF uses proper N * (PPI / DPI)

This hit me, because i was hosting a winforms control inside WPF and the fontsizes didn't match.

Xelowak and others added 21 commits October 23, 2024 14:28
basbeu and others added 15 commits November 12, 2025 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers

@imamfzn imamfzn imamfzn approved these changes

@f1mishutka f1mishutka f1mishutka approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Comments

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