Skip to content

armgit / SOMA

Public Imported from GitHub
0

Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice

App: echter fetter Schnitt der Terminalschrift

Kai-Jungsthoefel1a16d55e52bb
diff --git a/app/esbuild.config.mjs b/app/esbuild.config.mjs
index fd31a75..05b4199 100644
--- a/app/esbuild.config.mjs
+++ b/app/esbuild.config.mjs
@@ -35,7 +35,7 @@ fs.copyFileSync(path.join('node_modules', 'pdfjs-dist', 'LICENSE'), 'dist/render
// Schriften liegen lokal bei (die Content-Security-Policy erlaubt nur eigene Dateien, offline muss es auch gehen).
// IBM Plex steht unter der SIL Open Font License.
fs.mkdirSync('dist/renderer/fonts', { recursive: true });
-for (const [pkg, weights] of [['ibm-plex-sans', [400, 500, 600]], ['ibm-plex-mono', [400, 500]]]) {
+for (const [pkg, weights] of [['ibm-plex-sans', [400, 500, 600]], ['ibm-plex-mono', [400, 500, 700]]]) {
for (const w of weights) {
for (const subset of ['latin', 'latin-ext']) {
const file = `${pkg}-${subset}-${w}-normal.woff2`;
diff --git a/app/src/renderer/style.css b/app/src/renderer/style.css
index 9a02c92..5684143 100644
--- a/app/src/renderer/style.css
+++ b/app/src/renderer/style.css
@@ -7,11 +7,13 @@
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); }
+@font-face { font-family: 'IBM Plex Mono'; font-weight: 700; src: url(fonts/ibm-plex-mono-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; src: url(fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; src: url(fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; src: url(fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; src: url(fonts/ibm-plex-mono-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; src: url(fonts/ibm-plex-mono-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
+@font-face { font-family: 'IBM Plex Mono'; font-weight: 700; src: url(fonts/ibm-plex-mono-latin-ext-700-normal.woff2) format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
color-scheme:dark; /* nur dunkles Farbschema: Scrollleisten und Eingabefelder des Systems passen sich an */
diff --git a/app/src/renderer/terminals.ts b/app/src/renderer/terminals.ts
index b02fe67..f90d871 100644
--- a/app/src/renderer/terminals.ts
+++ b/app/src/renderer/terminals.ts
@@ -6,6 +6,13 @@ import { el } from './ui';
interface Tab { id: number; term: Terminal; fit: FitAddon; pane: HTMLElement; tab: HTMLElement; title: string; agent: boolean; exited: boolean }
+/**
+ * Normaler und fetter Schnitt der Terminalschrift, vorab geladen (beide Teilmengen, deshalb „aā“). Ohne echten fetten
+ * Schnitt rechnet Chromium das Fett nach, im DOM-Renderer sitzen runde Zeichen dann einen Pixel tiefer als gerade.
+ * WebGL legt Zeichen beim ersten Zeichnen in seinen Glyphen-Speicher, ein erst dann geladener Schnitt käme zu spät.
+ */
+const fontsReady = Promise.all(['400', '700'].map((w) => document.fonts.load(`${w} 13px "IBM Plex Mono"`, 'aā').catch(() => [])));
+
/**
* Terminal-Tabs (xterm.js). Jedes Terminal ist eine normale Shell im Projektordner (E19), Agenten laufen darin.
* Eingeklappt zeigt der Bereich nur eine schmale Leiste mit den Tabs, die Terminals laufen weiter.
@@ -32,9 +39,12 @@ export class TerminalTabs {
}
async add(opts: { command?: string; title?: string } = {}): Promise<number> {
+ // Vor dem Anlegen der Shell warten: Danach darf bis zum Eintrag in `tabs` nichts mehr warten, sonst gehen Ausgaben verloren
+ await fontsReady;
const id = await window.soma.term.create({ command: opts.command });
const term = new Terminal({
fontFamily: '"IBM Plex Mono", "Cascadia Mono", Consolas, monospace', fontSize: 13, lineHeight: 1, cursorBlink: true, scrollback: 5000,
+ fontWeight: '400', fontWeightBold: '700',
theme: { background: '#0f1114', foreground: '#c9ced4', cursor: '#e6e8eb', selectionBackground: 'rgba(242,154,56,0.30)', black: '#1b1e23', brightBlack: '#7f8994' },
});
const fit = new FitAddon();
diff --git a/app/test/smoke.mjs b/app/test/smoke.mjs
index 0fa0cd2..871fe29 100644
--- a/app/test/smoke.mjs
+++ b/app/test/smoke.mjs
@@ -106,6 +106,9 @@ try {
// 3) Terminal: echte Shell im Projektordner, soma im PATH
const tid = await ev(() => window.__t.terminals.activeId);
check('Ein Terminal wurde automatisch geöffnet', await ev(() => window.__t.terminals.count) === 1);
+ // Ohne echten fetten Schnitt rechnet Chromium das Fett nach, runde Zeichen sitzen dann einen Pixel tiefer
+ check('Terminalschrift: fett ist der echte Schnitt 700, vor dem Terminal geladen', await ev((id) => window.__t.terminals.tabs.get(id).term.options.fontWeightBold === '700'
+ && [...document.fonts].some((f) => f.family.includes('IBM Plex Mono') && f.weight === '700' && f.status === 'loaded'), tid));
await ev((id) => window.soma.term.write(id, 'soma --version\r'), tid);
const gotVersion = await waitFor('soma --version im Terminal', (id) => /^soma \d/m.test(window.__t.termText(id)), 20000, tid).catch(() => false);
check('Im Terminal läuft `soma` (PATH der Basisumgebung)', !!gotVersion);