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
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;

View File

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

View File

@ -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<int, size_t>::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<unicode_t, size_t>::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<std::pair<int, int>, double> & FontGeometry::getKerning() const {
const std::map<std::pair<int, int>, 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();

View File

@ -25,8 +25,8 @@ public:
GlyphRange(const std::vector<GlyphGeometry> *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<GlyphGeometry> *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<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
const char * getName() const;
const char *getName() const;
private:
double geometryScale;

View File

@ -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;
}

View File

@ -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

View File

@ -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<GlyphBox> & getLayout() const;
const std::vector<GlyphBox> &getLayout() const;
private:
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>
const AtlasStorage & ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::atlasStorage() const {
const AtlasStorage &ImmediateAtlasGenerator<T, N, GEN_FN, AtlasStorage>::atlasStorage() const {
return storage;
}
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;
}

View File

@ -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";

View File

@ -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<GlyphGeometry> &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;

View File

@ -6,7 +6,7 @@
namespace msdf_atlas {
static const char * const shadronFillGlyphMask = R"(
static const char *const shadronFillGlyphMask = R"(
template <ATLAS, RANGE, COLOR>
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 <ATLAS, RANGE, COLOR>
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 <median>
glsl struct GlyphVertex {

View File

@ -27,14 +27,14 @@ bool SquareSizeSelector<MULTIPLE>::operator()(int &width, int &height) const {
}
template <int MULTIPLE>
SquareSizeSelector<MULTIPLE> & SquareSizeSelector<MULTIPLE>::operator++() {
SquareSizeSelector<MULTIPLE> &SquareSizeSelector<MULTIPLE>::operator++() {
lowerBound = current+1;
updateCurrent();
return *this;
}
template <int MULTIPLE>
SquareSizeSelector<MULTIPLE> & SquareSizeSelector<MULTIPLE>::operator--() {
SquareSizeSelector<MULTIPLE> &SquareSizeSelector<MULTIPLE>::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;
}

View File

@ -12,8 +12,8 @@ class SquareSizeSelector {
public:
explicit SquareSizeSelector(int minArea = 0);
bool operator()(int &width, int &height) const;
SquareSizeSelector<MULTIPLE> & operator++();
SquareSizeSelector<MULTIPLE> & operator--();
SquareSizeSelector<MULTIPLE> &operator++();
SquareSizeSelector<MULTIPLE> &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;