[haiku-commits] BRANCH midar-github.master - src/apps/terminal

  • From: midar-github.master <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 29 Jan 2013 04:15:44 +0100 (CET)

added 1 changeset to branch 'refs/remotes/midar-github/master'
old head: 75c54cdac7fcf30377c5b35abc69ab946524db21
new head: 991d080389a9d9a1a1d71907cd38e9939509aa0d
overview: https://github.com/Midar/haiku/compare/75c54cd...991d080

----------------------------------------------------------------------------

991d080: Terminal: Fix bold rendering.
  
  The old behaviour was to render the letter twice with an x offset of 1,
  which made letters like m unreadable and just look like a blob.
  
  The new behaviour is to render them slightly lighter, just like many
  other terminals do.
  
  A saturated add was chosen instead of tint_color, as the results of
  tint_color were too extreme.

                                     [ Jonathan Schleifer <js@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      991d080389a9d9a1a1d71907cd38e9939509aa0d
Author:      Jonathan Schleifer <js@xxxxxxxxxxx>
Date:        Tue Jan 29 02:53:56 2013 UTC

----------------------------------------------------------------------------

1 file changed, 19 insertions(+), 9 deletions(-)
src/apps/terminal/TermView.cpp | 28 +++++++++++++++++++---------

----------------------------------------------------------------------------

diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp
index c79960e..dbc9a14 100644
--- a/src/apps/terminal/TermView.cpp
+++ b/src/apps/terminal/TermView.cpp
@@ -397,6 +397,15 @@ restrict_value(const Type& value, const Type& min, const 
Type& max)
 }
 
 
+template<typename Type>
+static inline Type
+saturated_add(Type a, Type b)
+{
+       const Type max = (Type)(-1);
+       return (max - a >= b ? a + b : max);
+}
+
+
 // #pragma mark - CharClassifier
 
 
@@ -1172,19 +1181,20 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 
attr, char *buf,
 
        inView->SetHighColor(rgb_fore);
 
-       // Draw character.
-       inView->MovePenTo(x1, y1 + fFontAscent);
-       inView->DrawString((char *) buf);
-
-       // bold attribute.
        if (IS_BOLD(attr)) {
-               inView->MovePenTo(x1 + 1, y1 + fFontAscent);
+               rgb_color bright = rgb_fore;
 
-               inView->SetDrawingMode(B_OP_OVER);
-               inView->DrawString((char *)buf);
-               inView->SetDrawingMode(B_OP_COPY);
+               bright.red = saturated_add<uint8>(bright.red, 64);
+               bright.green = saturated_add<uint8>(bright.green, 64);
+               bright.blue = saturated_add<uint8>(bright.blue, 64);
+
+               inView->SetHighColor(bright);
        }
 
+       // Draw character.
+       inView->MovePenTo(x1, y1 + fFontAscent);
+       inView->DrawString((char *) buf);
+
        // underline attribute
        if (IS_UNDER(attr)) {
                inView->MovePenTo(x1, y1 + fFontAscent);


Other related posts: