From b716311880fac43687e1c62586bb15a2f0e37652 Mon Sep 17 00:00:00 2001 From: Chlumsky Date: Sat, 9 Mar 2024 23:23:17 +0100 Subject: [PATCH] Minor code style change --- msdf-atlas-gen/DynamicAtlas.h | 4 ++-- msdf-atlas-gen/DynamicAtlas.hpp | 4 ++-- msdf-atlas-gen/FontGeometry.cpp | 14 +++++++------- msdf-atlas-gen/FontGeometry.h | 14 +++++++------- msdf-atlas-gen/GlyphGeometry.cpp | 4 ++-- msdf-atlas-gen/GlyphGeometry.h | 4 ++-- msdf-atlas-gen/ImmediateAtlasGenerator.h | 4 ++-- msdf-atlas-gen/ImmediateAtlasGenerator.hpp | 4 ++-- msdf-atlas-gen/json-export.cpp | 2 +- msdf-atlas-gen/main.cpp | 8 ++++---- msdf-atlas-gen/shadron-preview-generator.cpp | 6 +++--- msdf-atlas-gen/size-selectors.cpp | 12 ++++++------ msdf-atlas-gen/size-selectors.h | 12 ++++++------ 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/msdf-atlas-gen/DynamicAtlas.h b/msdf-atlas-gen/DynamicAtlas.h index 1956431..9e03dea 100644 --- a/msdf-atlas-gen/DynamicAtlas.h +++ b/msdf-atlas-gen/DynamicAtlas.h @@ -32,8 +32,8 @@ public: /// 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); /// Allows access to generator. Do not add glyphs to the generator directly! - AtlasGenerator & atlasGenerator(); - const AtlasGenerator & atlasGenerator() const; + AtlasGenerator &atlasGenerator(); + const AtlasGenerator &atlasGenerator() const; private: int side; diff --git a/msdf-atlas-gen/DynamicAtlas.hpp b/msdf-atlas-gen/DynamicAtlas.hpp index 516c0c8..fac5dda 100644 --- a/msdf-atlas-gen/DynamicAtlas.hpp +++ b/msdf-atlas-gen/DynamicAtlas.hpp @@ -80,12 +80,12 @@ typename DynamicAtlas::ChangeFlags DynamicAtlas: } template -AtlasGenerator & DynamicAtlas::atlasGenerator() { +AtlasGenerator &DynamicAtlas::atlasGenerator() { return generator; } template -const AtlasGenerator & DynamicAtlas::atlasGenerator() const { +const AtlasGenerator &DynamicAtlas::atlasGenerator() const { return generator; } diff --git a/msdf-atlas-gen/FontGeometry.cpp b/msdf-atlas-gen/FontGeometry.cpp index 45adf8b..08b2bef 100644 --- a/msdf-atlas-gen/FontGeometry.cpp +++ b/msdf-atlas-gen/FontGeometry.cpp @@ -15,11 +15,11 @@ bool FontGeometry::GlyphRange::empty() const { return glyphs->empty(); } -const GlyphGeometry * FontGeometry::GlyphRange::begin() const { +const GlyphGeometry *FontGeometry::GlyphRange::begin() const { return glyphs->data()+rangeStart; } -const GlyphGeometry * FontGeometry::GlyphRange::end() const { +const GlyphGeometry *FontGeometry::GlyphRange::end() const { return glyphs->data()+rangeEnd; } @@ -142,7 +142,7 @@ double FontGeometry::getGeometryScale() const { return geometryScale; } -const msdfgen::FontMetrics & FontGeometry::getMetrics() const { +const msdfgen::FontMetrics &FontGeometry::getMetrics() const { return metrics; } @@ -154,14 +154,14 @@ FontGeometry::GlyphRange FontGeometry::getGlyphs() const { return GlyphRange(glyphs, rangeStart, rangeEnd); } -const GlyphGeometry * FontGeometry::getGlyph(msdfgen::GlyphIndex index) const { +const GlyphGeometry *FontGeometry::getGlyph(msdfgen::GlyphIndex index) const { std::map::const_iterator it = glyphsByIndex.find(index.getIndex()); if (it != glyphsByIndex.end()) return &(*glyphs)[it->second]; return nullptr; } -const GlyphGeometry * FontGeometry::getGlyph(unicode_t codepoint) const { +const GlyphGeometry *FontGeometry::getGlyph(unicode_t codepoint) const { std::map::const_iterator it = glyphsByCodepoint.find(codepoint); if (it != glyphsByCodepoint.end()) return &(*glyphs)[it->second]; @@ -190,11 +190,11 @@ bool FontGeometry::getAdvance(double &advance, unicode_t codepoint1, unicode_t c return true; } -const std::map, double> & FontGeometry::getKerning() const { +const std::map, double> &FontGeometry::getKerning() const { return kerning; } -const char * FontGeometry::getName() const { +const char *FontGeometry::getName() const { if (name.empty()) return nullptr; return name.c_str(); diff --git a/msdf-atlas-gen/FontGeometry.h b/msdf-atlas-gen/FontGeometry.h index 4f3da26..a53167f 100644 --- a/msdf-atlas-gen/FontGeometry.h +++ b/msdf-atlas-gen/FontGeometry.h @@ -25,8 +25,8 @@ public: GlyphRange(const std::vector *glyphs, size_t rangeStart, size_t rangeEnd); size_t size() const; bool empty() const; - const GlyphGeometry * begin() const; - const GlyphGeometry * end() const; + const GlyphGeometry *begin() const; + const GlyphGeometry *end() const; private: const std::vector *glyphs; size_t rangeStart, rangeEnd; @@ -55,21 +55,21 @@ public: /// Returns the geometry scale to be used when loading glyphs double getGeometryScale() const; /// 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 GlyphIdentifierType getPreferredIdentifierType() const; /// Returns the list of all glyphs GlyphRange getGlyphs() const; /// Finds a glyph by glyph index or Unicode codepoint, returns null if not found - const GlyphGeometry * getGlyph(msdfgen::GlyphIndex index) const; - const GlyphGeometry * getGlyph(unicode_t codepoint) const; + const GlyphGeometry *getGlyph(msdfgen::GlyphIndex index) const; + const GlyphGeometry *getGlyph(unicode_t codepoint) const; /// 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, unicode_t codepoint1, unicode_t codepoint2) const; /// Returns the complete mapping of kerning pairs (by glyph indices) and their respective advance values - const std::map, double> & getKerning() const; + const std::map, double> &getKerning() const; /// Returns the name associated with the font or null if not set - const char * getName() const; + const char *getName() const; private: double geometryScale; diff --git a/msdf-atlas-gen/GlyphGeometry.cpp b/msdf-atlas-gen/GlyphGeometry.cpp index e63e124..f959b86 100644 --- a/msdf-atlas-gen/GlyphGeometry.cpp +++ b/msdf-atlas-gen/GlyphGeometry.cpp @@ -169,11 +169,11 @@ double GlyphGeometry::getGeometryScale() const { return geometryScale; } -const msdfgen::Shape & GlyphGeometry::getShape() const { +const msdfgen::Shape &GlyphGeometry::getShape() const { return shape; } -const msdfgen::Shape::Bounds & GlyphGeometry::getShapeBounds() const { +const msdfgen::Shape::Bounds &GlyphGeometry::getShapeBounds() const { return bounds; } diff --git a/msdf-atlas-gen/GlyphGeometry.h b/msdf-atlas-gen/GlyphGeometry.h index b7fd3c8..594020b 100644 --- a/msdf-atlas-gen/GlyphGeometry.h +++ b/msdf-atlas-gen/GlyphGeometry.h @@ -40,9 +40,9 @@ public: /// Returns the glyph's geometry scale double getGeometryScale() const; /// Returns the glyph's shape - const msdfgen::Shape & getShape() const; + const msdfgen::Shape &getShape() const; /// 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 double getAdvance() const; /// Returns the glyph's box in the atlas diff --git a/msdf-atlas-gen/ImmediateAtlasGenerator.h b/msdf-atlas-gen/ImmediateAtlasGenerator.h index 38357f3..40308a6 100644 --- a/msdf-atlas-gen/ImmediateAtlasGenerator.h +++ b/msdf-atlas-gen/ImmediateAtlasGenerator.h @@ -30,9 +30,9 @@ public: /// Sets the number of threads to be run by generate void setThreadCount(int threadCount); /// 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 - const std::vector & getLayout() const; + const std::vector &getLayout() const; private: AtlasStorage storage; diff --git a/msdf-atlas-gen/ImmediateAtlasGenerator.hpp b/msdf-atlas-gen/ImmediateAtlasGenerator.hpp index 0e08c41..5163812 100644 --- a/msdf-atlas-gen/ImmediateAtlasGenerator.hpp +++ b/msdf-atlas-gen/ImmediateAtlasGenerator.hpp @@ -74,12 +74,12 @@ void ImmediateAtlasGenerator::setThreadCount(int thr } template GEN_FN, class AtlasStorage> -const AtlasStorage & ImmediateAtlasGenerator::atlasStorage() const { +const AtlasStorage &ImmediateAtlasGenerator::atlasStorage() const { return storage; } template GEN_FN, class AtlasStorage> -const std::vector & ImmediateAtlasGenerator::getLayout() const { +const std::vector &ImmediateAtlasGenerator::getLayout() const { return layout; } diff --git a/msdf-atlas-gen/json-export.cpp b/msdf-atlas-gen/json-export.cpp index b04f004..b95c04d 100644 --- a/msdf-atlas-gen/json-export.cpp +++ b/msdf-atlas-gen/json-export.cpp @@ -40,7 +40,7 @@ static std::string escapeJsonString(const char *str) { return outStr; } -static const char * imageTypeString(ImageType type) { +static const char *imageTypeString(ImageType type) { switch (type) { case ImageType::HARD_MASK: return "hardmask"; diff --git a/msdf-atlas-gen/main.cpp b/msdf-atlas-gen/main.cpp index 0cf49e6..699b126 100644 --- a/msdf-atlas-gen/main.cpp +++ b/msdf-atlas-gen/main.cpp @@ -46,12 +46,12 @@ using namespace msdf_atlas; #define EXTRA_UNDERLINE #endif -static const char * const versionText = +static const char *const versionText = "MSDF-Atlas-Gen v" MSDF_ATLAS_VERSION_STRING "\n" " with MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n" "(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"() ----------------------------------------------------------------)" VERSION_UNDERLINE EXTRA_UNDERLINE R"( @@ -221,7 +221,7 @@ static bool cmpExtension(const char *path, const char *ext) { 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; while (*filename && *filename != '?') buffer.push_back(*filename++); @@ -322,7 +322,7 @@ static bool makeAtlas(const std::vector &glyphs, const std::vecto 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) int result = 0; diff --git a/msdf-atlas-gen/shadron-preview-generator.cpp b/msdf-atlas-gen/shadron-preview-generator.cpp index dabe66c..08d2f06 100644 --- a/msdf-atlas-gen/shadron-preview-generator.cpp +++ b/msdf-atlas-gen/shadron-preview-generator.cpp @@ -6,7 +6,7 @@ namespace msdf_atlas { -static const char * const shadronFillGlyphMask = R"( +static const char *const shadronFillGlyphMask = R"( template glsl vec4 fillGlyph(vec2 texCoord) { 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 glsl vec4 fillGlyph(vec2 texCoord) { 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 glsl struct GlyphVertex { diff --git a/msdf-atlas-gen/size-selectors.cpp b/msdf-atlas-gen/size-selectors.cpp index 7c33c01..3768d2e 100644 --- a/msdf-atlas-gen/size-selectors.cpp +++ b/msdf-atlas-gen/size-selectors.cpp @@ -27,14 +27,14 @@ bool SquareSizeSelector::operator()(int &width, int &height) const { } template -SquareSizeSelector & SquareSizeSelector::operator++() { +SquareSizeSelector &SquareSizeSelector::operator++() { lowerBound = current+1; updateCurrent(); return *this; } template -SquareSizeSelector & SquareSizeSelector::operator--() { +SquareSizeSelector &SquareSizeSelector::operator--() { upperBound = current; updateCurrent(); return *this; @@ -54,12 +54,12 @@ bool SquarePowerOfTwoSizeSelector::operator()(int &width, int &height) const { return side > 0; } -SquarePowerOfTwoSizeSelector & SquarePowerOfTwoSizeSelector::operator++() { +SquarePowerOfTwoSizeSelector &SquarePowerOfTwoSizeSelector::operator++() { side <<= 1; return *this; } -SquarePowerOfTwoSizeSelector & SquarePowerOfTwoSizeSelector::operator--() { +SquarePowerOfTwoSizeSelector &SquarePowerOfTwoSizeSelector::operator--() { side = 0; return *this; } @@ -74,7 +74,7 @@ bool PowerOfTwoSizeSelector::operator()(int &width, int &height) const { return w > 0 && h > 0; } -PowerOfTwoSizeSelector & PowerOfTwoSizeSelector::operator++() { +PowerOfTwoSizeSelector &PowerOfTwoSizeSelector::operator++() { if (w == h) w <<= 1; else @@ -82,7 +82,7 @@ PowerOfTwoSizeSelector & PowerOfTwoSizeSelector::operator++() { return *this; } -PowerOfTwoSizeSelector & PowerOfTwoSizeSelector::operator--() { +PowerOfTwoSizeSelector &PowerOfTwoSizeSelector::operator--() { w = 0, h = 0; return *this; } diff --git a/msdf-atlas-gen/size-selectors.h b/msdf-atlas-gen/size-selectors.h index b75fc3a..cd4ed37 100644 --- a/msdf-atlas-gen/size-selectors.h +++ b/msdf-atlas-gen/size-selectors.h @@ -12,8 +12,8 @@ class SquareSizeSelector { public: explicit SquareSizeSelector(int minArea = 0); bool operator()(int &width, int &height) const; - SquareSizeSelector & operator++(); - SquareSizeSelector & operator--(); + SquareSizeSelector &operator++(); + SquareSizeSelector &operator--(); private: int lowerBound, upperBound; @@ -29,8 +29,8 @@ class SquarePowerOfTwoSizeSelector { public: explicit SquarePowerOfTwoSizeSelector(int minArea = 0); bool operator()(int &width, int &height) const; - SquarePowerOfTwoSizeSelector & operator++(); - SquarePowerOfTwoSizeSelector & operator--(); + SquarePowerOfTwoSizeSelector &operator++(); + SquarePowerOfTwoSizeSelector &operator--(); private: int side; @@ -43,8 +43,8 @@ class PowerOfTwoSizeSelector { public: explicit PowerOfTwoSizeSelector(int minArea = 0); bool operator()(int &width, int &height) const; - PowerOfTwoSizeSelector & operator++(); - PowerOfTwoSizeSelector & operator--(); + PowerOfTwoSizeSelector &operator++(); + PowerOfTwoSizeSelector &operator--(); private: int w, h;