mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Change the PDFJS.bidi function calls slightly to avoid creating a seperate object to pass to PDF.JS bidi and just pass in a string
This commit is contained in:
parent
3db4e7266e
commit
83c499595c
2 changed files with 21 additions and 12 deletions
22
src/bidi.js
22
src/bidi.js
|
@ -138,11 +138,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||
}
|
||||
}
|
||||
|
||||
function bidi(text, startLevel) {
|
||||
var str = text.str;
|
||||
function bidiResult(content, direction) {
|
||||
this.content = content;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
function bidi(str, startLevel) {
|
||||
var direction = '';
|
||||
var strLength = str.length;
|
||||
if (strLength == 0)
|
||||
return str;
|
||||
return new bidiResult(str, direction);
|
||||
|
||||
// get types, fill arrays
|
||||
|
||||
|
@ -176,16 +181,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||
// if less than 30% chars are rtl then string is primarily ltr
|
||||
// if more than 30% chars are rtl then string is primarily rtl
|
||||
if (numBidi == 0) {
|
||||
text.direction = 'ltr';
|
||||
return str;
|
||||
direction = 'ltr';
|
||||
return new bidiResult(str, direction);
|
||||
}
|
||||
|
||||
if (startLevel == -1) {
|
||||
if ((strLength / numBidi) < 0.3) {
|
||||
text.direction = 'ltr';
|
||||
direction = 'ltr';
|
||||
startLevel = 0;
|
||||
} else {
|
||||
text.direction = 'rtl';
|
||||
direction = 'rtl';
|
||||
startLevel = 1;
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +443,8 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||
if (ch != '<' && ch != '>')
|
||||
result += ch;
|
||||
}
|
||||
return result;
|
||||
|
||||
return new bidiResult(str, direction);
|
||||
}
|
||||
|
||||
return bidi;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue