geelen / typeslab

Simple, shareable typographic posters
http://typeslab.com
GNU Affero General Public License v3.0
287 stars 33 forks source link

Issues with scandinavian characters #2

Closed JuhQ closed 9 years ago

JuhQ commented 9 years ago

It seems that the line height is wrong when using scandinavian characters, ä, ö, å for example.

Scandinavian character issue

geelen commented 9 years ago

Thanks for submitting. I need to either decide to come up with a strategy for predicting when this would occur (any diacritic above a capital letter) or develop a way to understand the real extent of a rendered piece of text. But I'll fix it!

toabi commented 9 years ago

Jip. +1

ericol commented 9 years ago

Same thing with spanish accentuated chars.

ErtugKaya commented 9 years ago

Beware that some characters have diacritics below. Here are some Turkish chars.

image

I guess, you should measure character heights. This may be a good start: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas

geelen commented 9 years ago

Fixed as of https://github.com/geelen/typeslab/pull/7

Thanks for letting me know about this!

toabi commented 9 years ago

Jey, much better. I just found some small special case: For those characters there is no font-combination where all letters are included and the ť hangs out.

Issue

geelen commented 9 years ago

Yeah, that's a different bug - canvas has a measureText function which is supposed to give me a real width of the rendered text, but it doesn't. I might use the same logic for depth checking as I do for width-checking, shouldn't be too hard, but I won't have time to fix it for a while. Anyone feel like throwing a PR at me? The lines in question are here: https://github.com/geelen/typeslab/blob/master/src/lib/models/line-metrics.js#L15-L25

I'd love to avoid calculating the depth twice, but I don't see how. In the use-case above, the line doesn't need to be resized, just shifted left. Maybe that case is easier to deal with...