iucar / rpms / root

Forked from rpms/root 3 years ago
Clone
Blob Blame History Raw
diff -ur root-5.34.20.orig/core/base/src/TApplication.cxx root-5.34.20/core/base/src/TApplication.cxx
--- root-5.34.20.orig/core/base/src/TApplication.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/core/base/src/TApplication.cxx	2014-08-16 19:24:53.337132201 +0200
@@ -265,22 +265,11 @@
    LoadGraphicsLibs();
 
    // Try to load TrueType font renderer. Only try to load if not in batch
-   // mode and Root.UseTTFonts is true and Root.TTFontPath exists. Abort silently
+   // mode and Root.UseTTFonts is true. Abort silently
    // if libttf or libGX11TTF are not found in $ROOTSYS/lib or $ROOTSYS/ttf/lib.
-   const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                       TTFFONTDIR);
-#else
-                                       "$(ROOTSYS)/fonts");
-#endif
-   char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission);
-   // Check for use of DFSG - fonts
-   if (!ttfont)
-      ttfont = gSystem->Which(ttpath, "FreeSansBold.ttf", kReadPermission);
-
 #if !defined(R__WIN32)
    if (!gROOT->IsBatch() && !strcmp(gVirtualX->GetName(), "X11") &&
-       ttfont && gEnv->GetValue("Root.UseTTFonts", 1)) {
+       gEnv->GetValue("Root.UseTTFonts", 1)) {
       if (gClassTable->GetDict("TGX11TTF")) {
          // in principle we should not have linked anything against libGX11TTF
          // but with ACLiC this can happen, initialize TGX11TTF by hand
@@ -294,7 +283,6 @@
       }
    }
 #endif
-   delete [] ttfont;
 
    // Create WM dependent application environment
    if (fAppImp)
diff -ur root-5.34.20.orig/graf2d/graf/inc/TTF.h root-5.34.20/graf2d/graf/inc/TTF.h
--- root-5.34.20.orig/graf2d/graf/inc/TTF.h	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf2d/graf/inc/TTF.h	2014-08-16 19:24:53.338132209 +0200
@@ -70,9 +70,8 @@
    static FT_BBox     fgCBox;                  // string control box
    static FT_CharMap  fgCharMap[kTTMaxFonts];  // font character map
    static Int_t       fgCurFontIdx;            // current font index
-   static Int_t       fgSymbItaFontIdx;        // Symbol italic font index
    static Int_t       fgFontCount;             // number of fonts loaded
-   static char       *fgFontName[kTTMaxFonts]; // font name
+   static Int_t       fgFontID[kTTMaxFonts];   // font ID
    static FT_Face     fgFace[kTTMaxFonts];     // font face
    static TTGlyph     fgGlyphs[kMaxGlyphs];    // glyphs
    static Bool_t      fgHinting;               // use hinting (true by default)
diff -ur root-5.34.20.orig/graf2d/graf/Module.mk root-5.34.20/graf2d/graf/Module.mk
--- root-5.34.20.orig/graf2d/graf/Module.mk	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf2d/graf/Module.mk	2014-08-16 19:24:53.338132209 +0200
@@ -46,7 +46,7 @@
 		@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \
 		   "$(SOFLAGS)" libGraf.$(SOEXT) $@ \
 		   "$(GRAFO) $(GRAFDO)" \
-		   "$(GRAFLIBEXTRA) $(MATHTEXTLIB) $(FREETYPELDFLAGS) $(FREETYPELIB)"
+		   "$(GRAFLIBEXTRA) $(MATHTEXTLIB) $(FREETYPELDFLAGS) $(FREETYPELIB) -lfontconfig"
 
 $(GRAFDS):      $(GRAFH) $(GRAFL) $(ROOTCINTTMPDEP)
 		$(MAKEDIR)
diff -ur root-5.34.20.orig/graf2d/graf/src/TTF.cxx root-5.34.20/graf2d/graf/src/TTF.cxx
--- root-5.34.20.orig/graf2d/graf/src/TTF.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf2d/graf/src/TTF.cxx	2014-08-16 20:48:07.427205257 +0200
@@ -17,15 +17,13 @@
 //                                                                      //
 //////////////////////////////////////////////////////////////////////////
 
-// RConfigure.h is needed for TTFFONTDIR
-#include "RConfigure.h"
-
 #include "TTF.h"
 #include "TSystem.h"
 #include "TEnv.h"
 #include "TMath.h"
 #include "TError.h"
 
+#include <fontconfig/fontconfig.h>
 
 // to scale fonts to the same size as the old TT version
 const Float_t kScale = 0.93376068;
@@ -40,10 +38,9 @@
 Int_t       TTF::fgWidth          = 0;
 Int_t       TTF::fgAscent         = 0;
 Int_t       TTF::fgCurFontIdx     = -1;
-Int_t       TTF::fgSymbItaFontIdx = -1;
 Int_t       TTF::fgFontCount      = 0;
 Int_t       TTF::fgNumGlyphs      = 0;
-char       *TTF::fgFontName[kTTMaxFonts];
+Int_t       TTF::fgFontID[kTTMaxFonts];
 FT_Matrix  *TTF::fgRotMatrix;
 FT_Library  TTF::fgLibrary;
 FT_BBox     TTF::fgCBox;
@@ -87,7 +84,6 @@
    if (!fgInit) return;
 
    for (int i = 0; i < fgFontCount; i++) {
-      delete [] fgFontName[i];
       FT_Done_Face(fgFace[i]);
    }
    if (fgRotMatrix) delete fgRotMatrix;
@@ -112,12 +108,15 @@
          charmap  = fgFace[fgCurFontIdx]->charmaps[i];
          platform = charmap->platform_id;
          encoding = charmap->encoding_id;
