use the correct glyphs
This commit is contained in:
@@ -26,7 +26,7 @@ private:
|
||||
TileData& tile;
|
||||
const Style& style;
|
||||
GlyphAtlas& glyphAtlas;
|
||||
FaceGlyphPositions faces;
|
||||
Faces faces;
|
||||
Placement placement;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
PlacementRange placementRange, float zoom);
|
||||
|
||||
void addFeature(const VectorTileFeature &feature,
|
||||
const IndexedFaceGlyphPositions &faces,
|
||||
const IndexedFaces &faces,
|
||||
const std::map<Value, Shaping> &shapings);
|
||||
|
||||
bool empty() const;
|
||||
|
||||
@@ -37,9 +37,9 @@ struct Glyph {
|
||||
const GlyphMetrics metrics;
|
||||
};
|
||||
|
||||
typedef std::vector<Glyph> GlyphPositions;
|
||||
typedef std::map<std::string, GlyphPositions> FaceGlyphPositions;
|
||||
typedef std::vector<const GlyphPositions *> IndexedFaceGlyphPositions;
|
||||
typedef std::map<uint32_t, Glyph> GlyphPositions;
|
||||
typedef std::map<std::string, GlyphPositions> Faces;
|
||||
typedef std::vector<const GlyphPositions *> IndexedFaces;
|
||||
|
||||
class GlyphPlacement {
|
||||
public:
|
||||
|
||||
@@ -18,9 +18,9 @@ public:
|
||||
|
||||
void addFeature(TextBucket &bucket, const std::vector<Coordinate> &line,
|
||||
const BucketGeometryDescription &info,
|
||||
const IndexedFaceGlyphPositions &faces,
|
||||
const IndexedFaces &faces,
|
||||
const Shaping &shaping);
|
||||
float measureText(const IndexedFaceGlyphPositions &faces,
|
||||
float measureText(const IndexedFaces &faces,
|
||||
const Shaping &shaping);
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,7 +32,7 @@ void TileParser::parseGlyphs() {
|
||||
for (const VectorTileGlyph &glyph : face.glyphs) {
|
||||
const Rect<uint16_t> rect =
|
||||
glyphAtlas.addGlyph((uint64_t)tile.id, name, glyph);
|
||||
glyphs.emplace_back(Glyph{rect, glyph.metrics});
|
||||
glyphs.emplace(glyph.id, Glyph{rect, glyph.metrics});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,9 +141,9 @@ std::shared_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
|
||||
// TODO: currently hardcoded to use the first font stack.
|
||||
const std::map<Value, Shaping>& shaping = layer.shaping.begin()->second;
|
||||
|
||||
const FaceGlyphPositions& const_faces = faces;
|
||||
const Faces& const_faces = faces;
|
||||
|
||||
IndexedFaceGlyphPositions faces;
|
||||
IndexedFaces faces;
|
||||
for (const std::string& face : layer.faces) {
|
||||
auto it = const_faces.find(face);
|
||||
if (it == const_faces.end()) {
|
||||
|
||||
@@ -103,7 +103,7 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom,
|
||||
};
|
||||
|
||||
void TextBucket::addFeature(const VectorTileFeature &feature,
|
||||
const IndexedFaceGlyphPositions &faces,
|
||||
const IndexedFaces &faces,
|
||||
const std::map<Value, Shaping> &shapings) {
|
||||
auto it_prop = feature.properties.find(geom_desc.text_field);
|
||||
if (it_prop == feature.properties.end()) {
|
||||
|
||||
@@ -33,14 +33,21 @@ bool byScale(const Anchor &a, const Anchor &b) { return a.scale < b.scale; }
|
||||
static const Glyph null_glyph;
|
||||
|
||||
inline const Glyph &getGlyph(const GlyphPlacement &placed,
|
||||
const IndexedFaceGlyphPositions &faces) {
|
||||
const IndexedFaces &faces) {
|
||||
if (placed.face < faces.size()) {
|
||||
const GlyphPositions &face = *faces[placed.face];
|
||||
if (&face) {
|
||||
if (placed.glyph < face.size()) {
|
||||
return face[placed.glyph];
|
||||
auto it = face.find(placed.glyph);
|
||||
if (it != face.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
fprintf(stderr, "glyph %d does not exist\n", placed.glyph);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "face pointer is null\n");
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "face does not exist\n");
|
||||
}
|
||||
|
||||
return null_glyph;
|
||||
@@ -137,7 +144,7 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs,
|
||||
}
|
||||
|
||||
PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
|
||||
const IndexedFaceGlyphPositions &faces, float fontScale,
|
||||
const IndexedFaces &faces, float fontScale,
|
||||
bool horizontal, const std::vector<Coordinate> &line,
|
||||
float maxAngleDelta, float rotate) {
|
||||
// The total text advance is the width of this label.
|
||||
@@ -260,7 +267,7 @@ PlacedGlyphs getGlyphs(Anchor &anchor, float advance, const Shaping &shaping,
|
||||
void Placement::addFeature(TextBucket& bucket,
|
||||
const std::vector<Coordinate> &line,
|
||||
const BucketGeometryDescription &info,
|
||||
const IndexedFaceGlyphPositions &faces,
|
||||
const IndexedFaces &faces,
|
||||
const Shaping &shaping) {
|
||||
|
||||
const bool horizontal = info.path == TextPathType::Horizontal;
|
||||
@@ -306,7 +313,7 @@ void Placement::addFeature(TextBucket& bucket,
|
||||
}
|
||||
}
|
||||
|
||||
float Placement::measureText(const IndexedFaceGlyphPositions &faces,
|
||||
float Placement::measureText(const IndexedFaces &faces,
|
||||
const Shaping &shaping) {
|
||||
float advance = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user