| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 | 1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| define(["require", "exports", "./../../fonts/pdf-standard-font", "./../../graphics/rightToLeft/text-shape", "./../../graphics/rightToLeft/bidirectional", "./../../enumerator", "./../../utils"], function (require, exports, pdf_standard_font_1, text_shape_1, bidirectional_1, enumerator_1, utils_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _RtlRenderer = (function () {
function _RtlRenderer() {
this._openBracket = '(';
this._closeBracket = ')';
}
_RtlRenderer.prototype._layout = function (line, font, rtl, wordSpace, format) {
var result = [];
if (font !== null && typeof font !== 'undefined' && line !== null && typeof line !== 'undefined') {
if (font._isUnicode) {
result = this._customLayout(line, rtl, format, font, wordSpace);
}
else {
result = [];
result[0] = line;
}
}
return result;
};
_RtlRenderer.prototype._splitLayout = function (line, font, rtl, wordSpace, format) {
var words = [];
if (font !== null && typeof font !== 'undefined' && line !== null && typeof line !== 'undefined') {
var system = false;
if (!system) {
words = this._customSplitLayout(line, font, rtl, wordSpace, format);
}
}
return words;
};
_RtlRenderer.prototype._getGlyphIndex = function (line, font, glyphs) {
glyphs = [];
if (font !== null && typeof font !== 'undefined' && line !== null && typeof line !== 'undefined') {
if (line.length === 0) {
return { _result: false, _glyphIndex: glyphs };
}
var renderer = new text_shape_1._ArabicShapeRenderer();
var text = renderer._shape(line);
var internalFont = font._fontInternal;
var ttfReader = internalFont._ttfReader;
glyphs = [text.length];
var i = 0;
for (var k = 0, len = text.length; k < len; k++) {
var ch = text[k];
var glyphInfo = ttfReader._getGlyph(ch);
if (glyphInfo !== null && typeof glyphInfo !== 'undefined') {
glyphs[i++] = (glyphInfo)._index;
}
}
}
var unicodeLine = new pdf_standard_font_1._UnicodeLine();
unicodeLine._result = true;
unicodeLine._glyphIndex = glyphs;
return unicodeLine;
};
_RtlRenderer.prototype._customLayout = function (line, rtl, format, font, wordSpace) {
var _this = this;
if (wordSpace === null || typeof wordSpace === 'undefined') {
var result = null;
if (line !== null && typeof line !== 'undefined') {
if (format !== null && typeof format !== 'undefined' && format.textDirection !== enumerator_1.PdfTextDirection.none) {
var bidi = new bidirectional_1._Bidirectional();
result = bidi._getLogicalToVisualString(line, rtl);
}
}
return result;
}
else {
var layouted = '';
var result = [];
if (line !== null && typeof line !== 'undefined' && font !== null && typeof font !== 'undefined') {
if (format !== null && typeof format !== 'undefined' && format.textDirection !== enumerator_1.PdfTextDirection.none) {
var renderer = new text_shape_1._ArabicShapeRenderer();
var txt = renderer._shape(line);
layouted = this._customLayout(txt, rtl, format);
}
if (wordSpace) {
var words = layouted.split('');
words = words.map(function (word) { return _this._addCharacter(font, word); });
result = words;
}
else {
result = [];
result[0] = this._addCharacter(font, layouted);
}
}
return result;
}
};
_RtlRenderer.prototype._addCharacter = function (font, glyphs) {
if (font !== null && typeof font !== 'undefined' && glyphs !== null && typeof glyphs !== 'undefined') {
var internalFont = font._fontInternal;
var ttfReader = internalFont._ttfReader;
font._setSymbols(glyphs);
glyphs = ttfReader._convertString(glyphs);
var bytes = utils_1._stringToUnicodeArray(glyphs);
glyphs = utils_1._bytesToString(bytes);
}
return glyphs;
};
_RtlRenderer.prototype._customSplitLayout = function (line, font, rtl, wordSpace, format) {
var words = [];
if (line !== null && typeof line !== 'undefined') {
var reversedLine = this._customLayout(line, rtl, format);
words = reversedLine.split('');
}
return words;
};
return _RtlRenderer;
}());
exports._RtlRenderer = _RtlRenderer;
});
|