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?
Calculate baseline of ttf?
Re: Calculate baseline of ttf?
found the solution (at least a workaround);
Generate the image twice;
1st time: append the chars (and find out the height of the image)
2nd time: don't append anything and find out the width of the image.
Finally; crop the image to the width (which you found the 2nd time) and the height (which you found the first time). Works perfect and no calculations required
Generate the image twice;
1st time: append the chars (and find out the height of the image)
2nd time: don't append anything and find out the width of the image.
Finally; crop the image to the width (which you found the 2nd time) and the height (which you found the first time). Works perfect and no calculations required
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Calculate baseline of ttf?
for more direct alignment with different fonts look at
Creating Lines of Mixed Font Styles
http://www.imagemagick.org/Usage/text/#mixed_font_lines
Creating Lines of Mixed Font Styles
http://www.imagemagick.org/Usage/text/#mixed_font_lines
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/