aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Font
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/Font')
-rw-r--r--src/libjin/Graphics/Font/Font.h66
-rw-r--r--src/libjin/Graphics/Font/TTF.cpp10
2 files changed, 66 insertions, 10 deletions
diff --git a/src/libjin/Graphics/Font/Font.h b/src/libjin/Graphics/Font/Font.h
index 14211e1..1d09cfc 100644
--- a/src/libjin/Graphics/Font/Font.h
+++ b/src/libjin/Graphics/Font/Font.h
@@ -13,23 +13,79 @@ namespace jin
class Font
{
public:
+ ///
+ /// Font constructor.
+ ///
Font(unsigned fontsize)
- : fontSize(fontsize)
+ : mFontSize(fontsize)
{
}
+
+ ///
+ /// Font destructor.
+ ///
virtual ~Font() {};
+ ///
+ /// Create page with given text.
+ ///
+ /// @param text Text to be typesetted.
+ /// @param lineheight Line height of text.
+ /// @param spacing Spacing between characters. 0 by default.
+ /// @return Page if created successfully, otherwise return null.
+ ///
virtual Page* typeset(const Text& text, int lineheight, int spacing = 0) = 0;
- virtual Page* typeset(const Content& text, int lineheight, int spacing = 0) = 0;
+ ///
+ /// Create page with given unicode codepoints.
+ ///
+ /// @param content Unicode codepoints to be typesetted.
+ /// @param lineheight Line height of text.
+ /// @param spacing Spacing between characters. 0 by default.
+ /// @return Page if created successfully, otherwise return null.
+ ///
+ virtual Page* typeset(const Content& content, int lineheight, int spacing = 0) = 0;
+
+ ///
+ /// Render page to given position.
+ ///
+ /// @param page Page to be rendered.
+ /// @param x X value of the position.
+ /// @param y Y value of the position.
+ ///
virtual void print(const Page* page, int x, int y) = 0;
- virtual void print(const Content& text, int x, int y, int lineheight, int spacing = 0) = 0;
+
+ ///
+ /// Render unicode codepoints to given position.
+ ///
+ /// @param content Unicode codepoints to be typesetted.
+ /// @param x X value of the position.
+ /// @param y Y value of the position.
+ /// @param lineheight Line height of the content.
+ /// @param spacing Spacing between characters.
+ ///
+ virtual void print(const Content& content, int x, int y, int lineheight, int spacing = 0) = 0;
+
+ ///
+ /// Render text to given position.
+ ///
+ /// @param text Text to be rendered.
+ /// @param x X value of the position.
+ /// @param y Y value of the position.
+ /// @param lineheight Line height of the text.
+ /// @param spacing Spacing between characters.
+ ///
virtual void print(const Text& text, int x, int y, int lineheight, int spacing = 0) = 0;
- inline unsigned getFontSize() { return fontSize; };
+ ///
+ /// Get font size.
+ ///
+ /// @return Font size.
+ ///
+ inline unsigned getFontSize() { return mFontSize; };
protected:
- unsigned fontSize;
+ unsigned mFontSize;
};
diff --git a/src/libjin/Graphics/Font/TTF.cpp b/src/libjin/Graphics/Font/TTF.cpp
index 4c3648a..b90bbba 100644
--- a/src/libjin/Graphics/Font/TTF.cpp
+++ b/src/libjin/Graphics/Font/TTF.cpp
@@ -317,7 +317,7 @@ namespace jin
int TTF::getCharWidth(int c)
{
int adw, lsb;
- ttf->pushTTFsize(fontSize);
+ ttf->pushTTFsize(mFontSize);
ttf->getHMetrics(c, &adw, &lsb);
ttf->popTTFsize();
return adw;
@@ -330,7 +330,7 @@ namespace jin
int TTF::getTextWidth(const Content& t, int spacing)
{
- ttf->pushTTFsize(fontSize);
+ ttf->pushTTFsize(mFontSize);
int res = 0;
int tmp = 0;
for (Codepoint c : t)
@@ -352,7 +352,7 @@ namespace jin
int TTF::getTextHeight(const Content& t, int lineheight)
{
- ttf->pushTTFsize(fontSize);
+ ttf->pushTTFsize(mFontSize);
int res = 0;
bool newline = true;
for (Codepoint c : t)
@@ -372,7 +372,7 @@ namespace jin
void TTF::getTextBox(const Content& text, int* w, int* h, int lineheight, int spacing)
{
- ttf->pushTTFsize(fontSize);
+ ttf->pushTTFsize(mFontSize);
*w = 0;
*h = 0;
int tmp = 0;
@@ -402,7 +402,7 @@ namespace jin
TTF::TTFGlyph& TTF::bakeGlyph(unsigned int character)
{
int w, h, xoff, yoff;
- ttf->pushTTFsize(fontSize);
+ ttf->pushTTFsize(mFontSize);
GLuint atlas = atlases.back();
const Color* bitmap = ttf->getCodepointBitmap(character, &w, &h, &xoff, &yoff);
int adw, lsb;