[BACK]Return to term_ps.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/term_ps.c between version 1.13 and 1.15

version 1.13, 2010/06/28 13:45:28 version 1.15, 2010/06/28 23:26:09
Line 31 
Line 31 
 #include "main.h"  #include "main.h"
 #include "term.h"  #include "term.h"
   
   /* TODO: all this will go away with different paper sizes. */
   #define PS_CHAR_HEIGHT    12
   #define PS_CHAR_TOPMARG  (792 - 24)
   #define PS_CHAR_TOP      (PS_CHAR_TOPMARG - 36)
   #define PS_CHAR_LEFT      36
   #define PS_CHAR_BOTMARG   24
   #define PS_CHAR_BOT      (PS_CHAR_BOTMARG + 36)
   
 struct  glyph {  struct  glyph {
         int               wx; /* WX in AFM */          int               wx; /* WX in AFM */
 };  };
   
 #define MAXCHAR           95  
   
 struct  font {  struct  font {
         const char       *name; /* FontName in AFM */          const char       *name; /* FontName in AFM */
   #define MAXCHAR           95 /* total characters we can handle */
         struct glyph      gly[MAXCHAR]; /* glyph metrics */          struct glyph      gly[MAXCHAR]; /* glyph metrics */
 };  };
   
Line 342  static const struct font fonts[3] = {
Line 349  static const struct font fonts[3] = {
         } },          } },
 };  };
   
 #define PS_CHAR_HEIGHT    12  /* These work the buffer used by the header and footer. */
 #define PS_CHAR_TOPMARG  (792 - 24)  
 #define PS_CHAR_TOP      (PS_CHAR_TOPMARG - 36)  
 #define PS_CHAR_LEFT      36  
 #define PS_CHAR_BOTMARG   24  
 #define PS_CHAR_BOT      (PS_CHAR_BOTMARG + 36)  
   
 #define PS_BUFSLOP        128  #define PS_BUFSLOP        128
 #define PS_GROWBUF(p, sz) \  #define PS_GROWBUF(p, sz) \
         do if ((p)->engine.ps.psmargcur + (sz) > \          do if ((p)->engine.ps.psmargcur + (sz) > \
Line 387  ps_alloc(void)
Line 388  ps_alloc(void)
         if (NULL == (p = term_alloc(TERMENC_ASCII)))          if (NULL == (p = term_alloc(TERMENC_ASCII)))
                 return(NULL);                  return(NULL);
   
         p->defrmargin = 78;          p->defrmargin = 612 - (PS_CHAR_LEFT * 2);
         p->tabwidth = 5;  
   
         p->type = TERMTYPE_PS;          p->type = TERMTYPE_PS;
         p->letter = ps_letter;          p->letter = ps_letter;
Line 551  ps_begin(struct termp *p)
Line 551  ps_begin(struct termp *p)
 static void  static void
 ps_pletter(struct termp *p, int c)  ps_pletter(struct termp *p, int c)
 {  {
           int              f;
   
         /*          /*
          * If we're not in a PostScript "word" context, then open one           * If we're not in a PostScript "word" context, then open one
Line 585  ps_pletter(struct termp *p, int c)
Line 586  ps_pletter(struct termp *p, int c)
   
         /* Write the character and adjust where we are on the page. */          /* Write the character and adjust where we are on the page. */
   
         /*          f = (int)p->engine.ps.lastf;
          * FIXME: at this time we emit only blacnks on non-ASCII  
          * letters.  
          */  
   
         if (c < 32 || (c - 32 > MAXCHAR)) {          if (c <= 32 || (c - 32 > MAXCHAR)) {
                 ps_putchar(p, ' ');                  ps_putchar(p, ' ');
                 p->engine.ps.pscol +=                  p->engine.ps.pscol += (fonts[f].gly[0].wx / 100);
                         (fonts[p->engine.ps.lastf].gly[32].wx / 100);  
                 return;                  return;
         }          }
   
         ps_putchar(p, c);          ps_putchar(p, c);
         p->engine.ps.pscol +=          c -= 32;
                 (fonts[p->engine.ps.lastf].gly[(int)c - 32].wx / 100);          p->engine.ps.pscol += (fonts[f].gly[c].wx / 100);
 }  }
   
   
Line 709  ps_advance(struct termp *p, size_t len)
Line 706  ps_advance(struct termp *p, size_t len)
          */           */
   
         ps_fclose(p);          ps_fclose(p);
         p->engine.ps.pscol += 0 == len ? 0 :          p->engine.ps.pscol += len;
                 len * (fonts[p->engine.ps.lastf].gly[0].wx / 100);  
 }  }
   
   
Line 763  static size_t
Line 759  static size_t
 ps_width(const struct termp *p, char c)  ps_width(const struct termp *p, char c)
 {  {
   
         return(1);          if (c <= 32 || c - 32 >= MAXCHAR)
                   return(fonts[(int)TERMFONT_NONE].gly[0].wx / 100);
   
           c -= 32;
           return(fonts[(int)TERMFONT_NONE].gly[(int)c].wx / 100);
 }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.15

CVSweb