Skip to main content

GetSmallCaps

Returns whether the text with the current text properties are displayed capitalized two points smaller than the actual font size.

Inherited from ApiTextPr.GetSmallCaps.

Example

Determine whether a run of text is formatted with small capitals in a document.

// How do I check if a piece of text uses small caps formatting in a document?

// Verify whether lowercase letters are displayed as reduced capitals in a text run in a document.

let doc = Api.GetDocument();
let myNewRunStyle = doc.CreateStyle("My New Run Style", "run");
let textPr = myNewRunStyle.GetTextPr();
textPr.SetCaps(true);
textPr.SetFontFamily("Calibri Light");
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
run.AddText("The text properties are changed and the style is added to the paragraph. ");
paragraph.AddElement(run);
run = Api.CreateRun();
run.SetStyle(myNewRunStyle);
run.AddText("This is a text run with its own style.");
textPr = run.GetTextPr();
textPr.SetSmallCaps(true);
paragraph.AddElement(run);
paragraph = Api.CreateParagraph();
let smallCaps = textPr.GetSmallCaps();
paragraph.AddText("Property of the small capitalized letters: " + smallCaps);
doc.Push(paragraph);