示例#1
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);
	
		
}
示例#2
0
文件: minghsp.c 项目: tkhaga/MingHSP
EXPORT BOOL WINAPI t_getAscent(float *p1, int p2, int p3, int p4)
{
	lstrcpy(funcname, "t_getAscent");
	*p1 = SWFText_getAscent(mhsp_text);
	return 0;
}