diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java index 9dafbcb32b..371c8158e2 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRule.java @@ -7,6 +7,7 @@ package org.mage.card.arcane; import java.awt.Font; import java.awt.Image; +import java.awt.Paint; import java.awt.font.GraphicAttribute; import java.awt.font.ImageGraphicAttribute; import java.awt.font.TextAttribute; @@ -47,6 +48,25 @@ public class TextboxRule { } } + public static class ColorRegion implements AttributeRegion { + + ColorRegion(int start, int end, Paint color) { + this.start = start; + this.end = end; + this.color = color; + } + private final int start; + private final int end; + private final Paint color; + + @Override + public void applyToAttributedString(AttributedString str, Font normal, Font italic) { + if (end > start + 1) { + str.addAttribute(TextAttribute.FOREGROUND, color, start, end); + } + } + } + // A special symbol embedded at some point in a string public static class EmbeddedSymbol implements AttributeRegion { diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java index e89873a670..a9ba60ed4f 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/TextboxRuleParser.java @@ -23,6 +23,7 @@ public final class TextboxRuleParser { private static final Pattern LevelAbilityPattern = Pattern.compile("Level (\\d+)-?(\\d*)(\\+?)"); private static final Pattern LoyaltyAbilityPattern = Pattern.compile("^(\\+|\\-)(\\d+|X): "); private static final Pattern SimpleKeywordPattern = Pattern.compile("^(\\w+( \\w+)?)\\s*(\\([^\\)]*\\))?\\s*$"); + private static final Pattern FontColorValuePattern = Pattern.compile("color\\s*=\\s*[\"'](\\w+)[\"']"); // Parse a given rule (given as a string) into a TextboxRule, replacing // symbol annotations, italics, etc, parsing out information such as @@ -200,6 +201,11 @@ public final class TextboxRuleParser { } } break; + case "/font": + // Font it is an additional info of a card + // lets make it blue like it is in tooltip + regions.add(new TextboxRule.ColorRegion(openingIndex, outputIndex, Color.BLUE)); + break; default: // Unknown build.append('<').append(tag).append('>');