This also fixes an issue where the requested font style could be incorrectly overwritten.pull/22/head
| @@ -25,7 +25,7 @@ elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQU | |||||
| -Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare | -Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare | ||||
| -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion | -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion | ||||
| -Wsign-conversion -Wbool-conversion -Wextra-semi -Wunreachable-code | -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 | -Wnullable-to-nonnull-conversion -Wno-ignored-qualifiers -Wswitch-enum | ||||
| -Wpedantic -Wdeprecated | -Wpedantic -Wdeprecated | ||||
| $<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>: | $<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>: | ||||
| @@ -37,7 +37,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | |||||
| -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wuninitialized | -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wuninitialized | ||||
| -Wunused-parameter -Wsign-compare -Wsign-conversion -Wunreachable-code | -Wunused-parameter -Wsign-compare -Wsign-conversion -Wunreachable-code | ||||
| -Wcast-align -Wno-implicit-fallthrough -Wno-maybe-uninitialized | -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 | -Wredundant-decls -Wno-strict-overflow -Wshadow | ||||
| $<$<COMPILE_LANGUAGE:CXX>: | $<$<COMPILE_LANGUAGE:CXX>: | ||||
| -Woverloaded-virtual -Wreorder -Wzero-as-null-pointer-constant>) | -Woverloaded-virtual -Wreorder -Wzero-as-null-pointer-constant>) | ||||
| @@ -855,7 +855,7 @@ ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const Value | |||||
| llvmFlags.common.addArray ({ | llvmFlags.common.addArray ({ | ||||
| "-Wshorten-64-to-32", "-Wconversion", "-Wint-conversion", | "-Wshorten-64-to-32", "-Wconversion", "-Wint-conversion", | ||||
| "-Wconditional-uninitialized", "-Wconstant-conversion", "-Wbool-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" | "-Wshadow-all", "-Wnullable-to-nonnull-conversion" | ||||
| }); | }); | ||||
| llvmFlags.cpp.addArray ({ | llvmFlags.cpp.addArray ({ | ||||
| @@ -865,7 +865,7 @@ ProjectExporter::BuildConfiguration::BuildConfiguration (Project& p, const Value | |||||
| auto& gccFlags = recommendedCompilerWarningFlags[CompilerNames::gcc] = BuildConfiguration::CompilerWarningFlags::getRecommendedForGCCAndLLVM(); | auto& gccFlags = recommendedCompilerWarningFlags[CompilerNames::gcc] = BuildConfiguration::CompilerWarningFlags::getRecommendedForGCCAndLLVM(); | ||||
| gccFlags.common.addArray ({ | gccFlags.common.addArray ({ | ||||
| "-Wextra", "-Wsign-compare", "-Wno-implicit-fallthrough", "-Wno-maybe-uninitialized", | "-Wextra", "-Wsign-compare", "-Wno-implicit-fallthrough", "-Wno-maybe-uninitialized", | ||||
| "-Wno-missing-field-initializers", "-Wredundant-decls", "-Wno-strict-overflow", | |||||
| "-Wredundant-decls", "-Wno-strict-overflow", | |||||
| "-Wshadow" | "-Wshadow" | ||||
| }); | }); | ||||
| } | } | ||||
| @@ -86,7 +86,7 @@ namespace | |||||
| return iter; | 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); | cacheOrder.push_front (result); | ||||
| return result; | return result; | ||||
| }(); | }(); | ||||
| @@ -397,7 +397,7 @@ void Graphics::drawMultiLineText (const String& text, const int startX, | |||||
| arrangement.addJustifiedText (args.font, args.text, | arrangement.addJustifiedText (args.font, args.text, | ||||
| (float) args.startX, (float) args.baselineY, (float) args.maximumLineWidth, | (float) args.startX, (float) args.baselineY, (float) args.maximumLineWidth, | ||||
| args.justification, args.leading); | args.justification, args.leading); | ||||
| return ConfiguredArrangement { std::move (arrangement) }; | |||||
| return ConfiguredArrangement { std::move (arrangement), {} }; | |||||
| }; | }; | ||||
| GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this, | GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this, | ||||
| @@ -432,7 +432,7 @@ void Graphics::drawText (const String& text, Rectangle<float> area, | |||||
| arrangement.justifyGlyphs (0, arrangement.getNumGlyphs(), | arrangement.justifyGlyphs (0, arrangement.getNumGlyphs(), | ||||
| args.area.getX(), args.area.getY(), args.area.getWidth(), args.area.getHeight(), | args.area.getX(), args.area.getY(), args.area.getWidth(), args.area.getHeight(), | ||||
| args.justificationType); | args.justificationType); | ||||
| return ConfiguredArrangement { std::move (arrangement) }; | |||||
| return ConfiguredArrangement { std::move (arrangement), {} }; | |||||
| }; | }; | ||||
| GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this, | GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this, | ||||
| @@ -482,7 +482,7 @@ void Graphics::drawFittedText (const String& text, Rectangle<int> area, | |||||
| args.justification, | args.justification, | ||||
| args.maximumNumberOfLines, | args.maximumNumberOfLines, | ||||
| args.minimumHorizontalScale); | args.minimumHorizontalScale); | ||||
| return ConfiguredArrangement { std::move (arrangement) }; | |||||
| return ConfiguredArrangement { std::move (arrangement), {} }; | |||||
| }; | }; | ||||
| GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this, | GlyphArrangementCache<ArrangementArgs>::getInstance()->draw (*this, | ||||
| @@ -108,6 +108,15 @@ struct DefaultFontInfo | |||||
| { | { | ||||
| struct Characteristics | 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; | String name, style; | ||||
| }; | }; | ||||
| @@ -124,7 +133,7 @@ struct DefaultFontInfo | |||||
| if (faceName == Font::getDefaultSerifFontName()) return defaultSerif; | if (faceName == Font::getDefaultSerifFontName()) return defaultSerif; | ||||
| if (faceName == Font::getDefaultMonospacedFontName()) return defaultFixed; | if (faceName == Font::getDefaultMonospacedFontName()) return defaultFixed; | ||||
| return { faceName }; | |||||
| return Characteristics { faceName }; | |||||
| } | } | ||||
| Characteristics defaultSans, defaultSerif, defaultFixed; | Characteristics defaultSans, defaultSerif, defaultFixed; | ||||
| @@ -140,14 +149,14 @@ private: | |||||
| for (auto& choice : choicesArray) | for (auto& choice : choicesArray) | ||||
| for (auto& name : names) | for (auto& name : names) | ||||
| if (name.startsWithIgnoreCase (choice.name)) | if (name.startsWithIgnoreCase (choice.name)) | ||||
| return { name, choice.style }; | |||||
| return Characteristics { name }.withStyle (choice.style); | |||||
| for (auto& choice : choicesArray) | for (auto& choice : choicesArray) | ||||
| for (auto& name : names) | for (auto& name : names) | ||||
| if (name.containsIgnoreCase (choice.name)) | 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() | static Characteristics getDefaultSansSerifFontCharacteristics() | ||||
| @@ -155,12 +164,12 @@ private: | |||||
| StringArray allFonts; | StringArray allFonts; | ||||
| FTTypefaceList::getInstance()->getSansSerifNames (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); | return pickBestFont (allFonts, targets); | ||||
| } | } | ||||
| @@ -169,12 +178,12 @@ private: | |||||
| StringArray allFonts; | StringArray allFonts; | ||||
| FTTypefaceList::getInstance()->getSerifNames (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); | return pickBestFont (allFonts, targets); | ||||
| } | } | ||||
| @@ -183,13 +192,13 @@ private: | |||||
| StringArray allFonts; | StringArray allFonts; | ||||
| FTTypefaceList::getInstance()->getMonospacedNames (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); | return pickBestFont (allFonts, targets); | ||||
| } | } | ||||
| @@ -204,7 +213,9 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) | |||||
| const auto characteristics = defaultInfo.getRealFontCharacteristics (font.getTypefaceName()); | const auto characteristics = defaultInfo.getRealFontCharacteristics (font.getTypefaceName()); | ||||
| f.setTypefaceName (characteristics.name); | f.setTypefaceName (characteristics.name); | ||||
| f.setTypefaceStyle (characteristics.style); | |||||
| if (font.getTypefaceStyle() == Font::getDefaultStyle()) | |||||
| f.setTypefaceStyle (characteristics.style); | |||||
| return Typeface::createSystemTypefaceFor (f); | return Typeface::createSystemTypefaceFor (f); | ||||
| } | } | ||||