implemented GetHasGlyphs for real
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14056 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
faccea3911
commit
2185eed6d2
@ -1174,7 +1174,10 @@ BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) con
|
||||
link.Attach<uint16>(fFamilyID);
|
||||
link.Attach<uint16>(fStyleID);
|
||||
link.Attach<int32>(numChars);
|
||||
link.Attach(charArray, numChars);
|
||||
|
||||
uint32 bytesInBuffer = UTF8CountBytes(charArray, numChars);
|
||||
link.Attach<int32>(bytesInBuffer);
|
||||
link.Attach(charArray, bytesInBuffer);
|
||||
|
||||
if (link.FlushWithReply(code) != B_OK
|
||||
|| code != SERVER_TRUE)
|
||||
|
@ -1740,15 +1740,20 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
// 1) uint16 - family ID
|
||||
// 2) uint16 - style ID
|
||||
// 3) int32 - numChars
|
||||
// 4) char - chars (numChars times)
|
||||
// 4) int32 - numBytes
|
||||
// 5) char - the char buffer with size numBytes
|
||||
|
||||
uint16 famid, styid;
|
||||
link.Read<uint16>(&famid);
|
||||
link.Read<uint16>(&styid);
|
||||
int32 numChars;
|
||||
link.Read<int32>(&numChars);
|
||||
char charArray[numChars];
|
||||
link.Read(&charArray, numChars);
|
||||
|
||||
uint32 numBytes;
|
||||
link.Read<uint32>(&numBytes);
|
||||
|
||||
char* charArray = new char[numBytes];
|
||||
link.Read(charArray, numBytes);
|
||||
|
||||
ServerFont font;
|
||||
if (font.SetFamilyAndStyle(famid, styid) == B_OK) {
|
||||
|
@ -339,11 +339,42 @@ ServerFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]
|
||||
if (!fStyle || !charArray || numChars <= 0 || !hasArray)
|
||||
return;
|
||||
|
||||
// TODO : implement for real
|
||||
FT_Face face = fStyle->GetFTFace();
|
||||
if (!face)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < numChars; i++) {
|
||||
FT_Set_Char_Size(face, 0, int32(fSize * 64), 72, 72);
|
||||
|
||||
// UTF8 handling...this can probably be smarter
|
||||
// Here is what I do in the AGGTextRenderer to handle UTF8...
|
||||
// It is probably highly inefficient, so it should be reviewed.
|
||||
int32 numBytes = UTF8CountBytes(charArray, numChars);
|
||||
int32 convertedLength = numBytes * 2;
|
||||
char* convertedBuffer = new char[convertedLength];
|
||||
|
||||
int32 state = 0;
|
||||
status_t ret;
|
||||
if ((ret = convert_from_utf8(B_UNICODE_CONVERSION,
|
||||
charArray, &numBytes,
|
||||
convertedBuffer, &convertedLength,
|
||||
&state, B_SUBSTITUTE)) >= B_OK
|
||||
&& (ret = swap_data(B_INT16_TYPE, convertedBuffer, convertedLength,
|
||||
B_SWAP_BENDIAN_TO_HOST)) >= B_OK) {
|
||||
|
||||
uint16* glyphIndex = (uint16*)convertedBuffer;
|
||||
// just to be sure
|
||||
numChars = min_c((uint32)numChars, convertedLength / sizeof(uint16));
|
||||
|
||||
for (int i = 0; i < numChars; i++) {
|
||||
hasArray[i] = FT_Get_Char_Index(face, glyphIndex[i]) > 0;
|
||||
}
|
||||
}
|
||||
delete[] convertedBuffer;
|
||||
|
||||
|
||||
/*for (int i = 0; i < numChars; i++) {
|
||||
hasArray[i] = true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user