-         if ((platform == 3 && encoding == 1) ||
+         if ((platform == 3 && encoding == 1 &&
+              (fgFontID[fgCurFontIdx] != 12 && fgFontID[fgCurFontIdx] != 15)) ||
              (platform == 0 && encoding == 0) ||
              (platform == 1 && encoding == 0 &&
-              !strcmp(fgFontName[fgCurFontIdx], "wingding.ttf")) ||
+              fgFontID[fgCurFontIdx] == 14) ||
+             (platform == 7 && encoding == 2 &&
+              (fgFontID[fgCurFontIdx] == 12 || fgFontID[fgCurFontIdx] == 15)) ||
              (platform == 1 && encoding == 0 &&
-              !strcmp(fgFontName[fgCurFontIdx], "symbol.ttf")))
+              (fgFontID[fgCurFontIdx] == 12 || fgFontID[fgCurFontIdx] == 15)))
          {
             fgCharMap[fgCurFontIdx] = charmap;
             if (FT_Set_Charmap(fgFace[fgCurFontIdx], fgCharMap[fgCurFontIdx]))
@@ -381,27 +380,147 @@
 
    if (!fontname || !fontname[0]) {
       Warning("TTF::SetTextFont",
-              "no font name specified, using default font %s", fgFontName[0]);
+              "no font name specified, using default font");
       fgCurFontIdx = 0;
       return 0;
    }
    const char *basename = gSystem->BaseName(fontname);
 
+   if (strcmp(basename, "timesi.ttf") == 0 ||
+       strcmp(basename, "FreeSerifItalic.otf") == 0) {
+      SetTextFont(12);
+   }
+   else if (strcmp(basename, "timesbd.ttf") == 0 ||
+            strcmp(basename, "FreeSerifBold.otf") == 0) {
+      SetTextFont(22);
+   }
+   else if (strcmp(basename, "timesbi.ttf") == 0 ||
+            strcmp(basename, "FreeSerifBoldItalic.otf") == 0) {
+      SetTextFont(32);
+   }
+   else if (strcmp(basename, "arial.ttf") == 0 ||
+            strcmp(basename, "FreeSans.otf") == 0) {
+      SetTextFont(42);
+   }
+   else if (strcmp(basename, "ariali.ttf") == 0 ||
+            strcmp(basename, "FreeSansOblique.otf") == 0) {
+      SetTextFont(52);
+   }
+   else if (strcmp(basename, "arialbd.ttf") == 0 ||
+            strcmp(basename, "FreeSansBold.otf") == 0) {
+      SetTextFont(62);
+   }
+   else if (strcmp(basename, "arialbi.ttf") == 0 ||
+            strcmp(basename, "FreeSansBoldOblique.otf") == 0) {
+      SetTextFont(72);
+   }
+   else if (strcmp(basename, "cour.ttf") == 0 ||
+            strcmp(basename, "FreeMono.otf") == 0) {
+      SetTextFont(82);
+   }
+   else if (strcmp(basename, "couri.ttf") == 0 ||
+            strcmp(basename, "FreeMonoOblique.otf") == 0) {
+      SetTextFont(92);
+   }
+   else if (strcmp(basename, "courbd.ttf") == 0 ||
+            strcmp(basename, "FreeMonoBold.otf") == 0) {
+      SetTextFont(102);
+   }
+   else if (strcmp(basename, "courbi.ttf") == 0 ||
+            strcmp(basename, "FreeMonoBoldOblique.otf") == 0) {
+      SetTextFont(112);
+   }
+   else if (strcmp(basename, "symbol.ttf") == 0) {
+      if (italic)
+         SetTextFont(152);
+      else
+         SetTextFont(122);
+   }
+   else if (strcmp(basename, "times.ttf") == 0 ||
+            strcmp(basename, "FreeSerif.otf") == 0) {
+      SetTextFont(132);
+   }
+   else if (strcmp(basename, "wingding.ttf") == 0) {
+      SetTextFont(142);
+   }
+   else if (strcmp(basename, "STIXGeneral.otf") == 0) {
+      SetTextFont(162);
+   }
+   else if (strcmp(basename, "STIXGeneralItalic.otf") == 0) {
+      SetTextFont(172);
+   }
+   else if (strcmp(basename, "STIXGeneralBol.otf") == 0) {
+      SetTextFont(182);
+   }
+   else if (strcmp(basename, "STIXGeneralBolIta.otf") == 0) {
+      SetTextFont(192);
+   }
+   else if (strcmp(basename, "STIXSiz1Sym.otf") == 0) {
+      SetTextFont(202);
+   }
+   else if (strcmp(basename, "STIXSiz1SymBol.otf") == 0) {
+      SetTextFont(212);
+   }
+   else if (strcmp(basename, "STIXSiz2Sym.otf") == 0) {
+      SetTextFont(222);
+   }
+   else if (strcmp(basename, "STIXSiz2SymBol.otf") == 0) {
+      SetTextFont(232);
+   }
+   else if (strcmp(basename, "STIXSiz3Sym.otf") == 0) {
+      SetTextFont(242);
+   }
+   else if (strcmp(basename, "STIXSiz3SymBol.otf") == 0) {
+      SetTextFont(252);
+   }
+   else if (strcmp(basename, "STIXSiz4Sym.otf") == 0) {
+      SetTextFont(262);
+   }
+   else if (strcmp(basename, "STIXSiz4SymBol.otf") == 0) {
+      SetTextFont(272);
+   }
+   else if (strcmp(basename, "STIXSiz5Sym.otf") == 0) {
+      SetTextFont(282);
+   }
+   else if (strcmp(basename, "DroidSansFallback.ttf") == 0) {
+      SetTextFont(292);
+   }
+   else {
+      Error("TTF::SetTextFont", "font %s not known to ROOT", basename);
+      if (fgFontCount) {
+         Warning("TTF::SetTextFont", "using default font");
+         fgCurFontIdx = 0;    // use font 0 (default font, set in ctor)
+         return 0;
+      } else {
+         return 1;
+      }
+   }
+
+   return 0;
+}
+
+//______________________________________________________________________________
+void TTF::SetTextFont(Font_t fontnumber)
+{
+   int fontid = fontnumber / 10;
+   if (fontid < 0 || fontid > 31) fontid = 0;
+
+   Int_t italic = 0;
+   if (fontid==15) italic = 1;
+
+   if (!fgInit) Init();
+
+   if (fontid == 0) {
+      fgCurFontIdx = 0;  // use font 0 (default font, set in ctor)
+      return;
+   }
+
    // check if font is in cache
    int i;
    for (i = 0; i < fgFontCount; i++) {
-      if (!strcmp(fgFontName[i], basename)) {
-         if (italic) {
-            if (i==fgSymbItaFontIdx) {
-               fgCurFontIdx = i;
-               return 0;
-            }
-         } else {
-            if (i!=fgSymbItaFontIdx) {
-               fgCurFontIdx = i;
-               return 0;
-            }
-         }
+      if (fgFontID[i] == fontid) {
+         fgCurFontIdx = i;
+         return;
       }
    }
 
@@ -409,161 +528,280 @@
    if (fgFontCount >= kTTMaxFonts) {
       Error("TTF::SetTextFont", "too many fonts opened (increase kTTMaxFont = %d)",
             kTTMaxFonts);
-      Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
+      Warning("TTF::SetTextFont", "using default font");
       fgCurFontIdx = 0;    // use font 0 (default font, set in ctor)
-      return 0;
+      return;
    }
 
-   // try to load font (font must be in Root.TTFontPath resource)
-   const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-# ifdef TTFFONTDIR
-                                       TTFFONTDIR
-# else
-                                       "$(ROOTSYS)/fonts"
-# endif
-                                      );
 
-   char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
+   char *ttfont = NULL;
+   int ttindex = 0;
 
+   if (fontid >= 16 && fontid <= 28) {
+      // Use the texlive-stix fonts if they exist
+      // Texlive-stix not packaged correctly - can not be found through fontconfig
+      // Use hardcoded path
+      const char *ttpath = "/usr/share/texlive/texmf-dist/fonts/opentype/public/stix";
+      switch (fontid) {
+      case 16:
+         ttfont = gSystem->Which(ttpath, "STIXGeneral.otf", kReadPermission);
+         break;
+      case 17:
+         ttfont = gSystem->Which(ttpath, "STIXGeneralItalic.otf", kReadPermission);
+         break;
+      case 18:
+         ttfont = gSystem->Which(ttpath, "STIXGeneralBol.otf", kReadPermission);
+         break;
+      case 19:
+         ttfont = gSystem->Which(ttpath, "STIXGeneralBolIta.otf", kReadPermission);
+         break;
+      case 20:
+         ttfont = gSystem->Which(ttpath, "STIXSizOneSymReg.otf", kReadPermission);
+         break;
+      case 21:
+         ttfont = gSystem->Which(ttpath, "STIXSizOneSymBol.otf", kReadPermission);
+         break;
+      case 22:
+         ttfont = gSystem->Which(ttpath, "STIXSizTwoSymReg.otf", kReadPermission);
+         break;
+      case 23:
+         ttfont = gSystem->Which(ttpath, "STIXSizTwoSymBol.otf", kReadPermission);
+         break;
+      case 24:
+         ttfont = gSystem->Which(ttpath, "STIXSizThreeSymReg.otf", kReadPermission);
+         break;
+      case 25:
+         ttfont = gSystem->Which(ttpath, "STIXSizThreeSymBol.otf", kReadPermission);
+         break;
+      case 26:
+         ttfont = gSystem->Which(ttpath, "STIXSizFourSymReg.otf", kReadPermission);
+         break;
+      case 27:
+         ttfont = gSystem->Which(ttpath, "STIXSizFourSymBol.otf", kReadPermission);
+         break;
+      case 28:
+         ttfont = gSystem->Which(ttpath, "STIXSizFiveSymReg.otf", kReadPermission);
+         break;
+      }
+   }
    if (!ttfont) {
-      Error("TTF::SetTextFont", "font file %s not found in path", fontname);
-      if (fgFontCount) {
-         Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
+      FcPattern *pat, *match;
+      FcCharSet *set = NULL;
+      FcResult result;
+
+      pat = FcPatternCreate ();
+
+      switch (fontid) {
+      case 1:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 2:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 3:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 4:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 5:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 6:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 7:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 8:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 9:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 10:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 11:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 12:
+      case 15:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"symbol");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 13:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 14:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"wingdings");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 16:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 17:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 18:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 19:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+         break;
+      case 20:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizeonesym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize1");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         // set = FcCharSetCreate ();
+         // FcCharSetAddChar (set, 0x239b); // Bracket pieces
+         // FcPatternAddCharSet (pat, FC_CHARSET, set);
+         break;
+      case 21:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizeonesym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize1");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         // set = FcCharSetCreate ();
+         // FcCharSetAddChar (set, 0x239b); // Bracket pieces
+         // FcPatternAddCharSet (pat, FC_CHARSET, set);
+         break;
+      case 22:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizetwosym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize2");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 23:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizetwosym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize2");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 24:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizethreesym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize13");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 25:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizethreesym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize3");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 26:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefoursym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize4");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 27:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefoursym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize4");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 28:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefivesym");
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize5");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         break;
+      case 29:
+      case 30:
+      case 31:
+         FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"droidsansfallback");
+         FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+         FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+         set = FcCharSetCreate ();
+         FcCharSetAddChar (set, 0x0410); // Cyrillic
+         FcCharSetAddChar (set, 0x4e00); // CJK
+         FcPatternAddCharSet (pat, FC_CHARSET, set);
+         break;
+      default:
+         Error("TTF::SetTextFont", "font %i not known to ROOT", fontid);
+         FcPatternDestroy (pat);
+         Warning("TTF::SetTextFont", "using default font");
          fgCurFontIdx = 0;    // use font 0 (default font, set in ctor)
