Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

font/font.h File Reference

VRR FONTLIB. More...

#include "geomlib/base.h"
#include "geomlib/transform.h"
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  font_ctl
 Control structure for font rendering. More...

struct  font_info
 Structure with information about font. More...

struct  font_t1_info
 Structure with information about Type1 font, including some Type1 specific fields. More...

struct  font_truetype_info

Defines

#define FAMILY_LENGTH   50

Enumerations

enum  font_type { FONT_TYPE_TYPE1, FONT_TYPE_TRUETYPE, FONT_TYPE_UNKNOWN, FONT_TYPE_INVALID }
enum  font_charmap {
  FONT_CHARMAP_NONE = 0, FONT_CHARMAP_STD, FONT_CHARMAP_TEX, FONT_CHARMAP_UNICODE,
  FONT_CHARMAP_LATIN1
}

Functions

font_ctlfont_ctl_init (struct font_ctl *ctl)
 Prepare font_ctl structure for use.

void font_ctl_cleanup (struct font_ctl *ctl)
 Discard the guts of struct font_ctl.

void font_init (const char *vrr_name)
 Initialize the font server.

void font_finish (void)
 Cleanup the font server.

int font_id_valid (int font_id)
 Test for valid font descriptor.

const char * font_filename (int font_id)
 Return font filename corresponding to fontdescriptor.

int font_load_file (const char *fname)
 Load font file into fontserver.

int font_get_glyph_bbox (struct font_ctl *ctl, uns char_code, struct geom_rectangle *bbox)
 Compute bounding box of a given glyph.

int font_get_string_bbox (struct font_ctl *ctl, const char *str, struct geom_rectangle *bbox)
 Compute bounding box of a given string.

int font_render_glyph (struct font_ctl *g, uns char_code)
 Render one given glyph.

int font_render_string (struct font_ctl *g, const char *str)
 Render given string.

int font_get_type (int font_id)
 Detect font type.

font_infofont_info (int font_id, struct font_info *fi)
 Return various information about given font file.

font_infofont_info_temporary (const char *fontpath, struct font_info *fi)
 Return various information about given font file.

font_t1_infofont_t1_info (int font_id, struct font_t1_info *fi)
 Return various information about given Type1 font.

font_truetype_info * font_truetype_info (int font_id, struct font_truetype_info *tt)
 Return various information about given TrueType font.

int font_get_glyph_advances (int font_id, struct garr *width)
 Return widths of all glyphs.

void font_info_dump (int font_id)
 Dump various debugging informations about font on stdout.

uns font_get_max_fontid (void)
 Return maximal fontdescriptor currently known to the fontserver.

int font_pfb_to_pfa (int font_id, FILE *out)
 Converts Type1 PFB files into PFA.

const char * font_get_ps_name (int font_id)
 Get PostScript fontname as specified by FontName entry in font dictionary.

int font_tt_to_type42 (int fontid, const char *fontname, FILE *out)
 Save TrueType font loaded into fontserver into external Type42 font file.

int font_char_decompose (struct font_ctl *ctl, int charcode, struct geom_pathset *pathset)
 Decompose glyph into a curve representation.

int font_pfb_sections (byte *buf, uns size, uns *length, uns *clear_text, uns *encrypted, uns *fixed)
 Try to compute section layout of PFB font files.

int font_pfb_data_store (byte *buf, uns size, byte *outbuf)
 Store the PFB font file data, without segment headers.

int font_pfa_to_pfb_buf (byte *buf, uns size, byte *outbuf)
 Convert the PFA font data into the binary PFB font data.

int font_pfa_to_pfb (int fntid, FILE *out)
 Convert the PFA font file into the binary PFB font file.

char * font_search (const char *family, const char *style, char *outbuf, uns bufsize)
 Search for the best matching font filename according to fontconfig database.


Detailed Description

VRR FONTLIB.

Routines for rendering font bitmaps and computing bboxes.

Copyright (c) 2004-2005,2007 The VRR Team <vrr@ucw.cz> This program is distributed under GNU General Public License, see COPYING.


Function Documentation

