示例#1
0
文件: text.c 项目: akleine/libming
void
SWFText_addUTF8String(SWFText text, const char* string, int* advance)
{
	unsigned short* widestring;
	int len = UTF8ExpandString(string, &widestring);

	SWFTextRecord textRecord = text->currentRecord;

	/* marginally sloppy to tack on a new record,
		 but I don't want to deal with concats */

	if ( textRecord == NULL || textRecord->string != NULL )
		textRecord = SWFText_addTextRecord(text);

	/* If SWFText_addTextRecord() failed, return early */
	if (NULL == textRecord)
		return;

	if ( textRecord->font.font == NULL )
		SWF_error("font must be set before calling addString");

	textRecord->advance = advance;
	textRecord->strlen = len;
	textRecord->string = widestring;
}
示例#2
0
void
SWFTextField_addUTF8Chars(SWFTextField field, const char *string)
{
	unsigned short *widestring;
	int n, len;
	if(field->fonttype == FontChar || field->fonttype == Font)
	{	len = UTF8ExpandString(string, &widestring);
		field->embeds = (unsigned short *)realloc(
			field->embeds, (field->embedlen + len) * 2);
		for(n = 0 ; n < len  ; n++)
			field->embeds[field->embedlen++] = widestring[n];
		free(widestring);
	}
}
示例#3
0
int
SWFText_getScaledUTF8StringWidth(SWFText text, const char *string)
{
	SWFFont font;
	int height = text->currentRecord->height;
	unsigned short* widestr;
	int len, ret;

	len = UTF8ExpandString(string, &widestr);
	if ( text->currentRecord->isResolved )
		font = SWFFontCharacter_getFont(text->currentRecord->font.fontchar);
	else
		font = text->currentRecord->font.font;

	if ( text->currentRecord->isBrowserFont )
		ret = 0;
	else
		ret = SWFFont_getScaledWideStringWidth(font, widestr, len) * height / 1024;
	free(widestr);
	return ret;
}