[luatex] font expansion / HZ

Patrick Gundlach patrick at gundla.ch
Mon Jan 10 11:20:08 CET 2011


Hi,

I'll post a complete non-working example. I would expect that the output differs when I switch between \pdfadjustspacing=0 and \pdfadjustspacing=2

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

\pdfoutput1
\pdfadjustspacing=2
% from the luatex wiki:
\directlua{
define_font = function(name, size)
  local filename, f

  filename = kpse.find_file(name, "opentype fonts")

  if size < 0 then
    size = (-655.36) * size
  end
  local ttffont = fontloader.to_table(fontloader.open(filename))
  if ttffont then
    f = { }
    f.name = ttffont.fontname
    f.fullname = ttffont.names[1].names.fullname
    f.parameters = { }
    f.designsize = size
    f.size = size
    direction = 0
    f.parameters.slant = 0
    f.parameters.space = size * 0.25
    f.parameters.space_stretch = 0.3 * size
    f.parameters.space_shrink = 0.1 * size
    f.parameters.x_height = 0.4 * size
    f.parameters.quad = 1.0 * size
    f.parameters.extra_space = 0

  f.stretch = 30
  f.shrink  = 20
  f.step    = 10
  f.auto_expand = true

    f.characters = { }
    local mag = size / ttffont.units_per_em
  
    local names_of_char = { }
    for char, glyph in pairs(ttffont.map.map) do
      names_of_char[ttffont.glyphs[glyph].name] = ttffont.map.backmap[glyph]
    end
  
    for char, glyph in pairs(ttffont.map.map) do
      local glyph_table = ttffont.glyphs[glyph]
  
      f.characters[char] = {
        index = glyph,
        width = glyph_table.width * mag,
        name = glyph_table.name }
      if glyph_table.boundingbox[4] then
        f.characters[char].height = glyph_table.boundingbox[4] * mag
      end
      if glyph_table.boundingbox[2] then
        f.characters[char].depth = -glyph_table.boundingbox[2] * mag
      end
  
      if glyph_table.kerns then
        local kerns = { }
        for _, kern in pairs(glyph_table.kerns) do
          kerns[names_of_char[kern.char]] = kern.off * mag
        end
        f.characters[char].kerns = kerns
      end
    end
    
    f.filename = filename
    f.type = "real"
    f.format = "opentype"
    f.embedding = "subset"
    f.cidinfo = {
      registry = "Adobe",
      ordering = "Identity",
      supplement = 0,
      version = 1 }
  end
  return f
end
local f = define_font("texgyreheros-regular.otf",65536 * 12)
local num = font.define(f)
tex.definefont("myfont",num)
}

\myfont
\hsize 4cm

Hello, here is some text without a meaning. This text should show, how a printed text will look like
at this place. If you read this text, you will get no information. Really? Is there no information?
Is there a difference between this text and some nonsense like »Huardest gefburn« Kjift – Never
mind! A blind text like this gives you information about the selected font, how the letters are
written and the impression of the look. This text should contain all letters of the alphabet and it
should be written in of the original language. There is no need for a special contents, but the
length of words should match to the language.

\bye
----------------------------------------------------------------------------------------------------





More information about the luatex mailing list