int font_char_decompose struct font_ctl ctl,
int  charcode,
struct geom_pathset *  pathset
 

Decompose glyph into a curve representation.

Parameters:
ctl font control structure, set font_id, font_size, transform and charmap
charcode character to decompose
pathset initialized (and possibly partially filled) output geom_pathset
Return values:
-1 on error, 0 if all OK

void font_ctl_cleanup struct font_ctl ctl  )  [inline, static]
 

Discard the guts of struct font_ctl.

You should call it after use of any font_ctl structure.

Parameters:
ctl structure to discard

struct font_ctl* font_ctl_init struct font_ctl ctl  )  [inline, static]
 

Prepare font_ctl structure for use.

Zeroes all fields and sets the default transformation to identity. You should call it before the first use of any font_ctl structure.

Parameters:
ctl structure to initialize
Returns:
always ctl

const char* font_filename int  font_id  ) 
 

Return font filename corresponding to fontdescriptor.

Parameters:
font_id font descriptor
Return values:
NULL filename not found
name font filename

int font_get_glyph_advances int  font_id,
struct garr *  width
 

Return widths of all glyphs.

Parameters:
font_id fontdescriptor
width growing array of reals
Return values:
-1 error occured
num number of glyph widths returned in width

int font_get_glyph_bbox struct font_ctl ctl,
uns  char_code,
struct geom_rectangle bbox
 

Compute bounding box of a given glyph.

Does not (re)allocate memory for bitmap in ctl, thus you don't have to deallocate it.

Parameters:
ctl render controlling structure (uses only fields font_id, font_size, charmap_conv, transform)
char_code character code
bbox pointer to resulting bbox, in milimeters
Return values:
-1 error occured
0 otherwise

uns font_get_max_fontid void   ) 
 

Return maximal fontdescriptor currently known to the fontserver.

Returns:
integer maximal fontdescriptor

const char* font_get_ps_name int  font_id  ) 
 

Get PostScript fontname as specified by FontName entry in font dictionary.

Parameters:
font_id font descriptor
Return values:
pointer to name (read only), NULL on error

int font_get_string_bbox struct font_ctl ctl,
const char *  str,
struct geom_rectangle bbox
 

Compute bounding box of a given string.

Does not (re)allocate memory for bitmap in ctl, thus you don't have to deallocate it.

Parameters:
ctl render controlling structure (uses only fields font_id, font_size, charmap_conv, transform)
str input string
bbox pointer to resulting bbox, in milimeters
Return values:
-1 error occured
0 otherwise

int font_get_type int  font_id  ) 
 

Detect font type.

Parameters:
font_id font descriptor
Return values:
one of FONT_TYPE_xxx constants

int font_id_valid int  font_id  ) 
 

Test for valid font descriptor.

Parameters:
font_id font descriptor
Return values:
1 valid font descriptor
0 invalid font descriptor

struct font_info* font_info int  font_id,
struct font_info fi
 

Return various information about given font file.

Parameters:
font_id font descriptor
fi pointer on struct where to put informations
Returns:
pointer to fi, NULL on error

void font_info_dump int  font_id  ) 
 

Dump various debugging informations about font on stdout.

Parameters:
font_id font descriptor corresponding the font to be dumped

struct font_info* font_info_temporary const char *  fontpath,
struct font_info fi
 

Return various information about given font file.

Does not load file into fontserver.

Parameters:
fontpath font filename
fi pointer on struct where to put informations
Returns:
pointer to fi, NULL on error

int font_load_file const char *  fname  ) 
 

Load font file into fontserver.

When called second time with the same filename, returns the same fontdescriptor as at the first time. Function checks if the fontfile is valid font usable by Freetype.

Parameters:
fname filename to load
Returns:
0 if error occured (fontfile is probably invalid), resulting font descriptor otherwise

int font_pfa_to_pfb int  fntid,
FILE *  out
 

Convert the PFA font file into the binary PFB font file.

If the input file is not PFA, just copies the file. Note that some nonstandard PFA cannot be converted succesfully.

Parameters:
fntid valid font descriptor
out output file opened for writing
Returns:
-1 on error (bad PFA file structure), 0 otherwise

