LibMB  1.9
Macros | Typedefs | Enumerations | Functions
MBFont - Simple font abstraction and rendering tools

mbpixbuf contains simple image manipulation and composition functions for client side images. More...

Macros

#define mb_drawable_pixmap(drw)   (drw)->xpixmap
 Returns a drawables X pixmap.
 

Typedefs

typedef struct MBColor MBColor
 Its not recommended you touch structure internals directly.
 
typedef struct MBFont MBFont
 Its not recommended you touch structure internals directly.
 
typedef struct MBDrawable MBDrawable
 Type for representing an mbdrawable. More...
 
typedef struct MBLayout MBLayout
 Experimental and therefore not as yet documented. More...
 

Enumerations

Functions

MBColormb_col_new_from_spec (MBPixbuf *pb, char *spec)
 Constructs a new MBColor from a string specification. More...
 
Bool mb_col_set (MBColor *col, char *spec)
 Sets an existing MBColor from a string specification. More...
 
void mb_col_set_rgba (MBColor *col, unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
 Sets an existing MBColor from r,g,b,a values. More...
 
void mb_col_get_rgba (MBColor *col, unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *alpha)
 Gets an r,g,b,a values from an existing MBColor. More...
 
void mb_col_unref (MBColor *col)
 Unrefs ( frees ) a created MBColor object. More...
 
MBFontmb_font_new (Display *dpy, char *family)
 Constructs a new MBFont instance. More...
 
void mb_font_ref (MBFont *font)
 Refs a created MBFont object. More...
 
void mb_font_unref (MBFont *font)
 Unrefs ( frees ) a created MBColor object. More...
 
MBFontmb_font_new_from_string (Display *dpy, char *spec)
 Constructs a new MBFont instance. More...
 
MBFontmb_font_set_from_string (MBFont *font, char *spec)
 Sets the font propertys from a textual description. More...
 
void mb_font_set_family (MBFont *font, const char *family)
 Sets the fonts family. More...
 
char * mb_font_get_family (MBFont *font)
 Gets the fonts family. More...
 
void mb_font_set_weight (MBFont *font, MBFontWeight weight)
 Sets the fonts weight. More...
 
MBFontWeight mb_font_get_weight (MBFont *font)
 Gets the fonts weight. More...
 
void mb_font_set_slant (MBFont *font, MBFontSlant slant)
 Sets the fonts slant. More...
 
void mb_font_set_point_size (MBFont *font, int points)
 Sets the fonts size. More...
 
int mb_font_get_point_size (MBFont *font)
 Gets the fonts point size. More...
 
int mb_font_set_size_to_pixels (MBFont *font, int max_pixels, int *points_to_try)
 Attempts to fit the point size to a pixel size. More...
 
void mb_font_set_color (MBFont *font, MBColor *col)
 Sets the fonts color. More...
 
MBColormb_font_get_color (MBFont *font)
 Gets the fonts point size. More...
 
int mb_font_get_height (MBFont *font)
 Gets the fonts height in pixels. More...
 
int mb_font_get_ascent (MBFont *font)
 Gets the fonts ascent in pixels. More...
 
int mb_font_get_descent (MBFont *font)
 Gets the fonts descent in pixels. More...
 
int mb_font_render_simple (MBFont *font, MBDrawable *drw, int x, int y, int width, unsigned char *text, int encoding, MBFontRenderOpts opts)
 Renders a line of text onto a MBDrawable. More...
 
int mb_font_render_simple_get_width (MBFont *font, int width, unsigned char *text, int encoding, MBFontRenderOpts opts)
 Returns the width in pixels of any text rendered with mb_font_render_simple, taking into account any clipping. More...
 
MBDrawablemb_drawable_new (MBPixbuf *pixbuf, int width, int height)
 Creates a new MBDrawable instance. More...
 
MBDrawablemb_drawable_new_from_pixmap (MBPixbuf *pixbuf, Pixmap pxm)
 Creates a new MBDrawable instance from a pre-existing pixmap. More...
 
void mb_drawable_unref (MBDrawable *drw)
 Unrefs ( frees ) a drawable. More...
 

Detailed Description

mbpixbuf contains simple image manipulation and composition functions for client side images.

Typedef Documentation

MBDrawable

Type for representing an mbdrawable.

This basically wraps X pixmaps and Xft Drawables

Its not recommended you touch this directly.

MBLayout

Experimental and therefore not as yet documented.

Its not recommended you touch this directly.

Function Documentation

void mb_col_get_rgba ( MBColor col,
unsigned char *  red,
unsigned char *  green,
unsigned char *  blue,
unsigned char *  alpha 
)

Gets an r,g,b,a values from an existing MBColor.

Parameters
colMBColor object to query
redred component
greengreen component
blueblue component
alphaalpha component
MBColor* mb_col_new_from_spec ( MBPixbuf pb,
char *  spec 
)

Constructs a new MBColor from a string specification.

The format of the specification can be a color name or the format '#rrggbb[aa]'

Parameters
pbMBPixbuf reference
spec
Returns
a MBColor object or NULL on failure.
Bool mb_col_set ( MBColor col,
char *  spec 
)

Sets an existing MBColor from a string specification.

The format of the specification can be a color name or the format '#rrggbb[aa]'

Parameters
colMBColor object to modify
specNew Color specification
Returns
True or False on failure.
void mb_col_set_rgba ( MBColor col,
unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned char  alpha 
)

Sets an existing MBColor from r,g,b,a values.

Parameters
colMBColor object to modify
redred component
greengreen component
blueblue component
alphaalpha component
void mb_col_unref ( MBColor col)

Unrefs ( frees ) a created MBColor object.

Parameters
colMBColor object to unref
MBDrawable* mb_drawable_new ( MBPixbuf pixbuf,
int  width,
int  height 
)

Creates a new MBDrawable instance.

MBDrawables are what MBfonts get rendered too.

Parameters
pixbufA MBPixbuf Instance.
widthWidth of requested drawable.
heightHeight of requested drawable.
Returns
A MBDrawable Instance
MBDrawable* mb_drawable_new_from_pixmap ( MBPixbuf pixbuf,
Pixmap  pxm 
)

Creates a new MBDrawable instance from a pre-existing pixmap.

Note, if created like this you are responsable for freeing the the drawables pixmap

Parameters
pixbufA MBPixbuf Instance.
pxmthe pixmap to create the drawable from
Returns
A MBDrawable Instance
void mb_drawable_unref ( MBDrawable drw)

Unrefs ( frees ) a drawable.

Parameters
drwMBDrawable to unref
int mb_font_get_ascent ( MBFont font)

Gets the fonts ascent in pixels.

Parameters
fontThe font to query
Returns
The font ascent in pixels
MBColor* mb_font_get_color ( MBFont font)

Gets the fonts point size.

Parameters
fontThe font to query
Returns
The fonts color
int mb_font_get_descent ( MBFont font)

Gets the fonts descent in pixels.

Parameters
fontThe font to query
Returns
The font descent in pixels
char* mb_font_get_family ( MBFont font)

Gets the fonts family.

Parameters
fontThe font to query
Returns
font family name
int mb_font_get_height ( MBFont font)

Gets the fonts height in pixels.

Parameters
fontThe font to query
Returns
The font height in pixels
int mb_font_get_point_size ( MBFont font)

Gets the fonts point size.

Parameters
fontThe font to query
Returns
The font point size
MBFontWeight mb_font_get_weight ( MBFont font)

Gets the fonts weight.

Parameters
fontThe font to query
Returns
The font weight
MBFont* mb_font_new ( Display *  dpy,
char *  family 
)

Constructs a new MBFont instance.

Parameters
dpyX Display
familyfont family name or NULL
Returns
a MBFont object or NULL on failure.
MBFont* mb_font_new_from_string ( Display *  dpy,
char *  spec 
)

Constructs a new MBFont instance.

Parameters
dpyX Display
specA description of the font. This will take Gtk2 style font descriptions or Xft style ones
Returns
a MBFont object or NULL on failure.
void mb_font_ref ( MBFont font)

Refs a created MBFont object.

Parameters
fontMBFont object to unref
int mb_font_render_simple ( MBFont font,
MBDrawable drw,
int  x,
int  y,
int  width,
unsigned char *  text,
int  encoding,
MBFontRenderOpts  opts 
)

Renders a line of text onto a MBDrawable.

Parameters
fontThe font to render
drwThe MBDrawable to render too
xThe X position on MBDrawable to render too
yThe Y position on MBDrawable to render too
widthThe maximum width in pixels to render
textThe text to render.
encodingthe encoding of the text to render
optsOr'd MBFontRenderOpts
Returns
The number of glyths rendered
int mb_font_render_simple_get_width ( MBFont font,
int  width,
unsigned char *  text,
int  encoding,
MBFontRenderOpts  opts 
)

Returns the width in pixels of any text rendered with mb_font_render_simple, taking into account any clipping.

Parameters
fontThe font to render
widthThe maximum width in pixels to render
textThe text to render.
encodingthe encoding of the text to render
optsOr'd MBFontRenderOpts
Returns
The width in pixels
void mb_font_set_color ( MBFont font,
MBColor col 
)

Sets the fonts color.

Note you must set a fonts color for it to be rendered

  • there is no default.
Parameters
fontThe font to alter
colThe requested color.
void mb_font_set_family ( MBFont font,
const char *  family 
)

Sets the fonts family.

Parameters
fontthe font to alter
familyfont family name
MBFont* mb_font_set_from_string ( MBFont font,
char *  spec 
)

Sets the font propertys from a textual description.

Parameters
fontthe font to alter
specA description of the font. This will take Gtk2 style font descriptions or Xft style ones
Returns
the MBFont object
void mb_font_set_point_size ( MBFont font,
int  points 
)

Sets the fonts size.

Parameters
fontThe font to alter
pointsrequested size in points
int mb_font_set_size_to_pixels ( MBFont font,
int  max_pixels,
int *  points_to_try 
)

Attempts to fit the point size to a pixel size.

Parameters
fontThe font to alter
max_pixelsPixel size to fit to
points_to_trya list on point sizes to try or NULL ( to use default values )
Returns
1 on a successful fit, 0 on failure.
void mb_font_set_slant ( MBFont font,
MBFontSlant  slant 
)

Sets the fonts slant.

Parameters
fontThe font to alter
slantThe requested font slant
void mb_font_set_weight ( MBFont font,
MBFontWeight  weight 
)

Sets the fonts weight.

Parameters
fontThe font to alter
weightThe requested font weight
void mb_font_unref ( MBFont font)

Unrefs ( frees ) a created MBColor object.

Parameters
fontMBFont object to unref