4 * Copyright (C) 2009-2015 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcdisplayinfo.h"
24 #include "bclistbox.inc"
25 #include "bcfontentry.h"
26 #include "bcresources.h"
27 #include "bcsignals.h"
28 #include "bcsynchronous.h"
29 #include "bcwindowbase.h"
31 #include "bccmodels.h"
41 #include <X11/extensions/XShm.h>
42 #include <fontconfig/fontconfig.h>
43 #include <fontconfig/fcfreetype.h>
50 int BC_Resources::error = 0;
52 VFrame* BC_Resources::bg_image = 0;
53 VFrame* BC_Resources::menu_bg = 0;
55 int BC_Resources::locale_utf8 = 0;
56 int BC_Resources::little_endian = 0;
57 char BC_Resources::language[LEN_LANG] = {0};
58 char BC_Resources::region[LEN_LANG] = {0};
59 char BC_Resources::encoding[LEN_ENCOD] = {0};
60 const char *BC_Resources::wide_encoding = 0;
61 ArrayList<BC_FontEntry*> *BC_Resources::fontlist = 0;
62 const char *BC_Resources::fc_properties[] = { FC_SLANT, FC_WEIGHT, FC_WIDTH };
63 #define LEN_FCPROP (sizeof(BC_Resources::fc_properties) / sizeof(const char*))
65 static const char *def_small_font = "-*-helvetica-medium-r-normal-*-%d-*"; // 10
66 static const char *def_small_font2 = "-*-helvetica-medium-r-normal-*-%d-*"; // 11
67 static const char *def_medium_font = "-*-helvetica-bold-r-normal-*-%d-*"; // 14
68 static const char *def_medium_font2 = "-*-helvetica-bold-r-normal-*-%d-*"; // 14
69 static const char *def_large_font = "-*-helvetica-bold-r-normal-*-%d-*"; // 18
70 static const char *def_large_font2 = "-*-helvetica-bold-r-normal-*-%d-*"; // 20
71 static const char *def_big_font =
72 "-*-bitstream charter-bold-r-normal-*-*-0-%d-%d-p-0-iso8859-1"; // 160
73 static const char *def_big_font2 =
74 "-*-nimbus sans l-bold-r-normal-*-*-0-%d-%d-p-0-iso8859-1"; // 160
75 static const char *def_small_fontset = "-*-helvetica-medium-r-normal-*-%d-*";// 10
76 static const char *def_medium_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 14
77 static const char *def_large_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 18
78 static const char *def_big_fontset = "-*-helvetica-bold-r-normal-*-%d-*"; // 24
79 static const char *def_small_font_xft = "Sans:pixelsize=%.4f"; // 10.6667
80 static const char *def_small_b_font_xft = "Sans:bold:pixelsize=%.4f"; // 10.6667
81 static const char *def_medium_font_xft = "Sans:pixelsize=%.4f"; // 13.3333
82 static const char *def_medium_b_font_xft = "Sans:bold:pixelsize=%.4f"; // 13.3333
83 static const char *def_large_font_xft = "Sans:pixelsize=%.4f"; // 21.3333
84 static const char *def_large_b_font_xft = "Sans:bold:pixelsize=%.4f"; // 21.3333
85 static const char *def_big_font_xft = "Sans:pixelsize=37.3333"; // 37.3333
86 static const char *def_big_b_font_xft = "Sans:bold:pixelsize=37.33333"; // 37.3333
88 #define default_font_xft2 "-microsoft-verdana-*-*-*-*-*-*-*-*-*-*-*-*"
90 const char* BC_Resources::small_font = 0;
91 const char* BC_Resources::small_font2 = 0;
92 const char* BC_Resources::medium_font = 0;
93 const char* BC_Resources::medium_font2 = 0;
94 const char* BC_Resources::large_font = 0;
95 const char* BC_Resources::large_font2 = 0;
96 const char* BC_Resources::big_font = 0;
97 const char* BC_Resources::big_font2 = 0;
98 const char* BC_Resources::small_fontset = 0;
99 const char* BC_Resources::medium_fontset = 0;
100 const char* BC_Resources::large_fontset = 0;
101 const char* BC_Resources::big_fontset = 0;
102 const char* BC_Resources::small_font_xft = 0;
103 const char* BC_Resources::small_font_xft2 = 0;
104 const char* BC_Resources::small_b_font_xft = 0;
105 const char* BC_Resources::medium_font_xft = 0;
106 const char* BC_Resources::medium_font_xft2 = 0;
107 const char* BC_Resources::medium_b_font_xft = 0;
108 const char* BC_Resources::large_font_xft = 0;
109 const char* BC_Resources::large_font_xft2 = 0;
110 const char* BC_Resources::large_b_font_xft = 0;
111 const char* BC_Resources::big_font_xft = 0;
112 const char* BC_Resources::big_font_xft2 = 0;
113 const char* BC_Resources::big_b_font_xft = 0;
115 #define def_font(v, s...) do { sprintf(string,def_##v,s); v = cstrdup(string); } while(0)
116 #define set_font(v, s) do { sprintf(string, "%s", s); v = cstrdup(string); } while(0)
117 #define iround(v) ((int)(v+0.5))
118 void BC_Resources::init_font_defs(double scale)
120 char string[BCTEXTLEN];
121 def_font(small_font, iround(scale*11));
122 def_font(small_font2, iround(scale*11));
123 def_font(medium_font, iround(scale*14));
124 def_font(medium_font2, iround(scale*14));
125 def_font(large_font, iround(scale*18));
126 def_font(large_font2, iround(scale*20));
127 def_font(big_font, iround(scale*160), iround(scale*160));
128 def_font(big_font2, iround(scale*160), iround(scale*160));
129 def_font(small_fontset, iround(scale*10));
130 def_font(medium_fontset, iround(scale*14));
131 def_font(large_fontset, iround(scale*18));
132 def_font(big_fontset, iround(scale*24));
133 def_font(small_font_xft, (scale*10.6667));
134 def_font(small_b_font_xft, (scale*10.6667));
135 def_font(medium_font_xft, (scale*13.3333));
136 def_font(medium_b_font_xft,(scale*13.3333));
137 def_font(large_font_xft, (scale*21.3333));
138 def_font(large_b_font_xft, (scale*21.3333));
139 def_font(big_font_xft, (scale*37.3333));
140 def_font(big_b_font_xft, (scale*37.3333));
142 set_font(small_font_xft2, default_font_xft2);
143 set_font(medium_font_xft2, default_font_xft2);
144 set_font(large_font_xft2, default_font_xft2);
145 set_font(big_font_xft2, default_font_xft2);
148 suffix_to_type_t BC_Resources::suffix_to_type[] =
150 { "m2v", ICON_FILM },
151 { "mov", ICON_FILM },
152 { "mp2", ICON_SOUND },
153 { "mp3", ICON_SOUND },
154 { "ac3", ICON_SOUND },
155 { "mpg", ICON_FILM },
156 { "vob", ICON_FILM },
157 { "ifo", ICON_FILM },
159 { "vts", ICON_FILM },
160 { "wav", ICON_SOUND }
163 BC_Signals* BC_Resources::signal_handler = 0;
164 Mutex BC_Resources::fontconfig_lock("BC_Resources::fonconfig_lock");
166 int BC_Resources::x_error_handler(Display *display, XErrorEvent *event)
168 #if defined(OUTPUT_X_ERROR)
170 XGetErrorText(event->display, event->error_code, string, 1024);
171 fprintf(stderr, "BC_Resources::x_error_handler: error_code=%d opcode=%d,%d %s\n",
178 BC_Resources::error = 1;
179 // This bug only happens in 32 bit mode.
180 // if(sizeof(long) == 4)
181 // BC_WindowBase::get_resources()->use_xft = 0;
185 int BC_Resources::machine_cpus = 1;
187 int BC_Resources::get_machine_cpus()
190 FILE *proc = fopen("/proc/cpuinfo", "r");
192 char string[BCTEXTLEN], *cp;
193 while(!feof(proc) && fgets(string, sizeof(string), proc) ) {
194 if( !strncasecmp(string, "processor", 9) &&
195 (cp = strchr(string, ':')) != 0 ) {
196 int n = atol(cp+1) + 1;
197 if( n > cpus ) cpus = n;
199 else if( !strncasecmp(string, "cpus detected", 13) &&
200 (cp = strchr(string, ':')) != 0 )
208 BC_Resources::BC_Resources()
212 display_info = new BC_DisplayInfo("", 0);
214 char *font_scale = getenv("BC_FONT_SCALE");
216 int display_w = display_info->get_root_w();
217 int display_h = display_info->get_root_h();
218 int display_size = display_h < display_w ? display_h : display_w;
219 scale = display_size / 1000.;
222 double env_scale = atof(font_scale);
223 if( env_scale > 0 ) scale = env_scale;
225 init_font_defs(scale);
226 id_lock = new Mutex("BC_Resources::id_lock");
227 create_window_lock = new Mutex("BC_Resources::create_window_lock", 1);
229 machine_cpus = get_machine_cpus();
231 for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
232 filebox_history[i].path[0] = 0;
238 little_endian = (*(const u_int32_t*)"\01\0\0\0") & 1;
239 wide_encoding = little_endian ? "UTF32LE" : "UTF32BE";
242 #include "images/file_film_png.h"
243 #include "images/file_folder_png.h"
244 #include "images/file_sound_png.h"
245 #include "images/file_unknown_png.h"
246 #include "images/file_column_png.h"
247 static VFrame* default_type_to_icon[] =
249 new VFrame(file_folder_png),
250 new VFrame(file_unknown_png),
251 new VFrame(file_film_png),
252 new VFrame(file_sound_png),
253 new VFrame(file_column_png)
255 type_to_icon = default_type_to_icon;
258 #include "images/bar_png.h"
259 static VFrame* default_bar = new VFrame(bar_png);
260 bar_data = default_bar;
263 #include "images/cancel_up_png.h"
264 #include "images/cancel_hi_png.h"
265 #include "images/cancel_dn_png.h"
266 static VFrame* default_cancel_images[] =
268 new VFrame(cancel_up_png),
269 new VFrame(cancel_hi_png),
270 new VFrame(cancel_dn_png)
273 #include "images/ok_up_png.h"
274 #include "images/ok_hi_png.h"
275 #include "images/ok_dn_png.h"
276 static VFrame* default_ok_images[] =
278 new VFrame(ok_up_png),
279 new VFrame(ok_hi_png),
280 new VFrame(ok_dn_png)
283 #include "images/usethis_up_png.h"
284 #include "images/usethis_uphi_png.h"
285 #include "images/usethis_dn_png.h"
286 static VFrame* default_usethis_images[] =
288 new VFrame(usethis_up_png),
289 new VFrame(usethis_uphi_png),
290 new VFrame(usethis_dn_png)
294 #include "images/checkbox_checked_png.h"
295 #include "images/checkbox_dn_png.h"
296 #include "images/checkbox_checkedhi_png.h"
297 #include "images/checkbox_up_png.h"
298 #include "images/checkbox_hi_png.h"
299 static VFrame* default_checkbox_images[] =
301 new VFrame(checkbox_up_png),
302 new VFrame(checkbox_hi_png),
303 new VFrame(checkbox_checked_png),
304 new VFrame(checkbox_dn_png),
305 new VFrame(checkbox_checkedhi_png)
308 #include "images/radial_checked_png.h"
309 #include "images/radial_dn_png.h"
310 #include "images/radial_checkedhi_png.h"
311 #include "images/radial_up_png.h"
312 #include "images/radial_hi_png.h"
313 static VFrame* default_radial_images[] =
315 new VFrame(radial_up_png),
316 new VFrame(radial_hi_png),
317 new VFrame(radial_checked_png),
318 new VFrame(radial_dn_png),
319 new VFrame(radial_checkedhi_png)
322 static VFrame* default_label_images[] =
324 new VFrame(radial_up_png),
325 new VFrame(radial_hi_png),
326 new VFrame(radial_checked_png),
327 new VFrame(radial_dn_png),
328 new VFrame(radial_checkedhi_png)
332 #include "images/check_png.h"
333 static VFrame* default_check_image = new VFrame(check_png);
334 check = default_check_image;
336 #include "images/file_text_up_png.h"
337 #include "images/file_text_hi_png.h"
338 #include "images/file_text_dn_png.h"
339 #include "images/file_icons_up_png.h"
340 #include "images/file_icons_hi_png.h"
341 #include "images/file_icons_dn_png.h"
342 #include "images/file_newfolder_up_png.h"
343 #include "images/file_newfolder_hi_png.h"
344 #include "images/file_newfolder_dn_png.h"
345 #include "images/file_rename_up_png.h"
346 #include "images/file_rename_hi_png.h"
347 #include "images/file_rename_dn_png.h"
348 #include "images/file_updir_up_png.h"
349 #include "images/file_updir_hi_png.h"
350 #include "images/file_updir_dn_png.h"
351 #include "images/file_delete_up_png.h"
352 #include "images/file_delete_hi_png.h"
353 #include "images/file_delete_dn_png.h"
354 #include "images/file_reload_up_png.h"
355 #include "images/file_reload_hi_png.h"
356 #include "images/file_reload_dn_png.h"
357 static VFrame* default_filebox_text_images[] =
359 new VFrame(file_text_up_png),
360 new VFrame(file_text_hi_png),
361 new VFrame(file_text_dn_png)
364 static VFrame* default_filebox_icons_images[] =
366 new VFrame(file_icons_up_png),
367 new VFrame(file_icons_hi_png),
368 new VFrame(file_icons_dn_png)
371 static VFrame* default_filebox_updir_images[] =
373 new VFrame(file_updir_up_png),
374 new VFrame(file_updir_hi_png),
375 new VFrame(file_updir_dn_png)
378 static VFrame* default_filebox_newfolder_images[] =
380 new VFrame(file_newfolder_up_png),
381 new VFrame(file_newfolder_hi_png),
382 new VFrame(file_newfolder_dn_png)
386 static VFrame* default_filebox_rename_images[] =
388 new VFrame(file_rename_up_png),
389 new VFrame(file_rename_hi_png),
390 new VFrame(file_rename_dn_png)
393 static VFrame* default_filebox_delete_images[] =
395 new VFrame(file_delete_up_png),
396 new VFrame(file_delete_hi_png),
397 new VFrame(file_delete_dn_png)
400 static VFrame* default_filebox_reload_images[] =
402 new VFrame(file_reload_up_png),
403 new VFrame(file_reload_hi_png),
404 new VFrame(file_reload_dn_png)
407 #include "images/listbox_button_dn_png.h"
408 #include "images/listbox_button_hi_png.h"
409 #include "images/listbox_button_up_png.h"
410 #include "images/listbox_button_disabled_png.h"
411 static VFrame* default_listbox_button[] =
413 new VFrame(listbox_button_up_png),
414 new VFrame(listbox_button_hi_png),
415 new VFrame(listbox_button_dn_png),
416 new VFrame(listbox_button_disabled_png)
418 listbox_button = default_listbox_button;
420 #include "images/menu_popup_bg_png.h"
421 static VFrame* default_listbox_bg = 0;
422 listbox_bg = default_listbox_bg;
424 #include "images/listbox_expandchecked_png.h"
425 #include "images/listbox_expandcheckedhi_png.h"
426 #include "images/listbox_expanddn_png.h"
427 #include "images/listbox_expandup_png.h"
428 #include "images/listbox_expanduphi_png.h"
429 static VFrame* default_listbox_expand[] =
431 new VFrame(listbox_expandup_png),
432 new VFrame(listbox_expanduphi_png),
433 new VFrame(listbox_expandchecked_png),
434 new VFrame(listbox_expanddn_png),
435 new VFrame(listbox_expandcheckedhi_png),
437 listbox_expand = default_listbox_expand;
439 #include "images/listbox_columnup_png.h"
440 #include "images/listbox_columnhi_png.h"
441 #include "images/listbox_columndn_png.h"
442 static VFrame* default_listbox_column[] =
444 new VFrame(listbox_columnup_png),
445 new VFrame(listbox_columnhi_png),
446 new VFrame(listbox_columndn_png)
448 listbox_column = default_listbox_column;
451 #include "images/listbox_up_png.h"
452 #include "images/listbox_dn_png.h"
453 listbox_up = new VFrame(listbox_up_png);
454 listbox_dn = new VFrame(listbox_dn_png);
455 listbox_title_overlap = 0;
456 listbox_title_margin = 0;
457 listbox_title_color = BLACK;
458 listbox_title_hotspot = 5;
460 listbox_border1 = DKGREY;
461 listbox_border2_hi = RED;
462 listbox_border2 = BLACK;
463 listbox_border3_hi = RED;
464 listbox_border3 = MEGREY;
465 listbox_border4 = WHITE;
466 listbox_selected = BLUE;
467 listbox_highlighted = LTGREY;
468 listbox_inactive = WHITE;
469 listbox_text = BLACK;
471 #include "images/pot_hi_png.h"
472 #include "images/pot_up_png.h"
473 #include "images/pot_dn_png.h"
474 static VFrame *default_pot_images[] =
476 new VFrame(pot_up_png),
477 new VFrame(pot_hi_png),
478 new VFrame(pot_dn_png)
481 #include "images/progress_up_png.h"
482 #include "images/progress_hi_png.h"
483 static VFrame* default_progress_images[] =
485 new VFrame(progress_up_png),
486 new VFrame(progress_hi_png)
490 pan_text_color = YELLOW;
492 #include "images/7seg_small/0_png.h"
493 #include "images/7seg_small/1_png.h"
494 #include "images/7seg_small/2_png.h"
495 #include "images/7seg_small/3_png.h"
496 #include "images/7seg_small/4_png.h"
497 #include "images/7seg_small/5_png.h"
498 #include "images/7seg_small/6_png.h"
499 #include "images/7seg_small/7_png.h"
500 #include "images/7seg_small/8_png.h"
501 #include "images/7seg_small/9_png.h"
502 #include "images/7seg_small/colon_png.h"
503 #include "images/7seg_small/period_png.h"
504 #include "images/7seg_small/a_png.h"
505 #include "images/7seg_small/b_png.h"
506 #include "images/7seg_small/c_png.h"
507 #include "images/7seg_small/d_png.h"
508 #include "images/7seg_small/e_png.h"
509 #include "images/7seg_small/f_png.h"
510 #include "images/7seg_small/space_png.h"
511 #include "images/7seg_small/dash_png.h"
512 static VFrame* default_medium_7segment[] =
524 new VFrame(colon_png),
525 new VFrame(period_png),
532 new VFrame(space_png),
536 generic_button_margin = 15;
537 draw_clock_background=1;
547 bg_light2 = bg_color;
550 border_light1 = bg_color;
551 border_light2 = MEGREY;
552 border_shadow1 = BLACK;
553 border_shadow2 = bg_color;
555 default_text_color = BLACK;
556 disabled_text_color = DMGREY;
558 button_light = MEGREY; // bright corner
559 // button_highlighted = LTGREY; // face when highlighted
560 button_highlighted = 0xffe000; // face when highlighted
561 button_down = MDGREY; // face when down
562 // button_up = MEGREY; // face when up
563 button_up = 0xffc000; // face when up
564 button_shadow = BLACK; // dark corner
565 button_uphighlighted = RED; // upper side when highlighted
568 tumble_duration = 150;
570 ok_images = default_ok_images;
571 cancel_images = default_cancel_images;
572 usethis_button_images = default_usethis_images;
573 filebox_descend_images = default_ok_images;
576 menu_highlighted = LTBLUE;
579 menu_shadow = DKCYAN;
582 #include "images/menuitem_up_png.h"
583 #include "images/menuitem_hi_png.h"
584 #include "images/menuitem_dn_png.h"
585 #include "images/menubar_up_png.h"
586 #include "images/menubar_hi_png.h"
587 #include "images/menubar_dn_png.h"
588 #include "images/menubar_bg_png.h"
590 static VFrame *default_menuitem_data[] =
592 new VFrame(menuitem_up_png),
593 new VFrame(menuitem_hi_png),
594 new VFrame(menuitem_dn_png),
596 menu_item_bg = default_menuitem_data;
599 static VFrame *default_menubar_data[] =
601 new VFrame(menubar_up_png),
602 new VFrame(menubar_hi_png),
603 new VFrame(menubar_dn_png),
605 menu_title_bg = default_menubar_data;
607 menu_popup_bg = new VFrame(menu_popup_bg_png);
609 menu_bar_bg = new VFrame(menubar_bg_png);
611 popupmenu_images = 0;
614 popupmenu_margin = 10;
615 popupmenu_triangle_margin = 10;
618 menu_title_text = BLACK;
619 popup_title_text = BLACK;
620 menu_item_text = BLACK;
621 menu_highlighted_fontcolor = BLACK;
622 progress_text = BLACK;
626 text_default = BLACK;
627 highlight_inverse = WHITE ^ BLUE;
628 text_background = WHITE;
629 text_background_hi = LTYELLOW;
630 text_background_noborder_hi = LTGREY;
631 text_background_noborder = -1;
632 text_border1 = DKGREY;
633 text_border2 = BLACK;
634 text_border2_hi = RED;
635 text_border3 = MEGREY;
636 text_border3_hi = LTPINK;
637 text_border4 = WHITE;
638 text_highlight = BLUE;
639 text_inactive_highlight = MEGREY;
641 toggle_highlight_bg = 0;
642 toggle_text_margin = 0;
644 // Delays must all be different for repeaters
648 tooltip_delay = 1000;
649 tooltip_bg_color = YELLOW;
650 tooltips_enabled = 1;
652 filebox_margin = 110;
654 filebox_mode = LISTBOX_TEXT;
655 sprintf(filebox_filter, "*");
658 filebox_columntype[0] = FILEBOX_NAME;
659 filebox_columntype[1] = FILEBOX_SIZE;
660 filebox_columntype[2] = FILEBOX_DATE;
661 filebox_columntype[3] = FILEBOX_EXTENSION;
662 filebox_columnwidth[0] = 200;
663 filebox_columnwidth[1] = 100;
664 filebox_columnwidth[2] = 100;
665 filebox_columnwidth[3] = 100;
666 dirbox_columntype[0] = FILEBOX_NAME;
667 dirbox_columntype[1] = FILEBOX_DATE;
668 dirbox_columnwidth[0] = 200;
669 dirbox_columnwidth[1] = 100;
671 filebox_text_images = default_filebox_text_images;
672 filebox_icons_images = default_filebox_icons_images;
673 filebox_updir_images = default_filebox_updir_images;
674 filebox_newfolder_images = default_filebox_newfolder_images;
675 filebox_rename_images = default_filebox_rename_images;
676 filebox_delete_images = default_filebox_delete_images;
677 filebox_reload_images = default_filebox_reload_images;
678 directory_color = BLUE;
681 filebox_sortcolumn = 0;
682 filebox_sortorder = BC_ListBox::SORT_ASCENDING;
683 dirbox_sortcolumn = 0;
684 dirbox_sortorder = BC_ListBox::SORT_ASCENDING;
687 pot_images = default_pot_images;
689 pot_x1 = pot_images[0]->get_w() / 2 - pot_offset;
690 pot_y1 = pot_images[0]->get_h() / 2 - pot_offset;
692 pot_needle_color = BLACK;
694 progress_images = default_progress_images;
698 meter_font = SMALLFONT_3D;
699 meter_font_color = RED;
702 medium_7segment = default_medium_7segment;
704 audiovideo_color = RED;
708 // Xft has priority over font set
710 // But Xft dies in 32 bit mode after some amount of drawing.
718 recursive_resizing = 1;
723 BC_Resources::~BC_Resources()
727 int BC_Resources::initialize_display(BC_WindowBase *window)
729 // Set up IPC cleanup handlers
732 // Test for shm. Must come before yuv test
738 void BC_Resources::init_shm(BC_WindowBase *window)
741 int (*old_handler)(Display *, XErrorEvent *) =
742 XSetErrorHandler(BC_Resources::x_error_handler);
744 if(XShmQueryExtension(window->display))
746 XShmSegmentInfo test_shm;
747 memset(&test_shm,0,sizeof(test_shm));
748 XImage *test_image = XShmCreateImage(window->display, window->vis,
749 window->default_depth, ZPixmap, (char*)NULL, &test_shm, 5, 5);
750 BC_Resources::error = 0;
751 test_shm.shmid = shmget(IPC_PRIVATE, 5 * test_image->bytes_per_line, (IPC_CREAT | 0600));
752 if(test_shm.shmid != -1) {
753 char *data = (char *)shmat(test_shm.shmid, NULL, 0);
754 if(data != (void *)-1) {
755 shmctl(test_shm.shmid, IPC_RMID, 0);
756 test_shm.shmaddr = data;
757 test_shm.readOnly = 0;
759 if(XShmAttach(window->display, &test_shm)) {
760 XSync(window->display, False);
767 XDestroyImage(test_image);
768 if(BC_Resources::error) use_shm = 0;
770 XSetErrorHandler(old_handler);
776 BC_Synchronous* BC_Resources::get_synchronous()
781 void BC_Resources::set_synchronous(BC_Synchronous *synchronous)
783 this->synchronous = synchronous;
792 int BC_Resources::get_top_border()
794 return display_info->get_top_border();
797 int BC_Resources::get_left_border()
799 return display_info->get_left_border();
802 int BC_Resources::get_right_border()
804 return display_info->get_right_border();
807 int BC_Resources::get_bottom_border()
809 return display_info->get_bottom_border();
813 int BC_Resources::get_bg_color() { return bg_color; }
815 int BC_Resources::get_bg_shadow1() { return bg_shadow1; }
817 int BC_Resources::get_bg_shadow2() { return bg_shadow2; }
819 int BC_Resources::get_bg_light1() { return bg_light1; }
821 int BC_Resources::get_bg_light2() { return bg_light2; }
824 int BC_Resources::get_id()
826 id_lock->lock("BC_Resources::get_id");
832 int BC_Resources::get_filebox_id()
834 id_lock->lock("BC_Resources::get_filebox_id");
835 int result = filebox_id++;
841 void BC_Resources::set_signals(BC_Signals *signal_handler)
843 BC_Resources::signal_handler = signal_handler;
846 int BC_Resources::init_fontconfig(const char *search_path)
848 if( fontlist ) return 0;
849 fontlist = new ArrayList<BC_FontEntry*>;
851 #define get_str(str,sep,ptr,cond) do { char *out = str; \
852 while( *ptr && !strchr(sep,*ptr) && (cond) ) *out++ = *ptr++; \
856 #define skip_str(sep, ptr) do { \
857 while( *ptr && strchr(sep,*ptr) ) ++ptr; \
860 char find_command[BCTEXTLEN];
861 sprintf(find_command,
862 "find %s -name 'fonts.dir' -print -exec cat {} \\;",
864 FILE *in = popen(find_command, "r");
866 FT_Library freetype_library = 0;
867 // FT_Face freetype_face = 0;
868 // FT_Init_FreeType(&freetype_library);
870 char line[BCTEXTLEN], current_dir[BCTEXTLEN];
873 while( !feof(in) && fgets(line, BCTEXTLEN, in) ) {
874 if(!strlen(line)) break;
878 // Get current directory
880 get_str(current_dir, "\n", in_ptr,1);
881 for( int i=strlen(current_dir); --i>=0 && current_dir[i]!='/'; )
886 //printf("TitleMain::build_fonts %s\n", line);
887 BC_FontEntry *entry = new BC_FontEntry;
888 char string[BCTEXTLEN];
890 get_str(string, "\n", in_ptr, in_ptr[0]!=' ' || in_ptr[1]!='-');
891 entry->path = cstrcat(2, current_dir, string);
893 skip_str(" -", in_ptr);
894 get_str(string, " -\n", in_ptr, 1);
895 if( !string[0] ) { delete entry; continue; }
896 entry->foundry = cstrdup(string);
897 if(*in_ptr == '-') in_ptr++;
899 get_str(string, "-\n", in_ptr, 1);
900 if( !string[0] ) { delete entry; continue; }
901 entry->family = cstrdup(string);
902 if(*in_ptr == '-') in_ptr++;
904 get_str(string, "-\n", in_ptr, 1);
905 entry->weight = cstrdup(string);
906 if(*in_ptr == '-') in_ptr++;
908 get_str(string, "-\n", in_ptr, 1);
909 entry->slant = cstrdup(string);
910 if(*in_ptr == '-') in_ptr++;
912 get_str(string, "-\n", in_ptr, 1);
913 entry->swidth = cstrdup(string);
914 if(*in_ptr == '-') in_ptr++;
916 get_str(string, "-\n", in_ptr, 1);
917 entry->adstyle = cstrdup(string);
918 if(*in_ptr == '-') in_ptr++;
920 get_str(string, "-\n", in_ptr, 1);
921 entry->pixelsize = atol(string);
922 if(*in_ptr == '-') in_ptr++;
924 get_str(string, "-\n", in_ptr, 1);
925 entry->pointsize = atol(string);
926 if(*in_ptr == '-') in_ptr++;
928 get_str(string, "-\n", in_ptr, 1);
929 entry->xres = atol(string);
930 if(*in_ptr == '-') in_ptr++;
932 get_str(string, "-\n", in_ptr, 1);
933 entry->yres = atol(string);
934 if(*in_ptr == '-') in_ptr++;
936 get_str(string, "-\n", in_ptr, 1);
937 entry->spacing = cstrdup(string);
938 if(*in_ptr == '-') in_ptr++;
940 get_str(string, "-\n", in_ptr, 1);
941 entry->avg_width = atol(string);
942 if(*in_ptr == '-') in_ptr++;
944 get_str(string, "-\n", in_ptr, 1);
945 entry->registry = cstrdup(string);
946 if(*in_ptr == '-') in_ptr++;
948 get_str(string, "-\n", in_ptr, 1);
949 entry->encoding = cstrdup(string);
950 if(*in_ptr == '-') in_ptr++;
953 //printf("TitleMain::build_fonts 1 %s\n", entry->path);
954 // This takes a real long time to do. Instead just take all fonts
955 // if(!load_freetype_face(freetype_library,
956 // freetype_face, entry->path) )
958 sprintf(line, "%s (%s)", entry->family, entry->foundry);
959 entry->displayname = cstrdup(line);
961 if(!strcasecmp(entry->weight, "demibold")) {
962 entry->fixed_style |= BC_FONT_BOLD;
963 entry->style |= FL_WEIGHT_DEMIBOLD;
965 else if(!strcasecmp(entry->weight, "bold")) {
966 entry->fixed_style |= BC_FONT_BOLD;
967 entry->style |= FL_WEIGHT_BOLD;
970 entry->style |= FL_WEIGHT_NORMAL;
973 if(!strcasecmp(entry->slant, "r")) {
974 entry->style |= FL_SLANT_ROMAN;
976 else if(!strcasecmp(entry->slant, "i")) {
977 entry->style |= FL_SLANT_ITALIC;
978 entry->fixed_style |= BC_FONT_ITALIC;
980 else if(!strcasecmp(entry->slant, "o")) {
981 entry->style |= FL_SLANT_OBLIQUE;
982 entry->fixed_style |= BC_FONT_ITALIC;
985 if(!strcasecmp(entry->swidth, "normal"))
986 entry->style = FL_WIDTH_NORMAL;
987 else if(!strcasecmp(entry->swidth, "ultracondensed"))
988 entry->style = FL_WIDTH_ULTRACONDENSED;
989 else if(!strcasecmp(entry->swidth, "extracondensed"))
990 entry->style = FL_WIDTH_EXTRACONDENSED;
991 else if(!strcasecmp(entry->swidth, "condensed"))
992 entry->style = FL_WIDTH_CONDENSED;
993 else if(!strcasecmp(entry->swidth, "semicondensed"))
994 entry->style = FL_WIDTH_SEMICONDENSED;
995 else if(!strcasecmp(entry->swidth, "semiexpanded"))
996 entry->style = FL_WIDTH_SEMIEXPANDED;
997 else if(!strcasecmp(entry->swidth, "expanded"))
998 entry->style = FL_WIDTH_EXPANDED;
999 else if(!strcasecmp(entry->swidth, "extraexpanded"))
1000 entry->style = FL_WIDTH_EXTRAEXPANDED;
1001 else if(!strcasecmp(entry->swidth, "ultraexpanded"))
1002 entry->style = FL_WIDTH_ULTRAEXPANDED;
1004 entry->style = FL_WIDTH_NORMAL;
1006 fontlist->append(entry);
1007 // printf("TitleMain::build_fonts %s: success\n", entry->path);
1008 //printf("TitleMain::build_fonts 2\n");
1013 // Load all the fonts from fontconfig
1017 FcChar8 *family, *file, *foundry, *style, *format;
1018 int slant, spacing, width, weight;
1019 int force_style = 0;
1020 // if you want limit search to TrueType put 1
1021 int limit_to_trutype = 1;
1024 char tmpstring[BCTEXTLEN];
1027 config = FcConfigGetCurrent();
1028 FcConfigSetRescanInterval(config, 0);
1030 pat = FcPatternCreate();
1031 os = FcObjectSetBuild ( FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT,
1032 FC_WIDTH, FC_SLANT, FC_FONTFORMAT, FC_SPACING, FC_STYLE, (char *) 0);
1033 FcPatternAddBool(pat, FC_SCALABLE, true);
1036 char langstr[LEN_LANG * 3];
1037 strcpy(langstr, language);
1040 strcat(langstr, "-");
1041 strcat(langstr, region);
1044 FcLangSet *ls = FcLangSetCreate();
1045 if(FcLangSetAdd(ls, (const FcChar8*)langstr))
1046 if(FcPatternAddLangSet(pat, FC_LANG, ls))
1047 FcLangSetDestroy(ls);
1050 fs = FcFontList(config, pat, os);
1051 FcPatternDestroy(pat);
1052 FcObjectSetDestroy(os);
1054 for (i = 0; fs && i < fs->nfont; i++) {
1055 FcPattern *font = fs->fonts[i];
1057 FcPatternGetString(font, FC_FONTFORMAT, 0, &format);
1058 //on this point you can limit font search
1059 if(limit_to_trutype && strcmp((char *)format, "TrueType"))
1062 sprintf(tmpstring, "%s", format);
1063 BC_FontEntry *entry = new BC_FontEntry;
1064 if(FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
1065 entry->path = cstrdup((char*)file);
1068 if(FcPatternGetString(font, FC_FOUNDRY, 0, &foundry) == FcResultMatch) {
1069 entry->foundry = cstrdup((char*)foundry);
1072 if(FcPatternGetInteger(font, FC_WEIGHT, 0, &weight) == FcResultMatch) {
1074 case FC_WEIGHT_THIN:
1075 case FC_WEIGHT_EXTRALIGHT:
1076 case FC_WEIGHT_LIGHT:
1077 case FC_WEIGHT_BOOK:
1079 entry->weight = cstrdup("medium");
1082 case FC_WEIGHT_NORMAL:
1083 case FC_WEIGHT_MEDIUM:
1085 entry->weight = cstrdup("medium");
1088 case FC_WEIGHT_BLACK:
1089 case FC_WEIGHT_SEMIBOLD:
1090 case FC_WEIGHT_BOLD:
1091 entry->weight = cstrdup("bold");
1092 entry->fixed_style |= BC_FONT_BOLD;
1095 case FC_WEIGHT_EXTRABOLD:
1096 case FC_WEIGHT_EXTRABLACK:
1098 entry->weight = cstrdup("bold");
1099 entry->fixed_style |= BC_FONT_BOLD;
1104 if(FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch)
1105 entry->family = cstrdup((char*)family);
1107 if(FcPatternGetInteger(font, FC_SLANT, 0, &slant) == FcResultMatch) {
1109 case FC_SLANT_ROMAN:
1111 entry->slant = cstrdup("r");
1112 entry->style |= FL_SLANT_ROMAN;
1114 case FC_SLANT_ITALIC:
1115 entry->slant = cstrdup("i");
1116 entry->style |= FL_SLANT_ITALIC;
1117 entry->fixed_style |= BC_FONT_ITALIC;
1119 case FC_SLANT_OBLIQUE:
1120 entry->slant = cstrdup("o");
1121 entry->style |= FL_SLANT_OBLIQUE;
1122 entry->fixed_style |= BC_FONT_ITALIC;
1127 if(FcPatternGetInteger(font, FC_WIDTH, 0, &width) == FcResultMatch) {
1129 case FC_WIDTH_ULTRACONDENSED:
1130 entry->swidth = cstrdup("ultracondensed");
1133 case FC_WIDTH_EXTRACONDENSED:
1134 entry->swidth = cstrdup("extracondensed");
1137 case FC_WIDTH_CONDENSED:
1138 entry->swidth = cstrdup("condensed");
1140 case FC_WIDTH_SEMICONDENSED:
1141 entry->swidth = cstrdup("semicondensed");
1144 case FC_WIDTH_NORMAL:
1146 entry->swidth = cstrdup("normal");
1149 case FC_WIDTH_SEMIEXPANDED:
1150 entry->swidth = cstrdup("semiexpanded");
1153 case FC_WIDTH_EXPANDED:
1154 entry->swidth = cstrdup("expanded");
1157 case FC_WIDTH_EXTRAEXPANDED:
1158 entry->swidth = cstrdup("extraexpanded");
1161 case FC_WIDTH_ULTRAEXPANDED:
1162 entry->swidth = cstrdup("ultraexpanded");
1167 if(FcPatternGetInteger(font, FC_SPACING, 0, &spacing) == FcResultMatch) {
1171 entry->spacing = cstrdup("p");
1175 entry->spacing = cstrdup("d");
1179 entry->spacing = cstrdup("m");
1183 entry->spacing = cstrdup("c");
1188 // Add fake stuff for compatibility
1189 entry->adstyle = cstrdup(" ");
1190 entry->pixelsize = 0;
1191 entry->pointsize = 0;
1194 entry->avg_width = 0;
1195 entry->registry = cstrdup("utf");
1196 entry->encoding = cstrdup("8");
1198 if(!FcPatternGetString(font, FC_STYLE, 0, &style) == FcResultMatch)
1201 // If font has a style unmanaged by titler plugin, force style to be displayed on name
1202 // in this way we can shown all available fonts styles.
1204 sprintf(tmpstring, "%s (%s)", entry->family, style);
1205 entry->displayname = cstrdup(tmpstring);
1208 if(strcmp(entry->foundry, "unknown")) {
1209 sprintf(tmpstring, "%s (%s)", entry->family, entry->foundry);
1210 entry->displayname = cstrdup(tmpstring);
1213 sprintf(tmpstring, "%s", entry->family);
1214 entry->displayname = cstrdup(tmpstring);
1218 fontlist->append(entry);
1221 FcFontSetDestroy(fs);
1222 if(freetype_library)
1223 FT_Done_FreeType(freetype_library);
1224 // for(int i = 0; i < fonts->total; i++)
1225 // fonts->values[i]->dump();
1227 FcConfigAppFontAddDir(0, (const FcChar8*)search_path);
1228 FcConfigSetRescanInterval(0, 0);
1230 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT,
1231 FC_WIDTH, FC_SLANT, FC_SPACING, FC_STYLE, (char *)0);
1232 pat = FcPatternCreate();
1233 FcPatternAddBool(pat, FC_SCALABLE, true);
1237 char langstr[LEN_LANG * 3];
1238 strcpy(langstr, language);
1242 strcat(langstr, "-");
1243 strcat(langstr, region);
1246 FcLangSet *ls = FcLangSetCreate();
1247 if(FcLangSetAdd(ls, (const FcChar8*)langstr))
1248 if(FcPatternAddLangSet(pat, FC_LANG, ls))
1249 FcLangSetDestroy(ls);
1252 fs = FcFontList(0, pat, os);
1253 FcPatternDestroy(pat);
1254 FcObjectSetDestroy(os);
1256 for(int i = 0; i < fs->nfont; i++)
1258 FcPattern *font = fs->fonts[i];
1259 BC_FontEntry *entry = new BC_FontEntry;
1262 if(FcPatternGetString(font, FC_FILE, 0, &strvalue) == FcResultMatch)
1264 entry->path = new char[strlen((char*)strvalue) + 1];
1265 strcpy(entry->path, (char*)strvalue);
1268 if(FcPatternGetString(font, FC_FOUNDRY, 0, &strvalue) == FcResultMatch)
1270 entry->foundry = new char[strlen((char*)strvalue) + 1];
1271 strcpy(entry->foundry, (char *)strvalue);
1274 if(FcPatternGetString(font, FC_FAMILY, 0, &strvalue) == FcResultMatch)
1276 entry->family = new char[strlen((char*)strvalue) + 2];
1277 strcpy(entry->family, (char*)strvalue);
1281 if(FcPatternGetInteger(font, FC_SLANT, 0, &intvalue) == FcResultMatch)
1285 case FC_SLANT_ROMAN:
1287 entry->style |= FL_SLANT_ROMAN;
1290 case FC_SLANT_ITALIC:
1291 entry->style |= FL_SLANT_ITALIC;
1294 case FC_SLANT_OBLIQUE:
1295 entry->style |= FL_SLANT_OBLIQUE;
1300 if(FcPatternGetInteger(font, FC_WEIGHT, 0, &intvalue) == FcResultMatch)
1304 case FC_WEIGHT_THIN:
1305 entry->style |= FL_WEIGHT_THIN;
1308 case FC_WEIGHT_EXTRALIGHT:
1309 entry->style |= FL_WEIGHT_EXTRALIGHT;
1312 case FC_WEIGHT_LIGHT:
1313 entry->style |= FL_WEIGHT_LIGHT;
1316 case FC_WEIGHT_BOOK:
1317 entry->style |= FL_WEIGHT_BOOK;
1320 case FC_WEIGHT_NORMAL:
1322 entry->style |= FL_WEIGHT_NORMAL;
1325 case FC_WEIGHT_MEDIUM:
1326 entry->style |= FL_WEIGHT_MEDIUM;
1329 case FC_WEIGHT_DEMIBOLD:
1330 entry->style |= FL_WEIGHT_DEMIBOLD;
1333 case FC_WEIGHT_BOLD:
1334 entry->style |= FL_WEIGHT_BOLD;
1337 case FC_WEIGHT_EXTRABOLD:
1338 entry->style |= FL_WEIGHT_EXTRABOLD;
1341 case FC_WEIGHT_BLACK:
1342 entry->style |= FL_WEIGHT_BLACK;
1345 case FC_WEIGHT_EXTRABLACK:
1346 entry->style |= FL_WEIGHT_EXTRABLACK;
1351 if(FcPatternGetInteger(font, FC_WIDTH, 0, &intvalue) == FcResultMatch)
1355 case FC_WIDTH_ULTRACONDENSED:
1356 entry->style |= FL_WIDTH_ULTRACONDENSED;
1359 case FC_WIDTH_EXTRACONDENSED:
1360 entry->style |= FL_WIDTH_EXTRACONDENSED;
1363 case FC_WIDTH_CONDENSED:
1364 entry->style |= FL_WIDTH_CONDENSED;
1367 case FC_WIDTH_SEMICONDENSED:
1368 entry->style = FL_WIDTH_SEMICONDENSED;
1371 case FC_WIDTH_NORMAL:
1373 entry->style |= FL_WIDTH_NORMAL;
1376 case FC_WIDTH_SEMIEXPANDED:
1377 entry->style |= FL_WIDTH_SEMIEXPANDED;
1380 case FC_WIDTH_EXPANDED:
1381 entry->style |= FL_WIDTH_EXPANDED;
1384 case FC_WIDTH_EXTRAEXPANDED:
1385 entry->style |= FL_WIDTH_EXTRAEXPANDED;
1388 case FC_WIDTH_ULTRAEXPANDED:
1389 entry->style |= FL_WIDTH_ULTRAEXPANDED;
1393 if(FcPatternGetInteger(font, FC_SPACING, 0, &intvalue) == FcResultMatch)
1397 case FC_PROPORTIONAL:
1399 entry->style |= FL_PROPORTIONAL;
1403 entry->style |= FL_DUAL;
1407 entry->style |= FL_MONO;
1411 entry->style |= FL_CHARCELL;
1415 if(entry->foundry && strcmp(entry->foundry, "unknown"))
1417 char tempstr[BCTEXTLEN];
1418 sprintf(tempstr, "%s (%s)", entry->family, entry->foundry);
1419 entry->displayname = new char[strlen(tempstr) + 1];
1420 strcpy(entry->displayname, tempstr);
1424 entry->displayname = new char[strlen(entry->family) + 1];
1425 strcpy(entry->displayname, entry->family);
1427 fontlist->append(entry);
1429 FcFontSetDestroy(fs);
1433 BC_FontEntry *BC_Resources::find_fontentry(const char *displayname, int style, int mask)
1435 BC_FontEntry *entry, *style_match, *displayname_match;
1442 for(int i = 0; i < fontlist->total; i++)
1444 entry = fontlist->values[i];
1446 if(strcmp(entry->displayname, displayname) == 0 &&
1447 (entry->style & mask) == style)
1451 // No exact match - assume normal width font
1452 style |= FL_WIDTH_NORMAL;
1453 mask |= FL_WIDTH_MASK;
1454 style_match = 0; displayname_match = 0;
1455 for(int i = 0; i < fontlist->total; i++)
1457 entry = fontlist->values[i];
1459 if(!strncasecmp(displayname, entry->family,
1460 strlen(entry->family)))
1462 if((entry->style & mask) == style)
1464 if(!displayname_match)
1465 displayname_match = entry;
1468 if((entry->style & mask) == style)
1471 style_match = entry;
1474 return displayname_match ? displayname_match : style_match;
1477 size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
1478 char *input, int input_length, char *output, int output_length)
1480 size_t inbytes, outbytes = 0;
1482 char *outbase = output;
1484 if(!from_enc || *from_enc == 0)
1487 if(!to_enc || *to_enc == 0)
1490 if(input_length < 0)
1491 inbytes = strlen(input);
1493 inbytes = input_length;
1495 if(strcmp(from_enc, to_enc) && inbytes)
1497 if((cd = iconv_open(to_enc, from_enc)) == (iconv_t)-1)
1499 printf(_("Conversion from %s to %s is not available"),
1504 outbytes = output_length - 1;
1506 iconv(cd, &input, &inbytes, &output, &outbytes);
1509 inbytes = output - outbase;
1513 memcpy(output, input, inbytes);
1514 outbytes -= inbytes;
1516 for(int i = 0; i < 4; i++)
1525 int BC_Resources::find_font_by_char(FT_ULong char_code, char *path_new, const FT_Face oldface)
1527 FcPattern *font, *ofont;
1533 // Do not search control codes
1537 if( (ofont = FcFreeTypeQueryFace(oldface, (const FcChar8*)"", 4097, 0)) != 0 ) {
1538 if( (font = find_similar_font(char_code, ofont)) != 0 ) {
1539 if(FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
1540 strcpy(path_new, (char*)file);
1543 FcPatternDestroy(font);
1545 FcPatternDestroy(ofont);
1550 FcPattern* BC_Resources::find_similar_font(FT_ULong char_code, FcPattern *oldfont)
1552 FcPattern *pat, *font;
1558 // Do not search control codes
1562 fontconfig_lock.lock("BC_Resources::find_similar_font");
1563 pat = FcPatternCreate();
1564 os = FcObjectSetBuild(FC_FILE, FC_CHARSET, FC_SCALABLE, FC_FAMILY,
1565 FC_SLANT, FC_WEIGHT, FC_WIDTH, (char *)0);
1567 FcPatternAddBool(pat, FC_SCALABLE, true);
1568 fcs = FcCharSetCreate();
1569 if(FcCharSetAddChar(fcs, char_code))
1570 FcPatternAddCharSet(pat, FC_CHARSET, fcs);
1571 FcCharSetDestroy(fcs);
1572 for( int i=0; i<(int)LEN_FCPROP; ++i ) {
1573 if(FcPatternGetInteger(oldfont, fc_properties[i], 0, &ival) == FcResultMatch)
1574 FcPatternAddInteger(pat, fc_properties[i], ival);
1576 fs = FcFontList(0, pat, os);
1577 for( int i=LEN_FCPROP; --i>=0 && !fs->nfont; ) {
1578 FcFontSetDestroy(fs);
1579 FcPatternDel(pat, fc_properties[i]);
1580 fs = FcFontList(0, pat, os);
1582 FcPatternDestroy(pat);
1583 FcObjectSetDestroy(os);
1587 for (int i = 0; i < fs->nfont; i++)
1589 font = fs->fonts[i];
1590 if(FcPatternGetCharSet(font, FC_CHARSET, 0, &fcs) == FcResultMatch)
1592 if(FcCharSetHasChar(fcs, char_code))
1594 pat = FcPatternDuplicate(font);
1599 FcFontSetDestroy(fs);
1600 fontconfig_lock.unlock();
1605 void BC_Resources::dump_fonts(FILE *fp)
1607 for( int i=0; i<fontlist->total; ++i ) {
1608 BC_FontEntry *ep = fontlist->values[i];
1609 fprintf(fp,"%s = %s\n",ep->displayname,ep->path);
1610 fprintf(fp," %s:%s:%s:%s:%s:%s:%d:%d:%d:%d:%d:%s:%d:%s:%s:%d\n",
1611 ep->foundry, ep->family, ep->weight, ep->slant, ep->swidth, ep->adstyle,
1612 ep->pixelsize, ep->pointsize, ep->xres, ep->yres, ep->style, ep->spacing,
1613 ep->avg_width, ep->registry, ep->encoding, ep->fixed_style);