Commit 655dcff0 authored by Christian Dywan's avatar Christian Dywan Committed by Javier Jardón
parent 34573b53
......@@ -74,7 +74,6 @@ gdk_extension_mode_get_type
gdk_fill_get_type
gdk_fill_rule_get_type
gdk_filter_return_get_type
gdk_font_type_get_type
gdk_function_get_type
gdk_gc_values_mask_get_type
gdk_grab_ownership_get_type
......@@ -394,28 +393,6 @@ gdk_colormap_get_type
gdk_color_get_type
</SECTION>
<SECTION>
<TITLE>Fonts</TITLE>
<FILE>fonts</FILE>
GdkFont
GdkFontType
gdk_font_load
gdk_fontset_load
gdk_fontset_load_for_display
gdk_font_get_display
gdk_font_ref
gdk_font_unref
gdk_font_id
gdk_font_equal
<SUBSECTION Standard>
GDK_TYPE_FONT
GDK_TYPE_FONT_TYPE
<SUBSECTION Private>
gdk_font_get_type
</SECTION>
<SECTION>
<TITLE>Drawing Primitives</TITLE>
<FILE>drawing</FILE>
......
<!-- ##### SECTION Title ##### -->
Fonts
<!-- ##### SECTION Short_Description ##### -->
Loading and manipulating fonts
<!-- ##### SECTION Long_Description ##### -->
<para>
The #GdkFont data type represents a font for drawing on
the screen. These functions provide support for
loading fonts, and also for determining the dimensions
of characters and strings when drawn with a particular
font.
</para>
<para>
Fonts in X are specified by a
<firstterm>X Logical Font Description</firstterm>.
The following description is considerably simplified.
For definitive information about XLFD's see the
X reference documentation. A X Logical Font Description (XLFD)
consists of a sequence of fields separated (and surrounded by) '-'
characters. For example, Adobe Helvetica Bold 12 pt, has the
full description:
<informalexample><programlisting>
"-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1"
</programlisting></informalexample>
</para>
<para>
The fields in the XLFD are:
<informaltable pgwide="1" frame="none">
<tgroup cols="2"><colspec colwidth="2*"/><colspec colwidth="8*"/>
<tbody>
<row>
<entry>Foundry</entry>
<entry>the company or organization where the font originated.</entry>
</row>
<row>
<entry>Family</entry>
<entry>the font family (a group of related font designs).</entry>
</row>
<row>
<entry>Weight</entry>
<entry>A name for the font's typographic weight
For example, 'bold' or 'medium').</entry>
</row>
<row>
<entry>Slant</entry>
<entry>The slant of the font. Common values are 'R' for Roman,
'I' for italoc, and 'O' for oblique.</entry>
</row>
<row>
<entry>Set Width</entry>
<entry>A name for the width of the font. For example,
'normal' or 'condensed'.</entry>
</row>
<row>
<entry>Add Style</entry>
<entry>Additional information to distinguish a font from
other fonts of the same family.</entry>
</row>
<row>
<entry>Pixel Size</entry>
<entry>The body size of the font in pixels.</entry>
</row>
<row>
<entry>Point Size</entry>
<entry>The body size of the font in 10ths of a point.
(A <firstterm>point</firstterm> is 1/72.27 inch) </entry>
</row>
<row>
<entry>Resolution X</entry>
<entry>The horizontal resolution that the font was designed for.</entry>
</row>
<row>
<entry>Resolution Y</entry>
<entry>The vertical resolution that the font was designed for .</entry>
</row>
<row>
<entry>Spacing</entry>
<entry>The type of spacing for the font - can be 'p' for proportional,
'm' for monospaced or 'c' for charcell.</entry>
</row>
<row>
<entry>Average Width</entry>
<entry>The average width of a glyph in the font. For monospaced
and charcell fonts, all glyphs in the font have this width</entry>
</row>
<row>
<entry>Charset Registry</entry>
<entry>The registration authority that owns the encoding for
the font. Together with the Charset Encoding field, this
defines the character set for the font.</entry>
</row>
<row>
<entry>Charset Encoding</entry>
<entry>An identifier for the particular character set encoding.</entry>
</row>
</tbody></tgroup></informaltable>
</para>
<para>
When specifying a font via a X logical Font Description,
'*' can be used as a wildcard to match any portion of
the XLFD. For instance, the above example could
also be specified as
<informalexample><programlisting>
"-*-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-1"
</programlisting></informalexample>
It is generally a good idea to use wildcards for any
portion of the XLFD that your program does not care
about specifically, since that will improve the
chances of finding a matching font.
</para>
<para>
A <firstterm>fontset</firstterm> is a list of fonts
that is used for drawing international text that may
contain characters from a number of different character
sets. It is represented by a list of XLFD's.
</para>
<para>
The font for a given character set is determined by going
through the list of XLFD's in order. For each one, if
the registry and and encoding fields match the desired
character set, then that font is used, otherwise if
the XLFD contains wild-cards for the registry and encoding
fields, the registry and encoding for the desired character
set are substituted in and a lookup is done. If a match is found
that font is used. Otherwise, processing continues
on to the next font in the list.
</para>
<para>
The functions for determining the metrics of a string
come in several varieties that can take a number
of forms of string input:
<variablelist>
<varlistentry>
<term>8-bit string</term>
<listitem><para>
When using functions like gdk_string_width() that
take a <type>gchar *</type>, if the font is of type
%GDK_FONT_FONT and is an 8-bit font, then each
<type>gchar</type> indexes the glyphs in the font directly.
</para></listitem>
</varlistentry>
<varlistentry>
<term>16-bit string</term>
<listitem><para>
For functions taking a <type>gchar *</type>, if the
font is of type %GDK_FONT_FONT, and is a 16-bit
font, then the <type>gchar *</type> argument is
interpreted as a <type>guint16 *</type> cast to
a <type>gchar *</type> and each <type>guint16</type>
indexes the glyphs in the font directly.
</para></listitem>
</varlistentry>
<varlistentry>
<term>Multibyte string</term>
<listitem><para>
For functions taking a <type>gchar *</type>, if the
font is of type %GDK_FONT_FONTSET, then the input
string is interpreted as a <firstterm>multibyte</firstterm>
encoded according to the current locale. (A multibyte
string is one in which each character may consist
of one or more bytes, with different lengths for different
characters in the string). The string will
be rendered using one or more different fonts from
the fontset.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<para>
GDK provides functions to determine a number of different
measurements (metrics) for a given string. (Need diagram
here).
<variablelist>
<varlistentry>
<term>ascent</term>
<listitem><para>
The vertical distance from the origin of the drawing
opereration to the top of the drawn character.
</para></listitem>
</varlistentry>
<varlistentry>
<term>descent</term>
<listitem><para>
The vertical distance from the origin of the drawing
opereration to the bottom of the drawn character.
</para></listitem>
</varlistentry>
<varlistentry>
<term>left bearing</term>
<listitem><para>
The horizontal distance from the origin of the drawing
operation to the left-most part of the drawn character.
</para></listitem>
</varlistentry>
<varlistentry>
<term>right bearing</term>
<listitem><para>
The horizontal distance from the origin of the drawing
operation to the right-most part of the drawn character.
</para></listitem>
</varlistentry>
<varlistentry>
<term>width bearing</term>
<listitem><para>
The horizontal distance from the origin of the drawing
operation to the correct origin for drawing another
string to follow the current one. Depending on the
font, this could be greater than or less than the
right bearing.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT GdkFont ##### -->
<para>
The <structname>GdkFont</structname> structure represents a font or fontset. It
contains the following public fields. A new <structname>GdkFont</structname>
structure is returned by gdk_font_load() or gdk_fontset_load(),
and is reference counted with gdk_font_ref() and gdk_font_unref()
</para>
@type: a value of type #GdkFontType which indicates
whether this font is a single font or a fontset.
@ascent: the maximum distance that the font, when drawn,
ascends above the baseline.
@descent: the maximum distance that the font, when drawn,
descends below the baseline.
<!-- ##### ENUM GdkFontType ##### -->
<para>
Indicates the type of a font. The possible values
are currently:
</para>
@GDK_FONT_FONT: the font is a single font.
@GDK_FONT_FONTSET: the font is a fontset.
<!-- ##### FUNCTION gdk_fontset_load ##### -->
<para>
</para>
@fontset_name:
@Returns:
<!-- ##### FUNCTION gdk_fontset_load_for_display ##### -->
<para>
</para>
@display:
@fontset_name:
@Returns:
<!-- ##### FUNCTION gdk_font_get_display ##### -->
<para>
</para>
@font:
@Returns:
<!-- ##### FUNCTION gdk_font_ref ##### -->
<para>
</para>
@font:
@Returns:
<!-- ##### FUNCTION gdk_font_unref ##### -->
<para>
</para>
@font:
<!-- ##### FUNCTION gdk_font_id ##### -->
<para>
</para>
@font:
@Returns:
<!-- ##### FUNCTION gdk_font_equal ##### -->
<para>
</para>
@fonta:
@fontb:
@Returns:
......@@ -82,7 +82,6 @@ gdk_public_h_sources = \
gdkdnd.h \
gdkdrawable.h \
gdkevents.h \
gdkfont.h \
gdkgc.h \
gdkimage.h \
gdkinput.h \
......@@ -130,7 +129,6 @@ gdk_c_sources = \
gdkdnd.c \
gdkdraw.c \
gdkevents.c \
gdkfont.c \
gdkgc.c \
gdkglobals.c \
gdkimage.c \
......
......@@ -27,7 +27,6 @@ libgdk_directfb_la_SOURCES = \
gdkdisplay-directfb.h \
gdkdrawable-directfb.c \
gdkevents-directfb.c \
gdkfont-directfb.c \
gdkgc-directfb.c \
gdkgeometry-directfb.c \
gdkglobals-directfb.c \
......
......@@ -31,7 +31,6 @@ gdkdisplay-directfb.c
gdkdnd-directfb.c
gdkdrawable-directfb.c
gdkevents-directfb.c
gdkfont-directfb.c
gdkgc-directfb.c
gdkgeometry-directfb.c
gdkglobals-directfb.c
......
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team.
*/
/*
* GTK+ DirectFB backend
* Copyright (C) 2001-2002 convergence integrated media GmbH
* Copyright (C) 2002-2004 convergence GmbH
* Written by Denis Oliver Kropp <dok@convergence.de> and
* Sven Neumann <sven@convergence.de>
*/
#undef GDK_DISABLE_DEPRECATED
#include "config.h"
#include "gdk.h"
#include <string.h>
#include "gdkdirectfb.h"
#include "gdkprivate-directfb.h"
#include "gdkinternals.h"
#include "gdkfont.h"
#include "gdkalias.h"
typedef struct _GdkFontDirectFB GdkFontDirectFB;
struct _GdkFontDirectFB
{
GdkFontPrivate base;
gint size;
IDirectFBFont *dfbfont;
};
static GdkFont *
gdk_directfb_bogus_font (gint height)
{
GdkFont *font;
GdkFontDirectFB *private;
private = g_new0 (GdkFontDirectFB, 1);
font = (GdkFont *)private;
font->type = GDK_FONT_FONT;
font->ascent = height*3/4;
font->descent = height/4;
private->size = height;
private->base.ref_count = 1;
return font;
}
/* ********************* */
GdkFont*
gdk_fontset_load (const gchar *fontset_name)
{
return gdk_directfb_bogus_font (10);
}
GdkFont *
gdk_fontset_load_for_display (GdkDisplay *display,const gchar *font_name) {
return gdk_directfb_bogus_font (10);
}
void
_gdk_font_destroy (GdkFont *font)
{
switch (font->type)
{
case GDK_FONT_FONT:
break;
case GDK_FONT_FONTSET:
break;
default:
g_error ("unknown font type.");
break;
}
g_free (font);
}
gint
_gdk_font_strlen (GdkFont *font,
const gchar *str)
{
GdkFontDirectFB *font_private;
gint length = 0;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (str != NULL, -1);
font_private = (GdkFontDirectFB*) font;
if (font->type == GDK_FONT_FONT)
{
guint16 *string_2b = (guint16 *)str;
while (*(string_2b++))
length++;
}
else if (font->type == GDK_FONT_FONTSET)
{
length = strlen (str);
}
else
g_error("undefined font type\n");
return length;
}
gint
gdk_font_id (const GdkFont *font)
{
const GdkFontDirectFB *font_private;
g_return_val_if_fail (font != NULL, 0);
font_private = (const GdkFontDirectFB*) font;
if (font->type == GDK_FONT_FONT)
{
return -1;
}
else
{
return 0;
}
}
gint
gdk_font_equal (const GdkFont *fonta,
const GdkFont *fontb)
{
const GdkFontDirectFB *privatea;
const GdkFontDirectFB *privateb;
g_return_val_if_fail (fonta != NULL, FALSE);
g_return_val_if_fail (fontb != NULL, FALSE);
privatea = (const GdkFontDirectFB*) fonta;
privateb = (const GdkFontDirectFB*) fontb;
if(fonta == fontb)
return TRUE;
return FALSE;
}
#define __GDK_FONT_X11_C__
#include "gdkaliasdef.c"
......@@ -41,7 +41,6 @@
#include <gdk/gdkdrawable.h>
#include <gdk/gdkenumtypes.h>
#include <gdk/gdkevents.h>
#include <gdk/gdkfont.h>
#include <gdk/gdkgc.h>
#include <gdk/gdkimage.h>
#include <gdk/gdkinput.h>
......
......@@ -279,7 +279,6 @@ gdk_subwindow_mode_get_type G_GNUC_CONST
gdk_visibility_state_get_type G_GNUC_CONST
gdk_wm_decoration_get_type G_GNUC_CONST
gdk_wm_function_get_type G_GNUC_CONST
gdk_font_type_get_type G_GNUC_CONST
gdk_cursor_type_get_type G_GNUC_CONST
gdk_drag_action_get_type G_GNUC_CONST
gdk_gc_values_mask_get_type G_GNUC_CONST
......@@ -295,26 +294,6 @@ gdk_visual_type_get_type G_GNUC_CONST
#endif
#endif
#if IN_HEADER(__GDK_FONT_H__)
#if IN_FILE(__GDK_FONT_C__)
gdk_font_get_type G_GNUC_CONST
gdk_font_ref
gdk_font_unref
#endif
#endif
#if IN_HEADER(__GDK_FONT_H__)
#if IN_FILE(__GDK_FONT_X11_C__)
#ifndef GDK_DISABLE_DEPRECATED
gdk_font_get_display
gdk_fontset_load
#endif
gdk_font_id
gdk_font_equal
gdk_fontset_load_for_display
#endif
#endif
#if IN_HEADER(__GDK_CAIRO_H__)
#if IN_FILE(__GDK_CAIRO_C__)
gdk_cairo_create
......
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#undef GDK_DISABLE_DEPRECATED
#include "config.h"
#include "gdkdisplay.h"
#include "gdkfont.h"
#include "gdkinternals.h"
#include "gdkalias.h"
GType
gdk_font_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static (g_intern_static_string ("GdkFont"),
(GBoxedCopyFunc)gdk_font_ref,
(GBoxedFreeFunc)gdk_font_unref);
return our_type;
}
/**
* gdk_font_ref:
* @font: a #GdkFont
*
* Increases the reference count of a font by one.
*
* Return value: @font
**/
GdkFont*
gdk_font_ref (GdkFont *font)
{
GdkFontPrivate *private;
g_return_val_if_fail (font != NULL, NULL);
private = (GdkFontPrivate*) font;
private->ref_count += 1;
return font;
}
/**
* gdk_font_unref:
* @font: a #GdkFont
*
* Decreases the reference count of a font by one.
* If the result is zero, destroys the font.
**/
void
gdk_font_unref (GdkFont *font)
{
GdkFontPrivate *private;
private = (GdkFontPrivate*) font;
g_return_if_fail (font != NULL);
g_return_if_fail (private->ref_count > 0);
private->ref_count -= 1;
if (private->ref_count == 0)
_gdk_font_destroy (font);
}
#define __GDK_FONT_C__
#include "gdkaliasdef.c"
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#if !defined(GDK_DISABLE_DEPRECATED) || defined(GDK_COMPILATION) || defined(GTK_COMPILATION)
#ifndef __GDK_FONT_H__
#define __GDK_FONT_H__
#include <gdk/gdktypes.h>
#include <pango/pango.h>