Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
[db] scale optical sizes to pt
Browse files Browse the repository at this point in the history
Fix #389
  • Loading branch information
phi-gamma committed Jan 29, 2017
1 parent 0baccc9 commit 6b324ec
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions src/luaotfload-database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ load_names = function (dry_run, no_rebuild)
names_version = names.version
if db_version ~= names_version then
logreport ("both", 0, "db",
[[Version mismatch; expected %4.3f, got %4.3f.]],
[[Version mismatch; expected %d, got %d.]],
names_version, db_version)
if not fonts_reloaded then
logreport ("both", 0, "db", [[Force rebuild.]])
Expand Down Expand Up @@ -1322,28 +1322,40 @@ local load_font_file = function (filename, subfont)
return ret
end

--- rawdata -> (int * int * int | bool)
local get_size_info do --- too many upvalues :/
local design_dimension_bp = true
local pt, bp = 7227.0, 7200.0

local get_size_info = function (rawinfo)
local design_size = rawinfo.design_size
local design_range_top = rawinfo.design_range_top
local design_range_bottom = rawinfo.design_range_bottom
--- rawdata -> (int * int * int | bool)

local fallback_size = design_size ~= 0 and design_size
or design_range_bottom ~= 0 and design_range_bottom
or design_range_top ~= 0 and design_range_top
get_size_info = function (rawinfo)
local design_size = rawinfo.design_size
local design_range_top = rawinfo.design_range_top
local design_range_bottom = rawinfo.design_range_bottom

if fallback_size then
design_size = (design_size or fallback_size) / 10
design_range_top = (design_range_top or fallback_size) / 10
design_range_bottom = (design_range_bottom or fallback_size) / 10
return {
design_size, design_range_top, design_range_bottom,
}
end
local fallback_size = design_size ~= 0 and design_size
or design_range_bottom ~= 0 and design_range_bottom
or design_range_top ~= 0 and design_range_top

return false
end
if fallback_size then
design_size = (design_size or fallback_size) / 10
design_range_top = (design_range_top or fallback_size) / 10
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
end

return {
design_size, design_range_top, design_range_bottom,
}
end

return false
end
end ---[local get_size_info]

--[[doc--
map_enlish_names -- Names-table for Lua fontloader objects. This
Expand Down Expand Up @@ -2605,7 +2617,7 @@ do
polluting the lookup table. What doesn’t work is, e. g.
treating weights > 500 as bold or allowing synonyms like
“heavy”, “black”.
--]]--
--]]--
if width == normal_width then
if pfmweight == bold_weight then
--- bold spectrum matches
Expand Down Expand Up @@ -3599,7 +3611,7 @@ return {
fonts.definers = fonts.definers or { resolvers = { } }

names.blacklist = blacklist
names.version = 2.9
names.version = 3 --- increase monotonically
names.data = nil --- contains the loaded database
names.lookups = nil --- contains the lookup cache

Expand Down

0 comments on commit 6b324ec

Please sign in to comment.