summaryrefslogtreecommitdiff
path: root/in_sfnt.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2007-02-08 21:50:00 +0000
committerBen Harris <bjh21@bjh21.me.uk>2007-02-08 21:50:00 +0000
commita0a77360d18d8207cbd67bb00297553fe90bc43a (patch)
tree2ba73cfd34a0ccc385e1b82536f76e0a291fda1f /in_sfnt.c
parent032b461a08eebc91d19f12c3e4d78032a5a173db (diff)
downloadhalibut-a0a77360d18d8207cbd67bb00297553fe90bc43a.zip
halibut-a0a77360d18d8207cbd67bb00297553fe90bc43a.tar.gz
halibut-a0a77360d18d8207cbd67bb00297553fe90bc43a.tar.bz2
halibut-a0a77360d18d8207cbd67bb00297553fe90bc43a.tar.xz
Support for embedding TrueType fonts in PDF output. The code isn't the most
beautiful I've ever written, and xpdf turns out not to support the encoding mechanism I've chosen, but it works in GhostScript so I'm not too unhappy for now. [originally from svn r7259]
Diffstat (limited to 'in_sfnt.c')
-rw-r--r--in_sfnt.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/in_sfnt.c b/in_sfnt.c
index fe16941..9e21bf2 100644
--- a/in_sfnt.c
+++ b/in_sfnt.c
@@ -802,3 +802,49 @@ void sfnt_writeps(font_info const *fi, FILE *ofp) {
sfree(breaks);
fprintf(ofp, "end /%s exch definefont\n", fi->name);
}
+
+void sfnt_cmap(font_encoding *fe, object *cmap) {
+ unsigned i;
+
+ objtext(cmap, "<</Type/CMap\n/CMapName/");
+ objtext(cmap, fe->name);
+ objtext(cmap, "\n/CIDSystemInfo<</Registry(Adobe)/Ordering(Identity)"
+ "/Supplement 0>>\n");
+ objstream(cmap, "%!PS-Adobe-3.0 Resource-CMap\n"
+ "%%DocumentNeededResources: procset CIDInit\n"
+ "%%IncludeResource: procset CIDInit\n"
+ "%%BeginResource: CMap ");
+ objstream(cmap, fe->name);
+ objstream(cmap, "\n%%Title (");
+ objstream(cmap, fe->name);
+ objstream(cmap, " Adobe Identity 0)\n%%Version: 1\n%%EndComments\n");
+ objstream(cmap, "/CIDInit/ProcSet findresource begin\n");
+ objstream(cmap, "12 dict begin begincmap\n");
+ objstream(cmap, "/CIDSystemInfo 3 dict dup begin\n"
+ "/Registry(Adobe)def/Ordering(Identity)def/Supplement 0 def "
+ "end def\n");
+ objstream(cmap, "/CMapName/");
+ objstream(cmap, fe->name);
+ objstream(cmap, " def/CMapType 0 def/WMode 0 def\n");
+ objstream(cmap, "1 begincodespacerange<00><FF>endcodespacerange\n");
+ for (i = 0; i < 256; i++) {
+ char buf[20];
+ if (fe->vector[i] == NOGLYPH)
+ continue;
+ objstream(cmap, "1 begincidchar");
+ sprintf(buf, "<%02X>", i);
+ objstream(cmap, buf);
+ sprintf(buf, "%hu", sfnt_glyphtoindex(fe->font->info->fontfile,
+ fe->vector[i]));
+ objstream(cmap, buf);
+ objstream(cmap, " endcidchar\n");
+ }
+ objstream(cmap, "endcmap CMapName currentdict /CMap defineresource pop "
+ "end end\n%%EndResource\n%%EOF\n");
+}
+
+void sfnt_data(font_info *fi, char **bufp, size_t *lenp) {
+ sfnt *sf = fi->fontfile;
+ *bufp = sf->data;
+ *lenp = sf->len;
+}