Utility: Replace UInt32 by TextStyleFlags

This commit is contained in:
Lynix
2019-04-13 13:09:53 +02:00
parent e665ea5373
commit 0582cbfc26
9 changed files with 52 additions and 40 deletions

View File

@@ -109,7 +109,7 @@ namespace Nz
}
}
bool Font::ExtractGlyph(unsigned int characterSize, char32_t character, UInt32 style, FontGlyph* glyph) const
bool Font::ExtractGlyph(unsigned int characterSize, char32_t character, TextStyleFlags style, FontGlyph* glyph) const
{
#if NAZARA_UTILITY_SAFE
if (!IsValid())
@@ -127,7 +127,7 @@ namespace Nz
return m_atlas;
}
std::size_t Font::GetCachedGlyphCount(unsigned int characterSize, UInt32 style) const
std::size_t Font::GetCachedGlyphCount(unsigned int characterSize, TextStyleFlags style) const
{
UInt64 key = ComputeKey(characterSize, style);
auto it = m_glyphes.find(key);
@@ -187,7 +187,7 @@ namespace Nz
return it->second; // Présent dans le cache, tout va bien
}
const Font::Glyph& Font::GetGlyph(unsigned int characterSize, UInt32 style, char32_t character) const
const Font::Glyph& Font::GetGlyph(unsigned int characterSize, TextStyleFlags style, char32_t character) const
{
UInt64 key = ComputeKey(characterSize, style);
return PrecacheGlyph(m_glyphes[key], characterSize, style, character);
@@ -256,13 +256,13 @@ namespace Nz
return m_data != nullptr;
}
bool Font::Precache(unsigned int characterSize, UInt32 style, char32_t character) const
bool Font::Precache(unsigned int characterSize, TextStyleFlags style, char32_t character) const
{
UInt64 key = ComputeKey(characterSize, style);
return PrecacheGlyph(m_glyphes[key], characterSize, style, character).valid;
}
bool Font::Precache(unsigned int characterSize, UInt32 style, const String& characterSet) const
bool Font::Precache(unsigned int characterSize, TextStyleFlags style, const String& characterSet) const
{
///TODO: Itération UTF-8 => UTF-32 sans allocation de buffer (Exposer utf8cpp ?)
std::u32string set = characterSet.GetUtf32String();
@@ -399,7 +399,7 @@ namespace Nz
s_defaultMinimumStepSize = minimumStepSize;
}
UInt64 Font::ComputeKey(unsigned int characterSize, UInt32 style) const
UInt64 Font::ComputeKey(unsigned int characterSize, TextStyleFlags style) const
{
// On prend le pas en compte
UInt64 sizePart = static_cast<UInt32>((characterSize/m_minimumStepSize)*m_minimumStepSize);
@@ -471,7 +471,7 @@ namespace Nz
NazaraError("Atlas has been released while in use");
}
const Font::Glyph& Font::PrecacheGlyph(GlyphMap& glyphMap, unsigned int characterSize, UInt32 style, char32_t character) const
const Font::Glyph& Font::PrecacheGlyph(GlyphMap& glyphMap, unsigned int characterSize, TextStyleFlags style, char32_t character) const
{
auto it = glyphMap.find(character);
if (it != glyphMap.end()) // Si le glyphe n'est pas déjà chargé
@@ -492,7 +492,7 @@ namespace Nz
glyph.requireFauxBold = false;
glyph.requireFauxItalic = false;
UInt32 supportedStyle = style;
TextStyleFlags supportedStyle = style;
if (style & TextStyle_Bold && !m_data->SupportsStyle(TextStyle_Bold))
{
glyph.requireFauxBold = true;

View File

@@ -25,7 +25,7 @@ namespace Nz
FT_Library s_library;
std::shared_ptr<FreeTypeLibrary> s_libraryOwner;
float s_invScaleFactor = 1.f / (1 << 6); // 1/64
constexpr float s_invScaleFactor = 1.f / (1 << 6); // 1/64
extern "C"
unsigned long FT_StreamRead(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count)
@@ -96,7 +96,7 @@ namespace Nz
return FT_Open_Face(s_library, &m_args, -1, nullptr) == 0;
}
bool ExtractGlyph(unsigned int characterSize, char32_t character, UInt32 style, FontGlyph* dst) override
bool ExtractGlyph(unsigned int characterSize, char32_t character, TextStyleFlags style, FontGlyph* dst) override
{
#ifdef NAZARA_DEBUG
if (!dst)
@@ -118,7 +118,7 @@ namespace Nz
const FT_Pos boldStrength = 2 << 6;
bool embolden = (style & TextStyle_Bold);
bool embolden = (style & TextStyle_Bold) != 0;
dst->advance = (embolden) ? boldStrength >> 6 : 0;
@@ -312,7 +312,7 @@ namespace Nz
m_args.stream = &m_stream;
}
bool SupportsStyle(UInt32 style) const override
bool SupportsStyle(TextStyleFlags style) const override
{
///TODO
return style == TextStyle_Regular || style == TextStyle_Bold;

View File

@@ -120,7 +120,7 @@ namespace Nz
return m_lines.size();
}
UInt32 SimpleTextDrawer::GetStyle() const
TextStyleFlags SimpleTextDrawer::GetStyle() const
{
return m_style;
}
@@ -159,7 +159,7 @@ namespace Nz
}
}
void SimpleTextDrawer::SetStyle(UInt32 style)
void SimpleTextDrawer::SetStyle(TextStyleFlags style)
{
m_style = style;
@@ -207,7 +207,7 @@ namespace Nz
return *this;
}
SimpleTextDrawer SimpleTextDrawer::Draw(const String& str, unsigned int characterSize, UInt32 style, const Color& color)
SimpleTextDrawer SimpleTextDrawer::Draw(const String& str, unsigned int characterSize, TextStyleFlags style, const Color& color)
{
SimpleTextDrawer drawer;
drawer.SetCharacterSize(characterSize);
@@ -218,7 +218,7 @@ namespace Nz
return drawer;
}
SimpleTextDrawer SimpleTextDrawer::Draw(Font* font, const String& str, unsigned int characterSize, UInt32 style, const Color& color)
SimpleTextDrawer SimpleTextDrawer::Draw(Font* font, const String& str, unsigned int characterSize, TextStyleFlags style, const Color& color)
{
SimpleTextDrawer drawer;
drawer.SetCharacterSize(characterSize);