diff --git a/crengine/src/hyphman.cpp b/crengine/src/hyphman.cpp index 24a97d561..12ec30522 100755 --- a/crengine/src/hyphman.cpp +++ b/crengine/src/hyphman.cpp @@ -17,7 +17,7 @@ #define NEW_HYPHENATION 1 // set to 1 for debug dump -#ifdef _DEBUG +#if defined(_DEBUG) && 0 #define DUMP_HYPHENATION_WORDS 1 #else #define DUMP_HYPHENATION_WORDS 0 diff --git a/crengine/src/lvtextfm.cpp b/crengine/src/lvtextfm.cpp index 2dc9a5950..d4c723f7a 100755 --- a/crengine/src/lvtextfm.cpp +++ b/crengine/src/lvtextfm.cpp @@ -25,7 +25,7 @@ #endif // to debug formatter -#ifdef _DEBUG +#if defined(_DEBUG) && 0 #ifdef _MSC_VER #define TR(...) CRLog::trace(__VA_ARGS__) #else @@ -510,6 +510,23 @@ class LVFormatter { } } + /// checks whether to add more space after italic character + int getAdditionalCharWidth( int pos, int maxpos ) { + if (m_text[pos]==0) // object + return 0; // no additional space + LVFont * font = (LVFont*)m_srcs[pos]->t.font; + if ( !font->getItalic() ) + return 0; // not italic + if ( posgetGlyphInfo(m_text[pos], &glyph, '?') ) + return 0; + int delta = glyph.originX + glyph.blackBoxX - glyph.width; + return delta > 0 ? delta : 0; + } + /// measure text of current paragraph void measureText() { @@ -568,6 +585,11 @@ class LVFormatter { // buf << L"_" << lChar16(m_text[start+k]) << L"_" << lString16::itoa(widths[k]); // } // TR(" %s", LCSTR(buf)); + int dw = getAdditionalCharWidth(i-1, m_length); + if ( dw ) { + m_widths[i-1] += dw; + lastWidth += dw; + } lastWidth += widths[len-1]; //len=m_length-1, preFormattedOnly, needReduceSpace ); + int endp = wrapPos+(lastMandatoryWrap<0 ? 1 : 0); + int lastnonspace = endp-1; + for ( int k=endp-1; k>=start; k-- ) { + if ( !((m_flags[k] & LCHAR_IS_SPACE) && !(m_flags[k] & LCHAR_IS_OBJECT)) ) { + lastnonspace = k; + break; + } + } + int dw = lastnonspace>=start ? getAdditionalCharWidth(lastnonspace, lastnonspace+1) : 0; + if (dw) { + TR("additional width = %d, after char %s", dw, LCSTR(lString16(m_text + endp - 1, 1))); + m_widths[lastnonspace] += dw; + } + addLine(pos, endp, x, para, interval, pos==0, wrapPos>=m_length-1, preFormattedOnly, needReduceSpace ); pos = wrapPos + 1; } }