diff --git a/headers/private/servers/app/Painter.h b/headers/private/servers/app/Painter.h index b8b2014eaa..d8d19606af 100644 --- a/headers/private/servers/app/Painter.h +++ b/headers/private/servers/app/Painter.h @@ -311,6 +311,7 @@ class Painter { // font file, it uses the FontManager to locate a file // by Family and Style AGGTextRenderer* fTextRenderer; + uint32 fLastFamilyAndStyle; }; // SetHighColor diff --git a/headers/private/servers/app/ServerFont.h b/headers/private/servers/app/ServerFont.h index 5c7925cdcf..61728c3b90 100644 --- a/headers/private/servers/app/ServerFont.h +++ b/headers/private/servers/app/ServerFont.h @@ -79,7 +79,7 @@ public: const char *GetPath(void) const { return fStyle->GetPath(); } uint16 StyleID(void) const { return fStyle->GetID(); } uint16 FamilyID(void) const { return fStyle->Family()->GetID(); } - uint32 GetFamilyAndStyle(void); + uint32 GetFamilyAndStyle(void) const; BRect BoundingBox(void); void Height(font_height *fh); diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 9665bcbc8f..2a6de1e197 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -213,7 +213,7 @@ status_t ServerFont::SetFamilyAndStyle(const uint32 &fontID) \brief Gets the ID values for the ServerFont instance in one shot \return the combination of family and style ID numbers */ -uint32 ServerFont::GetFamilyAndStyle(void) +uint32 ServerFont::GetFamilyAndStyle(void) const { uint32 famsty=0; diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index 1913a7ff3a..6609b8af95 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -63,7 +63,8 @@ Painter::Painter() fPenLocation(0.0, 0.0), fPatternHandler(new PatternHandler()), fFont(be_plain_font), - fTextRenderer(new AGGTextRenderer()) + fTextRenderer(new AGGTextRenderer()), + fLastFamilyAndStyle(0) { _UpdateFont(); _UpdateLineWidth(); @@ -276,8 +277,11 @@ Painter::SetFont(const ServerFont& font) fFont.SetShear(font.Shear()); fFont.SetRotation(font.Rotation()); fFont.SetSize(font.Size()); - - _UpdateFont(font.GetPath()); + + if (fLastFamilyAndStyle != font.GetFamilyAndStyle()) { + fLastFamilyAndStyle = font.GetFamilyAndStyle(); + _UpdateFont(font.GetPath()); + } } // #pragma mark - @@ -1034,19 +1038,23 @@ Painter::_RebuildClipping() void Painter::_UpdateFont(const char* pathToFontFile) { + bool success = false; if (pathToFontFile) { - fTextRenderer->SetFont(pathToFontFile); + success = fTextRenderer->SetFont(pathToFontFile); + if (!success) + fprintf(stderr, "unable to set '%s'\n", pathToFontFile); } else { font_family family; font_style style; fFont.GetFamilyAndStyle(&family, &style); - bool success = fTextRenderer->SetFamilyAndStyle(family, style); - if (!success) { + success = fTextRenderer->SetFamilyAndStyle(family, style); + if (!success) fprintf(stderr, "unable to set '%s' + '%s'\n", family, style); - fprintf(stderr, "font is still: '%s' + '%s'\n", - fTextRenderer->Family(), fTextRenderer->Style()); - } + } + if (!success) { + fprintf(stderr, "font is still: '%s' + '%s'\n", + fTextRenderer->Family(), fTextRenderer->Style()); } fTextRenderer->SetPointSize(fFont.Size());