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-12-15 21:59:56 +00:00
package textshaping ;import (_e "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-12-15 21:59:56 +00:00
func ArabicShape (text string )(string ,error ){_be :=_a .Paragraph {};_be .SetString (text );_f ,_g :=_be .Order ();if _g !=nil {return "",_g ;};for _fb :=0;_fb < _f .NumRuns ();_fb ++{_de :=_f .Run (_fb );_beb :=_de .String ();if _de .Direction ()==_a .RightToLeft {var (_c =_e .Shape (_beb );
_bebe =[]rune (_c );_bg =make ([]rune ,len (_bebe )););_ff :=0;for _ef :=len (_bebe )-1;_ef >=0;_ef --{_bg [_ff ]=_bebe [_ef ];_ff ++;};_beb =string (_bg );text =_b .Replace (text ,_b .TrimSpace (_de .String ()),_beb ,1);};};return text ,nil ;};