问题
I'm given a special font with numbers like that:
As you can see on the 3 for example, some numbers descent below the baseline. What I like to achieve is, that these numbers don't go below the line and that it looks like this:
In Word this can be easily set in the character settings for the same font. How can one render digits in TCPDF like this? I'm totally stuck there and have no clue how to proceed.
Cheers for any help!
回答1:
It can be done, but it's messy... In principle you'll have to do something like this:
- Break your text output into substrings where it changes from letters to numbers - probably using preg_split().
- Output the text with Cell() or MultiCell(), up to the point where the letters end and the numbers start.
- Raise the current Y-position using SetY().
- Output the numbers.
- Reset the Y-position to where it was before step 3 (assuming that you haven't crossed a line break).
- Repeat as necessary....
Of course, this raises the baseline for all numbers - from your sample it looks as if you need to raise the baseline for just some of them, which will be even more fiddly.
Good luck! :-)
来源:https://stackoverflow.com/questions/42201756/tcpdf-php-fonts-uppercase-numbers-descent-numbers-old-style