Class Autofit Stay organized with collections Save and categorize content based on your preferences.
Page Summary
Autofit describes the settings for how text fits within a shape's bounding box.
When a change might affect text fitting, autofit is deactivated, and font scale and line spacing reduction are reset to default values.
Methods are available to disable autofit, get the autofit type, font scale, and line spacing reduction of a shape.
The
disableAutofit()method sets the autofit type toNONE.The
getAutofitType(),getFontScale(), andgetLineSpacingReduction()methods provide information about the shape's autofit settings.
Describes the autofit settings of a shape. If a change is made that might affect text fittingwithin its bounding text box:
- Autofit is deactivated and set to
Autofit.Type.NONE - The font scale is reset to the default value and applied to the font size.
- The line spacing reduction is reset to the default value and applied to the line spacing.
Methods
| Method | Return type | Brief description |
|---|---|---|
disable | Autofit | Sets theAutofit of a shape toAutofit. |
get | Autofit | Gets theAutofit of the shape. |
get | Number | Gets the font scale applied to the shape. |
get | Number | Gets the line spacing reduction applied to the shape. |
Detailed documentation
disableAutofit()
Sets theAutofit of a shape toAutofit.
Return
Autofit — The autofit, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getAutofitType()
Gets theAutofit of the shape.
Return
Autofit — The autofit type.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getFontScale()
Gets the font scale applied to the shape. For shapes withAutofitAutofit orAutofit, this value is the default value of 1.ForAutofit, the value returned is what the original font size ismultiplied by to fit within the shape.
Return
Number — The font scale.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getLineSpacingReduction()
Gets the line spacing reduction applied to the shape. For shapes withAutofitAutofit orAutofit, this value is the default valueof 0. ForAutofit, the returned value is the amount of spacingsubtracted from the original spacing to make the text fit within the shape.
Return
Number — The line spacing.
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.