feat(launcher): 字体扫描迁移三级目录 (agent-193) — <family>/<weight>/<tier>/ 支持(两级向后兼容); FONT_PRESETS_MAX 17→64; 设置页 family→weight 两级不变,同weight多tier按加载大字库开关选档(关=common优先/开=gbk优先); index 落盘含三级条目
launcher ab8e610f→d3cae88b; test_font_tier/test_font_weight PASS 已知缺口: SDK meow_font.c MEOW_FONT_INDEX_MAX=32 截断(>32套需同步提); S_NET_MAX=8 family 上限; default 字体仍两级
This commit is contained in:
1 parent
6603e6686c
commit
3fd4726198
5 files changed
+366
-54
No files matched your search
@@ -824,10 +824,34 @@ ddone:
|
||||
}
|
||||
|
||||
|
||||
/* ---- 字体行「family→字重」两级子菜单(M2.6 字重结构)----
|
||||
/* 三级 (family,weight) 下多 tier 的选档偏好分(越大越优先;设置页写 font.file/class 值用)。
|
||||
* 关(font.load_full=0)→ common 优先(回退 gbk→full);开 → gbk 优先(回退 full→common)。 */
|
||||
static int font_tier_pick_rank(const char *tier, int load_full)
|
||||
{
|
||||
int is_common = tier && !strcmp(tier, "common");
|
||||
int is_gbk = tier && !strcmp(tier, "gbk");
|
||||
int is_full = tier && !strcmp(tier, "full");
|
||||
if (!load_full) {
|
||||
if (is_common) return 3;
|
||||
if (is_gbk) return 2;
|
||||
if (is_full) return 1;
|
||||
return 0;
|
||||
}
|
||||
if (is_gbk) return 3;
|
||||
if (is_full) return 2;
|
||||
if (is_common) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ---- 字体行「family→字重」两级子菜单(M2.6 字重结构;M2.8 三级适配)----
|
||||
* 一级:列出扫描到的去重 family(class 行首项「跟随全局」=空值);选 family 后自动进入
|
||||
* 二级:该 family 的可用字重(regular/bold/italic…)。选中写 out_val = 卡根相对路径
|
||||
* MeowOS/fonts/<family>/<weight>/font.png(或 class 行「跟随全局」=空串)。
|
||||
* MeowOS/fonts/<family>/<weight>/font.png(两级)或 .../<family>/<weight>/<tier>/font.png(三级,
|
||||
* 或 class 行「跟随全局」=空串)。
|
||||
* M2.8 三级冲突:同 (family,weight) 出现多个 tier → 选择器仍为 family→weight 两级、不新增 tier
|
||||
* 级菜单;每 weight 只显一行(代表 = 按「当前加载大字库」开关选档:关=common 优先、开=gbk 优先,
|
||||
* 见 font_tier_pick_rank),写值 = 该代表 tier 的卡根相对路径。
|
||||
* 复用 s_dd_modal(与 WiFi/关于 同款模态)。返回 1=已选中(out_val 已填),0=取消。 */
|
||||
static int s_font_dropdown(const srow_t *r, char *out_val, int vlen)
|
||||
{
|
||||
@@ -868,21 +892,47 @@ static int s_font_dropdown(const srow_t *r, char *out_val, int vlen)
|
||||
if (is_cls && pick == 0) { snprintf(out_val, vlen, ""); return 1; } /* 跟随全局 */
|
||||
const char *fam = fam_slug[pick];
|
||||
|
||||
/* ---- 二级:该 family 的字重列表(值=完整卡根相对路径,显示=label)---- */
|
||||
/* ---- 二级:该 family 的字重列表(去重:同 (family,weight) 只显一行)----
|
||||
* 三级结构下同 (family,weight) 出现多个 tier(common/gbk/full)→ 不新增 tier 级菜单,按
|
||||
* 「当前加载大字库」开关定档:关=common 优先、开=gbk 优先(font_tier_pick_rank)。 */
|
||||
int load_full = 0;
|
||||
meow_settings_get_switch("font.load_full", &load_full);
|
||||
char wt_pick[S_NET_MAX][32]; /* 该行代表的 weight slug */
|
||||
int wt_rank[S_NET_MAX]; /* 该行当前档位偏好分(保留最高分 tier 为行代表) */
|
||||
char wt_val[S_NET_MAX][MEOW_SET_MAX_LEN];
|
||||
char wt_text[S_NET_MAX][96];
|
||||
int wn = 0;
|
||||
for (int i = 0; i < font_presets_n && wn < S_NET_MAX; i++) {
|
||||
for (int i = 0; i < font_presets_n; i++) {
|
||||
if (!font_preset_fams[i] || strcmp(font_preset_fams[i], fam)) continue;
|
||||
snprintf(wt_val[wn], sizeof wt_val[0], "%s", font_presets[i]);
|
||||
snprintf(wt_text[wn], sizeof wt_text[0], "%s", font_preset_labels[i]);
|
||||
wn++;
|
||||
const char *wt = font_preset_wts[i] ? font_preset_wts[i] : "regular";
|
||||
const char *tier = font_preset_tiers[i] ? font_preset_tiers[i] : "common";
|
||||
int rank = font_tier_pick_rank(tier, load_full);
|
||||
int slot = -1;
|
||||
for (int k = 0; k < wn; k++) if (!strcmp(wt_pick[k], wt)) { slot = k; break; }
|
||||
if (slot < 0) {
|
||||
if (wn >= S_NET_MAX) break;
|
||||
snprintf(wt_pick[wn], sizeof wt_pick[0], "%s", wt);
|
||||
wt_rank[wn] = -1;
|
||||
slot = wn; wn++;
|
||||
}
|
||||
if (rank > wt_rank[slot]) { /* 保留档位偏好最高的一套作为该 weight 行代表 */
|
||||
wt_rank[slot] = rank;
|
||||
snprintf(wt_val[slot], sizeof wt_val[0], "%s", font_presets[i]);
|
||||
snprintf(wt_text[slot], sizeof wt_text[0], "%s", font_preset_labels[i]);
|
||||
}
|
||||
}
|
||||
if (wn <= 0) return 0; /* 该 family 无字重(理论不出现:能进 family 必已探到字重) */
|
||||
const char *witem[S_NET_MAX];
|
||||
for (int i = 0; i < wn; i++) witem[i] = wt_text[i];
|
||||
/* 当前位置高亮:按当前 font.file 的 (family,weight) 命中所显示 weight 行(不依赖 tier 精确匹配,
|
||||
* 因三级下 font.file 具体 tier 可能与该行代表 tier 不同)。 */
|
||||
int cur_wt = -1;
|
||||
for (int i = 0; i < wn; i++) if (cur[0] && !strcmp(wt_val[i], cur)) cur_wt = i;
|
||||
{
|
||||
char cfam2[64] = "", cwt2[32] = "";
|
||||
if (cur[0]) font_family_weight_from_png(cur, cfam2, sizeof cfam2, cwt2, sizeof cwt2);
|
||||
for (int i = 0; i < wn; i++)
|
||||
if (cwt2[0] && !strcmp(wt_pick[i], cwt2)) { cur_wt = i; break; }
|
||||
}
|
||||
int wp = s_dd_modal(r->label, witem, wn, cur_wt);
|
||||
if (wp < 0) return 0;
|
||||
snprintf(out_val, vlen, "%s", wt_val[wp]);
|
||||
|
||||
Reference in new issue
Block a user