/*! \brief This saves all family names and styles to the file specified in ServerConfig.h as SERVER_FONT_LIST as a flattened BMessage. This operation is not done very often because the access to disk adds a significant performance hit. The format for storage consists of two things: an array of strings with the name 'family' and a number of small string arrays which have the name of the font family. These are the style lists. Additionally, any fonts which have bitmap strikes contained in them or any fonts which are fixed-width are named in the arrays 'tuned' and 'fixed'. */ void FontServer::SaveList(void) { int32 famcount=0, stycount=0,i=0,j=0; FontFamily *fam; FontStyle *sty; BMessage fontmsg, familymsg('FONT'); BString famname, styname, extraname; bool fixed,tuned; famcount=families->CountItems(); for(i=0; i<famcount; i++) { fam=(FontFamily*)families->ItemAt(i); fixed=false; tuned=false; if(!fam) continue; famname=fam->Name(); // Add the family to the message familymsg.AddString("name",famname); stycount=fam->CountStyles(); for(j=0;j<stycount;j++) { styname.SetTo(fam->GetStyle(j)); if(styname.CountChars()>0) { // Add to list familymsg.AddString("styles", styname); // Check to see if it has prerendered strikes (has "tuned" fonts) sty=fam->GetStyle(styname.String()); if(!sty) continue; if(sty->HasTuned() && sty->IsScalable()) tuned=true; // Check to see if it is fixed-width if(sty->IsFixedWidth()) fixed=true; } } if(tuned) familymsg.AddBool("tuned",true); if(fixed) familymsg.AddBool("fixed",true); fontmsg.AddMessage("family",&familymsg); familymsg.MakeEmpty(); } BFile file(SERVER_FONT_LIST,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if(file.InitCheck()==B_OK) fontmsg.Flatten(&file); }