#ifndef CTAIMATHCONVERT_H #define CTAIMATHCONVERT_H // 然后包含 cmark-gfm 相关头文件 #include "cmark-gfm.h" #include "cmark-gfm-extension_api.h" #include "cmark-gfm-core-extensions.h" // Qt 相关头文件 #include #include #include #include #include #include #include #include #include // LaTeX 相关头文件 #include "latex.h" #include "platform/qt/graphic_qt.h" // 项目相关头文件 #include "ctai_base.h" class TexGuard { public: TexGuard() { tex::LaTeX::init(); } ~TexGuard() { tex::LaTeX::release(); } }; using namespace tex; class ctaiMathConvert :public QObject { Q_OBJECT public: explicit ctaiMathConvert(); ~ctaiMathConvert(); QString replace_tags_svg(const QString &text); void set_convert_opts(); void save_svg(QPixmap& img); private: void debug_latex_match(const QString &text, const QRegularExpressionMatch &match); QString clean_latex_for_mula(const QString &formula); QString math_convert_svg(const QString& text); QByteArray svg_to_base64(QPixmap& pix); TexGuard texGuard; //宽度 int m_render_width=300; int m_render_height=64; //文本大小 int m_text_size=20; //行距 float m_lineSpace=20 / 3.f; //颜色 tex::color m_color=0xff424242; //边距 int m_padding=3; //处理后保存模式 bool save_mode=false; }; #endif