Re: [gnome-print] Serializing a PangoFont



[ I'm phrasing this reply in terms of Pango HEAD and fontconfig,
  since that's what any development targetted beyond the next
  few months will need to deal with. I've also CC'ed Keith Packard
  in case he has any relevant thoughts ]

Chema Celorio <chema@ximian.com> writes:

> I worked a little bit more this weekend on the Pango API for
> gnome-print. I still don't have a clear understanding of how the API is
> going to look, since i don't know if the apps will give gnome-print a
> PangoLayout, a PangoLayoutLine or a PangoLayoutRun, or if the API will
> allow all of this to be printed. I'll think everything will fall into
> its place as i continue with this, my current short term objective is
> getting gedit to print the paps test utf8 file even if the code is in
> the wrong place and ugly, this will allow me to better understand what
> apps might need.
> 
> Anyway, I am currently stuck with trying to serialize a PangoFont. The
> way things work right now inside gnome-print, all the drawing calls that
> the application is sending gnome-print are recorded in a metafile and
> played back later. However, I have not been able to figure out a nice
> way of serializing a PangoFont. Right now I am converting the
> PangoLayout into a list of a struct that contqains { glyph, x, y &
> PangoFont} (the code is both in testprint and inside gnome-print).

The right way to serialize a PangoFont for the Xft or FT2 backends
is probably to store the "relevants parts" of the FcPattern for the
face, then reconsistitute the font from that later.

But what is relevant really depends on what the metafile is going
to be used for and how long it will be stored.

 - Do you want the exact same font file on disk?
 - Do you want a font with exactly the same name and an error
   if it doesn't exist?
 - Do you want the closest matching font?
 - Do you want the font that would have been loaded if the
   same PangoFontDescription 

If you want close to pixel-for-pixel results, and you want to
transport a metafile file between computers, then the only real
way you are going to do that is by embedding the font information
inside your file.

> The only viable alternative that i see right now is getting a
> PangoFontDescription from the font and when playing back the stream
> create a font from a description, however this is currently not possible
> unless i create a PangoLayout again, but i already know the layout I
> have the glyph and the position.

 pango_context_load_font (context, pango_font_describe(font)) 

Should give you a font that's reasonably similar to the original font.
(Unless the font is missing, in which case it will give you a 
"random" other font without any indication of error; one of the
deficiencies of FontConfig.)

Note, however, that there is no guarantee at all that the glyph indices in 
the new font will correspond to the original glyph indices in the
PangoGlyphString. 

(Even if the filename is the same, there is no guarantee; a new version
of the font could rearrange the glyphs.)

Really, unless you are sure that you are going to have *exactly* the
same font, you need to redo the layout.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]