added escapement_delta to AGGTextRenderer::RenderString and Painter

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14095 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2005-08-31 14:50:42 +00:00
parent 3c40c4cead
commit 7f74cecda3
5 changed files with 27 additions and 9 deletions
@@ -1093,7 +1093,7 @@ DisplayDriverPainter::DrawString(const char* string, int32 length,
// TODO: make the availability of the hardware cursor part of the // TODO: make the availability of the hardware cursor part of the
// HW acceleration flags and skip all calculations for HideSoftwareCursor // HW acceleration flags and skip all calculations for HideSoftwareCursor
// in case we don't have one. // in case we don't have one.
BRect b = fPainter->BoundingBox(string, length, pt); BRect b = fPainter->BoundingBox(string, length, pt, delta);
// stop here if we're supposed to render outside of the clipping // stop here if we're supposed to render outside of the clipping
b = fPainter->ClipRect(b); b = fPainter->ClipRect(b);
if (b.IsValid()) { if (b.IsValid()) {
+6 -3
View File
@@ -899,7 +899,8 @@ Painter::DrawString(const char* utf8String, uint32 length,
baseLine, baseLine,
fClippingRegion->Frame(), fClippingRegion->Frame(),
false, false,
&fPenLocation); &fPenLocation,
delta);
} }
return _Clipped(bounds); return _Clipped(bounds);
} }
@@ -985,14 +986,16 @@ Painter::InvertRect(const BRect& r) const
// BoundingBox // BoundingBox
BRect BRect
Painter::BoundingBox(const char* utf8String, uint32 length, Painter::BoundingBox(const char* utf8String, uint32 length,
const BPoint& baseLine) const const BPoint& baseLine, const escapement_delta* delta) const
{ {
static BRect dummy; static BRect dummy;
BPoint penPosition;
return fTextRenderer->RenderString(utf8String, return fTextRenderer->RenderString(utf8String,
length, length,
fFontRendererSolid, fFontRendererSolid,
fFontRendererBin, fFontRendererBin,
baseLine, dummy, true); baseLine, dummy, true, &penPosition,
delta);
} }
// StringWidth // StringWidth
+2 -3
View File
@@ -204,9 +204,8 @@ class Painter {
BRect InvertRect( const BRect& r) const; BRect InvertRect( const BRect& r) const;
BRect BoundingBox( const char* utf8String, BRect BoundingBox( const char* utf8String, uint32 length,
uint32 length, const BPoint& baseLine, const escapement_delta* delta = NULL) const;
const BPoint& baseLine) const;
float StringWidth( const char* utf8String, float StringWidth( const char* utf8String,
uint32 length) const; uint32 length) const;
@@ -41,6 +41,17 @@ rect_to_int(BRect r,
bottom = (int32)ceilf(r.bottom); bottom = (int32)ceilf(r.bottom);
} }
// is_white_space
inline bool
is_white_space(uint16 glyph)
{
// TODO: handle them all!
if (glyph == ' ' || glyph == B_TAB)
return true;
return false;
}
#define DEFAULT_UNI_CODE_BUFFER_SIZE 2048 #define DEFAULT_UNI_CODE_BUFFER_SIZE 2048
// constructor // constructor
@@ -150,7 +161,8 @@ AGGTextRenderer::RenderString(const char* string,
const BPoint& baseLine, const BPoint& baseLine,
const BRect& clippingFrame, const BRect& clippingFrame,
bool dryRun, bool dryRun,
BPoint* nextCharPos) BPoint* nextCharPos,
const escapement_delta* delta)
{ {
//printf("RenderString(\"%s\", length: %ld, dry: %d)\n", string, length, dryRun); //printf("RenderString(\"%s\", length: %ld, dry: %d)\n", string, length, dryRun);
@@ -210,6 +222,9 @@ AGGTextRenderer::RenderString(const char* string,
x += advanceX; x += advanceX;
y += advanceY; y += advanceY;
if (delta)
x += is_white_space(*p) ? delta->space : delta->nonspace;
// "glyphBounds" is the bounds of the glyph transformed // "glyphBounds" is the bounds of the glyph transformed
// by the x y location of the glyph along the base line, // by the x y location of the glyph along the base line,
// it is therefor yet "untransformed". // it is therefor yet "untransformed".
@@ -41,7 +41,8 @@ class AGGTextRenderer {
const BPoint& baseLine, const BPoint& baseLine,
const BRect& clippingFrame, const BRect& clippingFrame,
bool dryRun = false, bool dryRun = false,
BPoint* nextCharPos = NULL); BPoint* nextCharPos = NULL,
const escapement_delta* delta = NULL);
double StringWidth(const char* utf8String, double StringWidth(const char* utf8String,
uint32 length); uint32 length);