Changeset 3499 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jun 17, 2008, 4:52:49 PM (17 years ago)
Author:
mansoux
Message:

contournement pb XLoadQueryFont avec serveur X (XOrg) Mandriva - Bruno+Reza 17/06/2008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pifontx.cc

    r2615 r3499  
    289289  int count,k;
    290290  Display * mdsp = PIXDisplay();
    291   char **list;
     291  char **list = NULL;
    292292
    293293  for (k=0; k<5; k++)  {  // Recherche de la fonte pour tailles croissantes
    294294    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi_b[jat], fntsz[isz]+k);
    295295    list = XListFonts(mdsp, buff, 10, &count);
    296     XFreeFontNames(list);
    297296    if ((count <= 0) && (fnbo_b[jat] != NULL)) {
     297      if (list) XFreeFontNames(list); 
    298298      sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbo_b[jat], fntsz[isz]+k);
    299299      list = XListFonts(mdsp, buff, 10, &count);
    300       XFreeFontNames(list);
    301300    }
    302301    if (count > 0)  break;
    303     }
     302  }
    304303  // certaines fontes n'ont pas de version  bold ou italique
    305304  if ( (count == 0) && (jat > 0) ) {
    306305    for (k=0; k<5; k++)  {  // Recherche de la fonte pour tailles croissantes
     306      if (list) XFreeFontNames(list); 
    307307      sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi_b[0], fntsz[isz]+k);
    308308      list = XListFonts(mdsp, buff, 10, &count);
    309       XFreeFontNames(list);
    310309      if (count > 0)  break;
    311       }
    312310    }
    313   if (count > 0)
    314     fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, buff);
    315   else
    316     { printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff);   
    317     fntst[isz][jat][kfn] = defnt; }
     311  }
     312  if (count > 0) {
     313    for (int kkk=0; kkk<count; kkk++) {
     314      fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, list[kkk]);
     315      if (fntst[isz][jat][kfn] != NULL) break;
     316    }
     317    if (list) XFreeFontNames(list); 
     318  }
     319  else  {
     320    if (list) XFreeFontNames(list); 
     321    printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff);   
     322    fntst[isz][jat][kfn] = defnt;
     323    }
    318324  }
    319325
     
    343349                          XtNumber(resources), NULL, 0);
    344350sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam[0]);
     351list = NULL;
    345352list = XListFonts(mdsp, buff, 15, &count);
    346 XFreeFontNames(list);
    347353if (count < 5)
    348354  {
     
    350356         count, apd.fntFam[0]);
    351357  apd.fntFam[0] = "*-courier";
     358  if (list) XFreeFontNames(list);
    352359  }
    353360sprintf(buff,"-%s-%s-*-*-*-*-12-*-*-*-*", apd.fntFam[0], fnbi_b[0]);
    354361list = XListFonts(mdsp, buff, 10, &count);
    355 XFreeFontNames(list);
    356362if (count < 1) {
     363  if (list) XFreeFontNames(list);
    357364  sprintf(buff,"-*-fixed-*-*-*-*-12-*-*-*-*-*-*-*");
    358365  list = XListFonts(mdsp, buff, 10, &count);
    359   XFreeFontNames(list);
    360366  if (count < 1)   { 
     367    if (list) XFreeFontNames(list);
    361368    sprintf(buff,"fixed");
    362369    list = XListFonts(mdsp, buff, 10, &count);
    363     XFreeFontNames(list);
    364370  }
    365371  if (count < 1)   { 
     372    if (list) XFreeFontNames(list);
    366373    strcpy(buff,"");
    367374    list = XListFonts(mdsp, buff, 10, &count);
    368     XFreeFontNames(list);
    369375  }
    370376}
    371377if (count < 1) { 
     378  if (list) XFreeFontNames(list);
    372379  printf("PIFontX::Init/ Erreur, no font found ... \n");
    373380  defnt = NULL;
    374   }
    375 else defnt = XLoadQueryFont(mdsp, buff);
    376 
     381  //Reza+Bruno, 17 Juin 2008 - Il faut lancer une exception
     382  }
     383else {
     384  defnt = NULL;
     385  for (int kkk=0; kkk<count; kkk++) {
     386    defnt = XLoadQueryFont(mdsp, list[kkk]);
     387    if (defnt != NULL) break;
     388  }
     389  if (list) XFreeFontNames(list); 
     390}
    377391for (i=0; i<NMAXFONTSZ; i++)
    378392  for (j=0; j<NMAXFONTATT; j++) 
Note: See TracChangeset for help on using the changeset viewer.