fix boolean operators
This commit is contained in:
@@ -16,7 +16,7 @@ GlyphRange getGlyphRange(char32_t glyph);
|
||||
|
||||
struct GlyphMetrics {
|
||||
operator bool() const {
|
||||
return width == 0 && height == 0 && advance == 0;
|
||||
return !(width == 0 && height == 0 && advance == 0);
|
||||
}
|
||||
|
||||
// Glyph metrics.
|
||||
@@ -35,7 +35,7 @@ struct Glyph {
|
||||
: rect(rect), metrics(metrics) {}
|
||||
|
||||
operator bool() const {
|
||||
return !metrics && !rect;
|
||||
return metrics || rect;
|
||||
}
|
||||
|
||||
const Rect<uint16_t> rect;
|
||||
|
||||
@@ -15,7 +15,7 @@ struct Rect {
|
||||
return Rect(x * value, y * value, w * value, h * value);
|
||||
}
|
||||
|
||||
operator bool() const { return w == 0 || h == 0; }
|
||||
operator bool() const { return w != 0 && h != 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ bool SymbolBucket::hasData() const { return hasTextData() || hasIconData(); }
|
||||
|
||||
bool SymbolBucket::hasTextData() const { return !text.groups.empty(); }
|
||||
|
||||
bool SymbolBucket::hasIconData() const { return !icon.groups.empty() > 0; }
|
||||
bool SymbolBucket::hasIconData() const { return !icon.groups.empty(); }
|
||||
|
||||
void SymbolBucket::addGlyphsToAtlas(uint64_t tileid, const std::string stackname,
|
||||
const std::u32string &string, const FontStack &fontStack,
|
||||
|
||||
@@ -112,7 +112,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementS
|
||||
const float pad = glyph.padding;
|
||||
|
||||
if (anchor.x < 0 || anchor.x > 4096 || anchor.y < 0 || anchor.y > 4096) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float minScale = std::fmax(minPlacementScale, glyph.minScale);
|
||||
@@ -142,7 +142,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementS
|
||||
// NOTE: this isn't right because there can be glyphs with
|
||||
// the same anchor but differing box offsets.
|
||||
if (na == oa) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// todo: unhardcode the 8 = tileExtent/tileSize
|
||||
@@ -175,7 +175,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementS
|
||||
}
|
||||
|
||||
if (minPlacementScale > maxPlacementScale) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ Placement Placement::getGlyphs(Anchor &anchor, const vec2<float> &origin, const
|
||||
if (!glyph)
|
||||
continue;
|
||||
|
||||
if (!(rect && rect.w > 0 && rect.h > 0))
|
||||
if (!rect)
|
||||
continue;
|
||||
|
||||
const float x = (origin.x + shape.x + glyph.metrics.left - buffer + rect.w / 2) * boxScale;
|
||||
|
||||
Reference in New Issue
Block a user