|
List Info
Thread: Pango and non-system fonts
|
|
| Pango and non-system fonts |

|
2007-08-22 10:55:47 |
We are exploring the possibility of using Cairo+Pango to
render pages
from a PDF document. Does Pango have an API for specifying
fonts that
are not installed in the runtime system? For example, PDF
documents
often contain embedded fonts. We can programmatically
extract the
embedded font from a PDF document. How can we use this font
to render
text with Pango? It appears to us that the Pango API only
allows the
client application to specify fonts that are installed on
the system.
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |
  Canada |
2007-08-22 14:23:11 |
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()
> Does Pango have an API for specifying fonts that
> are not installed in the runtime system?
Not yet. See:
http
://bugzilla.gnome.org/show_bug.cgi?id=347237
> For example, PDF documents
> often contain embedded fonts. We can programmatically
extract the
> embedded font from a PDF document. How can we use this
font to render
> text with Pango? It appears to us that the Pango API
only allows the
> client application to specify fonts that are installed
on the system.
You don't need pango. Create a FT_Face using
FT_New_Memory_Face(),
create a cairo_scaled_font_t from it using
cairo_ft_font_face_create_for_ft_face(), install the font
using
cairo_set_font_face(), and draw glyphs using
cairo_show_glyphs().
--
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
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |

|
2007-08-23 13:08:28 |
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?
q
BT
50 792 Td
0 -18 Td
/F1 12 Tf
(Where are the glyphs?)Tj
ET
Q
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?
Mike
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |

|
2007-08-24 07:32:57 |
On 8/23/07, Mike Branciforte <branciforte.m gmail.com> 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?
>
> q
> BT
> 50 792 Td
> 0 -18 Td
> /F1 12 Tf
> (Where are the glyphs?)Tj
> ET
> Q
>
> 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?
The above is not really a request to draw the string
"Where are the
glyphs?" It's actually a request to display particular
glyphs from the
font in a way that is precisely defined by the PDF standard.
It just
so happens that way that glyph indices are encoded happens
to be
human-readable. That may sound like a technical detail, but
it becomes
a lot more evident when you have text where the characters
and glyphs
aren't 1:1 - as is common for many languages.
Even for English, you can have PDF files where the encoding
of the
glyphs doesn't show look like readable text in the file. The
only way
to correctly interpret a PDF file is to follow the encoding
and glyph
layout rules in the spec. And so, yes, you need to manually
position
your glyphs, and it is quite a bit of work to do it all
correctly.
- Owen
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |
  United States |
2007-08-24 07:28:41 |
On Thu, 2007-08-23 at 14:08 -0400, Mike Branciforte wrote:
> 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?
Have you considered looking at Poppler to find out how it
uses Cairo to
display PDFs?
http://poppler.freede
sktop.org/
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |
  Canada |
2007-08-24 18:21:04 |
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/c
airo/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
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |

|
2007-08-30 10:03:55 |
All of this has been very helpful, thanks. Now back to my
original
post. If and when Pango does support non-system fonts,
i.e.,
http
://bugzilla.gnome.org/show_bug.cgi?id=347237
would that circumvent the manual glyph positioning required
to set
text with only Cairo? It would be really cool to be able to
do
(speaking in pseudo-code)
setFont();
moveto()
showString()
Any hope for this in the near future? Or is text just to
darn complicated?
Thanks again for the helpful responses. I'll be digging back
into the
PDF spec to better understand the text operators.
Mike
On 8/24/07, Behdad Esfahbod <behdad behdad.org> wrote:
> 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/c
airo/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
>
>
>
>
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
| Re: Pango and non-system fonts |
  Canada |
2007-09-01 23:45:28 |
On Thu, 2007-08-30 at 11:03 -0400, Mike Branciforte wrote:
> All of this has been very helpful, thanks. Now back to
my original
> post. If and when Pango does support non-system fonts,
i.e.,
>
> http
://bugzilla.gnome.org/show_bug.cgi?id=347237
>
> would that circumvent the manual glyph positioning
required to set
> text with only Cairo?
No. PDF has glyph positions fixed into it.
> It would be really cool to be able to do
> (speaking in pseudo-code)
>
> setFont();
> moveto()
> showString()
>
> Any hope for this in the near future?
You can do this with Poppler. Pango is the wrong library to
look into.
> Or is text just to darn complicated?
Text is too darn complicated, but this is not an example of
it. Glyph
positioning that is just adding numbers is very trivial
compared to all
the shaping and other stuff that pango does.
> Thanks again for the helpful responses. I'll be digging
back into the
> PDF spec to better understand the text operators.
>
> Mike
behdad
> On 8/24/07, Behdad Esfahbod <behdad behdad.org> wrote:
> > 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/c
airo/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
> >
> >
> >
> >
--
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
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
|
|
[1-8]
|
|