Class TextStyle | Apps Script | Google for Developers (original) (raw)
Google Workspace services
Calendar
- Overview
- CalendarApp
- Classes
- Calendar
- CalendarEvent
- CalendarEventSeries
- EventGuest
- EventRecurrence
- RecurrenceRule
- Enums
- Color
- EventColor
- EventTransparency
- EventType
- GuestStatus
- Visibility
- Advanced services
- Calendar API
Docs
- Overview
- DocumentApp
- Classes
- Body
- Bookmark
- ContainerElement
- Date
- Document
- DocumentTab
- Equation
- EquationFunction
- EquationFunctionArgumentSeparator
- EquationSymbol
- FooterSection
- Footnote
- FootnoteSection
- HeaderSection
- HorizontalRule
- InlineDrawing
- InlineImage
- ListItem
- NamedRange
- PageBreak
- Paragraph
- Person
- Position
- PositionedImage
- Range
- RangeBuilder
- RangeElement
- RichLink
- Tab
- Table
- TableCell
- TableOfContents
- TableRow
- Text
- UnsupportedElement
- Interfaces
- Element
- Enums
- Attribute
- ElementType
- FontFamily
- GlyphType
- HorizontalAlignment
- ParagraphHeading
- PositionedLayout
- TabType
- TextAlignment
- VerticalAlignment
- Advanced services
- Docs API
Drive
- Overview
- DriveApp
- Classes
- File
- FileIterator
- Folder
- FolderIterator
- User
- Enums
- Access
- Permission
- Advanced services
- Drive API
- Drive Activity API
- Drive Labels API
Forms
- Overview
- FormApp
- Classes
- CheckboxGridItem
- CheckboxGridValidation
- CheckboxGridValidationBuilder
- CheckboxItem
- CheckboxValidation
- CheckboxValidationBuilder
- Choice
- DateItem
- DateTimeItem
- DurationItem
- Form
- FormResponse
- GridItem
- GridValidation
- GridValidationBuilder
- ImageItem
- ItemResponse
- ListItem
- MultipleChoiceItem
- PageBreakItem
- ParagraphTextItem
- ParagraphTextValidation
- ParagraphTextValidationBuilder
- QuizFeedback
- QuizFeedbackBuilder
- RatingItem
- ScaleItem
- SectionHeaderItem
- TextItem
- TextValidation
- TextValidationBuilder
- TimeItem
- VideoItem
- Interfaces
- Item
- Enums
- Alignment
- DestinationType
- FeedbackType
- ItemType
- PageNavigationType
- RatingIconType
Gmail
- Overview
- GmailApp
- Classes
- GmailAttachment
- GmailDraft
- GmailLabel
- GmailMessage
- GmailThread
- Advanced services
- Gmail API
Sheets
- Overview
- SpreadsheetApp
- Classes
- Banding
- BooleanCondition
- CellImage
- CellImageBuilder
- Color
- ColorBuilder
- ConditionalFormatRule
- ConditionalFormatRuleBuilder
- ContainerInfo
- DataSource for Connected Sheets
* BigQueryDataSourceSpec
* BigQueryDataSourceSpecBuilder
* DataExecutionStatus
* LookerDataSourceSpec
* LookerDataSourceSpecBuilder
* DataSource
* DataSourceChart
* DataSourceColumn
* DataSourceFormula
* DataSourceParameter
* DataSourcePivotTable
* DataSourceRefreshSchedule
* DataSourceRefreshScheduleFrequency
* DataSourceSheet
* DataSourceSheetFilter
* DataSourceSpec
* DataSourceSpecBuilder
* DataSourceTable
* DataSourceTableColumn
* DataSourceTableFilter - DataValidation
- DataValidationBuilder
- DateTimeGroupingRule
- DeveloperMetadata
- DeveloperMetadataFinder
- DeveloperMetadataLocation
- Drawing
- EmbeddedAreaChartBuilder
- EmbeddedBarChartBuilder
- EmbeddedChart
- EmbeddedChartBuilder
- EmbeddedColumnChartBuilder
- EmbeddedComboChartBuilder
- EmbeddedHistogramChartBuilder
- EmbeddedLineChartBuilder
- EmbeddedPieChartBuilder
- EmbeddedScatterChartBuilder
- EmbeddedTableChartBuilder
- Filter
- FilterCriteria
- FilterCriteriaBuilder
- GradientCondition
- Group
- NamedRange
- OverGridImage
- PageProtection
- PivotFilter
- PivotGroup
- PivotGroupLimit
- PivotTable
- PivotValue
- Protection
- Range
- RangeList
- RichTextValue
- RichTextValueBuilder
- Selection
- Sheet
- Slicer
- SortSpec
- Spreadsheet
- SpreadsheetTheme
- TextFinder
- TextRotation
- TextStyle
- TextStyleBuilder
- ThemeColor
- Enums
- AutoFillSeries
- BandingTheme
- BooleanCriteria
- BorderStyle
- CopyPasteType
- DataValidationCriteria
- DateTimeGroupingRuleType
- DeveloperMetadataLocationType
- DeveloperMetadataVisibility
- Dimension
- Direction
- FrequencyType
- GroupControlTogglePosition
- InterpolationType
- PivotTableSummarizeFunction
- PivotValueDisplayType
- ProtectionType
- RecalculationInterval
- RelativeDate
- SheetType
- SortOrder
- TextDirection
- TextToColumnsDelimiter
- ThemeColorType
- ValueType
- WrapStrategy
- Advanced services
- Sheets API
Slides
- Overview
- SlidesApp
- Classes
- AffineTransform
- AffineTransformBuilder
- AutoText
- Autofit
- Border
- Color
- ColorScheme
- ConnectionSite
- Fill
- Group
- Image
- Layout
- Line
- LineFill
- Link
- List
- ListStyle
- Master
- NotesMaster
- NotesPage
- Page
- PageBackground
- PageElement
- PageElementRange
- PageRange
- Paragraph
- ParagraphStyle
- PictureFill
- Point
- Presentation
- Selection
- Shape
- SheetsChart
- Slide
- SolidFill
- SpeakerSpotlight
- Table
- TableCell
- TableCellRange
- TableColumn
- TableRow
- TextRange
- TextStyle
- ThemeColor
- Video
- WordArt
- Enums
- AlignmentPosition
- ArrowStyle
- AutoTextType
- AutofitType
- CellMergeState
- ContentAlignment
- DashStyle
- FillType
- LineCategory
- LineFillType
- LineType
- LinkType
- ListPreset
- PageBackgroundType
- PageElementType
- PageType
- ParagraphAlignment
- PlaceholderType
- PredefinedLayout
- SelectionType
- ShapeType
- SheetsChartEmbedType
- SlideLinkingMode
- SlidePosition
- SpacingMode
- TextBaselineOffset
- TextDirection
- ThemeColorType
- VideoSourceType
- Advanced services
- Slides API
More...
- Groups
* Overview
* GroupsApp
* Classes
* Group
* Enums
* Role
* Advanced services
* Cloud Identity Groups API
* Migrate from Groups Service - People
* Advanced services
* People API
* Migrate from Contacts service
* Contacts
* Overview
* ContactsApp
* Classes
* AddressField
* CompanyField
* Contact
* ContactGroup
* CustomField
* DateField
* EmailField
* IMField
* PhoneField
* UrlField
* Enums
* ExtendedField
* Field
* Gender
* Priority
* Sensitivity
- Groups
Other Google services
Google Maps
YouTube
- Advanced services
- YouTube Data API
- YouTube Analytics API
- YouTube Content ID API
More...
- Google Ads & Merchant Center
- Google Data Studio
* Overview
* DataStudioApp
* Classes
* BigQueryConfig
* Checkbox
* CommunityConnector
* Config
* DebugError
* Field
* Fields
* GetAuthTypeResponse
* GetDataResponse
* GetSchemaResponse
* Info
* OptionBuilder
* SelectMultiple
* SelectSingle
* SetCredentialsResponse
* TextArea
* TextInput
* UserError
* Enums
* AggregationType
* AuthType
* BigQueryParameterType
* FieldType
Utility services
API & database connections
- JDBC
* Overview
* Jdbc
* Classes
* JdbcArray
* JdbcBlob
* JdbcCallableStatement
* JdbcClob
* JdbcConnection
* JdbcDatabaseMetaData
* JdbcDate
* JdbcParameterMetaData
* JdbcPreparedStatement
* JdbcRef
* JdbcResultSet
* JdbcResultSetMetaData
* JdbcRowId
* JdbcSQLXML
* JdbcSavepoint
* JdbcStatement
* JdbcStruct
* JdbcTime
* JdbcTimestamp
- JDBC
Data usability & optimization
- Optimization
* Overview
* LinearOptimizationService
* Classes
* LinearOptimizationConstraint
* LinearOptimizationEngine
* LinearOptimizationSolution
* Enums
* Status
* VariableType - XML
* Overview
* XmlService
* Classes
* Attribute
* Cdata
* Comment
* DocType
* Document
* Element
* EntityRef
* Format
* Namespace
* ProcessingInstruction
* Text
* Interfaces
* Content
* Enums
* ContentType
- Optimization
HTML & content
- Charts
* Overview
* Charts
* Classes
* AreaChartBuilder
* BarChartBuilder
* Chart
* ChartOptions
* ColumnChartBuilder
* DataTable
* DataTableBuilder
* DataViewDefinition
* DataViewDefinitionBuilder
* LineChartBuilder
* NumberRangeFilterBuilder
* PieChartBuilder
* ScatterChartBuilder
* StringFilterBuilder
* TableChartBuilder
* TextStyle
* TextStyleBuilder
* Interfaces
* DataTableSource
* Enums
* ChartHiddenDimensionStrategy
* ChartMergeStrategy
* ChartType
* ColumnType
* CurveStyle
* MatchType
* Orientation
* PickerValuesLayout
* PointStyle
* Position - HTML
* Overview
* google.script.history (client-side)
* google.script.host (client-side)
* google.script.run (client-side)
* google.script.url (client-side)
* HtmlService
* Classes
* HtmlOutput
* HtmlOutputMetaTag
* HtmlTemplate
* Enums
* SandboxMode
* XFrameOptionsMode
- Charts
Script execution & information
- Base
* Overview
* Browser
* Logger
* MimeType
* Session
* console
* Classes
* Blob
* Menu
* PromptResponse
* RgbColor
* Ui
* User
* Interfaces
* BlobSource
* Enums
* Button
* ButtonSet
* ColorType
* Month
* Weekday - Script
* Overview
* ScriptApp
* Classes
* AuthorizationInfo
* CalendarTriggerBuilder
* ClockTriggerBuilder
* DocumentTriggerBuilder
* FormTriggerBuilder
* Service
* SpreadsheetTriggerBuilder
* StateTokenBuilder
* Trigger
* TriggerBuilder
* Enums
* AuthMode
* AuthorizationStatus
* EventType
* InstallationSource
* TriggerSource
- Base
Script project resources
Manifest
Google Workspace add-ons
Services
- Card
* Overview
* CardService
* Classes
* Action
* ActionResponse
* ActionResponseBuilder
* ActionStatus
* Attachment
* AuthorizationAction
* AuthorizationException
* BorderStyle
* Button
* ButtonSet
* CalendarEventActionResponse
* CalendarEventActionResponseBuilder
* Card
* CardAction
* CardBuilder
* CardHeader
* CardSection
* CardWithId
* Carousel
* CarouselCard
* ChatActionResponse
* ChatClientDataSource
* ChatResponse
* ChatResponseBuilder
* ChatSpaceDataSource
* Chip
* ChipList
* CollapseControl
* Column
* Columns
* ComposeActionResponse
* ComposeActionResponseBuilder
* DatePicker
* DateTimePicker
* DecoratedText
* Dialog
* DialogAction
* Divider
* DriveItemsSelectedActionResponse
* DriveItemsSelectedActionResponseBuilder
* EditorFileScopeActionResponse
* EditorFileScopeActionResponseBuilder
* FixedFooter
* Grid
* GridItem
* HostAppDataSource
* IconImage
* Image
* ImageButton
* ImageComponent
* ImageCropStyle
* KeyValue
* LinkPreview
* MaterialIcon
* Navigation
* Notification
* OpenLink
* OverflowMenu
* OverflowMenuItem
* PlatformDataSource
* SelectionInput
* Suggestions
* SuggestionsResponse
* SuggestionsResponseBuilder
* Switch
* TextButton
* TextInput
* TextParagraph
* TimePicker
* UniversalActionResponse
* UniversalActionResponseBuilder
* UpdateDraftActionResponse
* UpdateDraftActionResponseBuilder
* UpdateDraftBccRecipientsAction
* UpdateDraftBodyAction
* UpdateDraftCcRecipientsAction
* UpdateDraftSubjectAction
* UpdateDraftToRecipientsAction
* UpdatedWidget
* Validation
* Widget
* Enums
* BorderType
* ChipListLayout
* CommonDataSource
* ComposedEmailType
* ContentType
* DisplayStyle
* GridItemLayout
* HorizontalAlignment
* HorizontalSizeStyle
* Icon
* ImageButtonStyle
* ImageCropType
* ImageStyle
* InputType
* Interaction
* LoadIndicator
* OnClose
* OpenAs
* ResponseType
* SelectionInputType
* Status
* SwitchControlType
* TextButtonStyle
* UpdateDraftBodyType
* VerticalAlignment
* WrapStyle - Conferencing Data
* Overview
* ConferenceDataService
* Classes
* ConferenceData
* ConferenceDataBuilder
* ConferenceError
* ConferenceParameter
* EntryPoint
* Enums
* ConferenceErrorType
* EntryPointFeature
* EntryPointType
- Card
Manifest
Apps Script API
v1
- Overview
- REST Resources
- Types
- ExecuteStreamResponse
- ExecutionError
- ExecutionResponse
- File
- LocalizedMessage
- NullValue
Class TextStyle
Stay organized with collections Save and categorize content based on your preferences.
TextStyle
The style of text.
Read methods in this class return null
if the corresponding [TextRange](/apps-script/reference/slides/text-range)
spans multiple text runs, and those runs have different values for the read method being called. To avoid this, query for text styles using the [TextRange](/apps-script/reference/slides/text-range)
s returned by the [TextRange.getRuns()](/apps-script/reference/slides/text-range#getRuns%28%29)
method.
If you use methods that edit how text fits within a shape, any autofit settings applied to the text styles are deactivated.
Methods
Method | Return type | Brief description |
---|---|---|
getBackgroundColor() | Color | Returns the background color of the text, or null if there are multiple styles on the text. |
getBaselineOffset() | TextBaselineOffset | Returns the vertical offset of text from its normal position, or null if there are multiple styles on the text. |
getFontFamily() | String | Returns the font family of the text, or null if there are multiple styles on the text. |
getFontSize() | Number | Returns the font size of the text in points, or null if there are multiple styles on the text. |
getFontWeight() | Integer | Returns the font weight of the text, or null if there are multiple styles on the text. |
getForegroundColor() | Color | Returns the foreground color of the text, or null if there are multiple styles on the text. |
getLink() | Link | Returns the Link on the text, or null if there is no link or if the link is on part of the text or if there are multiple links. |
hasLink() | Boolean | Returns true if there is link on the text, false if not, or null if the link is on part of the text or there are multiple links. |
isBackgroundTransparent() | Boolean | Returns true if the background of the text is transparent, false if not, ornull if there are multiple styles on the text. |
isBold() | Boolean | Returns true if the text is rendered as bold, false if not, or null if there are multiple styles on the text. |
isItalic() | Boolean | Returns true if the text is italicized, false if not, or null if there are multiple styles on the text. |
isSmallCaps() | Boolean | Returns true if the text is in small capital letters, false if not, or null if there are multiple styles on the text. |
isStrikethrough() | Boolean | Returns true if the text is struck through, false if not, or null if there are multiple styles on the text. |
isUnderline() | Boolean | Returns true if the text is underlined, false if not, or null if there are multiple styles on the text. |
removeLink() | TextStyle | Removes a Link. |
setBackgroundColor(color) | TextStyle | Sets the background color of the text. |
setBackgroundColor(red, green, blue) | TextStyle | Sets the background color of the text to the given RGB values from 0 to 255. |
setBackgroundColor(hexColor) | TextStyle | Sets the background color of the text to the given hex color string. |
setBackgroundColor(color) | TextStyle | Sets the background color of the text to the given ThemeColorType. |
setBackgroundColorTransparent() | TextStyle | Sets the background color of the text to transparent. |
setBaselineOffset(offset) | TextStyle | Sets the vertical offset of the text relative to its normal position. |
setBold(bold) | TextStyle | Sets whether the text should be rendered as bold. |
setFontFamily(fontFamily) | TextStyle | Sets the font family of the text . |
setFontFamilyAndWeight(fontFamily, fontWeight) | TextStyle | Sets the font family and weight of the text. |
setFontSize(fontSize) | TextStyle | Sets the font size of the text, in points. |
setForegroundColor(foregroundColor) | TextStyle | Sets the foreground color of the text. |
setForegroundColor(red, green, blue) | TextStyle | Sets the foreground color of the text to the given RGB values from 0 to 255. |
setForegroundColor(hexColor) | TextStyle | Sets the foreground color of the text to the given hex color string. |
setForegroundColor(color) | TextStyle | Sets the foreground color of the text to the given ThemeColorType. |
setItalic(italic) | TextStyle | Sets the whether the text is italicized. |
setLinkSlide(slideIndex) | TextStyle | Sets a Link to the given Slide using the zero-based index of the slide. |
setLinkSlide(slide) | TextStyle | Sets a Link to the given Slide, the link is set by the given slide ID. |
setLinkSlide(slidePosition) | TextStyle | Sets a Link to the given Slide using the relative position of the slide. |
setLinkUrl(url) | TextStyle | Sets a Link to the given non-empty URL string. |
setSmallCaps(smallCaps) | TextStyle | Sets whether the text is rendered in small capital letters. |
setStrikethrough(strikethrough) | TextStyle | Sets whether the text is struck through. |
setUnderline(underline) | TextStyle | Sets whether the text is underlined. |
Detailed documentation
getBackgroundColor()
Returns the background color of the text, or null
if there are multiple styles on the text.
Return
[Color](/apps-script/reference/slides/color)
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
getBaselineOffset()
Returns the vertical offset of text from its normal position, or null
if there are multiple styles on the text.
Return
[TextBaselineOffset](/apps-script/reference/slides/text-baseline-offset)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
getFontFamily()
Returns the font family of the text, or null
if there are multiple styles on the text.
Return
String
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
getFontSize()
Returns the font size of the text in points, or null
if there are multiple styles on the text.
Return
Number
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
getFontWeight()
Returns the font weight of the text, or null
if there are multiple styles on the text.
The weight is a multiple of 100 between 100 and 900, inclusive. This range corresponds to the numerical values described in the CSS 2.1 Specification, section 15.6, with non-numerical values disallowed. Weights greater than or equal to 700 are considered bold, in which case [isBold()](#isBold%28%29)
returns true
. The default value is 400 ("normal").
Return
Integer
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
getForegroundColor()
Returns the foreground color of the text, or null
if there are multiple styles on the text.
Return
[Color](/apps-script/reference/slides/color)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
getLink()
Returns the [Link](/apps-script/reference/slides/link)
on the text, or null
if there is no link or if the link is on part of the text or if there are multiple links. Call [hasLink()](#hasLink%28%29)
to determine whether the text has no link.
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const textLink = shape.getText().getTextStyle().getLink();
if (textLink != null) {
Logger.log(Shape text has a link of type: ${textLink.getLinkType()}
);
}
Return
[Link](/apps-script/reference/slides/link)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
hasLink()
Returns true
if there is link on the text, false
if not, or null
if the link is on part of the text or there are multiple links.
Links cannot be set on newline characters. Therefore, if the [TextRange](/apps-script/reference/slides/text-range)
contains a newline character, this method always returns either null
or false
.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
isBackgroundTransparent()
Returns true
if the background of the text is transparent, false
if not, ornull
if there are multiple styles on the text.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
isBold()
Returns true
if the text is rendered as bold, false
if not, or null
if there are multiple styles on the text.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
isItalic()
Returns true
if the text is italicized, false
if not, or null
if there are multiple styles on the text.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
isSmallCaps()
Returns true
if the text is in small capital letters, false
if not, or null
if there are multiple styles on the text.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
isStrikethrough()
Returns true
if the text is struck through, false
if not, or null
if there are multiple styles on the text.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
isUnderline()
Returns true
if the text is underlined, false
if not, or null
if there are multiple styles on the text.
Return
Boolean
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
removeLink()
Removes a [Link](/apps-script/reference/slides/link)
.
Removing a link removes the hyperlink foreground color and underline style on the text. If possible, these styles are applied to match the text preceding the link.
const textRange = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0].getText(); textRange.getTextStyle().removeLink();
Return
[TextStyle](#)
setBackgroundColor(color)
Sets the background color of the text.
Parameters
Name | Type | Description |
---|---|---|
color | Color |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setBackgroundColor(red, green, blue)
Sets the background color of the text to the given RGB values from 0 to 255.
Parameters
Name | Type | Description |
---|---|---|
red | Integer | |
green | Integer | |
blue | Integer |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setBackgroundColor(hexColor)
Sets the background color of the text to the given hex color string.
The hex string must be in the format '#RRGGBB'. For example, pink would be represented as '#FFC0CB'.
Parameters
Name | Type | Description |
---|---|---|
hexColor | String |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setBackgroundColor(color)
Sets the background color of the text to the given [ThemeColorType](/apps-script/reference/slides/theme-color-type)
.
Parameters
Name | Type | Description |
---|---|---|
color | ThemeColorType |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setBackgroundColorTransparent()
Sets the background color of the text to transparent.
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setBaselineOffset(offset)
Sets the vertical offset of the text relative to its normal position.
Parameters
Name | Type | Description |
---|---|---|
offset | TextBaselineOffset |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setBold(bold)
Sets whether the text should be rendered as bold.
Changing the text's boldness updates the font weight used to render the text.
Parameters
Name | Type | Description |
---|---|---|
bold | Boolean |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setFontFamily(fontFamily)
Sets the font family of the text .
Parameters
Name | Type | Description |
---|---|---|
fontFamily | String |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setFontFamilyAndWeight(fontFamily, fontWeight)
Sets the font family and weight of the text.
The weight is a multiple of 100 between 100 and 900, inclusive. This range corresponds to the numerical values described in the CSS 2.1 Specification, section 15.6, with non-numerical values disallowed. Weights greater than or equal to 700 are considered bold, in which case [isBold()](#isBold%28%29)
returns true
. The default value is 400 ("normal").
Parameters
Name | Type | Description |
---|---|---|
fontFamily | String | |
fontWeight | Integer |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setFontSize(fontSize)
Sets the font size of the text, in points.
Parameters
Name | Type | Description |
---|---|---|
fontSize | Number |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setForegroundColor(foregroundColor)
Sets the foreground color of the text.
Parameters
Name | Type | Description |
---|---|---|
foregroundColor | Color |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setForegroundColor(red, green, blue)
Sets the foreground color of the text to the given RGB values from 0 to 255.
Parameters
Name | Type | Description |
---|---|---|
red | Integer | |
green | Integer | |
blue | Integer |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setForegroundColor(hexColor)
Sets the foreground color of the text to the given hex color string.
The hex string must be in the format '#RRGGBB'. For example, pink would be represented as '#FFC0CB'.
Parameters
Name | Type | Description |
---|---|---|
hexColor | String |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setForegroundColor(color)
Sets the foreground color of the text to the given [ThemeColorType](/apps-script/reference/slides/theme-color-type)
.
Parameters
Name | Type | Description |
---|---|---|
color | ThemeColorType |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setItalic(italic)
Sets the whether the text is italicized.
Parameters
Name | Type | Description |
---|---|---|
italic | Boolean |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setLinkSlide(slideIndex)
Sets a [Link](/apps-script/reference/slides/link)
to the given [Slide](/apps-script/reference/slides/slide)
using the zero-based index of the slide.
Setting a link changes the style of the text to be underlined and to have a [ThemeColorType.HYPERLINK](/apps-script/reference/slides/theme-color-type#HYPERLINK)
foreground color. This can be changed via [setForegroundColor(hexColor)](#setForegroundColor%28String%29)
and [setUnderline(underline)](#setUnderline%28Boolean%29)
.
Since links cannot be set on newline characters, newline characters in the [TextRange](/apps-script/reference/slides/text-range)
are ignored.
// Set a link to the first slide of the presentation. const presentation = SlidesApp.getActivePresentation(); const slide = presentation.getSlides()[0]; const textRange = slide.getShapes()[0].getText(); textRange.getTextStyle().setLinkSlide(0);
Parameters
Name | Type | Description |
---|---|---|
slideIndex | Integer | The zero-based index to the slide. |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setLinkSlide(slide)
Sets a [Link](/apps-script/reference/slides/link)
to the given [Slide](/apps-script/reference/slides/slide)
, the link is set by the given slide ID.
Setting a link changes the style of the text to be underlined and to have a [ThemeColorType.HYPERLINK](/apps-script/reference/slides/theme-color-type#HYPERLINK)
foreground color. This can be changed via [setForegroundColor(hexColor)](#setForegroundColor%28String%29)
and [setUnderline(underline)](#setUnderline%28Boolean%29)
.
Since links cannot be set on newline characters, newline characters in the [TextRange](/apps-script/reference/slides/text-range)
are ignored.
// Set a link to the first slide of the presentation. const presentation = SlidesApp.getActivePresentation(); const slide = presentation.getSlides()[0]; const textRange = slide.getShapes()[0].getText(); textRange.getTextStyle().setLinkSlide(slide);
Parameters
Name | Type | Description |
---|---|---|
slide | Slide | The Slide to be linked. |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setLinkSlide(slidePosition)
Sets a [Link](/apps-script/reference/slides/link)
to the given [Slide](/apps-script/reference/slides/slide)
using the relative position of the slide.
Setting a link changes the style of the text to be underlined and to have a [ThemeColorType.HYPERLINK](/apps-script/reference/slides/theme-color-type#HYPERLINK)
foreground color. This can be changed via [setForegroundColor(hexColor)](#setForegroundColor%28String%29)
and [setUnderline(underline)](#setUnderline%28Boolean%29)
.
Since links cannot be set on newline characters, newline characters in the [TextRange](/apps-script/reference/slides/text-range)
are ignored.
// Set a link to the first slide of the presentation. const textRange = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0].getText(); textRange.getTextStyle().setLinkSlide(SlidesApp.SlidePosition.FIRST_SLIDE);
Parameters
Name | Type | Description |
---|---|---|
slidePosition | SlidePosition | The relative SlidePosition. |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setLinkUrl(url)
Sets a [Link](/apps-script/reference/slides/link)
to the given non-empty URL string.
Setting a link changes the style of the text to be underlined and to have a [ThemeColorType.HYPERLINK](/apps-script/reference/slides/theme-color-type#HYPERLINK)
foreground color. This can be changed via [setForegroundColor(hexColor)](#setForegroundColor%28String%29)
and [setUnderline(underline)](#setUnderline%28Boolean%29)
.
Since links cannot be set on newline characters, newline characters in the [TextRange](/apps-script/reference/slides/text-range)
are ignored.
// Set a link to the URL. const textRange = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0].getText(); textRange.getTextStyle().setLinkUrl('https://slides.google.com');
Parameters
Name | Type | Description |
---|---|---|
url | String | The URL string. |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setSmallCaps(smallCaps)
Sets whether the text is rendered in small capital letters.
Parameters
Name | Type | Description |
---|---|---|
smallCaps | Boolean |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setStrikethrough(strikethrough)
Sets whether the text is struck through.
Parameters
Name | Type | Description |
---|---|---|
strikethrough | Boolean |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/presentations.currentonly
https://www.googleapis.com/auth/presentations
setUnderline(underline)
Sets whether the text is underlined.
Parameters
Name | Type | Description |
---|---|---|
underline | Boolean |
Return
[TextStyle](#)
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
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 the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-03 UTC.