mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-08 20:48:41 +00:00
delimiter.js: Don't assign sizeMultiplier to span in prep for porting to flow. (#1006)
This commit is contained in:
committed by
Kevin Barabash
parent
9e6eb3a219
commit
73db0a2352
@@ -485,15 +485,7 @@ groupTypes.sqrt = function(group, options) {
|
|||||||
lineClearance + theta) * options.sizeMultiplier;
|
lineClearance + theta) * options.sizeMultiplier;
|
||||||
|
|
||||||
// Create a sqrt SVG of the required minimum size
|
// Create a sqrt SVG of the required minimum size
|
||||||
const img = delimiter.customSizedDelim("\\surd", minDelimiterHeight,
|
const {span: img, ruleWidth} = delimiter.sqrtImage(minDelimiterHeight, options);
|
||||||
false, options, group.mode);
|
|
||||||
|
|
||||||
// Calculate the actual line width.
|
|
||||||
// This actually should depend on the chosen font -- e.g. \boldmath
|
|
||||||
// should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
|
|
||||||
// have thicker rules.
|
|
||||||
const ruleWidth = options.fontMetrics().sqrtRuleThickness *
|
|
||||||
img.sizeMultiplier;
|
|
||||||
|
|
||||||
const delimDepth = img.height - ruleWidth;
|
const delimDepth = img.height - ruleWidth;
|
||||||
|
|
||||||
|
@@ -344,7 +344,13 @@ const sqrtSvg = function(sqrtName, height, viewBoxHeight, options) {
|
|||||||
return buildCommon.makeSpan(["hide-tail"], [svg], options);
|
return buildCommon.makeSpan(["hide-tail"], [svg], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
const sqrtSpan = function(height, delim, options) {
|
/**
|
||||||
|
* Make a sqrt image of the given height,
|
||||||
|
*/
|
||||||
|
const makeSqrtImage = function(height, options) {
|
||||||
|
const delim =
|
||||||
|
traverseSequence("\\surd", height, stackLargeDelimiterSequence, options);
|
||||||
|
|
||||||
// Create a span containing an SVG image of a sqrt symbol.
|
// Create a span containing an SVG image of a sqrt symbol.
|
||||||
let span;
|
let span;
|
||||||
let sizeMultiplier = options.sizeMultiplier; // default
|
let sizeMultiplier = options.sizeMultiplier; // default
|
||||||
@@ -381,9 +387,15 @@ const sqrtSpan = function(height, delim, options) {
|
|||||||
|
|
||||||
span.height = spanHeight;
|
span.height = spanHeight;
|
||||||
span.style.height = spanHeight + "em";
|
span.style.height = spanHeight + "em";
|
||||||
span.sizeMultiplier = sizeMultiplier;
|
|
||||||
|
|
||||||
return span;
|
return {
|
||||||
|
span,
|
||||||
|
// Calculate the actual line width.
|
||||||
|
// This actually should depend on the chosen font -- e.g. \boldmath
|
||||||
|
// should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
|
||||||
|
// have thicker rules.
|
||||||
|
ruleWidth: options.fontMetrics().sqrtRuleThickness * sizeMultiplier,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// There are three kinds of delimiters, delimiters that stack when they become
|
// There are three kinds of delimiters, delimiters that stack when they become
|
||||||
@@ -556,10 +568,6 @@ const makeCustomSizedDelim = function(delim, height, center, options, mode,
|
|||||||
// Look through the sequence
|
// Look through the sequence
|
||||||
const delimType = traverseSequence(delim, height, sequence, options);
|
const delimType = traverseSequence(delim, height, sequence, options);
|
||||||
|
|
||||||
if (delim === "\\surd") {
|
|
||||||
// Get an SVG image
|
|
||||||
return sqrtSpan(height, delimType, options);
|
|
||||||
} else {
|
|
||||||
// Get the delimiter from font glyphs.
|
// Get the delimiter from font glyphs.
|
||||||
// Depending on the sequence element we decided on, call the
|
// Depending on the sequence element we decided on, call the
|
||||||
// appropriate function.
|
// appropriate function.
|
||||||
@@ -569,11 +577,10 @@ const makeCustomSizedDelim = function(delim, height, center, options, mode,
|
|||||||
} else if (delimType.type === "large") {
|
} else if (delimType.type === "large") {
|
||||||
return makeLargeDelim(delim, delimType.size, center, options, mode,
|
return makeLargeDelim(delim, delimType.size, center, options, mode,
|
||||||
classes);
|
classes);
|
||||||
} else if (delimType.type === "stack") {
|
} else /* if (delimType.type === "stack") */ {
|
||||||
return makeStackedDelim(delim, height, center, options, mode,
|
return makeStackedDelim(delim, height, center, options, mode,
|
||||||
classes);
|
classes);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,6 +620,7 @@ const makeLeftRightDelim = function(delim, height, depth, options, mode,
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
sqrtImage: makeSqrtImage,
|
||||||
sizedDelim: makeSizedDelim,
|
sizedDelim: makeSizedDelim,
|
||||||
customSizedDelim: makeCustomSizedDelim,
|
customSizedDelim: makeCustomSizedDelim,
|
||||||
leftRightDelim: makeLeftRightDelim,
|
leftRightDelim: makeLeftRightDelim,
|
||||||
|
Reference in New Issue
Block a user