下面的代码片段效果很好,但是我想稍微优化一下,我在顶部指定字体列表。现在我必须在顶部指定以及每次再次给出相同的字体名称时调用函数。如何将这些字体分组在顶部,然后调用函数来读取每个元素?我不确定如何在 shell 脚本中做到这一点(OSX,但我认为它非常接近常见的 unix shell)
# font list
MENU_ENGRUSFRA=("menu-engrusfra" "menu-engrusfra")
DASHBOARD_1=("dashboard-1" "dashboard-1")
# ... more goes here
process_ipad() {
fontarr=("${!1}")
project=${fontarr[0]}${PROJECT_EXT}
hdfnt=${fontarr[1]}${HD_SUFFIX_IPAD}
sdfnt=${fontarr[1]}
# create HD .fnt
GDCL $project $OUTPUT_IPAD_DIR$hdfnt
# need arm conv for HD?
contains $hdfnt "arm" && $ARM_CONV $OUTPUT_IPAD_DIR$hdfnt$FNT_EXT
# create SD .fnt
GDCL $project $OUTPUT_IPAD_DIR$sdfnt -rfs 0.5
# need arm conv for SD?
contains $sdfnt "arm" && $ARM_CONV $OUTPUT_IPAD_DIR$sdfnt$FNT_EXT
echo "Done $sdfnt"
}
process_ipad MENU_ENGRUSFRA[@]
process_ipad DASHBOARD_1[@]
# sadly I have to mention here them as well