From c4cb4420b1dd37ae24d87d4d801f703cd2872141 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Fri, 9 Oct 2020 15:42:37 +0300 Subject: [PATCH] core - CustomTypefaceSpan polishing --- CHANGELOG.md | 15 +++++++++++++ gradle.properties | 2 +- .../core/spans/CustomTypefaceSpan.java | 22 ++++++++++++++++--- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8fa907b..c9d7c478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +# $SNAPSHOT; + +#### Changed +* `core` - `CustomTypefaceSpan` new `mergeStyles` functionality and new factory method([#298])
Thanks [@c-b-h] + +#### Deprecated +* `code` - `CustomTypefaceSpan(Typeface)` constructor, use `CustomTypefaceSpan.create(Typeface)` + or `CustomTypefaceSpan.create(Typeface, boolean)` factory methods instead + + +[#298]: https://github.com/noties/Markwon/pull/298 + +[@c-b-h]: https://github.com/c-b-h + + # 4.6.0 #### Added diff --git a/gradle.properties b/gradle.properties index f0e810f9..4496b270 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ android.enableJetifier=true android.enableBuildCache=true android.buildCacheDir=build/pre-dex-cache -VERSION_NAME=4.6.0 +VERSION_NAME=4.6.1-SNAPSHOT GROUP=io.noties.markwon POM_DESCRIPTION=Markwon markdown for Android diff --git a/markwon-core/src/main/java/io/noties/markwon/core/spans/CustomTypefaceSpan.java b/markwon-core/src/main/java/io/noties/markwon/core/spans/CustomTypefaceSpan.java index 5b55482c..68bbc829 100644 --- a/markwon-core/src/main/java/io/noties/markwon/core/spans/CustomTypefaceSpan.java +++ b/markwon-core/src/main/java/io/noties/markwon/core/spans/CustomTypefaceSpan.java @@ -12,7 +12,7 @@ import androidx.annotation.NonNull; * not used directly by the library, it\'s helpful for customizations. *

* Please note that this implementation does not validate current paint state - * and won\'t be updating/modifying supplied Typeface. + * and won\'t be updating/modifying supplied Typeface unless {@code mergeStyles} is specified * * @since 3.0.0 */ @@ -20,9 +20,19 @@ public class CustomTypefaceSpan extends MetricAffectingSpan { @NonNull public static CustomTypefaceSpan create(@NonNull Typeface typeface) { - return new CustomTypefaceSpan(typeface); + return create(typeface, false); } + /** + * NB! in order to merge typeface styles, supplied typeface must be + * able to be created via {@code Typeface.create(Typeface, int)} method. This would mean that bundled fonts + * inside {@code assets} folder would be able to display styles properly. + * + * @param mergeStyles control if typeface styles must be merged, for example, if + * this span (bold) is contained by other span (italic), + * {@code mergeStyles=true} would result in bold-italic + * @since $SNAPSHOT; + */ @NonNull public static CustomTypefaceSpan create(@NonNull Typeface typeface, boolean mergeStyles) { return new CustomTypefaceSpan(typeface, mergeStyles); @@ -32,11 +42,17 @@ public class CustomTypefaceSpan extends MetricAffectingSpan { private final boolean mergeStyles; + /** + * @deprecated $SNAPSHOT; use {{@link #create(Typeface)}} + * or {@link #create(Typeface, boolean)} factory method + */ + @Deprecated public CustomTypefaceSpan(@NonNull Typeface typeface) { this(typeface, false); } - public CustomTypefaceSpan(@NonNull Typeface typeface, boolean mergeStyles) { + // @since $SNAPSHOT; + CustomTypefaceSpan(@NonNull Typeface typeface, boolean mergeStyles) { this.typeface = typeface; this.mergeStyles = mergeStyles; }