Class Autofit
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ajustement automatique
Décrit les paramètres d'ajustement automatique d'une forme. Si une modification est apportée et qu'elle peut affecter l'ajustement du texte dans sa zone de texte de délimitation:
- L'ajustement automatique est désactivé et défini sur
AutofitType.NONE
.
- L'échelle de police est rétablie sur la valeur par défaut et appliquée à la taille de police.
- La réduction de l'interligne est réinitialisée sur la valeur par défaut et appliquée à l'interligne.
Documentation détaillée
disableAutofit()
Définit la valeur AutofitType
d'une forme sur AutofitType.NONE
.
Renvois
Autofit
: ajustement automatique, pour le chaînage.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getAutofitType()
Récupère le AutofitType
de la forme.
Renvois
AutofitType
: type d'ajustement automatique.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getFontScale()
Récupère l'échelle de police appliquée à la forme. Pour les formes avec AutofitType
AutofitType.NONE
ou AutofitType.SHAPE_AUTOFIT
, cette valeur est la valeur par défaut de 1.
Pour AutofitType.TEXT_AUTOFIT
, la valeur renvoyée est celle par laquelle la taille de police d'origine est multipliée pour s'adapter à la forme.
Renvois
Number
: échelle de la police.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getLineSpacingReduction()
Récupère la réduction de l'interligne appliquée à la forme. Pour les formes avec AutofitType
, AutofitType.NONE
ou AutofitType.SHAPE_AUTOFIT
, cette valeur est la valeur par défaut de 0. Pour AutofitType.TEXT_AUTOFIT
, la valeur renvoyée correspond à la quantité d'espacement soustraite de l'espacement d'origine pour que le texte s'adapte à la forme.
Renvois
Number
: interligne.
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[null,null,["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003eAutofit settings determine how text adjusts within a shape's boundaries in Google Slides, and when modified, the settings reset to defaults, impacting font scale and line spacing.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize methods like \u003ccode\u003edisableAutofit()\u003c/code\u003e, \u003ccode\u003egetAutofitType()\u003c/code\u003e, \u003ccode\u003egetFontScale()\u003c/code\u003e, and \u003ccode\u003egetLineSpacingReduction()\u003c/code\u003e to manage the Autofit behavior of shapes programmatically.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetFontScale()\u003c/code\u003e and \u003ccode\u003egetLineSpacingReduction()\u003c/code\u003e methods return default values for shapes with AutofitType.NONE or AutofitType.SHAPE_AUTOFIT, while for AutofitType.TEXT_AUTOFIT, they reflect adjustments made to fit text within the shape.\u003c/p\u003e\n"],["\u003cp\u003eAll provided methods necessitate authorization with specific scopes like \u003ccode\u003ehttps://www.googleapis.com/auth/presentations.currentonly\u003c/code\u003e or \u003ccode\u003ehttps://www.googleapis.com/auth/presentations\u003c/code\u003e for scripts to function correctly.\u003c/p\u003e\n"]]],[],null,["# Class Autofit\n\nAutofit\n\nDescribes the autofit settings of a shape. If a change is made that might affect text fitting\nwithin its bounding text box:\n\n- Autofit is deactivated and set to [AutofitType.NONE](/apps-script/reference/slides/autofit-type#NONE).\n- The font scale is reset to the default value and applied to the font size.\n- The line spacing reduction is reset to the default value and applied to the line spacing. \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------|-----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [disableAutofit()](#disableAutofit()) | [Autofit](#) | Sets the [AutofitType](/apps-script/reference/slides/autofit-type) of a shape to [AutofitType.NONE](/apps-script/reference/slides/autofit-type#NONE). |\n| [getAutofitType()](#getAutofitType()) | [AutofitType](/apps-script/reference/slides/autofit-type) | Gets the [AutofitType](/apps-script/reference/slides/autofit-type) of the shape. |\n| [getFontScale()](#getFontScale()) | `Number` | Gets the font scale applied to the shape. |\n| [getLineSpacingReduction()](#getLineSpacingReduction()) | `Number` | Gets the line spacing reduction applied to the shape. |\n\nDetailed documentation\n----------------------\n\n### `disable``Autofit()`\n\nSets the [AutofitType](/apps-script/reference/slides/autofit-type) of a shape to [AutofitType.NONE](/apps-script/reference/slides/autofit-type#NONE).\n\n#### Return\n\n\n[Autofit](#) --- The autofit, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Autofit``Type()`\n\nGets the [AutofitType](/apps-script/reference/slides/autofit-type) of the shape.\n\n#### Return\n\n\n[AutofitType](/apps-script/reference/slides/autofit-type) --- The autofit type.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Font``Scale()`\n\nGets the font scale applied to the shape. For shapes with [AutofitType](/apps-script/reference/slides/autofit-type) [AutofitType.NONE](/apps-script/reference/slides/autofit-type#NONE) or [AutofitType.SHAPE_AUTOFIT](/apps-script/reference/slides/autofit-type#SHAPE_AUTOFIT), this value is the default value of 1.\nFor [AutofitType.TEXT_AUTOFIT](/apps-script/reference/slides/autofit-type#TEXT_AUTOFIT), the value returned is what the original font size is\nmultiplied by to fit within the shape.\n\n#### Return\n\n\n`Number` --- The font scale.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Line``Spacing``Reduction()`\n\nGets the line spacing reduction applied to the shape. For shapes with [AutofitType](/apps-script/reference/slides/autofit-type)\n[AutofitType.NONE](/apps-script/reference/slides/autofit-type#NONE) or [AutofitType.SHAPE_AUTOFIT](/apps-script/reference/slides/autofit-type#SHAPE_AUTOFIT), this value is the default value\nof 0. For [AutofitType.TEXT_AUTOFIT](/apps-script/reference/slides/autofit-type#TEXT_AUTOFIT), the returned value is the amount of spacing\nsubtracted from the original spacing to make the text fit within the shape.\n\n#### Return\n\n\n`Number` --- The line spacing.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`"]]