Changed Font::setSize to Font::setFontResolution

This commit is contained in:
Robert Osfield 2005-01-27 11:10:50 +00:00
parent 67a5a020bf
commit a086a6d01b
5 changed files with 27 additions and 20 deletions

View File

@ -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)
{

View File

@ -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="<<this<<" "<<_filename<<" facade="<<_facade<<endl;

View File

@ -30,7 +30,7 @@ public:
virtual std::string getFileName() const { return _filename; }
virtual void setSize(unsigned int width, unsigned int height);
virtual void setFontResolution(unsigned int width, unsigned int height);
virtual osgText::Font::Glyph* getGlyph(unsigned int charcode);

View File

@ -1,4 +1,4 @@
;
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
@ -123,17 +123,17 @@ std::string Font::getFileName() const
return "";
}
void Font::setSize(unsigned int width, unsigned int height)
void Font::setFontResolution(unsigned int width, unsigned int height)
{
if (_implementation.valid()) _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;
}

View File

@ -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<unsigned int> deliminatorSet;