Skip to content

text size and position manipulation #1053

Answered by mozman
SalazarElite asked this question in Q&A
Discussion options

You must be logged in to vote

You can get a more precise solution if you don't mind getting HATCH entities as a result:

# additonal imports
from ezdxf.addons import text2path
from ezdxf import path
from ezdxf.fonts import fonts
from ezdxf.math import Matrix44

def as_hatches(data):
    texto_1 = data["modelo"]["text_1"]
    texto_2 = data["modelo"]["text_2"]

    doc = ezdxf.new()
    msp = doc.modelspace()
    ff = fonts.FontFace(family="DejaVu Sans")

    def fit_into_bbox(text: str, x: float, y: float, width: float, height: float):
        # draw the expected target size and location
        msp.add_lwpolyline(
            [(x, y), (x + width, y), (x + width, y + height), (x, y + height)],
            close=True,
…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SalazarElite
Comment options

Answer selected by SalazarElite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants