Skip to content

Commit db9b0b1

Browse files
committed
FEAT: font face update
1 parent ccd06eb commit db9b0b1

File tree

7 files changed

+19
-62
lines changed

7 files changed

+19
-62
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "style-composer",
3-
"version": "0.6.0-alpha5",
3+
"version": "0.6.0-alpha6",
44
"main": "./cjs/index.js",
55
"types": "./esm/index.d.ts",
66
"module": "./esm/index.js",

src/StyleHooks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import CascadingValuesContext, {CascadingValuesContextState}
2626
import {addFontLoadListener, getFontFace, isFontLoaded, loadFont, removeFontLoadListener} from "./font/FontFace";
2727
import child, {ChildQuery} from "./selector/ChildSelector";
2828
import StyleEnvironment from "./StyleEnvironment";
29+
import {fixStylePropTypes} from "./StyleSheetPropTypeFixer";
2930
import {ThemingContext} from "./theme/Theming";
3031

3132
export const useForceUpdate = (): [number, () => void] => {
@@ -66,6 +67,8 @@ export interface ComposedStyleOptions {
6667
autoFlattens?: boolean;
6768
}
6869

70+
fixStylePropTypes();
71+
6972
const findChildSelectors = (clazz: StyleClass): StyleSelector<any>[] | Falsy => {
7073
return clazz.__meta.hasAnySelectors && Object.values(clazz.__meta.rootScope.selectors).filter(selector => selector.type.id === child.id);
7174
};

src/StyleSheetPropTypeFixer.native.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-ignore
3+
import StyleSheetValidation from "react-native/Libraries/StyleSheet/StyleSheetValidation";
4+
5+
import propTypes from "prop-types";
6+
import {SUPPORTED_WEB_STYLES} from "./StyleConstants";
7+
8+
export const fixStylePropTypes = (): void => {
9+
StyleSheetValidation.addValidStylePropTypes(SUPPORTED_WEB_STYLES.reduce((props, key) => {
10+
props[key] = propTypes.string;
11+
return props;
12+
}, {} as any));
13+
};

src/StyleSheetPropTypeFixer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const fixStylePropTypes = (): void => {
2+
};

src/font/FontFace.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import WebFontBackend from "./backend/WebFontBackend";
1111
import FontBackend from "./backend/FontBackend";
1212
import {Platform} from "react-native";
13-
import {setupFontPreProcessor} from "./FontPreProcessor";
1413
import {isNative} from "../Utils";
1514

1615
export const fontFamilyMap: Record<string, FontFace> = {};
@@ -65,7 +64,6 @@ export const normaliseWeight = (weight: any): FontWeight => {
6564
};
6665

6766
export const loadFont = (fontFace: FontFace, weight?: FontWeight): FontLoadResult => {
68-
setupFontPreProcessor();
6967
return getFontBackend().loadFont(fontFace, normaliseWeight(weight || "regular"));
7068
};
7169

@@ -97,7 +95,6 @@ export const createFontFace = (
9795
Object.defineProperty(fontFace, "name", {
9896
value: name,
9997
});
100-
10198
for (const weight of Object.values(FontWeight)) {
10299
const styleValue = isNative() ? `${name}__${weight}` : [name, ...fontFace.options?.fallbacks || []].join(",");
103100
fontFace[weight] = () => {

src/font/FontPreProcessor.native.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/font/FontPreProcessor.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)