[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Add gid_to_name (a85d869)

Marcel Fabian Krüger tex at 2krueger.de
Wed Jan 22 01:55:41 CET 2020


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/a85d869833c5cf02b841a011108a8e441c4cc1b1

>---------------------------------------------------------------

commit a85d869833c5cf02b841a011108a8e441c4cc1b1
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed Jan 22 01:55:41 2020 +0100

    Add gid_to_name


>---------------------------------------------------------------

a85d869833c5cf02b841a011108a8e441c4cc1b1
 doc/luaotfload-main.tex      | 15 +++++++++++----
 src/luaotfload-auxiliary.lua | 13 +++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex
index 8ed838c..815c5cb 100644
--- a/doc/luaotfload-main.tex
+++ b/doc/luaotfload-main.tex
@@ -1898,18 +1898,25 @@ are defined for which scripts.
             has glyph \luaident{index}.
   \endaltitem
 
-  \beginaltitem  {aux.slot_of_name(name : string)}
-            Translates an Adobe Glyph name to the corresponding glyph
-            slot.
+  \beginaltitem  {aux.slot_of_name(id : int, name : string)}
+            Translates a name for a glyph in font \luaident{id} to the
+            corresponding glyph slot which can be used e.g.\ as an argument to
+            \inlinecode{\char}.
   \endaltitem
 
-  \beginaltitem  {aux.name_of_slot(slot : int)}
+  \beginaltitem  {aux.name_of_slot(id : int, slot : int)}
             The inverse of \luaident{slot_of_name}; note that this
             might be incomplete as multiple glyph names may map to the
             same codepoint, only one of which is returned by
             \luaident{name_of_slot}.
   \endaltitem
 
+  \beginaltitem  {aux.gid_of_name(id : int, name : string)}
+            Translates a Glyph name to the corresponding GID in font
+            \luaident{id}. This corresponds to the value returned by
+            \luaident{\XeTeXglyphindex} in \XeTeX.
+  \endaltitem
+
   \beginaltitem  {aux.provides_script(id : int, script : string)}
             Test if a font supports \luaident{script}.
   \endaltitem
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index f13a5d3..1480791 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -429,6 +429,19 @@ function aux.name_of_slot(codepoint)
   return false
 end
 
+--[[doc--
+
+  Get the GID of the glyph associated with a given name.
+
+--doc]]--
+function aux.gid_of_name(font_id, glyphname)
+  local slot = aux.slot_of_name(font_id, glyphname)
+  if not slot then return end
+  local tfmdata = identifiers[font_id] or font.fonts[font_id]
+  -- assert(tfmdata) -- Otherwise slot_of_name would have failed already
+  return tfmdata.characters[slot].index or slot
+end
+
 -----------------------------------------------------------------------
 ---                 features / scripts / languages
 -----------------------------------------------------------------------





More information about the latex3-commits mailing list