🎥 Make videos programmatically with React
chore(google-fonts): add API docs
Hidayatullah13b1b8bd1dfb
diff --git a/packages/docs/docs/google-fonts/index.md b/packages/docs/docs/google-fonts/index.mdnew file mode 100644index 0000000000..37d52153a8--- /dev/null+++ b/packages/docs/docs/google-fonts/index.md@@ -0,0 +1,131 @@+---+id: google-fonts+sidebar_label: Overview+title: "@remotion/google-fonts"+---++import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++The `@remotion/google-fonts` package provides APIs for easily integrating [Google Fonts](https://fonts.google.com/) into Remotion.++## Installation++<Tabs+defaultValue="npm"+values={[+{ label: 'npm', value: 'npm', },+{ label: 'yarn', value: 'yarn', },+{ label: 'pnpm', value: 'pnpm', },+]+}>+<TabItem value="npm">++```bash+npm i @remotion/google-fonts+```++ </TabItem>++ <TabItem value="yarn">++```bash+yarn add @remotion/google-fonts+```++ </TabItem>++ <TabItem value="pnpm">++```bash+pnpm i @remotion/google-fonts+```++ </TabItem>+</Tabs>++All Google Fonts is available under `"@remotion/google-fonts/<FontName>"`.++So if we want to use **Montserrat** font then we can import it from `"@remotion/google-fonts/Montserrat"`.++## Usage++Before using it, we need to import the fonts we want first, there are 2 ways to do this.++**Import one font**++```tsx+import { loadFont, family } from "@remotion/google-fonts/TitanOne";+```++**Import multiple fonts**++```tsx+import * as TitanOne from "@remotion/google-fonts/TitanOne";+import * as Montserrat from "@remotion/google-fonts/Montserrat";+```++After that call [loadFont()](./load-font.md) function with specific style, weights, and subsets.++```tsx+import * as TitanOne from "@remotion/google-fonts/TitanOne";+import * as Montserrat from "@remotion/google-fonts/Montserrat";++// Load Titan One font+TitanOne.loadFont("normal", {+ weights: ["400"],+ subsets: ["latin"],+});++// Load Montserrat using 2 font style+Montserrat.loadFont("normal", {+ weights: ["400", "600", "800"],+ subsets: ["latin", "latin-ext"],+});+Montserrat.loadFont("italic", {+ weights: ["400", "500", "600", "700", "800"],+ subsets: ["latin", "latin-ext"],+});+```++Then use it anywhere in our code.++```tsx+import * as TitanOne from "@remotion/google-fonts/TitanOne";++TitanOne.loadFont("normal", {+ weights: ["400"],+ subsets: ["latin"],+});++export const GoogleFontsDemoComposition = () => {+ return (+ <AbsoluteFill+ style={{+ justifyContent: "center",+ alignItems: "center",+ fontFamily: TitanOne.family,+ }}+ >+ <div>Hallo Google Fonts</div>+ </AbsoluteFill>+ );+};+```++## APIs++Each font will export these variables:++### loadFont()++Load font with selected style, weights, and subsets. See [loadFont()](./load-font.md).+++### family++The font family name, so we can pass this instead hardcode string.++### meta++Complete information about the current font.diff --git a/packages/docs/docs/google-fonts/load-font.md b/packages/docs/docs/google-fonts/load-font.mdnew file mode 100644index 0000000000..083f231957--- /dev/null+++ b/packages/docs/docs/google-fonts/load-font.md@@ -0,0 +1,57 @@+---+title: loadFont()+---++Load font with selected style, weights, and subsets.++```tsx+const loadFont: (+ style: string,+ options: {+ weights: string[],+ subsets: string[],+ }+) => void;+```++## Example++```tsx+import { loadFont, family } from "@remotion/google-fonts/Lobster";++loadFont("normal", {+ weights: ["400"],+ subsets: ["latin"],+});++export const GoogleFontsExample: React.FC = () => {+ return (+ <AbsoluteFill+ style={{+ justifyContent: 'center',+ alignItems: 'center',+ fontFamily: family,+ fontSize: 280,+ }}+ >+ <h1>Google Fonts</h1>+ </AbsoluteFill>+ );+};+```++## Argumets++### style++The font style we want to load.++### options++#### weights++List of Font weights that we want to load.++#### subsets++List of Font subsets that we want to load.\ No newline at end of filediff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 88af7c2469..097d313295 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -116,7 +116,6 @@ module.exports = {label: "@remotion/player",items: ["player/api"],},-{type: "category",label: "@remotion/gif",@@ -258,6 +257,17 @@ module.exports = {},items: ["noise/noise-2d", "noise/noise-3d", "noise/noise-4d"],},+ {+ type: "category",+ label: "@remotion/google-fonts",+ link: {+ type: "doc",+ id: "google-fonts/google-fonts",+ },+ items: [+ "google-fonts/load-font"+ ],+ },],mainSidebar: [{