Beispiel #1
0
void ps_printer::encode_subfont(subencoding *sub)
{
  assert(sub->glyphs != 0);
  out.put_literal_symbol(make_subencoding_name(sub->idx))
     .put_delimiter('[');
  for (int i = 0; i < 256; i++)
  {
    if (sub->glyphs[i])
      out.put_literal_symbol(sub->glyphs[i]);
    else
      out.put_literal_symbol(".notdef");
  }
  out.put_delimiter(']')
     .put_symbol("def");
}
Beispiel #2
0
void ps_printer::define_encoding(const char *encoding, int encoding_index)
{
  char *vec[256];
  int i;
  for (i = 0; i < 256; i++)
    vec[i] = 0;
  char *path;
  FILE *fp = font::open_file(encoding, &path);
  if (fp == 0)
    fatal("can't open encoding file `%1'", encoding);
  int lineno = 1;
  const int BUFFER_SIZE = 512;
  char buf[BUFFER_SIZE];
  while (fgets(buf, BUFFER_SIZE, fp) != 0) {
    char *p = buf;
    while (csspace(*p))
      p++;
    if (*p != '#' && *p != '\0' && (p = strtok(buf, WS)) != 0) {
      char *q = strtok(0, WS);
      int n = 0;		// pacify compiler
      if (q == 0 || sscanf(q, "%d", &n) != 1 || n < 0 || n >= 256)
	fatal_with_file_and_line(path, lineno, "bad second field");
      vec[n] = new char[strlen(p) + 1];
      strcpy(vec[n], p);
    }
    lineno++;
  }
  a_delete path;
  out.put_literal_symbol(make_encoding_name(encoding_index))
     .put_delimiter('[');
  for (i = 0; i < 256; i++) {
    if (vec[i] == 0)
      out.put_literal_symbol(".notdef");
    else {
      out.put_literal_symbol(vec[i]);
      a_delete vec[i];
    }
  }
  out.put_delimiter(']')
     .put_symbol("def");
  fclose(fp);
}