all repos — fluxbox @ e4c680e4cf73bc6da6435148265e8668b8de7dee

custom fork of the fluxbox windowmanager

fixed rotate argument for drawText
fluxgen fluxgen
commit

e4c680e4cf73bc6da6435148265e8668b8de7dee

parent

216da58a08a2b5645725448843f26c9e52c1b3df

1 files changed, 24 insertions(+), 3 deletions(-)

jump to
M src/FbTk/Font.ccsrc/FbTk/Font.cc

@@ -19,7 +19,7 @@ // 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. -//$Id: Font.cc,v 1.2 2002/12/01 13:42:14 rathnor Exp $ +//$Id: Font.cc,v 1.3 2002/12/08 19:12:07 fluxgen Exp $ #include "Font.hh"

@@ -156,10 +156,28 @@

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 { +void Font::drawText(Drawable w, int screen, GC gc, const char *text, size_t len, int x, int y, + bool rotate) const { if (text == 0 || len == 0) return; - m_fontimp->drawText(w, screen, gc, text, len, x, y); + if (!rotate && isRotated()) { + // if this was called with request to not rotated the text + // we just forward it to the implementation that handles rotation + // currently just XFontImp + // Using dynamic_cast just temporarly until there's a better solution + // to put in FontImp + try { + XFontImp *font = dynamic_cast<XFontImp *>(m_fontimp.get()); + font->setRotate(false); // disable rotation temporarly + font->drawText(w, screen, gc, text, len, x, y); + font->setRotate(true); // enable rotation + } catch (std::bad_cast &bc) { + // draw normal... + m_fontimp->drawText(w, screen, gc, text, len, x, y); + } + + } else + m_fontimp->drawText(w, screen, gc, text, len, x, y); } void Font::rotate(float angle) {

@@ -173,12 +191,15 @@ // change to a font imp that handles rotated fonts (i.e just XFontImp at the moment)

// if we're going to rotate this font if (angle != 0 && isAntialias() && !isRotated()) { m_fontimp.reset(new XFontImp(m_fontstr.c_str())); + if (!m_fontimp->loaded()) // if it failed to load font, try default font fixed + m_fontimp->load("fixed"); } //Note: only XFontImp implements FontImp::rotate m_fontimp->rotate(angle); m_rotated = (angle == 0 ? false : true); + m_angle = angle; } };