<commit_before>
#include "font_manager.h"
#include "font.h"

#include <iostream>
#include <stdexcept>
#include <sstream>
#include <tuple>
#include <map>
#include <vector>
#include <base/scope_guard.h>
#include <base/language.h>

#include <fontconfig/fontconfig.h>
#include <ft2build.h>
#include FT_FREETYPE_H

namespace script { namespace fontconfig
{

struct font_manager::pimpl
{
	FcConfig *config = nullptr;
	FT_Library ftlib;
};

////////////////////////////////////////

font_manager::font_manager( void )
	: _impl( new pimpl )
{
//	if ( FcInit() != FcTrue )
//		throw std::runtime_error( "error intializing fontconfig" );

	/*
	set_manager_name( "fontconfig" );
	std::stringstream version;
	int v = FcGetVersion();
	version << v/10000 << '.' << (v/100)%100 << '.' << v%100;
	set_manager_version( version.str() );
	*/

//	_impl->config = FcConfigGetCurrent();
	_impl->config = FcInitLoadConfigAndFonts();
	FcConfigSetRescanInterval( _impl->config, 0 );

	if ( FT_Init_FreeType( &(_impl->ftlib) ) != 0 )
		throw std::runtime_error( "freetype initialization failed" );
}

////////////////////////////////////////

font_manager::~font_manager( void )
{
	FT_Done_FreeType( _impl->ftlib );
<commit_msg>return to using FcInit mechanism to init and set global fontconfig<commit_after>
#include "font_manager.h"
#include "font.h"

#include <iostream>
#include <stdexcept>
#include <sstream>
#include <tuple>
#include <map>
#include <vector>
#include <base/scope_guard.h>
#include <base/language.h>

#include <fontconfig/fontconfig.h>
#include <ft2build.h>
#include FT_FREETYPE_H

namespace script { namespace fontconfig
{

struct font_manager::pimpl
{
	FcConfig *config = nullptr;
	FT_Library ftlib;
};

////////////////////////////////////////

font_manager::font_manager( void )
	: _impl( new pimpl )
{
	if ( FcInit() != FcTrue )
		throw std::runtime_error( "error intializing fontconfig" );

	/*
	set_manager_name( "fontconfig" );
	std::stringstream version;
	int v = FcGetVersion();
	version << v/10000 << '.' << (v/100)%100 << '.' << v%100;
	set_manager_version( version.str() );
	*/

	_impl->config = FcConfigGetCurrent();
	FcConfigSetRescanInterval( _impl->config, 0 );

	if ( FT_Init_FreeType( &(_impl->ftlib) ) != 0 )
		throw std::runtime_error( "freetype initialization failed" );
}

////////////////////////////////////////

font_manager::~font_manager( void )
{
	FT_Done_FreeType( _impl->ftlib );

{'fraction_non_alphanumeric': 0.2111388196176226, 'fraction_numerical': 0.014131338320864505, 'mean_word_length': 3.611111111111111, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2964319', 'n_tokens_mistral': 871, 'n_tokens_neox': 826, 'n_words': 176}