Patch level : 4.0
Files correlati : xvaga Ricompilazione Demo : [ ] Commento : Corretta gestione font per pdf git-svn-id: svn://10.65.10.50/trunk@14246 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9552027b8a
commit
ba0b6eb599
@ -615,6 +615,54 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
|
|||||||
return pTDC != NULL;
|
return pTDC != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// Font cache
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
WX_DECLARE_HASH_MAP(wxString, wxFont*, wxStringHash, wxStringEqual, wxFontHashMap);
|
||||||
|
|
||||||
|
class TFontCache
|
||||||
|
{
|
||||||
|
wxFontHashMap* m_map;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxFont& FindOrCreate(int pointSize, int family, int style, int weight,
|
||||||
|
bool underline, const wxString& face);
|
||||||
|
void Destroy();
|
||||||
|
TFontCache() : m_map(NULL) { }
|
||||||
|
~TFontCache() { Destroy(); }
|
||||||
|
|
||||||
|
} XVT_FONT_CACHE;
|
||||||
|
|
||||||
|
void TFontCache::Destroy()
|
||||||
|
{
|
||||||
|
if (m_map)
|
||||||
|
{
|
||||||
|
m_map->clear();
|
||||||
|
// delete m_map; // NON funziona ma non si capisce perche': PAZIENZA!
|
||||||
|
m_map = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxFont& TFontCache::FindOrCreate(int pointSize, int family, int style, int weight,
|
||||||
|
bool underline, const wxString& face)
|
||||||
|
{
|
||||||
|
if (m_map == NULL)
|
||||||
|
m_map = new wxFontHashMap;
|
||||||
|
|
||||||
|
wxString key;
|
||||||
|
key.Printf("%s_%d_%d_%d_%d", face, pointSize, style, weight, underline);
|
||||||
|
wxFont* pFont = (*m_map)[key];
|
||||||
|
if (pFont == NULL)
|
||||||
|
{
|
||||||
|
pFont = new wxFont(pointSize, family, style, weight, underline, face);
|
||||||
|
pFont->SetPointSize(pointSize); // Colpo di classe indispensabile per i PDF :-)
|
||||||
|
(*m_map)[key] = pFont;
|
||||||
|
}
|
||||||
|
return *pFont;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Generic window class
|
// Generic window class
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -2179,7 +2227,7 @@ wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
|||||||
const int nTarget10 = 10 * ppi.x; // pixel in 10 pollici in larghezza
|
const int nTarget10 = 10 * ppi.x; // pixel in 10 pollici in larghezza
|
||||||
const int cpi10 = 10 * 120 / nSize; // caratteri stimati in 10 pollici
|
const int cpi10 = 10 * 120 / nSize; // caratteri stimati in 10 pollici
|
||||||
const wxString str('M', cpi10); // stringa campione per stimare la larghezza
|
const wxString str('M', cpi10); // stringa campione per stimare la larghezza
|
||||||
int nMin = 1, nMax = nSize*16; // Limiti arbitrari
|
int nMin = 1, nMax = nSize*16; // Limiti arbitrari
|
||||||
int nBest = 0;
|
int nBest = 0;
|
||||||
while (nMin <= nMax)
|
while (nMin <= nMax)
|
||||||
{
|
{
|
||||||
@ -2205,7 +2253,7 @@ wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
|||||||
// Pezza per cercare di ovviare a dimensioni assurde calcolate dai sistemi Win *
|
// Pezza per cercare di ovviare a dimensioni assurde calcolate dai sistemi Win *
|
||||||
// Praticamente succede che il Courier 70 sia piu' piccolo del Curier 60
|
// Praticamente succede che il Courier 70 sia piu' piccolo del Curier 60
|
||||||
// Per cui una volta candidata una dimensione (nBest) tramite le righe precedenti
|
// Per cui una volta candidata una dimensione (nBest) tramite le righe precedenti
|
||||||
// cerco il primo font piu' piccolo che non sfonda
|
// cerco il primo font piu' piccolo che non sfondi
|
||||||
bool bPrevGood = true;
|
bool bPrevGood = true;
|
||||||
for (int i = 15; i > 0; i--)
|
for (int i = 15; i > 0; i--)
|
||||||
{
|
{
|
||||||
@ -2233,9 +2281,8 @@ wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
|
|||||||
nSize = (int)(nSize * dPrintScale + 0.5);
|
nSize = (int)(nSize * dPrintScale + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont* font = wxTheFontList->FindOrCreateFont(
|
// return wxTheFontList->FindOrCreateFont(nSize, Family(), Style(), Weight(), Underline(), FaceName());
|
||||||
nSize, Family(), Style(), Weight(), Underline(), FaceName());
|
return XVT_FONT_CACHE.FindOrCreate(nSize, Family(), Style(), Weight(), Underline(), FaceName());
|
||||||
return *font;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFontId::Copy(const wxFont& rFont)
|
void TFontId::Copy(const wxFont& rFont)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user