Minor code style change

This commit is contained in:
Chlumsky 2024-03-09 23:23:17 +01:00
parent 37d185878d
commit b716311880
13 changed files with 46 additions and 46 deletions

View File

@ -32,8 +32,8 @@ public:
/// Adds a batch of glyphs. Adding more than one glyph at a time may improve packing efficiency /// Adds a batch of glyphs. Adding more than one glyph at a time may improve packing efficiency
ChangeFlags add(GlyphGeometry *glyphs, int count, bool allowRearrange = false); ChangeFlags add(GlyphGeometry *glyphs, int count, bool allowRearrange = false);
/// Allows access to generator. Do not add glyphs to the generator directly! /// Allows access to generator. Do not add glyphs to the generator directly!
AtlasGenerator & atlasGenerator(); AtlasGenerator &atlasGenerator();
const AtlasGenerator & atlasGenerator() const; const AtlasGenerator &atlasGenerator() const;
private: private:
int side; int side;

View File

@ -80,12 +80,12 @@ typename DynamicAtlas<AtlasGenerator>::ChangeFlags DynamicAtlas<AtlasGenerator>:
} }
template <class AtlasGenerator> template <class AtlasGenerator>
AtlasGenerator & DynamicAtlas<AtlasGenerator>::atlasGenerator() { AtlasGenerator &DynamicAtlas<AtlasGenerator>::atlasGenerator() {
return generator; return generator;
} }
template <class AtlasGenerator> template <class AtlasGenerator>
const AtlasGenerator & DynamicAtlas<AtlasGenerator>::atlasGenerator() const { const AtlasGenerator &DynamicAtlas<AtlasGenerator>::atlasGenerator() const {
return generator; return generator;
} }

View File

