cgul_bdf_glyph.h File Reference

glyph for BDF fonts More...

#include "cgul_common.h"
#include "cgul_exception.h"
#include "cgul_libc.h"
#include "cgul_string.h"
#include "cgul_wchar.h"
Include dependency graph for cgul_bdf_glyph.h:
This graph shows which files directly or indirectly include this file:

Typedefs

typedef typedefCGUL_BEGIN_C struct cgul_bdf_glyph * cgul_bdf_glyph_t
 

Functions

CGUL_EXPORT cgul_bdf_glyph_t cgul_bdf_glyph__new (cgul_exception_t *cex)
 
CGUL_EXPORT void cgul_bdf_glyph__delete (cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT void cgul_bdf_glyph__copy (cgul_exception_t *cex, cgul_bdf_glyph_t dst, cgul_bdf_glyph_t src)
 
CGUL_EXPORT const char * cgul_bdf_glyph__get_descriptive_name (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT cgul_wchar_t cgul_bdf_glyph__get_encoding (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_ascent (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_descent (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_swidth_x (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_swidth_y (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_dwidth_x (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_dwidth_y (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_bb_width (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned int cgul_bdf_glyph__get_bb_height (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT int cgul_bdf_glyph__get_bb_x_offset (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT int cgul_bdf_glyph__get_bb_y_offset (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT int cgul_bdf_glyph__get_dot (cgul_exception_t *cex, cgul_bdf_glyph_t glyph, unsigned int x, unsigned int y)
 
CGUL_EXPORT size_t cgul_bdf_glyph__get_bytes_wide (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT unsigned long cgul_bdf_glyph__get_file_offset (cgul_exception_t *cex, cgul_bdf_glyph_t glyph)
 
CGUL_EXPORT void cgul_bdf_glyph__append_bitmap_to_string (cgul_exception_t *cex, cgul_bdf_glyph_t glyph, cgul_string_t s)
 
CGUL_EXPORT void cgul_bdf_glyph__write_file (cgul_exception_t *cex, cgul_bdf_glyph_t glyph, FILE *f)
 
CGUL_EXPORT void cgul_bdf_glyph__fdraw (cgul_exception_t *cex, cgul_bdf_glyph_t glyph, FILE *f, const char *prefix, const char *suffix, char c_active, char c_inactive)
 
CGUL_EXPORT void cgul_bdf_glyph__sdraw (cgul_exception_t *cex, cgul_bdf_glyph_t glyph, cgul_string_t s, const char *prefix, const char *suffix, char c_active, char c_inactive)
 

Detailed Description

Each instance of this class is one glyph from a BDF font file. It is an integral part of the cgul_bdf class.

Author
Paul Serice

Typedef Documentation

§ cgul_bdf_glyph_t

typedef typedefCGUL_BEGIN_C struct cgul_bdf_glyph* cgul_bdf_glyph_t

Opaque reference to a cgul_bdf_glyph instance.

Function Documentation

§ cgul_bdf_glyph__new()

CGUL_EXPORT cgul_bdf_glyph_t cgul_bdf_glyph__new ( cgul_exception_t cex)

This method creates a new cgul_bdf_glyph object. The caller is responsible for calling cgul_bdf_glyph__delete() on the pointer returned. If memory cannot be allocated, NULL is returned, and an exception is thrown.

Parameters
[in,out]cexc-style exception

§ cgul_bdf_glyph__delete()

CGUL_EXPORT void cgul_bdf_glyph__delete ( cgul_bdf_glyph_t  glyph)

This method deletes the glyph object freeing all internally allocated resources. After calling this method, glyph should no longer be dereferenced.

Parameters
[in]glyphcgul_bdf_glyph instance

§ cgul_bdf_glyph__copy()

CGUL_EXPORT void cgul_bdf_glyph__copy ( cgul_exception_t cex,
cgul_bdf_glyph_t  dst,
cgul_bdf_glyph_t  src 
)

This method does a deep copy of src to dst. If an error occurs, an exception is thrown, and dst will be in an undefined state.

Parameters
[in,out]cexc-style exception
[in]dstdestination glyph
[in]srcsource glyph

Referenced by cgul_bdf_glyph_cxx::copy().

§ cgul_bdf_glyph__get_descriptive_name()

CGUL_EXPORT const char* cgul_bdf_glyph__get_descriptive_name ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

This method returns the descriptive name for the character. This is the name that belongs on the STARTCHAR line. If no descriptive name is available, NULL is returned. Thus, it is important that you always check the return value. The pointer returned belongs to this class and should not be altered or freed.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
descriptive name or NULL

Referenced by cgul_bdf_glyph_cxx::get_descriptive_name().

§ cgul_bdf_glyph__get_encoding()

CGUL_EXPORT cgul_wchar_t cgul_bdf_glyph__get_encoding ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the encoding.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
encoding

Referenced by cgul_bdf_glyph_cxx::get_encoding().

§ cgul_bdf_glyph__get_ascent()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_ascent ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the ascent for the glyph. This is a value derived from the glyph's bounding box.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
ascent of glyph

Referenced by cgul_bdf_glyph_cxx::get_ascent().

§ cgul_bdf_glyph__get_descent()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_descent ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the descent for the glyph. This is a value derived from the glyph's bounding box.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
descent of glyph

Referenced by cgul_bdf_glyph_cxx::get_descent().

§ cgul_bdf_glyph__get_swidth_x()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_swidth_x ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the scalable width in the x-direction.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
scalable width in the x-direction

Referenced by cgul_bdf_glyph_cxx::get_swidth_x().

§ cgul_bdf_glyph__get_swidth_y()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_swidth_y ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the scalable width in the y-direction.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
scalable width in the y-direction

Referenced by cgul_bdf_glyph_cxx::get_swidth_y().

§ cgul_bdf_glyph__get_dwidth_x()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_dwidth_x ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the device width in the x-direction.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
device width in the x-direction

Referenced by cgul_bdf_glyph_cxx::get_dwidth_x().

§ cgul_bdf_glyph__get_dwidth_y()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_dwidth_y ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the device width in the y-direction.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
device width in the y-direction

Referenced by cgul_bdf_glyph_cxx::get_dwidth_y().

§ cgul_bdf_glyph__get_bb_width()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_bb_width ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the width of the glyph's bounding box.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
width of the glyph's bounding box

Referenced by cgul_bdf_glyph_cxx::get_bb_width().

§ cgul_bdf_glyph__get_bb_height()

CGUL_EXPORT unsigned int cgul_bdf_glyph__get_bb_height ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the height of the glyph's bounding box.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
height of the glyph's bounding box

Referenced by cgul_bdf_glyph_cxx::get_bb_height().

§ cgul_bdf_glyph__get_bb_x_offset()

CGUL_EXPORT int cgul_bdf_glyph__get_bb_x_offset ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the x-offset of the lower-left corner of the glyph's bounding box.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
x-offset of the lower-left corner of the glyph's bounding box

Referenced by cgul_bdf_glyph_cxx::get_bb_x_offset().

§ cgul_bdf_glyph__get_bb_y_offset()

CGUL_EXPORT int cgul_bdf_glyph__get_bb_y_offset ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the y-offset of the lower-left corner of the glyph's bounding box.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
y-offset of the lower-left corner of the glyph's bounding box

Referenced by cgul_bdf_glyph_cxx::get_bb_y_offset().

§ cgul_bdf_glyph__get_dot()

CGUL_EXPORT int cgul_bdf_glyph__get_dot ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph,
unsigned int  x,
unsigned int  y 
)

This method returns true if the dot at (x,y) inside the bounding box should be drawn. The x- and y-coordinates are relative to the top-left corner of the glyph's bounding box, not the top-left corner of the glyph itself. Also note that x and y values start with zero, not one.

NOTE: There is a cgul_bdf_glyph__set_dot() method in the private header.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
[in]xx-coordinate
[in]yy-coordinate
Returns
whether the dot should be drawn

Referenced by cgul_bdf_glyph_cxx::get_dot().

§ cgul_bdf_glyph__get_bytes_wide()

CGUL_EXPORT size_t cgul_bdf_glyph__get_bytes_wide ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the width of the glyph in bytes. Remember that the data is a bitmap so it is packed with 8 pixels per byte.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
width of the glyph in bytes

Referenced by cgul_bdf_glyph_cxx::get_bytes_wide().

§ cgul_bdf_glyph__get_file_offset()

CGUL_EXPORT unsigned long cgul_bdf_glyph__get_file_offset ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph 
)

Get the file offset of the STARTCHAR line that describes this glyph in the BDF. This information is used to generate the *.bdfi index file so that the glyph can be loaded on demand.

Parameters
[in]cexc-style exception
[in]glyphcgul_bdf_glyph instance
Returns
width of the glyph in bytes

§ cgul_bdf_glyph__append_bitmap_to_string()

CGUL_EXPORT void cgul_bdf_glyph__append_bitmap_to_string ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph,
cgul_string_t  s 
)

This method appends the bitmap of glyph as a character sequence of hex digits to the string s. The appended character sequence can be used as the data in the BITMAP section of a BDF file. If an error occurs, an exception is thrown.

Parameters
[in,out]cexc-style exception
[in]glyphcgul_bdf_glyph instance
[in]sstring

Referenced by cgul_bdf_glyph_cxx::append_bitmap_to_string().

§ cgul_bdf_glyph__write_file()

CGUL_EXPORT void cgul_bdf_glyph__write_file ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph,
FILE *  f 
)

Write the string representation of glyph to f. This is different from cgul_bdf_glyph__fdraw() in that it produces a valid snippet of BDF that can be used as the entire STARTCHAR ... ENDCHAR section.

Parameters
[in,out]cexc-style exception
[in]glyphcgul_bdf_glyph instance
[in]ffile

Referenced by cgul_bdf_glyph_cxx::write_file().

§ cgul_bdf_glyph__fdraw()

CGUL_EXPORT void cgul_bdf_glyph__fdraw ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph,
FILE *  f,
const char *  prefix,
const char *  suffix,
char  c_active,
char  c_inactive 
)

This method appends an ASCII image of the glyph to the file f. The image only shows the part of the glyph that is in the bounding box. Each active pixel is represented by the character c_active. Each inactive pixel is represented by c_inactive. If prefix is not NULL, it will be prefixed to each scan line. If suffix is not NULL, it will be appended to each scan line. If an error occurs, an exception is thrown.

Parameters
[in,out]cexc-style exception
[in]glyphcgul_bdf_glyph instance
[in]ffile
[in]prefixprefix for each scan line
[in]suffixsuffix for each scan line
[in]c_activeactive character
[in]c_inactiveinactive character

Referenced by cgul_bdf_glyph_cxx::fdraw().

§ cgul_bdf_glyph__sdraw()

CGUL_EXPORT void cgul_bdf_glyph__sdraw ( cgul_exception_t cex,
cgul_bdf_glyph_t  glyph,
cgul_string_t  s,
const char *  prefix,
const char *  suffix,
char  c_active,
char  c_inactive 
)

This method appends an ASCII image of the glyph to the string s. The image only shows the part of the glyph that is in the bounding box. Each active pixel is represented by the character c_active. Each inactive pixel is represented by c_inactive. If prefix is not NULL, it will be prefixed to each scan line. If suffix is not NULL, it will be appended to each scan line. If an error occurs, an exception is thrown.

Parameters
[in,out]cexc-style exception
[in]glyphcgul_bdf_glyph instance
[in,out]sstring
[in]prefixprefix for each scan line
[in]suffixsuffix for each scan line
[in]c_activeactive character
[in]c_inactiveinactive character

Referenced by cgul_bdf_glyph_cxx::sdraw().