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