예제 #1
0
void CBaselinePositions::Init( const scMuPoint& org,
							   MicroPoint		vjOffset,
							   TypeSpec 		spec,
							   const scFlowDir& fd )
{
	scAssert( spec != 0 );
	
	MicroPoint	ptsize = scCachedStyle::GetCachedStyle( spec ).GetPtSize();
	
	if ( fd.IsHorizontal() ) {
		fTop	= org.y - scRoundMP( (REAL)ptsize * RLU_BASEfmTop / scBaseRLUsystem );
		fMiddle = org.y - scRoundMP( (REAL)ptsize * ( RLU_BASEfmTop - (scBaseRLUsystem/2)) / scBaseRLUsystem );
		fRoman	= org.y;
		fBottom = org.y + scRoundMP( (REAL)ptsize * RLU_BASEfmBottom / scBaseRLUsystem );
		
		fTop	+= vjOffset;
		fMiddle += vjOffset;
		fRoman	+= vjOffset;
		fBottom += vjOffset;
		
	}
	else {
		fLeft	= org.x - ptsize / 2;
		fMiddle = org.x;
		fRight	= org.x + ptsize / 2;
		
		fLeft	-= vjOffset;
		fMiddle -= vjOffset;
		fRight	-= vjOffset;
	}
}
예제 #2
0
/* ==================================================================== */
void scDrawLine::ProcessRenMoji()
{
	scRenMojiStr	rm;
	CharRecord		fauxChar;
	unsigned		i;
	unsigned		numChars = fChRec->flags.GetRenMoji();

		// save spec	
	rm.fSpec	= fSpec;
	
	scAssert( numChars < 7 );
	
		// process characters
	for ( i = 0; i < numChars; i++ ) {
		rm.fRenMojiStr[i] = *fChRec;
		rm.fRenMojiStr[i+1].character = 0;
		IncrementBackingStore();
	}
	
	fauxChar.Set( emSpace,	(fChRec-1)->escapement );
	SetCharArray( fauxChar, false );
	
	rm.fPosition = fCurPos;
	
	if ( fFlowDir.IsHorizontal() ) {
		switch ( scCachedStyle::GetCachedStyle().GetHorzBaseline() ) {
			case kTopBaseline:
				rm.fPosition.y = fBaselinePositions.fTop;
				break;
			case kMiddleBaseline:
				rm.fPosition.y = fBaselinePositions.fMiddle;
				break;
			case kBottomBaseline:
				rm.fPosition.y = fBaselinePositions.fBottom;
				break;
			default:
			case kRomanBaseline:
				rm.fPosition.y = fBaselinePositions.fRoman;
				break;
		}
	}
	else {
		switch ( scCachedStyle::GetCachedStyle().GetVertBaseline() ) {		
			case kLeftBaseline:
				rm.fPosition.x = fBaselinePositions.fLeft;
				break;
			default:
			case kCenterBaseline:
				rm.fPosition.x = fBaselinePositions.fMiddle;
				break;
			case kRightBaseline:
				rm.fPosition.x = fBaselinePositions.fRight;
				break;
		}			
	}
	
	fRenMojiArray.AppendData( (ElementPtr)&rm );
}
예제 #3
0
// set the ComputedCharData structure
void scDrawLine::SetRubiCharData( const scRubiData& rd, 
								 const scFlowDir&	fd, 
								 eTSJustTypes		rubiJust,
								 int				count,
								 MicroPoint&		letterspace )
{
	REAL	rubifactor = ( (REAL)TSRubiSizeFactor( rd.fRubiSpec ) ) / 10000;
	
	fGlyphInfo.fontname 	= TSRubiFont( rd.fRubiSpec );
	fGlyphInfo.emphasis_	=  scCachedStyle::GetCurrentCache().GetEmphasis();
	fGlyphInfo.fontRender	= scCachedStyle::GetCurrentCache().GetFontRender();
	fGlyphInfo.typespec 	= scCachedStyle::GetCurrentCache().GetSpec();
	fGlyphInfo.color			= TSRubiColor( rd.fRubiSpec );
	
	fGlyphInfo.pointsize		= ROUND( scCachedStyle::GetCurrentCache().GetPtSize() * rubifactor );
	fGlyphInfo.setsize		= ROUND( scCachedStyle::GetCurrentCache().GetSetSize() * rubifactor );

	if ( fd.IsHorizontal() )
		fGlyphInfo.fBaseline		= kRomanBaseline;
	else
		fGlyphInfo.fBaseline		= kLeftBaseline;
		
	if ( rubiJust & lastLineJust && count > 1 ) {
		letterspace = rd.fLetterSpace * ( count - 1 );	
		if ( fd.IsHorizontal() ) {
			fGlyphInfo.setsize	+= ( letterspace / count );
			letterspace = 0;
		}
		else {
			fGlyphInfo.pointsize	+= ( letterspace / count );
			letterspace = 0;
		}
	}
	else
		letterspace =  rd.fLetterSpace;
	
	fGlyphInfo.oblique		= 0;
	fGlyphInfo.rotation 	= 0;
	fGlyphInfo.flowDir		= fFlowDir;
}
예제 #4
0
// this determines the leading plus paragraph space between this - the
// last line of a paragraph - and the next paragraph
MicroPoint scTextline::ParaLead( scLEADRefData& 	lead,
								 const scFlowDir&	fd )
{
	TypeSpec		prevLeadSpec,
					curLeadSpec;
	MicroPoint		spaceAbove,
					spaceBelow;
	MicroPoint		paraspace;
	scLEADRefData	topPara;
	scLEADRefData	belowPara;

	scContUnit* 	nextPara;
	
	nextPara = GetPara()->GetNext();
	if ( !nextPara )
		return 0;
	
	MaxLead( prevLeadSpec );
	curLeadSpec = nextPara->SpecAtStart();

	if ( fd.IsHorizontal() ) {
		spaceBelow =	scCachedStyle::GetCachedStyle( prevLeadSpec ).GetPtSize();
		spaceAbove =	scCachedStyle::GetCachedStyle( curLeadSpec ).GetPtSize();
	}
	else {
		spaceBelow =	scCachedStyle::GetCachedStyle( prevLeadSpec ).GetSetSize();
		spaceAbove =	scCachedStyle::GetCachedStyle( curLeadSpec ).GetSetSize();
	}
	
	topPara.Set( spaceBelow, fd );	
	belowPara.Set( spaceAbove, fd );	

	paraspace		= scCachedStyle::GetParaSpace( GetPara(), nextPara );
	
	lead.SetBelowLead( topPara.GetBelowLead() );
	lead.SetAboveLead( belowPara.GetAboveLead() );
	lead.SetExternalSpace( paraspace );
	
	return lead.GetLead();
}
예제 #5
0
void scLEADRefData::ComputeAboveBelow( MicroPoint lead, const scFlowDir& fd )
{
	if ( fd.IsHorizontal() ) {
		static REAL realAbove = (REAL)RLU_BASEfmTop / scBaseRLUsystem;
		static REAL realBelow = (REAL)RLU_BASEfmBottom / scBaseRLUsystem;
		static MicroPoint lastlead;
		static MicroPoint abovelead;
		static MicroPoint belowlead;

		if ( lastlead != lead ) {
			abovelead	= scRoundMP( realAbove * lead );
			belowlead	= scRoundMP( realBelow * lead );
			lastlead 	= lead;
		}
		fAboveLead = abovelead;
		fBelowLead = belowlead;
	}
	else {
		fAboveLead	= lead / 2;
		fBelowLead	= lead / 2;	
	}
}
예제 #6
0
/* ==================================================================== */
void scDrawLine::DrawRenMoji()
{
	int 		i,
				j;
	scRenMojiStr	rm;
	MicroPoint	microMeasure;
	MicroPoint	romanBaselineShift;
	MicroPoint	maxMeasure;
	REAL		ptsizeAdjust;
	REAL		setwidthAdjust;
	scFlowDir	antiFlowDir;
	scFlowDir	saveFlowDir( fFlowDir );
	TypeSpec	saveSpec	= scCachedStyle::GetCurrentCache().GetSpec();
	
	antiFlowDir.CounterFlow( fFlowDir );

	for ( i = 0; i < fRenMojiArray.GetNumItems(); i++ ) {
		fRenMojiArray.GetDataAt( i, (ElementPtr)&rm );

		scCachedStyle::SetFlowdir( antiFlowDir );
		scCachedStyle::GetCachedStyle( rm.fSpec );

		microMeasure = BRKComposeRenMoji( rm.fRenMojiStr, rm.fSpec, antiFlowDir, true );
		
		maxMeasure = scCachedStyle::GetCurrentCache().GetPtSize() * 2;

#ifdef kMakimotoRenMoji
		int doMakimotoRenMoji = 1;
#else
		int doMakimotoRenMoji = 0;
#endif
		if ( doMakimotoRenMoji && microMeasure > maxMeasure ) {
				// first try to reduce setwidth
			setwidthAdjust = (REAL)maxMeasure / microMeasure;
			
			if ( setwidthAdjust < 0.60 )
				ptsizeAdjust = setwidthAdjust;		// adjust pointsize to
			else
				ptsizeAdjust = 1.0;
			
			microMeasure = ROUND( microMeasure * setwidthAdjust );
			
			for ( j = 0; rm.fRenMojiStr[j].character; j++ )
				rm.fRenMojiStr[j].escapement = ROUND( rm.fRenMojiStr[j].escapement * setwidthAdjust );
		}
		else {
			setwidthAdjust	= 1.0;
			ptsizeAdjust	= 1.0;
		}
		
		MicroPoint ptsize = ROUND( ptsizeAdjust * scCachedStyle::GetCurrentCache().GetPtSize() );
		MicroPoint setsize = ROUND( setwidthAdjust * scCachedStyle::GetCurrentCache().GetSetSize() );

		if ( fFlowDir.IsVertical() ) {
			MicroPoint	midPoint,
						left;

			switch ( scCachedStyle::GetCachedStyle().GetVertBaseline() ) {					
				case kLeftBaseline:
					midPoint	= ROUND( scCachedStyle::GetCurrentCache().GetPtSize() * (scBaseRLUsystem/2) / scBaseRLUsystem );
					break;
				case kCenterBaseline:
					midPoint = 0;
					break;
				case kRightBaseline:
					midPoint	= ROUND( -scCachedStyle::GetCurrentCache().GetPtSize() * (scBaseRLUsystem/2) / scBaseRLUsystem );
					break;
			}
			romanBaselineShift = -(scCachedStyle::GetCurrentCache().GetPtSize()/2) + (ptsize/2) - (ptsize*RLU_BASEfmBottom/scBaseRLUsystem);
			left		= midPoint	- microMeasure / 2;
			rm.fPosition.Translate( left, romanBaselineShift );
		}
		else {
			MicroPoint	midPoint,
						top;
			switch ( scCachedStyle::GetCachedStyle().GetHorzBaseline() ) {
				case kTopBaseline:
					midPoint	= ROUND( scCachedStyle::GetCurrentCache().GetPtSize() * (scBaseRLUsystem/2) / scBaseRLUsystem );
					break;
				case kMiddleBaseline:
					midPoint = 0;
					break;
				case kBottomBaseline:
					midPoint	= ROUND( -scCachedStyle::GetCurrentCache().GetPtSize() * (scBaseRLUsystem/2) / scBaseRLUsystem );
					break;
				case kRomanBaseline:
					midPoint	= ROUND(-scCachedStyle::GetCurrentCache().GetPtSize() * (scBaseRLUsystem/2-RLU_BASEfmBottom) / scBaseRLUsystem);
					break;
			}
			top 		= midPoint - microMeasure/2;			
			rm.fPosition.Translate( -scCachedStyle::GetCurrentCache().GetSetSize() / 2, top );
		}
		
		fDrawOrigin = rm.fPosition;
		fFlowDir	= antiFlowDir;

		ptsize		= ROUND( ptsizeAdjust * scCachedStyle::GetCurrentCache().GetPtSize() );
		setsize 	= ROUND( setwidthAdjust * scCachedStyle::GetCurrentCache().GetSetSize() );
		
		if ( fFlowDir.IsHorizontal() )
			SetCharData( ptsize, setsize, antiFlowDir, kRomanBaseline  );
		else
			SetCharData( setsize, ptsize, antiFlowDir, kCenterBaseline );		
		
		for ( j = 0; rm.fRenMojiStr[j].character; j++ )
			SetCharArray( rm.fRenMojiStr[j], true );
			
		OutputLine();
		
		fFlowDir	= saveFlowDir;
	}
	
	scCachedStyle::SetFlowdir( saveFlowDir );
	scCachedStyle::GetCachedStyle( saveSpec );
}
예제 #7
0
// draw japanese rubi
void scDrawLine::DrawRubi( const scRubiData& rd )
{
	int 			i,
					count		= CharacterBufLen( rd.fCh );
	MicroPoint		hEscapement;
	MicroPoint		vEscapement;
	scXRect 		xrect( rd.fExtents );
	scMuPoint		org 		= rd.fOrg;
	scMuPoint		trans;
	TSJust			rubiJust	= TSRubiJust(  rd.fRubiSpec );
	MicroPoint		letterspace;
	
	scCachedStyle::GetCachedStyle( rd.fRubiSpec );
	SetRubiCharData( rd, fFlowDir, rubiJust, count, letterspace );
	
	trans = fOrigin;
	if ( fFlowDir.IsHorizontal() ) {
		switch ( scCachedStyle::GetCachedStyle().GetHorzBaseline() ) {
			case kTopBaseline:
				trans.y = fBaselinePositions.fTop;
				break;
			case kMiddleBaseline:
				trans.y = fBaselinePositions.fMiddle;
				break;
			case kBottomBaseline:
				trans.y = fBaselinePositions.fBottom;
				break;
			default:
			case kRomanBaseline:
				trans.y = fBaselinePositions.fRoman;
				break;
		}
	}
	else {
		switch ( scCachedStyle::GetCachedStyle().GetVertBaseline() ) {		
			case kLeftBaseline:
				trans.x = fBaselinePositions.fLeft;
				break;
			default:
			case kCenterBaseline:
				trans.x = fBaselinePositions.fMiddle;
				break;
			case kRightBaseline:
				trans.x = fBaselinePositions.fRight;
				break;
		}			
	}

	org.Translate( trans );
	fCurPos = org;

	if ( fFlowDir.IsVertical() ) {
		hEscapement = 0;
		vEscapement = fGlyphInfo.pointsize + letterspace;		
	}
	else {
		hEscapement = fGlyphInfo.setsize + letterspace;
		vEscapement = 0;
	}
	
	fChA	= fChArray;
	for ( i = 0; i < count; i++ ) {
		fChA[i].ch			= rd.fCh[i];
		fChA[i].flags.ClearFlags();
		fChA[i].hEscapement = hEscapement;
		fChA[i].vEscapement = vEscapement;		
	}

	APPDrawStartLine( fDawContext, org.x, org.y, hrect );
	APPDrawString( fDrawContext, fChArray, count, org.x, org.y, fGlyphInfo );
	APPDrawEndLine( fDrawContext ); 
}