From f465528a63f2682ff56508c146ef1d5b53c054b1 Mon Sep 17 00:00:00 2001 From: Junseong Park Date: Fri, 26 Sep 2025 11:24:34 +0900 Subject: [PATCH 1/2] i18n(ko-KR): update `fonts.mdx` --- .../ko/reference/experimental-flags/fonts.mdx | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/content/docs/ko/reference/experimental-flags/fonts.mdx b/src/content/docs/ko/reference/experimental-flags/fonts.mdx index c172d595537c3..7ee6703cf5ba9 100644 --- a/src/content/docs/ko/reference/experimental-flags/fonts.mdx +++ b/src/content/docs/ko/reference/experimental-flags/fonts.mdx @@ -325,6 +325,49 @@ import { Font } from 'astro:assets'; ``` +## 프로그래밍 방식으로 글꼴 데이터에 접근하기 + +`getFontData()` 함수는 [API 라우트](/ko/guides/endpoints/#서버-엔드포인트-api-라우트)에서 사용하거나, 자체 메타 태그를 생성하는 것과 같이 프로그래밍 방식으로 저수준 글꼴 패밀리 데이터를 가져오기 위한 것입니다. + +### `getFontData()` +

+ +**타입:** `(cssVariable: CssVariable) => FontData[]`
+ +

+ +지정된 [`cssVariable`](#cssvariable-1)에 대한 `src`, `weight`, `style`을 포함하는 `FontData` 객체의 배열을 반환합니다. + +다음은 [satori](https://github.com/vercel/satori)를 사용하여 OpenGraph 이미지를 생성할 때 URL로부터 글꼴 버퍼를 가져오기 위해 `getFontData()`를 사용하는 예시입니다. + +```tsx title="src/pages/og.png.ts" "getFontData(\"--font-roboto\")" "data[0].src[0].url" +import type{ APIRoute } from "astro" +import { getFontData } from "astro:assets" +import satori from "satori" + +export const GET: APIRoute = (context) => { + const data = getFontData("--font-roboto") + + const svg = await satori( +
hello, world
, + { + width: 600, + height: 400, + fonts: [ + { + name: "Roboto", + data: await fetch(new URL(data[0].src[0].url, context.url.origin)).then(res => res.arrayBuffer()), + weight: 400, + style: "normal", + }, + ], + }, + ) + + // ... +} +``` + ## 글꼴 구성 참조 글꼴의 모든 속성은 Astro 구성에서 설정해야 합니다. 일부 속성은 원격 및 로컬 글꼴 모두에 공통적이며, 다른 속성은 선택한 글꼴 제공자에 따라 사용할 수 있습니다. From 808bbe6c0616f970c8d203f52cf5e161e5ab0025 Mon Sep 17 00:00:00 2001 From: Yan <61414485+yanthomasdev@users.noreply.github.com> Date: Fri, 26 Sep 2025 08:54:58 -0300 Subject: [PATCH 2/2] Fix RFC link --- src/content/docs/ko/reference/experimental-flags/fonts.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/ko/reference/experimental-flags/fonts.mdx b/src/content/docs/ko/reference/experimental-flags/fonts.mdx index 7ee6703cf5ba9..e2d66fdbdb731 100644 --- a/src/content/docs/ko/reference/experimental-flags/fonts.mdx +++ b/src/content/docs/ko/reference/experimental-flags/fonts.mdx @@ -844,4 +844,4 @@ Astro 글꼴 제공자는 구성 객체와 실제 구현의 두 부분으로 구 ## 더 읽을거리 -이 실험적인 API에 대한 자세한 내용과 피드백을 제공하려면 [글꼴 RFC](https://github.com/withastro/roadmap/blob/rfc/fonts/proposals/0052-fonts.md)를 참조하세요. +이 실험적인 API에 대한 자세한 내용과 피드백을 제공하려면 [글꼴 RFC](https://github.com/withastro/roadmap/blob/rfc/fonts/proposals/0055-fonts.md)를 참조하세요.