Add FontFace
This commit is contained in:
parent
2a438f9489
commit
6ce6f8b2ce
2 changed files with 73 additions and 0 deletions
43
src/main/java/net/kemitix/fontface/FontFace.java
Normal file
43
src/main/java/net/kemitix/fontface/FontFace.java
Normal 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);
|
||||
}
|
30
src/main/java/net/kemitix/fontface/FontFaceImpl.java
Normal file
30
src/main/java/net/kemitix/fontface/FontFaceImpl.java
Normal 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";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue