gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.94k stars 639 forks source link

Text is duplicating for the "Jost Light" font style while creating PPT using PptxGenJs library #1301

Open SureshMetacube opened 11 months ago

SureshMetacube commented 11 months ago

Steps: 1) we have created a sheet in which we have used "Jost Light / Jost Light (Body)" font for description. 2) when we move to another slide and came back to the slide then it shows duplicate text. 3) when we edit or remove the duplicate created text then it edits the original text only. So it seems that this issue not actually creating duplicate text but it is showing duplicate. 4) This issue is only with Office 365 and this font style.

please find a screenshot and PPT as a reference test_sample.pptx . image

ChillyBots commented 7 months ago

I can reproduce this with any custom font. It seems dependent on the width of the text box, as well as other items on the page.

ChillyBots commented 7 months ago

@SureshMetacube Looks like it's down to this line:

https://github.com/gitbrent/PptxGenJS/blob/035cf6b26239e2ea1f27eefbcdb8134e504eb4f4/src/gen-objects.ts#L1062

It's automatically adding wrap true when we aren't explicitly setting it. Updating to this fixes the issue:

if (typeof itemOpts.wrap === 'boolean') { itemOpts._bodyProp.wrap = itemOpts.wrap; }

Of course, if you set wrap true again, the issue will return

ChillyBots commented 7 months ago

Apologies, the above solution is incorrect. This disables all wrapping, which is not desired. it is infact this line causing the error:

https://github.com/gitbrent/PptxGenJS/blob/035cf6b26239e2ea1f27eefbcdb8134e504eb4f4/src/gen-xml.ts#L998

reverting the fix for #174 fixes the issue (change charset to 0). This obviously breaks 174, so I suppose this is a toss-up for anyone forking