Esempio n. 1
0
void fnt_Normalize(fnt_LocalGraphicStateType* gs, F26Dot6 x, F26Dot6 y, shortVector* v)
{
	fract x1, y1;
	/*
	 *	Since x and y are 26.6, and currently that means they are really 16.6,
	 *	when treated as Fract, they are 0.[8]22, so shift up to 0.30 for accuracy
	 */
#ifdef HeiseiKakuGothic_fails_this_test
	CHECK_RANGE(gs, x, -32768L << 6, 32767L << 6);
	CHECK_RANGE(gs, y, -32768L << 6, 32767L << 6);
#endif
#ifdef cpuPrinter
#pragma unused (gs)
#endif
	{	int shift, count;
		F26Dot6 xx = x;
		F26Dot6 yy = y;
		
		if (xx < 0)	xx = -xx;
		if (yy < 0) yy = -yy;
		if (xx < yy) xx = yy;
		/*
		 *	0.5 <= max(x,y) < 1
		 */
		bitcount(xx, count); 
		shift = 8 * sizeof(fract) - 2 - count;
		x1 = (fract) x << shift;
		y1 = (fract) y << shift;
	}
	{	fract length;
			/* MTE Hack: fixed possible unwanted assignment */
			length = Magnitude(x1, y1);
		if (length)
		{	v->x = FixedRound( FractDivide( x1, length ) );
			v->y = FixedRound( FractDivide( y1, length ) );
		}	
		else
		{	PostInterpreterError(gs, interp_normalize_error);
			v->x = shortFrac1;
			v->y = 0;
		}
	}
}
Esempio n. 2
0
void TTScalerTTHintTran(
 	 const scalerTransform *theTransform,	/* Specify a Input Transformation? */
	 perFont *aPerFont,						/* Specify the context  */
 	 perTransformation  *theTrans 			/* point to transform block. */
 	) 	 
{
	perVariation * aPerVari=&aPerFont->theVary	;			/* Specify the context as a variation */
	fsg_SplineKey		key;			/* Scaler internal execution state */
   	perTransformation   *localPerTransform;
      
  	InitTheKeyByVary(&key, aPerVari);
  	FillBytes((char*)theTrans + theTrans->twilightZone.offset, TheFont(&key)->twilightZoneSize, 0);
	/* MTE: Setup some flags and control variables */
	/*	make a guess as to what they should be.. */
 	theTrans->executeInstructions	= true; 
 			/* MTE: always true? BitTestToBoolean(theTransform->flags & applyHintsTransform); */
	theTrans->returnDeviceMetrics= false; 
			/* MTE: always false??BitTestToBoolean(theTransform->flags & deviceMetricsTransform); */
	theTrans->preProgramRan 	= false;
	theTrans->cvtHasBeenScaled 	= false;
	theTrans->verticalOrientation = false; 
		/*  MTE: What should this be?BitTestToBoolean(theTransform->flags & verticalTransform); */
	theTrans->methodToBeUsedIfPossible = outlineWillBeUsed;
	theTrans->methodToBeUsedOtherwise = outlineWillBeUsed;

	/*
	 *	Set baseMap to the concatenation of pointSize € resolution € userMatrix
	*/
	theTrans->pointSize = theTransform->pointSize;
	theTrans->pixelDiameter	= Magnitude(theTransform->spotSize.x, theTransform->spotSize.y);
		
    ResetMapping(&theTrans->stretchTransform);
    theTrans->stretchTransform.map[0][0] = 
        MultiplyDivide(theTransform->pointSize, theTransform->resolution.x, FIXEDPOINTSPERINCH);
    theTrans->stretchTransform.map[1][1] = 
        MultiplyDivide(theTransform->pointSize, theTransform->resolution.y, FIXEDPOINTSPERINCH);
    if (TheFont(&key)->fontFlags & USE_INTEGER_SCALING) {
        theTrans->stretchTransform.map[0][0] = RoundedFixed(theTrans->stretchTransform.map[0][0]);
        theTrans->stretchTransform.map[1][1] = RoundedFixed(theTrans->stretchTransform.map[1][1]);
    }

    MapMapping(&theTrans->stretchTransform,( const gxMapping *) theTransform->fontMatrixPtr );
    theTrans->globalGS.localParBlock.scanControl = DEFAULT_DROPOUT_MODE;

	if (theTrans->executeInstructions)
	{	
		boolean b1,b2,b2a;
		int theMinVal,minFix;

        /* We assume that transform here has only positive stretch
           (no rotation, skew or flips allowed at this point).

           Note that hinting code does NOT apply this transform to outline.
           It assumes that outline is already scaled and uses transform for reference. */

 	 	theMinVal = TheFont(&key)->minimumPixPerEm; 
 	 	if (theMinVal> kMinimumPPEMWhereHintsStillWork) 
		    theMinVal=kMinimumPPEMWhereHintsStillWork ;  
		minFix=ff(theMinVal)-(0x8000L); /* adjust for fixed point rounding. */
		if (			/* MTE: no perspective, ever ! MxFlags(&theTrans->transState.baseMap) == 	perspectiveState || */
            (theTrans->stretchTransform.map[0][0] < minFix )
					||
            (theTrans->stretchTransform.map[1][1] < minFix)
           )
        {
            /* turnOffHinting: */
				theTrans->globalGS.localParBlock.scanControl = 0x101ff;					/* hard-code dropout control ON */
				theTrans->returnDeviceMetrics = theTrans->executeInstructions = false;	/* Do nothing. */
                /* Note: hinting will be reenabled as soon as we update 
                   t->ttd and call TTScalerTTHintTran() */
 				goto exit;
			}
			
		 	theTrans->globalGS.instrDefCount 	= TheFont(&key)->IDefCount;
			theTrans->globalGS.pointSize		= FixedRound(theTrans->pointSize);
#ifdef use_engine_characteristics_in_hints
				theTrans->globalGS.engine[kGreyEngineDistance]	= 0;
				theTrans->globalGS.engine[kBlackEngineDistance]	= FixedToF26Dot6( (FIXEDSQRT2 - theTrans->pixelDiameter) );
				theTrans->globalGS.engine[kWhiteEngineDistance]	= -theTrans->globalGS.engine[kBlackEngineDistance];
				theTrans->globalGS.engine[kIllegalEngineDistance]	= 0;
#endif
			theTrans->globalGS.variationCoordCount			= TheFont(&key)->axisCount;
			theTrans->globalGS.hasVariationCoord			= TheVari(&key)->hasStyleCoord;
			
            {
                register fixed scaleX = theTrans->stretchTransform.map[0][0];
                register fixed scaleY = theTrans->stretchTransform.map[1][1];
				theTrans->globalGS.cvtScale =/*  MTE: Maximum(scaleX, scaleY); */
						scaleX>scaleY ? scaleX :scaleY;
			}
			SetGlobalGSDefaults(&theTrans->globalGS);  	 
 	}
   exit:;
  }