PowerPoint.ShapeFont class
図形の TextRange オブジェクトのフォント名、フォント サイズ、色などのフォント属性を表します。
- Extends
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
// Gets navigational (complex) properties of the selected text range.
await PowerPoint.run(async (context) => {
const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
textRange.load("font,paragraphFormat/bulletFormat,paragraphFormat/horizontalAlignment");
await context.sync();
console.log("Font properties of selected text range:");
console.log(`\tallCaps: ${textRange.font.allCaps}`);
console.log(`\tbold: ${textRange.font.bold}`);
console.log(`\tcolor: ${textRange.font.color}`);
console.log(`\tdoubleStrikethrough: ${textRange.font.doubleStrikethrough}`);
console.log(`\titalic: ${textRange.font.italic}`);
console.log(`\tname: ${textRange.font.name}`);
console.log(`\tsize: ${textRange.font.size}`);
console.log(`\tsmallCaps: ${textRange.font.smallCaps}`);
console.log(`\tstrikethrough: ${textRange.font.strikethrough}`);
console.log(`\tsubscript: ${textRange.font.subscript}`);
console.log(`\tsuperscript: ${textRange.font.superscript}`);
console.log(`\tunderline: ${textRange.font.underline}`);
console.log("Paragraph format properties of selected text range:");
console.log(`\tbulletFormat.visible: ${textRange.paragraphFormat.bulletFormat.visible}`);
console.log(`\thorizontalAlignment: ${textRange.paragraphFormat.horizontalAlignment}`);
});
プロパティ
| all |
小文字を大文字にする All Caps 属性を使用するように
|
| bold |
|
| color | テキストの色の HTML 色コード表現を指定します (たとえば、"#FF0000" は赤を表します)。
|
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| double |
|
| italic |
|
| name | フォント名 ("Calibri" など) を指定します。 テキストが複合スクリプトまたは東アジア言語の場合、これは対応するフォント名です。それ以外の場合はラテンフォント名です。
|
| size | フォント サイズをポイント単位で指定します (例: 11)。
|
| small |
小文字を小さな大文字として表示する Small Caps 属性を使用するように、
|
| strikethrough |
取り消し線属性を使用するように
|
| subscript |
|
| superscript |
|
| underline | フォントに適用される下線の種類を指定します。 下線のスタイルが異なるテキスト フラグメントが |
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
プロパティの詳細
allCaps
小文字を大文字にする All Caps 属性を使用するようにTextRange内のテキストを設定するかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに All Caps 属性があります。false: すべての Caps 属性を持つテキストはありません。null: テキストの一部 (すべてではない) に All Caps 属性がある場合に返されます。
allCaps: boolean | null;
プロパティ値
boolean | null
注釈
bold
TextRange内のテキストを太字に設定するかどうかを指定します。 次の値が示される可能性があります。
true: テキストはすべて太字です。false: 太字のテキストはありません。null: テキストの一部 (すべてではない) が太字の場合に返されます。
bold: boolean | null;
プロパティ値
boolean | null
注釈
color
テキストの色の HTML 色コード表現を指定します (たとえば、"#FF0000" は赤を表します)。
TextRangeに異なる色のテキスト フラグメントが含まれている場合は、nullを返します。
color: string | null;
プロパティ値
string | null
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
// Sets the color of the selected text range to green.
await PowerPoint.run(async (context) => {
const textRange: PowerPoint.TextRange = context.presentation.getSelectedTextRange();
textRange.font.color = "green";
await context.sync();
});
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
doubleStrikethrough
TextRange内のテキストが Double 取り消し線属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに Double 取り消し線 属性があります。false: どのテキストにも Double 取り消し線 属性はありません。null: テキストの一部 (すべてではない) に Double 取り消し線 属性がある場合に返されます。
doubleStrikethrough: boolean | null;
プロパティ値
boolean | null
注釈
italic
TextRangeのテキストを斜体に設定するかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストが斜体になっています。false: どのテキストも斜体化されていません。null: テキストの一部 (すべてではない) が斜体になっている場合に返されます。
italic: boolean | null;
プロパティ値
boolean | null
注釈
name
フォント名 ("Calibri" など) を指定します。 テキストが複合スクリプトまたは東アジア言語の場合、これは対応するフォント名です。それ以外の場合はラテンフォント名です。
TextRangeに異なるフォント名を持つテキスト フラグメントが含まれている場合は、nullを返します。
name: string | null;
プロパティ値
string | null
注釈
size
フォント サイズをポイント単位で指定します (例: 11)。
TextRangeに異なるフォント サイズのテキスト フラグメントが含まれている場合は、nullを返します。
size: number | null;
プロパティ値
number | null
注釈
smallCaps
小文字を小さな大文字として表示する Small Caps 属性を使用するように、TextRange内のテキストを設定するかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに Small Caps 属性があります。false: どのテキストにも Small Caps 属性はありません。null: テキストの一部 (すべてではない) に Small Caps 属性がある場合に返されます。
smallCaps: boolean | null;
プロパティ値
boolean | null
注釈
strikethrough
取り消し線属性を使用するようにTextRange内のテキストを設定するかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに 取り消し線 属性があります。false: 取り消し線 属性を持つテキストはありません。null: テキストの一部 (すべてではない) に 取り消し線 属性がある場合に返されます。
strikethrough: boolean | null;
プロパティ値
boolean | null
注釈
subscript
TextRange内のテキストが Subscript 属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに Subscript 属性があります。false: Subscript 属性を持つテキストはありません。null: テキストの一部 (すべてではない) に Subscript 属性がある場合に返されます。
subscript: boolean | null;
プロパティ値
boolean | null
注釈
superscript
TextRange内のテキストが上付き文字属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに 上付き文字 属性があります。false: どのテキストにも 上付き文字 属性はありません。null: テキストの一部 (すべてではない) に 上付き文字 属性がある場合に返されます。
superscript: boolean | null;
プロパティ値
boolean | null
注釈
underline
フォントに適用される下線の種類を指定します。 下線のスタイルが異なるテキスト フラグメントがTextRangeに含まれている場合は、nullを返します。 詳細については、「 PowerPoint.ShapeFontUnderlineStyle 」を参照してください。
underline: PowerPoint.ShapeFontUnderlineStyle | "None" | "Single" | "Double" | "Heavy" | "Dotted" | "DottedHeavy" | "Dash" | "DashHeavy" | "DashLong" | "DashLongHeavy" | "DotDash" | "DotDashHeavy" | "DotDotDash" | "DotDotDashHeavy" | "Wavy" | "WavyHeavy" | "WavyDouble" | null;
プロパティ値
PowerPoint.ShapeFontUnderlineStyle | "None" | "Single" | "Double" | "Heavy" | "Dotted" | "DottedHeavy" | "Dash" | "DashHeavy" | "DashLong" | "DashLongHeavy" | "DotDash" | "DotDashHeavy" | "DotDotDash" | "DotDotDashHeavy" | "Wavy" | "WavyHeavy" | "WavyDouble" | null
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml
// This function gets the collection of shapes on the first slide,
// and adds a brace pair, {}, to the collection, while specifying its
// location and size. Then it names the shape, sets its text and font
// color, and centers it inside the braces.
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
const braces: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.bracePair, {
left: 100,
top: 400,
height: 50,
width: 150,
});
braces.name = "Braces";
braces.textFrame.textRange.text = "Shape text";
braces.textFrame.textRange.font.color = "purple";
braces.textFrame.textRange.font.underline = PowerPoint.ShapeFontUnderlineStyle.heavy;
braces.textFrame.verticalAlignment = PowerPoint.TextVerticalAlignment.middleCentered;
braces.textFrame.autoSizeSetting = PowerPoint.ShapeAutoSize.autoSizeShapeToFitText;
return context.sync();
});
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: PowerPoint.Interfaces.ShapeFontLoadOptions): PowerPoint.ShapeFont;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): PowerPoint.ShapeFont;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.ShapeFont;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
toJSON()
API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.ShapeFont オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.ShapeFontData として型指定) を返します。
toJSON(): PowerPoint.Interfaces.ShapeFontData;