1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_GFX_TEST_FONTCONFIG_UTIL_LINUX_H_ 6 #define UI_GFX_TEST_FONTCONFIG_UTIL_LINUX_H_ 7 8 #include <string> 9 10 #include "base/files/file_path.h" 11 12 namespace gfx { 13 14 // Array of paths to font files that are expected to exist on machines where 15 // tests are run. 16 extern const char* const kSystemFontsForFontconfig[]; 17 extern const size_t kNumSystemFontsForFontconfig; 18 19 // Strings appearing at the beginning and end of Fontconfig XML files. 20 extern const char kFontconfigFileHeader[]; 21 extern const char kFontconfigFileFooter[]; 22 23 // Strings appearing at the beginning and end of Fontconfig <match> stanzas. 24 extern const char kFontconfigMatchHeader[]; 25 extern const char kFontconfigMatchFooter[]; 26 27 // Initializes Fontconfig and creates and swaps in a new, empty config. 28 void SetUpFontconfig(); 29 30 // Deinitializes Fontconfig. 31 void TearDownFontconfig(); 32 33 // Loads the font file at |path| into the current config, returning true on 34 // success. 35 bool LoadFontIntoFontconfig(const base::FilePath& path); 36 37 // Instructs Fontconfig to load |path|, an XML configuration file, into the 38 // current config, returning true on success. 39 bool LoadConfigFileIntoFontconfig(const base::FilePath& path); 40 41 // Writes |data| to a file in |temp_dir| and passes it to 42 // LoadConfigFileIntoFontconfig(). 43 bool LoadConfigDataIntoFontconfig(const base::FilePath& temp_dir, 44 const std::string& data); 45 46 // Returns a Fontconfig <edit> stanza. 47 std::string CreateFontconfigEditStanza(const std::string& name, 48 const std::string& type, 49 const std::string& value); 50 51 // Returns a Fontconfig <test> stanza. 52 std::string CreateFontconfigTestStanza(const std::string& name, 53 const std::string& op, 54 const std::string& type, 55 const std::string& value); 56 57 // Returns a Fontconfig <alias> stanza. 58 std::string CreateFontconfigAliasStanza(const std::string& original_family, 59 const std::string& preferred_family); 60 61 } // namespace gfx 62 63 #endif // UI_GFX_TEST_FONTCONFIG_UTIL_LINUX_H_ 64