Skip to content

🎥 Make videos programmatically with React

chore: update google fonts docs

Hidayatullahd6edfc11aa5b
diff --git a/packages/docs/docs/google-fonts/index.md b/packages/docs/docs/google-fonts/index.md
index e8add68a89..00e01cb18a 100644
--- a/packages/docs/docs/google-fonts/index.md
+++ b/packages/docs/docs/google-fonts/index.md
@@ -65,7 +65,7 @@ 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.
+After that call [loadFont()](./load-font.md) function with specific style, weights, and subsets or just omit the function arguments to load all variant available.
```tsx
import * as TitanOne from "@remotion/google-fonts/TitanOne";
@@ -86,6 +86,9 @@ Montserrat.loadFont("italic", {
weights: ["400", "500", "600", "700", "800"],
subsets: ["latin", "latin-ext"],
});
+
+// Load all Montserrat variant
+Montserrat.loadFont();
```
Then use it anywhere in our code.
@@ -93,10 +96,7 @@ Then use it anywhere in our code.
```tsx
import * as TitanOne from "@remotion/google-fonts/TitanOne";
-TitanOne.loadFont("normal", {
- weights: ["400"],
- subsets: ["latin"],
-});
+TitanOne.loadFont();
export const GoogleFontsDemoComposition = () => {
return (
@@ -129,3 +129,26 @@ The font family name, so we can pass this instead hardcode string.
### info
Complete information about the current font.
+
+**Example:**
+
+```js
+{
+ fontFamily: 'Titan One',
+ importName: 'TitanOne',
+ version: 'v13',
+ url: 'https://fonts.googleapis.com/css2?family=Titan+One:ital,wght@0,400',
+ unicodeRanges: {
+ 'latin-ext': 'U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF',
+ 'latin': 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
+ },
+ fonts: {
+ normal: {
+ '400': {
+ 'latin-ext': 'https://fonts.gstatic.com/s/titanone/v13/mFTzWbsGxbbS_J5cQcjCmjgm6Es.woff2',
+ 'latin': 'https://fonts.gstatic.com/s/titanone/v13/mFTzWbsGxbbS_J5cQcjClDgm.woff2',
+ },
+ },
+ },
+}
+```
\ No newline at end of file
diff --git a/packages/docs/docs/google-fonts/load-font.md b/packages/docs/docs/google-fonts/load-font.md
index 8038a7c380..6a69621ebc 100644
--- a/packages/docs/docs/google-fonts/load-font.md
+++ b/packages/docs/docs/google-fonts/load-font.md
@@ -6,16 +6,41 @@ Load font with selected style, weights, and subsets.
```tsx
const loadFont: (
- style: string,
- options: {
- weights: string[],
- subsets: string[],
+ style?: string,
+ options?: {
+ weights?: string[],
+ subsets?: string[],
}
) => void;
```
## Example
+### Load all variant
+
+```tsx
+import { loadFont, fontFamily } from "@remotion/google-fonts/Lobster";
+
+loadFont();
+
+export const GoogleFontsExample: React.FC = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ fontFamily: fontFamily,
+ fontSize: 280,
+ }}
+ >
+ <h1>Google Fonts</h1>
+ </AbsoluteFill>
+ );
+};
+```
+
+### Load specific variant
+
```tsx
import { loadFont, fontFamily } from "@remotion/google-fonts/Lobster";
@@ -40,18 +65,88 @@ export const GoogleFontsExample: React.FC = () => {
};
```
+### Load font and use returned information
+
+```tsx
+import { loadFont } from "@remotion/google-fonts/Lobster";
+
+const { fontFamily } = loadFont();
+
+export const GoogleFontsExample: React.FC = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ fontFamily: fontFamily,
+ fontSize: 280,
+ }}
+ >
+ <h1>Google Fonts</h1>
+ </AbsoluteFill>
+ );
+};
+```
+
## Argumets
+Arguments can be omited if we want to load all variant available.
+
### style
+_optional_
+
The font style we want to load.
### options
+_optional_
+
#### weights
+_optional_
+
List of Font weights that we want to load.
#### subsets
-List of Font subsets that we want to load.
\ No newline at end of file
+_optional_
+
+List of Font subsets that we want to load.
+
+## Return value
+
+### fontFamily
+
+The font family name.
+
+### fonts
+
+The font variant information.
+
+**Example:**
+
+```js
+{
+ normal: {
+ '400': {
+ 'latin-ext': 'https://fonts.gstatic.com/s/titanone/v13/mFTzWbsGxbbS_J5cQcjCmjgm6Es.woff2',
+ 'latin': 'https://fonts.gstatic.com/s/titanone/v13/mFTzWbsGxbbS_J5cQcjClDgm.woff2',
+ },
+ },
+}
+```
+
+
+### unicodeRanges
+
+The font unicode ranges information.
+
+**Example:**
+
+```js
+{
+ 'latin-ext': 'U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF',
+ 'latin': 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
+}
+```
\ No newline at end of file