same font looks different X11 and Ghostscript - Xwindows

This is a discussion on same font looks different X11 and Ghostscript - Xwindows ; My application writes text to X11 display and to PostScript output. I want the rendered output by Ghostscript on that same X11 display to look *exactly* (identical pixels) like it does in my X11 app. But even if I use ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: same font looks different X11 and Ghostscript

  1. same font looks different X11 and Ghostscript

    My application writes text to X11 display and to PostScript output. I
    want the rendered output by Ghostscript on that same X11 display to
    look *exactly* (identical pixels) like it does in my X11 app.

    But even if I use exactly the same Type 1 font (Times Roman 18,
    which on my system maps "Nimbus Roman No 9 L" from URW) for
    both X11 and PostScript output, there are noticeable differences,
    especially in the spaces between letters and words, but even in
    the rendering for individual glyphs.

    It's easy to illustrate the discrepancy (this is on Fedora Core 3,
    Xorg 6.8.1.902, GNU Ghostscript 7.07, 100dpi display). Compare:

    % cat hello.ps
    /Times-Roman findfont 18 scalefont setfont
    10 10 moveto (The quick brown fox jumps over the lazy dog.) show
    % gs -g800x50 -sDEVICE=x11 hello.ps

    TO

    % xmessage -fn
    '-urw-nimbus roman no9 l-medium-r-normal--18-0-0-0-p-0-iso8859-1'
    "The quick brown fox jumps over the lazy dog."

    On my system, they're not even close. Larger fonts match a bit better,
    but it's never anywhere near identical.

    Questions:

    1. Is this to be expected? The same Type 1 font will be rendered with
    significant differences by X vs GhostScript? Why? Does the font data
    leave a lot of specifics up to the individual rendering engine?

    2. What are my choices for making Ghostscript and X11 match perfectly
    (or as best as possible)? I'm not wedded to Type 1 fonts or even
    X11 - my app just needs to manipulate text on a display, and then create
    PostScript that when rendered on that display looks the way it did in
    my app. Suggestions (short of embeeding Ghostcript in my app)?

    Thanks,
    -usman




  2. Re: same font looks different X11 and Ghostscript

    Usman Muzaffar wrote:
    > My application writes text to X11 display and to PostScript output. I
    > want the rendered output by Ghostscript on that same X11 display to
    > look *exactly* (identical pixels) like it does in my X11 app.


    I think that different renderers will always use different pixels.
    If not for any other reason, for the font mess of Linux (Unix/X11).
    There are just no fonts that you can 100% rely on. Every distro will
    have their own idea on that, and what to install by default.
    Or even if fonts are there, then gs / acroread / openoffice / kpdf
    will be able to use completely different sets of fonts.
    Maybe you should look into Xprint extension to see if you can
    eliminate double coding of your graphics - once for your X11 app,
    and then for Postscript.
    http://xprint.mozdev.org/docs/Xprint_FAQ.html

    Hope this helps,

    Dušan Peterc
    http://www.arahne.si

  3. Re: same font looks different X11 and Ghostscript

    [Caution: I haven't tried the example, and I'm not expert enough to be
    certain that what I'm saying is right in this particular case, but these
    are my impressions.]

    "Usman Muzaffar" writes:
    > My application writes text to X11 display and to PostScript output. I
    > want the rendered output by Ghostscript on that same X11 display to
    > look *exactly* (identical pixels) like it does in my X11 app.


    [Note that PostScript allows independent horizontal and vertical scaling of
    everything. Unless you ensure that nothing anywhere does any scaling
    (such as "fit to window size" scaling), this could be a cause of things
    looking different.]

    > But even if I use exactly the same Type 1 font (Times Roman 18,
    > which on my system maps "Nimbus Roman No 9 L" from URW) for
    > both X11 and PostScript output, there are noticeable differences,
    > especially in the spaces between letters and words, but even in
    > the rendering for individual glyphs.


    I'm not convinced that you are, in fact, getting exactly the same font
    descriptors. You might want to use a debugger and look at the font table
    entries after they've been loaded in each application to see whether they
    are, in fact, identical.

    > /Times-Roman findfont 18 scalefont setfont


    That will scale some scalable font description to size 18, whereas

    > '-urw-nimbus roman no9 l-medium-r-normal--18-0-0-0-p-0-iso8859-1'


    describes a font to be loaded from a description in a file. In my mind,
    those are not guaranteed to match despite the name similarity.

    It sounds like your app generates a Postscript file. Does it include the
    complete font description in the file, or are you just using a generic font
    name and size and hoping that the displaying program will be able to
    generate/load the same font?


    > 2. What are my choices for making Ghostscript and X11 match perfectly


    If your app, indeed, already includes a complete font description in the
    file, and if that doesn't work, then I think the most likely way to succeed
    is to capture the screen display as an image. As arahne, said, have a look
    at XPrint. Using an image avoids the whole issue of "will rendering
    software 1 produce the same result as rendering software 2". (Of course,
    there would still be the "scale whole document" issue, but presumably
    that's something you could deal with.)
    -WBE

+ Reply to Thread