Ejemplo n.º 1
0
Fl_FontSize *Fl_Font_::load_font(float psize)
{
    Fl_FontSize *f;
    if(cache_xlist()==0) {
        // use variable if no matching font...
        f = new Fl_FontSize("variable");
        f->minsize = 0;
        f->maxsize = 32767;
    } else {
        unsigned size = unsigned(psize);
	char *name = 0;
        if (name_ && name_[strlen(name_)-1] != '*') {
            name = find_direct_font(name_, size);
        } else {
            name = find_best_font(this, name_, size);
        }
        // okay, make the font:
        f = new Fl_FontSize(name);
        const char *enc = font_word(name, 13);
        if(enc && *enc++) {
            f->encoding_num = fl_encoding_number(enc);
        }
        f->minsize = size;
        f->maxsize = size;
    }

    if(f->encoding_num==-1)
        f->encoding_num = 1; //ISO8859-1

    f->encoding = fl_encoding_;

    f->next = first;
    first = f;
    return f;
}
Ejemplo n.º 2
0
static void 
load_fonts(
	Display 		*dpy, 
	XUtf8FontStruct	*font_set) 
{
	int i;
	char **list;

	i = 0;
	list = NULL;

	font_set->fonts = (XFontStruct**) 
		malloc(sizeof(XFontStruct*) * font_set->nb_font);
	
	font_set->ranges = (int*) 
		malloc(sizeof(int) *  font_set->nb_font * 2);

	font_set->descent = 0;
	font_set->ascent = 0;
	font_set->fid = 0;

	while (i < font_set->nb_font) {
		XFontStruct *fnt;

		fnt = font_set->fonts[i] = 
			find_best_font(dpy, &(font_set->font_name_list[i]));
		if (fnt) {
			font_set->fid = fnt->fid;
			if (fnt->ascent > font_set->ascent) {
				font_set->ascent = fnt->ascent;
			}
			if (fnt->descent > font_set->descent) {
				font_set->descent = fnt->descent;
			}
		} else {
			free(font_set->font_name_list[i]);
			font_set->font_name_list[i] = NULL;
		}
		i++;
	}

	font_set->encodings = 
		get_encodings(font_set->font_name_list, 
			font_set->ranges, font_set->nb_font);

	/* unload fonts with same encoding */
	for (i = 0; i < font_set->nb_font; i++) {
		if (font_set->font_name_list[i]) {
			int j;
			for (j = 0; j < i; j++) {
				if (font_set->font_name_list[j] &&
					font_set->encodings[j] ==
					font_set->encodings[i] &&
					font_set->ranges[2*j] ==
					font_set->ranges[2*i] &&
					font_set->ranges[(2*j)+1] &&
					font_set->ranges[(2*i)+1]) 
				{
	                       		XFreeFont(dpy, font_set->fonts[i]);
                        		free(font_set->font_name_list[i]);
					font_set->font_name_list[i] = NULL;
					font_set->fonts[i] = 0;
				}
			}
		}
	} 
}