OSDN Git Service

new pdf backend.
authormaqiyuan <maqiyuan@users.sourceforge.jp>
Sat, 3 May 2014 08:06:07 +0000 (16:06 +0800)
committermaqiyuan <maqiyuan@users.sourceforge.jp>
Sat, 3 May 2014 08:06:07 +0000 (16:06 +0800)
src/texsourc/itex.c
src/texsourc/makefile
src/texsourc/texd.h
src/texsourc/texmf.c
src/texsourc/yandy_pdf_backend.c [new file with mode: 0644]
src/texsourc/yandytex.h

index dea502c..830760e 100644 (file)
@@ -3014,9 +3014,7 @@ void primitive_ (str_number s, quarterword c, halfword o)
   eq_type(cur_val) = c;
   equiv(cur_val) = o;
 }
-#endif /* INITEX */
-
-/* more weird constants ? page 394 */
+#endif
 
 #ifdef INITEX
 /* sec 0944 */
@@ -4256,11 +4254,11 @@ void init_prim (void)
   primitive("skipdef", shorthand_def, 4);
   primitive("muskipdef", shorthand_def, 5);
   primitive("toksdef", shorthand_def, 6);
-  primitive("catcode", def_code, (hash_size + 1883));
-  primitive("mathcode", def_code, (hash_size + 2907));
-  primitive("lccode", def_code, (hash_size + 2139));
-  primitive("uccode", def_code, (hash_size + 2395));
-  primitive("sfcode", def_code, (hash_size + 2651));
+  primitive("catcode", def_code, cat_code_base);
+  primitive("mathcode", def_code, math_code_base);
+  primitive("lccode", def_code, lc_code_base);
+  primitive("uccode", def_code, uc_code_base);
+  primitive("sfcode", def_code, sf_code_base);
   primitive("delcode", def_code, (hash_size + 3474));
   primitive("textfont", def_family, (hash_size + 1835));
   primitive("scriptfont", def_family, (hash_size + 1851));
index 567549b..dab1724 100644 (file)
@@ -44,19 +44,23 @@ LFLAGS=/MAP
 objs = texmf.obj itex.obj openinou.obj subroute.obj local.obj \
        tex0.obj tex1.obj tex2.obj tex3.obj tex4.obj \
        tex5.obj tex6.obj tex7.obj tex8.obj tex9.obj \
-       yandy_pool.obj yandytex.res md5.obj md5file.obj
+       yandy_pool.obj yandytex.res md5.obj md5file.obj \
+       yandy_pdf_backend.obj
 
 # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
 
 texmf.exe: $(objs) 
        $(LINK) $(LFLAGS) texmf itex openinou subroute local \
        tex0 tex1 tex2 tex3 tex4 tex5 tex6 tex7 tex8 tex9 \
-       yandy_pool yandytex.res md5 md5file kpathsea\kpathsea.lib \
-       libharu\libhpdf.lib libpng\libpng.lib zlib\zlib.lib 
+       yandy_pool yandytex.res md5 md5file yandy_pdf_backend \
+       kpathsea\kpathsea.lib libharu\libhpdf.lib libpng\libpng.lib zlib\zlib.lib
        copy texmf.exe yandytex.exe
        del ..\yandy\bin\texmf.exe
        copy texmf.exe ..\yandy\bin\texmf.exe
 # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
+yandy_pdf_backend.obj: yandy_pdf_backend.c
+       $(CC) $(CFLAGS) yandy_pdf_backend.c
+
 md5.obj: libmd5\md5.c
        $(CC) -Ilibmd5 $(CFLAGS) libmd5\md5.c
 
index 4b5669b..bcd92b1 100644 (file)
@@ -2521,10 +2521,12 @@ extern int load_pool_strings (integer spare_size);
 #define help4(...)  tex_help(4, __VA_ARGS__)
 #define help5(...)  tex_help(5, __VA_ARGS__)
 #define help6(...)  tex_help(6, __VA_ARGS__)
+
 /********BINDING WITH LIBHARU*********/
 
 EXTERN HPDF_Doc  yandy_pdf;
 EXTERN HPDF_Page yandy_page;
 EXTERN HPDF_Font yandy_font;
+bool pdf_doing_string;
 
-/********BINDING WITH LIBHARU*********/
+/********BINDING WITH LIBHARU*********/
\ No newline at end of file
index eab366b..503dd53 100644 (file)
@@ -26,6 +26,7 @@
   #include <windows.h>
   #define MYLIBAPI __declspec(dllexport)
 #endif
