Skip to content

Commit

Permalink
字体授权相关信息完善
Browse files Browse the repository at this point in the history
  • Loading branch information
boybook committed Dec 28, 2024
1 parent 150bec0 commit d93ace1
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 23 deletions.
1 change: 1 addition & 0 deletions public/font/Smiley_Sans_Oblique_Regular.json

Large diffs are not rendered by default.

56 changes: 34 additions & 22 deletions src/components/SceneAndCameraSettingsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, useRef, useState } from "react";
import { Form, Input, Select, Slider, Modal, Button, Flex } from "antd";
import { Form, Input, Select, Slider, Modal, Button, Flex, Tag, Tooltip } from "antd";
import { CameraOptions } from "../types/text";
import { useLanguage } from "../language.tsx";
import { convertTTFtoFaceTypeJson as convertToFaceTypeJson, ConvertResult } from "../utils/ttfConverter.ts";
Expand All @@ -8,7 +8,7 @@ import { useMessage } from "../contexts/MessageContext.tsx";
import {
DeleteOutlined,
} from "@ant-design/icons";
import { builtinFontsMap } from "../utils/fonts.ts";
import { builtinFontsLicence, builtinFontsMap, FontLicenceInfo } from "../utils/fonts.ts";

// 让父组件传进来的一些状态和方法通过 props 传给此组件
interface CameraSettingsPanelProps {
Expand Down Expand Up @@ -96,26 +96,38 @@ const SceneAndCameraSettingsPanel: FC<CameraSettingsPanelProps> = ({
});
};

const fontOptions = Object.keys(fontsMap).map((fontName) => ({
label: (
<Flex justify={'space-between'} align={'center'}>
<span>{fontName}</span>
{!builtinFontsMap[fontName] && (
<Button
size="small"
type="text"
icon={<DeleteOutlined style={{ opacity: 0.5 }} />}
onClick={(e) => {
e.stopPropagation(); // 防止触发 Select 下拉收起
handleDeleteFont(fontName);
}}
>
</Button>
)}
</Flex>
),
value: fontName,
}));
const fontOptions = Object.keys(fontsMap).map((fontName) => {
const licenseInfo: FontLicenceInfo | undefined = builtinFontsLicence[fontName];
return {
label: (
<Flex justify={'space-between'} align={'center'}>
<Flex gap={'small'} align={'center'}>
<span>{fontName}</span>
{licenseInfo && (
<Tooltip
title={ <div dangerouslySetInnerHTML={{ __html: gLang(licenseInfo.tagTooltip) }} />}
>
<Tag color={licenseInfo.tagColor}>{gLang(licenseInfo.tag)}</Tag>
</Tooltip>
)}
</Flex>
{!builtinFontsMap[fontName] && (
<Button
size="small"
type="text"
icon={<DeleteOutlined style={{ opacity: 0.5 }} />}
onClick={(e) => {
e.stopPropagation(); // 防止触发 Select 下拉收起
handleDeleteFont(fontName);
}}
>
</Button>
)}
</Flex>
),
value: fontName,
}
});

