diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2019-07-08 06:07:11 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2019-07-08 06:07:11 +0000 |
commit | f93b62903a20648ab4328443b88495da81f70909 (patch) | |
tree | 6a870996cc04dca9a1ae3dbbc334b4c2a1385711 /Build/source/texk/web2c/luatexdir/luaharfbuzz/examples/core_types.lua | |
parent | 54d39e16610eee4dde770b0a6b569203c79abde8 (diff) |
sync with luatex rev.7174: luatex and luahbtex and jit variants
git-svn-id: svn://tug.org/texlive/trunk@51577 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luaharfbuzz/examples/core_types.lua')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/luaharfbuzz/examples/core_types.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luaharfbuzz/examples/core_types.lua b/Build/source/texk/web2c/luatexdir/luaharfbuzz/examples/core_types.lua new file mode 100644 index 00000000000..ec3d0d4388c --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/luaharfbuzz/examples/core_types.lua @@ -0,0 +1,52 @@ +local harfbuzz = require('harfbuzz') +local serpent = require('serpent') -- luarocks install serpent + +-- Harfbuzz API Version +print("Harfbuzz API version", harfbuzz.version()) + +-- Shapers available +print("Shapers:", serpent.line({ harfbuzz.shapers() }, {comment = false})) + +-- harfbuzz.Face +local face = harfbuzz.Face.new('../fonts/notonastaliq.ttf') +print('\nFace upem = '..face:get_upem()) + +-- harfbuzz.Font +local font = harfbuzz.Font.new(face) +local xs, xy = font:get_scale() +print("\nDefault font scale = X: "..xs..", Y: "..xy) + +-- harfbuzz.Buffer +local text = "یہ" -- U+06CC U+06C1 +local buf = harfbuzz.Buffer.new() +buf:add_utf8(text) + +-- harfbuzz.shape (Shapes text) +print("\nShaping '"..text.."' set with Noto Nastaliq Urdu") +harfbuzz.shape(font, buf, { language = harfbuzz.Language.new("urd"), script = harfbuzz.Script.new("Arab"), direction = harfbuzz.Direction.RTL}) + +local glyphs = buf:get_glyphs() +print("No. of glyphs", #glyphs) +print(serpent.line(glyphs, {comment = false})) + +local opts = { language = harfbuzz.Language.new("eng"), script = harfbuzz.Script.new("Latn"), direction = harfbuzz.Direction.LTR } +local amiri_face = harfbuzz.Face.new('../fonts/amiri-regular.ttf') +local amiri_font = harfbuzz.Font.new(amiri_face) + +-- shaping '123' w/o features +print("\nShaping '123' set with Amiri Regular and no features") +buf= harfbuzz.Buffer.new() +buf:add_utf8("123") +harfbuzz.shape(amiri_font, buf, opts) +glyphs = buf:get_glyphs() +print(serpent.line(glyphs, {comment = false})) + +-- shaping '123' with '+numr' (numerators) +print("\nShaping '123' set with Amiri Regular with 'numr' feature turned on") +buf= harfbuzz.Buffer.new() +buf:add_utf8("123") +opts.features = "+numr" +harfbuzz.shape(amiri_font, buf, opts) +glyphs = buf:get_glyphs() +print(serpent.line(glyphs, {comment = false})) + |