config_cp.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. function GetCodepage($llcc) {
  3. if (strlen($llcc) == 5) {
  4. $lang = substr(strtolower($llcc),0,2);
  5. $country = substr(strtoupper($llcc),3,2);
  6. }
  7. else { $lang = strtolower($llcc); $country = ''; }
  8. $unifonts = "";
  9. $dir = "ltr";
  10. $spacing = "";
  11. switch($lang){
  12. CASE "en":
  13. CASE "ca":
  14. CASE "cy":
  15. CASE "da":
  16. CASE "de":
  17. CASE "es":
  18. CASE "eu":
  19. CASE "fr":
  20. CASE "ga":
  21. CASE "fi":
  22. CASE "is":
  23. CASE "it":
  24. CASE "nl":
  25. CASE "no":
  26. CASE "pt":
  27. CASE "sv":
  28. $cp = "win-1252"; break;
  29. // ISO-8859-2
  30. CASE "cs":
  31. CASE "hr":
  32. CASE "hu":
  33. CASE "pl":
  34. CASE "ro":
  35. CASE "sk":
  36. CASE "sl":
  37. $cp = "iso-8859-2"; break;
  38. // ISO-8859-4
  39. CASE "et":
  40. CASE "kl":
  41. CASE "lt":
  42. CASE "lv":
  43. $cp = "iso-8859-4"; break;
  44. // WIN-1251
  45. CASE "bg":
  46. CASE "mk":
  47. CASE "ru":
  48. CASE "sr":
  49. CASE "uk":
  50. $cp = "win-1251"; break;
  51. // ISO-8859-9 (Turkish)
  52. CASE "tr":
  53. $cp = "iso-8859-9"; break;
  54. // ISO-8859-7 (Greek)
  55. CASE "el":
  56. $cp = "iso-8859-7"; break;
  57. // UTF-8
  58. CASE "id":
  59. CASE "ms":
  60. CASE "sh":
  61. CASE "sq":
  62. CASE "af":
  63. CASE "be":
  64. CASE "fo":
  65. CASE "gl":
  66. CASE "gv":
  67. $cp = "UTF-8"; break;
  68. // RTL Languages
  69. CASE "he": $cp = "UTF-8"; $dir = "rtl"; $spacing = "W"; $unifonts = "dejavusans,dejavusansB,dejavusansI,dejavusansBI,dejavusanscondensed,dejavusanscondensedB,dejavusanscondensedI,dejavusanscondensedBI,freesans,freesansB,freesansI,freesansBI,freeserif,freeserifB,freeserifI,freeserifBI,freemono,freemonoB,freemonoI,freemonoBI"; break;
  70. // Arabic
  71. CASE "ar": $cp = "UTF-8"; $dir = "rtl"; $spacing = "W"; $unifonts = "dejavusans,dejavusansB,dejavusansI,dejavusansBI,dejavusanscondensed,dejavusanscondensedB,dejavusanscondensedI,dejavusanscondensedBI,ar_1_001,ar_1_002,ar_1_003,ar_1_004,ar_1_005,ar_1_006,ar_1_007,ar_2_001,ar_2_002,ar_2_003,ar_2_004,ar_k_001,ar_k_002"; break;
  72. CASE "fa": $cp = "UTF-8"; $unifonts = "dejavusans,dejavusansB,dejavusansI,dejavusansBI,dejavusanscondensed,dejavusanscondensedB,dejavusanscondensedI,dejavusanscondensedBI,fa_1_001,fa_1_002"; $dir = "rtl"; $spacing = "W"; break;
  73. CASE "ps": $cp = "UTF-8"; $dir = "rtl"; $spacing = "W"; $unifonts = "ps_1_001"; break;
  74. CASE "ur": $cp = "UTF-8"; $dir = "rtl"; $spacing = "W"; $unifonts = "ur_1_001"; break;
  75. // Sindhi (Arabic or Devanagari)
  76. CASE "sd":
  77. if ($country == "IN") { $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_hi_1_001"; }
  78. else if ($country == "PK") { $cp = "UTF-8"; $dir = "rtl"; $spacing = "W"; $unifonts = "sd_1_001,sd_1_002"; }
  79. else { $cp = "UTF-8"; $dir = "rtl"; $spacing = "W"; $unifonts = "sd_1_001,sd_1_002"; }
  80. break;
  81. // INDIC
  82. // Assamese
  83. CASE "as": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_bn_1_001"; break;
  84. // Bengali
  85. CASE "bn": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_bn_1_001"; break;
  86. // Gujarati
  87. CASE "gu": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_gu_1_001"; break;
  88. // Hindi (Devanagari)
  89. CASE "hi": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_hi_1_001"; break;
  90. // Kannada
  91. CASE "kn": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_kn_1_001"; break;
  92. // Kashmiri
  93. CASE "ks": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_hi_1_001"; break;
  94. // Malayalam
  95. CASE "ml": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_ml_1_001"; break;
  96. // Nepali (Devanagari)
  97. CASE "ne": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_hi_1_001"; break;
  98. // Oriya
  99. CASE "or": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_or_1_001"; break;
  100. // Punjabi (Gurmukhi)
  101. CASE "pa": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_pa_1_001"; break;
  102. // Tamil
  103. CASE "ta": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_ta_1_001"; break;
  104. // Telegu
  105. CASE "te": $cp = "UTF-8"; $spacing = "W"; $unifonts = "ind_te_1_001"; break;
  106. // Sinhalese
  107. CASE "si": $cp = "UTF-8"; $spacing = "W"; $unifonts = "freesans"; break;
  108. // THAI
  109. CASE "th": $cp = "UTF-8"; $spacing = "C"; $unifonts = "garuda,garudaB,garudaI,garudaBI,norasi,norasiB,norasiI,norasiBI,freeserif"; break;
  110. // VIETNAMESE
  111. CASE "vi": $cp = "UTF-8"; $unifonts = "dejavusans,dejavusansB,dejavusansI,dejavusansBI,dejavusanscondensed,dejavusanscondensedB,dejavusanscondensedI,dejavusanscondensedBI,freeserif"; break;
  112. // CJK Langauges
  113. CASE "ja": $cp = "SHIFT_JIS"; $spacing = "C"; break;
  114. CASE "ko": $cp = "UHC"; $spacing = "C"; break;
  115. CASE "zh":
  116. if ($country == "HK" || $country == "TW") { $cp = "BIG5"; $spacing = "C"; }
  117. else if ($country == "CN") { $cp = "GBK"; $spacing = "C"; }
  118. else { $cp = "GBK"; $spacing = "C"; }
  119. break;
  120. /*
  121. // CJK Langauges - ALTERNATIVE
  122. CASE "ja":
  123. CASE "zh":
  124. $cp = "UTF-8"; $spacing = "C"; $unifonts = "zn_hannom_a"; break;
  125. CASE "ko": $cp = "UTF-8"; $spacing = "C"; $unifonts = "unbatang_0613"; break;
  126. */
  127. // Default UTF-8
  128. default: $cp = "UTF-8"; break; // mPDF 4.2 Don't need to set unifonts - will make all available if left blank
  129. // Default spacing set to '' (i.e. mixed character/word)
  130. }
  131. $unifonts_arr = array();
  132. if ($unifonts) {
  133. $unifonts_arr = preg_split('/\s*,\s*/',$unifonts);
  134. }
  135. return array($cp,$unifonts_arr,$dir,$spacing);
  136. }
  137. ?>