diff --git a/ts/output/common/FontData.ts b/ts/output/common/FontData.ts index 21ae2b263..29104c962 100644 --- a/ts/output/common/FontData.ts +++ b/ts/output/common/FontData.ts @@ -33,6 +33,7 @@ import {StyleList} from '../../util/StyleList.js'; export interface CharOptions { ic?: number; // italic correction value sk?: number; // skew value + dx?: number; // offset for combining characters unknown?: boolean; // true if not found in the given variant smp?: number; // Math Alphanumeric codepoint this char is mapped to } diff --git a/ts/output/common/Wrapper.ts b/ts/output/common/Wrapper.ts index 8d718fc35..219c28844 100644 --- a/ts/output/common/Wrapper.ts +++ b/ts/output/common/Wrapper.ts @@ -375,11 +375,14 @@ export class CommonWrapper< */ protected copySkewIC(bbox: BBox) { const first = this.childNodes[0]; - if (first && first.bbox.sk) { + if (first?.bbox.sk) { bbox.sk = first.bbox.sk; } + if (first?.bbox.dx) { + bbox.dx = first.bbox.dx; + } const last = this.childNodes[this.childNodes.length - 1]; - if (last && last.bbox.ic) { + if (last?.bbox.ic) { bbox.ic = last.bbox.ic; bbox.w += bbox.ic; } diff --git a/ts/output/common/Wrappers/TextNode.ts b/ts/output/common/Wrappers/TextNode.ts index 67a26d543..f7cad70e1 100644 --- a/ts/output/common/Wrappers/TextNode.ts +++ b/ts/output/common/Wrappers/TextNode.ts @@ -93,6 +93,7 @@ export function CommonTextNodeMixin(Base: T): Text if (d > bbox.d) bbox.d = d; bbox.ic = data.ic || 0; bbox.sk = data.sk || 0; + bbox.dx = data.dx || 0; } if (chars.length > 1) { bbox.sk = 0; diff --git a/ts/output/common/Wrappers/scriptbase.ts b/ts/output/common/Wrappers/scriptbase.ts index 5abf91faf..1f5b685f3 100644 --- a/ts/output/common/Wrappers/scriptbase.ts +++ b/ts/output/common/Wrappers/scriptbase.ts @@ -635,7 +635,7 @@ export function CommonScriptbaseMixin< const widths = boxes.map(box => box.w * box.rscale); widths[0] -= (this.baseRemoveIc && !this.baseCore.node.attributes.get('largeop') ? this.baseIc : 0); const w = Math.max(...widths); - const dw = []; + const dw = [] as number[]; let m = 0; for (const i of widths.keys()) { dw[i] = (align === 'center' ? (w - widths[i]) / 2 : @@ -649,6 +649,7 @@ export function CommonScriptbaseMixin< dw[i] += m; } } + [1, 2].map(i => dw[i] += (boxes[i] ? boxes[i].dx * boxes[0].scale : 0)); return dw; } diff --git a/ts/util/BBox.ts b/ts/util/BBox.ts index 73d7a6065..4d16b6d68 100644 --- a/ts/util/BBox.ts +++ b/ts/util/BBox.ts @@ -71,6 +71,7 @@ export class BBox { public pwidth: string; // percentage width (for tables) public ic: number; // italic correction public sk: number; // skew + public dx: number; // offset for combining characters as accents /* tslint:enable */ /** @@ -96,7 +97,7 @@ export class BBox { this.w = def.w || 0; this.h = ('h' in def ? def.h : -BIGDIMEN); this.d = ('d' in def ? def.d : -BIGDIMEN); - this.L = this.R = this.ic = this.sk = 0; + this.L = this.R = this.ic = this.sk = this.dx = 0; this.scale = this.rscale = 1; this.pwidth = ''; }