Calculate baseline of ttf?
Posted: 2009-06-20T01:11:09-07:00
Next problem;
Let's say i generate a couple of headers using imagemagick.
I have three headers:
- "aaa" (nothing at the top and/or nothing at the bottom);
- "Hello" (spikes at the top from the "H" and "l");
- "geez" (spikes at the bottom from the "g");
If i want all 3 images to be the exact same height with e.g. font-size 12 and i want to align the bottom of the text at thesame Y position, how do i do that?
So i don't want this:
But this:
Any help on this one is appreciated.
P.s. i don't know the text i am going to create upfront and i don't know if the font i am going to use has either bigger "extensions" on the top or the bottom.
My best guess is that i have to generate an image with all characters which are "default" (like acemnosuvwxz) and calculate it based on that?
Let's say i generate a couple of headers using imagemagick.
I have three headers:
- "aaa" (nothing at the top and/or nothing at the bottom);
- "Hello" (spikes at the top from the "H" and "l");
- "geez" (spikes at the bottom from the "g");
If i want all 3 images to be the exact same height with e.g. font-size 12 and i want to align the bottom of the text at thesame Y position, how do i do that?
So i don't want this:
But this:
Any help on this one is appreciated.
P.s. i don't know the text i am going to create upfront and i don't know if the font i am going to use has either bigger "extensions" on the top or the bottom.
My best guess is that i have to generate an image with all characters which are "default" (like acemnosuvwxz) and calculate it based on that?