1
0
Fork 0
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:
Jonas Jenwald 2021-11-03 22:09:14 +01:00 committed by GitHub
commit e1a35e7bb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 2 deletions

View file

@ -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 {