mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-01 03:10:06 +00:00
Warnings: Always supply all field initialisers
This also fixes an issue where the requested font style could be incorrectly overwritten.
This commit is contained in:
parent
6de457f932
commit
3bf635e004
4 changed files with 43 additions and 32 deletions
|
|
@ -25,7 +25,7 @@ elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQU
|
|||
-Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare
|
||||
-Wint-conversion -Wconditional-uninitialized -Wconstant-conversion
|
||||
-Wsign-conversion -Wbool-conversion -Wextra-semi -Wunreachable-code
|
||||
-Wcast-align -Wshift-sign-overflow -Wno-missing-field-initializers
|
||||
-Wcast-align -Wshift-sign-overflow
|
||||
-Wnullable-to-nonnull-conversion -Wno-ignored-qualifiers -Wswitch-enum
|
||||
-Wpedantic -Wdeprecated
|
||||
$<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>:
|
||||
|
|
@ -37,7 +37,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|||
-Wall -Wextra -Wpedantic -Wstrict-aliasing -Wuninitialized
|
||||
-Wunused-parameter -Wsign-compare -Wsign-conversion -Wunreachable-code
|
||||
-Wcast-align -Wno-implicit-fallthrough -Wno-maybe-uninitialized
|
||||
-Wno-missing-field-initializers -Wno-ignored-qualifiers -Wswitch-enum
|
||||
-Wno-ignored-qualifiers -Wswitch-enum
|
||||
-Wredundant-decls -Wno-strict-overflow -Wshadow
|
||||
$<$<COMPILE_LANGUAGE:CXX>:
|
||||
-Woverloaded-virtual -Wreorder -Wzero-as-null-pointer-constant>)
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const Value
|
|||
llvmFlags.common.addArray ({
|
||||
"-Wshorten-64-to-32", "-Wconversion", "-Wint-conversion",
|
||||
"-Wconditional-uninitialized", "-Wconstant-conversion", "-Wbool-conversion",
|
||||
"-Wextra-semi", "-Wshift-sign-overflow", "-Wno-missing-field-initializers",
|
||||
"-Wextra-semi", "-Wshift-sign-overflow",
|
||||
"-Wshadow-all", "-Wnullable-to-nonnull-conversion"
|
||||
});
|
||||
llvmFlags.cpp.addArray ({
|
||||
|
|
@ -865,7 +865,7 @@ ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const Value
|
|||
auto& gccFlags = recommendedCompilerWarningFlags[CompilerNames::gcc] = BuildConfiguration::CompilerWarningFlags::getRecommendedForGCCAndLLVM();
|
||||
gccFlags.common.addArray ({
|
||||
"-Wextra", "-Wsign-compare", "-Wno-implicit-fallthrough", "-Wno-maybe-uninitialized",
|
||||
"-Wno-missing-field-initializers", "-Wredundant-decls", "-Wno-strict-overflow",
|
||||
"-Wredundant-decls", "-Wno-strict-overflow",
|
||||
"-Wshadow"
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace
|
|||
return iter;
|
||||
}
|
||||
|
||||
auto result = cache.emplace (std::move (args), CachedGlyphArrangement { configureArrangement (args) }).first;
|
||||
auto result = cache.emplace (std::move (args), CachedGlyphArrangement { configureArrangement (args), {} }).first;
|
||||
cacheOrder.push_front (result);
|
||||
return result;
|
||||
}();
|
||||
|
|
@ -397,7 +397,7 @@ void Graphics::drawMultiLineText (const String& text, const int startX,
|
|||
arrangement.addJustifiedText (args.font, args.text,
|
||||
(float) args.startX, (float) args.baselineY, (float) args.maximumLineWidth,
|
||||
args.justification, args.leading);
|
||||
return ConfiguredArrangement { std::move (arrangement) };
|
||||
return ConfiguredArrangement { std::move (arrangement), {} };
|
||||
};
|
||||
|
||||
GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this,
|
||||
|
|
@ -432,7 +432,7 @@ void Graphics::drawText (const String& text, Rectangle<float> area,
|
|||
arrangement.justifyGlyphs (0, arrangement.getNumGlyphs(),
|
||||
args.area.getX(), args.area.getY(), args.area.getWidth(), args.area.getHeight(),
|
||||
args.justificationType);
|
||||
return ConfiguredArrangement { std::move (arrangement) };
|
||||
return ConfiguredArrangement { std::move (arrangement), {} };
|
||||
};
|
||||
|
||||
GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this,
|
||||
|
|
@ -482,7 +482,7 @@ void Graphics::drawFittedText (const String& text, Rectangle<int> area,
|
|||
args.justification,
|
||||
args.maximumNumberOfLines,
|
||||
args.minimumHorizontalScale);
|
||||
return ConfiguredArrangement { std::move (arrangement) };
|
||||
return ConfiguredArrangement { std::move (arrangement), {} };
|
||||
};
|
||||
|
||||
GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this,
|
||||
|
|
|
|||
|
|
@ -108,6 +108,15 @@ struct DefaultFontInfo
|
|||
{
|
||||
struct Characteristics
|
||||
{
|
||||
explicit Characteristics (String nameIn) : name (nameIn) {}
|
||||
|
||||
Characteristics withStyle (String styleIn) const
|
||||
{
|
||||
auto copy = *this;
|
||||
copy.style = std::move (styleIn);
|
||||
return copy;
|
||||
}
|
||||
|
||||
String name, style;
|
||||
};
|
||||
|
||||
|
|
@ -124,7 +133,7 @@ struct DefaultFontInfo
|
|||
if (faceName == Font::getDefaultSerifFontName()) return defaultSerif;
|
||||
if (faceName == Font::getDefaultMonospacedFontName()) return defaultFixed;
|
||||
|
||||
return { faceName };
|
||||
return Characteristics { faceName };
|
||||
}
|
||||
|
||||
Characteristics defaultSans, defaultSerif, defaultFixed;
|
||||
|
|
@ -140,14 +149,14 @@ private:
|
|||
for (auto& choice : choicesArray)
|
||||
for (auto& name : names)
|
||||
if (name.startsWithIgnoreCase (choice.name))
|
||||
return { name, choice.style };
|
||||
return Characteristics { name }.withStyle (choice.style);
|
||||
|
||||
for (auto& choice : choicesArray)
|
||||
for (auto& name : names)
|
||||
if (name.containsIgnoreCase (choice.name))
|
||||
return { name, choice.style };
|
||||
return Characteristics { name }.withStyle (choice.style);
|
||||
|
||||
return { *names.begin() };
|
||||
return Characteristics { *names.begin() };
|
||||
}
|
||||
|
||||
static Characteristics getDefaultSansSerifFontCharacteristics()
|
||||
|
|
@ -155,12 +164,12 @@ private:
|
|||
StringArray allFonts;
|
||||
FTTypefaceList::getInstance()->getSansSerifNames (allFonts);
|
||||
|
||||
static const Characteristics targets[] { { "Verdana" },
|
||||
{ "Bitstream Vera Sans", "Roman" },
|
||||
{ "Luxi Sans" },
|
||||
{ "Liberation Sans" },
|
||||
{ "DejaVu Sans" },
|
||||
{ "Sans" } };
|
||||
static const Characteristics targets[] { Characteristics { "Verdana" },
|
||||
Characteristics { "Bitstream Vera Sans" }.withStyle ("Roman"),
|
||||
Characteristics { "Luxi Sans" },
|
||||
Characteristics { "Liberation Sans" },
|
||||
Characteristics { "DejaVu Sans" },
|
||||
Characteristics { "Sans" } };
|
||||
return pickBestFont (allFonts, targets);
|
||||
}
|
||||
|
||||
|
|
@ -169,12 +178,12 @@ private:
|
|||
StringArray allFonts;
|
||||
FTTypefaceList::getInstance()->getSerifNames (allFonts);
|
||||
|
||||
static const Characteristics targets[] { { "Bitstream Vera Serif", "Roman" },
|
||||
{ "Times" },
|
||||
{ "Nimbus Roman" },
|
||||
{ "Liberation Serif" },
|
||||
{ "DejaVu Serif" },
|
||||
{ "Serif" } };
|
||||
static const Characteristics targets[] { Characteristics { "Bitstream Vera Serif" }.withStyle ("Roman"),
|
||||
Characteristics { "Times" },
|
||||
Characteristics { "Nimbus Roman" },
|
||||
Characteristics { "Liberation Serif" },
|
||||
Characteristics { "DejaVu Serif" },
|
||||
Characteristics { "Serif" } };
|
||||
return pickBestFont (allFonts, targets);
|
||||
}
|
||||
|
||||
|
|
@ -183,13 +192,13 @@ private:
|
|||
StringArray allFonts;
|
||||
FTTypefaceList::getInstance()->getMonospacedNames (allFonts);
|
||||
|
||||
static const Characteristics targets[] { { "DejaVu Sans Mono" },
|
||||
{ "Bitstream Vera Sans Mono", "Roman" },
|
||||
{ "Sans Mono" },
|
||||
{ "Liberation Mono" },
|
||||
{ "Courier" },
|
||||
{ "DejaVu Mono" },
|
||||
{ "Mono" } };
|
||||
static const Characteristics targets[] { Characteristics { "DejaVu Sans Mono" },
|
||||
Characteristics { "Bitstream Vera Sans Mono" }.withStyle ("Roman"),
|
||||
Characteristics { "Sans Mono" },
|
||||
Characteristics { "Liberation Mono" },
|
||||
Characteristics { "Courier" },
|
||||
Characteristics { "DejaVu Mono" },
|
||||
Characteristics { "Mono" } };
|
||||
return pickBestFont (allFonts, targets);
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +213,9 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font)
|
|||
|
||||
const auto characteristics = defaultInfo.getRealFontCharacteristics (font.getTypefaceName());
|
||||
f.setTypefaceName (characteristics.name);
|
||||
f.setTypefaceStyle (characteristics.style);
|
||||
|
||||
if (font.getTypefaceStyle() == Font::getDefaultStyle())
|
||||
f.setTypefaceStyle (characteristics.style);
|
||||
|
||||
return Typeface::createSystemTypefaceFor (f);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue