[DEV] add distance field compisiting (not work)
This commit is contained in:
parent
fbca6c4491
commit
c4479fa4cb
@ -15,7 +15,7 @@
|
||||
#define __class__ "ewol::compositing::Text"
|
||||
|
||||
|
||||
ewol::compositing::Text::Text(const std::string& _fontName, int32_t _fontSize) :
|
||||
ewol::compositing::Text::Text(const std::string& _fontName, int32_t _fontSize, bool _tmpInit) :
|
||||
m_position(0.0, 0.0, 0.0),
|
||||
m_clippingPosStart(0.0, 0.0, 0.0),
|
||||
m_clippingPosStop(0.0, 0.0, 0.0),
|
||||
@ -40,8 +40,10 @@ ewol::compositing::Text::Text(const std::string& _fontName, int32_t _fontSize) :
|
||||
m_selectionStartPos(-100),
|
||||
m_cursorPos(-100),
|
||||
m_font(NULL) {
|
||||
setFont(_fontName, _fontSize);
|
||||
loadProgram();
|
||||
if (_tmpInit == true) {
|
||||
setFont(_fontName, _fontSize);
|
||||
loadProgram();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -50,10 +52,10 @@ ewol::compositing::Text::~Text(void) {
|
||||
ewol::resource::Program::release(m_GLprogram);
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::loadProgram(void) {
|
||||
void ewol::compositing::Text::loadProgram(const std::string& _shaderName) {
|
||||
// get the shader resource :
|
||||
m_GLPosition = 0;
|
||||
m_GLprogram = ewol::resource::Program::keep("DATA:text.prog");
|
||||
m_GLprogram = ewol::resource::Program::keep(_shaderName);
|
||||
if (m_GLprogram != NULL) {
|
||||
m_GLPosition = m_GLprogram->getAttribute("EW_coord2d");
|
||||
m_GLColor = m_GLprogram->getAttribute("EW_color");
|
||||
@ -63,7 +65,7 @@ void ewol::compositing::Text::loadProgram(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest) {
|
||||
void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) {
|
||||
|
||||
// draw BG in any case:
|
||||
m_vectorialDraw.draw();
|
||||
@ -106,8 +108,7 @@ void ewol::compositing::Text::draw(const mat4& _transformationMatrix, bool _enab
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::compositing::Text::draw(bool _disableDepthTest) {
|
||||
void ewol::compositing::Text::drawD(bool _disableDepthTest) {
|
||||
// draw BG in any case:
|
||||
m_vectorialDraw.draw();
|
||||
|
||||
@ -141,6 +142,29 @@ void ewol::compositing::Text::draw(bool _disableDepthTest) {
|
||||
m_GLprogram->unUse();
|
||||
}
|
||||
|
||||
float ewol::compositing::Text::getSize(void) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return 1.0f;
|
||||
}
|
||||
return m_font->getFontSize();
|
||||
}
|
||||
float ewol::compositing::Text::getHeight(void) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return 10.0f;
|
||||
}
|
||||
return m_font->getHeight(m_mode);
|
||||
}
|
||||
ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(char32_t _charcode) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return NULL;
|
||||
}
|
||||
return m_font->getGlyphPointer(_charcode, m_mode);
|
||||
}
|
||||
|
||||
|
||||
void ewol::compositing::Text::translate(const vec3& _vect) {
|
||||
ewol::Compositing::translate(_vect);
|
||||
m_vectorialDraw.translate(_vect);
|
||||
@ -210,7 +234,7 @@ void ewol::compositing::Text::setPos(const vec3& _pos) {
|
||||
if (m_nbCharDisplayed == 0) {
|
||||
m_sizeDisplayStart = m_position;
|
||||
m_sizeDisplayStop = m_position;
|
||||
m_sizeDisplayStop.setY( m_sizeDisplayStop.y()+ m_font->getHeight(m_mode));
|
||||
m_sizeDisplayStop.setY( m_sizeDisplayStop.y()+ getHeight());
|
||||
EWOL_VERBOSE("update size 0 " << m_sizeDisplayStart << " " << m_sizeDisplayStop);
|
||||
} else {
|
||||
EWOL_VERBOSE("update size 3 " << m_sizeDisplayStart << " " << m_sizeDisplayStop);
|
||||
@ -315,10 +339,6 @@ void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) {
|
||||
}
|
||||
}
|
||||
|
||||
enum ewol::font::mode ewol::compositing::Text::getFontMode(void) {
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::setFontBold(bool _status) {
|
||||
if (_status == true) {
|
||||
// enable
|
||||
@ -543,10 +563,6 @@ void ewol::compositing::Text::printHTML(const std::u32string& _text) {
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::print(const std::string& _text, const std::vector<TextDecoration>& _decoration) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return;
|
||||
}
|
||||
etk::Color<> tmpFg(m_color);
|
||||
etk::Color<> tmpBg(m_colorBg);
|
||||
if (m_alignement == alignDisable) {
|
||||
@ -585,7 +601,7 @@ void ewol::compositing::Text::print(const std::string& _text, const std::vector<
|
||||
vec3 pos = m_position;
|
||||
m_vectorialDraw.setPos(pos);
|
||||
print(_text[iii]);
|
||||
float fontHeigh = m_font->getHeight(m_mode);
|
||||
float fontHeigh = getHeight();
|
||||
m_vectorialDraw.rectangleWidth(vec3(m_position.x()-pos.x(),fontHeigh,0.0f) );
|
||||
m_nbCharDisplayed++;
|
||||
} else {
|
||||
@ -651,7 +667,7 @@ void ewol::compositing::Text::print(const std::string& _text, const std::vector<
|
||||
printCursor(false);
|
||||
}
|
||||
for(size_t iii=currentId; (int64_t)iii<stop && iii<_text.size(); iii++) {
|
||||
float fontHeigh = m_font->getHeight(m_mode);
|
||||
float fontHeigh = getHeight();
|
||||
// get specific decoration if provided
|
||||
if (iii<_decoration.size()) {
|
||||
tmpFg = _decoration[iii].m_colorFg;
|
||||
@ -713,14 +729,14 @@ void ewol::compositing::Text::print(const std::string& _text, const std::vector<
|
||||
currentId = stop+1;
|
||||
// reset position :
|
||||
setPos(vec3(m_startTextpos,
|
||||
(float)(m_position.y() - m_font->getHeight(m_mode)),
|
||||
(float)(m_position.y() - getHeight()),
|
||||
m_position.z()) );
|
||||
m_nbCharDisplayed++;
|
||||
} else if((char32_t)_text[stop] == u32char::Return) {
|
||||
currentId = stop+1;
|
||||
// reset position :
|
||||
setPos(vec3(m_startTextpos,
|
||||
(float)(m_position.y() - m_font->getHeight(m_mode)),
|
||||
(float)(m_position.y() - getHeight()),
|
||||
m_position.z()) );
|
||||
m_nbCharDisplayed++;
|
||||
} else {
|
||||
@ -732,10 +748,6 @@ void ewol::compositing::Text::print(const std::string& _text, const std::vector<
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return;
|
||||
}
|
||||
etk::Color<> tmpFg(m_color);
|
||||
etk::Color<> tmpBg(m_colorBg);
|
||||
if (m_alignement == alignDisable) {
|
||||
@ -774,7 +786,7 @@ void ewol::compositing::Text::print(const std::u32string& _text, const std::vect
|
||||
vec3 pos = m_position;
|
||||
m_vectorialDraw.setPos(pos);
|
||||
print(_text[iii]);
|
||||
float fontHeigh = m_font->getHeight(m_mode);
|
||||
float fontHeigh = getHeight();
|
||||
m_vectorialDraw.rectangleWidth(vec3(m_position.x()-pos.x(),fontHeigh,0.0f) );
|
||||
m_nbCharDisplayed++;
|
||||
} else {
|
||||
@ -840,7 +852,7 @@ void ewol::compositing::Text::print(const std::u32string& _text, const std::vect
|
||||
printCursor(false);
|
||||
}
|
||||
for(size_t iii=currentId; (int64_t)iii<stop && iii<_text.size(); iii++) {
|
||||
float fontHeigh = m_font->getHeight(m_mode);
|
||||
float fontHeigh = getHeight();
|
||||
// get specific decoration if provided
|
||||
if (iii<_decoration.size()) {
|
||||
tmpFg = _decoration[iii].m_colorFg;
|
||||
@ -902,14 +914,14 @@ void ewol::compositing::Text::print(const std::u32string& _text, const std::vect
|
||||
currentId = stop+1;
|
||||
// reset position :
|
||||
setPos(vec3(m_startTextpos,
|
||||
(float)(m_position.y() - m_font->getHeight(m_mode)),
|
||||
(float)(m_position.y() - getHeight()),
|
||||
m_position.z()) );
|
||||
m_nbCharDisplayed++;
|
||||
} else if(_text[stop] == u32char::Return) {
|
||||
currentId = stop+1;
|
||||
// reset position :
|
||||
setPos(vec3(m_startTextpos,
|
||||
(float)(m_position.y() - m_font->getHeight(m_mode)),
|
||||
(float)(m_position.y() - getHeight()),
|
||||
m_position.z()) );
|
||||
m_nbCharDisplayed++;
|
||||
} else {
|
||||
@ -922,18 +934,14 @@ void ewol::compositing::Text::print(const std::u32string& _text, const std::vect
|
||||
|
||||
|
||||
void ewol::compositing::Text::print(const char32_t& _charcode) {
|
||||
if (NULL == m_font) {
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return;
|
||||
}
|
||||
// get a pointer on the glyph property :
|
||||
ewol::GlyphProperty* myGlyph = m_font->getGlyphPointer(_charcode, m_mode);
|
||||
ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode);
|
||||
if (NULL == myGlyph) {
|
||||
EWOL_ERROR(" font does not really existed ...");
|
||||
return;
|
||||
}
|
||||
int32_t fontSize = m_font->getFontSize();
|
||||
int32_t fontHeigh = m_font->getHeight(m_mode);
|
||||
int32_t fontSize = getSize();
|
||||
int32_t fontHeigh = getHeight();
|
||||
|
||||
// get the kerning ofset :
|
||||
float kerningOffset = 0;
|
||||
@ -1094,7 +1102,7 @@ void ewol::compositing::Text::print(const char32_t& _charcode) {
|
||||
|
||||
void ewol::compositing::Text::forceLineReturn(void) {
|
||||
// reset position :
|
||||
setPos(vec3(m_startTextpos, m_position.y() - m_font->getHeight(m_mode), 0) );
|
||||
setPos(vec3(m_startTextpos, m_position.y() - getHeight(), 0) );
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::compositing::Text::aligneMode _alignement) {
|
||||
@ -1199,10 +1207,6 @@ vec3 ewol::compositing::Text::calculateSizeDecorated(const std::u32string& _text
|
||||
}
|
||||
|
||||
vec3 ewol::compositing::Text::calculateSize(const std::string& _text) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
vec3 outputSize(0, 0, 0);
|
||||
for(auto element : _text) {
|
||||
vec3 tmpp = calculateSize(element);
|
||||
@ -1215,10 +1219,6 @@ vec3 ewol::compositing::Text::calculateSize(const std::string& _text) {
|
||||
}
|
||||
|
||||
vec3 ewol::compositing::Text::calculateSize(const std::u32string& _text) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
vec3 outputSize(0, 0, 0);
|
||||
for(auto element : _text) {
|
||||
vec3 tmpp = calculateSize(element);
|
||||
@ -1231,13 +1231,9 @@ vec3 ewol::compositing::Text::calculateSize(const std::u32string& _text) {
|
||||
}
|
||||
|
||||
vec3 ewol::compositing::Text::calculateSize(const char32_t& _charcode) {
|
||||
if (m_font == NULL) {
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
// get a pointer on the glyph property :
|
||||
ewol::GlyphProperty * myGlyph = m_font->getGlyphPointer(_charcode, m_mode);
|
||||
int32_t fontHeigh = m_font->getHeight(m_mode);
|
||||
ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode);
|
||||
int32_t fontHeigh = getHeight();
|
||||
|
||||
// get the kerning ofset :
|
||||
float kerningOffset = 0.0;
|
||||
@ -1254,7 +1250,7 @@ vec3 ewol::compositing::Text::calculateSize(const char32_t& _charcode) {
|
||||
}
|
||||
|
||||
void ewol::compositing::Text::printCursor(bool _isInsertMode, float _cursorSize) {
|
||||
int32_t fontHeigh = m_font->getHeight(m_mode);
|
||||
int32_t fontHeigh = getHeight();
|
||||
if (true == _isInsertMode) {
|
||||
m_vectorialDraw.rectangleWidth(vec3(_cursorSize, fontHeigh, 0) );
|
||||
} else {
|
||||
|
@ -45,13 +45,13 @@ namespace ewol {
|
||||
alignCenter,
|
||||
alignJustify
|
||||
};
|
||||
private:
|
||||
protected:
|
||||
ewol::compositing::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ...
|
||||
public:
|
||||
ewol::compositing::Drawing& getDrawing(void) {
|
||||
virtual ewol::compositing::Drawing& getDrawing(void) {
|
||||
return m_vectorialDraw;
|
||||
};
|
||||
private:
|
||||
protected:
|
||||
int32_t m_nbCharDisplayed; //!< prevent some error in calculation size.
|
||||
vec3 m_sizeDisplayStart; //!< The start windows of the display.
|
||||
vec3 m_sizeDisplayStop; //!< The end windows of the display.
|
||||
@ -60,52 +60,52 @@ namespace ewol {
|
||||
vec3 m_clippingPosStart; //!< Clipping start position
|
||||
vec3 m_clippingPosStop; //!< Clipping stop position
|
||||
bool m_clippingEnable; //!< true if the clipping must be activated
|
||||
private:
|
||||
protected:
|
||||
etk::Color<> m_color; //!< The text foreground color
|
||||
etk::Color<> m_colorBg; //!< The text background color
|
||||
etk::Color<> m_colorCursor; //!< The text cursor color
|
||||
etk::Color<> m_colorSelection; //!< The text Selection color
|
||||
private:
|
||||
protected:
|
||||
enum ewol::font::mode m_mode; //!< font display property : Regular/Bold/Italic/BoldItalic
|
||||
bool m_kerning; //!< Kerning enable or disable on the next elements displayed
|
||||
bool m_distanceField; //!< Texture in distance Field mode == > maybe move this in the font property.
|
||||
char32_t m_previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning
|
||||
private:
|
||||
protected:
|
||||
float m_startTextpos; //!< start position of the Alignement (when \n the text return at this position)
|
||||
float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one)
|
||||
enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...)
|
||||
private:
|
||||
protected:
|
||||
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
|
||||
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
|
||||
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
|
||||
int32_t m_GLColor; //!< openGL id on the element (color buffer)
|
||||
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
|
||||
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
|
||||
private:
|
||||
protected:
|
||||
int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection)
|
||||
int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100)
|
||||
private:
|
||||
protected:
|
||||
ewol::resource::TexturedFont* m_font; //!< Font resources
|
||||
private: // Text
|
||||
protected: // Text
|
||||
std::vector<vec2 > m_coord; //!< internal coord of the object
|
||||
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
|
||||
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
|
||||
private:
|
||||
protected:
|
||||
/**
|
||||
* @brief load the openGL program and get all the ID needed
|
||||
*/
|
||||
void loadProgram(void);
|
||||
virtual void loadProgram(const std::string& _shaderName="DATA:text.prog");
|
||||
public:
|
||||
/**
|
||||
* @brief generic constructor
|
||||
* @param[in] _fontName Name of the font that might be loaded
|
||||
* @param[in] _fontSize size of the font that might be loaded
|
||||
*/
|
||||
Text(const std::string& _fontName="", int32_t _fontSize=-1);
|
||||
Text(const std::string& _fontName="", int32_t _fontSize=-1, bool _tmpInit = true);
|
||||
/**
|
||||
* @brief generic destructor
|
||||
*/
|
||||
~Text(void);
|
||||
virtual ~Text(void);
|
||||
public: // Derived function
|
||||
virtual void translate(const vec3& _vect);
|
||||
virtual void rotate(const vec3& _vect, float _angle);
|
||||
@ -114,31 +114,43 @@ namespace ewol {
|
||||
/**
|
||||
* @brief draw All the refistered text in the current element on openGL
|
||||
*/
|
||||
void draw(bool _disableDepthTest=true);
|
||||
void draw(bool _disableDepthTest=true) {
|
||||
drawD(_disableDepthTest);
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false);
|
||||
void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false) {
|
||||
drawMT(_transformationMatrix, _enableDepthTest);
|
||||
}
|
||||
/**
|
||||
* @brief draw All the refistered text in the current element on openGL
|
||||
*/
|
||||
virtual void drawD(bool _disableDepthTest);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest);
|
||||
/**
|
||||
* @brief clear all the registered element in the current element
|
||||
*/
|
||||
void clear(void);
|
||||
virtual void clear(void);
|
||||
/**
|
||||
* @brief clear all the intermediate result detween 2 prints
|
||||
*/
|
||||
void reset(void);
|
||||
virtual void reset(void);
|
||||
/**
|
||||
* @brief get the current display position (sometime needed in the gui control)
|
||||
* @return the current position.
|
||||
*/
|
||||
const vec3& getPos(void) {
|
||||
virtual const vec3& getPos(void) {
|
||||
return m_position;
|
||||
};
|
||||
/**
|
||||
* @brief set position for the next text writen
|
||||
* @param[in] _pos Position of the text (in 3D)
|
||||
*/
|
||||
void setPos(const vec3& _pos);
|
||||
virtual void setPos(const vec3& _pos);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
@ -149,7 +161,7 @@ namespace ewol {
|
||||
* @brief set relative position for the next text writen
|
||||
* @param[in] _pos ofset apply of the text (in 3D)
|
||||
*/
|
||||
void setRelPos(const vec3& _pos);
|
||||
virtual void setRelPos(const vec3& _pos);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
@ -160,24 +172,24 @@ namespace ewol {
|
||||
* @brief set the Color of the current foreground font
|
||||
* @param[in] _color Color to set on foreground (for next print)
|
||||
*/
|
||||
void setColor(const etk::Color<>& _color) { m_color = _color; };
|
||||
virtual void setColor(const etk::Color<>& _color) { m_color = _color; };
|
||||
/**
|
||||
* @brief set the background color of the font (for selected Text (not the global BG))
|
||||
* @param[in] _color Color to set on background (for next print)
|
||||
*/
|
||||
void setColorBg(const etk::Color<>& _color);
|
||||
virtual void setColorBg(const etk::Color<>& _color);
|
||||
/**
|
||||
* @brief Request a clipping area for the text (next draw only)
|
||||
* @param[in] _pos Start position of the clipping
|
||||
* @param[in] _width Width size of the clipping
|
||||
*/
|
||||
void setClippingWidth(const vec3& _pos, const vec3& _width) {
|
||||
virtual void setClippingWidth(const vec3& _pos, const vec3& _width) {
|
||||
setClipping(_pos, _pos+_width);
|
||||
}
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
void setClippingWidth(const vec2& _pos, const vec2& _width) {
|
||||
virtual void setClippingWidth(const vec2& _pos, const vec2& _width) {
|
||||
setClipping(_pos, _pos+_width);
|
||||
};
|
||||
/**
|
||||
@ -185,11 +197,11 @@ namespace ewol {
|
||||
* @param[in] _pos Start position of the clipping
|
||||
* @param[in] _posEnd End position of the clipping
|
||||
*/
|
||||
void setClipping(const vec3& _pos, const vec3& _posEnd);
|
||||
virtual void setClipping(const vec3& _pos, const vec3& _posEnd);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
void setClipping(const vec2& _pos, const vec2& _posEnd) {
|
||||
virtual void setClipping(const vec2& _pos, const vec2& _posEnd) {
|
||||
setClipping(vec3(_pos.x(),_pos.y(),-1), vec3(_posEnd.x(),_posEnd.y(),1) );
|
||||
};
|
||||
/**
|
||||
@ -197,63 +209,68 @@ namespace ewol {
|
||||
* @brief _newMode The new status of the clipping
|
||||
*/
|
||||
// TODO : Rename setClippingActivity
|
||||
void setClippingMode(bool _newMode);
|
||||
virtual void setClippingMode(bool _newMode);
|
||||
/**
|
||||
* @brief Specify the font size (this reset the internal element of the current text (system requirement)
|
||||
* @param[in] _fontSize New font size
|
||||
*/
|
||||
void setFontSize(int32_t _fontSize);
|
||||
virtual void setFontSize(int32_t _fontSize);
|
||||
/**
|
||||
* @brief Specify the font name (this reset the internal element of the current text (system requirement)
|
||||
* @param[in] _fontName Current name of the selected font
|
||||
*/
|
||||
void setFontName(const std::string& _fontName);
|
||||
virtual void setFontName(const std::string& _fontName);
|
||||
/**
|
||||
* @brief Specify the font property (this reset the internal element of the current text (system requirement)
|
||||
* @param[in] fontName Current name of the selected font
|
||||
* @param[in] fontSize New font size
|
||||
*/
|
||||
void setFont(std::string _fontName, int32_t _fontSize);
|
||||
virtual void setFont(std::string _fontName, int32_t _fontSize);
|
||||
/**
|
||||
* @brief Specify the font mode for the next @ref print
|
||||
* @param[in] mode The font mode requested
|
||||
*/
|
||||
void setFontMode(enum ewol::font::mode _mode);
|
||||
virtual void setFontMode(enum ewol::font::mode _mode);
|
||||
/**
|
||||
* @brief get the current font mode
|
||||
* @return The font mode applied
|
||||
*/
|
||||
enum ewol::font::mode getFontMode(void);
|
||||
virtual enum ewol::font::mode getFontMode(void) {
|
||||
return m_mode;
|
||||
};
|
||||
virtual float getHeight(void);
|
||||
virtual float getSize(void);
|
||||
virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode);
|
||||
/**
|
||||
* @brief enable or disable the bold mode
|
||||
* @param[in] _status The new status for this display property
|
||||
*/
|
||||
void setFontBold(bool _status);
|
||||
virtual void setFontBold(bool _status);
|
||||
/**
|
||||
* @brief enable or disable the italic mode
|
||||
* @param[in] _status The new status for this display property
|
||||
*/
|
||||
void setFontItalic(bool _status);
|
||||
virtual void setFontItalic(bool _status);
|
||||
/**
|
||||
* @brief set the activation of the Kerning for the display (if it existed)
|
||||
* @param[in] _newMode enable/Diasable the kerning on this font.
|
||||
*/
|
||||
void setKerningMode(bool _newMode);
|
||||
virtual void setKerningMode(bool _newMode);
|
||||
/**
|
||||
* @brief Request the distance field mode for this text display
|
||||
* @param[in] _newMode enable/Diasable the Distance Field on this font.
|
||||
* @todo : not implemented for now
|
||||
*/
|
||||
void setDistanceFieldMode(bool _newMode);
|
||||
virtual void setDistanceFieldMode(bool _newMode);
|
||||
/**
|
||||
* @brief display a compleat string in the current element.
|
||||
* @param[in] _text The string to display.
|
||||
*/
|
||||
void print(const std::string& _text);
|
||||
virtual void print(const std::string& _text);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
void print(const std::u32string& _text);
|
||||
virtual void print(const std::u32string& _text);
|
||||
/**
|
||||
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
|
||||
*
|
||||
@ -283,9 +300,9 @@ namespace ewol {
|
||||
* @param[in] _text The string to display.
|
||||
* @TODO : implementation not done ....
|
||||
*/
|
||||
void printDecorated(const std::string& _text);
|
||||
virtual void printDecorated(const std::string& _text);
|
||||
//! @previous
|
||||
void printDecorated(const std::u32string& _text);
|
||||
virtual void printDecorated(const std::u32string& _text);
|
||||
/**
|
||||
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
|
||||
*
|
||||
@ -319,32 +336,32 @@ namespace ewol {
|
||||
* @param[in] _text The string to display.
|
||||
* @TODO : implementation not done ....
|
||||
*/
|
||||
void printHTML(const std::string& _text);
|
||||
virtual void printHTML(const std::string& _text);
|
||||
//! @previous
|
||||
void printHTML(const std::u32string& _text);
|
||||
virtual void printHTML(const std::u32string& _text);
|
||||
/**
|
||||
* @brief display a compleat string in the current element whith specific decorations (advence mode).
|
||||
* @param[in] _text The string to display.
|
||||
* @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get)
|
||||
*/
|
||||
void print(const std::string& _text, const std::vector<TextDecoration>& _decoration);
|
||||
virtual void print(const std::string& _text, const std::vector<TextDecoration>& _decoration);
|
||||
//! @previous
|
||||
void print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration);
|
||||
virtual void print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration);
|
||||
/**
|
||||
* @brief display the current char in the current element (note that the kerning is availlable if the position is not changed)
|
||||
* @param[in] _charcode Char that might be dispalyed
|
||||
*/
|
||||
void print(const char32_t& _charcode);
|
||||
virtual void print(const char32_t& _charcode);
|
||||
/**
|
||||
* @brief This generate the line return == > it return to the alignement position start and at the correct line position ==> it might be use to not know the line height
|
||||
*/
|
||||
void forceLineReturn(void);
|
||||
private:
|
||||
virtual void forceLineReturn(void);
|
||||
protected:
|
||||
/**
|
||||
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
|
||||
* @param[in] _element the exml element.
|
||||
*/
|
||||
void parseHtmlNode(exml::Element* _element);
|
||||
virtual void parseHtmlNode(exml::Element* _element);
|
||||
public:
|
||||
/**
|
||||
* @brief This generate the possibility to generate the big text property
|
||||
@ -353,53 +370,53 @@ namespace ewol {
|
||||
* @param[in] _alignement mode of alignement for the Text.
|
||||
* @note The text align in center change of line every display done (even if it was just a char)
|
||||
*/
|
||||
void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::compositing::Text::aligneMode _alignement=ewol::compositing::Text::alignDisable);
|
||||
virtual void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::compositing::Text::aligneMode _alignement=ewol::compositing::Text::alignDisable);
|
||||
/**
|
||||
* @brief disable the alignement system
|
||||
*/
|
||||
void disableAlignement(void);
|
||||
virtual void disableAlignement(void);
|
||||
/**
|
||||
* @brief get the current alignement property
|
||||
* @return the curent alignement type
|
||||
*/
|
||||
enum ewol::compositing::Text::aligneMode getAlignement(void);
|
||||
virtual enum ewol::compositing::Text::aligneMode getAlignement(void);
|
||||
/**
|
||||
* @brief calculate a theoric text size
|
||||
* @param[in] _text The string to calculate dimention.
|
||||
* @return The theoric size used.
|
||||
*/
|
||||
vec3 calculateSizeHTML(const std::string& _text);
|
||||
virtual vec3 calculateSizeHTML(const std::string& _text);
|
||||
//!@previous
|
||||
vec3 calculateSizeHTML(const std::u32string& _text);
|
||||
virtual vec3 calculateSizeHTML(const std::u32string& _text);
|
||||
/**
|
||||
* @brief calculate a theoric text size
|
||||
* @param[in] _text The string to calculate dimention.
|
||||
* @return The theoric size used.
|
||||
*/
|
||||
vec3 calculateSizeDecorated(const std::string& _text);
|
||||
virtual vec3 calculateSizeDecorated(const std::string& _text);
|
||||
//!@previous
|
||||
vec3 calculateSizeDecorated(const std::u32string& _text);
|
||||
virtual vec3 calculateSizeDecorated(const std::u32string& _text);
|
||||
/**
|
||||
* @brief calculate a theoric text size
|
||||
* @param[in] _text The string to calculate dimention.
|
||||
* @return The theoric size used.
|
||||
*/
|
||||
vec3 calculateSize(const std::string& _text);
|
||||
virtual vec3 calculateSize(const std::string& _text);
|
||||
//!@previous
|
||||
vec3 calculateSize(const std::u32string& _text);
|
||||
virtual vec3 calculateSize(const std::u32string& _text);
|
||||
/**
|
||||
* @brief calculate a theoric charcode size
|
||||
* @param[in] _charcode The µUnicode value to calculate dimention.
|
||||
* @return The theoric size used.
|
||||
*/
|
||||
vec3 calculateSize(const char32_t& _charcode);
|
||||
virtual vec3 calculateSize(const char32_t& _charcode);
|
||||
/**
|
||||
* @brief draw a cursor at the specify position
|
||||
* @param[in] _isInsertMode True if the insert mode is activated
|
||||
* @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20]
|
||||
*/
|
||||
void printCursor(bool _isInsertMode, float _cursorSize = 20.0f);
|
||||
private:
|
||||
virtual void printCursor(bool _isInsertMode, float _cursorSize = 20.0f);
|
||||
protected:
|
||||
/**
|
||||
* @brief calculate the element number that is the first out the alignement range
|
||||
* (start at the specify ID, and use start pos with current one)
|
||||
@ -411,12 +428,12 @@ namespace ewol {
|
||||
* @return true if the rifht has free space that can be use for jystify.
|
||||
* @return false if we find '\n'
|
||||
*/
|
||||
bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
|
||||
virtual bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
|
||||
private:
|
||||
virtual bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
|
||||
protected:
|
||||
// this section is reserved for HTML parsing and display:
|
||||
std::u32string m_htmlCurrrentLine; //!< current line for HTML display
|
||||
std::vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display
|
||||
@ -425,37 +442,37 @@ namespace ewol {
|
||||
* @brief add a line with the current m_htmlDecoTmp decoration
|
||||
* @param[in] _data The cuurent data to add.
|
||||
*/
|
||||
void htmlAddData(const std::u32string& _data);
|
||||
virtual void htmlAddData(const std::u32string& _data);
|
||||
/**
|
||||
* @brief draw the current line
|
||||
*/
|
||||
void htmlFlush(void);
|
||||
virtual void htmlFlush(void);
|
||||
public:
|
||||
/**
|
||||
* @brief remove the cursor display
|
||||
*/
|
||||
void disableCursor(void);
|
||||
virtual void disableCursor(void);
|
||||
/**
|
||||
* @brief set a cursor at a specific position:
|
||||
* @param[in] _cursorPos id of the cursor position
|
||||
*/
|
||||
void setCursorPos(int32_t _cursorPos);
|
||||
virtual void setCursorPos(int32_t _cursorPos);
|
||||
/**
|
||||
* @brief set a cursor at a specific position with his associated selection:
|
||||
* @param[in] _cursorPos id of the cursor position
|
||||
* @param[in] _selectionStartPos id of the starting of the selection
|
||||
*/
|
||||
void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos);
|
||||
virtual void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos);
|
||||
/**
|
||||
* @brief change the selection color
|
||||
* @param[in] _color New color for the Selection
|
||||
*/
|
||||
void setSelectionColor(const etk::Color<>& _color);
|
||||
virtual void setSelectionColor(const etk::Color<>& _color);
|
||||
/**
|
||||
* @brief change the cursor color
|
||||
* @param[in] _color New color for the Selection
|
||||
*/
|
||||
void setCursorColor(const etk::Color<>& _color);
|
||||
virtual void setCursorColor(const etk::Color<>& _color);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
165
sources/ewol/compositing/TextDF.cpp
Normal file
165
sources/ewol/compositing/TextDF.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/compositing/TextDF.h>
|
||||
#include <ewol/context/Context.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::compositing::TextDF"
|
||||
|
||||
|
||||
ewol::compositing::TextDF::TextDF(const std::string& _fontName, int32_t _fontSize) :
|
||||
ewol::compositing::Text::Text(_fontName, _fontSize, false),
|
||||
m_fontDF(NULL),
|
||||
m_size(9.0) {
|
||||
setFont(_fontName, _fontSize);
|
||||
loadProgram("DATA:fontDistanceField/font1.prog");
|
||||
}
|
||||
|
||||
|
||||
ewol::compositing::TextDF::~TextDF(void) {
|
||||
ewol::resource::DistanceFieldFont::release(m_fontDF);
|
||||
}
|
||||
|
||||
void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) {
|
||||
|
||||
// draw BG in any case:
|
||||
m_vectorialDraw.draw();
|
||||
|
||||
EWOL_WARNING("draw DF...");
|
||||
if (m_coord.size() <= 0 || m_fontDF == NULL) {
|
||||
// TODO : a remÚtre ...
|
||||
//EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
if (m_fontDF == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return;
|
||||
}
|
||||
if (m_GLprogram == NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
if (_enableDepthTest == true) {
|
||||
ewol::openGL::enable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
}
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 projMatrix = ewol::openGL::getMatrix();
|
||||
mat4 camMatrix = ewol::openGL::getCameraMatrix();
|
||||
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// TextureID
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId());
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// Texture :
|
||||
m_GLprogram->sendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||
// color :
|
||||
m_GLprogram->sendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
|
||||
m_GLprogram->unUse();
|
||||
if (_enableDepthTest == true) {
|
||||
ewol::openGL::disable(ewol::openGL::FLAG_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
|
||||
EWOL_WARNING("draw DF.2.");
|
||||
// draw BG in any case:
|
||||
m_vectorialDraw.draw();
|
||||
|
||||
if (m_coord.size() <= 0 || m_fontDF == NULL) {
|
||||
// TODO : a remètre ...
|
||||
//EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
if (m_fontDF == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return;
|
||||
}
|
||||
if (m_GLprogram == NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
// set Matrix : translation/positionMatrix
|
||||
mat4 tmpMatrix = ewol::openGL::getMatrix()*m_matrixApply;
|
||||
m_GLprogram->use();
|
||||
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// TextureID
|
||||
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId());
|
||||
// position :
|
||||
m_GLprogram->sendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// Texture :
|
||||
m_GLprogram->sendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
|
||||
// color :
|
||||
m_GLprogram->sendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
|
||||
// Request the draw od the elements :
|
||||
ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
|
||||
m_GLprogram->unUse();
|
||||
}
|
||||
|
||||
float ewol::compositing::TextDF::getHeight(void) {
|
||||
if (m_fontDF == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return 1;
|
||||
}
|
||||
return m_fontDF->getHeight(m_size);
|
||||
}
|
||||
|
||||
ewol::GlyphProperty * ewol::compositing::TextDF::getGlyphPointer(char32_t _charcode) {
|
||||
if (m_fontDF == NULL) {
|
||||
EWOL_WARNING("no font...");
|
||||
return NULL;
|
||||
}
|
||||
return m_fontDF->getGlyphPointer(_charcode);
|
||||
}
|
||||
|
||||
void ewol::compositing::TextDF::setFontSize(int32_t _fontSize) {
|
||||
clear();
|
||||
EWOL_VERBOSE("Set font Size: " << _fontSize);
|
||||
if (_fontSize <= 1) {
|
||||
m_size = ewol::getContext().getFontDefault().getSize();
|
||||
} else {
|
||||
m_size = _fontSize;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::compositing::TextDF::setFontName(const std::string& _fontName) {
|
||||
clear();
|
||||
// remove old one
|
||||
ewol::resource::DistanceFieldFont* previousFont = m_fontDF;
|
||||
std::string fontName;
|
||||
if (_fontName == "") {
|
||||
fontName = ewol::getContext().getFontDefault().getName();
|
||||
} else {
|
||||
fontName = _fontName;
|
||||
}
|
||||
EWOL_VERBOSE("Set font name: '" << fontName << "'");
|
||||
// link to new one
|
||||
m_fontDF = ewol::resource::DistanceFieldFont::keep(fontName);
|
||||
if (m_fontDF == NULL) {
|
||||
EWOL_ERROR("Can not get find resource");
|
||||
m_fontDF = previousFont;
|
||||
} else {
|
||||
ewol::resource::DistanceFieldFont::release(previousFont);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::compositing::TextDF::setFont(std::string _fontName, int32_t _fontSize) {
|
||||
setFontSize(_fontSize);
|
||||
setFontName(_fontName);
|
||||
}
|
||||
|
||||
void ewol::compositing::TextDF::setFontMode(enum ewol::font::mode _mode) {
|
||||
m_mode = _mode;
|
||||
}
|
63
sources/ewol/compositing/TextDF.h
Normal file
63
sources/ewol/compositing/TextDF.h
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_COMPOSITING_TEXT_DF_H__
|
||||
#define __EWOL_COMPOSITING_TEXT_DF_H__
|
||||
|
||||
#include <etk/Color.h>
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/compositing/Compositing.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/resource/DistanceFieldFont.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <exml/exml.h>
|
||||
#include <string>
|
||||
|
||||
namespace ewol {
|
||||
namespace compositing {
|
||||
class TextDF : public ewol::compositing::Text {
|
||||
protected:
|
||||
ewol::resource::DistanceFieldFont* m_fontDF; //!< Font resources
|
||||
public:
|
||||
/**
|
||||
* @brief generic constructor
|
||||
* @param[in] _fontName Name of the font that might be loaded
|
||||
* @param[in] _fontSize size of the font that might be loaded
|
||||
*/
|
||||
TextDF(const std::string& _fontName="", int32_t _fontSize=-1);
|
||||
/**
|
||||
* @brief generic destructor
|
||||
*/
|
||||
virtual ~TextDF(void);
|
||||
public:
|
||||
virtual void drawD(bool _disableDepthTest);
|
||||
/**
|
||||
* @previous
|
||||
*/
|
||||
virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest);
|
||||
protected:
|
||||
float m_size;
|
||||
public:
|
||||
virtual float getHeight(void);
|
||||
virtual float getSize(void) {
|
||||
return m_size;
|
||||
}
|
||||
virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode);
|
||||
|
||||
public:
|
||||
virtual void setFontSize(int32_t _fontSize);
|
||||
virtual void setFontName(const std::string& _fontName);
|
||||
virtual void setFont(std::string _fontName, int32_t _fontSize);
|
||||
virtual void setFontMode(enum ewol::font::mode _mode);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,13 +22,15 @@
|
||||
#undef __class__
|
||||
#define __class__ "resource::DistanceFieldFont"
|
||||
|
||||
#define SIZE_GENERATION (70)
|
||||
|
||||
ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontName) :
|
||||
ewol::resource::Texture(_fontName) {
|
||||
addObjectType("ewol::resource::DistanceFieldFont");
|
||||
m_font = NULL;
|
||||
m_lastGlyphPos.setValue(1,1);
|
||||
m_lastRawHeigh = 0;
|
||||
m_size = 70;
|
||||
m_sizeRatio = 1.0f;
|
||||
std::string localName = _fontName;
|
||||
std::vector<std::string> folderList;
|
||||
if (true == ewol::getContext().getFontDefault().getUseExternal()) {
|
||||
@ -79,14 +81,14 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
|
||||
}
|
||||
|
||||
if (m_fileName.size() == 0) {
|
||||
EWOL_ERROR("can not load FONT name : '" << m_fileName << "' ==> size=" << m_size );
|
||||
EWOL_ERROR("can not load FONT name : '" << m_fileName << "'" );
|
||||
m_font = NULL;
|
||||
return;
|
||||
}
|
||||
EWOL_INFO("Load FONT name : '" << m_fileName << "' ==> size=" << m_size);
|
||||
EWOL_INFO("Load FONT name : '" << m_fileName << "'");
|
||||
m_font = ewol::resource::FontFreeType::keep(m_fileName);
|
||||
if (m_font == NULL) {
|
||||
EWOL_ERROR("Pb Loading FONT name : '" << m_fileName << "' ==> size=" << m_size );
|
||||
EWOL_ERROR("Pb Loading FONT name : '" << m_fileName << "'" );
|
||||
}
|
||||
|
||||
// set the bassic charset:
|
||||
@ -94,7 +96,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
|
||||
if (m_font == NULL) {
|
||||
return;
|
||||
}
|
||||
m_height = m_font->getHeight(m_size);
|
||||
m_sizeRatio = ((float)SIZE_GENERATION) / ((float)m_font->getHeight(SIZE_GENERATION));
|
||||
// TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ???
|
||||
setImageSize(ivec2(256,32));
|
||||
// now we can acces directly on the image
|
||||
@ -204,7 +206,7 @@ bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
|
||||
egami::Image imageGlyphDistanceField;
|
||||
EWOL_DEBUG("Generate Glyph : " << _val);
|
||||
|
||||
if (m_font->getGlyphProperty(m_size, tmpchar) == true) {
|
||||
if (m_font->getGlyphProperty(SIZE_GENERATION, tmpchar) == true) {
|
||||
//EWOL_DEBUG("load char : '" << _val << "'=" << _val.get());
|
||||
hasChange = true;
|
||||
// change line if needed ...
|
||||
@ -224,7 +226,7 @@ bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
|
||||
}
|
||||
}
|
||||
// draw the glyph
|
||||
m_font->drawGlyph(imageGlyphRaw, m_size, tmpchar, 5);
|
||||
m_font->drawGlyph(imageGlyphRaw, SIZE_GENERATION, tmpchar, 5);
|
||||
|
||||
GenerateDistanceField(imageGlyphRaw, imageGlyphDistanceField);
|
||||
if (_val == 'Z') {
|
||||
|
@ -19,8 +19,7 @@ namespace ewol {
|
||||
class DistanceFieldFont : public ewol::resource::Texture {
|
||||
private:
|
||||
std::string m_fileName;
|
||||
int32_t m_size;
|
||||
int32_t m_height;
|
||||
float m_sizeRatio;
|
||||
// specific element to have the the know if the specify element is known...
|
||||
// == > otherwise I can just generate italic ...
|
||||
// == > Bold is a little more complicated (maybe with the bordersize)
|
||||
@ -37,22 +36,12 @@ namespace ewol {
|
||||
public:
|
||||
/**
|
||||
* @brief get the display height of this font
|
||||
* @param[in] _displayMode Mode to display the currrent font
|
||||
* @param[in] _size Request font size
|
||||
* @return Dimention of the font need between 2 lines
|
||||
*/
|
||||
// TODO : Might be deprecated ... ==> no size for this font ...
|
||||
int32_t getHeight(const enum ewol::font::mode _displayMode = ewol::font::Regular) {
|
||||
return m_height;
|
||||
float getHeight(float _size) {
|
||||
return _size * m_sizeRatio;;
|
||||
};
|
||||
/**
|
||||
* @brief get the font height (user friendly)
|
||||
* @return Dimention of the font the user requested
|
||||
*/
|
||||
// TODO : Might be deprecated ... ==> no size for this font ...
|
||||
int32_t getFontSize(void) {
|
||||
return m_size;
|
||||
};
|
||||
// TODO : Need to convert a text size in a real size and this oposite ...
|
||||
/**
|
||||
* @brief get the ID of a unicode charcode
|
||||
* @param[in] _charcode The unicodeValue
|
||||
|
@ -29,6 +29,7 @@ def create(target):
|
||||
myModule.add_src_file([
|
||||
'ewol/compositing/Compositing.cpp',
|
||||
'ewol/compositing/Text.cpp',
|
||||
'ewol/compositing/TextDF.cpp',
|
||||
'ewol/compositing/Drawing.cpp',
|
||||
'ewol/compositing/Image.cpp',
|
||||
'ewol/compositing/Sprite.cpp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user