cmd = "%s %s -dbg mathed -x lyx-quit" % (lyxexe, lyxfile)
proc = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
- regexp = re.compile(r'.*: read symbol \'(\S+)\s+inset:\s+(\S+)')
+ regexp = re.compile(r'.*: read symbol \'(\S+)\s+inset:\s+(\S+)\s+draw:\s+(\S*)\s+extra:\s+(\S+)')
# These insets are more complex than simply symbols, so the images need to
# be created manually
skipinsets = ['big', 'font', 'lyxblacktext', 'matrix', 'mbox', 'oldfont', \
'ref', 'split', 'space', 'style']
- symbols = []
+ mathsymbols = []
+ textsymbols = []
for line in stderr.split('\n'):
m = regexp.match(line)
if m:
inset = m.group(2)
if not inset in skipinsets:
- symbols.append(m.group(1))
- return symbols
+ if m.group(4) == 'textmode':
+ textsymbols.append(m.group(1))
+ else:
+ mathsymbols.append(m.group(1))
+ return (mathsymbols, textsymbols)
def getreplacements(filename):
return items
-def createimage(name, path, template, lyxexe, tempdir, replacements, toolbaritems, makefileentries):
+def createimage(name, path, template, lyxexe, tempdir, math, replacements, toolbaritems, makefileentries):
""" Create the image file for symbol name in path. """
if name in replacements.keys():
print 'Generating ' + name + suffix
lyxname = os.path.join(tempdir, filename)
lyxfile = open(lyxname + '.lyx', 'wt')
- lyxfile.write(template.replace('$a$', '$\\' + name + '$'))
+ if math:
+ lyxfile.write(template.replace('$a$', '$\\' + name + '$'))
+ else:
+ lyxfile.write(template.replace('$a$', '$\\text{\\' + name + '}$'))
lyxfile.close()
cmd = "%s %s.lyx -e dvi" % (lyxexe, lyxname)
proc = subprocess.Popen(cmd, shell=True)
if len(argv) == 3:
(base, ext) = os.path.splitext(argv[0])
- symbols = getlist(argv[1], base)
+ (mathsymbols, textsymbols) = getlist(argv[1], base)
cppfile = os.path.join(os.path.dirname(base), '../../src/frontends/qt4/GuiApplication.cpp')
replacements = getreplacements(cppfile)
uifile = os.path.join(os.path.dirname(base), '../../lib/ui/stdtoolbars.inc')
template = templatefile.read()
templatefile.close()
tempdir = tempfile.mkdtemp()
- for i in symbols:
- createimage(i, argv[2], template, argv[1], tempdir, replacements, toolbaritems, makefileentries)
+ for i in mathsymbols:
+ createimage(i, argv[2], template, argv[1], tempdir, True, replacements, toolbaritems, makefileentries)
+ for i in textsymbols:
+ createimage(i, argv[2], template, argv[1], tempdir, False, replacements, toolbaritems, makefileentries)
shutil.rmtree(tempdir)
else:
error(usage(argv[0]))
male wasy 26 0 x ♂
female wasy 25 0 x ♀
-currency wasy 27 0 x ¤
-phone wasy 7 0 x ☎
-recorder wasy 6 0 x ⌕
-clock wasy 28 0 x &clock;
+currency wasy 27 0 textmode ¤ wasysym # works in text mode only (produces \oe in math mode)
+phone wasy 7 0 textmode ☎ wasysym # works in text mode only (produces \Upsilon in math mode)
+recorder wasy 6 0 textmode ⌕ wasysym # works in text mode only (produces \Sigma in math mode)
+clock wasy 28 0 textmode &clock; wasysym # works in text mode only (produces \o in math mode)
lightning wasy 18 0 x ☇
-pointer wasy 9 0 x x
-RIGHTarrow wasy 17 0 x ▶
-LEFTarrow wasy 16 0 x ◀
-UParrow wasy 75 0 x ▲
-DOWNarrow wasy 76 0 x ▼
-#AC wasy n0.5pt\wasyfamily\char58\kern0.5pt}}
-#HF {\leavevmode
-# \lower0.9pt\hbox to 0pt{\kern0.5pt\wasyfamily\char58\hss}%
-# \raise0.9pt\hbox{\kern0.5pt\wasyfamily\char58\kern0.5pt}}
-#VHF wasy 64 0 x x
+# FIXME Display is wrong: qt does not display characters at the \t position (0x09)
+pointer wasy 9 0 textmode x wasysym # works in text mode only (produces \Psi in math mode)
+RIGHTarrow wasy 17 0 textmode ▶ wasysym # works in text mode only (produces \jmath in math mode)
+LEFTarrow wasy 16 0 textmode ◀ wasysym # works in text mode only (produces \imath in math mode)
+UParrow wasy 75 0 textmode ▲ wasysym # works in text mode only (produces K in math mode)
+DOWNarrow wasy 76 0 textmode ▼ wasysym # works in text mode only (produces L in math mode)
+AC wasy 58 0 textmode x wasysym # works in text mode only
+# \def\HF{\leavevmode \lower0.9pt\hbox to 0pt{\kern0.5pt\wasyfamily\char58\hss}\raise0.9pt\hbox{\kern0.5pt\wasyfamily\char58\kern0.5pt}} wasysym
+VHF wasy 64 0 x x
Square wasy 50 0 x □
#CheckedBox wasy 50\hss}\hbox{\wasyfamily\char8 0 x
XBox wasy 52 0 x ⊠
capricornus wasy 100 0 x ♑
aquarius wasy 101 0 x ♒
pisces wasy 102 0 x ♓
-conjunction wasy 86 0 x ☌
-opposition wasy 87 0 x ☍
+conjunction wasy 86 0 textmode ☌ wasysym # works in text mode only (produces V in math mode)
+opposition wasy 87 0 textmode ☍ wasysym # works in text mode only (produces W in math mode)
# APL characters
APLstar wasy 69 0 x ⍟
APLlog wasy 22 0 x x
# special characters
cent wasy 103 0 x �A2;
permil wasy 104 0 x ‰
-agemO wasy 48 0 x ℧
-thorn wasy 105 0 x þ
-Thorn wasy 106 0 x Þ
-openo wasy 108 0 x ɔ
-inve wasy 85 0 x ə
+agemO wasy 48 0 textmode ℧ wasysym # works in text mode only (produces 0 in math mode)
+thorn wasy 105 0 textmode þ wasysym # works in text mode only (produces i in math mode)
+Thorn wasy 106 0 textmode Þ wasysym # works in text mode only (produces j in math mode)
+openo wasy 108 0 textmode ɔ wasysym # works in text mode only (produces l in math mode)
+inve wasy 85 0 textmode ə wasysym # works in text mode only (produces U in math mode)
#mho wasy 48 0 mathord ℧ # already in amsfonts
#Join wasy 49 0 mathrel x
#include "support/docstream.h"
#include "support/textutils.h"
+#include <boost/scoped_ptr.hpp>
+
namespace lyx {
}
+InsetMath::mode_type InsetMathSymbol::currentMode() const
+{
+ return sym_->extra == "textmode" ? TEXT_MODE : MATH_MODE;
+}
+
+
bool InsetMathSymbol::isRelOp() const
{
return sym_->extra == "mathrel";
void InsetMathSymbol::write(WriteStream & os) const
{
- MathEnsurer ensurer(os);
+ boost::scoped_ptr<MathEnsurer> ensurer;
+ if (currentMode() != TEXT_MODE)
+ ensurer.reset(new MathEnsurer(os));
os << '\\' << name();
// $,#, etc. In theory the restriction based on catcodes, but then