| 1 |
/* tex-glyph.h: look for a TeX glyph font (GF or PK). |
| 2 |
|
| 3 |
Copyright 1993, 2008, 2009, 2011, 2018 Karl Berry. |
| 4 |
Copyright 1999, 2005 Olaf Weber. |
| 5 |
|
| 6 |
This library is free software; you can redistribute it and/or |
| 7 |
modify it under the terms of the GNU Lesser General Public |
| 8 |
License as published by the Free Software Foundation; either |
| 9 |
version 2.1 of the License, or (at your option) any later version. |
| 10 |
|
| 11 |
This library is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
Lesser General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU Lesser General Public License |
| 17 |
along with this library; if not, see <http://www.gnu.org/licenses/>. */ |
| 18 |
|
| 19 |
#ifndef KPATHSEA_TEX_GLYPH_H |
| 20 |
#define KPATHSEA_TEX_GLYPH_H |
| 21 |
|
| 22 |
#include <kpathsea/tex-file.h> |
| 23 |
|
| 24 |
|
| 25 |
#ifdef __cplusplus |
| 26 |
extern "C" { |
| 27 |
#endif |
| 28 |
|
| 29 |
/* This type describes the origin of a glyph font. */ |
| 30 |
|
| 31 |
typedef enum |
| 32 |
{ |
| 33 |
kpse_glyph_source_normal, /* the searched-for font: already existed */ |
| 34 |
kpse_glyph_source_alias, /* : was an alias for an existing file */ |
| 35 |
kpse_glyph_source_maketex, /* : was created on the fly */ |
| 36 |
kpse_glyph_source_fallback_res, /* : found at fallback resolutions */ |
| 37 |
kpse_glyph_source_fallback /* : wasn't found, but the fallback font was */ |
| 38 |
} kpse_glyph_source_type; |
| 39 |
|
| 40 |
|
| 41 |
typedef struct |
| 42 |
{ |
| 43 |
const_string name; /* font name found */ |
| 44 |
unsigned dpi; /* size found, for glyphs */ |
| 45 |
kpse_file_format_type format; /* glyph format found */ |
| 46 |
kpse_glyph_source_type source; /* where we found it */ |
| 47 |
} kpse_glyph_file_type; |
| 48 |
|
| 49 |
#define KPSE_GLYPH_FILE_NAME(f) ((f).name) |
| 50 |
#define KPSE_GLYPH_FILE_DPI(f) ((f).dpi) |
| 51 |
#define KPSE_GLYPH_FILE_FORMAT(f) ((f).format) |
| 52 |
#define KPSE_GLYPH_FILE_SOURCE(f) ((f).source) |
| 53 |
|
| 54 |
|
| 55 |
/* Search first for the font named FONT_NAME at resolution DPI in the |
| 56 |
glyph format FORMAT (see `try_size' for details of format searching). |
| 57 |
Then try resolutions within KPSE_BITMAP_TOLERANCE of DPI. Then if |
| 58 |
FONT_NAME is an alias defined in a texfonts.map do all the above for |
| 59 |
its real name. If not an alias, try creating it on the fly with |
| 60 |
mktexpk. Then try the resolutions in `kpse_fallback_sizes', then |
| 61 |
within the tolerance of each of those. Then try the above for |
| 62 |
kpse_fallback_name. Then fail. Return either the filename found, or |
| 63 |
NULL. Also return information about the file found in |
| 64 |
*GLYPH_FILE. */ |
| 65 |
extern KPSEDLL string kpathsea_find_glyph (kpathsea kpse, |
| 66 |
const_string font_name, unsigned dpi, |
| 67 |
kpse_file_format_type format, |
| 68 |
kpse_glyph_file_type *glyph_file); |
| 69 |
|
| 70 |
|
| 71 |
/* Defines how far away a pixel file can be found from its stated size. |
| 72 |
The DVI standard says any resolution within 0.2% of the stated size |
| 73 |
is ok, but we are more forgiving. */ |
| 74 |
#define KPSE_BITMAP_TOLERANCE(r) ((r) / 500.0 + 1) |
| 75 |
|
| 76 |
/* Check whether DPI1 is within KPSE_BITMAP_TOLERANCE of DPI2. */ |
| 77 |
extern KPSEDLL boolean kpathsea_bitmap_tolerance (kpathsea kpse, |
| 78 |
double dpi1, double dpi2); |
| 79 |
|
| 80 |
|
| 81 |
#if defined (KPSE_COMPAT_API) |
| 82 |
extern KPSEDLL string kpse_find_glyph (const_string font_name, unsigned dpi, |
| 83 |
kpse_file_format_type format, |
| 84 |
kpse_glyph_file_type *glyph_file); |
| 85 |
|
| 86 |
/* Look for a specific format only. */ |
| 87 |
#define kpse_find_pk(font_name, dpi, glyph_file) \ |
| 88 |
kpse_find_glyph (font_name, dpi, kpse_pk_format, glyph_file) |
| 89 |
#define kpse_find_gf(font_name, dpi, glyph_file) \ |
| 90 |
kpse_find_glyph (font_name, dpi, kpse_gf_format, glyph_file) |
| 91 |
|
| 92 |
extern KPSEDLL boolean kpse_bitmap_tolerance (double dpi1, double dpi2); |
| 93 |
#endif |
| 94 |
|
| 95 |
#ifdef __cplusplus |
| 96 |
} |
| 97 |
#endif |
| 98 |
|
| 99 |
#endif /* not KPATHSEA_TEX_GLYPH_H */ |