Commit b066d7826070749499011c4f37c764b1610071ad

sammy 2010-05-23T16:30:54

Add query functions to request FTGL configuration information: - C version: ftglGetString(); - C++ version: FTGL::GetString(); Currently supported strings are: - FTGL_CONFIG_VERSION: FTGL version information

diff --git a/demo/c-demo.c b/demo/c-demo.c
index 7dcf034..79028f8 100644
--- a/demo/c-demo.c
+++ b/demo/c-demo.c
@@ -244,6 +244,9 @@ int main(int argc, char **argv)
     ftglSetFontFaceSize(font[2], 80, 72);
     ftglSetFontCharMap(font[2], ft_encoding_unicode);
 
+    fprintf(stderr, "Using FTGL version %s\n",
+            ftglGetString(FTGL_CONFIG_VERSION));
+
     /* Run GLUT loop */
     glutMainLoop();
 
diff --git a/demo/simple.cpp b/demo/simple.cpp
index 850e312..c9b2db2 100644
--- a/demo/simple.cpp
+++ b/demo/simple.cpp
@@ -237,6 +237,9 @@ int main(int argc, char **argv)
     font[2]->FaceSize(80);
     font[2]->CharMap(ft_encoding_unicode);
 
+    fprintf(stderr, "Using FTGL version %s\n",
+            FTGL::GetString(FTGL::CONFIG_VERSION));
+
     // Run GLUT loop
     glutMainLoop();
 
diff --git a/msvc/vc71/ftgl_dll.vcproj b/msvc/vc71/ftgl_dll.vcproj
index e3e2b97..2868153 100644
--- a/msvc/vc71/ftgl_dll.vcproj
+++ b/msvc/vc71/ftgl_dll.vcproj
@@ -163,6 +163,9 @@
 				RelativePath="..\..\src\FTFont\FTFontGlue.cpp">
 			</File>
 			<File
+				RelativePath="..\..\src\FTGL.cpp">
+			</File>
+			<File
 				RelativePath="..\..\src\FTGlyph\FTGlyph.cpp">
 			</File>
 			<File
diff --git a/msvc/vc8/ftgl_dll.vcproj b/msvc/vc8/ftgl_dll.vcproj
index cacdda6..c0bdc6e 100644
--- a/msvc/vc8/ftgl_dll.vcproj
+++ b/msvc/vc8/ftgl_dll.vcproj
@@ -236,6 +236,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\FTGL.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\FTGlyphContainer.cpp"
 				>
 			</File>
diff --git a/msvc/vc8/ftgl_static.vcproj b/msvc/vc8/ftgl_static.vcproj
index a83c9e2..0f991c7 100644
--- a/msvc/vc8/ftgl_static.vcproj
+++ b/msvc/vc8/ftgl_static.vcproj
@@ -171,6 +171,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\FTGL.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\FTGlyphContainer.cpp"
 				>
 			</File>
diff --git a/msvc/vc9/ftgl_dll.vcproj b/msvc/vc9/ftgl_dll.vcproj
index b95b5ab..bc55835 100644
--- a/msvc/vc9/ftgl_dll.vcproj
+++ b/msvc/vc9/ftgl_dll.vcproj
@@ -231,6 +231,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\FTGL.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\FTGlyphContainer.cpp"
 				>
 			</File>
diff --git a/msvc/vc9/ftgl_static.vcproj b/msvc/vc9/ftgl_static.vcproj
index 4b5a2d1..b805fc4 100644
--- a/msvc/vc9/ftgl_static.vcproj
+++ b/msvc/vc9/ftgl_static.vcproj
@@ -172,6 +172,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\FTGL.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\FTGlyphContainer.cpp"
 				>
 			</File>
diff --git a/src/FTGL.cpp b/src/FTGL.cpp
new file mode 100644
index 0000000..b2951d4
--- /dev/null
+++ b/src/FTGL.cpp
@@ -0,0 +1,53 @@
+/*
+ * FTGL - OpenGL font library
+ *
+ * Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "config.h"
+
+#include "FTInternals.h"
+
+namespace FTGL {
+
+char const *GetString(ConfigString config)
+{
+    switch(config)
+    {
+    case CONFIG_VERSION:
+        return PACKAGE_VERSION;
+    }
+
+    return 0;
+}
+
+} // namespace FTGL
+
+FTGL_BEGIN_C_DECLS
+
+char const *ftglGetString(int config)
+{
+    return FTGL::GetString(static_cast<FTGL::ConfigString>(config));
+}
+
+FTGL_END_C_DECLS
+
diff --git a/src/FTGL/ftgl.h b/src/FTGL/ftgl.h
index a8a176c..cb1318f 100644
--- a/src/FTGL/ftgl.h
+++ b/src/FTGL/ftgl.h
@@ -65,6 +65,21 @@ namespace FTGL
         ALIGN_RIGHT   = 2,
         ALIGN_JUSTIFY = 3
     } TextAlignment;
+
+    typedef enum
+    {
+        CONFIG_VERSION = 1,
+    } ConfigString;
+
+    /**
+     * Return a string describing the current %FTGL instance
+     *
+     * @param config  Name of the string to retrieve. Can be one of:
+     *                 - CONFIG_VERSION: return the %FTGL release number.
+     * @return  A pointer to a constant string containing the requested
+     *          information, or 0 in case of invalid argument.
+     */
+    extern char const *GetString(ConfigString config);
 }
 #else
 #   define FTGL_RENDER_FRONT 0x0001
@@ -76,6 +91,18 @@ namespace FTGL
 #   define FTGL_ALIGN_CENTER  1
 #   define FTGL_ALIGN_RIGHT   2
 #   define FTGL_ALIGN_JUSTIFY 3
+
+#   define FTGL_CONFIG_VERSION 1
+
+    /**
+     * Return a string describing the current %FTGL instance
+     *
+     * @param config  Name of the string to retrieve. Can be one of:
+     *                 - FTGL_CONFIG_VERSION: return the %FTGL release number.
+     * @return  A pointer to a constant string containing the requested
+     *          information, or NULL in case of invalid argument.
+     */
+    extern char const *ftglGetString(int config);
 #endif
 
 // Compiler-specific conditional compilation
diff --git a/src/Makefile.am b/src/Makefile.am
index 1cf74e5..731d364 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,7 @@ libftgl_la_SOURCES = \
     FTContour.h \
     FTFace.cpp \
     FTFace.h \
+    FTGL.cpp \
     FTGlyphContainer.cpp \
     FTGlyphContainer.h \
     FTInternals.h \