Skip to content

Commit 431be91

Browse files
Merge pull request #468 from compositive/change-default-font-resolution
Change default font resolution
2 parents 723e44d + 9047193 commit 431be91

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

examples/styleguide/src/components/AccessibilityBadge.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react/prop-types */
12
import * as React from 'react';
23
import Badge from './Badge';
34

examples/styleguide/src/components/Badge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import * as React from 'react';
33
import { View, Text } from 'react-sketchapp';
44

5-
const Badge = ({ children, filled }) => (
5+
const Badge = ({ children, filled = false }) => (
66
<View
77
style={{
88
borderRadius: 4,

src/jsonUtils/sketchImpl/findFontName.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import hashStyle from '../../utils/hashStyle';
44
import { TextStyle } from '../../types';
55
import { FONT_STYLES } from '../textLayers';
6-
import { APPLE_BROKEN_SYSTEM_FONT } from '../../utils/constants';
76

87
// this borrows heavily from react-native's RCTFont class
98
// thanks y'all
@@ -100,10 +99,8 @@ export const findFont = (style: TextStyle): NSFont => {
10099
let fontWeight = style.fontWeight
101100
? FONT_WEIGHTS[style.fontWeight.toLowerCase()]
102101
: defaultFontWeight;
103-
// Default to Helvetica if fonts are missing
104-
// Must use two equals (==) for compatibility with Cocoascript
105-
// eslint-disable-next-line eqeqeq
106-
let familyName = defaultFontFamily == APPLE_BROKEN_SYSTEM_FONT ? 'Helvetica' : defaultFontFamily;
102+
103+
let familyName = defaultFontFamily;
107104
let isItalic = false;
108105
let isCondensed = false;
109106

@@ -156,7 +153,6 @@ export const findFont = (style: TextStyle): NSFont => {
156153
isItalic = style.fontStyle ? isItalic : isItalicFont(font);
157154
isCondensed = isCondensedFont(font);
158155
} else {
159-
console.log(`Unrecognized font family '${familyName}'`);
160156
font = NSFont.systemFontOfSize_weight(fontSize, fontWeight);
161157
}
162158

@@ -198,7 +194,7 @@ export const findFont = (style: TextStyle): NSFont => {
198194
return font;
199195
};
200196

201-
export default function findFontName(style: TextStyle) {
197+
export default function findFontName(style: TextStyle): string {
202198
const font = findFont(style);
203199
return font.fontDescriptor().postscriptName();
204200
}

src/utils/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@ export const INHERITABLE_FONT_STYLES = [
2020

2121
// Only components that are allowed as children of <Text> components
2222
export const VALID_TEXT_CHILDREN_TYPES = ['text'];
23-
24-
// Font displayed if San Francisco fonts are not found
25-
export const APPLE_BROKEN_SYSTEM_FONT = '.AppleSystemUIFont';

0 commit comments

Comments
 (0)