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/
2022-10-27 19:04:58 +00:00
package textshaping ;import (_g "github.com/unidoc/garabic";_a "golang.org/x/text/unicode/bidi";_b "strings";);
2022-07-13 21:28:43 +00:00
// ArabicShape returns shaped arabic glyphs string.
2022-10-27 19:04:58 +00:00
func ArabicShape (text string )(string ,error ){_cf :=_a .Paragraph {};_cf .SetString (text );_ac ,_bg :=_cf .Order ();if _bg !=nil {return "",_bg ;};for _gg :=0;_gg < _ac .NumRuns ();_gg ++{_d :=_ac .Run (_gg );_bc :=_d .String ();if _d .Direction ()==_a .RightToLeft {var (_ggg =_g .Shape (_bc );
_af =[]rune (_ggg );_bb =make ([]rune ,len (_af )););_bbf :=0;for _f :=len (_af )-1;_f >=0;_f --{_bb [_bbf ]=_af [_f ];_bbf ++;};_bc =string (_bb );text =_b .Replace (text ,_b .TrimSpace (_d .String ()),_bc ,1);};};return text ,nil ;};