Browse Source

Broken std::u32string is also only MinGW32's fault.

MSVC doesn't have it at all, for security reasons ;-)
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
573e18eabd
  1. 2
      src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp
  2. 2
      src/Plugins/MagnumFontConverter/MagnumFontConverter.h
  3. 2
      src/Text/AbstractFont.cpp
  4. 2
      src/Text/AbstractFont.h
  5. 10
      src/Text/AbstractFontConverter.cpp
  6. 8
      src/Text/AbstractFontConverter.h
  7. 14
      src/Text/Test/AbstractFontConverterTest.cpp

2
src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp

@ -44,7 +44,7 @@ auto MagnumFontConverter::doFeatures() const -> Features {
return Feature::ExportFont|Feature::ConvertData|Feature::MultiFile;
}
#ifndef _WIN32
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> MagnumFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const

2
src/Plugins/MagnumFontConverter/MagnumFontConverter.h

@ -58,7 +58,7 @@ class MagnumFontConverter: public Text::AbstractFontConverter {
private:
Features doFeatures() const override;
#ifndef _WIN32
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override;
#else
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const override;

2
src/Text/AbstractFont.cpp

@ -134,7 +134,7 @@ void AbstractFont::fillGlyphCache(GlyphCache& cache, const std::string& characte
doFillGlyphCache(cache, Utility::Unicode::utf32(characters));
}
#ifndef _WIN32
#ifndef __MINGW32__
void AbstractFont::doFillGlyphCache(GlyphCache&, const std::u32string&)
#else
void AbstractFont::doFillGlyphCache(GlyphCache&, const std::vector<char32_t>&)

2
src/Text/AbstractFont.h

@ -261,7 +261,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef _WIN32
#ifndef __MINGW32__
virtual void doFillGlyphCache(GlyphCache& cache, const std::u32string& characters);
#else
virtual void doFillGlyphCache(GlyphCache& cache, const std::vector<char32_t>& characters);

10
src/Text/AbstractFontConverter.cpp

@ -45,7 +45,7 @@ std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFo
return doExportFontToData(font, cache, filename, uniqueUnicode(characters));
}
#ifndef _WIN32
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
@ -68,7 +68,7 @@ Containers::Array<unsigned char> AbstractFontConverter::exportFontToSingleData(A
return doExportFontToSingleData(font, cache, uniqueUnicode(characters));
}
#ifndef _WIN32
#ifndef __MINGW32__
Containers::Array<unsigned char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const
#else
Containers::Array<unsigned char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const
@ -85,7 +85,7 @@ bool AbstractFontConverter::exportFontToFile(AbstractFont& font, GlyphCache& cac
return doExportFontToFile(font, cache, filename, uniqueUnicode(characters));
}
#ifndef _WIN32
#ifndef __MINGW32__
bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const
#else
bool AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const
@ -231,14 +231,14 @@ std::unique_ptr<GlyphCache> AbstractFontConverter::doImportGlyphCacheFromFile(co
return doImportGlyphCacheFromSingleData(data);
}
#ifndef _WIN32
#ifndef __MINGW32__
std::u32string AbstractFontConverter::uniqueUnicode(const std::string& characters)
#else
std::vector<char32_t> AbstractFontConverter::uniqueUnicode(const std::string& characters)
#endif
{
/* Convert UTF-8 to UTF-32 */
#ifndef _WIN32
#ifndef __MINGW32__
std::u32string result = Utility::Unicode::utf32(characters);
#else
std::vector<char32_t> result = Utility::Unicode::utf32(characters);

8
src/Text/AbstractFontConverter.h

@ -268,7 +268,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef _WIN32
#ifndef __MINGW32__
virtual std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
#else
virtual std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const;
@ -281,7 +281,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef _WIN32
#ifndef __MINGW32__
virtual Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const;
#else
virtual Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::vector<char32_t>& characters) const;
@ -297,7 +297,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
*/
#ifndef _WIN32
#ifndef __MINGW32__
virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const;
#else
virtual bool doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::vector<char32_t>& characters) const;
@ -344,7 +344,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
virtual std::unique_ptr<GlyphCache> doImportGlyphCacheFromFile(const std::string& filename) const;
private:
#ifndef _WIN32
#ifndef __MINGW32__
MAGNUM_TEXT_LOCAL static std::u32string uniqueUnicode(const std::string& characters);
#else
MAGNUM_TEXT_LOCAL static std::vector<char32_t> uniqueUnicode(const std::string& characters);

14
src/Text/Test/AbstractFontConverterTest.cpp

@ -66,7 +66,7 @@ AbstractFontConverterTest::AbstractFontConverterTest() {
void AbstractFontConverterTest::convertGlyphs() {
class GlyphExporter: public AbstractFontConverter {
public:
#ifndef _WIN32
#ifndef __MINGW32__
GlyphExporter(std::u32string& characters): characters(characters) {}
#else
GlyphExporter(std::vector<char32_t>& characters): characters(characters) {}
@ -75,7 +75,7 @@ void AbstractFontConverterTest::convertGlyphs() {
private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; }
#ifndef _WIN32
#ifndef __MINGW32__
Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string& characters) const override
#else
Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>& characters) const override
@ -85,21 +85,21 @@ void AbstractFontConverterTest::convertGlyphs() {
return nullptr;
}
#ifndef _WIN32
#ifndef __MINGW32__
std::u32string& characters;
#else
std::vector<char32_t>& characters;
#endif
};
#ifndef _WIN32
#ifndef __MINGW32__
std::u32string characters;
#else
std::vector<char32_t> characters;
#endif
GlyphExporter exporter(characters);
exporter.exportFontToSingleData(*static_cast<AbstractFont*>(nullptr), *static_cast<GlyphCache*>(nullptr), "abC01a0 ");
#ifndef _WIN32
#ifndef __MINGW32__
CORRADE_COMPARE(characters, U" 01Cab");
#else
CORRADE_COMPARE(characters, (std::vector<char32_t>{
@ -112,7 +112,7 @@ void AbstractFontConverterTest::exportFontToSingleData() {
private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont; }
#ifndef _WIN32
#ifndef __MINGW32__
Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const override
#else
Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const override
@ -138,7 +138,7 @@ void AbstractFontConverterTest::exportFontToFile() {
private:
Features doFeatures() const override { return Feature::ConvertData|Feature::ExportFont|Feature::MultiFile; }
#ifndef _WIN32
#ifndef __MINGW32__
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::u32string&) const override
#else
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportFontToData(AbstractFont&, GlyphCache&, const std::string& filename, const std::vector<char32_t>&) const override

Loading…
Cancel
Save