* added a version of SetFont() that takes a DrawState* to DrawingEngine and

Painter, that is needed to be able to tell if anti-aliasing is to be used,
  since the flags in the font can be overruled by the flags in the view...
* fixes aliased fonts reliably, tested with FontDemo


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21869 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2007-08-09 09:48:28 +00:00
parent 98eadf4b9d
commit fe914c98b4
5 changed files with 31 additions and 14 deletions
+1 -2
View File
@@ -1271,9 +1271,8 @@ ServerWindow::_DispatchViewMessage(int32 code,
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: ViewLayer name: %s\n", fTitle, fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: ViewLayer name: %s\n", fTitle, fCurrentLayer->Name()));
fCurrentLayer->CurrentState()->ReadFontFromLink(link); fCurrentLayer->CurrentState()->ReadFontFromLink(link);
// _UpdateDrawState(fCurrentLayer);
fWindowLayer->GetDrawingEngine()->SetFont( fWindowLayer->GetDrawingEngine()->SetFont(
fCurrentLayer->CurrentState()->Font()); fCurrentLayer->CurrentState());
break; break;
} }
case AS_LAYER_GET_STATE: case AS_LAYER_GET_STATE:
+16 -9
View File
@@ -185,28 +185,28 @@ DrawingEngine::ConstrainClippingRegion(const BRegion* region)
void void
DrawingEngine::SetDrawState(const DrawState* state, int32 xOffset, int32 yOffset) DrawingEngine::SetDrawState(const DrawState* state, int32 xOffset, int32 yOffset)
{ {
fPainter->SetDrawState(state, xOffset, yOffset); fPainter->SetDrawState(state, xOffset, yOffset);
} }
void void
DrawingEngine::SetHighColor(const rgb_color& color) DrawingEngine::SetHighColor(const rgb_color& color)
{ {
fPainter->SetHighColor(color); fPainter->SetHighColor(color);
} }
void void
DrawingEngine::SetLowColor(const rgb_color& color) DrawingEngine::SetLowColor(const rgb_color& color)
{ {
fPainter->SetLowColor(color); fPainter->SetLowColor(color);
} }
void void
DrawingEngine::SetPenSize(float size) DrawingEngine::SetPenSize(float size)
{ {
fPainter->SetPenSize(size); fPainter->SetPenSize(size);
} }
@@ -214,35 +214,42 @@ void
DrawingEngine::SetStrokeMode(cap_mode lineCap, join_mode joinMode, DrawingEngine::SetStrokeMode(cap_mode lineCap, join_mode joinMode,
float miterLimit) float miterLimit)
{ {
fPainter->SetStrokeMode(lineCap, joinMode, miterLimit); fPainter->SetStrokeMode(lineCap, joinMode, miterLimit);
} }
void void
DrawingEngine::SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc) DrawingEngine::SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc)
{ {
fPainter->SetBlendingMode(srcAlpha, alphaFunc); fPainter->SetBlendingMode(srcAlpha, alphaFunc);
} }
void void
DrawingEngine::SetPattern(const struct pattern& pattern) DrawingEngine::SetPattern(const struct pattern& pattern)
{ {
fPainter->SetPattern(pattern, false); fPainter->SetPattern(pattern, false);
} }
void void
DrawingEngine::SetDrawingMode(drawing_mode mode) DrawingEngine::SetDrawingMode(drawing_mode mode)
{ {
fPainter->SetDrawingMode(mode); fPainter->SetDrawingMode(mode);
} }
void void
DrawingEngine::SetFont(const ServerFont& font) DrawingEngine::SetFont(const ServerFont& font)
{ {
fPainter->SetFont(font); fPainter->SetFont(font);
}
void
DrawingEngine::SetFont(const DrawState* state)
{
fPainter->SetFont(state);
} }
+1
View File
@@ -79,6 +79,7 @@ public:
void SetBlendingMode(source_alpha srcAlpha, void SetBlendingMode(source_alpha srcAlpha,
alpha_function alphaFunc); alpha_function alphaFunc);
void SetFont(const ServerFont& font); void SetFont(const ServerFont& font);
void SetFont(const DrawState* state);
void SuspendAutoSync(); void SuspendAutoSync();
void Sync(); void Sync();
+12 -3
View File
@@ -130,9 +130,7 @@ Painter::SetDrawState(const DrawState* data, int32 xOffset, int32 yOffset)
// but for now... // but for now...
SetPenSize(data->PenSize()); SetPenSize(data->PenSize());
SetFont(data->Font()); SetFont(data);
fTextRenderer.SetAntialiasing(!(data->ForceFontAliasing()
|| data->Font().Flags() & B_DISABLE_ANTIALIASING));
fSubpixelPrecise = data->SubPixelPrecise(); fSubpixelPrecise = data->SubPixelPrecise();
@@ -260,6 +258,17 @@ void
Painter::SetFont(const ServerFont& font) Painter::SetFont(const ServerFont& font)
{ {
fTextRenderer.SetFont(font); fTextRenderer.SetFont(font);
fTextRenderer.SetAntialiasing(
!(font.Flags() & B_DISABLE_ANTIALIASING));
}
// SetFont
void
Painter::SetFont(const DrawState* state)
{
fTextRenderer.SetFont(state->Font());
fTextRenderer.SetAntialiasing(!(state->ForceFontAliasing()
|| state->Font().Flags() & B_DISABLE_ANTIALIASING));
} }
// #pragma mark - drawing // #pragma mark - drawing
@@ -85,6 +85,7 @@ class Painter {
alpha_function alphaFunc); alpha_function alphaFunc);
void SetFont(const ServerFont& font); void SetFont(const ServerFont& font);
void SetFont(const DrawState* state);
inline const ServerFont& Font() const inline const ServerFont& Font() const
{ return fTextRenderer.Font(); } { return fTextRenderer.Font(); }