Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 23, 2026

Diff for cpdf/svga.c between version 1.6 and 1.7

version 1.6, 2003/02/11 20:10:30 version 1.7, 2003/02/18 19:29:03
Line 11 
Line 11 
 #include "svga.h"  #include "svga.h"
 #include "utils.h"  #include "utils.h"
 #include "filter.h"  #include "filter.h"
   int x, y;
   float tfs;
   int w0 = 0,w1 = 0,tc = 0,th = 100,tw = 0;
 char *strndup(const char *s, size_t n);  char *strndup(const char *s, size_t n);
   
 void donothing(char *line)  void donothing(char *line)
Line 21  void donothing(char *line)
Line 23  void donothing(char *line)
   
 void text(char *line)  void text(char *line)
 {  {
         char *tj = NULL, delim[2];          int n;
         int x = 10, y = 10;          float uno_numero;
         if ((tj = strstr(line, "TJ")) != NULL) {          char *p = NULL,*dup;
                 delim[0] = ']';          if ((p = strstr(line, "Td")) != NULL) {
                 delim[1] = 'J';                          for(p -= 2;!isalpha(*p);p--);
                 while (*tj != '[')                          sscanf(p + 1,"%f %f Td",&trm[2][0],&trm[2][1]);
                         tj--;          }
         }          if ((p = strstr(line, "Tf")) != NULL) {
         if (!tj)                  for(p -= 2;*p != ' ';p--);
                 if ((tj = strstr(line, "Tj")) != NULL) {                  sscanf(p + 1,"%f Tf",&tfs);
                         delim[0] = ')';          }
                         delim[1] = 'j';          if ((p = strstr(line, "TJ")) != NULL) {
                         while (*tj != '(')                  while (*(p - 1) != '[')
                                 tj--;                          p--;
                   while (strncmp(p,"]TJ",3)) {
                           p++;
                           n = strchr(p,')') - p;
                           dup = strndup(p,n);
                           dup[n] = '\0';
                           p = strchr(p,')');
                           if(*(p + 1) != ']') {
                           n = sscanf(p, ")%f(", &uno_numero);
                           x = ((w0 - uno_numero / 1000) * tfs + tc + tw) * th;
                           y = (w1 - uno_numero / 1000) * tfs + tc + tw;
                           p += n + 1;
                           }
   #ifndef DEBUG
                           gl_writen(x, y, n, dup);
   #endif
                           p++;
                 }                  }
         if (!tj)          }
                 return;  
         tj++;          if ((p = strstr(line, "Tj")) != NULL) {
         while (*tj != delim[0] && *(tj + 1) != 'T'                  while (*(p - 1) != '(')
                && *(tj + 2) != delim[1]) {                          p--;
                   while (strncmp(p, ")Tj", 3)) {
 #ifndef DEBUG  #ifndef DEBUG
                 gl_writen(x, y, sizeof(char), tj);                          gl_writen(x, y, sizeof(char), p);
 #endif  #endif
                 x += 10;                          x += 10;
                 if (x == screen.x - 10) {                          if (x == screen.x - 10) {
                         x = 10;                                  x = 10;
                         y += 10;                                  y += 10;
                           }
                           if (y == screen.y - 10)
                                   y = 10;
                           p++;
                 }                  }
                 if (y == screen.y - 10)  
                         y = 10;  
                 tj++;  
         }          }
         return;  return;
 }  }
   
 void render(void)  void render(void)
Line 63  void render(void)
Line 83  void render(void)
         struct page *page;          struct page *page;
         void (*fun) (char *line) = donothing;          void (*fun) (char *line) = donothing;
         page = (struct page *) get_object(page_tree[current_page], NULL);          page = (struct page *) get_object(page_tree[current_page], NULL);
         if(!page)          if (!page)
                 return;                  return;
         dstlen = page->contents->length << 3;          dstlen = page->contents->length << 3;
         content = (char *) xcalloc((int) dstlen, sizeof(char));          content = (char *) xcalloc((int) dstlen, sizeof(char));
Line 73  void render(void)
Line 93  void render(void)
         gl_setfontcolors(0xFFFFFFFF, 0);          gl_setfontcolors(0xFFFFFFFF, 0);
 #endif  #endif
         if (page->contents->filter != -1) {          if (page->contents->filter != -1) {
                 filter(page->contents->filter, page->contents->stream,                  filter(page->contents->filter,
                          page->contents->stream,
                        page->contents->length, content, &dstlen);                         page->contents->length, content, &dstlen);
                 if (dstlen != page->contents->length << 3)                  if (dstlen != page->contents->length << 3)
                         content = (char *) realloc(content, dstlen);                          content = (char *) realloc(content, dstlen);
         }          }
         write(2, content, (int) dstlen);          write(2, content, (int) dstlen);
         p = content;          p = content;
           x = y = 10;
         while ((endline = strchr(p, '\n')) != NULL) {          while ((endline = strchr(p, '\n')) != NULL) {
                 dup = strndup(p, endline - p + 1);                  dup = strndup(p, endline - p + 1);
                 if (strstr(dup, "BT"))                  if (strstr(dup, "BT"))
                         fun = text;                          fun = text;
                 if (strstr(dup, "ET"))                  if (strstr(dup, "ET"))
                         fun = donothing;                          fun = donothing;
                   if (strstr(dup,"cm")) {
                           tlm[2][2] = 1.0;
                           sscanf(dup,"%f %f %f %f %f %f cm",
                                   &tlm[0][0],&tlm[0][1],&tlm[1][0],
                                   &tlm[1][1],&tlm[2][0],&tlm[2][1]);
                           fun = donothing;
                   }
                 fun(dup);                  fun(dup);
                 free(dup);                  free(dup);
                 p = endline + 1;                  p = endline + 1;
         }          }
 #ifndef DEBUG  #ifndef DEBUG
         gl_copyscreen(physicalscreen);          gl_copyscreen(physicalscreen);
           gl_clearscreen(0xFFFFFFFF);
 #endif  #endif
         free(content);          free(content);
         getchar();          getchar();

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top