Need help understanding how things fit together

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help understanding how things fit together

Anthony Kraft
I have been researching text rendering and have read what I can find about Pango, HarfBuzz, and FreeType. However, I cannot seem to put together exactly how these pieces fit together since all explanations are quite high level. I think what would help me the most is to understand what the inputs/outputs are of each layer and how they feed into one another (or possibly where you can skip a layer). 

_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help understanding how things fit together

Behdad Esfahbod-3
On 15-01-20 10:18 AM, Anthony Kraft wrote:
> I have been researching text rendering and have read what I can find about
> Pango, HarfBuzz, and FreeType. However, I cannot seem to put together exactly
> how these pieces fit together since all explanations are quite high level. I
> think what would help me the most is to understand what the inputs/outputs are
> of each layer and how they feed into one another (or possibly where you can
> skip a layer).

I suppose you've read this already:

  http://behdad.org/text/

In short:

  - FreeType, takes a font file and glyph indices, font size, hinting
settings, etc, and outputs bitmap images.  This is called rasterization.
Alternatively, you can just get the glyph vector outline out of FreeType and
do your own rasterization,

  - HarfBuzz, takes Unicode text and font file, font size, etc, and outputs
list glyph indices and positions to show those glyphs.  This is called
shaping.  No rasterization happens whatsoever,

  - Pango, takes maked-up Unicode text and lays it out in a box, using
HarfBuzz and FreeType among a stack of other libraries or alternatives.  This
is called paragraph layout.  It handles things like line breaking, text
selection, etc,

HTH
--
behdad
http://behdad.org/
_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help understanding how things fit together

Anthony Kraft
Very helpful, feel like I'm almost there. 

FT has a function FT_Get_Char_Index to get a glyph index from a unicode char code. Therefore, it seems you can feed Unicode + font file to FT directly and rasterize. What is the benefit of using HarfBuzz to do the unicode to glyph mapping instead of using FT directly?

On Tue, Jan 20, 2015 at 1:39 PM, Behdad Esfahbod <[hidden email]> wrote:
On 15-01-20 10:18 AM, Anthony Kraft wrote:
> I have been researching text rendering and have read what I can find about
> Pango, HarfBuzz, and FreeType. However, I cannot seem to put together exactly
> how these pieces fit together since all explanations are quite high level. I
> think what would help me the most is to understand what the inputs/outputs are
> of each layer and how they feed into one another (or possibly where you can
> skip a layer).

I suppose you've read this already:

  http://behdad.org/text/

In short:

  - FreeType, takes a font file and glyph indices, font size, hinting
settings, etc, and outputs bitmap images.  This is called rasterization.
Alternatively, you can just get the glyph vector outline out of FreeType and
do your own rasterization,

  - HarfBuzz, takes Unicode text and font file, font size, etc, and outputs
list glyph indices and positions to show those glyphs.  This is called
shaping.  No rasterization happens whatsoever,

  - Pango, takes maked-up Unicode text and lays it out in a box, using
HarfBuzz and FreeType among a stack of other libraries or alternatives.  This
is called paragraph layout.  It handles things like line breaking, text
selection, etc,

HTH
--
behdad
http://behdad.org/


_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help understanding how things fit together

Behdad Esfahbod-3
On 15-01-20 11:10 AM, Anthony Kraft wrote:
> FT has a function FT_Get_Char_Index to get a glyph index from a unicode char
> code. Therefore, it seems you can feed Unicode + font file to FT directly and
> rasterize. What is the benefit of using HarfBuzz to do the unicode to glyph
> mapping instead of using FT directly?

HarfBuzz does what's called "complex" shaping.  Ie, if you use
FT_Get_Char_Index, you won't get the correct shapes for Arabic, Indic
languages, Thai, etc.  You won't get things like ligatures, mark positioning,
etc either.

See images here:

  http://goo.gl/2wSRu


--
behdad
http://behdad.org/
_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help understanding how things fit together

Mindaugas Jaunius
Behdad, maybe your presentation using these slides were ever recorded and the video is available somewhere? Also what is the status of harbfbuzz/pango integration to android? I saw you mentioned it in slides.

2015-01-20 21:20 GMT+02:00 Behdad Esfahbod <[hidden email]>:
On 15-01-20 11:10 AM, Anthony Kraft wrote:
> FT has a function FT_Get_Char_Index to get a glyph index from a unicode char
> code. Therefore, it seems you can feed Unicode + font file to FT directly and
> rasterize. What is the benefit of using HarfBuzz to do the unicode to glyph
> mapping instead of using FT directly?

HarfBuzz does what's called "complex" shaping.  Ie, if you use
FT_Get_Char_Index, you won't get the correct shapes for Arabic, Indic
languages, Thai, etc.  You won't get things like ligatures, mark positioning,
etc either.

See images here:

  http://goo.gl/2wSRu


--
behdad
http://behdad.org/
_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list


_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Reply | Threaded
Open this post in threaded view
|

Re: Need help understanding how things fit together

Behdad Esfahbod-3
On 15-01-20 11:40 PM, Mindaugas Jaunius wrote:
> Behdad, maybe your presentation using these slides were ever recorded and the
> video is available somewhere?

Unfortunately the IUC conference is not recorded :(.  I've voiced my opinion
to the organizers.


> Also what is the status of harbfbuzz/pango
> integration to android? I saw you mentioned it in slides.

HarfBuzz has been integrated in the Android platform for many years now, as
part of the platform.  Native apps can ship with their own bundled HarfBuzz
and even Pango.  There are a few example bundlings on github.

I can answer more specific questions more specifically :).

behdad

> 2015-01-20 21:20 GMT+02:00 Behdad Esfahbod <[hidden email]
> <mailto:[hidden email]>>:
>
>     On 15-01-20 11:10 AM, Anthony Kraft wrote:
>     > FT has a function FT_Get_Char_Index to get a glyph index from a unicode char
>     > code. Therefore, it seems you can feed Unicode + font file to FT directly and
>     > rasterize. What is the benefit of using HarfBuzz to do the unicode to glyph
>     > mapping instead of using FT directly?
>
>     HarfBuzz does what's called "complex" shaping.  Ie, if you use
>     FT_Get_Char_Index, you won't get the correct shapes for Arabic, Indic
>     languages, Thai, etc.  You won't get things like ligatures, mark positioning,
>     etc either.
>
>     See images here:
>
>       http://goo.gl/2wSRu
>
>
>     --
>     behdad
>     http://behdad.org/
>     _______________________________________________
>     gtk-i18n-list mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
>
>

--
behdad
http://behdad.org/
_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list