Change the format of the BidiResult object.
This commit is contained in:
parent
897b99500e
commit
8d6565d1a8
20
src/bidi.js
20
src/bidi.js
@ -138,16 +138,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bidiResult(content, direction) {
|
function BidiResult(str, isLTR) {
|
||||||
this.content = content;
|
this.str = str;
|
||||||
this.direction = direction;
|
this.ltr = isLTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bidi(str, startLevel) {
|
function bidi(str, startLevel) {
|
||||||
var direction = '';
|
var isLTR = true;
|
||||||
var strLength = str.length;
|
var strLength = str.length;
|
||||||
if (strLength == 0)
|
if (strLength == 0)
|
||||||
return new bidiResult(str, direction);
|
return new BidiResult(str, ltr);
|
||||||
|
|
||||||
// get types, fill arrays
|
// get types, fill arrays
|
||||||
|
|
||||||
@ -181,16 +181,16 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||||||
// if less than 30% chars are rtl then string is primarily ltr
|
// 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 more than 30% chars are rtl then string is primarily rtl
|
||||||
if (numBidi == 0) {
|
if (numBidi == 0) {
|
||||||
direction = 'ltr';
|
isLTR = true;
|
||||||
return new bidiResult(str, direction);
|
return new BidiResult(str, isLTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startLevel == -1) {
|
if (startLevel == -1) {
|
||||||
if ((strLength / numBidi) < 0.3) {
|
if ((strLength / numBidi) < 0.3) {
|
||||||
direction = 'ltr';
|
isLTR = true;
|
||||||
startLevel = 0;
|
startLevel = 0;
|
||||||
} else {
|
} else {
|
||||||
direction = 'rtl';
|
isLTR = false;
|
||||||
startLevel = 1;
|
startLevel = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
|||||||
result += ch;
|
result += ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new bidiResult(result, direction);
|
return new BidiResult(result, isLTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bidi;
|
return bidi;
|
||||||
|
@ -1935,8 +1935,8 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
|
|||||||
var textDiv = textDivs[i];
|
var textDiv = textDivs[i];
|
||||||
var bidiText = PDFJS.bidi(textContent[i], -1);
|
var bidiText = PDFJS.bidi(textContent[i], -1);
|
||||||
|
|
||||||
textDiv.textContent = bidiText.content;
|
textDiv.textContent = bidiText.str;
|
||||||
textDiv.dir = bidiText.direction;
|
textDiv.dir = bidiText.ltr ? 'ltr' : 'rtl';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setupRenderLayoutTimer();
|
this.setupRenderLayoutTimer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user