This commit is contained in:
Young Hahn
2014-05-29 05:05:48 -04:00
parent 36796490de
commit d82acee8c7
10 changed files with 76 additions and 68 deletions

View File

@@ -2,6 +2,7 @@
#define LLMR_GEOMETRY_GLYPH_ATLAS
#include <llmr/geometry/binpack.hpp>
#include <llmr/text/glyph_store.hpp>
#include <string>
#include <set>
@@ -30,7 +31,7 @@ public:
Rect<uint16_t> addGlyph(uint64_t tile_id, const std::string& face_name,
const VectorTileGlyph& glyph);
const SDFGlyph& glyph);
void removeGlyphs(uint64_t tile_id);
void bind();

View File

@@ -4,6 +4,8 @@
#include <llmr/map/vector_tile_data.hpp>
#include <llmr/map/vector_tile.hpp>
#include <llmr/text/placement.hpp>
#include <llmr/text/glyph_store.hpp>
#include <llmr/text/glyph.hpp>
namespace llmr {
@@ -23,6 +25,7 @@ private:
bool obsolete() const;
void parseGlyphs();
void parseStyleLayers(const std::vector<LayerDescription>& layers);
void addGlyph(uint64_t tileid, const std::string stackname, const std::string &string, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face);
std::unique_ptr<Bucket> createBucket(const BucketDescription& bucket_desc);
std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);
std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc);

View File

@@ -7,6 +7,7 @@
#include <llmr/geometry/elements_buffer.hpp>
#include <llmr/map/vector_tile.hpp>
#include <llmr/text/types.hpp>
#include <llmr/text/glyph.hpp>
#include <memory>
#include <map>
#include <vector>
@@ -36,7 +37,7 @@ public:
PlacementRange placementRange, float zoom);
void addFeature(const VectorTileFeature &feature,
const IndexedFaces &faces,
const GlyphPositions &face,
const std::map<Value, Shaping> &shapings);
void drawGlyphs(TextShader &shader);

View File

@@ -4,7 +4,6 @@
#include <llmr/text/glyph.hpp>
#include <llmr/util/pbf.hpp>
#include <cstdint>
#include <vector>
#include <future>
@@ -17,6 +16,8 @@ namespace llmr {
class SDFGlyph {
public:
uint32_t id = 0;
// A signed distance field of the glyph with a border of 3 pixels.
std::string bitmap;
@@ -26,13 +27,15 @@ public:
class FontStack {
public:
void insert(uint32_t id, const GlyphMetrics &glyphMetrics, const std::string &bitmap);
void insert(uint32_t id, const SDFGlyph &glyph);
const std::map<uint32_t, GlyphMetrics> &getMetrics() const;
const std::map<uint32_t, SDFGlyph> &getSDFs() const;
const Shaping getShaping(const std::string &string) const;
private:
std::map<uint32_t, std::string> bitmaps;
std::map<uint32_t, GlyphMetrics> metrics;
std::map<uint32_t, SDFGlyph> sdfs;
mutable std::mutex mtx;
};

View File

@@ -18,9 +18,9 @@ public:
void addFeature(TextBucket &bucket, const std::vector<Coordinate> &line,
const BucketGeometryDescription &info,
const IndexedFaces &faces,
const GlyphPositions &face,
const Shaping &shaping);
float measureText(const IndexedFaces &faces,
float measureText(const GlyphPositions &face,
const Shaping &shaping);
private: