StrutStyle for leading/lineheight adjustment on ParagraphStyle + TextStyle.setLetterSpacing and TextStyle.setWordSpacing#299
Conversation
See python/cpython#128161 "Defining iterator in a separate class no longer works in 3.13" We have iterator for SkTextBlob defined by SkTextBlob::Iter(textblob), which is the c++/pybind11 equivalent of the same situation. Following the suggestion: python/cpython#128161 (comment) Also see actions/runner-images#11241 Fixes skia-python#295
…ht on textlayout.Paragraph
|
Argh, note to myself - this will collide with #293 in the next merge. Just slight inconvenience. |
|
@HinTak thanks for taking a look! Happy to help where I can. Hopefully I pulled in the #296 change properly. I added more tests and also added |
textlayout.StrutStyle for leading/lineheight adjustment on textlayout.ParagraphStyleStrutStyle for leading/lineheight adjustment on ParagraphStyle + TextStyle.setLetterSpacing and TextStyle.setWordSpacing
|
That's fine - indeed it is easier if you put in more changes in related area in one pull, or even small unrelated ones for that matter. As long as they are useful & a few more tests get added. |
|
@stenson I meant modifying the tests to look something like this: This is neater, don't you think? Also, this counts as 4 tests (each of them are allowed to behave differently), rather than 1 (stopping at the first failure). Have a go at adapting the |
|
@HinTak thanks for the example! That definitely makes sense and I'm happy to rewrite the tests, I'm just not sure I see how to convert the existing tests, as they all rely on capturing and comparing relative results like this: negative_one_x_letter_spacing = graf_with_letterspacing(-1.0).LongestLine
zero_x_letter_spacing = graf_with_letterspacing(0.0).LongestLine
assert zero_x_letter_spacing > negative_one_x_letter_spacingIs it preferable to have the tests test for specific values then? i.e. testing that the LongestLine is |
I thought that's straightforward? you could do something like this: |
|
As for what values to test - I think it is nice to test unusual / surprise values if only to document what they should be (and later detect if things change upstream), or if they misbehave, so zero / negatives are always interesting. Looks like strut has the same meaning in age old LaTeX - it is an invisible(zero width?) box of a certain height, so height less than 1 does not affect line spacings. |
|
It is a single character in LaTeX though, https://en.m.wikipedia.org/wiki/Strut_(typesetting) not a paragraph property. |
|
@HinTak that makes sense, I've updated all three new tests here to with |
|
Cool. Thanks for the work. I'll add this to the m134 pile - m133 was out a few days ago, so m134 should be in about a month's time. |
|
@HinTak that sounds great — thanks for the review |
Not sure if there’s already a plan to add this in the works, but this PR adds a minimal version of
textlayout.StrutStylewith.setLeadingfor modifying inter-line spacing withtextlayout.Paragraph.A code example (to modify https://github.com/HinTak/skia-python-examples/blob/main/skparagraph-example.py to get double-spacing):