Skip to content

Commit

Permalink
Merge pull request #695 from mathjax/combining-accents
Browse files Browse the repository at this point in the history
Add support for shifting combining-character accents into place
  • Loading branch information
dpvc committed May 24, 2021
2 parents a4f845d + 4b7cbdc commit 480d44b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions ts/output/common/FontData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 5 additions & 2 deletions ts/output/common/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions ts/output/common/Wrappers/TextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function CommonTextNodeMixin<T extends WrapperConstructor>(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;
Expand Down
3 changes: 2 additions & 1 deletion ts/output/common/Wrappers/scriptbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion ts/util/BBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/**
Expand All @@ -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 = '';
}
Expand Down

0 comments on commit 480d44b

Please sign in to comment.