Open jo-lang opened 10 months ago
font metrics is different:
for fn in ("Hiragino Sans W1", "LucidaGrande"):
s = FormattedString()
s.font(fn)
print(fn)
print(s.fontAscender())
print(s.fontDescender())
print(s.fontLeading())
print(s.fontLineHeight())
ah sorry, I did not describe the issue properly. yes font metrics are different, but shouldn’t it still show all ten lines of the text. there are only eight of the 10 lines in the 'Hiragino' example. in the example code the line-height needs to be at least 12 to show all lines. This makes it a bit more visual:
txt = '\n'.join(str(i) for i in range(10))
lh = 7
fstr = FormattedString(txt, fontSize=25, font='Hiragino Sans W1', lineHeight = lh)
text(fstr, (100, 400))
fstr = FormattedString(txt, fontSize=25, lineHeight = lh)
text(fstr, (300, 400))
I have noticed this problem recently, too, with a different font, but I found it hard to make a reproducer. The last snippet shows it loud and clear, thanks!
I came across this from a completely different use and it took some time to boil it done. but it’s actually even more confusing. the first example shows 8/10 and the second 7/10 lines.
We suspect the bug is in the makeTextBoxes()
function. This may also be related to some test failures we see on macOS 14.
maybe some hints: https://developer.apple.com/documentation/coretext/ctparagraphstylespecifier/kctparagraphstylespecifierlinespacing?language=objc
those specifiers aren't accessible witha NSParagraphStyle... and a CTParagraphStyleCreate has not full support of pyobjc
same issue in Apples TextEdit:
so maybe (I hope) not really a DrawBot issue...
attached the RTF files from TextEdit: numbers.zip
Using the 'Hiragino Sans W1' typeface in a formatted String with a lineheight smaller than the font-size some of the text is cut off. Anyone has an idea if this is font related?