unipdf/textshaping/textshaping.go
2022-07-13 21:28:43 +00:00

16 lines
1.1 KiB
Go

//
// 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/
package textshaping ;import (_f "github.com/unidoc/garabic";_c "golang.org/x/text/unicode/bidi";_be "strings";);
// ArabicShape returns shaped arabic glyphs string.
func ArabicShape (text string )(string ,error ){_g :=_c .Paragraph {};_g .SetString (text );_gd ,_a :=_g .Order ();if _a !=nil {return "",_a ;};for _ga :=0;_ga < _gd .NumRuns ();_ga ++{_d :=_gd .Run (_ga );_bc :=_d .String ();if _d .Direction ()==_c .RightToLeft {var (_e =_f .Shape (_bc );
_dd =[]rune (_e );_ag =make ([]rune ,len (_dd )););_af :=0;for _ac :=len (_dd )-1;_ac >=0;_ac --{_ag [_af ]=_dd [_ac ];_af ++;};_bc =string (_ag );text =_be .Replace (text ,_be .TrimSpace (_d .String ()),_bc ,1);};};return text ,nil ;};