void BFont::GetFamilyAndStyle(font_family* family, font_style* style) const { if (family == NULL && style == NULL) return; // it's okay to call this function with either family or style set to NULL font_family familyBuffer; font_style styleBuffer; if (family == NULL) family = &familyBuffer; if (style == NULL) style = &styleBuffer; BPrivate::AppServerLink link; link.StartMessage(AS_GET_FAMILY_AND_STYLE); link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fStyleID); int32 code; if (link.FlushWithReply(code) != B_OK || code != B_OK) { // the least we can do is to clear the buffers memset(*family, 0, sizeof(font_family)); memset(*style, 0, sizeof(font_style)); return; } link.ReadString(*family, sizeof(font_family)); link.ReadString(*style, sizeof(font_style)); }
status_t _get_system_default_font_(const char* which, font_family family, font_style style, float* _size) { BPrivate::AppServerLink link; link.StartMessage(AS_GET_SYSTEM_DEFAULT_FONT); link.AttachString(which, B_OS_NAME_LENGTH); int32 status = B_ERROR; if (link.FlushWithReply(status) != B_OK || status < B_OK) return status; link.ReadString(family, sizeof(font_family)); link.ReadString(style, sizeof(font_style)); link.Read<float>(_size); return B_OK; }
/*! \brief queries the server for the current decorator \param ref entry_ref into which to store current decorator's location \return boolean true/false */ bool get_decorator(BString& path) { BPrivate::AppServerLink link; link.StartMessage(AS_GET_DECORATOR); int32 code; if (link.FlushWithReply(code) != B_OK || code != B_OK) return false; return link.ReadString(path) == B_OK; }
/*! \brief queries the server for the name of the decorator with a certain index \param index The index of the decorator to get the name for \param name BString to receive the name of the decorator \return B_OK if successful, B_ERROR if not */ status_t get_decorator_name(const int32 &index, BString &name) { BPrivate::AppServerLink link; link.StartMessage(AS_GET_DECORATOR_NAME); link.Attach<int32>(index); int32 code; if (link.FlushWithReply(code) == B_OK && code == B_OK) { char *string; if (link.ReadString(&string) == B_OK) { name = string; free(string); return B_OK; } } return B_ERROR; }
void _init_global_fonts_() { BPrivate::AppServerLink link; link.StartMessage(AS_GET_SYSTEM_FONTS); int32 code; if (link.FlushWithReply(code) != B_OK || code != B_OK) { printf("DEBUG: Couldn't initialize global fonts!\n"); return; } char type[B_OS_NAME_LENGTH]; while (link.ReadString(type, sizeof(type)) >= B_OK && type[0]) { BFont dummy; BFont* font = &dummy; if (!strcmp(type, "plain")) font = &sPlainFont; else if (!strcmp(type, "bold")) font = &sBoldFont; else if (!strcmp(type, "fixed")) font = &sFixedFont; link.Read<uint16>(&font->fFamilyID); link.Read<uint16>(&font->fStyleID); link.Read<float>(&font->fSize); link.Read<uint16>(&font->fFace); link.Read<uint32>(&font->fFlags); font->fHeight.ascent = kUninitializedAscent; font->fExtraFlags = kUninitializedExtraFlags; } }