{"id":3404,"date":"2014-08-01T09:27:00","date_gmt":"2014-08-01T09:27:00","guid":{"rendered":"http:\/\/www.readytext.co.uk\/?p=3404"},"modified":"2014-08-01T09:27:00","modified_gmt":"2014-08-01T09:27:00","slug":"minimal-freetype-program-to-dump-postscript-font-names-with-file-globbing","status":"publish","type":"post","link":"https:\/\/www.readytext.co.uk\/?p=3404","title":{"rendered":"Minimal FreeType program to dump PostScript font names (with file globbing)"},"content":{"rendered":"<h1>Introduction<\/h1>\n<p>I needed to create an updated font map for some work with dvipng\/dvips and had to update <code>psfonts.map<\/code> 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 &#8220;file globbing&#8221; so that the utility&#8217;s command line could use wildcards &ndash; e,g.,<code>[path]\\*.pfb<\/code> 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 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/8bch7bkk.aspx\"><code>setargv.obj<\/code><\/a> 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 <code>setargv.obj<\/code> as an additional project dependency under &#8220;Additional Dependencies&#8221; in the project settings for the linker. With that in place, the following ultra-simple program (no error checking!!) prints the font&#8217;s PostScript name and the full path name of the corresponding font file.<\/p>\n<pre class=\"brush: plain; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;ft2build.h&gt;\r\n#include FT_FREETYPE_H\r\n#include FT_GLYPH_H\r\n#include FT_OUTLINE_H\r\n\r\n\r\nint main(int argc, char ** argv)\r\n{\r\n\r\n\tFT_Library libfreetype;\r\n\tFT_Face     ftface;\r\n\tint i;\r\n    \r\n\tFT_Init_FreeType( &amp;libfreetype );\r\n\r\n    for (i=1; i&lt;argc; i++){\r\n\r\n\t\tFT_New_Face( libfreetype, argv&#x5B;i], 0, &amp;ftface );\r\n\t\tprintf(&quot;%s %s\\n&quot;, FT_Get_Postscript_Name(ftface), argv&#x5B;i]);\r\n\t\tFT_Done_Face(ftface);\r\n    }\r\n\r\n\tFT_Done_FreeType(libfreetype);\r\n    return 0;\r\n\t\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3404","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3404"}],"version-history":[{"count":5,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3404\/revisions"}],"predecessor-version":[{"id":3409,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3404\/revisions\/3409"}],"wp:attachment":[{"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.readytext.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}