/* Preview.c generated by valac 0.56.17, the Vala compiler
 * generated from Preview.vala, do not modify */

/*
Copyright (C) 2012 Johan Mattsson

This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
*/

#include "birdfont.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <float.h>
#include <math.h>
#include <gio/gio.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	BIRD_FONT_PREVIEW_0_PROPERTY,
	BIRD_FONT_PREVIEW_NUM_PROPERTIES
};
static GParamSpec* bird_font_preview_properties[BIRD_FONT_PREVIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

static gpointer bird_font_preview_parent_class = NULL;

static gchar* bird_font_preview_real_get_name (BirdFontFontDisplay* base);
static gchar* bird_font_preview_real_get_label (BirdFontFontDisplay* base);
static void bird_font_preview_real_selected_canvas (BirdFontFontDisplay* base);
static gchar* bird_font_preview_get_html_file_name (void);
static gboolean bird_font_preview_real_needs_modifier (BirdFontFontDisplay* base);
static GType bird_font_preview_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

BirdFontPreview*
bird_font_preview_construct (GType object_type)
{
	BirdFontPreview * self = NULL;
	self = (BirdFontPreview*) bird_font_font_display_construct (object_type);
	return self;
}

BirdFontPreview*
bird_font_preview_new (void)
{
	return bird_font_preview_construct (BIRD_FONT_TYPE_PREVIEW);
}

static gchar*
bird_font_preview_real_get_name (BirdFontFontDisplay* base)
{
	BirdFontPreview * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontPreview*) base;
	_tmp0_ = g_strdup ("Preview");
	result = _tmp0_;
	return result;
}

static gchar*
bird_font_preview_real_get_label (BirdFontFontDisplay* base)
{
	BirdFontPreview * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BirdFontPreview*) base;
	_tmp0_ = bird_font_t_ ("Preview");
	result = _tmp0_;
	return result;
}

static void
bird_font_preview_real_selected_canvas (BirdFontFontDisplay* base)
{
	BirdFontPreview * self;
	self = (BirdFontPreview*) base;
	bird_font_main_window_set_scrollbar_size ((gdouble) 0);
}

gchar*
bird_font_preview_get_html_path (void)
{
	GFile* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	_tmp0_ = bird_font_preview_get_file ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_file_get_path (_tmp1_);
	_tmp3_ = (gchar*) _tmp2_;
	_g_object_unref0 (_tmp1_);
	result = _tmp3_;
	return result;
}

GFile*
bird_font_preview_get_file (void)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	gchar* fn = NULL;
	gchar* _tmp1_;
	GFile* dir = NULL;
	GFile* _tmp2_;
	GFile* file = NULL;
	GFile* _tmp3_;
	const gchar* _tmp4_;
	GFile* _tmp5_;
	GFile* _tmp6_;
	GFile* result;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = bird_font_preview_get_html_file_name ();
	fn = _tmp1_;
	_tmp2_ = bird_font_export_tool_get_export_dir ();
	dir = _tmp2_;
	_tmp3_ = dir;
	_tmp4_ = fn;
	_tmp5_ = bird_font_get_child (_tmp3_, _tmp4_);
	file = _tmp5_;
	_tmp6_ = file;
	if (!g_file_query_exists (_tmp6_, NULL)) {
		GFile* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		BirdFontFont* _tmp10_;
		_tmp7_ = file;
		_tmp8_ = g_file_get_path (_tmp7_);
		_tmp9_ = (gchar*) _tmp8_;
		_tmp10_ = font;
		bird_font_export_tool_generate_html_document (_tmp9_, _tmp10_);
		_g_free0 (_tmp9_);
	}
	result = file;
	_g_object_unref0 (dir);
	_g_free0 (fn);
	_g_object_unref0 (font);
	return result;
}

