From: Tony G. <Ton...@Su...> - 2003-04-29 16:46:19
|
Jesper Stigberg wrote at 25 Apr 2003 16:50:25 +0200: > Sorry for the late reply. That's okay. I've only just got back from the second half of my vacation. > Tony Graham wrote: > > Are you able to contribute your code to xmlroff or PangoPDF? > > > > Yes, as soon as I have some more time and the code is in reasonable shape I will. Great. > Perhaps the best thing would be to write the 'screen renderer' in a cross > platform tool kit (wxWindows,QT,GTK+) and use a pango backend based on > FT2/fontconfig. There is a QT example in the core Pango examples that may be useful to you. ... > > Now that none of area-to-pdf uses PDFlib, it is also possible to break > > up area-to-pdf and put each area type's code into the area type's > > implementation of the currently unused 'draw' function of FoArea. > > Is this something you are planning todo in the nearest future? It's actually something that I've wanted to do for a long time but haven't > And now ower to something completely different. > > *** If I understand xmlroff correctly you are using pt as 'device-unit'. This > works ok when using pangopdflib since it too (I assume) use pt as > unit, but my pango-win32 backend use pixel as unit. The result of > this is that all lengths/widths/heights are sometimes measured in > pixel (when they are 'received' from pango) and sometimes in > pt. It's not possible to know when to convert from pt to px and > when not to do it. Yes, xmlroff uses pt as the 'device-unit'; i.e., it converts all dimensions in the FO expressions into points. I haven't looked at the Pango Win32 backend, but Pango uses 1/1024 pt as a 'Pango Unit', and defines PANGO_SCALE to simplify converting points to Pango units. Pango uses Pango units except when it doesn't; e.g. for font sizes. Unfortunately, the Pango functions just use 'int' for all dimensions rather than defining a type for Pango units. (Actually, PangoGlyphUnit is defined in pango-glyph.h but is mostly only used in doc comments.) > I can see two solutions to this: > > 1. All pango-backends compatible with xmlroff must use pt as a unit. > > 2. Use a 'scale' in xmlroff to convert to pango-device-units, or convert from > pango-device-units to xmlroff-device-units. Or: 3. Require the child types of FoDoc (wish I had a better name for it) to handle the conversion from points (i.e., xmlroff units) to Pango backend units. For example, the current fo_doc_pdflib_render_layout() code does the multiplication by PANGO_SCALE to convert xmlroff units to Pango units. And, having complained about Pango, it now seems that xmlroff should define and use a typedef for xmlroff units to save people from repeating your confusion. > 1. will loose precision and will not be compatible with: > http://developer.gnome.org/doc/API/2.0/pango/pango-Glyph-Storage.html#PangoGlyphUnit > > 2. seems the way to do it. I don't know if there is an API in pango that lets > you express the device-unit in a 'known' unit, i.e. 'pango_deviceunit_to_twips' > etc. If not, the 'scale' has to be set explicit by the 'client' of xmlroff/libfo. In theory, the FT2 backend requires you to specify the resolution when creating a PangoContext (or a PangoFT2Context), but the call to FT_Set_Char_Size() in pangoft2.c shows that the resolution isn't really used. Also, the XSL Recommendation errata says that 1 px = 1/96 inch. Regards, Tony Graham ------------------------------------------------------------------------ XML Technology Center - Dublin Sun Microsystems Ireland Ltd Phone: +353 1 8199708 Hamilton House, East Point Business Park, Dublin 3 x(70)19708 |