TTFontMan Class Reference

A static class to allow acces to TrueType fonts. More...

#include <ttfonts.h>

Inheritance diagram for TTFontMan:

CCObject SimpleCCObject List of all members.

Public Member Functions

 TTFontMan ()
 Default constructor.

Static Public Member Functions

static void EnumAllFonts (OILEnumFonts *pClass)
 Gives the kernel a way of enumerating fonts itself.

Static Private Member Functions

static BOOL IsOkToCall ()
 Determine whether we can make further calls to the TrueType Manager.
static BOOL CacheNamedFont (String_64 *pFont)
 This function attempts to cache a font of the true type variety. It caches the font in the kernels font list, and hence can be accessed via FONTMANAGER-> calls.
static BOOL CacheCompatibleFont (String_64 *pFont)
 This function attempts to cache a font of the ATM variety.
static void ValidateCache ()
 This function will attempt to recache all true type fonts within the kernels font manager cache.
static void FindClosestFont ()
 Enumerates all the fonts, looking for a match to a panose number.
static TTFontCreateNewFont (String_64 *pFontName)
 This function attempts to create a font instance and will be called by the font manager when new fonts are added.
static OUTLINETEXTMETRICGetOutlineTextMetric (LOGFONT *pLogFont)
 Retrieves the OUTLINETEXTMETRIC structure for a TrueType font.

Friends

class OILFontMan

Detailed Description

A static class to allow acces to TrueType fonts.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/95

Definition at line 143 of file ttfonts.h.


Constructor & Destructor Documentation

TTFontMan::TTFontMan  ) 
 

Default constructor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/09/95

Definition at line 171 of file ttfonts.cpp.

00172 {
00173 }


Member Function Documentation

BOOL TTFontMan::CacheCompatibleFont String_64 pFontName  )  [static, private]
 

This function attempts to cache a font of the ATM variety.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pFontName = a pointer to a fontname to find and cache [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 240 of file ttfonts.cpp.

00241 {
00242     return FALSE;
00243 }

BOOL TTFontMan::CacheNamedFont String_64 pFontName  )  [static, private]
 

This function attempts to cache a font of the true type variety. It caches the font in the kernels font list, and hence can be accessed via FONTMANAGER-> calls.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pFontName = a pointer to a fontname to find and cache [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the font has been cached FALSE if not.

Definition at line 208 of file ttfonts.cpp.

00209 {
00210     CDC Screen;
00211     if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
00212     {
00213         Application* pApp = GetApplication();
00214         FontManager* pFontMan = pApp->GetFontManager();
00215         ERROR2IF(pFontMan == NULL,FALSE,"NULL FontManager ptr");
00216         pFontMan->ClearTempFont();
00217         EnumFontFamilies(Screen.m_hDC,
00218                          NULL,
00219                          (FONTENUMPROC) TTFontMan_CallBackCacheNamedFont,
00220                          (LPARAM)pFontName);
00221         Screen.DeleteDC();
00222         return pFontMan->TempFontValid();
00223     }
00224     return FALSE;
00225 }

TTFont * TTFontMan::CreateNewFont String_64 pFontName  )  [static, private]
 

This function attempts to create a font instance and will be called by the font manager when new fonts are added.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pFontName = a pointer to a fontname [INPUTS]
Returns:
NULL if no true type font structure has been created A pointer to a true type font structure if successfull.

Definition at line 306 of file ttfonts.cpp.

00307 {
00308     TTFont *pFont = new TTFont;
00309     if (pFont==NULL)
00310         return NULL;
00311     if (!pFont->Initialise(pFontName))
00312     {
00313         delete pFont;
00314         return NULL;
00315     }
00316     return pFont;
00317 }

void TTFontMan::EnumAllFonts OILEnumFonts pClass  )  [static]
 

Gives the kernel a way of enumerating fonts itself.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pClass = A pointer to an object to call back. [INPUTS]

Definition at line 438 of file ttfonts.cpp.

00439 {
00440     CDC Screen;
00441     if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
00442     {
00443         EnumFontFamilies(Screen.m_hDC,
00444                          NULL,
00445                          (FONTENUMPROC) TTFontMan_CallBackDispatchFont,
00446                          (LPARAM)pClass);
00447         Screen.DeleteDC();
00448     }
00449 }

void TTFontMan::FindClosestFont  )  [static, private]
 

Enumerates all the fonts, looking for a match to a panose number.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/08/96

Definition at line 279 of file ttfonts.cpp.

00280 {
00281     CDC Screen;
00282     if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
00283     {
00284         EnumFontFamilies(Screen.m_hDC,
00285                          NULL,
00286                          (FONTENUMPROC) TTFontMan_CallBackFindClosestFont,
00287                          NULL);
00288         Screen.DeleteDC();
00289     }
00290 }

OUTLINETEXTMETRIC * TTFontMan::GetOutlineTextMetric LOGFONT pLogFont  )  [static, private]
 

