scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
185 lines • 5.46 kB
JavaScript
import { AbsFont } from "scriptable-abstract";
const FONT_FAMILY = {
SFUI: {
REGULAR: ".SFUI-Regular",
ULTRALIGHT: ".SFUI-Ultralight",
THIN: ".SFUI-Thin",
LIGHT: ".SFUI-Light",
MEDIUM: ".SFUI-Medium",
SEMIBOLD: ".SFUI-Semibold",
BOLD: ".SFUI-Bold",
HEAVY: ".SFUI-Heavy",
BLACK: ".SFUI-Black",
ITALIC: ".SFUI-RegularItalic"
},
MENLO: {
ULTRALIGHT: "Menlo-UltraLight",
THIN: "Menlo-Thin",
LIGHT: "Menlo-Light",
REGULAR: "Menlo-Regular",
MEDIUM: "Menlo-Medium",
SEMIBOLD: "Menlo-Semibold",
BOLD: "Menlo-Bold",
HEAVY: "Menlo-Heavy",
BLACK: "Menlo-Black"
},
SFUI_ROUNDED: {
ULTRALIGHT: ".SFUIRounded-Ultralight",
THIN: ".SFUIRounded-Thin",
LIGHT: ".SFUIRounded-Light",
REGULAR: ".SFUIRounded-Regular"
}
};
const FONT_SIZE = {
LARGE_TITLE: 34,
TITLE1: 28,
TITLE2: 22,
TITLE3: 20,
HEADLINE: 17,
SUBHEADLINE: 15,
BODY: 17,
CALLOUT: 16,
FOOTNOTE: 13,
CAPTION1: 12,
CAPTION2: 11,
DEFAULT: 12
};
const DEFAULT_STATE = {
size: FONT_SIZE.DEFAULT,
methodCalls: []
};
class MockFont extends AbsFont {
constructor(name, size) {
super({
...DEFAULT_STATE,
name,
size: size ?? DEFAULT_STATE.size,
methodCalls: ["constructor"]
});
}
get asFont() {
return this;
}
getState() {
return this.state;
}
// Factory method for creating system fonts
static createSystemFont(family, size) {
return new this(family, size).asFont;
}
// Standard text styles
static largeTitle() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.LARGE_TITLE);
}
static title1() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.TITLE1);
}
static title2() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.TITLE2);
}
static title3() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.TITLE3);
}
static headline() {
return this.createSystemFont(FONT_FAMILY.SFUI.SEMIBOLD, FONT_SIZE.HEADLINE);
}
static subheadline() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.SUBHEADLINE);
}
static body() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.BODY);
}
static callout() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.CALLOUT);
}
static footnote() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.FOOTNOTE);
}
static caption1() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.CAPTION1);
}
static caption2() {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, FONT_SIZE.CAPTION2);
}
// System fonts
static systemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, size);
}
static ultraLightSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.ULTRALIGHT, size);
}
static thinSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.THIN, size);
}
static lightSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.LIGHT, size);
}
static regularSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.REGULAR, size);
}
static mediumSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.MEDIUM, size);
}
static semiboldSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.SEMIBOLD, size);
}
static boldSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.BOLD, size);
}
static heavySystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.HEAVY, size);
}
static blackSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.BLACK, size);
}
static italicSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI.ITALIC, size);
}
// Monospaced system fonts
static ultraLightMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.ULTRALIGHT, size);
}
static thinMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.THIN, size);
}
static lightMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.LIGHT, size);
}
static regularMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.REGULAR, size);
}
static mediumMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.MEDIUM, size);
}
static semiboldMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.SEMIBOLD, size);
}
static boldMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.BOLD, size);
}
static heavyMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.HEAVY, size);
}
static blackMonospacedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.MENLO.BLACK, size);
}
// Rounded system fonts
static ultraLightRoundedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI_ROUNDED.ULTRALIGHT, size);
}
static thinRoundedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI_ROUNDED.THIN, size);
}
static lightRoundedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI_ROUNDED.LIGHT, size);
}
static regularRoundedSystemFont(size) {
return this.createSystemFont(FONT_FAMILY.SFUI_ROUNDED.REGULAR, size);
}
}
export {
FONT_FAMILY,
FONT_SIZE,
MockFont
};
//# sourceMappingURL=font.js.map