[DEV] add reverse height to size for font height

This commit is contained in:
Edouard DUPIN 2014-01-22 23:15:10 +01:00
parent a2a70607c3
commit 5e3974f59d
6 changed files with 28 additions and 0 deletions

View File

@ -29,6 +29,14 @@ ewol::compositing::TextDF::~TextDF(void) {
ewol::resource::DistanceFieldFont::release(m_fontDF);
}
void ewol::compositing::TextDF::updateSizeToRender(const vec2& _size) {
float minSize = etk_min(_size.x(), _size.y());
if (m_fontDF != NULL) {
setFontSize(m_fontDF->getSize(minSize));
}
}
void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) {
// draw BG in any case:

View File

@ -38,6 +38,13 @@ namespace ewol {
* @brief generic destructor
*/
virtual ~TextDF(void);
public:
/**
* @brief Calculate size to be at the best size for a render in this special size.
* @note special for Distance field mode.
* @param[in] _size request dimention.
*/
void updateSizeToRender(const vec2& _size);
public:
virtual void clear(void);
virtual void drawD(bool _disableDepthTest);

View File

@ -43,6 +43,14 @@ namespace ewol {
float getHeight(float _size) {
return ((float)m_font->getHeight(_size));
};
/**
* @brief get the font size with a specific display size
* @param[in] _fontHeight Request font height
* @return Dimention of the font for this compleate line size.
*/
float getSize(float _fontHeight) {
return m_font->getSizeWithHeight(_fontHeight);
}
/**
* @brief get the ID of a unicode charcode
* @param[in] _charcode The unicodeValue

View File

@ -119,6 +119,9 @@ vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const std::string&
int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) {
return _fontSize*1.43f; // this is a really "magic" number ...
}
float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) {
return _fontHeight*0.6993f; // this is a really "magic" number ...
}
bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) {
if(false == m_init) {

View File

@ -50,6 +50,7 @@ namespace ewol {
vec2 getSize(int32_t _fontSize, const std::string& _unicodeString);
int32_t getHeight(int32_t _fontSize);
float getSizeWithHeight(float _fontHeight);
void generateKerning(int32_t _fontSize, std::vector<ewol::GlyphProperty>& _listGlyph);
public:

View File

@ -41,6 +41,7 @@ namespace ewol {
int32_t _borderSize = 0) = 0;
virtual vec2 getSize(int32_t _fontSize, const std::string& _unicodeString) = 0;
virtual float getSizeWithHeight(float _fontHeight) = 0;
virtual int32_t getHeight(int32_t _fontSize) = 0;