1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module pango.language; 7 8 import pango.utils; 9 import pango.script; 10 import pango.c.language; 11 import pango.c.script; 12 13 import std..string; 14 15 16 struct Language 17 { 18 PangoLanguage *nativePtr; 19 20 package this(PangoLanguage *ptr) { nativePtr = ptr; } 21 22 23 this (string lang) { 24 nativePtr = pango_language_from_string(toStringz(lang)); 25 } 26 27 28 static Language getDefault() { 29 return Language(pango_language_get_default()); 30 } 31 32 33 pure string toString() { 34 const(char)* s = pango_language_to_string(nativePtr); 35 if (s) { 36 return fromStringz(s).idup; 37 } 38 return ""; 39 } 40 41 pure @property string sampleString() 42 { 43 const(char)* s = pango_language_get_sample_string(nativePtr); 44 if (s) { 45 return fromStringz(s).idup; 46 } 47 return ""; 48 } 49 50 pure bool matches(string rangeList) { 51 return cast(bool)pango_language_matches(nativePtr, toStringz(rangeList)); 52 } 53 54 pure bool includesScript(Script script) { 55 return cast(bool)pango_language_includes_script(nativePtr, cast(PangoScript)script); 56 } 57 58 @property Script[] scripts() { 59 int num; 60 const(PangoScript)* outScripts = pango_language_get_scripts(nativePtr, &num); 61 if (outScripts && num > 0) { 62 const(Script)* dscripts = cast(const(Script)*)outScripts; 63 return dscripts[0 .. num].dup; 64 } 65 return []; 66 } 67 68 } 69