-
Notifications
You must be signed in to change notification settings - Fork 528
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
MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE attribute does not take effect #973
Comments
I have the same problem. I wonder if python-pptx is really even able to calculate the correct size. The calculation seems to only happen when you open the Excel file, and slightly tweak the shape size, or the text. |
Calculating the correct size would require using font metrics - which I don't believe python-pptx has access to or understanding of. |
I just found this method which looks interesting:
It doesn't quite work for me because I'm running linux in a docker container which is an unsupported OS, but it might work for others. It seems that python-pptx does have some understanding of fonts (although I'm unsure if font 'metrics' is a specific term). |
If you want to know how long a certain character string is you need font metrics - which describe the width of pairs of neighbouring characters. The only exception to this is fixed-pitch fonts. |
I am writing a script to extract the text content in pptx files and translate it into other languages. The problem I encountered is that when the translated text in the text box exceeds the length, this will cause the contents of adjacent text boxes to obscure each other. So I tried to set the MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE attribute to ensure that the text is automatically reduced when it overflows, but it did not work after running the code. The following is my code. Thank you very much for your advice.
prs.save(path)
The text was updated successfully, but these errors were encountered: