From 6971d4a0340aad6736ef6bd7bd16361d156142dd Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 3 Feb 2017 07:39:11 +0100 Subject: [db] fix dd conversion of asked size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes @zhouyan’s description of the conversion in case we’ll ever add further units. Reviewed-by: Yan Zhou --- src/luaotfload-database.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index 199eca8..87b4101 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -1061,10 +1061,33 @@ do --- we scale the requested size as though the value in the font was --- specified in the requested unit. + --- From @zhouyan: + + --- Let P be the asked size in pt, and Aᵤ = CᵤP, where u is the + --- designed unit, pt, bp, or dd, and + --- + --- Cpt = 1, Cbp = 7200/7227, Cdd = 1157/1238. + --- + --- That is, Aᵤ is the asked size in the desired unit. Let D be the + --- de-sign size (assumed to be in the unit of bp) as reported by + --- the font (divided by 10; in all the following we ignore the + --- factor 2^16 ). + --- + --- For simplicity, consider only the case of exact match to the + --- design size. That is, we would like to have Aᵤ = D. Let A′ᵤ = αᵤP + --- and D′ = βD be the scaled values used in comparisons. For the + --- comparison to work correctly, we need, + --- + --- Aᵤ = D ⟺ A′ᵤ = D′ , + --- + --- and thus αᵤ = βCᵤ. The fix in PR 400 is the case of β = 1. The + --- fix for review is β = 7227/7200, and the value of αᵤ is thus + --- correct for pt, bp, but not for dd. + local dimens = { bp = false, pt = function (v) return v * (7227 / 7200) end, - dd = function (v) return v * (7227 / 7200) * (1238 / 1157) end, + dd = function (v) return v * (7227 / 7200) * (1157 / 1238) end, } design_size_dimension = dimens.bp -- cgit v1.2.3