PowerPoint.ShapeFont class
図形の TextRange オブジェクトのフォント名、フォント サイズ、色などのフォント属性を表します。
- Extends
注釈
使用元
例
// 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");
const parentTextFrame: PowerPoint.TextFrame = textRange.getParentTextFrame();
const parentShape: PowerPoint.Shape = parentTextFrame.getParentShape();
const parentSlide: PowerPoint.Slide = parentShape.getParentSlide();
parentShape.load("id");
parentSlide.load("id");
await context.sync();
console.log(`Selected text range found in parent shape with ID ${parentShape.id} on parentSlide with ID ${parentSlide.id}`);
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 |
|
| bold |
|
| color | テキストの色の HTML カラー コード表現を指定します (例: "#FF0000" は赤を表します)。
|
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| double |
|
| italic |
|
| name | フォント名を指定します (例: "Calibri")。 テキストが複合文字または東アジア言語の場合、これは対応するフォント名です。それ以外の場合は、ラテン文字のフォント名です。
|
| size | フォント サイズをポイント単位で指定します (例: 11)。
|
| small |
|
| strikethrough |
|
| subscript |
|
| superscript |
|
| underline | フォントに適用する下線の種類を指定します。
|
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| toJSON() | API オブジェクトが |
プロパティの詳細
allCaps
TextRange内のテキストが、小文字を大文字として表示する All Caps 属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに All Caps 属性があります。false: いずれのテキストにも All 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
注釈
例
// 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内のテキストが取り消し線属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに 取り消し線属性 が付いています。false: 取り 消し線 属性を持つテキストはありません。null: テキストのすべてではなく一部に 取り消し線 属性がある場合は返されます。
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
TextRange内のテキストが、小文字を小文字として表示する Small Caps 属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
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内のテキストが "下付き" 属性を使用するように設定されているかどうかを指定します。 次の値が示される可能性があります。
true: すべてのテキストに "下付き " 属性があります。false: どのテキストにも 下付き 属性がありません。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
注釈
例
// 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;