Skip to content

Commit

Permalink
Bump levels and use fallback font for author when necessary (#13)
Browse files Browse the repository at this point in the history
1. Update levels.
2. Check if the author name uses characters not in goodtimes font; if so, use the fallback font.
3. Bump version to 1.04.
  • Loading branch information
ywnico authored Dec 11, 2023
1 parent a3ec5e4 commit 853d46a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions flowit-vita/app_skeleton/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ end
default_font_name = "good-times-rg.ttf"
number_font_name = "good-times-rg.ttf"
message_font_name = "LiberationSans-Regular.ttf" -- readable font for dialog text
fallback_font_name = "SourceHanSansHW-VF.ttf" -- fallback for characters not in good-times-rg

if (lang_code == "ja") or (lang_code == "ko") or (lang_code == "zh_t") or (lang_code == "zh_s") then
default_font_name = "SourceHanSansHW-VF.ttf"
Expand Down
2 changes: 1 addition & 1 deletion levels
Submodule levels updated 1 files
+375 −0 levelsCommunity.xml
8 changes: 7 additions & 1 deletion lib/game_drawing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,13 @@ function draw_info()
end

if (author ~= nil) then
draw_text(x_offset, 95 + y_offset, VG.font_author, author, "t", default_font_name)

local author_font_name = default_font_name
if (needsFallbackFont(author)) then
author_font_name = fallback_font_name
end

draw_text(x_offset, 95 + y_offset, VG.font_author, author, "t", author_font_name)
end

draw_text(x_offset, 115 + author_y_offset + y_offset, VG.font_small, get_i18n("moves:"), "t", default_font_name)
Expand Down
12 changes: 12 additions & 0 deletions lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ end
function round(n)
return math.floor(n+0.5)
end

-- Given a string, return true if it should be rendered in the fallback font and
-- false if it should be rendered in the default font (goodtimes).
-- Goodtimes has < 400 characters, so we just check directly instead of using
-- any font utils.
function needsFallbackFont(str)
local non_goodtimes = "[^ !\"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\%]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¥¦§¨©ª«®¯°±²³´¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĊċČčĎďĐđĒēĔĕĖėĘęĚěĞğĠġĢģĦħĪīĬĭĮįİıIJijĶķĹĺĻļĽľĿŀŁłŃńŅņŇňŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžȘșȚțˆˇ˘˙˚˛˜˝̦ẀẁẂẃẄẅỲỳ–—‘’‚“”„†‡•…‰‹›⁄⁰⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅]"
if (string.match(str, non_goodtimes)) then
return true
end
return false
end
2 changes: 1 addition & 1 deletion lib/version.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-- Flowit-vita version (not the same as the version on the upstream Flowit app for Android)
version_str = "1.03"
version_str = "1.04"
1 change: 1 addition & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ end
default_font_name = "good-times-rg.ttf"
number_font_name = "good-times-rg.ttf"
message_font_name = "LiberationSans-Regular.ttf" -- readable font for dialog text
fallback_font_name = "SourceHanSansHW-VF.ttf" -- fallback for characters not in good-times-rg

if (lang_code == "ja") or (lang_code == "ko") or (lang_code == "zh_t") or (lang_code == "zh_s") then
default_font_name = "SourceHanSansHW-VF.ttf"
Expand Down

0 comments on commit 853d46a

Please sign in to comment.