EgtGeomKernel :
- a ExtText aggiunta GetAuxSurf (solo per font di sistema) - molto migliorata gestione anelli e spikes nella creazione di regioni.
This commit is contained in:
+85
@@ -16,6 +16,8 @@
|
||||
#include "FontOs.h"
|
||||
#include "FontAux.h"
|
||||
#include "FontConst.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
@@ -23,6 +25,7 @@
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
@@ -329,6 +332,88 @@ OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetRegion( const string& sText, int nInsPos, ISURFFRPLIST& lstSFR) const
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// rendo corrente il font
|
||||
HFONT hPrevFont = (HFONT) SelectObject( m_hDC, m_hFont) ;
|
||||
if ( hPrevFont == nullptr)
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
double dScaZ = 1 ;
|
||||
|
||||
// recupero altezza maiuscole e interlinea
|
||||
double dHCap = m_dHeight ;
|
||||
double dH = m_dH * m_dHeight / m_dHCap ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// ciclo sui codici
|
||||
double dMaxW = 0 ;
|
||||
double dMinH = 0 ;
|
||||
Vector3d vtMove ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// verifico se comando di a capo
|
||||
int nLbLen ;
|
||||
if ( IsLineBreak( vCode, i, nLbLen)) {
|
||||
vtMove.Set( 0, vtMove.y - dH, 0) ;
|
||||
if ( vtMove.y < dMinH)
|
||||
dMinH = vtMove.y ;
|
||||
i += nLbLen ;
|
||||
continue ;
|
||||
}
|
||||
// recupero l'outline
|
||||
double dAdvance ;
|
||||
ICURVEPLIST lstPC ;
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo trasformo opportunamente
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
// inverto i percorsi per avere gli esterni CCW
|
||||
(*iIter)->Invert() ;
|
||||
// la trasformo per avere solo archi e rette
|
||||
GetCurveComposite( *iIter)->ArcsBezierCurvesToArcsPerpExtr( LIN_TOL_FINE, ANG_STRAIGHT) ;
|
||||
}
|
||||
// creo la regione
|
||||
SurfFlatRegionByContours SfrCntr( false, true) ;
|
||||
for ( auto& PC : lstPC)
|
||||
SfrCntr.AddCurve( PC) ;
|
||||
PtrOwner<SurfFlatRegion> pSfr( GetBasicSurfFlatRegion( SfrCntr.GetSurf())) ;
|
||||
if ( ! IsNull( pSfr)) {
|
||||
// trasformazioni
|
||||
pSfr->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
pSfr->Translate( vtMove) ;
|
||||
// inserimento in lista
|
||||
lstSFR.push_back( Release( pSfr)) ;
|
||||
}
|
||||
// aggiorno per larghezza
|
||||
vtMove += Vector3d( dAdvance * dScaX + m_dAddAdvance, 0, 0) ;
|
||||
if ( vtMove.x > dMaxW)
|
||||
dMaxW = vtMove.x ;
|
||||
}
|
||||
|
||||
// sistemazioni per la posizione del punto di inserimento
|
||||
Vector3d vtIpMove = GetTextInsertPointMove( dMaxW, dHCap, dMinH, nInsPos) ;
|
||||
for ( const auto& pSfr : lstSFR)
|
||||
pSfr->Translate( vtIpMove) ;
|
||||
|
||||
// ripristino il font originale
|
||||
SelectObject( m_hDC, hPrevFont) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg,
|
||||
|
||||
Reference in New Issue
Block a user