zabbix / zabbix-docker

Official Zabbix Dockerfiles
https://www.zabbix.com
GNU Affero General Public License v3.0
2.39k stars 1.38k forks source link

Error with NotoSansCJKjp-Regular.ttf fonts in alpine images #1077

Closed pabloyoyoista closed 1 year ago

pabloyoyoista commented 1 year ago
SUMMARY

I am using zabbix-web-apache-mysql:alpine-5.0-latest image. Since tag 5.0.33 (presumable commit a966d3fca479319ca32c9761c93e1572fc7f4b02), the legends of classic graphs do not have any text, but just empty color squares. The logs show repeated entries of PHP Warning: imagettftext(): Could not find/open font in /usr/share/zabbix/include/graphs.inc.php on line 548. Downloading the DejaVuSans font from the repo, and replacing its name back in include/defines.inc.php, then the graphs correctly display again.

OS / ENVIRONMENT / Used docker-compose files

I'm running the zabbix-web-apache-mysql:alpine-5.0-latest directly through podman.

CONFIGURATION
STEPS TO REPRODUCE

Fire up an zabbix-web-apache-mysql:alpine-5.0-latest container, access it, and try to create some classic graph. See how the legend does not display.

EXPECTED RESULTS

The legend displays correctly in the classic graphs.

ACTUAL RESULTS

Missing fonts in some graphs (can provide screenshot if necessary).

Maybe the new downloaded NotoSansCJKjp font has some incompatibilities with alpine? The said font is available through font-noto-sans package, so maybe one option is to directly use that one?

dotneft commented 1 year ago

I can not reproduce the problem. For me everything is fine

Screenshot 2023-05-10 at 21 42 03
pabloyoyoista commented 1 year ago

Uh, is that with the alpine-based container? This is what I'm seeing:

image

And the only things I have in the Dockerfile that I use to build it are:

FROM docker://zabbix/zabbix-web-apache-mysql:alpine-5.0-latest

USER root     
ENV PHP_TZ='Europe/Madrid'    

RUN apk add --no-cache tzdata && \                                                             
    ln -fs /usr/share/zoneinfo/${PHP_TZ} /etc/localtime && \         
    echo ${PHP_TZ} > /etc/timezone && \     
    date                 

Hopefully is nothing else in my setup that's causing the issue, would be a pain to troubleshoot.

dotneft commented 1 year ago

try to pull and rebuild.

jbgomond commented 1 year ago

I have the error too in the ubuntu version (6.4.2). No texts on Zabbix charts ...

PHP Warning: imagettftext(): Could not find/open font in /usr/share/zabbix/include/graphs.inc.php on line 555

dotneft commented 1 year ago

what image do you use?

jbgomond commented 1 year ago

This one : zabbix/zabbix-web-nginx-mysql:6.4.2-ubuntu

image

pabloyoyoista commented 1 year ago

I can confirm that #1078 fixed the issue, thanks!

zohairraza commented 8 months ago

hi, this is happening in zabbix-web-apache-mysql:ubuntu-6.0-latest too

zohairraza commented 8 months ago

I figured it out, the include/defines.php file has DejaVuSans hardcoded define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name

I changed this to NotoSansCJKjp-Regular and it worked, but I switched back to using DejaVuSans because it loads faster than NotoSansCJKjp-Regular

For that, I had to do a symlink from correct DejaVuSans location and then it works okay ln -s /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf /usr/share/zabbix/assets/fonts/DejaVuSans.ttf

So web-apache-mysql-6.0 needs a fix in the UI since build-mysql image in that branch is using NotoSansCJKjp-Regular font https://github.com/zabbix/zabbix-docker/blob/6.0/Dockerfiles/build-mysql/ubuntu/Dockerfile#L76

or maybe keep using DejaVuSans in 6.0 branch as it is faster but copy it in the sources instead of symlinking it from Linux distros. They keep changing the location.