]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Rename API functions of pdfutils.h to "cf..."
authorTill Kamppeter <till.kamppeter@gmail.com>
Wed, 6 Apr 2022 22:20:51 +0000 (00:20 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Wed, 6 Apr 2022 22:20:51 +0000 (00:20 +0200)
Also renamed constants to start with "CF_" and data types to start
with "cf_".

cupsfilters/pdfutils.c
cupsfilters/pdfutils.h
cupsfilters/texttopdf.c
filter/test_pdf1.c
filter/test_pdf2.c

index 8dbf65d215572ed9b04fbe2ef1e41daccc2b3efe..1b138b464bcab3a4e7843784134accb2dbe7fb94 100644 (file)
@@ -16,7 +16,7 @@
 #include "pdfutils.h"
 #include "fontembed/embed.h"
 
-void pdfOut_printf(pdfOut *pdf,const char *fmt,...) // {{{
+void cfPDFOutPrintF(cf_pdf_out_t *pdf,const char *fmt,...) // {{{
 {
   assert(pdf);
   int len;
@@ -29,7 +29,7 @@ void pdfOut_printf(pdfOut *pdf,const char *fmt,...) // {{{
 }
 // }}}
 
-void pdfOut_putString(pdfOut *pdf,const char *str,int len) // {{{ - >len==-1: strlen()
+void cfPDFOutPutString(cf_pdf_out_t *pdf,const char *str,int len) // {{{ - >len==-1: strlen()
 {
   assert(pdf);
   assert(str);
@@ -60,7 +60,7 @@ void pdfOut_putString(pdfOut *pdf,const char *str,int len) // {{{ - >len==-1: st
 }
 // }}}
 
-void pdfOut_putHexString(pdfOut *pdf,const char *str,int len) // {{{ - >len==-1: strlen()
+void cfPDFOutPutHexString(cf_pdf_out_t *pdf,const char *str,int len) // {{{ - >len==-1: strlen()
 {
   assert(pdf);
   assert(str);
@@ -76,11 +76,11 @@ void pdfOut_putHexString(pdfOut *pdf,const char *str,int len) // {{{ - >len==-1:
 }
 // }}}
 
-pdfOut *pdfOut_new() // {{{ -  NULL on error 
+cf_pdf_out_t *cfPDFOutNew() // {{{ -  NULL on error 
 {
-  pdfOut *ret=malloc(sizeof(pdfOut));
+  cf_pdf_out_t *ret=malloc(sizeof(cf_pdf_out_t));
   if (ret) {
-    memset(ret,0,sizeof(pdfOut));
+    memset(ret,0,sizeof(cf_pdf_out_t));
   }
 
   return ret;
@@ -88,7 +88,7 @@ pdfOut *pdfOut_new() // {{{ -  NULL on error
 // }}}
 
 // NOTE: uses statically allocated buffer
-const char *pdfOut_to_pdfdate(struct tm *curtm) // {{{
+const char *cfPDFOutToPDFDate(struct tm *curtm) // {{{
 {
   static char curdate[250];
   if (!curtm) {
@@ -106,7 +106,7 @@ const char *pdfOut_to_pdfdate(struct tm *curtm) // {{{
 }
 // }}}
 
-int pdfOut_add_xref(pdfOut *pdf) // {{{  -  returns obj_no
+int cfPDFOutAddXRef(cf_pdf_out_t *pdf) // {{{  -  returns obj_no
 {
   assert(pdf);
   assert(pdf->xrefsize<=pdf->xrefalloc);
@@ -126,7 +126,7 @@ int pdfOut_add_xref(pdfOut *pdf) // {{{  -  returns obj_no
 }
 // }}}
 
-int pdfOut_add_page(pdfOut *pdf,int obj) // {{{ -  returns false on error
+int cfPDFOutAddPage(cf_pdf_out_t *pdf,int obj) // {{{ -  returns false on error
 {
   assert(pdf);
   assert(obj>0);
@@ -147,15 +147,15 @@ int pdfOut_add_page(pdfOut *pdf,int obj) // {{{ -  returns false on error
 }
 // }}}
 
-int pdfOut_add_kv(pdfOut *pdf,const char *key,const char *val) // {{{ -  returns false on error
+int cfPDFOutAddKeyValue(cf_pdf_out_t *pdf,const char *key,const char *val) // {{{ -  returns false on error
 {
   assert(pdf);
   assert(pdf->kvsize<=pdf->kvalloc);
 
   if (pdf->kvsize==pdf->kvalloc) {
-    struct keyval_t *tmp;
+    struct cf_keyval_t *tmp;
     pdf->kvalloc+=10;
-    tmp=realloc(pdf->kv,sizeof(struct keyval_t)*pdf->kvalloc);
+    tmp=realloc(pdf->kv,sizeof(struct cf_keyval_t)*pdf->kvalloc);
     if (!tmp) {
       pdf->kvalloc=-1;
       return 0;
@@ -172,7 +172,7 @@ int pdfOut_add_kv(pdfOut *pdf,const char *key,const char *val) // {{{ -  returns
 }
 // }}}
 
-int pdfOut_begin_pdf(pdfOut *pdf) // ,...output_device?...) // {{{ - false on error
+int cfPDFOutBeginPDF(cf_pdf_out_t *pdf) // ,...output_device?...) // {{{ - false on error
 {
   assert(pdf);
   assert(pdf->kvsize==0); // otherwise: finish_pdf has not been called
@@ -180,16 +180,16 @@ int pdfOut_begin_pdf(pdfOut *pdf) // ,...output_device?...) // {{{ - false on er
 
   pdf->xrefsize=pdf->pagessize=0;
   pdf->filepos=0;
-  pages_obj=pdfOut_add_xref(pdf); // fixed later
+  pages_obj=cfPDFOutAddXRef(pdf); // fixed later
   if (pages_obj!=1) {
     return 0;
   }
-  pdfOut_printf(pdf,"%%PDF-1.3\n");
+  cfPDFOutPrintF(pdf,"%%PDF-1.3\n");
   return 1;
 }
 // }}}
 
-void pdfOut_finish_pdf(pdfOut *pdf) // {{{
+void cfPDFOutFinishPDF(cf_pdf_out_t *pdf) // {{{
 {
   int iA;
   int root_obj,info_obj=0,xref_start;
@@ -198,21 +198,21 @@ void pdfOut_finish_pdf(pdfOut *pdf) // {{{
   // pages 
   const int pages_obj=1;
   pdf->xref[0]=pdf->filepos; // now fix it
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Type/Pages\n"
                     "  /Count %d\n"
                     "  /Kids [",
                     pages_obj,pdf->pagessize);
   for (iA=0;iA<pdf->pagessize;iA++) {
-    pdfOut_printf(pdf,"%d 0 R ",pdf->pages[iA]);
+    cfPDFOutPrintF(pdf,"%d 0 R ",pdf->pages[iA]);
   }
-  pdfOut_printf(pdf,"]\n"
+  cfPDFOutPrintF(pdf,"]\n"
                     ">>\n"
                     "endobj\n");
 
   // rootdict
-  root_obj=pdfOut_add_xref(pdf);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  root_obj=cfPDFOutAddXRef(pdf);
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Type/Catalog\n"
                     "  /Pages %d 0 R\n"
                     ">>\n"
@@ -221,40 +221,40 @@ void pdfOut_finish_pdf(pdfOut *pdf) // {{{
 
   // info 
   if (pdf->kvsize) {
-    info_obj=pdfOut_add_xref(pdf);
-    pdfOut_printf(pdf,"%d 0 obj\n"
+    info_obj=cfPDFOutAddXRef(pdf);
+    cfPDFOutPrintF(pdf,"%d 0 obj\n"
                       "<<\n",
                       info_obj);
     for (iA=0;iA<pdf->kvsize;iA++) {
-      pdfOut_printf(pdf,"  /%s ",pdf->kv[iA].key);
-      pdfOut_putString(pdf,pdf->kv[iA].value,-1);
-      pdfOut_printf(pdf,"\n");
+      cfPDFOutPrintF(pdf,"  /%s ",pdf->kv[iA].key);
+      cfPDFOutPutString(pdf,pdf->kv[iA].value,-1);
+      cfPDFOutPrintF(pdf,"\n");
     }
-    pdfOut_printf(pdf,">>\n"
+    cfPDFOutPrintF(pdf,">>\n"
                       "endobj\n");
   }
   // TODO: some return-value checking (??)
  
   // write xref
   xref_start=pdf->filepos;
-  pdfOut_printf(pdf,"xref\n"
+  cfPDFOutPrintF(pdf,"xref\n"
                     "%d %d\n"
                     "%010d 65535 f \n",
                     0,pdf->xrefsize+1,0);
   for (iA=0;iA<pdf->xrefsize;iA++) {
-    pdfOut_printf(pdf,"%010ld 00000 n \n",
+    cfPDFOutPrintF(pdf,"%010ld 00000 n \n",
                       pdf->xref[iA]);
   }
-  pdfOut_printf(pdf,"trailer\n"
+  cfPDFOutPrintF(pdf,"trailer\n"
                     "<<\n"
                     "  /Size %d\n"
                     "  /Root %d 0 R\n",
                     pdf->xrefsize+1,
                     root_obj);
   if (info_obj) {
-    pdfOut_printf(pdf,"  /Info %d 0 R\n",info_obj);
+    cfPDFOutPrintF(pdf,"  /Info %d 0 R\n",info_obj);
   }
-  pdfOut_printf(pdf,">>\n"
+  cfPDFOutPrintF(pdf,">>\n"
                     "startxref\n"
                     "%d\n"
                     "%%%%EOF\n",
@@ -270,7 +270,7 @@ void pdfOut_finish_pdf(pdfOut *pdf) // {{{
 }
 // }}}
 
-void pdfOut_free(pdfOut *pdf) // {{{
+void cfPDFOutFree(cf_pdf_out_t *pdf) // {{{
 {
   if (pdf) {
     assert(pdf->kvsize==0); // otherwise: finish_pdf has not been called
@@ -284,7 +284,7 @@ void pdfOut_free(pdfOut *pdf) // {{{
 
 static void pdfOut_outfn(const char *buf,int len,void *context) // {{{
 {
-  pdfOut *pdf=(pdfOut *)context;
+  cf_pdf_out_t *pdf=(cf_pdf_out_t *)context;
 
   if (fwrite(buf,1,len,stdout)!=len) {
     perror("Short write");
@@ -295,7 +295,7 @@ static void pdfOut_outfn(const char *buf,int len,void *context) // {{{
 }
 // }}}
 
-int pdfOut_write_font(pdfOut *pdf,EMB_PARAMS *emb) // {{{ 
+int cfPDFOutWriteFont(cf_pdf_out_t *pdf,EMB_PARAMS *emb) // {{{ 
 {
   assert(pdf);
   assert(emb);
@@ -303,13 +303,13 @@ int pdfOut_write_font(pdfOut *pdf,EMB_PARAMS *emb) // {{{
   EMB_PDF_FONTDESCR *fdes=emb_pdf_fontdescr(emb);
   if (!fdes) {
     if (emb->outtype==EMB_FMT_STDFONT) { // std-14 font
-      const int f_obj=pdfOut_add_xref(pdf);
+      const int f_obj=cfPDFOutAddXRef(pdf);
       char *res=emb_pdf_simple_stdfont(emb);
       if (!res) {
         return 0;
       }
 
-      pdfOut_printf(pdf,"%d 0 obj\n"
+      cfPDFOutPrintF(pdf,"%d 0 obj\n"
                         "%s"
                         "endobj\n"
                         ,f_obj,res);
@@ -319,54 +319,54 @@ int pdfOut_write_font(pdfOut *pdf,EMB_PARAMS *emb) // {{{
     return 0;
   }
 
-  const int ff_obj=pdfOut_add_xref(pdf);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  const int ff_obj=cfPDFOutAddXRef(pdf);
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Length %d 0 R\n"
                     ,ff_obj,ff_obj+1);
   if (emb_pdf_get_fontfile_subtype(emb)) {
-    pdfOut_printf(pdf,"  /Subtype /%s\n",
+    cfPDFOutPrintF(pdf,"  /Subtype /%s\n",
                       emb_pdf_get_fontfile_subtype(emb));
   }
   if (emb->outtype==EMB_FMT_TTF) {
-    pdfOut_printf(pdf,"  /Length1 %d 0 R\n"
+    cfPDFOutPrintF(pdf,"  /Length1 %d 0 R\n"
                       ,ff_obj+2);
   } else if (emb->outtype==EMB_FMT_T1) { // TODO
-    pdfOut_printf(pdf,"  /Length1 ?\n"
+    cfPDFOutPrintF(pdf,"  /Length1 ?\n"
                       "  /Length2 ?\n"
                       "  /Length3 ?\n"
                       );
   }
-  pdfOut_printf(pdf,">>\n"
+  cfPDFOutPrintF(pdf,">>\n"
                     "stream\n");
   long streamsize=-pdf->filepos;
   const int outlen=emb_embed(emb,pdfOut_outfn,pdf);
   streamsize+=pdf->filepos;
-  pdfOut_printf(pdf,"\nendstream\n"
+  cfPDFOutPrintF(pdf,"\nendstream\n"
                     "endobj\n");
 
-  const int l0_obj=pdfOut_add_xref(pdf);
+  const int l0_obj=cfPDFOutAddXRef(pdf);
   assert(l0_obj==ff_obj+1);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "%ld\n"
                     "endobj\n"
                     ,l0_obj,streamsize);
 
   if (emb->outtype==EMB_FMT_TTF) {
-    const int l1_obj=pdfOut_add_xref(pdf);
+    const int l1_obj=cfPDFOutAddXRef(pdf);
     assert(l1_obj==ff_obj+2);
-    pdfOut_printf(pdf,"%d 0 obj\n"
+    cfPDFOutPrintF(pdf,"%d 0 obj\n"
                       "%d\n"
                       "endobj\n"
                       ,l1_obj,outlen);
   }
 
-  const int fd_obj=pdfOut_add_xref(pdf);
+  const int fd_obj=cfPDFOutAddXRef(pdf);
   char *res=emb_pdf_simple_fontdescr(emb,fdes,ff_obj);
   if (!res) {
     free(fdes);
     return 0;
   }
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "%s"
                     "endobj\n"
                     ,fd_obj,res);
@@ -377,14 +377,14 @@ int pdfOut_write_font(pdfOut *pdf,EMB_PARAMS *emb) // {{{
     free(fdes);
     return 0;
   }
-  const int f_obj=pdfOut_add_xref(pdf);
+  const int f_obj=cfPDFOutAddXRef(pdf);
   res=emb_pdf_simple_font(emb,fdes,fwid,fd_obj);
   if (!res) {
     free(fwid);
     free(fdes);
     return 0;
   }
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "%s"
                     "endobj\n"
                     ,f_obj,res);
@@ -397,8 +397,8 @@ int pdfOut_write_font(pdfOut *pdf,EMB_PARAMS *emb) // {{{
       free(fdes);
       return 0;
     }
-    const int cf_obj=pdfOut_add_xref(pdf);
-    pdfOut_printf(pdf,"%d 0 obj\n"
+    const int cf_obj=cfPDFOutAddXRef(pdf);
+    cfPDFOutPrintF(pdf,"%d 0 obj\n"
                       "%s"
                       "endobj\n"
                       ,cf_obj,res);
@@ -416,7 +416,7 @@ int pdfOut_write_font(pdfOut *pdf,EMB_PARAMS *emb) // {{{
 one_page(...parent,resources,mediabox,contents);
 {
 //                    "  /Resources %d 0 R\n"
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Type/Page\n"
                     "  /Parent 1 0 R\n"
                     "  /MediaBox [0 0 %d %d]\n"
index 7c53477de7daba94029d0ffb1caca53e5156dc12..48998f64302cb845f63df3307226d655ddf14576 100644 (file)
@@ -8,8 +8,9 @@
  *
  */
 #include <time.h>
+#include <fontembed/embed.h>
 
-struct keyval_t {
+struct cf_keyval_t {
   char *key,*value;
 };
 
@@ -23,58 +24,57 @@ typedef struct {
   long *xref;
 
   int kvsize,kvalloc;
-  struct keyval_t *kv;
-} pdfOut;
+  struct cf_keyval_t *kv;
+} cf_pdf_out_t;
 
-/* allocates a new pdfOut structure
+/* allocates a new cf_pdf_out_t structure
  * returns NULL on error
  */
-pdfOut *pdfOut_new();
-void pdfOut_free(pdfOut *pdf);
+cf_pdf_out_t *cfPDFOutNew();
+void cfPDFOutFree(cf_pdf_out_t *pdf);
 
 /* start outputting a pdf
  * returns false on error
  */
-int pdfOut_begin_pdf(pdfOut *pdf);
-void pdfOut_finish_pdf(pdfOut *pdf);
+int cfPDFOutBeginPDF(cf_pdf_out_t *pdf);
+void cfPDFOutFinishPDF(cf_pdf_out_t *pdf);
 
 /* General output routine for our pdf.
  * Keeps track of characters actually written out
  */
-void pdfOut_printf(pdfOut *pdf,const char *fmt,...)
+void cfPDFOutPrintF(cf_pdf_out_t *pdf,const char *fmt,...)
   __attribute__((format(printf, 2, 3)));
 
 /* write out an escaped pdf string: e.g.  (Text \(Test\)\n)
  * >len==-1: use strlen(str) 
  */
-void pdfOut_putString(pdfOut *pdf,const char *str,int len);
-void pdfOut_putHexString(pdfOut *pdf,const char *str,int len);
+void cfPDFOutPutString(cf_pdf_out_t *pdf,const char *str,int len);
+void cfPDFOutPutHexString(cf_pdf_out_t *pdf,const char *str,int len);
 
 /* Format the broken up timestamp according to
  * pdf requirements for /CreationDate
  * NOTE: uses statically allocated buffer 
  */
-const char *pdfOut_to_pdfdate(struct tm *curtm);
+const char *cfPDFOutToPDFDate(struct tm *curtm);
 
 /* begin a new object at current point of the 
  * output stream and add it to the xref table.
  * returns the obj number.
  */
-int pdfOut_add_xref(pdfOut *pdf);
+int cfPDFOutAddXRef(cf_pdf_out_t *pdf);
 
 /* adds page dictionary >obj to the global Pages tree
  * returns false on error
  */
-int pdfOut_add_page(pdfOut *pdf,int obj);
+int cfPDFOutAddPage(cf_pdf_out_t *pdf,int obj);
 
 /* add a >key,>val pair to the document's Info dictionary
  * returns false on error
  */
-int pdfOut_add_kv(pdfOut *pdf,const char *key,const char *val);
+int cfPDFOutAddKeyValue(cf_pdf_out_t *pdf,const char *key,const char *val);
 
 /* Writes the font >emb including descriptor to the pdf 
  * and returns the object number.
  * On error 0 is returned.
  */
-struct _EMB_PARAMS;
-int pdfOut_write_font(pdfOut *pdf,struct _EMB_PARAMS *emb);
+int cfPDFOutWriteFont(cf_pdf_out_t *pdf,struct _EMB_PARAMS *emb);
index e9d59b0e73f7dc4ec3daeac98f2beeca7a4a1558..57e12806bb543efed4a686aa9afb11fd202f8fca 100644 (file)
@@ -489,7 +489,7 @@ typedef struct texttopdf_doc_s
   unsigned char        Codes[65536];   /* Unicode glyph mapping to font */
   int          Widths[256];    /* Widths of each font */
   int          Directions[256];/* Text directions for each font */
-  pdfOut       *pdf;
+  cf_pdf_out_t *pdf;
   int          FontResource;   /* Object number of font resource dictionary */
   float                FontScaleX, FontScaleY; /* The font matrix */
   lchar_t      *Title, *Date;  /* The title and date strings */
@@ -1601,7 +1601,7 @@ WriteEpilogue(texttopdf_doc_t *doc)
       if ((!emb->subset) ||
          (bits_used(emb->subset, emb->font->sfnt->numGlyphs)))
       {
-        emb->font->fobj=pdfOut_write_font(doc->pdf,emb);
+        emb->font->fobj=cfPDFOutWriteFont(doc->pdf,emb);
         assert(emb->font->fobj);
       }
     }
@@ -1613,7 +1613,7 @@ WriteEpilogue(texttopdf_doc_t *doc)
 
   // now fix FontResource
   doc->pdf->xref[doc->FontResource-1]=doc->pdf->filepos;
-  pdfOut_printf(doc->pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(doc->pdf,"%d 0 obj\n"
                     "<<\n",
                     doc->FontResource);
 
@@ -1624,17 +1624,17 @@ WriteEpilogue(texttopdf_doc_t *doc)
       EMB_PARAMS *emb=doc->Fonts[j][i];
       if (emb->font->fobj) // used
       {
-        pdfOut_printf(doc->pdf,"  /%s%02x %d 0 R\n",names[i],j,emb->font->fobj);
+        cfPDFOutPrintF(doc->pdf,"  /%s%02x %d 0 R\n",names[i],j,emb->font->fobj);
       }
     }
   }
 
-  pdfOut_printf(doc->pdf,">>\n"
+  cfPDFOutPrintF(doc->pdf,">>\n"
                     "endobj\n");
 
-  pdfOut_finish_pdf(doc->pdf);
+  cfPDFOutFinishPDF(doc->pdf);
 
-  pdfOut_free(doc->pdf);
+  cfPDFOutFree(doc->pdf);
 }
 
 /*
@@ -1646,8 +1646,8 @@ WritePage(texttopdf_doc_t *doc)
 {
   int  line;                   /* Current line */
 
-  int content=pdfOut_add_xref(doc->pdf);
-  pdfOut_printf(doc->pdf,"%d 0 obj\n"
+  int content=cfPDFOutAddXRef(doc->pdf);
+  cfPDFOutPrintF(doc->pdf,"%d 0 obj\n"
                "<</Length %d 0 R\n"
                ">>\n"
                "stream\n"
@@ -1663,19 +1663,19 @@ WritePage(texttopdf_doc_t *doc)
     write_line(line, doc->Page[line], doc);
 
   size+= ((doc->pdf->filepos)+2);
-  pdfOut_printf(doc->pdf,"Q\n"
+  cfPDFOutPrintF(doc->pdf,"Q\n"
                "endstream\n"
                "endobj\n");
   
-  int len_obj=pdfOut_add_xref(doc->pdf);
+  int len_obj=cfPDFOutAddXRef(doc->pdf);
   assert(len_obj==content+1);
-  pdfOut_printf(doc->pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(doc->pdf,"%d 0 obj\n"
                "%ld\n"
                "endobj\n",
                len_obj,size);
 
-  int obj=pdfOut_add_xref(doc->pdf);
-  pdfOut_printf(doc->pdf,"%d 0 obj\n"
+  int obj=cfPDFOutAddXRef(doc->pdf);
+  cfPDFOutPrintF(doc->pdf,"%d 0 obj\n"
                "<</Type/Page\n"
                "  /Parent 1 0 R\n"
                "  /MediaBox [0 0 %.0f %.0f]\n"
@@ -1685,7 +1685,7 @@ WritePage(texttopdf_doc_t *doc)
                "endobj\n",
                obj,doc->PageWidth, doc->PageLength, content,
                doc->FontResource);
-  pdfOut_add_page(doc->pdf,obj);
+  cfPDFOutAddPage(doc->pdf,obj);
 
   memset(doc->Page[0], 0,
         sizeof(lchar_t) * (doc->SizeColumns) * (doc->SizeLines));
@@ -1771,22 +1771,22 @@ WriteProlog(const char *title,          /* I - Title of job */
   */
 
   assert(!(doc->pdf));
-  doc->pdf = pdfOut_new();
+  doc->pdf = cfPDFOutNew();
   assert(doc->pdf);
 
-  pdfOut_begin_pdf(doc->pdf);
-  pdfOut_printf(doc->pdf,"%%cupsRotation: %d\n",
+  cfPDFOutBeginPDF(doc->pdf);
+  cfPDFOutPrintF(doc->pdf,"%%cupsRotation: %d\n",
                (doc->Orientation & 3) * 90); // TODO?
 
-  pdfOut_add_kv(doc->pdf,"Creator","texttopdf/" PACKAGE_VERSION);
+  cfPDFOutAddKeyValue(doc->pdf,"Creator","texttopdf/" PACKAGE_VERSION);
 
   curtime = time(NULL);
   curtm   = localtime(&curtime);
   strftime(curdate, sizeof(curdate), "%c", curtm);
 
-  pdfOut_add_kv(doc->pdf,"CreationDate",pdfOut_to_pdfdate(curtm));
-  pdfOut_add_kv(doc->pdf,"Title",title);
-  pdfOut_add_kv(doc->pdf,"Author",user); // was(PostScript): /For
+  cfPDFOutAddKeyValue(doc->pdf,"CreationDate",cfPDFOutToPDFDate(curtm));
+  cfPDFOutAddKeyValue(doc->pdf,"Title",title);
+  cfPDFOutAddKeyValue(doc->pdf,"Author",user); // was(PostScript): /For
   // }}}
 
  /*
@@ -2273,7 +2273,7 @@ WriteProlog(const char *title,            /* I - Title of job */
   doc->FontScaleY=68.0 / (doc->LinesPerInch);
 
   // allocate now, for pages to use. will be fixed in epilogue
-  doc->FontResource=pdfOut_add_xref(doc->pdf);
+  doc->FontResource=cfPDFOutAddXRef(doc->pdf);
 
   if (doc->PrettyPrint)
   {
@@ -2507,7 +2507,7 @@ write_string(int     col, /* I - Start column */
     y -= 36.0 / (float)(doc->LinesPerInch);
 
   if (attr & ATTR_UNDERLINE)
-    pdfOut_printf(doc->pdf,"q 0.5 w 0 g %.3f %.3f m %.3f %.3f l S Q ",
+    cfPDFOutPrintF(doc->pdf,"q 0.5 w 0 g %.3f %.3f m %.3f %.3f l S Q ",
                       x, y - 6.8 / (doc->LinesPerInch),
                       x + (float)len * 72.0 / (float)(doc->CharsPerInch),
                       y - 6.8 / (doc->LinesPerInch));
@@ -2516,22 +2516,22 @@ write_string(int     col,       /* I - Start column */
   {
     if (doc->ColorDevice) {
       if (attr & ATTR_RED)
-        pdfOut_printf(doc->pdf,"0.5 0 0 rg\n");
+        cfPDFOutPrintF(doc->pdf,"0.5 0 0 rg\n");
       else if (attr & ATTR_GREEN)
-        pdfOut_printf(doc->pdf,"0 0.5 0 rg\n");
+        cfPDFOutPrintF(doc->pdf,"0 0.5 0 rg\n");
       else if (attr & ATTR_BLUE)
-        pdfOut_printf(doc->pdf,"0 0 0.5 rg\n");
+        cfPDFOutPrintF(doc->pdf,"0 0 0.5 rg\n");
       else
-        pdfOut_printf(doc->pdf,"0 g\n");
+        cfPDFOutPrintF(doc->pdf,"0 g\n");
     } else {
       if ( (attr & ATTR_RED)||(attr & ATTR_GREEN)||(attr & ATTR_BLUE) )
-        pdfOut_printf(doc->pdf,"0.2 g\n");
+        cfPDFOutPrintF(doc->pdf,"0.2 g\n");
       else
-        pdfOut_printf(doc->pdf,"0 g\n");
+        cfPDFOutPrintF(doc->pdf,"0 g\n");
     }
   }
   else
-    pdfOut_printf(doc->pdf,"0 g\n");
+    cfPDFOutPrintF(doc->pdf,"0 g\n");
   
   write_font_str(x,y,attr & ATTR_FONT,s,len, doc);
 }
@@ -2548,17 +2548,17 @@ static void write_font_str(float x,float y,int fontid, lchar_t *str,
   if (len==-1) {
     for (len=0;str[len].ch;len++);
   }
-  pdfOut_printf(doc->pdf,"BT\n");
+  cfPDFOutPrintF(doc->pdf,"BT\n");
 
   if (x == (int)x)
-    pdfOut_printf(doc->pdf,"  %.0f ", x);
+    cfPDFOutPrintF(doc->pdf,"  %.0f ", x);
   else
-    pdfOut_printf(doc->pdf,"  %.3f ", x);
+    cfPDFOutPrintF(doc->pdf,"  %.3f ", x);
 
   if (y == (int)y)
-    pdfOut_printf(doc->pdf,"%.0f Td\n", y);
+    cfPDFOutPrintF(doc->pdf,"%.0f Td\n", y);
   else
-    pdfOut_printf(doc->pdf,"%.3f Td\n", y);
+    cfPDFOutPrintF(doc->pdf,"%.3f Td\n", y);
 
   int lastfont,font;
 
@@ -2581,7 +2581,7 @@ static void write_font_str(float x,float y,int fontid, lchar_t *str,
 
     if (otf) // TODO?
     {
-      pdfOut_printf(doc->pdf,"  %.3f Tz\n",
+      cfPDFOutPrintF(doc->pdf,"  %.3f Tz\n",
                    doc->FontScaleX * 600.0 /
                    (otf_get_width(otf, 4) * 1000.0 /
                     otf->unitsPerEm) * 100.0 / (doc->FontScaleY)); // TODO? 
@@ -2591,11 +2591,11 @@ static void write_font_str(float x,float y,int fontid, lchar_t *str,
     }
     else
     {
-      pdfOut_printf(doc->pdf,"  %.3f Tz\n",
+      cfPDFOutPrintF(doc->pdf,"  %.3f Tz\n",
                    doc->FontScaleX*100.0/(doc->FontScaleY)); // TODO?
     }
 
-    pdfOut_printf(doc->pdf,"  /%s%02x %.3f Tf <",
+    cfPDFOutPrintF(doc->pdf,"  /%s%02x %.3f Tf <",
                  names[fontid],lastfont,doc->FontScaleY);
 
     while (len > 0)
@@ -2619,20 +2619,20 @@ static void write_font_str(float x,float y,int fontid, lchar_t *str,
       if (otf) // TODO
       {
         const unsigned short gid=emb_get(emb,ch);
-        pdfOut_printf(doc->pdf, "%04x", gid);
+        cfPDFOutPrintF(doc->pdf, "%04x", gid);
       }
       else // std 14 font with 7-bit us-ascii uses single byte encoding, TODO
       {
-        pdfOut_printf(doc->pdf, "%02x", ch);
+        cfPDFOutPrintF(doc->pdf, "%02x", ch);
       }
 
       len --;
       str ++;
     }
 
-    pdfOut_printf(doc->pdf,"> Tj\n");
+    cfPDFOutPrintF(doc->pdf,"> Tj\n");
   }
-  pdfOut_printf(doc->pdf,"ET\n");
+  cfPDFOutPrintF(doc->pdf,"ET\n");
 }
 // }}}
 
@@ -2648,7 +2648,7 @@ static float stringwidth_x(lchar_t *str, texttopdf_doc_t * doc)
 static void write_pretty_header(texttopdf_doc_t *doc) // {{{
 {
   float x,y;
-  pdfOut_printf(doc->pdf,"q\n"
+  cfPDFOutPrintF(doc->pdf,"q\n"
                "0.9 g\n");
 
   if (doc->Duplex && (doc->NumPages & 1) == 0)
@@ -2662,10 +2662,10 @@ static void write_pretty_header(texttopdf_doc_t *doc) // {{{
     y = doc->PageTop + 72.0f / (doc->LinesPerInch);
   }
 
-  pdfOut_printf(doc->pdf,"1 0 0 1 %.3f %.3f cm\n",x,y); // translate
-  pdfOut_printf(doc->pdf,"0 0 %.3f %.3f re f\n",
+  cfPDFOutPrintF(doc->pdf,"1 0 0 1 %.3f %.3f cm\n",x,y); // translate
+  cfPDFOutPrintF(doc->pdf,"0 0 %.3f %.3f re f\n",
                doc->PageRight - doc->PageLeft, 144.0f / (doc->LinesPerInch));
-  pdfOut_printf(doc->pdf,"0 g 0 G\n");
+  cfPDFOutPrintF(doc->pdf,"0 g 0 G\n");
 
   if (doc->Duplex && (doc->NumPages & 1) == 0)
   {
@@ -2701,6 +2701,6 @@ static void write_pretty_header(texttopdf_doc_t *doc) // {{{
   write_font_str(x, y, ATTR_BOLD, pagestr, -1, doc);
   free(pagestr);
 
-  pdfOut_printf(doc->pdf, "Q\n");
+  cfPDFOutPrintF(doc->pdf, "Q\n");
 }
 // }}}
index 0fadea4a77186a91d316b276142371d963822f55..1ed6f29e3912cd9d18985aa3cef88b4129860771 100644 (file)
@@ -4,16 +4,16 @@
 
 int main()
 {
-  pdfOut *pdf;
+  cf_pdf_out_t *pdf;
 
-  pdf=pdfOut_new();
+  pdf=cfPDFOutNew();
   assert(pdf);
 
-  pdfOut_begin_pdf(pdf);
+  cfPDFOutBeginPDF(pdf);
 
   // bad font
-  int font_obj=pdfOut_add_xref(pdf);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  int font_obj=cfPDFOutAddXRef(pdf);
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Type/Font\n"
                     "  /Subtype /Type1\n" // /TrueType,/Type3
                     "  /BaseFont /%s\n"
@@ -22,9 +22,9 @@ int main()
                     ,font_obj,"Courier");
   // test
   const int PageWidth=595,PageLength=842;
-  int cobj=pdfOut_add_xref(pdf);
+  int cobj=cfPDFOutAddXRef(pdf);
   const char buf[]="BT /a 10 Tf (abc) Tj ET";
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Length %d\n"
                     ">>\n"
                     "stream\n"
@@ -33,8 +33,8 @@ int main()
                     "endobj\n"
                     ,cobj,strlen(buf),buf);
 
-  int obj=pdfOut_add_xref(pdf);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  int obj=cfPDFOutAddXRef(pdf);
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Type/Page\n"
                     "  /Parent 1 0 R\n"
                     "  /MediaBox [0 0 %d %d]\n"
@@ -43,10 +43,10 @@ int main()
                     ">>\n"
                     "endobj\n"
                     ,obj,PageWidth,PageLength,cobj,font_obj); // TODO: into pdf->
-  pdfOut_add_page(pdf,obj);
-  pdfOut_finish_pdf(pdf);
+  cfPDFOutAddPage(pdf,obj);
+  cfPDFOutFinishPDF(pdf);
 
-  pdfOut_free(pdf);
+  cfPDFOutFree(pdf);
 
   return 0;
 }
index 3d58a59d004f00e567f561da355d8d7a0fa7efff..85524ba4774dc624c41c73aacf16040a10641824 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <stdio.h>
 
-static inline void write_string(pdfOut *pdf,EMB_PARAMS *emb,const char *str) // {{{
+static inline void write_string(cf_pdf_out_t *pdf,EMB_PARAMS *emb,const char *str) // {{{
 {
   assert(pdf);
   assert(emb);
@@ -25,19 +25,19 @@ static inline void write_string(pdfOut *pdf,EMB_PARAMS *emb,const char *str) //
       emb_get(emb,(unsigned char)str[iA]);
       // TODO: pdf: otf_from_pdf_default_encoding
     }
-    pdfOut_putString(pdf,str,-1);
+    cfPDFOutPutString(pdf,str,-1);
   }
 }
 // }}}
 
 int main()
 {
-  pdfOut *pdf;
+  cf_pdf_out_t *pdf;
 
-  pdf=pdfOut_new();
+  pdf=cfPDFOutNew();
   assert(pdf);
 
-  pdfOut_begin_pdf(pdf);
+  cfPDFOutBeginPDF(pdf);
 
   // font, pt.1 
   const char *fn=TESTFONT;
@@ -62,33 +62,33 @@ int main()
 
   // test
   const int PageWidth=595,PageLength=842;
-  const int cobj=pdfOut_add_xref(pdf);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  const int cobj=cfPDFOutAddXRef(pdf);
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Length %d 0 R\n"
                     ">>\n"
                     "stream\n"
                     ,cobj,cobj+1);
   long streamlen=-pdf->filepos;
-  pdfOut_printf(pdf,"BT /a 10 Tf ");
+  cfPDFOutPrintF(pdf,"BT /a 10 Tf ");
   write_string(pdf,emb,"Test");
-  pdfOut_printf(pdf," Tj ET");
+  cfPDFOutPrintF(pdf," Tj ET");
 
   streamlen+=pdf->filepos;
-  pdfOut_printf(pdf,"\nendstream\n"
+  cfPDFOutPrintF(pdf,"\nendstream\n"
                     "endobj\n");
-  const int clobj=pdfOut_add_xref(pdf);
+  const int clobj=cfPDFOutAddXRef(pdf);
   assert(clobj==cobj+1);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "%d\n"
                     "endobj\n"
                     ,clobj,streamlen);
 
   // font
-  int font_obj=pdfOut_write_font(pdf,emb);
+  int font_obj=cfPDFOutWriteFont(pdf,emb);
   assert(font_obj);
 
-  int obj=pdfOut_add_xref(pdf);
-  pdfOut_printf(pdf,"%d 0 obj\n"
+  int obj=cfPDFOutAddXRef(pdf);
+  cfPDFOutPrintF(pdf,"%d 0 obj\n"
                     "<</Type/Page\n"
                     "  /Parent 1 0 R\n"
                     "  /MediaBox [0 0 %d %d]\n"
@@ -97,10 +97,10 @@ int main()
                     ">>\n"
                     "endobj\n"
                     ,obj,PageWidth,PageLength,cobj,font_obj); // TODO: into pdf->
-  pdfOut_add_page(pdf,obj);
-  pdfOut_finish_pdf(pdf);
+  cfPDFOutAddPage(pdf,obj);
+  cfPDFOutFinishPDF(pdf);
 
-  pdfOut_free(pdf);
+  cfPDFOutFree(pdf);
 
   emb_close(emb);