Commits

Philipp Gesang committed 77edede

add example implementing fonts.otf.char() from the legacy version

Comments (0)

Files changed (2)

ltx-fontspec-feature-9.tex

 \usepackage{fontspec}
 \setmainfont{Adobe Garamond Pro}
 
-\font\agarmitlcsmcp="file:agaramondpro_italic.otf:+smcp"
+%\font\agarmitlcsmcp="file:agaramondpro_italic.otf:+smcp"
 
 \begin{document}
                     foo       \fontname\font \par
  \hrule
 
  {\scshape\itshape  foobar    \fontname\font}\par
- {\agarmitlcsmcp    foobar    \fontname\font}\par
+ %{\agarmitlcsmcp    foobar    \fontname\font}\par
 
 \end{document}

pln-get_glyph-1.tex

+%% http://tex.stackexchange.com/q/120736
+\luatexsuppresslongerror1
+\input luaotfload.sty
+\def\beginluacode{%
+  \begingroup
+  \catcode`\%=11
+  \catcode`\_=11
+  \beginluacodeindeed%
+}
+
+\def\beginluacodeindeed#1\endluacode{%
+  \directlua{#1}%
+  \endgroup%
+}
+
+\beginluacode
+  documentdata       = documentdata or { }
+
+  local stringformat = string.format
+  local texsprint    = tex.sprint
+  local slot_of_name = luaotfload.aux.slot_of_name
+
+  documentdata.fontchar = function (chr)
+    local chr = slot_of_name(font.current(), chr, false)
+    if chr and type(chr) == "number" then
+      texsprint
+        (stringformat ([[\char"%X]], chr))
+    end
+  end
+\endluacode
+
+\def\fontchar#1{\directlua{documentdata.fontchar "#1"}}
+
+\font\1="file:GaramondPremrPro.otf" at 20pt \1
+
+\fontchar{bullet.01}\endgraf
+\fontchar{bullet.02}\endgraf
+\fontchar{bullet.03}\endgraf
+
+\bye