Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uprefactor(fontweight): allow unknown fontweight value #8
Conversation
|
https://searchfox.org/mozilla-central/source/gfx/thebes/gfxDWriteFontList.h#98-133 may be the code that Firefox uses to deal with this. |
|
@jdm, yes, looks somewhat related. For me legit way looks like
I tried 1 quickly but rust doesn't offer out of box way to mix with c-style enum for those with |
|
That does sound like the correct way to deal with it. |
|
/cc @jdm for visibility. |
|
The CI problem is not caused by this PR; I've opened #10 for that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
kwonoj commentedJul 2, 2018
•
edited
Related with servo/servo#21076.
Given reproducible code snippet
When try to read weight from
Microsoft Yahei, only onLightweight will throw exception. surprisingly whileDWRITE_FONT_WEIGHTenum doesn't specify it in documented listYahei's light fontweight is not300:but having adjusted value of
290and enum conversion fails since there isn't matching value.This PR refactors
FontWeightenum to not use discriminator values, and addFontWeight::Unknown(u32)type to allow fallback if C enum contains non-matching values to enum values. There are couple of way I tried, but wasn't entirely sure around each approaches - except require manual matching from u32 value to enum and vice versa, this approach provides simplest way to resolve issue.Unknown(u32)will provide fallback even if it occursStill, technically this can be breaking change if any consumer uses direct casting to u32 of enum values instead of using
to_u32()interface: but so far I know there doesn't seem way to create non-breaking change if we'd like to have fallback values.Note: this doesn't resolve servo side crash immediately - servo need to implement to handle fallback values.