Re: [hatari-devel] GEMDOS filename handling

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On torstai 14 elokuu 2014, Eero Tamminen wrote:
> On torstai 14 elokuu 2014, Thomas Huth wrote:
> > schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
> > > It's probably easiest to make sure the that SDL GUI font has
> > > same character table as Atari so that the same mapping can
> > > be used as what you used for GEMDOS HD emulation.
> > 
> > Please don't do that! We might want to add i18n support to the GUI
> > one day and then we certainly do not want to mess around with strings
> > in the Atari codepage there.

In case it was unclear, I wasn't suggesting changing the internal
storage for file paths (in RAM or config file) from the current
host represention (nowadays UTF-8 on Linux, something else on
Windows).  It was only about what glyps should be in the SDL GUI
font bitmap, in which order and how to use them to show strings
with 8-bit characters.

Currently SDL GUI shows Linux 8-bit UTF-8 paths with multiple
characters which is really ugly.  Because Max already provided
conversion functions, doing the conversion from host file names
to Atari charset when rendering the string is only few lines of
code [1].

However, SDL GUI font doesn't use Atari character order, but
something else.  Thomas, would it be possible to get a version
of Hatari SDL font bitmap where characters are in Atari character
order?

[1] Attached is a patch.  It's a few more lines because it
    does the conversion only when it's needed.  Most of strings
    don't have 8-bit chars, so it's a small perf win.

    Btw. When testing that, I noticed that file selector draws
    the dialog twice whenever list is scrolled...


> IMHO UTF-8 is the way to go for the GUI.

If the limited set of western glyphs available in 8-bit font
is enough and you really want SDL GUI translations, GUI string
representation could be standardized, e.g. to UTF-8.

This would mean additional conversion(s) in addition to what
I proposed.  File names would need to be converted to UTF-8
when they're read from host, and those strings would need to
be converted from UTF-8 to font bitmap indeces / encoding
(like other strings).


	- Eero
diff -r d0ef89465bc0 src/gui-sdl/sdlgui.c
--- a/src/gui-sdl/sdlgui.c	Fri Aug 15 20:38:42 2014 +0300
+++ b/src/gui-sdl/sdlgui.c	Sat Aug 16 01:14:50 2014 +0300
@@ -15,6 +15,7 @@
 #include "main.h"
 #include "screen.h"
 #include "sdlgui.h"
+#include "str.h"
 
 #include "font5x8.h"
 #include "font10x16.h"
@@ -209,6 +210,17 @@
 
 /*-----------------------------------------------------------------------*/
 /**
+ * Return zero if given string is ASCII, non-zero if it's 8-bit (Utf-8 etc)
+ */
+static int SDLGui_Is8bit(const char *txt)
+{
+	while (*txt && (unsigned char)(*txt) < 128)
+		txt++;
+	return *txt;
+}
+
+/*-----------------------------------------------------------------------*/
+/**
  * Return text length which ignores underlining.
  */
 static int SDLGui_TextLen(const char *str)
@@ -231,6 +243,14 @@
 	int i, offset;
 	unsigned char c;
 	SDL_Rect sr, dr;
+	char *changed = NULL;
+
+	if (SDLGui_Is8bit(txt)) {
+		changed = strdup(txt);
+		fprintf(stderr, "Converting: '%s'\n", txt);
+		Str_HostToAtari(txt, changed, '#');
+		txt = changed;
+	}
 
 	/* underline offset needs to go outside the box for smaller font */
 	if (sdlgui_fontheight < 16)
@@ -261,6 +281,8 @@
 		sr.h=sdlgui_fontheight;
 		SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr);
 	}
+	if (changed)
+		free(changed);
 }
 
 /*-----------------------------------------------------------------------*/


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/