TCPDF/PHP & Fonts: Uppercase Numbers (Descent numbers? Old style?)

核能气质少年 提交于 2019-12-10 22:39:15

问题


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:

  1. Break your text output into substrings where it changes from letters to numbers - probably using preg_split().
  2. Output the text with Cell() or MultiCell(), up to the point where the letters end and the numbers start.
  3. Raise the current Y-position using SetY().
  4. Output the numbers.
  5. Reset the Y-position to where it was before step 3 (assuming that you haven't crossed a line break).
  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!