2002-11-26 16:01:28 +00:00
|
|
|
// XftFontImp.hh Xft font implementation for FbTk
|
2005-01-24 18:02:34 +00:00
|
|
|
// Copyright (c) 2002-2004 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2002-11-26 16:01:28 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2004-11-19 11:37:27 +00:00
|
|
|
//$Id$
|
2002-11-26 16:01:28 +00:00
|
|
|
|
2003-01-05 23:39:50 +00:00
|
|
|
#ifndef FBTK_XFTFONTIMP_HH
|
|
|
|
#define FBTK_XFTFONTIMP_HH
|
2002-11-26 16:01:28 +00:00
|
|
|
|
|
|
|
#include <X11/Xft/Xft.h>
|
- Usage of xft-fonts is prefered, except a font-description starts with '-'
- Removed "antialias"-option completly, to enable/disable "antialias"
use either <fontname>:antialias=<bool> in the style or use
Xft.antialias: <bool> in your .Xdefaults
- Added new styleresources:
*.font.effect: <halo|shadow>
*.font.shadow.x : <int> - shadow x offset
*.font.shadow.y : <int> - shadow y offset
*.font.shadow.color : <color> - color of shadow
*.font.halo.color : <color> - color of halo
- Removed 'shadow' and 'halo' options from fontdefinitions:
!! Style authors have to update their styles !!
- Simplified XmbFontImp to not try all possible fonts to match locale
- Style authors may specify multiple fonts:
<font1>|<font2>|<font3>
if loading of font1 fails, fluxbox probes <font2>, etc. The last font is
"fixed". Hints for style authors:
- if xft tries to load a font it will _ALWAYS_ return a valid font,
it doesnt have to look like the one you want to have, read more
about it: http://fontconfig.org/fontconfig-user.html
- export XFT_DEBUG=1 before running fluxbox helps to see
which fonts are picked.
eg:
*.font: Verdana,Arial-12:antialias=true|-artwiz-snap-*-
if fluxbox is compiled with xft this will NEVER try to
load "-artwiz-snap-*-" since xft gives for sure a font,
most likely Verdana or Arial but noone knows. So, if
fluxbox has no xft support the first fontpattern fails
and fluxbox tries the next one, which might be successful.
if everything fails, it will use "fixed"
- Added caching of fonts, fonts are only loaded once.
- Fixed #1090902 (slow utf8 start)
2005-06-03 07:25:48 +00:00
|
|
|
#include "FontImp.hh"
|
2003-01-05 23:39:50 +00:00
|
|
|
|
2002-11-26 16:01:28 +00:00
|
|
|
namespace FbTk {
|
|
|
|
|
2003-01-05 23:39:50 +00:00
|
|
|
/// Handles Xft font drawing
|
2002-11-26 16:01:28 +00:00
|
|
|
class XftFontImp:public FbTk::FontImp {
|
|
|
|
public:
|
2002-12-01 13:42:15 +00:00
|
|
|
XftFontImp(const char *fontname, bool utf8);
|
|
|
|
~XftFontImp();
|
|
|
|
bool load(const std::string &name);
|
2004-09-11 23:01:34 +00:00
|
|
|
void drawText(const FbDrawable &w, int screen, GC gc, const char *text, size_t len, int x, int y) const;
|
2002-12-01 13:42:15 +00:00
|
|
|
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; }
|
2004-11-19 12:00:20 +00:00
|
|
|
bool utf8() const { return m_utf8mode; }
|
2002-11-26 16:01:28 +00:00
|
|
|
private:
|
2002-12-01 13:42:15 +00:00
|
|
|
XftFont *m_xftfont;
|
|
|
|
bool m_utf8mode;
|
2002-11-26 16:01:28 +00:00
|
|
|
};
|
|
|
|
|
2003-12-16 17:06:52 +00:00
|
|
|
} // end namespace FbTk
|
2002-11-26 16:01:28 +00:00
|
|
|
|
2003-01-05 23:39:50 +00:00
|
|
|
#endif // FBTK_XFTFONTIMP_HH
|