Class: Fontconfig::Config
- Inherits:
-
Object
- Object
- Fontconfig::Config
- Defined in:
- ext/fontconfig/fc_config.c
Class Method Summary collapse
-
.enable_home!(*args) ⇒ Object
FcConfigEnableHome – controls use of the home directory.
-
.filename(filename) ⇒ Object
FcConfigFilename – Find a config file.
-
.get_current ⇒ Object
// FcConfigReference – Increment config reference count.
-
.home ⇒ Object
FcConfigHome – return the current home directory.
-
.new(*args) ⇒ Object
FcConfigCreate – Create a configuration.
Instance Method Summary collapse
-
#app_font_add_dir(path) ⇒ Object
FcConfigAppFontAddDir – Add fonts from directory to font database.
-
#app_font_add_file(path) ⇒ Object
FcConfigAppFontAddFile – Add font file to font database.
-
#app_font_clear! ⇒ Object
FcConfigAppFontClear – Remove all app fonts from font database.
-
#build_fonts! ⇒ Object
FcConfigBuildFonts – Build font database.
-
#cache_dirs ⇒ Object
FcConfigGetCacheDirs – return the list of directories searched for cache files.
-
#config_dirs ⇒ Object
FcConfigGetConfigDirs – Get config directories.
-
#config_files ⇒ Object
FcConfigGetConfigFiles – Get config files.
-
#font_dirs ⇒ Object
FcConfigGetFontDirs – Get font directories.
-
#font_match(pattern) ⇒ Object
TODO: check for this?.
-
#font_render_prepare(pat, font) ⇒ Object
FcFontRenderPrepare – Prepare pattern for loading font file.
-
#font_sort(*args) ⇒ Object
FcFontSort – Return list of matching fonts.
-
#parse_and_load(*args) ⇒ Object
FcConfigParseAndLoad – load a configuration file.
-
#rescan_interval ⇒ Object
FcConfigGetRescanInterval – Get config rescan interval.
-
#rescan_interval=(interval) ⇒ Object
FcConfigSetRescanInterval – Set config rescan interval.
-
#set_current! ⇒ Object
FcConfigSetCurrent – Set configuration as default.
-
#set_sys_root!(root) ⇒ Object
FcConfigSetSysRoot – Set the system root directory.
-
#substitute(*args) ⇒ Object
FcConfigSubstitute – Execute substitutions.
-
#substitute_with_pat(*args) ⇒ Object
FcConfigSubstituteWithPat – Execute substitutions.
-
#sys_root ⇒ Object
FcConfigGetSysRoot – Obtain the system root directory.
-
#up_to_date? ⇒ Boolean
FcConfigUptoDate – Check timestamps on config files.
Class Method Details
.enable_home!(*args) ⇒ Object
FcConfigEnableHome – controls use of the home directory.
105 106 107 108 109 110 111 |
# File 'ext/fontconfig/fc_config.c', line 105 static VALUE rb_config_enable_home(int argc, VALUE *argv, VALUE klass){ VALUE enable; if(rb_scan_args(argc, argv, "01", &enable) == 0){ enable = Qtrue; } return BOOL2VAL(FcConfigEnableHome(RTEST(enable))); } |
.filename(filename) ⇒ Object
FcConfigFilename – Find a config file
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'ext/fontconfig/fc_config.c', line 59 static VALUE rb_config_filename(VALUE klass, VALUE filename){ // in FONTCONFIG_PATH char* fname = 0; if(RTEST(filename)){ if(TYPE(filename) != T_STRING) filename = rb_any_to_s(filename); fname = RSTRING_PTR(filename); } char* res = FcConfigFilename(fname); if(!res){ rb_raise(rb_eRuntimeError, "cannot get config filename"); } VALUE rb_res = rb_str_new2(res); FcStrFree(res); //? return rb_res; } |
.get_current ⇒ Object
// FcConfigReference – Increment config reference count
78 79 80 81 82 83 84 |
# File 'ext/fontconfig/fc_config.c', line 78 static VALUE rb_config_get_current(VALUE klass){ FcConfig* conf = FcConfigGetCurrent(); if(!conf) rb_raise(rb_eRuntimeError, "no current in FcConfigGetCurrent"); FcConfigReference(conf); return config_wrap(conf); } |
.home ⇒ Object
FcConfigHome – return the current home directory.
97 98 99 100 101 102 |
# File 'ext/fontconfig/fc_config.c', line 97 static VALUE rb_config_home(VALUE klass){ char* home = FcConfigHome(); if(!home) return Qnil; return rb_str_new2(home); } |
.new(*args) ⇒ Object
FcConfigCreate – Create a configuration
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'ext/fontconfig/fc_config.c', line 39 static VALUE rb_config_new(int argc, VALUE *argv, VALUE klass){ FcConfig * conf = FcConfigCreate(); VALUE file; rb_scan_args(argc, argv, "01", &file); if(!conf){ rb_raise(rb_eRuntimeError, "Cannot create FcConfig"); } VALUE self = config_wrap(conf); if(RTEST(file)){ if(!rb_config_parse_and_load(1, &file, self) == Qfalse){ FcConfigDestroy(conf); RTYPEDDATA_DATA(self) = 0; rb_raise(rb_eRuntimeError, "Cannot load FcConfig"); } } return self; } |
Instance Method Details
#app_font_add_dir(path) ⇒ Object
FcConfigAppFontAddDir – Add fonts from directory to font database
203 204 205 |
# File 'ext/fontconfig/fc_config.c', line 203 static VALUE rb_config_app_font_add_dir(VALUE self, VALUE path){ return BOOL2VAL(FcConfigAppFontAddDir(CONFIG_UNWRAP(self), StringValuePtr(path))); } |
#app_font_add_file(path) ⇒ Object
FcConfigAppFontAddFile – Add font file to font database
198 199 200 |
# File 'ext/fontconfig/fc_config.c', line 198 static VALUE rb_config_app_font_add_file(VALUE self, VALUE path){ return BOOL2VAL(FcConfigAppFontAddFile(CONFIG_UNWRAP(self), StringValuePtr(path))); } |
#app_font_clear! ⇒ Object
FcConfigAppFontClear – Remove all app fonts from font database
192 193 194 195 |
# File 'ext/fontconfig/fc_config.c', line 192 static VALUE rb_config_app_font_clear(VALUE self){ FcConfigAppFontClear(CONFIG_UNWRAP(self)); return self; } |
#build_fonts! ⇒ Object
FcConfigBuildFonts – Build font database
114 115 116 117 118 |
# File 'ext/fontconfig/fc_config.c', line 114 static VALUE rb_config_build_fonts(VALUE self){ //TODO: set some flag? //changes after this have undetermined effects return BOOL2VAL(FcConfigBuildFonts(CONFIG_UNWRAP(self))); } |
#cache_dirs ⇒ Object
FcConfigGetCacheDirs – return the list of directories searched for cache files
149 150 151 152 |
# File 'ext/fontconfig/fc_config.c', line 149 static VALUE rb_config_get_cache_dirs(VALUE self){ FcStrList * list = FcConfigGetCacheDirs(CONFIG_UNWRAP(self)); return FcStrList2Array(list); } |
#config_dirs ⇒ Object
FcConfigGetConfigDirs – Get config directories
131 132 133 134 |
# File 'ext/fontconfig/fc_config.c', line 131 static VALUE rb_config_get_config_dirs(VALUE self){ FcStrList * list = FcConfigGetConfigDirs(CONFIG_UNWRAP(self)); return FcStrList2Array(list); } |
#config_files ⇒ Object
FcConfigGetConfigFiles – Get config files
143 144 145 146 |
# File 'ext/fontconfig/fc_config.c', line 143 static VALUE rb_config_get_config_files(VALUE self){ FcStrList * list = FcConfigGetConfigFiles(CONFIG_UNWRAP(self)); return FcStrList2Array(list); } |
#font_dirs ⇒ Object
FcConfigGetFontDirs – Get font directories
137 138 139 140 |
# File 'ext/fontconfig/fc_config.c', line 137 static VALUE rb_config_get_font_dirs(VALUE self){ FcStrList * list = FcConfigGetFontDirs(CONFIG_UNWRAP(self)); return FcStrList2Array(list); } |
#font_match(pattern) ⇒ Object
TODO: check for this?
211 212 213 214 215 216 217 218 219 220 221 |
# File 'ext/fontconfig/fc_config.c', line 211 static VALUE rb_config_font_match(VALUE self, VALUE pattern){ if(!is_fc_pattern(pattern)){ rb_raise(rb_eArgError, "argument must be Fontconfig::Pattern"); } FcResult res; // result of FcFontRenderPrepare for font and the provided pattern //??? FcPattern* match = FcFontMatch(CONFIG_UNWRAP(self), RTYPEDDATA_DATA(pattern), &res); if(match){ return pattern_wrap(match); } return Qnil; } |
#font_render_prepare(pat, font) ⇒ Object
FcFontRenderPrepare – Prepare pattern for loading font file
180 181 182 183 184 185 186 187 188 189 |
# File 'ext/fontconfig/fc_config.c', line 180 static VALUE rb_config_font_render_prepare(VALUE self, VALUE pat, VALUE font){ if(!is_fc_pattern(pat) || !is_fc_pattern(font)){ rb_raise(rb_eArgError, "arguments must be Fontconfig::Pattern"); } FcPattern * res = FcFontRenderPrepare(CONFIG_UNWRAP(self), (FcPattern*)RTYPEDDATA_DATA(pat), (FcPattern*)RTYPEDDATA_DATA(font)); if(!res){ rb_raise(rb_eRuntimeError, "FcFontRenderPrepare returned NULL"); } return pattern_wrap(res); } |
#font_sort(*args) ⇒ Object
FcFontSort – Return list of matching fonts
316 317 318 319 320 321 322 323 324 325 326 |
# File 'ext/fontconfig/fc_config.c', line 316 static VALUE rb_config_font_sort(int argc, VALUE *argv, VALUE self){ VALUE pattern, trim; rb_scan_args(argc, argv, "11", &pattern, &trim); //charset - ignored. if(!RTEST(pattern) || !is_fc_pattern(pattern)){ rb_raise(rb_eArgError, "pattern must be Fonconfig::Pattern"); } FcResult res; FcFontSet* set = FcFontSort(CONFIG_UNWRAP(self), pattern_unwrap(pattern), RTEST(trim), 0, &res); return font_set_wrap(set); } |
#parse_and_load(*args) ⇒ Object
FcConfigParseAndLoad – load a configuration file
28 29 30 31 32 33 34 35 36 |
# File 'ext/fontconfig/fc_config.c', line 28 static VALUE rb_config_parse_and_load(int argc, VALUE *argv, VALUE self){ VALUE path, complain = Qnil; rb_scan_args(argc, argv, "11", &path, &complain); if(TYPE(path)!=T_STRING) path = rb_any_to_s(path); int res = FcConfigParseAndLoad(CONFIG_UNWRAP(self), RSTRING_PTR(path), RTEST(complain)); return BOOL2VAL(res); } |
#rescan_interval ⇒ Object
FcConfigGetRescanInterval – Get config rescan interval
155 156 157 |
# File 'ext/fontconfig/fc_config.c', line 155 static VALUE rb_config_get_rescan_interval(VALUE self){ return INT2FIX(FcConfigGetRescanInterval(CONFIG_UNWRAP(self))); } |
#rescan_interval=(interval) ⇒ Object
FcConfigSetRescanInterval – Set config rescan interval
160 161 162 163 |
# File 'ext/fontconfig/fc_config.c', line 160 static VALUE rb_config_set_rescan_interval(VALUE self, VALUE interval){ interval = rb_to_int(interval); return INT2FIX(FcConfigSetRescanInterval(CONFIG_UNWRAP(self), NUM2INT(interval))); } |
#set_current! ⇒ Object
FcConfigSetCurrent – Set configuration as default
87 88 89 |
# File 'ext/fontconfig/fc_config.c', line 87 static VALUE rb_config_set_current(VALUE self){ return BOOL2VAL(FcConfigSetCurrent(CONFIG_UNWRAP(self))); } |
#set_sys_root!(root) ⇒ Object
FcConfigSetSysRoot – Set the system root directory
174 175 176 177 |
# File 'ext/fontconfig/fc_config.c', line 174 static VALUE rb_config_set_sys_root(VALUE self, VALUE root){ FcConfigSetSysRoot(CONFIG_UNWRAP(self), StringValuePtr(root)); return self; } |
#substitute(*args) ⇒ Object
FcConfigSubstitute – Execute substitutions
238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'ext/fontconfig/fc_config.c', line 238 static VALUE rb_config_substitute(int argc, VALUE *argv, VALUE self){ VALUE pattern, match_kind; rb_scan_args(argc, argv, "11", &pattern, &match_kind); if(!is_fc_pattern(pattern)){ rb_raise(rb_eArgError, "argument must be Fontconfig::Pattern"); } FcMatchKind kind = FcMatchPattern; //TODO: default? if(RTEST(match_kind)) kind = sym2match_kind(match_kind); return BOOL2VAL(FcConfigSubstitute(CONFIG_UNWRAP(self), RTYPEDDATA_DATA(pattern), kind)); } |
#substitute_with_pat(*args) ⇒ Object
FcConfigSubstituteWithPat – Execute substitutions
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'ext/fontconfig/fc_config.c', line 253 static VALUE rb_config_substitute_with_pat(int argc, VALUE *argv, VALUE self){ VALUE pattern, pat, match_kind; int n = rb_scan_args(argc, argv, "12", &pattern, &pat, &match_kind); if(n == 2){ match_kind = pat; pat = Qnil; } if(!is_fc_pattern(pattern)){ rb_raise(rb_eArgError, "argument must be Fontconfig::Pattern"); } FcPattern* pat_pat = 0; if(RTEST(pat)){ if(!is_fc_pattern(pat)){ rb_raise(rb_eArgError, "argument must be Fontconfig::Pattern"); } pat_pat = RTYPEDDATA_DATA(pat); } FcMatchKind kind = FcMatchPattern; //TODO: default? if(RTEST(match_kind)) kind = sym2match_kind(match_kind); return BOOL2VAL(FcConfigSubstituteWithPat(CONFIG_UNWRAP(self), RTYPEDDATA_DATA(pattern), pat_pat, kind)); } |
#sys_root ⇒ Object
FcConfigGetSysRoot – Obtain the system root directory
166 167 168 169 170 171 |
# File 'ext/fontconfig/fc_config.c', line 166 static VALUE rb_config_get_sys_root(VALUE self){ const char* res = FcConfigGetSysRoot(CONFIG_UNWRAP(self)); if(!res) return Qnil; return rb_str_new2(res); } |
#up_to_date? ⇒ Boolean
FcConfigUptoDate – Check timestamps on config files
92 93 94 |
# File 'ext/fontconfig/fc_config.c', line 92 static VALUE rb_config_up_to_date_p(VALUE self){ return BOOL2VAL(FcConfigUptoDate(CONFIG_UNWRAP(self))); } |