We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Font.setComplexScript()

Hi,


In the API reference of the Aspose.Slides, there’s a property Font.ComplexScript which specifies whether the contents of the run shall be treated as complex script text regardless of their Unicode character values when determining the formatting for the run.

How can I achieve this behavior directly in MS Word?

I have a document with some Arabic text, but when I invoke run.getFont().getComplexScript() for each run, I always get false.

Here’s the code I used:

String documentPath = “ArabicToEnglishTest.docx”;

Document document = new Document(documentPath);

List runs = new ArrayList();

try {
document.accept(new DocumentVisitor() {
@Override
public int visitRun(Run run) throws Exception {
runs.add(run);

return super.visitRun(run);
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}

for (Run run : runs) {
System.out.println(run.getText() + ": " + run.getFont().getComplexScript());
}

Can you help me achieve this?

Thanks,
Zeljko

Hi Zeljko,


Thanks for your inquiry. We have tested the scenario and noticed that setComplexScript() return false for Arabic text. We have logged a ticket WORDSJAVA-1562 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved. We are sorry for the inconvenience.

Best Regards,

@Zeljko

Thanks for your patience. We have investigated the issue and found it is not a bug but expected behavior.

This option has the following description:

“Specifies whether the contents of this run shall be treated as complex script text regardless of their Unicode character values when determining the formatting for this run.”

OOXML part “2.3.2.6 cs (Use Complex Script Formatting on Run)” has the following comment for this element:

“This means that a consumer shall use the complex script formatting applied to the run [Example: The bCs value 12 (§2.3.2.2), not the b value (§2.3.2.1). end example] when determining the resulting formatting properties”

This option determines how MSW has to process properties of the run. A run in Microsoft Word can have up to four fonts assigned to it. Different characters in a single run can use different fonts depending on their Unicode character code. The attached picture in documentation shows settings for complex script fonts which shall be used to display the text content of this run for all characters in the Complex Script range.

Furthermore, in reference to your above questions:

How can I achieve this behavior directly in MS Word?

Looks like MSW has not such feature in the GUI. When this option is on, then you can see that Complex Script formatting is applied for all text in the run.

Can you help me achieve this?

You can get “True” for specified property, when it will be set directly in the document (i.e. formatting will be changed). In case when “ComplexScript=false”, then you can find at least one character from the Complex Script range in the run to check that complex script formatting applied for this run.

Best Regards,