Skip to content

Commit 7a531fe

Browse files
committed
Add support for shifting combining-character accents into place
1 parent 7ebd823 commit 7a531fe

5 files changed

Lines changed: 9 additions & 4 deletions

File tree

ts/output/common/FontData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {StyleList} from '../../util/StyleList.js';
3333
export interface CharOptions {
3434
ic?: number; // italic correction value
3535
sk?: number; // skew value
36+
dx?: number; // offset for combining characters
3637
unknown?: boolean; // true if not found in the given variant
3738
smp?: number; // Math Alphanumeric codepoint this char is mapped to
3839
}

ts/output/common/Wrapper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,9 @@ export class CommonWrapper<
375375
*/
376376
protected copySkewIC(bbox: BBox) {
377377
const first = this.childNodes[0];
378-
if (first && first.bbox.sk) {
379-
bbox.sk = first.bbox.sk;
378+
if (first) {
379+
first.bbox.sk && (bbox.sk = first.bbox.sk);
380+
first.bbox.dx && (bbox.dx = first.bbox.dx);
380381
}
381382
const last = this.childNodes[this.childNodes.length - 1];
382383
if (last && last.bbox.ic) {

ts/output/common/Wrappers/TextNode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export function CommonTextNodeMixin<T extends WrapperConstructor>(Base: T): Text
9393
if (d > bbox.d) bbox.d = d;
9494
bbox.ic = data.ic || 0;
9595
bbox.sk = data.sk || 0;
96+
bbox.dx = data.dx || 0;
9697
}
9798
if (chars.length > 1) {
9899
bbox.sk = 0;

ts/output/common/Wrappers/scriptbase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ export function CommonScriptbaseMixin<
635635
const widths = boxes.map(box => box.w * box.rscale);
636636
widths[0] -= (this.baseRemoveIc && !this.baseCore.node.attributes.get('largeop') ? this.baseIc : 0);
637637
const w = Math.max(...widths);
638-
const dw = [];
638+
const dw = [] as number[];
639639
let m = 0;
640640
for (const i of widths.keys()) {
641641
dw[i] = (align === 'center' ? (w - widths[i]) / 2 :
@@ -649,6 +649,7 @@ export function CommonScriptbaseMixin<
649649
dw[i] += m;
650650
}
651651
}
652+
[1, 2].map(i => dw[i] += (boxes[i] ? boxes[i].dx * boxes[0].scale : 0));
652653
return dw;
653654
}
654655

ts/util/BBox.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class BBox {
7171
public pwidth: string; // percentage width (for tables)
7272
public ic: number; // italic correction
7373
public sk: number; // skew
74+
public dx: number; // offset for combining characters as accents
7475
/* tslint:enable */
7576

7677
/**
@@ -96,7 +97,7 @@ export class BBox {
9697
this.w = def.w || 0;
9798
this.h = ('h' in def ? def.h : -BIGDIMEN);
9899
this.d = ('d' in def ? def.d : -BIGDIMEN);
99-
this.L = this.R = this.ic = this.sk = 0;
100+
this.L = this.R = this.ic = this.sk = this.dx = 0;
100101
this.scale = this.rscale = 1;
101102
this.pwidth = '';
102103
}

0 commit comments

Comments
 (0)