The International Simutrans Forum

 

Author Topic: Fix for font path label  (Read 366 times)

0 Members and 1 Guest are viewing this topic.

Offline Roboron

  • Devotee
  • *
  • Posts: 329
    • Las Galácticas Aventuras de Komoyo Diga
  • Languages: ES, EN
Fix for font path label
« on: October 10, 2020, 05:06:42 PM »
Just a small fix. Font path in font selection dialog was showing path_to_userdir + path_to_font_folder, so the game was displaying weird paths (like /home/.../simutrans//usr/share/fonts). Apparently, there is no need to concat the path_to_userdir in that section of the code (or so I think), so I just removed it.

Before / After
« Last Edit: October 11, 2020, 05:31:51 PM by Roboron »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10815
  • Languages: De,EN,JP
Re: Fix for font path label
« Reply #1 on: October 11, 2020, 01:14:26 PM »
Since the savegame frame is used for all saves, I wonder if this does not break some other dialogues. Also the display on Linux seems very different that from WIndows.

Offline Roboron

  • Devotee
  • *
  • Posts: 329
    • Las Galácticas Aventuras de Komoyo Diga
  • Languages: ES, EN
Re: Fix for font path label
« Reply #2 on: October 11, 2020, 03:50:35 PM »
I fail to see where others dialogs are using that (not savegame_frame, but the expanded list of paths displayed on screen). But, if this a issue, I've come with another solution: just modify the first condition to see if parameter is a path. Comparing first character should be enough (/). If we want a solution for Windows, we could compare also "C:\", but I think you have implied that the windows version don't suffer from this.

Quote
   if (strncmp(name.c_str(),env_t::program_dir,program_dir_len) == 0
      || strncmp(name.c_str(),"/",1) == 0 ) {
      // starts with program_dir
      // or starts with "/" (is a unix path)
      tstrncpy(path_expanded, name.c_str(), FILENAME_MAX);
   }

That's it, same effect, no code removed.

A test follows (saves, themes, fonts, scenario). Curious to see that only save is a relative path.

Quote
Original path is: save/
Path expanded is: /home/rober/simutrans/save/
Original path is: /home/rober/.local/share/simutrans/themes/
Path expanded is: /home/rober/.local/share/simutrans/themes/
Original path is: /home/rober/simutrans/themes/
Path expanded is: /home/rober/simutrans/themes/
Original path is: /home/rober/.local/share/simutrans/font/
Path expanded is: /home/rober/.local/share/simutrans/font/
Original path is: /home/rober/.fonts/cantarell/
Path expanded is: /home/rober/.fonts/cantarell/
Original path is: /home/rober/.fonts/
Path expanded is: /home/rober/.fonts/
Original path is: /home/rober/.local/share/fonts/cantarell/
Path expanded is: /home/rober/.local/share/fonts/cantarell/
Original path is: /home/rober/.local/share/fonts/
Path expanded is: /home/rober/.local/share/fonts/
Original path is: /usr/share/fonts/noto-cjk/
Path expanded is: /usr/share/fonts/noto-cjk/
Original path is: /usr/share/fonts/adobe-source-code-pro/
Path expanded is: /usr/share/fonts/adobe-source-code-pro/
Original path is: /usr/share/fonts/noto/
Path expanded is: /usr/share/fonts/noto/
Original path is: /usr/share/fonts/TTF/
Path expanded is: /usr/share/fonts/TTF/
Original path is: /usr/share/fonts/cantarell/
Path expanded is: /usr/share/fonts/cantarell/
Original path is: /usr/share/fonts/gsfonts/
Path expanded is: /usr/share/fonts/gsfonts/
Original path is: /usr/share/fonts/liberation/
Path expanded is: /usr/share/fonts/liberation/
Original path is: /usr/share/fonts/
Path expanded is: /usr/share/fonts/
Original path is: /home/rober/.local/share/simutrans/pak/scenario/
Path expanded is: /home/rober/.local/share/simutrans/pak/scenario/
« Last Edit: October 11, 2020, 04:06:46 PM by Roboron »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10815
  • Languages: De,EN,JP
Re: Fix for font path label
« Reply #3 on: October 12, 2020, 12:07:35 AM »
Sorry, now I finally see the problem. Yes, your are right, that needs fixing. Thanks, done in r9276