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:
parent
1559de1285
commit
f2fd129852
|
@ -131,7 +131,7 @@ class ServerFont {
|
|||
escapement_delta delta) const;
|
||||
|
||||
bool GetBoundingBoxesAsString(const char charArray[],
|
||||
int32 numChars, BRect rectArray[],
|
||||
int32 numChars, BRect rectArray[], bool string_escapement,
|
||||
font_metric_mode mode, escapement_delta delta);
|
||||
|
||||
bool GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[],
|
||||
|
|
|
@ -2336,21 +2336,21 @@ BView::DrawChar(char c, BPoint location)
|
|||
void
|
||||
BView::DrawString(const char *string, escapement_delta *delta)
|
||||
{
|
||||
DrawString(string, strlen(string), PenLocation());
|
||||
DrawString(string, strlen(string), PenLocation(), delta);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BView::DrawString(const char *string, BPoint location, escapement_delta *delta)
|
||||
{
|
||||
DrawString(string, strlen(string), location);
|
||||
DrawString(string, strlen(string), location, delta);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
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);
|
||||
|
||||
// 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.Attach(rectArray, sizeof(rectArray));
|
||||
success = true;
|
||||
|
|
|
@ -526,7 +526,7 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
|
|||
|
||||
bool
|
||||
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)
|
||||
return false;
|
||||
|
@ -558,10 +558,18 @@ ServerFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, BRe
|
|||
numChars = min_c((uint32)numChars, convertedLength / sizeof(uint16));
|
||||
|
||||
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);
|
||||
if (face->glyph) {
|
||||
rectArray[i].left = float(face->glyph->metrics.horiBearingX) /64.0;
|
||||
rectArray[i].right = float(face->glyph->metrics.horiBearingX
|
||||
if (i<numChars-1)
|
||||
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;
|
||||
rectArray[i].top = -float(face->glyph->metrics.horiBearingY) /64.0;
|
||||
rectArray[i].bottom = float(face->glyph->metrics.height
|
||||
|
|
|
@ -2075,7 +2075,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||
if (fCurrentLayer && fCurrentLayer->fLayerData)
|
||||
driver->DrawString(string, length,
|
||||
fCurrentLayer->ConvertToTop(location),
|
||||
fCurrentLayer->fLayerData);
|
||||
fCurrentLayer->fLayerData, &delta);
|
||||
|
||||
free(string);
|
||||
break;
|
||||
|
|
|
@ -1075,7 +1075,7 @@ DisplayDriverPainter::DrawString(const char *string, const int32 &length,
|
|||
static DrawData d;
|
||||
d.SetHighColor(color);
|
||||
|
||||
DrawString(string, length, pt, &d);
|
||||
DrawString(string, length, pt, &d, delta);
|
||||
}
|
||||
*/
|
||||
// DrawString
|
||||
|
@ -1101,7 +1101,7 @@ DisplayDriverPainter::DrawString(const char* string, int32 length,
|
|||
fGraphicsCard->HideSoftwareCursor(b);
|
||||
|
||||
//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);
|
||||
|
||||
fGraphicsCard->Invalidate(touched);
|
||||
|
|
Loading…
Reference in New Issue