From bd0a8039e89b9403b58ac5a9827a333276a6fbf6 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Sat, 22 Jun 2013 16:16:21 +0200
Subject: treat *medium* as a synonym for *bold*
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

treating *medium* as *regular* weight leads to incorrect matches with
Garamond Premier and likely other fonts as well. apparently, this also
happened with other typographical programs, e. g.

    http://blogs.adobe.com/typblography/2008/05/indesign_font_conflicts.html

note: the matching algorithm could be rewritten so as to resolve names
in two passes:

1. collect a list of candidates. if there is a literal match, pick that one

2. test style synonyms against the candidates according to a precedence list so that “regular” always precedes “medium”

to take this thought a bit further, the synonyms could also be ordered
by weight according to some assumptions. then we could pick the closest
weight present in the database. example: suppose *regular* is assigned a
weight index of 3, *medium* gets *4* (i. e. just a tad heavier), and
*bold* 7.  then the synonym regular would be preferred for the request
*regular* if present, but medium would be chosen over bold if there is
no *regular* shape. this would probably be overkill, though.
---
 luaotfload-database.lua | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 41adf88..4c45d21 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -326,12 +326,14 @@ end
 
 local style_synonyms = { set = { } }
 do
+    --- read this: http://blogs.adobe.com/typblography/2008/05/indesign_font_conflicts.html
+    --- tl;dr: font style synonyms are unreliable.
     style_synonyms.list = {
-        regular    = { "normal",        "roman",
-                       "plain",         "book",
-                       "medium", },
+        regular    = { "normal",         "roman",
+                       "plain",          "book", },
         bold       = { "demi",           "demibold",
-                       "semibold",       "boldregular",},
+                       "semibold",       "boldregular",
+                       "medium" },
         italic     = { "regularitalic",  "normalitalic",
                        "oblique",        "slanted", },
         bolditalic = { "boldoblique",    "boldslanted",
-- 
cgit v1.2.3