Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lineWidth from the Metrics object, since it is never used. #936

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ts/core/MathDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,17 +711,17 @@ export abstract class AbstractMathDocument<N, T, D> implements MathDocument<N, T
* @override
*/
public convert(math: string, options: OptionList = {}) {
let {format, display, end, ex, em, containerWidth, lineWidth, scale, family} = userOptions({
let {format, display, end, ex, em, containerWidth, scale, family} = userOptions({
format: this.inputJax[0].name, display: true, end: STATE.LAST,
em: 16, ex: 8, containerWidth: null, lineWidth: 1000000, scale: 1, family: ''
em: 16, ex: 8, containerWidth: null, scale: 1, family: ''
}, options);
if (containerWidth === null) {
containerWidth = 80 * ex;
}
const jax = this.inputJax.reduce((jax, ijax) => (ijax.name === format ? ijax : jax), null);
const mitem = new this.options.MathItem(math, jax, display);
mitem.start.node = this.adaptor.body(this.document);
mitem.setMetrics(em, ex, containerWidth, lineWidth, scale);
mitem.setMetrics(em, ex, containerWidth, scale);
if (this.outputJax.options.mtextInheritFont) {
mitem.outputData.mtextFamily = family;
}
Expand Down
7 changes: 2 additions & 5 deletions ts/core/MathItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export type Metrics = {
em: number;
ex: number;
containerWidth: number;
lineWidth: number;
scale: number;
};

Expand Down Expand Up @@ -178,10 +177,9 @@ export interface MathItem<N, T, D> {
* @param {number} em The size of 1 em in pixels
* @param {number} ex The size of 1 ex in pixels
* @param {number} cwidth The container width in pixels
* @param {number} lwidth The line breaking width in pixels
* @param {number} scale The scaling factor (unitless)
*/
setMetrics(em: number, ex: number, cwidth: number, lwidth: number, scale: number): void;
setMetrics(em: number, ex: number, cwidth: number, scale: number): void;

/**
* Set or return the current processing state of this expression,
Expand Down Expand Up @@ -390,11 +388,10 @@ export abstract class AbstractMathItem<N, T, D> implements MathItem<N, T, D> {
/**
* @override
*/
public setMetrics(em: number, ex: number, cwidth: number, lwidth: number, scale: number) {
public setMetrics(em: number, ex: number, cwidth: number, scale: number) {
this.metrics = {
em: em, ex: ex,
containerWidth: cwidth,
lineWidth: lwidth,
scale: scale
};
}
Expand Down
7 changes: 3 additions & 4 deletions ts/output/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ export abstract class CommonOutputJax<
const parent = adaptor.parent(math.start.node);
if (math.state() < STATE.METRICS && parent) {
const map = maps[math.display ? 1 : 0];
const {em, ex, containerWidth, lineWidth, scale, family} = map.get(parent);
math.setMetrics(em, ex, containerWidth, lineWidth, scale);
const {em, ex, containerWidth, scale, family} = map.get(parent);
math.setMetrics(em, ex, containerWidth, scale);
if (this.options.mtextInheritFont) {
math.outputData.mtextFamily = family;
}
Expand Down Expand Up @@ -592,8 +592,7 @@ export abstract class CommonOutputJax<
adaptor.nodeBBox(adaptor.firstChild(node) as N).left - 2);
const scale = Math.max(this.options.minScale,
this.options.matchFontHeight ? ex / this.font.params.x_height / em : 1);
const lineWidth = 1000000; // no linebreaking (otherwise would be a percentage of cwidth)
return {em, ex, containerWidth, lineWidth, scale, family};
return {em, ex, containerWidth, scale, family};
}

/*****************************************************************/
Expand Down