Synthesizing fonts using Cairo/Pango

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

Synthesizing fonts using Cairo/Pango

Carl Hetherington-2
Hi all,

I am writing text to a Cairo RGB24 ImageSurface using code along the lines
of

FcConfigAppFontAddFile (..., "Arial.ttf");

auto surface = Cairo::ImageSurface::create (...);
auto context = Cairo::Context::create (surface);
auto layout = Pango::Layout::create (context);
Pango::FontDescription font ("Arial");
layout->set_font_description (font);
layout->set_markup ("<span style=\"italic\">Hello world</span>");
layout->add_to_cairo_context (context);

Is there any way I can get Pango/Cairo/whoever to synthesize italic/bold
fonts for me if I only supply a "regular" font file?

As a complete punt I tried:

auto ff = context->get_font_face();
cairo_ft_font_face_set_synthesize (ff->cobj(), CAIRO_FT_SYNTHESIZE_OBLIQUE | CAIRO_FT_SYNTHESIZE_BOLD);

but no joy.  Any tips?

Thanks very much,
Carl
_______________________________________________
gtk-i18n-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synthesizing fonts using Cairo/Pango

Behdad Esfahbod-3
pangocairo is supposed to do that automatically.  Is this on Windows / Mac by any chance?

On Mon, Jul 17, 2017 at 3:46 PM, Carl Hetherington <[hidden email]> wrote:
Hi all,

I am writing text to a Cairo RGB24 ImageSurface using code along the lines
of

FcConfigAppFontAddFile (..., "Arial.ttf");

auto surface = Cairo::ImageSurface::create (...);
auto context = Cairo::Context::create (surface);
auto layout = Pango::Layout::create (context);
Pango::FontDescription font ("Arial");
layout->set_font_description (font);
layout->set_markup ("<span style=\"italic\">Hello world</span>");
layout->add_to_cairo_context (context);

Is there any way I can get Pango/Cairo/whoever to synthesize italic/bold
fonts for me if I only supply a "regular" font file?

As a complete punt I tried:

auto ff = context->get_font_face();
cairo_ft_font_face_set_synthesize (ff->cobj(), CAIRO_FT_SYNTHESIZE_OBLIQUE | CAIRO_FT_SYNTHESIZE_BOLD);

but no joy.  Any tips?

Thanks very much,
Carl
_______________________________________________
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
|  
Report Content as Inappropriate

Re: Synthesizing fonts using Cairo/Pango

Carl Hetherington-2
Hi Behdad,

This is on Ubuntu 16.04.  It works fine if I remove the
FcConfigAppFontAddFile.  I'm happy to build Pango/Cairo from source and
do any debugging that would help.

Thank you,
Carl

On Tue, 18 Jul 2017, Behdad Esfahbod wrote:

