Re: How to enable cairo in Windows?

Theo Veenker <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On 10/31/2011 10:41 PM, Sverre Stausland wrote:
> Hi cairo users,
>
> I am trying to find a way to enable cairo for Windows. I am using
> Windows XP SP3, and my incentive for enabling cairo is that it is
> required for using the Cairo package in R
> (http://www.rforge.net/Cairo/).
>
> According to http://www.cairographics.org/download/ under 'Windows',
> cairo can be enabled in the following way:
>
> "
> Go to official GTK+ for Windows page.

I just tried to create PDF output using cairo+pango and the Doulos SIL
font under windows. With the binaries from
http://ftp.gnome.org/pub/gnome/binaries/win32[/dependencies] it
works fine. So it's probaly that the pdf backend in R's Cairo package
isn't compiled with all the options you require. I suppose you have
to talk to the developer of that package. Otherwise I have no clue.

I case you want to try if the setup you have works at all under windows
I attached the test thingy. If desired I can send you the exe.

Theo

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
ipa-pdf-test.c (text/x-csrc, 2 KB)
// linux:
// gcc `pkg-config --cflags --libs pangocairo` ipa-pdf-test.c -o ipa-pdf-test

// win32:
// WIN32_PKG=$HOME/local/win32
// INCDIRS="-I$WIN32_PKG/include/pango-1.0 -I$WIN32_PKG/include/cairo -I$WIN32_PKG/include/glib-2.0 -I$WIN32_PKG/lib/glib-2.0/include"
// LIBDIRS="-L$WIN32_PKG/lib"
// LIBS="-lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0"
// i586-mingw32msvc-gcc ipa-pdf-test.c -oipa-pdf-test.exe $INCDIRS $LIBDIRS $LIBS

#include <stdio.h>
#include <cairo.h>
#include <cairo-pdf.h>
#include <pango/pangocairo.h>

int main(int argc, char *argv[])
{
    cairo_t *cr;
    cairo_surface_t *surface;
    PangoFontMap* fontmap;
    PangoContext *pangocontext;
    PangoLayout *pangolayout;
    PangoFontDescription* pangofd;

    surface = cairo_pdf_surface_create("ipa-pdf-test.pdf", 400, 200);
    cr = cairo_create(surface);
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
    cairo_paint (cr);

    pangofd = pango_font_description_new();
    pango_font_description_set_family_static(pangofd, "Doulos SIL");
    pango_font_description_set_absolute_size(pangofd, 50 * PANGO_SCALE);
    pango_font_description_set_style(pangofd, PANGO_STYLE_NORMAL);
    pango_font_description_set_weight(pangofd, PANGO_WEIGHT_NORMAL);
    pango_font_description_set_variant(pangofd, PANGO_VARIANT_NORMAL);
    pango_font_description_set_stretch(pangofd, PANGO_STRETCH_NORMAL);

    fontmap = pango_cairo_font_map_get_default();
    pangocontext = 
    	pango_cairo_font_map_create_context((PangoCairoFontMap*)fontmap);
    pango_context_set_font_description(pangocontext, pangofd);
    pangolayout = pango_layout_new(pangocontext);
    g_object_unref(pangocontext);
    pango_font_description_free(pangofd);

    pango_layout_set_text(pangolayout, "Ħéłŀŏ ẉṏṝᶅᵭ!", -1);
    cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
    cairo_move_to(cr, 20, 100);
    pango_cairo_show_layout_line(cr, pango_layout_get_line(pangolayout, 0));
    g_object_unref(pangolayout);

    cairo_destroy(cr);
    cairo_surface_destroy(surface);

    return 0;
}
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.