<commit_before>
#include <vector>
#include <string>
#include <unordered_map>
#include <memory>
#include <iostream>
#include <cctype>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_net.h>
#include <physfs.h>
#include <res_path.h>
#include <scheme-defs.h>
#include <scheme-private.h>
#include <scheme.h>
#include <stb_truetype.h>
#include "hashstring.h"
#include "locator.h"
#include "servicecounter.h"
#include "service.h"
#include "servicecheckout.h"
#include "scripting.h"
#include "tinyscm_if.h"
#include "image.h"
#include "font.h"

namespace venk {

bool FontService::initialise(FontService* self) {
	(void) self;
	// ServiceCheckout<ScriptingService> scripting;
	// scheme* sc = scripting->get_scheme();
	// register_font_functions(sc);
	return true;
}

bool FontService::shutdown(FontService* self) {
	(void) self;
	// self->fontTable.clear();
	return true;
}


// -------------------- Font methods --------------------

Font::Font(const std::string& fontName) {
	std::string fullFileName = getResourcePath();
	fullFileName = fullFileName + "fonts/" + fontName;
	SDL_RWops *rwops = SDL_RWFromFile(fullFileName.c_str(), "rb");
	if (rwops != nullptr) {
		Sint64 size = SDL_RWsize(rwops);
		if (size != -1L) {
			void *buf = SDL_malloc(size);
			size_t read = SDL_RWread(rwops, buf, 1, size);
			if (read == size) {
				int result = stbtt_InitFont(font, (const unsigned char*) buf, 0);
				if (result == 0) {
					SDL_RWclose(rwops);
					return;
				} else {
					std::cerr << "Creating " << fontName << " failed" << std::endl;
				}
			} else {
				std::cerr << "Reading " << fontName << " failed" << std::endl;
			}
			SDL_free(buf);
		} else {
			std::cerr << "Probing " << fontName << " failed" << std::endl;
		}
		SDL_RWclose(rwops);<commit_msg>More PhysFS conversions<commit_after>
#include <vector>
#include <string>
#include <unordered_map>
#include <memory>
#include <iostream>
#include <cctype>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_net.h>
#include <physfs.h>
#include <physfsrwops.h>
#include <res_path.h>
#include <scheme-defs.h>11
#include <scheme-private.h>
#include <scheme.h>
#include <stb_truetype.h>
#include "hashstring.h"
#include "locator.h"
#include "servicecounter.h"
#include "service.h"
#include "servicecheckout.h"
#include "scripting.h"
#include "tinyscm_if.h"
#include "image.h"
#include "font.h"

namespace venk {

bool FontService::initialise(FontService* self) {
	(void) self;
	// ServiceCheckout<ScriptingService> scripting;
	// scheme* sc = scripting->get_scheme();
	// register_font_functions(sc);
	return true;
}

bool FontService::shutdown(FontService* self) {
	(void) self;
	// self->fontTable.clear();
	return true;
}


// -------------------- Font methods --------------------

Font::Font(const std::string& fontName) {
	std::string fullFileName = getResourcePath();
	fullFileName =  "fonts/" + fontName;
	SDL_RWops *rwops =  PHYSFSRWOPS_openRead(fullFileName.c_str());
	if (rwops != nullptr) {
		Sint64 size = SDL_RWsize(rwops);
		if (size != -1L) {
			void *buf = SDL_malloc(size);
			size_t read = SDL_RWread(rwops, buf, 1, size);
			if (read == size) {
				int result = stbtt_InitFont(font, (const unsigned char*) buf, 0);
				if (result == 0) {
					SDL_RWclose(rwops);
					return;
				} else {
					std::cerr << "Creating " << fontName << " failed" << std::endl;
				}
			} else {
				std::cerr << "Reading " << fontName << " failed" << std::endl;
			}
			SDL_free(buf);
		} else {
			std::cerr << "Probing " << fontName << " failed" << std::endl;
		}
		SDL_RWclose(rwops);
{'fraction_non_alphanumeric': 0.18883878241262683, 'fraction_numerical': 0.003945885005636978, 'mean_word_length': 3.908713692946058, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 40, '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': '5951890', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1301, 'n_words': 285}