mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2025-02-03 11:09:20 +08:00
jkqtmathtext_render: added option to generate listing of all symbols + fixed some bugs
This commit is contained in:
parent
baeb7f9e38
commit
d3b0e88bb8
@ -1398,7 +1398,7 @@ JKQTMathText::tokenType JKQTMathText::getToken() {
|
|||||||
const QString verbEndChar=parseString.mid(currentTokenID, 1);
|
const QString verbEndChar=parseString.mid(currentTokenID, 1);
|
||||||
currentTokenName=readUntil(true, verbEndChar);
|
currentTokenName=readUntil(true, verbEndChar);
|
||||||
return currentToken=MTTinstructionVerbatim;
|
return currentToken=MTTinstructionVerbatim;
|
||||||
} else if (currentTokenName.startsWith("begin")) {
|
} else if (currentTokenName=="begin") {
|
||||||
currentTokenID++;
|
currentTokenID++;
|
||||||
if (parseString[currentTokenID]!='{') error_list.append(tr("error @ ch. %1: didn't find '{' after '\\begin'").arg(currentTokenID)); // find closing brace '}' after '\\begin{name');
|
if (parseString[currentTokenID]!='{') error_list.append(tr("error @ ch. %1: didn't find '{' after '\\begin'").arg(currentTokenID)); // find closing brace '}' after '\\begin{name');
|
||||||
currentTokenName=readUntil(true, "}");
|
currentTokenName=readUntil(true, "}");
|
||||||
@ -1413,9 +1413,9 @@ JKQTMathText::tokenType JKQTMathText::getToken() {
|
|||||||
return currentToken=MTTinstructionVerbatim;
|
return currentToken=MTTinstructionVerbatim;
|
||||||
}
|
}
|
||||||
return currentToken=MTTinstructionBegin;
|
return currentToken=MTTinstructionBegin;
|
||||||
} else if (currentTokenName.startsWith("end")) {
|
} else if (currentTokenName=="end") {
|
||||||
currentTokenID++;
|
currentTokenID++;
|
||||||
if (parseString[currentTokenID]!='{') error_list.append(tr("error @ ch. %1: didn't find '{' after '\\end'").arg(currentTokenID)); // find closing brace '}' after '\\begin{name');
|
if (currentTokenID>=parseString.size() || parseString[currentTokenID]!='{') error_list.append(tr("error @ ch. %1: didn't find '{' after '\\end'").arg(currentTokenID)); // find closing brace '}' after '\\begin{name');
|
||||||
currentTokenName=readUntil(true, "}");
|
currentTokenName=readUntil(true, "}");
|
||||||
return currentToken=MTTinstructionEnd;
|
return currentToken=MTTinstructionEnd;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,9 @@ class JKQTMathTextNode; // forward
|
|||||||
<br>using "Courier New": \image html jkqtmathtext/jkqtmathtext_couriernew.png
|
<br>using "Courier New": \image html jkqtmathtext/jkqtmathtext_couriernew.png
|
||||||
<br>using "Comic Sans MS": \image html jkqtmathtext/jkqtmathtext_comicsans.png
|
<br>using "Comic Sans MS": \image html jkqtmathtext/jkqtmathtext_comicsans.png
|
||||||
<br>using "Old English Text": \image html jkqtmathtext/jkqtmathtext_OldEnglish.png
|
<br>using "Old English Text": \image html jkqtmathtext/jkqtmathtext_OldEnglish.png
|
||||||
|
<br>using "Computer Modern": \image html jkqtmathtext/jkqtmathtext_computermodern.png
|
||||||
|
<br>using "Fira": \image html jkqtmathtext/jkqtmathtext_fira.png
|
||||||
|
<br>using "MS Segoe UI": \image html jkqtmathtext/jkqtmathtext_mssegoeui.png
|
||||||
.
|
.
|
||||||
|
|
||||||
Math-mode is activated by enclosing your equation in \c $...$ or \c \\[...\\] . This mode is optimized for mathematical equations. Here is an example of the difference:
|
Math-mode is activated by enclosing your equation in \c $...$ or \c \\[...\\] . This mode is optimized for mathematical equations. Here is an example of the difference:
|
||||||
@ -362,13 +365,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
|||||||
void setFontCaligraphic(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
|
void setFontCaligraphic(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
|
||||||
/** \brief retrieves the font to be used for text in the logical font MTEcaligraphic */
|
/** \brief retrieves the font to be used for text in the logical font MTEcaligraphic */
|
||||||
QString getFontCaligraphic() const;
|
QString getFontCaligraphic() const;
|
||||||
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEblackboard */
|
/** \brief set the font \a fontName and it's encoding \a encoding to be used for text in the logical font MTEblackboard \see setFontBlackboardSimulated()
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
void setFontBlackboard(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
|
void setFontBlackboard(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
|
||||||
/** \brief blackboard font is simulated by using roman with outlines only */
|
/** \copydoc blackboardSimulated */
|
||||||
void setFontBlackboardSimulated(bool doSimulate);
|
void setFontBlackboardSimulated(bool doSimulate);
|
||||||
/** \brief is blackboard font simulated by using roman with outlines only */
|
/** \copydoc blackboardSimulated \see setFontBlackboardSimulated() */
|
||||||
bool isFontBlackboardSimulated() const;
|
bool isFontBlackboardSimulated() const;
|
||||||
/** \brief retrieves the font to be used for text in the logical font MTEblackboard */
|
/** \brief retrieves the font to be used for text in the logical font MTEblackboard \see setFontBlackboardSimulated() */
|
||||||
QString getFontBlackboard() const;
|
QString getFontBlackboard() const;
|
||||||
/** \brief set the font \a fontName and it's encoding \a encoding to be used for symbols in the logical font \a font */
|
/** \brief set the font \a fontName and it's encoding \a encoding to be used for symbols in the logical font \a font */
|
||||||
void setFallbackFontSymbols(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
|
void setFallbackFontSymbols(const QString & fontName, JKQTMathTextFontEncoding encoding=JKQTMathTextFontEncoding::MTFEStandard);
|
||||||
@ -626,7 +632,16 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathText : public QObject {
|
|||||||
|
|
||||||
/** \brief stores information about the different fonts used by LaTeX markup */
|
/** \brief stores information about the different fonts used by LaTeX markup */
|
||||||
QHash<JKQTMathTextEnvironmentFont, JKQTMathTextFontDefinition> fontDefinitions;
|
QHash<JKQTMathTextEnvironmentFont, JKQTMathTextFontDefinition> fontDefinitions;
|
||||||
/** \brief if enabled, the blackboard-characters are simulated by using font outlines only */
|
/** \brief if enabled, the blackboard-characters are simulated by using font outlines only
|
||||||
|
*
|
||||||
|
* A possible choice for a blackboard font (Castellar) looks like this:
|
||||||
|
* \image html jkqtmathtext/jkqtmathtext_bb.png
|
||||||
|
* If such a font is not available, you can set this property blackboardSimulated
|
||||||
|
* to \c true and chose a font, like e.g. Arial to output blackboard-letters as:
|
||||||
|
* \image html jkqtmathtext/jkqtmathtext_bb_sim.png
|
||||||
|
*
|
||||||
|
* \see setFontBlackboard() setFontBlackboardSimulated()
|
||||||
|
*/
|
||||||
bool blackboardSimulated;
|
bool blackboardSimulated;
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,6 +306,12 @@ bool JKQTMathTextSymbolNode::hasSymbol(const QString &symbolName)
|
|||||||
return symbols.contains(symbolName);
|
return symbols.contains(symbolName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList JKQTMathTextSymbolNode::getSymbols()
|
||||||
|
{
|
||||||
|
fillSymbolTables();
|
||||||
|
return symbols.keys();
|
||||||
|
}
|
||||||
|
|
||||||
bool JKQTMathTextSymbolNode::isSubSuperscriptBelowAboveSymbol(const QString &symbolName)
|
bool JKQTMathTextSymbolNode::isSubSuperscriptBelowAboveSymbol(const QString &symbolName)
|
||||||
{
|
{
|
||||||
fillSymbolTables();
|
fillSymbolTables();
|
||||||
@ -462,6 +468,7 @@ void JKQTMathTextSymbolNode::fillSymbolTables()
|
|||||||
symbols["|"]=SimpleUprightTextSymbol("||", "‖").addUprightUnicode(QChar(0x2016));
|
symbols["|"]=SimpleUprightTextSymbol("||", "‖").addUprightUnicode(QChar(0x2016));
|
||||||
symbols["}"]=SimpleUprightTextSymbol("}");
|
symbols["}"]=SimpleUprightTextSymbol("}");
|
||||||
symbols["AC"]=UprightSymbolUnicode(QChar(0x223F)).addUprightHtml("∿").addUprightStd("~");
|
symbols["AC"]=UprightSymbolUnicode(QChar(0x223F)).addUprightHtml("∿").addUprightStd("~");
|
||||||
|
symbols["circonflex"]=SimpleTextSymbol("^");
|
||||||
symbols["aa"]=SimpleTextSymbol(QChar(0xE5));
|
symbols["aa"]=SimpleTextSymbol(QChar(0xE5));
|
||||||
symbols["ae"]=SimpleTextSymbol(QChar(0xE6));
|
symbols["ae"]=SimpleTextSymbol(QChar(0xE6));
|
||||||
symbols["AE"]=SimpleTextSymbol(QChar(0xC6));
|
symbols["AE"]=SimpleTextSymbol(QChar(0xC6));
|
||||||
|
@ -83,6 +83,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode {
|
|||||||
void getSymbolSize(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, double& subSuperXCorrection, double& subBesidesXCorrection, const JKQTMathTextNodeSize* prevNodeSize=nullptr);
|
void getSymbolSize(QPainter& painter, JKQTMathTextEnvironment currentEv, double& width, double& baselineHeight, double& overallHeight, double& strikeoutPos, double& subSuperXCorrection, double& subBesidesXCorrection, const JKQTMathTextNodeSize* prevNodeSize=nullptr);
|
||||||
/** \brief checks whether the given symbol name can be prepresented by this type of node */
|
/** \brief checks whether the given symbol name can be prepresented by this type of node */
|
||||||
static bool hasSymbol(const QString& symbolName);
|
static bool hasSymbol(const QString& symbolName);
|
||||||
|
/** \brief return a list of all defined symbols */
|
||||||
|
static QStringList getSymbols();
|
||||||
/** \brief checks whether the given symbol name can be prepresented by this type of node */
|
/** \brief checks whether the given symbol name can be prepresented by this type of node */
|
||||||
static bool isSubSuperscriptBelowAboveSymbol(const QString& symbolName);
|
static bool isSubSuperscriptBelowAboveSymbol(const QString& symbolName);
|
||||||
protected:
|
protected:
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "jkqtmathtext/jkqtmathtextlabel.h"
|
#include "jkqtmathtext/jkqtmathtextlabel.h"
|
||||||
#include "jkqtcommon/jkqtpstringtools.h"
|
#include "jkqtcommon/jkqtpstringtools.h"
|
||||||
|
#include "jkqtmathtext/nodes/jkqtmathtextsymbolnode.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void processFont(const QString font, QStringList& fonts, QString& mathFont)
|
void processFont(const QString font, QStringList& fonts, QString& mathFont)
|
||||||
@ -64,6 +65,8 @@ int main(int argc, char* argv[])
|
|||||||
parser.addOption(inputfileOption);
|
parser.addOption(inputfileOption);
|
||||||
QCommandLineOption outputDirectoryOption("outputdir", "write results into this directory.", "outputdir", app.applicationDirPath());
|
QCommandLineOption outputDirectoryOption("outputdir", "write results into this directory.", "outputdir", app.applicationDirPath());
|
||||||
parser.addOption(outputDirectoryOption);
|
parser.addOption(outputDirectoryOption);
|
||||||
|
QCommandLineOption listsymbolsOption("listsymbols", "list all symbols in the given output file and generate images.", "listsymbols", "");
|
||||||
|
parser.addOption(listsymbolsOption);
|
||||||
QCommandLineOption drawBoxesOption("drawboxes", "draw boxes.");
|
QCommandLineOption drawBoxesOption("drawboxes", "draw boxes.");
|
||||||
parser.addOption(drawBoxesOption);
|
parser.addOption(drawBoxesOption);
|
||||||
QCommandLineOption verboseOption("verbose", "verbose output.");
|
QCommandLineOption verboseOption("verbose", "verbose output.");
|
||||||
@ -111,15 +114,40 @@ int main(int argc, char* argv[])
|
|||||||
const QDir outputDir(parser.value(outputDirectoryOption));
|
const QDir outputDir(parser.value(outputDirectoryOption));
|
||||||
const QString outputFilename_cmdline=outputDir.absoluteFilePath(args.value(1, "output.png"));
|
const QString outputFilename_cmdline=outputDir.absoluteFilePath(args.value(1, "output.png"));
|
||||||
const QString inputfile=parser.value(inputfileOption);
|
const QString inputfile=parser.value(inputfileOption);
|
||||||
|
const QString listsymbols=parser.value(listsymbolsOption);
|
||||||
const bool verbose = parser.isSet(verboseOption);
|
const bool verbose = parser.isSet(verboseOption);
|
||||||
|
|
||||||
QStringList latex, outputFilename;
|
QStringList latex, outputFilename;
|
||||||
QList<QMap<QString,QString>> cmdoptions;
|
QList<QMap<QString,QString>> cmdoptions;
|
||||||
if (inputfile.size()<=0) {
|
if (listsymbols.size()>0) {
|
||||||
latex.append(latex_cmdline);
|
//std::cout<<"LISTSYMBOLS: "<<outputDir.absoluteFilePath(listsymbols).toStdString()<<"\n";
|
||||||
outputFilename.append(outputFilename_cmdline);
|
QFile fileListF(outputDir.absoluteFilePath(listsymbols));
|
||||||
cmdoptions.append(QMap<QString,QString>());
|
if (fileListF.open(QFile::WriteOnly|QFile::Text)) {
|
||||||
} else {
|
QTextStream fileList(&fileListF);
|
||||||
|
int i=1;
|
||||||
|
fileList<<"/*!\n"
|
||||||
|
" \\defgroup jkqtmathtext_supportedlatexsymbols Supported LaTeX-Symbols\n"
|
||||||
|
" \\ingroup jkqtmathtext_general\n\n";
|
||||||
|
fileList<<" <table>\n";
|
||||||
|
fileList<<" <tr>\n";
|
||||||
|
for (const QString& symbol: JKQTMathTextSymbolNode::getSymbols()) {
|
||||||
|
if (symbol.size()>0 && symbol[0].isLetter()) {
|
||||||
|
latex.append("\\"+symbol);
|
||||||
|
outputFilename.append("jkqtmathtext_symbols_"+symbol+".png");
|
||||||
|
cmdoptions.append(QMap<QString,QString>());
|
||||||
|
//std::cout<<" - "<<latex.last().toStdString()<<": "<<outputFilename.last().toStdString()<<"\n";
|
||||||
|
fileList<<" <td><code>\\\\"<<symbol<<"</code>:\n <td> \\image html jkqtmathtext/symbols/"<<outputFilename.last()<<"\n";
|
||||||
|
if (i%3==0) {
|
||||||
|
fileList<<" </tr>\n <tr>\n";
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fileList<<" </tr>";
|
||||||
|
fileList<<" </table>\n";
|
||||||
|
fileList<<"*/\n";
|
||||||
|
}
|
||||||
|
} else if (inputfile.size()>0){
|
||||||
QFile f(inputfile);
|
QFile f(inputfile);
|
||||||
if (f.open(QFile::ReadOnly|QFile::Text)) {
|
if (f.open(QFile::ReadOnly|QFile::Text)) {
|
||||||
QString currentOutFile="";
|
QString currentOutFile="";
|
||||||
@ -182,13 +210,18 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
latex.append(latex_cmdline);
|
||||||
|
outputFilename.append(outputFilename_cmdline);
|
||||||
|
cmdoptions.append(QMap<QString,QString>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
std::cout
|
std::cout
|
||||||
<<"===========================================================\n"
|
<<"===========================================================\n"
|
||||||
<<"= jkqtmathtext_render: ";
|
<<"= jkqtmathtext_render: ";
|
||||||
if (inputfile.size()>0) std::cout<<"FILE-MODE ("<<inputfile.toStdString()<<")\n";
|
if (inputfile.size()>0) std::cout<<"FILE-MODE (read from "<<inputfile.toStdString()<<")\n";
|
||||||
|
else if (listsymbols.size()>0) std::cout<<"LIST-SYMBOLS-MODE (store to "<<listsymbols.toStdString()<<")\n";
|
||||||
else std::cout<<"COMMAND-LINE-MODE\n";
|
else std::cout<<"COMMAND-LINE-MODE\n";
|
||||||
std::cout<<"\n"
|
std::cout<<"\n"
|
||||||
<<"===========================================================\n";
|
<<"===========================================================\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user