now uses delta escapement
improved GetBoundingBoxesAsString (just for fun, keep in mind we'll use AGGTextRenderer in the end :) ) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14091 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -131,7 +131,7 @@ class ServerFont {
|
|||||||
escapement_delta delta) const;
|
escapement_delta delta) const;
|
||||||
|
|
||||||
bool GetBoundingBoxesAsString(const char charArray[],
|
bool GetBoundingBoxesAsString(const char charArray[],
|
||||||
int32 numChars, BRect rectArray[],
|
int32 numChars, BRect rectArray[], bool string_escapement,
|
||||||
font_metric_mode mode, escapement_delta delta);
|
font_metric_mode mode, escapement_delta delta);
|
||||||
|
|
||||||
bool GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[],
|
bool GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[],
|
||||||
|
|||||||
@@ -2336,21 +2336,21 @@ BView::DrawChar(char c, BPoint location)
|
|||||||
void
|
void
|
||||||
BView::DrawString(const char *string, escapement_delta *delta)
|
BView::DrawString(const char *string, escapement_delta *delta)
|
||||||
{
|
{
|
||||||
DrawString(string, strlen(string), PenLocation());
|
DrawString(string, strlen(string), PenLocation(), delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BView::DrawString(const char *string, BPoint location, escapement_delta *delta)
|
BView::DrawString(const char *string, BPoint location, escapement_delta *delta)
|
||||||
{
|
{
|
||||||
DrawString(string, strlen(string), location);
|
DrawString(string, strlen(string), location, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BView::DrawString(const char *string, int32 length, escapement_delta *delta)
|
BView::DrawString(const char *string, int32 length, escapement_delta *delta)
|
||||||
{
|
{
|
||||||
DrawString(string, length, PenLocation());
|
DrawString(string, length, PenLocation(), delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2008,7 +2008,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
font.SetFlags(flags);
|
font.SetFlags(flags);
|
||||||
|
|
||||||
// TODO implement for real
|
// TODO implement for real
|
||||||
if (font.GetBoundingBoxesAsString(charArray, numChars, rectArray, mode, delta)) {
|
if (font.GetBoundingBoxesAsString(charArray, numChars, rectArray, string_escapement, mode, delta)) {
|
||||||
fLink.StartMessage(SERVER_TRUE);
|
fLink.StartMessage(SERVER_TRUE);
|
||||||
fLink.Attach(rectArray, sizeof(rectArray));
|
fLink.Attach(rectArray, sizeof(rectArray));
|
||||||
success = true;
|
success = true;
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
ServerFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, BRect rectArray[],
|
ServerFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, BRect rectArray[],
|
||||||
font_metric_mode mode, escapement_delta delta)
|
bool string_escapement, font_metric_mode mode, escapement_delta delta)
|
||||||
{
|
{
|
||||||
if (!fStyle || !charArray || numChars <= 0 || !rectArray)
|
if (!fStyle || !charArray || numChars <= 0 || !rectArray)
|
||||||
return false;
|
return false;
|
||||||
@@ -558,10 +558,18 @@ ServerFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, BRe
|
|||||||
numChars = min_c((uint32)numChars, convertedLength / sizeof(uint16));
|
numChars = min_c((uint32)numChars, convertedLength / sizeof(uint16));
|
||||||
|
|
||||||
for (int i = 0; i < numChars; i++) {
|
for (int i = 0; i < numChars; i++) {
|
||||||
|
if (string_escapement) {
|
||||||
|
if (i>0)
|
||||||
|
rectArray[i].OffsetBy(is_white_space(glyphIndex[i-1]) ? delta.space/2.0 : delta.nonspace/2.0, 0.0);
|
||||||
|
rectArray[i].OffsetBy(is_white_space(glyphIndex[i]) ? delta.space/2.0 : delta.nonspace/2.0, 0.0);
|
||||||
|
}
|
||||||
FT_Load_Char(face, glyphIndex[i], FT_LOAD_NO_BITMAP);
|
FT_Load_Char(face, glyphIndex[i], FT_LOAD_NO_BITMAP);
|
||||||
if (face->glyph) {
|
if (face->glyph) {
|
||||||
rectArray[i].left = float(face->glyph->metrics.horiBearingX) /64.0;
|
if (i<numChars-1)
|
||||||
rectArray[i].right = float(face->glyph->metrics.horiBearingX
|
rectArray[i+1].left = rectArray[i+1].right = rectArray[i].left +
|
||||||
|
face->glyph->metrics.horiAdvance / 64.0;
|
||||||
|
rectArray[i].left += float(face->glyph->metrics.horiBearingX) /64.0;
|
||||||
|
rectArray[i].right += float(face->glyph->metrics.horiBearingX
|
||||||
+ face->glyph->metrics.width)/64.0;
|
+ face->glyph->metrics.width)/64.0;
|
||||||
rectArray[i].top = -float(face->glyph->metrics.horiBearingY) /64.0;
|
rectArray[i].top = -float(face->glyph->metrics.horiBearingY) /64.0;
|
||||||
rectArray[i].bottom = float(face->glyph->metrics.height
|
rectArray[i].bottom = float(face->glyph->metrics.height
|
||||||
|
|||||||
@@ -2075,7 +2075,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
||||||
driver->DrawString(string, length,
|
driver->DrawString(string, length,
|
||||||
fCurrentLayer->ConvertToTop(location),
|
fCurrentLayer->ConvertToTop(location),
|
||||||
fCurrentLayer->fLayerData);
|
fCurrentLayer->fLayerData, &delta);
|
||||||
|
|
||||||
free(string);
|
free(string);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1075,7 +1075,7 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length,
|
|||||||
static DrawData d;
|
static DrawData d;
|
||||||
d.SetHighColor(color);
|
d.SetHighColor(color);
|
||||||
|
|
||||||
DrawString(string, length, pt, &d);
|
DrawString(string, length, pt, &d, delta);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// DrawString
|
// DrawString
|
||||||
@@ -1101,7 +1101,7 @@ DisplayDriverPainter::DrawString(const char* string, int32 length,
|
|||||||
fGraphicsCard->HideSoftwareCursor(b);
|
fGraphicsCard->HideSoftwareCursor(b);
|
||||||
|
|
||||||
//now = system_time();
|
//now = system_time();
|
||||||
BRect touched = fPainter->DrawString(string, length, pt);
|
BRect touched = fPainter->DrawString(string, length, pt, delta);
|
||||||
//printf("drawing string: %lld µs\n", system_time() - now);
|
//printf("drawing string: %lld µs\n", system_time() - now);
|
||||||
|
|
||||||
fGraphicsCard->Invalidate(touched);
|
fGraphicsCard->Invalidate(touched);
|
||||||
|
|||||||
Reference in New Issue
Block a user