@ -15,11 +15,11 @@ bool FontGeometry::GlyphRange::empty() const {
return glyphs->empty(); return glyphs->empty();
} }
const GlyphGeometry * FontGeometry::GlyphRange::begin() const { const GlyphGeometry *FontGeometry::GlyphRange::begin() const {
return glyphs->data()+rangeStart; return glyphs->data()+rangeStart;
} }
const GlyphGeometry * FontGeometry::GlyphRange::end() const { const GlyphGeometry *FontGeometry::GlyphRange::end() const {
return glyphs->data()+rangeEnd; return glyphs->data()+rangeEnd;
} }
@ -142,7 +142,7 @@ double FontGeometry::getGeometryScale() const {
return geometryScale; return geometryScale;
} }
const msdfgen::FontMetrics & FontGeometry::getMetrics() const { const msdfgen::FontMetrics &FontGeometry::getMetrics() const {
return metrics; return metrics;
} }
@ -154,14 +154,14 @@ FontGeometry::GlyphRange FontGeometry::getGlyphs() const {
return GlyphRange(glyphs, rangeStart, rangeEnd); return GlyphRange(glyphs, rangeStart, rangeEnd);
} }
const GlyphGeometry * FontGeometry::getGlyph(msdfgen::GlyphIndex index) const { const GlyphGeometry *FontGeometry::getGlyph(msdfgen::GlyphIndex index) const {
std::map<int, size_t>::const_iterator it = glyphsByIndex.find(index.getIndex()); std::map<int, size_t>::const_iterator it = glyphsByIndex.find(index.getIndex());
if (it != glyphsByIndex.end()) if (it != glyphsByIndex.end())
return &(*glyphs)[it->second]; return &(*glyphs)[it->second];
return nullptr; return nullptr;
} }
const GlyphGeometry * FontGeometry::getGlyph(unicode_t codepoint) const { const GlyphGeometry *FontGeometry::getGlyph(unicode_t codepoint) const {
std::map<unicode_t, size_t>::const_iterator it = glyphsByCodepoint.find(codepoint); std::map<unicode_t, size_t>::const_iterator it = glyphsByCodepoint.find(codepoint);
if (it != glyphsByCodepoint.end()) if (it != glyphsByCodepoint.end())
return &(*glyphs)[it->second]; return &(*glyphs)[it->second];
@ -190,11 +190,11 @@ bool FontGeometry::getAdvance(double &advance, unicode_t codepoint1, unicode_t c
return true; return true;
} }
const std::map<std::pair<int, int>, double> & FontGeometry::getKerning() const { const std::map<std::pair<int, int>, double> &FontGeometry::getKerning() const {
return kerning; return kerning;
} }
const char * FontGeometry::getName() const { const char *FontGeometry::getName() const {
if (name.empty()) if (name.empty())
return nullptr; return nullptr;
return name.c_str(); return name.c_str();

View File

@ -25,8 +25,8 @@ public:
GlyphRange(const std::vector<GlyphGeometry> *glyphs, size_t rangeStart, size_t rangeEnd); GlyphRange(const std::vector<GlyphGeometry> *glyphs, size_t rangeStart, size_t rangeEnd);
size_t size() const; size_t size() const;
bool empty() const; bool empty() const;
const GlyphGeometry * begin() const; const GlyphGeometry *begin() const;
const GlyphGeometry * end() const; const GlyphGeometry *end() const;
private: private:
const std::vector<GlyphGeometry> *glyphs; const std::vector<GlyphGeometry> *glyphs;
size_t rangeStart, rangeEnd; size_t rangeStart, rangeEnd;
@ -55,21 +55,21 @@ public:
/// Returns the geometry scale to be used when loading glyphs /// Returns the geometry scale to be used when loading glyphs
double getGeometryScale() const; double getGeometryScale() const;
/// Returns the processed font metrics /// Returns the processed font metrics
const msdfgen::FontMetrics & getMetrics() const; const msdfgen::FontMetrics &getMetrics() const;
/// Returns the type of identifier that was used to load glyphs /// Returns the type of identifier that was used to load glyphs
GlyphIdentifierType getPreferredIdentifierType() const; GlyphIdentifierType getPreferredIdentifierType() const;
/// Returns the list of all glyphs /// Returns the list of all glyphs
GlyphRange getGlyphs() const; GlyphRange getGlyphs() const;
/// Finds a glyph by glyph index or Unicode codepoint, returns null if not found /// Finds a glyph by glyph index or Unicode codepoint, returns null if not found
const GlyphGeometry * getGlyph(msdfgen::GlyphIndex index) const; const GlyphGeometry *getGlyph(msdfgen::GlyphIndex index) const;
const GlyphGeometry * getGlyph(unicode_t codepoint) const; const GlyphGeometry *getGlyph(unicode_t codepoint) const;
/// Outputs the advance between two glyphs with kerning taken into consideration, returns false on failure /// Outputs the advance between two glyphs with kerning taken into consideration, returns false on failure
bool getAdvance(double &advance, msdfgen::GlyphIndex index1, msdfgen::GlyphIndex index2) const; bool getAdvance(double &advance, msdfgen::GlyphIndex index1, msdfgen::GlyphIndex index2) const;
bool getAdvance(double &advance, unicode_t codepoint1, unicode_t codepoint2) const; bool getAdvance(double &advance, unicode_t codepoint1, unicode_t codepoint2) const;
/// Returns the complete mapping of kerning pairs (by glyph indices) and their respective advance values /// Returns the complete mapping of kerning pairs (by glyph indices) and their respective advance values
const std::map<std::pair<int, int>, double> & getKerning() const; const std::map<std::pair<int, int>, double> &getKerning() const;
/// Returns the name associated with the font or null if not set /// Returns the name associated with the font or null if not set
const char * getName() const; const char *getName() const;
private: private:
double geometryScale; double geometryScale;

View File

@ -169,11 +169,11 @@ double GlyphGeometry::getGeometryScale() const {
return geometryScale; return geometryScale;
} }
const msdfgen::Shape & GlyphGeometry::getShape() const { const msdfgen::Shape &GlyphGeometry::getShape() const {
return shape; return shape;
} }
const msdfgen::Shape::Bounds & GlyphGeometry::getShapeBounds() const { const msdfgen::Shape::Bounds &GlyphGeometry::getShapeBounds() const {
return bounds; return bounds;
} }

View File

@ -40,9 +40,9 @@ public:
/// Returns the glyph's geometry scale /// Returns the glyph's geometry scale
double getGeometryScale() const; double getGeometryScale() const;
/// Returns the glyph's shape /// Returns the glyph's shape
const msdfgen::Shape & getShape() const; const msdfgen::Shape &getShape() const;
/// Returns the glyph's shape's raw bounds /// Returns the glyph's shape's raw bounds
const msdfgen::Shape::Bounds & getShapeBounds() const; const msdfgen::Shape::Bounds &getShapeBounds() const;
/// Returns the glyph's advance /// Returns the glyph's advance
double getAdvance() const; double getAdvance() const;
/// Returns the glyph's box in the atlas /// Returns the glyph's box in the atlas

View File

@ -30,9 +30,9 @@ public:
/// Sets the number of threads to be run by generate /// Sets the number of threads to be run by generate
void setThreadCount(int threadCount); void setThreadCount(int threadCount);
/// Allows access to the underlying AtlasStorage /// Allows access to the underlying AtlasStorage
const AtlasStorage & atlasStorage() const; const AtlasStorage &atlasStorage() const;
/// Returns the layout of the contained glyphs as a list of GlyphBoxes /// Returns the layout of the contained glyphs as a list of GlyphBoxes
const std::vector<GlyphBox> & getLayout() const; const std::vector<GlyphBox> &getLayout() const;
private: private:
AtlasStorage storage; AtlasStorage storage;

View File

@ -74,12 +74,12 @@ void ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::setThreadCount(int thr
} }
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage> template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
const AtlasStorage & ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::atlasStorage() const { const AtlasStorage &ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::atlasStorage() const {
return storage; return storage;
} }
template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage> template <typename T, int N, GeneratorFunction<T, N> GEN_FN, class AtlasStorage>
const std::vector<GlyphBox> & ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::getLayout() const { const std::vector<GlyphBox> &ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::getLayout() const {
return layout; return layout;
} }

View File

@ -40,7 +40,7 @@ static std::string escapeJsonString(const char *str) {
return outStr; return outStr;
} }
static const char * imageTypeString(ImageType type) { static const char *imageTypeString(ImageType type) {
switch (type) { switch (type) {
case ImageType::HARD_MASK: case ImageType::HARD_MASK:
return "hardmask"; return "hardmask";

View File

@ -46,12 +46,12 @@ using namespace msdf_atlas;
#define EXTRA_UNDERLINE #define EXTRA_UNDERLINE
#endif #endif
static const char * const versionText = static const char *const versionText =
"MSDF-Atlas-Gen v" MSDF_ATLAS_VERSION_STRING "\n" "MSDF-Atlas-Gen v" MSDF_ATLAS_VERSION_STRING "\n"
" with MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n" " with MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n"
"(c) 2020 - " STRINGIZE(MSDF_ATLAS_COPYRIGHT_YEAR) " Viktor Chlumsky"; "(c) 2020 - " STRINGIZE(MSDF_ATLAS_COPYRIGHT_YEAR) " Viktor Chlumsky";
static const char * const helpText = R"( static const char *const helpText = R"(
MSDF Atlas Generator by Viktor Chlumsky v)" MSDF_ATLAS_VERSION_STRING R"( (with MSDFgen v)" MSDFGEN_VERSION_STRING TITLE_SUFFIX R"() MSDF Atlas Generator by Viktor Chlumsky v)" MSDF_ATLAS_VERSION_STRING R"( (with MSDFgen v)" MSDFGEN_VERSION_STRING TITLE_SUFFIX R"()
----------------------------------------------------------------)" VERSION_UNDERLINE EXTRA_UNDERLINE R"( ----------------------------------------------------------------)" VERSION_UNDERLINE EXTRA_UNDERLINE R"(
@ -221,7 +221,7 @@ static bool cmpExtension(const char *path, const char *ext) {
return true; return true;
} }
static msdfgen::FontHandle * loadVarFont(msdfgen::FreetypeHandle *library, const char *filename) { static msdfgen::FontHandle *loadVarFont(msdfgen::FreetypeHandle *library, const char *filename) {
std::string buffer; std::string buffer;
while (*filename && *filename != '?') while (*filename && *filename != '?')
buffer.push_back(*filename++); buffer.push_back(*filename++);
@ -322,7 +322,7 @@ static bool makeAtlas(const std::vector<GlyphGeometry> &glyphs, const std::vecto
return success; return success;
} }
int main(int argc, const char * const *argv) { int main(int argc, const char *const *argv) {
#define ABORT(msg) do { fputs(msg "\n", stderr); return 1; } while (false) #define ABORT(msg) do { fputs(msg "\n", stderr); return 1; } while (false)
int result = 0; int result = 0;

View File

@ -6,7 +6,7 @@
namespace msdf_atlas { namespace msdf_atlas {
static const char * const shadronFillGlyphMask = R"( static const char *const shadronFillGlyphMask = R"(
template <ATLAS, RANGE, COLOR> template <ATLAS, RANGE, COLOR>
glsl vec4 fillGlyph(vec2 texCoord) { glsl vec4 fillGlyph(vec2 texCoord) {
float fill = texture((ATLAS), texCoord).r; float fill = texture((ATLAS), texCoord).r;
@ -14,7 +14,7 @@ glsl vec4 fillGlyph(vec2 texCoord) {
} }
)"; )";
static const char * const shadronFillGlyphSdf = R"( static const char *const shadronFillGlyphSdf = R"(
template <ATLAS, RANGE, COLOR> template <ATLAS, RANGE, COLOR>
glsl vec4 fillGlyph(vec2 texCoord) { glsl vec4 fillGlyph(vec2 texCoord) {
vec3 s = texture((ATLAS), texCoord).rgb; vec3 s = texture((ATLAS), texCoord).rgb;
@ -24,7 +24,7 @@ glsl vec4 fillGlyph(vec2 texCoord) {
} }
)"; )";
static const char * const shadronPreviewPreamble = R"( static const char *const shadronPreviewPreamble = R"(
#include <median> #include <median>
glsl struct GlyphVertex { glsl struct GlyphVertex {

View File

@ -27,14 +27,14 @@ bool SquareSizeSelector<MULTIPLE>::operator()(int &width, int &height) const {
} }
template <int MULTIPLE> template <int MULTIPLE>
SquareSizeSelector<MULTIPLE> & SquareSizeSelector<MULTIPLE>::operator++() { SquareSizeSelector<MULTIPLE> &SquareSizeSelector<MULTIPLE>::operator++() {
lowerBound = current+1; lowerBound = current+1;
updateCurrent(); updateCurrent();
return *this; return *this;
} }
template <int MULTIPLE> template <int MULTIPLE>
SquareSizeSelector<MULTIPLE> & SquareSizeSelector<MULTIPLE>::operator--() { SquareSizeSelector<MULTIPLE> &SquareSizeSelector<MULTIPLE>::operator--() {
upperBound = current; upperBound = current;
updateCurrent(); updateCurrent();
return *this; return *this;
@ -54,12 +54,12 @@ bool SquarePowerOfTwoSizeSelector::operator()(int &width, int &height) const {
return side > 0; return side > 0;
} }
SquarePowerOfTwoSizeSelector & SquarePowerOfTwoSizeSelector::operator++() { SquarePowerOfTwoSizeSelector &SquarePowerOfTwoSizeSelector::operator++() {
side <<= 1; side <<= 1;
return *this; return *this;
} }
SquarePowerOfTwoSizeSelector & SquarePowerOfTwoSizeSelector::operator--() { SquarePowerOfTwoSizeSelector &SquarePowerOfTwoSizeSelector::operator--() {
side = 0; side = 0;
return *this; return *this;
} }
@ -74,7 +74,7 @@ bool PowerOfTwoSizeSelector::operator()(int &width, int &height) const {
return w > 0 && h > 0; return w > 0 && h > 0;
} }
PowerOfTwoSizeSelector & PowerOfTwoSizeSelector::operator++() { PowerOfTwoSizeSelector &PowerOfTwoSizeSelector::operator++() {
if (w == h) if (w == h)
w <<= 1; w <<= 1;
else else
@ -82,7 +82,7 @@ PowerOfTwoSizeSelector & PowerOfTwoSizeSelector::operator++() {
return *this; return *this;
} }
PowerOfTwoSizeSelector & PowerOfTwoSizeSelector::operator--() { PowerOfTwoSizeSelector &PowerOfTwoSizeSelector::operator--() {
w = 0, h = 0; w = 0, h = 0;
return *this; return *this;
} }

View File

@ -12,8 +12,8 @@ class SquareSizeSelector {
public: public:
explicit SquareSizeSelector(int minArea = 0); explicit SquareSizeSelector(int minArea = 0);
bool operator()(int &width, int &height) const; bool operator()(int &width, int &height) const;
SquareSizeSelector<MULTIPLE> & operator++(); SquareSizeSelector<MULTIPLE> &operator++();
SquareSizeSelector<MULTIPLE> & operator--(); SquareSizeSelector<MULTIPLE> &operator--();
private: private:
int lowerBound, upperBound; int lowerBound, upperBound;
@ -29,8 +29,8 @@ class SquarePowerOfTwoSizeSelector {
public: public:
explicit SquarePowerOfTwoSizeSelector(int minArea = 0); explicit SquarePowerOfTwoSizeSelector(int minArea = 0);
bool operator()(int &width, int &height) const; bool operator()(int &width, int &height) const;
SquarePowerOfTwoSizeSelector & operator++(); SquarePowerOfTwoSizeSelector &operator++();
SquarePowerOfTwoSizeSelector & operator--(); SquarePowerOfTwoSizeSelector &operator--();
private: private:
int side; int side;
@ -43,8 +43,8 @@ class PowerOfTwoSizeSelector {
public: public:
explicit PowerOfTwoSizeSelector(int minArea = 0); explicit PowerOfTwoSizeSelector(int minArea = 0);
bool operator()(int &width, int &height) const; bool operator()(int &width, int &height) const;
PowerOfTwoSizeSelector & operator++(); PowerOfTwoSizeSelector &operator++();
PowerOfTwoSizeSelector & operator--(); PowerOfTwoSizeSelector &operator--();
private: private:
int w, h; int w, h;