InsetMathFont: harden the new switches against unexpected values.

This commit is contained in:
Thibaut Cuvelier 2024-10-30 01:55:22 +01:00
parent 87fb63220a
commit 110e654b67

View File

@ -88,6 +88,7 @@ public:
font.family_ = MATH_MONOSPACE_FAMILY;
else if (tag == "textipa" || tag == "textsc" || tag == "noun")
font.family_ = MATH_SMALL_CAPS;
// Otherwise, the tag is not recognised, use the default font.
return font;
}
@ -127,6 +128,13 @@ public:
span_class = "noun";
break;
}
// Explicitly match the cases with an empty output. This ensures that we catch at runtime
// invalid values for the enum while keeping compile-time warnings.
if (span_class.empty() && (family_ != MATH_NORMAL_FAMILY || family_ != MATH_DOUBLE_STRUCK_FAMILY)) {
LYXERR(Debug::MATHED,
"Unexpected case in MathFontInfo::toHTMLSpanClass: family_ = " << family_
<< ", series = " << series_ << ", shape = " << shape_);
}
if (series_ == MATH_BOLD_SERIES) {
if (!span_class.empty()) span_class += "-";
@ -177,6 +185,12 @@ private:
// No valid value...
return "";
}
// Better safe than sorry.
LYXERR(Debug::MATHED,
"Unexpected case in MathFontInfo::toMathVariantForMathML3: family_ = " << family_
<< ", series = " << series_ << ", shape = " << shape_);
return "";
}
std::string toMathVariantForMathMLCore() const