#815 font size does not calculate correct text size

v1.0_(example)
closed
nobody
None
1
2014-03-25
2013-06-09
Lubos Dz
No

HTML tag is incorrectly converted to units.
Rather than converting to pt it simply uses integer value making output text almost illegible.

## reproduce steps:
1. create document (default units pt)
2. insert HTML $pdf->writeHTMLCell( $width, $height, $x, $y, $value, ... ) 
   with $value = "<font size=5>some text</font>"

## expected output:
text size increased proportionally to default value of 3, means 5/3 ratio, e.g. 16pt.

## received output:
text of size 5px - almost not legible.

The problem is following line:

$dom[$key]['fontsize'] = intval($dom[$key]['attribute']['size']);

Instead of converting font size, it simply uses integer value.

Here is conversion table for all values <font size="1 .. 7">:

<font size=1> .. should convert to 8pt
<font size=2> .. should convert to 10pt
<font size=3> .. should convert to 12pt  (size 3 is default in all browsers)
<font size=4> .. should convert to 14pt
<font size=5> .. should convert to 16pt
<font size=6> .. should convert to 18pt
<font size=7> .. should convert to 20pt

See also:

http://www.w3schools.com/tags/att_font_size.asp 
"A number from 1 to 7 that defines the size of the text. Browser default is 3."

Discussion

  • Nicola Asuni
    Nicola Asuni
    2013-06-10

    • status: open --> closed
     
  • Nicola Asuni
    Nicola Asuni
    2013-06-10

    In TCPDF, on the font tag, when the unit is not specified, then the value is considered to be expressed in point.
    The old 1-7 numbering is not supported.
    If you want more control I suggest to specify the unit of measure or use an inline style.

     
  • Lubos Dz
    Lubos Dz
    2013-06-10

    Unfortunatelly, I have no control over generated tags - it is generated by inline wysiwyg via docExec commands (http://www.quirksmode.org/dom/execCommand.html).
    I might do regex filter on long strings, which is ineffective and unreliable.
    I think it would be rather easy to add few lines of code and support this feature. Unfortunatelly, TCPDF is not hosted on git or other collaboration platform, so I cannot commit fix either.