summaryrefslogtreecommitdiff
path: root/scripts/cmapcleanz.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-04-04 16:36:21 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-04-25 12:26:32 +0200
commita6d083bb776ecd498e57450ef84c20e39ae604cf (patch)
treea1f4399f011eb2b59e21f0588d322690a6ab14f4 /scripts/cmapcleanz.c
parent84cf672da90dfdaa2dfd2742cc69fa0bad268081 (diff)
downloadmupdf-a6d083bb776ecd498e57450ef84c20e39ae604cf.tar.xz
Add CMap processing scripts, and turn cmapdump into mutool.
A dumping script written in python. A flattening script written in python (for easier editing). A subsetting script written in shell to minimize CMaps by reusing subsets. Use 'mutool cmapdump' to bootstrap or verify cmap dumps.
Diffstat (limited to 'scripts/cmapcleanz.c')
-rw-r--r--scripts/cmapcleanz.c141
1 files changed, 7 insertions, 134 deletions
diff --git a/scripts/cmapcleanz.c b/scripts/cmapcleanz.c
index 07373f61..dee04044 100644
--- a/scripts/cmapcleanz.c
+++ b/scripts/cmapcleanz.c
@@ -1,36 +1,10 @@
/* cmapclean.c -- parse a CMap file and write it back out */
-/* We never want to build memento versions of the cmapdump util */
-#undef MEMENTO
-
-/* We never want large file access here */
-#undef FZ_LARGEFILE
-
#include <stdio.h>
#include <string.h>
#include "mupdf/pdf.h"
-#include "../source/fitz/context.c"
-#include "../source/fitz/error.c"
-#include "../source/fitz/memory.c"
-#include "../source/fitz/output.c"
-#include "../source/fitz/string.c"
-#include "../source/fitz/buffer.c"
-#include "../source/fitz/stream-open.c"
-#include "../source/fitz/stream-read.c"
-#include "../source/fitz/strtod.c"
-#include "../source/fitz/strtof.c"
-#include "../source/fitz/ftoa.c"
-#include "../source/fitz/printf.c"
-#ifdef _WIN32
-#include "../source/fitz/time.c"
-#endif
-
-#include "../source/pdf/pdf-lex.c"
-#include "../source/pdf/pdf-cmap.c"
-#include "../source/pdf/pdf-cmap-parse.c"
-
void pc(unsigned int c)
{
if (c <= 0xff) printf("<%02x>", c);
@@ -63,7 +37,7 @@ main(int argc, char **argv)
fi = fz_open_file(ctx, argv[1]);
cmap = pdf_load_cmap(ctx, fi);
- fz_close(fi);
+ fz_drop_stream(ctx, fi);
printf("begincmap\n");
printf("/CMapName /%s def\n", cmap->cmap_name);
@@ -105,7 +79,7 @@ main(int argc, char **argv)
for (k = 0; k < cmap->rlen; k++) {
if (cmap->ranges[k].high - cmap->ranges[k].low == 0) {
pc(cmap->ranges[k].low);
- printf("%u\n", cmap->ranges[k].out);
+ printf(" %u\n", cmap->ranges[k].out);
}
}
printf("endcidchar\n");
@@ -117,8 +91,9 @@ main(int argc, char **argv)
for (k = 0; k < cmap->rlen; k++) {
if (cmap->ranges[k].high - cmap->ranges[k].low > 0) {
pc(cmap->ranges[k].low);
+ putchar(' ');
pc(cmap->ranges[k].high);
- printf("%u\n", cmap->ranges[k].out);
+ printf(" %u\n", cmap->ranges[k].out);
}
}
printf("endcidrange\n");
@@ -160,6 +135,7 @@ main(int argc, char **argv)
/* 1-to-many */
+#if 0
if (cmap->mlen > 0)
{
printf("beginbfchar\n");
@@ -173,113 +149,10 @@ main(int argc, char **argv)
}
printf("endbfchar\n");
}
+#endif
printf("endcmap\n");
- fz_free_context(ctx);
- return 0;
-}
-
-void fz_new_font_context(fz_context *ctx)
-{
-}
-
-void fz_drop_font_context(fz_context *ctx)
-{
-}
-
-fz_font_context *fz_keep_font_context(fz_context *ctx)
-{
- return NULL;
-}
-
-void fz_new_colorspace_context(fz_context *ctx)
-{
-}
-
-void fz_drop_colorspace_context(fz_context *ctx)
-{
-}
-
-fz_colorspace_context *fz_keep_colorspace_context(fz_context *ctx)
-{
- return NULL;
-}
-
-void fz_new_aa_context(fz_context *ctx)
-{
-}
-
-void fz_drop_aa_context(fz_context *ctx)
-{
-}
-
-void fz_copy_aa_context(fz_context *dst, fz_context *src)
-{
-}
-
-void *fz_keep_storable(fz_context *ctx, const fz_storable *sc)
-{
- fz_storable *s = (fz_storable *)sc;
- return fz_keep_imp(ctx, s, &s->refs);
-}
-
-void fz_drop_storable(fz_context *ctx, const fz_storable *sc)
-{
- fz_storable *s = (fz_storable *)sc;
- if (fz_drop_imp(ctx, s, &s->refs))
- s->drop(ctx, s);
-}
-
-void fz_new_store_context(fz_context *ctx, size_t max)
-{
-}
-
-void fz_drop_store_context(fz_context *ctx)
-{
-}
-
-fz_store *fz_keep_store_context(fz_context *ctx)
-{
- return NULL;
-}
-
-int fz_store_scavenge(fz_context *ctx, size_t size, int *phase)
-{
- return 0;
-}
-
-void fz_new_glyph_cache_context(fz_context *ctx)
-{
-}
-
-void fz_drop_glyph_cache_context(fz_context *ctx)
-{
-}
-
-fz_glyph_cache *fz_keep_glyph_cache(fz_context *ctx)
-{
- return NULL;
-}
-
-void fz_new_document_handler_context(fz_context *ctx)
-{
-}
-
-void fz_drop_document_handler_context(fz_context *ctx)
-{
-}
-
-fz_document_handler_context *fz_keep_document_handler_context(fz_context *ctx)
-{
- return NULL;
-}
-
-void fz_default_image_decode(void *arg, int w, int h, int l2factor, fz_irect *irect)
-{
-}
-
-int fz_default_image_scale(void *arg, int w, int h, int src_w, int src_h)
-{
+ fz_drop_context(ctx);
return 0;
}