Re: Pango and non-system fonts



On Thu, 2007-08-23 at 14:08 -0400, Mike Branciforte wrote:
> On 8/22/07, Behdad Esfahbod <behdad behdad org> wrote:
> > On Wed, 2007-08-22 at 11:55 -0400, Mike Branciforte wrote:
> > > We are exploring the possibility of using Cairo+Pango to render pages
> > > from a PDF document.
> >
> > You don't need / shouldn't use pango for rendering PDF.  Pango is used
> > to convert characters to glyphs and to lay text out.  PDF on the other
> > hand, includes layed-out glyphs.  Just show it, using
> > cairo_show_glyphs()
> 
> You lost me. Where are the "layed-out glyphs" in this PDF fragment
> that would show the string "Where are the glyphs?" in a PDF viewer?

So, Owen already answered this elegantly.  I'll just add a few words to
it.


> q
> BT
> 50 792 Td
> 0 -18 Td
> /F1 12 Tf
> (Where are the glyphs?)Tj
> ET
> Q

The (Where are the glyphs) bytes are neither characters, nor glyphs, but
they do choose glyphs, in a  font-specific way described in the PDF
standard.  Try producing a PDF with the ligature for the 'fi' sequence
and see how it's not human-readable anymore.  Read the PDF standard Text
chapter and you'll get it all.  I summarized some of it a while back, it
may help:

http://lists.cairographics.org/archives/cairo/2007-February/009452.html

Also, the Tj operator can be best thought of as an optimization for the
more general text operators, that computes the position of glyphs based
on *natural advance width* of the glyphs, as defined in the PDF font
structure (not the font file).


> It seems that in order to use cairo_show_glyphs() then I would have to
> create an array of glyphs, one "glyph" for each character in the
> phrase "Where are the glyphs?"? That means I would have to compute the
> x and y position for each glyph? Sounds like a lot of work. Am I
> missing something?

It's not really a lot of work.  If you have the width array, glyph
position computing is as trivial as:

  glyph[i].x = glyph[i-1].x + width[glyph[i].index];
  glyph[i].y = glyph[i-1].y;


> Mike
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759






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