Class Autofit

  • 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.

  • ThedisableAutofit() method sets the autofit type toNONE.

  • ThegetAutofitType(),getFontScale(), andgetLineSpacingReduction() methods provide information about the shape's autofit settings.

Autofit

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 toAutofitType.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

MethodReturn typeBrief description
disableAutofit()AutofitSets theAutofitType of a shape toAutofitType.NONE.
getAutofitType()AutofitTypeGets theAutofitType of the shape.
getFontScale()NumberGets the font scale applied to the shape.
getLineSpacingReduction()NumberGets the line spacing reduction applied to the shape.

Detailed documentation

disableAutofit()

Sets theAutofitType of a shape toAutofitType.NONE.

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.currentonly
  • https://www.googleapis.com/auth/presentations

getAutofitType()

Gets theAutofitType of the shape.

Return

AutofitType — The autofit type.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getFontScale()

Gets the font scale applied to the shape. For shapes withAutofitTypeAutofitType.NONE orAutofitType.SHAPE_AUTOFIT, this value is the default value of 1.ForAutofitType.TEXT_AUTOFIT, 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.currentonly
  • https://www.googleapis.com/auth/presentations

getLineSpacingReduction()

Gets the line spacing reduction applied to the shape. For shapes withAutofitTypeAutofitType.NONE orAutofitType.SHAPE_AUTOFIT, this value is the default valueof 0. ForAutofitType.TEXT_AUTOFIT, 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.currentonly
  • https://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.