unipdf/textshaping/textshaping.go

16 lines
1.1 KiB
Go
Raw Normal View History

2022-07-13 21:28:43 +00:00
//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
2024-06-27 16:15:49 +00:00
package textshaping ;import (_c "github.com/unidoc/garabic";_g "golang.org/x/text/unicode/bidi";_a "strings";);
2022-07-13 21:28:43 +00:00
// ArabicShape returns shaped arabic glyphs string.
2024-06-27 16:15:49 +00:00
func ArabicShape (text string )(string ,error ){_d :=_g .Paragraph {};_d .SetString (text );_cd ,_de :=_d .Order ();if _de !=nil {return "",_de ;};for _ce :=0;_ce < _cd .NumRuns ();_ce ++{_b :=_cd .Run (_ce );_db :=_b .String ();if _b .Direction ()==_g .RightToLeft {var (_gc =_c .Shape (_db );
_bf =[]rune (_gc );_fd =make ([]rune ,len (_bf )););_e :=0;for _aa :=len (_bf )-1;_aa >=0;_aa --{_fd [_e ]=_bf [_aa ];_e ++;};_db =string (_fd );text =_a .Replace (text ,_a .TrimSpace (_b .String ()),_db ,1);};};return text ,nil ;};