Merge with develop
This commit is contained in:
parent
0be0a1e9e7
commit
85838aec19
13 changed files with 205 additions and 45 deletions
|
@ -77,7 +77,7 @@ namespace NLGUI
|
||||||
class CStyleParams
|
class CStyleParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CStyleParams () : TextColor(255,255,255,255)
|
CStyleParams () : FontFamily(""), TextColor(255,255,255,255)
|
||||||
{
|
{
|
||||||
FontSize=10;
|
FontSize=10;
|
||||||
FontWeight=400;
|
FontWeight=400;
|
||||||
|
@ -92,6 +92,7 @@ namespace NLGUI
|
||||||
uint FontSize;
|
uint FontSize;
|
||||||
uint FontWeight;
|
uint FontWeight;
|
||||||
bool FontOblique;
|
bool FontOblique;
|
||||||
|
std::string FontFamily;
|
||||||
NLMISC::CRGBA TextColor;
|
NLMISC::CRGBA TextColor;
|
||||||
bool Underlined;
|
bool Underlined;
|
||||||
bool StrikeThrough;
|
bool StrikeThrough;
|
||||||
|
@ -508,6 +509,15 @@ namespace NLGUI
|
||||||
return _GlobalColor.back();
|
return _GlobalColor.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Current font name
|
||||||
|
std::vector<std::string> _FontFamily;
|
||||||
|
inline const char* getFontFamily() const
|
||||||
|
{
|
||||||
|
if (_FontFamily.empty())
|
||||||
|
return "";
|
||||||
|
return _FontFamily.back().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Current font size
|
// Current font size
|
||||||
std::vector<uint> _FontSize;
|
std::vector<uint> _FontSize;
|
||||||
inline uint getFontSize() const
|
inline uint getFontSize() const
|
||||||
|
|
|
@ -586,8 +586,12 @@ namespace NLGUI
|
||||||
static NL3D::UDriver *driver;
|
static NL3D::UDriver *driver;
|
||||||
static NL3D::UTextContext *textcontext;
|
static NL3D::UTextContext *textcontext;
|
||||||
|
|
||||||
|
typedef CHashMap< std::string, NL3D::UTextContext* > TFontsList;
|
||||||
|
static TFontsList fonts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static NL3D::UTextContext* getTextContext(){ return textcontext; }
|
static NL3D::UTextContext* getTextContext(const std::string &name="");
|
||||||
|
static bool registerFont(const std::string &name, const std::string &font);
|
||||||
|
|
||||||
/// Set of hw cursor images
|
/// Set of hw cursor images
|
||||||
static std::set< std::string > *hwCursors;
|
static std::set< std::string > *hwCursors;
|
||||||
|
|
|
@ -80,6 +80,7 @@ namespace NLGUI
|
||||||
/// Set
|
/// Set
|
||||||
|
|
||||||
void setText (const ucstring &text);
|
void setText (const ucstring &text);
|
||||||
|
void setFontName (const std::string &name);
|
||||||
void setFontSize (sint nFontSize);
|
void setFontSize (sint nFontSize);
|
||||||
void setEmbolden (bool nEmbolden);
|
void setEmbolden (bool nEmbolden);
|
||||||
void setOblique (bool nOblique);
|
void setOblique (bool nOblique);
|
||||||
|
@ -104,6 +105,7 @@ namespace NLGUI
|
||||||
|
|
||||||
ucstring getText() const { return _Text; }
|
ucstring getText() const { return _Text; }
|
||||||
sint getFontSize() const;
|
sint getFontSize() const;
|
||||||
|
std::string getFontName() const { return _FontName; }
|
||||||
bool getEmbolden() { return _Embolden; }
|
bool getEmbolden() { return _Embolden; }
|
||||||
bool getOblique() { return _Oblique; }
|
bool getOblique() { return _Oblique; }
|
||||||
NLMISC::CRGBA getColor() { return _Color; }
|
NLMISC::CRGBA getColor() { return _Color; }
|
||||||
|
@ -227,6 +229,8 @@ namespace NLGUI
|
||||||
uint _Index;
|
uint _Index;
|
||||||
/// info on the computed String associated to this text control
|
/// info on the computed String associated to this text control
|
||||||
NL3D::UTextContext::CStringInfo _Info;
|
NL3D::UTextContext::CStringInfo _Info;
|
||||||
|
/// Font name to get TextContext
|
||||||
|
std::string _FontName;
|
||||||
/// the font size
|
/// the font size
|
||||||
sint _FontSize;
|
sint _FontSize;
|
||||||
bool _Embolden;
|
bool _Embolden;
|
||||||
|
@ -320,7 +324,7 @@ namespace NLGUI
|
||||||
CFormatInfo Format;
|
CFormatInfo Format;
|
||||||
public:
|
public:
|
||||||
// build from a string, using the current text context
|
// build from a string, using the current text context
|
||||||
void build(const ucstring &text, uint numSpaces= 0);
|
void build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces= 0);
|
||||||
};
|
};
|
||||||
typedef std::vector<CWord> TWordVect;
|
typedef std::vector<CWord> TWordVect;
|
||||||
|
|
||||||
|
@ -331,9 +335,9 @@ namespace NLGUI
|
||||||
// ctor
|
// ctor
|
||||||
CLine();
|
CLine();
|
||||||
// Clear the line & remove text contexts
|
// Clear the line & remove text contexts
|
||||||
void clear();
|
void clear(NL3D::UTextContext &textContext);
|
||||||
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
|
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
|
||||||
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth);
|
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth, NL3D::UTextContext &textContext);
|
||||||
void addWord(const CWord &word, uint fontWidth);
|
void addWord(const CWord &word, uint fontWidth);
|
||||||
uint getNumWords() const { return (uint)_Words.size(); }
|
uint getNumWords() const { return (uint)_Words.size(); }
|
||||||
CWord &getWord(uint index) { return _Words[index]; }
|
CWord &getWord(uint index) { return _Words[index]; }
|
||||||
|
|
|
@ -442,6 +442,7 @@ namespace NLGUI
|
||||||
OptionTimeoutMessages,
|
OptionTimeoutMessages,
|
||||||
OptionTimeoutContext,
|
OptionTimeoutContext,
|
||||||
OptionTimeoutContextHtml,
|
OptionTimeoutContextHtml,
|
||||||
|
OptionMonospaceFont,
|
||||||
NumSystemOptions
|
NumSystemOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1218,6 +1218,7 @@ namespace NLGUI
|
||||||
registerAnchorName(MY_HTML_A);
|
registerAnchorName(MY_HTML_A);
|
||||||
|
|
||||||
CStyleParams style;
|
CStyleParams style;
|
||||||
|
style.FontFamily = getFontFamily();
|
||||||
style.FontSize = getFontSize();
|
style.FontSize = getFontSize();
|
||||||
style.TextColor = LinkColor;
|
style.TextColor = LinkColor;
|
||||||
style.Underlined = true;
|
style.Underlined = true;
|
||||||
|
@ -1226,6 +1227,7 @@ namespace NLGUI
|
||||||
if (present[HTML_A_STYLE] && value[HTML_A_STYLE])
|
if (present[HTML_A_STYLE] && value[HTML_A_STYLE])
|
||||||
getStyleParams(value[HTML_A_STYLE], style);
|
getStyleParams(value[HTML_A_STYLE], style);
|
||||||
|
|
||||||
|
_FontFamily.push_back(style.FontFamily);
|
||||||
_FontSize.push_back(style.FontSize);
|
_FontSize.push_back(style.FontSize);
|
||||||
_TextColor.push_back(style.TextColor);
|
_TextColor.push_back(style.TextColor);
|
||||||
_FontUnderlined.push_back(style.Underlined);
|
_FontUnderlined.push_back(style.Underlined);
|
||||||
|
@ -1568,7 +1570,7 @@ namespace NLGUI
|
||||||
if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT])
|
if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT])
|
||||||
tooltip = value[MY_HTML_INPUT_ALT];
|
tooltip = value[MY_HTML_INPUT_ALT];
|
||||||
|
|
||||||
// by default not inherited
|
// by default not inherited, font family defaults to system font
|
||||||
CStyleParams style;
|
CStyleParams style;
|
||||||
style.TextColor = TextColor;
|
style.TextColor = TextColor;
|
||||||
style.FontSize = TextFontSize;
|
style.FontSize = TextFontSize;
|
||||||
|
@ -1579,6 +1581,7 @@ namespace NLGUI
|
||||||
getStyleParams(value[MY_HTML_INPUT_STYLE], style);
|
getStyleParams(value[MY_HTML_INPUT_STYLE], style);
|
||||||
|
|
||||||
_TextColor.push_back(style.TextColor);
|
_TextColor.push_back(style.TextColor);
|
||||||
|
_FontFamily.push_back(style.FontFamily);
|
||||||
_FontSize.push_back(style.FontSize);
|
_FontSize.push_back(style.FontSize);
|
||||||
_FontWeight.push_back(style.FontWeight);
|
_FontWeight.push_back(style.FontWeight);
|
||||||
_FontOblique.push_back(style.FontOblique);
|
_FontOblique.push_back(style.FontOblique);
|
||||||
|
@ -1794,6 +1797,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popIfNotEmpty(_FontFamily);
|
||||||
popIfNotEmpty(_FontSize);
|
popIfNotEmpty(_FontSize);
|
||||||
popIfNotEmpty(_TextColor);
|
popIfNotEmpty(_TextColor);
|
||||||
popIfNotEmpty(_FontWeight);
|
popIfNotEmpty(_FontWeight);
|
||||||
|
@ -1910,7 +1914,29 @@ namespace NLGUI
|
||||||
newParagraph(PBeginSpace);
|
newParagraph(PBeginSpace);
|
||||||
break;
|
break;
|
||||||
case HTML_PRE:
|
case HTML_PRE:
|
||||||
|
{
|
||||||
|
CStyleParams style;
|
||||||
|
style.TextColor = getTextColor();
|
||||||
|
style.FontFamily = "monospace";
|
||||||
|
style.FontSize = getFontSize();
|
||||||
|
style.FontWeight = getFontWeight();
|
||||||
|
style.FontOblique = getFontOblique();
|
||||||
|
style.Underlined = getFontUnderlined();
|
||||||
|
style.StrikeThrough = getFontStrikeThrough();
|
||||||
|
|
||||||
|
if (present[MY_HTML_SPAN_STYLE] && value[MY_HTML_SPAN_STYLE])
|
||||||
|
getStyleParams(value[MY_HTML_SPAN_STYLE], style);
|
||||||
|
|
||||||
|
_TextColor.push_back(style.TextColor);
|
||||||
|
_FontFamily.push_back(style.FontFamily);
|
||||||
|
_FontSize.push_back(style.FontSize);
|
||||||
|
_FontWeight.push_back(style.FontWeight);
|
||||||
|
_FontOblique.push_back(style.FontOblique);
|
||||||
|
_FontUnderlined.push_back(style.Underlined);
|
||||||
|
_FontStrikeThrough.push_back(style.StrikeThrough);
|
||||||
|
|
||||||
_PRE.push_back(true);
|
_PRE.push_back(true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case HTML_TABLE:
|
case HTML_TABLE:
|
||||||
{
|
{
|
||||||
|
@ -2039,7 +2065,7 @@ namespace NLGUI
|
||||||
// Got one form ?
|
// Got one form ?
|
||||||
if (!(_Forms.empty()))
|
if (!(_Forms.empty()))
|
||||||
{
|
{
|
||||||
// not inherited by default
|
// not inherited by default, font family defaults to system font
|
||||||
CStyleParams style;
|
CStyleParams style;
|
||||||
style.TextColor = TextColor;
|
style.TextColor = TextColor;
|
||||||
style.FontWeight = FONT_WEIGHT_NORMAL;
|
style.FontWeight = FONT_WEIGHT_NORMAL;
|
||||||
|
@ -2050,6 +2076,7 @@ namespace NLGUI
|
||||||
getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style);
|
getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style);
|
||||||
|
|
||||||
_TextColor.push_back(style.TextColor);
|
_TextColor.push_back(style.TextColor);
|
||||||
|
_FontFamily.push_back(style.FontFamily);
|
||||||
_FontSize.push_back(style.FontSize);
|
_FontSize.push_back(style.FontSize);
|
||||||
_FontWeight.push_back(style.FontWeight);
|
_FontWeight.push_back(style.FontWeight);
|
||||||
_FontOblique.push_back(style.FontOblique);
|
_FontOblique.push_back(style.FontOblique);
|
||||||
|
@ -2136,6 +2163,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
CStyleParams style;
|
CStyleParams style;
|
||||||
style.TextColor = getTextColor();
|
style.TextColor = getTextColor();
|
||||||
|
style.FontFamily = getFontFamily();
|
||||||
style.FontSize = getFontSize();
|
style.FontSize = getFontSize();
|
||||||
style.FontWeight = getFontWeight();
|
style.FontWeight = getFontWeight();
|
||||||
style.FontOblique = getFontOblique();
|
style.FontOblique = getFontOblique();
|
||||||
|
@ -2146,6 +2174,7 @@ namespace NLGUI
|
||||||
getStyleParams(value[MY_HTML_SPAN_STYLE], style);
|
getStyleParams(value[MY_HTML_SPAN_STYLE], style);
|
||||||
|
|
||||||
_TextColor.push_back(style.TextColor);
|
_TextColor.push_back(style.TextColor);
|
||||||
|
_FontFamily.push_back(style.FontFamily);
|
||||||
_FontSize.push_back(style.FontSize);
|
_FontSize.push_back(style.FontSize);
|
||||||
_FontWeight.push_back(style.FontWeight);
|
_FontWeight.push_back(style.FontWeight);
|
||||||
_FontOblique.push_back(style.FontOblique);
|
_FontOblique.push_back(style.FontOblique);
|
||||||
|
@ -2300,6 +2329,7 @@ namespace NLGUI
|
||||||
popIfNotEmpty (_FontSize);
|
popIfNotEmpty (_FontSize);
|
||||||
break;
|
break;
|
||||||
case HTML_A:
|
case HTML_A:
|
||||||
|
popIfNotEmpty (_FontFamily);
|
||||||
popIfNotEmpty (_FontSize);
|
popIfNotEmpty (_FontSize);
|
||||||
popIfNotEmpty (_TextColor);
|
popIfNotEmpty (_TextColor);
|
||||||
popIfNotEmpty (_FontUnderlined);
|
popIfNotEmpty (_FontUnderlined);
|
||||||
|
@ -2325,6 +2355,13 @@ namespace NLGUI
|
||||||
endParagraph();
|
endParagraph();
|
||||||
break;
|
break;
|
||||||
case HTML_PRE:
|
case HTML_PRE:
|
||||||
|
popIfNotEmpty (_FontFamily);
|
||||||
|
popIfNotEmpty (_FontSize);
|
||||||
|
popIfNotEmpty (_FontWeight);
|
||||||
|
popIfNotEmpty (_FontOblique);
|
||||||
|
popIfNotEmpty (_TextColor);
|
||||||
|
popIfNotEmpty (_FontUnderlined);
|
||||||
|
popIfNotEmpty (_FontStrikeThrough);
|
||||||
popIfNotEmpty (_PRE);
|
popIfNotEmpty (_PRE);
|
||||||
break;
|
break;
|
||||||
case HTML_DIV:
|
case HTML_DIV:
|
||||||
|
@ -2371,6 +2408,7 @@ namespace NLGUI
|
||||||
_Forms.back().Entries.push_back (entry);
|
_Forms.back().Entries.push_back (entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popIfNotEmpty (_FontFamily);
|
||||||
popIfNotEmpty (_FontSize);
|
popIfNotEmpty (_FontSize);
|
||||||
popIfNotEmpty (_FontWeight);
|
popIfNotEmpty (_FontWeight);
|
||||||
popIfNotEmpty (_FontOblique);
|
popIfNotEmpty (_FontOblique);
|
||||||
|
@ -2537,6 +2575,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HTML_SPAN:
|
case HTML_SPAN:
|
||||||
|
popIfNotEmpty (_FontFamily);
|
||||||
popIfNotEmpty (_FontSize);
|
popIfNotEmpty (_FontSize);
|
||||||
popIfNotEmpty (_FontWeight);
|
popIfNotEmpty (_FontWeight);
|
||||||
popIfNotEmpty (_FontOblique);
|
popIfNotEmpty (_FontOblique);
|
||||||
|
@ -4008,6 +4047,7 @@ namespace NLGUI
|
||||||
// Compatible with current parameters ?
|
// Compatible with current parameters ?
|
||||||
if (!skipLine &&
|
if (!skipLine &&
|
||||||
(getTextColor() == _CurrentViewLink->getColor()) &&
|
(getTextColor() == _CurrentViewLink->getColor()) &&
|
||||||
|
(getFontFamily() == _CurrentViewLink->getFontName()) &&
|
||||||
(getFontSize() == (uint)_CurrentViewLink->getFontSize()) &&
|
(getFontSize() == (uint)_CurrentViewLink->getFontSize()) &&
|
||||||
(getFontUnderlined() == _CurrentViewLink->getUnderlined()) &&
|
(getFontUnderlined() == _CurrentViewLink->getUnderlined()) &&
|
||||||
(getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) &&
|
(getFontStrikeThrough() == _CurrentViewLink->getStrikeThrough()) &&
|
||||||
|
@ -4072,6 +4112,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
newLink->setText(tmpStr);
|
newLink->setText(tmpStr);
|
||||||
newLink->setColor(getTextColor());
|
newLink->setColor(getTextColor());
|
||||||
|
newLink->setFontName(getFontFamily());
|
||||||
newLink->setFontSize(getFontSize());
|
newLink->setFontSize(getFontSize());
|
||||||
newLink->setEmbolden(embolden);
|
newLink->setEmbolden(embolden);
|
||||||
newLink->setOblique(getFontOblique());
|
newLink->setOblique(getFontOblique());
|
||||||
|
@ -5762,6 +5803,17 @@ namespace NLGUI
|
||||||
style.FontOblique = true;
|
style.FontOblique = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (it->first == "font-family")
|
||||||
|
{
|
||||||
|
if (it->second == "inherit")
|
||||||
|
style.FontFamily = getFontFamily();
|
||||||
|
else
|
||||||
|
if (it->second == "monospace")
|
||||||
|
style.FontFamily = "monospace";
|
||||||
|
else
|
||||||
|
style.FontFamily = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
if (it->first == "font-weight")
|
if (it->first == "font-weight")
|
||||||
{
|
{
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace NLGUI
|
||||||
NL3D::UTextContext* CViewRenderer::textcontext = NULL;
|
NL3D::UTextContext* CViewRenderer::textcontext = NULL;
|
||||||
std::set< std::string >* CViewRenderer::hwCursors = NULL;
|
std::set< std::string >* CViewRenderer::hwCursors = NULL;
|
||||||
float CViewRenderer::hwCursorScale = 1.0f;
|
float CViewRenderer::hwCursorScale = 1.0f;
|
||||||
|
CViewRenderer::TFontsList CViewRenderer::fonts;
|
||||||
|
|
||||||
CViewRenderer::CViewRenderer()
|
CViewRenderer::CViewRenderer()
|
||||||
{
|
{
|
||||||
|
@ -214,17 +215,65 @@ namespace NLGUI
|
||||||
ite++;
|
ite++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TFontsList::iterator iteFonts = fonts.begin();
|
||||||
|
while (iteFonts != fonts.end())
|
||||||
|
{
|
||||||
|
driver->deleteTextContext(iteFonts->second);
|
||||||
|
++iteFonts;
|
||||||
|
}
|
||||||
|
|
||||||
_GlobalTextures.clear();
|
_GlobalTextures.clear();
|
||||||
_SImages.clear();
|
_SImages.clear();
|
||||||
_SImageIterators.clear();
|
_SImageIterators.clear();
|
||||||
_TextureMap.clear();
|
_TextureMap.clear();
|
||||||
_IndexesToTextureIds.clear();
|
_IndexesToTextureIds.clear();
|
||||||
|
fonts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
NL3D::UDriver* CViewRenderer::getDriver(){
|
NL3D::UDriver* CViewRenderer::getDriver(){
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
NL3D::UTextContext* CViewRenderer::getTextContext(const std::string &name)
|
||||||
|
{
|
||||||
|
if (name.size() > 0 && fonts.count(name) > 0)
|
||||||
|
return fonts[name];
|
||||||
|
|
||||||
|
return textcontext;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
bool CViewRenderer::registerFont(const std::string &name, const std::string &font)
|
||||||
|
{
|
||||||
|
nlassert(driver != NULL);
|
||||||
|
|
||||||
|
// free existing font
|
||||||
|
if (fonts.count(name) > 0)
|
||||||
|
driver->deleteTextContext(fonts[name]);
|
||||||
|
|
||||||
|
std::string fontFile = CPath::lookup(font, false);
|
||||||
|
if (fontFile.size() == 0)
|
||||||
|
{
|
||||||
|
nlwarning("Font file '%s' not found", font.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NL3D::UTextContext *context;
|
||||||
|
context = driver->createTextContext(fontFile);
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
nlwarning("Cannot create a TextContext with font '%s'.", font.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
context->setKeep800x600Ratio(false);
|
||||||
|
|
||||||
|
fonts[name] = context;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CViewRenderer::setTextContext(NL3D::UTextContext *textcontext)
|
void CViewRenderer::setTextContext(NL3D::UTextContext *textcontext)
|
||||||
{
|
{
|
||||||
CViewRenderer::textcontext = textcontext;
|
CViewRenderer::textcontext = textcontext;
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace NLGUI
|
||||||
|
|
||||||
_FontSize = 12 +
|
_FontSize = 12 +
|
||||||
CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32();
|
CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32();
|
||||||
|
_FontName.clear();
|
||||||
_Embolden = false;
|
_Embolden = false;
|
||||||
_Oblique = false;
|
_Oblique = false;
|
||||||
_Color = CRGBA(255,255,255,255);
|
_Color = CRGBA(255,255,255,255);
|
||||||
|
@ -134,7 +135,7 @@ namespace NLGUI
|
||||||
CViewText::~CViewText()
|
CViewText::~CViewText()
|
||||||
{
|
{
|
||||||
if (_Index != 0xFFFFFFFF)
|
if (_Index != 0xFFFFFFFF)
|
||||||
CViewRenderer::getTextContext()->erase (_Index);
|
CViewRenderer::getTextContext(_FontName)->erase (_Index);
|
||||||
clearLines();
|
clearLines();
|
||||||
|
|
||||||
if (!_Setuped)
|
if (!_Setuped)
|
||||||
|
@ -148,7 +149,7 @@ namespace NLGUI
|
||||||
CViewText &CViewText::operator=(const CViewText &vt)
|
CViewText &CViewText::operator=(const CViewText &vt)
|
||||||
{
|
{
|
||||||
if (_Index != 0xFFFFFFFF)
|
if (_Index != 0xFFFFFFFF)
|
||||||
CViewRenderer::getTextContext()->erase (_Index);
|
CViewRenderer::getTextContext(_FontName)->erase (_Index);
|
||||||
|
|
||||||
// Create database entries
|
// Create database entries
|
||||||
_Active = vt._Active;
|
_Active = vt._Active;
|
||||||
|
@ -958,7 +959,7 @@ namespace NLGUI
|
||||||
return;
|
return;
|
||||||
rVR.getScreenOOSize (oow, ooh);
|
rVR.getScreenOOSize (oow, ooh);
|
||||||
|
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
|
|
||||||
|
|
||||||
// *** get current color
|
// *** get current color
|
||||||
|
@ -983,8 +984,6 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
if (_Lines.size() == 0) return;
|
if (_Lines.size() == 0) return;
|
||||||
|
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
|
||||||
|
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
TextContext->setShaded (_Shadow);
|
TextContext->setShaded (_Shadow);
|
||||||
TextContext->setShadeOutline (_ShadowOutline);
|
TextContext->setShadeOutline (_ShadowOutline);
|
||||||
|
@ -1260,6 +1259,24 @@ namespace NLGUI
|
||||||
_FormatTags.clear();
|
_FormatTags.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
void CViewText::setFontName(const std::string &name)
|
||||||
|
{
|
||||||
|
if (_FontName == name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_FontName.length() > 0)
|
||||||
|
{
|
||||||
|
if (_Index != 0xFFFFFFFF)
|
||||||
|
CViewRenderer::getTextContext(_FontName)->erase (_Index);
|
||||||
|
clearLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
_FontName = name;
|
||||||
|
computeFontSize ();
|
||||||
|
invalidateContent();
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::setFontSize (sint nFontSize)
|
void CViewText::setFontSize (sint nFontSize)
|
||||||
{
|
{
|
||||||
|
@ -1403,6 +1420,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat)
|
void CViewText::flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat)
|
||||||
{
|
{
|
||||||
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
// create a new line?
|
// create a new line?
|
||||||
if(!linePushed)
|
if(!linePushed)
|
||||||
{
|
{
|
||||||
|
@ -1410,7 +1428,7 @@ namespace NLGUI
|
||||||
linePushed= true;
|
linePushed= true;
|
||||||
}
|
}
|
||||||
// Append to the last line
|
// Append to the last line
|
||||||
_Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth);
|
_Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth, *TextContext);
|
||||||
// reset the word
|
// reset the word
|
||||||
ucCurrentWord = ucstring("");
|
ucCurrentWord = ucstring("");
|
||||||
}
|
}
|
||||||
|
@ -1446,7 +1464,7 @@ namespace NLGUI
|
||||||
rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth);
|
rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
|
|
||||||
// Parse the letter
|
// Parse the letter
|
||||||
{
|
{
|
||||||
|
@ -1492,6 +1510,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::addDontClipWordLine(std::vector<CWord> &currLine)
|
void CViewText::addDontClipWordLine(std::vector<CWord> &currLine)
|
||||||
{
|
{
|
||||||
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
// create a new line
|
// create a new line
|
||||||
_Lines.push_back(TLineSPtr(new CLine));
|
_Lines.push_back(TLineSPtr(new CLine));
|
||||||
|
|
||||||
|
@ -1506,7 +1525,7 @@ namespace NLGUI
|
||||||
if(currLine[i].Format!=lineWordFormat)
|
if(currLine[i].Format!=lineWordFormat)
|
||||||
{
|
{
|
||||||
// add the current lineWord to the line.
|
// add the current lineWord to the line.
|
||||||
_Lines.back()->addWord(lineWord, 0, lineWordFormat, _FontWidth);
|
_Lines.back()->addWord(lineWord, 0, lineWordFormat, _FontWidth, *TextContext);
|
||||||
// get new lineWordFormat
|
// get new lineWordFormat
|
||||||
lineWordFormat= currLine[i].Format;
|
lineWordFormat= currLine[i].Format;
|
||||||
// and clear
|
// and clear
|
||||||
|
@ -1521,7 +1540,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!lineWord.empty())
|
if(!lineWord.empty())
|
||||||
_Lines.back()->addWord(lineWord, 0, lineWordFormat, _FontWidth);
|
_Lines.back()->addWord(lineWord, 0, lineWordFormat, _FontWidth, *TextContext);
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
currLine.clear();
|
currLine.clear();
|
||||||
|
@ -1531,6 +1550,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces)
|
void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces)
|
||||||
{
|
{
|
||||||
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
UTextContext::CStringInfo si;
|
UTextContext::CStringInfo si;
|
||||||
//
|
//
|
||||||
TCharPos currPos = 0;
|
TCharPos currPos = 0;
|
||||||
|
@ -1624,7 +1644,7 @@ namespace NLGUI
|
||||||
// Get the word value.
|
// Get the word value.
|
||||||
wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd);
|
wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd);
|
||||||
// compute width of word
|
// compute width of word
|
||||||
si = CViewRenderer::getTextContext()->getStringInfo(wordValue);
|
si = TextContext->getStringInfo(wordValue);
|
||||||
|
|
||||||
// compute size of spaces/Tab + word
|
// compute size of spaces/Tab + word
|
||||||
newLineWidth = lineWidth + numSpaces * _SpaceWidth;
|
newLineWidth = lineWidth + numSpaces * _SpaceWidth;
|
||||||
|
@ -1681,7 +1701,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
uint maxNumSpaces = std::max(1U, (uint) (nMaxWidth / _SpaceWidth));
|
uint maxNumSpaces = std::max(1U, (uint) (nMaxWidth / _SpaceWidth));
|
||||||
CWord spaceWord; // a word with only spaces in it
|
CWord spaceWord; // a word with only spaces in it
|
||||||
spaceWord.build (ucstring (""), maxNumSpaces);
|
spaceWord.build (ucstring (""), *TextContext, maxNumSpaces);
|
||||||
spaceWord.Format= wordFormat;
|
spaceWord.Format= wordFormat;
|
||||||
_Lines.push_back(TLineSPtr(new CLine));
|
_Lines.push_back(TLineSPtr(new CLine));
|
||||||
_Lines.back()->addWord(spaceWord, _FontWidth);
|
_Lines.back()->addWord(spaceWord, _FontWidth);
|
||||||
|
@ -1703,14 +1723,14 @@ namespace NLGUI
|
||||||
for(currChar = 0; currChar < wordValue.length(); ++currChar)
|
for(currChar = 0; currChar < wordValue.length(); ++currChar)
|
||||||
{
|
{
|
||||||
oneChar = wordValue[currChar];
|
oneChar = wordValue[currChar];
|
||||||
si = CViewRenderer::getTextContext()->getStringInfo(oneChar);
|
si = TextContext->getStringInfo(oneChar);
|
||||||
if ((uint) (px + si.StringWidth) > nMaxWidth) break;
|
if ((uint) (px + si.StringWidth) > nMaxWidth) break;
|
||||||
px += si.StringWidth;
|
px += si.StringWidth;
|
||||||
}
|
}
|
||||||
currChar = std::max((uint) 1, currChar); // must fit at least one character otherwise there's an infinite loop
|
currChar = std::max((uint) 1, currChar); // must fit at least one character otherwise there's an infinite loop
|
||||||
wordValue = _Text.substr(spaceEnd, currChar);
|
wordValue = _Text.substr(spaceEnd, currChar);
|
||||||
CWord word;
|
CWord word;
|
||||||
word.build(wordValue, numSpaces);
|
word.build(wordValue, *TextContext, numSpaces);
|
||||||
word.Format= wordFormat;
|
word.Format= wordFormat;
|
||||||
_Lines.push_back(TLineSPtr(new CLine));
|
_Lines.push_back(TLineSPtr(new CLine));
|
||||||
float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth;
|
float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth;
|
||||||
|
@ -1745,7 +1765,7 @@ namespace NLGUI
|
||||||
if (!wordValue.empty() || numSpaces != 0)
|
if (!wordValue.empty() || numSpaces != 0)
|
||||||
{
|
{
|
||||||
CWord word;
|
CWord word;
|
||||||
word.build(wordValue, numSpaces);
|
word.build(wordValue, *TextContext, numSpaces);
|
||||||
word.Format= wordFormat;
|
word.Format= wordFormat;
|
||||||
// update line width
|
// update line width
|
||||||
_Lines.back()->addWord(word, _FontWidth);
|
_Lines.back()->addWord(word, _FontWidth);
|
||||||
|
@ -1822,7 +1842,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::updateTextContext ()
|
void CViewText::updateTextContext ()
|
||||||
{
|
{
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
|
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
TextContext->setShaded (_Shadow);
|
TextContext->setShaded (_Shadow);
|
||||||
|
@ -1856,13 +1876,13 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
while (_Lines.size() > _MultiMaxLine)
|
while (_Lines.size() > _MultiMaxLine)
|
||||||
{
|
{
|
||||||
_Lines.back()->clear();
|
_Lines.back()->clear(*TextContext);
|
||||||
_Lines.pop_back();
|
_Lines.pop_back();
|
||||||
}
|
}
|
||||||
_Lines.pop_back();
|
_Lines.pop_back();
|
||||||
CViewText::CLine *endLine = new CViewText::CLine;
|
CViewText::CLine *endLine = new CViewText::CLine;
|
||||||
CViewText::CWord w;
|
CViewText::CWord w;
|
||||||
w.build(string("..."));
|
w.build(string("..."), *TextContext);
|
||||||
endLine->addWord(w, _FontWidth);
|
endLine->addWord(w, _FontWidth);
|
||||||
_Lines.push_back(TLineSPtr(endLine));
|
_Lines.push_back(TLineSPtr(endLine));
|
||||||
}
|
}
|
||||||
|
@ -2150,7 +2170,7 @@ namespace NLGUI
|
||||||
void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const
|
void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const
|
||||||
{
|
{
|
||||||
NLMISC::clamp(index, 0, (sint) _Text.length());
|
NLMISC::clamp(index, 0, (sint) _Text.length());
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
TextContext->setShaded (_Shadow);
|
TextContext->setShaded (_Shadow);
|
||||||
TextContext->setShadeOutline (_ShadowOutline);
|
TextContext->setShadeOutline (_ShadowOutline);
|
||||||
|
@ -2257,7 +2277,7 @@ namespace NLGUI
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Tool fct : From a word and a x coordinate, give the matching character index
|
// Tool fct : From a word and a x coordinate, give the matching character index
|
||||||
static uint getCharacterIndex(const ucstring &textValue, float x)
|
static uint getCharacterIndex(const ucstring &textValue, float x, NL3D::UTextContext &textContext)
|
||||||
{
|
{
|
||||||
float px = 0.f;
|
float px = 0.f;
|
||||||
UTextContext::CStringInfo si;
|
UTextContext::CStringInfo si;
|
||||||
|
@ -2267,7 +2287,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
// get character width
|
// get character width
|
||||||
singleChar[0] = textValue[i];
|
singleChar[0] = textValue[i];
|
||||||
si = CViewRenderer::getTextContext()->getStringInfo(singleChar);
|
si = textContext.getStringInfo(singleChar);
|
||||||
px += si.StringWidth;
|
px += si.StringWidth;
|
||||||
// the character is at the i - 1 position
|
// the character is at the i - 1 position
|
||||||
if (px > x)
|
if (px > x)
|
||||||
|
@ -2284,7 +2304,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const
|
void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const
|
||||||
{
|
{
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
|
|
||||||
// setup the text context
|
// setup the text context
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
|
@ -2365,7 +2385,7 @@ namespace NLGUI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// the coord is in the word itself
|
// the coord is in the word itself
|
||||||
index = charPos + currWord.NumSpaces + getCharacterIndex(currWord.Text, (float) x - (px + spacesWidth));
|
index = charPos + currWord.NumSpaces + getCharacterIndex(currWord.Text, (float) x - (px + spacesWidth), *TextContext);
|
||||||
cursorAtPreviousLineEnd = false;
|
cursorAtPreviousLineEnd = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2390,7 +2410,7 @@ namespace NLGUI
|
||||||
index = 0;
|
index = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index = getCharacterIndex(_Text, (float) x);
|
index = getCharacterIndex(_Text, (float) x, *TextContext);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2428,15 +2448,16 @@ namespace NLGUI
|
||||||
quadSize--;
|
quadSize--;
|
||||||
}
|
}
|
||||||
// select what quad to skip
|
// select what quad to skip
|
||||||
CViewRenderer::getTextContext()->setStringSelection(stringId, quadStart, quadSize);
|
CViewRenderer::getTextContext(_FontName)->setStringSelection(stringId, quadStart, quadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::clearLines()
|
void CViewText::clearLines()
|
||||||
{
|
{
|
||||||
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
for(uint k = 0; k < _Lines.size(); ++k)
|
for(uint k = 0; k < _Lines.size(); ++k)
|
||||||
{
|
{
|
||||||
_Lines[k]->clear();
|
_Lines[k]->clear(*TextContext);
|
||||||
}
|
}
|
||||||
_Lines.clear();
|
_Lines.clear();
|
||||||
}
|
}
|
||||||
|
@ -2490,10 +2511,10 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::CLine::addWord(const ucstring &text, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth)
|
void CViewText::CLine::addWord(const ucstring &text, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth, NL3D::UTextContext &textContext)
|
||||||
{
|
{
|
||||||
CWord word;
|
CWord word;
|
||||||
word.build(text, numSpaces);
|
word.build(text, textContext, numSpaces);
|
||||||
word.Format= wordFormat;
|
word.Format= wordFormat;
|
||||||
addWord(word, fontWidth);
|
addWord(word, fontWidth);
|
||||||
}
|
}
|
||||||
|
@ -2515,12 +2536,12 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::CLine::clear()
|
void CViewText::CLine::clear(NL3D::UTextContext &textContext)
|
||||||
{
|
{
|
||||||
for(uint k = 0; k < _Words.size(); ++k)
|
for(uint k = 0; k < _Words.size(); ++k)
|
||||||
{
|
{
|
||||||
if (_Words[k].Index != 0xffffffff)
|
if (_Words[k].Index != 0xffffffff)
|
||||||
CViewRenderer::getTextContext()->erase(_Words[k].Index);
|
textContext.erase(_Words[k].Index);
|
||||||
}
|
}
|
||||||
_Words.clear();
|
_Words.clear();
|
||||||
_NumChars = 0;
|
_NumChars = 0;
|
||||||
|
@ -2537,13 +2558,12 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::CWord::build(const ucstring &text, uint numSpaces/*=0*/)
|
void CViewText::CWord::build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
NumSpaces = numSpaces;
|
NumSpaces = numSpaces;
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
Index = textContext.textPush(text);
|
||||||
Index = TextContext->textPush(text);
|
Info = textContext.getStringInfo(Index);
|
||||||
Info = TextContext->getStringInfo(Index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -2564,7 +2584,7 @@ namespace NLGUI
|
||||||
static const ucstring lineFeedStr("\n");
|
static const ucstring lineFeedStr("\n");
|
||||||
float maxWidth = 0;
|
float maxWidth = 0;
|
||||||
|
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
TextContext->setShaded (_Shadow);
|
TextContext->setShaded (_Shadow);
|
||||||
TextContext->setShadeOutline (_ShadowOutline);
|
TextContext->setShadeOutline (_ShadowOutline);
|
||||||
|
@ -2651,7 +2671,7 @@ namespace NLGUI
|
||||||
// If we can't clip the words, return the size of the largest word
|
// If we can't clip the words, return the size of the largest word
|
||||||
else if ((_TextMode == DontClipWord) || (_TextMode == Justified))
|
else if ((_TextMode == DontClipWord) || (_TextMode == Justified))
|
||||||
{
|
{
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
TextContext->setShaded (_Shadow);
|
TextContext->setShaded (_Shadow);
|
||||||
TextContext->setShadeOutline (_ShadowOutline);
|
TextContext->setShadeOutline (_ShadowOutline);
|
||||||
|
@ -2709,7 +2729,7 @@ namespace NLGUI
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void CViewText::computeFontSize ()
|
void CViewText::computeFontSize ()
|
||||||
{
|
{
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
TextContext->setHotSpot (UTextContext::BottomLeft);
|
TextContext->setHotSpot (UTextContext::BottomLeft);
|
||||||
TextContext->setShaded (_Shadow);
|
TextContext->setShaded (_Shadow);
|
||||||
TextContext->setShadeOutline (_ShadowOutline);
|
TextContext->setShadeOutline (_ShadowOutline);
|
||||||
|
@ -2727,6 +2747,13 @@ namespace NLGUI
|
||||||
|
|
||||||
// for now we can't know that directly from UTextContext
|
// for now we can't know that directly from UTextContext
|
||||||
UTextContext::CStringInfo si = TextContext->getStringInfo(chars);
|
UTextContext::CStringInfo si = TextContext->getStringInfo(chars);
|
||||||
|
|
||||||
|
// font generator changes unknown glyphs to dot '.'. use fallback if it looks odd
|
||||||
|
if (_FontSize > (si.StringHeight + si.StringLine))
|
||||||
|
{
|
||||||
|
chars.fromUtf8("|");
|
||||||
|
si = TextContext->getStringInfo(chars);
|
||||||
|
}
|
||||||
// add a padding of 1 pixel else the top will be truncated
|
// add a padding of 1 pixel else the top will be truncated
|
||||||
_FontHeight = (uint) si.StringHeight+1;
|
_FontHeight = (uint) si.StringHeight+1;
|
||||||
_FontLegHeight = (uint) si.StringLine;
|
_FontLegHeight = (uint) si.StringLine;
|
||||||
|
@ -3081,7 +3108,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert in ULetterColors
|
// convert in ULetterColors
|
||||||
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext();
|
NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(_FontName);
|
||||||
ULetterColors * letterColors = TextContext->createLetterColors();
|
ULetterColors * letterColors = TextContext->createLetterColors();
|
||||||
for(uint i=0; i<tempLetterColors.size(); i++)
|
for(uint i=0; i<tempLetterColors.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3170,6 +3170,7 @@ namespace NLGUI
|
||||||
_SystemOptions[OptionTimeoutMessages]= opt->getValue("messages_timeout");
|
_SystemOptions[OptionTimeoutMessages]= opt->getValue("messages_timeout");
|
||||||
_SystemOptions[OptionTimeoutContext]= opt->getValue("context_timeout");
|
_SystemOptions[OptionTimeoutContext]= opt->getValue("context_timeout");
|
||||||
_SystemOptions[OptionTimeoutContextHtml]= opt->getValue("context_html_timeout");
|
_SystemOptions[OptionTimeoutContextHtml]= opt->getValue("context_html_timeout");
|
||||||
|
_SystemOptions[OptionMonospaceFont]= opt->getValue("monospace_font");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1916,6 +1916,8 @@ This MUST follow the Enum MISSION_DESC::TIconId
|
||||||
value="basic.ttf" /> -->
|
value="basic.ttf" /> -->
|
||||||
<param name="font"
|
<param name="font"
|
||||||
value="ryzom.ttf" />
|
value="ryzom.ttf" />
|
||||||
|
<param name="monospace_font"
|
||||||
|
value="ryzom_monospace.ttf" />
|
||||||
<param name="add_coef_font"
|
<param name="add_coef_font"
|
||||||
value="1" />
|
value="1" />
|
||||||
<param name="mul_coef_anim"
|
<param name="mul_coef_anim"
|
||||||
|
|
|
@ -838,6 +838,8 @@ This MUST follow the Enum MISSION_DESC::TIconId
|
||||||
value="basic.ttf" /> -->
|
value="basic.ttf" /> -->
|
||||||
<param name="font"
|
<param name="font"
|
||||||
value="ryzom.ttf" />
|
value="ryzom.ttf" />
|
||||||
|
<param name="monospace_font"
|
||||||
|
value="ryzom_monospace.ttf" />
|
||||||
<param name="add_coef_font"
|
<param name="add_coef_font"
|
||||||
value="3" />
|
value="3" />
|
||||||
<param name="mul_coef_anim"
|
<param name="mul_coef_anim"
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
value="basic.ttf" /> -->
|
value="basic.ttf" /> -->
|
||||||
<param name="font"
|
<param name="font"
|
||||||
value="ryzom.ttf" />
|
value="ryzom.ttf" />
|
||||||
|
<param name="monospace_font"
|
||||||
|
value="ryzom_monospace.ttf" />
|
||||||
<param name="add_coef_font"
|
<param name="add_coef_font"
|
||||||
value="0" />
|
value="0" />
|
||||||
<param name="mul_coef_anim"
|
<param name="mul_coef_anim"
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
value="outgame.ttf" /> -->
|
value="outgame.ttf" /> -->
|
||||||
<param name="font"
|
<param name="font"
|
||||||
value="ryzom.ttf" />
|
value="ryzom.ttf" />
|
||||||
|
<param name="monospace_font"
|
||||||
|
value="ryzom_monospace.ttf" />
|
||||||
<param name="add_coef_font"
|
<param name="add_coef_font"
|
||||||
value="3" />
|
value="3" />
|
||||||
<param name="mul_coef_anim"
|
<param name="mul_coef_anim"
|
||||||
|
|
|
@ -1572,6 +1572,10 @@ void CInterfaceManager::setupOptions()
|
||||||
if ((!sFont.empty()) && (Driver != NULL))
|
if ((!sFont.empty()) && (Driver != NULL))
|
||||||
resetTextContext(sFont.c_str(), true);
|
resetTextContext(sFont.c_str(), true);
|
||||||
// Continue to parse the rest of the interface
|
// Continue to parse the rest of the interface
|
||||||
|
|
||||||
|
sFont = wm->getSystemOption (CWidgetManager::OptionMonospaceFont).getValStr();
|
||||||
|
if ((!sFont.empty()) && (Driver != NULL))
|
||||||
|
CViewRenderer::registerFont("monospace", sFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue