Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need some C code to generate Bezier curves from Metafont source code. Ideally, I'd like to have a C/C++ function with the following specifications:

Input: an array of text strings (the lines in the MetaFont program)

Output: an array of Bezier curves representing the centerlines of the "pen" strokes (plus some information about the pen used for each stroke).

So, internally, this code would parse the MetFont source, solve little systems of linear equations, and calculate the control points of the Bezier curves.

Code like this must exist in both MetaFont and MetaPost, but I'm having trouble finding it. Which files/functions should I look at first ? Thanks.

Adding edits here, as instructed: Remaining questions are:

(1) Are mplib.c and mplib.h the best starting points ?

(2) If they are, where can I find them ?

(3) If not, where else should I look ?

I think I have the answers, but I couldn't figure out how to answer my own question:

I think mplib.c and mplib.h probably are the best starting points. They are not part of the source distributions. You have to generate them by applying ctangle to mp.w (which is huge).

share|improve this question
1  
I found the mplib project. That sounds promising. –  bubba Oct 20 '12 at 3:46
    
Even better -- I found mplibapi.tex. I'd like to typeset this document, to make it easier to read. But it contains strange markup like \usetypescript[palatino] and there is no standard latex markup like begin{document}. I see pdf files for older versions, but not the latest (and much improved) version that was created about a month ago. –  bubba Oct 20 '12 at 4:26
    
I discovered that the unfamiliar markup is ConTEXt stuff, and found a way to typeset the document. So, now I have something to study, at least. –  bubba Oct 20 '12 at 5:39
    
Apparently, I should be looking at mplib.h. But I can't find it. It doesn't seem to be included in the metapost source that I found here: foundry.supelec.fr/gf/project/metapost –  bubba Oct 20 '12 at 6:34
1  
Please edit your question instead of adding comments to it. –  Martin Schröder Oct 20 '12 at 12:43

1 Answer 1

up vote 3 down vote accepted

The mplib package is pretty close to what I wanted (despite its prehistoric architecture) and mplib.h and mp.c are the relevant files.

They can't be found in the source repository because they are generated by using the "tangle" utility. After finding out about tangle, you might be tempted to look for a source file called mplib.w. That doesn't exist, either -- the actual source file is called mp.w.

There are about 27000 lines of code in mp.w, and the TeX file it generates has about 800 pages. But, it looks like the needed capabilities are in there. Somewhere.

For simple tasks, the documented API is all that's needed, so it's not necessary to dig through the old internal code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.