|
1 | 1 | --[[ |
2 | | -TastyText 2.1 |
| 2 | +TastyText 2.2 |
3 | 3 | Copyright (c) 2014 Minh Ngo |
4 | 4 |
|
5 | 5 | This software is provided 'as-is', without any express or implied |
@@ -73,14 +73,14 @@ if composite_number >= 009002 then |
73 | 73 | utf8sub = function(str,i,j) |
74 | 74 | j = j or -1 |
75 | 75 |
|
76 | | - -- only set l if i or j is negative |
77 | | - local l = (i >= 0 and j >= 0) or utf8.len(str) |
78 | | - i = (i >= 0) and i or l + i + 1 |
79 | | - j = (j >= 0) and j or l + j + 1 |
80 | | - |
81 | | - if i < 0 then i = 1 elseif i > l then i = l end |
82 | | - if j < 0 then j = 1 elseif j > l then j = l end |
83 | | - |
| 76 | + if i < 1 or j < 1 then |
| 77 | + local l = utf8.len(str) |
| 78 | + i = (i >= 0) and i or l + i + 1 |
| 79 | + j = (j >= 0) and j or l + j + 1 |
| 80 | + |
| 81 | + if i < 0 then i = 1 elseif i > l then i = l end |
| 82 | + if j < 0 then j = 1 elseif j > l then j = l end |
| 83 | + end |
84 | 84 |
|
85 | 85 | local byte_a = utf8.offset(str,i) |
86 | 86 | local byte_b = utf8.offset(str,j+1)-1 |
@@ -112,7 +112,7 @@ local escape_tag = string.format('%s([%s%s])',ESCAPE,START,END) |
112 | 112 | --TEXT CLASS |
113 | 113 | ------------------------------------------------------------------------ |
114 | 114 |
|
115 | | -local TastyText = {_VERSION = '2.1'} |
| 115 | +local TastyText = {_VERSION = '2.2'} |
116 | 116 | TastyText.__index= TastyText |
117 | 117 |
|
118 | 118 | function TastyText.new(str,limit,default_font,tags,line_height) |
|
0 commit comments