[ZBXNEXT-834] Automatically change font based on user's profile Created: 2011 Jul 07  Updated: 2012 Oct 14

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F)
Affects Version/s: 1.9.4 (alpha)
Fix Version/s: None

Type: Change Request Priority: Trivial
Reporter: Brian Huang Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I suggest a way to automatically change the font based on the user's profile.

Referred to my own idea: http://www.zabbix.com/forum/showthread.php?t=22148&page=2, this approach can automatically change font just by using soft links to the font files and the locale names as the names of the soft links:

First, I added a function setFontnames() into the file include/locales.inc.php as followed.

function setFontnames()

{ global $USER_DETAILS; $ZBX_FONT_NAME = $USER_DETAILS['lang']; $ZBX_GRAPH_FONT_NAME = $USER_DETAILS['lang']; }

In the directory fonts, I added some Unicode fonts and added soft links:
i.e.
$ ln -s DejaVuSans.ttf en_GB.ttf
$ ln -s bsmi00lp.ttf zh_CN.ttf
$ ln -s uming.ttc zh_TW.ttf
....

Finally, I called setFontnames() in the file include/graphs.inc.php at the beginning of each of the following functions:

function imageText($image, $fontsize, $angle, $x, $y, $color, $string)

{ setFontnames(); ... }

function imageTextSize($fontsize, $angle, $string){ setFontnames(); ... }

Instead of the final step, it would be better to change the font name whenever a user's language has been changed.



 Comments   
Comment by Brian Huang [ 2011 Jul 29 ]

Does that mean this feature will be implemented in version 2.0?

If so, I have some suggestions:

1. Font Management: A user can click on a button to browse a font file on the local drive. The user also select a language for that font. After uploading the font for the language. The system automatically create symbolic links for the font and the language.

2. Automatic font change and fallback: The system will then automatically use the font based on the language the user has selected. If not found, fall back to the default one. That is, there is a fallback font.

Comment by Brian Huang [ 2012 Jul 01 ]

I just rebuilt zabbix 2.0.1rc2 and made the font change as followed:
$ sed -i "/\$gdinfo = gd_info();/ a\ global \$USER_DETAILS;" graphs.inc.php
$ sed -i "s/ZBX_FONT_NAME.'.ttf'/\$USER_DETAILS['lang'].'.ttf'/g" graphs.inc.php
$ sed -i "s/ZBX_GRAPH_FONT_NAME.'.ttf'/\$USER_DETAILS['lang'].'.ttf'/g" graphs.inc.php

I just build 2.0.1, the issue still exists. No font auto change either.

Comment by Brian Huang [ 2012 Jul 01 ]

I also need to modify locales.inc.php
$ sed -i "/English (en_GB)/ a\ 'zh_TW' => _('Chinese (zh_TW)')," locales.inc.php
$ sed -i "/'en_gb' => 'english',/ a\ 'zh_tw' => 'chinese-traditional'," locales.inc.php

,in addition to
$ sed -i "/\$gdinfo = gd_info();/ a\ global \$USER_DETAILS;" graphs.inc.php
$ sed -i "s/ZBX_FONT_NAME.'.ttf'/\$USER_DETAILS['lang'].'.ttf'/g" graphs.inc.php
$ sed -i "s/ZBX_GRAPH_FONT_NAME.'.ttf'/\$USER_DETAILS['lang'].'.ttf'/g" graphs.inc.php

And, the fonts:
cd to fonts directory:
(1) Simplified Chinese: this font wqy-zenhei will show all words correctly. Many others I have tested just wouldn't do.
$ wget http://downloads.sourceforge.net/project/wqy/wqy-zenhei/0.9.45%20%28Fighting-state%20RC1%29/wqy-zenhei-0.9.45.tar.gz
$ tar xfzv wqy-zenhei-0.9.45.tar.gz
$ ln -s wqy-zenhei/wqy-zenhei.ttc zh_CN.ttf
(2) Traditional Chinese
still working on it. will update soon after I finish building 2.0.1.

Generated at Sat May 09 18:10:31 EEST 2026 using Jira 10.3.18#10030018-sha1:5642e4ad348b6c2a83ebdba689d04763a2393cab.