From 85ed21ef22c9f161eddd16a09bc42b2c3c9e3e51 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Mon, 5 Aug 2024 12:56:30 +0200 Subject: [PATCH] compensate for bezier curvature --- butils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/butils.py b/butils.py index 404ae9a..b1462f7 100644 --- a/butils.py +++ b/butils.py @@ -595,9 +595,19 @@ def set_text_on_curve(text_properties): glyph_advance = (-1 * glyph.bound_box[0][0] + glyph.bound_box[4][0]) * scalor + text_properties.letter_spacing + # now we need to compensate for curvature + # otherwise letters will be closer together the curvier the bezier is + # this could be done more efficiently, but whatever + previous_location = calc_point_on_bezier_curve(mom, advance, False) + new_location = calc_point_on_bezier_curve(mom, advance + glyph_advance, False) + curve_compensation = 0 + while (previous_location - new_location).length < glyph_advance: + curve_compensation = curve_compensation + glyph_advance * 0.1 + new_location = calc_point_on_bezier_curve(mom, advance + glyph_advance + curve_compensation, False) + ob.scale = (scalor, scalor, scalor) - advance = advance + glyph_advance + advance = advance + glyph_advance + curve_compensation if regenerate: mom.users_collection[0].objects.link(ob)