From 6ce6f8b2ce356136ca682425bf9998d261baee95 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 18 Sep 2020 18:20:31 +0100 Subject: [PATCH] Add FontFace --- .../java/net/kemitix/fontface/FontFace.java | 43 +++++++++++++++++++ .../net/kemitix/fontface/FontFaceImpl.java | 30 +++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/main/java/net/kemitix/fontface/FontFace.java create mode 100644 src/main/java/net/kemitix/fontface/FontFaceImpl.java diff --git a/src/main/java/net/kemitix/fontface/FontFace.java b/src/main/java/net/kemitix/fontface/FontFace.java new file mode 100644 index 0000000..fe2ec20 --- /dev/null +++ b/src/main/java/net/kemitix/fontface/FontFace.java @@ -0,0 +1,43 @@ +package net.kemitix.fontface; + +import java.net.URI; + +public interface FontFace { + static FontFace of( + URI fontUri, + int size, + String colour, + int shadowOffsetX, + int shadowOffsetY + ) { + final String shadowColour = FontFaceImpl.shadowColour(colour); + return new FontFaceImpl(fontUri, size, colour, + shadowColour, shadowOffsetX, shadowOffsetY); + } + + static FontFace of( + URI fontUri, + int size, + String colour + ) { + return of(fontUri, size, colour, 0, 0); + } + + URI getFontLocation(); + + int getSize(); + + String getColour(); + + String getShadowColour(); + + int getShadowOffsetX(); + + int getShadowOffsetY(); + + FontFace withSize(int size); + FontFace withColour(String colour); + FontFace withShadowColour(String colour); + FontFace withShadowOffsetX(int offset); + FontFace withShadowOffsetY(int offsetY); +} diff --git a/src/main/java/net/kemitix/fontface/FontFaceImpl.java b/src/main/java/net/kemitix/fontface/FontFaceImpl.java new file mode 100644 index 0000000..8c36e8a --- /dev/null +++ b/src/main/java/net/kemitix/fontface/FontFaceImpl.java @@ -0,0 +1,30 @@ +package net.kemitix.fontface; + +import lombok.*; + +import java.net.URI; + +@Getter +@With +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PACKAGE) +public class FontFaceImpl implements FontFace { + + private URI fontLocation; + private int size; + private String colour; + private String shadowColour; + private int shadowOffsetX; + private int shadowOffsetY; + + static String shadowColour(final String colour) { + switch (colour) { + case "white": + case "yellow": + return "black"; + default: + return "white"; + } + } + +}