I work on XSL-FO (to play exact invoice print) format http://xmlgraphics.apache.org/fop/ to parse all on
QTextDocument && dispay on QTextBrowser or QGraphicsScene .

i found em unit nummer is this same as inch? or how is the faktor to convert on point?


[HTML]
<fo:block>
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">Sized</fo:block>
<fo:block>
The image
(<fo:external-graphic width="150pt" height="50pt" src="images/fop.jpg"/>)
has the width and height set.
</fo:block>
</fo:block>
[/HTML]


is the faktor here correct or mistake?

Qt Code:
  1. double FopFormat::ConvertUnit( const QString &data )
  2. {
  3. #define MM_TO_POINT(mm) ((mm)*2.83465058)
  4. #define CM_TO_POINT(cm) ((cm)*28.3465058)
  5. #define DM_TO_POINT(dm) ((dm)*283.465058)
  6. #define INCH_TO_POINT(inch) ((inch)*72.0)
  7. #define PI_TO_POINT(pi) ((pi)*12)
  8. #define DD_TO_POINT(dd) ((dd)*154.08124)
  9. #define CC_TO_POINT(cc) ((cc)*12.840103)
  10. #define EM_TO_POINT(em) ((em)*25.02)
  11.  
  12. double points = 0;
  13. if ( data.endsWith( "pt" ) ) {
  14. points = data.left( data.length() - 2 ).toDouble();
  15. } else if ( data.endsWith( "cm" ) ) {
  16. double value = data.left( data.length() - 2 ).toDouble();
  17. points = CM_TO_POINT( value );
  18. } else if ( data.endsWith( "em" ) ) {
  19. double value = data.left( data.length() - 2 ).toDouble();
  20. points = EM_TO_POINT( value );
  21. } else if ( data.endsWith( "mm" ) ) {
  22. double value = data.left( data.length() - 2 ).toDouble();
  23. points = MM_TO_POINT( value );
  24. } else if ( data.endsWith( "dm" ) ) {
  25. double value = data.left( data.length() - 2 ).toDouble();
  26. points = DM_TO_POINT( value );
  27. } else if ( data.endsWith( "in" ) ) {
  28. double value = data.left( data.length() - 2 ).toDouble();
  29. points = INCH_TO_POINT( value );
  30. } else if ( data.endsWith( "inch" ) ) {
  31. double value = data.left( data.length() - 4 ).toDouble();
  32. points = INCH_TO_POINT( value );
  33. } else if ( data.endsWith( "pi" ) ) {
  34. double value = data.left( data.length() - 4 ).toDouble();
  35. points = PI_TO_POINT( value );
  36. } else if ( data.endsWith( "dd" ) ) {
  37. double value = data.left( data.length() - 4 ).toDouble();
  38. points = DD_TO_POINT( value );
  39. } else if ( data.endsWith( "cc" ) ) {
  40. double value = data.left( data.length() - 4 ).toDouble();
  41. points = CC_TO_POINT( value );
  42. } else {
  43. points = 12;
  44. qDebug( "unknown unit %s", qPrintable( data ) );
  45. }
  46.  
  47. return points;
  48. }
To copy to clipboard, switch view to plain text mode