From Romain Ouabdelkader, "This is a fix for osgText to calculate kerning and to load glyph3D with the text's font resolution.
Font::getKerning(...), Font::getGlyph3D(...) doesn't ask for a font resolution so it uses the last font resolution requested by Font:: getGlyph(...). This can leads to different results depending of the precedent call to Font::getGlyph(...). See http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2016-January/271952.html for more infos. This fix adds a font resolution parameter to Font::getKerning(...), Font::getGlyph3D(...) and to the font implementations. This was made under the base revision r15182."
This commit is contained in:
parent
937ef73521
commit
67202b2662
@ -104,7 +104,7 @@ void Layout::layout(TextNode& text) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osgText::Glyph3D* glyph = font->getGlyph3D(charcode);
|
osgText::Glyph3D* glyph = font->getGlyph3D(resolution, charcode);
|
||||||
OSG_NOTICE<<"pos = "<<pos<<", charcode="<<charcode<<", glyph="<<glyph<< std::endl;
|
OSG_NOTICE<<"pos = "<<pos<<", charcode="<<charcode<<", glyph="<<glyph<< std::endl;
|
||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
@ -116,7 +116,7 @@ void Layout::layout(TextNode& text) const
|
|||||||
|
|
||||||
if (previousCharcode!=0 && charcode!=0)
|
if (previousCharcode!=0 && charcode!=0)
|
||||||
{
|
{
|
||||||
osg::Vec2 offset = font->getKerning(previousCharcode, charcode, kerningType);
|
osg::Vec2 offset = font->getKerning(resolution, previousCharcode, charcode, kerningType);
|
||||||
OSG_NOTICE<<" offset = "<<offset<< std::endl;
|
OSG_NOTICE<<" offset = "<<offset<< std::endl;
|
||||||
pos.x() += offset.x();
|
pos.x() += offset.x();
|
||||||
pos.y() += offset.y();
|
pos.y() += offset.y();
|
||||||
|
@ -35,9 +35,9 @@ public:
|
|||||||
|
|
||||||
virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes, unsigned int charcode);
|
virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes, unsigned int charcode);
|
||||||
|
|
||||||
virtual osgText::Glyph3D* getGlyph3D(unsigned int /*charcode*/) { return 0; }
|
virtual osgText::Glyph3D* getGlyph3D(const osgText::FontResolution& /*fontRes*/, unsigned int /*charcode*/) { return 0; }
|
||||||
|
|
||||||
virtual osg::Vec2 getKerning(unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType);
|
virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType);
|
||||||
|
|
||||||
virtual bool hasVertical() const;
|
virtual bool hasVertical() const;
|
||||||
|
|
||||||
|
@ -93,15 +93,15 @@ public:
|
|||||||
const osg::StateSet* getStateSet() const { return _stateset.get(); }
|
const osg::StateSet* getStateSet() const { return _stateset.get(); }
|
||||||
|
|
||||||
|
|
||||||
/** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/
|
/** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes and a font resolution.*/
|
||||||
virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType);
|
virtual osg::Vec2 getKerning(const FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, KerningType kerningType);
|
||||||
|
|
||||||
/** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/
|
/** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/
|
||||||
virtual Glyph* getGlyph(const FontResolution& fontSize, unsigned int charcode);
|
virtual Glyph* getGlyph(const FontResolution& fontSize, unsigned int charcode);
|
||||||
|
|
||||||
|
|
||||||
/** Get a Glyph3D for specified charcode.*/
|
/** Get a Glyph3D for specified charcode and a font size.*/
|
||||||
virtual Glyph3D* getGlyph3D(unsigned int charcode);
|
virtual Glyph3D* getGlyph3D(const FontResolution& fontSize, unsigned int charcode);
|
||||||
|
|
||||||
/** Return true if this font provides vertical alignments and spacing or glyphs.*/
|
/** Return true if this font provides vertical alignments and spacing or glyphs.*/
|
||||||
virtual bool hasVertical() const;
|
virtual bool hasVertical() const;
|
||||||
@ -181,6 +181,7 @@ protected:
|
|||||||
typedef std::map< unsigned int, osg::ref_ptr<Glyph3D> > Glyph3DMap;
|
typedef std::map< unsigned int, osg::ref_ptr<Glyph3D> > Glyph3DMap;
|
||||||
|
|
||||||
typedef std::map< FontResolution, GlyphMap > FontSizeGlyphMap;
|
typedef std::map< FontResolution, GlyphMap > FontSizeGlyphMap;
|
||||||
|
typedef std::map< FontResolution, Glyph3DMap > FontSizeGlyph3DMap;
|
||||||
|
|
||||||
mutable OpenThreads::Mutex _glyphMapMutex;
|
mutable OpenThreads::Mutex _glyphMapMutex;
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ protected:
|
|||||||
GlyphTextureList _glyphTextureList;
|
GlyphTextureList _glyphTextureList;
|
||||||
|
|
||||||
|
|
||||||
Glyph3DMap _glyph3DMap;
|
FontSizeGlyph3DMap _sizeGlyph3DMap;
|
||||||
|
|
||||||
// current active size of font
|
// current active size of font
|
||||||
FontResolution _fontSize;
|
FontResolution _fontSize;
|
||||||
@ -228,10 +229,10 @@ public:
|
|||||||
virtual Glyph* getGlyph(const FontResolution& fontRes, unsigned int charcode) = 0;
|
virtual Glyph* getGlyph(const FontResolution& fontRes, unsigned int charcode) = 0;
|
||||||
|
|
||||||
/** Get a Glyph3D for specified charcode.*/
|
/** Get a Glyph3D for specified charcode.*/
|
||||||
virtual Glyph3D* getGlyph3D(unsigned int charcode) = 0;
|
virtual Glyph3D* getGlyph3D(const FontResolution& fontRes, unsigned int charcode) = 0;
|
||||||
|
|
||||||
/** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/
|
/** 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) = 0;
|
virtual osg::Vec2 getKerning(const FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, KerningType kerningType) = 0;
|
||||||
|
|
||||||
/** Return true if this font provides vertical alignments and spacing or glyphs.*/
|
/** Return true if this font provides vertical alignments and spacing or glyphs.*/
|
||||||
virtual bool hasVertical() const = 0;
|
virtual bool hasVertical() const = 0;
|
||||||
|
@ -413,10 +413,12 @@ osgText::Glyph* FreeTypeFont::getGlyph(const osgText::FontResolution& fontRes, u
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osgText::Glyph3D * FreeTypeFont::getGlyph3D(unsigned int charcode)
|
osgText::Glyph3D * FreeTypeFont::getGlyph3D(const osgText::FontResolution& fontRes, unsigned int charcode)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
||||||
|
|
||||||
|
setFontResolution(fontRes);
|
||||||
|
|
||||||
//
|
//
|
||||||
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
// GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being
|
||||||
// returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct
|
// returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct
|
||||||
@ -515,10 +517,12 @@ osgText::Glyph3D * FreeTypeFont::getGlyph3D(unsigned int charcode)
|
|||||||
return glyph.release();
|
return glyph.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec2 FreeTypeFont::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType)
|
osg::Vec2 FreeTypeFont::getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());
|
||||||
|
|
||||||
|
setFontResolution(fontRes);
|
||||||
|
|
||||||
if (!FT_HAS_KERNING(_face) || (kerningType == osgText::KERNING_NONE)) return osg::Vec2(0.0f,0.0f);
|
if (!FT_HAS_KERNING(_face) || (kerningType == osgText::KERNING_NONE)) return osg::Vec2(0.0f,0.0f);
|
||||||
|
|
||||||
FT_Kerning_Mode mode = (kerningType==osgText::KERNING_DEFAULT) ? ft_kerning_default : ft_kerning_unfitted;
|
FT_Kerning_Mode mode = (kerningType==osgText::KERNING_DEFAULT) ? ft_kerning_default : ft_kerning_unfitted;
|
||||||
|
@ -33,11 +33,11 @@ public:
|
|||||||
|
|
||||||
virtual bool supportsMultipleFontResolutions() const { return true; }
|
virtual bool supportsMultipleFontResolutions() const { return true; }
|
||||||
|
|
||||||
virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes,unsigned int charcode);
|
virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes, unsigned int charcode);
|
||||||
|
|
||||||
virtual osgText::Glyph3D* getGlyph3D(unsigned int charcode);
|
virtual osgText::Glyph3D* getGlyph3D(const osgText::FontResolution& fontRes, unsigned int charcode);
|
||||||
|
|
||||||
virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType _kerningType);
|
virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType _kerningType);
|
||||||
|
|
||||||
virtual bool hasVertical() const;
|
virtual bool hasVertical() const;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ TXFFont::hasVertical() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec2
|
osg::Vec2
|
||||||
TXFFont::getKerning(unsigned int, unsigned int, osgText::KerningType)
|
TXFFont::getKerning(const osgText::FontResolution&, unsigned int, unsigned int, osgText::KerningType)
|
||||||
{
|
{
|
||||||
return osg::Vec2(0, 0);
|
return osg::Vec2(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ public:
|
|||||||
|
|
||||||
virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes, unsigned int charcode);
|
virtual osgText::Glyph* getGlyph(const osgText::FontResolution& fontRes, unsigned int charcode);
|
||||||
|
|
||||||
virtual osgText::Glyph3D* getGlyph3D(unsigned int) { return 0; }
|
virtual osgText::Glyph3D* getGlyph3D(const osgText::FontResolution&, unsigned int) { return 0; }
|
||||||
|
|
||||||
virtual bool hasVertical() const;
|
virtual bool hasVertical() const;
|
||||||
|
|
||||||
virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType);
|
virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType);
|
||||||
|
|
||||||
bool loadFont(std::istream& stream);
|
bool loadFont(std::istream& stream);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ QFontImplementation::getGlyph(const osgText::FontResolution& fontRes, unsigned i
|
|||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec2
|
osg::Vec2
|
||||||
QFontImplementation::getKerning(unsigned int /*leftcharcode*/, unsigned int /*rightcharcode*/, osgText::KerningType /*kerningType*/)
|
QFontImplementation::getKerning(const osgText::FontResolution& /*fontRes*/, unsigned int /*leftcharcode*/, unsigned int /*rightcharcode*/, osgText::KerningType /*kerningType*/)
|
||||||
{
|
{
|
||||||
return osg::Vec2(0, 0);
|
return osg::Vec2(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ osgText::Glyph* DefaultFont::getGlyph(const FontResolution& fontRes, unsigned in
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
osg::Vec2 DefaultFont::getKerning(unsigned int,unsigned int, KerningType)
|
osg::Vec2 DefaultFont::getKerning(const osgText::FontResolution&, unsigned int, unsigned int, KerningType)
|
||||||
{
|
{
|
||||||
// no kerning on default font.
|
// no kerning on default font.
|
||||||
return osg::Vec2(0.0f,0.0f);
|
return osg::Vec2(0.0f,0.0f);
|
||||||
|
@ -34,9 +34,9 @@ public:
|
|||||||
|
|
||||||
virtual osgText::Glyph* getGlyph(const FontResolution& fontRes, unsigned int charcode);
|
virtual osgText::Glyph* getGlyph(const FontResolution& fontRes, unsigned int charcode);
|
||||||
|
|
||||||
virtual osgText::Glyph3D* getGlyph3D(unsigned int /*charcode*/) { return 0; }
|
virtual osgText::Glyph3D* getGlyph3D(const osgText::FontResolution& /*fontRes*/, unsigned int /*charcode*/) { return 0; }
|
||||||
|
|
||||||
virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType);
|
virtual osg::Vec2 getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, KerningType kerningType);
|
||||||
|
|
||||||
virtual bool hasVertical() const;
|
virtual bool hasVertical() const;
|
||||||
|
|
||||||
|
@ -377,22 +377,32 @@ Glyph* Font::getGlyph(const FontResolution& fontRes, unsigned int charcode)
|
|||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glyph3D* Font::getGlyph3D(unsigned int charcode)
|
Glyph3D* Font::getGlyph3D(const FontResolution &fontRes, unsigned int charcode)
|
||||||
{
|
{
|
||||||
|
if (!_implementation) return 0;
|
||||||
|
|
||||||
|
FontResolution fontResUsed(0,0);
|
||||||
|
if (_implementation->supportsMultipleFontResolutions()) fontResUsed = fontRes;
|
||||||
|
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
|
||||||
Glyph3DMap::iterator itr = _glyph3DMap.find(charcode);
|
FontSizeGlyph3DMap::iterator itr = _sizeGlyph3DMap.find(fontResUsed);
|
||||||
if (itr!=_glyph3DMap.end()) return itr->second.get();
|
if (itr!=_sizeGlyph3DMap.end())
|
||||||
|
{
|
||||||
|
Glyph3DMap& glyphmap = itr->second;
|
||||||
|
Glyph3DMap::iterator gitr = glyphmap.find(charcode);
|
||||||
|
if (gitr!=glyphmap.end()) return gitr->second.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Glyph3D* glyph = _implementation.valid() ? _implementation->getGlyph3D(charcode) : 0;
|
Glyph3D* glyph = _implementation->getGlyph3D(fontResUsed, charcode);
|
||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
|
||||||
_glyph3DMap[charcode] = glyph;
|
_sizeGlyph3DMap[fontResUsed][charcode] = glyph;
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::setThreadSafeRefUnref(bool threadSafe)
|
void Font::setThreadSafeRefUnref(bool threadSafe)
|
||||||
@ -437,9 +447,9 @@ void Font::releaseGLObjects(osg::State* state) const
|
|||||||
// const_cast<Font*>(this)->_sizeGlyphMap.clear();
|
// const_cast<Font*>(this)->_sizeGlyphMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec2 Font::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType)
|
osg::Vec2 Font::getKerning(const FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, KerningType kerningType)
|
||||||
{
|
{
|
||||||
if (_implementation.valid()) return _implementation->getKerning(leftcharcode,rightcharcode,kerningType);
|
if (_implementation.valid()) return _implementation->getKerning(fontRes, leftcharcode, rightcharcode, kerningType);
|
||||||
else return osg::Vec2(0.0f,0.0f);
|
else return osg::Vec2(0.0f,0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,14 +132,14 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite
|
|||||||
{
|
{
|
||||||
case LEFT_TO_RIGHT:
|
case LEFT_TO_RIGHT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(activefont->getKerning(previous_charcode,charcode,_kerningType));
|
osg::Vec2 delta(activefont->getKerning(_fontSize, previous_charcode, charcode, _kerningType));
|
||||||
cursor.x() += delta.x() * wr;
|
cursor.x() += delta.x() * wr;
|
||||||
cursor.y() += delta.y() * hr;
|
cursor.y() += delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RIGHT_TO_LEFT:
|
case RIGHT_TO_LEFT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(activefont->getKerning(charcode,previous_charcode,_kerningType));
|
osg::Vec2 delta(activefont->getKerning(_fontSize, charcode, previous_charcode, _kerningType));
|
||||||
cursor.x() -= delta.x() * wr;
|
cursor.x() -= delta.x() * wr;
|
||||||
cursor.y() -= delta.y() * hr;
|
cursor.y() -= delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
@ -396,14 +396,14 @@ void Text::computeGlyphRepresentation()
|
|||||||
{
|
{
|
||||||
case LEFT_TO_RIGHT:
|
case LEFT_TO_RIGHT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(activefont->getKerning(previous_charcode,charcode,_kerningType));
|
osg::Vec2 delta(activefont->getKerning(_fontSize, previous_charcode, charcode, _kerningType));
|
||||||
cursor.x() += delta.x() * wr;
|
cursor.x() += delta.x() * wr;
|
||||||
cursor.y() += delta.y() * hr;
|
cursor.y() += delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RIGHT_TO_LEFT:
|
case RIGHT_TO_LEFT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(activefont->getKerning(charcode,previous_charcode,_kerningType));
|
osg::Vec2 delta(activefont->getKerning(_fontSize, charcode, previous_charcode, _kerningType));
|
||||||
cursor.x() -= delta.x() * wr;
|
cursor.x() -= delta.x() * wr;
|
||||||
cursor.y() -= delta.y() * hr;
|
cursor.y() -= delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
|
@ -135,7 +135,7 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i
|
|||||||
return lastChar;
|
return lastChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glyph3D* glyph = _font->getGlyph3D(charcode);
|
Glyph3D* glyph = _font->getGlyph3D(_fontSize, charcode);
|
||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
||||||
@ -152,14 +152,14 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i
|
|||||||
{
|
{
|
||||||
case LEFT_TO_RIGHT:
|
case LEFT_TO_RIGHT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(_font->getKerning(previous_charcode,charcode,_kerningType));
|
osg::Vec2 delta(_font->getKerning(_fontSize, previous_charcode, charcode, _kerningType));
|
||||||
cursor.x() += delta.x() * wr;
|
cursor.x() += delta.x() * wr;
|
||||||
cursor.y() += delta.y() * hr;
|
cursor.y() += delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RIGHT_TO_LEFT:
|
case RIGHT_TO_LEFT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(_font->getKerning(charcode,previous_charcode,_kerningType));
|
osg::Vec2 delta(_font->getKerning(_fontSize, charcode, previous_charcode, _kerningType));
|
||||||
cursor.x() -= delta.x() * wr;
|
cursor.x() -= delta.x() * wr;
|
||||||
cursor.y() -= delta.y() * hr;
|
cursor.y() -= delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
@ -226,7 +226,7 @@ String::iterator Text3D::computeLastCharacterOnLine(osg::Vec2& cursor, String::i
|
|||||||
// Subtract off glyphs from the cursor position (to correctly center text)
|
// Subtract off glyphs from the cursor position (to correctly center text)
|
||||||
if(*prevChar != '-')
|
if(*prevChar != '-')
|
||||||
{
|
{
|
||||||
Glyph3D* glyph = _font->getGlyph3D(*prevChar);
|
Glyph3D* glyph = _font->getGlyph3D(_fontSize, *prevChar);
|
||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
switch(_layout)
|
switch(_layout)
|
||||||
@ -299,7 +299,7 @@ void Text3D::computeGlyphRepresentation()
|
|||||||
{
|
{
|
||||||
unsigned int charcode = *itr;
|
unsigned int charcode = *itr;
|
||||||
|
|
||||||
Glyph3D* glyph = _font->getGlyph3D(charcode);
|
Glyph3D* glyph = _font->getGlyph3D(_fontSize, charcode);
|
||||||
if (glyph)
|
if (glyph)
|
||||||
{
|
{
|
||||||
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
const osg::BoundingBox & bb = glyph->getBoundingBox();
|
||||||
@ -316,14 +316,14 @@ void Text3D::computeGlyphRepresentation()
|
|||||||
{
|
{
|
||||||
case LEFT_TO_RIGHT:
|
case LEFT_TO_RIGHT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(_font->getKerning(previous_charcode,charcode,_kerningType));
|
osg::Vec2 delta(_font->getKerning(_fontSize, previous_charcode, charcode, _kerningType));
|
||||||
cursor.x() += delta.x() * wr;
|
cursor.x() += delta.x() * wr;
|
||||||
cursor.y() += delta.y() * hr;
|
cursor.y() += delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RIGHT_TO_LEFT:
|
case RIGHT_TO_LEFT:
|
||||||
{
|
{
|
||||||
osg::Vec2 delta(_font->getKerning(charcode,previous_charcode,_kerningType));
|
osg::Vec2 delta(_font->getKerning(_fontSize, charcode, previous_charcode, _kerningType));
|
||||||
cursor.x() -= delta.x() * wr;
|
cursor.x() -= delta.x() * wr;
|
||||||
cursor.y() -= delta.y() * hr;
|
cursor.y() -= delta.y() * hr;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user