Comments (4)
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.
This is a big problem for exports, because nothing really ever fits onto the single slide properly.
from python-pptx.
Calculating the correct size would require using font metrics - which I don't believe python-pptx has access to or understanding of.
from python-pptx.
I just found this method which looks interesting:
shape.text_frame.fit_text()
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).
The following class looks interesting:
pptx.text.fonts.py - especially the _best_fit_font_size method.
from python-pptx.
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.
from python-pptx.
Related Issues (20)
- How to embed an .h3d (Hyperworks output file) file? HOT 3
- Line char None values
- How to set shink in sharp when text box overflow in Python pptx HOT 1
- Fit shape to text?
- Hide a shape HOT 2
- ValueError: value must be in range 256 to 2147483647 inclusive, got 2147483648 - when adding slide HOT 13
- Removing video results in corrupted file. HOT 6
- Create multiple slides with concurrent.futures HOT 1
- run function on click HOT 1
- How to access and create media objects HOT 8
- copying slide-masters HOT 2
- Make xlsxwriter an optional dependency HOT 4
- There is a bug for load image under the package "langchain.document_loaders import UnstructuredImageLoader" HOT 1
- Add OLE shapes
- auto_size not working HOT 2
- notes_placeholder and notes_text_frame are None when a note exists HOT 2
- Minor Gridlines format settings in charts
- Custom Lazyproperty and Pylance mismatch, no type hints HOT 2
- 我开源了一个完整版的 AiPPT 项目 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-pptx.