From 1b6e3c1750aa199719a6165276ae858c1b89096e Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sat, 19 Oct 2002 14:01:05 +0000 Subject: ascent and descent --- src/Font.cc | 9 ++++++++- src/Font.hh | 4 +++- src/FontImp.hh | 4 +++- src/XFontImp.hh | 4 +++- src/XftFontImp.hh | 4 +++- src/XmbFontImp.hh | 4 +++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Font.cc b/src/Font.cc index 7023c88..c86bb84 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.cc,v 1.15 2002/10/16 23:22:45 fluxgen Exp $ +//$Id: Font.cc,v 1.16 2002/10/19 14:01:05 fluxgen Exp $ #include "Font.hh" @@ -152,6 +152,13 @@ unsigned int Font::height() const { return m_fontimp->height(); } +int Font::ascent() const { + return m_fontimp->ascent(); +} + +int Font::descent() const { + return m_fontimp->descent(); +} void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const { if (text == 0 || len == 0) return; diff --git a/src/Font.hh b/src/Font.hh index b7b9cf2..93cbd87 100644 --- a/src/Font.hh +++ b/src/Font.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Font.hh,v 1.7 2002/10/16 23:26:41 fluxgen Exp $ +//$Id: Font.hh,v 1.8 2002/10/19 14:00:37 fluxgen Exp $ #ifndef FBTK_FONT_HH #define FBTK_FONT_HH @@ -60,6 +60,8 @@ public: */ unsigned int textWidth(const char * const text, unsigned int size) const; unsigned int height() const; + int ascent() const; + int descent() const; void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; bool isAntialias() const { return m_antialias; } private: diff --git a/src/FontImp.hh b/src/FontImp.hh index 0f4db9a..f822b73 100644 --- a/src/FontImp.hh +++ b/src/FontImp.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FontImp.hh,v 1.2 2002/10/15 16:43:15 fluxgen Exp $ +// $Id: FontImp.hh,v 1.3 2002/10/19 13:57:48 fluxgen Exp $ #ifndef FBTK_FONTIMP_HH #define FBTK_FONTIMP_HH @@ -42,6 +42,8 @@ public: virtual bool load(const std::string &name) = 0; virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const = 0; virtual unsigned int textWidth(const char * const text, unsigned int size) const = 0; + virtual int ascent() const = 0; + virtual int descent() const = 0; virtual unsigned int height() const = 0; virtual bool loaded() const = 0; protected: diff --git a/src/XFontImp.hh b/src/XFontImp.hh index 30ad7ed..8ea7af1 100644 --- a/src/XFontImp.hh +++ b/src/XFontImp.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XFontImp.hh,v 1.2 2002/10/15 16:44:26 fluxgen Exp $ +// $Id: XFontImp.hh,v 1.3 2002/10/19 13:58:47 fluxgen Exp $ #ifndef XFONTIMP_HH #define XFONTIMP_HH @@ -33,6 +33,8 @@ public: bool load(const std::string &filename); unsigned int textWidth(const char * const text, unsigned int size) const; unsigned int height() const; + int ascent() const { return m_fontstruct ? m_fontstruct->ascent : 0; } + int descent() const { return m_fontstruct ? m_fontstruct->descent : 0; } void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; bool loaded() const { return m_fontstruct != 0; } private: diff --git a/src/XftFontImp.hh b/src/XftFontImp.hh index d03e65a..78f4080 100644 --- a/src/XftFontImp.hh +++ b/src/XftFontImp.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: XftFontImp.hh,v 1.3 2002/10/16 23:13:54 fluxgen Exp $ +//$Id: XftFontImp.hh,v 1.4 2002/10/19 13:58:21 fluxgen Exp $ #ifndef XFTFONTIMP_HH #define XFTFONTIMP_HH @@ -35,6 +35,8 @@ public: void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; unsigned int textWidth(const char * const text, unsigned int len) const; unsigned int height() const; + int ascent() const { return m_xftfont ? m_xftfont->ascent : 0; } + int descent() const { return m_xftfont ? m_xftfont->descent : 0; } bool loaded() const { return m_xftfont != 0; } private: XftFont *m_xftfont; diff --git a/src/XmbFontImp.hh b/src/XmbFontImp.hh index 64a176f..4fb2a2e 100644 --- a/src/XmbFontImp.hh +++ b/src/XmbFontImp.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XmbFontImp.hh,v 1.3 2002/10/16 23:30:17 fluxgen Exp $ +// $Id: XmbFontImp.hh,v 1.4 2002/10/19 13:58:58 fluxgen Exp $ #ifndef XMBFONTIMP_HH #define XMBFONTIMP_HH @@ -34,6 +34,8 @@ public: virtual void drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y) const; unsigned int textWidth(const char * const text, unsigned int len) const; unsigned int height() const; + int ascent() const { return m_setextents ? -m_setextents->max_ink_extent.y : 0; } + int descent() const { return m_setextents ? m_setextents->max_ink_extent.height + m_setextents->max_ink_extent.y : 0; } bool loaded() const { return m_fontset != 0; } private: XFontSet m_fontset; -- cgit v0.11.2