diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd42ee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ diff --git a/AddinUtilities.cs b/AddinUtilities.cs index cb8c573..de756b1 100644 --- a/AddinUtilities.cs +++ b/AddinUtilities.cs @@ -64,6 +64,24 @@ public static void initFonts() m_latexFontShapes.Add(new LatexFontShape("Slanted", "sl")); m_latexFontShapes.Add(new LatexFontShape("Small caps", "sc")); } + if (m_latexMathFonts == null) + { + m_latexMathFonts = new List(); + m_latexMathFonts.Add(new LatexMathFont("Standard", "")); + m_latexMathFonts.Add(new LatexMathFont("Palatino", "mathpazo")); + m_latexMathFonts.Add(new LatexMathFont("Sans Math", "sansmathfonts")); + m_latexMathFonts.Add(new LatexMathFont("CM Bright", "cmbright")); + m_latexMathFonts.Add(new LatexMathFont("Times", "mathptmx")); + m_latexMathFonts.Add(new LatexMathFont("Fourier", "fourier")); + m_latexMathFonts.Add(new LatexMathFont("Euler", "eulervm")); + } + } + + private static List m_latexMathFonts = null; + public static List LatexMathFonts + { + get { return m_latexMathFonts; } + set { m_latexMathFonts = value; } } public static LatexFont getLatexFont(string name) @@ -96,6 +114,16 @@ public static LatexFontShape getLatexFontShape(string name) return null; } + public static LatexMathFont getLatexMathFont(string name) + { + foreach (LatexMathFont f in m_latexMathFonts) + { + if (f.fontName == name) + return f; + } + return null; + } + public static Color stringToColor(string colorText) { if (colorText == null) diff --git a/Changelog.txt b/Changelog.txt index 817b21e..c575bdf 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +1.0.2 + - Allow selection of math font through GUI + 1.0.1 - Convert text to curves before import diff --git a/LatexDialog.cs b/LatexDialog.cs index 4b303e3..ab8ac92 100644 --- a/LatexDialog.cs +++ b/LatexDialog.cs @@ -40,6 +40,11 @@ public string FontShape get { return comboBoxShape.Text; } } + public string MathFont + { + get { return comboBoxMathFont.Text; } + } + public string LatexCode { get { return m_scintilla.Text; } @@ -113,6 +118,7 @@ private void init(string title) comboBoxFont.Text = mgr.SettingsData.font; comboBoxSeries.Text = mgr.SettingsData.fontSeries; comboBoxShape.Text = mgr.SettingsData.fontShape; + comboBoxMathFont.Text = mgr.SettingsData.mathFont; buttonColor.BackColor = AddinUtilities.stringToColor(mgr.SettingsData.textColor); m_textColor = mgr.SettingsData.textColor; pictureBoxPreview.BackColor = Color.White; @@ -131,6 +137,7 @@ public void init(LatexEquation eq, string title) comboBoxFont.Text = eq.m_font.fontName; comboBoxSeries.Text = eq.m_fontSeries.fontSeries; comboBoxShape.Text = eq.m_fontShape.fontShape; + comboBoxMathFont.Text = eq.m_mathFont.fontName; try { @@ -166,6 +173,7 @@ private void createFontEntries() comboBoxFont.Items.AddRange(AddinUtilities.LatexFonts.ToArray()); comboBoxSeries.Items.AddRange(AddinUtilities.LatexFontSeries.ToArray()); comboBoxShape.Items.AddRange(AddinUtilities.LatexFontShapes.ToArray()); + comboBoxMathFont.Items.AddRange(AddinUtilities.LatexMathFonts.ToArray()); } void LatexDialog_FormClosing(object sender, FormClosingEventArgs e) @@ -221,12 +229,14 @@ private bool generateEquation(bool createShape) mgr.SettingsData.font = comboBoxFont.Text; mgr.SettingsData.fontSeries = comboBoxSeries.Text; mgr.SettingsData.fontShape = comboBoxShape.Text; + mgr.SettingsData.mathFont = comboBoxMathFont.Text; mgr.SettingsData.textColor = m_textColor; mgr.saveSettings(); m_latexEquation = new LatexEquation(m_scintilla.Text, size, m_textColor, (LatexFont)comboBoxFont.SelectedItem, (LatexFontSeries)comboBoxSeries.SelectedItem, - (LatexFontShape)comboBoxShape.SelectedItem); + (LatexFontShape)comboBoxShape.SelectedItem, + (LatexMathFont)comboBoxMathFont.SelectedItem); // Run once with preview to get depth value m_finishedSuccessfully = true; @@ -348,7 +358,16 @@ private void openLatexTemplateToolStripMenuItem_Click(object sender, EventArgs e string templateFileName = AddinUtilities.getAppDataLocation() + "\\LatexTemplate.txt"; System.Diagnostics.Process.Start(templateFileName); } - + + private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) + { + + } + + private void label3_Click(object sender, EventArgs e) + { + + } } public class LatexFont @@ -399,4 +418,20 @@ public override string ToString() } } + public class LatexMathFont + { + public LatexMathFont(string fn, string lpn) + { + fontName = fn; + latexPackageName = lpn; + } + public string fontName; + public string latexPackageName; + + public override string ToString() + { + return fontName; + } + } + } diff --git a/LatexDialog.designer.cs b/LatexDialog.designer.cs index 01d044f..230df65 100644 --- a/LatexDialog.designer.cs +++ b/LatexDialog.designer.cs @@ -50,6 +50,9 @@ private void InitializeComponent() this.panel1 = new System.Windows.Forms.Panel(); this.pictureBoxPreview = new System.Windows.Forms.PictureBox(); this.groupBoxLatex = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); + this.comboBoxMathFont = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); @@ -76,6 +79,7 @@ private void InitializeComponent() this.groupBoxPreview.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit(); + this.tableLayoutPanel5.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); @@ -87,26 +91,28 @@ private void InitializeComponent() this.tableLayoutPanel1.ColumnCount = 1; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 4); this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 0, 2); this.tableLayoutPanel1.Controls.Add(this.splitContainer1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel5, 0, 3); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5); - this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowCount = 5; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(594, 377); + this.tableLayoutPanel1.Size = new System.Drawing.Size(594, 426); this.tableLayoutPanel1.TabIndex = 0; + this.tableLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel1_Paint); // // tableLayoutPanel2 // this.tableLayoutPanel2.ColumnCount = 7; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 55F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 65F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 35F)); @@ -118,7 +124,7 @@ private void InitializeComponent() this.tableLayoutPanel2.Controls.Add(this.buttonColor, 3, 0); this.tableLayoutPanel2.Controls.Add(this.label2, 2, 0); this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel2.Location = new System.Drawing.Point(8, 275); + this.tableLayoutPanel2.Location = new System.Drawing.Point(8, 294); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.RowCount = 1; this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); @@ -132,7 +138,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(3, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(30, 24); + this.label1.Size = new System.Drawing.Size(46, 24); this.label1.TabIndex = 1; this.label1.Text = "font size"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -154,7 +160,7 @@ private void InitializeComponent() "48", "72", "96"}); - this.comboBoxFontSize.Location = new System.Drawing.Point(55, 0); + this.comboBoxFontSize.Location = new System.Drawing.Point(60, 0); this.comboBoxFontSize.Margin = new System.Windows.Forms.Padding(0); this.comboBoxFontSize.Name = "comboBoxFontSize"; this.comboBoxFontSize.Size = new System.Drawing.Size(60, 21); @@ -164,7 +170,7 @@ private void InitializeComponent() // buttonColor // this.buttonColor.BackColor = System.Drawing.Color.Black; - this.buttonColor.Location = new System.Drawing.Point(180, 0); + this.buttonColor.Location = new System.Drawing.Point(185, 0); this.buttonColor.Margin = new System.Windows.Forms.Padding(0); this.buttonColor.Name = "buttonColor"; this.buttonColor.Size = new System.Drawing.Size(30, 23); @@ -177,9 +183,9 @@ private void InitializeComponent() this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(118, 0); + this.label2.Location = new System.Drawing.Point(123, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(56, 24); + this.label2.Size = new System.Drawing.Size(50, 24); this.label2.TabIndex = 1; this.label2.Text = "text color"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -194,7 +200,7 @@ private void InitializeComponent() this.tableLayoutPanel3.Controls.Add(this.buttonPreview, 1, 0); this.tableLayoutPanel3.Controls.Add(this.buttonCancel, 2, 0); this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(8, 335); + this.tableLayoutPanel3.Location = new System.Drawing.Point(8, 384); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; this.tableLayoutPanel3.RowCount = 1; this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); @@ -239,7 +245,7 @@ private void InitializeComponent() // tableLayoutPanel4 // this.tableLayoutPanel4.ColumnCount = 7; - this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 55F)); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 150F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F)); this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 125F)); @@ -253,7 +259,7 @@ private void InitializeComponent() this.tableLayoutPanel4.Controls.Add(this.comboBoxSeries, 3, 0); this.tableLayoutPanel4.Controls.Add(this.comboBoxShape, 5, 0); this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel4.Location = new System.Drawing.Point(8, 305); + this.tableLayoutPanel4.Location = new System.Drawing.Point(8, 324); this.tableLayoutPanel4.Name = "tableLayoutPanel4"; this.tableLayoutPanel4.RowCount = 1; this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); @@ -267,7 +273,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(3, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(27, 24); + this.label4.Size = new System.Drawing.Size(25, 24); this.label4.TabIndex = 1; this.label4.Text = "font"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -276,7 +282,7 @@ private void InitializeComponent() // this.comboBoxFont.Dock = System.Windows.Forms.DockStyle.Fill; this.comboBoxFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxFont.Location = new System.Drawing.Point(55, 0); + this.comboBoxFont.Location = new System.Drawing.Point(60, 0); this.comboBoxFont.Margin = new System.Windows.Forms.Padding(0); this.comboBoxFont.Name = "comboBoxFont"; this.comboBoxFont.Size = new System.Drawing.Size(150, 21); @@ -287,7 +293,7 @@ private void InitializeComponent() this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(208, 0); + this.label5.Location = new System.Drawing.Point(213, 0); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(34, 24); this.label5.TabIndex = 1; @@ -299,9 +305,9 @@ private void InitializeComponent() this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(373, 0); + this.label6.Location = new System.Drawing.Point(378, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(34, 24); + this.label6.Size = new System.Drawing.Size(36, 24); this.label6.TabIndex = 1; this.label6.Text = "shape"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -312,7 +318,7 @@ private void InitializeComponent() this.comboBoxSeries.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxSeries.DropDownWidth = 125; this.comboBoxSeries.FormattingEnabled = true; - this.comboBoxSeries.Location = new System.Drawing.Point(245, 0); + this.comboBoxSeries.Location = new System.Drawing.Point(250, 0); this.comboBoxSeries.Margin = new System.Windows.Forms.Padding(0); this.comboBoxSeries.Name = "comboBoxSeries"; this.comboBoxSeries.Size = new System.Drawing.Size(125, 21); @@ -323,7 +329,7 @@ private void InitializeComponent() this.comboBoxShape.Dock = System.Windows.Forms.DockStyle.Fill; this.comboBoxShape.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxShape.FormattingEnabled = true; - this.comboBoxShape.Location = new System.Drawing.Point(412, 0); + this.comboBoxShape.Location = new System.Drawing.Point(417, 0); this.comboBoxShape.Margin = new System.Windows.Forms.Padding(0); this.comboBoxShape.Name = "comboBoxShape"; this.comboBoxShape.Size = new System.Drawing.Size(80, 21); @@ -343,8 +349,8 @@ private void InitializeComponent() // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.groupBoxLatex); - this.splitContainer1.Size = new System.Drawing.Size(578, 261); - this.splitContainer1.SplitterDistance = 75; + this.splitContainer1.Size = new System.Drawing.Size(578, 280); + this.splitContainer1.SplitterDistance = 76; this.splitContainer1.TabIndex = 0; this.splitContainer1.TabStop = false; // @@ -354,7 +360,7 @@ private void InitializeComponent() this.groupBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBoxPreview.Location = new System.Drawing.Point(0, 0); this.groupBoxPreview.Name = "groupBoxPreview"; - this.groupBoxPreview.Size = new System.Drawing.Size(578, 75); + this.groupBoxPreview.Size = new System.Drawing.Size(578, 76); this.groupBoxPreview.TabIndex = 99; this.groupBoxPreview.TabStop = false; this.groupBoxPreview.Text = "Preview"; @@ -368,7 +374,7 @@ private void InitializeComponent() this.panel1.Location = new System.Drawing.Point(3, 16); this.panel1.Margin = new System.Windows.Forms.Padding(20, 5, 20, 5); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(572, 56); + this.panel1.Size = new System.Drawing.Size(572, 57); this.panel1.TabIndex = 99; this.panel1.VisibleChanged += new System.EventHandler(this.panel1_VisibleChanged); // @@ -388,22 +394,61 @@ private void InitializeComponent() this.groupBoxLatex.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBoxLatex.Location = new System.Drawing.Point(0, 0); this.groupBoxLatex.Name = "groupBoxLatex"; - this.groupBoxLatex.Size = new System.Drawing.Size(578, 182); + this.groupBoxLatex.Size = new System.Drawing.Size(578, 200); this.groupBoxLatex.TabIndex = 0; this.groupBoxLatex.TabStop = false; this.groupBoxLatex.Text = "Latex"; // + // tableLayoutPanel5 + // + this.tableLayoutPanel5.ColumnCount = 3; + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 150F)); + this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel5.Controls.Add(this.comboBoxMathFont, 1, 0); + this.tableLayoutPanel5.Controls.Add(this.label3, 0, 0); + this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel5.Location = new System.Drawing.Point(8, 354); + this.tableLayoutPanel5.Name = "tableLayoutPanel5"; + this.tableLayoutPanel5.RowCount = 1; + this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel5.Size = new System.Drawing.Size(578, 24); + this.tableLayoutPanel5.TabIndex = 5; + // + // comboBoxMathFont + // + this.comboBoxMathFont.Dock = System.Windows.Forms.DockStyle.Fill; + this.comboBoxMathFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxMathFont.Location = new System.Drawing.Point(60, 0); + this.comboBoxMathFont.Margin = new System.Windows.Forms.Padding(0); + this.comboBoxMathFont.Name = "comboBoxMathFont"; + this.comboBoxMathFont.Size = new System.Drawing.Size(150, 21); + this.comboBoxMathFont.TabIndex = 1; + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(51, 24); + this.label3.TabIndex = 0; + this.label3.Text = "math font"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.label3.Click += new System.EventHandler(this.label3_Click); + // // toolStripContainer1 // // // toolStripContainer1.ContentPanel // this.toolStripContainer1.ContentPanel.Controls.Add(this.tableLayoutPanel1); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(594, 377); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(594, 426); this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Name = "toolStripContainer1"; - this.toolStripContainer1.Size = new System.Drawing.Size(594, 402); + this.toolStripContainer1.Size = new System.Drawing.Size(594, 450); this.toolStripContainer1.TabIndex = 1; this.toolStripContainer1.Text = "toolStripContainer1"; // @@ -420,7 +465,7 @@ private void InitializeComponent() this.optionsToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(594, 25); + this.menuStrip1.Size = new System.Drawing.Size(594, 24); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // @@ -437,14 +482,14 @@ private void InitializeComponent() this.addSnippetToolStripMenuItem, this.previewToolStripMenuItem}); this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(42, 21); + this.toolStripMenuItem1.Size = new System.Drawing.Size(39, 20); this.toolStripMenuItem1.Text = "&Edit"; // // findToolStripMenuItem // this.findToolStripMenuItem.Name = "findToolStripMenuItem"; this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); - this.findToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.findToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.findToolStripMenuItem.Text = "Find"; this.findToolStripMenuItem.Click += new System.EventHandler(this.findToolStripMenuItem_Click); // @@ -452,7 +497,7 @@ private void InitializeComponent() // this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem"; this.replaceToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.H))); - this.replaceToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.replaceToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.replaceToolStripMenuItem.Text = "Replace"; this.replaceToolStripMenuItem.Click += new System.EventHandler(this.replaceToolStripMenuItem_Click); // @@ -460,20 +505,20 @@ private void InitializeComponent() // this.incrementalSearchToolStripMenuItem.Name = "incrementalSearchToolStripMenuItem"; this.incrementalSearchToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.incrementalSearchToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.incrementalSearchToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.incrementalSearchToolStripMenuItem.Text = "Incremental search"; this.incrementalSearchToolStripMenuItem.Click += new System.EventHandler(this.incrementalSearchToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(316, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(293, 6); // // commentLineToolStripMenuItem // this.commentLineToolStripMenuItem.Name = "commentLineToolStripMenuItem"; this.commentLineToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q))); - this.commentLineToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.commentLineToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.commentLineToolStripMenuItem.Text = "Comment lines"; this.commentLineToolStripMenuItem.Click += new System.EventHandler(this.commentLineToolStripMenuItem_Click); // @@ -482,20 +527,20 @@ private void InitializeComponent() this.uncommentLineToolStripMenuItem.Name = "uncommentLineToolStripMenuItem"; this.uncommentLineToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.Q))); - this.uncommentLineToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.uncommentLineToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.uncommentLineToolStripMenuItem.Text = "Uncomment lines"; this.uncommentLineToolStripMenuItem.Click += new System.EventHandler(this.uncommentLineToolStripMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(316, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(293, 6); // // addSnippetToolStripMenuItem // this.addSnippetToolStripMenuItem.Name = "addSnippetToolStripMenuItem"; this.addSnippetToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.J))); - this.addSnippetToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.addSnippetToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.addSnippetToolStripMenuItem.Text = "Add snippet"; this.addSnippetToolStripMenuItem.Click += new System.EventHandler(this.addSnippetToolStripMenuItem_Click); // @@ -503,7 +548,7 @@ private void InitializeComponent() // this.previewToolStripMenuItem.Name = "previewToolStripMenuItem"; this.previewToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F5; - this.previewToolStripMenuItem.Size = new System.Drawing.Size(319, 24); + this.previewToolStripMenuItem.Size = new System.Drawing.Size(296, 22); this.previewToolStripMenuItem.Text = "Preview"; this.previewToolStripMenuItem.Click += new System.EventHandler(this.buttonPreview_Click); // @@ -513,20 +558,20 @@ private void InitializeComponent() this.changeOptionsToolStripMenuItem, this.openLatexTemplateToolStripMenuItem}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21); + this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.optionsToolStripMenuItem.Text = "&Options"; // // changeOptionsToolStripMenuItem // this.changeOptionsToolStripMenuItem.Name = "changeOptionsToolStripMenuItem"; - this.changeOptionsToolStripMenuItem.Size = new System.Drawing.Size(189, 24); + this.changeOptionsToolStripMenuItem.Size = new System.Drawing.Size(174, 22); this.changeOptionsToolStripMenuItem.Text = "Change options"; this.changeOptionsToolStripMenuItem.Click += new System.EventHandler(this.changeOptionsToolStripMenuItem_Click); // // openLatexTemplateToolStripMenuItem // this.openLatexTemplateToolStripMenuItem.Name = "openLatexTemplateToolStripMenuItem"; - this.openLatexTemplateToolStripMenuItem.Size = new System.Drawing.Size(189, 24); + this.openLatexTemplateToolStripMenuItem.Size = new System.Drawing.Size(174, 22); this.openLatexTemplateToolStripMenuItem.Text = "Edit Latex template"; this.openLatexTemplateToolStripMenuItem.Click += new System.EventHandler(this.openLatexTemplateToolStripMenuItem_Click); // @@ -536,7 +581,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(594, 402); + this.ClientSize = new System.Drawing.Size(594, 450); this.Controls.Add(this.toolStripContainer1); this.MainMenuStrip = this.menuStrip1; this.Name = "LatexDialog"; @@ -556,6 +601,8 @@ private void InitializeComponent() this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit(); + this.tableLayoutPanel5.ResumeLayout(false); + this.tableLayoutPanel5.PerformLayout(); this.toolStripContainer1.ContentPanel.ResumeLayout(false); this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); this.toolStripContainer1.TopToolStripPanel.PerformLayout(); @@ -606,6 +653,9 @@ private void InitializeComponent() private System.Windows.Forms.Button buttonPreview; private System.Windows.Forms.ToolStripMenuItem previewToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openLatexTemplateToolStripMenuItem; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox comboBoxMathFont; } } diff --git a/LatexFileGenerator.cs b/LatexFileGenerator.cs index b687d2d..2f844d7 100644 --- a/LatexFileGenerator.cs +++ b/LatexFileGenerator.cs @@ -15,12 +15,13 @@ public class LatexEquation public LatexFont m_font; public LatexFontSeries m_fontSeries; public LatexFontShape m_fontShape; + public LatexMathFont m_mathFont; public int m_textShapeId; public int m_imageWidth; public int m_imageHeight; public Corel.Interop.VGCore.Shape m_shape; - public LatexEquation(string latexCode, float fontSize, string textColor, LatexFont font, LatexFontSeries fontSeries, LatexFontShape fontShape) + public LatexEquation(string latexCode, float fontSize, string textColor, LatexFont font, LatexFontSeries fontSeries, LatexFontShape fontShape, LatexMathFont mathFont) { m_code = latexCode; m_fontSize = fontSize; @@ -28,12 +29,13 @@ public LatexEquation(string latexCode, float fontSize, string textColor, LatexFo m_font = font; m_fontSeries = fontSeries; m_fontShape = fontShape; + m_mathFont = mathFont; m_imageWidth = 0; m_imageHeight = 0; m_textShapeId = -1; } - public LatexEquation(string latexCode, float fontSize, string textColor, LatexFont font, LatexFontSeries fontSeries, LatexFontShape fontShape, int textShapeId) + public LatexEquation(string latexCode, float fontSize, string textColor, LatexFont font, LatexFontSeries fontSeries, LatexFontShape fontShape, LatexMathFont mathFont, int textShapeId) { m_code = latexCode; m_fontSize = fontSize; @@ -41,6 +43,7 @@ public LatexEquation(string latexCode, float fontSize, string textColor, LatexFo m_font = font; m_fontSeries = fontSeries; m_fontShape = fontShape; + m_mathFont = mathFont; m_imageWidth = 0; m_imageHeight = 0; m_textShapeId = textShapeId; @@ -78,8 +81,15 @@ public static void writeTexFile(string fileName, LatexEquation equation) } } + string addonPackages = ""; + if (equation.m_mathFont.fontName != "Standard") + { + addonPackages += "\\usepackage{" + equation.m_mathFont.latexPackageName + "}\n"; + } + templateText = templateText.Replace("${addonPackages}", addonPackages); + string content = ""; - content += "\\definecolor{txtcolor}{rgb}{" + equation.m_color + "}\n"; ; + content += "\\definecolor{txtcolor}{rgb}{" + equation.m_color + "}\n"; content += "\\color{txtcolor}\n"; content += "\\changefont{" + equation.m_font.latexFontName + "}{" + equation.m_fontSeries.latexFontSeries + "}{" + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 8c287de..b854dc4 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -33,5 +33,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.2.0")] +[assembly: AssemblyFileVersion("1.0.2.0")] diff --git a/Resources/LatexTemplate.txt b/Resources/LatexTemplate.txt index 5e6d901..a9ad4f9 100644 --- a/Resources/LatexTemplate.txt +++ b/Resources/LatexTemplate.txt @@ -6,6 +6,9 @@ \usepackage{bbm} \usepackage{ae,aecompl} \usepackage{color} + +${addonPackages} + \newcommand{\changefont}[5]{\fontfamily{#1} \fontseries{#2} \fontshape{#3} \fontsize{#4}{#5}\selectfont} \setlength{\parindent}{0pt} \begin{document} diff --git a/SettingsManager.cs b/SettingsManager.cs index 2abc095..79b8b7b 100644 --- a/SettingsManager.cs +++ b/SettingsManager.cs @@ -73,6 +73,7 @@ public bool loadSettings() m_settings.font = "Times Roman"; m_settings.fontSeries = "Standard"; m_settings.fontShape = "Standard"; + m_settings.mathFont = "Standard"; m_settings.insertAtCursor = true; result = false; } @@ -101,6 +102,7 @@ public class Settings public string font; public string fontSeries; public string fontShape; + public string mathFont; public bool insertAtCursor; } } \ No newline at end of file diff --git a/ShapeTags.cs b/ShapeTags.cs index 3eb2803..bde1964 100644 --- a/ShapeTags.cs +++ b/ShapeTags.cs @@ -25,6 +25,7 @@ public static void setShapeTags(LatexEquation equation) addTag(equation.m_shape, "LatexFont", equation.m_font.fontName); addTag(equation.m_shape, "LatexFontSeries", equation.m_fontSeries.fontSeries); addTag(equation.m_shape, "LatexFontShape", equation.m_fontShape.fontShape); + addTag(equation.m_shape, "LatexMathFont", equation.m_mathFont.fontName); addTag(equation.m_shape, "LatexTextShapeId", equation.m_textShapeId.ToString()); addTag(equation.m_shape, "Latex4CorelDrawVersion", AddinUtilities.getVersionString()); } @@ -39,7 +40,8 @@ public static LatexEquation getLatexEquation(Shape s) getLatexTextColor(s), getLatexFont(s), getLatexFontSeries(s), - getLatexFontShape(s)); + getLatexFontShape(s), + getLatexMathFont(s)); } return null; } @@ -65,6 +67,19 @@ public static LatexFont getLatexFont(Shape s) return null; } + public static LatexMathFont getLatexMathFont(Shape s) + { + Version objVer = new Version(s.ObjectData["Latex4CorelDrawVersion"].Value.ToString()); + if (objVer < new Version(1, 0, 2, 0)) + return new LatexMathFont("Standard", ""); + + string str = (string)s.ObjectData["LatexMathFont"].Value; + if (str != null) + return AddinUtilities.getLatexMathFont(str); + + return null; + } + public static LatexFontShape getLatexFontShape(Shape s) { string str = (string)s.ObjectData["LatexFontShape"].Value;