PowerPoint.ShapeFont class
Representa los atributos de fuente, como el nombre de la fuente, el tamaño de fuente y el color, para el objeto TextRange de una forma.
- Extends
Comentarios
Conjunto de API: PowerPointApi 1.4
Usada por
Ejemplos
// 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}`);
});
Propiedades
| all |
Especifica si el texto de está
|
| bold | Especifica si el texto en está
|
| color | Especifica la representación del código de color HTML del color del texto (por ejemplo, "#FF0000" representa el rojo). Devuelve |
| context | El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office. |
| double |
Especifica si el texto está
|
| italic | Especifica si el texto de está
|
| name | Especifica el nombre de la fuente (por ejemplo, "Calibri"). Si el texto es un alfabeto complejo o un idioma de Asia Oriental, este es el nombre de fuente correspondiente; de lo contrario, es el nombre de la fuente latina. Devuelve |
| size | Especifica el tamaño de fuente en puntos (por ejemplo, 11). Devuelve |
| small |
Especifica si el texto está
|
| strikethrough | Especifica si el texto está configurado para
|
| subscript | Especifica si el texto de está
|
| superscript | Especifica si el texto de la
|
| underline | Especifica el tipo de subrayado aplicado a la fuente. Devuelve |
Métodos
| load(options) | Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| load(property |
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| load(property |
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| toJSON() | Reemplaza el método JavaScript |
Detalles de las propiedades
allCaps
Especifica si el texto de está TextRange configurado para utilizar el atributo Todo mayúsculas , que hace que las letras minúsculas aparezcan como mayúsculas. Los valores posibles son los siguientes:
true: todo el texto tiene el atributo en mayúsculas .false: ninguna parte del texto tiene el atributo Todo mayúsculas .null: devuelto si parte del texto, pero no todo, tiene el atributo Todo mayúsculas .
allCaps: boolean | null;
Valor de propiedad
boolean | null
Comentarios
bold
Especifica si el texto en está TextRange establecido en negrita. Los valores posibles son los siguientes:
true: Todo el texto está en negrita.false: Ninguna parte del texto está en negrita.null: devuelto si parte del texto (pero no todo) está en negrita.
bold: boolean | null;
Valor de propiedad
boolean | null
Comentarios
color
Especifica la representación del código de color HTML del color del texto (por ejemplo, "#FF0000" representa el rojo). Devuelve null si contiene TextRange fragmentos de texto con colores diferentes.
color: string | null;
Valor de propiedad
string | null
Comentarios
Conjunto de API: PowerPointApi 1.4
Ejemplos
// 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
El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office.
context: RequestContext;
Valor de propiedad
doubleStrikethrough
Especifica si el texto está TextRange configurado para utilizar el atributo de tachado doble . Los valores posibles son los siguientes:
true: todo el texto tiene el atributo Double tachado .false: ninguna parte del texto tiene el atributo de tachado doble .null: devuelto si parte del texto, pero no todo, tiene el atributo de tachado doble .
doubleStrikethrough: boolean | null;
Valor de propiedad
boolean | null
Comentarios
italic
Especifica si el texto de está TextRange establecido en cursiva. Los valores posibles son los siguientes:
true: todo el texto está en cursiva.false: Ninguna parte del texto está en cursiva.null: devuelto si parte del texto (pero no todo) está en cursiva.
italic: boolean | null;
Valor de propiedad
boolean | null
Comentarios
name
Especifica el nombre de la fuente (por ejemplo, "Calibri"). Si el texto es un alfabeto complejo o un idioma de Asia Oriental, este es el nombre de fuente correspondiente; de lo contrario, es el nombre de la fuente latina. Devuelve null si contiene TextRange fragmentos de texto con nombres de fuente diferentes.
name: string | null;
Valor de propiedad
string | null
Comentarios
size
Especifica el tamaño de fuente en puntos (por ejemplo, 11). Devuelve null si contiene TextRange fragmentos de texto con diferentes tamaños de fuente.
size: number | null;
Valor de propiedad
number | null
Comentarios
smallCaps
Especifica si el texto está TextRange configurado para utilizar el atributo versalitas , que hace que las letras minúsculas aparezcan como letras mayúsculas pequeñas. Los valores posibles son los siguientes:
true: todo el texto tiene el atributo versalitas .false: Ninguna parte del texto tiene el atributo de versalitas .null: devuelto si parte del texto, pero no todo, tiene el atributo versalitas .
smallCaps: boolean | null;
Valor de propiedad
boolean | null
Comentarios
strikethrough
Especifica si el texto está configurado para TextRange utilizar el atributo Tachado . Los valores posibles son los siguientes:
true: todo el texto tiene el atributo Tachado .false: ninguna parte del texto tiene el atributo Tachado .null: devuelto si parte del texto, pero no todo, tiene el atributo Tachado .
strikethrough: boolean | null;
Valor de propiedad
boolean | null
Comentarios
subscript
Especifica si el texto de está TextRange configurado para utilizar el atributo Subíndice . Los valores posibles son los siguientes:
true: todo el texto tiene el atributo Subíndice .false: ninguna parte del texto tiene el atributo Subíndice .null: devuelto si parte del texto, pero no todo, tiene el atributo Subíndice .
subscript: boolean | null;
Valor de propiedad
boolean | null
Comentarios
superscript
Especifica si el texto de la TextRange organización está configurado para utilizar el atributo Superíndice . Los valores posibles son los siguientes:
true: todo el texto tiene el atributo Superíndice .false: ninguna parte del texto tiene el atributo Superíndice .null: devuelto si parte del texto, pero no todo, tiene el atributo Superíndice .
superscript: boolean | null;
Valor de propiedad
boolean | null
Comentarios
underline
Especifica el tipo de subrayado aplicado a la fuente. Devuelve null si contiene TextRange fragmentos de texto con diferentes estilos de subrayado. Consulta PowerPoint.ShapeFontUnderlineStyle para obtener más información.
underline: PowerPoint.ShapeFontUnderlineStyle | "None" | "Single" | "Double" | "Heavy" | "Dotted" | "DottedHeavy" | "Dash" | "DashHeavy" | "DashLong" | "DashLongHeavy" | "DotDash" | "DotDashHeavy" | "DotDotDash" | "DotDotDashHeavy" | "Wavy" | "WavyHeavy" | "WavyDouble" | null;
Valor de propiedad
PowerPoint.ShapeFontUnderlineStyle | "None" | "Single" | "Double" | "Heavy" | "Dotted" | "DottedHeavy" | "Dash" | "DashHeavy" | "DashLong" | "DashLongHeavy" | "DotDash" | "DotDashHeavy" | "DotDotDash" | "DotDotDashHeavy" | "Wavy" | "WavyHeavy" | "WavyDouble" | null
Comentarios
Conjunto de API: PowerPointApi 1.4
Ejemplos
// 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();
});
Detalles del método
load(options)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(options?: PowerPoint.Interfaces.ShapeFontLoadOptions): PowerPoint.ShapeFont;
Parámetros
Proporciona opciones para las propiedades del objeto que se van a cargar.
Devoluciones
load(propertyNames)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(propertyNames?: string | string[]): PowerPoint.ShapeFont;
Parámetros
- propertyNames
-
string | string[]
Una cadena delimitada por comas o una matriz de cadenas que especifican las propiedades que se van a cargar.
Devoluciones
load(propertyNamesAndPaths)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.ShapeFont;
Parámetros
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select es una cadena delimitada por comas que especifica las propiedades que se van a cargar y propertyNamesAndPaths.expand es una cadena delimitada por comas que especifica las propiedades de navegación que se van a cargar.
Devoluciones
toJSON()
Reemplaza el método JavaScript toJSON() para proporcionar una salida más útil cuando se pasa un objeto API a JSON.stringify(). (JSON.stringify, a su vez, llama al toJSON método del objeto que se le pasa). Mientras que el objeto original PowerPoint.ShapeFont es un objeto API, el toJSON método devuelve un objeto JavaScript simple (escrito como PowerPoint.Interfaces.ShapeFontData) que contiene copias superficiales de cualquier propiedad secundaria cargada del objeto original.
toJSON(): PowerPoint.Interfaces.ShapeFontData;