Пример #1
0
Файл: glc.c Проект: cout/mglc
/* Mark for deletion GLC context c.
 * FIX ME!! If no client is using the GLC context, then we should delete the 
 * context immediately.  This requires adding thread support.
 */
void glcDeleteContext(GLint c) {
	int i, j;

	if(!glcIsContext(c)) {
		last_error = GLC_PARAMETER_ERROR;
		return;
	}

	/* Find this context in the list */
	for(j = 0; glcContextList[j] != 0; j++)
		if(glcContextList[j] == c) break;

	/* Delete all fonts in this context */
	for(i = glcContexts[c].num_fonts-1; i > 0; i--)
		glcDeleteFont(i);

	/* Delete the GL lists we are using */
	glDeleteLists(g->list_base, 256);

	/* Mark this context as unused */
	glcContexts[j].isContext = FALSE;

	/* Delete this context from the list */
	for(; glcContextList[j] != 0; j++)
		glcContextList[j] = glcContextList[j + 1];
}
Пример #2
0
void iV_TextShutdown()
{
	if (_glcFont_Regular)
	{
		glcDeleteFont(_glcFont_Regular);
	}

	if (_glcFont_Bold)
	{
		glcDeleteFont(_glcFont_Bold);
	}

	glcContext(0);

	if (_glcContext)
	{
		glcDeleteContext(_glcContext);
	}
}
Пример #3
0
void hack_init (xstuff_t * XStuff)
{
  //Load the fonts for printing debug info to the window.
#ifdef HAVE_GLC
  glc_ctx = glcGenContext ();
  glcContext (glc_ctx);

  for (unsigned int ii = 0; ii < FONT_COUNT; ii++) {
    fonts[ii].id = glcGenFontID();
    if (glcNewFontFromFamily(fonts[ii].id, fonts[ii].name) != fonts[ii].id) {
printf("%s\n", fonts[ii].name);
      glcDeleteFont(fonts[ii].id);
      fonts[ii].id = 0;
    }
  }

  glcScale (FONT_SIZE, FONT_SIZE);
#endif

  hack_reshape (XStuff);

  TextureInit ();
  WorldInit ();
}
Пример #4
0
Файл: glc.c Проект: cout/mglc
/* Beginning with the first element of the GLC master list, find the first
 * master whose string attribute GLC_FAMILY equals inFamily.  We do not
 * implement masters, so we simulate this behaviour using the X font server's
 * list of fonts as our list of masters.  Return fontnum on success, or
 * zero otherwise.
 */
GLint glcNewFontFromFamily(GLint fontnum, const char *s) {
	char **xfontlist;
	int fontlen = strlen(s);
	char *fontname;
	int num_fonts;
	int font, our_font[NUM_GLC_STYLES];
	int i, j;
	char *t;
	int font_can_transform = TRUE;

#ifdef DEBUG
	fprintf(stderr, "glcNewFontFromFamily(%d, \"%s\")\n", fontnum, s);
#endif

	if(currentGlcContext == 0) {
		last_error = GLC_STATE_ERROR;
		return 0;
	}

	/* Get a list of fonts from the X server that match this font family,
	 * giving precedence to adobe fonts.
	 */
	fontname = (char*)malloc(fontlen+1024);
	sprintf(fontname, "-adobe-%s-*-*-*-*-[1 0 0 1]-0-*-*-*-*-*-*", s);
	xfontlist = XListFonts(g->display, fontname, 1000, &num_fonts);
	if(num_fonts == 0) {
		sprintf(fontname, "-*-%s-*-*-*-*-[1 0 0 1]-0-*-*-*-*-*-*", s);
		xfontlist = XListFonts(g->display, fontname, 1000, &num_fonts);
		if(num_fonts == 0) {
			font_can_transform = FALSE;
			sprintf(fontname, "-*-%s-*-*-*-*-0-0-*-*-*-*-*-*", s);
			xfontlist = XListFonts(g->display, fontname, 1000, &num_fonts);
			if(num_fonts == 0) {
				for(j = 0; j < NUM_GLC_STYLES; j++)
					g->fonts[fontnum][j].isFont = FALSE;
#ifdef DEBUG
				fprintf(stderr, "No X fonts found for request %s.\n", fontname);
#endif
				free(fontname);
				return 0;
			}
		}
	}
	free(fontname);

	/* Determine which fonts in this family have the faces we are looking
	 * for.  We search the structure upside-down, because fonts that
	 * come first should take precedence.
	 */
	for(j = 0; j < NUM_GLC_STYLES; j++) our_font[j] = INT_MAX;
	for(font = num_fonts-1; font >= 0; font--) {
		if(strstr(xfontlist[font], "medium-r")) {
			our_font[GLC_STYLE_NORMAL] = font;
		} else if(strstr(xfontlist[font], "bold-r")) {
			our_font[GLC_STYLE_BOLD] = font;
		} else if(strstr(xfontlist[font], "medium-i")) {
			our_font[GLC_STYLE_ITALIC] = font;
		} else if(strstr(xfontlist[font], "bold-i")) {
			our_font[GLC_STYLE_BOLD_ITALIC] = font;
		}
	}

	/* Set the font information in the GLC context */
	for(j = 0; j < NUM_GLC_STYLES; j++) {
		if(our_font[j] != INT_MAX) {
			if(g->fonts[fontnum][j].isFont) glcDeleteFont(fontnum);
			g->fonts[fontnum][j].xfont = XLoadFont(g->display, xfontlist[our_font[j]]);
			g->fonts[fontnum][j].isFont = TRUE;
			g->fonts[fontnum][j].name = strdup(s);
			g->fonts[fontnum][j].xfontprefix = strdup(xfontlist[our_font[j]]);
			for(t = g->fonts[fontnum][j].xfontprefix,i=0; *t != 0 && i < 7; t++)
				if(*t == '-') i++;
			if(*t != 0) {
				*(t-1) = 0;
				for(t++; *t != 0 && i < 8; t++) if(*t == '-') i++;
			}
			g->fonts[fontnum][j].xfontsuffix = t;
			g->fonts[fontnum][j].can_transform = font_can_transform;
			g->fonts[fontnum][j].xfontinfo = NULL;
			g->fonts[fontnum][j].xfont = 0;
#ifdef DEBUG
			fprintf(stderr, "Using font %s-[1 0 0 1]-%s\n",
				g->fonts[fontnum][j].xfontprefix,
				g->fonts[fontnum][j].xfontsuffix);
#endif
		} else {
			g->fonts[fontnum][j].isFont = FALSE;
#ifdef DEBUG
			fprintf(stderr, "Not using font style %d.\n", j);
#endif
		}
	}

	/* Free the list of fonts and return */
	XFreeFontNames(xfontlist);
	return fontnum;
}