Skip to content

Commit f71a387

Browse files
authored
GLICT/fonts.cpp: Add docstrings to a few more functions and methods.
1 parent b4a6a29 commit f71a387

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

glict/GLICT/fonts.cpp

+52-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ glictFont* glictCreateFont(const char* name) {
7878
return fnt;
7979
}
8080

81+
/** \brief Return the font specified by the passed name.
82+
* \param name Specifies the name of the font, for example `system`
83+
* \return The font specified by the name
84+
*/
8185
glictFont* glictFindFont(const char* name) {
8286

8387
_GLICTFONTVECTORITERATOR it;
@@ -86,6 +90,10 @@ glictFont* glictFindFont(const char* name) {
8690
return NULL;
8791
}
8892

93+
/** \brief Unregisters the font specified by the passed name.
94+
* \param name Specifies the name of the font to be deleted
95+
* \return True if the font was deleted, false if it was not found
96+
*/
8997
bool glictDeleteFont(const char* name) {
9098
_GLICTFONTVECTORITERATOR it;
9199

@@ -202,10 +210,31 @@ bool glictFontRender(const char* text, const char* fontname, float fontsize, flo
202210
return false;
203211
}
204212

213+
/** \brief Returns the rendered dimensions of the passed text for the passed font.
214+
* \param text Specifies the text being drawn
215+
* \param font Specifies the font used for rendering
216+
* \return Returns the width of the text in pixels
217+
*
218+
* This is a convenience function that calls the other version of this function
219+
* with default font size of 10.
220+
*/
205221
float glictFontSize(const char* text, const char* font) {
206222
return glictFontSize(text, font, 10);
207223
}
208224

225+
/**
226+
* \brief Returns the rendered dimensions of the passed text for the passed font.
227+
* \param text Specifies the text being drawn
228+
* \param font Specifies the font used for rendering
229+
* \param size Specifies the height of the font
230+
* \return Width of the text in pixels
231+
*
232+
* This function finds the font specified by font parameter, and then calls its
233+
* size function. If the font does not support size function, it will attempt to
234+
* resize the font by calling the render function with a scaling factor. In
235+
* this case, the scaling factor assumes that the font is rendered at size 1
236+
* (height of 1px).
237+
*/
209238
float glictFontSize(const char* text, const char* font, float size) {
210239

211240
glictFont* fnt = glictFindFont(font);
@@ -222,6 +251,10 @@ float glictFontSize(const char* text, const char* font, float size) {
222251
return 0;
223252
}
224253

254+
/** \brief Sets the currently active color for the passed font.
255+
* \param font Specifies the font for which the color is being set
256+
* \param col Specifies the color to be set
257+
*/
225258
void glictFontColor(const char* font, glictColor &col) {
226259
glictFont* fnt = glictFindFont(font);
227260
if (!fnt) {
@@ -233,6 +266,11 @@ void glictFontColor(const char* font, glictColor &col) {
233266
fnt->SetColor(fnt->fontparam,col);
234267
}
235268
}
269+
270+
/** \brief Returns the currently active color for the passed font.
271+
* \param font Specifies the font for which the color is being retrieved
272+
* \return Currently active color for the font
273+
*/
236274
glictColor glictFontColor(const char* font) {
237275
glictFont* fnt = glictFindFont(font);
238276
if (!fnt) {
@@ -244,7 +282,10 @@ glictColor glictFontColor(const char* font) {
244282
return fnt->activecolor;
245283
}
246284

247-
285+
/** \brief Counts the number of lines in the passed string.
286+
* \param txt The text in which lines are being counted
287+
* \return The number of lines in the text
288+
*/
248289
int glictFontNumberOfLines(const char* txt) {
249290
int count=1; // at least 1 line
250291
for (unsigned int i=0;i<strlen(txt);i++) {
@@ -276,9 +317,19 @@ glictFont::~glictFont() {
276317
// nope
277318
}
278319

320+
/** \brief Sets the name of the font represented by this class instance.
321+
* \param name The name of the font
322+
*
323+
* This function sets the name of the font. The name is used to identify the
324+
* font in the font list.
325+
*/
279326
void glictFont::SetName(const char* name) {
280327
this->name = name;
281328
}
329+
330+
/** \brief Gets the name of this font.
331+
* \return The name of the font
332+
*/
282333
std::string glictFont::GetName() {
283334
return this->name;
284335
}

0 commit comments

Comments
 (0)