Example #1
0
int
SWFText_getScaledStringWidth(SWFText text, const char *string)
{
	SWFFont font;
	int height;
	unsigned short* widestr;
	int len = strlen(string);
	int n, ret;
	
	if(text->currentRecord == NULL)
		return -1;

	height = text->currentRecord->height;
	widestr = (unsigned short *)malloc(2 * len);

	/* If malloc failed, return -1 to signify this */
	if (NULL == text)
		return -1;

	for(n = 0 ; n < len ; n++)
		widestr[n] = (unsigned char)string[n];

	if ( text->currentRecord->isResolved )
		font = SWFFontCharacter_getFont(text->currentRecord->font.fontchar);
	else
		font = text->currentRecord->font.font;

	ret = SWFFont_getScaledWideStringWidth(font, widestr, len) * height / 1024;
	free(widestr);
	return ret;
}
Example #2
0
int
SWFText_getScaledWideStringWidth(SWFText text, const unsigned short *string)
{
	SWFFont font;
	int height = text->currentRecord->height;
	int len;

	for(len = 0 ; *string ; len++)
		;
	if ( text->currentRecord->isResolved )
		font = SWFFontCharacter_getFont(text->currentRecord->font.fontchar);
	else
		font = text->currentRecord->font.font;

	if ( text->currentRecord->isBrowserFont )
		return 0;
	else
		return SWFFont_getScaledWideStringWidth(font, string, len) * height / 1024;
}
Example #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;
}
Example #4
0
float
SWFFont_getWideStringWidth(SWFFont font, const unsigned short *string, int len)
{
    return SWFFont_getScaledWideStringWidth(font, string, len) / Ming_scale;
}