+
 #pragma warning(disable:4996)
 #include <kpathsea/config.h>
 #include <kpathsea/c-ctype.h>
diff --git a/src/texsourc/yandy_pdf_backend.c b/src/texsourc/yandy_pdf_backend.c
new file mode 100644 (file)
index 0000000..f011522
--- /dev/null
@@ -0,0 +1,171 @@
+/* Copyright 2014 Clerk Ma
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301 USA.  */
+
+#ifdef _WINDOWS
+  #define NOCOMM
+  #define NOSOUND
+  #define NODRIVERS
+  #define STRICT
+  #pragma warning(disable:4115) // kill rpcasync.h complaint
+  #include <windows.h>
+  #define MYLIBAPI __declspec(dllexport)
+#endif
+
+#pragma warning(disable:4996)
+#pragma warning(disable:4131) // old style declarator
+#pragma warning(disable:4135) // conversion between different integral types
+#pragma warning(disable:4127) // conditional expression is constant
+
+#include <setjmp.h>
+
+#define EXTERN extern
+
+#include "texd.h"
+
+HPDF_Doc  yandy_pdf;
+HPDF_Page yandy_page;
+HPDF_Font yandy_font;
+
+void pdf_out(unsigned char i)
+{
+  char temp[2] = {i, '\0'};
+  HPDF_PageAttr attr = (HPDF_PageAttr) yandy_page->attr;
+  HPDF_Stream_WriteStr(attr->stream, temp);
+}
+
+void pdf_print_octal(integer n)
+{
+  unsigned int k = 0;
+
+  do
+    {
+      dig[k] = n % 8;
+      n = n / 8;
+      incr(k);
+    }
+  while (n != 0);
+
+  if (k == 1)
+  {
+    pdf_out('0');
+    pdf_out('0');
+  }
+
+  if (k == 2)
+  {
+    pdf_out('0');
+  }
+
+  while (k > 0)
+  {
+    decr(k);
+    pdf_out('0' + dig[k]);
+  }
+}
+
+void pdf_print_int(integer n)
+{
+  integer k;
+  integer m;
+
+  if (n < 0)
+  {
+    pdf_out('-');
+    if (n > -100000000)
+      n = -n;
+    else
+    {
+      m = -1 - n;
+      n = m / 10;
+      m = m % 10 + 1;
+      k = 1;
+      if (m < 10)
+        dig[0] = (char) m;
+      else
+      {
+        dig[0] = 0;
+        incr(n);
+      }
+    }
+  }
+  do
+    {
+      dig[k] = n % 10;
+      n = n / 10;
+      incr(k);
+    }
+  while (n != 0);
+
+  while (k > 0)
+  {
+    decr(k);
+    pdf_out('0' + dig[k]);
+  }
+}
+
+void pdf_print_char(unsigned char c)
+{
+  if ((c < 32) || (c == 92) || (c == 40) || (c == 41) || (c > 127))
+  {
+    pdf_out(92);
+    pdf_print_octal(c);
+  }
+  else
+  {
+    pdf_out(c);
+  }
+}
+
+void pdf_print_string(char * s)
+{
+  HPDF_PageAttr attr = (HPDF_PageAttr) yandy_page->attr;
+  HPDF_Stream_WriteStr(attr->stream, s);
+}
+
+void pdf_end_string(void)
+{
+  if (pdf_doing_string)
+  {
+    pdf_print_string(")] TJ\012");
+    pdf_doing_string = false;
+  }
+}
+
+void pdf_begin_string(void)
+{
+  scaled s;
+
+  s = cur_h - pdf_delta_h;
+
+  if (!pdf_doing_string)
+  {
+    pdf_print_string(" [");
+    if (s == 0)
+      pdf_out('(');
+  }
+
+  if (s != 0)
+  {
+    if (pdf_doing_string)
+      pdf_out(')');
+    pdf_print_int(-s);
+    pdf_out('(');
+    pdf_delta_h = cur_h;
+  }
+
+  pdf_doing_string = true;
+}
\ No newline at end of file
index 9652cf8..beb119a 100644 (file)
@@ -91,7 +91,6 @@ extern bool eoln (FILE * file);
 extern bool open_input (FILE **f, path_constant_type path_index, char *fopen_mode);
 extern bool open_output (FILE **f, char *fopen_mode);
 extern int check_fclose (FILE * f);
-extern void argv();
 
 #define show_line(str,flag) fputs(str,stdout)
 #define show_char(chr) putc(chr, stdout)