Improve support for double width characters

This commit is contained in:
Tom Z?hner
2019-08-31 09:35:01 +02:00
parent e06ebad8a1
commit 08fcdfd8f5
9 changed files with 73 additions and 10 deletions
Generated Vendored
+18 -3
View File
@@ -850,10 +850,24 @@ var Parser = /** @class */ (function () {
if (!_Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"]._isalpha(ch)) {
if (ch === "\'") {
var hex = this.readChar() + this.readChar();
this.readChar();
this.readChar();
var followingHex = this.readChar() + this.readChar();
if (this.parser.state.pap.charactertype === _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"].CHARACTER_TYPE.DOUBLE) {
this.readChar();
this.readChar();
hex += this.readChar() + this.readChar();
// Character is defined as double width
hex += followingHex;
}
else if (this.parser.state.pap.charactertype == null
&& _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"]._parseHex(hex) >= 128
&& _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"]._parseHex(followingHex) < 128) {
// Character type is undefined, inferred as double width
hex += followingHex;
}
else {
// Character is single width, unread characters
for (var i = 0; i < 4; i++) {
this.unreadChar();
}
}
param = _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"]._parseHex(hex);
if (isNaN(param)) {
@@ -8324,6 +8338,7 @@ var Pap = /** @class */ (function () {
this.justification = _Helper__WEBPACK_IMPORTED_MODULE_0__["Helper"].JUSTIFICATION.LEFT;
this.spacebefore = 0;
this.spaceafter = 0;
this.charactertype = null;
}
}
return Pap;
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -65,7 +65,7 @@ export class Pap {
public justification: string;
public spacebefore: number;
public spaceafter: number;
public charactertype: string;
public charactertype: string | null;
constructor(parent: Pap) {
if (parent != null) {
@@ -87,6 +87,7 @@ export class Pap {
this.justification = Helper.JUSTIFICATION.LEFT;
this.spacebefore = 0;
this.spaceafter = 0;
this.charactertype = null;
}
}
}
+17 -3
View File
@@ -324,11 +324,25 @@ export class Parser {
if (!Helper._isalpha(ch)) {
if (ch === "\'") {
let hex = this.readChar() + this.readChar();
this.readChar();
this.readChar();
const followingHex = this.readChar() + this.readChar();
if (this.parser.state.pap.charactertype === Helper.CHARACTER_TYPE.DOUBLE) {
this.readChar();
this.readChar();
hex += this.readChar() + this.readChar();
// Character is defined as double width
hex += followingHex;
} else if (this.parser.state.pap.charactertype == null
&& Helper._parseHex(hex) >= 128
&& Helper._parseHex(followingHex) < 128) {
// Character type is undefined, inferred as double width
hex += followingHex;
} else {
// Character is single width, unread characters
for (let i = 0; i < 4; i++) {
this.unreadChar();
}
}
param = Helper._parseHex(hex);
if (isNaN(param)) {
throw new RTFJSError("Could not parse hexadecimal number");
@@ -0,0 +1,3 @@
{
"generator": "Riched20 10.0.18362"
}
@@ -0,0 +1,30 @@
<div style="margin-bottom: 10pt; min-height: 11pt; text-align: left;">
<span style="font-family: MS PGothic; font-size: 11pt;">要フャホ要ァクフ刑カオ洋
</span>
<span style="font-family: Calibri; font-size: 11pt;">8
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">宮ニネ前察ツサ田ヌィスキヲアヌイテ予
</span>
<span style="font-family: Calibri; font-size: 11pt;">9
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">イョケヘクヤトニ優ゥケナニ。サャ輸ク奪都ツコ全炭熟ソノケ
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">優施「シ構集テア亀ニネヌ様カ界表イエレカゥ真
</span>
<span style="font-family: Calibri; font-size: 11pt;">5
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">ュクシネアル子ャヌ型ヤ゙
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">ナカ
</span>
<span style="font-family: Calibri; font-size: 11pt;">7
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">職ツワルェ確想ミ終トォ覚ッネャ本ト富ゥッセフナ
</span>
<span style="font-family: Calibri; font-size: 11pt;">71
</span>
<span style="font-family: MS PGothic; font-size: 11pt;">修ヒコ
</span>
</div>
<div style="margin-bottom: 10pt; min-height: 11pt; text-align: left;">
</div>
Binary file not shown.