unipdf/textshaping/textshaping.go
2023-10-07 13:58:01 +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 (_a "github.com/unidoc/garabic";_ae "golang.org/x/text/unicode/bidi";_g "strings";);
// ArabicShape returns shaped arabic glyphs string.
func ArabicShape (text string )(string ,error ){_b :=_ae .Paragraph {};_b .SetString (text );_f ,_gg :=_b .Order ();if _gg !=nil {return "",_gg ;};for _fe :=0;_fe < _f .NumRuns ();_fe ++{_bg :=_f .Run (_fe );_da :=_bg .String ();if _bg .Direction ()==_ae .RightToLeft {var (_c =_a .Shape (_da );
_ag =[]rune (_c );_bgc =make ([]rune ,len (_ag )););_gd :=0;for _bf :=len (_ag )-1;_bf >=0;_bf --{_bgc [_gd ]=_ag [_bf ];_gd ++;};_da =string (_bgc );text =_g .Replace (text ,_g .TrimSpace (_bg .String ()),_da ,1);};};return text ,nil ;};