From e8796dac888cfbfe436f7a729a990ab581b58e5f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 1 Jun 2020 07:45:39 +0000 Subject: [PATCH] EgtGeomKernel 2.2f1 : - migliorie a gestione font. --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes FontManager.cpp | 18 +++++++++--------- FontManager.h | 34 ++++++++++++++++++---------------- FontNfe.cpp | 16 ++++++++-------- FontNfe.h | 16 ++++++++-------- FontOs.cpp | 24 ++++++++++++------------ FontOs.h | 24 ++++++++++++------------ 7 files changed, 67 insertions(+), 65 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 8e9fbc114d45db0602e598bd9e8782adf0cfbf91..e908e80397fdb41349903c4fe9fa869803272d4c 100644 GIT binary patch delta 118 zcmdlNy)SyhH#Sx?1|0^&&A-{?nVHiV3@0mc>u&bq>S2M3-{!MM7I$OZ+#~G9j8n2h Q8ZL=uq6g#VEaea`09rgA5&!@I delta 118 zcmdlNy)SyhH#Sxi1|0^Y&A-{?nVC}u&bq>S2M3-{!MM7I$OZ+#~G9j8n2h Q8ZL=uq6g#VEaea`09YO#3IG5A diff --git a/FontManager.cpp b/FontManager.cpp index eaeb973..93ca3b7 100644 --- a/FontManager.cpp +++ b/FontManager.cpp @@ -73,7 +73,7 @@ FontManager::SetCurrFont( const string& sFont, int nWeight, bool bItalic, //---------------------------------------------------------------------------- bool -FontManager::GetCapHeight( double& dCapH) +FontManager::GetCapHeight( double& dCapH) const { if ( m_bCurrNfeFont) return m_NfeFont.GetCapHeight( dCapH) ; @@ -83,7 +83,7 @@ FontManager::GetCapHeight( double& dCapH) //---------------------------------------------------------------------------- bool -FontManager::GetAscent( double& dAsc) +FontManager::GetAscent( double& dAsc) const { if ( m_bCurrNfeFont) return m_NfeFont.GetAscent( dAsc) ; @@ -93,7 +93,7 @@ FontManager::GetAscent( double& dAsc) //---------------------------------------------------------------------------- bool -FontManager::GetDescent( double& dDesc) +FontManager::GetDescent( double& dDesc) const { if ( m_bCurrNfeFont) return m_NfeFont.GetDescent( dDesc) ; @@ -103,7 +103,7 @@ FontManager::GetDescent( double& dDesc) //---------------------------------------------------------------------------- bool -FontManager::GetCapBox( const string& sText, int nInsPos, BBox3d& b3Box) +FontManager::GetCapBox( const string& sText, int nInsPos, BBox3d& b3Box) const { if ( m_bCurrNfeFont) return m_NfeFont.GetXBox( sText, nInsPos, true, b3Box) ; @@ -113,7 +113,7 @@ FontManager::GetCapBox( const string& sText, int nInsPos, BBox3d& b3Box) //---------------------------------------------------------------------------- bool -FontManager::GetBBox( const string& sText, int nInsPos, BBox3d& b3Box) +FontManager::GetBBox( const string& sText, int nInsPos, BBox3d& b3Box) const { if ( m_bCurrNfeFont) return m_NfeFont.GetXBox( sText, nInsPos, false, b3Box) ; @@ -123,7 +123,7 @@ FontManager::GetBBox( const string& sText, int nInsPos, BBox3d& b3Box) //---------------------------------------------------------------------------- bool -FontManager::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) +FontManager::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const { if ( m_bCurrNfeFont) return m_NfeFont.GetOutline( sText, nInsPos, lstPC) ; @@ -133,7 +133,7 @@ FontManager::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) //---------------------------------------------------------------------------- bool -FontManager::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) +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) ; @@ -143,7 +143,7 @@ FontManager::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, //---------------------------------------------------------------------------- bool -FontManager::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYARCLIST& lstPA) +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) ; @@ -153,7 +153,7 @@ FontManager::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, d //---------------------------------------------------------------------------- bool -FontManager::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) +FontManager::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const { if ( m_bCurrNfeFont) return m_NfeFont.GetTextLines( sText, nInsPos, vPt, vLine) ; diff --git a/FontManager.h b/FontManager.h index 5eb50cd..3391fd7 100644 --- a/FontManager.h +++ b/FontManager.h @@ -22,23 +22,30 @@ //---------------------------------------------------------------------------- class FontManager { + public : + static FontManager& GetFontManager( void) + { static FontManager fntMgr ; + return fntMgr ; } + public : bool Init( const std::string& sNfeFontDir, const std::string& sDefaultFont) ; bool SetCurrFont( const std::string& sFont, int nWeight, bool bItalic, double dHeight, double dRatio, double dAddAdvance) ; - const std::string& GetNfeFontDir( void) + const std::string& GetNfeFontDir( void) const { return m_sNfeFontDir ; } - const std::string& GetDefaultFont( void) + const std::string& GetDefaultFont( void) const { return m_sDefaultFont ; } - bool GetCapHeight( double& dCapH) ; - bool GetAscent( double& dAsc) ; - bool GetDescent( double& dDesc) ; - bool GetCapBox( const std::string& sText, int nInsPos, BBox3d& b3Box) ; - bool GetBBox( const std::string& sText, int nInsPos, BBox3d& b3Box) ; - bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) ; - bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ; - bool ApproxWithArcs( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYARCLIST& lstPA) ; - bool GetTextLines( const std::string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) ; + bool IsNfeFont( void) const + { return m_bCurrNfeFont ; } + bool GetCapHeight( double& dCapH) const ; + bool GetAscent( double& dAsc) const ; + bool GetDescent( double& dDesc) const ; + bool GetCapBox( const std::string& sText, int nInsPos, BBox3d& b3Box) const ; + bool GetBBox( const std::string& sText, int nInsPos, BBox3d& b3Box) const ; + bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) const ; + bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const ; + bool ApproxWithArcs( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, POLYARCLIST& lstPA) const ; + bool GetTextLines( const std::string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const ; private : std::string m_sNfeFontDir ; @@ -47,11 +54,6 @@ class FontManager NfeFont m_NfeFont ; OsFont m_OsFont ; - public : - static FontManager& GetFontManager( void) - { static FontManager fntMgr ; - return fntMgr ; } - private : FontManager( void) {} FontManager( FontManager const& copy) = delete ; diff --git a/FontNfe.cpp b/FontNfe.cpp index 69b0d56..3ef55f5 100644 --- a/FontNfe.cpp +++ b/FontNfe.cpp @@ -113,7 +113,7 @@ NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic, //---------------------------------------------------------------------------- bool -NfeFont::GetCapHeight( double& dCapH) +NfeFont::GetCapHeight( double& dCapH) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -127,7 +127,7 @@ NfeFont::GetCapHeight( double& dCapH) //---------------------------------------------------------------------------- bool -NfeFont::GetAscent( double& dAsc) +NfeFont::GetAscent( double& dAsc) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -141,7 +141,7 @@ NfeFont::GetAscent( double& dAsc) //---------------------------------------------------------------------------- bool -NfeFont::GetDescent( double& dDesc) +NfeFont::GetDescent( double& dDesc) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -155,7 +155,7 @@ NfeFont::GetDescent( double& dDesc) //---------------------------------------------------------------------------- bool -NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) +NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -222,7 +222,7 @@ NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3 //---------------------------------------------------------------------------- bool -NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) +NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -307,7 +307,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) //---------------------------------------------------------------------------- bool NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYLINELIST& lstPL) + POLYLINELIST& lstPL) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -393,7 +393,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub //---------------------------------------------------------------------------- bool NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYARCLIST& lstPA) + POLYARCLIST& lstPA) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) @@ -478,7 +478,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl //---------------------------------------------------------------------------- bool -NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) +NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const { // verifico esistenza font corrente if ( m_pGDB == nullptr || m_sFont.empty()) diff --git a/FontNfe.h b/FontNfe.h index b6b9063..c2a4da5 100644 --- a/FontNfe.h +++ b/FontNfe.h @@ -26,16 +26,16 @@ class NfeFont ~NfeFont( void) ; bool SetCurrFont( const std::string& sFontPath, int nWeight, bool bItalic, double dHeight, double dRatio, double dAddAdvance) ; - bool GetCapHeight( double& dCapH) ; - bool GetAscent( double& dAsc) ; - bool GetDescent( double& dDesc) ; - bool GetXBox( const std::string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) ; - bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) ; + bool GetCapHeight( double& dCapH) const ; + bool GetAscent( double& dAsc) const ; + bool GetDescent( double& dDesc) const ; + bool GetXBox( const std::string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) const ; + bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) const ; bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYLINELIST& lstPL) ; + POLYLINELIST& lstPL) const ; bool ApproxWithArcs( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYARCLIST& lstPA) ; - bool GetTextLines( const std::string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) ; + POLYARCLIST& lstPA) const ; + bool GetTextLines( const std::string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const ; private : IGeomDB* m_pGDB ; diff --git a/FontOs.cpp b/FontOs.cpp index 8f5ae38..c23d99d 100644 --- a/FontOs.cpp +++ b/FontOs.cpp @@ -140,7 +140,7 @@ OsFont::CalcFontData( void) //---------------------------------------------------------------------------- bool -OsFont::GetCapHeight( double& dCapH) +OsFont::GetCapHeight( double& dCapH) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -154,7 +154,7 @@ OsFont::GetCapHeight( double& dCapH) //---------------------------------------------------------------------------- bool -OsFont::GetAscent( double& dAsc) +OsFont::GetAscent( double& dAsc) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -168,7 +168,7 @@ OsFont::GetAscent( double& dAsc) //---------------------------------------------------------------------------- bool -OsFont::GetDescent( double& dDesc) +OsFont::GetDescent( double& dDesc) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -182,7 +182,7 @@ OsFont::GetDescent( double& dDesc) //---------------------------------------------------------------------------- bool -OsFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) +OsFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -251,7 +251,7 @@ OsFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3B //---------------------------------------------------------------------------- bool -OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) +OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -332,7 +332,7 @@ OsFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) //---------------------------------------------------------------------------- bool OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYLINELIST& lstPL) + POLYLINELIST& lstPL) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -417,7 +417,7 @@ OsFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doubl //---------------------------------------------------------------------------- bool OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYARCLIST& lstPA) + POLYARCLIST& lstPA) const { // verifico esistenza font corrente if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty()) @@ -501,7 +501,7 @@ OsFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, double //---------------------------------------------------------------------------- bool -OsFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) +OsFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const { // pulisco i parametri di ritorno vPt.clear() ; @@ -605,7 +605,7 @@ MediaTwoFixed( FIXED fx1, FIXED fx2) //---------------------------------------------------------------------------- bool -OsFont::GetCharAdvance( unsigned int nChar, double& dAdvance) +OsFont::GetCharAdvance( unsigned int nChar, double& dAdvance) const { GLYPHMETRICS gm ; MAT2 mat = { {0,1},{0,0},{0,0},{0,1}} ; @@ -620,7 +620,7 @@ OsFont::GetCharAdvance( unsigned int nChar, double& dAdvance) //---------------------------------------------------------------------------- bool -OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC) +OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC) const { GLYPHMETRICS gm ; MAT2 mat = { {0,1},{0,0},{0,0},{0,1}} ; @@ -733,7 +733,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC //---------------------------------------------------------------------------- bool -OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const Point3d& ptEnd) +OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const Point3d& ptEnd) const { // verifico curva composita if ( pCCompo == nullptr) @@ -754,7 +754,7 @@ OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const //---------------------------------------------------------------------------- bool OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo, - const Point3d& ptStart, const Point3d& ptMid, const Point3d& ptEnd) + const Point3d& ptStart, const Point3d& ptMid, const Point3d& ptEnd) const { // verifico curva composita if ( pCCompo == nullptr) diff --git a/FontOs.h b/FontOs.h index 42f4d1e..3af5385 100644 --- a/FontOs.h +++ b/FontOs.h @@ -29,24 +29,24 @@ class OsFont ~OsFont( void) ; bool SetCurrFont( const std::string& sFontPath, int nWeight, bool bItalic, double dHeight, double dRatio, double dAddAdvance) ; - bool GetCapHeight( double& dCapH) ; - bool GetAscent( double& dAsc) ; - bool GetDescent( double& dDesc) ; - bool GetXBox( const std::string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) ; - bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) ; + bool GetCapHeight( double& dCapH) const ; + bool GetAscent( double& dAsc) const ; + bool GetDescent( double& dDesc) const ; + bool GetXBox( const std::string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3Box) const ; + bool GetOutline( const std::string& sText, int nInsPos, ICURVEPLIST& lstPC) const ; bool ApproxWithLines( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYLINELIST& lstPL) ; + POLYLINELIST& lstPL) const ; bool ApproxWithArcs( const std::string& sText, int nInsPos, double dLinTol, double dAngTolDeg, - POLYARCLIST& lstPA) ; - bool GetTextLines( const std::string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) ; + POLYARCLIST& lstPA) const ; + bool GetTextLines( const std::string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTOR& vLine) const ; private : bool CalcFontData( void) ; - bool GetCharAdvance( unsigned int nChar, double& dAdvance) ; - bool GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC) ; - bool AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const Point3d& ptEnd) ; + bool GetCharAdvance( unsigned int nChar, double& dAdvance) const ; + bool GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC) const ; + bool AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const Point3d& ptEnd) const ; bool AddCBezierQuadToCompo( ICurveComposite* pCCompo, - const Point3d& ptStart, const Point3d& ptMid, const Point3d& ptEnd) ; + const Point3d& ptStart, const Point3d& ptMid, const Point3d& ptEnd) const ; private : HDC m_hDC ;