[gl2ps] Translate pixels to points

Pantxo Diribarne pantxo.diribarne at gmail.com
Thu Oct 27 10:26:28 CEST 2016


I'd like to come back to this discussion in regard to the discrepancy
>>> between SVG and EPS output size: from a M-by-N *pixels* opengl viewport,
>>> gl2ps draws a M-by-N *points* figure for EPS format and a M-by-N *pixels*
>>> figure for SVG format.
>>> I think one of those should be fixed.
>>>
>>> As I said in the beginning of the discussion, I'd vote for introducing a
>>> new "resolution" (default 72 pixels per inch) argument for gl2psBeginPage.
>>> This would provide a way to translate screen coordinates into whatever
>>> units we like in gl2ps.
>>>
>>> Pantxo
>>>
>>>
>>> I like your suggestion. That would simplify things. Are you working on a
>>> patch?
>>>
>>> Since "points" has a different meaning for Linux, Windows (96 ppi), and
>>> Mac (72 ppi), should the default change with os? Or is the ppi always 72
>>> for pdf?
>>>
>>> Ben
>>>
>>
>> Why does the screen resolution (hardware+software) have to be OS specific
>> (pure software)?
>>
>> As for the patch, I'd like to hear opinions before going ahead. In
>> particular the approach I propose will change the signature of
>> gl2psBeginPage which will force every user to change their code. Another
>> less invasive option would be adding a "gl2psScreenResolution" function.
>> The drawback is that such parameter has no reason to be changed in the
>> middle of a drawing so having it fixed from the start seems more consistent.
>>
>> Pantxo
>>
>
> Ben, now I think I understand what you meant. Actually it is "pixel" that
> have a different meaning for different systems: some use screen(physical)
> pixels (linux) and others use device independent pixels (Mac).
> E.g in Mac carbon API if you request a 10-by-10 pixels window you will
> obtain a 20-by-20 physical pixels window on retina (HDPI) screens. This is
> untrue for the opengl API which always works with physical pixels. See e.g.
> http://blog.qt.io/blog/2013/04/25/retina-display-support-for
> -mac-os-ios-and-x11/
>
> This tells us that a "resolution" argument should be expressed in
> physical(screen)-pixels per inch.
>
> Pantxo
>

I went ahead and produced a patch (see attached). I chose the invasive
approach (adding an argument to gl2psBeginPage) since the resolution must
be known at the very beginning of the process.

Pantxo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gl2ps/attachments/20161027/0196e1fe/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resolution3.patch
Type: text/x-diff
Size: 8410 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gl2ps/attachments/20161027/0196e1fe/attachment.patch>