Esempio n. 1
0
int main()
{
    SWFMovie m = newSWFMovie();
    SWFText text = newSWFText();
    SWFTextField textfield = newSWFTextField();
    SWFDisplayItem it;

    SWFFont font = newSWFFont_fromFile(MEDIADIR "/font01.fdb");
    if(font == NULL)
    {
        perror(MEDIADIR "/font01.fdb");
        exit(EXIT_FAILURE);
    }

    SWFText_setFont(text, font);
    SWFText_setColor(text, 0, 0, 0xff, 0xff);
    SWFText_setHeight(text, 20);
    SWFText_moveTo(text, 100, 100);
    SWFText_addString(text, "1234567890", NULL);

    SWFTextField_setFont(textfield, font);
    SWFTextField_addString(textfield, "1234567890");
    SWFTextField_setColor(textfield, 0xff, 0, 0, 0xff);
    SWFTextField_setHeight(textfield, 20);

    SWFMovie_add(m, text);
    it = SWFMovie_add(m, textfield);
    SWFDisplayItem_moveTo(it, 100, 120);
    SWFMovie_nextFrame(m);
    SWFMovie_save(m, "test04.swf");

    return 0;
}
Esempio n. 2
0
    /*
     * 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);
	
			
}
Esempio n. 3
0
 	/*
     * device_MetricInfo should return height, depth, and
     * width information for the given character in DEVICE
     * units.
     * Note: in an 8-bit locale, c is 'char'.
     * In an mbcslocale, it is wchar_t, and at least some
     * of code assumes that is UCS-2 (Windows, true) or UCS-4.
     * This is used for formatting mathematical expressions
     * and for exact centering of text (see GText)
     * If the device cannot provide metric information then
     * it MUST return 0.0 for ascent, descent, and width.
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   font, cex, ps
     */
static void SWF_MetricInfo( int c, const pGEcontext plotParams,
		double *ascent, double *descent, double *width, pDevDesc deviceInfo ){

	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;

	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_MetricInfo:");
		fflush(swfInfo->logFile);
	}

	SWFText text_object = newSWFText();
	//char *s;
	//sprintf(s, "%c", c);

	// Tell the text object to use the font previously loaded
	SWFText_setFont(text_object, swfInfo->ss);

	// Set the height of the text
	SWFText_setHeight(text_object, plotParams->ps * plotParams->cex);

	// Add a string to the text object
	//FIXME!!! pass real character.
	SWFText_addString(text_object, "a", NULL);

	double a = SWFText_getAscent(text_object);
	double d = SWFText_getDescent(text_object);
	double w = SWFText_getStringWidth(text_object, "a");
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"Calculated Ascent=%5.2f, Decent=%5.2f, Width=%5.2f\n", 
				a, d, w);
		fflush(swfInfo->logFile);
	}
	
	*ascent = a;
	*descent = d;
	*width = w;
	
	destroySWFText(text_object);
	
		
}
Esempio n. 4
0
 /*
     * device_StrWidth should return the width of the given
     * string in DEVICE units.
     * An example is ...
     *
     * static double X11_StrWidth(const char *str,
     *                            const pGEcontext gc,
     *                            pDevDesc dd)
     *
     * R_GE_gcontext parameters that should be honoured (if possible):
     *   font, cex, ps
     */
static double SWF_StrWidth( const char *str,
		const pGEcontext plotParams, pDevDesc deviceInfo )
{
	/* Shortcut pointers to variables of interest. */
	swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific;
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"SWF_StrWidth: ");
		fflush(swfInfo->logFile);
	}
	
	SWFText text_object = newSWFText();
	
	// 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);
	
	if( swfInfo->debug == TRUE )
		fprintf(swfInfo->logFile, "Honoring ps=%7.2f, cex=%7.2f\n",
			plotParams->ps, plotParams->cex);
	
	float width = SWFText_getStringWidth(text_object, str);
	
	if( swfInfo->debug == TRUE ){
		fprintf(swfInfo->logFile,
			"\tCalculated Width of \"%s\" as %7.2f\n", str, width);
		fflush(swfInfo->logFile);
	}
	
	destroySWFText(text_object);
	
	return width;
}
Esempio n. 5
0
EXPORT BOOL WINAPI t_setHeight(float height, int p2, int p3, int p4)
{
	lstrcpy(funcname, "t_setHeight");
	SWFText_setHeight(mhsp_text, height);
	return 0;
}
Esempio n. 6
0
int main(void)
{
        // Create local variables
        int i;
        SWFDisplayItem image_display_item;
        SWFFont font_object;
        SWFMovie test_movie;
        SWFText text_object;


        // Initialise the movie structure in memory
        Ming_init();
        test_movie = newSWFMovieWithVersion(7);

        // Set the desired compression level 
		// for the output (9 = maximum compression)
        Ming_setSWFCompression(9);

        // Set the background color for the movie
        SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00);

        // Adjust the dimensions of the movie
        SWFMovie_setDimension(test_movie, 800, 600);

        // Set the frame rate for the movie to 24 frames per second
        SWFMovie_setRate(test_movie, 24.0);

        // Load a font from disk
        font_object = newSWFFont_fromFile("../../fonts/vera/Vera.ttf");
        if (NULL == font_object)
        {
                // Something went wrong, so exit
                printf("Unable to load font from file.\n");
                return EXIT_FAILURE;
        }

        // Create a new, empty text object
        text_object = newSWFText();

        // Tell the text object to use the font previously loaded
        SWFText_setFont(text_object, font_object);

        // Set the height of the text
        SWFText_setHeight(text_object, 18.0);

        // Set the color of the text
        SWFText_setColor(text_object, 0x00, 0x00, 0xff, 0xff);

        // Add a string to the text object
        SWFText_addString(text_object, "This is some example text", NULL);

        // Add the text object to the movie (at 0,0)
        image_display_item = SWFMovie_add(test_movie, (SWFBlock) text_object);

        // Move to 100, 100
        SWFDisplayItem_moveTo(image_display_item, 100.00, 100.0);

        // Progressively move the text down and to the right
        for (i = 0; i <= 250; i++)
        {
                SWFMovie_nextFrame(test_movie);
                SWFDisplayItem_move(image_display_item, 2, 2);
        }

        // Save the swf movie file to disk
        SWFMovie_save(test_movie, "ming-test-text.swf");

        // Free the swf movie in memory
        destroySWFMovie(test_movie);

        // Free the swf text object
        destroySWFText(text_object);

        return EXIT_SUCCESS;
}