import { Platform } from 'react-native';

// https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e
// https://hiddentao.com/archives/2017/03/10/get-custom-fonts-working-in-react-native/

const font = {
	'Open Sans': {
		weights: {
			ExtraBold: '800',
			Bold: '700',
			SemiBold: '600',
			Light: '300',
			Normal: '400',
		},
		styles: {
			Italic: 'italic',
		},
	},
};


export const fontMaker = (options = {}) => {
	const { weight, style, family } = Object.assign({
		weight: null,
		style: null,
		family: 'Open Sans',
	}, options);

	const { weights, styles } = font[family];

	if (Platform.OS === 'android') {
		const suffix = (weights[weight] ? weight : '') + (styles[style] ? style : '');
		return {
			fontFamily: family + (suffix.length ? `-${suffix}` : ''),
		};
	}
	return {
		fontFamily: family,
		fontWeight: weights[weight] || weights.Normal,
		fontStyle: styles[style] || 'normal',
	};
};
