diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luaotfload-configuration.lua | 49 | ||||
-rw-r--r-- | src/luaotfload-database.lua | 39 |
2 files changed, 74 insertions, 14 deletions
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index 8484c62..46e9074 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -92,6 +92,11 @@ local valid_formats = tabletohash { "otf", "ttc", "ttf", "afm", "pfb" } +--- cf. TeXbook p. 57 +local valid_designsize_dimens = tabletohash { + "bp", "pt", "dd" +} + local default_anon_sequence = { "tex", "path", "name" } @@ -203,6 +208,7 @@ local default_config = { update_live = true, compress = true, max_fonts = 2^51, + designsize_dimen= "bp", }, run = { anon_sequence = default_anon_sequence, @@ -314,6 +320,18 @@ local set_font_filter = function () return true end +local set_size_dimension = function () + local names = fonts.names + if names and names.size_dimension then + local dim = config.luaotfload.db.designsize_dimen + if not dim or dim == "" then + dim = default_config.db.designsize_dimen + end + names.set_size_dimension (dim) + end + return true +end + local set_name_resolver = function () local names = fonts.names if names and names.resolve_cached then @@ -382,6 +400,7 @@ reconf_tasks = { { "Build cache paths" , build_cache_paths }, { "Check terminal dimensions" , check_termwidth }, { "Set the font filter" , set_font_filter }, + { "Set design size dimension" , set_size_dimension }, { "Install font name resolver", set_name_resolver }, { "Set default features" , set_default_features }, } @@ -482,6 +501,21 @@ local option_spec = { out_t = number_t, --- TODO int_t from 5.3.x on transform = tointeger, }, + designsize_dimen = { + in_t = string_t, + out_t = string_t, + transform = function (dim) + if not valid_designsize_dimens [dim] then + local default = valid_designsize_dimens.__default + logreport ("both", 0, "conf", + "Invalid dimension %q specified for design sizes, \z + using default %q.", dim, default) + return default + end + logreport ("both", 4, "conf", "Chosen design size dimension %q.", dim) + return dim + end + }, }, run = { anon_sequence = { @@ -698,13 +732,14 @@ local conf_footer = [==[ local formatters = { db = { - compress = { false, format_boolean }, - formats = { false, format_string }, - max_fonts = { false, format_integer }, - scan_local = { false, format_boolean }, - skip_read = { false, format_boolean }, - strip = { false, format_boolean }, - update_live = { false, format_boolean }, + compress = { false, format_boolean }, + designsize_dimen = { false, format_string }, + formats = { false, format_string }, + max_fonts = { false, format_integer }, + scan_local = { false, format_boolean }, + skip_read = { false, format_boolean }, + strip = { false, format_boolean }, + update_live = { false, format_boolean }, }, default_features = { __default = { true, format_keyval }, diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index d0a2420..5750966 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -162,7 +162,6 @@ local tablesort = table.sort local utf8gsub = unicode.utf8.gsub local utf8lower = unicode.utf8.lower local utf8len = unicode.utf8.len -local zlibcompress = zlib.compress --- these come from Lualibs/Context local filebasename = file.basename @@ -1322,9 +1321,34 @@ local load_font_file = function (filename, subfont) return ret end -local get_size_info do --- too many upvalues :/ - local design_dimension_bp = true - local pt, bp = 7227.0, 7200.0 +local set_size_dimension +local get_size_info +do --- too many upvalues :/ + --- cf. TeXbook p. 57 + local dimens = { + pt = function (v) return v end, + bp = function (v) return (v * 7200.0) / 7227.0 end, + dd = function (v) return (v * 1157.0) / 1238.0 end, + } + + local dimen_pt = 1 + local dimen_bp = 2 + local dimen_dd = 3 + + local size_dimen = dimens.bp + local set_size_dimen = function (dim) + local f = dimens [dim] + if f then + logreport ("both", 4, "db", + "Interpreting design sizes as %q, factor %.6f.", + dim, f (1.000000)) + size_dimen = f + return + end + logreport ("both", 0, "db", + "Invalid dimension %q requested for design sizes; \z + ignoring.") + end --- rawdata -> (int * int * int | bool) @@ -1343,9 +1367,9 @@ local get_size_info do --- too many upvalues :/ design_range_bottom = (design_range_bottom or fallback_size) / 10 if design_dimension_bp == true then - design_size = (design_size * bp) / pt - design_range_top = (design_range_top * bp) / pt - design_range_bottom = (design_range_bottom * bp) / pt + design_size = size_dimen (design_size ) + design_range_top = size_dimen (design_range_top ) + design_range_bottom = size_dimen (design_range_bottom) end return { @@ -3572,6 +3596,7 @@ local api = { local export = { set_font_filter = set_font_filter, + set_size_dimension = set_size_dimension, flush_lookup_cache = flush_lookup_cache, save_lookups = save_lookups, load = load_names, |