How do you tell whether text fits within its bounding shape?
Solution 1:
As of January 2021, you can set auto fit setting in Google Slides editor.
When you click inside shape, you can see new Auto-fit setting, set to "Do not autofit" by default:
You can change it to "Shrink text on overflow":
Or another option: "Resize shape to fit text":
Update (July 2021): there new autofit
properties of Shape element:
autofitType
The autofit type of the shape. If the autofit type is
AUTOFIT_TYPE_UNSPECIFIED
, the autofit type is inherited from a parent placeholder if it exists. The field is automatically set toNONE
if a request is made that might affect text fitting within its bounding text box. In this case thefontScale
is applied to thefontSize
and thelineSpacingReduction
is applied to thelineSpacing
. Both properties are also reset to default values.
fontScale - readonly
The font scale applied to the shape. For shapes with
autofitType
NONE
orSHAPE_AUTOFIT
, this value is the default value of 1. ForTEXT_AUTOFIT
, this value multiplied by thefontSize
gives the font size that is rendered in the editor.
lineSpacingReduction - readonly
The line spacing reduction applied to the shape. For shapes with
autofitType
NONE
orSHAPE_AUTOFIT
, this value is the default value of 0. ForTEXT_AUTOFIT
, this value subtracted from thelineSpacing
gives the line spacing that is rendered in the editor.
P.S. autofitType
may be not marked as readonly in documentation, but there seems to be a bug which currently prevents an easy way to set it (to any other value than NONE
), see https://issuetracker.google.com/issues/189153562#comment5 and https://developers.google.com/apps-script/reference/slides/autofit (just getAutofitType()
available)