Back to index

plt-scheme  4.2.1
Public Member Functions | Public Attributes
wxSuffixMap Class Reference

List of all members.

Public Member Functions

void Initialize (const char *, const char *, int weight, int style, int fam)
 wxSuffixMap ()

Public Attributes

char * map [wxNUM_WEIGHTS][wxNUM_STYLES]

Detailed Description

Definition at line 244 of file FontDirectory.cxx.


Constructor & Destructor Documentation

Definition at line 276 of file FontDirectory.cxx.

                         {
  int i, j;
  for (i = 0; i < wxNUM_WEIGHTS; i++) {
    for (j = 0; j < wxNUM_STYLES; j++) {
      map[i][j] = NULL;
    }
  }
}

Member Function Documentation

void wxSuffixMap::Initialize ( const char *  resname,
const char *  devresname,
int  weight,
int  style,
int  fam 
)

Definition at line 412 of file FontDirectory.cxx.

{
  const char *weight, *style;
  char *v = NULL;
  int i, drn;

  {
    switch (wt) {
    case wxWEIGHT_NORMAL:
      weight = "Medium";
      break;
    case wxWEIGHT_LIGHT:
      weight = "Light";
      break;
    case wxWEIGHT_BOLD:
      default:
      weight = "Bold";
    }
    {
      int len, closer = 0, startpos = 0;
      const char *rnames[3];

      switch (st) {
      case wxSTYLE_NORMAL:
       style = "Straight";
       break;
      case wxSTYLE_ITALIC:
       style = "Italic";
       break;
      case wxSTYLE_SLANT:
      default:
       style = "Slant";
      }

      rnames[0] = resname;
      rnames[1] = weight;
      rnames[2] = style;
      
      SearchResource(devresname, rnames, 3, &v);

      /* Expand macros in the found string: */
    found:
      len = (v ? strlen(v) : 0);
      for (i = 0; i < len; i++) {
       if (v[i] == '$' && ((v[i+1] == '[') || (v[i+1] == '{'))) {
         startpos = i;
         if (v[i+1] == '[')
           closer = ']';
         else
           closer = '}';
         i++;
       } else if (v[i] == closer) {
         int newstrlen, noff;
         const char *r = NULL;
         char *naya, *name;
         
         noff = startpos + 2;
         name = v;
         v[i] = 0;

         if (closer == '}') {
           int i, count, len;
           char **names;

           for (i = 0, count = 1; name[i + noff]; i++) {
             if (name[i + noff] == ',') {
              count++;
              name[i + noff] = 0;
             }
           }
           
           len = i;

           names = new WXGC_PTRS char*[count];

           {
             char *cs;
             cs = COPYSTRING_TO_ALIGNED(name, noff);
             names[0] = cs;
           }
           for (i = 0, count = 1; i < len; i++) {
             if (!name[i + noff]) {
              {
                char *cs;
                cs = COPYSTRING_TO_ALIGNED(name, i + 1 + noff);
                names[count++] = cs;
              }
             }
           }

           SearchResource("", (const char **)names, count, (char **)&r);

           if (!r) {
             for (i = 0; i < len; i++) {
              if (!name[i + noff])
                name[i + noff] = ',';
             }
             r = "";
             printf("Bad resource name \"%s\" in font lookup\n", name + noff);
           }
         } else if (!strcmp(name + noff, "weight")) {
           r = weight;
         } else if (!strcmp(name + noff, "style")) {
           r = style;
         } else if (!strcmp(name + noff, "family")) {
           switch (fam) {
           case wxSYSTEM:
             r = "System";
             break;
           case wxDECORATIVE:
             r = "Decorative";
             break;
           case wxROMAN:
             r = "Roman";
             break;
           case wxMODERN:
             r = "Modern";
             break;
           case wxTELETYPE:
             r = "Teletype";
             break;
           case wxSWISS:
             r = "Swiss";
             break;
           case wxSCRIPT:
             r = "Script";
             break;
           case wxSYMBOL:
             r = "Symbol";
             break;
           default:
             r = "Default";
           }
         } else {
           r = "";
           printf("Bad font macro name \"%s\"\n", name + noff);
         }
         newstrlen = strlen(r);

         naya = new WXGC_ATOMIC char[len + newstrlen + 1];
         memcpy(naya, v, startpos);
         memcpy(naya + startpos, r, newstrlen);
         memcpy(naya + startpos + newstrlen, v + i + 1, len - i + 1);

         v = naya;

         goto found;
       }
      }

      drn = ((resname[0] == '@') ? 1 : 0);

#if defined(wx_msw) || defined(wx_mac)
      if (!v)
       v = copystring(resname + drn);
#endif
#ifdef wx_x
      if (!strcmp(devresname, "Screen")) {
       if (v && (v[0] == '+')) {
         memmove(v, v + 1, strlen(v));
       } else {
         int len, ds;
         char *src;
         char *normalcy;
         /* Build name using special heuristics:
            -([^-]*) => -*-\1-<weight>-<style>-normal-*-*-%d-*-*-*-*-*-*
            -([^-]*)-(.*) => -\1-\2-<weight>-<style>-normal-*-*-%d-*-*-*-*-*-*
            ([^-].*[^-]) => \1
            */

         if (v) {
           src = (char *)v;
           ds = 0;
         } else {
           src = (char *)resname;
           ds = drn;
         }

         len = strlen(src XFORM_OK_PLUS ds);
         if (src[ds] == '-') {
           char *prefix;
           int c = 0;
           for (i = 0; i < len; i++) {
             if (src[ds + i] == '-')
              c++;
           }
           
           v = new WXGC_ATOMIC char[len + 40];
           if (c < 2)
             prefix = "-*";
           else
             prefix = "";
           
           if (c < 3) {
             switch (wt) {
             case wxWEIGHT_NORMAL:
              weight = "-medium";
              break;
             case wxWEIGHT_LIGHT:
              weight = "-light";
              break;
             case wxWEIGHT_BOLD:
             default:
              weight = "-bold";
             }
           } else
             weight = "";
           
           if (c < 4) {
             switch (st) {
             case wxSTYLE_NORMAL:
              style = "-r";
             break;
             case wxSTYLE_ITALIC:
              style = "-i";
              break;
             case wxSTYLE_SLANT:
             default:
              style = "-o";
             }
           } else
             style = "";
           
           if (c < 5)
             normalcy = "-normal";
           else
             normalcy = "";
           
           sprintf(v, "%s%s%s%s%s-*-*-%%d-*-*-*-*-*-*",
                  prefix, src + ds, weight, style, normalcy);
         } else
           v = COPYSTRING_TO_ALIGNED(src, ds);
       }
      }
#endif

      /* We have a final value: */
      map[wt][st] = v;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 246 of file FontDirectory.cxx.


The documentation for this class was generated from the following file: