Add FontFace

This commit is contained in:
Paul Campbell 2020-09-18 18:20:31 +01:00
parent 2a438f9489
commit 6ce6f8b2ce
2 changed files with 73 additions and 0 deletions

View file

@ -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);
}

View file

@ -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";
}
}
}