pkgconfdir = $(libdir)/pkgconfig
pkgconf_DATA = \
libcupsfilters.pc \
- libppd.pc \
- libfontembed.pc
+ libppd.pc
doc_DATA = \
ABOUT-NLS \
ln-srf \
libcupsfilters.pc.in \
libppd.pc.in \
- libfontembed.pc.in \
utils/cups-browsed.service \
utils/cups-browsed-upstart.conf \
utils/driverless-fax.in \
EXTRA_DIST += $(pkgcharset_DATA)
-# =================
-# Fontembed library
-# =================
-pkgfontembedincludedir = $(includedir)/fontembed
-pkgfontembedinclude_DATA = \
- fontembed/bitset.h \
- fontembed/embed.h \
- fontembed/embed-pdf.h \
- fontembed/fontfile.h \
- fontembed/iofn.h \
- fontembed/sfnt.h
-
-lib_LTLIBRARIES = libfontembed.la
-
-check_PROGRAMS = \
- test-analyze \
- test-pdf \
- test-ps
-TESTS = \
- test-analyze \
- test-pdf \
- test-ps
-
-libfontembed_la_SOURCES = \
- fontembed/aglfn13.c \
- fontembed/dynstring.c \
- fontembed/dynstring-private.h \
- fontembed/debug-internal.h \
- fontembed/embed.c \
- fontembed/embed-sfnt.c \
- fontembed/embed-sfnt-int-private.h \
- fontembed/embed-pdf.c \
- fontembed/embed-pdf-int-private.h \
- fontembed/fontfile.c \
- fontembed/frequent.c \
- fontembed/frequent-private.h \
- fontembed/macroman-private.h \
- fontembed/sfnt.c \
- fontembed/sfnt-int-private.h \
- fontembed/sfnt-subset.c \
- $(pkgfontembedinclude_DATA)
-libfontembed_la_LDFLAGS = \
- -no-undefined \
- -version-info 1
-
-test_analyze_SOURCES = fontembed/test-analyze.c
-test_analyze_LDADD = libfontembed.la
-
-test_pdf_SOURCES = fontembed/test-pdf.c
-test_pdf_LDADD = libfontembed.la
-
-test_ps_SOURCES = fontembed/test-ps.c
-test_ps_LDADD = libfontembed.la
-
-EXTRA_DIST += \
- $(pkgfontembedinclude_DATA) \
- fontembed/README
+# =======
+# Filters
+# =======
pkgfilter_PROGRAMS =
pkgfilterdir = $(CUPS_SERVERBIN)/filter
cupsfilters/colormanager.h \
cupsfilters/driver.h \
cupsfilters/filter.h \
+ cupsfilters/fontembed.h \
cupsfilters/ieee1284.h \
cupsfilters/image.h \
cupsfilters/ipp.h \
cupsfilters/pdfutils.h \
cupsfilters/raster.h
-lib_LTLIBRARIES += libcupsfilters.la
+lib_LTLIBRARIES = libcupsfilters.la
-check_PROGRAMS += \
+check_PROGRAMS = \
testcmyk \
testdither \
testimage \
testrgb \
- test1284
-TESTS += \
- testdither
+ test1284 \
+ test-analyze \
+ test-pdf \
+ test-ps
+TESTS = \
+ testdither \
+ test-analyze \
+ test-pdf \
+ test-ps
+
# testcmyk # fails as it opens some image.ppm which is nowerhe to be found.
# testimage # requires also some ppm file as argument
# testrgb # same error
cupsfilters/debug-internal.h \
cupsfilters/dither.c \
cupsfilters/filter.c \
+ cupsfilters/fontembed/aglfn13.c \
+ cupsfilters/fontembed/dynstring.c \
+ cupsfilters/fontembed/dynstring-private.h \
+ cupsfilters/fontembed/embed.c \
+ cupsfilters/fontembed/embed-sfnt.c \
+ cupsfilters/fontembed/embed-sfnt-private.h \
+ cupsfilters/fontembed/embed-pdf.c \
+ cupsfilters/fontembed/embed-pdf-private.h \
+ cupsfilters/fontembed/fontfile.c \
+ cupsfilters/fontembed/frequent.c \
+ cupsfilters/fontembed/frequent-private.h \
+ cupsfilters/fontembed/macroman-private.h \
+ cupsfilters/fontembed/sfnt.c \
+ cupsfilters/fontembed/sfnt-private.h \
+ cupsfilters/fontembed/sfnt-subset.c \
cupsfilters/ghostscript.c \
cupsfilters/ieee1284.c \
cupsfilters/image.c \
cupsfilters/universal.c \
$(pkgfiltersinclude_DATA)
libcupsfilters_la_LIBADD = \
- libfontembed.la \
$(FONTCONFIG_LIBS) \
- $(GETLINE) \
- $(STRCASESTR) \
$(CUPS_LIBS) \
$(LCMS_LIBS) \
$(LIBQPDF_LIBS) \
$(POPPLER_LIBS) \
-lm
libcupsfilters_la_CFLAGS = \
- -I$(srcdir)/fontembed/ \
+ -I$(srcdir)/cupsfilters/fontembed/ \
$(FONTCONFIG_CFLAGS) \
$(CUPS_CFLAGS) \
$(LCMS_CFLAGS) \
libcupsfilters_CXXFLAGS = -std=c++0x $(libcupsfilters_CFLAGS) # -std=c++11
libcupsfilters_la_LIBADD += $(DBUS_LIBS)
endif
-libcupsfilters_la_DEPENDENCIES = \
- libfontembed.la \
- $(GETLINE) \
- $(STRCASESTR)
testcmyk_SOURCES = \
cupsfilters/testcmyk.c \
libcupsfilters.la \
-lm
+test_analyze_SOURCES = cupsfilters/fontembed/test-analyze.c
+test_analyze_LDADD = libcupsfilters.la
+
+test_pdf_SOURCES = cupsfilters/fontembed/test-pdf.c
+test_pdf_LDADD = libcupsfilters.la
+
+test_ps_SOURCES = cupsfilters/fontembed/test-ps.c
+test_ps_LDADD = libcupsfilters.la
+
EXTRA_DIST += \
$(pkgfiltersinclude_DATA) \
cupsfilters/image.pgm \
- cupsfilters/image.ppm
+ cupsfilters/image.ppm \
+ cupsfilters/fontembed/README
test1284_SOURCES = \
cupsfilters/test1284.c
test_pdf1_SOURCES = \
filter/test_pdf1.c \
- fontembed/embed.h \
- fontembed/sfnt.h
-test_pdf1_CFLAGS = -I$(srcdir)/fontembed/ \
+ cupsfilters/fontembed.h
+test_pdf1_CFLAGS = \
+ -I$(srcdir)/cupsfilters/fontembed/ \
-I$(srcdir)/cupsfilters/
-test_pdf1_LDADD = libfontembed.la \
+test_pdf1_LDADD = \
libcupsfilters.la
test_pdf2_SOURCES = \
filter/test_pdf2.c \
- fontembed/embed.h \
- fontembed/sfnt.h
-test_pdf2_CFLAGS = -I$(srcdir)/fontembed/ \
+ cupsfilters/fontembed.h
+test_pdf2_CFLAGS = \
+ -I$(srcdir)/cupsfilters/fontembed/ \
-I$(srcdir)/cupsfilters/
-test_pdf2_LDADD = libfontembed.la \
+test_pdf2_LDADD = \
libcupsfilters.la
universal_SOURCES = \
AC_CONFIG_FILES([
libcupsfilters.pc
libppd.pc
- libfontembed.pc
Makefile
utils/cups-browsed
utils/cups-browsed.conf
--- /dev/null
+#ifndef _CUPSFILTERS_FONTEMBED_H_
+#define _CUPSFILTERS_FONTEMBED_H_
+
+
+//
+// Include necessary headers...
+//
+
+#include <stdlib.h>
+#include <stdio.h>
+
+
+//
+// Constants and macros...
+//
+
+#define OTF_F_FMT_CFF 0x10000
+#define OTF_F_DO_CHECKSUM 0x40000
+
+#define OTF_TAG(a, b, c, d) (unsigned int)(((a) << 24) | ((b) << 16) | \
+ ((c) << 8) | (d))
+#define OTF_UNTAG(a) (((unsigned int)(a) >> 24) & 0xff), \
+ (((unsigned int)(a) >> 16) & 0xff), \
+ (((unsigned int)(a) >> 8) & 0xff), \
+ (((unsigned int)(a)) & 0xff)
+
+
+//
+// Types and structures...
+//
+
+// OpenType Font (OTF) handling
+
+typedef struct
+{
+ unsigned int tag;
+ unsigned int checkSum;
+ unsigned int offset;
+ unsigned int length;
+} OTF_DIRENT;
+
+typedef struct
+{
+ FILE *f;
+ unsigned int numTTC, useTTC;
+ unsigned int version;
+
+ unsigned short numTables;
+ OTF_DIRENT *tables;
+
+ int flags;
+ unsigned short unitsPerEm;
+ unsigned short indexToLocFormat; // 0=short, 1=long
+ unsigned short numGlyphs;
+
+ // optionally loaded data
+ unsigned int *glyphOffsets;
+ unsigned short numberOfHMetrics;
+ char *hmtx, *name, *cmap;
+ const char *unimap; // ptr to (3,1) or (3,0) cmap start
+
+ // single glyf buffer, allocated large enough by otf_load_more()
+ char *gly;
+ OTF_DIRENT *glyfTable;
+
+} OTF_FILE;
+
+// SFNT Font files
+
+struct _FONTFILE
+{
+ OTF_FILE *sfnt;
+ // ??? *cff;
+ char *stdname;
+ union
+ {
+ int fobj;
+ void *user;
+ };
+};
+
+typedef struct _FONTFILE FONTFILE;
+
+// Output callback function type
+
+typedef void (*OUTPUT_FN)(const char *buf, int len, void *context);
+
+// Bit manipulation
+
+typedef int* BITSET;
+
+// General font embedding
+
+typedef enum
+{
+ EMB_FMT_T1, // type1, with AFM/PFM,PFA/PFB
+ EMB_FMT_TTF, // sfnt, for TTF(glyf)
+ EMB_FMT_OTF, // sfnt+cff, for OTF(cff)
+ EMB_FMT_CFF, // cff, for raw CFF
+ EMB_FMT_STDFONT // don't embed (already present)
+} EMB_FORMAT;
+
+typedef enum
+{
+ EMB_DEST_NATIVE, // just subsetting/conversion
+ EMB_DEST_PS,
+//EMB_DEST_PS2,
+//EMB_DEST_PDF13,
+ EMB_DEST_PDF16
+} EMB_DESTINATION;
+
+typedef enum
+{
+ EMB_RIGHT_FULL = 0,
+ EMB_RIGHT_NONE = 0x02,
+ EMB_RIGHT_READONLY = 0x04,
+ EMB_RIGHT_NO_SUBSET = 0x0100,
+ EMB_RIGHT_BITMAPONLY = 0x0200
+} EMB_RIGHT_TYPE;
+
+typedef enum
+{
+ EMB_A_MULTIBYTE = 0x01, // embedd as multibyte font?
+ EMB_A_SUBSET = 0x02, // do subsetting?
+ EMB_A_T1_TO_CFF = 0x04, // convert Type1 to CFF?
+ EMB_A_CFF_TO_OTF = 0x08, // wrap CFF(from input or T1+CONVERT_CFF) in sfnt?
+ // (OTF)
+ EMB_A_OTF_TO_CFF = 0x10, // unwrap CFF
+
+ EMB_A_CLOSE_FONTFILE = 0x8000
+} EMB_ACTIONS;
+
+typedef enum
+{
+ EMB_C_MUST_SUBSET = 0x01, // (fail, when not possible)
+ EMB_C_EDITABLE_SUBSET = 0x02, // (...)
+ EMB_C_NEVER_SUBSET = 0x04, // (...)
+
+ EMB_C_FORCE_MULTIBYTE = 0x08, // always use multibyte fonts
+
+ EMB_C_PDF_OT = 0x10, // output TTF/OTF (esp. CFF to OTF)
+ EMB_C_KEEP_T1 = 0x20, // don't convert T1 to CFF
+
+ EMB_C_TAKE_FONTFILE = 0x8000 // take ownership of fontfile
+} EMB_CONSTRAINTS;
+
+typedef struct _EMB_PARAMS
+{
+ EMB_FORMAT intype;
+ EMB_FORMAT outtype;
+ EMB_DESTINATION dest;
+
+ EMB_ACTIONS plan;
+
+ // font infos
+ FONTFILE *font;
+ EMB_RIGHT_TYPE rights;
+// public:
+ BITSET subset;
+} EMB_PARAMS;
+
+// PDF file font embedding
+typedef struct
+{
+ char *fontname;
+ unsigned int flags;
+
+ // for the following: 0 = not set/invalid
+ int bbxmin, bbymin, bbxmax, bbymax;
+ int italicAngle; // >= 90: not set/invalid
+ int ascent;
+ int descent;
+ int capHeight;
+ int stemV;
+ // optional, default = 0:
+ int xHeight;
+ int avgWidth;
+
+ // CID-additions:
+ char *panose; // 12 bytes
+ char *registry, *ordering;
+ int supplement;
+
+ char data[1]; // used for storing e.g. > fontname
+} EMB_PDF_FONTDESCR;
+
+typedef struct
+{
+ // normal font
+ int first, last;
+ int *widths;
+
+ // multibyte font
+ int default_width;
+ int *warray; // format: (len c w ... w)*
+ // if (len < 0) { c1 (c2 = c1 + (-len)) w } else { c w[len] },
+ // terminated by len == 0
+
+ int data[1];
+} EMB_PDF_FONTWIDTHS;
+
+
+//
+// Prototypes...
+//
+
+// OpenType Font (OTF) handling
+
+// To load TTC collections: append e.g. "/3" for the third font in the file.
+OTF_FILE *otf_load(const char *file);
+void otf_close(OTF_FILE *otf);
+
+char *otf_get_table(OTF_FILE *otf, unsigned int tag, int *ret_len);
+
+int otf_get_width(OTF_FILE *otf, unsigned short gid);
+const char *otf_get_name(OTF_FILE *otf, int platformID, int encodingID,
+ int languageID, int nameID, int *ret_len);
+int otf_get_glyph(OTF_FILE *otf, unsigned short gid);
+unsigned short otf_from_unicode(OTF_FILE *otf, int unicode);
+
+// TODO?! allow glyphs==NULL for non-subsetting table reduction?
+int otf_subset(OTF_FILE *otf, BITSET glyphs, OUTPUT_FN output, void *context);
+int otf_ttc_extract(OTF_FILE *otf, OUTPUT_FN output, void *context);
+int otf_subset_cff(OTF_FILE *otf, BITSET glyphs, OUTPUT_FN output,
+ void *context);
+int otf_cff_extract(OTF_FILE *otf, OUTPUT_FN output, void *context);
+
+// SFNT Font files
+
+FONTFILE *fontfile_open_sfnt(OTF_FILE *otf);
+FONTFILE *fontfile_open_std(const char *name);
+void fontfile_close(FONTFILE *ff);
+
+// General font embedding
+
+EMB_PARAMS *emb_new(FONTFILE *font, EMB_DESTINATION dest, EMB_CONSTRAINTS mode);
+// emb_embed does only the "binary" part
+int emb_embed(EMB_PARAMS *emb, OUTPUT_FN output, void *context);
+ // returns number of bytes written
+void emb_close(EMB_PARAMS *emb);
+
+// PDF file font embedding
+
+const char *emb_pdf_get_font_subtype(EMB_PARAMS *emb);
+const char *emb_pdf_get_fontfile_key(EMB_PARAMS *emb);
+const char *emb_pdf_get_fontfile_subtype(EMB_PARAMS *emb);
+
+EMB_PDF_FONTDESCR *emb_pdf_fontdescr(EMB_PARAMS *emb);
+EMB_PDF_FONTWIDTHS *emb_pdf_fontwidths(EMB_PARAMS *emb);
+
+/** TODO elsewhere **/
+char *emb_pdf_simple_fontdescr(EMB_PARAMS *emb, EMB_PDF_FONTDESCR *fdes,
+ int fontfile_obj_ref);
+char *emb_pdf_simple_font(EMB_PARAMS *emb, EMB_PDF_FONTDESCR *fdes,
+ EMB_PDF_FONTWIDTHS *fwid, int fontdescr_obj_ref);
+char *emb_pdf_simple_cidfont(EMB_PARAMS *emb, const char *fontname,
+ int descendant_obj_ref);
+char *emb_pdf_simple_stdfont(EMB_PARAMS *emb);
+
+
+//
+// Inline functions...
+//
+
+// Bit manipulation
+
+static inline void
+bit_set(BITSET bs,
+ int num)
+{
+ bs[num / (8 * sizeof(int))] |= 1 << (num % (8 * sizeof(int)));
+}
+
+
+static inline int
+bit_check(BITSET bs,
+ int num)
+{
+ return bs [num / (8 * sizeof(int))] & 1 << (num % (8 * sizeof(int)));
+}
+
+
+// Use free() when done. returns NULL on bad_alloc
+static inline BITSET
+bitset_new(int size)
+{
+ return (BITSET)calloc(1, ((size + 8 * sizeof(int) - 1) &
+ ~(8 * sizeof(int) - 1)) / 8);
+}
+
+
+static inline int
+bits_used(BITSET bits,
+ int size) // {{{ returns true if any bit is used
+{
+ size = (size + 8 * sizeof(int) - 1) / (8 * sizeof(int));
+ while (size > 0)
+ {
+ if (*bits)
+ return (1);
+ bits ++;
+ size --;
+ }
+ return (0);
+}
+// }}}
+
+// General font embedding
+
+// TODO: encoding, TODO: ToUnicode
+static inline void
+emb_set(EMB_PARAMS *emb,
+ int unicode,
+ unsigned short gid) // {{{
+{
+ if (emb->subset)
+ {
+ if (emb->plan & EMB_A_MULTIBYTE)
+ {
+ bit_set(emb->subset, gid);
+ // ToUnicode.add(gid, unicode);
+ }
+ else
+ {
+ // TODO ... encoding
+ }
+ }
+}
+// }}}
+
+// TODO: encoding?, TODO: non-sfnt
+static inline unsigned short
+emb_get(EMB_PARAMS *emb, int unicode) // {{{ gid
+{
+ const unsigned short gid = otf_from_unicode(emb->font->sfnt, unicode);
+ emb_set(emb, unicode, gid);
+ return (gid);
+}
+// }}}
+
+
+#endif // !_CUPSFILTERS_FONTEMBED_H_
-libfontembed - font embedding and subsetting library
-----------------------------------------------------
+fontembed/ - font embedding and subsetting functions in libcupsfilters
+----------------------------------------------------------------------
-This library implements all the stuff required to
+Currently used for the cfFilterTextToPDF() filter function (files
+cupsfilters/texttopdf.c, cupsfilters/pdfutils.c,
+cupsfilters/pdfutils.h).
+
+These functions implement all the stuff required to
embed and subset TrueType fonts, as for example
-required in PDF files. It is completely self-contained,
+required in PDF files. There are completely self-contained,
although a FreeType binding might come sometime in the future.
Currently glyf-flavored TrueType is fully supported,
Usage
-----
-(TODO)... see test_pdf.c ...
+(TODO)... see cupsfilters/fontembed/test-pdf.c ...
+
+ * for direct sfnt access and for embedding use <cupsfilters/fontembed.h>
- * for direct sfnt access: use <sfnt.h>
- * for embedding: use <embed.h> (which includes <fontfile.h>)
License (MIT)
-------------
#include "dynstring-private.h"
-#include "debug-internal.h"
+#include <cupsfilters/debug-internal.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
-#include "embed.h"
-#include "embed-pdf.h" // already included fron embed.h ...
-#include "embed-pdf-int-private.h"
-#include "embed-sfnt-int-private.h"
-#include "debug-internal.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
+#include "embed-pdf-private.h"
+#include "embed-sfnt-private.h"
+#include "frequent-private.h"
#include <errno.h>
#include <string.h>
#include <time.h>
-#include "frequent-private.h"
// NOTE: these must be in sync with the EMB_FORMAT enum
#ifndef _FONTEMBED_EMBED_SFNT_INT_H_
#define _FONTEMBED_EMBED_SFNT_INT_H_
-#include "sfnt.h"
-#include "embed-pdf.h"
+#include <cupsfilters/fontembed.h>
EMB_RIGHT_TYPE emb_otf_get_rights(OTF_FILE *otf);
-#include "embed.h"
-#include "embed-pdf-int-private.h"
-#include "embed-sfnt-int-private.h"
-#include "sfnt.h"
-#include "sfnt-int-private.h"
-#include "debug-internal.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
+#include "embed-pdf-private.h"
+#include "embed-sfnt-private.h"
+#include "sfnt-private.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "embed.h"
-#include "embed-sfnt-int-private.h"
-#include "debug-internal.h"
+#include <cupsfilters/fontembed.h>
+#include "embed-sfnt-private.h"
+#include <cupsfilters/debug-internal.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
-#include "fontfile.h"
-#include "debug-internal.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
#include <string.h>
#include "frequent-private.h"
-#include "debug-internal.h"
+#include <cupsfilters/debug-internal.h>
#include <stdlib.h>
-#include "sfnt.h"
-#include "sfnt-int-private.h"
-#include "bitset.h"
-#include "debug-internal.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
+#include "sfnt-private.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "sfnt.h"
-#include "sfnt-int-private.h"
-#include "debug-internal.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
+#include "sfnt-private.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "sfnt.h"
-#include "sfnt-int-private.h"
-#include "embed.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
+#include "embed-sfnt-private.h"
+#include "sfnt-private.h"
#include "config.h"
-#include "embed-sfnt-int-private.h"
-#include "debug-internal.h"
#include <stdio.h>
#include <stdlib.h>
-#include "embed.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
#include "config.h"
-#include "sfnt.h"
-#include "debug-internal.h"
#include <stdio.h>
#include <stdlib.h>
-#include "embed.h"
+#include <cupsfilters/fontembed.h>
+#include <cupsfilters/debug-internal.h>
#include "config.h"
-#include "sfnt.h"
-#include "debug-internal.h"
#include <stdio.h>
#include <stdlib.h>
//
#include <stdio.h>
-#include "debug-internal.h"
#include <stdarg.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include "pdfutils.h"
-#include "fontembed/embed.h"
+#include "fontembed.h"
+#include "debug-internal.h"
//
//
#include <time.h>
-#include <fontembed/embed.h>
+#include <cupsfilters/fontembed.h>
//
// Include necessary headers...
//
-#include "debug-internal.h"
#include <config.h>
-#include "cupsfilters/pdfutils.h"
-#include "cupsfilters/raster.h"
+#include "pdfutils.h"
+#include "debug-internal.h"
+#include "filter.h"
+#include "raster.h"
+#include "fontembed.h"
#include <ctype.h>
#include <errno.h>
-#include "filter.h"
#include "fontconfig/fontconfig.h"
-#include "fontembed/embed.h"
-#include "fontembed/sfnt.h"
-#include "fontembed/fontfile.h"
//
#include "pdfutils.h"
#include "config.h"
#include "debug-internal.h"
-#include "fontembed/embed.h"
-#include "fontembed/sfnt.h"
+#include "cupsfilters/fontembed.h"
#include <stdio.h>
+++ /dev/null
-#ifndef _FONTEMBED_BITSET_H_
-#define _FONTEMBED_BITSET_H_
-
-#include <stdlib.h>
-
-typedef int* BITSET;
-
-
-static inline void
-bit_set(BITSET bs,
- int num)
-{
- bs[num / (8 * sizeof(int))] |= 1 << (num % (8 * sizeof(int)));
-}
-
-
-static inline int
-bit_check(BITSET bs,
- int num)
-{
- return bs [num / (8 * sizeof(int))] & 1 << (num % (8 * sizeof(int)));
-}
-
-
-// Use free() when done. returns NULL on bad_alloc
-static inline BITSET
-bitset_new(int size)
-{
- return (BITSET)calloc(1, ((size + 8 * sizeof(int) - 1) &
- ~(8 * sizeof(int) - 1)) / 8);
-}
-
-
-static inline int
-bits_used(BITSET bits,
- int size) // {{{ returns true if any bit is used
-{
- size = (size + 8 * sizeof(int) - 1) / (8 * sizeof(int));
- while (size > 0)
- {
- if (*bits)
- return (1);
- bits ++;
- size --;
- }
- return (0);
-}
-// }}}
-
-#endif // !_FONTEMBED_BITSET_H_
+++ /dev/null
-//
-// Internal debugging macros for libfontembed.
-//
-// Copyright © 2007-2018 by Apple Inc.
-// Copyright © 1997-2005 by Easy Software Products.
-//
-// Licensed under Apache License v2.0. See the file "LICENSE" for more
-// information.
-//
-
-#ifndef _FONTEMBED_DEBUG_INTERNAL_H_
-# define _FONTEMBED_DEBUG_INTERNAL_H_
-
-
-//
-// C++ magic...
-//
-
-# ifdef __cplusplus
-extern "C" {
-# endif // __cplusplus
-
-
-//
-// The debug macros are used if you compile with DEBUG defined.
-//
-// Usage:
-//
-// DEBUG_assert(boolean expression);
-//
-
-# ifdef DEBUG
-# include <assert.h>
-# define DEBUG_assert(x) assert(x)
-# else
-# define DEBUG_assert(x)
-# endif // DEBUG
-
-# ifdef __cplusplus
-}
-# endif // __cplusplus
-
-#endif // !_FONTEMBED_DEBUG_INTERNAL_H_
+++ /dev/null
-#ifndef _FONTEMBED_EMBED_PDF_H_
-#define _FONTEMBED_EMBED_PDF_H_
-
-
-// all the necessary information for PDF font embedding
-typedef struct
-{
- char *fontname;
- unsigned int flags;
-
- // for the following: 0 = not set/invalid
- int bbxmin, bbymin, bbxmax, bbymax;
- int italicAngle; // >= 90: not set/invalid
- int ascent;
- int descent;
- int capHeight;
- int stemV;
- // optional, default = 0:
- int xHeight;
- int avgWidth;
-
- // CID-additions:
- char *panose; // 12 bytes
- char *registry, *ordering;
- int supplement;
-
- char data[1]; // used for storing e.g. > fontname
-} EMB_PDF_FONTDESCR;
-
-typedef struct
-{
- // normal font
- int first, last;
- int *widths;
-
- // multibyte font
- int default_width;
- int *warray; // format: (len c w ... w)*
- // if (len < 0) { c1 (c2 = c1 + (-len)) w } else { c w[len] },
- // terminated by len == 0
-
- int data[1];
-} EMB_PDF_FONTWIDTHS;
-
-
-const char *emb_pdf_get_font_subtype(EMB_PARAMS *emb);
-const char *emb_pdf_get_fontfile_key(EMB_PARAMS *emb);
-const char *emb_pdf_get_fontfile_subtype(EMB_PARAMS *emb);
-
-EMB_PDF_FONTDESCR *emb_pdf_fontdescr(EMB_PARAMS *emb);
-EMB_PDF_FONTWIDTHS *emb_pdf_fontwidths(EMB_PARAMS *emb);
-
-/** TODO elsewhere **/
-char *emb_pdf_simple_fontdescr(EMB_PARAMS *emb, EMB_PDF_FONTDESCR *fdes,
- int fontfile_obj_ref);
-char *emb_pdf_simple_font(EMB_PARAMS *emb, EMB_PDF_FONTDESCR *fdes,
- EMB_PDF_FONTWIDTHS *fwid, int fontdescr_obj_ref);
-char *emb_pdf_simple_cidfont(EMB_PARAMS *emb, const char *fontname,
- int descendant_obj_ref);
-char *emb_pdf_simple_stdfont(EMB_PARAMS *emb);
-
-#endif // !_FONTEMBED_EMBED_PDF_H_
+++ /dev/null
-#ifndef _FONTEMBED_EMBED_H_
-#define _FONTEMBED_EMBED_H_
-
-#include "bitset.h"
-#include "fontfile.h"
-#include "iofn.h"
-
-
-typedef enum
-{
- EMB_FMT_T1, // type1, with AFM/PFM,PFA/PFB
- EMB_FMT_TTF, // sfnt, for TTF(glyf)
- EMB_FMT_OTF, // sfnt+cff, for OTF(cff)
- EMB_FMT_CFF, // cff, for raw CFF
- EMB_FMT_STDFONT // don't embed (already present)
-} EMB_FORMAT;
-
-typedef enum
-{
- EMB_DEST_NATIVE, // just subsetting/conversion
- EMB_DEST_PS,
-// EMB_DEST_PS2,
-// EMB_DEST_PDF13,
- EMB_DEST_PDF16
-} EMB_DESTINATION;
-
-typedef enum
-{
- EMB_RIGHT_FULL = 0,
- EMB_RIGHT_NONE = 0x02,
- EMB_RIGHT_READONLY = 0x04,
- EMB_RIGHT_NO_SUBSET = 0x0100,
- EMB_RIGHT_BITMAPONLY = 0x0200
-} EMB_RIGHT_TYPE;
-
-typedef enum
-{
- EMB_A_MULTIBYTE = 0x01, // embedd as multibyte font?
- EMB_A_SUBSET = 0x02, // do subsetting?
- EMB_A_T1_TO_CFF = 0x04, // convert Type1 to CFF?
- EMB_A_CFF_TO_OTF = 0x08, // wrap CFF(from input or T1+CONVERT_CFF) in sfnt?
- // (OTF)
- EMB_A_OTF_TO_CFF = 0x10, // unwrap CFF
-
- EMB_A_CLOSE_FONTFILE = 0x8000
-} EMB_ACTIONS;
-
-typedef enum
-{
- EMB_C_MUST_SUBSET = 0x01, // (fail, when not possible)
- EMB_C_EDITABLE_SUBSET = 0x02, // (...)
- EMB_C_NEVER_SUBSET = 0x04, // (...)
-
- EMB_C_FORCE_MULTIBYTE = 0x08, // always use multibyte fonts
-
- EMB_C_PDF_OT = 0x10, // output TTF/OTF (esp. CFF to OTF)
- EMB_C_KEEP_T1 = 0x20, // don't convert T1 to CFF
-
- EMB_C_TAKE_FONTFILE = 0x8000 // take ownership of fontfile
-} EMB_CONSTRAINTS;
-
-typedef struct _EMB_PARAMS
-{
- EMB_FORMAT intype;
- EMB_FORMAT outtype;
- EMB_DESTINATION dest;
-
- EMB_ACTIONS plan;
-
- // font infos
- FONTFILE *font;
- EMB_RIGHT_TYPE rights;
-// public:
- BITSET subset;
-} EMB_PARAMS;
-
-
-EMB_PARAMS *emb_new(FONTFILE *font, EMB_DESTINATION dest, EMB_CONSTRAINTS mode);
-// emb_embed does only the "binary" part
-int emb_embed(EMB_PARAMS *emb, OUTPUT_FN output, void *context);
- // returns number of bytes written
-void emb_close(EMB_PARAMS *emb);
-
-
-// TODO: encoding, TODO: ToUnicode
-static inline void
-emb_set(EMB_PARAMS *emb,
- int unicode,
- unsigned short gid) // {{{
-{
- if (emb->subset)
- {
- if (emb->plan & EMB_A_MULTIBYTE)
- {
- bit_set(emb->subset, gid);
- // ToUnicode.add(gid, unicode);
- }
- else
- {
- // TODO ... encoding
- }
- }
-}
-// }}}
-
-
-// TODO: encoding?, TODO: non-sfnt
-static inline unsigned short
-emb_get(EMB_PARAMS *emb, int unicode) // {{{ gid
-{
- const unsigned short gid = otf_from_unicode(emb->font->sfnt, unicode);
- emb_set(emb, unicode, gid);
- return (gid);
-}
-// }}}
-
-#include "embed-pdf.h"
-
-#endif // !_FONTEMBED_EMBED_H_
+++ /dev/null
-#ifndef _FONTEMBED_FONTFILE_H_
-#define _FONTEMBED_FONTFILE_H_
-
-#include "sfnt.h"
-
-struct _FONTFILE
-{
- OTF_FILE *sfnt;
- // ??? *cff;
- char *stdname;
- union
- {
- int fobj;
- void *user;
- };
-};
-
-typedef struct _FONTFILE FONTFILE;
-
-FONTFILE *fontfile_open_sfnt(OTF_FILE *otf);
-FONTFILE *fontfile_open_std(const char *name);
-void fontfile_close(FONTFILE *ff);
-
-#endif // !_FONTEMBED_FONTFILE_H_
+++ /dev/null
-#ifndef _FONTEMBED_IOFN_H_
-#define _FONTEMBED_IOFN_H_
-
-typedef void (*OUTPUT_FN)(const char *buf, int len, void *context);
-
-#endif // !_FONTEMBED_IOFN_H_
+++ /dev/null
-#ifndef _FONTEMBED_SFNT_H_
-#define _FONTEMBED_SFNT_H_
-
-#include <stdio.h>
-
-typedef struct
-{
- unsigned int tag;
- unsigned int checkSum;
- unsigned int offset;
- unsigned int length;
-} OTF_DIRENT;
-
-typedef struct
-{
- FILE *f;
- unsigned int numTTC, useTTC;
- unsigned int version;
-
- unsigned short numTables;
- OTF_DIRENT *tables;
-
- int flags;
- unsigned short unitsPerEm;
- unsigned short indexToLocFormat; // 0=short, 1=long
- unsigned short numGlyphs;
-
- // optionally loaded data
- unsigned int *glyphOffsets;
- unsigned short numberOfHMetrics;
- char *hmtx, *name, *cmap;
- const char *unimap; // ptr to (3,1) or (3,0) cmap start
-
- // single glyf buffer, allocated large enough by otf_load_more()
- char *gly;
- OTF_DIRENT *glyfTable;
-
-} OTF_FILE;
-
-#define OTF_F_FMT_CFF 0x10000
-#define OTF_F_DO_CHECKSUM 0x40000
-
-// to load TTC collections: append e.g. "/3" for the third font in the file.
-OTF_FILE *otf_load(const char *file);
-void otf_close(OTF_FILE *otf);
-
-#define OTF_TAG(a, b, c, d) (unsigned int)(((a) << 24) | ((b) << 16) | \
- ((c) << 8) | (d))
-#define OTF_UNTAG(a) (((unsigned int)(a) >> 24) & 0xff), \
- (((unsigned int)(a) >> 16) & 0xff), \
- (((unsigned int)(a) >> 8) & 0xff), \
- (((unsigned int)(a)) & 0xff)
-
-char *otf_get_table(OTF_FILE *otf, unsigned int tag, int *ret_len);
-
-int otf_get_width(OTF_FILE *otf, unsigned short gid);
-const char *otf_get_name(OTF_FILE *otf, int platformID, int encodingID,
- int languageID, int nameID, int *ret_len);
-int otf_get_glyph(OTF_FILE *otf, unsigned short gid);
-unsigned short otf_from_unicode(OTF_FILE *otf, int unicode);
-
-#include "bitset.h"
-#include "iofn.h"
-
-// TODO?! allow glyphs==NULL for non-subsetting table reduction?
-int otf_subset(OTF_FILE *otf, BITSET glyphs, OUTPUT_FN output, void *context);
-int otf_ttc_extract(OTF_FILE *otf, OUTPUT_FN output, void *context);
-int otf_subset_cff(OTF_FILE *otf, BITSET glyphs, OUTPUT_FN output,
- void *context);
-int otf_cff_extract(OTF_FILE *otf, OUTPUT_FN output, void *context);
-
-#endif // !_FONTEMBED_SFNT_H_
+++ /dev/null
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: libfontembed
-Description: Library for de/embedding fonts to PDF files
-Version: @VERSION@
-
-Libs: -L${libdir} -lfontembed
-Cflags: -I${includedir}/fontembed