* Fixed GetGlyphShapes(). The BShapes that are outputted are correct now but the app_server still cannot draw them correctly.

* Changed the allocation to new for GetGlyphShapes() and GetEscapements() as the data is deleted in ServerApp.cpp
* Minor cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16231 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2006-02-04 22:20:00 +00:00
parent ec56c2c1dc
commit bb96bd0a70
4 changed files with 44 additions and 36 deletions
+1 -1
View File
@@ -612,7 +612,7 @@ FT_BEGIN_HEADER
/* accuracy during scan-conversion). The transformation is simple: */
/* */
/* x' = (x << shift) - delta */
/* y' = (x << shift) - delta */
/* y' = (y << shift) - delta */
/* */
/* Set the value of `shift' and `delta' to 0 to get the original */
/* point coordinates. */
+6 -4
View File
@@ -1274,7 +1274,7 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShape
// TODO: implement code specifically for passing BShapes to and from the server
if (!charArray || numChars < 1 || !glyphShapeArray)
return;
int32 code;
BPrivate::AppServerLink link;
@@ -1285,9 +1285,11 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShape
link.Attach<float>(fShear);
link.Attach<float>(fRotation);
link.Attach<uint32>(fFlags);
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 != B_OK)
@@ -1303,7 +1305,7 @@ BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) con
{
if (!charArray || numChars < 1 || !hasArray)
return;
int32 code;
BPrivate::AppServerLink link;
+12 -12
View File
@@ -1565,7 +1565,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
// 5) float - rotation
// 6) uint32 - flags
// 7) int32 - numChars
// 8) char - chars (numChars times)
// 8) int32 - numBytes
// 8) char - chars (bytesInBuffer times)
// Returns:
// 1) BShape - glyph shape
@@ -1582,11 +1583,12 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
link.Read<float>(&rotation);
link.Read<uint32>(&flags);
int32 numChars;
int32 numChars, numBytes;
link.Read<int32>(&numChars);
link.Read<int32>(&numBytes);
char charArray[numChars];
link.Read(&charArray, numChars);
char charArray[numBytes];
link.Read(&charArray, numBytes);
ServerFont font;
status_t status = font.SetFamilyAndStyle(familyID, styleID);
@@ -1620,21 +1622,19 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
// 1) uint16 - family ID
// 2) uint16 - style ID
// 3) int32 - numChars
// 4) int32 - numBytes
// 5) char - the char buffer with size numBytes
// 4) int32 - numBytes
// 5) char - the char buffer with size numBytes
uint16 familyID, styleID;
link.Read<uint16>(&familyID);
link.Read<uint16>(&styleID);
int32 numChars;
int32 numChars, numBytes;
link.Read<int32>(&numChars);
uint32 numBytes;
link.Read<uint32>(&numBytes);
link.Read<int32>(&numBytes);
char* charArray = new char[numBytes];
link.Read(charArray, numBytes);
ServerFont font;
status_t status = font.SetFamilyAndStyle(familyID, styleID);
if (status == B_OK) {
@@ -1738,7 +1738,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
fLink.Attach<BPoint>(escapements[i]);
}
delete escapements;
delete[] escapements;
} else
fLink.StartMessage(B_ERROR);
} else
+25 -19
View File
@@ -30,11 +30,12 @@ inline BPoint
VectorToPoint(FT_Vector *vector)
{
BPoint result;
result.x = float(int32(vector->x)) / 2097152;
result.y = -float(int32(vector->y)) / 2097152;
result.x = float(vector->x) / 64;
result.y = -float(vector->y) / 64;
return result;
}
int
MoveToFunc(FT_Vector *to, void *user)
{
@@ -42,6 +43,7 @@ MoveToFunc(FT_Vector *to, void *user)
return 0;
}
int
LineToFunc(FT_Vector *to, void *user)
{
@@ -49,34 +51,35 @@ LineToFunc(FT_Vector *to, void *user)
return 0;
}
int
ConicToFunc(FT_Vector *control, FT_Vector *to, void *user)
{
BPoint controls[3];
controls[0] = VectorToPoint(control);
controls[1] = VectorToPoint(to);
controls[2] = controls[1];
((BShape *)user)->BezierTo(controls);
return 0;
}
int
CubicToFunc(FT_Vector *control1, FT_Vector *control2, FT_Vector *to, void *user)
{
BPoint controls[3];
controls[0] = VectorToPoint(control1);
controls[1] = VectorToPoint(control2);
controls[2] = VectorToPoint(to);
((BShape *)user)->BezierTo(controls);
return 0;
}
// is_white_space
inline bool
is_white_space(uint16 glyph)
{
@@ -320,54 +323,57 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars) const
{
if (!charArray || numChars <= 0)
return NULL;
FT_Outline_Funcs funcs;
funcs.move_to = MoveToFunc;
funcs.line_to = LineToFunc;
funcs.conic_to = ConicToFunc;
funcs.cubic_to = CubicToFunc;
funcs.shift = 0;
funcs.delta = 0;
FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face)
return NULL;
FT_Set_Char_Size(face, 0, int32(fSize * 64), 72, 72);
Angle rotation(fRotation);
Angle shear(fShear);
// First, rotate
FT_Matrix rmatrix;
rmatrix.xx = (FT_Fixed)( rotation.Cosine()*0x10000);
rmatrix.xy = (FT_Fixed)(-rotation.Sine()*0x10000);
rmatrix.yx = (FT_Fixed)( rotation.Sine()*0x10000);
rmatrix.yy = (FT_Fixed)( rotation.Cosine()*0x10000);
// Next, shear
FT_Matrix smatrix;
smatrix.xx = (FT_Fixed)(0x10000);
smatrix.xy = (FT_Fixed)(-shear.Cosine()*0x10000);
smatrix.yx = (FT_Fixed)(0);
smatrix.yy = (FT_Fixed)(0x10000);
// Multiply togheter
FT_Matrix_Multiply(&rmatrix, &smatrix);
//FT_Vector pen;
//FT_Set_Transform(face, &smatrix, &pen);
BShape **shapes = (BShape **)malloc(sizeof(BShape *) * numChars);
BShape **shapes = new BShape *[numChars];
for (int i = 0; i < numChars; i++) {
shapes[i] = new BShape();
shapes[i]->Clear();
// TODO : this is wrong (the nth char isn't charArray[i])
FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP);
FT_Outline outline = face->glyph->outline;
FT_Outline_Decompose(&outline, &funcs, shapes[i]);
shapes[i]->Close();
}
return shapes;
}
@@ -500,7 +506,7 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
// of the BeBook. Have actual tests been done here?
// TODO: handle UTF8... see below!!
BPoint *escapements = (BPoint *)malloc(sizeof(BPoint) * numChars);
BPoint *escapements = new BPoint[numChars];
for (int i = 0; i < numChars; i++) {
// TODO : this is wrong (the nth char isn't charArray[i])
FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP);