protected void updateFont(Font font, FontData fontData) {
// Set properties for Font
font.clearFormatting();
setProperty(fontData.getBold(), font::setBold);
setProperty(
fontData.getUnderline(),
underline -> font.setUnderline(Underline.fromName(underline.name())));
setProperty(fontData.getFontAscii(), font::setNameAscii);
setProperty(
fontData.getFontHighAnsi(),
fontHighAnsi -> {
font.setNameOther(fontHighAnsi);
font.setNameFarEast(fontHighAnsi);
font.setNameBi(fontHighAnsi);
});
setProperty(fontData.getAllCaps(), font::setAllCaps);
setProperty(fontData.getSmallCaps(), font::setSmallCaps);
setProperty(fontData.getFontColor(), color -> font.setColor(Color.decode(color)));
setProperty(fontData.getFontSize(), font::setSize);
setProperty(fontData.getItalic(), font::setItalic);
}
Yes, Aspose.Words does support small caps formatting. You can apply small caps to text by setting the SmallCaps
property of the Font
class to true
. This will display lowercase letters in uppercase form but with the same height as the lowercase letters, while uppercase letters will remain unchanged.
Here is a code example demonstrating how to set small caps formatting in Aspose.Words for Java:
import com.aspose.words.*;
public class SmallCapsExample {
public static void main(String[] args) throws Exception {
// Create a new document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set the font properties
Font font = builder.getFont();
font.setName("Arial");
font.setSize(12);
font.setSmallCaps(true); // Enable small caps formatting
// Write text with small caps
builder.writeln("This text is in small caps.");
// Save the document
doc.save("SmallCapsExample.docx");
}
}
In this example, the text “This text is in small caps.” will be formatted with small caps. You can adjust the font name and size as needed.
If you have any further questions or need additional examples, feel free to ask!
Give Example text How it look if we Apply smallcaps for this word Schedule?
@AAddd Here are documents generated by the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getFont().setSmallCaps(true); // Enable small caps formatting
// Write text with small caps
builder.writeln("Schedule");
// Save the document
doc.save("C:\\Temp\\out.docx");
doc.save("C:\\Temp\\out.pdf");
out.docx (7.2 KB)
out.pdf (15.5 KB)
Text looks like this: