From a086a6d01b2c92aec5ba70d8fc288c0de80d9747 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 27 Jan 2005 11:10:50 +0000 Subject: [PATCH] Changed Font::setSize to Font::setFontResolution --- include/osgText/Font | 21 ++++++++++++++------- src/osgPlugins/freetype/FreeTypeFont.cpp | 8 ++++---- src/osgPlugins/freetype/FreeTypeFont.h | 2 +- src/osgText/Font.cpp | 10 +++++----- src/osgText/Text.cpp | 6 +++--- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/include/osgText/Font b/include/osgText/Font index dc4dbf1fc..1be27b6c1 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -64,11 +64,18 @@ public: virtual std::string getFileName() const; - /** Set the pixel width and height hint.*/ - virtual void setSize(unsigned int width, unsigned int height); +#ifdef USE_DEPRECATED_API + virtual void setSize(unsigned int width, unsigned int height) { setFontResolution(width,height); } - unsigned int getWidth() const; - unsigned int getHeight() const; + unsigned int getWidth() const { return getFontWidth(); } + unsigned int getHeight() const { return getFontHeight(); } +#endif + + /** Set the pixel width and height hint.*/ + virtual void setFontResolution(unsigned int width, unsigned int height); + + unsigned int getFontWidth() const; + unsigned int getFontHeight() const; /** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/ virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType); @@ -153,7 +160,7 @@ public: virtual std::string getFileName() const = 0; /** Set the pixel width and height hint.*/ - virtual void setSize(unsigned int width, unsigned int height) = 0; + virtual void setFontResolution(unsigned int width, unsigned int height) = 0; /** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/ virtual Glyph* getGlyph(unsigned int charcode) = 0; @@ -164,9 +171,9 @@ public: /** Return true if this font provides vertical alignments and spacing or glyphs.*/ virtual bool hasVertical() const = 0; - void setWidth(unsigned int width) { _facade->_width = width; } + void setFontWidth(unsigned int width) { _facade->_width = width; } - void setHeight(unsigned int height) { _facade->_height = height; } + void setFontHeight(unsigned int height) { _facade->_height = height; } void addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph* glyph) { diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index 8d5e7c747..f8f924992 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -26,7 +26,7 @@ FreeTypeFont::~FreeTypeFont() { } -void FreeTypeFont::setSize(unsigned int width, unsigned int height) +void FreeTypeFont::setFontResolution(unsigned int width, unsigned int height) { if (width+2*_facade->getGlyphImageMargin()>_facade->getTextureWidthHint() || height+2*_facade->getGlyphImageMargin()>_facade->getTextureHeightHint()) @@ -49,8 +49,8 @@ void FreeTypeFont::setSize(unsigned int width, unsigned int height) } else { - setWidth(width); - setHeight(height); + setFontWidth(width); + setFontHeight(height); } } @@ -155,7 +155,7 @@ osgText::Font::Glyph* FreeTypeFont::getGlyph(unsigned int charcode) glyph->setVerticalBearing(osg::Vec2((float)metrics->vertBearingX/64.0f,(float)(metrics->vertBearingY-metrics->height)/64.0f)); // top middle. glyph->setVerticalAdvance((float)metrics->vertAdvance/64.0f); - addGlyph(_facade->getWidth(),_facade->getHeight(),charcode,glyph.get()); + addGlyph(_facade->getFontWidth(),_facade->getFontHeight(),charcode,glyph.get()); // cout << " in getGlyph() implementation="<setSize(width, height); + if (_implementation.valid()) _implementation->setFontResolution(width, height); } -unsigned int Font::getWidth() const +unsigned int Font::getFontWidth() const { return _width; } -unsigned int Font::getHeight() const +unsigned int Font::getFontHeight() const { return _height; } diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 60a032f85..931d7cfbd 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -257,7 +257,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2 cursor, String::iter Font* activefont = getActiveFont(); if (!activefont) return last; - float hr = _characterHeight/(float)activefont->getHeight(); + float hr = _characterHeight/(float)activefont->getFontHeight(); float wr = hr/_characterAspectRatio; bool horizontal = _layout!=VERTICAL; @@ -370,9 +370,9 @@ void Text::computeGlyphRepresentation() bool horizontal = _layout!=VERTICAL; bool kerning = true; - activefont->setSize(_fontWidth,_fontHeight); + activefont->setFontResolution(_fontWidth,_fontHeight); - float hr = _characterHeight/(float)activefont->getHeight(); + float hr = _characterHeight/(float)activefont->getFontHeight(); float wr = hr/_characterAspectRatio; std::set deliminatorSet;