/* $Id: font_bdf.h 3978 2003-05-23 10:19:38Z micah $
 *
 * font_bdf.h - Definitions shared between the BDF font engine and the
 *              set of compiled-in fonts.
 *
 * PicoGUI small and efficient client/server GUI
 * Copyright (C) 2000-2003 Micah Dowty <micahjd@users.sourceforge.net>
 *
 * 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.1 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 
 * 
 * Contributors:
 * 
 * 
 * 
 */

#ifndef __H_FONT_BDF
#define __H_FONT_BDF

#include <pgserver/font.h>


/* A description of a particular instance of a font - the font structure
   and parameters that effect how it is rendered
*/
struct bdf_fontdesc {
  struct bdf_font *font;
  struct bdf_fontstyle_node *fs;   /* The fontstyle this was generated from */
  u32 style;            /* Store the style that created this fontdesc */
  int interline_space;  /* Extra spacing between lines, for
			   doublespace, etc. */
  int interchar_space;  /* Extra spacing between characters,
			   for expanded text */
  int margin;
  int boldw;    /* If nonzero, font will be offset and duplicated this
		   many times to produce bold.  Must use lgop == PG_LGOP_OR
		   for this to work. */
  int hline;    /* If this is non-negative, draw a horizontal line at this many
		   pixels down from the top of the font. Can be used to
		   create underline, overline, or strikeout. */
  int skew;     /* If nonzero, an italic is generated by shearing the
		   image horizontally one pixel for every 'skew' vertical
		   pixels */
  int italicw;  /* Extra width added by the italic */
};

/* This is a description that goes along with a font style.
   It indicates its name, size, bold, italic, etc.
   This is searched to produce a fontdesc. */
struct bdf_fontstyle_node {
  const u8 *name;
  int size;
  long flags;
  struct bdf_fontstyle_node *next;

  /* Various versions of this font. If one of these is NULL it can be
   * synthesized from the above information */
  struct bdf_font *normal;  /* The only required one */
  struct bdf_font *bold;
  struct bdf_font *italic;
  struct bdf_font *bolditalic;

  int boldw;    /* Width of a bold if a bold version is not available */
};

/* One glyph in a font */
struct bdf_fontglyph {
  s32 encoding;
  u32 bitmap;   /* Offset to bitmap data                  */
  s16 dwidth;   /* Delta X between this char and the next */
  s16 w,h;      /* Width and height of the glyph bitmap   */
  s16 x,y;      /* X and Y displacement for the glyph     */
};

/* An individual bitmapped font */
struct bdf_font {
  u16 numglyphs;    /* Total number of glyphs in the table */
  u16 defaultglyph; /* Default glyph, when the requested glyph isn't found */
  s16 w,h;          /* Font size (pixels) */            
  s16 ascent;       /* Distance glyphs will extend above the baseline */
  s16 descent;      /* Distance glyphs will extend below the baseline */

  struct bdf_fontglyph const *glyphs;   /* Table of glyphs */
  u8 const *bitmaps;                    /* Chunk of bitmap data for the font */
};


extern struct bdf_fontstyle_node *bdf_fontstyles;

#endif /* __H_FONT_BDF */

/* The End */
