/* 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 Library 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
 * Library General Public License for more details.
 *
 * 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.
 */
#include "gdk.h"
#include "gdkprivate.h"
#include <string.h>

/* Height of font, which we propagate to the outside world */
#define FYP (FY)

GdkFont *only_font;

static GdkFont *
fake_font(void)
{
  GdkFont * res;
  res =  g_new (GdkFont, 1);
  bzero(res, sizeof(GdkFont));
  res->type = 0;
  res->ascent = FYP;
  res->descent = 0;
  return res;
}

void
gdk_font_init(void)
{
  only_font = fake_font();
}

GdkFont*
gdk_font_load (const gchar *font_name)
{
  return only_font;
}

GdkFont*
gdk_fontset_load (gchar *fontset_name)
{
  return only_font;
}

GdkFont*
gdk_font_ref (GdkFont *font)
{
  return font;
}

void
gdk_font_unref (GdkFont *font)
{
}

gint
gdk_font_id (const GdkFont *font)
{
  return 0;
}

gint
gdk_font_equal (const GdkFont *fonta,
                const GdkFont *fontb)
{
  return 1;
}

gint
gdk_string_width (GdkFont     *font,
		  const gchar *string)
{
  return strlen(string) * FX;
}

gint
gdk_text_width (GdkFont      *font,
		const gchar  *text,
		gint          text_length)
{
  return text_length * FX;
}

gint
gdk_text_width_wc (GdkFont	  *font,
		   const GdkWChar *text,
		   gint		   text_length)
{
  return text_length * FX;
}

/* Problem: What if a character is a 16 bits character ?? */
gint
gdk_char_width (GdkFont *font,
		gchar    character)
{
  return FX;
}

gint
gdk_char_width_wc (GdkFont *font,
		   GdkWChar character)
{
  return FX;
}

gint
gdk_string_measure (GdkFont     *font,
                    const gchar *string)
{
  g_return_val_if_fail (font != NULL, -1);
  g_return_val_if_fail (string != NULL, -1);

  return gdk_text_measure (font, string, strlen (string));
}

void
gdk_text_extents (GdkFont     *font,
                  const gchar *text,
                  gint         text_length,
		  gint        *lbearing,
		  gint        *rbearing,
		  gint        *width,
		  gint        *ascent,
		  gint        *descent)
{
  if (lbearing) *lbearing = 0;
  if (rbearing) *rbearing = FX*text_length;
  if (ascent) *ascent = FYP;
  if (descent) *descent = 0;
}

void
gdk_text_extents_wc (GdkFont        *font,
		     const GdkWChar *text,
		     gint            text_length,
		     gint           *lbearing,
		     gint           *rbearing,
		     gint           *width,
		     gint           *ascent,
		     gint           *descent)
{
  gdk_text_extents(font, "ignore_me", text_length, lbearing, rbearing, width, ascent, descent);
}

void
gdk_string_extents (GdkFont     *font,
		    const gchar *string,
		    gint        *lbearing,
		    gint        *rbearing,
		    gint        *width,
		    gint        *ascent,
		    gint        *descent)
{
  g_return_if_fail (font != NULL);
  g_return_if_fail (string != NULL);

  gdk_text_extents (font, string, strlen (string),
		    lbearing, rbearing, width, ascent, descent);
}


gint
gdk_text_measure (GdkFont     *font,
                  const gchar *text,
                  gint         text_length)
{
  return FX*text_length;
}

gint
gdk_char_measure (GdkFont *font,
                  gchar    character)
{
  g_return_val_if_fail (font != NULL, -1);

  return gdk_text_measure (font, &character, 1);
}

gint
gdk_string_height (GdkFont     *font,
		   const gchar *string)
{
  return FYP;
}

gint
gdk_text_height (GdkFont     *font,
		 const gchar *text,
		 gint         text_length)
{
  return gdk_string_height(font, "");
}

gint
gdk_char_height (GdkFont *font,
		 gchar    character)
{
  g_return_val_if_fail (font != NULL, -1);

  return gdk_text_height (font, &character, 1);
}

