From f1d70d8037d222969a2b652c3bec05b424511b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 9 Nov 2005 18:37:01 +0000 Subject: [PATCH] New private function _get_system_default_font_() that makes the AS_GET_DEFAULT_SYSTEM_FONT command available to the fonts preferences. Now uses the maximum length argument for LinkSender::AttachString() it got from the API user. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14801 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Font.cpp | 39 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 71ecd51d99..bb4f5d4c87 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -360,21 +360,38 @@ void _set_system_font_(const char *which, font_family family, font_style style, float size) { - if (which == NULL || strcmp(which, "plain") - || strcmp(which, "bold") || strcmp(which, "fixed")) - return; - BPrivate::AppServerLink link; link.StartMessage(AS_SET_SYSTEM_FONT); - link.AttachString(which); - link.AttachString(family); - link.AttachString(style); + link.AttachString(which, B_OS_NAME_LENGTH); + link.AttachString(family, sizeof(font_family)); + link.AttachString(style, sizeof(font_style)); link.Attach(size); link.Flush(); } +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(_size); + return B_OK; +} + + /*! \brief Returns the number of installed font families \return The number of installed font families @@ -527,8 +544,8 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style) BPrivate::AppServerLink link; link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS); - link.AttachString(family); - link.AttachString(style); + link.AttachString(family, sizeof(font_family)); + link.AttachString(style, sizeof(font_style)); link.Attach(fFamilyID); link.Attach(0xffff); link.Attach(fFace); @@ -600,7 +617,7 @@ BFont::SetFamilyAndFace(const font_family family, uint16 face) { BPrivate::AppServerLink link; link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS); - link.AttachString(family); + link.AttachString(family, sizeof(font_family)); link.AttachString(NULL); // no style given link.Attach(fFamilyID); link.Attach(0xffff); @@ -985,6 +1002,8 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[], link.Attach(fSpacing); link.Attach(numStrings); + // TODO: all strings into a single array??? + // we do have a maximum message length, and it could be easily touched here... for (int32 i = 0; i < numStrings; i++) { link.Attach(lengthArray[i]); link.AttachString(stringArray[i]);