Skip to content

Commit

Permalink
Merge pull request #596 from Mogztter/issue-574-plantuml-cjk-text-length
Browse files Browse the repository at this point in the history
resolves #574 install a chinese font
  • Loading branch information
ggrossetie authored Feb 8, 2021
2 parents 9792365 + f687032 commit bd124e0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/ops/docker/jdk11-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ RUN apk add --update --no-cache \
libjpeg \
giflib-dev \
graphviz \
ttf-freefont
ttf-freefont \
# Chinese font (available only in edge/testing)
&& apk add --update --no-cache \
--repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ \
wqy-zenhei

COPY ops/docker/logback.xml /etc/logback.xml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ void should_decode_valid_plantuml_encoded_source_with_default_encoder() throws D
assertThat(sourceDecoded).isEqualTo("@startuml\nBob -> Alice : hello\n@enduml");
}

@Test
void should_decode_cjk_encoded_source() throws DecodeException {
String sourceDecoded = DiagramSource.plantumlDecode("SoWkIImgoStCIybDBE1Iq59uicFNqwbBNxRtFftGmUMG2XI7o040");
assertThat(sourceDecoded).isEqualTo("@startmindmap\n" +
" * 为啥重合\n" +
"@endmindmap");
}

@Test
void should_not_trim() throws IOException, DecodeException {
String source = "\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down
3 changes: 3 additions & 0 deletions tests/smoke/diagrams/chinese.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@startmindmap
* 为啥重合
@endmindmap
13 changes: 13 additions & 0 deletions tests/smoke/smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ describe('Diagrams', () => {
})
})

describe('Chinese font', () => {
it(`plantuml should compute correct text length (issue#574)`, async () => {
const testCase = {engine: 'plantuml', file: 'chinese.puml'}
const response = await sendRequest(testCase, 'svg')
try {
expect(response.body.toString('utf8')).to.include('textLength="56"')
} catch (err) {
console.log('response:', response.text)
throw err
}
})
})

describe('Health', () => {
['/health', '/healthz', '/v1/health'].forEach((endpoint) => {
it(`should return health status from ${endpoint}`, async () => {
Expand Down

0 comments on commit bd124e0

Please sign in to comment.