Hi !
Assumptions : CellPadding =0 ,margins=0,cellheightRatio=1.
Is it possible to get the Ascent and Descent of the font for a Particular string.Not including all of the characters but only some?
I need this to position two words exactly below each other but i dont want the second word to start at the baseline of the first.Rather start at the end of the first ,so that there is no overlap.
i Have tried getStringHeight but it does not give me accurate results,since i am using fonts like scriptina,bickham,copper alt etc which extend both above and below the baseline.
Here is a summary of what i want to do -
$text1="ABC";
$text2="XYZ";
$x=50;
$y=50;
$text1_h = (Function to get Exact height with Ascent + Descent ,of only the characters used in text1)
//currently using
//$text1_h= $pdf->getStringHeight(0, $text1, false, false, '', 0);
Looks like not all the tables of the ttf file are being utilized.
-------Horizontal Metrics (hmtx) - Available------
the php file generated for the font contains the $cw array for character specific width , coming from the 'hmtx' table of ttf being parsed in method "addTTFfont" in tcpdf_fonts.php (line 784).
-------Vertical Metrics (vmtx) - Unavailable------
if similarly a $ch array can be generated from the 'vmtx' table it will solve the problem of obtaining exact character height , hence exact string height.
Can anyone provide such a modification ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In abstract terms - this code recalculates the Ascender and Descender Values from "imagettfbbox" available from the GD library in the "getCellCode" function in tcpdf.php. this allows correct rendering of those super crazy fonts when you use
$pdf->Text( ... ) call.
If you need more help , drop a mail at maxcode360@gmail.com . Thanks !
Thanks !
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi !
Assumptions : CellPadding =0 ,margins=0,cellheightRatio=1.
Is it possible to get the Ascent and Descent of the font for a Particular string.Not including all of the characters but only some?
I need this to position two words exactly below each other but i dont want the second word to start at the baseline of the first.Rather start at the end of the first ,so that there is no overlap.
i Have tried getStringHeight but it does not give me accurate results,since i am using fonts like scriptina,bickham,copper alt etc which extend both above and below the baseline.
Here is a summary of what i want to do -
Note the use of $y+$text1_h
My output does not match exactly at the end rather overlaps just below the baseline when characters like 'y' are used.
Any help will be appreciated ! Thanks !
Saw this post which is a related issue ! it can help make more sense.
http://sourceforge.net/p/tcpdf/discussion/435311/thread/43a94146/#73de
Last edit: maxcode360 2014-09-05
Looks like not all the tables of the ttf file are being utilized.
-------Horizontal Metrics (hmtx) - Available------
the php file generated for the font contains the $cw array for character specific width , coming from the 'hmtx' table of ttf being parsed in method "addTTFfont" in tcpdf_fonts.php (line 784).
-------Vertical Metrics (vmtx) - Unavailable------
if similarly a $ch array can be generated from the 'vmtx' table it will solve the problem of obtaining exact character height , hence exact string height.
Can anyone provide such a modification ?
For those who are looking for a solution and dont mind changing the code. Its not very elegant but it gets the job done.
http://pastebin.com/22XqM3nM
In abstract terms - this code recalculates the Ascender and Descender Values from "imagettfbbox" available from the GD library in the "getCellCode" function in tcpdf.php. this allows correct rendering of those super crazy fonts when you use
$pdf->Text( ... ) call.
If you need more help , drop a mail at maxcode360@gmail.com . Thanks !
Thanks !
The ascent and descent values are now provided by the getFontAscent() and getFontDescent() methods.