Skip to content
Permalink
Browse files

bug fix for #1118 and158b13c (#1130)

* no longer crash when lenThatFits == 0

* try to prevent break in CJK sentence

try to prevent  break in CJK sentence, and some minor adjustments to the reparse logic.

* tweak lenThatFits  

get lenThatFits suits  (pageDx  -  currX)  instead of (pageDx - NewLineX())
and some other corresponding corrections

* add lentmp

* Revert "Merge branch 'master' into pr/2"

This reverts commit caf0697, reversing
changes made to 21c252e.

* Revert "Revert "Merge branch 'master' into pr/2""

This reverts commit 07191b3.

* Revert "Revert "Revert "Merge branch 'master' into pr/2"""

This reverts commit 85c2f51.

* Update HtmlFormatter.cpp

bug fix for  158b13c

* limit windows min width dynamically

limit windows min width to prevent render loop when siderbar is too big

* Revert "limit windows min width dynamically"

This reverts commit a5c4a26.

* Update HtmlFormatter.cpp

* Revert "Revert "limit windows min width dynamically""

This reverts commit f1abbed.
  • Loading branch information...
ultranity authored and kjk committed Feb 17, 2019
1 parent 21c252e commit 5694a5df8ca69fe2fb6d0abbfaf446e3ec32e6c3
Showing with 12 additions and 7 deletions.
  1. +10 −6 src/HtmlFormatter.cpp
  2. +2 −1 src/SumatraPDF.cpp
@@ -679,11 +679,15 @@ void HtmlFormatter::EmitElasticSpace() {

// return true if we can break a word on a given character during layout
static bool CanBreakWordOnChar(WCHAR c) {
// this is called frequently, so check most common characters first
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
return false;
// don't break on Chinese and Japan characters
// https://github.com/sumatrapdfreader/sumatrapdf/issues/250
// https://github.com/sumatrapdfreader/sumatrapdf/pull/1057
// There are other ranges, but far less common
// https://stackoverflow.com/questions/1366068/whats-the-complete-range-for-chinese-characters-in-unicode
if (c >= 0x2E80 && c <= 0xA4CF) {
return true;
}
return true;
return false;
}

// a text run is a string of consecutive text with uniform style
@@ -719,16 +723,16 @@ void HtmlFormatter::EmitTextRun(const char* s, const char* end) {
size_t lenThatFits = StringLenForWidth(textMeasure, buf, strLen, pageDx - currX);
// try to prevent a break in the middle of a word
if (lenThatFits > 0) {
size_t lentmp = lenThatFits;
if (!CanBreakWordOnChar(buf[lenThatFits])) {
size_t lentmp = lenThatFits;
for (lentmp = lenThatFits; lentmp > 0; lentmp--) {
if (CanBreakWordOnChar(buf[lentmp - 1])) {
break;
}
}
if (lentmp == 0) {
// make a new line if the word need to show in another line
if (currX != 0) {
if (currX != NewLineX()) {
FlushCurrLine(false);
continue;
}
@@ -4129,7 +4129,8 @@ static LRESULT FrameOnCommand(WindowInfo* win, HWND hwnd, UINT msg, WPARAM wPara
}

static LRESULT OnFrameGetMinMaxInfo(MINMAXINFO* info) {
info->ptMinTrackSize.x = MIN_WIN_DX;
//limit windows min width to prevent render loop when siderbar is too big
info->ptMinTrackSize.x = MIN_WIN_DX - SIDEBAR_MIN_WIDTH + gGlobalPrefs->sidebarDx;
info->ptMinTrackSize.y = MIN_WIN_DY;
return 0;
}

0 comments on commit 5694a5d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.