-         return 0;
-      } else {
-         return 1;
+         return;
+         break;
       }
+
+      FcConfigSubstitute (NULL, pat, FcMatchPattern);
+      FcDefaultSubstitute (pat);
+      match = FcFontMatch (NULL, pat, &result);
+      char* ttfnt;
+      FcPatternGetString (match, FC_FILE, 0, (FcChar8**)&ttfnt);
+      ttfont = StrDup (ttfnt);
+      FcPatternGetInteger (match, FC_INDEX, 0, &ttindex);
+      FcPatternDestroy (match);
+      FcPatternDestroy (pat);
+      if (set) FcCharSetDestroy (set);
    }
 
    FT_Face  tface = 0;
 
-   if (FT_New_Face(fgLibrary, ttfont, 0, &tface)) {
+   if (FT_New_Face(fgLibrary, ttfont, ttindex, &tface)) {
       Error("TTF::SetTextFont", "error loading font %s", ttfont);
       delete [] ttfont;
       if (tface) FT_Done_Face(tface);
-      if (fgFontCount) {
-         Warning("TTF::SetTextFont", "using default font %s", fgFontName[0]);
-         fgCurFontIdx = 0;
-         return 0;
-      } else {
-         return 1;
-      }
+      Warning("TTF::SetTextFont", "using default font");
+      fgCurFontIdx = 0;
+      return;
    }
 
    delete [] ttfont;
 
-   fgFontName[fgFontCount] = StrDup(basename);
+   fgFontID[fgFontCount]   = fontid;
    fgCurFontIdx            = fgFontCount;
    fgFace[fgCurFontIdx]    = tface;
    fgCharMap[fgCurFontIdx] = 0;
    fgFontCount++;
 
    if (italic) {
-      fgSymbItaFontIdx = fgCurFontIdx;
       FT_Matrix slantMat;
       slantMat.xx = (1 << 16);
       slantMat.xy = ((1 << 16) >> 2);
       slantMat.yx = 0;
       slantMat.yy = (1 << 16);
-      FT_Set_Transform( fgFace[fgSymbItaFontIdx], &slantMat, NULL );
-   }
-
-   return 0;
-}
-
-//______________________________________________________________________________
-void TTF::SetTextFont(Font_t fontnumber)
-{
-   // Set specified font.
-   // List of the currently supported fonts (screen and PostScript)
-   // =============================================================
-   //   Font ID       X11                        TTF
-   //        1 : times-medium-i-normal       timesi.ttf
-   //        2 : times-bold-r-normal         timesbd.ttf
-   //        3 : times-bold-i-normal         timesi.ttf
-   //        4 : helvetica-medium-r-normal   arial.ttf
-   //        5 : helvetica-medium-o-normal   ariali.ttf
-   //        6 : helvetica-bold-r-normal     arialbd.ttf
-   //        7 : helvetica-bold-o-normal     arialbi.ttf
-   //        8 : courier-medium-r-normal     cour.ttf
-   //        9 : courier-medium-o-normal     couri.ttf
-   //       10 : courier-bold-r-normal       courbd.ttf
-   //       11 : courier-bold-o-normal       courbi.ttf
-   //       12 : symbol-medium-r-normal      symbol.ttf
-   //       13 : times-medium-r-normal       times.ttf
-   //       14 :                             wingding.ttf
-   //       15 : symbol oblique is emulated from symbol.ttf
-
-   // Added by cholm for use of DFSG - fonts - based on Kevins fix.
-   // Table of Microsoft and (for non-MSFT operating systems) backup
-   // FreeFont TTF fonts.
-   static const char *fonttable[][2] = {
-     { "Root.TTFont.0", "FreeSansBold.otf" },
-     { "Root.TTFont.1", "FreeSerifItalic.otf" },
-     { "Root.TTFont.2", "FreeSerifBold.otf" },
-     { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
-     { "Root.TTFont.4", "FreeSans.otf" },
-     { "Root.TTFont.5", "FreeSansOblique.otf" },
-     { "Root.TTFont.6", "FreeSansBold.otf" },
-     { "Root.TTFont.7", "FreeSansBoldOblique.otf" },
-     { "Root.TTFont.8", "FreeMono.otf" },
-     { "Root.TTFont.9", "FreeMonoOblique.otf" },
-     { "Root.TTFont.10", "FreeMonoBold.otf" },
-     { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
-     { "Root.TTFont.12", "symbol.ttf" },
-     { "Root.TTFont.13", "FreeSerif.otf" },
-     { "Root.TTFont.14", "wingding.ttf" },
-     { "Root.TTFont.15", "symbol.ttf" },
-     { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
-     { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
-     { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
-     { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
-     { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
-     { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
-     { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
-     { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
-     { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
-     { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
-     { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
-     { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
-     { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
-     { "Root.TTFont.ME", "DroidSansFallback.ttf" },
-     { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
-     { "Root.TTFont.CJKGothic", "DroidSansFallback.ttf" }
-   };
-
-   static int fontset = -1;
-   int        thisset = fontset;
-
-   int fontid = fontnumber / 10;
-   if (fontid < 0 || fontid > 31) fontid = 0;
-
-   if (thisset == -1) {
-      // try to load font (font must be in Root.TTFontPath resource)
-      // to see which fontset we have available
-      const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                          TTFFONTDIR
-#else
-                                          "$(ROOTSYS)/fonts"
-#endif
-                                         );
-      char *ttfont = gSystem->Which(ttpath, gEnv->GetValue(fonttable[fontid][0], fonttable[fontid][1]), kReadPermission);
-      if (ttfont) {
-         delete [] ttfont;
-         thisset = 0;
-      } else {
-         // try backup free font
-         thisset = 1;
-      }
+      FT_Set_Transform( fgFace[fgCurFontIdx], &slantMat, NULL );
    }
-   Int_t italic = 0;
-   if (fontid==15) italic = 1;
-   int ret = SetTextFont(gEnv->GetValue(fonttable[fontid][thisset], fonttable[fontid][1]), italic);
-   // Do not define font set is we're loading the symbol.ttf - it's
-   // the same in both cases.
-   if (ret == 0 && fontid != 12) fontset = thisset;
 }
 
 //______________________________________________________________________________
diff -ur root-5.34.20.orig/graf2d/postscript/Module.mk root-5.34.20/graf2d/postscript/Module.mk
--- root-5.34.20.orig/graf2d/postscript/Module.mk	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf2d/postscript/Module.mk	2014-08-16 19:24:53.363132437 +0200
@@ -50,7 +50,7 @@
 		@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \
 		   "$(SOFLAGS)" libPostscript.$(SOEXT) $@ \
 		   "$(POSTSCRIPTO) $(POSTSCRIPTDO)" \
-		   "$(POSTSCRIPTLIBEXTRA) $(MATHTEXTLIB) $(FREETYPELDFLAGS) $(FREETYPELIB)"
+		   "$(POSTSCRIPTLIBEXTRA) $(MATHTEXTLIB) $(FREETYPELDFLAGS) $(FREETYPELIB) -lfontconfig"
 
 $(POSTSCRIPTDS): $(POSTSCRIPTH) $(POSTSCRIPTL) $(ROOTCINTTMPDEP)
 		$(MAKEDIR)
diff -ur root-5.34.20.orig/graf2d/postscript/src/TPostScript.cxx root-5.34.20/graf2d/postscript/src/TPostScript.cxx
--- root-5.34.20.orig/graf2d/postscript/src/TPostScript.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf2d/postscript/src/TPostScript.cxx	2014-08-16 20:30:03.271041920 +0200
@@ -238,6 +238,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <wchar.h>
+#include <fontconfig/fontconfig.h>
 
 #include "Riostream.h"
 #include "Byteswap.h"
@@ -1511,63 +1512,244 @@
 {
    // Embed font in PS file.
 
-   static const char *fonttable[32][2] = {
-      { "Root.TTFont.0", "FreeSansBold.otf" },
-      { "Root.TTFont.1", "FreeSerifItalic.otf" },
-      { "Root.TTFont.2", "FreeSerifBold.otf" },
-      { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
-      { "Root.TTFont.4", "FreeSans.otf" },
-      { "Root.TTFont.5", "FreeSansOblique.otf" },
-      { "Root.TTFont.6", "FreeSansBold.otf" },
-      { "Root.TTFont.7", "FreeSansBoldOblique.otf" },
-      { "Root.TTFont.8", "FreeMono.otf" },
-      { "Root.TTFont.9", "FreeMonoOblique.otf" },
-      { "Root.TTFont.10", "FreeMonoBold.otf" },
-      { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
-      { "Root.TTFont.12", "symbol.ttf" },
-      { "Root.TTFont.13", "FreeSerif.otf" },
-      { "Root.TTFont.14", "wingding.ttf" },
-      { "Root.TTFont.15", "symbol.ttf" },
-      { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
-      { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
-      { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
-      { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
-      { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
-      { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
-      { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
-      { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
-      { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
-      { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
-      { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
-      { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
-      { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
-      { "Root.TTFont.ME", "DroidSansFallback.ttf" },
-      { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
-      { "Root.TTFont.CJKCothic", "DroidSansFallback.ttf" }
-   };
-
    PrintStr("%%IncludeResource: ProcSet (FontSetInit)@");
 
-   // try to load font (font must be in Root.TTFontPath resource)
-   const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                       TTFFONTDIR
-#else // TTFFONTDIR
-                                       "$(ROOTSYS)/fonts"
-#endif // TTFFONTDIR
-                                       );
-
    for (Int_t fontid = 1; fontid < 30; fontid++) {
       if (fontid != 15) {
-         const char *filename = gEnv->GetValue(
-                                               fonttable[fontid][0], fonttable[fontid][1]);
-         char *ttfont = gSystem->Which(ttpath, filename,
-                                       kReadPermission);
+
+         char *ttfont = NULL;
+
+         if (fontid >= 16 && fontid <= 28) {
+            // Use the texlive-stix fonts if they exist
+            // Texlive-stix not packaged correctly - can not be found through fontconfig
+            // Use hardcoded path
+            const char *ttpath = "/usr/share/texlive/texmf-dist/fonts/opentype/public/stix";
+            switch (fontid) {
+            case 16:
+               ttfont = gSystem->Which(ttpath, "STIXGeneral.otf", kReadPermission);
+               break;
+            case 17:
+               ttfont = gSystem->Which(ttpath, "STIXGeneralItalic.otf", kReadPermission);
+               break;
+            case 18:
+               ttfont = gSystem->Which(ttpath, "STIXGeneralBol.otf", kReadPermission);
+               break;
+            case 19:
+               ttfont = gSystem->Which(ttpath, "STIXGeneralBolIta.otf", kReadPermission);
+               break;
+            case 20:
+               ttfont = gSystem->Which(ttpath, "STIXSizOneSymReg.otf", kReadPermission);
+               break;
+            case 21:
+               ttfont = gSystem->Which(ttpath, "STIXSizOneSymBol.otf", kReadPermission);
+               break;
+            case 22:
+               ttfont = gSystem->Which(ttpath, "STIXSizTwoSymReg.otf", kReadPermission);
+               break;
+            case 23:
+               ttfont = gSystem->Which(ttpath, "STIXSizTwoSymBol.otf", kReadPermission);
+               break;
+            case 24:
+               ttfont = gSystem->Which(ttpath, "STIXSizThreeSymReg.otf", kReadPermission);
+               break;
+            case 25:
+               ttfont = gSystem->Which(ttpath, "STIXSizThreeSymBol.otf", kReadPermission);
+               break;
+            case 26:
+               ttfont = gSystem->Which(ttpath, "STIXSizFourSymReg.otf", kReadPermission);
+               break;
+            case 27:
+               ttfont = gSystem->Which(ttpath, "STIXSizFourSymBol.otf", kReadPermission);
+               break;
+            case 28:
+               ttfont = gSystem->Which(ttpath, "STIXSizFiveSymReg.otf", kReadPermission);
+               break;
+            }
+         }
+
+         if (!ttfont) {
+            FcPattern *pat, *match;
+            FcCharSet *set = NULL;
+            FcResult result;
+
+            pat = FcPatternCreate ();
+
+            switch (fontid) {
+            case 1:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 2:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 3:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 4:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 5:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 6:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 7:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 8:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 9:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 10:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 11:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 12:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"symbol");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 13:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 14:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"wingdings");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 16:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 17:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 18:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 19:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+               break;
+            case 20:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizeonesym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize1");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               // set = FcCharSetCreate ();
+               // FcCharSetAddChar (set, 0x239b); // Bracket pieces
+               // FcPatternAddCharSet (pat, FC_CHARSET, set);
+               break;
+            case 21:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizeonesym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize1");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               // set = FcCharSetCreate ();
+               // FcCharSetAddChar (set, 0x239b); // Bracket pieces
+               // FcPatternAddCharSet (pat, FC_CHARSET, set);
+               break;
+            case 22:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizetwosym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize2");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 23:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizetwosym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize2");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 24:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizethreesym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize13");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 25:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizethreesym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize3");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 26:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefoursym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize4");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 27:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefoursym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize4");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 28:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefivesym");
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize5");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               break;
+            case 29:
+               FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"droidsansfallback");
+               FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+               FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+               set = FcCharSetCreate ();
+               FcCharSetAddChar (set, 0x0410); // Cyrillic
+               FcCharSetAddChar (set, 0x4e00); // CJK
+               FcPatternAddCharSet (pat, FC_CHARSET, set);
+               break;
+            }
+
+            FcConfigSubstitute (NULL, pat, FcMatchPattern);
+            FcDefaultSubstitute (pat);
+            match = FcFontMatch (NULL, pat, &result);
+            char *ttfnt;
+            FcPatternGetString (match, FC_FILE, 0, (FcChar8**)&ttfnt);
+            ttfont = StrDup(ttfnt);
+            FcPatternDestroy (match);
+            FcPatternDestroy (pat);
+            if (set) FcCharSetDestroy (set);
+         }
 
          if(!ttfont) {
-            Error("TPostScript::FontEmbed",
-                  "font %d (filename `%s') not found in path",
-                  fontid, filename);
+            Error("TPostScript::FontEmbed", "font %d not found in path",
+                  fontid);
          } else {
             if (FontEmbedType2(ttfont)) {
                // nothing
@@ -1576,9 +1758,8 @@
             } else if(FontEmbedType42(ttfont)) {
                // nothing
             } else {
-               Error("TPostScript::FontEmbed",
-                     "failed to embed font %d (filename `%s')",
-                     fontid, filename);
+               Error("TPostScript::FontEmbed", "failed to embed font %d)",
+                     fontid);
             }
             delete [] ttfont;
          }
@@ -2571,10 +2752,10 @@
       { "Root.PSFont.5",             "/Helvetica-Oblique" },
       { "Root.PSFont.6",             "/Helvetica-Bold" },
       { "Root.PSFont.7",             "/Helvetica-BoldOblique" },
-      { "Root.PSFont.8",             "/Courrier" },
-      { "Root.PSFont.9",             "/Courrier-Oblique" },
-      { "Root.PSFont.10",            "/Courrier-Bold" },
-      { "Root.PSFont.11",            "/Courrier-BoldOblique" },
+      { "Root.PSFont.8",             "/Courier" },
+      { "Root.PSFont.9",             "/Courier-Oblique" },
+      { "Root.PSFont.10",            "/Courier-Bold" },
+      { "Root.PSFont.11",            "/Courier-BoldOblique" },
       { "Root.PSFont.12",            "/Symbol" },
       { "Root.PSFont.13",            "/Times-Roman" },
       { "Root.PSFont.14",            "/ZapfDingbats" },
diff -ur root-5.34.20.orig/graf3d/gl/Module.mk root-5.34.20/graf3d/gl/Module.mk
--- root-5.34.20.orig/graf3d/gl/Module.mk	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf3d/gl/Module.mk	2014-08-16 19:24:53.377132564 +0200
@@ -78,7 +78,7 @@
 		@$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \
 		   "$(SOFLAGS)" libRGL.$(SOEXT) $@ "$(GLO) $(GLO1) $(GLDO)" \
 		   "$(GLLIBEXTRA) $(FTGLLIBDIR) $(FTGLLIBS) \
-		    $(GLEWLIBDIR) $(GLEWLIBS) $(GLLIBS)"
+		    $(GLEWLIBDIR) $(GLEWLIBS) $(GLLIBS) -lfontconfig"
 
 $(GLDS):	$(GLH2) $(GLL) $(ROOTCINTTMPDEP)
 		$(MAKEDIR)
diff -ur root-5.34.20.orig/graf3d/gl/src/TGLFontManager.cxx root-5.34.20/graf3d/gl/src/TGLFontManager.cxx
--- root-5.34.20.orig/graf3d/gl/src/TGLFontManager.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf3d/gl/src/TGLFontManager.cxx	2014-08-16 19:24:53.378132573 +0200
@@ -36,6 +36,7 @@
 # include "FTGLBitmapFont.h"
 #endif
 
+#include <fontconfig/fontconfig.h>
 
 //______________________________________________________________________________
 // TGLFont
@@ -413,7 +414,7 @@
 ClassImp(TGLFontManager);
 
 TObjArray   TGLFontManager::fgFontFileArray;
-Int_t TGLFontManager::fgExtendedFontStart;
+Int_t TGLFontManager::fgExtendedFontStart = 0;
 TGLFontManager::FontSizeVec_t TGLFontManager::fgFontSizeArray;
 Bool_t  TGLFontManager::fgStaticInitDone = kFALSE;
 
@@ -444,19 +445,238 @@
    FontMap_i it = fFontMap.find(TGLFont(size, fileID, mode));
    if (it == fFontMap.end())
    {
-      TString ttpath, file;
-# ifdef TTFFONTDIR
-      ttpath = gEnv->GetValue("Root.TTGLFontPath", TTFFONTDIR );
-# else
-      ttpath = gEnv->GetValue("Root.TTGLFontPath", "$(ROOTSYS)/fonts");
-# endif
-      {
-         //For extenede we have both ttf and otf.
-         char *fp = gSystem->Which(ttpath, fileID < fgExtendedFontStart ?
-                                   ((TObjString*)fgFontFileArray[fileID])->String() + ".ttf" :
-                                   ((TObjString*)fgFontFileArray[fileID])->String());
-         file = fp;
-         delete [] fp;
+      char *file = NULL;
+      int ttindex = 0;
+
+      if (fileID >= 15 && fileID <= 27) {
+         // Use the texlive-stix fonts if they exist
+         // Texlive-stix not packaged correctly - can not be found through fontconfig
+         // Use hardcoded path
+         const char *ttpath = "/usr/share/texlive/texmf-dist/fonts/opentype/public/stix";
+         switch (fileID) {
+         case 15:
+            file = gSystem->Which(ttpath, "STIXGeneral.otf", kReadPermission);
+            break;
+         case 16:
+            file = gSystem->Which(ttpath, "STIXGeneralItalic.otf", kReadPermission);
+            break;
+         case 17:
+            file = gSystem->Which(ttpath, "STIXGeneralBol.otf", kReadPermission);
+            break;
+         case 18:
+            file = gSystem->Which(ttpath, "STIXGeneralBolIta.otf", kReadPermission);
+            break;
+         case 19:
+            file = gSystem->Which(ttpath, "STIXSizOneSymReg.otf", kReadPermission);
+            break;
+         case 20:
+            file = gSystem->Which(ttpath, "STIXSizOneSymBol.otf", kReadPermission);
+            break;
+         case 21:
+            file = gSystem->Which(ttpath, "STIXSizTwoSymReg.otf", kReadPermission);
+            break;
+         case 22:
+            file = gSystem->Which(ttpath, "STIXSizTwoSymBol.otf", kReadPermission);
+            break;
+         case 23:
+            file = gSystem->Which(ttpath, "STIXSizThreeSymReg.otf", kReadPermission);
+            break;
+         case 24:
+            file = gSystem->Which(ttpath, "STIXSizThreeSymBol.otf", kReadPermission);
+            break;
+         case 25:
+            file = gSystem->Which(ttpath, "STIXSizFourSymReg.otf", kReadPermission);
+            break;
+         case 26:
+            file = gSystem->Which(ttpath, "STIXSizFourSymBol.otf", kReadPermission);
+            break;
+         case 27:
+            file = gSystem->Which(ttpath, "STIXSizFiveSymReg.otf", kReadPermission);
+            break;
+         }
+      }
+
+      if (!file) {
+         FcPattern *pat, *match;
+         FcCharSet *set = NULL;
+         FcResult result;
+
+         pat = FcPatternCreate ();
+
+         switch (fileID) {
+         case 0:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 1:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 2:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 3:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 4:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 5:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 6:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 7:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 8:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 9:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 10:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 11:
+         case 14:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"symbol");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 12:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 13:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"wingdings");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 15:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 16:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 17:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 18:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixgeneral");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+            break;
+         case 19:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizeonesym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize1");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            // set = FcCharSetCreate ();
+            // FcCharSetAddChar (set, 0x239b); // Bracket pieces
+            // FcPatternAddCharSet (pat, FC_CHARSET, set);
+            break;
+         case 20:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizeonesym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize1");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            // set = FcCharSetCreate ();
+            // FcCharSetAddChar (set, 0x239b); // Bracket pieces
+            // FcPatternAddCharSet (pat, FC_CHARSET, set);
+            break;
+         case 21:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizetwosym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize2");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 22:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizetwosym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize2");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 23:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizethreesym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize13");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 24:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizethreesym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize3");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 25:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefoursym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize4");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 26:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefoursym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize4");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 27:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsizefivesym");
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"stixsize5");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            break;
+         case 28:
+         case 29:
+         case 30:
+            FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"droidsansfallback");
+            FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+            FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+            set = FcCharSetCreate ();
+            FcCharSetAddChar (set, 0x0410); // Cyrillic
+            FcCharSetAddChar (set, 0x4e00); // CJK
+            FcPatternAddCharSet (pat, FC_CHARSET, set);
+         }
+
+         FcConfigSubstitute (NULL, pat, FcMatchPattern);
+         FcDefaultSubstitute (pat);
+         match = FcFontMatch (NULL, pat, &result);
+         char* ttfnt;
+         FcPatternGetString (match, FC_FILE, 0, (FcChar8**)&ttfnt);
+         file = StrDup (ttfnt);
+         FcPatternGetInteger (match, FC_INDEX, 0, &ttindex);
+         FcPatternDestroy (match);
+         FcPatternDestroy (pat);
+         if (set) FcCharSetDestroy (set);
       }
 
       FTFont* ftfont = 0;
@@ -482,10 +702,14 @@
             ftfont = new FTGLTextureFont(file);
             break;
          default:
+            delete [] file;
             Error("TGLFontManager::RegisterFont", "invalid FTGL type");
             return;
             break;
       }
+
+      delete [] file;
+
       ftfont->FaceSize(size);
       const TGLFont &mf = fFontMap.insert(std::make_pair(TGLFont(size, fileID, mode, ftfont, 0), 1)).first->first;
       out.CopyAttributes(mf);
@@ -567,8 +791,6 @@
 {
    if (fgStaticInitDone == kFALSE) InitStatics();
 
-   assert(fgExtendedFontStart > 0 && "GetExtendedFontStartIndex, invalid index");
-   
    return fgExtendedFontStart;
 }
 
@@ -636,28 +858,6 @@
    fgFontFileArray.Add(new TObjString("wingding")); // 140
    fgFontFileArray.Add(new TObjString("symbol"));   // 150
 
-   fgExtendedFontStart = fgFontFileArray.GetEntries();
-   //"Extended" fonts for gl-pad.
-   //fgPadFontStart + ...
-   fgFontFileArray.Add(new TObjString("FreeSerifItalic.otf"));      //  10 (160)
-   fgFontFileArray.Add(new TObjString("FreeSerifBold.otf"));        //  20 (170)
-   fgFontFileArray.Add(new TObjString("FreeSerifBoldItalic.otf"));  //  30
-
-   fgFontFileArray.Add(new TObjString("FreeSans.otf"));             //  40
-   fgFontFileArray.Add(new TObjString("FreeSansOblique.otf"));      //  50
-   fgFontFileArray.Add(new TObjString("FreeSansBold.otf"));         //  60
-   fgFontFileArray.Add(new TObjString("FreeSansBoldOblique.otf"));  //  70
-
-   fgFontFileArray.Add(new TObjString("FreeMono.otf"));             //  80
-   fgFontFileArray.Add(new TObjString("FreeMonoOblique.otf"));      //  90
-   fgFontFileArray.Add(new TObjString("FreeMonoBold.otf"));         // 100
-   fgFontFileArray.Add(new TObjString("FreeMonoBoldOblique.otf"));  // 110
-
-   fgFontFileArray.Add(new TObjString("symbol.ttf"));               // 120
-   fgFontFileArray.Add(new TObjString("FreeSerif.otf"));            // 130
-   fgFontFileArray.Add(new TObjString("wingding.ttf"));             // 140
-   fgFontFileArray.Add(new TObjString("symbol.ttf"));               // 150
-
    fgFontFileArray.Add(new TObjString("STIXGeneral.otf"));          // 200
    fgFontFileArray.Add(new TObjString("STIXGeneralItalic.otf"));    // 210
    fgFontFileArray.Add(new TObjString("STIXGeneralBol.otf"));       // 220
diff -ur root-5.34.20.orig/graf3d/gl/src/TGLText.cxx root-5.34.20/graf3d/gl/src/TGLText.cxx
--- root-5.34.20.orig/graf3d/gl/src/TGLText.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/graf3d/gl/src/TGLText.cxx	2014-08-16 19:24:53.378132573 +0200
@@ -34,6 +34,8 @@
 # include "FTGLBitmapFont.h"
 #endif
 
+#include <fontconfig/fontconfig.h>
+
 #define FTGL_BITMAP  0
 #define FTGL_PIXMAP  1
 #define FTGL_OUTLINE 2
@@ -173,33 +175,91 @@
 {
    int fontid = fontnumber / 10;
 
-   const char *fontname=0;
-   if (fontid == 0)  fontname = "arialbd.ttf";
-   if (fontid == 1)  fontname = "timesi.ttf";
-   if (fontid == 2)  fontname = "timesbd.ttf";
-   if (fontid == 3)  fontname = "timesbi.ttf";
-   if (fontid == 4)  fontname = "arial.ttf";
-   if (fontid == 5)  fontname = "ariali.ttf";
-   if (fontid == 6)  fontname = "arialbd.ttf";
-   if (fontid == 7)  fontname = "arialbi.ttf";
-   if (fontid == 8)  fontname = "cour.ttf";
-   if (fontid == 9)  fontname = "couri.ttf";
-   if (fontid == 10) fontname = "courbd.ttf";
-   if (fontid == 11) fontname = "courbi.ttf";
-   if (fontid == 12) fontname = "symbol.ttf";
-   if (fontid == 13) fontname = "times.ttf";
-   if (fontid == 14) fontname = "wingding.ttf";
-
-   // try to load font (font must be in Root.TTFontPath resource)
-   const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-# ifdef TTFFONTDIR
-                                        TTFFONTDIR
-# else
-                                        "$(ROOTSYS)/fonts"
-# endif
-                                        );
+   FcPattern *pat, *match;
+   FcResult result;
+   char *ttfont;
+   int ttindex;
+
+   pat = FcPatternCreate ();
+
+   switch (fontid) {
+   case 1:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+      break;
+   case 2:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 3:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+      break;
+   case 4:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 5:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+      break;
+   case 6:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 7:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"arial");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+      break;
+   case 8:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 9:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+      break;
+   case 10:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 11:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"courier new");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
+      break;
+   case 12:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"symbol");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 13:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"times new roman");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   case 14:
+      FcPatternAddString (pat, FC_FAMILY, (const FcChar8*)"wingdings");
+      FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
+      FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
+      break;
+   }
 
-   char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission);
+   FcConfigSubstitute (NULL, pat, FcMatchPattern);
+   FcDefaultSubstitute (pat);
+   match = FcFontMatch (NULL, pat, &result);
+   FcPatternGetString (match, FC_FILE, 0, (FcChar8**)&ttfont);
+   FcPatternGetInteger (match, FC_INDEX, 0, &ttindex);
 
    if (fGLTextFont) delete fGLTextFont;
 
@@ -207,7 +267,9 @@
 
    fGLTextFont = new FTGLPolygonFont(ttfont);
 
+   FcPatternDestroy (match);
+   FcPatternDestroy (pat);
+
    if (!fGLTextFont->FaceSize(1))
-      Error("SetGLTextFont","Cannot set FTGL::FaceSize"),
-   delete [] ttfont;
+      Error("SetGLTextFont","Cannot set FTGL::FaceSize");
 }
diff -ur root-5.34.20.orig/gui/gui/src/TGApplication.cxx root-5.34.20/gui/gui/src/TGApplication.cxx
--- root-5.34.20.orig/gui/gui/src/TGApplication.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/gui/gui/src/TGApplication.cxx	2014-08-16 19:24:53.379132582 +0200
@@ -83,25 +83,12 @@
    gROOT->SetBatch(kFALSE);
 
    if (strcmp(appClassName, "proofserv")) {
-      const char *ttpath = gEnv->GetValue("Root.TTFontPath",
-#ifdef TTFFONTDIR
-                                          TTFFONTDIR);
-#else
-                                          "$(ROOTSYS)/fonts");
-#endif
-
-      char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission);
-      // Added by cholm for use of DFSG - fonts - based on fix by Kevin
-      if (!ttfont)
-         ttfont = gSystem->Which(ttpath, "FreeSansBold.ttf", kReadPermission);
-      if (ttfont && gEnv->GetValue("Root.UseTTFonts", 1)) {
+      if (gEnv->GetValue("Root.UseTTFonts", 1)) {
          TPluginHandler *h;
          if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", "x11ttf")))
             if (h->LoadPlugin() == -1)
                Info("TGApplication", "no TTF support");
       }
-
-      delete [] ttfont;
    }
 
    // Create the canvas colors early so they are allocated before
diff -ur root-5.34.20.orig/gui/gui/src/TGSpeedo.cxx root-5.34.20/gui/gui/src/TGSpeedo.cxx
--- root-5.34.20.orig/gui/gui/src/TGSpeedo.cxx	2014-08-13 15:03:22.000000000 +0200
+++ root-5.34.20/gui/gui/src/TGSpeedo.cxx	2014-08-16 19:24:53.379132582 +0200
@@ -119,8 +119,7 @@
 
    TString sc;
    Float_t step, mark[5];
-   TString fp = gEnv->GetValue("Root.TTFontPath", "");
-   TString ar = fp + "/arialbd.ttf";
+   TString ar = "arialbd.ttf";
    Int_t i, nexe, offset;
 
    const TGFont *counterFont = fClient->GetFont("-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*");
@@ -528,8 +527,7 @@
          delete fImage2;
       fImage2 = (TImage*)fImage->Clone("fImage2");
       if (!fImage2 || !fImage2->IsValid()) return;
-      TString fp = gEnv->GetValue("Root.TTFontPath", "");
-      TString ar = fp + "/arialbd.ttf";
+      TString ar = "arialbd.ttf";
       // format counter value
       Int_t nexe = 0;
       Int_t ww = fCounter;
@@ -609,8 +607,7 @@
          delete fImage2;
       fImage2 = (TImage*)fImage->Clone("fImage2");
       if (!fImage2 || !fImage2->IsValid()) return;
-      TString fp = gEnv->GetValue("Root.TTFontPath", "");
-      TString ar = fp + "/arialbd.ttf";
+      TString ar = "arialbd.ttf";
       // format counter value
       Int_t nexe = 0;
       Int_t ww = fCounter;