CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.68k stars 4.19k forks source link

Android requires full path to terminus added to generated config/fonts.json #72922

Open oosyrag opened 7 months ago

oosyrag commented 7 months ago

Describe the bug

Android defaults to unifont because it requires the full path to terminus (see https://github.com/CleverRaven/Cataclysm-DDA/issues/63871#issuecomment-1452831314). The fonts.json config file generates with relative paths for terminus and unifont, and then the full path to unifont is added, but not the full path to terminus.

This is the contents of a generated fonts.json on Android, latest experimental:

{
  "typeface": [ "data/font/Terminus.ttf", "data/font/unifont.ttf", "/storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/data/font/unifont.ttf" ],
  "map_typeface": [ "data/font/Terminus.ttf", "data/font/unifont.ttf", "/storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/data/font/unifont.ttf" ],
  "overmap_typeface": [ "data/font/Terminus.ttf", "data/font/unifont.ttf", "/storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/data/font/unifont.ttf" ]
}

/storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/data/font/Terminus.ttf needs to be added ahead of the unifont entry.

Attach save file

N/A

Steps to reproduce

Install on Android, run game, see unifont.

Expected behavior

Install on Android, run game, see terminus.

Screenshots

Default (unifont)

Screenshot_2024-04-09-00-48-46-07_6fe8938556442e3d4f710ab4f9a16601

I can get terminus to show up by either adding the full path to terminus to the front of the list in fonts.json (/storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/data/font/Terminus.ttf), OR by directly renaming/replacing the unifont.ttf file with Terminus.ttf,

Screenshot_2024-04-09-00-50-37-52_6fe8938556442e3d4f710ab4f9a16601

Versions and configuration

OS: Android OS Version: Manufacturer: OnePlus; Model: HD1900; Release: 12; Incremental: Q.202303230244; Game Version: cdda-experimental-2024-04-07-0018 84dae0b [64-bit] Graphics Version: Tiles Game Language: System language [] Mods loaded: [ Dark Days Ahead [dda], Disable NPC Needs [no_npc_food], Portal Storms Ignore NPCs [personal_portal_storms], Slowdown Fungal Growth [no_fungal_growth] ]

Additional context

oosyrag commented 7 months ago

There's a function in font_loader.cpp line 8 that dynamically adds the path to unifont to the back of the list if it doesn't find the path to unifont already in the list. In the newer Android versions I'm guessing "data/font/unifont.ttf" doesn't count, so this function appends the full, correct unifont path (for Android, "/storage/emulated/0/Android/data/com.cleverraven.cataclysmdda.experimental/files/data/font/unifont.ttf"). No such functionality for terminus though.

ed: To clarify, the "ensure_unifont_loaded()" function works as intended by adding the correct valid path to unifont in Android, because the existing paths to the two fonts are invalid.

oosyrag commented 7 months ago

@ZhilkinSerg can you take a look at this when you get a chance? Basically I would like to not have the path specified in fontdata.json, only the name, and use PATH_INFO::fontdir() instead to get and write the correct path to fonts.json for Android. But I saw you did the opposite in #45319 and I'm not really certain I understand the change, so I wanted to ask.