JFont
+ Collaboration diagram for JFont:

Typedefs

typedef struct _jfont t_jfont
 An instance of a jgraphics font.

Enumerations

enum  t_jgraphics_font_slant { JGRAPHICS_FONT_SLANT_NORMAL, JGRAPHICS_FONT_SLANT_ITALIC }
 Enumeration of slanting options for font display. More...
enum  t_jgraphics_font_weight { JGRAPHICS_FONT_WEIGHT_NORMAL, JGRAPHICS_FONT_WEIGHT_BOLD }
 Enumeration of font weight options for font display. More...

Functions

t_jfontjfont_create (const char *family, t_jgraphics_font_slant slant, t_jgraphics_font_weight weight, double size)
 Create a new font object.
t_jfontjfont_reference (t_jfont *font)
 Create new reference to an existing font object.
void jfont_destroy (t_jfont *font)
 Release or free a font object.
long jfont_isequalto (t_jfont *font, t_jfont *other)
 Compare two fonts to see if they are equivalent.
void jfont_set_font_size (t_jfont *font, double size)
 Set the size of a font object.
void jfont_set_underline (t_jfont *font, char ul)
 Set the underlining of a font object.
void jfont_extents (t_jfont *font, t_jgraphics_font_extents *extents)
 Get extents of this font.
void jfont_text_measure (t_jfont *font, const char *utf8, double *width, double *height)
 Given a font, find out how much area is required to render a string of text.
void jfont_text_measuretext_wrapped (t_jfont *font, const char *utf8, double wrapwidth, long includewhitespace, double *width, double *height, long *numlines)
 Given a font, find out how much area is required to render a string of text, provided a horizontal maximum limit at which the text is wrapped.
void jfont_get_em_dimensions (t_jfont *font, double *width, double *height)
 Given a font, find out the width and height of the 'M' character.
t_max_err jfont_getfontlist (long *count, t_symbol ***list)
 Get a list of font names.
long jbox_get_font_weight (t_object *b)
 Get the slant box's font.
long jbox_get_font_slant (t_object *b)
 Get the slant box's font.

Enumeration Type Documentation

Enumeration of slanting options for font display.

Enumerator:
JGRAPHICS_FONT_SLANT_NORMAL 

Normal slanting (typically this means no slanting)

JGRAPHICS_FONT_SLANT_ITALIC 

Italic slanting.

Enumeration of font weight options for font display.

Enumerator:
JGRAPHICS_FONT_WEIGHT_NORMAL 

Normal font weight.

JGRAPHICS_FONT_WEIGHT_BOLD 

Bold font weight.


Function Documentation

long jbox_get_font_slant ( t_object b)

Get the slant box's font.

Parameters:
bAn object's box.
Returns:
A value from the t_jgraphics_font_slant enum.
long jbox_get_font_weight ( t_object b)

Get the slant box's font.

Parameters:
bAn object's box.
Returns:
A value from the t_jgraphics_font_weight enum.
t_jfont* jfont_create ( const char *  family,
t_jgraphics_font_slant  slant,
t_jgraphics_font_weight  weight,
double  size 
)

Create a new font object.

Parameters:
familyThe name of the font family (e.g. Arial).
slantThe type of slant for the font.
weightThe type of weight for the font.
sizeThe size of the font.
Returns:
The new font object.
void jfont_destroy ( t_jfont font)

Release or free a font object.

Parameters:
fontThe font object to release.
void jfont_extents ( t_jfont font,
t_jgraphics_font_extents extents 
)

Get extents of this font.

Parameters:
fontThe font object.
extentsThe font extents upon return/
void jfont_get_em_dimensions ( t_jfont font,
double *  width,
double *  height 
)

Given a font, find out the width and height of the 'M' character.

This is equivalent to jfont_text_measure(font, "M", width, height) but is faster.

Parameters:
fontThe font object.
widthThe address of a variable to hold the width upon return.
heightThe address of a variable to hold the height upon return.
t_max_err jfont_getfontlist ( long *  count,
t_symbol ***  list 
)

Get a list of font names.

Parameters:
countThe addres of a variable to hold the count of font names in list upon return.
listThe address of a t_symbol** initialized to NULL. Upon return this will be set to an array of count t_symbol pointers. This array should be freed using sysmem_freeptr() when you are done with it.
Returns:
A Max error code.
long jfont_isequalto ( t_jfont font,
t_jfont other 
)

Compare two fonts to see if they are equivalent.

Parameters:
fontThe first font object that is being compared.
otherThe second font object that is being compared.
Returns:
Nonzero value if the two fonts are equivalent.
t_jfont* jfont_reference ( t_jfont font)

Create new reference to an existing font object.

Parameters:
fontThe font object for which to obtain a reference.
Returns:
The new font object reference.
void jfont_set_font_size ( t_jfont font,
double  size 
)

Set the size of a font object.

Parameters:
fontThe font object.
sizeThe new size for the font object.
void jfont_set_underline ( t_jfont font,
char  ul 
)

Set the underlining of a font object.

Parameters:
fontThe font object.
ulPass true to underline, or false for no underlining.
void jfont_text_measure ( t_jfont font,
const char *  utf8,
double *  width,
double *  height 
)

Given a font, find out how much area is required to render a string of text.

Parameters:
fontThe font object.
utf8The text whose rendering will be measured.
widthThe address of a variable to hold the width upon return.
heightThe address of a variable to hold the height upon return.
void jfont_text_measuretext_wrapped ( t_jfont font,
const char *  utf8,
double  wrapwidth,
long  includewhitespace,
double *  width,
double *  height,
long *  numlines 
)

Given a font, find out how much area is required to render a string of text, provided a horizontal maximum limit at which the text is wrapped.

Parameters:
fontThe font object.
utf8The text whose rendering will be measured.
wrapwidthThe maximum width, above which text should wrap onto a new line.
includewhitespaceIf non-zero, include whitespace in the measurement.
widthThe address of a variable to hold the width upon return.
heightThe address of a variable to hold the height upon return.
numlinesThe address of a variable to hold the number of lines of text after wrapping upon return.