#17229 closed bug (fixed)
Bad character escapements for some bold fonts
Reported by: | hgsfghs | Owned by: | madmax |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta4 |
Component: | Servers/app_server | Version: | R1/beta3 |
Keywords: | Cc: | madmax | |
Blocked By: | Blocking: | ||
Platform: | All |
Description
BFont.StringWidth () and BFont.GetEscapements () seem to return overly wide sizes for bold fonts. It can be reproduced by the following code:
BView vw; /* Get a view somehow */ const char *str = "Haiku test string"; float fl[strlen (str)]; edge_info ei[strlen (str)]; ft.GetEscapements (str, strlen (str), (float *) &fl); ft.GetEdges (str, strlen (str), (edge_info *) &ei); vw->LockLooper (); vw->PushState (); vw->PushState (); vw->SetHighColor (128, 0, 0, 255); vw->SetPenSize (2.0); BRect r (0, 0, ft.StringWidth (str) - 1, 50); vw->StrokeRect (r); vw->PopState (); vw->MovePenTo (0, 50); vw->SetFont (&ft); vw->DrawString (str); vw->PopState (); vw->UnlockLooper ();
The rectangle drawn will be far wider than the text drawn, which is not the case with a plain font. Similar issues, albeit on a character-by-character basis can be seen in the escapements returned by BFont.GetEscapements ().
I have attached two screenshots, depicting the difference between the result of calling GetStringWidth () on a regular font and that of calling the same function on a bold font.
Attachments (2)
Change History (25)
by , 3 years ago
Attachment: | Screenshot from 2021-08-31 19-34-14.png added |
---|
by , 3 years ago
Attachment: | Screenshot from 2021-08-31 19-29-16.png added |
---|
StringWidth of string with plain font
comment:1 by , 3 years ago
Cc: | added |
---|---|
Component: | Kits → Servers/app_server |
Keywords: | bfont escapements removed |
Owner: | changed from | to
madmax, you seem to be the burgeoning fonts rendering person, perhaps you might have some time to look into this?
comment:2 by , 3 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 3 years ago
Summary: | Bad character escapements for bold fonts → Bad character escapements for some bold fonts |
---|
Reproducible with Noto Sans Bold, but not with Noto Sans Display Bold (or any other of the very few I've tested with).
comment:4 by , 3 years ago
I also noticed that BFont.GetEdges () and BFont.GetEscapements () doesn't seem to respect shear. Could this be related somehow?
comment:5 by , 3 years ago
The problem is not with metrics. The painter is using SemiBold style instead of Bold for that font. Will try to find out why later in the evening.
comment:8 by , 3 years ago
It doesn't seem like the patch has been installed yet. Is there any way I can help with this? Right now, it's preventing some important features such as reading e-mail with RMAIL from working correctly in Emacs.
Thanks.
comment:9 by , 3 years ago
Sorry, it seems this one got lost in the code review process, I have just merged it now.
comment:10 by , 3 years ago
Milestone: | Unscheduled → R1/beta4 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
comment:11 by , 3 years ago
Thanks! One last question: will this patch end up in R1/Beta3 systems updated through SoftwareUpdater, or will it only show up in nightlies?
comment:12 by , 3 years ago
I have only merged it for nightlies. We can backport it to the beta3 branch as well if needed.
follow-up: 18 comment:13 by , 3 years ago
It would be nice to have Emacs work properly in R1/Beta3 (since that's the system I use for testing), but if you think it's too risky to backport then that's fine as well.
Thanks :)
comment:14 by , 3 years ago
I'd say let's wait for a week or two and if no one complains about regressions in nightlies we can backport it. Remind me then because I will probably forget to do it.
comment:16 by , 3 years ago
It's been two weeks, so if there haven't been any regressions I think it would be nice for someone to backport it to R1/Beta3. WDYT?
Thanks.
comment:18 by , 3 years ago
Replying to hgsfghs:
It would be nice to have Emacs work properly in R1/Beta3 (since that's the system I use for testing)
To be clear, does that mean we have not checked the patch solves your real problem in nightlies? It does fix a problem with font flags that leads to the issue in the description, but I only ran the test you provided and a few similar ones. Is that extracted from the code used by emacs? If that's not the case, can you provide instructions (detailed ones including setup, I have no emacs experience) to reproduce it in emacs?
comment:19 by , 3 years ago
No, I just meant to say that it would be nice to have it backported to the beta branch, since I use that for testing. I installed one of the nightlies temporarily to test, and it does fix the problem with Emacs.
Thanks.
StringWidth of string with bold font