mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #14213 from Snuffleupagus/issue-11656
Tweak the Bidi-detection heuristics for very short RTL strings (issue 11656)
This commit is contained in:
commit
e1a35e7bb6
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