File: t1fontmake.lua

package info (click to toggle)
texlive-extra 2022.20230122-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,466,588 kB
  • sloc: perl: 398,710; xml: 35,871; python: 29,125; cs: 25,850; sh: 17,610; makefile: 17,304; ansic: 15,490; java: 12,811; javascript: 9,898; lisp: 1,755; csh: 1,129; ruby: 1,072; awk: 151; tcl: 142; pascal: 138; cpp: 41; sed: 36; haskell: 5
file content (48 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local libertineproperty = function(x)
  local property = x:gsub("I","italic")
  property = property:gsub("B", "bold")
  return string.lower(property)
end


local fontfixes = {
["Lin Libertine"] = function(x)
  return "Linux Libertine O", libertineproperty(x)
end,
["Lin Biolinum"] = function(x)
  return "Linux Biolinum O", libertineproperty(x) .. "sans"
end
}

for rec in io.lines() do
  local filename = rec:match("([^%/]+).tfm$")
  local propertystring = filename:lower()
  local fontname = filename:match("([^%-]+)")
  local t = {}
  fontname:gsub("([A-Z]*[a-z]+)", function(x) t[#t+1] = x end)
  fontname = table.concat(t," ")
  local fontfunc = fontfixes[fontname]
  if fontfunc then
    fontname, propertystring = fontfunc(filename)
    propertystring = string.lower(propertystring)
  end
  local bold = propertystring:match("bold") and "font-weight: bold;"
  local slanted = propertystring:match("slanted") and "font-style: oblique;"
  local italic = propertystring:match("italic") and "font-style: italic;"
  local smallcaps = (propertystring:match("sc") or propertystring:match("smallcaps")) and "font-variant: small-caps;"
  local sans = propertystring:match("sans") and "sans-serif"
  local mono = propertystring:match("mono") and "monospace"
  local cssfontname = string.format("font-name: '%s', %s", fontname,(mono or sans) or "serif")
  local t = {}
  table.insert(t,bold)
  table.insert(t,slanted)
  table.insert(t,italic)
  table.insert(t,smallcaps)
  table.insert(t,cssfontname)
  local css = table.concat(t, " ")
  print(string.format('\\<%s\\><<<', filename))
  print(".lm-ec")
  print("htfcss: ".. filename .." " ..css)
  print(">>>")
  print(string.format("\n\\AddFont{%s}{alias/t1fonts/%s}{}\n", filename, filename))
end