mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 11:23:45 +00:00
InsetMathFont: harden the new switches against unexpected values.
This commit is contained in:
parent
87fb63220a
commit
110e654b67
@ -88,6 +88,7 @@ public:
|
|||||||
font.family_ = MATH_MONOSPACE_FAMILY;
|
font.family_ = MATH_MONOSPACE_FAMILY;
|
||||||
else if (tag == "textipa" || tag == "textsc" || tag == "noun")
|
else if (tag == "textipa" || tag == "textsc" || tag == "noun")
|
||||||
font.family_ = MATH_SMALL_CAPS;
|
font.family_ = MATH_SMALL_CAPS;
|
||||||
|
// Otherwise, the tag is not recognised, use the default font.
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
@ -106,26 +107,33 @@ public:
|
|||||||
{
|
{
|
||||||
std::string span_class;
|
std::string span_class;
|
||||||
switch (family_) {
|
switch (family_) {
|
||||||
case MATH_NORMAL_FAMILY:
|
case MATH_NORMAL_FAMILY:
|
||||||
break;
|
break;
|
||||||
case MATH_FRAKTUR_FAMILY:
|
case MATH_FRAKTUR_FAMILY:
|
||||||
span_class = "fraktur";
|
span_class = "fraktur";
|
||||||
break;
|
break;
|
||||||
case MATH_SANS_FAMILY:
|
case MATH_SANS_FAMILY:
|
||||||
span_class = "sans";
|
span_class = "sans";
|
||||||
break;
|
break;
|
||||||
case MATH_MONOSPACE_FAMILY:
|
case MATH_MONOSPACE_FAMILY:
|
||||||
span_class = "monospace";
|
span_class = "monospace";
|
||||||
break;
|
break;
|
||||||
case MATH_DOUBLE_STRUCK_FAMILY:
|
case MATH_DOUBLE_STRUCK_FAMILY:
|
||||||
// This style does not exist in HTML and cannot be implemented in CSS.
|
// This style does not exist in HTML and cannot be implemented in CSS.
|
||||||
break;
|
break;
|
||||||
case MATH_SCRIPT_FAMILY:
|
case MATH_SCRIPT_FAMILY:
|
||||||
span_class = "script";
|
span_class = "script";
|
||||||
break;
|
break;
|
||||||
case MATH_SMALL_CAPS:
|
case MATH_SMALL_CAPS:
|
||||||
span_class = "noun";
|
span_class = "noun";
|
||||||
break;
|
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 (series_ == MATH_BOLD_SERIES) {
|
||||||
@ -175,8 +183,14 @@ private:
|
|||||||
return shape_ == MATH_UP_SHAPE ? "bold" : "bold-italic";
|
return shape_ == MATH_UP_SHAPE ? "bold" : "bold-italic";
|
||||||
case MATH_SMALL_CAPS:
|
case MATH_SMALL_CAPS:
|
||||||
// No valid value...
|
// No valid value...
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Better safe than sorry.
|
||||||
|
LYXERR(Debug::MATHED,
|
||||||
|
"Unexpected case in MathFontInfo::toMathVariantForMathML3: family_ = " << family_
|
||||||
|
<< ", series = " << series_ << ", shape = " << shape_);
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toMathVariantForMathMLCore() const
|
std::string toMathVariantForMathMLCore() const
|
||||||
|
Loading…
Reference in New Issue
Block a user