- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exponent::GUI::Fonts::CFont Class Reference

Inheritance diagram for Exponent::GUI::Fonts::CFont:

List of all members.

## Detailed Description

Font wrapper class.

Date:
  21/09/2004

Author:
  Paul Chana

Version:
  1.0.0 Initial version

Note:
  All contents of this source code are copyright 2005 Exp Digital Uk.
  This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
  with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
  Certain sections of this code may come from other sources. They are credited where applicable.
  If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk

Id
  CFont.hpp,v 1.6 2007/03/07 22:18:51 paul Exp

Definition at line 43 of file CFont.hpp.

## Public Member Functions

- CFont (const CFont &font)
- CFont (const CString &fontname="Arial", const unsigned long height=10)
- HFONT getFont () const
- const CString & getFontName () const
- long getFontSize () const
- long getHeight () const
- long getWidth () const
- CFont & operator= (const CFont &font)
- void setFont (const CString &fontName, const long height, const bool italic=false, const bool underline=false, const bool strike=false, const bool bold=false)
- void setFont (const CFontReference &font)
- void setFontName (const CString &fontname)
- void setHeight (const unsigned long height)
- virtual ~CFont ()

## Static Public Member Functions

- static void createDefaultFont ()
- static void destroyDefaultFont ()
- static long getFontSizeFromPointSize (const long pointSize)
- static long getStringLength (const CString &string, void *drawContext=NULL)

## Static Public Attributes

- static CFont * CFONT_SYSTEM_FONT

## Protected Member Functions

- void loadFont ()
- void unloadFont ()

## Protected Attributes

- HFONT m_fontHandle
- CString m_fontName
- long m_height
- LOGFONT m_logFont

## Constructor & Destructor Documentation

Exponent::GUI::Fonts::CFont::CFont | ( | const CString & | fontname = `"Arial"`,
|  | const unsigned long | height = `10` |
| ) |  |  |

Construction

Parameters:

  | fontname | The natural name of the font
  | height | The height of the font

Exponent::GUI::Fonts::CFont::CFont | ( | const CFont & | font | ) |

Copy Construction

Parameters:

  | font | The font to copy

virtual Exponent::GUI::Fonts::CFont::~CFont | ( |  | ) | `[virtual]`

Destruction

## Member Function Documentation

static void Exponent::GUI::Fonts::CFont::createDefaultFont | ( |  | ) | `[static]`

Create the defalt font

static void Exponent::GUI::Fonts::CFont::destroyDefaultFont | ( |  | ) | `[static]`

Destroy the default font

HFONT Exponent::GUI::Fonts::CFont::getFont | ( |  | ) | const`[inline]`

Get hte handle to the font

Return values:

  | HFONT | The windows font handle

Definition at line 124 of file CFont.hpp.

References m_fontHandle.

const CString& Exponent::GUI::Fonts::CFont::getFontName | ( |  | ) | const`[inline]`

Get the font name

Return values:

  | const | CString& The name of the font

Definition at line 149 of file CFont.hpp.

References m_fontName.

long Exponent::GUI::Fonts::CFont::getFontSize | ( |  | ) | const

Get the font size

Return values:

  | long | The font height

static long Exponent::GUI::Fonts::CFont::getFontSizeFromPointSize | ( | const long | pointSize | ) | `[static]`

Compute the size of a font given the point size

Parameters:

  | pointSize | The point size of a font

long Exponent::GUI::Fonts::CFont::getHeight | ( |  | ) | const

Get the font height

Return values:

  | long | The font height

static long Exponent::GUI::Fonts::CFont::getStringLength | ( | const CString & | string,
|  | void * | drawContext = `NULL` |
| ) |  |  | `[static]`

Get the length of a string in pixels

Parameters:

  | string | The string to comppute
  | drawContext | The drawContext, only needed for windows, on mac can be null

Return values:

  | long | The length of the string

long Exponent::GUI::Fonts::CFont::getWidth | ( |  | ) | const

Get the font width

Return values:

  | long | The font width

void Exponent::GUI::Fonts::CFont::loadFont | ( |  | ) | `[protected]`

Load the font

CFont& Exponent::GUI::Fonts::CFont::operator= | ( | const CFont & | font | ) |

Assignment operator

Parameters:

  | font | The font to copy

void Exponent::GUI::Fonts::CFont::setFont | ( | const CString & | fontName,
|  | const long | height,
|  | const bool | italic = `false`,
|  | const bool | underline = `false`,
|  | const bool | strike = `false`,
|  | const bool | bold = `false` |
| ) |  |  |

Set the font

Parameters:

  | fontName | The name of the font
  | height | The height of the font
  | italic | True if you want to draw in italic, false otherwise
  | underline | True if you want to underline the font, false otherwise
  | strike | True if you want to strike through the text, false otherwise
  | bold | True if you want a bold variant, false otherwise

Note:
  italic, underline, strike and bold are currently under development, they will work on windows, on mac they are still under construction

void Exponent::GUI::Fonts::CFont::setFont | ( | const CFontReference & | font | ) |

Set the font

Parameters:

  | font | The font to copy

void Exponent::GUI::Fonts::CFont::setFontName | ( | const CString & | fontname | ) |

SEt the filename (loads the font)

Parameters:

  | fontname | THe name of the font

void Exponent::GUI::Fonts::CFont::setHeight | ( | const unsigned long | height | ) |

Set the height

Parameters:

  | height | The height of the font

void Exponent::GUI::Fonts::CFont::unloadFont | ( |  | ) | `[protected]`

Unload the font

## Member Data Documentation

CFont* Exponent::GUI::Fonts::CFont::CFONT_SYSTEM_FONT`[static]`

The standard system font

Definition at line 55 of file CFont.hpp.

HFONT Exponent::GUI::Fonts::CFont::m_fontHandle`[protected]`

Handle to the font

Definition at line 198 of file CFont.hpp.

Referenced by getFont().

CString Exponent::GUI::Fonts::CFont::m_fontName`[protected]`

What is the name of the font

Definition at line 202 of file CFont.hpp.

Referenced by getFontName().

long Exponent::GUI::Fonts::CFont::m_height`[protected]`

The actual height

Definition at line 203 of file CFont.hpp.

LOGFONT Exponent::GUI::Fonts::CFont::m_logFont`[protected]`

The log font structure

Definition at line 199 of file CFont.hpp.