diff --git a/src/apps/mail/Content.cpp b/src/apps/mail/Content.cpp index ef75d1990d..4d76c79487 100644 --- a/src/apps/mail/Content.cpp +++ b/src/apps/mail/Content.cpp @@ -680,7 +680,7 @@ TContentView::MessageReceived(BMessage *msg) { BFont *font; msg->FindPointer("font", (void **)&font); - fTextView->SetFontAndColor(0, LONG_MAX, font); + fTextView->UpdateFont(font); fTextView->Invalidate(Bounds()); break; } @@ -919,6 +919,21 @@ TTextView::~TTextView() } +void +TTextView::UpdateFont(const BFont* newFont) +{ + fFont = *newFont; + + // update the text run array safely with new font + text_run_array *runArray = RunArray(0, LONG_MAX); + for (int i = 0; i < runArray->count; i++) + runArray->runs[i].font = *newFont; + + SetRunArray(0, LONG_MAX, runArray); + FreeRunArray(runArray); +} + + void TTextView::AttachedToWindow() { diff --git a/src/apps/mail/Content.h b/src/apps/mail/Content.h index dd4f88b2c1..7317b4308f 100644 --- a/src/apps/mail/Content.h +++ b/src/apps/mail/Content.h @@ -177,6 +177,7 @@ class TTextView : public BTextView { void AddQuote(int32 start, int32 finish); void RemoveQuote(int32 start, int32 finish); + void UpdateFont(const BFont* newFont); void WindowActivated(bool flag); void Undo(BClipboard *clipboard);