Skip to content

Commit

Permalink
FIX issue #116 "Most of the examples fail to launch with MSVC2019 + Q…
Browse files Browse the repository at this point in the history
…t5 environment" (missing local variable declaration!) + changed a bit the font lookup code in JKQTMathText to work more in line with typical system configurations
  • Loading branch information
jkriege2 committed Jan 11, 2024
1 parent 4cd8a46 commit ef07a02
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
Binary file modified doc/images/jkqtmathtext/jkqtmathtext_unicode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/jkqtmathtext/jkqtmathtext_useguifonts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/jkqtmathtext/jkqtmathtext_utf8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/jkqtmathtext_test/testform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 11 additions & 10 deletions lib/jkqtmathtext/jkqtmathtexttools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}();
Expand Down
2 changes: 1 addition & 1 deletion lib/jkqtmathtext/jkqtmathtexttools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit ef07a02

Please sign in to comment.