plantuml-service
plantuml-service copied to clipboard
Problem of SVG image's textLength
When I use Chinese characters, the SVG image's textLength is smaller then expected.
actual

source code:
<text xmlns="http://www.w3.org/2000/svg" fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacingAndGlyphs" textLength="14" x="104" y="28.1543">中文</text>
expected

source code:
<text xmlns="http://www.w3.org/2000/svg" fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacingAndGlyphs" textLength="24" x="104" y="28.1543">中文</text>
Is this a PlantUML issue? or a plantuml-server issue?
It's right when I test with PlantUML.
Java Version: 1.8.0_152 PlantUML Version: git master
Perhaps this issue is related to the java version. I try to deploy the plantuml-service locally for testing.
Thanks for the information.
Can you give us the PlantUML code?
PlantUML test code:
FileFormatOption formatOption = new FileFormatOption(FileFormat.SVG, true);
SourceStringReader renderer = new SourceStringReader(Defines.createEmpty(), "@startuml\n"
+ "class Hello\n"
+ "class 中文\n"
+ "Hello --> 中文\n"
+ "@enduml", new ArrayList<String>());
ByteArrayOutputStream out = new ByteArrayOutputStream();
renderer.outputImage(out, formatOption);
System.out.println(out.toString("UTF-8"));
I deploy the plantuml-service locally for testing. And it's OK.
@startuml
class Hello
class 中文
Hello --> 中文
@enduml
reproduces this problem.
Upgrading JDK (#29) does not solve this issue. I guess it might be caused by fonts.
Maybe you are right.
Install takao-fonts that is used in our production (https://github.com/bitjourney/plantuml-service/commit/98859ac7209a72681151491799859e7203843db2), but the problem remains.
Hmm, maybe Chinese fonts are required?
Hmm, I agree with you.