mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Tweak the Bidi-detection heuristics for very short RTL strings (issue 11656)
Very short strings can narrowly miss the existing Bidi-detection threshold, leading to incorrect text-selection and copying behaviour. In my testing, neither Adobe Reader or PDFium seem to handle copying "correctly" for this document. Hence it's not entirely clear to me that we actually want to fix this, since tweaking these heuristics can *obviously* cause regressions elsewhere (and our test coverage for RTL-text isn't exactly great).
This commit is contained in:
parent
6a15973a1b
commit
5f77d3719b
5 changed files with 44 additions and 2 deletions
|
@ -158,7 +158,8 @@ function bidi(str, startLevel = -1, vertical = false) {
|
|||
|
||||
// Detect the bidi method
|
||||
// - If there are no rtl characters then no bidi needed
|
||||
// - If less than 30% chars are rtl then string is primarily ltr
|
||||
// - If less than 30% chars are rtl then string is primarily ltr,
|
||||
// unless the string is very short.
|
||||
// - If more than 30% chars are rtl then string is primarily rtl
|
||||
if (numBidi === 0) {
|
||||
isLTR = true;
|
||||
|
@ -166,7 +167,7 @@ function bidi(str, startLevel = -1, vertical = false) {
|
|||
}
|
||||
|
||||
if (startLevel === -1) {
|
||||
if (numBidi / strLength < 0.3) {
|
||||
if (numBidi / strLength < 0.3 && strLength > 4) {
|
||||
isLTR = true;
|
||||
startLevel = 0;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue