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
This commit is contained in:
+29
-10
@@ -360,21 +360,38 @@ void
|
|||||||
_set_system_font_(const char *which, font_family family, font_style style,
|
_set_system_font_(const char *which, font_family family, font_style style,
|
||||||
float size)
|
float size)
|
||||||
{
|
{
|
||||||
if (which == NULL || strcmp(which, "plain")
|
|
||||||
|| strcmp(which, "bold") || strcmp(which, "fixed"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_SET_SYSTEM_FONT);
|
link.StartMessage(AS_SET_SYSTEM_FONT);
|
||||||
link.AttachString(which);
|
link.AttachString(which, B_OS_NAME_LENGTH);
|
||||||
link.AttachString(family);
|
link.AttachString(family, sizeof(font_family));
|
||||||
link.AttachString(style);
|
link.AttachString(style, sizeof(font_style));
|
||||||
link.Attach<float>(size);
|
link.Attach<float>(size);
|
||||||
link.Flush();
|
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<float>(_size);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the number of installed font families
|
\brief Returns the number of installed font families
|
||||||
\return 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;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||||
link.AttachString(family);
|
link.AttachString(family, sizeof(font_family));
|
||||||
link.AttachString(style);
|
link.AttachString(style, sizeof(font_style));
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
link.Attach<uint16>(0xffff);
|
link.Attach<uint16>(0xffff);
|
||||||
link.Attach<uint16>(fFace);
|
link.Attach<uint16>(fFace);
|
||||||
@@ -600,7 +617,7 @@ BFont::SetFamilyAndFace(const font_family family, uint16 face)
|
|||||||
{
|
{
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS);
|
||||||
link.AttachString(family);
|
link.AttachString(family, sizeof(font_family));
|
||||||
link.AttachString(NULL); // no style given
|
link.AttachString(NULL); // no style given
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
link.Attach<uint16>(0xffff);
|
link.Attach<uint16>(0xffff);
|
||||||
@@ -985,6 +1002,8 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
|
|||||||
link.Attach<uint8>(fSpacing);
|
link.Attach<uint8>(fSpacing);
|
||||||
link.Attach<int32>(numStrings);
|
link.Attach<int32>(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++) {
|
for (int32 i = 0; i < numStrings; i++) {
|
||||||
link.Attach<int32>(lengthArray[i]);
|
link.Attach<int32>(lengthArray[i]);
|
||||||
link.AttachString(stringArray[i]);
|
link.AttachString(stringArray[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user