Ticket #7955: CorrectTabWidth.patch

File CorrectTabWidth.patch, 1000 bytes (added by x-ist, 12 years ago)

Correction of tab width calculation in BTextView.

  • src/kits/interface/TextView.cpp

    From eaafa73f0df9d20c60f693faf641e896c6333095 Mon Sep 17 00:00:00 2001
    From: x-ist <fakeEmail@fakesite.fake>
    Date: Mon, 6 Aug 2012 19:44:42 +0000
    Subject: [PATCH] In rare cases such as described in #7955 BTextView happens
     to calculate the width of a tab close to zero (e.g.
     0.000031). This patch adds a fallback to the default tab
     width in that case.
    
    ---
     src/kits/interface/TextView.cpp |    6 +++++-
     1 file changed, 5 insertions(+), 1 deletion(-)
    
    diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp
    index d46414d..8ed8cea 100644
    a b BTextView::_StyledWidth(int32 fromOffset, int32 length, float* outAscent,  
    41984198float
    41994199BTextView::_ActualTabWidth(float location) const
    42004200{
    4201     return fTabWidth - fmod(location, fTabWidth);
     4201    float tabWidth = fTabWidth - fmod(location, fTabWidth);
     4202    if (round(tabWidth) == 0)
     4203        tabWidth = fTabWidth;
     4204       
     4205    return tabWidth;
    42024206}
    42034207
    42044208