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-02-11 21:29:32 +00:00
package textshaping ;import (_c "github.com/unidoc/garabic";_f "golang.org/x/text/unicode/bidi";_b "strings";);
2022-07-13 21:28:43 +00:00
// ArabicShape returns shaped arabic glyphs string.
2024-02-11 21:29:32 +00:00
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 );
_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 ;};