Incorrect character spacing (1548)

Hi,

There’s a shape with some text in the attached file. When I remove the text and it’s formatting and add it back, it gets messed up in the saved file. Precisely, character spacing gets set to 0.

Code:

Diagram diagram = new Diagram("Drawing1.vsdx");

ShapeCollection shapes = diagram.getPages().get(0).getShapes();

Shape shape = shapes.get(0);

FormatTxtCollection formatTxtCollection = shape.getText().getValue();

formatTxtCollection.clear();

CharCollection chars = shape.getChars();

Char firstChar = chars.get(0);

chars.clear();

chars.add(firstChar);
formatTxtCollection.add(new Cp(0));
formatTxtCollection.add(new Txt("Screening Part 1"));
formatTxtCollection.add(new Txt(""));
formatTxtCollection.add(new Txt("\n"));

Char ch = new Char();
ch.getStyle().setValue(17);
chars.add(ch);
formatTxtCollection.add(new Cp(1));
formatTxtCollection.add(new Txt("Days -35 thru -15"));
formatTxtCollection.add(new Txt(""));
formatTxtCollection.add(new Txt("\n"));

diagram.save("Drawing1-aspose.vsdx", SaveFileFormat.VSDX);

Drawing1.vsdx.zip (23.6 KB)
1548.PNG (59.0 KB)

Can you check this?

Thanks,
Zeljko

@Zeljko,

You need to set the font scale of Char element to 100 percent. This is the modified part of your code.
Java

Char ch = new Char();
ch.getStyle().setValue(17);
ch.getFontScale().setValue(1); 
chars.add(ch);

Hi Imran,

Thanks for your help.

The way my application works is if there’s no formatting difference between the first and the second text, it applies the same formatting values from the first char to the second char. But if you read font scale values of the first char, you’ll get: -1.7976931348623157E308 which forces text to shrink.
According to your previous post, the value should be 1, as the first text has character spacing of 100% when you check it in MS Visio.

Try this code:

Char firstChar = chars.get(0);

System.out.println(firstChar.getFontScale().getValue());

Regards,
Zeljko

@Zeljko,

We managed to replicate the problem of incorrect retrieval of the font scale value. It has been logged under the ticket ID DIAGRAMJAVA-50594 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

@Zeljko,

In reference to the ticket ID DIAGRAMJAVA-50594, the font scale value is available in the Master of this shape. Please try this line of code:
C#

CharCollection chars = shape.getInheritChars();