Beispiel #1
0
Exec_stat MCF_unparsetextatts(Properties which, uint4 flags, MCStringRef name, uint2 height, uint2 size, uint2 style, MCValueRef &r_result)
{
	switch (which)
	{
	case P_TEXT_ALIGN:
		switch (flags & F_ALIGNMENT)
		{
		case F_ALIGN_LEFT:
            r_result = MCSTR(MCleftstring);
            break;
		case F_ALIGN_CENTER:
			r_result = MCSTR(MCcenterstring);
			break;
		case F_ALIGN_RIGHT:
			r_result = MCSTR(MCrightstring);
			break;
		case F_ALIGN_JUSTIFY:
			r_result = MCSTR(MCjustifystring);
            break;
		}
		break;
	case P_TEXT_FONT:
        r_result = MCValueRetain(name);
		break;
	case P_TEXT_HEIGHT:
        {
        MCAutoNumberRef t_height;
        /* UNCHECKED */ MCNumberCreateWithUnsignedInteger(height, &t_height);
        r_result = MCValueRetain(*t_height);
		break;
        }
	case P_TEXT_SIZE:
        {
        MCAutoNumberRef t_size;
        /* UNCHECKED */ MCNumberCreateWithUnsignedInteger(size, &t_size);
            r_result = MCValueRetain(*t_size);
		break;
        }
	case P_TEXT_STYLE:
		{
			if (style == FA_DEFAULT_STYLE)
			{
                r_result = MCSTR(MCplainstring);
				return ES_NORMAL;
			}

			if (r_result != nil)
                MCValueRelease(r_result);
            MCAutoListRef t_list;
            /* UNCHECKED */ MCListCreateMutable(',', &t_list);
			if (MCF_getweightint(style) != MCFW_MEDIUM)
                MCListAppendCString(*t_list, MCF_getweightstring(style));
			if (style & FA_ITALIC || style & FA_OBLIQUE)
                MCListAppendCString(*t_list, MCF_getslantlongstring(style));
			if (style & FA_BOX)
                MCListAppendCString(*t_list, MCboxstring);
			if (style & FA_3D_BOX)
                MCListAppendCString(*t_list, MCthreedboxstring);
			if (style & FA_UNDERLINE)
                MCListAppendCString(*t_list, MCunderlinestring);
			if (style & FA_STRIKEOUT)
                MCListAppendCString(*t_list, MCstrikeoutstring);
			if (style & FA_LINK)
                MCListAppendCString(*t_list, MClinkstring);
			if (MCF_getexpandint(style) != FE_NORMAL)
                MCListAppendCString(*t_list, MCF_getexpandstring(style));
            
            MCAutoStringRef t_string;
            /* UNCHECKED */ MCListCopyAsString(*t_list, &t_string);
            r_result = MCValueRetain(*t_string);
		}
		break;
	default:
		break;
	}
	return ES_NORMAL;
}
Beispiel #2
0
MCOldFontnode::MCOldFontnode(const MCString &fname, uint2 &size, uint2 style)
{
	char fontname[XLFD_LENGTH];

	uint4 length = fname.getlength();
	reqname = new char[length + 1];
	MCU_lower(reqname, fname);
	reqname[length] = '\0';
	reqsize = size;
	reqstyle = style;
	
	uint2 t_original_size;
	t_original_size = size;
	
	XFontStruct *fs = NULL;
	
	memset(&font, 0, sizeof(MCFontStruct));
	
	font.charset = 0;
	if (MCnoui)
		return;

		Boolean t_is_unicode = False;

		// MW-2005-02-08: We aren't going to use XMBTEXT for now, instead we will
		//   search for an appropriate ISO10646 font if in 'encoding mode'.
		if (strchr(reqname, ',') != NULL)
		{
			sprintf(fontname, "-*-%.*s-%s-%s-%s--%d-*-*-*-*-*-iso10646-*",
			        strchr(reqname, ',') - reqname, reqname, MCF_getweightstring(style),
			        MCF_getslantshortstring(style),
			        MCF_getexpandstring(style), size);
			t_is_unicode = True;
		}
		else
			sprintf(fontname, "-*-%s-%s-%s-%s--%d-*-*-*-*-*-iso8859-%d",
			        reqname, MCF_getweightstring(style),
			        MCF_getslantshortstring(style),
			        MCF_getexpandstring(style), size, MCcharset);
		
		if ((fs = XLoadQueryFont(MCdpy, fontname)) == NULL)
			fs = lookup(reqname, size, style);
		else
			font.unicode = t_is_unicode;

		if (fs == NULL)
			if ((fs = XLoadQueryFont(MCdpy, reqname)) != NULL)
			{
				if (pixelsize == 0)
					pixelsize = XInternAtom(MCdpy, "PIXEL_SIZE", True);
				uint2 i = fs->n_properties;
				while (i--)
					if (fs->properties[i].name == pixelsize)
					{
						size = reqsize = fs->properties[i].card32;
						break;
					}
				size = reqsize = fs->ascent + fs->descent - 2;
			}

		if (fs == NULL)
			fs = lookup(DEFAULT_TEXT_FONT, size, style);
		if (fs == NULL)
			fs = XLoadQueryFont(MCdpy, "fixed");

	
		font.reqname = strdup(reqname) ;
		font.reqsize = reqsize ;
		font.reqstyle = reqstyle ;
	
		font.fstruct = fs;
		font.max_byte1 = fs -> max_byte1;

		font.ascent = fs -> ascent;
		font.descent = fs -> descent;

		font.unicode = t_is_unicode;
		if (t_is_unicode)
			font.charset = LCH_UNICODE;
}
Beispiel #3
0
Exec_stat MCF_unparsetextatts(Properties which, MCExecPoint &ep, uint4 flags,
                              const char *name, uint2 height, uint2 size,
                              uint2 style)
{
	switch (which)
	{
	case P_TEXT_ALIGN:
		switch (flags & F_ALIGNMENT)
		{
		case F_ALIGN_LEFT:
			ep.setstaticcstring(MCleftstring);
			break;
		case F_ALIGN_CENTER:
			ep.setstaticcstring(MCcenterstring);
			break;
		case F_ALIGN_RIGHT:
			ep.setstaticcstring(MCrightstring);
			break;
		case F_ALIGN_JUSTIFY:
			ep.setstaticcstring(MCjustifystring);
			break;
		}
		break;
	case P_TEXT_FONT:
		ep.setsvalue(name);
		break;
	case P_TEXT_HEIGHT:
		ep.setint(height);
		break;
	case P_TEXT_SIZE:
		ep.setint(size);
		break;
	case P_TEXT_STYLE:
		{
			if (style == FA_DEFAULT_STYLE)
			{
				ep.setstaticcstring(MCplainstring);
				return ES_NORMAL;
			}
			
			uint32_t j;
			j = 0;

			ep.clear();
			if (MCF_getweightint(style) != MCFW_MEDIUM)
				ep.concatcstring(MCF_getweightstring(style), EC_COMMA, j++ == 0);
			if (style & FA_ITALIC || style & FA_OBLIQUE)
				ep.concatcstring(MCF_getslantlongstring(style), EC_COMMA, j++ == 0);
			if (style & FA_BOX)
				ep.concatcstring(MCboxstring, EC_COMMA, j++ == 0);
			if (style & FA_3D_BOX)
				ep.concatcstring(MCthreedboxstring, EC_COMMA, j++ == 0);
			if (style & FA_UNDERLINE)
				ep.concatcstring(MCunderlinestring, EC_COMMA, j++ == 0);
			if (style & FA_STRIKEOUT)
				ep.concatcstring(MCstrikeoutstring, EC_COMMA, j++ == 0);
			if (style & FA_LINK)
				ep.concatcstring(MClinkstring, EC_COMMA, j++ == 0);
			if (MCF_getexpandint(style) != FE_NORMAL)
				ep.concatcstring(MCF_getexpandstring(style), EC_COMMA, j++ == 0);
		}
		break;
	default:
		break;
	}
	return ES_NORMAL;
}