diff --git a/check_fonts.py b/tools/check_fonts.py similarity index 92% rename from check_fonts.py rename to tools/check_fonts.py index f54b3a3..d342c90 100644 --- a/check_fonts.py +++ b/tools/check_fonts.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import re, os +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + def analyze_font(filepath): with open(filepath, 'r', encoding='utf-8') as f: content = f.read() @@ -50,7 +52,6 @@ def analyze_font(filepath): total_bitmap_size = len(byte_vals) print(f" Total bitmap data: {total_bitmap_size} bytes") - # Verify bitmap_index consistency warnings = [] for i, g in enumerate(glyphs): if i == 0: @@ -78,11 +79,10 @@ def analyze_font(filepath): else: print(f" No bitmap inconsistencies found") - # Print sample glyph data for idx in [1, 2]: if idx < len(glyphs): g = glyphs[idx] print(f" Glyph {idx}: bitmap_index={g.get('bitmap_index')}, adv_w={g.get('adv_w')}, box_w={g.get('box_w')}, box_h={g.get('box_h')}") -for f in ['app/tasks/custom_cjk_16.c', 'app/tasks/custom_cjk_20.c', 'app/tasks/custom_cjk_30.c', 'app/tasks/custom_cjk_40.c']: - analyze_font(f) +for f in ['custom_cjk_16.c', 'custom_cjk_20.c', 'custom_cjk_30.c', 'custom_cjk_40.c']: + analyze_font(os.path.join(project_root, 'app/tasks', f)) diff --git a/check_pixels.py b/tools/check_pixels.py similarity index 70% rename from check_pixels.py rename to tools/check_pixels.py index f06d58c..505b203 100644 --- a/check_pixels.py +++ b/tools/check_pixels.py @@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- import re +import os + +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def check_bitmap(filepath): with open(filepath, 'r', encoding='utf-8') as f: @@ -19,11 +22,10 @@ def check_bitmap(filepath): bytes_vals.append(int(x)) except: pass - # 4bpp: each byte has 2 pixels (high nibble, low nibble) pixels = [] for b in bytes_vals: - pixels.append((b >> 4) & 0x0F) # high nibble - pixels.append(b & 0x0F) # low nibble + pixels.append((b >> 4) & 0x0F) + pixels.append(b & 0x0F) max_val = max(pixels) nonzero = [v for v in pixels if v > 0] min_nonzero = min(nonzero) if nonzero else 0 @@ -32,7 +34,7 @@ def check_bitmap(filepath): else: print(f'{filepath}: no match') -check_bitmap('app/tasks/custom_cjk_40.c') -check_bitmap('app/tasks/custom_cjk_30.c') -check_bitmap('app/tasks/custom_cjk_20.c') -check_bitmap('app/tasks/custom_cjk_16.c') +check_bitmap(os.path.join(project_root, 'app/tasks/custom_cjk_40.c')) +check_bitmap(os.path.join(project_root, 'app/tasks/custom_cjk_30.c')) +check_bitmap(os.path.join(project_root, 'app/tasks/custom_cjk_20.c')) +check_bitmap(os.path.join(project_root, 'app/tasks/custom_cjk_16.c')) diff --git a/diag_font.py b/tools/diag_font.py similarity index 91% rename from diag_font.py rename to tools/diag_font.py index 9411d82..8704047 100644 --- a/diag_font.py +++ b/tools/diag_font.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import re, os, glob +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + def pg(fp): with open(fp, encoding='utf-8') as f: c = f.read() @@ -19,7 +21,7 @@ def pg(fp): tests = [[0x8bbe,0x7f6e,0x91cd,0x91cf],[0x6309,0x6b64,0x542f,0x52a8],[0x5f53,0x524d,0x91cd,0x91cf],[0x5305,0x88c5,0x8ba1,0x6570],[0x8fd0,0x884c,0x72b6,0x6001],[0x5df2,0x505c,0x6b62],[0x542f,0x52a8],[0x505c,0x6b62],[0x8fd0,0x884c,0x4e2d]] ts = [''.join(chr(u) for u in t) for t in tests] -for fp in sorted(glob.glob('app/tasks/custom_cjk_*.c')): +for fp in sorted(glob.glob(os.path.join(project_root, 'app/tasks/custom_cjk_*.c'))): bs = os.path.basename(fp) fs = int(re.search(r'_(\d+)\.c$', fp).group(1)) gs, us = pg(fp) diff --git a/fix_font.py b/tools/fix_font.py similarity index 90% rename from fix_font.py rename to tools/fix_font.py index 63e4559..24466d3 100644 --- a/fix_font.py +++ b/tools/fix_font.py @@ -1,6 +1,8 @@ import re, os, glob -font_files = glob.glob('app/tasks/custom_cjk_*.c') +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +font_files = glob.glob(os.path.join(project_root, 'app/tasks/custom_cjk_*.c')) for filepath in font_files: with open(filepath, 'r', encoding='utf-8') as f: @@ -16,7 +18,6 @@ for filepath in font_files: return full_line.replace(f'adv_w = {adv_w}', f'adv_w = {new_adv_w}') return full_line - # Match adv_w, box_w, and optionally box_h and ofs_x in any order pattern = r'\.adv_w = (\d+), \.box_w = (\d+)(?:, \.box_h = \d+)?(?:, \.ofs_x = (\d+))?' fixed_content = re.sub(pattern, fix_adv_w, content) @@ -24,7 +25,6 @@ for filepath in font_files: f.write(fixed_content) print(f"=== {os.path.basename(filepath)} ===") - # Show changed values original = content changed_lines = [] for line_num, (orig_line, fix_line) in enumerate(zip(original.split('\n'), fixed_content.split('\n')), 1): diff --git a/freeze_font.py b/tools/freeze_font.py similarity index 83% rename from freeze_font.py rename to tools/freeze_font.py index e37103e..a442ae8 100644 --- a/freeze_font.py +++ b/tools/freeze_font.py @@ -3,7 +3,8 @@ from fontTools.varLib import instancer import os src = r"vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf" -src = os.path.join(os.path.dirname(os.path.abspath(__file__)), src) +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +src = os.path.join(project_root, src) for weight, name in [(500, "Medium"), (700, "Bold")]: dst = src.replace(".ttf", f"_{name}.ttf") diff --git a/gen_font.py b/tools/gen_font.py similarity index 93% rename from gen_font.py rename to tools/gen_font.py index 075bd38..2f6aa9e 100644 --- a/gen_font.py +++ b/tools/gen_font.py @@ -4,7 +4,8 @@ from PIL import Image, ImageDraw import os import sys -os.chdir(r'D:\20_AI\LSPi') +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +os.chdir(project_root) def render_glyph_to_bitmap(font_path, char, size, bpp=4): from PIL import ImageFont @@ -183,7 +184,7 @@ def write_lvgl_font(filename, size, bpp, glyph_bitmaps, glyph_dscs, unicode_list f.write("#endif\n") def main(): - font_path = "vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf" + font_path = os.path.join(project_root, "vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf") chars_16 = list("0123456789.-+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") chars_16.extend([0x5F53, 0x524D, 0x91CD, 0x91CF, 0x603B, 0x5305, 0x6570, 0x8BBE, @@ -203,18 +204,18 @@ def main(): chars_40 = list("0123456789.") print("Generating custom_cjk_16.c...") - generate_font(font_path, chars_16, 16, "app/tasks/custom_cjk_16.c") + generate_font(font_path, chars_16, 16, os.path.join(project_root, "app/tasks/custom_cjk_16.c")) print("Generating custom_cjk_20.c...") - generate_font(font_path, chars_20, 20, "app/tasks/custom_cjk_20.c") + generate_font(font_path, chars_20, 20, os.path.join(project_root, "app/tasks/custom_cjk_20.c")) print("Generating custom_cjk_30.c...") - generate_font(font_path, chars_30, 30, "app/tasks/custom_cjk_30.c") + generate_font(font_path, chars_30, 30, os.path.join(project_root, "app/tasks/custom_cjk_30.c")) print("Generating custom_cjk_40.c...") - generate_font(font_path, chars_40, 40, "app/tasks/custom_cjk_40.c") + generate_font(font_path, chars_40, 40, os.path.join(project_root, "app/tasks/custom_cjk_40.c")) print("Done!") if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/gen_lvgl_font.py b/tools/gen_lvgl_font.py similarity index 96% rename from gen_lvgl_font.py rename to tools/gen_lvgl_font.py index 192924d..7252889 100644 --- a/gen_lvgl_font.py +++ b/tools/gen_lvgl_font.py @@ -8,6 +8,9 @@ from fontTools.ttLib import TTFont from PIL import Image, ImageDraw, ImageFont import struct import sys +import os + +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) class FontGenerator: def __init__(self, font_path, size): @@ -182,7 +185,7 @@ class FontGenerator: def main(): - font_path = "./vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_medium.ttf" + font_path = os.path.join(project_root, "vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_medium.ttf") sizes = [16, 20, 30, 40] ascii_codes = [0x2B, 0x2D, 0x2E] + list(range(0x30, 0x3A)) @@ -207,9 +210,9 @@ def main(): print(f" {success}/{len(all_codes)} characters added") - output = f"app/tasks/custom_cjk_{size}.c" + output = os.path.join(project_root, f"app/tasks/custom_cjk_{size}.c") gen.generate_lvgl_font(output) print(f" Written to {output}") if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/patch_font_weight.py b/tools/patch_font_weight.py similarity index 94% rename from patch_font_weight.py rename to tools/patch_font_weight.py index f68dc97..13bc6bd 100644 --- a/patch_font_weight.py +++ b/tools/patch_font_weight.py @@ -2,7 +2,8 @@ import struct import os ttf_path = "vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf" -ttf_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), ttf_path) +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +ttf_path = os.path.join(project_root, ttf_path) with open(ttf_path, "rb") as f: data = bytearray(f.read()) diff --git a/raw_test_16.c b/tools/raw_test_16.c similarity index 100% rename from raw_test_16.c rename to tools/raw_test_16.c diff --git a/raw_test_40.c b/tools/raw_test_40.c similarity index 100% rename from raw_test_40.c rename to tools/raw_test_40.c diff --git a/regen_font.py b/tools/regen_font.py similarity index 96% rename from regen_font.py rename to tools/regen_font.py index adeca7e..b163d37 100644 --- a/regen_font.py +++ b/tools/regen_font.py @@ -3,7 +3,8 @@ import subprocess import sys import os -os.chdir(r'D:\20_AI\LSPi') +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +os.chdir(project_root) def run_cmd(cmd): cmd_str = ' '.join(cmd) @@ -81,4 +82,4 @@ def main(): print("All fonts generated successfully!") if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/regen_font_new.py b/tools/regen_font_new.py similarity index 83% rename from regen_font_new.py rename to tools/regen_font_new.py index f29a303..276a4bc 100644 --- a/regen_font_new.py +++ b/tools/regen_font_new.py @@ -4,8 +4,10 @@ import subprocess import os +project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + lv_font_conv_path = "C:\\Users\\gxms0\\AppData\\Roaming\\npm\\lv_font_conv.cmd" -font_path = "./vue/vue3/src/assets/fonts/simhei.ttf" +font_path = os.path.join(project_root, "vue/vue3/src/assets/fonts/simhei.ttf") codes = [ 0x2B, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, @@ -28,7 +30,7 @@ for size in sizes: "--format=lvgl", "--bpp=4", "--no-compress", - "-o", f"app/tasks/custom_cjk_{size}.c", + "-o", os.path.join(project_root, f"app/tasks/custom_cjk_{size}.c"), ] for code in codes: @@ -42,4 +44,4 @@ for size in sizes: except subprocess.CalledProcessError as e: print(f" Failed: {e.stderr}") -print("Done") \ No newline at end of file +print("Done") diff --git a/test_font.c b/tools/test_font.c similarity index 100% rename from test_font.c rename to tools/test_font.c diff --git a/test_multi.c b/tools/test_multi.c similarity index 100% rename from test_multi.c rename to tools/test_multi.c diff --git a/test_single.c b/tools/test_single.c similarity index 100% rename from test_single.c rename to tools/test_single.c diff --git a/vue/vue3/.gitignore b/vue/vue3/.gitignore deleted file mode 100644 index a547bf3..0000000 --- a/vue/vue3/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/vue/vue3/README.md b/vue/vue3/README.md deleted file mode 100644 index 33895ab..0000000 --- a/vue/vue3/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Vue 3 + TypeScript + Vite - -This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` - - diff --git a/vue/vue3/package.json b/vue/vue3/package.json deleted file mode 100644 index f93b811..0000000 --- a/vue/vue3/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "pixso-vue-template", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" - }, - "dependencies": { - "vue": "^3.5.17", - "vue-router": "^4.5.1" - }, - "devDependencies": { - "@vitejs/plugin-vue": "^6.0.0", - "@vue/tsconfig": "^0.7.0", - "typescript": "~5.8.3" - } -} \ No newline at end of file diff --git a/vue/vue3/src/App.vue b/vue/vue3/src/App.vue deleted file mode 100644 index d978254..0000000 --- a/vue/vue3/src/App.vue +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf b/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf deleted file mode 100644 index 4e0c62e..0000000 Binary files a/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf and /dev/null differ diff --git a/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_Bold.ttf b/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_Bold.ttf deleted file mode 100644 index 1db0e15..0000000 Binary files a/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_Bold.ttf and /dev/null differ diff --git a/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_medium.ttf b/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_medium.ttf deleted file mode 100644 index cb89140..0000000 Binary files a/vue/vue3/src/assets/fonts/NotoSansSC-VariableFont_wght_2_medium.ttf and /dev/null differ diff --git a/vue/vue3/src/assets/fonts/simhei.ttf b/vue/vue3/src/assets/fonts/simhei.ttf deleted file mode 100644 index 1f1bdf8..0000000 Binary files a/vue/vue3/src/assets/fonts/simhei.ttf and /dev/null differ diff --git a/vue/vue3/src/assets/styles/font.css b/vue/vue3/src/assets/styles/font.css deleted file mode 100644 index 2591027..0000000 --- a/vue/vue3/src/assets/styles/font.css +++ /dev/null @@ -1,3 +0,0 @@ -@font-face { - font-family: "Noto Sans SC-Regular"; font-style: normal; src: url('@/assets/fonts/NotoSansSC-VariableFont_wght_2.ttf') - } \ No newline at end of file diff --git a/vue/vue3/src/assets/styles/global.css b/vue/vue3/src/assets/styles/global.css deleted file mode 100644 index 6379d48..0000000 --- a/vue/vue3/src/assets/styles/global.css +++ /dev/null @@ -1,26 +0,0 @@ -* { - box-sizing: border-box; - margin: 0; - padding: 0; -} - -ol,ul,menu { - padding-inline-start: 0; - list-style: none; -} - -ol li::marker, ul li::before { - letter-spacing: 0; -} - -.scroll-container > div { - width: 100%; -} - -.container > div { - width: 100%; -} - -.Pixso-canvas-0_1 > div { - width: 100%; -} \ No newline at end of file diff --git a/vue/vue3/src/main.ts b/vue/vue3/src/main.ts deleted file mode 100644 index 673a51c..0000000 --- a/vue/vue3/src/main.ts +++ /dev/null @@ -1,16 +0,0 @@ -import './assets/styles/font.css'; -import './assets/styles/global.css' -import { createApp } from 'vue' -import './styles.css' -import './assets/styles/font.css' -import App from './App.vue' -import { router } from './router' - -createApp(App).use(router).mount('#app') - - -declare global { - interface Window { - app: any; - } -} diff --git a/vue/vue3/src/router/index.ts b/vue/vue3/src/router/index.ts deleted file mode 100644 index 639868a..0000000 --- a/vue/vue3/src/router/index.ts +++ /dev/null @@ -1,22 +0,0 @@ - -import { createRouter, createWebHistory , type RouteRecordRaw } from "vue-router"; - -const routes: RouteRecordRaw[] = [{path: "/", name: "Frame21", component: () => import("@/views/Frame21.vue"), meta: { guid: "2:1" }},]; - -const routePathMap = new Map(); - -export const getRoutePathByGuid = (guid: string) => { - if (!guid) return; - if (routePathMap.has(guid)) return routePathMap.get(guid); - - const route = routes.find((item) => item.meta?.guid === guid); - if (!route) return; - routePathMap.set(guid, route.path); - - return route.path; -} - -export const router = createRouter({ - history: createWebHistory(), - routes, -}); diff --git a/vue/vue3/src/style.css b/vue/vue3/src/style.css deleted file mode 100644 index f1513d2..0000000 --- a/vue/vue3/src/style.css +++ /dev/null @@ -1,16 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -body { - height: 100vh; - width: 100vw; - overflow: hidden; -} - -#app { - height: 100%; - width: 100%; -} diff --git a/vue/vue3/src/styles.css b/vue/vue3/src/styles.css deleted file mode 100644 index b836ccc..0000000 --- a/vue/vue3/src/styles.css +++ /dev/null @@ -1,18 +0,0 @@ - -* { - margin: 0; - padding: 0; - box-sizing: border-box; - word-break: break-word; -} - -body { - height: 100vh; - width: 100vw; - overflow: hidden; -} - -#app { - height: 100%; - width: 100%; -} diff --git a/vue/vue3/src/views/Frame21.vue b/vue/vue3/src/views/Frame21.vue deleted file mode 100644 index 5e6711b..0000000 --- a/vue/vue3/src/views/Frame21.vue +++ /dev/null @@ -1,317 +0,0 @@ - - - diff --git a/vue/vue3/src/vite-env.d.ts b/vue/vue3/src/vite-env.d.ts deleted file mode 100644 index 657a1c9..0000000 --- a/vue/vue3/src/vite-env.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -declare module "*.vue" { - import { defineComponent } from "vue"; - - const component: ReturnType; - export default component; -} diff --git a/vue/vue3/tsconfig.app.json b/vue/vue3/tsconfig.app.json deleted file mode 100644 index 7d07dd7..0000000 --- a/vue/vue3/tsconfig.app.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "@vue/tsconfig/tsconfig.dom.json", - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, - }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] -} diff --git a/vue/vue3/tsconfig.json b/vue/vue3/tsconfig.json deleted file mode 100644 index 1ffef60..0000000 --- a/vue/vue3/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files": [], - "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } - ] -} diff --git a/vue/vue3/tsconfig.node.json b/vue/vue3/tsconfig.node.json deleted file mode 100644 index d8838ee..0000000 --- a/vue/vue3/tsconfig.node.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2023", - "lib": ["ES2023"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "moduleDetection": "force", - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true, - "baseUrl": ".", - "paths": { - "@/*": ["src/*"], - }, - }, - "include": ["vite.config.ts"] -} diff --git a/vue/vue3/vite.config.ts b/vue/vue3/vite.config.ts deleted file mode 100644 index eef4f09..0000000 --- a/vue/vue3/vite.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' - -// https://vite.dev/config/ -export default defineConfig({ - plugins: [vue()], - resolve: { - alias: { - '@': '/src', - }, - }, -})