diff --git a/packages/render-html/src/TRenderEngineProvider.tsx b/packages/render-html/src/TRenderEngineProvider.tsx index f3e22de4e..d6d6327df 100644 --- a/packages/render-html/src/TRenderEngineProvider.tsx +++ b/packages/render-html/src/TRenderEngineProvider.tsx @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; import useTRenderEngine from './hooks/useTRenderEngine'; import { TransientRenderEngineConfig } from './shared-types'; import RenderRegistryProvider from './context/RenderRegistryProvider'; +import defaultSystemFonts from './defaultSystemFonts'; const defaultTRenderEngine = {} as any; @@ -52,63 +53,6 @@ export const defaultFallbackFonts = { serif: Platform.select({ ios: 'Times New Roman', default: 'serif' }) }; -/** - * Default system fonts based on current platform. If you are using Expo, use - * `Constants.systemFonts` instead. - */ -export const defaultSystemFonts = Platform.select({ - default: [], - ios: [ - 'San Francisco', - 'Arial', - 'ArialHebrew', - 'Avenir', - 'Baskerville', - 'Bodoni 72', - 'Bradley Hand', - 'Chalkboard SE', - 'Cochin', - 'Copperplate', - 'Courier', - 'Courier New', - 'Damascus', - 'Didot', - 'Futura', - 'Geeza Pro', - 'Georgia', - 'Gill Sans', - 'Helvetica', - 'Helvetica Neue', - 'Hiragino Sans', - 'Hoefler Text', - 'Iowan Old Style', - 'Kailasa', - 'Khmer Sangam MN', - 'Marker Felt', - 'Menlo', - 'Mishafi', - 'Noteworthy', - 'Optima', - 'Palatino', - 'Papyrus', - 'Savoye LET', - 'Symbol', - 'Thonburi', - 'Times New Roman', - 'Trebuchet MS', - 'Verdana', - 'Zapf Dingbats', - 'Zapfino' - ], - android: [ - 'Roboto', - 'notoserif', - 'sans-serif-light', - 'sans-serif-thin', - 'sans-serif-medium' - ] -}); - export const defaultTRenderEngineProviderProps: TransientRenderEngineConfig = { htmlParserOptions: { decodeEntities: true diff --git a/packages/render-html/src/defaultSystemFonts.android.ts b/packages/render-html/src/defaultSystemFonts.android.ts new file mode 100644 index 000000000..fa0c76e3f --- /dev/null +++ b/packages/render-html/src/defaultSystemFonts.android.ts @@ -0,0 +1,9 @@ +const defaultSystemFonts = [ + 'Roboto', + 'notoserif', + 'sans-serif-light', + 'sans-serif-thin', + 'sans-serif-medium' +]; + +export default defaultSystemFonts; diff --git a/packages/render-html/src/defaultSystemFonts.ios.ts b/packages/render-html/src/defaultSystemFonts.ios.ts new file mode 100644 index 000000000..04c4663b4 --- /dev/null +++ b/packages/render-html/src/defaultSystemFonts.ios.ts @@ -0,0 +1,44 @@ +const defaultSystemFonts = [ + 'San Francisco', + 'Arial', + 'ArialHebrew', + 'Avenir', + 'Baskerville', + 'Bodoni 72', + 'Bradley Hand', + 'Chalkboard SE', + 'Cochin', + 'Copperplate', + 'Courier', + 'Courier New', + 'Damascus', + 'Didot', + 'Futura', + 'Geeza Pro', + 'Georgia', + 'Gill Sans', + 'Helvetica', + 'Helvetica Neue', + 'Hiragino Sans', + 'Hoefler Text', + 'Iowan Old Style', + 'Kailasa', + 'Khmer Sangam MN', + 'Marker Felt', + 'Menlo', + 'Mishafi', + 'Noteworthy', + 'Optima', + 'Palatino', + 'Papyrus', + 'Savoye LET', + 'Symbol', + 'Thonburi', + 'Times New Roman', + 'Trebuchet MS', + 'Verdana', + 'Zapf Dingbats', + 'Zapfino' +]; + +export default defaultSystemFonts; diff --git a/packages/render-html/src/defaultSystemFonts.macos.ts b/packages/render-html/src/defaultSystemFonts.macos.ts new file mode 100644 index 000000000..7e9ad3bd6 --- /dev/null +++ b/packages/render-html/src/defaultSystemFonts.macos.ts @@ -0,0 +1,128 @@ +const defaultSystemFonts = [ + 'Al Bayan', + 'American Typewriter', + 'Andalé Mono', + 'Apple Casual', + 'Apple Chancery', + 'Apple Garamond', + 'Apple Gothic', + 'Apple LiGothic', + 'Apple LiSung', + 'Apple Myungjo', + 'Apple Symbols', + '.AquaKana', + 'Arial', + 'Arial Hebrew', + 'Ayuthaya', + 'Baghdad', + 'Baskerville', + 'Beijing', + 'BiauKai', + 'Big Caslon', + 'Browallia New', + 'BrowalliaUPC', + 'Brush Script', + 'Candara', + 'Chalkboard', + 'Chalkduster', + 'Charcoal', + 'Charcoal CY', + 'Chicago', + 'Cochin', + 'Comic Sans', + 'Consolas', + 'Cooper', + 'Copperplate', + 'Corsiva Hebrew', + 'Courier', + 'Courier New', + 'DecoType Naskh', + 'Devanagari', + 'Didot', + 'Euphemia UCAS', + 'Futura', + 'Gadget', + 'Geeza Pro', + 'Geezah', + 'Geneva', + 'Geneva CY', + 'Georgia', + 'Gill Sans', + 'Gujarati', + 'Gung Seoche', + 'Gurmukhi', + 'Hangangche', + 'HeadlineA', + 'Hei', + 'Helvetica', + 'Helvetica CY', + 'Helvetica Neue', + 'Herculanum', + 'Hiragino Kaku Gothic Pro', + 'Hiragino Kaku Gothic ProN', + 'Hiragino Kaku Gothic Std', + 'Hiragino Kaku Gothic StdN', + 'Hiragino Maru Gothic Pro', + 'Hiragino Maru Gothic ProN', + 'Hiragino Mincho Pro', + 'Hiragino Mincho ProN', + 'Hoefler Text', + 'Inai Mathi', + 'Impact', + 'Jung Gothic', + 'Kai', + 'Keyboard', + 'Krungthep', + 'KufiStandard GK', + 'Kuenstler Script', + 'LastResort', + 'LiHei Pro', + 'LiSong Pro', + 'Lucida Sans', + 'Marker Felt', + 'Menlo', + 'Monaco', + 'Monaco CY', + 'Mshtakan', + 'Nadeem', + 'New Peninim', + 'New York', + 'NISC GB18030', + 'Optima', + 'Osaka', + 'Palatino', + 'Papyrus', + 'PC Myungjo', + 'Pilgiche', + 'Plantagenet Cherokee', + 'Raanana', + 'Sand', + 'Sathu', + 'Seoul', + 'Shin Myungjo Neue', + 'Silom', + 'Skia', + 'Snell Roundhand', + 'ST FangSong', + 'ST FangSong 2', + 'ST Heiti', + 'ST Kaiti', + 'ST Song', + 'Symbol', + 'Tae Graphic', + 'Tahoma', + 'Taipei', + 'Techno', + 'Textile', + 'Thonburi', + 'Times', + 'Times CY', + 'Times New Roman', + 'Trebuchet MS', + 'Verdana', + 'Zapf Chancery', + 'Zapf Dingbats', + 'Zapfino' +]; + +export default defaultSystemFonts; diff --git a/packages/render-html/src/defaultSystemFonts.ts b/packages/render-html/src/defaultSystemFonts.ts new file mode 100644 index 000000000..010837a73 --- /dev/null +++ b/packages/render-html/src/defaultSystemFonts.ts @@ -0,0 +1,7 @@ +/** + * Default system fonts based on current platform. + * + * @remarks If you are using Expo, use `Constants.systemFonts` instead. + */ +const defaultSystemFonts = ['Arial', 'Courier New', 'Georgia']; +export default defaultSystemFonts; diff --git a/packages/render-html/src/defaultSystemFonts.windows.ts b/packages/render-html/src/defaultSystemFonts.windows.ts new file mode 100644 index 000000000..8568effd4 --- /dev/null +++ b/packages/render-html/src/defaultSystemFonts.windows.ts @@ -0,0 +1,63 @@ +const defaultSystemFonts = [ + 'Arial', + 'Arial Black', + 'Bahnschrift', + 'Calibri', + 'Cambria', + 'Cambria Math', + 'Candara', + 'Comic Sans MS', + 'Consolas', + 'Constantia', + 'Corbel', + 'Courier New', + 'Ebrima', + 'Franklin Gothic Medium', + 'Gabriola', + 'Gadugi', + 'Georgia', + 'HoloLens MDL2 Assets', + 'Impact', + 'Ink Free', + 'Javanese Text', + 'Leelawadee UI', + 'Lucida Console', + 'Lucida Sans Unicode', + 'Malgun Gothic', + 'Marlett', + 'Microsoft Himalaya', + 'Microsoft JhengHei', + 'Microsoft New Tai Lue', + 'Microsoft PhagsPa', + 'Microsoft Sans Serif', + 'Microsoft Tai Le', + 'Microsoft YaHei', + 'Microsoft Yi Baiti', + 'MingLiU-ExtB', + 'Mongolian Baiti', + 'MS Gothic', + 'MV Boli', + 'Myanmar Text', + 'Nirmala UI', + 'Palatino Linotype', + 'Segoe MDL2 Assets', + 'Segoe Print', + 'Segoe Script', + 'Segoe UI', + 'Segoe UI Historic', + 'Segoe UI Emoji', + 'Segoe UI Symbol', + 'SimSun', + 'Sitka', + 'Sylfaen', + 'Symbol', + 'Tahoma', + 'Times New Roman', + 'Trebuchet MS', + 'Verdana', + 'Webdings', + 'Wingdings', + 'Yu Gothic' +]; + +export default defaultSystemFonts; diff --git a/packages/render-html/src/index.ts b/packages/render-html/src/index.ts index 19192769c..80be568ce 100644 --- a/packages/render-html/src/index.ts +++ b/packages/render-html/src/index.ts @@ -52,9 +52,9 @@ export type { TNodeChildrenRendererProps } from './TNodeChildrenRenderer'; export { default as TNodeRenderer } from './TNodeRenderer'; export { default as TRenderEngineProvider, - defaultFallbackFonts, - defaultSystemFonts + defaultFallbackFonts } from './TRenderEngineProvider'; +export { default as defaultSystemFonts } from './defaultSystemFonts'; export { default as RenderHTMLFragment } from './RenderHTMLFragment'; export { default as useInternalRenderer } from './hooks/useInternalRenderer'; export { default as useNormalizedUrl } from './hooks/useNormalizedUrl';