github.com/unidoc/unipdf/v3@v3.55.0/textshaping/textshaping.go (about) 1 // 2 // Copyright 2020 FoxyUtils ehf. All rights reserved. 3 // 4 // This is a commercial product and requires a license to operate. 5 // A trial license can be obtained at https://unidoc.io 6 // 7 // DO NOT EDIT: generated by unitwist Go source code obfuscator. 8 // 9 // Use of this source code is governed by the UniDoc End User License Agreement 10 // terms that can be accessed at https://unidoc.io/eula/ 11 12 package textshaping ;import (_c "github.com/unidoc/garabic";_f "golang.org/x/text/unicode/bidi";_b "strings";); 13 14 // ArabicShape returns shaped arabic glyphs string. 15 func ArabicShape (text string )(string ,error ){_gc :=_f .Paragraph {};_gc .SetString (text );_e ,_d :=_gc .Order ();if _d !=nil {return "",_d ;};for _ca :=0;_ca < _e .NumRuns ();_ca ++{_ee :=_e .Run (_ca );_bc :=_ee .String ();if _ee .Direction ()==_f .RightToLeft {var (_cg =_c .Shape (_bc ); 16 _fg =[]rune (_cg );_ba =make ([]rune ,len (_fg )););_cc :=0;for _bf :=len (_fg )-1;_bf >=0;_bf --{_ba [_cc ]=_fg [_bf ];_cc ++;};_bc =string (_ba );text =_b .Replace (text ,_b .TrimSpace (_ee .String ()),_bc ,1);};};return text ,nil ;};