Back to index

lightning-sunbird  0.9+nobinonly
glyphstring.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  * Pango
00003  * glyphstring.c:
00004  *
00005  * ***** BEGIN LICENSE BLOCK *****
00006  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00007  *
00008  * The contents of this file are subject to the Mozilla Public License Version
00009  * 1.1 (the "License"); you may not use this file except in compliance with
00010  * the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  *
00013  * Software distributed under the License is distributed on an "AS IS" basis,
00014  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00015  * for the specific language governing rights and limitations under the
00016  * License.
00017  *
00018  * The Original Code is the Pango Library (www.pango.org).
00019  *
00020  * The Initial Developer of the Original Code is
00021  * Red Hat Software.
00022  * Portions created by the Initial Developer are Copyright (C) 1999
00023  * the Initial Developer. All Rights Reserved.
00024  *
00025  * Contributor(s):
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include <glib.h>
00042 #include "pango-glyph.h"
00043 
00051 PangoliteGlyphString *
00052 pangolite_glyph_string_new(void)
00053 {
00054   PangoliteGlyphString *string = g_new(PangoliteGlyphString, 1);
00055   
00056   string->num_glyphs = 0;
00057   string->space = 0;
00058   string->glyphs = NULL;
00059   string->log_clusters = NULL;
00060   return string;
00061 }
00062 
00070 void
00071 pangolite_glyph_string_set_size(PangoliteGlyphString *string, gint new_len)
00072 {
00073   g_return_if_fail (new_len >= 0);
00074 
00075   while (new_len > string->space) {
00076     if (string->space == 0)
00077       string->space = 1;
00078     else
00079       string->space *= 2;
00080     
00081     if (string->space < 0)
00082       g_error("%s: glyph string length overflows maximum integer size", 
00083               "pangolite_glyph_string_set_size");
00084   }
00085   
00086   string->glyphs = g_realloc(string->glyphs, 
00087                              string->space * sizeof(PangoliteGlyphInfo));
00088   string->log_clusters = g_realloc(string->log_clusters, 
00089                                    string->space * sizeof (gint));
00090   string->num_glyphs = new_len;
00091 }
00092 
00099 void
00100 pangolite_glyph_string_free(PangoliteGlyphString *string)
00101 {
00102   g_free(string->glyphs);
00103   g_free(string->log_clusters);
00104   g_free(string);
00105 }