Results 1 to 4 of 4

Thread: Strange Unit em - same as inch? on XSLT-Fo format

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Strange Unit em - same as inch? on XSLT-Fo format

    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 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Strange Unit em - same as inch? on XSLT-Fo format

    1 em represents the width of "m" and its exact value in points depends on the font you choose.

    There's also 1 ex, which is equal to height of "x".

  3. The following user says thank you to jacek for this useful post:

    patrik08 (13th July 2007)

  4. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Strange Unit em - same as inch? on XSLT-Fo format

    Quote Originally Posted by jacek View Post
    1 em represents the width of "m" and its exact value in points depends on the font you choose.
    There's also 1 ex, which is equal to height of "x".
    Ahh... 10em = 10pt depends on the font? i hope true type stay same.... tanks..

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Strange Unit em - same as inch? on XSLT-Fo format

    No, it's like Jacek said. It'll be easier to explain it with ex - if you have a font that is 12pt high then 1ex will be about 8pt. As "m" is the widest character for proportional fonts, the width of "m" will have a larger value (in points) than the width of "i", so you can't just say that your font is "8 points wide" (unless the font is monospaced, like Courier), but you can say that its "m" glyph is 12 points wide.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.