Back to index

texmacs  1.0.7.15
Defines | Functions | Variables
printer.cpp File Reference
#include "printer.hpp"
#include "Metafont/tex_files.hpp"
#include "Freetype/tt_file.hpp"
#include "file.hpp"
#include "image_files.hpp"
#include "analyze.hpp"
#include "iterator.hpp"
#include "merge_sort.hpp"
#include "scheme.hpp"

Go to the source code of this file.

Defines

#define HEX_PER_LINE   30

Functions

static string prepare_text (string s)
static string find_ps_font_name (string name, string s)
static SI parse_length (string pfb, int &pos)
static string pfb_to_pfa (url file)
renderer printer (url ps_file_name, int dpi, int nr_pages, string page_type, bool landscape, double paper_w, double paper_h)

Variables

string PS_CLIP_PUSH ("gsave")
string PS_CLIP_POP ("grestore")
string PS_CLIP ("cl")
string PS_LINE ("ln")
string PS_FILL ("fl")
string PS_ARC ("ac")
string PS_FILL_ARC ("fac")
string PS_STROKE ("st")
string PS_POL_START ("sp")
string PS_POL_NEXT ("np")
string PS_POL_END ("ep")
string PS1 ("u")
string PS2 ("z")
static const char * hex_string = "0123456789ABCDEF"

Define Documentation

#define HEX_PER_LINE   30

Definition at line 387 of file printer.cpp.


Function Documentation

static string find_ps_font_name ( string  name,
string  s 
) [static]

Definition at line 372 of file printer.cpp.

                                          {
  int i, n= N(s);
  for (i=0; i<n; i++) {
    if (test (s, i, "/FontName /")) {
      i += 11;
      int start= i;
      while (i<n && s[i] != ' ') i++;
      return s (start, i);
    }
    while (i<n && s[i] != '\12' && s[i] != '\15') i++;
  }
  return name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SI parse_length ( string  pfb,
int &  pos 
) [static]

Definition at line 389 of file printer.cpp.

                                              {
  QN c4= (QN) pfb[pos++];
  QN c3= (QN) pfb[pos++];
  QN c2= (QN) pfb[pos++];
  QI c1= (QI) pfb[pos++];
  return (((((((SI) c1)<<8)+ ((SI) c2))<<8)+ ((SI) c3))<<8)+ c4;
}

Here is the caller graph for this function:

static string pfb_to_pfa ( url  file) [static]

Definition at line 397 of file printer.cpp.

                                    {
  //cout << "pfb_to_pfa :" << file << LF;
  string pfb, pfa;
  QN magic, type = 0;
  SI length;
  
  (void) load_string (file, pfb, true);
  int pos = 0, size = N(pfb);
  while ((pos < size) && (type != 3)) {
    parse (pfb, pos, magic);
    //cout << "magic:" << as_hexadecimal(magic,2) << LF ;
    if (magic != 128) {
      FAILED ("Not a pfb file");
    }
    parse (pfb, pos, type);
    //cout << "type:" << as_hexadecimal(type,2) << LF;
    switch (type) {
        
      case 1 :
        // plain text
        length = parse_length (pfb, pos);
        // parse (pfb, pos, length);
        //cout << "plain text of size " << length << LF;
        for (int i=0; i <length; i++) {
          QI ch;
          parse(pfb, pos, ch);
          if (ch == '\r') pfa << "\n";
          else pfa << ch;
        }
        break;
        
      case 2 :
        // binary data
        length = parse_length (pfb, pos);
        //        parse (pfb, pos, length);
        //cout << "binary data of size " << length << LF;
        for (int i=0; i <length; i++) {
          QI ch;
          parse(pfb, pos, ch);
          pfa << as_hexadecimal (ch, 2);
          if ((i+1) % HEX_PER_LINE == 0) pfa << "\n"; 
        }
        break;
        
      case 3 :
        //cout << "end of file"  << LF;
        // end of file
        break;
        
      default : 
        FAILED ("Unknown field type while reading PFB file");
        break;
        
    }
  }
  return pfa;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string prepare_text ( string  s) [static]

Definition at line 292 of file printer.cpp.

                        {
  int i;
  string r;
  for (i=0; i<N(s); i++) {
    int c= ((unsigned char) s[i]);
    if ((s[i]=='(') || (s[i]==')') || (s[i]=='\\'))
      r << '\\' << s[i];
    else if ((c <= 32) || (c >= 128)) {
      r << '\\';
      r << ('0' + (c >> 6));
      r << ('0' + ((c >> 3) & 7));
      r << ('0' + (c & 7));
    }
    else r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

renderer printer ( url  ps_file_name,
int  dpi,
int  nr_pages,
string  page_type,
bool  landscape,
double  paper_w,
double  paper_h 
)

Definition at line 877 of file printer.cpp.

{
  page_type= as_string (call ("correct-paper-size", object (page_type)));
  return tm_new<printer_rep> (ps_file_name, dpi, nr_pages,
                              page_type, landscape, paper_w, paper_h);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char* hex_string = "0123456789ABCDEF" [static]

Definition at line 321 of file printer.cpp.

string PS1("u")
string PS2("z")
string PS_ARC("ac")
string PS_CLIP("cl")
string PS_CLIP_POP("grestore")
string PS_CLIP_PUSH("gsave")
string PS_FILL("fl")
string PS_LINE("ln")