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; } }
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; } }
static void BezCompute( scVertex* dstV, const scVertex* srcV ) { int i; dstV[0] = srcV[0]; dstV[scBezBlendSize-1] = srcV[3]; for ( i = 1; i < scBezBlendSize - 1; i++ ) { dstV[i].x = scRoundMP( srcV[0].x * bezblend[i].ca + srcV[1].x * bezblend[i].cb + srcV[2].x * bezblend[i].cc + srcV[3].x * bezblend[i].cd ); dstV[i].y = scRoundMP( srcV[0].y * bezblend[i].ca + srcV[1].y * bezblend[i].cb + srcV[2].y * bezblend[i].cc + srcV[3].y * bezblend[i].cd ); dstV[i].fPointType = eCornerPoint; } }
GlyphSize scCachedStyle::GetEscapement( UCS2 ch ) { if ( GetDeviceValues() ) { if ( ch >= 256 ) return FIgetDEVEscapement( fSpec, ch ); if ( fWidths[ch] == kInvalMP ) { if ( GetSmallCaps() && CTIsLowerCase( ch ) ) fWidths[ch] = scRoundMP( FIgetDEVEscapement( fSpec, ::CTToUpper( ch ) ) * kSmallCapCorrection ); else fWidths[ch] = FIgetDEVEscapement( fSpec, GetCorrectedGlyph( ch ) ); } } else { REAL conversion; if ( fFlowDir.IsHorizontal() ) conversion = fSetConv; else conversion = fPtConv; if ( ch >= 256 ) { RLU rluWidth = FIgetRLUEscapement( fSpec, ch ); if ( rluWidth == scBaseRLUsystem ) { if ( fFlowDir.IsHorizontal() ) return GetSetSize(); else return GetPtSize(); } return scRoundGS( conversion * rluWidth ) + GetOptLSP(); } if ( fWidths[ch] == kInvalMP ) { // it has not been previously computed switch ( ch ) { default: { RLU rluWidth; if ( GetSmallCaps() && CTIsLowerCase( ch ) ) rluWidth = (RLU)scRoundGS( FIgetRLUEscapement( fSpec, ::CTToUpper( ch ) ) * kSmallCapCorrection ); else rluWidth = FIgetRLUEscapement( fSpec, GetCorrectedGlyph( ch ) ); if ( rluWidth == scBaseRLUsystem ) { fWidths[ch] = scRoundMP( conversion * rluWidth ); if ( fFlowDir.IsHorizontal() ) fWidths[ch] = GetSetSize() + GetOptLSP(); else fWidths[ch] = GetPtSize() + GetOptLSP(); } else fWidths[ch] = scRoundMP( conversion * rluWidth ); } break; case 0: case scVertTab: case scHardReturn: if ( fFlowDir.IsHorizontal() ) fWidths[ch] = GetSetSize(); else fWidths[ch] = GetPtSize(); break; case scNoBreakSpace: fWidths[ch] = GetOptWord(); break; // these really need to be further up stream case scNoBreakHyph: case scDiscHyphen: fWidths[ch] = 0; break; case scFigureSpace: fWidths[ch] = scRoundMP( conversion * FIgetRLUEscapement( fSpec, '0' ) ); break; case scThinSpace: fWidths[ch] = scRoundMP( conversion * scBaseRLUsystem / 6 ); break; case scEnSpace: fWidths[ch] = scRoundMP( conversion * scBaseRLUsystem / 2 ); break; case scEmSpace: fWidths[ch] = scRoundMP( conversion * scBaseRLUsystem ); break; } } if ( fWidths[ch] == 0 ) return 0; } return fWidths[ch] + GetOptLSP(); }
void scCachedStyle::ComputeExtentsnCursor( void ) { if ( GetDeviceValues() ) { scXRect rect; MicroPoint a,b,c,d; FIgetDEVFontExtents( fSpec, a, b, c, d, rect ); if ( fFlowDir.IsHorizontal() ) { scAssert( rect.Valid( eFirstQuad ) ); rect.FirstToFourth( GetPtSize() ); scAssert( rect.Valid( eFourthQuad ) ); fInkExtents.y1 = rect.y1; fInkExtents.y2 = rect.y2; fInkExtents.x1 = rect.x1; fInkExtents.x2 = rect.x2; } else { fInkExtents.y1 = 0; fInkExtents.y2 = rect.y1 - rect.y2; fInkExtents.x1 = -(rect.x2/2) - rect.x1; fInkExtents.x2 = rect.x2/2; } } else { scRLURect rect; RLU a,b,c,d; FIgetRLUFontExtents( fSpec, a, b, c, d, rect ); if ( fFlowDir.IsHorizontal() ) { scAssert( rect.Valid( eFirstQuad ) ); rect.FirstToFourth( scBaseRLUsystem ); } scAssert( rect.Valid( eFourthQuad ) ); fInkExtents.y1 = scRoundMP( fPtConv * rect.rluTop ); fInkExtents.y2 = scRoundMP( fPtConv * rect.rluBottom ); fInkExtents.x1 = scRoundMP( fSetConv * rect.rluLeft ); fInkExtents.x2 = scRoundMP( fSetConv * rect.rluRight ); } REAL obliqOff = 0; if ( GetHorzOblique() ) obliqOff = (REAL)tan( AngleToRadians( GetHorzOblique() ) ); if ( GetHorzOblique() < 0 ) fInkExtents.x1 += scRoundMP( GetPtSize() * obliqOff ); if ( GetHorzOblique() < 0 ) fInkExtents.x2 += scRoundMP( GetPtSize() * obliqOff ); scAssert( fInkExtents.Valid( eFourthQuad ) ); if ( fFlowDir.IsHorizontal() ) fInkExtents.Translate( 0, -GetBaseline() ); else fInkExtents.Translate( GetBaseline(), 0 ); if ( fFlowDir.IsHorizontal() ) { scLEADRefData ld; ld.Set( GetPtSize(), fFlowDir ); fLogicalExtents.Set( 0, -ld.GetAboveLead(), GetSetSize(), ld.GetBelowLead() ); } else fLogicalExtents.Set( -GetSetSize()/2, 0, GetSetSize()/2, GetPtSize() ); if ( fFlowDir.IsHorizontal() ) { fCursorY1 = -scRoundMP( fPtConv * RLU_BASEfmTop ); fCursorY2 = scRoundMP( fPtConv * RLU_BASEfmBottom ); } else { fCursorX1 = -GetSetSize() / 2; fCursorX2 = GetSetSize() / 2; } }