Support font.math.*DeviceTable as indexable object#1
Support font.math.*DeviceTable as indexable object#1mf2vec-dev merged 9 commits intomf2vec-dev:py-math-devtabfrom
Conversation
mf2vec-dev
left a comment
There was a problem hiding this comment.
Thank you very much for looking into this. I did some testing and it seems to work.
Besides the comments, please also update fontforge.rst.
The only thing that is a bit strange is the behavior of something like the following. I understand why this happens, but this may not be the most intuitive behavior for some users.
font.math.MathLeadingDeviceTable[10] = 1
a = font.math.MathLeadingDeviceTable
print(font.math.MathLeadingDeviceTable[10]) # 1
print(a[10]) # 1
print('')
a[10] = 2
print(font.math.MathLeadingDeviceTable[10]) # 2
print(a[10]) # 2
print('')
font.math.SpaceAfterScriptDeviceTable = a
a[10] = 3
print(font.math.MathLeadingDeviceTable[10]) # 3
print(a[10]) # 3
print(font.math.SpaceAfterScriptDeviceTable[10]) # 2(a = font.math.*DeviceTable by reference and font.math.*DeviceTable = a by value)
I'm not sure if this can or should be changed. However, it's fine for me to merge it with this behavior if there is no easy alternative.
I think we can resolve this ambiguity by forcing user into explicit copy: Alternatively, we can just forbid copying into another device table altogether. @skef, what do you think about the desired API? |
What would be the disadvantage of always copying on assignment ourselves in this case? Would that lead to too much confusion about what was by value and what was by reference? Is this even possible to differentiate at the C-API level (genuine question)? I would have thought both would just look the same internally. |
|
Copy on assignment is inherently non-Pythonic, so the following would be confusing: For my |
|
@mf2vec-dev, please review |
mf2vec-dev
left a comment
There was a problem hiding this comment.
Thanks for implementing the iterator.
In light of the discussion in this PR and in fontforge#5348, I'm fine with the current approach.
No description provided.