[lltx] Optical sizes and Adobe fonts

Philipp Gesang Philipp.Gesang at alumni.uni-heidelberg.de
Sun Aug 4 13:48:35 CEST 2013


Hi David,

attached is a small script that lists which font size gets
assigned which font face in a 12pt document.

To test minion or garamond premiere, run:

  texlua getfontinfo.lua minion
  texlua getfontinfo.lua garamond

If it reports mismatches (likely so) then please post the output. 

Best regards,
Philipp



···<date: 2013-07-31, Wednesday>···<from: David Bellows>···

> Hello all,
> 
> I posted the following question on Stack Exchange about how to specify
> optical sizes for fonts that come with them. I had thought there would
> be some set of options I could specify with \setmainfont but it's
> looking more and more like that's not the case. So instead it might be
> an issue with luaotfload that I'm not capable of dealing with.
> 
> http://tex.stackexchange.com/questions/126096/selecting-optical-sizes-for-all-fonts-in-a-family
> 
> Is this the sort of issue y'all want to hear about in general? Is
> there more information you need from me? While I'm not a coder I am
> interested in helping in whatever little ways I can. I am going
> through all the commercial fonts I've purchased over the years and
> making sure they work perfectly with LuaTeX so do you want me to
> communicate those findings with you?
> 
> Sincerely,
> David Bellows

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
-------------- next part --------------
#!/usr/bin/env texlua

local fileprefix, fontname
if arg[2] then
  fileprefix      = arg[1]
  fontname        = arg[2]
elseif arg[1] == "garamond" then
  fileprefix      = "GaramondPremrPro"
  fontname        = "Garamond Premier Pro"
elseif arg[1] == "minion" then
  fileprefix      = "MinionPro"
  fontname        = "Minion Pro"
else
  print "usage:"
  print "   getfontinfo.lua minion"
  print "   getfontinfo.lua garamond"
  print "   getfontinfo.lua <font file prefix> <font name>"
  os.exit (-1)
end

-----------------------------------------------------------------------

kpse.set_program_name "luatex"

local lpeg            = require "lpeg"
local C, P, lpegmatch = lpeg.C, lpeg.P, lpeg.match
local dummyfunction   = function (...) return ... end
config = { luaotfload = { update_live = false, loglevel = 5 } }

require "lualibs"

local write, write_nl = texio.write, texio.write_nl
texio.write, texio.write_nl = dummyfunction, dummyfunction
require "luaotfload-basics-gen.lua"

require "luaotfload-override.lua"
logs.set_loglevel (config.luaotfload.loglevel)

require "luaotfload-database"

local out = function (...) io.write (string.format (...)) end

local map = function (f, t)
  local l = #t
  local tmp = { }
  if l > 0 then
    for i = 1, l do
      tmp[i] = f (t[i])
    end
  end
  return tmp
end

local names       = fonts.names
names.data        = names.load ()
local mappings    = names.data.mappings
local filedata    = names.data.filenames

local p_otf       = P".otf" * P(-1)
local p_filepfx   = P (fileprefix) * (1 - p_otf)^1 * p_otf
local p_abspath   = (1 - p_filepfx)^0 * p_filepfx

out ("\n»» Looking up %s design sizes in font index ««\n\n", fontname)

local div10       = function (x) return x / 10 end

for i = 1, #mappings do local record = mappings[i]
  if lpegmatch (p_abspath, record.filename) then
    out ("File %s.\n", record.filename)

    out (" ((%s %s %s)\n  (design %.1f) (max %.1f) (min %.1f))\n\n",
         record.sanitized.prefmodifiers,
         record.sanitized.subfamily,
         record.fontstyle_name or "nil",
         table.unpack (map (div10, record.size)))
  end
end

out ("\n»» Determining resolver results for common sizes of %s ««\n\n", fontname)

local sizes = { --- assuming 12pt main font
  { "tiny",       8    },
  { "scriptsize", 9    },
  { "small",      10.9 },
  { "normalsize", 12   },
  { "large",      14.3 },
  { "Large",      17.2 },
  { "LARGE",      20.7 },
  { "Huge",       24.8 },
}

local styles = {
  [false] = "regular",
  i       = "italic",
  b       = "bold",
  bi      = "bolditalic",
}

--- hacks like this will be unnecessary from Luaotfload 2.4 on

local nameresolver = names.resolve
local fileresolver = names.crude_file_lookup
local requesthandler

fonts.constructors           = { }
fonts.definers.registersplit = function (_, f, _) requesthandler = f end
fonts.handlers = { otf = { features = { normalize = dummyfunction,
                                        register  = dummyfunction },
                           enhancers = { register = dummyfunction } } }

require "luaotfload-features"

local getrecord = function (file)
  local index = filedata.base[file]
  if index then
    return mappings[index]
  end
end

for i = 1, #sizes do local size = sizes[i]
  out ("\\%s -> %.2f\n", size[1], size[2])

  for modifier, style in next, styles do
    modifier = modifier and "/" .. modifier .. "" or ""

    local query = "name:" .. fontname .. modifier .. "/s=" .. string.format ("%.2f", size[2])

    local tmpspec = {
      name          = query,
      lookup        = "name",
      specification = query,
      features      = { },
    }

    tmpspec       = requesthandler (tmpspec)
    tmpspec.size  = size[2] * 2^16
    local filename, _, success = nameresolver (nil, nil, tmpspec)

    local dsnsize, size_min, size_max

    local record = getrecord (filename)
    if record and next (record.size) then
      dsnsize, size_max, size_min = table.unpack (map (div10, record.size))
    else
      success = false
    end

    if success and next (record.size) then
      local fits
      if size_min < size[2] and size[2] < size_max then
        fits = true
      end
      out ("%15s : (%s %4.1f < %4.1f < %4.1f) %s\n",
           style,
           fits and "right" or "wrong",
           size_min, dsnsize, size_max,
           filename)
    else
      out ("  %s : not found or no size info!\n", filename)
    end
  end
  io.write "\n"
end

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://tug.org/pipermail/lualatex-dev/attachments/20130804/abaacca2/attachment.bin>


More information about the lualatex-dev mailing list