forked from Blendman974/faceclaw
Fix issue where you could want up without the official Even font extracted, if you skipped onboarding
This commit is contained in:
1 parent
54005ae95a
commit
8a86cf28e1
6 files changed
+134
-8
No files matched your search
@@ -4,6 +4,7 @@
|
||||
* Preview Only mode works
|
||||
* Voice input uses phone mic in preview mode
|
||||
* Ring input on phone screen is swipe-style rather than separate buttons
|
||||
* Fix an issue where you could be missing the EvenHub font after skipping onboarding
|
||||
|
||||
## 0.6.1 - 2026-08-30
|
||||
* Settings import/export scripts work on release builds
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, ImageSource } from "@nativescript/core";
|
||||
import { EvenAIStatus, EvenAIStatusName, EventSourceType, EventSourceTypeName, OsEventTypeList, OsEventTypeName, WatchGestureType, WatchGestureTypeName } from "./events";
|
||||
import { loadDeviceAddresses } from "./device-addresses";
|
||||
import { isValidMacAddress, loadDeviceAddresses } from "./device-addresses";
|
||||
import {
|
||||
ensureBlePermissions,
|
||||
ensureVoicePermissions,
|
||||
@@ -16,6 +16,7 @@ import { onAndroidNotificationPosted } from "../native/notification-icons";
|
||||
import { openEvenAppSettings, readEvenAppNotificationState } from "../native/even-app-conflict";
|
||||
import { grayImageToPreviewSource } from "../native/gray-image-preview";
|
||||
import { firmwareIncompatibilityMessage } from "./firmware-compat";
|
||||
import { hasExtractedEvenHubFonts } from "./firmware-builder";
|
||||
import { resumeAutoReconnect, suppressAutoReconnect } from "./reconnect-policy";
|
||||
import { WearRemote, type WearRemoteInputKind } from "./wear-remote";
|
||||
|
||||
@@ -107,6 +108,7 @@ export type DashboardSnapshot = {
|
||||
firmwareWarningVisible: boolean;
|
||||
screenRecordingActive: boolean;
|
||||
batteryOptimizationWarningVisible: boolean;
|
||||
fontsMissingWarningVisible: boolean;
|
||||
/**
|
||||
* True while the headless preview display is standing in for a glasses
|
||||
* connection (preview-only mode): the mirror is live and interactive, but
|
||||
@@ -207,6 +209,10 @@ class DashboardController {
|
||||
private evenAppConflictMessage = "";
|
||||
private firmwareWarningMessage = "";
|
||||
private batteryOptimizationWarningVisible = false;
|
||||
private fontsMissingWarningVisible = false;
|
||||
// Sticky positive: the extracted-font file doesn't vanish mid-session, so a
|
||||
// successful check spares later refreshes the file read and JSON parse.
|
||||
private extractedFontsConfirmed = false;
|
||||
private screenRecordingActive = false;
|
||||
private displayPreview: ImageSource | null = createInitialDisplayPreview();
|
||||
private silentMode = false;
|
||||
@@ -905,6 +911,7 @@ class DashboardController {
|
||||
firmwareWarningVisible: this.firmwareWarningMessage.length > 0,
|
||||
screenRecordingActive: this.screenRecordingActive,
|
||||
batteryOptimizationWarningVisible: this.batteryOptimizationWarningVisible,
|
||||
fontsMissingWarningVisible: this.fontsMissingWarningVisible,
|
||||
previewMode: this.isPreviewDisplayActive(),
|
||||
};
|
||||
}
|
||||
@@ -977,8 +984,28 @@ class DashboardController {
|
||||
}, 5_000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warn when glasses are paired but the phone-side G2 fonts were never
|
||||
* extracted (the onboarding flash flow normally extracts them, but a dev
|
||||
* install or an imported config can arrive paired without them). Preview-only
|
||||
* users have no addresses configured and are never warned.
|
||||
*/
|
||||
refreshEvenHubFontStatus(): void {
|
||||
const addresses = loadDeviceAddresses();
|
||||
const paired = isValidMacAddress(addresses.right) && isValidMacAddress(addresses.left);
|
||||
if (paired && !this.extractedFontsConfirmed) {
|
||||
this.extractedFontsConfirmed = hasExtractedEvenHubFonts();
|
||||
}
|
||||
const warningVisible = paired && !this.extractedFontsConfirmed;
|
||||
if (warningVisible !== this.fontsMissingWarningVisible) {
|
||||
this.fontsMissingWarningVisible = warningVisible;
|
||||
this.emit();
|
||||
}
|
||||
}
|
||||
|
||||
refreshEvenAppStatus(): void {
|
||||
this.refreshBatteryOptimizationStatus();
|
||||
this.refreshEvenHubFontStatus();
|
||||
const state = readEvenAppNotificationState();
|
||||
const wasActive = this.evenNotificationActive;
|
||||
this.evenNotificationActive = state.evenNotificationActive;
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
} from "./firmware-fonts";
|
||||
import { fetchWithUserAgent } from "../util/http";
|
||||
import { bytesToHex, hexToBytes as hexToBytesLenient } from "../util/hex-util";
|
||||
import { EvenHubFont } from "../graphics/evenhub-font";
|
||||
|
||||
declare const com: any;
|
||||
|
||||
@@ -180,6 +181,10 @@ function persistEvenHubFonts(base: ArrayBuffer): void {
|
||||
},
|
||||
);
|
||||
if (writeError) throw writeError;
|
||||
// A degraded EvenHubFont (built before this extraction existed) is cached
|
||||
// per JS context; drop it so the next render picks up the real fonts
|
||||
// without an app restart.
|
||||
EvenHubFont.invalidate();
|
||||
} catch (error) {
|
||||
throw new FirmwareBuildError(
|
||||
`The firmware was verified, but its EvenHub fonts could not be extracted: ${(error as Error)?.message ?? error}`,
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
* firmware into app-private storage while Faceclaw prepares custom firmware.
|
||||
* They are not distributed with Faceclaw.
|
||||
* - The final fallback is the G2's serialized Source Han Sans SC Light font,
|
||||
* which Faceclaw can bundle under the SIL Open Font License.
|
||||
* which Faceclaw can bundle under the SIL Open Font License. It carries no
|
||||
* ASCII (it starts at U+00A4), so while the extracted fonts are missing a
|
||||
* bundled Roboto backstops Latin text (see TTF_FALLBACK_ASSET_PATH).
|
||||
* - Text SIZING / KERNING / WRAPPING: @evenrealities/pretext, whose advance
|
||||
* tables the bitmaps were validated against. Using pretext for measurement
|
||||
* means our line breaks match exactly where EvenHub apps (which measure
|
||||
@@ -22,11 +24,24 @@ import { getTextWidth } from "@evenrealities/pretext";
|
||||
import { EVENHUB_RUNTIME_FONT_FILENAME, isEvenHubFontAsset } from "../g2/firmware-fonts";
|
||||
import { toUint8Array } from "../util/array-util";
|
||||
import { GrayImage, grayToNibble, type FwTextFont, type PlacedFwText, type PlacedFwTextGlyph } from "./image";
|
||||
import { TtfFont } from "./ttf-font";
|
||||
|
||||
declare const com: any;
|
||||
|
||||
const CJK_ASSET_PATH = "fonts/source-han-sans/SourceHanSansSC-Light-20.lvgl.bin";
|
||||
|
||||
/**
|
||||
* Last-resort face used ONLY while the extracted firmware fonts are missing.
|
||||
* The bundled CJK partition font starts at U+00A4 with no ASCII at all (on
|
||||
* stock it sits behind the main firmware's Latin fonts), so without this an
|
||||
* un-extracted install renders Latin text as nothing. Advances still come
|
||||
* from pretext, so layout and wrapping are unchanged; only the ink is
|
||||
* Roboto's. Once the real fonts are extracted this path is disabled and
|
||||
* unknown codepoints go back to stock's silent skip.
|
||||
*/
|
||||
const TTF_FALLBACK_ASSET_PATH = "fonts/ttf/Roboto-Regular.ttf";
|
||||
const TTF_FALLBACK_SIZE_PX = 20;
|
||||
|
||||
/** [boxW, boxH, ofsX, ofsY, bitmapOffset, bitmapLen] */
|
||||
type GlyphRecord = [number, number, number, number, number, number];
|
||||
|
||||
@@ -95,8 +110,12 @@ export class EvenHubFont implements FwTextFont {
|
||||
private readonly cjkPath: string;
|
||||
private readonly cjkBaseline: number;
|
||||
private readonly cjkGlyphs = new Map<number, CjkGlyph | null>();
|
||||
/** Degraded mode: the extracted asset was missing, so Roboto backstops. */
|
||||
private readonly useTtfFallback: boolean;
|
||||
private ttfFallback: TtfFont | null | undefined;
|
||||
|
||||
private constructor(asset: FontAsset) {
|
||||
private constructor(asset: FontAsset, useTtfFallback = false) {
|
||||
this.useTtfFallback = useTtfFallback;
|
||||
this.lineHeight = asset.lineHeight;
|
||||
this.baseline = asset.baseline;
|
||||
this.bitmap = base64Decode(asset.bitmapBase64);
|
||||
@@ -124,21 +143,32 @@ export class EvenHubFont implements FwTextFont {
|
||||
if (!isEvenHubFontAsset(parsed)) throw new Error("invalid font asset structure");
|
||||
asset = parsed;
|
||||
} catch (error) {
|
||||
console.warn(`Could not load the extracted G2 fonts; using Source Han Sans only: ${error}`);
|
||||
console.warn(`Could not load the extracted G2 fonts; using fallback faces: ${error}`);
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
"The G2 fonts have not been extracted yet; using Source Han Sans only. " +
|
||||
"Reinstall Faceclaw's custom firmware to prepare the exact fallback chain.",
|
||||
"The G2 fonts have not been extracted yet; using fallback faces. " +
|
||||
"The home screen's warning flag offers to prepare them.",
|
||||
);
|
||||
}
|
||||
EvenHubFont.cached = new EvenHubFont(
|
||||
asset ?? { lineHeight: 27, baseline: 22, glyphs: {}, bitmapBase64: "" },
|
||||
asset === null,
|
||||
);
|
||||
}
|
||||
return EvenHubFont.cached;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the cached instance so the next get() re-reads the extracted asset.
|
||||
* Called after a successful firmware-font extraction: without this, a
|
||||
* degraded instance built before the extraction would keep rendering with
|
||||
* the fallback faces until the app restarts.
|
||||
*/
|
||||
static invalidate(): void {
|
||||
EvenHubFont.cached = null;
|
||||
}
|
||||
|
||||
hasGlyph(codePoint: number): boolean {
|
||||
return this.glyphs.has(codePoint) || this.getCjkGlyph(codePoint) !== null;
|
||||
}
|
||||
@@ -262,7 +292,11 @@ export class EvenHubFont implements FwTextFont {
|
||||
} else {
|
||||
flushRun();
|
||||
const cjk = this.getCjkGlyph(cp);
|
||||
if (cjk) this.drawGlyph(image, cjk.record, cjk.bitmap, penX, y + this.cjkBaseline, value);
|
||||
if (cjk) {
|
||||
this.drawGlyph(image, cjk.record, cjk.bitmap, penX, y + this.cjkBaseline, value);
|
||||
} else if (this.useTtfFallback) {
|
||||
this.drawTtfFallbackGlyph(image, cp, penX, baselineY, value);
|
||||
}
|
||||
}
|
||||
penX += this.advanceOf(cp, cps[i + 1] ?? 0);
|
||||
}
|
||||
@@ -336,6 +370,21 @@ export class EvenHubFont implements FwTextFont {
|
||||
return lines.length;
|
||||
}
|
||||
|
||||
/** Degraded-mode ink: the codepoint's Roboto glyph, aligned on our baseline. */
|
||||
private drawTtfFallbackGlyph(image: GrayImage, cp: number, penX: number, baselineY: number, value: number): void {
|
||||
if (this.ttfFallback === undefined) {
|
||||
this.ttfFallback = TtfFont.load(
|
||||
knownFolders.currentApp().getFile(TTF_FALLBACK_ASSET_PATH).path,
|
||||
TTF_FALLBACK_SIZE_PX,
|
||||
);
|
||||
}
|
||||
const font = this.ttfFallback;
|
||||
const glyph = font?.getGlyph(cp);
|
||||
if (!font || !glyph || !glyph.coverage || glyph.bbxWidth <= 0) return;
|
||||
// drawGlyph's y is the TTF line top (baseline at y + ascent).
|
||||
image.drawGlyph(font, glyph, penX, baselineY - font.ascent, value);
|
||||
}
|
||||
|
||||
private getCjkGlyph(codePoint: number): CjkGlyph | null {
|
||||
const cached = this.cjkGlyphs.get(codePoint);
|
||||
if (cached !== undefined) return cached;
|
||||
|
||||
@@ -84,6 +84,10 @@
|
||||
<Label text="Android will slow Faceclaw to a crawl when the phone screen is off unless it is exempt from battery optimization." textWrap="true" />
|
||||
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
|
||||
</StackLayout>
|
||||
<StackLayout visibility="{{ fontsMissingWarningVisibility }}" class="warnings-modal-item">
|
||||
<Label text="The G2 fonts have not been extracted, so EvenHub apps will render with fallback fonts. Preparing them downloads the official firmware to extract its fonts; your glasses are not reflashed." textWrap="true" />
|
||||
<Button text="Prepare G2 fonts" tap="{{ onPrepareFontsTap }}" class="-primary" />
|
||||
</StackLayout>
|
||||
<Button text="Close" tap="{{ onWarningsModalCloseTap }}" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
@@ -60,6 +60,7 @@ export class MainViewModel extends Observable {
|
||||
private _firmwareWarningVisible = false;
|
||||
private _screenRecordingActive = false;
|
||||
private _batteryOptimizationWarningVisible = false;
|
||||
private _fontsMissingWarningVisible = false;
|
||||
private _warningsModalVisible = false;
|
||||
private _previewMode = false;
|
||||
private _phase: "disconnected" | "connecting" | "connected" | "charging" | "disconnecting" = "disconnected";
|
||||
@@ -106,6 +107,7 @@ export class MainViewModel extends Observable {
|
||||
this.firmwareWarningVisible = snapshot.firmwareWarningVisible;
|
||||
this.screenRecordingActive = snapshot.screenRecordingActive;
|
||||
this.batteryOptimizationWarningVisible = snapshot.batteryOptimizationWarningVisible;
|
||||
this.fontsMissingWarningVisible = snapshot.fontsMissingWarningVisible;
|
||||
this.refreshPadFocusLine();
|
||||
}));
|
||||
// Brightness / display mode can change from the glasses' Settings app too.
|
||||
@@ -570,6 +572,43 @@ export class MainViewModel extends Observable {
|
||||
return this._batteryOptimizationWarningVisible ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get fontsMissingWarningVisible(): boolean {
|
||||
return this._fontsMissingWarningVisible;
|
||||
}
|
||||
|
||||
set fontsMissingWarningVisible(value: boolean) {
|
||||
if (this._fontsMissingWarningVisible !== value) {
|
||||
this._fontsMissingWarningVisible = value;
|
||||
this.notifyPropertyChange("fontsMissingWarningVisible", value);
|
||||
this.notifyPropertyChange("fontsMissingWarningVisibility", this.fontsMissingWarningVisibility);
|
||||
this.refreshWarningIndicator();
|
||||
}
|
||||
}
|
||||
|
||||
get fontsMissingWarningVisibility(): "visible" | "collapse" {
|
||||
return this._fontsMissingWarningVisible ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump back into the onboarding firmware check, whose missing-fonts path
|
||||
* downloads the stock firmware and extracts the G2 fonts without reflashing.
|
||||
* The check probes the glasses itself, so drop the main connection first;
|
||||
* like pairing, this is a detour rather than a Disconnect, so lift the
|
||||
* auto-reconnect suppression right away.
|
||||
*/
|
||||
async onPrepareFontsTap(): Promise<void> {
|
||||
this.setWarningsModalVisible(false);
|
||||
if (this.phase === "connected" || this.phase === "charging" || this.phase === "connecting") {
|
||||
try {
|
||||
await dashboardController.disconnect();
|
||||
} catch {
|
||||
// proceed anyway; the firmware check reports its own connection trouble
|
||||
}
|
||||
resumeAutoReconnect();
|
||||
}
|
||||
Frame.topmost()?.navigate({ moduleName: "phone-ui/onboarding-firmware-check-page" });
|
||||
}
|
||||
|
||||
onAllowBackgroundUsageTap(): void {
|
||||
this.setWarningsModalVisible(false);
|
||||
dashboardController.requestBatteryOptimizationExemption();
|
||||
@@ -581,7 +620,8 @@ export class MainViewModel extends Observable {
|
||||
return (
|
||||
this._evenAppConflictWarningVisible ||
|
||||
this._firmwareWarningVisible ||
|
||||
this._batteryOptimizationWarningVisible
|
||||
this._batteryOptimizationWarningVisible ||
|
||||
this._fontsMissingWarningVisible
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user