User forums > Using Code::Blocks

How to use the temporary fonts?

<< < (2/2)

MortenMacFly:

--- Quote from: Loaden on January 17, 2010, 02:47:23 pm ---yes! is same.
http://docs.wxwidgets.org/stable/wx_filefunctions.html#wxfindfirstfile

--- End quote ---
Ok. But I'd still prefer IsEmpty() to avoid conflicts / misunderstandings with wxSting's Empty() method (notice the capital first letter), which clears the string.

Loaden:

--- Quote from: MortenMacFly on January 17, 2010, 03:28:55 pm ---
--- Quote from: Loaden on January 17, 2010, 02:47:23 pm ---yes! is same.
http://docs.wxwidgets.org/stable/wx_filefunctions.html#wxfindfirstfile

--- End quote ---
Ok. But I'd still prefer IsEmpty() to avoid conflicts / misunderstandings with wxSting's Empty() method (notice the capital first letter), which clears the string.

--- End quote ---
Well.

--- Code: ---#ifdef __WXMSW__
        wxString font = wxFindFirstFile(_T("share/CodeBlocks/fonts/*.*"));
        while (!font.IsEmpty())
        {
            AddFontResource(font);
            font = wxFindNextFile();
        }

        SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
#endif
--- End code ---

Loaden:
Need to free fonts, this patch better.

--- Code: ---Index: app.cpp

===================================================================

--- app.cpp (revision 6089)

+++ app.cpp (working copy)

@@ -656,6 +656,16 @@

 
         CheckVersion();
 
+#ifdef __WXMSW__
+        wxString font = wxFindFirstFile(_T("share/CodeBlocks/fonts/*.*"));
+        while (!font.IsEmpty())
+        {
+            ::AddFontResource(font);
+            font = wxFindNextFile();
+        }
+        ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
+#endif
+
         // run startup script
         try
         {
@@ -725,6 +735,8 @@

 #ifdef __WXMSW__
     if (m_ExceptionHandlerLib)
         FreeLibrary(m_ExceptionHandlerLib);
+
+
 #endif
     if (m_pSingleInstance)
         delete m_pSingleInstance;
@@ -732,6 +744,16 @@

     // ultimate shutdown...
     Manager::Free();
 
+#ifdef __WXMSW__
+        wxString font = wxFindFirstFile(_T("share/CodeBlocks/fonts/*.*"));
+        while (!font.IsEmpty())
+        {
+            ::RemoveFontResource(font);
+            font = wxFindNextFile();
+        }
+        ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
+#endif
+
     // WX docs say that this function's return value is ignored,
     // but we return our value anyway. It might not be ignored at some point...
     return m_Batch ? m_BatchExitCode : 0;

--- End code ---

[attachment deleted by admin]

Loaden:
Sorry, need an absolute path, rather than a relative path!

--- Code: ---Index: app.cpp

===================================================================

--- app.cpp (revision 6089)

+++ app.cpp (working copy)

@@ -656,6 +656,17 @@

 
         CheckVersion();
 
+#ifdef __WXMSW__
+        wxString fontPath = GetAppPath() + _T("/share/CodeBlocks/fonts/*.*");
+        wxString font = wxFindFirstFile(fontPath);
+        while (!font.IsEmpty())
+        {
+            ::AddFontResource(font);
+            font = wxFindNextFile();
+        }
+        ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
+#endif
+
         // run startup script
         try
         {
@@ -725,6 +736,8 @@

 #ifdef __WXMSW__
     if (m_ExceptionHandlerLib)
         FreeLibrary(m_ExceptionHandlerLib);
+
+
 #endif
     if (m_pSingleInstance)
         delete m_pSingleInstance;
@@ -732,6 +745,17 @@

     // ultimate shutdown...
     Manager::Free();
 
+#ifdef __WXMSW__
+        wxString fontPath = GetAppPath() + _T("/share/CodeBlocks/fonts/*.*");
+        wxString font = wxFindFirstFile(fontPath);
+        while (!font.IsEmpty())
+        {
+            ::RemoveFontResource(font);
+            font = wxFindNextFile();
+        }
+        ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
+#endif
+
     // WX docs say that this function's return value is ignored,
     // but we return our value anyway. It might not be ignored at some point...
     return m_Batch ? m_BatchExitCode : 0;

--- End code ---

[attachment deleted by admin]

Navigation

[0] Message Index

[*] Previous page

Go to full version