Esempio n. 1
0
WMFont*
WMCreateFont(WMScreen *scrPtr, char *fontName)
{
    WMFont *font;
    Display *display = scrPtr->display;
    char *fname, *ptr;

    /* This is for back-compat (to allow reading of old xlfd descriptions) */
    if (fontName[0]=='-' && (ptr = strchr(fontName, ','))) {
        // warn for deprecation
        fname = wmalloc(ptr - fontName + 1);
        strncpy(fname, fontName, ptr - fontName);
        fname[ptr - fontName] = 0;
    } else {
        fname = wstrdup(fontName);
    }

    font = WMHashGet(scrPtr->fontCache, fname);
    if (font) {
        WMRetainFont(font);
        wfree(fname);
        return font;
    }

    font = wmalloc(sizeof(WMFont));
    memset(font, 0, sizeof(WMFont));

    font->screen = scrPtr;

    // remove
    printf("WMCreateFont: %s\n", fname);

    if (fname[0] == '-') {
        // Backward compat thing. Remove in a later version
        font->font = XftFontOpenXlfd(display, scrPtr->screen, fname);
    } else {
        font->font = XftFontOpenName(display, scrPtr->screen, fname);
    }
    if (!font->font) {
        wfree(font);
        wfree(fname);
        return NULL;
    }
    font->height = font->font->ascent+font->font->descent;
    font->y = font->font->ascent;

    font->refCount = 1;

    font->name = fname;

    assert(WMHashInsert(scrPtr->fontCache, font->name, font)==NULL);

    return font;
}
Esempio n. 2
0
void WMSetBalloonTextForView(const char *text, WMView * view)
{
	char *oldText = NULL;
	WMScreen *scr = view->screen;

	if (text) {
		oldText = WMHashInsert(scr->balloon->table, view, wstrdup(text));
	} else {
		oldText = WMHashGet(scr->balloon->table, view);

		WMHashRemove(scr->balloon->table, view);
	}

	if (oldText) {
		wfree(oldText);
	}
}