Permalink
Browse files

Fixed issue #06849: Bad caracter for statistics graph in some language

Dev: review default font, DejaVus Sans seems best, FreeSans can be a good alternative
Dev: Add a array of alternate fonts files for specific language. Don't include fonts files for specific language
  • Loading branch information...
1 parent 142a4a6 commit 54c41e70431b96b08449ccf741d132812fd73df6 @Shnoulle Shnoulle committed Nov 12, 2012
@@ -353,6 +353,20 @@
* Set this to specific font-file (for example 'vera.ttf') or set it to 'auto' and LimeSurvey tried to pick the best font depending on your survey base language
*/
$config['chartfontfile']='auto';
+/**
+* $alternatechartfontfile - array of the font file name used to created the charts in statistics in specific langage - this font must reside in <limesurvey root folder>/fonts
+* Only used if $chartfontfile is set to auto. If font file doesn't exist in <limesurvey root folder>/fonts, an alert is sent to admin
+*/
+$config['alternatechartfontfile']=array(
+ 'hi'=>'FreeSans.ttf',
+ 'ja'=> 'migmix-1p-regular.ttf',
+ 'ko'=>'UnBatang.ttf',
+ 'si'=>'FreeSans.ttf',
+ 'th'=>'TlwgTypist.ttf',
+ 'zh-Hant-HK'=>'fireflysung.ttf',
+ 'zh-Hant-HK'=>'fireflysung.ttf',
+ 'zh-Hant-HK'=>'fireflysung.ttf',
+);
/**
* $chartfontsize - set the size of the font to created the charts in statistics
@@ -39,28 +39,28 @@ function createChart($iQuestionID, $iSurveyID, $type=null, $lbl, $gdata, $grawda
$scriptname = Yii::app()->getConfig("scriptname");
$chartfontfile = Yii::app()->getConfig("chartfontfile");
$chartfontsize = Yii::app()->getConfig("chartfontsize");
+ $alternatechartfontfile = Yii::app()->getConfig("alternatechartfontfile");
$language = $oLanguage->langcode;
+ $clang = $oLanguage;
$cachefilename = "";
/* Set the fonts for the chart */
if ($chartfontfile=='auto')
{
- $chartfontfile='vera.ttf';
- if ( $language=='ar')
+ // Tested with ar,be,el,fa,hu,he,is,lt,mt,sr, and en (english)
+ // Not working for hi, si, zh, th, ko, ja : see $config['alternatechartfontfile'] to add some specific language font
+ $chartfontfile='DejaVuSans.ttf';
+ if(array_key_exists($language,$alternatechartfontfile))
{
- $chartfontfile='KacstOffice.ttf';
- }
- elseif ($language=='fa' )
- {
- $chartfontfile='KacstFarsi.ttf';
- }
- elseif ($language=='el' )
- {
- $chartfontfile='DejaVuLGCSans.ttf';
- }
- elseif ($language=='zh-Hant-HK' || $language=='zh-Hant-TW' || $language=='zh-Hans')
- {
- $chartfontfile='fireflysung.ttf';
+ $neededfontfile = $alternatechartfontfile[$language];
+ if(is_file($rootdir."/fonts/".$neededfontfile))
+ {
+ $chartfontfile=$neededfontfile;
+ }
+ else
+ {
+ Yii::app()->session['flashmessage'] = sprintf($clang->gT('The fonts file %s was not found in <limesurvey root folder>/fonts directory. Please, see the txt file for your language in fonts directory.'),$neededfontfile);
+ }
}
}
View
@@ -0,0 +1,116 @@
+DejaVu fonts 2.33 (c)2004-2011 DejaVu fonts team
+------------------------------------------------
+
+The DejaVu fonts are a font family based on the Bitstream Vera Fonts
+(http://gnome.org/fonts/). Its purpose is to provide a wider range of
+characters (see status.txt for more information) while maintaining the
+original look and feel.
+
+DejaVu fonts are based on Bitstream Vera fonts version 1.10.
+
+Fonts are published in source form as SFD files (Spline Font Database from
+FontForge - http://fontforge.sf.net/) and in compiled form as TTF files
+(TrueType fonts).
+
+For more information go to http://dejavu.sourceforge.net/.
+
+------------------------------------------------
+Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
+Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
+
+Bitstream Vera Fonts Copyright
+------------------------------
+
+Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
+a trademark of Bitstream, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of the fonts accompanying this license ("Fonts") and associated
+documentation files (the "Font Software"), to reproduce and distribute the
+Font Software, including without limitation the rights to use, copy, merge,
+publish, distribute, and/or sell copies of the Font Software, and to permit
+persons to whom the Font Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright and trademark notices and this permission notice shall
+be included in all copies of one or more of the Font Software typefaces.
+
+The Font Software may be modified, altered, or added to, and in particular
+the designs of glyphs or characters in the Fonts may be modified and
+additional glyphs or characters may be added to the Fonts, only if the fonts
+are renamed to names not containing either the words "Bitstream" or the word
+"Vera".
+
+This License becomes null and void to the extent applicable to Fonts or Font
+Software that has been modified and is distributed under the "Bitstream
+Vera" names.
+
+The Font Software may be sold as part of a larger software package but no
+copy of one or more of the Font Software typefaces may be sold by itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
+FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
+ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
+FONT SOFTWARE.
+
+Except as contained in this notice, the names of Gnome, the Gnome
+Foundation, and Bitstream Inc., shall not be used in advertising or
+otherwise to promote the sale, use or other dealings in this Font Software
+without prior written authorization from the Gnome Foundation or Bitstream
+Inc., respectively. For further information, contact: fonts at gnome dot
+org.
+
+Arev Fonts Copyright
+------------------------------
+
+Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the fonts accompanying this license ("Fonts") and
+associated documentation files (the "Font Software"), to reproduce
+and distribute the modifications to the Bitstream Vera Font Software,
+including without limitation the rights to use, copy, merge, publish,
+distribute, and/or sell copies of the Font Software, and to permit
+persons to whom the Font Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright and trademark notices and this permission notice
+shall be included in all copies of one or more of the Font Software
+typefaces.
+
+The Font Software may be modified, altered, or added to, and in
+particular the designs of glyphs or characters in the Fonts may be
+modified and additional glyphs or characters may be added to the
+Fonts, only if the fonts are renamed to names not containing either
+the words "Tavmjong Bah" or the word "Arev".
+
+This License becomes null and void to the extent applicable to Fonts
+or Font Software that has been modified and is distributed under the
+"Tavmjong Bah Arev" names.
+
+The Font Software may be sold as part of a larger software package but
+no copy of one or more of the Font Software typefaces may be sold by
+itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
+TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
+
+Except as contained in this notice, the name of Tavmjong Bah shall not
+be used in advertising or otherwise to promote the sale, use or other
+dealings in this Font Software without prior written authorization
+from Tavmjong Bah. For further information, contact: tavmjong @ free
+. fr.
+
+$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit 54c41e7

Please sign in to comment.