Skip to content

Commit

Permalink
Fix misalginment with non-tashkeeled letters
Browse files Browse the repository at this point in the history
  • Loading branch information
latiif committed Jan 31, 2020
1 parent e5600cc commit 5baf8f3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/buger/goterm v0.0.0-20181115115552-c206103e1f37 h1:uxxtrnACqI9zK4ENDMf0WpXfUsHP5V8liuq5QdgDISU=
github.com/buger/goterm v0.0.0-20181115115552-c206103e1f37/go.mod h1:u9UyCz2eTrSGy6fbupqJ54eY5c4IC8gREQ1053dK12U=
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7 h1:wYqz/tQaWUgGKyx+B/rssSE6wkIKdY5Ee6ryOmzarIg=
golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4 changes: 0 additions & 4 deletions goarabic/stringutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ func constructAlphabetMap(letters []Harf) map[rune]bool {
func SmartLength(s *string) int {
// len() use int as return value, so we'd better follow for compatibility
length := 0

for _, value := range *s {
if tashkeel[value] {
continue
}
length++
}

return length
}

Expand Down Expand Up @@ -299,9 +297,7 @@ func breakLineAt(pos int, str string) (fst, snd string) {
//padRTL Fills the leading places with spaces to make an RTL text
func padRTL(strlen, size int, str string) string {
plotsToFill := size - strlen

padding := strings.Repeat(" ", plotsToFill)

return padding + str
}

Expand Down
15 changes: 4 additions & 11 deletions goarabic/tashkeel.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,10 @@ func ApplyTashkeel(table []rune, s string) string {
i++
}

// Store remaining elements of second array
for j < n2 {
if table[j] != rune(0) {
r[k] = table[j]
k++
}
j++
}

return string(r)

// ignore trailing empty 0 from tashkeel table
trimmed := make([]rune, k)
copy(trimmed, r)
return string(trimmed)
}

var tashkeels = []rune{
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func main() {
ara.ToGlyph(
ara.Smooth(
ara.RemoveTashkeel(rawText)))))))

}

if err := scanner.Err(); err != nil {
Expand Down

0 comments on commit 5baf8f3

Please sign in to comment.