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

Fix the REGULAR bit of the fsSelection being set incorrectly #1222

Merged
merged 1 commit into from
May 10, 2023
Merged

Fix the REGULAR bit of the fsSelection being set incorrectly #1222

merged 1 commit into from
May 10, 2023

Conversation

negset
Copy link
Contributor

@negset negset commented May 10, 2023

Description

This commit resolves the issue of the fsSelection of the OS/2 table not being properly set.

According to Microsoft's documentation, bit 6 (REGULAR) of fsSelection is recommended to be set only when bit 0 (ITALIC) and bit 5 (BOLD) are clear.
However, the current script sets bit 6 (REGULAR) without following this rule (for example, when the font name is XXX-BoldItalic.ttf).

So, I have made changes to ensure that bit 6 (REGULAR) is not set when bit 0 (ITALIC), bit 5 (BOLD), or bit 9 (OBLIQUE) is set.
While the documentation does not specify whether bit 6 (REGULAR) should be cleared when bit 9 (OBLIQUE) is set, I think it should be treated like 0 (ITALIC) and bit 5 (BOLD).

Requirements / Checklist

What does this Pull Request (PR) do?

How should this be manually tested?

Any background context you can provide?

What are the relevant tickets (if any)?

Screenshots (if appropriate or helpful)

Set bit 6 (REGULAR) of fsSelection only when bit 0 (ITALIC), bit 5 (BOLD), and bit 9 (OBLIQUE) are clear.
@Finii
Copy link
Collaborator

Finii commented May 10, 2023

Thanks for the excellent catch!

What do you think about this change instead:

-if len(self.weight_token) == 0 and not b & (ITALIC | BOLD | OBLIQUE):
+if len(self.weight_token) == 0 and not b & (ITALIC | BOLD):

As OBLIQUE is already handled by the (non) empty weight_token. But maybe your code is more clear.
You decide.

Checking if --has-no-italic is handled correctly...
Ah yes, that is handled only later in the concrete name-string generation.

@Finii Finii added this to the v3.0.1 milestone May 10, 2023
@Finii
Copy link
Collaborator

Finii commented May 10, 2023

Interestingly Bit 9 (Oblique) is not mentioned 🤔

Bit 6: If bit 6 is set, then bits 0 and 5 must be clear, else the behavior is undefined. Note that, if both bit 0 and bit 5 are clear, that does not give any indication as to whether or not bit 6 will be clear. For example, Arial Light is not the regular style of Arial and would have all bits cleared.

Anyhow. After a ☕ I believe your redundant but more explicit code is better 👍

@Finii
Copy link
Collaborator

Finii commented May 10, 2023

Thanks again!

I will merge this together with the other 3.0.1 patches.

@Finii
Copy link
Collaborator

Finii commented May 10, 2023

@allcontributors add @negset for code

@allcontributors
Copy link
Contributor

@Finii

I've put up a pull request to add @negset! 🎉

@Finii Finii merged commit 7e2326b into ryanoasis:master May 10, 2023
@negset
Copy link
Contributor Author

negset commented May 10, 2023

Thank you for merging my pull request!

LNKLEO pushed a commit to LNKLEO/Nerd that referenced this pull request Nov 24, 2023
Fix the REGULAR bit of the fsSelection being set incorrectly
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

Successfully merging this pull request may close these issues.

2 participants