> pangocairo is supposed to do that automatically.  Is this on Windows / Mac by any chance?
>
> On Mon, Jul 17, 2017 at 3:46 PM, Carl Hetherington <[hidden email]> wrote:
>       Hi all,
>
>       I am writing text to a Cairo RGB24 ImageSurface using code along the lines
>       of
>
>       FcConfigAppFontAddFile (..., "Arial.ttf");
>
>       auto surface = Cairo::ImageSurface::create (...);
>       auto context = Cairo::Context::create (surface);
>       auto layout = Pango::Layout::create (context);
>       Pango::FontDescription font ("Arial");
>       layout->set_font_description (font);
>       layout->set_markup ("<span style=\"italic\">Hello world</span>");
>       layout->add_to_cairo_context (context);
>
>       Is there any way I can get Pango/Cairo/whoever to synthesize italic/bold
>       fonts for me if I only supply a "regular" font file?
>
>       As a complete punt I tried:
>
>       auto ff = context->get_font_face();
>       cairo_ft_font_face_set_synthesize (ff->cobj(), CAIRO_FT_SYNTHESIZE_OBLIQUE | CAIRO_FT_SYNTHESIZE_BOLD);
>
>       but no joy.  Any tips?
>
>       Thanks very much,
>       Carl
>       _______________________________________________
>       gtk-i18n-list mailing list
>       [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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Synthesizing fonts using Cairo/Pango

Behdad Esfahbod-3
On Tue, Jul 18, 2017 at 1:32 AM, Carl Hetherington <[hidden email]> wrote:
Hi Behdad,

This is on Ubuntu 16.04.  It works fine if I remove the
FcConfigAppFontAddFile.

Humm . I wouldn't have expected that.

 
  I'm happy to build Pango/Cairo from source and
do any debugging that would help.

Try calling FcInitLoadConfigAndFonts first for example...
 
Thank you,
Carl

On Tue, 18 Jul 2017, Behdad Esfahbod wrote:

> pangocairo is supposed to do that automatically.  Is this on Windows / Mac by any chance?
>
> On Mon, Jul 17, 2017 at 3:46 PM, Carl Hetherington <[hidden email]> wrote:
>       Hi all,
>
>       I am writing text to a Cairo RGB24 ImageSurface using code along the lines
>       of
>
>       FcConfigAppFontAddFile (..., "Arial.ttf");
>
>       auto surface = Cairo::ImageSurface::create (...);
>       auto context = Cairo::Context::create (surface);
>       auto layout = Pango::Layout::create (context);
>       Pango::FontDescription font ("Arial");
>       layout->set_font_description (font);
>       layout->set_markup ("<span style=\"italic\">Hello world</span>");
>       layout->add_to_cairo_context (context);
>
>       Is there any way I can get Pango/Cairo/whoever to synthesize italic/bold
>       fonts for me if I only supply a "regular" font file?
>
>       As a complete punt I tried:
>
>       auto ff = context->get_font_face();
>       cairo_ft_font_face_set_synthesize (ff->cobj(), CAIRO_FT_SYNTHESIZE_OBLIQUE | CAIRO_FT_SYNTHESIZE_BOLD);
>
>       but no joy.  Any tips?
>
>       Thanks very much,
>       Carl
>       _______________________________________________
>       gtk-i18n-list mailing list
>       [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




--

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

Re: Synthesizing fonts using Cairo/Pango

Carl Hetherington-2
Hi Behdad,

[snip]

> Try calling FcInitLoadConfigAndFonts first for example...

Many, many thanks: using FcInitLoadConfig() instead of FcConfigCreate()
appears to have fixed it!

All the best,
Carl


>  
>       Thank you,
>       Carl
>
>       On Tue, 18 Jul 2017, Behdad Esfahbod wrote:
>
>       > pangocairo is supposed to do that automatically.  Is this on Windows / Mac by any chance?
>       >
>       > On Mon, Jul 17, 2017 at 3:46 PM, Carl Hetherington <[hidden email]> wrote:
>       >       Hi all,
>       >
>       >       I am writing text to a Cairo RGB24 ImageSurface using code along the lines
>       >       of
>       >
>       >       FcConfigAppFontAddFile (..., "Arial.ttf");
>       >
>       >       auto surface = Cairo::ImageSurface::create (...);
>       >       auto context = Cairo::Context::create (surface);
>       >       auto layout = Pango::Layout::create (context);
>       >       Pango::FontDescription font ("Arial");
>       >       layout->set_font_description (font);
>       >       layout->set_markup ("<span style=\"italic\">Hello world</span>");
>       >       layout->add_to_cairo_context (context);
>       >
>       >       Is there any way I can get Pango/Cairo/whoever to synthesize italic/bold
>       >       fonts for me if I only supply a "regular" font file?
>       >
>       >       As a complete punt I tried:
>       >
>       >       auto ff = context->get_font_face();
>       >       cairo_ft_font_face_set_synthesize (ff->cobj(), CAIRO_FT_SYNTHESIZE_OBLIQUE | CAIRO_FT_SYNTHESIZE_BOLD);
>       >
>       >       but no joy.  Any tips?
>       >
>       >       Thanks very much,
>       >       Carl
>       >       _______________________________________________
>       >       gtk-i18n-list mailing list
>       >       [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
>
>
>
>
> --
> 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
|  
Report Content as Inappropriate

Re: Synthesizing fonts using Cairo/Pango

Behdad Esfahbod-3
On Wed, Jul 19, 2017 at 2:13 AM, Carl Hetherington <[hidden email]> wrote:
Hi Behdad,

[snip]

> Try calling FcInitLoadConfigAndFonts first for example...

Many, many thanks: using FcInitLoadConfig() instead of FcConfigCreate()
appears to have fixed it!

See!  You didn't include the FcConfigCreate() in your snippet; that's why I found it strange ;).
 
All the best,
Carl


>  
>       Thank you,
>       Carl
>
>       On Tue, 18 Jul 2017, Behdad Esfahbod wrote:
>
>       > pangocairo is supposed to do that automatically.  Is this on Windows / Mac by any chance?
>       >
>       > On Mon, Jul 17, 2017 at 3:46 PM, Carl Hetherington <[hidden email]> wrote:
>       >       Hi all,
>       >
>       >       I am writing text to a Cairo RGB24 ImageSurface using code along the lines
>       >       of
>       >
>       >       FcConfigAppFontAddFile (..., "Arial.ttf");
>       >
>       >       auto surface = Cairo::ImageSurface::create (...);
>       >       auto context = Cairo::Context::create (surface);
>       >       auto layout = Pango::Layout::create (context);
>       >       Pango::FontDescription font ("Arial");
>       >       layout->set_font_description (font);
>       >       layout->set_markup ("<span style=\"italic\">Hello world</span>");
>       >       layout->add_to_cairo_context (context);
>       >
>       >       Is there any way I can get Pango/Cairo/whoever to synthesize italic/bold
>       >       fonts for me if I only supply a "regular" font file?
>       >
>       >       As a complete punt I tried:
>       >
>       >       auto ff = context->get_font_face();
>       >       cairo_ft_font_face_set_synthesize (ff->cobj(), CAIRO_FT_SYNTHESIZE_OBLIQUE | CAIRO_FT_SYNTHESIZE_BOLD);
>       >
>       >       but no joy.  Any tips?
>       >
>       >       Thanks very much,
>       >       Carl
>       >       _______________________________________________
>       >       gtk-i18n-list mailing list
>       >       [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
>
>
>
>
> --
> 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
Loading...