From bc4237aa7d632dca64332e75d8853f642523cb9d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 8 Jun 2010 00:48:36 +0000 Subject: luaotfload 1.10 (7jun10) git-svn-id: svn://tug.org/texlive/trunk@18808 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/luaotfload/NEWS | 15 ++ .../doc/luatex/luaotfload/luaotfload.pdf | Bin 313337 -> 318005 bytes .../scripts/luaotfload/mkluatexfontdb.lua | 40 +--- .../texmf-dist/source/luatex/luaotfload/Makefile | 18 +- .../source/luatex/luaotfload/luaotfload.dtx | 83 ++++++--- .../tex/luatex/luaotfload/luaotfload.lua | 27 ++- .../tex/luatex/luaotfload/luaotfload.sty | 2 +- .../tex/luatex/luaotfload/otfl-font-clr.lua | 2 +- .../tex/luatex/luaotfload/otfl-font-nms.lua | 204 +++++++++++---------- .../tex/luatex/luaotfload/otfl-font-xtx.lua | 16 +- .../tex/luatex/luaotfload/otfl-luat-ovr.lua | 1 + 11 files changed, 244 insertions(+), 164 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/luatex/luaotfload/NEWS b/Master/texmf-dist/doc/luatex/luaotfload/NEWS index fc39edc44b7..cdebd817372 100644 --- a/Master/texmf-dist/doc/luatex/luaotfload/NEWS +++ b/Master/texmf-dist/doc/luatex/luaotfload/NEWS @@ -1,6 +1,21 @@ Change History -------------- +2010/06/07, luaotfload v1.10: + * provide a fonts.names.scan(dir) function that temporally loads fonts + from the specified dir into the names database + * Log loaded font file before attempting to open it + * fix XeTeX's square brackets syntax so that it doesn't trigger database + update + * fix loading fonts with absolute path + * add \fontdimen8 support, for XeTeX compatibility + * be more verbose when updating the font database + * improve fonts.conf parsing + * make sure when a TFM font is requested we don't end up loading a non-TFM + font with a similar name instead + * Remove --fc-cache option from mkluatexfontdb.lua, since we no longer use + fontconfig tools + 2010/05/30, luaotfload v1.09: * the last release didn't even load * fix passing --destdir to mkluatexfontdb diff --git a/Master/texmf-dist/doc/luatex/luaotfload/luaotfload.pdf b/Master/texmf-dist/doc/luatex/luaotfload/luaotfload.pdf index 17d6bc63f7f..606246b52d5 100644 Binary files a/Master/texmf-dist/doc/luatex/luaotfload/luaotfload.pdf and b/Master/texmf-dist/doc/luatex/luaotfload/luaotfload.pdf differ diff --git a/Master/texmf-dist/scripts/luaotfload/mkluatexfontdb.lua b/Master/texmf-dist/scripts/luaotfload/mkluatexfontdb.lua index 5eac9ae06af..a72478bda7f 100755 --- a/Master/texmf-dist/scripts/luaotfload/mkluatexfontdb.lua +++ b/Master/texmf-dist/scripts/luaotfload/mkluatexfontdb.lua @@ -36,13 +36,13 @@ Valid options: -v --verbose=LEVEL be more verbose (print the searched directories) -vv print the loaded fonts -vvv print all steps of directory searching - --fc-cache run fc-cache before updating database --sys install the database system-wide (default is only for the current user) -V --version print version and exit -h --help print this message -Fonts are found on Windows or Linux with fontconfig (i.e., using fc-list). +Fonts are searched in directories on Windows or Linux that have been +searched with fontconfig. On Mac OS X, only fonts located in the following standard font locations are included in the font database: @@ -51,12 +51,12 @@ included in the font database: In particular, fonts installed in other locations with "Font Book" will not be available. -Rather than using fontconfig or, in Mac OS X, searching the default font -locations, you may specify where fonts are located by setting the OSFONTDIR -environment variable. Doing so will override the use of fontconfig or -scanning the system font locations. If you wish to continue to include them -while also including other font locations, simply include them in the list. -For example (using a bash shell), +Rather than using the fontconfig locations or, in Mac OS X, searching the +default system font locations, you may specify where fonts are located by +setting the OSFONTDIR environment variable. Doing so will override the use of +fontconfig or scanning the system font locations. If you wish to continue to +include them while also including other font locations, simply include them in +the list. For example (using a bash shell), export OSFONTDIR='/path/to/other/fonts:/Users/will/Library/Fonts:...' @@ -80,7 +80,6 @@ local long_opts = { force = "f", quiet = "q", help = "h", - ['fc-cache'] = 0 , sys = 0 , verbose = 1 , version = "V", @@ -88,26 +87,6 @@ local long_opts = { local short_opts = "d:fqpvVh" -local function do_run_fc_cache(c) - --[[ - Function running fc-cache if needed. - The argument is nil for default, 0 for no fc-cache and 1 for fc-cache. - Default behaviour is to run fc-cache if available. - --]] - if c == 0 then return end - if not c then - -- TODO: detect if fc-cache is available - end - local toexec = 'fc-cache' - if os.type == 'windows' then - toexec = 'fc-cache.exe' -- TODO: to test on a non-cygwin Windows - end - log('executing %s...\n', toexec) - os.execute(toexec) -end - --- a temporary variable, containing the command line option concerning fc-cache -local run_fc_cache = 0 local force_reload = nil local function process_cmdline() @@ -132,8 +111,6 @@ local function process_cmdline() output_directory = optarg [i] elseif v == "f" then force_reload = 1 - elseif v == "fc-cache" then - run_fc_cache = 1 elseif v == "sys" then output_directory = names.path.systemdir end @@ -146,7 +123,6 @@ local function process_cmdline() end process_cmdline() -do_run_fc_cache(run_fc_cache) local function generate(force) log("generating font names database.") diff --git a/Master/texmf-dist/source/luatex/luaotfload/Makefile b/Master/texmf-dist/source/luatex/luaotfload/Makefile index 2f38501ec9c..0dbcb178512 100644 --- a/Master/texmf-dist/source/luatex/luaotfload/Makefile +++ b/Master/texmf-dist/source/luatex/luaotfload/Makefile @@ -15,6 +15,8 @@ SOURCE = $(DTX) $(OTFL) README Makefile NEWS $(SCRIPT) # test files TESTDIR = tests TESTFILES = $(wildcard $(TESTDIR)/*.tex) +TESTFILE_SYS = $(TESTDIR)/systemfonts.tex $(TESTDIR)/fontconfig_conf_reading.tex +TESTFILES_TL = $(filter-out $(TESTFILE_SYS), $(TESTFILES)) # Files grouped by installation location SCRIPTFILES = $(SCRIPT) @@ -84,12 +86,18 @@ install: $(ALL_FILES) @echo "Installing in '$(TEXMFROOT)'." $(run-install) -check: $(RUNFILES) $(TESTFILES) - @for f in $(TESTFILES); do \ +check: $(RUNFILES) $(TESTFILES_TL) + @for f in $(TESTFILES_TL); do \ echo "check: luatex $$f"; \ - luatex --interaction=batchmode $$f > /dev/null || exit $$?; \ + luatex --interaction=batchmode --output-directory $(TESTDIR) $$f \ + > /dev/null || exit $$?; \ done +check-all: $(TESTFILE_SYS) check + @echo "check: luatex $<" + @luatex --interaction=batchmode --output-directory $(TESTDIR) $< \ + >/dev/null + manifest: @echo "Source files:" @for f in $(SOURCE); do echo $$f; done @@ -98,8 +106,8 @@ manifest: @for f in $(GENERATED); do echo $$f; done clean: - @$(RM) -- *.log *.aux *.toc *.idx *.ind *.ilg *.out + @$(RM) -- *.log *.aux *.toc *.idx *.ind *.ilg *.out $(TESTDIR)/*.log mrproper: clean - @$(RM) -- $(GENERATED) $(ZIPS) + @$(RM) -- $(GENERATED) $(ZIPS) $(TESTDIR)/*.pdf diff --git a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx index 975680b8612..874843b62fc 100644 --- a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx +++ b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx @@ -35,7 +35,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: luaotfload 2010/05/30 v1.09 ConTeXt font loading system} +\Msg{* Package: luaotfload 2010/06/07 v1.10 ConTeXt font loading system} \Msg{************************************************************************} \keepsilent @@ -102,7 +102,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luaotfload.drv}% - [2010/05/30 v1.09 ConTeXt font loading system]% + [2010/06/07 v1.10 ConTeXt font loading system]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb} \usepackage[colorlinks=true]{hyperref} @@ -140,7 +140,7 @@ and the derived files % \GetFileInfo{luaotfload.drv} % % \title{The \textsf{luaotfload} package} -% \date{2010/05/30 v1.09} +% \date{2010/06/07 v1.10} % \author{ Elie Roux\footnote{\texttt{elie.roux@telecom-bretagne.eu}} % \and Khaled Hosny\footnote{\texttt{khaledhosny@eglug.org}}} % @@ -311,25 +311,23 @@ and the derived files % to keep track of fonts available to \LuaTeX. Using this database, fonts can % be loaded by font name as well as filename. % -% This font database must be maintained as you add (and remove) fonts to your -% system. To update the database, run the script |mkluatexfontdb.lua| that is -% included with this package. If you have not run it before, it may take quite -% some time to process every font on your computer. Subsequent runs to update -% the database will be quite fast, however. -% -% In \TeX~Live~2010, there will be a button in the \TeX~Live package manager -% to run |mkluatexfontdb.lua|. +% This font database is maintained automatically as you add and remove fonts +% to/from your system. To update the database manually, run the script +% |mkluatexfontdb| that is included with this package. If you have not run it +% before, it may take quite some time to process every font on your computer. +% This is particularly noticeable if it occurs during a typesetting run. +% Subsequent runs to update the database will be quite fast, however. % % The script will parse standard places for fonts in your system to build the -% font database. On Windows and Linus, it will use |fc-list| to find the -% fonts; on Mac~OS~X, it will search in the standard font locations -% |~/Library/Fonts|, |/Library/Fonts|, |/System/Library/Fonts|, and -% |/Network/Library/Fonts|, +% font database. Linux, it will use |fontconfig| to find the font locations; +% on Windows and Mac~OS~X, it will search in the standard font locations, +% |%WINDIR%\Fonts| in Windows and |~/Library/Fonts|, |/Library/Fonts|, +% |/System/Library/Fonts|, and |/Network/Library/Fonts| in Mac~OS~X. % -% If you do not wish the script to locate fonts automatically but would rather -% specify the exact locations in which to find your fonts, set the |OSFONTDIR| -% environment variable instead. When this variable is set, the script will -% only search in those directories. +% If you do not wish the script to search the standard font locations by +% default but would rather specify the exact locations in which to find your +% fonts, set the |OSFONTDIR| environment variable instead. When this variable +% is set, the script will only search in those directories. % % |mkluatexfontdb.lua --help| provides a brief summary of the functionality of % the script and includes some advanced options that we have not mentioned @@ -413,8 +411,8 @@ module('luaotfload', package.seeall) luaotfload.module = { name = "luaotfload", - version = 1.09, - date = "2010/05/30", + version = 1.10, + date = "2010/06/07", description = "ConTeXt font loading system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", @@ -459,6 +457,8 @@ end % \end{macrocode} % +% \subsection{Module loading} +% % We load the \ConTeXt\ files with this function. It automatically adds the % \texttt{otfl-} prefix to it, so that we call it with the actual \ConTeXt\ % name. @@ -556,6 +556,42 @@ luaotfload.loadmodule('font-clr.lua') % \end{macrocode} % +% \subsection{Emulating font dimensions} +% +% And here add some code to emulate \XeTeX's \cs{fontdimen8}, +% which stores the caps-height of the font. (Cf.\ \cs{fontdimen5} which +% stores the x-height.) +% +% Falls back to measuring the glyph if the font doesn't contain the +% necessary information. +% This needs to be extended for fonts that don't contain an `X'. +% +% \begin{macrocode} +local function def_font(...) + local fontdata = fonts.define.read(...) + if type(fontdata) == "table" and fontdata.shared then + local capheight + local units = fontdata.units + local size = fontdata.size + local otfdata = fontdata.shared.otfdata + + if otfdata.pfminfo.os2_capheight > 0 then + capheight = otfdata.pfminfo.os2_capheight/units*size + else + if fontdata.characters[string.byte("X")] then + capheight = fontdata.characters[string.byte("X")].height + else + capheight = otfdata.metadata.ascent/units*size + end + end + fontdata.parameters[8] = capheight + end + return fontdata +end +% \end{macrocode} +% +% \subsection{\ConTeXt\ override} +% % Here we override some defaults set in \ConTeXt\ code. % % \begin{macrocode} @@ -577,7 +613,7 @@ function luaotfload.register_callbacks() 'luaotfload.hpack_filter') luatexbase.reset_callback('define_font') luatexbase.add_to_callback('define_font', - fonts.define.read, + def_font, 'luaotfload.define_font', 1) luatexbase.add_to_callback('find_vf_file', fonts.vf.find, @@ -595,6 +631,7 @@ function luaotfload.unregister_callbacks() 'luaotfload.find_vf_file') end % \end{macrocode} +% % \iffalse % % \fi @@ -616,7 +653,7 @@ end \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luaotfload}% - [2010/05/30 v1.09 ConTeXt font loading system] + [2010/06/07 v1.10 ConTeXt font loading system] \RequirePackage{luatextra} \fi diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua index bcf831d10f9..7396218ca4d 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.lua @@ -20,8 +20,8 @@ module('luaotfload', package.seeall) luaotfload.module = { name = "luaotfload", - version = 1.09, - date = "2010/05/30", + version = 1.10, + date = "2010/06/07", description = "ConTeXt font loading system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", @@ -111,6 +111,27 @@ luaotfload.loadmodule('font-dum.lua') luaotfload.loadmodule('font-nms.lua') luaotfload.loadmodule('font-clr.lua') +local function def_font(...) + local fontdata = fonts.define.read(...) + if type(fontdata) == "table" and fontdata.shared then + local capheight + local units = fontdata.units + local size = fontdata.size + local otfdata = fontdata.shared.otfdata + + if otfdata.pfminfo.os2_capheight > 0 then + capheight = otfdata.pfminfo.os2_capheight/units*size + else + if fontdata.characters[string.byte("X")] then + capheight = fontdata.characters[string.byte("X")].height + else + capheight = otfdata.metadata.ascent/units*size + end + end + fontdata.parameters[8] = capheight + end + return fontdata +end fonts.mode = "node" @@ -124,7 +145,7 @@ function luaotfload.register_callbacks() 'luaotfload.hpack_filter') luatexbase.reset_callback('define_font') luatexbase.add_to_callback('define_font', - fonts.define.read, + def_font, 'luaotfload.define_font', 1) luatexbase.add_to_callback('find_vf_file', fonts.vf.find, diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty index 4a1aa9d4559..c2bccfdcb51 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty @@ -24,7 +24,7 @@ \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luaotfload}% - [2010/05/30 v1.09 ConTeXt font loading system] + [2010/06/07 v1.10 ConTeXt font loading system] \RequirePackage{luatextra} \fi diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-clr.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-clr.lua index e1f0faa4184..a6cf63ffc9f 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-clr.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-clr.lua @@ -16,7 +16,7 @@ table.insert(fonts.triggers,"color") function initializers.common.color(tfmdata,value) if value then - tfmdata.color = value + tfmdata.color = tostring(value) add_color_callback() end end diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua index 4050f266096..73a45c9dbf0 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua @@ -38,7 +38,7 @@ local splitpath, expandpath = file.split_path, kpse.expand_path local glob, basename = dir.glob, file.basename local upper, lower, format = string.upper, string.lower, string.format local gsub, match, rpadd = string.gsub, string.match, string.rpadd -local gmatch, sub = string.gmatch, string.sub +local gmatch, sub, find = string.gmatch, string.sub, string.find local utfgsub = unicode.utf8.gsub local trace_short = false --tracing adapted to rebuilding of the database inside a document @@ -93,11 +93,10 @@ function names.load() foundname = systempath end if data then - logs.report("load font", - "loaded font names database: %s", foundname) + logs.info("Font names database loaded: " .. foundname) else - logs.report("load font", - "no font names database found, generating new one") + logs.info([[Font names database not found, generating new one. + This can take several minutes; please be patient.]]) data = names.update() names.save(data) end @@ -128,24 +127,6 @@ local loaded = false local reloaded = false function names.resolve(specification) - local tfm = resolvers.find_file(specification.name, "tfm") - local ext = lower(file.extname(specification.name)) - - if tfm then - -- is a tfm font, skip names database - if ext == 'tfm' then - return specification.name, false - else - return specification.name..'.tfm', false - end - elseif resolvers.find_file(specification.name, "ofm") then - if ext == 'ofm' then - return specification.name, false - else - return specification.name..'.ofm', false - end - end - local name = sanitize(specification.name) local style = sanitize(specification.style) or "regular" @@ -165,28 +146,6 @@ function names.resolve(specification) local data = names.data if type(data) == "table" and data.version == names.version then if data.mappings then - -- if the specified name ends like a font file, we first look for - -- it through kpse, and if we don't find it, we look for it in - -- the database. - if table.contains(font_extensions_lc, ext) then - local fname = specification.name - -- for absolute and relative path, kpse will find them, so - -- there shouldn't be any problem - local path = resolvers.find_file(fname, "opentype fonts") - if not path then - path = resolvers.find_file(fname, "truetype fonts") - end - if path then - return path -- or fname ? - else - for _,face in ipairs(data.mappings) do - if basename(face.filename[1]) == fname then - return face.filename[1], face.filename[2] - end - end - end - return specification.name - end local found = { } for _,face in ipairs(data.mappings) do local family = sanitize(face.names.family) @@ -230,8 +189,6 @@ function names.resolve(specification) found[1] = face break end - else - found[1] = face end else if name == fullname @@ -437,9 +394,6 @@ local function load_font(filename, fontnames, newfontnames, texmf) end return end - if trace_loading then - logs.report("loading font: %s", basefile) - end local info = fontloader.info(filename) if info then if type(info) == "table" and #info > 1 then @@ -508,15 +462,9 @@ fonts.path_normalize = path_normalize if os.name == "macosx" then -- While Mac OS X 10.6 has a problem with TTC files, ignore them globally: - font_extensions = { - "otf", "ttf", "dfont", "OTF", "TTF", "DFONT" - } - font_extensions_lc = { "otf", "ttf", "dfont" } + font_extensions = { "otf", "ttf", "dfont" } else - font_extensions = { - "otf", "ttf", "ttc", "dfont", "OTF", "TTF", "TTC", "DFONT" - } - font_extensions_lc = { "otf", "ttf", "ttc", "dfont" } + font_extensions = { "otf", "ttf", "ttc", "dfont" } end local function scan_dir(dirname, fontnames, newfontnames, texmf) @@ -532,23 +480,28 @@ local function scan_dir(dirname, fontnames, newfontnames, texmf) if trace_search then logs.report("scanning '%s'", dirname) end - for _,ext in ipairs(font_extensions) do - found = glob(dirname .. "/**." .. ext) - -- note that glob fails silently on broken symlinks, which happens - -- sometimes in TeX Live. - if trace_search then - logs.report("%s '%s' fonts found", #found, ext) + for _,i in next, font_extensions do + for _,ext in next, { i, upper(i) } do + found = glob(format("%s/**.%s$", dirname, ext)) + -- note that glob fails silently on broken symlinks, which happens + -- sometimes in TeX Live. + if trace_search then + logs.report("%s '%s' fonts found", #found, ext) + end + nbfound = nbfound + #found + table.append(list, found) end - nbfound = nbfound + #found - table.append(list, found) end if trace_search then logs.report("%d fonts found in '%s'", nbfound, dirname) end list = remove_ignore_fonts(list) -- fixme: general solution required - for _,fnt in ipairs(list) do - fnt = path_normalize(fnt) - load_font(fnt, fontnames, newfontnames, texmf) + for _,file in next, list do + file = path_normalize(file) + if trace_loading then + logs.report("loading font: %s", file) + end + load_font(file, fontnames, newfontnames, texmf) end end @@ -583,15 +536,15 @@ local function scan_texmf_fonts(fontnames, newfontnames) --]] if trace_progress then if expandpath("$OSFONTDIR"):is_empty() then - logs.report("scanning TEXMF fonts:") + logs.report("Scanning TEXMF fonts:") else - logs.report("scanning TEXMF and OS fonts:") + logs.report("Scanning TEXMF and OS fonts:") end elseif trace_short then if expandpath("$OSFONTDIR"):is_empty() then - logs.info("scanning TEXMF fonts...") + logs.info("Scanning TEXMF fonts...") else - logs.info("scanning TEXMF and OS fonts...") + logs.info("Scanning TEXMF and OS fonts...") end end local fontdirs = expandpath("$OPENTYPEFONTS"):gsub("^\.", "") @@ -625,26 +578,73 @@ end The code is minimal, please report any error it may generate. ]] -local function read_fonts_conf() - local f = io.open("/etc/fonts/fonts.conf") +local function read_fonts_conf(path, results) + local f = io.open(path) if not f then - error("Cannot open the file /etc/fonts/fonts.conf") + error("Cannot open the file "..path) end - local results = {} local incomments = false for line in f:lines() do - -- spaghetti code... hmmm... - if incomments and sub(line, 1, 3) == '-->' then - incomments = false - elseif sub(line, 1, 4) == '') + if tmp then + incomments = false + line = sub(line, tmp+3) + else + line = nil + end + else + local tmp = find(line, '