/*! \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); }
uint32 FontFamily::Flags() { if (fFlags == kInvalidFamilyFlags) { fFlags = 0; int32 count = fStyles.CountItems(); for (int32 i = 0; i < count; i++) { FontStyle* style = fStyles.ItemAt(i); if (style->IsFixedWidth()) fFlags |= B_IS_FIXED; if (style->IsFullAndHalfFixed()) fFlags |= B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED; if (style->TunedCount() > 0) fFlags |= B_HAS_TUNED_FONT; } } return fFlags; }
status_t DesktopSettingsPrivate::_Load() { // TODO: add support for old app_server_settings file as well BPath basePath; status_t status = _GetPath(basePath); if (status < B_OK) return status; // read workspaces settings BPath path(basePath); path.Append("workspaces"); BFile file; status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { int32 columns; int32 rows; if (settings.FindInt32("columns", &columns) == B_OK && settings.FindInt32("rows", &rows) == B_OK) { _ValidateWorkspacesLayout(columns, rows); fWorkspacesColumns = columns; fWorkspacesRows = rows; } int32 i = 0; while (i < kMaxWorkspaces && settings.FindMessage("workspace", i, &fWorkspaceMessages[i]) == B_OK) { i++; } } } // read font settings path = basePath; path.Append("fonts"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK && gFontManager->Lock()) { const char* family; const char* style; float size; if (settings.FindString("plain family", &family) == B_OK && settings.FindString("plain style", &style) == B_OK && settings.FindFloat("plain size", &size) == B_OK) { FontStyle* fontStyle = gFontManager->GetStyle(family, style); fPlainFont.SetStyle(fontStyle); fPlainFont.SetSize(size); } if (settings.FindString("bold family", &family) == B_OK && settings.FindString("bold style", &style) == B_OK && settings.FindFloat("bold size", &size) == B_OK) { FontStyle* fontStyle = gFontManager->GetStyle(family, style); fBoldFont.SetStyle(fontStyle); fBoldFont.SetSize(size); } if (settings.FindString("fixed family", &family) == B_OK && settings.FindString("fixed style", &style) == B_OK && settings.FindFloat("fixed size", &size) == B_OK) { FontStyle* fontStyle = gFontManager->GetStyle(family, style); if (fontStyle != NULL && fontStyle->IsFixedWidth()) fFixedFont.SetStyle(fontStyle); fFixedFont.SetSize(size); } int32 hinting; if (settings.FindInt32("hinting", &hinting) == B_OK) gDefaultHintingMode = hinting; gFontManager->Unlock(); } } // read mouse settings path = basePath; path.Append("mouse"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { int32 mode; if (settings.FindInt32("mode", &mode) == B_OK) fMouseMode = (mode_mouse)mode; int32 focusFollowsMouseMode; if (settings.FindInt32("focus follows mouse mode", &focusFollowsMouseMode) == B_OK) { fFocusFollowsMouseMode = (mode_focus_follows_mouse)focusFollowsMouseMode; } bool acceptFirstClick; if (settings.FindBool("accept first click", &acceptFirstClick) == B_OK) { fAcceptFirstClick = acceptFirstClick; } } } // read appearance settings path = basePath; path.Append("appearance"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { // menus float fontSize; if (settings.FindFloat("font size", &fontSize) == B_OK) fMenuInfo.font_size = fontSize; const char* fontFamily; if (settings.FindString("font family", &fontFamily) == B_OK) strlcpy(fMenuInfo.f_family, fontFamily, B_FONT_FAMILY_LENGTH); const char* fontStyle; if (settings.FindString("font style", &fontStyle) == B_OK) strlcpy(fMenuInfo.f_style, fontStyle, B_FONT_STYLE_LENGTH); rgb_color bgColor; if (settings.FindInt32("bg color", (int32*)&bgColor) == B_OK) fMenuInfo.background_color = bgColor; int32 separator; if (settings.FindInt32("separator", &separator) == B_OK) fMenuInfo.separator = separator; bool clickToOpen; if (settings.FindBool("click to open", &clickToOpen) == B_OK) fMenuInfo.click_to_open = clickToOpen; bool triggersAlwaysShown; if (settings.FindBool("triggers always shown", &triggersAlwaysShown) == B_OK) { fMenuInfo.triggers_always_shown = triggersAlwaysShown; } // scrollbars bool proportional; if (settings.FindBool("proportional", &proportional) == B_OK) fScrollBarInfo.proportional = proportional; bool doubleArrows; if (settings.FindBool("double arrows", &doubleArrows) == B_OK) fScrollBarInfo.double_arrows = doubleArrows; int32 knob; if (settings.FindInt32("knob", &knob) == B_OK) fScrollBarInfo.knob = knob; int32 minKnobSize; if (settings.FindInt32("min knob size", &minKnobSize) == B_OK) fScrollBarInfo.min_knob_size = minKnobSize; // subpixel font rendering bool subpix; if (settings.FindBool("subpixel antialiasing", &subpix) == B_OK) gSubpixelAntialiasing = subpix; int8 averageWeight; if (settings.FindInt8("subpixel average weight", &averageWeight) == B_OK) { gSubpixelAverageWeight = averageWeight; } bool subpixelOrdering; if (settings.FindBool("subpixel ordering", &subpixelOrdering) == B_OK) { gSubpixelOrderingRGB = subpixelOrdering; } // colors for (int32 i = 0; i < kNumColors; i++) { char colorName[12]; snprintf(colorName, sizeof(colorName), "color%" B_PRId32, (int32)index_to_color_which(i)); settings.FindInt32(colorName, (int32*)&fShared.colors[i]); } } } // read dragger settings path = basePath; path.Append("dragger"); status = file.SetTo(path.Path(), B_READ_ONLY); if (status == B_OK) { BMessage settings; status = settings.Unflatten(&file); if (status == B_OK) { if (settings.FindBool("show", &fShowAllDraggers) != B_OK) fShowAllDraggers = true; } } return B_OK; }