//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : FontManager.cpp Data : 28.05.14 Versione : 1.5f1 // Contenuto : Implementazione della classe FontManager. // // // // Modifiche : 28.05.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "FontManager.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //---------------------------------------------------------------------------- bool FontManager::Init( const string& sNfeFontDir, const string& sDefaultFont) { // assegno direttorio file per font Nfe m_sNfeFontDir = sNfeFontDir ; TrimRight( m_sNfeFontDir, " \\") ; // assegno nome font di default m_sDefaultFont = sDefaultFont ; return true ; } //---------------------------------------------------------------------------- bool FontManager::SetCurrFont( const string& sFont, int nWeight, bool bItalic, double dHeight, double dRatio, double dAddAdvance) { // gestione font di default string sFontName = (( sFont.empty()) ? m_sDefaultFont : sFont) ; // lo cerco tra i font Nfe if ( FileExtensionMatches( sFontName, "NFE")) { // verifico che il font richiesto esista, altrimenti prendo default se Nfe string sPath = m_sNfeFontDir + "\\" + sFontName ; if ( ! ExistsFile( sPath)) { sPath = m_sNfeFontDir + "\\" + m_sDefaultFont ; // verifico esistenza, altrimenti prendo il primo dello stesso tipo if ( ! ExistsFile( sPath)) { if ( FindFirstFileEgt( m_sNfeFontDir + "\\*.Nfe", sFontName)) sPath = m_sNfeFontDir + "\\" + sFontName ; } } // imposto il font corrente m_bCurrNfeFont = true ; if ( ! m_NfeFont.SetCurrFont( sPath, nWeight, bItalic, dHeight, dRatio, dAddAdvance)) return false ; } // altrimenti lo cerco tra i font di sistema else { m_bCurrNfeFont = false ; if ( ! m_OsFont.SetCurrFont( sFontName, nWeight, bItalic, dHeight, dRatio, dAddAdvance)) return false ; } return true ; } //---------------------------------------------------------------------------- bool FontManager::GetCapHeight( double& dCapH) const { if ( m_bCurrNfeFont) return m_NfeFont.GetCapHeight( dCapH) ; else return m_OsFont.GetCapHeight( dCapH) ; } //---------------------------------------------------------------------------- bool FontManager::GetAscent( double& dAsc) const { if ( m_bCurrNfeFont) return m_NfeFont.GetAscent( dAsc) ; else return m_OsFont.GetAscent( dAsc) ; } //---------------------------------------------------------------------------- bool FontManager::GetDescent( double& dDesc) const { if ( m_bCurrNfeFont) return m_NfeFont.GetDescent( dDesc) ; else return m_OsFont.GetDescent( dDesc) ; } //---------------------------------------------------------------------------- bool FontManager::GetCapBox( const string& sText, int nInsPos, BBox3d& b3Box) const { if ( m_bCurrNfeFont) return m_NfeFont.GetXBox( sText, nInsPos, true, b3Box) ; else return m_OsFont.GetXBox( sText, nInsPos, true, b3Box) ; } //---------------------------------------------------------------------------- bool FontManager::GetBBox( const string& sText, int nInsPos, BBox3d& b3Box) const { if ( m_bCurrNfeFont) return m_NfeFont.GetXBox( sText, nInsPos, false, b3Box) ; else return m_OsFont.GetXBox( sText, nInsPos, false, b3Box) ; } //---------------------------------------------------------------------------- bool FontManager::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const { if ( m_bCurrNfeFont) return m_NfeFont.GetOutline( sText, nInsPos, lstPC) ; else return m_OsFont.GetOutline( sText, nInsPos, lstPC) ; } //---------------------------------------------------------------------------- bool FontManager::GetRegion( const string& sText, int nInsPos, ISURFFRPLIST& lstSFR) const { if ( m_bCurrNfeFont) return false ; else return m_OsFont.GetRegion( sText, nInsPos, lstSFR) ; } //---------------------------------------------------------------------------- bool FontManager::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const { if ( m_bCurrNfeFont) return m_NfeFont.ApproxWithLines( sText, nInsPos, dLinTol, dAngTolDeg, lstPL) ; else return m_OsFont.ApproxWithLines( sText, nInsPos, dLinTol, dAngTolDeg, lstPL) ; } //---------------------------------------------------------------------------- bool FontManager::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYARCLIST& lstPA) const { if ( m_bCurrNfeFont) return m_NfeFont.ApproxWithArcs( sText, nInsPos, dLinTol, dAngTolDeg, lstPA) ; else return m_OsFont.ApproxWithArcs( sText, nInsPos, dLinTol, dAngTolDeg, lstPA) ; } //---------------------------------------------------------------------------- bool FontManager::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const { if ( m_bCurrNfeFont) return m_NfeFont.GetTextLines( sText, nInsPos, vPt, vLine) ; else return m_OsFont.GetTextLines( sText, nInsPos, vPt, vLine) ; }