Ejemplo n.º 1
0
int 
read_font_info(pointer u,  strnumber nom, strnumber aire, scaled s,
               integer natural_dir) {
  integer f;
  char *cnom, *caire = NULL;
  char *msg;
  cnom  = xstrdup(makecstring(nom));
  if (aire != 0) 
    caire = xstrdup(makecstring(aire));

  f = new_font();
  if ((f = do_define_font(f, cnom,caire,s,natural_dir))) {
	if (caire != NULL) free(caire);
	free(cnom);
    return f;
  } else {
    char *help[] = {"I wasn't able to read the size data for this font,",
		    "so I will ignore the font specification.",
		    "[Wizards can fix TFM files using TFtoPL/PLtoTF.]",
		    "You might try inserting a different font spec;",
		    "e.g., type `I\font<same font id>=<substitute font name>'.",
		    NULL } ;
	if(!get_suppress_fontnotfound_error()) {
	  msg = font_error_message(u, cnom, s);
	  tex_error(msg,help);
	  free(msg);
	}
	if (caire != NULL) free(caire);
	free(cnom);
    return 0;
  }
}
Ejemplo n.º 2
0
int gettoks (lua_State *L) {
  int i;
  size_t k;
  strnumber t;
  int cur_cs;
  int texstr;
  char *s;
  i = lua_gettop(L);
  if (lua_type(L,i)==LUA_TSTRING) {
    s = (char *)lua_tolstring(L,i, &k);
    texstr = maketexlstring(s,k);
    cur_cs = string_lookup(texstr);
    flush_str(texstr);
    if (is_undefined_cs(cur_cs)) {
      lua_pushnil(L);
      return 1;
    }
    k = zget_equiv(cur_cs)-get_toks_base();
  } else {
    k = (int)luaL_checkinteger(L,i);
  }

  check_index_range(k);
  t = get_tex_toks_register(k);
  lua_pushstring(L, makecstring(t));
  flush_str(t);
  return 1;
}
Ejemplo n.º 3
0
static unsigned char *get_cs_text(int cs)
{
    if (cs == null_cs)
        return (unsigned char *) xstrdup("\\csname\\endcsname");
    else if ((cs_text(cs) < 0) || (cs_text(cs) >= str_ptr))
        return (unsigned char *) xstrdup("");
    else
        return (unsigned char *) makecstring(cs_text(cs));
}
Ejemplo n.º 4
0
static int do_getstat(lua_State * L, int i)
{
    int t;
    const char *st;
    charfunc f;
    intfunc g;
    numfunc n;
    int str;
    t = stats[i].type;
    switch (t) {
    case 'S':
        f = stats[i].value;
        st = f();
        lua_pushstring(L, st);
        break;
    case 's':
        str = *(int *) (stats[i].value);
        if (str) {
            char *ss = makecstring(str);
            lua_pushstring(L, ss);
            free(ss);
        } else {
            lua_pushnil(L);
        }
        break;
    case 'N':
        n = stats[i].value;
        lua_pushnumber(L, n());
        break;
    case 'G':
        g = stats[i].value;
        lua_pushnumber(L, g());
        break;
    case 'g':
        lua_pushnumber(L, *(int *) (stats[i].value));
        break;
    case 'B':
        g = stats[i].value;
        lua_pushboolean(L, g());
        break;
    case 'n':
        if (*(halfword *) (stats[i].value) != 0)
            lua_nodelib_push_fast(L, *(halfword *) (stats[i].value));
        else
            lua_pushnil(L);
        break;
    case 'b':
        lua_pushboolean(L, *(int *) (stats[i].value));
        break;
    default:
        lua_pushnil(L);
    }
    return 1;
}
Ejemplo n.º 5
0
char *
get_convert (int cur_code) {
  int texstr;
  char *str = NULL;
  texstr = the_convert_string(cur_code);
  if (texstr) {
    str = makecstring(texstr);
    flush_str(texstr);
  }
  return str;
}
Ejemplo n.º 6
0
boolean is_primitive(str_number csname)
{
int n,m;
char*ss;
m= prim_lookup(csname);
ss= makecstring(csname);
n= string_lookup(ss,str_length(csname));
free(ss);
return((n!=undefined_cs_cmd)&&
(m!=undefined_primitive)&&
(eq_type(n)==prim_eq_type(m))&&(equiv(n)==prim_equiv(m)));
}
Ejemplo n.º 7
0
/* return 1 == identical */
boolean
cmp_font_name (integer id, strnumber t) {
  char *tid , *tt;
  if (!is_valid_font(id)) 
    return 0;
  tt = makecstring(t);
  tid = font_name(id);
  if (tt == NULL && tid == NULL)
    return 1;
  if (tt == NULL || tid == NULL || strcmp(tid,tt)!=0)
    return 0;
  return 1;
}
Ejemplo n.º 8
0
static char *
font_error_message (pointer u, char *nom, scaled s) {
  char *str = xmalloc(256);
  char *c = makecstring(zget_cs_text(u));
  char *extra =  "metric data not found or bad";
  if (s>=0 ) {
    snprintf(str,255,"Font \\%s=%s at %gpt not loadable: %s", c, nom, (double)s/65536, extra);
  } else if (s!=-1000) {
    snprintf(str,255,"Font \\%s=%s scaled %d not loadable: %s", c, nom, (int)(-s), extra);
  } else {
    snprintf(str,255,"Font \\%s=%s not loadable: %s", c, nom, extra);
  }
  return str;
}
Ejemplo n.º 9
0
char *
get_something_internal (int cur_cmd, int cur_code) {
  int texstr;
  char *str;
  int save_cur_val,save_cur_val_level;
  save_cur_val = cur_val;
  save_cur_val_level = cur_val_level;
  zscan_something_simple(cur_cmd,cur_code);
  texstr = the_scanned_result();
  cur_val = save_cur_val;
  cur_val_level = save_cur_val_level;  
  str = makecstring(texstr);
  flush_str(texstr);
  return str;
}
Ejemplo n.º 10
0
boolean
cmp_font_area (integer id, strnumber t) {
  char *tt = NULL;
  char *tid = font_area(id);
  if (t == 0) {
    if (tid == NULL || strlen(tid)==0)
      return 1;
    else 
      return 0;
  }
  tt = makecstring(t);
  if ((tt == NULL || strlen(tt)==0) && (tid == NULL  || strlen(tid)==0))
    return 1;
  if (tt == NULL || strcmp(tid,tt)!=0)
    return 0;
  return 1;
}
Ejemplo n.º 11
0
static fmentryptr fmlookup(internalfontnumber f)
{
    char *tfm;
    fm_entry *fm;
    fm_entry tmp;
    if (tfm_tree == NULL)
        fm_read_info();         /* only to read default map file */
    tfm = makecstring(fontname[f]);
    assert(strcmp(tfm, nontfm) != 0);

    /* Look up for full <tfmname>[+-]<expand> */
    tmp.tfm_name = tfm;
    fm = (fm_entry *) avl_find(tfm_tree, &tmp);
    if (fm != NULL) {
        fm->in_use = true;
        return (fmentryptr) fm;
    }
    return (fmentryptr) dummy_fm_entry();
}
Ejemplo n.º 12
0
void deftounicode(strnumber glyph, strnumber unistr)
{
    char buf[SMALL_BUF_SIZE], *p;
    char buf2[SMALL_BUF_SIZE], *q;
    int valid_unistr;           /* 0: invalid; 1: unicode value; 2: string */
    int i, l;
    glyph_unicode_entry *gu, t;
    void **aa;

    p = makecstring(glyph);
    assert(strlen(p) < SMALL_BUF_SIZE);
    strcpy(buf, p);             /* copy the result to buf before next call of makecstring() */
    p = makecstring(unistr);
    while (*p == ' ')
        p++;                    /* ignore leading spaces */
    l = strlen(p);
    while (l > 0 && p[l - 1] == ' ')
        l--;                    /* ignore traling spaces */
    valid_unistr = 1;           /* a unicode value is the most common case */
    for (i = 0; i < l; i++) {
        if (p[i] == ' ')
            valid_unistr = 2;   /* if a space occurs we treat this entry as a string */
        else if (!isXdigit(p[i])) {
            valid_unistr = 0;
            break;
        }
    }
    if (l == 0 || valid_unistr == 0 || strlen(buf) == 0
        || strcmp(buf, notdef) == 0) {
        pdftex_warn("ToUnicode: invalid parameter(s): `%s' => `%s'", buf, p);
        return;
    }
    if (glyph_unicode_tree == NULL) {
        glyph_unicode_tree =
            avl_create(comp_glyph_unicode_entry, NULL, &avl_xallocator);
        assert(glyph_unicode_tree != NULL);
    }
    t.name = buf;
    /* allow overriding existing entries */
    if ((gu = (glyph_unicode_entry *) avl_find(glyph_unicode_tree, &t)) != NULL) {
        if (gu->code == UNI_STRING) {
            assert(gu->unicode_seq != NULL);
            xfree(gu->unicode_seq);
        }
    } else {                    /* make new entry */
        gu = new_glyph_unicode_entry();
        gu->name = xstrdup(buf);
    }
    if (valid_unistr == 2) {    /* a string with space(s) */
        /* copy p to buf2, ignoring spaces */
        for (q = buf2; *p != 0; p++)
            if (*p != ' ')
                *q++ = *p;
        *q = 0;
        gu->code = UNI_STRING;
        gu->unicode_seq = xstrdup(buf2);
    } else {
        i = sscanf(p, "%lX", &(gu->code));
        assert(i == 1);
    }
    aa = avl_probe(glyph_unicode_tree, gu);
    assert(aa != NULL);
}
Ejemplo n.º 13
0
void pdfmapline(integer t)
{
    process_map_item(makecstring(tokens_to_string(t)), MAPLINE);
    flush_str(last_tokens_string);
}
Ejemplo n.º 14
0
void pdfmapline(integer t)
{
    process_map_item(makecstring(tokenstostring(t)), MAPLINE);
    flushstr(lasttokensstring);
}