diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index 7e5b8848ce..25ffdb9bfc 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -2038,7 +2038,7 @@ JKQTmathText::MTsymbolNode::MTsymbolNode(JKQTmathText* parent, QString name, boo <<"subsetnot"<<"bot"<<"leftharpoonup"<<"rightharpoonup"<<"upharpoonleft"<<"downharpoonleft"<<"leftrightharpoon"<<"rightleftharpoon"<<"coprod"<<"leftharpoondown" <<"rightharpoondown"<<"upharpoonright"<<"downharpoonright"<<"nwarrow"<<"nearrow"<<"searrow"<<"swarrow"<<"mapsto"<<"div"<<"multimap"<<"maporiginal"<<"mapimage" <<"times"<<"propto"<<"bullet"<<"neq"<<"ne"<<"equiv"<<"approx"<<"otimes"<<"oplus"<<"oslash"<<"cap"<<"land"<<"cup"<<"lor"<<"supset"<<"supseteq"<<"supsetnot" - <<"subset"<<"subseteq"<<"in"<<"notin"<<"cdot"<<"wedge"<<"vee"<<"cong"<<"bot"; + <<"subset"<<"subseteq"<<"in"<<"notin"<<"cdot"<<"wedge"<<"vee"<<"cong"<<"bot"<<"mid"; } if (extendWInMM.contains(n)) { @@ -2213,7 +2213,7 @@ JKQTmathText::MTsymbolNode::MTsymbolNode(JKQTmathText* parent, QString name, boo winSymbolSymbol.insert("rfloor", QChar(0xFB)); winSymbolSymbol.insert("subsetnot", QChar(0xCB)); winSymbolSymbol.insert("DC", "="); - winSymbolSymbol.insert("bot", QChar(0x5E)); + winSymbolSymbol.insert("mid", "|"); winSymbolSymbol.insert("cdots", QString(3, QChar(0xD7))); winSymbolSymbol.insert("dots", QChar(0xDC)); winSymbolSymbol.insert("ldots", QChar(0xDC)); @@ -2314,6 +2314,7 @@ JKQTmathText::MTsymbolNode::MTsymbolNode(JKQTmathText* parent, QString name, boo unicodeSymbol.insert("subsetnot", QChar(0x2284)); unicodeSymbol.insert("DC", QChar(0x2393)); unicodeSymbol.insert("bot", QChar(0x22A4)); + unicodeSymbol.insert("mid", QChar(0xFF5C)); unicodeSymbol.insert("cdots", QString(QChar(0x00B7)) + QString(QChar(0x00B7)) + QString(QChar(0x00B7))); unicodeSymbol.insert("vdots", QChar(0x22EE)); unicodeSymbol.insert("iddots", QChar(0x22F0)); @@ -2528,7 +2529,7 @@ JKQTmathText::MTsymbolNode::MTsymbolNode(JKQTmathText* parent, QString name, boo latexSymbol.insert("forall", QChar(0x38)); latexSymbol.insert("exists", QChar(0x39)); latexSymbol.insert("cong", QChar(0xbb)); - latexSymbol.insert("bot", QChar(0x3f)); + latexSymbol.insert("mid", "|"); } @@ -2756,6 +2757,7 @@ void JKQTmathText::MTsymbolNode::getSizeInternal(QPainter& painter, JKQTmathText width=fm.width("a"); if (symbolName=="|") width=fm.width("1")*0.8; else if (symbolName=="infty") width=fm.width("M"); + else if (symbolName=="quad") width=parent->getTBR(f, "M", painter.device()).width(); else if (symbolName==" ") width=parent->getTBR(f, "x", painter.device()).width(); else if (symbolName==";") width=parent->getTBR(f, "x", painter.device()).width()*0.75; else if (symbolName==":") width=parent->getTBR(f, "x", painter.device()).width()*0.5; @@ -2808,8 +2810,11 @@ double JKQTmathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J QFontMetricsF fm1(f1, painter.device()); painter.setFont(f); + double shift=0; if (extendWidthInMathmode && currentEv.insideMath) { - x=x+0.5*width*(parent->get_mathoperator_width_factor()-1.0); + double origwidth=width/parent->get_mathoperator_width_factor(); + shift=0.5*(width-origwidth); + //width=width*parent->get_mathoperator_width_factor(); } //std::cout<<"symbol '"<getTBR(f, "M", painter.device()).height()-fm.xHeight())/3.0; QLineF l(xx, yy, xx+xwi/3.0+((currentEv.italic)?(xwi/3.0):0), yy); if (drawBar&&l.length()>0) painter.drawLine(l); @@ -2835,7 +2840,7 @@ double JKQTmathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J f1.setItalic(false); painter.setFont(f1); painter.save(); - painter.translate(x+fm1.width("8")/3.0, y-fm1.xHeight()); + painter.translate(x+shift+fm1.width("8")/3.0, y-fm1.xHeight()); painter.rotate(90); painter.drawText(QPointF(0,0), "8"); painter.restore(); @@ -2845,7 +2850,7 @@ double JKQTmathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J painter.setFont(f1); painter.save(); - painter.translate(x, y); + painter.translate(x+shift, y); painter.drawText(QPointF(0,0), "|"); painter.translate(fm1.width("8")/3.0, 0); painter.drawText(QPointF(0,0), "|"); @@ -2853,6 +2858,7 @@ double JKQTmathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J // here are some spaces } else if (symbolName==" ") { // full space + } else if (symbolName=="quad") { // 75% space } else if (symbolName==";") { // 75% space } else if (symbolName==":") { // 50% space } else if (symbolName==",") { // 25% space @@ -2861,41 +2867,42 @@ double JKQTmathText::MTsymbolNode::draw(QPainter& painter, double x, double y, J double width=parent->getTBR(f, "X", painter.device()).width()*3.0; double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeArrow(x+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); + QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); painter.drawPath(path); } else if (symbolName=="longrightarrow"){ double width=parent->getTBR(f, "X", painter.device()).width()*3.0; double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeArrow(x+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); + QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); painter.drawPath(path); } else if (symbolName=="Longleftarrow") { double width=parent->getTBR(f, "X", painter.device()).width()*3.0; double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeDArrow(x+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); + QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, false); painter.drawPath(path); } else if (symbolName=="Longrightarrow") { double width=parent->getTBR(f, "X", painter.device()).width()*3.0; double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeDArrow(x+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); + QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, false, true); painter.drawPath(path); } else if (symbolName=="longleftrightarrow") { double width=parent->getTBR(f, "X", painter.device()).width()*3.0; double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeArrow(x+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); + QPainterPath path=makeArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); painter.drawPath(path); } else if (symbolName=="Longleftrightarrow") { double width=parent->getTBR(f, "X", painter.device()).width()*3.0; double dx=parent->getTBR(f, "X", painter.device()).width()*0.25; double ypos=y-parent->getTBR(f, "x", painter.device()).height()/2.0; - QPainterPath path=makeDArrow(x+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); + QPainterPath path=makeDArrow(x+shift+dx, ypos, width, parent->getTBR(f, "M", painter.device()).height()*0.5, true, true); painter.drawPath(path); } else { // draw a box to indicate an unavailable symbol QRectF tbr=parent->getTBR(f, "M", painter.device()); - painter.drawRect(QRectF(x,y-tbr.height(), xwi, tbr.height()*0.8)); + painter.drawRect(QRectF(x+shift,y-tbr.height(), xwi, tbr.height()*0.8)); + parent->error_list<<"unknown symbol '"<. It was not published by SIL International, and does not legally state the distribution terms for fonts that use the OFL. A release under the OFL is only valid when using the original English text. However, we recognize that this unofficial translation will help users and designers not familiar with English to better understand and use the OFL. We encourage designers who consider releasing their creation under the OFL to read the OFL-FAQ in their own language if it is available. Please go to http://scripts.sil.org/OFL for the official version of the license and the accompanying OFL-FAQ." + +- Keep your unofficial translation current and update it at our request if needed, for example if there is any ambiguity which could lead to confusion. + +If you start such a unofficial translation effort of the OFL and OFL-FAQ please let us know. + + +9 ABOUT SIL INTERNATIONAL + +9.1 Who is SIL International and what do they do? +SIL serves language communities worldwide, building their capacity for sustainable language development, by means of research, translation, training and materials development. SIL makes its services available to all without regard to religious belief, political ideology, gender, race, or ethnic background. SIL's members and volunteers share a Christian commitment. + +9.2 What does this have to do with font licensing? +The ability to read, write, type and publish in one's own language is one of the most critical needs for millions of people around the world. This requires fonts that are widely available and support lesser-known languages. SIL develops - and encourages others to develop - a complete stack of writing systems implementation components available under open licenses. This open stack includes input methods, smart fonts, smart rendering libraries and smart applications. There has been a need for a common open license that is specifically applicable to fonts and related software (a crucial component of this stack), so SIL developed the SIL Open Font License with the help of the Free/Libre and Open Source Software community. + +9.3 How can I contact SIL? +Our main web site is: http://www.sil.org/ +Our site about complex scripts is: http://scripts.sil.org/ +Information about this license (and contact information) is at: http://scripts.sil.org/OFL + + +APPENDIX A - FONTLOG EXAMPLE + +Here is an example of the recommended format for a FONTLOG, although other formats are allowed. + +----- +FONTLOG for the GlobalFontFamily fonts + +This file provides detailed information on the GlobalFontFamily Font Software. This information should be distributed along with the GlobalFontFamily fonts and any derivative works. + +Basic Font Information + +GlobalFontFamily is a Unicode typeface family that supports all languages that use the Latin script and its variants, and could be expanded to support other scripts. + +NewWorldFontFamily is based on the GlobalFontFamily and also supports Greek, Hebrew, Cyrillic and Armenian. + +More specifically, this release supports the following Unicode ranges... +This release contains... +Documentation can be found at... +To contribute to the project... + +ChangeLog + +1 August 2008 (Tom Parker) GlobalFontFamily version 1.2.1 +- Tweaked the smart font code (Branch merged with trunk version) +- Provided improved build and debugging environment for smart behaviours + +7 February 2007 (Pat Johnson) NewWorldFontFamily Version 1.3 +- Added Greek and Cyrillic glyphs + +7 March 2006 (Fred Foobar) NewWorldFontFamily Version 1.2 +- Tweaked contextual behaviours + +1 Feb 2005 (Jane Doe) NewWorldFontFamily Version 1.1 +- Improved build script performance and verbosity +- Extended the smart code documentation +- Corrected minor typos in the documentation +- Fixed position of combining inverted breve below (U+032F) +- Added OpenType/Graphite smart code for Armenian +- Added Armenian glyphs (U+0531 -> U+0587) +- Released as "NewWorldFontFamily" + +1 Jan 2005 (Joe Smith) GlobalFontFamily Version 1.0 +- Initial release + +Acknowledgements + +If you make modifications be sure to add your name (N), email (E), web-address (if you have one) (W) and description (D). This list is in alphabetical order. + +N: Jane Doe +E: jane@university.edu +W: http://art.university.edu/projects/fonts +D: Contributor - Armenian glyphs and code + +N: Fred Foobar +E: fred@foobar.org +W: http://foobar.org +D: Contributor - misc Graphite fixes + +N: Pat Johnson +E: pat@fontstudio.org +W: http://pat.fontstudio.org +D: Designer - Greek & Cyrillic glyphs based on Roman design + +N: Tom Parker +E: tom@company.com +W: http://www.company.com/tom/projects/fonts +D: Engineer - original smart font code + +N: Joe Smith +E: joe@fontstudio.org +W: http://joe.fontstudio.org +D: Designer - original Roman glyphs + +Fontstudio.org is an not-for-profit design group whose purpose is... +Foobar.org is a distributed community of developers... +Company.com is a small business who likes to support community designers... +University.edu is a renowed educational institution with a strong design department... +----- diff --git a/test/jkqtmathtext_test/jkqtmathtext_test.pro b/test/jkqtmathtext_test/jkqtmathtext_test.pro index fbcea3668d..90d68103a2 100644 --- a/test/jkqtmathtext_test/jkqtmathtext_test.pro +++ b/test/jkqtmathtext_test/jkqtmathtext_test.pro @@ -11,7 +11,7 @@ RCC_DIR = rccs CONFIG += qt windows -TARGET = jkqtplot_test +TARGET = jkqtmathtext_test QT += core gui svg xml @@ -38,4 +38,4 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport DEPENDPATH += . ../../lib INCLUDEPATH += ../../lib CONFIG (debug, debug|release):LIBS += -L../../lib/debug -ljkqtplotterlib -CONFIG (release):LIBS += -L../../lib/release -ljkqtplotterlib \ No newline at end of file +CONFIG (release):LIBS += -L../../lib/release -ljkqtplotterlib diff --git a/test/jkqtmathtext_test/testform.cpp b/test/jkqtmathtext_test/testform.cpp index a1b01cfb32..196693bc16 100644 --- a/test/jkqtmathtext_test/testform.cpp +++ b/test/jkqtmathtext_test/testform.cpp @@ -8,7 +8,8 @@ TestForm::TestForm(QWidget *parent) : ui(new Ui::TestForm) { ui->setupUi(this); - ui->cmbTestset->addItem("simple equarelationslities", "$a{\\leq}b$, $a{\\geq}b$, $a{\\equiv}b$, $a=b$, $a{\\neq}b$, $ab$"); + ui->cmbTestset->addItem("simple relations", "$a{\\leq}b$, $a{\\geq}b$, $a{\\equiv}b$, $a=b$, $a{\\neq}b$, $ab$"); + ui->cmbTestset->addItem("simple relations in different modes", "math: $a{\\leq}b$, math/no braces: $a\\leq b$, no math: a{\\leq}b, no math/no braces: a\\leq b"); ui->cmbTestset->addItem("named symbols 1", "ll: $\\ll$\\ gg: $\\gg$\\ leq: $\\leq$\\ geq: $\\geq$\\ pm: $\\pm$\\ mp: $\\mp$\\ "); ui->cmbTestset->addItem("named symbols 2", "nexists: $\\nexists$\\ ni: $\\ni$\\ notni: $\\notni$\\ circ: $\\circ$\\ sim: $\\sim$\\ emptyset: $\\emptyset$\\ odot: $\\odot$\\ ominus: $\\ominus$\\ subsetnot: $\\subsetnot$\\ bot: $\\bot$"); ui->cmbTestset->addItem("named symbols 3", "leftharpoonup: $\\leftharpoonup$\\ rightharpoonup: $\\rightharpoonup$\\ upharpoonleft: $\\upharpoonleft$\\ downharpoonleft: $\\downharpoonleft$\\ leftrightharpoon: $\\leftrightharpoon$\\ rightleftharpoon: $\\rightleftharpoon$"); @@ -120,8 +121,12 @@ TestForm::TestForm(QWidget *parent) : ui->cmbTestset->addItem(QLatin1String("Schrödinger's equation"), "$\\left[-\\frac{\\hbar^2}{2m}\\frac{\\partial^2}{\\partial x^2}+V\\right]\\Psi(x)=\\mathrm{i}\\hbar\\frac{\\partial}{\\partial t}\\Psi(x)$"); ui->cmbTestset->addItem("Cauchy-Schwarz inequality", "$\\left( \\sum_{k=1}^n a_k b_k \\right)^2 \\leq \\left( \\sum_{k=1}^n a_k^2 \\right) \\left( \\sum_{k=1}^n b_k^2 \\right)$"); ui->cmbTestset->addItem("Maxwell's equations", "$\\begin{aligned}\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac{1}{c}\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac{1}{c}\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \\end{aligned}$"); + ui->cmbTestset->addItem("Langevin Equation", "$m \\dot{v}(t) = -\\gamma v(t) + F(x,t)+ f(t)$"); + ui->cmbTestset->addItem("Fokker-Planck Equation", "$\\frac{\\partial}{\\partial t}P(y,t)=-\\frac{\\partial}{\\partial y}\\left[ A(y,t)P(y,t)\\right] +\\frac{\\Gamma}{2}\\frac{\\partial^2}{\\partial y^2}\\left[ P(y,t)\\right]$"); + ui->cmbTestset->addItem("Hamilton Equations of motion", "$\\mathcal{H}(\\mathbf{q},\\mathbf{p})=\\frac{\\mathbf{p}^2}{2\\,m}+V(\\mathbf{q})\\ \\ \\ \\text{and}\\ \\ \\ \\dot{q}_k =\\frac{p_k}{m}\\ ,\\ \\dot{p}_k = - \\frac{\\partial V}{\\partial q_k}$"); + ui->cmbTestset->addItem("Gaussian Distrubution", "$f(x | \\mu,\\sigma^2)=\\frac{1}{\\sqrt{2\\pi\\sigma^2}}\\operatorname{exp}\\left(-\\frac{(x-\\mu)^2}{2\\sigma^2}\\right)=\\frac{1}{\\sqrt{2\\pi\\sigma^2}} e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}\\quad -\\inftycmbTestset->addItem("User-Editable Text"); - //ui->cmbTestset->addItem("", "$$"); + // //ui->cmbTestset->addItem("", "$$"); //ui->cmbTestset->addItem("", "$$"); //ui->cmbTestset->addItem("", ""); @@ -358,6 +363,14 @@ void TestForm::updateMath() double durationSizingMS=0, durationTimingMS=0; Y+=draw(painter, X1, Y, mt, QString("%1, %2, %3pt").arg(ui->cmbTestset->currentText()).arg(ui->cmbFont->currentText()).arg(size), durationSizingMS, durationTimingMS); + if (i==0) { + if (mt.get_error_list().size()>0) { + ui->labError->setText(""+mt.get_error_list().join("
")+"
"); + } else { + ui->labError->setText("OK"); + } + } + ui->labRenderTimes->setText(ui->labRenderTimes->text()+QString(" %1pt: %2ms/%3ms").arg(size).arg(durationSizingMS, 0, 'F', 1).arg(durationTimingMS, 0, 'F', 1)); ui->textBrowser->textCursor().insertHtml("
"+mt.toHtml(&okh)+"


"); qDebug()<<"HTML: ---------------------------------------------\n"< + + + + + +