diff --git a/doc/dox/whatsnew.dox b/doc/dox/whatsnew.dox index c9ef022bd9..b94196bc05 100644 --- a/doc/dox/whatsnew.dox +++ b/doc/dox/whatsnew.dox @@ -40,6 +40,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
  • IMPROVED: added x-correction for sub/superscript above/below/besides integrals
  • IMPROVED: rendering of sqrt
  • IMPROVED: rendering and size calculation of decorations
  • +
  • IMPROVED: tokenizing and parsing of text in text-mode: now a lot of accents with commands like \"a, \'e and variants (e.g. {\"a}, \"{a}, ...) are supported now
  • IMPROVED/breaking: refactored symbol node JKQTMathTextSymbolNode and changed font-lookup!
  • IMPROVED/NEW/breaking: refactored whitespace-processing node JKQTMathTextWhitespaceNode, now all major LaTeX whitespace commands are supported properly
  • IMPROVED/NEW/breaking: refactored LaTeX parser in JKQTMathText
  • @@ -56,6 +57,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
  • NEW: added top-corner (\ulcorner/\urcorner) and bottom-corner brackets (\llcorner/\lrcorner)
  • NEW: added \overbracket and \underbracket
  • NEW: added \shaded{color}{...}
  • +
  • NEW: added \acute{X}, \grave{X}, \acute{X}
  • NEW: added functions to set the font-size in pixels (as alternative to the existing functions that set them in points), implements request #76 from user:igormironchik
  • diff --git a/doc/images/jkqtmathtext/MTDacute.png b/doc/images/jkqtmathtext/MTDacute.png new file mode 100644 index 0000000000..f94f338491 Binary files /dev/null and b/doc/images/jkqtmathtext/MTDacute.png differ diff --git a/doc/images/jkqtmathtext/MTDgrave.png b/doc/images/jkqtmathtext/MTDgrave.png new file mode 100644 index 0000000000..fa3bb066cd Binary files /dev/null and b/doc/images/jkqtmathtext/MTDgrave.png differ diff --git a/examples/jkqtmathtext_test/mathtest.pdf b/examples/jkqtmathtext_test/mathtest.pdf index d962b30eed..6a6b9c004e 100644 Binary files a/examples/jkqtmathtext_test/mathtest.pdf and b/examples/jkqtmathtext_test/mathtest.pdf differ diff --git a/examples/jkqtmathtext_test/mathtest.tex b/examples/jkqtmathtext_test/mathtest.tex index f8527026c0..6b46239e40 100644 --- a/examples/jkqtmathtext_test/mathtest.tex +++ b/examples/jkqtmathtext_test/mathtest.tex @@ -40,6 +40,9 @@ \begin{document} \begin{itemize} + \item\textbf{Text: Umlaute \& fonts: } rm: \textrm{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, sf: \textsf{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, tt: \texttt{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, cal: \textcal{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, scr: \textscr{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, bb: \textbb{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, frak: \textfrak{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}, + \item\textbf{text: Umlaute}:\"A\"a\`A\`a\'A\'a\^A\^a\~A\~a\r{A}\r{a}\u{A}\u{a}\=A\=a\AA\aa{\AE}{\ae}\v{C}\v{c}\"E\"e\.e\L\l\"O\"o\`O\`o\'O\'o\^O\^o\~O\~o\O\o{\OE}{\ae}\v{S}\v{s}\ss\"U\"u\`U\`u\'U\'u\^U\^u\~U\~u + \item\textbf{math: Umlaute and fonts} base: $\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S$, rm: $\mathrm{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$, sf: $\mathsf{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$, tt: $\mathtt{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$, cal: $\mathcal{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$, scr: $\mathscr{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$, bb: $\mathbb{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$, frak: $\mathfrak{\"Aq{\"u}\"{a}t{\oe}r00, 123-45+6.0\%\S}$ \item\textbf{std dev:} \[\sigma_x=\sqrt{\langle (x-\langle x\rangle)^2\rangle}=\sqrt{\frac{1}{N-1}\cdot\left( \sum_{i=1}^N{x_i}^2-\frac{1}{N}\cdot\left(\sum_{i=1}^Nx_i\right)^2\right)} \] \item\textbf{std dev 2:} \[\sigma_x=\sqrt{\langle (x-\langle x\rangle)^2\rangle}=\sqrt{\frac{1}{N-1}\cdot\left( \sum_{i=1}^Nx_i^2-\frac{1}{N}\cdot\left(\sum_{i=1}^Nx_i\right)^2\right)} \] diff --git a/examples/jkqtmathtext_test/testform.cpp b/examples/jkqtmathtext_test/testform.cpp index 99c29df114..f93cf4a551 100644 --- a/examples/jkqtmathtext_test/testform.cpp +++ b/examples/jkqtmathtext_test/testform.cpp @@ -20,8 +20,18 @@ TestForm::TestForm(QWidget *parent) : ui(new Ui::TestForm) { ui->setupUi(this); - ui->cmbTestset->addItem("text: fonts", "rm: \\textrm{ABCabc123}, sf: \\textsf{ABCabc123}, tt: \\texttt{ABCabc123}, cal: \\textcal{ABCabc123}, scr: \\textscr{ABCabc123}, bb: \\textbb{ABCabc123}, frak: \\textfrak{ABCabc123}, "); - ui->cmbTestset->addItem("math-fonts", "rm: $\\mathrm{ABCabc123}$, sf: $\\mathsf{ABCabc123}$, tt: $\\mathtt{ABCabc123}$, cal: $\\mathcal{ABCabc123}$, scr: $\\mathscr{ABCabc123}$, bb: $\\mathbb{ABCabc123}$, frak: $\\mathfrak{ABCabc123}$, "); + const QString testText="ABCabc00, 123-45+6.0\\%\\S"; + const QString umla="\\\"A\\\"a\\`A\\`a\\'A\\'a\\^A\\^a\\~A\\~a\\r{A}\\r{a}\\u{A}\\u{a}\\=A\\=a\\AA\\aa{\\AE}{\\ae}\\v{C}\\v{c}\\\"E\\\"e\\.e\\L\\l\\\"O\\\"o\\`O\\`o\\'O\\'o\\^O\\^o\\~O\\~o\\O\\o{\\OE}{\\ae}\\v{S}\\v{s}\\ss\\\"U\\\"u\\`U\\`u\\'U\\'u\\^U\\^u\\~U\\~u"; + const QString testTextUmla="\\\"Aq{\\\"u}\\\"{a}t{\\oe}r00, 123-45+6.0\\%\\S"; + const QString umla_math="\\ddot{A}\\ddot{a}\\grave{A}\\grave{a}\\acute{A}\\acute{a}\\hat{A}\\hat{a}\\tilde{A}\\tilde{a}\\r{A}\\r{a}\\u{A}\\u{a}\\bar{A}\\bar{a}\\AA\\aa{\\AE}{\\ae}\\check{C}\\check{c}\\ddot{E}\\ddot{e}\\dot{e}\\L\\l\\ddot{O}\\ddot{o}\\grave{O}\\grave{o}\\acute{O}\\acute{o}\\hat{O}\\hat{o}\\tilde{O}\\tilde{o}\\O\\o{\\OE}{\\ae}\\check{S}\\check{s}\\ss\\ddot{U}\\ddot{u}\\grave{U}\\grave{u}\\acute{U}\\acute{u}\\hat{U}\\hat{u}\\tilde{U}\\tilde{u}"; + const QString testTextUmla_math="\\ddot{A}q{\\ddot{u}}\\ddot{{}a}t{\\oe}r00, 123-45+6.0\\%\\S"; + ui->cmbTestset->addItem("text: fonts", "rm: \\textrm{"+testText+"}, sf: \\textsf{"+testText+"}, tt: \\texttt{"+testText+"}, cal: \\textcal{"+testText+"}, scr: \\textscr{"+testText+"}, bb: \\textbb{"+testText+"}, frak: \\textfrak{"+testText+"}, "); + ui->cmbTestset->addItem("text: umlaute", umla); + ui->cmbTestset->addItem("text: umlaute and fonts", "rm: \\textrm{"+testTextUmla+"}, sf: \\textsf{"+testTextUmla+"}, tt: \\texttt{"+testTextUmla+"}, cal: \\textcal{"+testTextUmla+"}, scr: \\textscr{"+testTextUmla+"}, bb: \\textbb{"+testTextUmla+"}, frak: \\textfrak{"+testTextUmla+"}, "); + ui->cmbTestset->addItem("math: fonts", "base: $"+testText+"$, rm: $\\mathrm{"+testText+"}$, sf: $\\mathsf{"+testText+"}$, tt: $\\mathtt{"+testText+"}$, cal: $\\mathcal{"+testText+"}$, scr: $\\mathscr{"+testText+"}$, bb: $\\mathbb{"+testText+"}$, frak: $\\mathfrak{"+testText+"}$, "); + ui->cmbTestset->addItem("math: umlaute", "$"+umla_math+"$"); + ui->cmbTestset->addItem("math: umlaute and \\text{...}", "\\${\\backslash}text{...}\\$: $\\text{"+umla+"}\\ \\ \\ \\$...\\$: "+umla+"$"); + ui->cmbTestset->addItem("math: umlaute and fonts", "base: $"+testTextUmla_math+"$, rm: $\\mathrm{"+testTextUmla_math+"}$, sf: $\\mathsf{"+testTextUmla_math+"}$, tt: $\\mathtt{"+testTextUmla_math+"}$, cal: $\\mathcal{"+testTextUmla_math+"}$, scr: $\\mathscr{"+testTextUmla_math+"}$, bb: $\\mathbb{"+testTextUmla_math+"}$, frak: $\\mathfrak{"+testTextUmla_math+"}$, "); ui->cmbTestset->addItem("math: simple relations", "$a{\\leq}b$, $a{\\geq}b$, $a{\\equiv}b$, $a=b$, $a{\\neq}b$, $ab$"); const auto wsExample=[](const QStringList& spaces, const QString before, const QString& after)->QString { QString s; @@ -57,7 +67,7 @@ TestForm::TestForm(QWidget *parent) : ui->cmbTestset->addItem("text 1", "text \\mathbf{bold}"); ui->cmbTestset->addItem("text 2", "text \\mathbf{bold}\\textcolor{red}{RED}"); const auto mathDecoExample=[](const QString& deco)->QString { return "\\"+deco+"{x}\\"+deco+"{i}\\"+deco+"{X}\\"+deco+"{\\psi}\\"+deco+"{abc}"; }; - ui->cmbTestset->addItem("decoration: math", "$"+mathDecoExample("vec")+" -- "+mathDecoExample("dot")+" -- "+mathDecoExample("ddot")+" -- "+mathDecoExample("ocirc")+" -- "+mathDecoExample("overline")+" -- "+mathDecoExample("underline")+" -- "+mathDecoExample("hat")+" -- "+mathDecoExample("widehat")+" -- "+mathDecoExample("check")+" -- "+mathDecoExample("widecheck")+" -- "+mathDecoExample("breve")+" -- "+mathDecoExample("tilde")+" -- "+mathDecoExample("widetilde")+" -- "+mathDecoExample("uul")+" -- "+mathDecoExample("ool")+" -- "+mathDecoExample("bar")+" -- "+mathDecoExample("arrow")+" -- "+mathDecoExample("cancel")+" -- "+mathDecoExample("bcancel")+" -- "+mathDecoExample("xcancel")+" -- "+mathDecoExample("sout")+"$"); + ui->cmbTestset->addItem("decoration: math", "$"+mathDecoExample("vec")+" -- "+mathDecoExample("grave")+" -- "+mathDecoExample("acute")+" -- "+mathDecoExample("dot")+" -- "+mathDecoExample("ddot")+" -- "+mathDecoExample("ocirc")+" -- "+mathDecoExample("overline")+" -- "+mathDecoExample("underline")+" -- "+mathDecoExample("hat")+" -- "+mathDecoExample("widehat")+" -- "+mathDecoExample("check")+" -- "+mathDecoExample("widecheck")+" -- "+mathDecoExample("breve")+" -- "+mathDecoExample("tilde")+" -- "+mathDecoExample("widetilde")+" -- "+mathDecoExample("uul")+" -- "+mathDecoExample("ool")+" -- "+mathDecoExample("bar")+" -- "+mathDecoExample("arrow")+" -- "+mathDecoExample("cancel")+" -- "+mathDecoExample("bcancel")+" -- "+mathDecoExample("xcancel")+" -- "+mathDecoExample("sout")+"$"); ui->cmbTestset->addItem("decoration: text", "Text \\ul{underlined Text Equator} -- \\ol{overlined Text Equator} -- \\sout{striked out Text Equator} -- \\cancel{canceled out Text Equator} -- \\bcancel{b-canceled out Text Equator} -- \\xcancel{x-canceled out Text Equator}"); ui->cmbTestset->addItem("mathtest", "This is normal text: $this is math:\\langle r^2(\\tau)\\rangle=\\left\\langle (\\vec{r}(t)-\\vec{r}(t+\\tau) )^2\\right\\rangle\\ \\ \\ g(\\tau)=\\frac{1}{N}\\cdot\\left(1+\\frac{2}{3}\\frac{\\langle r^2(\\tau)\\rangle}{w_{xy}^2}\\right)^{-1} \\lfloor\\rfloor\\lceil\\rceil\\langle\\rangle\\left\\{\\vec{a}\\left|\\|\\vec{a}\\|_2\\geq2\\right.\\right\\} \\vec{r}\\vec{R}\\frac{\\sqrt{\\sqrt{\\sqrt{\\sum_{i=0}^\\infty \\hat{i}^2}+y^\\alpha}+1}}{\\dot{v}\\equiv\\ddot{r}}\\argmin_{\\vec{k}}\\sum_{\\sqrt{i}=0}^{N}\\int_{x_0}^{x_1}\\left(\\left(\\left(x\\right)\\right)\\right)\\underbrace{\\left[\\left\\{\\frac{\\partial f}{\\partial x}\\right\\}\\cdot\\frac{1}{2}\\right]}{\\text{underbraced text \\hbar}}\\cdots\\frac{\\sqrt{\\sum_{i=0}^2 \\hat{i}^2}+y^\\alpha}{\\dot{v}\\equiv\\ddot{r}}, \\hat{t}\\hat{T} \\overbrace{\\left|\\sqrt{x\\cdot Y}\\right|}{\\propto\\bbN\\circ\\bbZ} \\left<\\arrow{x(\\tau)}\\cdot\\vec{R}(t+\\bar{\\tau})\\right> \\alpha\\beta\\gamma\\delta\\epsilon\\Gamma\\Delta\\Theta\\Omega \\left\\_\\left~\\cbrt{\\hbar\\omega}\\right~\\right\\_$"); ui->cmbTestset->addItem("math: upper/lower parantheses test:", "$\\text{bblabla} \\frac{1}{2}\\cdot\\left(\\frac{1}{\\mathrm{e}^x+\\mathrm{e}^{-x}}\\right)\\cdot\\left(\\frac{1}{\\frac{1+2}{5+x}}\\right)\\cdot\\left(\\frac{1}{\\exp\\left[-\\frac{y^2}{\\sqrt{x}}\\right]\\cdot\\exp\\left[-\\frac{1}{\\frac{1}{2}}\\right]}\\right) $"); diff --git a/lib/jkqtmathtext/jkqtmathtext.cpp b/lib/jkqtmathtext/jkqtmathtext.cpp index 7ac5d97ad6..e38c270c73 100644 --- a/lib/jkqtmathtext/jkqtmathtext.cpp +++ b/lib/jkqtmathtext/jkqtmathtext.cpp @@ -996,16 +996,288 @@ JKQTMathText::tokenType JKQTMathText::getToken() { static QSet TokenCharacters; static QSet mathEnvironmentSpecialChars, mathEnvironmentSpecialEndChars; static QSet SingleCharInstructions; + static QHash accentLetters; + static QSet accentLetters_LenBackslash; + static QSet accentLetters_LenCurly; if (TokenCharacters.size()==0) { mathEnvironmentSpecialChars<<'(' << '[' << '|' << ')' << ']' << '+' << '-' << '*' << '/' << '<' << '>' << '='; mathEnvironmentSpecialEndChars<<'(' << '&' << '[' << '|' << ')' << ']' << '\\' << '$' << '{' << '}' << '_' << '^' << '+' << '-' << '/' << '*' << '=' << '<' << '>'; TokenCharacters<<'_'<<'^'<<'\\'<<'$'<<'&'<<'}'<<'{'<<'['<<']'; SingleCharInstructions<<'|'<<';'<<':'<<'!'<<','<<'_'<<'\\'<<'$'<<'%'<<'&'<<'#'<<'}'<<'{'<<' '<<'['<<']'; + + auto fAddUml=[](const QString& cmd, const QChar& letter, const QChar& ch) { + QString i; + if (cmd.size()>0 && !letter.isNull()) { + i="\\"+cmd+letter; + accentLetters[i]=ch; accentLetters_LenBackslash.insert(i.size()); + i="{\\"+cmd+letter+"}"; + accentLetters[i]=ch; accentLetters_LenCurly.insert(i.size()); + i="\\"+cmd+"{"+letter+"}"; + accentLetters[i]=ch; accentLetters_LenBackslash.insert(i.size()); + } else if (cmd.size()>0 && letter.isNull()) { + i="\\"+cmd+" "; + accentLetters[i]=ch; accentLetters_LenBackslash.insert(i.size()); + i="\\"+cmd+"\t"; + accentLetters[i]=ch; accentLetters_LenBackslash.insert(i.size()); + i="\\"+cmd+"\n"; + accentLetters[i]=ch; accentLetters_LenBackslash.insert(i.size()); + i="\\"+cmd+"\\"; + accentLetters[i]=ch; accentLetters_LenBackslash.insert(i.size()); + i="{\\"+cmd+"}"; + accentLetters[i]=ch; accentLetters_LenCurly.insert(i.size()); + } + }; + // instructions like \"{a} + fAddUml("\"", 'A', QChar(0xC4)); + fAddUml("\"", 'E', QChar(0xCB)); + fAddUml("\"", 'I', QChar(0xCF)); + fAddUml("\"", 'O', QChar(0xD6)); + fAddUml("\"", 'U', QChar(0xDC)); + fAddUml("\"", 'Y', QChar(0x178)); + fAddUml("\"", 'a', QChar(0xE4)); + fAddUml("\"", 'e', QChar(0xEB)); + fAddUml("\"", 'i', QChar(0xEF)); + fAddUml("\"", 'o', QChar(0xF6)); + fAddUml("\"", 'u', QChar(0xFC)); + fAddUml("\"", 'y', QChar(0xFF)); + + fAddUml("'", 'A', QChar(0xC1)); + fAddUml("'", 'E', QChar(0xC9)); + fAddUml("'", 'I', QChar(0xCD)); + fAddUml("'", 'O', QChar(0xD3)); + fAddUml("'", 'U', QChar(0xDA)); + fAddUml("'", 'Y', QChar(0xDD)); + fAddUml("'", 'a', QChar(0xE1)); + fAddUml("'", 'e', QChar(0xE9)); + fAddUml("'", 'i', QChar(0xED)); + fAddUml("'", 'o', QChar(0xF3)); + fAddUml("'", 'u', QChar(0xFA)); + fAddUml("'", 'y', QChar(0xFD)); + fAddUml("'", 'C', QChar(0x106)); + fAddUml("'", 'c', QChar(0x107)); + fAddUml("'", 'L', QChar(0x139)); + fAddUml("'", 'l', QChar(0x13A)); + fAddUml("'", 'N', QChar(0x143)); + fAddUml("'", 'n', QChar(0x144)); + fAddUml("'", 'R', QChar(0x154)); + fAddUml("'", 'r', QChar(0x155)); + fAddUml("'", 'S', QChar(0x15A)); + fAddUml("'", 's', QChar(0x15B)); + fAddUml("'", 'Z', QChar(0x179)); + fAddUml("'", 'z', QChar(0x17A)); + fAddUml("'", 'G', QChar(0x1F4)); + fAddUml("'", 'g', QChar(0x1F5)); + + fAddUml("`", 'A', QChar(0xC0)); + fAddUml("`", 'E', QChar(0xC8)); + fAddUml("`", 'I', QChar(0xCC)); + fAddUml("`", 'O', QChar(0xD2)); + fAddUml("`", 'U', QChar(0xD9)); + fAddUml("`", 'a', QChar(0xE0)); + fAddUml("`", 'e', QChar(0xE8)); + fAddUml("`", 'i', QChar(0xEC)); + fAddUml("`", 'o', QChar(0xF2)); + fAddUml("`", 'u', QChar(0xF9)); + fAddUml("`", 'N', QChar(0x1F8)); + fAddUml("`", 'n', QChar(0x1F9)); + + fAddUml("^", 'A', QChar(0xC2)); + fAddUml("^", 'E', QChar(0xCA)); + fAddUml("^", 'I', QChar(0xCE)); + fAddUml("^", 'O', QChar(0xD4)); + fAddUml("^", 'U', QChar(0xDB)); + fAddUml("^", 'a', QChar(0xE2)); + fAddUml("^", 'e', QChar(0xEA)); + fAddUml("^", 'i', QChar(0xEE)); + fAddUml("^", 'o', QChar(0xF4)); + fAddUml("^", 'u', QChar(0xFB)); + fAddUml("^", 'C', QChar(0x108)); + fAddUml("^", 'c', QChar(0x109)); + fAddUml("^", 'G', QChar(0x11C)); + fAddUml("^", 'g', QChar(0x11D)); + fAddUml("^", 'H', QChar(0x124)); + fAddUml("^", 'h', QChar(0x125)); + fAddUml("^", 'J', QChar(0x134)); + fAddUml("^", 'j', QChar(0x135)); + fAddUml("^", 'S', QChar(0x15C)); + fAddUml("^", 's', QChar(0x15D)); + fAddUml("^", 'W', QChar(0x174)); + fAddUml("^", 'w', QChar(0x175)); + fAddUml("^", 'Y', QChar(0x176)); + fAddUml("^", 'y', QChar(0x177)); + + fAddUml("v", 'C', QChar(0x10C)); + fAddUml("v", 'c', QChar(0x10D)); + fAddUml("v", 'D', QChar(0x10E)); + fAddUml("v", 'd', QChar(0x10F)); + fAddUml("v", 'E', QChar(0x11A)); + fAddUml("v", 'e', QChar(0x11B)); + fAddUml("v", 'L', QChar(0x13D)); + fAddUml("v", 'l', QChar(0x13E)); + fAddUml("v", 'N', QChar(0x147)); + fAddUml("v", 'n', QChar(0x148)); + fAddUml("v", 'R', QChar(0x158)); + fAddUml("v", 'r', QChar(0x159)); + fAddUml("v", 'S', QChar(0x160)); + fAddUml("v", 's', QChar(0x161)); + fAddUml("v", 'T', QChar(0x164)); + fAddUml("v", 't', QChar(0x165)); + fAddUml("v", 'Z', QChar(0x17D)); + fAddUml("v", 'z', QChar(0x17E)); + fAddUml("v", 'A', QChar(0x1CD)); + fAddUml("v", 'a', QChar(0x1CE)); + fAddUml("v", 'I', QChar(0x1CF)); + fAddUml("v", 'i', QChar(0x1D0)); + fAddUml("v", 'O', QChar(0x1D1)); + fAddUml("v", 'o', QChar(0x1D2)); + fAddUml("v", 'U', QChar(0x1D3)); + fAddUml("v", 'u', QChar(0x1D4)); + fAddUml("v", 'G', QChar(0x1E6)); + fAddUml("v", 'g', QChar(0x1E7)); + fAddUml("v", 'K', QChar(0x1E8)); + fAddUml("v", 'k', QChar(0x1E9)); + fAddUml("v", 'j', QChar(0x1F0)); + fAddUml("v", 'H', QChar(0x21E)); + fAddUml("v", 'h', QChar(0x21F)); + + fAddUml("~", 'A', QChar(0xC3)); + fAddUml("~", 'N', QChar(0xD1)); + fAddUml("~", 'O', QChar(0xD5)); + fAddUml("~", 'a', QChar(0xE3)); + fAddUml("~", 'n', QChar(0xF1)); + fAddUml("~", 'o', QChar(0xF5)); + fAddUml("~", 'I', QChar(0x128)); + fAddUml("~", 'i', QChar(0x129)); + fAddUml("~", 'U', QChar(0x168)); + fAddUml("~", 'u', QChar(0x169)); + + fAddUml("r", 'A', QChar(0xC5)); + fAddUml("r", 'a', QChar(0xE5)); + fAddUml("r", 'U', QChar(0x16E)); + fAddUml("r", 'u', QChar(0x16F)); + + + fAddUml("=", 'A', QChar(0xC2)); + fAddUml("=", 'E', QChar(0xCA)); + fAddUml("=", 'I', QChar(0xCE)); + fAddUml("=", 'O', QChar(0xD4)); + fAddUml("=", 'U', QChar(0xDB)); + fAddUml("=", 'a', QChar(0xE2)); + fAddUml("=", 'e', QChar(0xEA)); + fAddUml("=", 'i', QChar(0xEE)); + fAddUml("=", 'o', QChar(0xF4)); + fAddUml("=", 'u', QChar(0xFB)); + fAddUml("=", 'Y', QChar(0x108)); + fAddUml("=", 'y', QChar(0x109)); + + fAddUml(".", 'C', QChar(0x10A)); + fAddUml(".", 'c', QChar(0x10B)); + fAddUml(".", 'E', QChar(0x116)); + fAddUml(".", 'e', QChar(0x117)); + fAddUml(".", 'G', QChar(0x120)); + fAddUml(".", 'g', QChar(0x121)); + fAddUml(".", 'I', QChar(0x130)); + fAddUml(".", 'Z', QChar(0x17B)); + fAddUml(".", 'z', QChar(0x17C)); + fAddUml(".", 'A', QChar(0x226)); + fAddUml(".", 'a', QChar(0x227)); + fAddUml(".", 'O', QChar(0x22E)); + fAddUml(".", 'o', QChar(0x22F)); + fAddUml(".", 'B', QChar(0x1E02)); + fAddUml(".", 'b', QChar(0x1E03)); + fAddUml(".", 'D', QChar(0x1E0A)); + fAddUml(".", 'd', QChar(0x1E0B)); + fAddUml(".", 'F', QChar(0x1E1E)); + fAddUml(".", 'f', QChar(0x1E1F)); + fAddUml(".", 'H', QChar(0x1E22)); + fAddUml(".", 'h', QChar(0x1E23)); + fAddUml(".", 'M', QChar(0x1E40)); + fAddUml(".", 'm', QChar(0x1E41)); + fAddUml(".", 'N', QChar(0x1E44)); + fAddUml(".", 'n', QChar(0x1E45)); + fAddUml(".", 'P', QChar(0x1E56)); + fAddUml(".", 'p', QChar(0x1E57)); + fAddUml(".", 'R', QChar(0x1E58)); + fAddUml(".", 'r', QChar(0x1E59)); + fAddUml(".", 'S', QChar(0x1E60)); + fAddUml(".", 's', QChar(0x1E61)); + fAddUml(".", 'T', QChar(0x1E6A)); + fAddUml(".", 't', QChar(0x1E6B)); + fAddUml(".", 'W', QChar(0x1E86)); + fAddUml(".", 'w', QChar(0x1E87)); + fAddUml(".", 'X', QChar(0x1E8A)); + fAddUml(".", 'x', QChar(0x1E8B)); + fAddUml(".", 'Y', QChar(0x1E8E)); + fAddUml(".", 'y', QChar(0x1E8F)); + + fAddUml("u", 'A', QChar(0x102)); + fAddUml("u", 'a', QChar(0x103)); + fAddUml("u", 'E', QChar(0x114)); + fAddUml("u", 'e', QChar(0x115)); + fAddUml("u", 'G', QChar(0x11E)); + fAddUml("u", 'g', QChar(0x11F)); + fAddUml("u", 'I', QChar(0x12C)); + fAddUml("u", 'i', QChar(0x12D)); + fAddUml("u", 'O', QChar(0x14E)); + fAddUml("u", 'o', QChar(0x14F)); + fAddUml("u", 'U', QChar(0x16C)); + fAddUml("u", 'u', QChar(0x16D)); + + + fAddUml("c", 'C', QChar(0xC7)); + fAddUml("c", 'c', QChar(0xE7)); + fAddUml("c", 'G', QChar(0x122)); + fAddUml("c", 'g', QChar(0x123)); + fAddUml("c", 'K', QChar(0x136)); + fAddUml("c", 'k', QChar(0x137)); + fAddUml("c", 'L', QChar(0x13B)); + fAddUml("c", 'l', QChar(0x13C)); + fAddUml("c", 'N', QChar(0x145)); + fAddUml("c", 'n', QChar(0x146)); + fAddUml("c", 'R', QChar(0x156)); + fAddUml("c", 'r', QChar(0x157)); + fAddUml("c", 'S', QChar(0x15E)); + fAddUml("c", 's', QChar(0x15F)); + fAddUml("c", 'T', QChar(0x162)); + fAddUml("c", 't', QChar(0x163)); + fAddUml("c", 'E', QChar(0x228)); + fAddUml("c", 'e', QChar(0x229)); + fAddUml("c", 'D', QChar(0x1E10)); + fAddUml("c", 'd', QChar(0x1E11)); + fAddUml("c", 'H', QChar(0x1E28)); + fAddUml("c", 'h', QChar(0x1E29)); + + // ligatures, instructions without {letter} + fAddUml("ss", QChar(), QChar(0xDF)); + fAddUml("ae", QChar(), QChar(0xE6)); + fAddUml("AE", QChar(), QChar(0xC6)); + fAddUml("oe", QChar(), QChar(0x153)); + fAddUml("OE", QChar(), QChar(0x152)); + fAddUml("o", QChar(), QChar(0xF8)); + fAddUml("O", QChar(), QChar(0xD8)); + fAddUml("S", QChar(), QChar(0xA7)); + fAddUml("l", QChar(), QChar(0x142)); + fAddUml("L", QChar(), QChar(0x141)); + fAddUml("aa", QChar(), QChar(0xE5)); + fAddUml("AA", QChar(), QChar(0xC5)); } //---------------------------------------------------------- // read an instruction name if (c=='\\') { + //---------------------------------------------------------- + // parsing accent instructions like \ss \"{a} ... + if (!parsingMathEnvironment){ + for (int len: accentLetters_LenBackslash) { + const QString acc=parseString.mid(currentTokenID, len); + if (acc.size()==len && accentLetters.contains(acc)) { + currentTokenName=accentLetters[acc]; + currentTokenID+=acc.trimmed().size()-1; // forward the instruction, omit trailing whitespace in instruction + if (acc.endsWith('\\')) currentTokenID--; + return currentToken=MTTtext; + } + } + } currentTokenID++; if (currentTokenID>=parseString.size()-1) return currentToken=MTTnone; c=parseString[currentTokenID]; @@ -1042,32 +1314,39 @@ JKQTMathText::tokenType JKQTMathText::getToken() { //---------------------------------------------------------- // check for { character } else if (c=='{') { - //std::cout<<"found openbrace\n"; + //---------------------------------------------------------- + // parsing accent instructions like {\ss} + if (!parsingMathEnvironment){ + for (int len: accentLetters_LenCurly) { + const QString acc=parseString.mid(currentTokenID, len); + if (acc.size()==len && accentLetters.contains(acc)) { + currentTokenName=accentLetters[acc]; + currentTokenID+=acc.trimmed().size()-1; // forward the instruction, omit trailing whitespace in instruction + if (acc.endsWith('\\')) currentTokenID--; + return currentToken=MTTtext; + } + } + } return currentToken=MTTopenbrace; //---------------------------------------------------------- // check for } character } else if (c=='}') { - //std::cout<<"found closebrace\n"; return currentToken=MTTclosebrace; //---------------------------------------------------------- // check for [ character } else if (c=='[') { - //std::cout<<"found openbracket\n"; return currentToken=MTTopenbracket; //---------------------------------------------------------- // check for ] character } else if (c==']') { - //std::cout<<"found closebracket\n"; return currentToken=MTTclosebracket; //---------------------------------------------------------- // check for _ character } else if (c=='_') { - //std::cout<<"found underscore\n"; return currentToken=MTTunderscore; //---------------------------------------------------------- // check for ^ character } else if (c=='^') { - //std::cout<<"found hat\n"; return currentToken=MTThat; //---------------------------------------------------------- // check for whitespace character @@ -1142,9 +1421,27 @@ JKQTMathTextNode* JKQTMathText::parseLatexString(bool get, JKQTMathTextBraceType while (currentToken!=MTTnone) { getNew=true; if (currentToken==MTTtext) { - const QString text=currentTokenName; - const bool addWhite=(getToken()==MTTwhitespace) && (!parsingMathEnvironment); - getNew=addWhite; + QString text=currentTokenName; + bool addWhite=false; + if (!parsingMathEnvironment) { + getToken(); + getNew=false; + while (currentToken==MTTtext || currentToken==MTTwhitespace) { + if (currentToken==MTTtext) { + text+=currentTokenName; + getNew=true; + } else if (currentToken==MTTwhitespace) { + text+=" "; + getNew=true; + } + getToken(); + getNew=false; + } + if (text.size()>0 && text[text.size()-1].isSpace()) { + addWhite=true; + text=text.left(text.size()-1); + } + } if (parsingMathEnvironment) { if (mathEnvironmentSpecialText.contains(text.trimmed()) && JKQTMathTextSymbolNode::hasSymbol(text.trimmed())) { nl->addChild(new JKQTMathTextSymbolNode(this, text.trimmed())); diff --git a/lib/jkqtmathtext/jkqtmathtext.h b/lib/jkqtmathtext/jkqtmathtext.h index 630584b2e7..849136d0a0 100644 --- a/lib/jkqtmathtext/jkqtmathtext.h +++ b/lib/jkqtmathtext/jkqtmathtext.h @@ -140,7 +140,7 @@ class JKQTMathTextNode; // forward symbols may differ (there are not all symbols defined in the MS Windows Symbol font!). Best coverage should be given by Unicode font encoding with a good unicode font installed!
    \image html jkqtmathtext/jkqtmathtext_symbols.png - - \\vec{x} \\dot{x} \\ddot{x} \\overline{x} \\underline{x} \\hat{x} \\tilde{x} \\uul{x} \\ool{x} \\bar{x} \\arrow{x} : Decorations over/under symbols \image html jkqtmathtext/jkqtmathtext_mathdeco.png + - \\vec{x} \\dot{x} \\ddot{x} \\overline{x} \\underline{x} \\hat{x} \\tilde{x} \\uul{x} \\ool{x} \\bar{x} \\arrow{x} \\widehat{x} \\widetilde{x} ...: Decorations over/under symbols \image html jkqtmathtext/jkqtmathtext_mathdeco.png - \\verb{don't parse this _aaa\\LaTeX} : interpret enclosed text as verbose \image html jkqtmathtext/jkqtmathtext_verb.png . diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp index 7cc86ddf21..7cbe7eb6a2 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.cpp @@ -42,6 +42,10 @@ QString JKQTMathTextDecoratedNode::DecorationType2String(JKQTMathTextDecoratedNo switch(mode) { case MTDvec: return "vec"; + case MTDgrave: + return "grave"; + case MTDacute: + return "acute"; case MTDtilde: return "tilde"; case MTDbreve: @@ -171,11 +175,16 @@ void JKQTMathTextDecoratedNode::fillInstructions() instructions["v"]=MTDcheck; instructions["widecheck"]=MTDwidecheck; instructions["bar"]=MTDbar; + instructions["="]=MTDbar; instructions["dot"]=MTDdot; instructions["."]=MTDdot; instructions["ocirc"]=MTDocirc; instructions["tilde"]=MTDtilde; instructions["~"]=MTDtilde; + instructions["acute"]=MTDacute; + instructions["'"]=MTDacute; + instructions["grave"]=MTDgrave; + instructions["`"]=MTDgrave; instructions["breve"]=MTDbreve; instructions["u"]=MTDbreve; instructions["widetilde"]=MTDwidetilde; @@ -210,6 +219,7 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK const double deco_width=std::max(width_x*0.5,cwidth-2.0*deco_xoffset-italic_xcorrection); const double deco_vecwidth=width_x*0.33; const double deco_vecheight=deco_height*0.33; + const double deco_accentwidth=deco_height/4.0; const double deco_miniwidth=((decoration==MTDtilde||decoration==MTDbreve)?fm.boundingRect("j").width():fm.boundingRect("^").width())-italic_xcorrection; const double decotop_xcenter=x+italic_xcorrection+(cwidth-italic_xcorrection)/2.0; const double decotop_xstart=decotop_xcenter-deco_width/2.0+linewidth/2.0; @@ -217,9 +227,9 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK const double decobot_xstart=x+linewidth/2.0; const double decobot_xend=x+cwidth-italic_xcorrection-linewidth/2.0; const double decobot_xcenter=(decobot_xstart+decobot_xend)/2.0; - const double deco_ypos=y-cbaselineHeight-decoSeparation-linewidth/2.0; - const double deco_ytop=y-cbaselineHeight-decoSeparation-deco_height+linewidth/2.0; - const double deco_ycenter=y-cbaselineHeight-decoSeparation-deco_height/2.0; + const double deco_ytopbot=y-cbaselineHeight-decoSeparation-linewidth/2.0; + const double deco_ytoptop=y-cbaselineHeight-decoSeparation-deco_height+linewidth/2.0; + const double deco_ytopcenter=y-cbaselineHeight-decoSeparation-deco_height/2.0; @@ -232,15 +242,55 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK double xnew=getChild()->draw(painter, x, y, ev); + auto fDrawFontAccent=[&](QChar aDirect=QChar(), QChar aFallback=QChar()) -> bool { + if (!aDirect.isNull() && fm.inFont(aDirect)) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + const QRectF tbra=fm.tightBoundingRect(aDirect); + painter.translate(decotop_xcenter-tbra.width()/2.0, (deco_ytopcenter+deco_ytopbot)/2.0); + //painter.setPen("red"); + //painter.drawEllipse(0-2,0-2,4,4); + painter.translate(-tbra.x(), -tbra.y()); + //painter.setPen("magenta"); + //painter.drawEllipse(0-2,0-2,4,4); + if (tbra.width()>0 && tbra.height()>0) { + painter.setFont(font); + painter.drawText(0,0,aDirect); + //painter.setPen("blue"); + //painter.drawRect(tbra); + //painter.drawEllipse(0-2,0-2,4,4); + return true; + } + } + if (!aFallback.isNull() && fm.inFont(aFallback)) { + painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); + const QRectF tbra=fm.tightBoundingRect(aFallback); + painter.translate(decotop_xcenter-tbra.width()/2.0, deco_ytopcenter); + //painter.setPen("yellow"); + //painter.drawEllipse(0-2,0-2,4,4); + painter.translate(-tbra.x(), -tbra.y()); + //painter.setPen("cyan"); + //painter.drawEllipse(0-2,0-2,4,4); + if (tbra.width()>0 && tbra.height()>0) { + painter.setFont(font); + painter.drawText(0,0,aFallback); + //painter.setPen("green"); + //painter.drawRect(tbra); + //painter.drawEllipse(0-2,0-2,4,4); + return true; + } + } + return false; + }; + if (decoration==MTDvec) { painter.setPen(p); QPolygonF poly; - poly<0) painter.drawLine(l); painter.setPen(pold); } else if (decoration==MTDbar) { @@ -250,9 +300,9 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK painter.setPen(pold); } else if (decoration==MTDdoubleoverline) { painter.setPen(p); - const QLineF l(decotop_xstart, deco_ypos, decotop_xend, deco_ypos); + const QLineF l(decotop_xstart, deco_ytopbot, decotop_xend, deco_ytopbot); if (l.length()>0) painter.drawLine(l); - const QLineF l2(decotop_xstart, deco_ypos-2.0*p.widthF(), decotop_xend, deco_ypos-2.0*p.widthF()); + const QLineF l2(decotop_xstart, deco_ytopbot-2.0*p.widthF(), decotop_xend, deco_ytopbot-2.0*p.widthF()); if (l2.length()>0) painter.drawLine(l2); painter.setPen(pold); } else if (decoration==MTDunderline) { @@ -269,100 +319,124 @@ double JKQTMathTextDecoratedNode::draw(QPainter& painter, double x, double y, JK painter.setPen(pold); } else if (decoration==MTDarrow) { painter.setPen(p); - const QLineF l(decotop_xstart, deco_ycenter, decotop_xend, deco_ycenter); + const QLineF l(decotop_xstart, deco_ytopcenter, decotop_xend, deco_ytopcenter); if (l.length()>0) painter.drawLine(l); QPolygonF poly; - poly<0) painter.drawLine(l); painter.setPen(pold); } else if (decoration==MTDbcancel) { painter.setPen(p); - const QLineF l(decobot_xstart, deco_ypos, decotop_xend, decobelow_ypos); + const QLineF l(decobot_xstart, deco_ytopbot, decotop_xend, decobelow_ypos); if (l.length()>0) painter.drawLine(l); painter.setPen(pold); } else if (decoration==MTDxcancel) { painter.setPen(p); - const QLineF l(decobot_xstart, deco_ypos, decotop_xend, decobelow_ypos); + const QLineF l(decobot_xstart, deco_ytopbot, decotop_xend, decobelow_ypos); if (l.length()>0) painter.drawLine(l); - const QLineF l1(decobot_xstart, decobelow_ypos, decotop_xend, deco_ypos); + const QLineF l1(decobot_xstart, decobelow_ypos, decotop_xend, deco_ytopbot); if (l1.length()>0) painter.drawLine(l1); painter.setPen(pold); } diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h index b14f8d5406..b96a317a0f 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextdecoratednode.h @@ -48,7 +48,7 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing MTDwidehat, /*!< \brief full-width hat over block \image html jkqtmathtext/MTDwidehat.png */ MTDcheck, /*!< \brief small v over block \image html jkqtmathtext/MTDcheck.png */ MTDwidecheck, /*!< \brief full-width v over block \image html jkqtmathtext/MTDwidecheck.png */ - MTDbreve, /*!< \brief small tilde over block \image html jkqtmathtext/MTDbreve.png */ + MTDbreve, /*!< \brief small cup (breve) over block \image html jkqtmathtext/MTDbreve.png */ MTDocirc, /*!< \brief single circle over block \image html jkqtmathtext/MTDocirc.png */ MTDdot, /*!< \brief single dot over block \image html jkqtmathtext/MTDvec.png */ MTDddot, /*!< \brief double dot over block \image html jkqtmathtext/MTDddot.png */ @@ -60,6 +60,8 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextDecoratedNode: public JKQTMathTextSing MTDdoubleunderline, /*!< \brief double underline under block \image html jkqtmathtext/MTDdoubleunderline.png */ MTDtilde, /*!< \brief small tilde over block \image html jkqtmathtext/MTDtilde.png */ MTDwidetilde, /*!< \brief full width tilde over block \image html jkqtmathtext/MTDwidetilde.png */ + MTDacute, /*!< \brief small acute accent over block \image html jkqtmathtext/MTDacute.png */ + MTDgrave, /*!< \brief small grave accent over block \image html jkqtmathtext/MTDgrave.png */ MTDcancel, /*!< \brief cancel text with sloped line \image html jkqtmathtext/MTDcancel.png */ MTDbcancel, /*!< \brief cancel text with backward sloped line \image html jkqtmathtext/MTDbcancel.png */ MTDxcancel, /*!< \brief cancel text with X \image html jkqtmathtext/MTDxcancel.png */ diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp b/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp index 6822470630..e03ee8c7a2 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp +++ b/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.cpp @@ -378,22 +378,22 @@ void JKQTMathTextSymbolNode::addGreekLetterVariants_WinSymbol_Unicode_Html(const symbols["up"+baseInstructionName]=UprightGreekLetter_WinSymbol_Unicode_Html(letterWinSymbol, letterUnicode, html); } -JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolStd(const QString &symbol, const QString &html) +JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::StdSymbol(const QString &symbol, const QString &html) { return SymbolFullProps(MTFEStandard, SymbolProps(symbol), html); } -JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolUnicode(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor) +JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::UnicodeSymbol(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor) { return SymbolFullProps(MTFEUnicode, SymbolProps(symbol, _flags, _fontScalingFactor, _yShiftFactor)); } -JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolUnicode(const QString &symbol, const QString &html) +JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::UnicodeSymbol(const QString &symbol, const QString &html) { return SymbolFullProps(MTFEUnicode, SymbolProps(symbol), html); } -JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::SymbolStd(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor) +JKQTMathTextSymbolNode::SymbolFullProps JKQTMathTextSymbolNode::StdSymbol(const QString &symbol, SymbolFlags _flags, double _fontScalingFactor, double _yShiftFactor) { return SymbolFullProps(MTFEStandard, SymbolProps(symbol, _flags, _fontScalingFactor, _yShiftFactor), symbol); } @@ -455,26 +455,30 @@ void JKQTMathTextSymbolNode::fillSymbolTables() symbols["ae"]=SimpleTextSymbol(QChar(0xE6)); symbols["AE"]=SimpleTextSymbol(QChar(0xC6)); symbols["AA"]=SimpleTextSymbol(QChar(0xC5)); - symbols["oe"]=SymbolUnicode(QChar(0x153)).addStd("oe").addHtml("œ"); - symbols["OE"]=SymbolUnicode(QChar(0x152)).addStd("OE").addHtml("Œ"); + symbols["oe"]=UnicodeSymbol(QChar(0x153)).addStd("oe").addHtml("œ"); + symbols["OE"]=UnicodeSymbol(QChar(0x152)).addStd("OE").addHtml("Œ"); symbols["ss"]=SimpleTextSymbol(QChar(0xDF)).addHtml("ß"); + symbols["l"]=UnicodeSymbol(QChar(0x141)).addHtml("ł"); + symbols["L"]=UnicodeSymbol(QChar(0x142)).addHtml("Ł"); + symbols["o"]=SimpleTextSymbol(QChar(0xF8)).addHtml("ø"); + symbols["O"]=SimpleTextSymbol(QChar(0xD8)).addHtml("Ø"); { auto s=UprightSymbolUnicode(QChar(0x212B)).addUprightStd(QChar(0xC5)); symbols["Angstrom"]=s; symbols["Angstroem"]=s; } - { auto s=SymbolUnicode(QChar(0x2136)).addHtml("ℶ"); + { auto s=UnicodeSymbol(QChar(0x2136)).addHtml("ℶ"); symbols["Beth"]=s; symbols["Bet"]=s; symbols["beth"]=s; symbols["bet"]=s; } symbols["Box"]=UprightSymbolUnicode(QChar(0x25A1)); - symbols["DC"]=SymbolUnicode(QChar(0x2393)).addWinSymbol(QChar(0xBB)).addStd("="); - symbols["EUR"]=SymbolUnicode(QChar(0x20AC)); + symbols["DC"]=UnicodeSymbol(QChar(0x2393)).addWinSymbol(QChar(0xBB)).addStd("="); + symbols["EUR"]=UnicodeSymbol(QChar(0x20AC)); symbols["Im"]=UprightSymbolUnicode(QChar(0x2111)).addHtml("ℑ").addWinSymbol(QChar(0xC1)); - symbols["No"]=SymbolUnicode(QChar(0x2116)); + symbols["No"]=UnicodeSymbol(QChar(0x2116)); { auto s=UprightSymbolUnicode(QChar(0x2126)).addUprightWinSymbol("W").addUprightHtml("Ω"); symbols["Ohm"]=s; symbols["ohm"]=s; } symbols["P"]=SimpleTextSymbol(QChar(0xB6)).addHtml("¶"); - symbols["Re"]=SymbolUnicode(QChar(0x211C)).addHtml("ℜ").addWinSymbol(QChar(0xC2)); + symbols["Re"]=UnicodeSymbol(QChar(0x211C)).addHtml("ℜ").addWinSymbol(QChar(0xC2)); { auto s=SimpleTextSymbol(QChar(0xA7)).addHtml("§"); symbols["S"]=s; symbols["§"]=s;} - symbols["accurrent"]=SymbolUnicode(QChar(0x23E6)); - { auto s=SymbolUnicode(QChar(0x2135)).addHtml("ℵ").addWinSymbol(QChar(0xC0)); + symbols["accurrent"]=UnicodeSymbol(QChar(0x23E6)); + { auto s=UnicodeSymbol(QChar(0x2135)).addHtml("ℵ").addWinSymbol(QChar(0xC0)); symbols["alef"]=s; symbols["aleph"]=s; symbols["Aleph"]=s; symbols["Alef"]=s; } symbols["angle"]=UprightSymbolUnicode(QChar(0x2220)).addHtml("∠").addWinSymbol(QChar(0xD0)); symbols["backslash"]=SimpleTextSymbol("\\"); @@ -486,8 +490,8 @@ void JKQTMathTextSymbolNode::fillSymbolTables() { auto s=UprightSymbolUnicode(QChar(0x231F)); symbols["brcorner"]=s; symbols["lrcorner"]=s; } symbols["bullet"]=UprightSymbolUnicode(QChar(0x2022)).addUprightHtml("•").addUprightWinSymbol(QChar(0xB7)); - symbols["cdots"]=SymbolUnicode(QChar(0x22EF)).addHtml("···").addStd(QString(3, QChar(0xB7))); - { auto s=SymbolUnicode(QChar(0x2103)).addUprightStd("°C").addUprightHtml("°C"); + symbols["cdots"]=UnicodeSymbol(QChar(0x22EF)).addHtml("···").addStd(QString(3, QChar(0xB7))); + { auto s=UnicodeSymbol(QChar(0x2103)).addUprightStd("°C").addUprightHtml("°C"); symbols["celsius"]=s; symbols["degC"]=s; } symbols["cent"]=SimpleTextSymbol(QChar(0xA2), "¢"); symbols["checkmark"]=UprightSymbolStd(QChar(0x2713)).addUprightHtml("✓"); @@ -499,53 +503,53 @@ void JKQTMathTextSymbolNode::fillSymbolTables() symbols["dagger"]=s; symbols["dag"]=s; symbols["textdagger"]=s; } { auto s=UprightSymbolUnicode(QChar(0x2021)).addUprightHtml("‡"); symbols["ddagger"]=s; symbols["ddag"]=s; symbols["textdaggerdbl"]=s; } - { auto s=SymbolUnicode(QChar(0x2138)).addHtml("ℸ"); + { auto s=UnicodeSymbol(QChar(0x2138)).addHtml("ℸ"); symbols["dalet"]=s; symbols["Dalet"]=s; symbols["daleth"]=s; symbols["Daleth"]=s; } symbols["dd"] = SymbolFullProps(SymbolProps("d", Upright|BoldOff), "d", Upright|BoldOff); symbols["diamond"]=UprightSymbolUnicode(QChar(0x22C4)).addHtml("⋄").addWinSymbol(QChar(0xE0)); - symbols["dollar"]=SymbolUnicode(QChar(0x0024)); + symbols["dollar"]=UnicodeSymbol(QChar(0x0024)); { auto s=SimpleTextSymbol(QChar(0x24), "$"); symbols["dollar"]=s; symbols["$"]=s; } - symbols["dprime"]=SymbolUnicode(QChar(0x2033)).addHtml("″").addStd("''"); + symbols["dprime"]=UnicodeSymbol(QChar(0x2033)).addHtml("″").addStd("''"); symbols["ee"] = SymbolFullProps(SymbolProps("e", Upright|BoldOff), "e", Upright|BoldOff); - { auto s=SymbolUnicode(QChar(0x2026)).addHtml("…").addWinSymbol(QChar(0xBC)).addStd("..."); + { auto s=UnicodeSymbol(QChar(0x2026)).addHtml("…").addWinSymbol(QChar(0xBC)).addStd("..."); symbols["ellipsis"]=s; symbols["dots"]=s; symbols["ldots"]=s; } { auto s=SimpleTextSymbol(QChar(0x20AC), "€"); symbols["euro"]=s; symbols["EUR"]=s; } - { auto s=SymbolUnicode(QChar(0x2109)); + { auto s=UnicodeSymbol(QChar(0x2109)); symbols["fahrenheit"]=s; symbols["degF"]=s; } - symbols["female"]=SymbolUnicode(QChar(0x2640)).addHtml("♀"); - symbols["flq"]=SymbolUnicode(QChar(0x2039)).addHtml("‹").addStd("<"); - symbols["flqq"]=SymbolUnicode(QChar(0x00AB)).addHtml("«").addStd(QChar(0xAB)); - symbols["frown"]=SymbolUnicode(QChar(0x2322)).addHtml("⌢"); - symbols["frq"]=SymbolUnicode(QChar(0x203A)).addHtml("›").addStd(">"); - symbols["frqq"]=SymbolUnicode(QChar(0x00BB)).addHtml("»").addStd(QChar(0xBB)); - { auto s=SymbolUnicode(QChar(0x2137)).addHtml("ℷ"); + symbols["female"]=UnicodeSymbol(QChar(0x2640)).addHtml("♀"); + symbols["flq"]=UnicodeSymbol(QChar(0x2039)).addHtml("‹").addStd("<"); + symbols["flqq"]=UnicodeSymbol(QChar(0x00AB)).addHtml("«").addStd(QChar(0xAB)); + symbols["frown"]=UnicodeSymbol(QChar(0x2322)).addHtml("⌢"); + symbols["frq"]=UnicodeSymbol(QChar(0x203A)).addHtml("›").addStd(">"); + symbols["frqq"]=UnicodeSymbol(QChar(0x00BB)).addHtml("»").addStd(QChar(0xBB)); + { auto s=UnicodeSymbol(QChar(0x2137)).addHtml("ℷ"); symbols["gimel"]=s; symbols["Gimel"]=s; } - symbols["glq"]=SymbolUnicode(QChar(0x2018)).addHtml("‘").addStd("'"); - symbols["glqq"]=SymbolUnicode(QChar(0x201C)).addHtml("“").addStd("\""); - symbols["grq"]=SymbolUnicode(QChar(0x2019)).addHtml("’").addStd("'"); - symbols["grqq"]=SymbolUnicode(QChar(0x201D)).addHtml("”").addStd("\""); + symbols["glq"]=UnicodeSymbol(QChar(0x2018)).addHtml("‘").addStd("'"); + symbols["glqq"]=UnicodeSymbol(QChar(0x201C)).addHtml("“").addStd("\""); + symbols["grq"]=UnicodeSymbol(QChar(0x2019)).addHtml("’").addStd("'"); + symbols["grqq"]=UnicodeSymbol(QChar(0x201D)).addHtml("”").addStd("\""); symbols["hbar"]=UprightSymbolUnicode(QChar(0x210F)).addUprightHtml("ℏ").addStd("h", ItalicOn|DrawLeftHBar); symbols["hexagon"]=UprightSymbolUnicode(QChar(0x2394)); symbols["ii"] = SymbolFullProps(SymbolProps("i", Upright|BoldOff), "i", Upright|BoldOff); - symbols["infty"]=SymbolUnicode(QChar(0x221E)).addHtml("∞").addWinSymbol(QChar(0xA5)).addStd("8", RotateSymbol90); + symbols["infty"]=UnicodeSymbol(QChar(0x221E)).addHtml("∞").addWinSymbol(QChar(0xA5)).addStd("8", RotateSymbol90); symbols["langle"]=UprightSymbolUnicode(QChar(0x2329)).addWinSymbol(QChar(0xE1)); symbols["lceil"]=UprightSymbolUnicode(QChar(0x2308)).addHtml("⌈").addWinSymbol(QChar(0xE9)); { auto s=SimpleTextSymbol("...").addUnicode(QChar(0x2026)).addWinSymbol(QChar(0xB6)); symbols["ldots"]=s; symbols["dots"]=s; } symbols["lfloor"]=UprightSymbolUnicode(QChar(0x230A)).addHtml("⌊").addWinSymbol(QChar(0xEB)); - symbols["lightning"]=SymbolUnicode(QChar(0x21AF)); - symbols["male"]=SymbolUnicode(QChar(0x2642)).addHtml("♂"); + symbols["lightning"]=UnicodeSymbol(QChar(0x21AF)); + symbols["male"]=UnicodeSymbol(QChar(0x2642)).addHtml("♂"); symbols["measuredangle"]=UprightSymbolUnicode(QChar(0x2221)).addHtml("∡"); symbols["micro"] = SimpleTextSymbol(QChar(0xB5), "µ"); symbols["ohm"]=UprightSymbolUnicode(QChar(0x2126)).addUprightHtml("Ω").addUprightWinSymbol(QChar(0x57)); symbols["partial"]=UprightSymbolUnicode(QChar(0x2202)).addUprightHtml("∂").addUprightWinSymbol(QChar(0xB6)); - { auto s=SymbolUnicode(QChar(0x2030)).addHtml("‰"); + { auto s=UnicodeSymbol(QChar(0x2030)).addHtml("‰"); symbols["perthousand"]=s; symbols["permil"]=s; } symbols["pound"]=SimpleTextSymbol(QChar(0xA3), "£"); - symbols["pound"]=SymbolUnicode(QChar(0x00A3)); - symbols["prime"]=SymbolUnicode(QChar(0x2032)).addHtml("′").addStd("'"); + symbols["pound"]=UnicodeSymbol(QChar(0x00A3)); + symbols["prime"]=UnicodeSymbol(QChar(0x2032)).addHtml("′").addStd("'"); symbols["rangle"]=UprightSymbolUnicode(QChar(0x232A)).addWinSymbol(QChar(0xF1)); symbols["rceil"]=UprightSymbolUnicode(QChar(0x2309)).addHtml("⌉").addWinSymbol(QChar(0xF9)); { auto s=SimpleTextSymbol(QChar(0xAA), "®"); @@ -555,21 +559,21 @@ void JKQTMathTextSymbolNode::fillSymbolTables() symbols["smile"]=UprightSymbolUnicode(QChar(0x2323)).addHtml("⌣"); symbols["sphericalangle"]=UprightSymbolUnicode(QChar(0x2222)).addHtml("∢"); symbols["star"]=UprightSymbolUnicode(QChar(0x22C6)); - symbols["tcohm"]=SymbolUnicode(QChar(0x2126)); + symbols["tcohm"]=UnicodeSymbol(QChar(0x2126)); symbols["textbar"]=SimpleTextSymbol("|", "|"); { auto s=SimpleTextSymbol(QChar(0xB0), "°"); symbols["textdegree"]=s; symbols["degree"] = s; } symbols["textgreater"]=SimpleTextSymbol(">", ">"); symbols["textless"]=SimpleTextSymbol("<", "<"); - { auto s=SymbolUnicode(QChar(0x231C)); + { auto s=UnicodeSymbol(QChar(0x231C)); symbols["tlcorner"]=s; symbols["ulcorner"]=s; } - symbols["trademark"]=SymbolUnicode(QChar(0x2122)).addHtml("™").addWinSymbol(QChar(0xD4)).addStd("(TM)"); - symbols["trapezium"]=SymbolUnicode(QChar(0x23E2)).addHtml("⏢"); + symbols["trademark"]=UnicodeSymbol(QChar(0x2122)).addHtml("™").addWinSymbol(QChar(0xD4)).addStd("(TM)"); + symbols["trapezium"]=UnicodeSymbol(QChar(0x23E2)).addHtml("⏢"); { auto s=UprightSymbolUnicode(QChar(0x231D)); symbols["trcorner"]=s; symbols["urcorner"]=s; } - symbols["trprime"]=SymbolUnicode(QChar(0x2034)).addHtml("‴").addStd("'''"); - symbols["varcarriagereturn"]=SymbolUnicode(QChar(0x23CE)).addWinSymbol(QChar(0xBF)); - symbols["varhexagonlrbonds"]=SymbolUnicode(QChar(0x232C)); + symbols["trprime"]=UnicodeSymbol(QChar(0x2034)).addHtml("‴").addStd("'''"); + symbols["varcarriagereturn"]=UnicodeSymbol(QChar(0x23CE)).addWinSymbol(QChar(0xBF)); + symbols["varhexagonlrbonds"]=UnicodeSymbol(QChar(0x232C)); symbols["yen"]=SimpleTextSymbol(QChar(0xA5), "¥"); @@ -636,7 +640,7 @@ void JKQTMathTextSymbolNode::fillSymbolTables() symbols["Uparrow"]=UprightSymbolUnicode(QChar(0x21D1)).addUprightHtml("⇑").addUprightWinSymbol(QChar(0xDD)); symbols["Updownarrow"]=UprightSymbolUnicode(QChar(0x21D5)).addUprightHtml("⇕"); symbols["approx"]=MathOperatorSymbolUnicode(QChar(0x2248)).addMathOperatorHtml("≈").addMathOperatorWinSymbol(QChar(0xBB)); - symbols["bbC"]=SymbolUnicode(QChar(0x2102)); + symbols["bbC"]=UnicodeSymbol(QChar(0x2102)); symbols["bbH"]=MathOperatorSymbolUnicode(QChar(0x210D)); symbols["bbN"]=MathOperatorSymbolUnicode(QChar(0x2115)); symbols["bbP"]=MathOperatorSymbolUnicode(QChar(0x2119)); diff --git a/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.h b/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.h index ed81273d5c..84187887e5 100644 --- a/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.h +++ b/lib/jkqtmathtext/nodes/jkqtmathtextsymbolnode.h @@ -262,13 +262,13 @@ class JKQTMATHTEXT_LIB_EXPORT JKQTMathTextSymbolNode: public JKQTMathTextNode { /** \brief insert GreekLetter_WinSymbol_Unicode_Html() as \a baseInstructionName and UprightGreekLetter_WinSymbol_Unicode_Html and "up"+\a letterWinSymbol into symbols */ static void addGreekLetterVariants_WinSymbol_Unicode_Html(const QString& baseInstructionName, const QString& letterWinSymbol, const QString& letterUnicode, const QString& html); /** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */ - static SymbolFullProps SymbolStd(const QString& symbol, const QString& html); + static SymbolFullProps StdSymbol(const QString& symbol, const QString& html); /** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */ - static SymbolFullProps SymbolUnicode(const QString& symbol, const QString& html); + static SymbolFullProps UnicodeSymbol(const QString& symbol, const QString& html); /** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */ - static SymbolFullProps SymbolStd(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0); + static SymbolFullProps StdSymbol(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0); /** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */ - static SymbolFullProps SymbolUnicode(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0); + static SymbolFullProps UnicodeSymbol(const QString& symbol, SymbolFlags _flags=AsOutside, double _fontScalingFactor=1.0, double _yShiftFactor=0.0); /** \brief constructs a SymbolProps for a symbol with encoding in Standard-fonts a */ static SymbolFullProps UprightSymbolStd(const QString& symbol, const QString& html=QString()); /** \brief constructs a SymbolProps for a symbol with encoding in UnicodeFull-fonts a */