return (
<>
Expand Down
24 changes: 24 additions & 0 deletions src/language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ export const languageConfig: Readonly<LanguageConfig> = {
nameInput: "请输入字体名称(用于显示在字体列表里的名称)",
success: "字体添加成功",
failed: "字体添加失败(详细原因请看控制台)",
},
fontLicence: {
netease: "限制商用",
neteaseTooltip: "商用限制(由于网易已购买商用授权并用于《我的世界》游戏,您可在网易《我的世界》游戏的内部使用)<br>个人用途请遵循<a href=\"https://www.hanyi.com.cn/faq-doc-1\" target=\"_blank\">《汉仪字库个人非商用须知》</a><br>商用请购买商用授权 <a href=\"https://www.hanyi.com.cn/license\" target=\"_blank\">https://www.hanyi.com.cn/license</a>",
sil: "开放许可证",
minecraftTenTooltip: "Minecraft Ten Font © 2024, Fardilizer<br>该字体依据 <a href=\"https://fontstruct.com/fontstructions/license/2552125/minecraft-ten-5\" target=\"_blank\"> SIL 开放字体许可证(SIL Open Font License,版本 1.1)</a> 授权使用。",
fusionPixelTooltip: "Fusion Pixel © 2022, TakWolf<br>该字体依据 <a href=\"https://github.com/TakWolf/fusion-pixel-font/blob/master/LICENSE-OFL\" target=\"_blank\"> SIL 开放字体许可证(SIL Open Font License,版本 1.1)</a> 授权使用。",
smileyTooltip: "Copyright (c) 2022--2024, atelierAnchor <https://atelier-anchor.com><br>该字体依据 <a href=\"https://github.com/atelier-anchor/smiley-sans/blob/main/LICENSE\" target=\"_blank\"> SIL 开放字体许可证(SIL Open Font License,版本 1.1)</a> 授权使用。"
}
},
en_US: {
Expand Down Expand Up @@ -152,6 +160,14 @@ export const languageConfig: Readonly<LanguageConfig> = {
nameInput: "Please input the font name",
success: "Font added successfully",
failed: "Font adding failed (please check the console for more details)",
},
fontLicence: {
netease: "Limitation",
neteaseTooltip: "Commercial use is restricted, only for internal use of NetEase games",
sil: "SIL",
minecraftTenTooltip: "Minecraft Ten Font © 2024, Fardilizer<br>This font is licensed under the SIL Open Font License, Version 1.1. Full license text available at <a href=\"https://fontstruct.com/fontstructions/license/2552125/minecraft-ten-5\" target=\"_blank\">https://fontstruct.com/fontstructions/license/2552125/minecraft-ten-5</a>",
fusionPixelTooltip: "Fusion Pixel © 2022, TakWolf<br>This font is licensed under the SIL Open Font License, Version 1.1. Full license text available at <a href=\"https://github.com/TakWolf/fusion-pixel-font/blob/master/LICENSE-OFL\" target=\"_blank\">https://github.com/TakWolf/fusion-pixel-font/blob/master/LICENSE-OFL</a>",
smileyTooltip: "Smiley Sans © 2022--2024, atelierAnchor <https://atelier-anchor.com><br>This font is licensed under the SIL Open Font License, Version 1.1. Full license text available at <a href=\"https://github.com/atelier-anchor/smiley-sans/blob/main/LICENSE\" target=\"_blank\">https://github.com/atelier-anchor/smiley-sans/blob/main/LICENSE</a>"
}
},
ja_JP: {
Expand Down Expand Up @@ -222,6 +238,14 @@ export const languageConfig: Readonly<LanguageConfig> = {
nameInput: "フォント名を入力してください",
success: "フォントが追加されました",
failed: "フォントの追加に失敗しました(詳細はコンソールを確認してください)"
},
fontLicence: {
netease: "制限",
neteaseTooltip: "商用利用は制限されており、NetEaseゲームの内部利用のみです",
sil: "SIL",
minecraftTenTooltip: "Minecraft Ten Font © 2024, Fardilizer<br>このフォントは SIL Open Font License、バージョン 1.1 でライセンスされています。完全なライセンステキストは<a href=\"https://fontstruct.com/fontstructions/license/2552125/minecraft-ten-5\" target=\"_blank\">こちら</a>でご覧いただけます。",
fusionPixelTooltip: "Fusion Pixel © 2022, TakWolf<br>このフォントは SIL Open Font License、バージョン 1.1 でライセンスされています。完全なライセンステキストは<a href=\"https://github.com/TakWolf/fusion-pixel-font/blob/master/LICENSE-OFL\" target=\"_blank\">こちら</a>でご覧いただけます。",
smileyTooltip: "Smiley Sans © 2022--2024, atelierAnchor <https://atelier-anchor.com><br>このフォントは SIL Open Font License、バージョン 1.1 でライセンスされています。完全なライセンステキストは<a href=\"https://github.com/atelier-anchor/smiley-sans/blob/main/LICENSE\" target=\"_blank\">こちら</a>でご覧いただけます。"
}
},
};
Expand Down
37 changes: 36 additions & 1 deletion src/utils/fonts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
export const builtinFontsMap: { [name: string]: string } = {
"REEJI Taiko Magic": "font/REEJI-TaikoMagicGB-Flash_Regular.json",
// "REEJI Taiko Magic": "font/REEJI-TaikoMagicGB-Flash_Regular.json",
"汉仪力量黑(简)": "font/HYLiLiangHeiJ_Regular.json",
"Minecraft Ten": "font/Minecraft_Ten_Regular.json",
"Fusion Pixel 8px": "font/Fusion_Pixel_8px_Proportional_zh_hans_Regular.json",
"Fusion Pixel 10px": "font/Fusion_Pixel_10px_Proportional_zh_hans_Regular.json",
"得意黑": "font/Smiley_Sans_Oblique_Regular.json"
};

export const builtinFontsTextureYOffset: { [name: string]: number } = {
"REEJI Taiko Magic": 0.1,
"汉仪力量黑(简)": 0.18,
"Fusion Pixel 8px": 0.15,
"Fusion Pixel 10px": 0.115,
}

export interface FontLicenceInfo {
tagColor: string;
tag: string;
tagTooltip: string;
}

export const builtinFontsLicence: { [name: string]: FontLicenceInfo } = {
"汉仪力量黑(简)": {
tagColor: "orange",
tag: "fontLicence.netease",
tagTooltip: "fontLicence.neteaseTooltip",
},
"Minecraft Ten": {
tagColor: "success",
tag: "fontLicence.sil",
tagTooltip: "fontLicence.minecraftTenTooltip",
},
"Fusion Pixel 8px": {
tagColor: "success",
tag: "fontLicence.sil",
tagTooltip: "fontLicence.fusionPixelTooltip",
},
"Fusion Pixel 10px": {
tagColor: "success",
tag: "fontLicence.sil",
tagTooltip: "fontLicence.fusionPixelTooltip",
},
"得意黑": {
tagColor: "success",
tag: "fontLicence.sil",
tagTooltip: "fontLicence.smileyTooltip",
}
}

0 comments on commit d93ace1

Please sign in to comment.