Bug 30200 - Cannot set italic slant on mac with quartz font backend
Summary: Cannot set italic slant on mac with quartz font backend
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: quartz font backend (show other bugs)
Version: 1.10.0
Hardware: x86-64 (AMD64) Mac OS X (All)
: medium normal
Assignee: Vladimir Vukicevic
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-15 00:10 UTC by Igor Nikitin
Modified: 2010-09-16 06:38 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
result file (313 bytes, image/png)
2010-09-15 00:43 UTC, Igor Nikitin
Details

Description Igor Nikitin 2010-09-15 00:10:26 UTC
#include <cairo/cairo.h>

int main( int argc, char** argv )
{
    cairo_surface_t* surface    = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, 40, 15 );
    cairo_t*         target     = cairo_create( surface );

    cairo_set_font_size( target, 12 );
    cairo_select_font_face(
        target,
        "Lucida Grande", // Default font on mac
        CAIRO_FONT_SLANT_ITALIC,
        CAIRO_FONT_WEIGHT_NORMAL );

    cairo_set_source_rgb( target, 0, 0, 0 );

    cairo_move_to( target, 0, 12 );
    cairo_show_text( target, "TEST" );
    cairo_stroke( target );

    cairo_surface_write_to_png( surface, "/Users/igor/test.png" );

    return 0;
}

cairo was builded with such flags:

./configure --disable-xlib --disable-ft --disable-dependency-tracking --enable-quartz=yes --enable-quartz-font=yes
Comment 1 Igor Nikitin 2010-09-15 00:43:52 UTC
Created attachment 38714 [details]
result file
Comment 2 Andrea Canciani 2010-09-16 03:02:13 UTC
The default "Lucida Grande" available on MacOS X has no italic variant.
To confirm this look for Lucida Grande in Font Book or write "TEST" in TextEdit, set its font to Lucida Grande and try to make it Italic.

If you want to use SLANT_ITALIC, you need a font which actually has an italic shape.
(Please notice that some fonts have oblique style instead of italic and the quartz font backend considers them to be different).
Comment 3 Igor Nikitin 2010-09-16 04:52:22 UTC
Thanks for reply, whether it is possible to check up presence of the necessary font somehow?

cairo_select_font_face(
    target,
    "Lucida Grande", // Default font on mac
    CAIRO_FONT_SLANT_ITALIC,
    CAIRO_FONT_WEIGHT_NORMAL );

cairo_status_t status = cairo_status( mpTarget );

// Here status == CAIRO_STATUS_SUCCESS
Comment 4 Andrea Canciani 2010-09-16 06:13:20 UTC
(In reply to comment #3)
> Thanks for reply, whether it is possible to check up presence of the necessary
> font somehow?
Cairo does its best to provide a font that looks like the one you asked for, but will fallback to less and less similar fonts, ending with "Helvetica" (normal) if it can't find what you were asking for.
If you want to make sure the font will be the one you specified, you should probably use CGFontCreateWithFontName to create the CGFont and cairo_quartz_font_face_create_for_cgfont to use it within cairo.
Comment 5 Igor Nikitin 2010-09-16 06:38:13 UTC
(In reply to comment #4)
> If you want to make sure the font will be the one you specified, you should
> probably use CGFontCreateWithFontName to create the CGFont and
> cairo_quartz_font_face_create_for_cgfont to use it within cairo.

thanks


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.