compensate for bezier curvature

This commit is contained in:
themancalledjakob 2024-08-05 12:56:30 +02:00
parent a6e760db64
commit 85ed21ef22

View file

@ -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 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) ob.scale = (scalor, scalor, scalor)
advance = advance + glyph_advance advance = advance + glyph_advance + curve_compensation
if regenerate: if regenerate:
mom.users_collection[0].objects.link(ob) mom.users_collection[0].objects.link(ob)