Example #1
0
/* old LoadFont.c*/
Font
XLoadFont(Display * dpy, _Xconst char *name)
{
 	GR_FONT_ID font = 0;
	int height;
	char *fontname;

DPRINTF("XLoadFont('%s')\n", name);
	/* first try to find XLFD or fontname from X11/fonts.dir and fonts.alias files*/
	fontname = font_findfont((char *)name, 0, 0, &height);
	if(fontname) {
#if HAVE_STATICFONTS
		int size;
		unsigned char *data;

		/* check static font list*/
		if (font_staticGetBufferInfo(fontname, &data, &size))
			font = GrCreateFontFromBuffer(data, size, "TTF", height, height);
		else
#endif
 		font = GrCreateFontEx(fontname, height, height, NULL);
	} else if (!strcmp(name, "fixed")) {
DPRINTF("XLoadFont: mapping 'fixed' to builtin SystemFixed\n");
		/* special-case handle 'fixed' and map to builtin system fixed font*/
		fontname = strdup(MWFONT_SYSTEM_FIXED);
		height = 13;
		font = GrCreateFontEx(fontname, 0, 0, NULL); /* height zero to force builtin lookup by name*/
	}
    GrSetFontAttr(font, GR_TFKERNING | GR_TFANTIALIAS, 0);
DPRINTF("XLoadFont('%s') = '%s' height %d [%d]\n", name, fontname, height, font);
	if (fontname)
		Xfree(fontname);
	return font;
}
Example #2
0
static void
GrCreateFontFromBufferWrapper(void *r)
{
#if HAVE_FREETYPE_2_SUPPORT
	imagelist_t *buffer;
	nxCreateFontFromBufferReq *req = r;
	GR_FONT_ID result;
	
	buffer = findImageBuffer(req->buffer_id);
	if (!buffer) {
		result = 0;
	} else {
		result = GrCreateFontFromBuffer(buffer->data, buffer->size,
			(const char *)req->format, req->height, req->width);
		
		freeImageBuffer(buffer);
	}
	
	GsWriteType(current_fd, GrNumCreateFontFromBuffer);
	GsWrite(current_fd, &result, sizeof(result));
#endif /*HAVE_FREETYPE_2_SUPPORT*/
}