---
name: "CL_Font"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_Font"
---

# CL\_Font(3)

ClanLib's font class.

## NAME

CL\_Font - ClanLib's font class.

## DESCRIPTION

This class allows you to easilly draw text onto the backbuffer or to a renderer target.

The font can be created in two ways. Either it is loaded from a resource, or it is created using the font description interface. The font and its description have the same relationship/functionality as the surface and its provider.

Please read the CL\_Font\_Description page if you want an description on how to create your a font.

## CLASS MEMBERS

- **enum alignments**(

  ```
   ALIGN_LEFT,
  ALIGN_CENTER,
  ALIGN_RIGHT )
  ```

- static CL\_Font \***load**(

  ```
   const char *res_id,
  CL_ResourceManager *resource_manager)
  ```

- **CL\_Font**(

  ```
  CL_Font_Description *font_desc)
  ```

- virtual **~CL\_Font**()

  - int **get\_height**()

  - int **get\_text\_width**(

  ```
  const char *text)
  ```

- void **print\_left**(

  ```
  int x,
  int y,
  const char *text)
  ```

- void **print\_left**(

  ```
  int x,
  int y,
  float scale_x,
  float scale_y,
  const char *text)
  ```

- void **print\_center**(

  ```
  int x,
  int y,
  const char *text)
  ```

- void **print\_right**(

  ```
  int x,
  int y,
  const char *text)
  ```

- void **put\_target**(

  ```
  int x,
  int y,
  const char *text,
  CL_Target *target,
  int alignment=ALIGN_LEFT)
  ```

## MEMBERS WITH DESCRIPTIONS

- **enum alignments**(

  ```
   ALIGN_LEFT,
  ALIGN_CENTER,
  ALIGN_RIGHT )
  ```

  ```
  Description:
  ```

- static CL\_Font \***load**(

  ```
   const char *res_id,
  CL_ResourceManager *resource_manager)
  ```

  ```
  Parameters:
  res_id - The resource ID of the font.
  resource_manager - The resource manager used to load the
  resources from.
  ```

  ```
  Description:
  ```

  Loads the font from resources.

- **CL\_Font**(

  ```
  CL_Font_Description *font_desc)
  ```

  ```
  Parameters:
  font_desc - The font description used to construct the font.
  ```

  ```
  Description:
  ```

  Loads the font from a font description.

- virtual **~CL\_Font**()

  ```
  Description:
  ```

- int **get\_height**()

  ```
  Description:
  ```

  Returns the height of the font.

  ```
  Return value:
  ```

  Width of the font.

- int **get\_text\_width**(

  ```
  const char *text)
  ```

  ```
  Parameters:
  text - Text string the width should be calculated from.
  ```

  ```
  Description:
  ```

  Return the width of *text* if drawn with this font.

  ```
  Return value:
  ```

  Width of the text (in pixels).

- void **print\_left**(

  ```
  int x,
  int y,
  const char *text)
  ```

  ```
  Parameters:
  x - X coordinate (in pixels) the text is drawn at.
  y - Y coordiante (in pixels) the text is drawn at.
  text - The text to be drawn with this font.
  ```

  ```
  Description:
  ```

  Prints *text* left aligned at coordinates (*x*,*y*).

- void **print\_left**(

  ```
  int x,
  int y,
  float scale_x,
  float scale_y,
  const char *text)
  ```

  ```
  Parameters:
  x - X coordinate (in pixels) the text is drawn at.
  y - Y coordiante (in pixels) the text is drawn at.
  scale_x - Scale font width scale_x times.
  scale_y - Scale font height scale_y times.
  text - The text to be drawn with this font.
  ```

  ```
  Description:
  ```

  Prints *text* left aligned at coordinates (*x*,*y*).

- void **print\_center**(

  ```
  int x,
  int y,
  const char *text)
  ```

  ```
  Parameters:
  x - X coordinate (in pixels) the text is centered at.
  y - Y coordiante (in pixels) the text is centered at.
  text - The text to be drawn with this font.
  ```

  ```
  Description:
  ```

  Prints *text* center aligned at coordinates (*x*,*y*).

- void **print\_right**(

  ```
  int x,
  int y,
  const char *text)
  ```

  ```
  Parameters:
  x - X coordinate (in pixels) the text is ends at.
  y - Y coordiante (in pixels) the text is drawn at.
  text - The text to be drawn with this font.
  ```

  ```
  Description:
  ```

  Prints *text* right aligned at coordinates (*x*,*y*).

- void **put\_target**(

  ```
  int x,
  int y,
  const char *text,
  CL_Target *target,
  int alignment=ALIGN_LEFT)
  ```

  ```
  Parameters:
  x - X coordinate (in pixels)
  y - Y coordiante (in pixels)
  text - The text to be drawn with this font.
  target - the target surface to blit to.
  alignment - the alignment of the text, CL_Font::ALIGN_LEFT, CL_Font::ALIGN_CENTER, CL_Font::ALIGN_RIGHT
  ```

  ```
  Description:
  ```

  Prints *text* aligned with alignment at coordinates (*x*,*y*) to the target surface.If CL\_Font::ALIGN\_LEFT is specified the text is draw starting from x, y.If CL\_Font::ALIGN\_CENTER is specified the text is centered at x, y.If CL\_Font::ALIGN\_RIGHT is specified the text ends at x, y;

## SEE ALSO

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