Retrieves the OUTLINETEXTMETRIC structure for a TrueType font.

Author:
Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/08/96
Parameters:
pLogFont - pointer to the LOGFONT describing the font in question [INPUTS]
Returns:
pointer to an OUTLINETEXTMETRIC structure, or NULL if none exists.
The caller is responsible for deleting this after use.

Definition at line 333 of file ttfonts.cpp.

00334 {
00335     ERROR2IF(pLogFont==NULL, FALSE, "Parameter pLogFont==NULL.");
00336 
00337     // watch closely now - it gets fairly involved down here
00338 
00339     OUTLINETEXTMETRIC *pOutlineTextMetric = NULL;
00340     INT32 Value;
00341 
00342     CDC DisplayDC;
00343     if (DisplayDC.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
00344     {
00345         CFont *pNewCFont = new CFont;
00346 
00347         if (pNewCFont->CreateFontIndirect(pLogFont) != NULL)
00348         {
00349             //      **  **                                                  **   **
00350             //       ** **      must remember to select the old CFont        ** **
00351             //        ***       back in again when we've                      ***
00352             //       ** **      finished using this new CFont!               ** **
00353             //      **   **                                                 **   **
00354             
00355             CFont *pOldCFont = DisplayDC.SelectObject(pNewCFont);
00356             
00357             if (pOldCFont != NULL)
00358             {
00359                 TEXTMETRIC MyTextMetric;
00360 
00361                 if (DisplayDC.GetTextMetrics(&MyTextMetric) != 0)
00362                 {
00363                     if (MyTextMetric.tmPitchAndFamily & TMPF_TRUETYPE == TMPF_TRUETYPE)
00364                     {
00365                         // its a TrueType font, so get the OUTLINETEXTMETRIC structure and run
00366 
00367                         Value = DisplayDC.GetOutlineTextMetrics(NULL, NULL);
00368 
00369                         // claim a block of memory for the OUTLINETEXTMETRIC class
00370                         pOutlineTextMetric = (OUTLINETEXTMETRIC *) malloc(Value);
00371 
00372                         // now get the OUTLINETEXTMETRIC structure itself
00373                         Value = DisplayDC.GetOutlineTextMetrics(Value, pOutlineTextMetric);
00374 
00375                         if (Value==FALSE)
00376                         {
00377                             // failed to get the outline text metrics, so free the memory we claimed
00378                             free(pOutlineTextMetric);
00379                             pOutlineTextMetric=NULL;
00380                         }
00381                     }
00382                     else
00383                     {
00384                         // not a truetype font, so do nothing.
00385                     }
00386                 }
00387                 else
00388                 {
00389                     DisplayDC.SelectObject(pOldCFont);
00390                     DisplayDC.DeleteDC();
00391                     delete pNewCFont;
00392                     ERROR2(NULL, "Unable to retrieve TEXTMETRIC structure from DisplayDC.")
00393                 }
00394 
00395                 //      **  **                                                  **   **
00396                 //       ** **      select the old CFont back into the           ** **
00397                 //        ***       DC now we've finished using the               ***
00398                 //       ** **      new CFont!                                   ** **
00399                 //      **   **                                                 **   **
00400 
00401                 DisplayDC.SelectObject(pOldCFont);
00402             }
00403             else
00404             {
00405                 delete pNewCFont;
00406                 DisplayDC.DeleteDC();
00407                 ERROR2(NULL, "Unable to select font into IC.");
00408             }
00409         }
00410         else
00411         {
00412             delete pNewCFont;
00413             DisplayDC.DeleteDC();
00414             ERROR2(NULL, "Unable to create font.");
00415         }
00416         delete pNewCFont;
00417         DisplayDC.DeleteDC();
00418     }
00419     else
00420     {
00421         ERROR2(NULL, "Unable to create an IC.");
00422     }
00423 
00424     return pOutlineTextMetric;
00425 }

BOOL TTFontMan::IsOkToCall  )  [static, private]
 

Determine whether we can make further calls to the TrueType Manager.

static BOOL TTFontMan::IsOkToCall()

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
01/9/95
Returns:
TRUE if the TrueType mangler is actually running and can be used on this OpSys

Definition at line 186 of file ttfonts.cpp.

00187 {
00188     // Currently its always true as this is the winoil
00189     return TRUE;
00190 }

void TTFontMan::ValidateCache  )  [static, private]
 

This function will attempt to recache all true type fonts within the kernels font manager cache.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95

Definition at line 256 of file ttfonts.cpp.

00257 {
00258     CDC Screen;
00259     if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0))
00260     {
00261         EnumFontFamilies(Screen.m_hDC,
00262                          NULL,
00263                          (FONTENUMPROC) TTFontMan_CallBackValidateFont,
00264                          NULL);
00265         Screen.DeleteDC();
00266     }
00267 }


Friends And Related Function Documentation

friend class OILFontMan [friend]
 

Definition at line 147 of file ttfonts.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:28 2007 for Camelot by  doxygen 1.4.4