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 12namespace gfx { 13 14// Array of paths to font files that are expected to exist on machines where 15// tests are run. 16extern const char* const kSystemFontsForFontconfig[]; 17extern const size_t kNumSystemFontsForFontconfig; 18 19// Strings appearing at the beginning and end of Fontconfig XML files. 20extern const char kFontconfigFileHeader[]; 21extern const char kFontconfigFileFooter[]; 22 23// Strings appearing at the beginning and end of Fontconfig <match> stanzas. 24extern const char kFontconfigMatchHeader[]; 25extern const char kFontconfigMatchFooter[]; 26 27// Initializes Fontconfig and creates and swaps in a new, empty config. 28void SetUpFontconfig(); 29 30// Deinitializes Fontconfig. 31void TearDownFontconfig(); 32 33// Loads the font file at |path| into the current config, returning true on 34// success. 35bool 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. 39bool LoadConfigFileIntoFontconfig(const base::FilePath& path); 40 41// Writes |data| to a file in |temp_dir| and passes it to 42// LoadConfigFileIntoFontconfig(). 43bool LoadConfigDataIntoFontconfig(const base::FilePath& temp_dir, 44 const std::string& data); 45 46// Returns a Fontconfig <edit> stanza. 47std::string CreateFontconfigEditStanza(const std::string& name, 48 const std::string& type, 49 const std::string& value); 50 51// Returns a Fontconfig <test> stanza. 52std::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. 58std::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