Can I call some function of FontForge in my own C# project?

659 views Asked by At

I have installed Cygwin and FontForge successfully in the Windows7 operating system and they seem work very well.I find that FontForge is a powerful tool~~However I have a very naive question...Can I call some function of FontForge in my own C# project? It's the first time for me to use the open source project, and I don't know how to combine the open source codes with my own codes~

1

There are 1 answers

0
Johan Nordberg On

I've currently building a project that uses fontforge and I call it from C# as a Process that starts bash.exe and running fontforge as a command line arguments.

Here's an example:

Process p = new Process();
string cygwinDir = @"c:\cygwin\bin";
p.StartInfo.FileName = Path.Combine(cygwinDir, "bash.exe");
p.StartInfo.Arguments = "--login -c \"fontforge.exe -script '" + this.cygwinWorkPath + "script.pe";
p.StartInfo.WorkingDirectory = this.windowsWorkPath;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start();
p.WaitForExit();

var standardError = p.StandardError.ReadToEnd();
var standardOutput = p.StandardOutput.ReadToEnd();
var exitCode = p.ExitCode;

cygwinWorkpath is something like /myworkfolder and windowsWorkPath is like c:\cygwin\myworkfolder.