-
Notifications
You must be signed in to change notification settings - Fork 44
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
Check Object documentation for Glyph(?) #743
Comments
The dependency on fontTools |
@benkiel, does it make sense to mandate subclassing of FontMath objects on similar grounds (e.g, with regard to the Also, are the |
@benkiel, @typesupply, there seems to be a discrepancy between the base level interpolation function and the higher level interpolation methods.
IntFloatType = Union[int, float]
def interpolate(a: IntFloatType, b: IntFloatType, v: IntFloatType) -> IntFloatType:
return a + (b - a) * v
a: MathGlyph
b: MathGlyph
v: Union[IntFloatType, Tuple[IntFloatType, IntFloatType]] Even if |
What do you mean with normalising the factor? |
Since |
Not sure I understand why that would be useful?
|
OK, I'm clearly missing something then. My objection was purely syntactical. There is no way that I can see for |
I might be able to help clarify...
So, I hope that makes sense. My brain is not fully booted up yet this morning. Please let me know if you need more info. *Full credit because this isn't documented anywhere: @LettError came up with the idea that glyphs could behave like numbers and that would allow us to use mathematical equations to process outlines very easily. It is one of the most brilliant tools things we have to work with. I'm still in awe of it and what it has enabled. |
As I mentioned earlier, I accept that I realise that this code goes way back, and, as such, must be thoroughly tested. I just don't see how it works. :) BTW, I don't know of a type that denotes emulated numeric types, but I guess those objects would usually inherit from numeric types? Otherwise, |
Ah. I forgot to explain this. The normalization happens inside of the fontMath objects. For example, in MathGlyph: if a singleton comes in as the factor, it is converted to a tuple. Then:
So, you are correct that |
Thanks! I was confused when I couldn't find the |
It seems that the builtin |
|
@benkiel, great! BTW, do you have any view on this?
|
I think it is fine to mandate subclassing of FontMath objects there, as they depend on that. The As a general philosophy, the documentation generated on the website is intended for folks writing scripts. Documentation for folks implementing fontParts can be in code, only surfacing to the website where it makes sense to help scripters, if that makes sense. Tricky with the two audiences, I know. |
@benkiel, I see. I guess it doesn't hurt to reference them in other classes using Sphinx syntax anyway. Even if the links won't work in the generated documentation, these references do clarify where to find the code they're pointing to. While I have your attention, would you mind answering this post as well: Thanks! |
Even though there is no open issue with regard to this, I'm assuming
glyph.py
should be revised with type annotations and updated docstrings, similarly to other modules in the pipeline.If so, there is an issue with the type hinting of the pen-related methods: what should their annotated pen type actually be?
One option, which is in line with my revisions in font.py and layer.py, is to use the appropriate abstract base classes from FontTools (like
AbstractPen
andAbstractPointPen
. This is straightforward and allows direct cross reference to their documentation, but mandates a dependency on FontTools. Another, more flexible, but complicated option is to define specific typing protocols for pen objects, which only restricts the environment objects in terms of how certain methods should be defined.I'm not sure which of these is the best for FontParts, or how a protocol for e.g., Pen and PointPen should be defined.
What say you, @benkiel, @typesupply?
The text was updated successfully, but these errors were encountered: