コード例 #1
0
ファイル: swfDevice.c プロジェクト: yixuan/R2SWF-archive
/* TODO: respect hadj */
void swfTextUTF8(double x, double y, const char *str, double rot, double hadj, const pGEcontext gc, pDevDesc dd)
{
#ifdef SWF_DEBUG
    Rprintf("textUTF8 called\n");
    Rprintf("** family = %s, font = %d\n", gc->fontfamily, gc->fontface);
    Rprintf("** textUTF8(str[0] = %d, str[1] = %d, str[2] = %d, str[3] = %d)\n",
            str[0], str[1], str[2], str[3]);
#endif
    pswfDesc swfInfo = (pswfDesc) dd->deviceSpecific;
    SWFShape text = newSWFShape();
    SWFDisplayItem text_display;
    /* Convert UTF-8 string to Unicode array */
    int maxLen = strlen(str);
    wchar_t *unicode = (wchar_t *) calloc(maxLen + 1, sizeof(wchar_t));
    int len = utf8towcs(unicode, str, maxLen);
    
    FT_Face face = swfGetFTFace(gc, swfInfo);
    double fontSize = gc->ps * gc->cex;

    swfSetTextColor(text, gc, swfInfo);
    SWFShape_addString(text, unicode, len, fontSize, face,
                       &(swfInfo->outlnFuns));
    
    text_display = SWFMovieClip_add(swfInfo->currentFrame, (SWFBlock) text);
    SWFDisplayItem_moveTo(text_display, x, y);
    SWFDisplayItem_rotate(text_display, rot);
}
コード例 #2
0
ファイル: swfDevice.c プロジェクト: rforge/swfdevice
    /*
     * device_Text should have the side-effect that the
     * given text is drawn at the given location.
     * The text should be rotated according to rot (degrees)
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   font, cex, ps, col, gamma
     */
static void SWF_Text( double x, double y, const char *str,
		double rot, double hadj, const pGEcontext plotParams, 
		pDevDesc deviceInfo)
{
	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_Text: Writing Text \"%s\"\n", str);
		fflush(swfInfo->logFile);
	}
	
	/* It is possible that this will be very expensive and storing 
	 * a single text object in swfInfo may be better.
	 */
	SWFText text_object = newSWFText();
	SWFDisplayItem text_display;
	/*Ming (0,0) is the top left, convert to R (0,0) at bottom left*/
	y = deviceInfo->top - y;
	
	//found = !strcmp(name, fontlist->family->fxname);
	
	// Tell the text object to use the font previously loaded
	SWFText_setFont(text_object, 
		selectFont(plotParams->fontface, plotParams->fontfamily, swfInfo));
	
	// Set the height of the text
	SWFText_setHeight(text_object, plotParams->ps * plotParams->cex);
	
	// Set the color of the text
	byte red = R_RED(plotParams->col);
	byte green = R_GREEN(plotParams->col);
	byte blue = R_BLUE(plotParams->col);
	byte alpha =  R_ALPHA(plotParams->col);
	SWFText_setColor(text_object, red, green, blue, alpha);
	
	// Add a string to the text object
	SWFText_addString(text_object, str, NULL);
	
	// Add the text object to the movie (at 0,0)
	text_display = SWFMovie_add(swfInfo->m, (SWFBlock) text_object);
	
	addToDisplayList( text_display );
	
	// Move to correct coordinate and rotate
	SWFDisplayItem_moveTo(text_display, x, y);
	SWFDisplayItem_rotate(text_display, rot);
	
			
}
コード例 #3
0
ファイル: minghsp.c プロジェクト: tkhaga/MingHSP
EXPORT BOOL WINAPI i_rotate(float degrees, int p2, int p3, int p4)
{
	lstrcpy(funcname, "i_rotate");
	SWFDisplayItem_rotate(mhsp_item, degrees);
	return 0;
}