Enforce GL_POLYGON_BIT in FTPolygonFont, so that the caller's context does not interfere with our rendering. Addresses SF bug #2021485.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/src/FTFont/FTPolygonFont.cpp b/src/FTFont/FTPolygonFont.cpp
index 594e91f..2948e0c 100644
--- a/src/FTFont/FTPolygonFont.cpp
+++ b/src/FTFont/FTPolygonFont.cpp
@@ -2,7 +2,7 @@
* FTGL - OpenGL font library
*
* Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
- * Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
+ * 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
@@ -87,3 +87,40 @@ FTPolygonFontImpl::FTPolygonFontImpl(FTFont *ftFont,
load_flags = FT_LOAD_NO_HINTING;
}
+
+template <typename T>
+inline FTPoint FTPolygonFontImpl::RenderI(const T* string, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode)
+{
+ // Protect GL_POLYGON
+ glPushAttrib(GL_POLYGON_BIT);
+
+ // Activate front and back face filling. If the caller wants only
+ // front face, it can set proper culling.
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ FTPoint tmp = FTFontImpl::Render(string, len,
+ position, spacing, renderMode);
+
+ glPopAttrib();
+
+ return tmp;
+}
+
+
+FTPoint FTPolygonFontImpl::Render(const char * string, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode)
+{
+ return RenderI(string, len, position, spacing, renderMode);
+}
+
+
+FTPoint FTPolygonFontImpl::Render(const wchar_t * string, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode)
+{
+ return RenderI(string, len, position, spacing, renderMode);
+}
+
diff --git a/src/FTFont/FTPolygonFontImpl.h b/src/FTFont/FTPolygonFontImpl.h
index ddf46ed..3f4f1e2 100644
--- a/src/FTFont/FTPolygonFontImpl.h
+++ b/src/FTFont/FTPolygonFontImpl.h
@@ -2,7 +2,7 @@
* FTGL - OpenGL font library
*
* Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
- * Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
+ * 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
@@ -45,16 +45,29 @@ class FTPolygonFontImpl : public FTFontImpl
* Set the outset distance for the font. Only implemented by
* FTOutlineFont, FTPolygonFont and FTExtrudeFont
*
- * @param depth The outset distance.
+ * @param outset The outset distance.
*/
virtual void Outset(float o) { outset = o; }
+ virtual FTPoint Render(const char *s, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode);
+
+ virtual FTPoint Render(const wchar_t *s, const int len,
+ FTPoint position, FTPoint spacing,
+ int renderMode);
+
private:
/**
- * The outset distance (front and back) for the font.
+ * The outset distance for the font.
*/
float outset;
+
+ /* Internal generic Render() implementation */
+ template <typename T>
+ inline FTPoint RenderI(const T *s, const int len,
+ FTPoint position, FTPoint spacing, int mode);
};
-#endif // __FTPolygonFontImpl__
+#endif // __FTPolygonFontImpl__