Fixed some communication mismatches I introduced earlier: we are no longer sending
whole font_family/style strings (each 64 bytes), but only strings, because they are usually shorter than 64 bytes. This should fix the StyleEdit problems Stefano were seeing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14628 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+24
-31
@@ -151,18 +151,18 @@ count_font_families(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int32
|
int32
|
||||||
count_font_styles(font_family name)
|
count_font_styles(font_family family)
|
||||||
{
|
{
|
||||||
int32 code, count;
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_COUNT_FONT_STYLES);
|
link.StartMessage(AS_COUNT_FONT_STYLES);
|
||||||
link.Attach(name, sizeof(font_family));
|
link.AttachString(family);
|
||||||
|
|
||||||
|
int32 code;
|
||||||
if (link.FlushWithReply(code) != B_OK
|
if (link.FlushWithReply(code) != B_OK
|
||||||
|| code != B_OK)
|
|| code != B_OK)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
int32 count;
|
||||||
link.Read<int32>(&count);
|
link.Read<int32>(&count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -177,28 +177,26 @@ count_font_styles(font_family name)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_font_family(int32 index, font_family *name, uint32 *flags)
|
get_font_family(int32 index, font_family *_name, uint32 *_flags)
|
||||||
{
|
{
|
||||||
// Fix over R5, which does not check for NULL font family names - it just crashes
|
if (_name == NULL)
|
||||||
if (!name)
|
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
int32 code;
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_GET_FAMILY_NAME);
|
link.StartMessage(AS_GET_FAMILY_NAME);
|
||||||
link.Attach<int32>(index);
|
link.Attach<int32>(index);
|
||||||
|
|
||||||
if (link.FlushWithReply(code) != B_OK
|
int32 status = B_ERROR;
|
||||||
|| code != B_OK)
|
if (link.FlushWithReply(status) != B_OK
|
||||||
return B_ERROR;
|
|| status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
link.Read<font_family>(name);
|
link.ReadString(*_name, sizeof(font_family));
|
||||||
|
|
||||||
uint32 value;
|
uint32 flags;
|
||||||
link.Read<uint32>(&value);
|
link.Read<uint32>(&flags);
|
||||||
if (flags)
|
if (_flags)
|
||||||
*flags = value;
|
*_flags = flags;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -549,13 +547,13 @@ BFont::GetFamilyAndStyle(font_family *family, font_style *style) const
|
|||||||
if (link.FlushWithReply(code) != B_OK
|
if (link.FlushWithReply(code) != B_OK
|
||||||
|| code != B_OK) {
|
|| code != B_OK) {
|
||||||
// the least we can do is to clear the buffers
|
// the least we can do is to clear the buffers
|
||||||
memset(family, 0, sizeof(font_family));
|
memset(*family, 0, sizeof(font_family));
|
||||||
memset(style, 0, sizeof(font_style));
|
memset(*style, 0, sizeof(font_style));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
link.Read<font_family>(family);
|
link.ReadString(*family, sizeof(font_family));
|
||||||
link.Read<font_style>(style);
|
link.ReadString(*style, sizeof(font_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -847,9 +845,7 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
|
|||||||
if (!stringArray || !lengthArray || numStrings < 1 || !widthArray)
|
if (!stringArray || !lengthArray || numStrings < 1 || !widthArray)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int32 code;
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_GET_STRING_WIDTHS);
|
link.StartMessage(AS_GET_STRING_WIDTHS);
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
link.Attach<uint16>(fStyleID);
|
link.Attach<uint16>(fStyleID);
|
||||||
@@ -862,6 +858,7 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
|
|||||||
link.AttachString(stringArray[i]);
|
link.AttachString(stringArray[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 code;
|
||||||
if (link.FlushWithReply(code) != B_OK
|
if (link.FlushWithReply(code) != B_OK
|
||||||
|| code != B_OK)
|
|| code != B_OK)
|
||||||
return;
|
return;
|
||||||
@@ -884,11 +881,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
|
|||||||
if (!charArray || numChars < 1 || !escapementArray)
|
if (!charArray || numChars < 1 || !escapementArray)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: The R5 implementation crashes if delta == NULL!
|
|
||||||
|
|
||||||
int32 code;
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_GET_ESCAPEMENTS_AS_FLOATS);
|
link.StartMessage(AS_GET_ESCAPEMENTS_AS_FLOATS);
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
link.Attach<uint16>(fStyleID);
|
link.Attach<uint16>(fStyleID);
|
||||||
@@ -898,7 +891,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
|
|||||||
|
|
||||||
link.Attach<float>(delta ? delta->nonspace : 0.0);
|
link.Attach<float>(delta ? delta->nonspace : 0.0);
|
||||||
link.Attach<float>(delta ? delta->space : 0.0);
|
link.Attach<float>(delta ? delta->space : 0.0);
|
||||||
|
|
||||||
// TODO: Should we not worry about the port capacity here?!?
|
// TODO: Should we not worry about the port capacity here?!?
|
||||||
link.Attach<int32>(numChars);
|
link.Attach<int32>(numChars);
|
||||||
|
|
||||||
@@ -906,6 +899,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
|
|||||||
link.Attach<int32>(bytesInBuffer);
|
link.Attach<int32>(bytesInBuffer);
|
||||||
link.Attach(charArray, bytesInBuffer);
|
link.Attach(charArray, bytesInBuffer);
|
||||||
|
|
||||||
|
int32 code;
|
||||||
if (link.FlushWithReply(code) != B_OK
|
if (link.FlushWithReply(code) != B_OK
|
||||||
|| code != B_OK)
|
|| code != B_OK)
|
||||||
return;
|
return;
|
||||||
@@ -929,9 +923,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
|
|||||||
if (!charArray || numChars < 1 || !escapementArray)
|
if (!charArray || numChars < 1 || !escapementArray)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int32 code;
|
|
||||||
BPrivate::AppServerLink link;
|
BPrivate::AppServerLink link;
|
||||||
|
|
||||||
link.StartMessage(AS_GET_ESCAPEMENTS);
|
link.StartMessage(AS_GET_ESCAPEMENTS);
|
||||||
link.Attach<uint16>(fFamilyID);
|
link.Attach<uint16>(fFamilyID);
|
||||||
link.Attach<uint16>(fStyleID);
|
link.Attach<uint16>(fStyleID);
|
||||||
@@ -956,6 +948,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 code;
|
||||||
if (link.FlushWithReply(code) != B_OK
|
if (link.FlushWithReply(code) != B_OK
|
||||||
|| code != B_OK)
|
|| code != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1230,19 +1230,12 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
link.Read<uint16>(&styleID);
|
link.Read<uint16>(&styleID);
|
||||||
|
|
||||||
gFontServer->Lock();
|
gFontServer->Lock();
|
||||||
|
|
||||||
FontStyle *fontStyle = gFontServer->GetStyle(familyID, styleID);
|
FontStyle *fontStyle = gFontServer->GetStyle(familyID, styleID);
|
||||||
if (fontStyle != NULL) {
|
if (fontStyle != NULL) {
|
||||||
font_family family;
|
|
||||||
font_style style;
|
|
||||||
|
|
||||||
strncpy(family, fontStyle->Family()->Name(), sizeof(font_family) - 1);
|
|
||||||
family[sizeof(font_family) - 1] = 0;
|
|
||||||
strncpy(style, fontStyle->Name(), sizeof(font_style) - 1);
|
|
||||||
style[sizeof(font_style) - 1] = 0;
|
|
||||||
|
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach(family, sizeof(font_family));
|
fLink.AttachString(fontStyle->Family()->Name());
|
||||||
fLink.Attach(style, sizeof(font_style));
|
fLink.AttachString(fontStyle->Name());
|
||||||
} else
|
} else
|
||||||
fLink.StartMessage(B_BAD_VALUE);
|
fLink.StartMessage(B_BAD_VALUE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user