gdkfont.c

Go to the documentation of this file.
00001 /* GDK - The GIMP Drawing Kit
00002  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 /*
00021  * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
00022  * file for a list of people on the GTK+ Team.  See the ChangeLog
00023  * files for a list of changes.  These files are distributed with
00024  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
00025  */
00026 
00027 #include "gdkfont.h"
00028 #include "gdkprivate.h"
00029 
00030 GdkFont *gdk_font_ref(GdkFont * font)
00031 {
00032    GdkFontPrivate *private;
00033 
00034    g_return_val_if_fail(font != NULL, NULL);
00035 
00036    private = (GdkFontPrivate *) font;
00037    private->ref_count += 1;
00038    return font;
00039 }
00040 
00041 void gdk_font_unref(GdkFont * font)
00042 {
00043    GdkFontPrivate *private;
00044    private = (GdkFontPrivate *) font;
00045 
00046    g_return_if_fail(font != NULL);
00047    g_return_if_fail(private->ref_count > 0);
00048 
00049    private->ref_count -= 1;
00050    if (private->ref_count == 0)
00051       _gdk_font_destroy(font);
00052 }
00053 
00054 gint gdk_string_width(GdkFont * font, const gchar * string)
00055 {
00056    g_return_val_if_fail(font != NULL, -1);
00057    g_return_val_if_fail(string != NULL, -1);
00058 
00059    return gdk_text_width(font, string, _gdk_font_strlen(font, string));
00060 }
00061 
00062 gint gdk_char_width(GdkFont * font, gchar character)
00063 {
00064    g_return_val_if_fail(font != NULL, -1);
00065 
00066    return gdk_text_width(font, &character, 1);
00067 }
00068 
00069 gint gdk_char_width_wc(GdkFont * font, GdkWChar character)
00070 {
00071    g_return_val_if_fail(font != NULL, -1);
00072 
00073    return gdk_text_width_wc(font, &character, 1);
00074 }
00075 
00076 gint gdk_string_measure(GdkFont * font, const gchar * string)
00077 {
00078    g_return_val_if_fail(font != NULL, -1);
00079    g_return_val_if_fail(string != NULL, -1);
00080 
00081    return gdk_text_measure(font, string, _gdk_font_strlen(font, string));
00082 }
00083 
00084 void
00085 gdk_string_extents(GdkFont * font,
00086                    const gchar * string,
00087                    gint * lbearing,
00088                    gint * rbearing,
00089                    gint * width, gint * ascent, gint * descent)
00090 {
00091    g_return_if_fail(font != NULL);
00092    g_return_if_fail(string != NULL);
00093 
00094    gdk_text_extents(font, string, _gdk_font_strlen(font, string),
00095                     lbearing, rbearing, width, ascent, descent);
00096 }
00097 
00098 
00099 gint gdk_text_measure(GdkFont * font, const gchar * text, gint text_length)
00100 {
00101    gint rbearing;
00102 
00103    g_return_val_if_fail(font != NULL, -1);
00104    g_return_val_if_fail(text != NULL, -1);
00105 
00106    gdk_text_extents(font, text, text_length, NULL, &rbearing, NULL, NULL,
00107                     NULL);
00108    return rbearing;
00109 }
00110 
00111 gint gdk_char_measure(GdkFont * font, gchar character)
00112 {
00113    g_return_val_if_fail(font != NULL, -1);
00114 
00115    return gdk_text_measure(font, &character, 1);
00116 }
00117 
00118 gint gdk_string_height(GdkFont * font, const gchar * string)
00119 {
00120    g_return_val_if_fail(font != NULL, -1);
00121    g_return_val_if_fail(string != NULL, -1);
00122 
00123    return gdk_text_height(font, string, _gdk_font_strlen(font, string));
00124 }
00125 
00126 gint gdk_text_height(GdkFont * font, const gchar * text, gint text_length)
00127 {
00128    gint ascent, descent;
00129 
00130    g_return_val_if_fail(font != NULL, -1);
00131    g_return_val_if_fail(text != NULL, -1);
00132 
00133    gdk_text_extents(font, text, text_length, NULL, NULL, NULL, &ascent,
00134                     &descent);
00135    return ascent + descent;
00136 }
00137 
00138 gint gdk_char_height(GdkFont * font, gchar character)
00139 {
00140    g_return_val_if_fail(font != NULL, -1);
00141 
00142    return gdk_text_height(font, &character, 1);
00143 }

Generated on Tue Jul 5 14:14:37 2011 for ROOT_528-00b_version by  doxygen 1.5.1