gboolean
bird_font_preview_has_html_document (void)
{
	gchar* path = NULL;
	gchar* _tmp0_;
	GFile* dir = NULL;
	GFile* _tmp1_;
	GFile* file = NULL;
	GFile* _tmp2_;
	gboolean result;
	_tmp0_ = bird_font_preview_get_html_file_name ();
	path = _tmp0_;
	_tmp1_ = bird_font_export_tool_get_export_dir ();
	dir = _tmp1_;
	_tmp2_ = bird_font_get_child (dir, path);
	file = _tmp2_;
	result = g_file_query_exists (file, NULL);
	_g_object_unref0 (file);
	_g_object_unref0 (dir);
	_g_free0 (path);
	return result;
}

void
bird_font_preview_generate_html_document (void)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	gchar* path = NULL;
	gchar* _tmp1_;
	GFile* dir = NULL;
	GFile* _tmp2_;
	GFile* file = NULL;
	GFile* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = bird_font_preview_get_html_file_name ();
	path = _tmp1_;
	_tmp2_ = bird_font_export_tool_get_export_dir ();
	dir = _tmp2_;
	_tmp3_ = bird_font_get_child (dir, path);
	file = _tmp3_;
	_tmp4_ = g_file_get_path (file);
	_tmp5_ = (gchar*) _tmp4_;
	bird_font_export_tool_generate_html_document (_tmp5_, font);
	_g_free0 (_tmp5_);
	_g_object_unref0 (file);
	_g_object_unref0 (dir);
	_g_free0 (path);
	_g_object_unref0 (font);
}

