GetLangOpts

MPDF recognises IETF language tags as: - a single primary language subtag composed of a two letter language code from ISO 639-1 (2002), or a three letter code from ISO 639-2 (1998), ISO 639-3 (2007) or ISO 639-5 (2008) (usually written in lower case); - an optional script subtag, composed of a four letter script code from ISO 15924 (usually written in title case); - an optional region subtag composed of a two letter country code from ISO 3166-1 alpha-2 (usually written in upper case), or a three digit code from UN M.49 for geographical regions; Subtags are not case sensitive, but the specification recommends using the same case as in the Language Subtag Registry, where region subtags are uppercase, script subtags are titlecase and all other subtags are lowercase.

Description

GetLangOpts( $llcc, $adobeCJK, &$fontdata ); 

Region subtags are often deprecated by the registration of specific primary language subtags from ISO 639-3 which are now preferred values.. For example, ar-DZ is deprecated with the preferred value arq for Algerian Spoken Arabic;

Example: Serbian written in the Cyrillic (sr-Cyrl) or Latin (sr-Latn) script

und (for undetermined or undefined) is used in situations in which a script must be indicated but the language cannot be identified. e.g. und-Cyrl is an undefined language written in Cyrillic script.

Parameters (3)

0. $llcc
The llcc.
1. $adobecjk
The adobecjk.
2. $fontdata
The fontdata.

