mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-17 00:38:39 +00:00
Use style specific FONTDIM metrics (#545)
Summary: FONTDIM metrics include metrics like sup2, sup3, etc. which are used for position sub/super-scripts, fractions, delimiters, etc. TeX uses three different font styles: textfont2 (DISPLAY & TEXT), scriptfont2 (SCRIPT), and scriptscriptfont2 (SCRIPTSCRIPT) and has different sets of metrics for each. This diff adds style specific metrics for better TeX compliance. Notable squashed commits: - Recreated screenshots (martin) - fix getEmPerEx to use getXHeight - regularize how we access options.style, remove unnecessary newlines - use var style = options.style in more places in buildHTML
This commit is contained in:
committed by
Martin von Gagern
parent
ace67541a0
commit
22957d40f6
@@ -81,7 +81,7 @@ var makeSmallDelim = function(delim, style, center, options, mode) {
|
||||
if (center) {
|
||||
var shift =
|
||||
(1 - options.style.sizeMultiplier / style.sizeMultiplier) *
|
||||
fontMetrics.metrics.axisHeight;
|
||||
options.style.metrics.axisHeight;
|
||||
|
||||
span.style.top = shift + "em";
|
||||
span.height -= shift;
|
||||
@@ -105,7 +105,7 @@ var makeLargeDelim = function(delim, size, center, options, mode) {
|
||||
|
||||
if (center) {
|
||||
var shift = (1 - options.style.sizeMultiplier) *
|
||||
fontMetrics.metrics.axisHeight;
|
||||
options.style.metrics.axisHeight;
|
||||
|
||||
span.style.top = shift + "em";
|
||||
span.height -= shift;
|
||||
@@ -278,7 +278,7 @@ var makeStackedDelim = function(delim, heightTotal, center, options, mode) {
|
||||
// that in this context, "center" means that the delimiter should be
|
||||
// centered around the axis in the current style, while normally it is
|
||||
// centered around the axis in textstyle.
|
||||
var axisHeight = fontMetrics.metrics.axisHeight;
|
||||
var axisHeight = options.style.metrics.axisHeight;
|
||||
if (center) {
|
||||
axisHeight *= options.style.sizeMultiplier;
|
||||
}
|
||||
@@ -508,7 +508,7 @@ var makeCustomSizedDelim = function(delim, height, center, options, mode) {
|
||||
var makeLeftRightDelim = function(delim, height, depth, options, mode) {
|
||||
// We always center \left/\right delimiters, so the axis is always shifted
|
||||
var axisHeight =
|
||||
fontMetrics.metrics.axisHeight * options.style.sizeMultiplier;
|
||||
options.style.metrics.axisHeight * options.style.sizeMultiplier;
|
||||
|
||||
// Taken from TeX source, tex.web, function make_left_right
|
||||
var delimiterFactor = 901;
|
||||
|
Reference in New Issue
Block a user