diff options
Diffstat (limited to 'src/cairo.c')
-rw-r--r-- | src/cairo.c | 93 |
1 files changed, 77 insertions, 16 deletions
diff --git a/src/cairo.c b/src/cairo.c index 7c469854d..7e6f1d7b4 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -1,24 +1,40 @@ /* cairo - a vector graphics library with display and print output * - * Copyright © 2002 University of Southern California + * Copyright © 2002 University of Southern California * * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * - * Author: Carl D. Worth <cworth@isi.edu> + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + * The Original Code is the cairo graphics library. + * + * The Initial Developer of the Original Code is University of Southern + * California. + * + * Contributor(s): + * Carl D. Worth <cworth@isi.edu> */ + #include "cairoint.h" #define CAIRO_TOLERANCE_MINIMUM 0.0002 /* We're limited by 16 bits of sub-pixel precision */ @@ -884,12 +900,27 @@ cairo_text_extents (cairo_t *cr, const unsigned char *utf8, cairo_text_extents_t *extents) { + cairo_glyph_t *glyphs = NULL; + int nglyphs; + CAIRO_CHECK_SANITY (cr); if (cr->status) return; - - cr->status = _cairo_gstate_text_extents (cr->gstate, utf8, extents); + + cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &nglyphs); CAIRO_CHECK_SANITY (cr); + + if (cr->status) { + if (glyphs) + free (glyphs); + return; + } + + cr->status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, nglyphs, extents); + CAIRO_CHECK_SANITY (cr); + + if (glyphs) + free (glyphs); } void @@ -910,6 +941,9 @@ cairo_glyph_extents (cairo_t *cr, void cairo_show_text (cairo_t *cr, const unsigned char *utf8) { + cairo_glyph_t *glyphs = NULL; + int nglyphs; + CAIRO_CHECK_SANITY (cr); if (cr->status) return; @@ -917,8 +951,20 @@ cairo_show_text (cairo_t *cr, const unsigned char *utf8) if (utf8 == NULL) return; - cr->status = _cairo_gstate_show_text (cr->gstate, utf8); + cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &nglyphs); CAIRO_CHECK_SANITY (cr); + + if (cr->status) { + if (glyphs) + free (glyphs); + return; + } + + cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, nglyphs); + CAIRO_CHECK_SANITY (cr); + + if (glyphs) + free (glyphs); } void @@ -935,12 +981,27 @@ cairo_show_glyphs (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs) void cairo_text_path (cairo_t *cr, const unsigned char *utf8) { + cairo_glyph_t *glyphs = NULL; + int nglyphs; + CAIRO_CHECK_SANITY (cr); if (cr->status) return; - cr->status = _cairo_gstate_text_path (cr->gstate, utf8); + cr->status = _cairo_gstate_text_to_glyphs (cr->gstate, utf8, &glyphs, &nglyphs); CAIRO_CHECK_SANITY (cr); + + if (cr->status) { + if (glyphs) + free (glyphs); + return; + } + + cr->status = _cairo_gstate_glyph_path (cr->gstate, glyphs, nglyphs); + CAIRO_CHECK_SANITY (cr); + + if (glyphs) + free (glyphs); } void |