Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '24'
cache: 'npm'

- name: Install dependencies
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ http://localhost:3000 에서 확인
## License

MIT License

단, 카드에 임베드되는 JetBrains Mono 폰트(`src/utils/fonts/`)는 [SIL Open Font License 1.1](src/utils/fonts/OFL.txt)을 따릅니다.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "dreamhack-readme-stats",
"version": "1.0.0",
"private": true,
"engines": {
"node": "24.x"
},
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
59 changes: 59 additions & 0 deletions scripts/generate-font-subset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# SVG 카드에 임베드할 JetBrains Mono 서브셋 폰트(src/utils/fonts/jetbrainsMono.ts)를 생성합니다.
#
# GitHub README처럼 SVG가 <img>로 렌더링되면 브라우저가 외부 리소스(@import 등) 로드를 차단해
# Google Fonts를 쓸 수 없고 OS 기본 monospace 폰트로 대체됩니다.
# 그래서 카드에 쓰는 글자(ASCII)와 굵기(400~700)만 남긴 가변 폰트를 base64로 SVG에 직접 넣습니다.
#
# 필요: curl, python3 + fonttools, brotli
# pip install fonttools==4.65.0 brotli==1.2.1 (버전이 다르면 생성 결과가 달라질 수 있음)
# 사용: ./scripts/generate-font-subset.sh (다른 python 사용 시 PYTHON=/path/to/python 지정)

set -euo pipefail

VERSION="v2.304"
BASE_URL="https://raw.githubusercontent.com/JetBrains/JetBrainsMono/$VERSION"
FONT_SHA256="662a196d58f1183bf2d77428b6d5283fe3f45161ab021bea4036bc98e5cac016"
OFL_SHA256="30f0c136e3c88e422d0791acd97238870f9054a9729bc34cf2ff0d4ed8cac4ad"
UNICODES="U+0020-007E"
WEIGHT_MIN=400
WEIGHT_MAX=700
PYTHON="${PYTHON:-python3}"

OUT_DIR="$(cd "$(dirname "$0")/.." && pwd)/src/utils/fonts"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

# 실행할 때마다 같은 결과가 나오도록 폰트 타임스탬프 고정
export SOURCE_DATE_EPOCH=0

curl -sSfL -o "$TMP_DIR/font.ttf" "$BASE_URL/fonts/variable/JetBrainsMono%5Bwght%5D.ttf"
curl -sSfL -o "$TMP_DIR/OFL.txt" "$BASE_URL/OFL.txt"
echo "$FONT_SHA256 $TMP_DIR/font.ttf" | shasum -a 256 -c -
echo "$OFL_SHA256 $TMP_DIR/OFL.txt" | shasum -a 256 -c -

"$PYTHON" -m fontTools.varLib.instancer "$TMP_DIR/font.ttf" "wght=$WEIGHT_MIN:$WEIGHT_MAX" \
-o "$TMP_DIR/instanced.ttf" -q

# 리거처 등 레이아웃 기능은 제외하고, 라이선스 정보(name ID 13, 14)는 유지
"$PYTHON" -m fontTools.subset "$TMP_DIR/instanced.ttf" \
--unicodes="$UNICODES" \
--layout-features='' \
--name-IDs=0,1,2,3,4,5,6,13,14 \
--flavor=woff2 \
--output-file="$TMP_DIR/subset.woff2"

FONT_BASE64="$(base64 < "$TMP_DIR/subset.woff2" | tr -d '\n')"

mkdir -p "$OUT_DIR"
cp "$TMP_DIR/OFL.txt" "$OUT_DIR/OFL.txt"
cat > "$OUT_DIR/jetbrainsMono.ts" <<EOF
// 이 파일은 scripts/generate-font-subset.sh 로 생성되었습니다. 직접 수정하지 마세요.
// JetBrains Mono $VERSION 가변 폰트 (wght $WEIGHT_MIN~$WEIGHT_MAX, $UNICODES 서브셋)
// SIL Open Font License 1.1 (같은 디렉터리의 OFL.txt 참고)
export const jetBrainsMonoFontFace =
"@font-face { font-family: 'JetBrains Mono'; font-weight: $WEIGHT_MIN $WEIGHT_MAX; src: url(data:font/woff2;base64,$FONT_BASE64) format('woff2'); }";
EOF

echo "생성 완료: $OUT_DIR/jetbrainsMono.ts ($(wc -c < "$TMP_DIR/subset.woff2" | tr -d ' ') bytes woff2)"
17 changes: 17 additions & 0 deletions src/__tests__/utils/generateCategorySvg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,21 @@ describe('generateCategorySvg 유틸리티 함수 테스트', () => {
expect(result).toContain('fill="#21262d"'); // cardBackground
expect(result).toContain('stroke="#30363d"'); // border
});

it('폰트를 외부에서 불러오지 않고 SVG에 임베드해야 함', () => {
const mockStats: TCategoryStats = {
nickname: 'weakness',
total_score: 5000,
categories: [
{ name: 'web', score: 2000, rank: 50, color: '#ff6b6b' }
]
};

const result = generateCategorySvg(mockStats);

// <img>로 렌더링되는 SVG는 외부 리소스(@import)를 불러올 수 없음
expect(result).not.toContain('@import');
expect(result).toContain("font-family: 'JetBrains Mono'");
expect(result).toContain('url(data:font/woff2;base64,');
});
});
9 changes: 9 additions & 0 deletions src/__tests__/utils/generateStatsSvg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ describe('generateStatsSvg 유틸리티 함수 테스트', () => {
expect(result).toContain('fill="#21262d"'); // cardBackground
expect(result).toContain('stroke="#30363d"'); // border
});

it('폰트를 외부에서 불러오지 않고 SVG에 임베드해야 함', () => {
const result = generateStatsSvg(mockStats);

// <img>로 렌더링되는 SVG는 외부 리소스(@import)를 불러올 수 없음
expect(result).not.toContain('@import');
expect(result).toContain("font-family: 'JetBrains Mono'");
expect(result).toContain('url(data:font/woff2;base64,');
});
});
93 changes: 93 additions & 0 deletions src/utils/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Loading
Loading