CreativeInquiry / PEmbroider

Embroidery Library for Processing
Other
442 stars 28 forks source link

Error with Greek Hershey font #18

Closed golanlevin closed 4 years ago

golanlevin commented 4 years ago

The code:

E.textFont(PEmbroiderFont.GREEK_SIMPLEX);
E.text("Ξεσκεπαζω την ψυχοφθορα βδελυγμια.", 50, 50);

Produces an error: ArrayIndexOutOfBoundsException: 894

LingDong- commented 4 years ago

@golanlevin

The Hershey font mapping is not unicode

It matches each letter in greek alphabet to ASCII

E.g. alpha->a, beta->b

So try:

E.textFont(PEmbroiderFont.GREEK_SIMPLEX);
E.text("Xeskepazo tin psychofthora vdelygmia.",50,50);

I don't think they have unicode back in the days of Hershey font. But if it's important I can spend some time modifying the mapping to the greek block in unicode. But then there's also Russian and math symbols etc. Not sure if it's worth the trouble ;) image

golanlevin commented 4 years ago

OK. @LingDong- , maybe add a check for non-ASCII input and report an error/warning for now?

LingDong- commented 4 years ago

👌sure!

LingDong- commented 4 years ago

Added warning when glyph is not found, and draw a space instead: a58b12c1e3549d6a63ad0c03bbc5ef67ddee4388