void
bird_font_preview_delete_html_document (void)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	gchar* path = NULL;
	gchar* _tmp1_;
	GFile* dir = NULL;
	GFile* _tmp2_;
	GFile* file = NULL;
	GFile* _tmp3_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = bird_font_preview_get_html_file_name ();
	path = _tmp1_;
	_tmp2_ = bird_font_font_get_folder (font);
	dir = _tmp2_;
	_tmp3_ = bird_font_get_child (dir, path);
	file = _tmp3_;
	{
		g_file_delete (file, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_warning ("Preview.vala:74: %s", _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (file);
		_g_object_unref0 (dir);
		_g_free0 (path);
		_g_object_unref0 (font);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_object_unref0 (file);
	_g_object_unref0 (dir);
	_g_free0 (path);
	_g_object_unref0 (font);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static gchar*
bird_font_preview_get_html_file_name (void)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* result;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = bird_font_export_settings_get_file_name (font);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_to_string (_tmp2_);
	_tmp4_ = g_strconcat (_tmp3_, ".html", NULL);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp2_);
	result = _tmp5_;
	_g_object_unref0 (font);
	return result;
}

GFile*
bird_font_preview_get_html_file (void)
{
	GFile* _tmp0_;
	GFile* result;
	_tmp0_ = bird_font_preview_get_file ();
	result = _tmp0_;
	return result;
}

gchar*
bird_font_preview_get_uri (void)
{
	GFile* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* result;
	_tmp0_ = bird_font_preview_get_html_file ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_file_get_path (_tmp1_);
	_tmp3_ = (gchar*) _tmp2_;
	_tmp4_ = bird_font_tab_content_path_to_uri (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	result = _tmp5_;
	return result;
}

gchar*
bird_font_preview_get_windows_uri (void)
{
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp0_;
	gchar* html = NULL;
	gchar* _tmp1_;
	GFile* dir = NULL;
	GFile* _tmp2_;
	GFile* file = NULL;
	GFile* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	_tmp0_ = bird_font_bird_font_get_current_font ();
	font = _tmp0_;
	_tmp1_ = bird_font_preview_get_html_file_name ();
	html = _tmp1_;
	_tmp2_ = bird_font_font_get_folder (font);
	dir = _tmp2_;
	_tmp3_ = bird_font_get_child (dir, html);
	file = _tmp3_;
	_tmp4_ = g_file_get_path (file);
	_tmp5_ = (gchar*) _tmp4_;
	_tmp6_ = g_strconcat ("file:///", _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	result = _tmp7_;
	_g_object_unref0 (file);
	_g_object_unref0 (dir);
	_g_free0 (html);
	_g_object_unref0 (font);
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

gchar*
bird_font_preview_get_html_with_absolute_paths (void)
{
	GString* sb = NULL;
	GString* _tmp0_;
	GDataInputStream* dis = NULL;
	gchar* line = NULL;
	guint rid = 0U;
	BirdFontFont* font = NULL;
	BirdFontFont* _tmp1_;
	GFile* preview_directory = NULL;
	GFile* f_ttf = NULL;
	GFile* f_eot = NULL;
	GFile* f_svg = NULL;
	GString* _tmp109_;
	const gchar* _tmp110_;
	gchar* _tmp111_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	_tmp0_ = g_string_new ("");
	sb = _tmp0_;
	rid = (guint) g_random_int ();
	_tmp1_ = bird_font_bird_font_get_current_font ();
	font = _tmp1_;
	{
		GFileInputStream* _tmp2_ = NULL;
		GFile* _tmp3_;
		GFile* _tmp4_;
		GFileInputStream* _tmp5_;
		GFileInputStream* _tmp6_;
		GDataInputStream* _tmp7_;
		gchar* d = NULL;
		BirdFontFont* _tmp8_;
		gchar* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp13_;
		GFile* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gboolean _tmp21_;
		GFile* dir = NULL;
		const gchar* _tmp22_;
		GFile* _tmp23_;
		GFile* _tmp24_;
		BirdFontFont* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		const gchar* _tmp28_;
		gchar* _tmp29_;
		gchar* _tmp30_;
		GFile* _tmp31_;
		GFile* _tmp32_;
		BirdFontFont* _tmp33_;
		gchar* _tmp34_;
		gchar* _tmp35_;
		const gchar* _tmp36_;
		gchar* _tmp37_;
		gchar* _tmp38_;
		GFile* _tmp39_;
		GFile* _tmp40_;
		BirdFontFont* _tmp41_;
		gchar* _tmp42_;
		gchar* _tmp43_;
		const gchar* _tmp44_;
		gchar* _tmp45_;
		gchar* _tmp46_;
		GFile* _tmp47_;
		GFile* _tmp48_;
		GFile* _tmp49_;
		gchar* name = NULL;
		BirdFontFont* _tmp50_;
		gchar* _tmp51_;
		_tmp3_ = bird_font_preview_get_file ();
		_tmp4_ = _tmp3_;
		_tmp5_ = g_file_read (_tmp4_, NULL, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_tmp2_ = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp7_ = g_data_input_stream_new ((GInputStream*) _tmp2_);
		_g_object_unref0 (dis);
		dis = _tmp7_;
		_tmp8_ = font;
		_tmp9_ = bird_font_font_get_export_directory (_tmp8_);
		d = _tmp9_;
		_tmp10_ = d;
		if (_tmp10_ == NULL) {
			BirdFontFont* _tmp11_;
			gchar* _tmp12_;
			g_warning ("Preview.vala:119: Export dir is not set.");
			bird_font_export_tool_set_output_directory ();
			_tmp11_ = font;
			_tmp12_ = bird_font_font_get_export_directory (_tmp11_);
			_g_free0 (d);
			d = _tmp12_;
		}
		_tmp13_ = d;
		_tmp14_ = g_file_new_for_path ((const gchar*) _tmp13_);
		_g_object_unref0 (preview_directory);
		preview_directory = _tmp14_;
		_tmp15_ = d;
		_tmp16_ = string_to_string ((const gchar*) _tmp15_);
		_tmp17_ = g_strconcat ("previwdir ", _tmp16_, NULL);
		_tmp18_ = _tmp17_;
		bird_font_printd (_tmp18_);
		_g_free0 (_tmp18_);
		_tmp19_ = bird_font_export_tool_get_export_folder ();
		_tmp20_ = _tmp19_;
		_tmp21_ = g_strcmp0 (_tmp20_, "") == 0;
		_g_free0 (_tmp20_);
		if (_tmp21_) {
			bird_font_export_tool_set_output_directory ();
		}
		_tmp22_ = d;
		_tmp23_ = g_file_new_for_path ((const gchar*) _tmp22_);
		dir = _tmp23_;
		_tmp24_ = dir;
		_tmp25_ = font;
		_tmp26_ = bird_font_export_settings_get_file_name (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = string_to_string (_tmp27_);
		_tmp29_ = g_strconcat (_tmp28_, ".ttf", NULL);
		_tmp30_ = _tmp29_;
		_tmp31_ = bird_font_get_child (_tmp24_, _tmp30_);
		_g_object_unref0 (f_ttf);
		f_ttf = _tmp31_;
		_g_free0 (_tmp30_);
		_g_free0 (_tmp27_);
		_tmp32_ = dir;
		_tmp33_ = font;
		_tmp34_ = bird_font_export_settings_get_file_name (_tmp33_);
		_tmp35_ = _tmp34_;
		_tmp36_ = string_to_string (_tmp35_);
		_tmp37_ = g_strconcat (_tmp36_, ".eot", NULL);
		_tmp38_ = _tmp37_;
		_tmp39_ = bird_font_get_child (_tmp32_, _tmp38_);
		_g_object_unref0 (f_eot);
		f_eot = _tmp39_;
		_g_free0 (_tmp38_);
		_g_free0 (_tmp35_);
		_tmp40_ = dir;
		_tmp41_ = font;
		_tmp42_ = bird_font_export_settings_get_file_name (_tmp41_);
		_tmp43_ = _tmp42_;
		_tmp44_ = string_to_string (_tmp43_);
		_tmp45_ = g_strconcat (_tmp44_, ".svg", NULL);
		_tmp46_ = _tmp45_;
		_tmp47_ = bird_font_get_child (_tmp40_, _tmp46_);
		_g_object_unref0 (f_svg);
		f_svg = _tmp47_;
		_g_free0 (_tmp46_);
		_g_free0 (_tmp43_);
		_tmp48_ = f_ttf;
		if (!g_file_query_exists (_tmp48_, NULL)) {
			g_warning ("Preview.vala:138: TTF file does not exist.");
		}
		_tmp49_ = f_svg;
		if (!g_file_query_exists (_tmp49_, NULL)) {
			g_warning ("Preview.vala:142: SVG file does not exist.");
		}
		_tmp50_ = font;
		_tmp51_ = bird_font_export_settings_get_file_name (_tmp50_);
		name = _tmp51_;
		while (TRUE) {
			gchar* _tmp52_ = NULL;
			GDataInputStream* _tmp53_;
			gchar* _tmp54_;
			gchar* _tmp55_;
			const gchar* _tmp56_;
			const gchar* _tmp57_;
			const gchar* _tmp58_;
			const gchar* _tmp59_;
			gchar* _tmp60_;
			gchar* _tmp61_;
			GFile* _tmp62_;
			gchar* _tmp63_;
			gchar* _tmp64_;
			gchar* _tmp65_;
			gchar* _tmp66_;
			const gchar* _tmp67_;
			gchar* _tmp68_;
			gchar* _tmp69_;
			gchar* _tmp70_;
			gchar* _tmp71_;
			gchar* _tmp72_;
			const gchar* _tmp73_;
			const gchar* _tmp74_;
			const gchar* _tmp75_;
			gchar* _tmp76_;
			gchar* _tmp77_;
			GFile* _tmp78_;
			gchar* _tmp79_;
			gchar* _tmp80_;
			gchar* _tmp81_;
			gchar* _tmp82_;
			const gchar* _tmp83_;
			gchar* _tmp84_;
			gchar* _tmp85_;
			gchar* _tmp86_;
			gchar* _tmp87_;
			gchar* _tmp88_;
			const gchar* _tmp89_;
			const gchar* _tmp90_;
			const gchar* _tmp91_;
			gchar* _tmp92_;
			gchar* _tmp93_;
			GFile* _tmp94_;
			gchar* _tmp95_;
			gchar* _tmp96_;
			gchar* _tmp97_;
			gchar* _tmp98_;
			const gchar* _tmp99_;
			gchar* _tmp100_;
			gchar* _tmp101_;
			gchar* _tmp102_;
			gchar* _tmp103_;
			gchar* _tmp104_;
			GString* _tmp105_;
			const gchar* _tmp106_;
			_tmp53_ = dis;
			_tmp54_ = g_data_input_stream_read_line (_tmp53_, NULL, NULL, &_inner_error0_);
			_tmp52_ = _tmp54_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (name);
				_g_object_unref0 (dir);
				_g_free0 (d);
				_g_object_unref0 (_tmp2_);
				goto __catch0_g_error;
			}
			_tmp55_ = _tmp52_;
			_tmp52_ = NULL;
			_g_free0 (line);
			line = _tmp55_;
			_tmp56_ = line;
			if (!(_tmp56_ != NULL)) {
				_g_free0 (_tmp52_);
				break;
			}
			_tmp57_ = line;
			_tmp58_ = name;
			_tmp59_ = string_to_string (_tmp58_);
			_tmp60_ = g_strconcat (_tmp59_, ".ttf", NULL);
			_tmp61_ = _tmp60_;
			_tmp62_ = f_ttf;
			_tmp63_ = g_file_get_path (_tmp62_);
			_tmp64_ = (gchar*) _tmp63_;
			_tmp65_ = bird_font_tab_content_path_to_uri (_tmp64_);
			_tmp66_ = _tmp65_;
			_tmp67_ = string_to_string (_tmp66_);
			_tmp68_ = g_strdup_printf ("%u", rid);
			_tmp69_ = _tmp68_;
			_tmp70_ = g_strconcat (_tmp67_, "?", _tmp69_, NULL);
			_tmp71_ = _tmp70_;
			_tmp72_ = string_replace ((const gchar*) _tmp57_, _tmp61_, _tmp71_);
			_g_free0 (line);
			line = _tmp72_;
			_g_free0 (_tmp71_);
			_g_free0 (_tmp69_);
			_g_free0 (_tmp66_);
			_g_free0 (_tmp64_);
			_g_free0 (_tmp61_);
			_tmp73_ = line;
			_tmp74_ = name;
			_tmp75_ = string_to_string (_tmp74_);
			_tmp76_ = g_strconcat (_tmp75_, ".eot", NULL);
			_tmp77_ = _tmp76_;
			_tmp78_ = f_eot;
			_tmp79_ = g_file_get_path (_tmp78_);
			_tmp80_ = (gchar*) _tmp79_;
			_tmp81_ = bird_font_tab_content_path_to_uri (_tmp80_);
			_tmp82_ = _tmp81_;
			_tmp83_ = string_to_string (_tmp82_);
			_tmp84_ = g_strdup_printf ("%u", rid);
			_tmp85_ = _tmp84_;
			_tmp86_ = g_strconcat (_tmp83_, "?", _tmp85_, NULL);
			_tmp87_ = _tmp86_;
			_tmp88_ = string_replace ((const gchar*) _tmp73_, _tmp77_, _tmp87_);
			_g_free0 (line);
			line = _tmp88_;
			_g_free0 (_tmp87_);
			_g_free0 (_tmp85_);
			_g_free0 (_tmp82_);
			_g_free0 (_tmp80_);
			_g_free0 (_tmp77_);
			_tmp89_ = line;
			_tmp90_ = name;
			_tmp91_ = string_to_string (_tmp90_);
			_tmp92_ = g_strconcat (_tmp91_, ".svg", NULL);
			_tmp93_ = _tmp92_;
			_tmp94_ = f_svg;
			_tmp95_ = g_file_get_path (_tmp94_);
			_tmp96_ = (gchar*) _tmp95_;
			_tmp97_ = bird_font_tab_content_path_to_uri (_tmp96_);
			_tmp98_ = _tmp97_;
			_tmp99_ = string_to_string (_tmp98_);
			_tmp100_ = g_strdup_printf ("%u", rid);
			_tmp101_ = _tmp100_;
			_tmp102_ = g_strconcat (_tmp99_, "?", _tmp101_, NULL);
			_tmp103_ = _tmp102_;
			_tmp104_ = string_replace ((const gchar*) _tmp89_, _tmp93_, _tmp103_);
			_g_free0 (line);
			line = _tmp104_;
			_g_free0 (_tmp103_);
			_g_free0 (_tmp101_);
			_g_free0 (_tmp98_);
			_g_free0 (_tmp96_);
			_g_free0 (_tmp93_);
			_tmp105_ = sb;
			_tmp106_ = line;
			g_string_append (_tmp105_, (const gchar*) _tmp106_);
			_g_free0 (_tmp52_);
		}
		_g_free0 (name);
		_g_object_unref0 (dir);
		_g_free0 (d);
		_g_object_unref0 (_tmp2_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp107_;
		const gchar* _tmp108_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp107_ = e;
		_tmp108_ = _tmp107_->message;
		g_warning ("Preview.vala:155: %s", _tmp108_);
		g_warning ("Preview.vala:156: Failed to load html into canvas.");
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (f_svg);
		_g_object_unref0 (f_eot);
		_g_object_unref0 (f_ttf);
		_g_object_unref0 (preview_directory);
		_g_object_unref0 (font);
		_g_free0 (line);
		_g_object_unref0 (dis);
		_g_string_free0 (sb);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp109_ = sb;
	_tmp110_ = _tmp109_->str;
	_tmp111_ = g_strdup (_tmp110_);
	result = _tmp111_;
	_g_object_unref0 (f_svg);
	_g_object_unref0 (f_eot);
	_g_object_unref0 (f_ttf);
	_g_object_unref0 (preview_directory);
	_g_object_unref0 (font);
	_g_free0 (line);
	_g_object_unref0 (dis);
	_g_string_free0 (sb);
	return result;
}

static gboolean
bird_font_preview_real_needs_modifier (BirdFontFontDisplay* base)
{
	BirdFontPreview * self;
	gboolean result;
	self = (BirdFontPreview*) base;
	result = TRUE;
	return result;
}

static void
bird_font_preview_class_init (BirdFontPreviewClass * klass,
                              gpointer klass_data)
{
	bird_font_preview_parent_class = g_type_class_peek_parent (klass);
	((BirdFontFontDisplayClass *) klass)->get_name = (gchar* (*) (BirdFontFontDisplay*)) bird_font_preview_real_get_name;
	((BirdFontFontDisplayClass *) klass)->get_label = (gchar* (*) (BirdFontFontDisplay*)) bird_font_preview_real_get_label;
	((BirdFontFontDisplayClass *) klass)->selected_canvas = (void (*) (BirdFontFontDisplay*)) bird_font_preview_real_selected_canvas;
	((BirdFontFontDisplayClass *) klass)->needs_modifier = (gboolean (*) (BirdFontFontDisplay*)) bird_font_preview_real_needs_modifier;
}

static void
bird_font_preview_instance_init (BirdFontPreview * self,
                                 gpointer klass)
{
}

static GType
bird_font_preview_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontPreviewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_preview_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontPreview), 0, (GInstanceInitFunc) bird_font_preview_instance_init, NULL };
	GType bird_font_preview_type_id;
	bird_font_preview_type_id = g_type_register_static (BIRD_FONT_TYPE_FONT_DISPLAY, "BirdFontPreview", &g_define_type_info, 0);
	return bird_font_preview_type_id;
}

GType
bird_font_preview_get_type (void)
{
	static volatile gsize bird_font_preview_type_id__once = 0;
	if (g_once_init_enter (&bird_font_preview_type_id__once)) {
		GType bird_font_preview_type_id;
		bird_font_preview_type_id = bird_font_preview_get_type_once ();
		g_once_init_leave (&bird_font_preview_type_id__once, bird_font_preview_type_id);
	}
	return bird_font_preview_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

