plantuml-service icon indicating copy to clipboard operation
plantuml-service copied to clipboard

Problem of SVG image's textLength

Open akuma opened this issue 7 years ago • 10 comments

When I use Chinese characters, the SVG image's textLength is smaller then expected.

actual

2018-01-17 8 01 23

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

2018-01-17 8 03 02

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>

akuma avatar Jan 17 '18 12:01 akuma

Is this a PlantUML issue? or a plantuml-server issue?

gfx avatar Jan 17 '18 23:01 gfx

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.

akuma avatar Jan 18 '18 02:01 akuma

Thanks for the information.

Can you give us the PlantUML code?

gfx avatar Jan 18 '18 02:01 gfx

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"));

akuma avatar Jan 18 '18 04:01 akuma

I deploy the plantuml-service locally for testing. And it's OK.

akuma avatar Jan 18 '18 05:01 akuma

@startuml
    class Hello
    class 中文
    Hello --> 中文
@enduml

reproduces this problem.

gfx avatar Jan 18 '18 06:01 gfx

Upgrading JDK (#29) does not solve this issue. I guess it might be caused by fonts.

gfx avatar Jan 18 '18 06:01 gfx

Maybe you are right.

akuma avatar Jan 18 '18 06:01 akuma

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?

gfx avatar Jan 18 '18 06:01 gfx

Hmm, I agree with you.

akuma avatar Jan 18 '18 12:01 akuma