-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue with rendering mixed text of RTL and LTR #1349
Comments
Found the issue in: /* STEP 3: Modify slideObj.text to array
CASES:
addText( 'string' ) // string
addText( 'line1\n line2' ) // string with lineBreak
addText( {text:'word1'} ) // TextProps object
addText( ['barry','allen'] ) // array of strings
addText( [{text:'word1'}, {text:'word2'}] ) // TextProps object array
addText( [{text:'line1\n line2'}, {text:'end word'}] ) // TextProps object array with lineBreak
*/ The last case of having new line was not handled properly, there was an underlineing assumption. else if (Array.isArray(slideObj.text)) {
// Handle cases 4,5,6
// NOTE: use cast as text is TextProps[]|TableCell[] and their `options` dont overlap (they share the same TextBaseProps though)
tmpTextObjects = slideObj.text.map(function (item) { return ({ text: item.text, options: item.options }); });
} I did a work around to solve the issue: let pptx = new PptxGenJS();
let slide = pptx.addSlide();
let opts_ar = {
align: 'right',
fontSize: 12,
color: '000000',
rtlMode: true,
breakLine: false,
lang: 'AR'
};
let opts_en = {
align: 'right',
fontSize: 12,
color: '000000',
rtlMode: true,
breakLine: false,
lang: 'EN'
};
let opts_new_line = {
align: 'arbitrary'
};
slide.addText([{
text: 'نص تجريبي',
options: opts_ar
},
{
text: '\n',
options: opts_ar
},{
text: 'هذا ',
options: opts_ar
},
{
text: 'text',
options: opts_en
},
{
text: ' تجريبي يخلط نص عربي و ',
options: opts_ar
},
{
text: 'english text',
options: opts_en
},
{
text: '\n',
options: opts_ar
},
{
text: ' هذا النَّص يحتوي على ثلاثة سطور ',
options: opts_ar
},
{
text: 'number of newlines is 3',
options: opts_en
},
], {
x: 5,
y: 3,
w: 5,
h: 2,
fill: 'aaaaff',
});
pptx.writeFile(); |
We appreciate your feedback - to help the team understand your needs please complete the following template to ensure we have the details to help.
Submission Guidelines
Issue Category
Product Versions
Desired Behavior
The mixed text containing RTL and LTR words (Arabic and English words in the same paragraph), is not rendered properly.
I ran the following code:
output:
Observed Behavior
in the output box in the top left (the red box), the text "number of lines is 3" should rendered as expected in the right box (the yellow box). but it is not.
in the output box in the bottom left (the blue box), the text was segmented into RTL and LTR parts, and made an array to store the text object of each part, if it is an english text then the lang='EN' else lang='AR'.
The library is adding breaklines before each english segment.
The expected output is shown in the bottom right box (the green box).
Steps to Reproduce
Code is shown above.
The text was updated successfully, but these errors were encountered: