summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luaharfbuzz/docs/examples/core_types.lua.html
blob: 6345ea3c6fae691752831942d360b14bdab68de7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>luaharfbuzz Documentation</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>luaharfbuzz</h1>




<h2>Examples</h2>
<ul class="nowrap">
  <li><strong>core_types.lua</strong></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
  <li><a href="../index.html">harfbuzz</a></li>
</ul>

</div>

<div id="content">

    <h2>core_types.lua</h2>
<pre>
<span class="keyword">local</span> harfbuzz = <span class="global">require</span>(<span class="string">'harfbuzz'</span>)
<span class="keyword">local</span> serpent  = <span class="global">require</span>(<span class="string">'serpent'</span>) <span class="comment">-- luarocks install serpent
</span>
<span class="comment">-- Harfbuzz API Version
</span><span class="global">print</span>(<span class="string">"Harfbuzz API version"</span>, harfbuzz.version())

<span class="comment">-- Shapers available
</span><span class="global">print</span>(<span class="string">"Shapers:"</span>, serpent.line({ harfbuzz.shapers() }, {comment = <span class="keyword">false</span>}))

<span class="comment">-- harfbuzz.Face
</span><span class="keyword">local</span> face = harfbuzz.Face.new(<span class="string">'../fonts/notonastaliq.ttf'</span>)
<span class="global">print</span>(<span class="string">'\nFace upem = '</span>..face:get_upem())

<span class="comment">-- harfbuzz.Font
</span><span class="keyword">local</span> font = harfbuzz.Font.new(face)
<span class="keyword">local</span> xs, xy = font:get_scale()
<span class="global">print</span>(<span class="string">"\nDefault font scale = X: "</span>..xs..<span class="string">", Y: "</span>..xy)

<span class="comment">-- harfbuzz.Buffer
</span><span class="keyword">local</span> text = <span class="string">"یہ"</span> <span class="comment">-- U+06CC U+06C1
</span><span class="keyword">local</span> buf = harfbuzz.Buffer.new()
buf:add_utf8(text)

<span class="comment">-- harfbuzz.shape (Shapes text)
</span><span class="global">print</span>(<span class="string">"\nShaping '"</span>..text..<span class="string">"' set with Noto Nastaliq Urdu"</span>)
harfbuzz.shape(font, buf, { language = harfbuzz.Language.new(<span class="string">"urd"</span>), script = harfbuzz.Script.new(<span class="string">"Arab"</span>), direction = harfbuzz.Direction.RTL})

<span class="keyword">local</span> glyphs = buf:get_glyphs()
<span class="global">print</span>(<span class="string">"No. of glyphs"</span>, #glyphs)
<span class="global">print</span>(serpent.line(glyphs, {comment = <span class="keyword">false</span>}))

<span class="keyword">local</span> opts = { language = harfbuzz.Language.new(<span class="string">"eng"</span>), script = harfbuzz.Script.new(<span class="string">"Latn"</span>), direction = harfbuzz.Direction.LTR }
<span class="keyword">local</span> amiri_face = harfbuzz.Face.new(<span class="string">'../fonts/amiri-regular.ttf'</span>)
<span class="keyword">local</span> amiri_font = harfbuzz.Font.new(amiri_face)

<span class="comment">-- shaping '123' w/o features
</span><span class="global">print</span>(<span class="string">"\nShaping '123' set with Amiri Regular and no features"</span>)
buf= harfbuzz.Buffer.new()
buf:add_utf8(<span class="string">"123"</span>)
harfbuzz.shape(amiri_font, buf, opts)
glyphs = buf:get_glyphs()
<span class="global">print</span>(serpent.line(glyphs, {comment = <span class="keyword">false</span>}))

<span class="comment">-- shaping '123' with '+numr' (numerators)
</span><span class="global">print</span>(<span class="string">"\nShaping '123' set with Amiri Regular with 'numr' feature turned on"</span>)
buf= harfbuzz.Buffer.new()
buf:add_utf8(<span class="string">"123"</span>)
opts.features = <span class="string">"+numr"</span>
harfbuzz.shape(amiri_font, buf, opts)
glyphs = buf:get_glyphs()
<span class="global">print</span>(serpent.line(glyphs, {comment = <span class="keyword">false</span>}))</pre>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2019-07-31 18:39:39 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>