⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fontxlfd.c

📁 unix vnc 协议源码. VNC是一款远程控制工具软件.
💻 C
📖 第 1 页 / 共 2 页
字号:
		    if (which == POINTSIZE_MASK)			vals->values_supplied |= POINTSIZE_ARRAY;		    else			vals->values_supplied |= PIXELSIZE_ARRAY;		}		else ptr = (char *)0;	    }	}    }    else    {	int value;	if (ptr = GetInt(ptr, &value))	{	    vals->values_supplied &= ~which;	    if (value > 0)	    {		matrix[3] = (double)value;		if (which == POINTSIZE_MASK)		{		    matrix[3] /= 10.0;		    vals->values_supplied |= POINTSIZE_SCALAR;		}		else		    vals->values_supplied |= PIXELSIZE_SCALAR;		/* If we're concocting the pixelsize array from a scalar,		   we will need to normalize element 0 for the pixel shape.		   This is done in FontFileCompleteXLFD(). */		matrix[0] = matrix[3];		matrix[1] = matrix[2] = 0.0;	    }	    else if (value < 0)	    {		if (which == POINTSIZE_MASK)		    vals->values_supplied |= POINTSIZE_WILDCARD;		else		    vals->values_supplied |= PIXELSIZE_WILDCARD;	    }	}    }    return ptr;}static void append_ranges(fname, nranges, ranges)char *fname;int nranges;fsRange *ranges;{    if (nranges)    {        int i;        strcat(fname, "[");        for (i = 0; i < nranges && strlen(fname) < 1010; i++)        {	    if (i) strcat(fname, " ");	    sprintf(fname + strlen(fname), "%d",		    minchar(ranges[i]));	    if (ranges[i].min_char_low ==	        ranges[i].max_char_low &&	        ranges[i].min_char_high ==	        ranges[i].max_char_high) continue;	    sprintf(fname + strlen(fname), "_%d",		    maxchar(ranges[i]));        }        strcat(fname, "]");    }}BoolFontParseXLFDName(fname, vals, subst)    char       *fname;    FontScalablePtr vals;    int         subst;{    register char *ptr;    register char *ptr1,               *ptr2,               *ptr3,               *ptr4;    register char *ptr5;    FontScalableRec tmpvals;    char        replaceChar = '0';    char        tmpBuf[1024];    int         spacingLen;    int		l;    char	*p;    bzero(&tmpvals, sizeof(tmpvals));    if (subst != FONT_XLFD_REPLACE_VALUE)	*vals = tmpvals;    if (!(*(ptr = fname) == '-' || *ptr++ == '*' && *ptr == '-') ||  /* fndry */	    !(ptr = strchr(ptr + 1, '-')) ||	/* family_name */	    !(ptr1 = ptr = strchr(ptr + 1, '-')) ||	/* weight_name */	    !(ptr = strchr(ptr + 1, '-')) ||	/* slant */	    !(ptr = strchr(ptr + 1, '-')) ||	/* setwidth_name */	    !(ptr = strchr(ptr + 1, '-')) ||	/* add_style_name */	    !(ptr = strchr(ptr + 1, '-')) ||	/* pixel_size */	    !(ptr = GetMatrix(ptr + 1, &tmpvals, PIXELSIZE_MASK)) ||	    !(ptr2 = ptr = GetMatrix(ptr + 1, &tmpvals, POINTSIZE_MASK)) ||	    !(ptr = GetInt(ptr + 1, &tmpvals.x)) ||	/* resolution_x */	    !(ptr3 = ptr = GetInt(ptr + 1, &tmpvals.y)) ||  /* resolution_y */	    !(ptr4 = ptr = strchr(ptr + 1, '-')) ||	/* spacing */	    !(ptr5 = ptr = GetInt(ptr + 1, &tmpvals.width)) || /* average_width */	    !(ptr = strchr(ptr + 1, '-')) ||	/* charset_registry */	    strchr(ptr + 1, '-'))/* charset_encoding */	return FALSE;    /* Lop off HP charset subsetting enhancement.  Interpreting this       field requires allocating some space in which to return the       results.  So, to prevent memory leaks, this procedure will simply       lop off and ignore charset subsetting, and initialize the       relevant vals fields to zero.  It's up to the caller to make its       own call to FontParseRanges() if it's interested in the charset       subsetting.  */    if (subst != FONT_XLFD_REPLACE_NONE &&	(p = strchr(strrchr(fname, '-'), '[')))    {	tmpvals.values_supplied |= CHARSUBSET_SPECIFIED;	*p = '\0';    }    /* Fill in deprecated fields for the benefit of rasterizers that care       about them. */    tmpvals.pixel = (tmpvals.pixel_matrix[3] >= 0) ?		    (int)(tmpvals.pixel_matrix[3] + .5) :		    (int)(tmpvals.pixel_matrix[3] - .5);    tmpvals.point = (tmpvals.point_matrix[3] >= 0) ?                    (int)(tmpvals.point_matrix[3] * 10 + .5) :                    (int)(tmpvals.point_matrix[3] * 10 - .5);    spacingLen = ptr4 - ptr3 + 1;    switch (subst) {    case FONT_XLFD_REPLACE_NONE:	*vals = tmpvals;	break;    case FONT_XLFD_REPLACE_STAR:	replaceChar = '*';    case FONT_XLFD_REPLACE_ZERO:	strcpy(tmpBuf, ptr2);	ptr5 = tmpBuf + (ptr5 - ptr2);	ptr3 = tmpBuf + (ptr3 - ptr2);	ptr2 = tmpBuf;	ptr = ptr1 + 1;	ptr = strchr(ptr, '-') + 1;		/* skip weight */	ptr = strchr(ptr, '-') + 1;		/* skip slant */	ptr = strchr(ptr, '-') + 1;		/* skip setwidth_name */	ptr = strchr(ptr, '-') + 1;		/* skip add_style_name */	if ((ptr - fname) + spacingLen + strlen(ptr5) + 10 >= (unsigned)1024)	    return FALSE;	*ptr++ = replaceChar;	*ptr++ = '-';	*ptr++ = replaceChar;	*ptr++ = '-';	*ptr++ = '*';	*ptr++ = '-';	*ptr++ = '*';	if (spacingLen > 2)	{	    memmove(ptr, ptr3, spacingLen);	    ptr += spacingLen;	}	else	{	    *ptr++ = '-';	    *ptr++ = '*';	    *ptr++ = '-';	}	*ptr++ = replaceChar;	strcpy(ptr, ptr5);	*vals = tmpvals;	break;    case FONT_XLFD_REPLACE_VALUE:	if (vals->values_supplied & PIXELSIZE_MASK)	{	    tmpvals.values_supplied =		(tmpvals.values_supplied & ~PIXELSIZE_MASK) |		(vals->values_supplied & PIXELSIZE_MASK);	    tmpvals.pixel_matrix[0] = vals->pixel_matrix[0];	    tmpvals.pixel_matrix[1] = vals->pixel_matrix[1];	    tmpvals.pixel_matrix[2] = vals->pixel_matrix[2];	    tmpvals.pixel_matrix[3] = vals->pixel_matrix[3];	}	if (vals->values_supplied & POINTSIZE_MASK)	{	    tmpvals.values_supplied =		(tmpvals.values_supplied & ~POINTSIZE_MASK) |		(vals->values_supplied & POINTSIZE_MASK);	    tmpvals.point_matrix[0] = vals->point_matrix[0];	    tmpvals.point_matrix[1] = vals->point_matrix[1];	    tmpvals.point_matrix[2] = vals->point_matrix[2];	    tmpvals.point_matrix[3] = vals->point_matrix[3];	}	if (vals->x >= 0)	    tmpvals.x = vals->x;	if (vals->y >= 0)	    tmpvals.y = vals->y;	if (vals->width >= 0)	    tmpvals.width = vals->width;	else if (vals->width < -1)	/* overload: -1 means wildcard */	    tmpvals.width = -vals->width;	p = ptr1 + 1;				/* weight field */	l = strchr(p, '-') - p;	sprintf(tmpBuf, "%*.*s", l, l, p);	p += l + 1;				/* slant field */	l = strchr(p, '-') - p;	sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);	p += l + 1;				/* setwidth_name */	l = strchr(p, '-') - p;	sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);	p += l + 1;				/* add_style_name field */	l = strchr(p, '-') - p;	sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);	strcat(tmpBuf, "-");	if ((tmpvals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY)	{	    char buffer[80];	    strcat(tmpBuf, "[");	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[0],		   buffer, 0));	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[1],		   buffer, 1));	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[2],		   buffer, 1));	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[3],		   buffer, 1));	    strcat(tmpBuf, "]");	}	else	{	    sprintf(tmpBuf + strlen(tmpBuf), "%d",		    (int)(tmpvals.pixel_matrix[3] + .5));	}	strcat(tmpBuf, "-");	if ((tmpvals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY)	{	    char buffer[80];	    strcat(tmpBuf, "[");	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[0],		   buffer, 0));	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[1],		   buffer, 1));	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[2],		   buffer, 1));	    strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[3],		   buffer, 1));	    strcat(tmpBuf, "]");	}	else	{	    sprintf(tmpBuf + strlen(tmpBuf), "%d",		    (int)(tmpvals.point_matrix[3] * 10.0 + .5));	}	sprintf(tmpBuf + strlen(tmpBuf), "-%d-%d%*.*s%d%s",		tmpvals.x, tmpvals.y,		spacingLen, spacingLen, ptr3, tmpvals.width, ptr5);	strcpy(ptr1 + 1, tmpBuf);	if ((vals->values_supplied & CHARSUBSET_SPECIFIED) && !vals->nranges)	    strcat(fname, "[]");	else	    append_ranges(fname, vals->nranges, vals->ranges);	break;    }    return TRUE;}fsRange *FontParseRanges(name, nranges)char *name;int *nranges;{    int n;    unsigned long l;    char *p1, *p2;    fsRange *result = (fsRange *)0;    name = strchr(name, '-');    for (n = 1; name && n < 14; n++)	name = strchr(name + 1, '-');    *nranges = 0;    if (!name || !(p1 = strchr(name, '['))) return (fsRange *)0;    p1++;    while (*p1 && *p1 != ']')    {	fsRange thisrange;	l = strtol(p1, &p2, 0);	if (p2 == p1 || l > 0xffff) break;	thisrange.max_char_low = thisrange.min_char_low = l & 0xff;	thisrange.max_char_high = thisrange.min_char_high = l >> 8;	p1 = p2;	if (*p1 == ']' || *p1 == ' ')	{	    while (*p1 == ' ') p1++;	    if (add_range(&thisrange, nranges, &result, TRUE) != Successful)		break;	}	else if (*p1 == '_')	{	    l = strtol(++p1, &p2, 0);	    if (p2 == p1 || l > 0xffff) break;	    thisrange.max_char_low = l & 0xff;	    thisrange.max_char_high = l >> 8;	    p1 = p2;	    if (*p1 == ']' || *p1 == ' ')	    {		while (*p1 == ' ') p1++;		if (add_range(&thisrange, nranges, &result, TRUE) != Successful)		    break;	    }	}	else break;    }    return result;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -