I am writing a quiz generator, started using HTML which turns out to be hard to deterministically decide where things will be. So I am going to use postscript. When I write out a question, and the box where the student is to write the answer, I need to know exactly where the box will be. This depends on the question text.
Inside the engine, I can easily access the x y cursor location that I am using to render. The question is how to get that information outside the engine. I could write a file, though I read that is not considered good practice: File i/o in postscript
I could write c++ code that uses freetype to open the fonts, calculate the location, but that's doing the same work twice, in two different languages, and what if I want to render images in there? I want the rendering and calculation to be done in only one place.
Is there any way to do this cleanly, is there an alternate tool anyone can suggest? At the moment my only concept is to write the locations of each box out to a file during the render, which means running unsafe.