I am trying to create simple images with a text made of a few digits on the center.
The problem is that I need to manually offset the position, is there a way to make it “centered” in a visual sense, i.e. where the span from the extreme of the digit and the border is thesame in the 4 directions ?
I have tried so far the above snippet:
Drawing(300, 300, "hello-world.png")
textcentered("123", 0, 0)
text("123",Point(-17, 60), halign=:center,valign=:center)
This results in the following image, where you can see that the the red text is not centered, and I have to manually adjust it:
Fonts aren’t perfectly aligned - I often nudge them to optically align them:
I was really wondering about an improved solution for this as well. Glad to see I wasn’t the only one struggeling.
But furthermore I’m still curious as to how the placement works because I get this weird placement also with monospaced fonts:
Could I maybe create a consistent bordered text by splitting the word up in letters and positioing those seperately?
I might dive into trying that in a bit because I’d like to finish this logo I’m making.
I think this is a different issue from the original poster, who needed to use the correct keyword. I think you might be after “text as path”, converting text to graphic paths so that you can fill and stroke them separately? (documentation here).
textoutlines("Wormhole", O, :fillpreserve, halign=:center)
Splitting the text up into separate letters is straightforward - use
textextents() to get the dimensions of each character. If you look at the code for
textcurve() you get an idea of how to do it:
A nice that solves simply. Thanks again cormullion.