summaryrefslogtreecommitdiff
path: root/src/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-04-21 23:24:27 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-04-21 23:24:27 +0200
commit9f3000ade19fda594cef0f5ee37cdb88eb638e87 (patch)
tree7647605a178876f2ee9772f09961c67f0a2a0fc1 /src/luaotfload-database.lua
parentff1cc8f4d4e1d52cc1e9df9fd01f74395c782db5 (diff)
downloadluaotfload-9f3000ade19fda594cef0f5ee37cdb88eb638e87.tar.gz
Revert "[db,conf] drop support for PS fonts"
This reverts commit c4c250414a83cc8c4ae99d286ed69a3763510609. Partially, anyways: All mentions of the PFA format were stripped. Since the new loader adds back in support for PFB-flavored PS fonts without AFM we should support it from Luaotfload as well.
Diffstat (limited to 'src/luaotfload-database.lua')
-rw-r--r--src/luaotfload-database.lua70
1 files changed, 64 insertions, 6 deletions
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 135ab0e..f18875c 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -207,8 +207,7 @@ local make_luanames = function (path)
end
local format_precedence = {
- "otf", "ttc", "ttf", "afm",
- --- "pfb", "pfa",
+ "otf", "ttc", "ttf", "afm", "pfb"
}
local location_precedence = {
@@ -359,7 +358,7 @@ This is a sketch of the luaotfload db:
conflicts : { barename : int; basename : int }; // filename conflict with font at index; happens with subfonts
familyname : string; // sanitized name of the font family the font belongs to, usually from the names table
fontname : string; // sanitized name of the font
- format : string; // "otf" | "ttf" | "afm"
+ format : string; // "otf" | "ttf" | "afm" | "pfb"
fullname : string; // sanitized full name of the font including style modifiers
fullpath : string; // path to font in filesystem
index : int; // index in the mappings table
@@ -495,6 +494,7 @@ local lookup_fullpath
local save_lookups
local save_names
local set_font_filter
+local t1_fullinfo
local update_names
--- state of the database
@@ -1617,13 +1617,71 @@ ot_fullinfo = function (filename,
return res
end
+--[[doc--
+
+ Type1 font inspector. In comparison with OTF, PFB’s contain a good
+ deal less name fields which makes it tricky in some parts to find a
+ meaningful representation for the database.
+
+ Good read: http://www.adobe.com/devnet/font/pdfs/5004.AFM_Spec.pdf
+
+--doc]]--
+
+--- string -> int -> bool -> string -> fontentry
+
+t1_fullinfo = function (filename, _subfont, location, basename, format)
+ local sanitized
+ local metadata = load_font_file (filename)
+ local fontname = metadata.fontname
+ local fullname = metadata.fullname
+ local familyname = metadata.familyname
+ local italicangle = metadata.italicangle
+ local style = ""
+ local weight
+
+ sanitized = sanitize_fontnames ({
+ fontname = fontname,
+ psname = fullname,
+ metafamily = familyname,
+ familyname = familyname,
+ weight = metadata.weight, --- string identifier
+ prefmodifiers = style,
+ })
+
+ weight = sanitized.weight
+
+ if weight == "bold" then
+ style = weight
+ end
+
+ if italicangle ~= 0 then
+ style = style .. "italic"
+ end
+
+ return {
+ basename = basename,
+ fullpath = filename,
+ subfont = false,
+ location = location or "system",
+ format = format,
+ fullname = sanitized.fullname,
+ fontname = sanitized.fontname,
+ familyname = sanitized.familyname,
+ plainname = fullname,
+ psname = sanitized.fontname,
+ version = metadata.version,
+ size = false,
+ fontstyle_name = style ~= "" and style or weight,
+ weight = metadata.pfminfo and pfminfo.weight or 400,
+ italicangle = italicangle,
+ }
+end
+
local loaders = {
otf = ot_fullinfo,
ttc = ot_fullinfo,
ttf = ot_fullinfo,
-
-----pfb = t1_fullinfo, --> may come back one day, so
-----pfa = t1_fullinfo, --> we keep the indirection
+ pfb = t1_fullinfo,
}
--- not side-effect free!