2002-05-18 14:03:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2000 Computing Research Labs, New Mexico State University
|
2011-11-27 16:39:53 +01:00
|
|
|
* Copyright 2001-2004, 2011 Francesco Zappa Nardelli
|
2002-05-18 14:03:43 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
|
|
|
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
2002-05-21 16:13:01 +02:00
|
|
|
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#ifndef BDF_H_
|
|
|
|
#define BDF_H_
|
2002-05-18 14:03:43 +02:00
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
|
2002-05-18 14:03:43 +02:00
|
|
|
/*
|
2002-05-21 16:13:01 +02:00
|
|
|
* Based on bdf.h,v 1.16 2000/03/16 20:08:51 mleisher
|
2002-05-18 14:03:43 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
2015-12-19 17:02:13 +01:00
|
|
|
#include FT_INTERNAL_HASH_H
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
/* Imported from bdfP.h */
|
|
|
|
|
2015-08-01 07:53:48 +02:00
|
|
|
#define _bdf_glyph_modified( map, e ) \
|
|
|
|
( (map)[(e) >> 5] & ( 1UL << ( (e) & 31 ) ) )
|
|
|
|
#define _bdf_set_glyph_modified( map, e ) \
|
|
|
|
( (map)[(e) >> 5] |= ( 1UL << ( (e) & 31 ) ) )
|
|
|
|
#define _bdf_clear_glyph_modified( map, e ) \
|
|
|
|
( (map)[(e) >> 5] &= ~( 1UL << ( (e) & 31 ) ) )
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
/* end of bdfP.h */
|
|
|
|
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* BDF font options macros and types.
|
|
|
|
*
|
|
|
|
*/
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
#define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */
|
|
|
|
#define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */
|
|
|
|
#define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */
|
|
|
|
#define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */
|
|
|
|
#define BDF_MONOWIDTH 0x10 /* Font has mono width. */
|
|
|
|
#define BDF_CHARCELL 0x20 /* Font has charcell spacing. */
|
2002-05-18 14:03:43 +02:00
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
#define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \
|
|
|
|
BDF_MONOWIDTH | \
|
|
|
|
BDF_CHARCELL )
|
2002-05-18 14:03:43 +02:00
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
#define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \
|
|
|
|
BDF_KEEP_COMMENTS | \
|
|
|
|
BDF_KEEP_UNENCODED | \
|
|
|
|
BDF_PROPORTIONAL )
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
typedef struct bdf_options_t_
|
|
|
|
{
|
|
|
|
int correct_metrics;
|
|
|
|
int keep_unencoded;
|
|
|
|
int keep_comments;
|
|
|
|
int font_spacing;
|
2002-05-18 14:03:43 +02:00
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
} bdf_options_t;
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
/* Callback function type for unknown configuration options. */
|
|
|
|
typedef int
|
|
|
|
(*bdf_options_callback_t)( bdf_options_t* opts,
|
|
|
|
char** params,
|
|
|
|
unsigned long nparams,
|
|
|
|
void* client_data );
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* BDF font property macros and types.
|
|
|
|
*
|
|
|
|
*/
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
#define BDF_ATOM 1
|
|
|
|
#define BDF_INTEGER 2
|
|
|
|
#define BDF_CARDINAL 3
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
/* This structure represents a particular property of a font. */
|
|
|
|
/* There are a set of defaults and each font has their own. */
|
|
|
|
typedef struct bdf_property_t_
|
|
|
|
{
|
|
|
|
char* name; /* Name of the property. */
|
|
|
|
int format; /* Format of the property. */
|
|
|
|
int builtin; /* A builtin property. */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
char* atom;
|
2009-07-31 17:30:22 +02:00
|
|
|
long l;
|
|
|
|
unsigned long ul;
|
2002-05-18 14:03:43 +02:00
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
} value; /* Value of the property. */
|
2002-05-18 14:03:43 +02:00
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
} bdf_property_t;
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* BDF font metric and glyph types.
|
|
|
|
*
|
|
|
|
*/
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
typedef struct bdf_bbx_t_
|
|
|
|
{
|
|
|
|
unsigned short width;
|
|
|
|
unsigned short height;
|
|
|
|
|
|
|
|
short x_offset;
|
|
|
|
short y_offset;
|
|
|
|
|
|
|
|
short ascent;
|
|
|
|
short descent;
|
|
|
|
|
|
|
|
} bdf_bbx_t;
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
typedef struct bdf_glyph_t_
|
|
|
|
{
|
|
|
|
char* name; /* Glyph name. */
|
2018-08-13 15:01:53 +02:00
|
|
|
unsigned long encoding; /* Glyph encoding. */
|
2002-05-21 16:13:01 +02:00
|
|
|
unsigned short swidth; /* Scalable width. */
|
|
|
|
unsigned short dwidth; /* Device width. */
|
|
|
|
bdf_bbx_t bbx; /* Glyph bounding box. */
|
|
|
|
unsigned char* bitmap; /* Glyph bitmap. */
|
|
|
|
unsigned long bpr; /* Number of bytes used per row. */
|
|
|
|
unsigned short bytes; /* Number of bytes used for the bitmap. */
|
|
|
|
|
|
|
|
} bdf_glyph_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct bdf_font_t_
|
|
|
|
{
|
|
|
|
char* name; /* Name of the font. */
|
|
|
|
bdf_bbx_t bbx; /* Font bounding box. */
|
|
|
|
|
2015-02-22 09:16:53 +01:00
|
|
|
unsigned long point_size; /* Point size of the font. */
|
2002-05-21 16:13:01 +02:00
|
|
|
unsigned long resolution_x; /* Font horizontal resolution. */
|
|
|
|
unsigned long resolution_y; /* Font vertical resolution. */
|
|
|
|
|
|
|
|
int spacing; /* Font spacing value. */
|
|
|
|
|
|
|
|
unsigned short monowidth; /* Logical width for monowidth font. */
|
|
|
|
|
2018-08-13 15:01:53 +02:00
|
|
|
unsigned long default_char; /* Encoding of the default glyph. */
|
2002-05-21 16:13:01 +02:00
|
|
|
|
|
|
|
long font_ascent; /* Font ascent. */
|
|
|
|
long font_descent; /* Font descent. */
|
|
|
|
|
|
|
|
unsigned long glyphs_size; /* Glyph structures allocated. */
|
|
|
|
unsigned long glyphs_used; /* Glyph structures used. */
|
|
|
|
bdf_glyph_t* glyphs; /* Glyphs themselves. */
|
|
|
|
|
|
|
|
unsigned long unencoded_size; /* Unencoded glyph struct. allocated. */
|
|
|
|
unsigned long unencoded_used; /* Unencoded glyph struct. used. */
|
|
|
|
bdf_glyph_t* unencoded; /* Unencoded glyphs themselves. */
|
|
|
|
|
|
|
|
unsigned long props_size; /* Font properties allocated. */
|
|
|
|
unsigned long props_used; /* Font properties used. */
|
|
|
|
bdf_property_t* props; /* Font properties themselves. */
|
|
|
|
|
|
|
|
char* comments; /* Font comments. */
|
|
|
|
unsigned long comments_len; /* Length of comment string. */
|
|
|
|
|
|
|
|
void* internal; /* Internal data for the font. */
|
|
|
|
|
|
|
|
unsigned short bpp; /* Bits per pixel. */
|
|
|
|
|
|
|
|
FT_Memory memory;
|
|
|
|
|
|
|
|
bdf_property_t* user_props;
|
|
|
|
unsigned long nuser_props;
|
2015-12-19 17:02:13 +01:00
|
|
|
FT_HashRec proptbl;
|
2002-05-21 16:13:01 +02:00
|
|
|
|
|
|
|
} bdf_font_t;
|
|
|
|
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Types for load/save callbacks.
|
|
|
|
*
|
|
|
|
*/
|
2002-05-21 16:13:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Error codes. */
|
|
|
|
#define BDF_MISSING_START -1
|
|
|
|
#define BDF_MISSING_FONTNAME -2
|
|
|
|
#define BDF_MISSING_SIZE -3
|
|
|
|
#define BDF_MISSING_CHARS -4
|
|
|
|
#define BDF_MISSING_STARTCHAR -5
|
|
|
|
#define BDF_MISSING_ENCODING -6
|
|
|
|
#define BDF_MISSING_BBX -7
|
|
|
|
|
|
|
|
#define BDF_OUT_OF_MEMORY -20
|
|
|
|
|
|
|
|
#define BDF_INVALID_LINE -100
|
|
|
|
|
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* BDF font API.
|
|
|
|
*
|
|
|
|
*/
|
2002-05-21 16:13:01 +02:00
|
|
|
|
|
|
|
FT_LOCAL( FT_Error )
|
|
|
|
bdf_load_font( FT_Stream stream,
|
|
|
|
FT_Memory memory,
|
|
|
|
bdf_options_t* opts,
|
|
|
|
bdf_font_t* *font );
|
|
|
|
|
|
|
|
FT_LOCAL( void )
|
|
|
|
bdf_free_font( bdf_font_t* font );
|
|
|
|
|
|
|
|
FT_LOCAL( bdf_property_t * )
|
|
|
|
bdf_get_property( char* name,
|
|
|
|
bdf_font_t* font );
|
|
|
|
|
|
|
|
FT_LOCAL( bdf_property_t * )
|
|
|
|
bdf_get_font_property( bdf_font_t* font,
|
2003-04-25 07:35:04 +02:00
|
|
|
const char* name );
|
2002-05-21 16:13:01 +02:00
|
|
|
|
2002-05-18 14:03:43 +02:00
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
2002-05-21 16:13:01 +02:00
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#endif /* BDF_H_ */
|
2002-05-21 16:13:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|