Skip to content

Commit

Permalink
Merge pull request #1 from mfschumann/importTextAsCurves
Browse files Browse the repository at this point in the history
import text as curves to avoid problems with automatic font substitution
  • Loading branch information
janbender authored Apr 28, 2017
2 parents f84fd2d + 902ec1c commit 7926a09
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
29 changes: 28 additions & 1 deletion AddinUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,31 @@ public static bool executeDviPs(LatexEquation equation)
return true;
}

public static bool executePs2Pdf(LatexEquation equation)
{
string appPath = AddinUtilities.getAppDataLocation();
Directory.SetCurrentDirectory(appPath);


SettingsManager mgr = SettingsManager.getCurrent();
try
{
File.Delete(appPath + "\\teximport.pdf");
}
catch
{
MessageBox.Show("teximport.pdf could not be written. Permission denied.");
return false;
}

string output = "";

// run ps2pdf
startProcess("cmd.exe", "/c \"" + mgr.SettingsData.miktexPath + "\\ps2pdf.exe\" -dNoOutputFonts teximport.ps teximport.pdf", true, false, out output);

return true;
}

public static bool createLatexPng(LatexEquation equation, bool firstRun)
{
// Check paths
Expand All @@ -364,7 +389,7 @@ public static bool createLatexPng(LatexEquation equation, bool firstRun)
return true;
}

public static bool createLatexPs(LatexEquation equation)
public static bool createLatexPdf(LatexEquation equation)
{
// Check paths
SettingsManager mgr = SettingsManager.getCurrent();
Expand All @@ -376,6 +401,8 @@ public static bool createLatexPs(LatexEquation equation)
return false;
if (!executeDviPs(equation))
return false;
if (!executePs2Pdf(equation))
return false;

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.0.1
- Convert text to curves before import

1.0

- Initial release
6 changes: 3 additions & 3 deletions LatexDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ private bool generateEquation(bool createShape)
m_finishedSuccessfully = AddinUtilities.createLatexPng(m_latexEquation, false);
else
{
m_finishedSuccessfully = AddinUtilities.createLatexPs(m_latexEquation);
m_finishedSuccessfully = AddinUtilities.createLatexPdf(m_latexEquation);

if (m_finishedSuccessfully)
{
string imageFile = Path.Combine(AddinUtilities.getAppDataLocation(), "teximport.ps");
string imageFile = Path.Combine(AddinUtilities.getAppDataLocation(), "teximport.pdf");
Corel.Interop.VGCore.StructImportOptions impopt = new Corel.Interop.VGCore.StructImportOptions();
impopt.MaintainLayers = true;
Corel.Interop.VGCore.ImportFilter impflt = DockerUI.Current.CorelApp.ActiveLayer.ImportEx(imageFile, Corel.Interop.VGCore.cdrFilter.cdrPSInterpreted, impopt);
Corel.Interop.VGCore.ImportFilter impflt = DockerUI.Current.CorelApp.ActiveLayer.ImportEx(imageFile, Corel.Interop.VGCore.cdrFilter.cdrPDF, impopt);
impflt.Finish();
m_latexEquation.m_shape = DockerUI.Current.CorelApp.ActiveShape;
ShapeTags.setShapeTags(m_latexEquation);
Expand Down

0 comments on commit 7926a09

Please sign in to comment.