home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / atap.lha / ATAP / SourceCode / FindBaseName.c < prev    next >
Text File  |  1992-06-13  |  941b  |  35 lines

  1. char *FindBaseName(char *typefaceName)
  2.  
  3. /* This pulls out a base family name from a typeface name.
  4.    This works on Adobe's principle of typeface naming with
  5.    dash marks; "AvantGarde-Demi" and "AvantGarde-Oblique"
  6.    for example, belong to the family "AvantGarde". Also,
  7.    "Helvetica" and "Helvetica-Black" belong to "Helvetica".
  8.  
  9.    Since there can be multiple hyphens in a typeface name,
  10.    like "Helvetica-Condensed-Oblique", the last hyphen is
  11.    considered and this function would return "Helvetica-Condensed". 
  12.    Get the string using strcpy(). */
  13.  
  14. {
  15. static    char    baseName[68];        
  16. static    int    index,strLength,hyphenLoc;
  17.  
  18.     strLength=strlen(typefaceName);
  19.     hyphenLoc=0;
  20.  
  21.     for (index=0;index<=strLength;index++)
  22.     {
  23.         if (typefaceName[index]=='-')
  24.             hyphenLoc=index;
  25.     }
  26.     if (hyphenLoc==0)
  27.         hyphenLoc=strLength;
  28.  
  29.     for (index=0;index<hyphenLoc;index++)
  30.         baseName[index]=typefaceName[index];
  31.     baseName[hyphenLoc]=0;
  32.  
  33.     return(baseName);
  34. };
  35.