yuzutech / kroki

Creates diagrams from textual descriptions!
https://kroki.io
MIT License
2.87k stars 211 forks source link

Text is sometimes cut off when rendered in Mermaid #1298

Closed hiroaki0923 closed 2 years ago

hiroaki0923 commented 2 years ago

Issue:

Text is sometimes cut off when rendered in Mermaid.

The issue can be observed on the official website. The letter e in Anyone is cut off.

The letter e in anyone is cut off.

Environment:

Workaround:

Install font-noto by apk add font-noto into the kroki-mermaid image, and it now displays like this.

font-noto installed

The text is no longer cut off, but the paddings seem to be a little bit strange.

When I put font-noto-all instead of font-noto, it looked different. The trailing of kroki has been cut off.

font-noto-all installed

Closer to mermaid.live might be when to add font-liberation-nerd instead of font-noto. Since the browser tries to render the font in trebuchet ms defined in mermaid.min.js, it makes sense that liberation would be closer. The baseline seems to be a little off though.

font-liberation-nerd installed

I don't think it necessarily needs to be close in appearance to the mermaid.live, but I would like the text to appear uncut. I would appreciate some kind of fix. Thank you!

ggrossetie commented 2 years ago

According to https://github.com/mermaid-js/mermaid-live-editor/blob/master/Dockerfile, https://mermaid.live/ is based on nginx:alpine. It would be interesting to list which fonts is installed.

ggrossetie commented 2 years ago
# apk info
alpine-baselayout-data
musl
busybox
alpine-baselayout
alpine-keys
ca-certificates-bundle
libcrypto1.1
libssl1.1
ssl_client
zlib
apk-tools
scanelf
musl-utils
libc-utils
pcre2
nginx
geoip
nginx-module-geoip
brotli-libs
libbz2
libpng
freetype
libjpeg-turbo
libwebp
libgd
nginx-module-image-filter
ncurses-terminfo-base
ncurses-libs
libedit
nginx-module-njs
libgpg-error
libgcrypt
xz-libs
libxml2
libxslt
nginx-module-xslt
libintl
tzdata
ca-certificates
nghttp2-libs
libcurl
curl
ggrossetie commented 2 years ago
# apk info
musl
busybox
alpine-baselayout
alpine-keys
libcrypto1.1
libssl1.1
ca-certificates-cacert
libtls-standalone
ssl_client
zlib
apk-tools
scanelf
musl-utils
libc-utils
eudev-libs
expat
libbz2
libpng
freetype
libuuid
fontconfig
libfontenc
mkfontscale
mkfontdir
ttf-opensans
libgcc
libogg
libstdc++
flac
libxau
libbsd
libxdmcp
libxcb
libx11
libxcomposite
libxfixes
libxrender
libxcursor
libxdamage
libxext
libxi
libxrandr
libxscrnsaver
libxtst
alsa-lib
libffi
libintl
libblkid
libmount
pcre
glib
atk
dbus-libs
at-spi2-core
at-spi2-atk
sdl2
fribidi
libass
gmp
nettle
p11-kit
libtasn1
libunistring
gnutls
ncurses-terminfo-base
ncurses-terminfo
ncurses-libs
lame
opus
libtheora
libjpeg-turbo
v4l-utils-libs
libpciaccess
libdrm
libva
libvdpau
libvorbis
libvpx
x264-libs
x265-libs
xvidcore
ffmpeg-libs
pixman
cairo
avahi-libs
cups-libs
libevent
libxml2
shared-mime-info
hicolor-icon-theme
tiff
gdk-pixbuf
gtk-update-icon-cache
libxinerama
cairo-gobject
libepoxy
graphite2
harfbuzz
libxft
pango
wayland-libs-client
wayland-libs-cursor
wayland-libs-egl
libxkbcommon
gtk+3.0
nspr
sqlite-libs
nss
re2
snappy
libwebp
libgpg-error
libgcrypt
libxslt
chromium
ggrossetie commented 2 years ago

My guess is that it's working because Mermaid is using fonts installed client-side (i.e., on your machine).

"Fira Sans" and "Source Sans Pro" might be good alternative to "trebuchet ms".

ggrossetie commented 2 years ago

Here's the result when "Fira Sans" is installed:

Without "Fira Sans"
current
With "Fira Sans"
modified
Capture d’écran 2022-07-16 à 22 36 26 Capture d’écran 2022-07-16 à 22 22 23
hiroaki0923 commented 2 years ago

@Mogztter Thank you for your investigation and for your suggestion for a better solution! It looks perfect, including the padding 👍