Usage

  1. if ( !function_exists( 'GetLangOpts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-pdf/vendor/blueliquiddesigns/mpdf/config_lang2fonts.php'; 
  3.  
  4. // The llcc. 
  5. $llcc = null; 
  6.  
  7. // The adobecjk. 
  8. $adobecjk = null; 
  9.  
  10. // The fontdata. 
  11. $fontdata = &$fontdata; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = GetLangOpts($llcc, $adobecjk, $fontdata); 
  15.  

Defined (1)

The function is defined in the following location(s).

/vendor/blueliquiddesigns/mpdf/config_lang2fonts.php  
  1. function GetLangOpts($llcc, $adobeCJK, &$fontdata) 
  2. $tags = preg_split('/-/', $llcc); 
  3. $lang = strtolower($tags[0]); 
  4. $country = ''; 
  5. $script = ''; 
  6. if (isset($tags[1]) && $tags[1]) { 
  7. if (strlen($tags[1]) == 4) { 
  8. $script = strtolower($tags[1]); 
  9. } else { 
  10. $country = strtolower($tags[1]); 
  11. if (isset($tags[2]) && $tags[2]) { 
  12. $country = strtolower($tags[2]); 
  13.  
  14. $unifont = ""; 
  15. $coreSuitable = false; 
  16.  
  17. switch ($lang) { 
  18.  
  19. /** European */ 
  20. CASE "en": CASE "eng": // English // LATIN 
  21. CASE "eu": CASE "eus": // Basque 
  22. CASE "br": CASE "bre": // Breton 
  23. CASE "ca": CASE "cat": // Catalan 
  24. CASE "co": CASE "cos": // Corsican 
  25. CASE "kw": CASE "cor": // Cornish 
  26. CASE "cy": CASE "cym": // Welsh 
  27. CASE "cs": CASE "ces": // Czech 
  28. CASE "da": CASE "dan": // Danish 
  29. CASE "nl": CASE "nld": // Dutch 
  30. CASE "et": CASE "est": // Estonian 
  31. CASE "fo": CASE "fao": // Faroese 
  32. CASE "fi": CASE "fin": // Finnish 
  33. CASE "fr": CASE "fra": // French 
  34. CASE "gl": CASE "glg": // Galician 
  35. CASE "de": CASE "deu": // German 
  36. CASE "ht": CASE "hat": // Haitian; Haitian Creole 
  37. CASE "hu": CASE "hun": // Hungarian 
  38. CASE "ga": CASE "gle": // Irish 
  39. CASE "is": CASE "isl": // Icelandic 
  40. CASE "it": CASE "ita": // Italian 
  41. CASE "la": CASE "lat": // Latin 
  42. CASE "lb": CASE "ltz": // Luxembourgish 
  43. CASE "li": CASE "lim": // Limburgish 
  44. CASE "lt": CASE "lit": // Lithuanian 
  45. CASE "lv": CASE "lav": // Latvian 
  46. CASE "gv": CASE "glv": // Manx 
  47. CASE "no": CASE "nor": // Norwegian 
  48. CASE "nn": CASE "nno": // Norwegian Nynorsk 
  49. CASE "nb": CASE "nob": // Norwegian Bokml 
  50. CASE "pl": CASE "pol": // Polish 
  51. CASE "pt": CASE "por": // Portuguese 
  52. CASE "ro": CASE "ron": // Romanian 
  53. CASE "gd": CASE "gla": // Scottish Gaelic 
  54. CASE "es": CASE "spa": // Spanish 
  55. CASE "sv": CASE "swe": // Swedish 
  56. CASE "sl": CASE "slv": // Slovene 
  57. CASE "sk": CASE "slk": // Slovak 
  58. $unifont = "dejavusanscondensed"; 
  59. // Edit this value to define how mPDF behaves when using new mPDF('-x') 
  60. // If set to TRUE, mPDF will use Adobe core fonts only when it recognises the languages above 
  61. $coreSuitable = true; 
  62. break; 
  63.  
  64. CASE "ru": CASE "rus": // Russian // CYRILLIC 
  65. CASE "ab": CASE "abk": // Abkhaz 
  66. CASE "av": CASE "ava": // Avaric 
  67. CASE "ba": CASE "bak": // Bashkir 
  68. CASE "be": CASE "bel": // Belarusian 
  69. CASE "bg": CASE "bul": // Bulgarian 
  70. CASE "ce": CASE "che": // Chechen 
  71. CASE "cv": CASE "chv": // Chuvash 
  72. CASE "kk": CASE "kaz": // Kazakh 
  73. CASE "kv": CASE "kom": // Komi 
  74. CASE "ky": CASE "kir": // Kyrgyz 
  75. CASE "mk": CASE "mkd": // Macedonian 
  76. CASE "cu": CASE "chu": // Old Church Slavonic 
  77. CASE "os": CASE "oss": // Ossetian 
  78. CASE "sr": CASE "srp": // Serbian 
  79. CASE "tg": CASE "tgk": // Tajik 
  80. CASE "tt": CASE "tat": // Tatar 
  81. CASE "tk": CASE "tuk": // Turkmen 
  82. CASE "uk": CASE "ukr": // Ukrainian 
  83. $unifont = "dejavusanscondensed"; /** freeserif best coverage for supplements etc. */ 
  84. break; 
  85.  
  86. CASE "hy": CASE "hye": // ARMENIAN 
  87. $unifont = "dejavusans"; 
  88. break; 
  89. CASE "ka": CASE "kat": // GEORGIAN 
  90. $unifont = "dejavusans"; 
  91. break; 
  92.  
  93. CASE "el": CASE "ell": // GREEK 
  94. $unifont = "dejavusanscondensed"; 
  95. break; 
  96. CASE "cop": // COPTIC 
  97. $unifont = "quivira"; 
  98. break; 
  99.  
  100. CASE "got": // GOTHIC 
  101. $unifont = "freeserif"; 
  102. break; 
  103.  
  104. /** African */ 
  105. CASE "nqo": // NKO 
  106. $unifont = "dejavusans"; 
  107. break; 
  108. //CASE "bax": // BAMUM 
  109. //CASE "ha": CASE "hau": // Hausa 
  110. CASE "vai": // VAI 
  111. $unifont = "freesans"; 
  112. break; 
  113. CASE "am": CASE "amh": // Amharic ETHIOPIC 
  114. CASE "ti": CASE "tir": // Tigrinya ETHIOPIC 
  115. $unifont = "abyssinicasil"; 
  116. break; 
  117.  
  118.  
  119.  
  120. /** Middle Eastern */ 
  121. CASE "ar": CASE "ara": // Arabic NB Arabic text identified by Autofont will be marked as und-Arab 
  122. $unifont = "xbriyaz"; 
  123. break; 
  124. CASE "fa": CASE "fas": // Persian (Farsi) 
  125. $unifont = "xbriyaz"; 
  126. break; 
  127. CASE "ps": CASE "pus": // Pashto 
  128. $unifont = "xbriyaz"; 
  129. break; 
  130. CASE "ku": CASE "kur": // Kurdish 
  131. $unifont = "xbriyaz"; 
  132. break; 
  133. CASE "ur": CASE "urd": // Urdu 
  134. $unifont = "xbriyaz"; 
  135. break; 
  136. CASE "he": CASE "heb": // HEBREW 
  137. CASE "yi": CASE "yid": // Yiddish 
  138. $unifont = "taameydavidclm"; // dejavusans, dejavusanscondensed, freeserif are fine if you do not need cantillation marks 
  139. break; 
  140.  
  141.  
  142. CASE "syr": // SYRIAC 
  143. $unifont = "estrangeloedessa"; 
  144. break; 
  145.  
  146.  
  147. //CASE "arc": // IMPERIAL_ARAMAIC 
  148. //CASE ""ae: // AVESTAN 
  149. CASE "xcr": // CARIAN 
  150. $unifont = "aegean"; 
  151. break; 
  152. CASE "xlc": // LYCIAN 
  153. $unifont = "aegean"; 
  154. break; 
  155. CASE "xld": // LYDIAN 
  156. $unifont = "aegean"; 
  157. break; 
  158. //CASE "mid": // MANDAIC 
  159. //CASE "peo": // OLD_PERSIAN 
  160. CASE "phn": // PHOENICIAN 
  161. $unifont = "aegean"; 
  162. break; 
  163. //CASE "smp": // SAMARITAN 
  164. CASE "uga": // UGARITIC 
  165. $unifont = "aegean"; 
  166. break; 
  167.  
  168.  
  169. /** Central Asian */ 
  170. CASE "bo": CASE "bod": // TIBETAN 
  171. CASE "dz": CASE "dzo": // Dzongkha 
  172. $unifont = "jomolhari"; 
  173. break; 
  174. //CASE "mn": CASE "mon": // MONGOLIAN (Vertical script) 
  175. //CASE "ug": CASE "uig": // Uyghur 
  176. //CASE "uz": CASE "uzb": // Uzbek 
  177. //CASE "az": CASE "azb": // South Azerbaijani 
  178.  
  179.  
  180. /** South Asian */ 
  181. CASE "as": CASE "asm": // Assamese 
  182. $unifont = "freeserif"; 
  183. break; 
  184. CASE "bn": CASE "ben": // BENGALI; Bangla 
  185. $unifont = "freeserif"; 
  186. break; 
  187. CASE "ks": CASE "kas": // Kashmiri 
  188. $unifont = "freeserif"; 
  189. break; 
  190. CASE "hi": CASE "hin": // Hindi DEVANAGARI 
  191. CASE "bh": CASE "bih": // Bihari (Bhojpuri, Magahi, and Maithili) 
  192. CASE "sa": CASE "san": // Sanskrit 
  193. $unifont = "freeserif"; 
  194. break; 
  195. CASE "gu": CASE "guj": // Gujarati 
  196. $unifont = "freeserif"; 
  197. break; 
  198. CASE "pa": CASE "pan": // Panjabi, Punjabi GURMUKHI 
  199. $unifont = "freeserif"; 
  200. break; 
  201. CASE "kn": CASE "kan": // Kannada 
  202. $unifont = "lohitkannada"; 
  203. break; 
  204. CASE "mr": CASE "mar": // Marathi 
  205. $unifont = "freeserif"; 
  206. break; 
  207. CASE "ml": CASE "mal": // MALAYALAM 
  208. $unifont = "freeserif"; 
  209. break; 
  210. CASE "ne": CASE "nep": // Nepali 
  211. $unifont = "freeserif"; 
  212. break; 
  213. CASE "or": CASE "ori": // ORIYA 
  214. $unifont = "freeserif"; 
  215. break; 
  216. CASE "si": CASE "sin": // SINHALA 
  217. $unifont = "kaputaunicode"; 
  218. break; 
  219. CASE "ta": CASE "tam": // TAMIL 
  220. $unifont = "freeserif"; 
  221. break; 
  222. CASE "te": CASE "tel": // TELUGU 
  223. $unifont = "pothana2000"; 
  224. break; 
  225.  
  226.  
  227. // Sindhi (Arabic or Devanagari) 
  228. CASE "sd": CASE "snd": // Sindhi 
  229. if ($country == "IN") { 
  230. $unifont = "freeserif"; 
  231. } else if ($country == "PK") { 
  232. $unifont = "lateef"; 
  233. } else { 
  234. $unifont = "lateef"; 
  235. break; 
  236.  
  237.  
  238. //CASE "ccp": // CHAKMA 
  239. //CASE "lep": // LEPCHA 
  240. //CASE "sat": // OL_CHIKI 
  241. //CASE "saz": // SAURASHTRA 
  242. CASE "syl": // SYLOTI_NAGRI 
  243. $unifont = "mph2bdamase"; 
  244. break; 
  245. //CASE "dgo": // TAKRI 
  246. CASE "dv": CASE "div": // Divehi; Maldivian THAANA 
  247. $unifont = "freeserif"; 
  248. break; 
  249.  
  250.  
  251.  
  252. /** South East Asian */ 
  253. CASE "km": CASE "khm": // KHMER 
  254. $unifont = "khmeros"; 
  255. break; 
  256. CASE "lo": CASE "lao": // LAO 
  257. $unifont = "dhyana"; 
  258. break; 
  259. CASE "my": CASE "mya": // MYANMAR Burmese 
  260. $unifont = "tharlon"; // zawgyi-one is non-unicode compliant but in wide usage 
  261. // ayar is also not strictly compliant 
  262. // padaukbook is unicode compliant 
  263. break; 
  264. CASE "th": CASE "tha": // THAI 
  265. $unifont = "garuda"; 
  266. break; 
  267.  
  268.  
  269.  
  270. // VIETNAMESE 
  271. CASE "vi": CASE "vie": // Vietnamese 
  272. $unifont = "dejavusanscondensed"; 
  273. break; 
  274.  
  275.  
  276. //CASE "ms": CASE "msa": // Malay 
  277. //CASE "ban": // BALINESE 
  278. //CASE "bya": // BATAK 
  279. CASE "bug": // BUGINESE 
  280. $unifont = "freeserif"; 
  281. break; 
  282. //CASE "cjm": // CHAM 
  283. //CASE "jv": // JAVANESE 
  284. CASE "su": // SUNDANESE 
  285. $unifont = "sundaneseunicode"; 
  286. break; 
  287. CASE "tdd": // TAI_LE 
  288. $unifont = "tharlon"; 
  289. break; 
  290. CASE "blt": // TAI_VIET 
  291. $unifont = "taiheritagepro"; 
  292. break; 
  293.  
  294.  
  295. /** Phillipine */ 
  296. CASE "bku": // BUHID 
  297. $unifont = "quivira"; 
  298. break; 
  299. CASE "hnn": // HANUNOO 
  300. $unifont = "quivira"; 
  301. break; 
  302. CASE "tl": // TAGALOG 
  303. $unifont = "quivira"; 
  304. break; 
  305. CASE "tbw": // TAGBANWA 
  306. $unifont = "quivira"; 
  307. break; 
  308.  
  309.  
  310. /** East Asian */ 
  311. CASE "zh": CASE "zho": // Chinese 
  312. if ($country == "HK" || $country == "TW") { 
  313. if ($adobeCJK) { 
  314. $unifont = "big5"; 
  315. } else if ($country == "CN") { 
  316. if ($adobeCJK) { 
  317. $unifont = "gb"; 
  318. } else { 
  319. if ($adobeCJK) { 
  320. $unifont = "gb"; 
  321. break; 
  322. CASE "ko": CASE "kor": // HANGUL Korean 
  323. if ($adobeCJK) { 
  324. $unifont = "uhc"; 
  325. break; 
  326. CASE "ja": CASE "jpn": // Japanese HIRAGANA KATAKANA 
  327. if ($adobeCJK) { 
  328. $unifont = "sjis"; 
  329. break; 
  330. CASE "ii": CASE "iii": // Nuosu; Yi 
  331. if ($adobeCJK) { 
  332. $unifont = "gb"; 
  333. CASE "lis": // LISU 
  334. $unifont = "quivira"; 
  335. break; 
  336.  
  337.  
  338.  
  339. /** American */ 
  340. CASE "chr": // CHEROKEE 
  341. CASE "oj": CASE "oji": // Ojibwe; Chippewa 
  342. CASE "cr": CASE "cre": // Cree CANADIAN_ABORIGINAL 
  343. CASE "iu": CASE "iku": // Inuktitut 
  344. $unifont = "aboriginalsans"; 
  345. break; 
  346.  
  347.  
  348. /** Undetermined language - script used */ 
  349. CASE "und": 
  350.  
  351. switch ($script) { 
  352.  
  353. /** European */ 
  354. CASE "latn": // LATIN 
  355. $unifont = "dejavusanscondensed"; 
  356. break; 
  357. CASE "cyrl": // CYRILLIC 
  358. $unifont = "dejavusanscondensed"; /** freeserif best coverage for supplements etc. */ 
  359. break; 
  360. CASE "cprt": // CYPRIOT 
  361. $unifont = "aegean"; 
  362. break; 
  363. CASE "glag": // GLAGOLITIC 
  364. $unifont = "mph2bdamase"; 
  365. break; 
  366. CASE "linb": // LINEAR_B 
  367. $unifont = "aegean"; 
  368. break; 
  369. CASE "ogam": // OGHAM 
  370. $unifont = "dejavusans"; 
  371. break; 
  372. CASE "ital": // OLD_ITALIC 
  373. $unifont = "aegean"; 
  374. break; 
  375. CASE "shaw": // SHAVIAN 
  376. $unifont = "mph2bdamase"; 
  377. break; 
  378.  
  379. /** African */ 
  380. CASE "ethi": // ETHIOPIC 
  381. $unifont = "abyssinicasil"; 
  382. break; 
  383. //CASE "merc": // MEROITIC_CURSIVE 
  384. //CASE "mero": // MEROITIC_HIEROGLYPHS 
  385. CASE "osma": // OSMANYA 
  386. $unifont = "mph2bdamase"; 
  387. break; 
  388. CASE "tfng": // TIFINAGH 
  389. $unifont = "dejavusans"; 
  390. break; 
  391.  
  392. /** Middle Eastern */ 
  393. CASE "arab": // ARABIC 
  394. $unifont = "xbriyaz"; 
  395. break; 
  396. //CASE "sarb": // OLD_SOUTH_ARABIAN 
  397. //CASE "prti": // INSCRIPTIONAL_PARTHIAN 
  398. //CASE "phli": // INSCRIPTIONAL_PAHLAVI 
  399.  
  400.  
  401. /** Central Asian */ 
  402. //CASE "orkh": // OLD_TURKIC 
  403. //CASE "phag": // PHAGS_PA (Vertical script) 
  404.  
  405. /** South Asian */ 
  406. //CASE "brah": // BRAHMI 
  407. //CASE "kthi": // KAITHI 
  408. CASE "khar": // KHAROSHTHI 
  409. $unifont = "mph2bdamase"; 
  410. break; 
  411. CASE "mtei": // MEETEI_MAYEK 
  412. $unifont = "eeyekunicode"; 
  413. break; 
  414. //CASE "shrd": // SHARADA 
  415. //CASE "sora": // SORA_SOMPENG 
  416.  
  417. /** South East Asian */ 
  418. CASE "kali": // KAYAH_LI 
  419. $unifont = "freemono"; 
  420. break; 
  421. //CASE "rjng": // REJANG 
  422. CASE "lana": // TAI_THAM 
  423. $unifont = "lannaalif"; 
  424. break; 
  425. CASE "talu": // NEW_TAI_LUE 
  426. $unifont = "daibannasilbook"; 
  427. break; 
  428.  
  429. /** East Asian */ 
  430. CASE "hans": // HAN (SIMPLIFIED) 
  431. if ($adobeCJK) { 
  432. $unifont = "gb"; 
  433. break; 
  434. //CASE "plrd": // MIAO 
  435.  
  436. /** American */ 
  437. CASE "dsrt": // DESERET 
  438. $unifont = "mph2bdamase"; 
  439. break; 
  440.  
  441. /** Other */ 
  442. CASE "brai": // BRAILLE 
  443. $unifont = "dejavusans"; 
  444. break; 
  445. } // endswitch 
  446. break; 
  447. } // endswitch 
  448.  
  449.  
  450. return array($coreSuitable, $unifont);