| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| break | ||
|
|
||
| if best_font is not None: | ||
| if abs(map_weight_name_to_score(prop.get_weight()) |
There was a problem hiding this comment.
pep8 is pretty unhappy about the formatting here.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks! This should be better.
Sorry, something went wrong.
|
Could you also add a test that warnings are actually raised when we miss a weight? We will always have dejavu installed so maybe one of the very high or low weights? |
Sorry, something went wrong.
|
Thanks @colathro ! It was great working with you today! |
Sorry, something went wrong.
|
I think we should warn anytime there's no exact match, rather than with a threshold of 100. |
Sorry, something went wrong.
| 'black': 900, | ||
| } | ||
|
|
||
| def map_weight_name_to_score(weight): |
There was a problem hiding this comment.
this should be private
Sorry, something went wrong.
There was a problem hiding this comment.
When you say private, I think of other language access modifiers. In Python would that be just making this a class method?
Sorry, something went wrong.
There was a problem hiding this comment.
Just prepend an underscore to its name.
Sorry, something went wrong.
I'm not quite able to figure out the best way to do this. I can't quite get the output to appear in the warnings no matter what I try. Is this due to the logger not actually implementing Warnings? |
Sorry, something went wrong.
|
The font weight dict looks incomplete, tested some fonts on Win10:
CJK fonts may not have same weight value compared to Latin fonts |
Sorry, something went wrong.
|
The CSS font weight names are mentioned in https://www.w3.org/TR/css-fonts-4/#font-weight-prop https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Common_weight_name_mapping so the intermediate values should not be included, Windows likely just maps them to the closest name. It actually looks like our weights name table is wrong... The full table in the CSS spec is 100 thin (aka hairline in MozDev) plus the vendor-specific ones fontconfig (https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/master/src/fcweight.c) MozDev, and Windows (https://docs.microsoft.com/en-us/dotnet/api/system.windows.fontweights?view=netframework-4.8#remarks) |
Sorry, something went wrong.
|
Are those font weight inconsistencies handled by #16203? Where would this PR stand after that one? |
Sorry, something went wrong.
|
Users can still request e.g. Foobar Thin font and if that doesn't exist but Foobar Regular does then we will return that, and I think it still makes sense to warn in that case? |
Sorry, something went wrong.
|
I'm pushing this to 3.4 as there seems to be some discussion about when we should warn (on a non-perfect match or any miss-match). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
#15529
We check if the chosen font is +-100 from the desired user outcome. If so, we log a warning documenting the desired and the actual used.
Test is added to make sure new function for string mappings are correct.
PR Checklist