STM publishing: tools, technologies and changeA WordPress site for STM Publishing

15Aug/14Off

Tip: PCRE, how to fix the stack overflow problem (Windows)

Posted by Graham Douglas

I kept hitting a stack overflow problem when using the PCRE regular expression C library under windows. To fix it, put the following line in PCRE's config.h to tell it not to use recursion but to use the heap instead.

#define NO_RECURSE 1

Worked for me.

1Aug/14Off

Introduction

I needed to create an updated font map for some work with dvipng/dvips and had to update psfonts.map to contain the mapping between tfm/pfb files and the corresponding PostScript name for each font. To do that I wrote a tiny C program (a simple throw-away utility using FreeType) to extract the PostScript font name from the .pfb files. To save time I used "file globbing" so that the utility's command line could use wildcards – e,g.,[path]\*.pfb to list all Type 1 fonts in [path]. To use file globbing with Windows you need to link your code with an object file called setargv.obj which takes care of the messy details and expands the wildcards on the command line. I use the now-ancient Visual Studio 2008 IDE (good enough for me!) and needed to add setargv.obj as an additional project dependency under "Additional Dependencies" in the project settings for the linker. With that in place, the following ultra-simple program (no error checking!!) prints the font's PostScript name and the full path name of the corresponding font file.

#include <stdio.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_OUTLINE_H

int main(int argc, char ** argv)
{

FT_Library libfreetype;
FT_Face     ftface;
int i;

FT_Init_FreeType( &libfreetype );

for (i=1; i<argc; i++){

FT_New_Face( libfreetype, argv[i], 0, &ftface );
printf("%s %s\n", FT_Get_Postscript_Name(ftface), argv[i]);
FT_Done_Face(ftface);
}

FT_Done_FreeType(libfreetype);
return 0;

}

22Jun/14Off

2Jun/14Off

And finally: Funky effects with multiple words and vowel placement!

Posted by Graham Douglas

(You'll need to download the PDF or zoom in with the Google PDF viewer). Just to complete the work: "funky effects" with multiple words and vowel positioning according to OpenType mark-to-base rules in the font.

10Nov/13Off

Xpost: New open source PostScript interpreter being developed

Posted by Graham Douglas

Just a brief post to note that a new PostScript interpreter, called Xpost, is being developed. For details see announcement on Google Groups. Definitely one I shall be following.

29Oct/13Off

Quick tip: Decompressing PDFs for Debugging

Posted by Graham Douglas

If you are creating special effects in PDFs (e.g., using pdfTeX's \pdfliteral{...} or via \special{...}) it can be extremely helpful to see the raw PDF code being output by your code/macros etc – especially when debugging! Often, by default, PDF content streams are compressed/encoded into binary data which makes it extremely difficult to access the raw PDF data/content. However, you can use the recently released free community version of Coherent's excellent command-line PDF manipulation software to decompress the binary data into plain text. It's as simple as:

cpdf -decompress compressedfile.pdf -o decompressedfile.pdf

cpdf has a wealth of other interesting command-line options too.