drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

Fallback font changes line height

Open frankrolf opened this issue 6 years ago • 7 comments

Another issue which may be a macOS problem instead: If font fallback occurs, the line height is changed to correspond to the metrics of the fallback font (or perhaps the largest vertical metrics(?)).

This is an example:

margin = 30
newPage('A4')

text_rect = (
    margin,
    3 * margin,
    width() - 3 * margin,
    height() - 4 * margin)
    
content = '''\
The Ķegums Hydro Power Plant is the oldest hydropower plant on the river Daugava and the third largest in Latvia located in Ķegums. The complex consist of two power plants. The first plant was built from 1936 to 1940. 猫 The plant was totally renovated from 1998 to 2001, including replacement of four hydroelectric sets with a nominal output of around 65 MW. 
'''

fs = FormattedString(
    content,
    font='Seravek',
    fontSize=23,
)

textBox(fs, text_rect)

Again, I can already observe the shift in line spacing in the code panel, which is why I think macOS is to blame.

Screen Shot 2019-09-24 at 16 18 04

frankrolf avatar Sep 24 '19 14:09 frankrolf

If you set a lineHeight in the formattedString DrawBot will keep that lineHeight for each line of text.

I don't think this is a bug, its just two different fonts with different metrics in the same line of text, so the line height will be depends on the hightest one. Unless a lineHeight is set.

typemytype avatar Nov 02 '19 21:11 typemytype

Unfortunately, that’s not the case: Screen Shot 2019-11-02 at 23 31 14

frankrolf avatar Nov 02 '19 22:11 frankrolf

Perhaps related to #52 ?

frankrolf avatar Nov 02 '19 22:11 frankrolf

Perhaps related to #52 ?

Very likely.

I think the question is how to implement "Exact" line heights https://github.com/typemytype/drawbot/issues/52#issuecomment-352177049

justvanrossum avatar Nov 03 '19 05:11 justvanrossum

Flip the switch and observe the difference:

s = """The Ķegums Hydro Power Plant is the oldest hydropower plant on the river Daugava and the third largest in Latvia located in Ķegums. The complex consist of two power plants. The first plant was built from 1936 to 1940. %sThe plant was totally renovated from 1998 to 2001, including replacement of four hydroelectric sets with a nominal output of around 65 MW."""

if False:
    extra = "万 "
else:
    extra = ""
font("Times")
fontSize(36)
lineHeight(38)
textBox(s % extra, (100, 100, 600, 400))

Although, when I try the same in TextEdit, I get a behavior closer to this with "Exactly" turned on, at least on 10.10.

justvanrossum avatar Nov 03 '19 06:11 justvanrossum

Btw. I see no difference when using a FormattedString or not.

justvanrossum avatar Nov 03 '19 06:11 justvanrossum

a minor change when using lineHeight() when they are layout on top of each other Screen Shot 2019-11-03 at 10 15 30

typemytype avatar Nov 03 '19 09:11 typemytype