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"
|
2006-03-26 04:02:30 +00:00
|
|
|
#include <string>
|
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);
|
2007-01-05 13:43:54 +00:00
|
|
|
void drawText(const FbDrawable &w, int screen, GC gc, const FbString &text, size_t len, int x, int y , FbTk::Orientation orient);
|
2006-05-07 03:41:27 +00:00
|
|
|
unsigned int textWidth(const FbString &text, unsigned int len) const;
|
2002-12-01 13:42:15 +00:00
|
|
|
unsigned int height() const;
|
2006-03-26 04:02:30 +00:00
|
|
|
int ascent() const { return m_xftfonts[0] ? m_xftfonts[0]->ascent : 0; }
|
|
|
|
int descent() const { return m_xftfonts[0] ? m_xftfonts[0]->descent : 0; }
|
|
|
|
bool loaded() const { return m_xftfonts[0] != 0; }
|
2004-11-19 12:00:20 +00:00
|
|
|
bool utf8() const { return m_utf8mode; }
|
2006-03-26 04:02:30 +00:00
|
|
|
bool validOrientation(FbTk::Orientation orient);
|
|
|
|
|
2002-11-26 16:01:28 +00:00
|
|
|
private:
|
2006-03-26 04:02:30 +00:00
|
|
|
XftFont *m_xftfonts[4]; // 4 possible orientations
|
2007-01-05 13:43:54 +00:00
|
|
|
bool m_xftfonts_loaded[4]; // whether we've tried loading the orientation
|
2006-03-26 04:02:30 +00:00
|
|
|
// rotated xft fonts don't give proper extents info, so we keep the "real"
|
|
|
|
// one around for it
|
2002-12-01 13:42:15 +00:00
|
|
|
bool m_utf8mode;
|
2006-03-26 04:02:30 +00:00
|
|
|
|
|
|
|
std::string m_name;
|
|
|
|
int m_angle;
|
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
|