FIX issue #116 "Most of the examples fail to launch with MSVC2019 + Qt5 environment" (missing local variable declaration!) + changed a bit the font lookup code in JKQTMathText to work more in line with typical system configurations

This commit is contained in:
jkriege2 2024-01-11 11:31:12 +01:00
parent 4cd8a46245
commit ef07a02e9b
6 changed files with 20 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -39,10 +39,18 @@ TestForm::TestForm(QWidget *parent) :
" text: & abc123+d/e\\\\\n"
" textit: & \\textit{abc123+d/e}\\\\\n"
" textbf: & \\textbf{abc123+d/e}\\\\\n"
" textsf: & \\textsf{abc123+d/e}\\\\\n"
" textrm: & \\textrm{abc123+d/e}\\\\\n"
" texttt: & \\texttt{abc123+d/e}\\\\\n"
" textcal: & \\textcal{abc123+d/e}\\\\\n"
" textfrak: & \\textfrak{abc123+d/e}\\\\\n"
" math: & $abc123+d/e$\\\\\n"
" mathrm: & $\\mathrm{abc123+d/e}$\\\\\n"
" mathsf: & $\\mathsf{abc123+d/e}$\\\\\n"
" mathtt: & $\\mathtt{abc123+d/e}$\\\\\n"
" mathit: & $\\mathit{abc123+d/e}$\\\\\n"
" mathbf: & $\\mathbf{abc123+d/e}$\\\\\n"
" mathcal: & $\\mathcal{abc123+d/e}$\n"
" mathfrak: & $\\mathfrak{abc123+d/e}$\n"
"\\end{matrix}");
ui->cmbTestset->addItem("text: umlaute", umla);

View File

@ -432,14 +432,14 @@ JKQTMathTextFontSpecifier JKQTMathTextFontSpecifier::getAppFontFamilies()
}
}
if (!set) {
if (f.styleHint()==QFont::SansSerif) {
const JKQTMathTextFontSpecifier fira=getFIRAFamilies();
if (fira.hasFallbackSymbolFontName()) fontSpec.m_fallbackSymbolFont=fira.fallbackSymbolsFontName();
if (fira.hasMathFontName()) fontSpec.m_mathFontName=fira.mathFontName();
} else {
if (f.styleHint()==QFont::Serif) {
const JKQTMathTextFontSpecifier xits=getXITSFamilies();
if (xits.hasFallbackSymbolFontName()) fontSpec.m_fallbackSymbolFont=xits.fallbackSymbolsFontName();
if (xits.hasMathFontName()) fontSpec.m_mathFontName=xits.mathFontName();
} else {
const JKQTMathTextFontSpecifier fira=getFIRAFamilies();
if (fira.hasFallbackSymbolFontName()) fontSpec.m_fallbackSymbolFont=fira.fallbackSymbolsFontName();
if (fira.hasMathFontName()) fontSpec.m_mathFontName=fira.mathFontName();
}
}
return fontSpec;
@ -450,14 +450,15 @@ JKQTMathTextFontSpecifier JKQTMathTextFontSpecifier::getAppFontFamilies()
JKQTMathTextFontSpecifier JKQTMathTextFontSpecifier::getAppFontSFFamilies()
{
static JKQTMathTextFontSpecifier fontSpec=[]() -> JKQTMathTextFontSpecifier {
JKQTMathTextFontSpecifier fontSpec;
const QFont f=QGuiApplication::font().family();
QFont testFnt;
if (f.styleHint()==QFont::SansSerif) {
testFnt.setStyleHint(QFont::StyleHint::Serif);
fontSpec.m_fontName=fontSpec.m_mathFontName=testFnt.defaultFamily();
} else {
if (f.styleHint()==QFont::Serif) {
testFnt.setStyleHint(QFont::StyleHint::SansSerif);
fontSpec.m_fontName=fontSpec.m_mathFontName=testFnt.defaultFamily();
fontSpec.m_fontName=fontSpec.m_mathFontName=testFnt.defaultFamily();;
} else {
testFnt.setStyleHint(QFont::StyleHint::Serif);
fontSpec.m_fontName=fontSpec.m_mathFontName=testFnt.defaultFamily();;
}
return fontSpec;
}();

View File

@ -147,7 +147,7 @@ struct JKQTMATHTEXT_LIB_EXPORT JKQTMathTextFontSpecifier {
* font with symbols is "Segoe UI Symbol" ...
*/
static JKQTMathTextFontSpecifier getAppFontFamilies();
/** \brief initialize with the default app font-families for "serif" text and math and tries to find a matching fallback-font. This may be used to initialize sans-serif-fonts
/** \brief initialize with the default app font-families for "sans-serif" text and math and tries to find a matching fallback-font. This may be used to initialize sans-serif-fonts
*
* This method encodes some pre-coded knowledge of suitable combinations of fonts for different systems.
*