文字樣式。
如果對應的 Text 跨越多個文字執行,且這些執行個體針對所呼叫的讀取方法有不同的值,這個類別中的讀取方法會傳回 null。如要避免發生這種情況,請使用 Text 方法傳回的 Text 查詢文字樣式。
如果您使用的方法會編輯文字在形狀內的顯示方式,系統會停用套用至文字樣式的任何自動調整設定。
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
get | Color|null | 傳回文字的背景顏色,如果文字有多種樣式,則傳回 null。 |
get | Text | 傳回文字與正常位置的垂直偏移量,如果文字有多種樣式,則傳回 null。 |
get | String|null | 傳回文字的字型系列,如果文字有多種樣式,則傳回 null。 |
get | Number|null | 傳回文字的字型大小 (以點為單位),如果文字有多種樣式,則傳回 null。 |
get | Integer|null | 傳回文字的字型粗細,如果文字有多種樣式,則傳回 null。 |
get | Color|null | 傳回文字的前景顏色,如果文字有多種樣式,則傳回 null。 |
get | Link|null | 傳回文字的 Link,如果沒有連結、連結位於部分文字,或有多個連結,則傳回 null。 |
has | Boolean|null | 如果文字有連結,則傳回 true;如果沒有,則傳回 false;如果連結位於部分文字或有多個連結,則傳回 null。 |
is | Boolean|null | 如果文字背景為透明,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。 |
is | Boolean|null | 如果文字以粗體顯示,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。 |
is | Boolean|null | 如果文字為斜體,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。 |
is | Boolean|null | 如果文字為小型大寫字母,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。 |
is | Boolean|null | 如果文字加上刪除線,則傳回 true;如果沒有,則傳回 false;如果文字有多種樣式,則傳回 null。 |
is | Boolean|null | 如果文字加上底線,則傳回 true;如果沒有,則傳回 false;如果文字有多種樣式,則傳回 null。 |
remove | Text | 移除 Link。 |
set | Text | 設定文字的背景顏色。 |
set | Text | 將文字的背景顏色設為指定 RGB 值 (0 到 255)。 |
set | Text | 將文字的背景顏色設為指定的十六進位顏色字串。 |
set | Text | 將文字的背景顏色設為指定的 Theme。 |
set | Text | 將文字的背景顏色設為透明。 |
set | Text | 設定文字相對於正常位置的垂直位移。 |
set | Text | 設定文字是否應以粗體顯示。 |
set | Text | 設定文字的字型系列。 |
set | Text | 設定文字的字型系列和粗細。 |
set | Text | 設定文字的字型大小 (以點為單位)。 |
set | Text | 設定文字的前景顏色。 |
set | Text | 將文字的前景色設為指定 RGB 值 (0 到 255)。 |
set | Text | 將文字的前景顏色設為指定的十六進位顏色字串。 |
set | Text | 將文字的前景顏色設為指定的 Theme。 |
set | Text | 設定文字是否為斜體。 |
set | Text | 使用投影片的索引 (從零開始計算),將 Link 設為指定 Slide。 |
set | Text | 將 Link 設為指定 Slide,連結會依指定投影片 ID 設定。 |
set | Text | 使用投影片的相對位置,將 Link 設為指定 Slide。 |
set | Text | 將 Link 設為指定的非空白網址字串。 |
set | Text | 設定文字是否以小型大寫字母顯示。 |
set | Text | 設定文字是否要加上刪除線。 |
set | Text | 設定文字是否加上底線。 |
內容詳盡的說明文件
get Background Color()
get Baseline Offset()
傳回文字與正常位置的垂直偏移量,如果文字有多種樣式,則傳回 null。
回攻員
Text:文字與正常位置的垂直偏移量。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Font Family()
傳回文字的字型系列,如果文字有多種樣式,則傳回 null。
回攻員
String|null - 文字的字型系列。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Font Size()
傳回文字的字型大小 (以點為單位),如果文字有多種樣式,則傳回 null。
回攻員
Number|null:文字的字型大小 (以點為單位)。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Font Weight()
傳回文字的字型粗細,如果文字有多種樣式,則傳回 null。
權重是 100 到 900 (含 100 和 900) 之間的倍數。這個範圍對應至 CSS 2.1 規格第 15.6 節所述的數值,且不允許非數值。如果權重大於或等於 700,系統會視為粗體,此時 is 會傳回 true。預設值為 400 (「normal」)。
回攻員
Integer|null:文字的字型粗細。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Foreground Color()
get Link()
傳回文字的 Link,如果沒有連結、連結位於部分文字,或有多個連結,則傳回 null。呼叫 has,判斷文字是否沒有連結。
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()}`); }
回攻員
Link|null:文字中的連結。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
has Link()
is Background Transparent()
如果文字背景為透明,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。
回攻員
Boolean|null - 文字背景是否透明。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
is Bold()
如果文字以粗體顯示,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。
回攻員
Boolean|null:文字是否以粗體顯示。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
is Italic()
如果文字為斜體,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。
回攻員
Boolean|null:文字是否為斜體。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
is Small Caps()
如果文字為小型大寫字母,則傳回 true;如果不是,則傳回 false;如果文字有多種樣式,則傳回 null。
回攻員
Boolean|null:文字是否為小型大寫字母。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
is Strikethrough()
如果文字加上刪除線,則傳回 true;如果沒有,則傳回 false;如果文字有多種樣式,則傳回 null。
回攻員
Boolean|null:文字是否加上刪除線。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
is Underline()
如果文字加上底線,則傳回 true;如果沒有,則傳回 false;如果文字有多種樣式,則傳回 null。
回攻員
Boolean|null:文字是否加上底線。
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
remove Link()
set Background Color(color)
set Background Color(red, green, blue)
set Background Color(hexColor)
set Background Color(color)
將文字的背景顏色設為指定的 Theme。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
color | Theme | 主題顏色類型。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
set Background Color Transparent()
set Baseline Offset(offset)
設定文字相對於正常位置的垂直位移。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
offset | Text | 要設定的基準偏移。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
set Bold(bold)
set Font Family(fontFamily)
set Font Family And Weight(fontFamily, fontWeight)
set Font Size(fontSize)
set Foreground Color(foregroundColor)
set Foreground Color(red, green, blue)
set Foreground Color(hexColor)
set Foreground Color(color)
將文字的前景顏色設為指定的 Theme。
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
color | Theme | 主題顏色類型。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
set Italic(italic)
set Link Slide(slideIndex)
使用投影片的索引 (從零開始計算),將 Link 設為指定 Slide。
設定連結後,文字樣式會加上底線,並套用Theme前景顏色。這項設定可以透過 set 和 set 變更。
由於無法在換行字元上設定連結,系統會忽略 Text 中的換行字元。
// 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);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
slide | Integer | 投影片的索引,從零開始。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
set Link Slide(slide)
將 Link 設為指定 Slide,連結會依指定投影片 ID 設定。
設定連結後,文字樣式會加上底線,並套用Theme前景顏色。這項設定可以透過 set 和 set 變更。
由於無法在換行字元上設定連結,系統會忽略 Text 中的換行字元。
// 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);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
slide | Slide | 要連結的 Slide。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
set Link Slide(slidePosition)
設定連結後,文字樣式會加上底線,並套用Theme前景顏色。這項設定可以透過 set 和 set 變更。
由於無法在換行字元上設定連結,系統會忽略 Text 中的換行字元。
// 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);
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
slide | Slide | 相對 Slide。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
set Link Url(url)
將 Link 設為指定的非空白網址字串。
設定連結後,文字樣式會加上底線,並套用Theme前景顏色。這項設定可以透過 set 和 set 變更。
由於無法在換行字元上設定連結,系統會忽略 Text 中的換行字元。
// Set a link to the URL. const textRange = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0].getText(); textRange.getTextStyle().setLinkUrl('https://slides.google.com');
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
url | String | 網址字串。 |
回攻員
Text — This Text, for chaining.
授權
使用這個方法的指令碼需要透過下列一或多個範圍授權:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations