Re: Help needed using different fonts

Behdad Esfahbod <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
You should ask on the gtk-i18n mailing list.   The Windows backend is just not
that good...

behdad

On 08/29/11 09:00, Deepak Kumar JAIN wrote:
> Hello Maarten
> 
> I am working with MS Visual Studio 2008 on 64 bit windows with cairo and pango.
> 
> This is the following code.
> /
> draw_text (cairo_t *cr)
> {
> #define RADIUS 150
> #define N_WORDS 10
> #define FONT "Monotype Corsiva,27"
>   PangoLayout *layout;
>   PangoFontDescription *desc;
>   int i;
>   /* Center coordinates on the middle of the region we are drawing
>    */
>   /* Create a PangoLayout, set the font and text */
>   layout = pango_cairo_create_layout (cr);
>   pango_layout_set_text (layout, "Text", -1);
>   desc = pango_font_description_from_string (FONT);
>   pango_layout_set_font_description (layout, desc);
>   pango_font_description_free (desc);
>   /* Draw the layout N_WORDS times in a circle */
>       int width, height;
>       double red;
>       cairo_save (cr);
>       /* Gradient from red at angle == 60 to blue at angle == 240 */
>       cairo_set_source_rgb (cr, 1, 0, 0);
>       /* Inform Pango to re-layout the text with the new transformation */
>       pango_cairo_update_layout (cr, layout);
>       pango_layout_get_size (layout, &width, &height);
>       cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
>       pango_cairo_show_layout (cr, layout);
>       cairo_restore (cr);
>   /* free the layout object */
>   g_object_unref (layout);
> }
> int main (int argc, char **argv)
> {
>   cairo_t *cr;
>   char *filename;
>   cairo_status_t status;
>   cairo_surface_t *surface;
>   filename = "montotype1.png";
>   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
>                                         2 * RADIUS, 2 * RADIUS);
>   cr = cairo_create (surface);
>   cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
>   cairo_paint (cr);
>   draw_text (cr);
>   cairo_destroy (cr);
>   status = cairo_surface_write_to_png (surface, filename);
>   cairo_surface_destroy (surface);
>   if (status != CAIRO_STATUS_SUCCESS)
>     {
>       g_printerr ("Could not save png to '%s'\n", filename);
>       return 1;
>     }
>   cin.get();
>   return 0;
> }/
> 
> Working with Times Roman, I used ",;" and it worked but when I try Monotype
> Corsiva, it throws the same warning as
> 
> PANGO Warning: Couldn't load font " Monotype Corsiva -not Rotated 27", falling
> back to "Sans Not -Rotated 27" , expect ugly output.
> 
> Thanks,
> Deepak 
> 
> 
> 
> 
> On Mon, Aug 29, 2011 at 2:47 PM, Maarten Bosmans <[email protected]
> <mailto:[email protected]>> wrote:
> 
>     2011/8/29 Deepak Kumar JAIN <[email protected]
>     <mailto:[email protected]>>:
>     > Thanks Maarten;
>     >
>     > But still some of the fonst dont work and I get the same warning
>     >
>     > fonts like Monotype Corsiva. What Should I do for those fonts?
> 
>     So it was fixed for Times New Roman, but not for Monotype Corsiva?
>     Weird. What did you do to make times work?
>     Did you use pango_font_description_set_family?
> 
>     Please provide some more background info of the code that fails, error
>     messages and info on the platform you are on.
> 
>     Maarten
> 
>     > On Mon, Aug 29, 2011 at 11:11 AM, Maarten Bosmans <[email protected]
>     <mailto:[email protected]>>
>     > wrote:
>     >>
>     >>
>     >>
>     http://blogs.operationaldynamics.com/andrew/software/java-gnome/use-comma-in-font-description
>     >>
>     >> 2011/8/29 Deepak Kumar JAIN <[email protected]
>     <mailto:[email protected]>>:
>     >> >
>     >> > Hello All,
>     >> >
>     >> > I am new to Cairo Graphics. I heard about cairoGraphics from a developer
>     >> > at
>     >> > SHARP labs.
>     >> >
>     >> > I am developing a text manipulation plugin which do several things like
>     >> > underline, strikeout text, etc.
>     >> >
>     >> > But I want to write the text in different fints like Times new Roman,
>     >> > Arial
>     >> > , Courier, etc depending on what user prefers. These fonts will be input
>     >> > by
>     >> > the user and then on the basis of input by user, I have to write a text
>     >> > on
>     >> > the image.  But I am not able to write the text with Times New Roman.
>     >> > I am using pango_font_description_from_string(FONT) where FONT is
>     >> > defined as
>     >> > #define FONT "Arial 27". It works for Arial but when I try to use Times
>     >> > New
>     >> > Roman, it says
>     >> > " Pango Warning" couldn't load font Times ", falling back to "Sans not
>     >> > Rotaed 27" , expect ugly output.
>     >> >
>     >> > Please help me in this regard by suggesting how should I proceed?
>     >> >
>     >> > Thanks,
>     >> >
>     >> > Deepak JAIN
>     >> >
>     >> > --
>     >> >
>     >> > Thanks & Regards,
>     >> > Deepak Kumar JAIN
>     >> > Internship student,
>     >> > Orange Labs,France Telecom,
>     >> > Rennes, France
>     >> > Contact: +33(0)6 31 15 44 66 <tel:%2B33%280%296%2031%2015%2044%2066>
>     >> > www.deepakkumarjain.co.cc <http://www.deepakkumarjain.co.cc>
>     >> >
>     >> > "I err therefore I am "- Saint Augustine
>     >> >
>     >> >
>     >> >
>     >> >
>     >> > --
>     >> >
>     >> > Thanks & Regards,
>     >> > Deepak Kumar JAIN
>     >> > Internship student,
>     >> > Orange Labs,France Telecom,
>     >> > Rennes, France
>     >> > Contact: +33(0)6 31 15 44 66 <tel:%2B33%280%296%2031%2015%2044%2066>
>     >> > www.deepakkumarjain.co.cc <http://www.deepakkumarjain.co.cc>
>     >> >
>     >> > "I err therefore I am "- Saint Augustine
>     >> >
>     >> >
>     >> > --
>     >> > cairo mailing list
>     >> > [email protected] <mailto:[email protected]>
>     >> > http://lists.cairographics.org/mailman/listinfo/cairo
>     >> >
>     >
>     >
>     >
>     > --
>     >
>     > Thanks & Regards,
>     > Deepak Kumar JAIN
>     > Internship student,
>     > Orange Labs,France Telecom,
>     > Rennes, France
>     > Contact: +33(0)6 31 15 44 66 <tel:%2B33%280%296%2031%2015%2044%2066>
>     > www.deepakkumarjain.co.cc <http://www.deepakkumarjain.co.cc>
>     >
>     > "I err therefore I am "- Saint Augustine
>     >
>     >
> 
> 
> 
> 
> -- 
> 
> Thanks & Regards,
> Deepak Kumar JAIN
> Internship student,
> Orange Labs,France Telecom,
> Rennes, France
> Contact: +33(0)6 31 15 44 66
> www.deepakkumarjain.co.cc <http://www.deepakkumarjain.co.cc>
> 
> "/I err therefore I am /"- Saint Augustine
>  
> 
> 
> 
> --
> cairo mailing list
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo
--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.