#include <fontlist.h>
Public Member Functions | |
FontList () | |
Default constructor. | |
~FontList () | |
Default destructor, will remove all entries in the font list before it gets deleted. | |
BOOL | Build (Document *pDoc) |
Builds a list of font names, which are used in this document. Each item in the list contains a usage count too. | |
BOOL | AddItem (FontListItem *pFontListObj) |
Adds a font list item to our list. | |
FontListItem * | GetFirstItem () |
Lets you get the first Font object in the list. | |
FontListItem * | GetNextItem (FontListItem *pCurrItem) |
Lets you get the next font item in the list. | |
FontListItem * | FindFontMatch (const String_64 &FName, INT32 style, FontClass Class=FC_UNDEFINED) |
Trys to find the font name in our list. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (FontList) | |
BOOL | EnumerateItems (Node *pNode) |
Scans the entire tree from the node given on entry. All fonts used in this (sub)tree are compiled into a list. Font attributes of bold and italic are taken into account. Separate records are created if the same fontname has different style attributes applied in different areas of the tree. A usage count is also kept of every font found. | |
Private Attributes | |
List | TheFontList |
CCAttrMap | AppliedAtts |
Definition at line 162 of file fontlist.h.
|
Default constructor.
Definition at line 179 of file fontlist.cpp.
|
|
Default destructor, will remove all entries in the font list before it gets deleted.
Definition at line 196 of file fontlist.cpp. 00197 { 00198 TheFontList.DeleteAll(); 00199 }
|
|
Adds a font list item to our list.
Definition at line 374 of file fontlist.cpp. 00375 { 00376 TheFontList.AddTail(pFListItem); 00377 return TRUE; 00378 }
|
|
Builds a list of font names, which are used in this document. Each item in the list contains a usage count too.
Definition at line 217 of file fontlist.cpp. 00218 { 00219 ERROR2IF(pDoc==NULL,FALSE,"FontList::Build passed a NULL document"); 00220 00221 // Delete all previous entries 00222 TheFontList.DeleteAll(); 00223 00224 Node* pNode = pDoc->GetFirstNode(); 00225 ENSURE(pNode != NULL,"No first node!"); 00226 if (!EnumerateItems(pNode)) 00227 { 00228 TheFontList.DeleteAll(); 00229 return FALSE; 00230 } 00231 return TRUE; 00232 }
|
|
|
|
Scans the entire tree from the node given on entry. All fonts used in this (sub)tree are compiled into a list. Font attributes of bold and italic are taken into account. Separate records are created if the same fontname has different style attributes applied in different areas of the tree. A usage count is also kept of every font found.
Definition at line 254 of file fontlist.cpp. 00255 { 00256 while (pNode!=NULL) 00257 { 00258 if (IS_A(pNode,TextChar)) 00259 { 00260 TextChar* pChar = (TextChar*)pNode; 00261 AppliedAtts.RemoveAll(); 00262 00263 if (pChar->FindAppliedAttributes(&AppliedAtts)) 00264 { 00265 void* pFontName; 00266 00267 if( AppliedAtts.Lookup( CC_RUNTIME_CLASS(AttrTxtFontTypeface), pFontName ) ) 00268 { 00269 void *pBold, *pItalic; 00270 INT32 style=0; 00271 00272 if( AppliedAtts.Lookup( CC_RUNTIME_CLASS(AttrTxtBold), pBold ) ) 00273 { 00274 AttrTxtBold* pBoldAttr = (AttrTxtBold*) pBold; 00275 TxtBoldAttribute* pAttr = &(pBoldAttr->Value); 00276 if ((pAttr) && (pAttr->BoldOn)) 00277 style+=1; 00278 } 00279 00280 if( AppliedAtts.Lookup( CC_RUNTIME_CLASS(AttrTxtItalic), pItalic ) ) 00281 { 00282 AttrTxtItalic* pItalicAttr = (AttrTxtItalic*)pItalic; 00283 TxtItalicAttribute* pAttr = &(pItalicAttr->Value); 00284 if ((pAttr) && (pAttr->ItalicOn)) 00285 style+=2; 00286 } 00287 00288 AttrTxtFontTypeface* pFontAttr = (AttrTxtFontTypeface*)pFontName; 00289 00290 FontClass Class = FONTMANAGER->GetFontClass(pFontAttr->Value.HTypeface); 00291 00292 String_64 FName; 00293 if (FONTMANAGER->GetFontName(pFontAttr->Value.HTypeface, FName)) 00294 { 00295 FontListItem* FListObj = FindFontMatch(FName,style); 00296 if (FListObj) 00297 FListObj->IncUsage(); 00298 else 00299 { 00300 FListObj = new FontListItem; 00301 if (!FListObj) 00302 return FALSE; 00303 00304 FListObj->Initialise(FName,style, Class); 00305 AddItem(FListObj); 00306 } 00307 } 00308 } 00309 } 00310 } 00311 00312 Node* qNode=pNode->FindFirstChild(); 00313 if (qNode) 00314 { 00315 if (!EnumerateItems(qNode)) 00316 return FALSE; 00317 } 00318 00319 pNode=pNode->FindNext(); 00320 } 00321 00322 return TRUE; 00323 }
|
|
Trys to find the font name in our list.
Definition at line 344 of file fontlist.cpp. 00345 { 00346 FontListItem* pFont = GetFirstItem(); 00347 while (pFont!=NULL) 00348 { 00349 if ( (pFont->GetFontName()==fname) && 00350 (pFont->GetFontStyle()==style) && 00351 ((pFont->GetFontClass()==Class) || Class == FC_UNDEFINED) 00352 ) 00353 return pFont; 00354 00355 pFont = GetNextItem(pFont); 00356 } 00357 return NULL; 00358 }
|
|
Lets you get the first Font object in the list.
Definition at line 394 of file fontlist.cpp. 00395 { 00396 return ((FontListItem*)TheFontList.GetHead()); 00397 }
|
|
Lets you get the next font item in the list.
Definition at line 413 of file fontlist.cpp. 00414 { 00415 return ((FontListItem*)TheFontList.GetNext(pCurrFontItem)); 00416 }
|
|
Definition at line 181 of file fontlist.h. |
|
Definition at line 180 of file fontlist.h. |