Ejemplo n.º 1
0
static int
do_bfchar (CMap *cmap, ifreader *input, int count)
{
  pst_obj *tok1, *tok2;

  while (count-- > 0) { 
    if (ifreader_need(input, TOKEN_LEN_MAX*2) == 0)
      return -1;
    if ((tok1 = pst_get_token(&(input->cursor), input->endptr)) == NULL)
      return -1;
    if ((tok2 = pst_get_token(&(input->cursor), input->endptr)) == NULL) {
      pst_release_obj(tok1);
      return -1;
    }
    /* We only support single CID font as descendant font, charName should not come here. */
    if (PST_STRINGTYPE(tok1) && PST_STRINGTYPE(tok2)) {
      CMap_add_bfchar(cmap,
		      (unsigned char *) pst_data_ptr(tok1), (int) pst_length_of(tok1),
		      (unsigned char *) pst_data_ptr(tok2), (int) pst_length_of(tok2));
    } else if (PST_NAMETYPE(tok2))
      ERROR("%s: Mapping to charName not supported.", CMAP_PARSE_DEBUG_STR);
    else
      WARN("%s: Invalid CMap mapping record. (ignored)", CMAP_PARSE_DEBUG_STR);
    pst_release_obj(tok1);
    pst_release_obj(tok2);
  }

  return check_next_token(input, "endbfchar");
}
Ejemplo n.º 2
0
static int
add_map (CMap *cmap, mapDef *mtab,
	 unsigned char *codestr, int depth)
{
  int     c;
  mapDef *mtab1;

  for (c = 0; c < 256; c++) {
    codestr[depth] = (unsigned char) (c & 0xff);
    if (LOOKUP_CONTINUE(mtab[c].flag)) {
      mtab1 = mtab[c].next;
      add_map(cmap, mtab1, codestr, depth + 1);
    } else {
      if (MAP_DEFINED(mtab[c].flag)) {
	switch (MAP_TYPE(mtab[c].flag)) {
	case MAP_IS_CID: case MAP_IS_CODE:
	  CMap_add_bfchar(cmap,
			  codestr, depth + 1,
			  mtab[c].code, mtab[c].len);
	  break;
	case MAP_IS_NAME:
	  ERROR("%s: Unexpected error...", CMAP_DEBUG_STR);
	  break;
	case MAP_IS_NOTDEF:
	  break;
	default:
	  ERROR("%s: Unknown mapping type: %d",
		CMAP_DEBUG_STR, MAP_TYPE(mtab[c].flag));
	}
      }
    }
  }

  return 0;
}
Ejemplo n.º 3
0
static int
add_inverse_map (CMap *icmap, mapDef *mtab,
		 unsigned char *codestr, int depth,
		 unsigned char *used_slot)
{
  CID     cid;
  int     c;
  mapDef *mtab1;

  for (c = 0; c < 256; c++) {
    codestr[depth] = (unsigned char) (c & 0xff);
    if (LOOKUP_CONTINUE(mtab[c].flag)) {
      mtab1 = mtab[c].next;
      add_inverse_map(icmap, mtab1, codestr, depth + 1, used_slot);
    } else {
      if (MAP_DEFINED(mtab[c].flag)) {
	switch (MAP_TYPE(mtab[c].flag)) {
	  /* We should restrict it to to-CID mapping.
	   * However...
	   */
	case MAP_IS_CID: case MAP_IS_CODE:
	  if (mtab[c].len == 2) {
	    cid = (mtab[c].code[0] << 8)|mtab[c].code[1];
#ifndef is_used_char2
#define is_used_char2(b,c) (((b)[(c)/8]) & (1 << (7-((c)%8))))
#endif
	    if (!used_slot ||
		is_used_char2(used_slot, cid)) {
	      CMap_add_bfchar(icmap,
			      mtab[c].code, mtab[c].len,
			      codestr, depth + 1);
	    }
	  }
	  break;
	case MAP_IS_NAME:
	  ERROR("%s: Unexpected error...", CMAP_DEBUG_STR);
	  break;
	case MAP_IS_NOTDEF:
	  break;
	default:
	  ERROR("%s: Unknown mapping type: %d",
		CMAP_DEBUG_STR, MAP_TYPE(mtab[c].flag));
	}
      }
    }
  }

  return 0;
}
Ejemplo n.º 4
0
/*
 * bfrange
 *  <codeLo> <codeHi> [destCode1 destCode2 ...]
 */
static int
handle_codearray (CMap *cmap, ifreader *input, unsigned char *codeLo, int dim, int count)
{
  pst_obj *tok = NULL;

  if (dim < 1)
    ERROR("Invalid code range.");
  while (count-- > 0) {
    if ((tok = pst_get_token(&(input->cursor), input->endptr)) == NULL)
      return -1;
    else if (PST_STRINGTYPE(tok)) {
      CMap_add_bfchar(cmap, codeLo, dim, (unsigned char *) pst_data_ptr(tok), (int) pst_length_of(tok));
    } else if (PST_MARKTYPE(tok) || !PST_NAMETYPE(tok))
      ERROR("%s: Invalid CMap mapping record.", CMAP_PARSE_DEBUG_STR);
    else
      ERROR("%s: Mapping to charName not supported.", CMAP_PARSE_DEBUG_STR);
    pst_release_obj(tok);
    codeLo[dim-1] += 1;
  }

  return check_next_token(input, "]");
}