[DEV] segfault correction and dynamic management of the font position
This commit is contained in:
parent
6533b8af29
commit
150df589e6
2
build
2
build
@ -1 +1 @@
|
||||
Subproject commit 78d74b125f820fbeed698ddde87904fd99757c71
|
||||
Subproject commit 6c1649f36f63f6ab5d8c99ed1aa566d2ecec627c
|
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
||||
Subproject commit 46b81ecbbf1a907cfc1c629af848d1b0aeadd7dc
|
||||
Subproject commit 6d94d06efa8df92fe002f411118797ed6679e956
|
@ -769,12 +769,16 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
|
||||
|
||||
void ewol::Text::Print(const uniChar_t charcode)
|
||||
{
|
||||
if (m_font == NULL) {
|
||||
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);
|
||||
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);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
#include <ewol/renderer/os/eSystem.h>
|
||||
|
||||
#include <ewol/renderer/resources/TexturedFont.h>
|
||||
#include <ewol/renderer/os/gui.h>
|
||||
#include <ewol/commandLine.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
@ -17,6 +18,10 @@
|
||||
#undef __class__
|
||||
#define __class__ "ewol"
|
||||
|
||||
void ewol::SetFontSourcesFolder(bool inOsSystem)
|
||||
{
|
||||
ewol::font::SetFontPropety(inOsSystem);
|
||||
}
|
||||
|
||||
int32_t ewol::Run(int32_t argc, const char* argv[])
|
||||
{
|
||||
|
@ -105,6 +105,11 @@ namespace ewol
|
||||
* @note Does not work on Andoid
|
||||
*/
|
||||
void SetIcon(etk::UString icon);
|
||||
/**
|
||||
* @brief Select the position of the font folder (in the OS path or in the DATA: path)
|
||||
* @param[in] inOsSystem Set at true if you want to select the os system folder.
|
||||
*/
|
||||
void SetFontSourcesFolder(bool inOsSystem);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -45,6 +45,16 @@ static int32_t simpleSQRT(int32_t value)
|
||||
return val;
|
||||
}
|
||||
|
||||
static bool& GetFontInSystem(void)
|
||||
{
|
||||
static bool fontInOs = true;
|
||||
return fontInOs;
|
||||
}
|
||||
|
||||
void ewol::font::SetFontPropety(bool inOSSystem)
|
||||
{
|
||||
GetFontInSystem() = inOSSystem;
|
||||
}
|
||||
|
||||
ewol::TexturedFont::TexturedFont(etk::UString fontName) :
|
||||
ewol::Texture(fontName)
|
||||
@ -89,17 +99,18 @@ ewol::TexturedFont::TexturedFont(etk::UString fontName) :
|
||||
m_name = fontName.Extract(0, (tmpPos - tmpData));
|
||||
m_size = tmpSize;
|
||||
|
||||
etk::UString fontBaseFolder("DATA:fonts");
|
||||
if (true==GetFontInSystem()) {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
fontBaseFolder = "/system/font";
|
||||
#elif defined(__TARGET_OS__Linux)
|
||||
fontBaseFolder = "/usr/share/fonts/truetype";
|
||||
#endif
|
||||
}
|
||||
etk::FSNode myFolder(fontBaseFolder);
|
||||
EWOL_INFO("try to find font named : '" << m_name << "' in : '" << myFolder <<"'");
|
||||
// find the real Font name :
|
||||
etk::Vector<etk::UString> output;
|
||||
#ifdef __EWOL_INTEGRATED_FONT__
|
||||
etk::FSNode myFolder("DATA:fonts");
|
||||
#else
|
||||
#if defined(__TARGET_OS__Android)
|
||||
etk::FSNode myFolder("/system/font");
|
||||
#elif defined(__TARGET_OS__Linux)
|
||||
etk::FSNode myFolder("/usr/share/fonts/truetype");
|
||||
#endif
|
||||
#endif
|
||||
myFolder.FolderGetRecursiveFiles(output);
|
||||
for (int32_t iii=0; iii<output.Size(); iii++) {
|
||||
//EWOL_DEBUG(" file : " << output[iii]);
|
||||
|
@ -17,6 +17,7 @@ namespace ewol
|
||||
{
|
||||
namespace font
|
||||
{
|
||||
void SetFontPropety(bool inOSSystem);
|
||||
typedef enum {
|
||||
Regular=0,
|
||||
Italic,
|
||||
|
@ -52,15 +52,15 @@ namespace ewol
|
||||
class GlyphProperty
|
||||
{
|
||||
public:
|
||||
uniChar_t m_UVal; //!< Unicode value
|
||||
int32_t m_glyphIndex; //!< Glyph index in the system
|
||||
ivec2 m_sizeTexture; //!< size of the element to display
|
||||
ivec2 m_bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string)
|
||||
ivec2 m_advance; //!< space use in the display for this specific char
|
||||
vec2 m_texturePosStart; //!< Texture normalised position (START)
|
||||
vec2 m_texturePosStop; //!< Texture normalised position (STOP)
|
||||
uniChar_t m_UVal; //!< Unicode value
|
||||
int32_t m_glyphIndex; //!< Glyph index in the system
|
||||
ivec2 m_sizeTexture; //!< size of the element to display
|
||||
ivec2 m_bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string)
|
||||
ivec2 m_advance; //!< space use in the display for this specific char
|
||||
vec2 m_texturePosStart; //!< Texture normalised position (START)
|
||||
vec2 m_texturePosStop; //!< Texture normalised position (STOP)
|
||||
private:
|
||||
etk::Vector<ewol::Kerning> m_kerning; //!< kerning values of link of all elements
|
||||
etk::Vector<ewol::Kerning> m_kerning; //!< kerning values of link of all elements
|
||||
public:
|
||||
float KerningGet(const uniChar_t charcode)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
import lutinModule
|
||||
import lutinTools
|
||||
import os
|
||||
import datetime
|
||||
|
||||
def Create(target):
|
||||
# set the ewol folder for Android basic sources ...
|
||||
@ -141,10 +142,11 @@ def Create(target):
|
||||
#endif
|
||||
|
||||
myModule.AddExportPath(lutinTools.GetCurrentPath(__file__))
|
||||
|
||||
now = datetime.datetime.now()
|
||||
myModule.CompileFlags_CC([
|
||||
'-Wno-write-strings',
|
||||
'-DEWOL_VERSION_TAG_NAME="\\"TAG-build\\""',
|
||||
"-DBUILD_TIME=\"\\\""+str(now.day)+"/"+str(now.month)+"/"+str(now.year)+"\\\"\"",
|
||||
'-Wall'])
|
||||
|
||||
if target.name=="Linux":
|
||||
@ -196,7 +198,6 @@ def Create(target):
|
||||
elif target.name=="Windows":
|
||||
myModule.AddModuleDepend("glew")
|
||||
myModule.AddSrcFile("ewol/renderer/os/gui.Windows.cpp")
|
||||
myModule.CompileFlags_CC('-D__EWOL_INTEGRATED_FONT__')
|
||||
else:
|
||||
debug.error("unknow mode...")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user