{"id":14974364,"url":"https://github.com/flyskywhy/react-native-font-sim","last_synced_at":"2025-10-11T01:35:25.386Z","repository":{"id":142847987,"uuid":"106495934","full_name":"flyskywhy/react-native-font-sim","owner":"flyskywhy","description":"React Native font SimSun \u003c宋体\u003e SimHei \u003c黑体\u003e KaiTi\u003c楷体\u003e , support iOS and Android both.","archived":false,"fork":false,"pushed_at":"2023-03-15T07:03:07.000Z","size":17196,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-20T14:53:16.449Z","etag":null,"topics":["font","kaiti","react-native","simhei","simsun"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flyskywhy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-11T02:34:57.000Z","updated_at":"2025-03-25T01:12:22.000Z","dependencies_parsed_at":"2023-07-28T07:16:08.676Z","dependency_job_id":null,"html_url":"https://github.com/flyskywhy/react-native-font-sim","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/flyskywhy/react-native-font-sim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyskywhy%2Freact-native-font-sim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyskywhy%2Freact-native-font-sim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyskywhy%2Freact-native-font-sim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyskywhy%2Freact-native-font-sim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flyskywhy","download_url":"https://codeload.github.com/flyskywhy/react-native-font-sim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flyskywhy%2Freact-native-font-sim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005931,"owners_count":26083985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["font","kaiti","react-native","simhei","simsun"],"created_at":"2024-09-24T13:50:27.738Z","updated_at":"2025-10-11T01:35:25.378Z","avatar_url":"https://github.com/flyskywhy.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-font-sim\n[![npm version](http://img.shields.io/npm/v/react-native-font-sim.svg?style=flat-square)](https://npmjs.org/package/react-native-font-sim \"View this project on npm\")\n[![npm downloads](http://img.shields.io/npm/dm/react-native-font-sim.svg?style=flat-square)](https://npmjs.org/package/react-native-font-sim \"View this project on npm\")\n[![npm licence](http://img.shields.io/npm/l/react-native-font-sim.svg?style=flat-square)](https://npmjs.org/package/react-native-font-sim \"View this project on npm\")\n[![Platform](https://img.shields.io/badge/platform-ios%20%7C%20android-989898.svg?style=flat-square)](https://npmjs.org/package/react-native-font-sim \"View this project on npm\")\n\nFont `SimSun(宋体)`, `SimHei(黑体)` and `KaiTi(楷体)`, can work with `\u003cText/\u003e` or `\u003cGCanvasView/\u003e` or [react-native-font-picker](https://github.com/flyskywhy/react-native-font-picker).\n\n## Installation\n    npm install react-native-font-sim\n    npx react-native-asset -a ./node_modules/react-native-font-sim/fonts\n\noptional:\n\n    cd android/app/src/main/assets/fonts/\n    rm SimSun.ttf SimHei.ttf KaiTi.ttf\n    ln -s ../../../../../../node_modules/react-native-font-sim/fonts/* ./\n    cd -\n\nIf use `ln -s` above optional, run `react-native-asset` next time will got error, then need manually `cp` them before run `react-native-asset`.\n\nPS: The same steps can also install ttf files in e.g. [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons).\n\n## Usage\n### `\u003cText/\u003e`\n```\n\u003cText style={{fontFamily: SimSun}}\u003eI'm 宋体.\u003c/Text\u003e\n\u003cText style={{fontFamily: SimHei}}\u003eI'm 黑体.\u003c/Text\u003e\n\u003cText style={{fontFamily: KaiTi}}\u003eI'm 楷体.\u003c/Text\u003e\n\n```\n\n### `\u003cGCanvasView/\u003e`\n```\nimport {GCanvasView, registerFont} from '@flyskywhy/react-native-gcanvas';\nif (Platform.OS !== 'web') {\n  var RNFS = require('react-native-fs');\n}\n...\nif (Platform.OS === 'android') {\n  const destFontsPath = `${RNFS.ExternalDirectoryPath}/fonts`;\n  if (!(await RNFS.exists(destFontsPath))) {\n    await RNFS.mkdir(destFontsPath);\n  }\n  const dest = `${destFontsPath}/KaiTi.ttf`;\n  await RNFS.copyFileAssets('fonts/KaiTi.ttf', dest);\n  registerFont(dest);\n}\n\nconst ctx = this.canvas.getContext('2d');\nctx.font = '50px KaiTi';\nctx.fillText('原生画布NativeCanvas', 20, 100);\n...\n\u003cGCanvasView\n onCanvasCreate={canvas =\u003e this.canvas = canvas}\n style={styles.gcanvas}\n/\u003e\n```\n\n### as custom fonts of [react-native-font-picker](https://github.com/flyskywhy/react-native-font-picker)\nThus can let e.g. `KaiTi` be choosed just like `times new roman` as [Font Picker to fillText](https://github.com/flyskywhy/GCanvasRNExamples/blob/master/app/components/FontPicker2FillText.js) on [@flyskywhy/react-native-gcanvas](https://github.com/flyskywhy/react-native-gcanvas) by [react-native-font-picker](https://github.com/flyskywhy/react-native-font-picker).\n\n\u003cimg src=\"https://raw.githubusercontent.com/flyskywhy/GCanvasRNExamples/master/assets/FontPicker2FillText.gif\" width=\"480\"\u003e\n\n## Donate\nTo support my work, please consider donate.\n\n- ETH: 0xd02fa2738dcbba988904b5a9ef123f7a957dbb3e\n\n- \u003cimg src=\"https://raw.githubusercontent.com/flyskywhy/flyskywhy/main/assets/alipay_weixin.png\" width=\"500\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyskywhy%2Freact-native-font-sim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflyskywhy%2Freact-native-font-sim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflyskywhy%2Freact-native-font-sim/lists"}