From: Jesper S. <je...@no...> - 2003-04-30 11:58:27
|
Tony Graham wrote: .... > > > > *** 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. I think that this is the problem. From: http://developer.gnome.org/doc/API/2.0/pango/pango-Glyph-Storage.html#PangoGlyphUnit "...The PangoGlyphUnit type is used to store dimensions within Pango. Dimensions are stored in 1/PANGO_SCALE of a device unit. (A device unit might be a pixel for screen display, or a point on a printer.)..." note the "...(A device unit might be a pixel for screen display, or a point on a printer.)..." i.e. a 'device-unit' may be a pt, but it does not have to. >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. I don't think this will work. Consider this snippet from fo-block-area.c: void fo_block_area_new(...) { ... pango_layout_get_extents (pango_layout, NULL, &logical); fo_area_area_set_height (*new_area, logical.height / PANGO_SCALE + border_before_width + padding_before + border_after_width + padding_after); ... } If the pango version in use uses pt as 'device-unit', all is fine. But if it uses another unit we have a mix of 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. Note that in fo-expr-eval.c pt==px. #define POINT2DEVICE(x) x #define PIXEL2DEVICE(x) x Do you want me to file a bug? Regards, Jesper. |