freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] Path delimiter characters


From: Detlef Würkner
Subject: Re: [Devel] Path delimiter characters
Date: Mon, 09 Aug 2004 09:58:56 +0200

address@hidden (Masatake YAMATO) wrote:

> I read your suggestions; and wondered how to modify the code.
> Could you answer my questions?

I'll try :)

> > In src/base/ftrfork.c there exists this function
> 
> ...
> 
> The question is how ftrfork.c is useful on OS other than Unix like OS.
> 
> raccess_make_file_name is used in some of guessing functions (see ftrfork.c).
> Guessing functions are
> 
>     raccess_guess_apple_double
>     raccess_guess_apple_single
>     raccess_guess_darwin_ufs_export
>     raccess_guess_darwin_hfsplus
>     raccess_guess_vfat
>     raccess_guess_linux_cap
>     raccess_guess_linux_double
>     raccess_guess_linux_netatalk
> 
> Some of them are useful for GNU/Linux and MacOSX but not for the other OS.
> I guess functions useful for every OS are:
> 
>   raccess_guess_apple_double
>   raccess_guess_apple_single
>   raccess_guess_darwin_ufs_export(If the OS supports Windows' CIFS or Samba)
>   raccess_guess_darwin_hfsplus(Only meaningful on systems with hfs+ drivers 
> (or Macs))
>   raccess_guess_vfat
> 
> In above functions, raccess_make_file_name access is used in:
> 
>    raccess_guess_darwin_ufs_export(If the OS supports Windows' CIFS or Samba)
>    raccess_guess_darwin_hfsplus(Only meaningful on systems with hfs+ drivers 
> (or Macs))
>    raccess_guess_vfat
> 
> So I guess thses guessing functions are something to do with this separator 
> issue.
> Is this right on AmigsOS?

Well, its probably not absolutely necessary to use any of those guessing
functions in AmigaOS anyway. All existing FreeType implementations for
AmigaOS do use some sort of font installer which creates configuration
files which do contain the full path to a font file. Those font
installers do scan entire directories for available fonts so it doesnt
matter if a font is stored in e.g. dirname/fontname.otf or
dirname.resource/fontname.otf as long as the user specifies the right
directory to search for fonts during font installation.

There exist AmigaOS clients for e.g. Samba and NFS, and there exist CD
filesystems for AmigaOS which can read Mac CDs and use special
extensions for the resource fork, e.g. fontname.rs or fontname.rsrc.
As written above the filename doesnt matter as long as it is visible
(If the exporting file system would only show dirname/fontname.otf but
dirname.resource/fontname.otf would be a hidden file then AmigaOS would
really need the guessing functions).

> If only a few guessing functions are something to do with this separator 
> issue, I think
> the better modifications are
> 
> 1. Adding 4th argument(separator) to `raccess_make_file_name'
> 2. Passing SECOND_PATH_DELIMITER to raccess_make_file_name from the guessing 
> function
> 
>   static char*
>   raccess_make_file_name( FT_Memory    memory,
>                           const char  *original_name,
>                           const char  *insertion,
>                         char         separator )
>   {
>     char*        new_name;
>     char*        tmp;
>     const char*  sep_pos;
>     unsigned     new_length;
>     FT_ULong     error;
> 
>     /* Use '/' as the default separator. */
>     if ( separator == '\0' )
>       separator = '/';
>     
>     new_length = ft_strlen( original_name ) + ft_strlen( insertion );
>     if ( FT_ALLOC( new_name, new_length + 1 ) )
>       return NULL;
> 
>     tmp = ft_strrchr( original_name, separator );
>     if ( tmp )
>     {
>       ft_strncpy( new_name, original_name, tmp - original_name + 1 );
>       new_name[tmp - original_name + 1] = '\0';
>       sep_pos = tmp + 1;
>     }
>     else
>     {
>       sep_pos       = original_name;
>       new_name[0] = '\0';
>     }
> 
>     ft_strcat( new_name, insertion );
>     ft_strcat( new_name, sep_pos );
> 
>     return new_name;
>   }

That would not work with AmigaOS. Did choose "SECOND_PATH_DELIMITER"
and not "OTHER_PATH_DELIMITER" as name because AmigaOS has the two
delimiters '/' and ':' :-) Valid examples so you get an idea are e.g.

Volume:TopDirectory/SubDirectory/SubSubDirectory/File.pcf
Device:TopDirectory/SubDirectory/SubSubDirectory/File.cff
Device:File.otf
SubDirectory/File.ttc (relative to current directory)
:File.fon (in top directory of the current volume)
/File.pfr (in parent directory of the current directory)
//File.pfb (in directory two levels above the current directory)

When the part to the left of the ':' is modified by the guessing
function, AmigaOS shows a requester "Please insert volume
[modified volume name] in any drive".

A good solution that would probably also work with Windows
(which IIRC uses ':', '/' and '\\' as path delimiters) would be
a function that gets a list of path delimiter characters (e.g. a
simple string of chars) defined in a config header file and that
would search for the last occurence of any of those delimiters
in the path string. A suggestion (untested):

  static char*
  raccess_make_file_name( FT_Memory    memory,
                          const char  *original_name,
                          const char  *insertion )
  {
    char*        new_name;
    char*        tmp;
    char*        separator;
    char*        last_separator = NULL;
    const char*  part2;
    unsigned     new_length;
    FT_ULong     error;

    new_length = ft_strlen( original_name ) + ft_strlen( insertion );
    if ( FT_ALLOC( new_name, new_length + 1 ) )
      return NULL;

    for ( separator = FT_PATH_SEPARATORS; *separator != '\0'; separator++ )
    {
      tmp = ft_strrchr( original_name, *separator );
      if ( tmp > last_separator )
        last_separator = tmp;
    }
    if ( last_separator )
    {
      ft_strncpy( new_name, original_name, last_separator - original_name + 1 );
      new_name[last_separator - original_name + 1] = '\0';
      part2 = last_separator + 1;
    }
    else
    {
      part2       = original_name;
      new_name[0] = '\0';
    }

    ft_strcat( new_name, insertion );
    ft_strcat( new_name, part2 );

    return new_name;
  }

which could be used with e.g.

#define FT_PATH_SEPARATORS "/"    /* Unix    */
#define FT_PATH_SEPARATORS ":/\\" /* Windows */
#define FT_PATH_SEPARATORS ":\\"  /* MS-DOS  */
#define FT_PATH_SEPARATORS ":/"   /* AmigaOS */

P.S.: A big SORRY, just noticed that the whole guessing functions
can easy be deacivated by not defining
FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
in ftoption.h so there exists no need to change anything in the
FreeType2 sources. My apologies.

Ciao, Detlef
-- 
_ // address@hidden
\X/  Detlef Wuerkner, Langgoens/Germany



reply via email to

[Prev in Thread] Current Thread [Next in Thread]