cad font fix
This commit is contained in:
1 parent
e18eab7a64
commit
cbf05a9ee1
5 files changed
+681
-8
No files matched your search
@@ -38,6 +38,8 @@
|
||||
"web-ifc": "^0.0.77"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fontsource-variable/noto-sans-kr": "^5.3.0",
|
||||
"@noto-pdf-ts/fonts-kr": "^0.0.1-alpha.0",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@types/three": "^0.172.0",
|
||||
|
||||
@@ -28,6 +28,14 @@ const assets = [
|
||||
'viewer-assets/wasm/occt-import-js.wasm',
|
||||
],
|
||||
['web-ifc/web-ifc.wasm', 'viewer-assets/wasm/web-ifc.wasm'],
|
||||
[
|
||||
'@noto-pdf-ts/fonts-kr/dist/fonts/NotoSansKR-VF.ttf',
|
||||
'viewer-assets/cad-resources/fonts/NotoSansKR-VF.ttf',
|
||||
],
|
||||
[
|
||||
'@fontsource-variable/noto-sans-kr/LICENSE',
|
||||
'viewer-assets/cad-resources/fonts/OFL-1.1.txt',
|
||||
],
|
||||
];
|
||||
|
||||
await Promise.all(
|
||||
@@ -41,12 +49,45 @@ await Promise.all(
|
||||
const resources = path.join(publicDir, 'viewer-assets', 'cad-resources');
|
||||
await mkdir(path.join(resources, 'fonts'), { recursive: true });
|
||||
await mkdir(path.join(resources, 'templates'), { recursive: true });
|
||||
await writeFile(path.join(resources, 'fonts.json'), '[]\n');
|
||||
const fontManifest = `${JSON.stringify(
|
||||
[
|
||||
{
|
||||
name: [
|
||||
'Noto Sans KR',
|
||||
'arial',
|
||||
'batang',
|
||||
'dotum',
|
||||
'ghs',
|
||||
'gulim',
|
||||
'hztxt',
|
||||
'isocpeur',
|
||||
'malgun',
|
||||
'malgun gothic',
|
||||
'pmingliu',
|
||||
'romans',
|
||||
'sanss___',
|
||||
'simplex',
|
||||
'swisscbo',
|
||||
'whgtxt',
|
||||
'whs',
|
||||
],
|
||||
file: 'NotoSansKR-VF.ttf',
|
||||
type: 'mesh',
|
||||
description: 'Open-source Korean CAD fallback (SIL OFL 1.1)',
|
||||
},
|
||||
],
|
||||
null,
|
||||
2,
|
||||
)}\n`;
|
||||
await Promise.all([
|
||||
writeFile(path.join(resources, 'fonts.json'), fontManifest),
|
||||
writeFile(path.join(resources, 'fonts', 'fonts.json'), fontManifest),
|
||||
]);
|
||||
await writeFile(
|
||||
path.join(resources, 'README.txt'),
|
||||
[
|
||||
'Optional CAD fonts and templates can be placed here.',
|
||||
'Only files with redistribution rights should be added.',
|
||||
'Noto Sans KR is bundled as the open-source Korean CAD fallback.',
|
||||
'Additional CAD fonts may be placed here when redistribution is permitted.',
|
||||
'The read-only viewer does not require a drawing template.',
|
||||
'',
|
||||
].join('\n'),
|
||||
|
||||
@@ -29,9 +29,11 @@ const WORKERS = {
|
||||
const router = useRouter();
|
||||
const fileInput = ref<HTMLInputElement | null>(null);
|
||||
const localFile = ref<File>();
|
||||
const pendingFile = ref<File>();
|
||||
const filename = ref('CAD 도면');
|
||||
const ready = ref(false);
|
||||
const viewerCreated = ref(false);
|
||||
const fontReady = ref(false);
|
||||
const error = ref('');
|
||||
const notice = ref('');
|
||||
const theme = useSystemTheme();
|
||||
@@ -51,7 +53,8 @@ settings.set('isShowToolbar', true);
|
||||
function applyFiles(files: File[]) {
|
||||
const file = files.find((item) => /\.(?:dxf|dwg)$/i.test(item.name));
|
||||
if (!file) return;
|
||||
localFile.value = file;
|
||||
pendingFile.value = file;
|
||||
if (fontReady.value) localFile.value = file;
|
||||
filename.value = file.name;
|
||||
error.value = '';
|
||||
notice.value =
|
||||
@@ -103,6 +106,19 @@ function onFileSelected(event: Event) {
|
||||
void nextTick();
|
||||
}
|
||||
|
||||
async function onViewerCreated() {
|
||||
viewerCreated.value = true;
|
||||
try {
|
||||
await AcApDocManager.instance.loadFonts(['Noto Sans KR']);
|
||||
} catch {
|
||||
notice.value =
|
||||
'대체 글꼴을 불러오지 못했습니다. 일부 CAD 문자가 표시되지 않을 수 있습니다.';
|
||||
} finally {
|
||||
fontReady.value = true;
|
||||
if (pendingFile.value) localFile.value = pendingFile.value;
|
||||
}
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
void router.push({ name: 'home' });
|
||||
}
|
||||
@@ -140,7 +156,7 @@ function onClose() {
|
||||
:progressive-rendering="true"
|
||||
:fail-on-font-load-error="false"
|
||||
locale="en"
|
||||
@create="viewerCreated = true"
|
||||
@create="onViewerCreated"
|
||||
/>
|
||||
<div v-if="ready && !localFile && viewerCreated" class="empty-state">
|
||||
<strong>CAD 도면을 선택해 주세요.</strong>
|
||||
|
||||
@@ -31,6 +31,11 @@ const thirdParty = [
|
||||
license: 'MPL-2.0',
|
||||
url: 'https://github.com/ThatOpen/engine_web-ifc',
|
||||
},
|
||||
{
|
||||
name: 'Noto Sans KR',
|
||||
license: 'SIL OFL 1.1',
|
||||
url: 'https://github.com/notofonts/noto-cjk',
|
||||
},
|
||||
{ name: 'Express', license: 'MIT', url: 'https://github.com/expressjs/express' },
|
||||
{ name: 'jsonwebtoken', license: 'MIT', url: 'https://github.com/auth0/node-jsonwebtoken' },
|
||||
{ name: 'multer', license: 'MIT', url: 'https://github.com/expressjs/multer' },
|
||||
@@ -98,9 +103,9 @@ const thirdParty = [
|
||||
GPL-3.0-only로 배포됩니다.
|
||||
</p>
|
||||
<p class="muted">
|
||||
CAD 폰트는 재배포 권리가 명확한 파일만 자체 호스팅해야 합니다. 본 배포본은
|
||||
상용 AutoCAD 폰트를 포함하지 않으며, 누락된 글꼴은 대체 글꼴로 표시될 수
|
||||
있습니다.
|
||||
상용 AutoCAD 폰트는 포함하지 않습니다. 누락된 한글·라틴 글꼴은 SIL Open
|
||||
Font License 1.1의 Noto Sans KR로 대체하며, 원본 글꼴과 글자 폭·형태가
|
||||
다를 수 있습니다.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in new issue
Block a user