diff options
Diffstat (limited to 'Build/source/texk/lcdf-typetools/otftotfm')
11 files changed, 299 insertions, 200 deletions
diff --git a/Build/source/texk/lcdf-typetools/otftotfm/Makefile.am b/Build/source/texk/lcdf-typetools/otftotfm/Makefile.am index 09af4e1376c..e8652fb2548 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/Makefile.am +++ b/Build/source/texk/lcdf-typetools/otftotfm/Makefile.am @@ -13,6 +13,7 @@ otftotfm_SOURCES = \ secondary.cc secondary.hh \ uniprop.cc uniprop.hh \ util.cc util.hh +EXTRA_otftotfm_SOURCES = kpseinterface.c kpseinterface.h otftotfm_LDADD = ../libefont/libefont.a ../liblcdf/liblcdf.a otftotfm_DEPENDENCIES = ../libefont/libefont.a ../liblcdf/liblcdf.a diff --git a/Build/source/texk/lcdf-typetools/otftotfm/Makefile.in b/Build/source/texk/lcdf-typetools/otftotfm/Makefile.in index 2151eacdec2..3ea279fc8a0 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/Makefile.in +++ b/Build/source/texk/lcdf-typetools/otftotfm/Makefile.in @@ -57,7 +57,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_template_objs.m4 \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_HEADER = $(top_builddir)/autoconf.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" @@ -96,8 +96,8 @@ LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(otftotfm_SOURCES) -DIST_SOURCES = $(am__otftotfm_SOURCES_DIST) +SOURCES = $(otftotfm_SOURCES) $(EXTRA_otftotfm_SOURCES) +DIST_SOURCES = $(am__otftotfm_SOURCES_DIST) $(EXTRA_otftotfm_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -260,6 +260,7 @@ otftotfm_SOURCES = automatic.cc automatic.hh dvipsencoding.cc \ dvipsencoding.hh glyphfilter.cc glyphfilter.hh metrics.cc \ metrics.hh otftotfm.cc otftotfm.hh secondary.cc secondary.hh \ uniprop.cc uniprop.hh util.cc util.hh $(am__append_1) +EXTRA_otftotfm_SOURCES = kpseinterface.c kpseinterface.h otftotfm_LDADD = ../libefont/libefont.a ../liblcdf/liblcdf.a \ $(am__append_3) otftotfm_DEPENDENCIES = ../libefont/libefont.a ../liblcdf/liblcdf.a \ diff --git a/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc b/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc index ad303d690a2..ee38173c762 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/automatic.cc @@ -476,13 +476,13 @@ installed_truetype(const String &ttf_filename, bool allow_generate, ErrorHandler // perhaps generate type 42 in the future, for now just copy if (allow_generate && ttf_filename && ttf_filename != "-" && getodir(O_TRUETYPE, errh)) { - String ttf_filename = odir[O_TRUETYPE] + "/" + file; - if (ttf_filename.find_left('\'') >= 0 || ttf_filename.find_left('\"') >= 0) + String installed_ttf_filename = odir[O_TRUETYPE] + "/" + file; + if (installed_ttf_filename.find_left('\'') >= 0 || installed_ttf_filename.find_left('\"') >= 0) return String(); int retval; - if (!same_filename(ttf_filename, ttf_filename)) { - String command = "cp " + shell_quote(ttf_filename) + " " + shell_quote(ttf_filename); + if (!same_filename(ttf_filename, installed_ttf_filename)) { + String command = "cp " + shell_quote(ttf_filename) + " " + shell_quote(installed_ttf_filename); retval = mysystem(command.c_str(), errh); if (retval == 127) errh->error("could not run %<%s%>", command.c_str()); @@ -492,13 +492,13 @@ installed_truetype(const String &ttf_filename, bool allow_generate, ErrorHandler errh->error("%<%s%> failed", command.c_str()); } else { if (verbose) - errh->message("TrueType file %s already located in output directory", ttf_filename.c_str()); + errh->message("TrueType file %s already located in output directory", installed_ttf_filename.c_str()); retval = 0; } if (retval == 0) { - update_odir(O_TRUETYPE, ttf_filename, errh); - return ttf_filename; + update_odir(O_TRUETYPE, installed_ttf_filename, errh); + return installed_ttf_filename; } } @@ -605,7 +605,7 @@ update_autofont_map(const String &fontname, String mapline, ErrorHandler *errh) while (!feof(f)) if (char *x = sa.reserve(8192)) { int amt = fread(x, 1, 8192, f); - sa.forward(amt); + sa.adjust_length(amt); } else { fclose(f); return errh->error("Out of memory!"); diff --git a/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.cc b/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.cc index 0575c665225..5ca912ee58d 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.cc @@ -26,115 +26,162 @@ #include <algorithm> #include "util.hh" -enum { GLYPHLIST_MORE = 0x40000000, - U_EMPTYSLOT = 0xD801, U_ALTSELECTOR = 0xD802 }; -static HashMap<String, int> glyphlist(-1); +enum { GLYPHLIST_ALTERNATIVE = 0x40000000, + GLYPHLIST_USEMAP = GLYPHLIST_ALTERNATIVE, + U_EMPTYSLOT = 0xD801, + U_ALTSELECTOR = 0xD802 }; +static HashMap<String, uint32_t> glyphlist(-1); +static Vector<uint32_t> glyphmap; static PermString::Initializer perm_initializer; PermString DvipsEncoding::dot_notdef(".notdef"); #define NEXT_GLYPH_NAME(gn) ("/" + (gn)) -int +void DvipsEncoding::add_glyphlist(String text) { - // XXX ignores glyph names that map to multiple characters - const char *data = text.c_str(); - int pos = 0, len = text.length(); - while (1) { + const char *s = text.begin(), *end = text.end(); + while (s != end) { // move to first nonblank - while (pos < len && isspace((unsigned char) data[pos])) - pos++; - // parse line - if (pos >= len) - return 0; - else if (data[pos] != '#') { - int first = pos; - for (; pos < len && !isspace((unsigned char) data[pos]) && data[pos] != ';'; pos++) - /* nada */; - String glyph_name = text.substring(first, pos - first); - int value; - char *next; - read_uni: - if (first == pos - || pos + 1 >= len - || (data[pos] != ';' && data[pos] != ',') - || !isxdigit((unsigned char) data[pos+1]) - || ((value = strtol(data + pos + 1, &next, 16)), - (!isspace((unsigned char) *next) && *next && *next != ';' && *next != ','))) - return -1; - while (*next == ' ' || *next == '\t') - next++; - if (*next == '\r' || *next == '\n') - glyphlist.insert(glyph_name, value); - else if (*next == ';' || *next == ',') - glyphlist.insert(glyph_name, value | GLYPHLIST_MORE); - else - while (*next != '\r' && *next != '\n' && *next != ';' && *next != ',') - next++; - pos = next - data; - if (*next == ';' || *next == ',') { // read another possibility - glyph_name = NEXT_GLYPH_NAME(glyph_name); - // XXX given "DDDD,EEEE EEEE,FFFF", will not store "FFFF" - goto read_uni; + while (s != end && isspace((unsigned char) *s)) + ++s; + // ignore comments + if (*s == '#') { + skip_to_end_of_line: + while (s != end && *s != '\n' && *s != '\r') + ++s; + continue; + } + // parse glyph name + const char *name_start = s; + while (s != end && !isspace((unsigned char) *s) && *s != ';') + ++s; + if (s == name_start) + goto skip_to_end_of_line; + String glyph_name = text.substring(name_start, s).compact(); + int map_pos = glyphmap.size(); + // parse Unicodes + while (1) { + while (s != end && (*s == ' ' || *s == '\t')) + ++s; + if (s == end || *s == '\n' || *s == '\r' || *s == '#' + || (map_pos == glyphmap.size() && *s != ';' && *s != ',')) + break; + if (*s == ';' || *s == ',') { + ++s; + while (s != end && (*s == ' ' || *s == '\t')) + ++s; + if (s == end || !isxdigit((unsigned char) *s)) + goto skip_to_end_of_line; + if (map_pos != glyphmap.size()) + glyphmap.push_back(GLYPHLIST_ALTERNATIVE); } - } else - while (pos < len && data[pos] != '\n' && data[pos] != '\r') - pos++; + uint32_t u = 0; + while (s != end && isxdigit((unsigned char) *s)) { + if (*s >= '0' && *s <= '9') + u = (u << 4) + *s - '0'; + else if (*s >= 'A' && *s <= 'F') + u = (u << 4) + *s - 'A' + 10; + else + u = (u << 4) + *s - 'a' + 10; + ++s; + } + if (u == 0 || u > 0x10FFFF) + goto skip_to_end_of_line; + glyphmap.push_back(u); + if (s != end && !isspace((unsigned char) *s) && *s != ',' && *s != ';') + break; + } + // store result + if (map_pos == glyphmap.size() - 1) { + glyphlist.insert(glyph_name, glyphmap.back()); + glyphmap.pop_back(); + } else { + glyphlist.insert(glyph_name, map_pos | GLYPHLIST_USEMAP); + glyphmap.push_back(0); + } + goto skip_to_end_of_line; } } -void -DvipsEncoding::glyphname_unicode(String gn, Vector<int> &unis, bool *more) +static void +unicode_add_suffix(Vector<uint32_t> &prefix, + int prefix_starting_from, + const Vector<uint32_t> &suffix) { - if (more) - *more = false; + int prefix_size = prefix.size(); + for (Vector<uint32_t>::const_iterator it = suffix.begin(); + it != suffix.end() && *it != 0; + ++it) + if (*it == GLYPHLIST_ALTERNATIVE) { + prefix.push_back(*it); + for (int i = prefix_starting_from; i < prefix_size; ++i) + prefix.push_back(prefix[i]); + } else + prefix.push_back(*it); +} - // first, drop all characters to the right of the first dot +bool +DvipsEncoding::glyphname_unicode(String gn, Vector<uint32_t> &unis) +{ + int unis_first_size = unis.size(); + + // drop all characters to the right of the first dot String::iterator dot = std::find(gn.begin(), gn.end(), '.'); if (dot < gn.end()) gn = gn.substring(gn.begin(), dot); - // then, separate into components - while (gn) { - String::iterator underscore = std::find(gn.begin(), gn.end(), '_'); - String component = gn.substring(gn.begin(), underscore); - gn = gn.substring(underscore + 1, gn.end()); - - // check glyphlist - int value = glyphlist[component]; - uint32_t uval; - if (value >= 0) { - unis.push_back(value & ~GLYPHLIST_MORE); - if (more && (value & GLYPHLIST_MORE) && !gn) - *more = true; - } else if (component.length() >= 7 - && (component.length() % 4) == 3 - && (memcmp(component.data(), "uni", 3) == 0 - // 16.Aug.2008: Some texnansx.enc have incorrect "Uni" - // prefix, but we might as well understand it. - || memcmp(component.data(), "Uni", 3) == 0)) { - int old_size = unis.size(); - for (const char* s = component.begin() + 3; s < component.end(); s += 4) - if (parse_unicode_number(s, s + 4, -1, uval)) - unis.push_back(uval); - else { - unis.resize(old_size); - break; - } - } else if (component.length() >= 5 - && component.length() <= 7 - && component[0] == 'u' - && parse_unicode_number(component.begin() + 1, component.end(), -1, uval)) - unis.push_back(uval); + // map the first component, handle later components recursively + String::iterator underscore = std::find(gn.begin(), gn.end(), '_'); + String component = gn.substring(gn.begin(), underscore); + int prefix_start = 0; + Vector<uint32_t> suffix; + if (String gn_suffix = gn.substring(underscore + 1, gn.end())) { + if (!glyphname_unicode(gn_suffix, suffix)) + return false; } -} -int -DvipsEncoding::glyphname_unicode(const String &gn, bool *more) -{ - Vector<int> unis; - glyphname_unicode(gn, unis, more); - return (unis.size() == 1 ? unis[0] : -1); + // check glyphlist + int value = glyphlist[component]; + uint32_t uval; + if (value >= 0 && !(value & GLYPHLIST_USEMAP)) + unis.push_back(value); + else if (value >= 0) { + for (int i = (value & ~GLYPHLIST_USEMAP); + glyphmap[i]; + ++i) + if (glyphmap[i] == GLYPHLIST_ALTERNATIVE) { + unicode_add_suffix(unis, prefix_start, suffix); + unis.push_back(GLYPHLIST_ALTERNATIVE); + prefix_start = unis.size(); + } else + unis.push_back(glyphmap[i]); + } else if (component.length() >= 7 + && (component.length() % 4) == 3 + && (memcmp(component.data(), "uni", 3) == 0 + // 16.Aug.2008: Some texnansx.enc have incorrect "Uni" + // prefix, but we might as well understand it. + || memcmp(component.data(), "Uni", 3) == 0)) { + int old_size = unis.size(); + for (const char *s = component.begin() + 3; + s < component.end(); + s += 4) + if (parse_unicode_number(s, s + 4, -1, uval)) + unis.push_back(uval); + else { + unis.resize(unis_first_size); + return false; + } + } else if (component.length() >= 5 + && component.length() <= 7 + && component[0] == 'u' + && parse_unicode_number(component.begin() + 1, component.end(), -1, uval)) + unis.push_back(uval); + else + return false; + + unicode_add_suffix(unis, prefix_start, suffix); + return true; } @@ -462,24 +509,19 @@ DvipsEncoding::parse_unicoding_words(Vector<String> &v, int override, ErrorHandl /* no warnings to delete a glyph */; else { for (int i = 2; i < v.size(); i++) { - bool more; // some care to get all possibilities - int uni = glyphname_unicode(v[i], &more); - if (uni < 0) { - errh->warning("can't map %<%s%> to Unicode", v[i].c_str()); + if (i > 2) + _unicoding.push_back(GLYPHLIST_ALTERNATIVE); + if (!glyphname_unicode(v[i], _unicoding)) { + errh->warning("can%,t map %<%s%> to Unicode", v[i].c_str()); if (i == 2) errh->warning("target %<%s%> will be deleted from encoding", v[0].c_str()); - } else { - _unicoding.push_back(uni); - while (more) { - v[i] = NEXT_GLYPH_NAME(v[i]); - if ((uni = glyphname_unicode(v[i], &more)) >= 0) - _unicoding.push_back(uni); - } + else + _unicoding.pop_back(); } } } - _unicoding.push_back(-1); + _unicoding.push_back(0); if (override > 0 || _unicoding_map[v[0]] < 0) _unicoding_map.insert(v[0], original_size); return 0; @@ -688,9 +730,9 @@ DvipsEncoding::bad_codepoint(int code, Metrics &metrics, Vector<String> &unencod } if (_warn_missing) { - Vector<uint32_t> unicodes; - bool unicodes_explicit = x_unicodes(_e[code], unicodes); - if (!unicodes_explicit || unicodes.size() > 0) { + Vector<uint32_t> garbage; + bool unicodes_explicit = x_unicodes(_e[code], garbage); + if (!unicodes_explicit || garbage.size() > 0) { Vector<Setting> v; v.push_back(Setting(Setting::RULE, 500, 500)); v.push_back(Setting(Setting::SPECIAL, String("Warning: missing glyph '") + _e[code] + "'")); @@ -714,21 +756,11 @@ DvipsEncoding::x_unicodes(PermString chname, Vector<uint32_t> &unicodes) const { int i = _unicoding_map[chname]; if (i >= 0) { - for (; _unicoding[i] >= 0; i++) + for (; _unicoding[i] > 0; i++) unicodes.push_back(_unicoding[i]); return true; } else { - bool more; - if ((i = glyphname_unicode(chname, &more)) >= 0) - unicodes.push_back(i); - if (more) { // might be multiple possibilities - String gn = chname; - do { - gn = NEXT_GLYPH_NAME(gn); - if ((i = glyphname_unicode(gn, &more)) >= 0) - unicodes.push_back(i); - } while (more); - } + glyphname_unicode(chname, unicodes); return false; } } @@ -745,16 +777,27 @@ DvipsEncoding::make_metrics(Metrics &metrics, const FontInfo &finfo, Secondary * if (chname == dot_notdef) continue; - // find all Unicodes - Vector<uint32_t> unicodes; - (void) x_unicodes(chname, unicodes); - - // find first Unicode supported by the font + // find first single Unicode glyph supported by the font Efont::OpenType::Glyph glyph = 0; - uint32_t glyph_uni = (unicodes.size() ? unicodes[0] : 0); - for (uint32_t *u = unicodes.begin(); u < unicodes.end() && !glyph; u++) - if ((glyph = map_uni(*u, *finfo.cmap, metrics)) > 0) - glyph_uni = *u; + uint32_t glyph_uni = 0; + { + Vector<uint32_t> unicodes; + (void) x_unicodes(chname, unicodes); + Vector<uint32_t>::iterator u = unicodes.begin(); + while (u != unicodes.end() && glyph <= 0) { + uint32_t this_uni = u[0]; + ++u; + if (u != unicodes.end()) { + if (*u != GLYPHLIST_ALTERNATIVE) + break; + ++u; + } + + glyph = map_uni(this_uni, *finfo.cmap, metrics); + if (glyph_uni == 0 || glyph > 0) + glyph_uni = this_uni; + } + } // find named glyph, if any Efont::OpenType::Glyph named_glyph = finfo.glyphid(chname); @@ -809,9 +852,14 @@ DvipsEncoding::make_metrics(Metrics &metrics, const FontInfo &finfo, Secondary * // May need to try secondaries later. Store this slot. // Try secondaries, if there's explicit unicoding or no named_glyph. if (unicodes_explicit || named_glyph <= 0) - for (uint32_t *u = unicodes.begin(); u < unicodes.end(); u++) - if (secondary->encode_uni(code, chname, *u, metrics, errh)) + for (uint32_t *u = unicodes.begin(); u != unicodes.end(); ) { + uint32_t *endu = u + 1; + while (endu != unicodes.end() && *endu != GLYPHLIST_ALTERNATIVE) + ++endu; + if (secondary->encode_uni(code, chname, u, endu, metrics, errh)) goto encoded; + u = (endu == unicodes.end() ? endu : endu + 1); + } // 1. We were not able to find the glyph using Unicode or secondaries. // 2. There might be a named_glyph. @@ -819,9 +867,14 @@ DvipsEncoding::make_metrics(Metrics &metrics, const FontInfo &finfo, Secondary * // which should turn off the character (even if a named_glyph exists), // UNLESS the glyph was explicitly requested. if (named_glyph > 0 - && (!unicodes_explicit || unicodes.size() > 0 - || (_encoding_required.size() > code && _encoding_required[code]))) - metrics.encode(code, unicodes.size() ? unicodes[0] : 0, named_glyph); + && (!unicodes_explicit + || unicodes.size() > 0 + || (_encoding_required.size() > code && _encoding_required[code]))) { + uint32_t uni = 0; + if (unicodes.size() == 1 || (unicodes.size() > 0 && unicodes[1] == GLYPHLIST_ALTERNATIVE)) + uni = unicodes[0]; + metrics.encode(code, uni, named_glyph); + } encoded: /* all set */; diff --git a/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.hh b/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.hh index 5c472670863..de2561d1011 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.hh +++ b/Build/source/texk/lcdf-typetools/otftotfm/dvipsencoding.hh @@ -11,9 +11,7 @@ class DvipsEncoding { public: DvipsEncoding(); - static int add_glyphlist(String); - static int glyphname_unicode(const String &, bool *more = 0); - static void glyphname_unicode(String, Vector<int> &, bool *more = 0); + static void add_glyphlist(String); operator bool() const { return _e.size() > 0; } const String &name() const { return _name; } @@ -67,7 +65,7 @@ class DvipsEncoding { public: Vector<Ligature> _lig; Vector<Ligature> _pos; HashMap<PermString, int> _unicoding_map; - Vector<int> _unicoding; + Vector<uint32_t> _unicoding; mutable Vector<uint32_t> _unicodes; @@ -100,6 +98,8 @@ class DvipsEncoding { public: static PermString dot_notdef; + static bool glyphname_unicode(String, Vector<uint32_t> &); + friend inline bool operator==(const Ligature&, const Ligature&); }; diff --git a/Build/source/texk/lcdf-typetools/otftotfm/metrics.cc b/Build/source/texk/lcdf-typetools/otftotfm/metrics.cc index 5d2ac48fc84..1b41e81964b 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/metrics.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/metrics.cc @@ -1184,7 +1184,7 @@ Metrics::shrink_encoding(int size, const DvipsEncoding &dvipsenc, ErrorHandler * for (Code c = 0; c < _encoding.size(); c++) if (VirtualChar *vc = _encoding[c].virtual_char) { - /* Make sure that if this virutal character appears, its parts + /* Make sure that if this virtual character appears, its parts will also appear, by scoring the parts less */ int score = scores[c] - 1, font_number = 0; for (Setting *s = vc->setting.begin(); s != vc->setting.end(); s++) diff --git a/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.1 b/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.1 index 212f4508ba7..fbeb186950f 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.1 +++ b/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.1 @@ -1,5 +1,5 @@ '\"t -.ds V 2.83 +.ds V 2.85 .de M .BR "\\$1" "(\\$2)\\$3" .. @@ -881,8 +881,9 @@ automatic mode. .BI \-\-glyphlist= file Use .I file -as the Adobe glyph list, which helps translate glyph names to Unicode code -points. See ENCODINGS, below, for more information. +as a Adobe glyph list, which helps translate glyph names to Unicode code +points. Give multiple options to include multiple files. +See ENCODINGS, below, for more information. ' .Sp .TP 5 diff --git a/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc b/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc index 49d97241fc0..e7207672e07 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/otftotfm.cc @@ -626,6 +626,8 @@ output_pl(Metrics &metrics, const String &ps_name, int boundary_char, if (vpl) { int vpl_first_font = (metrics.need_base() ? 0 : 1); font_mapping.assign(metrics.n_mapped_fonts(), 0); + if (vpl_first_font == 1 && font_mapping.size() == 1) + font_mapping.push_back(0); // how many times is each font used? Vector<Setting> settings; for (int i = 0; i < 256; i++) @@ -957,7 +959,7 @@ write_encoding_file(String &filename, const String &encoding_name, while (!feof(f)) if (char *x = sa.reserve(8192)) { int amt = fread(x, 1, 8192, f); - sa.forward(amt); + sa.adjust_length(amt); } else { fclose(f); return errh->error("Out of memory!"); diff --git a/Build/source/texk/lcdf-typetools/otftotfm/secondary.cc b/Build/source/texk/lcdf-typetools/otftotfm/secondary.cc index 4a48f52fadb..3d040bc9a44 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/secondary.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/secondary.cc @@ -32,51 +32,57 @@ #include <limits.h> #include <algorithm> -enum { U_EXCLAMDOWN = 0x00A1, // U+00A1 INVERTED EXCLAMATION MARK - U_DEGREE = 0x00B0, // U+00B0 DEGREE SIGN - U_QUESTIONDOWN = 0x00BF, // U+00BF INVERTED QUESTION MARK - U_IJ = 0x0132, // U+0132 LATIN CAPITAL LIGATURE IJ - U_ij = 0x0133, // U+0133 LATIN SMALL LIGATURE IJ - U_DOTLESSJ = 0x0237, // U+0237 LATIN SMALL LETTER DOTLESS J - U_RINGABOVE = 0x02DA, // U+02DA RING ABOVE - U_COMBININGRINGABOVE = 0x030A, // U+030A COMBINING RING ABOVE - U_CWM = 0x200C, // U+200C ZERO WIDTH NON-JOINER - U_ENDASH = 0x2013, // U+2013 EN DASH - U_PERTENTHOUSAND = 0x2031, // U+2031 PER TEN THOUSAND SIGN - U_INTERROBANG = 0x203D, // U+203D INTERROBANG - U_FRACTION = 0x2044, // U+2044 FRACTION SLASH - U_CENTIGRADE = 0x2103, // U+2103 DEGREE CELSIUS - U_ASTERISKMATH = 0x2217, // U+2217 ASTERISK OPERATOR - U_BARDBL = 0x2225, // U+2225 PARALLEL TO - U_VISIBLESPACE = 0x2423, // U+2423 OPEN BOX - U_DBLBRACKETLEFT = 0x27E6, - U_DBLBRACKETRIGHT = 0x27E7, - U_SS = 0xD800, // invalid Unicode - U_EMPTYSLOT = 0xD801, // invalid Unicode (not handled by Secondary) - U_ALTSELECTOR = 0xD802, // invalid Unicode - U_SSSMALL = 0xD803, // invalid Unicode - U_FFSMALL = 0xD804, // invalid Unicode - U_FISMALL = 0xD805, // invalid Unicode - U_FLSMALL = 0xD806, // invalid Unicode - U_FFISMALL = 0xD807, // invalid Unicode - U_FFLSMALL = 0xD808, // invalid Unicode - U_CAPITALCWM = 0xD809, // invalid Unicode - U_ASCENDERCWM = 0xD80A, // invalid Unicode - U_INTERROBANGDOWN = 0xD80B, // invalid Unicode - U_TWELVEUDASH = 0xD80C, // invalid Unicode - U_RINGFITTED = 0xD80D, // invalid Unicode - U_USE_KERNX = 0xD80E, // invalid Unicode, not in maps - U_VS1 = 0xFE00, - U_VS16 = 0xFE0F, - U_VS17 = 0xE0100, - U_VS256 = 0xE01FF, - U_DOTLESSJ_2 = 0xF6BE, - U_THREEQUARTERSEMDASH = 0xF6DE, - U_FSMALL = 0xF766, - U_ISMALL = 0xF769, - U_LSMALL = 0xF76C, - U_SSMALL = 0xF773, - U_MATHDOTLESSJ = 0x1D6A5 +enum { + U_EXCLAMDOWN = 0x00A1, // U+00A1 INVERTED EXCLAMATION MARK + U_DEGREE = 0x00B0, // U+00B0 DEGREE SIGN + U_QUESTIONDOWN = 0x00BF, // U+00BF INVERTED QUESTION MARK + U_IJ = 0x0132, // U+0132 LATIN CAPITAL LIGATURE IJ + U_ij = 0x0133, // U+0133 LATIN SMALL LIGATURE IJ + U_DOTLESSJ = 0x0237, // U+0237 LATIN SMALL LETTER DOTLESS J + U_RINGABOVE = 0x02DA, // U+02DA RING ABOVE + U_COMBININGRINGABOVE = 0x030A, // U+030A COMBINING RING ABOVE + U_CWM = 0x200C, // U+200C ZERO WIDTH NON-JOINER + U_ENDASH = 0x2013, // U+2013 EN DASH + U_PERTENTHOUSAND = 0x2031, // U+2031 PER TEN THOUSAND SIGN + U_INTERROBANG = 0x203D, // U+203D INTERROBANG + U_FRACTION = 0x2044, // U+2044 FRACTION SLASH + U_CENTIGRADE = 0x2103, // U+2103 DEGREE CELSIUS + U_ASTERISKMATH = 0x2217, // U+2217 ASTERISK OPERATOR + U_BARDBL = 0x2225, // U+2225 PARALLEL TO + U_VISIBLESPACE = 0x2423, // U+2423 OPEN BOX + U_DBLBRACKETLEFT = 0x27E6, // U+27E6 MATHEMATICAL LEFT WHITE SQUARE BRACKET + U_DBLBRACKETRIGHT = 0x27E7, // U+27E7 MATHEMATICAL RIGHT WHITE SQUARE BRACKET + U_INTERROBANGDOWN = 0x2E18, // U+2E18 INVERTED INTERROBANG + U_EMPTYSLOT = 0xD801, // invalid Unicode (not handled by Secondary) + U_ALTSELECTOR = 0xD802, // invalid Unicode + U_CAPITALCWM = 0xD809, // invalid Unicode + U_ASCENDERCWM = 0xD80A, // invalid Unicode + U_TWELVEUDASH = 0xD80C, // invalid Unicode + U_RINGFITTED = 0xD80D, // invalid Unicode + + // BEGIN BACKWARDS COMPATIBILITY -- newer texglyphlist.txt does not include + // these code points + U_SS = 0xD800, // invalid Unicode + U_SSSMALL = 0xD803, // invalid Unicode + U_FFSMALL = 0xD804, // invalid Unicode + U_FISMALL = 0xD805, // invalid Unicode + U_FLSMALL = 0xD806, // invalid Unicode + U_FFISMALL = 0xD807, // invalid Unicode + U_FFLSMALL = 0xD808, // invalid Unicode + // END BACKWARDS COMPATIBILITY + + U_USE_KERNX = 0xD80E, // invalid Unicode, not in maps + U_VS1 = 0xFE00, + U_VS16 = 0xFE0F, + U_VS17 = 0xE0100, + U_VS256 = 0xE01FF, + U_DOTLESSJ_2 = 0xF6BE, + U_THREEQUARTERSEMDASH = 0xF6DE, + U_FSMALL = 0xF766, + U_ISMALL = 0xF769, + U_LSMALL = 0xF76C, + U_SSMALL = 0xF773, + U_MATHDOTLESSJ = 0x1D6A5 // U+1D6A5 MATHEMATICAL ITALIC SMALL DOTLESS J }; @@ -221,6 +227,34 @@ Secondary::~Secondary() } bool +Secondary::encode_uni(int code, PermString name, + const uint32_t *uni_begin, const uint32_t *uni_end, + Metrics &metrics, ErrorHandler *errh) +{ + if (uni_begin + 1 == uni_end) + return encode_uni(code, name, *uni_begin, metrics, errh); + else { + Vector<Setting> v; + int max_s = 0; + while (uni_begin != uni_end) { + Vector<Setting> subv; + int s = setting(*uni_begin, subv, metrics, errh); + if (s == 0) + return false; + if (subv.size() && v.size()) + v.push_back(Setting(Setting::KERN)); + for (Vector<Setting>::const_iterator it = subv.begin(); + it != subv.end(); ++it) + v.push_back(*it); + max_s = (max_s > s ? max_s : s); + ++uni_begin; + } + metrics.encode_virtual(code, name, 0, v, max_s > 1); + return true; + } +} + +bool Secondary::encode_uni(int code, PermString name, uint32_t uni, Metrics &metrics, ErrorHandler *errh) { Vector<Setting> v; @@ -251,7 +285,7 @@ Secondary::setting(uint32_t uni, Vector<Setting> &v, Metrics &metrics, ErrorHand if (_next) return _next->setting(uni, v, metrics, errh); else - return false; + return 0; } bool @@ -292,7 +326,9 @@ T1Secondary::char_setting(Vector<Setting> &v, Metrics &metrics, int uni, ...) bool T1Secondary::encode_uni(int code, PermString name, uint32_t uni, Metrics &metrics, ErrorHandler *errh) { - if (uni == U_ALTSELECTOR || (uni >= U_VS1 && uni <= U_VS16) || (uni >= U_VS17 && uni <= U_VS256)) { + if (uni == U_ALTSELECTOR + || (uni >= U_VS1 && uni <= U_VS16) + || (uni >= U_VS17 && uni <= U_VS256)) { Vector<Setting> v; setting(uni, v, metrics, errh); int which = (uni == U_ALTSELECTOR ? 0 : (uni <= U_VS16 ? uni - U_VS1 + 1 : uni - U_VS17 + 17)); @@ -398,6 +434,9 @@ T1Secondary::setting(uint32_t uni, Vector<Setting> &v, Metrics &metrics, ErrorHa int vsize = v.size(); extern int letterspace; + if (char_setting(v, metrics, uni, 0)) + return 1; + switch (uni) { case U_CWM: diff --git a/Build/source/texk/lcdf-typetools/otftotfm/secondary.hh b/Build/source/texk/lcdf-typetools/otftotfm/secondary.hh index 875068078ed..c349a48dcf6 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/secondary.hh +++ b/Build/source/texk/lcdf-typetools/otftotfm/secondary.hh @@ -65,6 +65,7 @@ class Secondary { public: virtual ~Secondary(); void set_next(Secondary *s) { _next = s; } typedef Efont::OpenType::Glyph Glyph; + bool encode_uni(int code, PermString name, const uint32_t *uni_begin, const uint32_t *uni_end, Metrics &metrics, ErrorHandler *errh); virtual bool encode_uni(int code, PermString name, uint32_t uni, Metrics &, ErrorHandler *); virtual int setting(uint32_t uni, Vector<Setting> &, Metrics &, ErrorHandler *); private: diff --git a/Build/source/texk/lcdf-typetools/otftotfm/util.cc b/Build/source/texk/lcdf-typetools/otftotfm/util.cc index 241d2eb733c..e2769da429b 100644 --- a/Build/source/texk/lcdf-typetools/otftotfm/util.cc +++ b/Build/source/texk/lcdf-typetools/otftotfm/util.cc @@ -52,7 +52,7 @@ read_file(String filename, ErrorHandler *errh, bool warning) while (!feof(f)) { if (char *x = sa.reserve(8192)) { int amt = fread(x, 1, 8192, f); - sa.forward(amt); + sa.adjust_length(amt); } else { errh->xmessage((warning ? errh->e_warning : errh->e_error) + ErrorHandler::make_landmark_anno(filename), "Out of memory!"); break; @@ -206,7 +206,8 @@ parse_unicode_number(const char* begin, const char* end, int require_prefix, uin else return false; - if (value <= 0xD7FF || (value >= 0xE000 && value <= 0x10FFFF)) { + if (value > 0 + && (value <= 0xD7FF || (value >= 0xE000 && value <= 0x10FFFF))) { result = value; return true; } else @@ -233,7 +234,7 @@ shell_command_output(String cmdline, const String &input, ErrorHandler *errh, bo while (!feof(p) && !ferror(p) && sa.length() < 200000) { int x = fread(sa.reserve(2048), 1, 2048, p); if (x > 0) - sa.forward(x); + sa.adjust_length(x); else if (x < 0 && errno != EAGAIN) errh->error("%<%s%>: %s", cmdline.c_str(), strerror(errno)); } |