int font_pfa_to_pfb_buf byte *  buf,
uns  size,
byte *  outbuf
 

Convert the PFA font data into the binary PFB font data.

Output buffer must be large enough, that means at least size+20. If the input data is not PFA, just copies the input buffer. Note that some nonstandard PFA cannot be converted succesfully.

Parameters:
buf buffer with loaded PFA font file
size size of the buf buffer in bytes
outbuf output buffer where to store the result, must be of size at least size+20 and buf and outbuf must not overlap
Returns:
-1 on error (bad PFA file structure), number of output bytes otherwise

int font_pfb_data_store byte *  buf,
uns  size,
byte *  outbuf
 

Store the PFB font file data, without segment headers.

Especially useful for PDF export. Note that this can fail on some very nonstandard PFB font files. outbuf must be at least the same size as buf. buf == outbuf is allowed.

Parameters:
buf buffer with loaded PFB font file
size size of the buf buffer in bytes
outbuf output buffer where to store the data, buf == outbuf is allowed
Returns:
-1 on error (invalid PFB format), number of output bytes otherwise

int font_pfb_sections byte *  buf,
uns  size,
uns *  length,
uns *  clear_text,
uns *  encrypted,
uns *  fixed
 

Try to compute section layout of PFB font files.

Note that this can fail on some very nonstandard PFB font files. Does not modify any of the output arguments in case of error.

Parameters:
buf buffer with loaded PFB font file
size size of the buf buffer in bytes
length total data size of all sections in bytes, can be NULL
clear_text size of the initial ASCII section in bytes, can be NULL
encrypted size of the encrypted body in bytes, can be NULL
fixed size of the ASCII trailer in bytes, can be NULL
Returns:
-1 on error (invalid PFB format), 0 otherwise

int font_pfb_to_pfa int  font_id,
FILE *  out
 

Converts Type1 PFB files into PFA.

Just rewrites if the original file is PFA.

Parameters:
font_id fontdescriptor
out output file opened for writing
Return values:
-1 error occured
0 otherwise

int font_render_glyph struct font_ctl g,
uns  char_code
 

Render one given glyph.

Warning: function looks at font_ctl.bitmap and font_ctl.bsize, allocates new bitmap if fields are zero or automatically reallocates bitmap if it is too small.

Parameters:
g render controlling structure
char_code character to be rendered
Return values:
-1 error occured
0 otherwise

int font_render_string struct font_ctl g,
const char *  str
 

Render given string.

Warning: function looks at font_ctl.bitmap and font_ctl.bsize, allocates new bitmap if fields are zero or automatically reallocates bitmap if it is too small.

Parameters:
g render controlling structure
str string to be rendered
Return values:
-1 error occured
0 otherwise

char* font_search const char *  family,
const char *  style,
char *  outbuf,
uns  bufsize
 

Search for the best matching font filename according to fontconfig database.

In case outbuf is too small, the filename is truncated to fit into the buffer.

Parameters:
family family name, can be NULL
style style name, can be NULL
outbuf output buffer where to store the filename, should be large enough
bufsize output buffer size
Return values:
NULL something wrong happened
outbuf otherwise

struct font_t1_info* font_t1_info int  font_id,
struct font_t1_info fi
 

Return various information about given Type1 font.

Parameters:
font_id fontdescriptor
fi pointer on struct where to put informations
Returns:
pointer to fi, NULL on error

struct font_truetype_info* font_truetype_info int  font_id,
struct font_truetype_info *  tt
 

Return various information about given TrueType font.

Parameters:
font_id fontdescriptor
tt pointer on struct where to put informations
Returns:
pointer to fi, NULL on error

int font_tt_to_type42 int  fontid,
const char *  fontname,
FILE *  out
 

Save TrueType font loaded into fontserver into external Type42 font file.

Parameters:
fontid font descriptor
fontname manually set the FontName dictionary entry, autodetect if NULL
out output file opened for writing
Return values:
-1 on error, 0 if all OK


Generated on Tue Dec 9 16:30:09 2008 for Vrr by doxygen 1.3.5