-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fallback font support (#2640)
- Loading branch information
Showing
8 changed files
with
113 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@react-pdf/examples": minor | ||
"@react-pdf/layout": minor | ||
"@react-pdf/font": minor | ||
--- | ||
|
||
Add support for fontFamily fallbacks e.g. fontFamily: ['Roboto', 'NotoSansArabic'] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint react/prop-types: 0 */ | ||
/* eslint react/jsx-sort-props: 0 */ | ||
|
||
import React from 'react'; | ||
import { Document, Page, Text, StyleSheet, Font } from '@react-pdf/renderer'; | ||
|
||
import RobotoFont from '../../public/Roboto-Regular.ttf'; | ||
import NotoSansArabicFont from '../../public/NotoSansArabic-Regular.ttf'; | ||
|
||
const styles = StyleSheet.create({ | ||
body: { | ||
paddingTop: 35, | ||
paddingBottom: 45, | ||
paddingHorizontal: 35, | ||
position: 'relative', | ||
}, | ||
regular: { | ||
fontFamily: ['Roboto', 'NotoSansArabic'], | ||
fontWeight: 900, | ||
}, | ||
}); | ||
|
||
Font.register({ | ||
family: 'Roboto', | ||
fonts: [ | ||
{ | ||
src: RobotoFont, | ||
fontWeight: 400, | ||
}, | ||
], | ||
}); | ||
|
||
Font.register({ | ||
family: 'NotoSansArabic', | ||
fonts: [ | ||
{ | ||
src: NotoSansArabicFont, | ||
fontWeight: 400, | ||
}, | ||
], | ||
}); | ||
|
||
const MyDoc = () => { | ||
return ( | ||
<Page style={styles.body}> | ||
<Text style={styles.regular}>Test امتحان</Text> | ||
</Page> | ||
); | ||
}; | ||
|
||
const App = () => { | ||
return ( | ||
<Document> | ||
<MyDoc /> | ||
</Document> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters