mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +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;
|
||||
|
||||
// Create a sqrt SVG of the required minimum size
|
||||
const img = delimiter.customSizedDelim("\\surd", minDelimiterHeight,
|
||||
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 {span: img, ruleWidth} = delimiter.sqrtImage(minDelimiterHeight, options);
|
||||
|
||||
const delimDepth = img.height - ruleWidth;
|
||||
|
||||
|
@@ -344,7 +344,13 @@ const sqrtSvg = function(sqrtName, height, viewBoxHeight, 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.
|
||||
let span;
|
||||
let sizeMultiplier = options.sizeMultiplier; // default
|
||||
@@ -381,9 +387,15 @@ const sqrtSpan = function(height, delim, options) {
|
||||
|
||||
span.height = spanHeight;
|
||||
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
|
||||
@@ -556,23 +568,18 @@ const makeCustomSizedDelim = function(delim, height, center, options, mode,
|
||||
// Look through the sequence
|
||||
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.
|
||||
// Depending on the sequence element we decided on, call the
|
||||
// appropriate function.
|
||||
if (delimType.type === "small") {
|
||||
return makeSmallDelim(delim, delimType.style, center, options,
|
||||
mode, classes);
|
||||
} else if (delimType.type === "large") {
|
||||
return makeLargeDelim(delim, delimType.size, center, options, mode,
|
||||
classes);
|
||||
} else if (delimType.type === "stack") {
|
||||
return makeStackedDelim(delim, height, center, options, mode,
|
||||
classes);
|
||||
}
|
||||
// Get the delimiter from font glyphs.
|
||||
// Depending on the sequence element we decided on, call the
|
||||
// appropriate function.
|
||||
if (delimType.type === "small") {
|
||||
return makeSmallDelim(delim, delimType.style, center, options,
|
||||
mode, classes);
|
||||
} else if (delimType.type === "large") {
|
||||
return makeLargeDelim(delim, delimType.size, center, options, mode,
|
||||
classes);
|
||||
} else /* if (delimType.type === "stack") */ {
|
||||
return makeStackedDelim(delim, height, center, options, mode,
|
||||
classes);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -613,6 +620,7 @@ const makeLeftRightDelim = function(delim, height, depth, options, mode,
|
||||
};
|
||||
|
||||
export default {
|
||||
sqrtImage: makeSqrtImage,
|
||||
sizedDelim: makeSizedDelim,
|
||||
customSizedDelim: makeCustomSizedDelim,
|
||||
leftRightDelim: makeLeftRightDelim,
|
||||
|
Reference in New Issue
Block a user