[mapguide-commits] r4592 - in trunk/MgDev/Common: Renderers Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Feb 9 18:27:24 EST 2010


Author: waltweltonlair
Date: 2010-02-09 18:27:23 -0500 (Tue, 09 Feb 2010)
New Revision: 4592

Modified:
   trunk/MgDev/Common/Renderers/FontManager.cpp
   trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
Log:
Fix #1269 (Two font manager issues)

Added code to address the two issues described in the ticket.

Also made a small optimization to RS_FontEngine.  There was code which was computing the
number of screen units per pixel instead of simply getting the value from the renderer.


Modified: trunk/MgDev/Common/Renderers/FontManager.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/FontManager.cpp	2010-02-09 17:52:20 UTC (rev 4591)
+++ trunk/MgDev/Common/Renderers/FontManager.cpp	2010-02-09 23:27:23 UTC (rev 4592)
@@ -249,37 +249,41 @@
             // do we have a file?
             if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
             {
-                wstring entryName(fontdir);
-                entryName += L"\\";
-                entryName += FindFileData.cFileName;
+                // skip special Windows files
+                if (wcscmp(FindFileData.cFileName, L"desktop.ini") != 0)
+                {
+                    wstring entryName(fontdir);
+                    entryName += L"\\";
+                    entryName += FindFileData.cFileName;
 
-                // ok, load up the face information
-                FT_Face face = NULL;
-                FT_Long index = 0;
-                FT_Long num_faces = 0;
+                    // ok, load up the face information
+                    FT_Face face = NULL;
+                    FT_Long index = 0;
+                    FT_Long num_faces = 0;
 
-                do
-                {
-                    string en;
-                    UnicodeString::WideCharToMultiByte(entryName.c_str(), en);
-                    error = FT_New_Face(m_library, en.c_str(), index, &face);
-
-                    if (!error)
+                    do
                     {
-                        // init num_faces if necessary
-                        if (!num_faces)
-                            num_faces = face->num_faces;
-                    }
+                        string en;
+                        UnicodeString::WideCharToMultiByte(entryName.c_str(), en);
+                        error = FT_New_Face(m_library, en.c_str(), index, &face);
 
-                    create_font(face, index, entryName.c_str());
+                        if (!error)
+                        {
+                            // init num_faces if necessary
+                            if (!num_faces)
+                                num_faces = face->num_faces;
+                        }
 
-                    // dispose of face
-                    FT_Done_Face(face);
+                        create_font(face, index, entryName.c_str());
 
-                    // increment our face index
-                    index++;
+                        // dispose of face
+                        FT_Done_Face(face);
+
+                        // increment our face index
+                        index++;
+                    }
+                    while (!error && index < num_faces);
                 }
-                while (!error && index < num_faces);
             }
 
             bOK = FindNextFile(hFile, &FindFileData);
@@ -287,6 +291,19 @@
 
         FindClose(hFile);
     }
+
+    // The font matching code iterates over the font list, and the first font in the
+    // list always becomes the one to beat.  In the case where none of the fonts match
+    // (they all have the same score), this first font ends up winning.  So make sure
+    // a reasonably good font, like Arial, is the first one in the list.
+    wstring lowerName = L"arial"; // use lower-case
+    RS_Font* font = (RS_Font*)FindFont(lowerName, false, false);
+    if (font && font->m_fullname == lowerName)
+    {
+        // we found Arial - move it to the front
+        m_fontlist.remove(font);
+        m_fontlist.push_front(font);
+    }
 }
 #else
 // initialize the font list

Modified: trunk/MgDev/Common/Stylization/RS_FontEngine.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/RS_FontEngine.cpp	2010-02-09 17:52:20 UTC (rev 4591)
+++ trunk/MgDev/Common/Stylization/RS_FontEngine.cpp	2010-02-09 23:27:23 UTC (rev 4592)
@@ -652,7 +652,7 @@
 
     // truncate the offset to the nearest pixel so we get uniform ghosting around
     // the string (the same number of pixels on each side after rendering)
-    double screenUnitsPerPixel = MILLIMETERS_PER_INCH * m_pSERenderer->GetScreenUnitsPerMillimeterDevice() / m_pSERenderer->GetDpi();
+    double screenUnitsPerPixel = m_pSERenderer->GetScreenUnitsPerPixel();
     offset -= fmod(offset, screenUnitsPerPixel);
 
     // finally, make sure we have at least one pixel's worth of offset
@@ -904,7 +904,7 @@
 
     // truncate the offset to the nearest pixel so we get uniform ghosting around
     // the string (the same number of pixels on each side after rendering)
-    double screenUnitsPerPixel = MILLIMETERS_PER_INCH * m_pSERenderer->GetScreenUnitsPerMillimeterDevice() / m_pSERenderer->GetDpi();
+    double screenUnitsPerPixel = m_pSERenderer->GetScreenUnitsPerPixel();
     offset -= fmod(offset, screenUnitsPerPixel);
 
     // finally, make sure we have at least one pixel's worth of offset



More information about the mapguide-commits mailing list