| 1 |
local libertineproperty = function(x) |
| 2 |
local property = x:gsub("I","italic") |
| 3 |
property = property:gsub("B", "bold") |
| 4 |
return string.lower(property) |
| 5 |
end |
| 6 |
|
| 7 |
|
| 8 |
local fontfixes = { |
| 9 |
["Lin Libertine"] = function(x) |
| 10 |
return "Linux Libertine O", libertineproperty(x) |
| 11 |
end, |
| 12 |
["Lin Biolinum"] = function(x) |
| 13 |
return "Linux Biolinum O", libertineproperty(x) .. "sans" |
| 14 |
end |
| 15 |
} |
| 16 |
|
| 17 |
for rec in io.lines() do |
| 18 |
local filename = rec:match("([^%/]+).tfm$") |
| 19 |
local propertystring = filename:lower() |
| 20 |
local fontname = filename:match("([^%-]+)") |
| 21 |
local t = {} |
| 22 |
fontname:gsub("([A-Z]*[a-z]+)", function(x) t[#t+1] = x end) |
| 23 |
fontname = table.concat(t," ") |
| 24 |
local fontfunc = fontfixes[fontname] |
| 25 |
if fontfunc then |
| 26 |
fontname, propertystring = fontfunc(filename) |
| 27 |
propertystring = string.lower(propertystring) |
| 28 |
end |
| 29 |
local bold = propertystring:match("bold") and "font-weight: bold;" |
| 30 |
local slanted = propertystring:match("slanted") and "font-style: oblique;" |
| 31 |
local italic = propertystring:match("italic") and "font-style: italic;" |
| 32 |
local smallcaps = (propertystring:match("sc") or propertystring:match("smallcaps")) and "font-variant: small-caps;" |
| 33 |
local sans = propertystring:match("sans") and "sans-serif" |
| 34 |
local mono = propertystring:match("mono") and "monospace" |
| 35 |
local cssfontname = string.format("font-name: '%s', %s", fontname,(mono or sans) or "serif") |
| 36 |
local t = {} |
| 37 |
table.insert(t,bold) |
| 38 |
table.insert(t,slanted) |
| 39 |
table.insert(t,italic) |
| 40 |
table.insert(t,smallcaps) |
| 41 |
table.insert(t,cssfontname) |
| 42 |
local css = table.concat(t, " ") |
| 43 |
print(string.format('\\<%s\\><<<', filename)) |
| 44 |
print(".lm-ec") |
| 45 |
print("htfcss: ".. filename .." " ..css) |
| 46 |
print(">>>") |
| 47 |
print(string.format("\n\\AddFont{%s}{alias/t1fonts/%s}{}\n", filename, filename)) |
| 48 |
end |