Guest User

Untitled

a guest
Jun 30th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.29 KB | None | 0 0
  1. diff --git a/content/shell/app/webkit_test_platform_support_linux.cc b/content/shell/app/webkit_test_platform_support_linux.cc
  2. index fd59257..960055d 100644
  3. --- a/content/shell/app/webkit_test_platform_support_linux.cc
  4. +++ b/content/shell/app/webkit_test_platform_support_linux.cc
  5. @@ -13,6 +13,10 @@
  6.  #include "base/files/file_path.h"
  7.  #include "base/path_service.h"
  8.  
  9. +#include <list>
  10. +#include <string.h>
  11. +#include <vector>
  12. +
  13.  namespace content {
  14.  
  15.  namespace {
  16. @@ -38,6 +42,88 @@ bool CheckAndLoadFontFile(
  17.    return true;
  18.  }
  19.  
  20. +
  21. +struct HasCharEntry {
  22. +  HasCharEntry() : numSupportedFonts(0), supportedBy(std::vector<std::string>()) {};
  23. +  FcChar32 theChar;
  24. +  unsigned numSupportedFonts;
  25. +  std::vector<std::string> supportedBy;
  26. +};
  27. +
  28. +typedef std::list<HasCharEntry> HasCharList;
  29. +
  30. +static const unsigned long MAX_UNICODE = 0x10FFFF;
  31. +
  32. +static HasCharList charSupportList(MAX_UNICODE, HasCharEntry());
  33. +
  34. +void fillUcsChars() {
  35. +  unsigned int charCount = 0;
  36. +  for(HasCharList::iterator i = charSupportList.begin(); i != charSupportList.end(); ++i) {
  37. +    (*i).theChar = charCount++;
  38. +  }
  39. +}
  40. +
  41. +bool compareNumSupported(const HasCharEntry& first, const HasCharEntry& second) {
  42. +  return first.numSupportedFonts < second.numSupportedFonts;
  43. +}
  44. +
  45. +
  46. +void analyzeFontFallback(FcConfig* config) {
  47. +
  48. +  FcPattern* pat = FcPatternCreate();
  49. +  FcObjectSet* os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, FC_LANG, FC_FILE, FC_CHARSET, (char *) 0);
  50. +  FcFontSet* fs = FcFontList(config, pat, os);
  51. +  fillUcsChars();
  52. +
  53. +  for (int i=0; fs && i < fs->nfont; ++i) {
  54. +    FcPattern* font = fs->fonts[i];
  55. +    FcChar8* file, *style, *family;
  56. +    if (FcPatternGetString(font, FC_FILE, 0, &file) != FcResultMatch ||
  57. +        FcPatternGetString(font, FC_FAMILY, 0, &family) != FcResultMatch ||
  58. +        FcPatternGetString(font, FC_STYLE, 0, &style) != FcResultMatch)
  59. +      continue;
  60. +
  61. +    FcCharSet* charSet;
  62. +    if (FcPatternGetCharSet(font, FC_CHARSET, 0,  &charSet) != FcResultMatch) {
  63. +      printf("Font %s cannot report charset.\n", family);
  64. +      continue;
  65. +    }
  66. +
  67. +    HasCharList::iterator j = charSupportList.begin();
  68. +    while (j != charSupportList.end())
  69. +    {
  70. +      if (FcCharSetHasChar(charSet, (*j).theChar)) {
  71. +        (*j).numSupportedFonts++;
  72. +        (*j).supportedBy.push_back(std::string((char*)file));
  73. +                
  74. +      }
  75. +      ++j;
  76. +    }
  77. +        
  78. +  }
  79. +    
  80. +  charSupportList.sort(compareNumSupported);
  81. +  int lastSupportedNumFonts = 0;
  82. +  for (HasCharList::iterator i = charSupportList.begin(); i != charSupportList.end(); i++) {
  83. +    if (!(*i).numSupportedFonts)
  84. +      continue;
  85. +        
  86. +    if ((*i).numSupportedFonts > lastSupportedNumFonts) {
  87. +      printf("\n<br>Supported by %d fonts:<br>\n", (*i).numSupportedFonts);
  88. +      lastSupportedNumFonts = (*i).numSupportedFonts;
  89. +    }
  90. +        
  91. +    printf("&#x%x; ",(*i).theChar);
  92. +  }
  93. +    
  94. +  if (fs)
  95. +    FcFontSetDestroy(fs);
  96. +
  97. +
  98. +
  99. +}
  100. +
  101. +
  102.  static bool LoadFontResources(const base::FilePath& base_path,
  103.                                FcConfig* font_config) {
  104.    const char* const own_fonts[] = {"AHEM____.TTF", "GardinerModBug.ttf",
  105. @@ -146,6 +232,8 @@ bool SetupFontConfig() {
  106.      return false;
  107.    }
  108.  
  109. +  // analyzeFontFallback(font_config);
  110. +
  111.    return true;
  112.  }
Advertisement
Add Comment
Please, Sign In to add comment