EgtGeomKernel 2.2f1 :

- migliorie a gestione font.
This commit is contained in:
Dario Sassi
2020-06-01 07:45:39 +00:00
parent 420a82b278
commit e8796dac88
7 changed files with 67 additions and 65 deletions
BIN
View File
Binary file not shown.
+9 -9
View File
@@ -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) ;
+18 -16
View File
@@ -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 ;
+8 -8
View File
@@ -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())
+8 -8
View File
@@ -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 ;
+12 -12
View File
@@ -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)
+12 -12
View File
@@ -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 ;