Merge pull request #270 from mapbox/glyphrange-boost-locale

Glyphrange boost locale
This commit is contained in:
Young Hahn
2014-05-29 11:15:28 -04:00
4 changed files with 52 additions and 11 deletions

44
include/llmr/util/utf.hpp Normal file
View File

@@ -0,0 +1,44 @@
#ifndef LLMR_UTIL_UTF
#define LLMR_UTIL_UTF
#include <memory>
// g++/libstdc++ is missing c++11 codecvt support
#ifdef __linux__
#include <boost/locale.hpp>
#else
#include <codecvt>
#endif
namespace llmr {
namespace util {
#ifdef __linux__
class utf8_to_utf32 {
public:
explicit utf8_to_utf32() {}
std::u32string convert(std::string const& utf8) {
return boost::locale::conv::utf_to_utf<char32_t>(utf8);
}
};
#else
class utf8_to_utf32 {
public:
explicit utf8_to_utf32()
: utf32conv_() {}
std::u32string convert(std::string const& utf8) {
return utf32conv_.from_bytes(utf8);
}
private:
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv_;
};
#endif
}}
#endif

View File

@@ -71,7 +71,7 @@ source MacOSX.sh
if [ ! -f out/build-cpp11-libcpp-x86_64/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -d out/build-cpp11-libcpp-x86_64/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../linux/ `pwd`/../../common/ ; fi
if [ ! -d out/build-cpp11-libcpp-x86_64/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../include/ `pwd`/../../linux/ `pwd`/../../common/ ; fi
echo ' ...done'
rm -rf out/packages
@@ -91,7 +91,7 @@ source Linux.sh
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -d out/build-cpp11-libstdcpp-gcc-x86_64/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../linux/ `pwd`/../../common/ ; fi
if [ ! -d out/build-cpp11-libstdcpp-gcc-x86_64/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../include/ `pwd`/../../linux/ `pwd`/../../common/ ; fi
rm -rf out/packages

View File

@@ -12,8 +12,7 @@
#include <llmr/text/glyph_store.hpp>
#include <llmr/util/std.hpp>
#include <codecvt>
#include <llmr/util/utf.hpp>
using namespace llmr;
@@ -172,9 +171,7 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
std::unique_ptr<TextBucket> bucket = std::make_unique<TextBucket>(
tile.textVertexBuffer, tile.triangleElementsBuffer, bucket_desc, placement);
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> ucs4conv;
util::utf8_to_utf32 ucs4conv;
// Determine and load glyph ranges
{
@@ -194,7 +191,7 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
continue;
}
const std::u32string string = ucs4conv.from_bytes(toString(it_prop->second));
const std::u32string string = ucs4conv.convert(toString(it_prop->second));
// Loop through all characters of this text and collect unique codepoints.
for (uint32_t chr : string) {
@@ -206,7 +203,7 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
}
// Create a copy!
const FontStack fontStack = glyphStore.getFontStack(bucket_desc.geometry.font);
//const FontStack fontStack = glyphStore.getFontStack(bucket_desc.geometry.font);
// Shape and place all labels.
{
@@ -224,7 +221,7 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
continue;
}
const std::u32string string = ucs4conv.from_bytes(toString(it_prop->second));
const std::u32string string = ucs4conv.convert(toString(it_prop->second));
// TODO: Shape label
// TODO: Place label

View File

@@ -92,7 +92,7 @@ void GlyphPBF::parse(FontStack &stack) {
}
}
stack.insert(id, glyph);
stack.insert(id, glyph.metrics, glyph.bitmap);
} else {
fontstack_pbf.skip();
}