* Started documenting the FTLayout C bindings.
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
diff --git a/src/FTGL/FTLayout.h b/src/FTGL/FTLayout.h
index ac0cb32..e422543 100644
--- a/src/FTGL/FTLayout.h
+++ b/src/FTGL/FTLayout.h
@@ -78,38 +78,49 @@ class FTGL_EXPORT FTLayout
FTGL_BEGIN_C_DECLS
+/**
+ * FTGLlayout is the interface for layout managers that render text.
+ */
struct _FTGLlayout;
typedef struct _FTGLlayout FTGLlayout;
-FTGL_EXPORT FTGLlayout *ftglCreateSimpleLayout(void);
-
-FTGL_EXPORT void ftglDestroyLayout(FTGLlayout*);
-
-FTGL_EXPORT void ftglLayoutBBox (FTGLlayout *, const char*, float []);
-
-FTGL_EXPORT void ftglLayoutRender (FTGLlayout *, const char *);
-FTGL_EXPORT void ftglLayoutRenderMode (FTGLlayout *, const char *, int);
-FTGL_EXPORT void ftglLayoutRenderSpace (FTGLlayout *, const char *, float);
-
-FTGL_EXPORT void ftglLayoutSetFont (FTGLlayout *, FTGLfont*);
-FTGL_EXPORT FTGLfont* ftglLayoutGetFont (FTGLlayout *);
+/**
+ * Destroy an FTGL layout object.
+ *
+ * @param layout An FTGLlayout* object.
+ */
+FTGL_EXPORT void ftglDestroyLayout(FTGLlayout* layout);
-FTGL_EXPORT void ftglLayoutSetLineLength (FTGLlayout *, const float);
-FTGL_EXPORT float ftglLayoutGetLineLength (FTGLlayout *);
+/**
+ * Get the bounding box for a string.
+ *
+ * @param layout An FTGLlayout* object.
+ * @param string A char buffer
+ * @param bounds An array of 6 float values where the bounding box's lower
+ * left near and upper right far 3D coordinates will be stored.
+ */
+FTGL_EXPORT void ftglGetLayoutBBox(FTGLlayout *layout, const char* string,
+ float bounds[6]);
-#ifdef __cplusplus /*FIXME: Éric, this is WRONG */
-FTGL_EXPORT void ftglLayoutSetAlignment (FTGLlayout *, const FTGL::TextAlignment);
-FTGL_EXPORT FTGL::TextAlignment ftglLayoutGetAlignement (FTGLlayout *);
-#else
-FTGL_EXPORT void ftglLayoutSetAlignment (FTGLlayout *, const int);
-FTGL_EXPORT int ftglLayoutGetAlignement (FTGLlayout *);
-#endif
+/**
+ * Render a string of characters.
+ *
+ * @param layout An FTGLlayout* object.
+ * @param string Char string to be output.
+ * @param mode Render mode to display.
+ */
+FTGL_EXPORT void ftglRenderLayout(FTGLlayout *layout, const char *string,
+ int mode);
-FTGL_EXPORT void ftglLayoutSetLineSpacing (FTGLlayout *, const float);
-FTGL_EXPORT float ftglLayoutGetLineSpacing (FTGLlayout *);
+/**
+ * Query a layout for errors.
+ *
+ * @param layout An FTGLlayout* object.
+ * @return The current error code.
+ */
+FTGL_EXPORT FT_Error ftglGetLayoutError(FTGLlayout* layout);
FTGL_END_C_DECLS
#endif /* __FTLayout__ */
-
diff --git a/src/FTGL/FTSimpleLayout.h b/src/FTGL/FTSimpleLayout.h
index 10ada2f..6d17313 100644
--- a/src/FTGL/FTSimpleLayout.h
+++ b/src/FTGL/FTSimpleLayout.h
@@ -133,5 +133,25 @@ class FTGL_EXPORT FTSimpleLayout : public FTLayout
#endif //__cplusplus
+FTGL_BEGIN_C_DECLS
+
+FTGL_EXPORT FTGLlayout *ftglCreateSimpleLayout(void);
+
+FTGL_EXPORT void ftglRenderLayoutSpace(FTGLlayout *, const char *, float);
+
+FTGL_EXPORT void ftglSetLayoutFont(FTGLlayout *, FTGLfont*);
+FTGL_EXPORT FTGLfont *ftglGetLayoutFont(FTGLlayout *);
+
+FTGL_EXPORT void ftglSetLayoutLineLength(FTGLlayout *, const float);
+FTGL_EXPORT float ftglGetLayoutLineLength(FTGLlayout *);
+
+FTGL_EXPORT void ftglSetLayoutAlignment(FTGLlayout *, const int);
+FTGL_EXPORT int ftglGetLayoutAlignement(FTGLlayout *);
+
+FTGL_EXPORT void ftglSetLayoutLineSpacing(FTGLlayout *, const float);
+FTGL_EXPORT float ftglGetLayoutLineSpacing(FTGLlayout *);
+
+FTGL_END_C_DECLS
+
#endif /* __FTSimpleLayout__ */
diff --git a/src/FTLayout/FTLayoutGlue.cpp b/src/FTLayout/FTLayoutGlue.cpp
index 3772f36..76b07d7 100644
--- a/src/FTLayout/FTLayoutGlue.cpp
+++ b/src/FTLayout/FTLayoutGlue.cpp
@@ -87,23 +87,19 @@ void ftglDestroyLayout(FTGLlayout *l)
}
// virtual void BBox(const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)
-C_FUN(void, ftglLayoutBBox, (FTGLlayout *f, const char * s, float c[6]),
+C_FUN(void, ftgGetlLayoutBBox, (FTGLlayout *f, const char * s, float c[6]),
return, BBox, (s, c[0], c[1], c[2], c[3], c[4], c[5]));
-// virtual void Render(const char* string);
-C_FUN(void, ftglLayoutRender, (FTGLlayout *f, const char *s),
- return, Render, (s));
-
// virtual void Render(const char* string, int renderMode);
-C_FUN(void, ftglLayoutRenderMode, (FTGLlayout *f, const char *s, int r),
+C_FUN(void, ftglRenderLayout, (FTGLlayout *f, const char *s, int r),
return, Render, (s, r));
// void RenderSpace(const char *string, const float ExtraSpace = 0.0)
-C_FUN(void, ftglLayoutRenderSpace, (FTGLlayout *f, const char *s, float e),
+C_FUN(void, ftglRenderLayoutSpace, (FTGLlayout *f, const char *s, float e),
return, RenderSpace, (s, e));
// void SetFont(FTFont *fontInit)
-void ftglLayoutSetFont(FTGLlayout *f, FTGLfont *font)
+void ftglSetLayoutFont(FTGLlayout *f, FTGLfont *font)
{
if(!f || !f->ptr)
{
@@ -121,7 +117,7 @@ void ftglLayoutSetFont(FTGLlayout *f, FTGLfont *font)
}
// FTFont *GetFont()
-FTGLfont *ftglLayoutGetFont(FTGLlayout *f)
+FTGLfont *ftglGetLayoutFont(FTGLlayout *f)
{
if(!f || !f->ptr)
{
@@ -132,28 +128,31 @@ FTGLfont *ftglLayoutGetFont(FTGLlayout *f)
}
// void SetLineLength(const float LineLength);
-C_FUN(void, ftglLayoutSetLineLength, (FTGLlayout *f, const float length),
+C_FUN(void, ftglSetLayoutLineLength, (FTGLlayout *f, const float length),
return, SetLineLength, (length));
// float GetLineLength() const
-C_FUN(float, ftglLayoutGetLineLength, (FTGLlayout *f),
+C_FUN(float, ftglGetLayoutLineLength, (FTGLlayout *f),
return 0.0f, GetLineLength, ());
// void SetAlignment(const TextAlignment Alignment)
-C_FUN(void, ftglLayoutSetAlignment, (FTGLlayout *f, FTGL::TextAlignment a),
+C_FUN(void, ftglSetLayoutAlignment, (FTGLlayout *f, const int a),
return, SetAlignment, (a));
// TextAlignment GetAlignment() const
-C_FUN(FTGL::TextAlignment, ftglLayoutGetAlignement, (FTGLlayout *f),
+C_FUN(int, ftglGetLayoutAlignement, (FTGLlayout *f),
return FTGL::ALIGN_LEFT, GetAlignment, ());
// void SetLineSpacing(const float LineSpacing)
-C_FUN(void, ftglLayoutSetLineSpacing, (FTGLlayout *f, const float l),
+C_FUN(void, ftglSetLayoutLineSpacing, (FTGLlayout *f, const float l),
return, SetLineSpacing, (l));
// float GetLineSpacing() const
-C_FUN(float, ftglLayoutGetLineSpacing, (FTGLlayout *f),
+C_FUN(float, ftglGetLayoutLineSpacing, (FTGLlayout *f),
return 0.0f, GetLineSpacing, ());
+// FT_Error FTLayout::Error() const;
+C_FUN(FT_Error, ftglGetLayoutError, (FTGLlayout *f), return -1, Error, ());
+
FTGL_END_C_DECLS