예제 #1
0
파일: pkfont.c 프로젝트: YandYTeX/ptex-ng
static FILE *
dpx_open_pk_font_at (const char *ident, unsigned dpi)
{
  FILE  *fp;
  char  *fqpn;
  kpse_glyph_file_type kpse_file_info;

  fqpn = kpse_find_glyph(ident, dpi, kpse_pk_format, &kpse_file_info);
  if (!fqpn)
    return  NULL;
  fp   = MFOPEN(fqpn, FOPEN_RBIN_MODE);
  RELEASE(fqpn);

  return  fp;
}
예제 #2
0
static int find_file(lua_State * L)
{
    int i, t;
    const char *st;
    unsigned ftype = kpse_tex_format;
    int mexist = 0;
    TEST_PROGRAM_NAME_SET;
    if (lua_type(L, 1) != LUA_TSTRING) {
        luaL_error(L, "not a file name");
    }
    st = lua_tostring(L, 1);
    i = lua_gettop(L);
    while (i > 1) {
        t = lua_type(L, i) ;
        if (t == LUA_TBOOLEAN) {
            mexist = lua_toboolean(L, i);
        } else if (t == LUA_TNUMBER) {
            mexist = (int) lua_tointeger(L, i);
        } else if (t == LUA_TSTRING) {
            int op = luaL_checkoption(L, i, NULL, filetypenames);
            ftype = filetypes[op];
        } else {
            /* ignore */
        }
        i--;
    }
    if (ftype == kpse_pk_format ||
        ftype == kpse_gf_format || ftype == kpse_any_glyph_format) {
        /* ret.format, ret.name, ret.dpi */
        kpse_glyph_file_type ret;
        lua_pushstring(L, kpse_find_glyph(st, (unsigned) mexist, ftype, &ret));
    } else {
        if (mexist > 0)
            mexist = 1;
        if (mexist < 0)
            mexist = 0;
        lua_pushstring(L, kpse_find_file(st, ftype, mexist));
    }
    return 1;
}
예제 #3
0
FILE *
font_open(char *font, char **font_ret, double dpi, int *dpi_ret,

	  int dummy, char **filename_ret
#ifdef T1LIB
	  , int *t1id
#endif
	  )
{
    char *name;
    kpse_glyph_file_type file_ret;
    UNUSED(dummy);

    /* defaults in case of success; filename_ret will be
       non-NULL iff the fallback font is used.
    */
    *font_ret = NULL;
    /* filename_ret is NULL iff a T1 version of a font has been used */
    *filename_ret = NULL;
    *dpi_ret = dpi;
    
#ifdef Omega
    /* for omega, first try 16-bit ovf's, then 8-bit vf's. */
    name = kpse_find_ovf(font);
    if (name == NULL)
	name = kpse_find_vf(font);
#else
    name = kpse_find_vf(font);
#endif

#ifdef T1LIB
    if (resource.t1lib) {
	*t1id = -1;
    }
#endif /* T1LIB */

    if (name) { /* found a vf font */
	/* pretend it has the expected dpi value, else caller will complain */
	*dpi_ret = dpi;
	*filename_ret = name;
	return xfopen_local(name, FOPEN_R_MODE);
    }

#ifdef T1LIB
    if (resource.t1lib) {
	/* First try: T1 font of correct size */
	*t1id = find_T1_font(font);
	if (*t1id >= 0) {
	    TRACE_T1((stderr, "found T1 font %s", font));
	    return NULL;
	}
	TRACE_T1((stderr,
		  "T1 version of font %s not found, trying pixel version next, then fallback",
		  font));
    }
#endif /* T1LIB */
    /* Second try: PK/GF/... font within allowable size range */
    name = kpse_find_glyph(font, (unsigned)(dpi + .5),
			   kpse_any_glyph_format, &file_ret);

    if (name) { /* success */
	*dpi_ret = file_ret.dpi;
	*filename_ret = name;
	return xfopen_local(name, FOPEN_R_MODE);
    }
    else if (alt_font != NULL) {
	/* The strange thing about kpse_find_glyph() is that it
	   won't create a PK version of alt_font if it doesn't
	   already exist. So we invoke it explicitly a second time
	   for that one.
	*/
#ifdef T1LIB
	if (resource.t1lib) {
	    /* Third try: T1 version of fallback font */
	    *t1id = find_T1_font(alt_font);
	    if (*t1id >= 0) {
		TRACE_T1((stderr, "found fallback font %s\n", font));
		*font_ret = xstrdup(alt_font);
		return NULL;
	    }
	    TRACE_T1((stderr,
		      "Type1 version of fallback font %s not found, trying pixel version",
		      alt_font));
	}
#endif /* T1LIB */
	/* Forth try: PK version of fallback font */
	name = kpse_find_glyph(alt_font, (unsigned)(dpi + .5),
			       kpse_any_glyph_format, &file_ret);
	if (name) { /* success */
	    *dpi_ret = file_ret.dpi;
	    *filename_ret = name;
	    *font_ret = xstrdup(alt_font);
	    return xfopen_local(name, FOPEN_R_MODE);
	}
    }
    /* all other cases are failure */
    return NULL;
}
예제 #4
0
font_open P6C(char *,font, char **,font_ret, double, dpi, int *,dpi_ret, 
			  int, dummy, char **,filename_ret, int *,t1id)

#endif
{
  FILE *ret;
  char *name;
#ifdef WIN32
  extern void UpdateStatusBar(LPSTR lpszStatusString, 
			      WORD partNumber, WORD displayFlags);
  char szBuf[80];

  wsprintf(szBuf, "Finding font %s", font);
  UpdateStatusBar(szBuf, 0, 0);
#endif
  
#ifdef Omega
  name = kpse_find_ovf (font);
  if (!name) name = kpse_find_vf(font);
#else
  name = kpse_find_vf (font);
#endif
#if TTF
  *ttfid=-1
#endif
#if T1
  *t1id=-1;
#endif
  if (name) {
    /* VF fonts don't have a resolution, but load_font will complain if
       we don't return what it asked for.  */
    *dpi_ret = dpi;
    *font_ret = NULL;
  } else {
    kpse_glyph_file_type file_ret;

#if TTF
    /* First atempt to load it as TrueType font */

    *dpi_ret = dpi;
    *font_ret = NULL;
    *filename_ret = NULL;
    *ttfid=find_TTF_font(font);
    if (*ttfid>=0) return NULL;
#endif
#if T1
    /* First atempt to load it as T1 font */

    *dpi_ret = dpi;
    *font_ret = NULL;
    *filename_ret = NULL;
    *t1id=find_T1_font(font);
    if (*t1id>=0) return NULL;
#endif

    name = kpse_find_glyph (font, (unsigned) (dpi + .5),
			    kpse_any_glyph_format, &file_ret);

    if (name) {
      /* If we got it normally, from an alias, or from mktexpk,
	 don't fill in FONT_RET.  That tells load_font to complain.  */
      *font_ret
	= file_ret.source == kpse_glyph_source_fallback ? file_ret.name
	: NULL; /* tell load_font we found something good */
          
      *dpi_ret = file_ret.dpi;
    }
    /* If no VF and no PK, FONT_RET is irrelevant? */
  }
  
  /* If we found a name, return the stream. */
  ret = name ? xfopen_local (name, FOPEN_RBIN_MODE) : NULL;
  *filename_ret = name;

  return ret;
}