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

/*
Copyright (C) 2014 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 <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <glib/gstdio.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_BIRD_FONT_PART_0_PROPERTY,
	BIRD_FONT_BIRD_FONT_PART_NUM_PROPERTIES
};
static GParamSpec* bird_font_bird_font_part_properties[BIRD_FONT_BIRD_FONT_PART_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 BIRD_FONT_TYPE_BIRD_FONT_FILE (bird_font_bird_font_file_get_type ())
#define BIRD_FONT_BIRD_FONT_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BIRD_FONT_TYPE_BIRD_FONT_FILE, BirdFontBirdFontFile))
#define BIRD_FONT_BIRD_FONT_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BIRD_FONT_TYPE_BIRD_FONT_FILE, BirdFontBirdFontFileClass))
#define BIRD_FONT_IS_BIRD_FONT_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BIRD_FONT_TYPE_BIRD_FONT_FILE))
#define BIRD_FONT_IS_BIRD_FONT_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BIRD_FONT_TYPE_BIRD_FONT_FILE))
#define BIRD_FONT_BIRD_FONT_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BIRD_FONT_TYPE_BIRD_FONT_FILE, BirdFontBirdFontFileClass))

typedef struct _BirdFontBirdFontFile BirdFontBirdFontFile;
typedef struct _BirdFontBirdFontFileClass BirdFontBirdFontFileClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block9Data Block9Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _BirdFontBirdFontPartPrivate {
	BirdFontFont* font;
	GeeArrayList* parts;
	gchar* root_directory;
};

struct _Block9Data {
	int _ref_count_;
	BirdFontBirdFontPart* self;
	GDataOutputStream* os;
	BirdFontBirdFontFile* bf;
	gboolean _error_;
};

static gint BirdFontBirdFontPart_private_offset;
static gpointer bird_font_bird_font_part_parent_class = NULL;
static gchar* bird_font_bird_font_part_FILE_ATTRIBUTES;
static gchar* bird_font_bird_font_part_FILE_ATTRIBUTES = NULL;

static void __lambda334_ (BirdFontBirdFontPart* self);
static void ___lambda334__bird_font_font_font_deleted (BirdFontFont* _sender,
                                                gpointer self);
VALA_EXTERN GType bird_font_bird_font_file_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BirdFontBirdFontFile* bird_font_bird_font_file_new (BirdFontFont* f);
VALA_EXTERN BirdFontBirdFontFile* bird_font_bird_font_file_construct (GType object_type,
                                                          BirdFontFont* f);
static void bird_font_bird_font_part_find_all_parts (BirdFontBirdFontPart* self,
                                              const gchar* bfp_file,
                                              GError** error);
static void bird_font_bird_font_part_copy_backgrounds (BirdFontBirdFontPart* self,
                                                const gchar* folder,
                                                GError** error);
VALA_EXTERN gboolean bird_font_bird_font_file_load_part (BirdFontBirdFontFile* self,
                                             const gchar* bfp_file);
static GFile* bird_font_bird_font_part_get_destination_file (BirdFontBirdFontPart* self,
                                                      const gchar* name,
                                                      const gchar* subdir1,
                                                      const gchar* subdir2,
                                                      GError** error);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static GDataOutputStream* bird_font_bird_font_part_create_file (BirdFontBirdFontPart* self,
                                                         const gchar* name,
                                                         const gchar* subdir1,
                                                         const gchar* subdir2,
                                                         GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_root_tag (BirdFontBirdFontFile* self,
                                              GDataOutputStream* os,
                                              GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_closing_root_tag (BirdFontBirdFontFile* self,
                                                      GDataOutputStream* os,
                                                      GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_description (BirdFontBirdFontFile* self,
                                                 GDataOutputStream* os,
                                                 GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_lines (BirdFontBirdFontFile* self,
                                           GDataOutputStream* os,
                                           GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_settings (BirdFontBirdFontFile* self,
                                              GDataOutputStream* os,
                                              GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_spacing_classes (BirdFontBirdFontFile* self,
                                                     GDataOutputStream* os,
                                                     GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_ligatures (BirdFontBirdFontFile* self,
                                               GDataOutputStream* os);
VALA_EXTERN void bird_font_bird_font_file_write_alternates (BirdFontBirdFontFile* self,
                                                GDataOutputStream* os,
                                                GError** error);
static void ___lambda338_ (Block9Data* _data9_,
                    BirdFontGlyphCollection* gc);
static gchar* bird_font_bird_font_part_get_first_number_in_unicode (BirdFontGlyph* g);
VALA_EXTERN void bird_font_bird_font_file_write_glyph_collection_start (BirdFontBirdFontFile* self,
                                                            BirdFontGlyphCollection* gc,
                                                            BirdFontGlyphMaster* master,
                                                            GDataOutputStream* os,
                                                            GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_selected (BirdFontBirdFontFile* self,
                                              BirdFontGlyphMaster* master,
                                              GDataOutputStream* os,
                                              GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_glyph_collection_end (BirdFontBirdFontFile* self,
                                                          GDataOutputStream* os,
                                                          GError** error);
static void bird_font_bird_font_part_write_glyph (BirdFontBirdFontPart* self,
                                           BirdFontBirdFontFile* bf,
                                           BirdFontGlyphCollection* gc,
                                           BirdFontGlyphMaster* master,
                                           BirdFontGlyph* g,
                                           GError** error);
static void bird_font_bird_font_part_write_glyph_background_image (BirdFontBirdFontPart* self,
                                                            BirdFontBirdFontFile* bf,
                                                            BirdFontGlyphCollection* gc,
                                                            BirdFontGlyph* g,
                                                            GError** error);
static void ____lambda338__gfunc (gconstpointer data,
                           gpointer self);
VALA_EXTERN void bird_font_bird_font_file_write_kerning (BirdFontBirdFontFile* self,
                                             GDataOutputStream* os,
                                             GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_images (BirdFontBirdFontFile* self,
                                            GDataOutputStream* os,
                                            GError** error);
VALA_EXTERN void bird_font_bird_font_file_write_glyph (BirdFontBirdFontFile* self,
                                           BirdFontGlyph* g,
                                           GDataOutputStream* os,
                                           GError** error);
static GFile* bird_font_bird_font_part_find_root (BirdFontBirdFontPart* self,
                                           const gchar* directory,
                                           GError** error);
static void bird_font_bird_font_part_find_parts (BirdFontBirdFontPart* self,
                                          const gchar* directory,
                                          GError** error);
static GFile* bird_font_bird_font_part_new_subdirectory (BirdFontBirdFontPart* self,
                                                  GFile* d,
                                                  const gchar* subdir,
                                                  GError** error);
static void bird_font_bird_font_part_finalize (GObject * obj);
static GType bird_font_bird_font_part_get_type_once (void);

static inline gpointer
bird_font_bird_font_part_get_instance_private (BirdFontBirdFontPart* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontBirdFontPart_private_offset);
}

static void
__lambda334_ (BirdFontBirdFontPart* self)
{
	BirdFontFont* _tmp0_;
	_tmp0_ = bird_font_font_empty;
	self->priv->font = _tmp0_;
}

static void
___lambda334__bird_font_font_font_deleted (BirdFontFont* _sender,
                                           gpointer self)
{
	__lambda334_ ((BirdFontBirdFontPart*) self);
}

BirdFontBirdFontPart*
bird_font_bird_font_part_construct (GType object_type,
                                    BirdFontFont* font)
{
	BirdFontBirdFontPart * self = NULL;
	GeeArrayList* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (font != NULL, NULL);
	self = (BirdFontBirdFontPart*) g_object_new (object_type, NULL);
	self->priv->font = font;
	g_signal_connect_object (font, "font-deleted", (GCallback) ___lambda334__bird_font_font_font_deleted, self, 0);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->parts);
	self->priv->parts = _tmp0_;
	_tmp1_ = g_strdup ("");
	_g_free0 (self->priv->root_directory);
	self->priv->root_directory = _tmp1_;
	return self;
}

BirdFontBirdFontPart*
bird_font_bird_font_part_new (BirdFontFont* font)
{
	return bird_font_bird_font_part_construct (BIRD_FONT_TYPE_BIRD_FONT_PART, font);
}

gboolean
bird_font_bird_font_part_load (BirdFontBirdFontPart* self,
                               const gchar* bfp_file)
{
	BirdFontBirdFontFile* bf = NULL;
	BirdFontFont* _tmp0_;
	BirdFontBirdFontFile* _tmp1_;
	GFile* bfp_dir = NULL;
	GFile* image_dir = NULL;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (bfp_file != NULL, FALSE);
	_tmp0_ = self->priv->font;
	_tmp1_ = bird_font_bird_font_file_new (_tmp0_);
	bf = _tmp1_;
	{
		BirdFontFont* _tmp2_;
		BirdFontFont* _tmp3_;
		GeeArrayList* _tmp4_;
		const gchar* _tmp5_;
		GFile* _tmp6_;
		GFile* _tmp7_;
		GFile* _tmp8_;
		GFile* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		bird_font_bird_font_part_find_all_parts (self, bfp_file, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = self->priv->font;
		bird_font_font_set_bfp (_tmp2_, TRUE);
		_tmp3_ = self->priv->font;
		_tmp4_ = _tmp3_->background_images;
		gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp4_);
		_tmp5_ = self->priv->root_directory;
		_tmp6_ = g_file_new_for_path (_tmp5_);
		_g_object_unref0 (bfp_dir);
		bfp_dir = _tmp6_;
		_tmp7_ = bfp_dir;
		_tmp8_ = bird_font_get_child (_tmp7_, "images");
		_g_object_unref0 (image_dir);
		image_dir = _tmp8_;
		_tmp9_ = image_dir;
		_tmp10_ = g_file_get_path (_tmp9_);
		_tmp11_ = (gchar*) _tmp10_;
		bird_font_bird_font_part_copy_backgrounds (self, _tmp11_, &_inner_error0_);
		_g_free0 (_tmp11_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		{
			GeeArrayList* _fn_list = NULL;
			GeeArrayList* _tmp12_;
			gint _fn_size = 0;
			GeeArrayList* _tmp13_;
			gint _tmp14_;
			gint _tmp15_;
			gint _fn_index = 0;
			_tmp12_ = self->priv->parts;
			_fn_list = _tmp12_;
			_tmp13_ = _fn_list;
			_tmp14_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp13_);
			_tmp15_ = _tmp14_;
			_fn_size = _tmp15_;
			_fn_index = -1;
			while (TRUE) {
				gint _tmp16_;
				gint _tmp17_;
				gchar* fn = NULL;
				GeeArrayList* _tmp18_;
				gpointer _tmp19_;
				BirdFontBirdFontFile* _tmp20_;
				const gchar* _tmp21_;
				_fn_index = _fn_index + 1;
				_tmp16_ = _fn_index;
				_tmp17_ = _fn_size;
				if (!(_tmp16_ < _tmp17_)) {
					break;
				}
				_tmp18_ = _fn_list;
				_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _tmp18_, _fn_index);
				fn = (gchar*) _tmp19_;
				_tmp20_ = bf;
				_tmp21_ = fn;
				bird_font_bird_font_file_load_part (_tmp20_, _tmp21_);
				_g_free0 (fn);
			}
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp22_;
		const gchar* _tmp23_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp22_ = e;
		_tmp23_ = _tmp22_->message;
		g_warning ("BirdFontPart.vala:61: %s", _tmp23_);
		result = FALSE;
		_g_error_free0 (e);
		_g_object_unref0 (image_dir);
		_g_object_unref0 (bfp_dir);
		_g_object_unref0 (bf);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp24_ = FALSE;
		_g_object_unref0 (image_dir);
		_g_object_unref0 (bfp_dir);
		_g_object_unref0 (bf);
		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 _tmp24_;
	}
	result = TRUE;
	_g_object_unref0 (image_dir);
	_g_object_unref0 (bfp_dir);
	_g_object_unref0 (bf);
	return result;
}

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

gchar*
bird_font_bird_font_part_get_path (BirdFontBirdFontPart* self)
{
	gchar* path = NULL;
	gchar* _tmp0_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("");
	path = _tmp0_;
	{
		GFile* _tmp1_ = NULL;
		BirdFontFont* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		GFile* _tmp7_;
		GFile* _tmp8_;
		gchar* _tmp9_;
		_tmp2_ = self->priv->font;
		_tmp3_ = _tmp2_->full_name;
		_tmp4_ = string_to_string (_tmp3_);
		_tmp5_ = g_strconcat (_tmp4_, ".bfp", NULL);
		_tmp6_ = _tmp5_;
		_tmp7_ = bird_font_bird_font_part_get_destination_file (self, _tmp6_, "", "", &_inner_error0_);
		_tmp8_ = _tmp7_;
		_g_free0 (_tmp6_);
		_tmp1_ = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp9_ = g_file_get_path (_tmp1_);
		_g_free0 (path);
		path = (gchar*) _tmp9_;
		_g_object_unref0 (_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp10_;
		const gchar* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		g_warning ("BirdFontPart.vala:74: %s", _tmp11_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (path);
		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;
	}
	result = path;
	return result;
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		BirdFontBirdFontPart* self;
		self = _data9_->self;
		_g_object_unref0 (_data9_->bf);
		_g_object_unref0 (_data9_->os);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static void
___lambda338_ (Block9Data* _data9_,
               BirdFontGlyphCollection* gc)
{
	BirdFontBirdFontPart* self;
	GError* _inner_error0_ = NULL;
	self = _data9_->self;
	g_return_if_fail (gc != NULL);
	{
		gchar* selected_file_name = NULL;
		gchar* dir_name = NULL;
		BirdFontGlyph* _tmp0_;
		BirdFontGlyph* _tmp1_;
		gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		if (bird_font_is_null (gc)) {
			g_warning ("BirdFontPart.vala:154: No glyph collection");
		}
		_tmp0_ = bird_font_glyph_collection_get_current (G_TYPE_CHECK_INSTANCE_CAST (gc, BIRD_FONT_TYPE_GLYPH_COLLECTION, BirdFontGlyphCollection));
		_tmp1_ = _tmp0_;
		_tmp2_ = bird_font_bird_font_part_get_first_number_in_unicode (_tmp1_);
		_g_free0 (selected_file_name);
		selected_file_name = _tmp2_;
		_g_object_unref0 (_tmp1_);
		_tmp3_ = selected_file_name;
		_tmp4_ = bird_font_bird_font_part_get_subdir_name (self, _tmp3_);
		_g_free0 (dir_name);
		dir_name = _tmp4_;
		{
			GeeArrayList* _master_list = NULL;
			GeeArrayList* _tmp5_;
			gint _master_size = 0;
			GeeArrayList* _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			gint _master_index = 0;
			_tmp5_ = gc->glyph_masters;
			_master_list = _tmp5_;
			_tmp6_ = _master_list;
			_tmp7_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp6_);
			_tmp8_ = _tmp7_;
			_master_size = _tmp8_;
			_master_index = -1;
			while (TRUE) {
				gint _tmp9_;
				gint _tmp10_;
				BirdFontGlyphMaster* master = NULL;
				GeeArrayList* _tmp11_;
				gpointer _tmp12_;
				GDataOutputStream* _tmp13_ = NULL;
				const gchar* _tmp14_;
				const gchar* _tmp15_;
				BirdFontGlyphMaster* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				const gchar* _tmp19_;
				gchar* _tmp20_;
				gchar* _tmp21_;
				const gchar* _tmp22_;
				GDataOutputStream* _tmp23_;
				GDataOutputStream* _tmp24_;
				GDataOutputStream* _tmp25_;
				BirdFontBirdFontFile* _tmp26_;
				GDataOutputStream* _tmp27_;
				BirdFontBirdFontFile* _tmp28_;
				BirdFontGlyphMaster* _tmp29_;
				GDataOutputStream* _tmp30_;
				BirdFontBirdFontFile* _tmp31_;
				BirdFontGlyphMaster* _tmp32_;
				GDataOutputStream* _tmp33_;
				BirdFontBirdFontFile* _tmp34_;
				GDataOutputStream* _tmp35_;
				BirdFontBirdFontFile* _tmp36_;
				GDataOutputStream* _tmp37_;
				GDataOutputStream* _tmp38_;
				_master_index = _master_index + 1;
				_tmp9_ = _master_index;
				_tmp10_ = _master_size;
				if (!(_tmp9_ < _tmp10_)) {
					break;
				}
				_tmp11_ = _master_list;
				_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _master_index);
				master = (BirdFontGlyphMaster*) _tmp12_;
				_tmp14_ = selected_file_name;
				_tmp15_ = string_to_string (_tmp14_);
				_tmp16_ = master;
				_tmp17_ = bird_font_glyph_master_get_id (_tmp16_);
				_tmp18_ = _tmp17_;
				_tmp19_ = string_to_string (_tmp18_);
				_tmp20_ = g_strconcat ("selected_", _tmp15_, "_", _tmp19_, ".bfp", NULL);
				_tmp21_ = _tmp20_;
				_tmp22_ = dir_name;
				_tmp23_ = bird_font_bird_font_part_create_file (self, _tmp21_, "glyphs", _tmp22_, &_inner_error0_);
				_tmp24_ = _tmp23_;
				_g_free0 (_tmp21_);
				_g_free0 (_tmp18_);
				_tmp13_ = _tmp24_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_tmp25_ = _tmp13_;
				_tmp13_ = NULL;
				_g_object_unref0 (_data9_->os);
				_data9_->os = _tmp25_;
				_tmp26_ = _data9_->bf;
				_tmp27_ = _data9_->os;
				bird_font_bird_font_file_write_root_tag (_tmp26_, _tmp27_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp13_);
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_tmp28_ = _data9_->bf;
				_tmp29_ = master;
				_tmp30_ = _data9_->os;
				bird_font_bird_font_file_write_glyph_collection_start (_tmp28_, gc, _tmp29_, _tmp30_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp13_);
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_tmp31_ = _data9_->bf;
				_tmp32_ = master;
				_tmp33_ = _data9_->os;
				bird_font_bird_font_file_write_selected (_tmp31_, G_TYPE_CHECK_INSTANCE_CAST (_tmp32_, BIRD_FONT_TYPE_GLYPH_MASTER, BirdFontGlyphMaster), _tmp33_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp13_);
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_tmp34_ = _data9_->bf;
				_tmp35_ = _data9_->os;
				bird_font_bird_font_file_write_glyph_collection_end (_tmp34_, _tmp35_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp13_);
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_tmp36_ = _data9_->bf;
				_tmp37_ = _data9_->os;
				bird_font_bird_font_file_write_closing_root_tag (_tmp36_, _tmp37_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp13_);
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_tmp38_ = _data9_->os;
				g_output_stream_close ((GOutputStream*) _tmp38_, NULL, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp13_);
					_g_object_unref0 (master);
					_g_free0 (dir_name);
					_g_free0 (selected_file_name);
					goto __catch0_g_error;
				}
				_g_object_unref0 (_tmp13_);
				_g_object_unref0 (master);
			}
		}
		{
			GeeArrayList* _master_list = NULL;
			GeeArrayList* _tmp39_;
			gint _master_size = 0;
			GeeArrayList* _tmp40_;
			gint _tmp41_;
			gint _tmp42_;
			gint _master_index = 0;
			_tmp39_ = gc->glyph_masters;
			_master_list = _tmp39_;
			_tmp40_ = _master_list;
			_tmp41_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp40_);
			_tmp42_ = _tmp41_;
			_master_size = _tmp42_;
			_master_index = -1;
			while (TRUE) {
				gint _tmp43_;
				gint _tmp44_;
				BirdFontGlyphMaster* master = NULL;
				GeeArrayList* _tmp45_;
				gpointer _tmp46_;
				_master_index = _master_index + 1;
				_tmp43_ = _master_index;
				_tmp44_ = _master_size;
				if (!(_tmp43_ < _tmp44_)) {
					break;
				}
				_tmp45_ = _master_list;
				_tmp46_ = gee_abstract_list_get ((GeeAbstractList*) _tmp45_, _master_index);
				master = (BirdFontGlyphMaster*) _tmp46_;
				{
					GeeArrayList* _g_list = NULL;
					BirdFontGlyphMaster* _tmp47_;
					GeeArrayList* _tmp48_;
					gint _g_size = 0;
					GeeArrayList* _tmp49_;
					gint _tmp50_;
					gint _tmp51_;
					gint _g_index = 0;
					_tmp47_ = master;
					_tmp48_ = _tmp47_->glyphs;
					_g_list = _tmp48_;
					_tmp49_ = _g_list;
					_tmp50_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp49_);
					_tmp51_ = _tmp50_;
					_g_size = _tmp51_;
					_g_index = -1;
					while (TRUE) {
						gint _tmp52_;
						gint _tmp53_;
						BirdFontGlyph* g = NULL;
						GeeArrayList* _tmp54_;
						gpointer _tmp55_;
						_g_index = _g_index + 1;
						_tmp52_ = _g_index;
						_tmp53_ = _g_size;
						if (!(_tmp52_ < _tmp53_)) {
							break;
						}
						_tmp54_ = _g_list;
						_tmp55_ = gee_abstract_list_get ((GeeAbstractList*) _tmp54_, _g_index);
						g = (BirdFontGlyph*) _tmp55_;
						{
							BirdFontBirdFontFile* _tmp56_;
							BirdFontGlyphMaster* _tmp57_;
							BirdFontGlyph* _tmp58_;
							BirdFontBirdFontFile* _tmp59_;
							BirdFontGlyph* _tmp60_;
							_tmp56_ = _data9_->bf;
							_tmp57_ = master;
							_tmp58_ = g;
							bird_font_bird_font_part_write_glyph (self, _tmp56_, gc, _tmp57_, _tmp58_, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								goto __catch1_g_error;
							}
							_tmp59_ = _data9_->bf;
							_tmp60_ = g;
							bird_font_bird_font_part_write_glyph_background_image (self, _tmp59_, gc, _tmp60_, &_inner_error0_);
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								goto __catch1_g_error;
							}
						}
						goto __finally1;
						__catch1_g_error:
						{
							GError* e = NULL;
							GError* _tmp61_;
							const gchar* _tmp62_;
							e = _inner_error0_;
							_inner_error0_ = NULL;
							_tmp61_ = e;
							_tmp62_ = _tmp61_->message;
							g_warning ("BirdFontPart.vala:178: %s", _tmp62_);
							_g_error_free0 (e);
						}
						__finally1:
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_g_object_unref0 (g);
							_g_object_unref0 (master);
							_g_free0 (dir_name);
							_g_free0 (selected_file_name);
							goto __catch0_g_error;
						}
						_g_object_unref0 (g);
					}
				}
				_g_object_unref0 (master);
			}
		}
		_g_free0 (dir_name);
		_g_free0 (selected_file_name);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp63_;
		const gchar* _tmp64_;
		gchar* _tmp65_;
		gchar* _tmp66_;
		GError* _tmp67_;
		const gchar* _tmp68_;
		const gchar* _tmp69_;
		gchar* _tmp70_;
		gchar* _tmp71_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp63_ = self->priv->root_directory;
		_tmp64_ = string_to_string (_tmp63_);
		_tmp65_ = g_strconcat ("Can not save bfp files to ", _tmp64_, "\n", NULL);
		_tmp66_ = _tmp65_;
		g_warning ("BirdFontPart.vala:183: %s", _tmp66_);
		_g_free0 (_tmp66_);
		_tmp67_ = e;
		_tmp68_ = _tmp67_->message;
		_tmp69_ = string_to_string (_tmp68_);
		_tmp70_ = g_strconcat (_tmp69_, " \n", NULL);
		_tmp71_ = _tmp70_;
		g_warning ("BirdFontPart.vala:184: %s", _tmp71_);
		_g_free0 (_tmp71_);
		_data9_->_error_ = TRUE;
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static void
____lambda338__gfunc (gconstpointer data,
                      gpointer self)
{
	___lambda338_ (self, (BirdFontGlyphCollection*) data);
}

gboolean
bird_font_bird_font_part_save (BirdFontBirdFontPart* self)
{
	Block9Data* _data9_;
	BirdFontFont* _tmp0_;
	BirdFontBirdFontFile* _tmp1_;
	gchar* file_name = NULL;
	gchar* glyph_dir_name = NULL;
	GFile* glyph_file = NULL;
	const gchar* _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_data9_->self = g_object_ref (self);
	_tmp0_ = self->priv->font;
	_tmp1_ = bird_font_bird_font_file_new (_tmp0_);
	_data9_->bf = _tmp1_;
	_data9_->_error_ = FALSE;
	_tmp2_ = self->priv->root_directory;
	if (g_strcmp0 (_tmp2_, "") == 0) {
		g_warning ("BirdFontPart.vala:89: No directory is created for this birdfont part.");
		result = FALSE;
		_g_object_unref0 (glyph_file);
		_g_free0 (glyph_dir_name);
		_g_free0 (file_name);
		block9_data_unref (_data9_);
		_data9_ = NULL;
		return result;
	}
	{
		GDataOutputStream* _tmp29_ = NULL;
		BirdFontFont* _tmp30_;
		const gchar* _tmp31_;
		const gchar* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		GDataOutputStream* _tmp35_;
		GDataOutputStream* _tmp36_;
		GDataOutputStream* _tmp37_;
		BirdFontBirdFontFile* _tmp38_;
		GDataOutputStream* _tmp39_;
		BirdFontBirdFontFile* _tmp40_;
		GDataOutputStream* _tmp41_;
		GDataOutputStream* _tmp42_;
		GDataOutputStream* _tmp43_ = NULL;
		GDataOutputStream* _tmp44_;
		GDataOutputStream* _tmp45_;
		BirdFontBirdFontFile* _tmp46_;
		GDataOutputStream* _tmp47_;
		BirdFontBirdFontFile* _tmp48_;
		GDataOutputStream* _tmp49_;
		BirdFontBirdFontFile* _tmp50_;
		GDataOutputStream* _tmp51_;
		GDataOutputStream* _tmp52_;
		GDataOutputStream* _tmp53_ = NULL;
		GDataOutputStream* _tmp54_;
		GDataOutputStream* _tmp55_;
		BirdFontBirdFontFile* _tmp56_;
		GDataOutputStream* _tmp57_;
		BirdFontBirdFontFile* _tmp58_;
		GDataOutputStream* _tmp59_;
		BirdFontBirdFontFile* _tmp60_;
		GDataOutputStream* _tmp61_;
		GDataOutputStream* _tmp62_;
		GDataOutputStream* _tmp63_ = NULL;
		GDataOutputStream* _tmp64_;
		GDataOutputStream* _tmp65_;
		BirdFontBirdFontFile* _tmp66_;
		GDataOutputStream* _tmp67_;
		BirdFontBirdFontFile* _tmp68_;
		GDataOutputStream* _tmp69_;
		BirdFontBirdFontFile* _tmp70_;
		GDataOutputStream* _tmp71_;
		GDataOutputStream* _tmp72_;
		GDataOutputStream* _tmp73_ = NULL;
		GDataOutputStream* _tmp74_;
		GDataOutputStream* _tmp75_;
		BirdFontBirdFontFile* _tmp76_;
		GDataOutputStream* _tmp77_;
		BirdFontBirdFontFile* _tmp78_;
		GDataOutputStream* _tmp79_;
		BirdFontBirdFontFile* _tmp80_;
		GDataOutputStream* _tmp81_;
		GDataOutputStream* _tmp82_;
		GDataOutputStream* _tmp83_ = NULL;
		GDataOutputStream* _tmp84_;
		GDataOutputStream* _tmp85_;
		BirdFontBirdFontFile* _tmp86_;
		GDataOutputStream* _tmp87_;
		BirdFontBirdFontFile* _tmp88_;
		GDataOutputStream* _tmp89_;
		BirdFontBirdFontFile* _tmp90_;
		GDataOutputStream* _tmp91_;
		GDataOutputStream* _tmp92_;
		GDataOutputStream* _tmp93_ = NULL;
		GDataOutputStream* _tmp94_;
		GDataOutputStream* _tmp95_;
		BirdFontBirdFontFile* _tmp96_;
		GDataOutputStream* _tmp97_;
		BirdFontBirdFontFile* _tmp98_;
		GDataOutputStream* _tmp99_;
		BirdFontBirdFontFile* _tmp100_;
		GDataOutputStream* _tmp101_;
		GDataOutputStream* _tmp102_;
		BirdFontFont* _tmp103_;
		BirdFontGlyphTable* _tmp104_;
		GDataOutputStream* _tmp105_ = NULL;
		GDataOutputStream* _tmp106_;
		GDataOutputStream* _tmp107_;
		BirdFontBirdFontFile* _tmp108_;
		GDataOutputStream* _tmp109_;
		BirdFontBirdFontFile* _tmp110_;
		GDataOutputStream* _tmp111_;
		BirdFontBirdFontFile* _tmp112_;
		GDataOutputStream* _tmp113_;
		GDataOutputStream* _tmp114_;
		GDataOutputStream* _tmp115_ = NULL;
		GDataOutputStream* _tmp116_;
		GDataOutputStream* _tmp117_;
		BirdFontBirdFontFile* _tmp118_;
		GDataOutputStream* _tmp119_;
		BirdFontBirdFontFile* _tmp120_;
		GDataOutputStream* _tmp121_;
		BirdFontBirdFontFile* _tmp122_;
		GDataOutputStream* _tmp123_;
		GDataOutputStream* _tmp124_;
		{
			GeeArrayList* _deleted_glyph_list = NULL;
			BirdFontFont* _tmp3_;
			GeeArrayList* _tmp4_;
			gint _deleted_glyph_size = 0;
			GeeArrayList* _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			gint _deleted_glyph_index = 0;
			_tmp3_ = self->priv->font;
			_tmp4_ = _tmp3_->deleted_glyphs;
			_deleted_glyph_list = _tmp4_;
			_tmp5_ = _deleted_glyph_list;
			_tmp6_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp5_);
			_tmp7_ = _tmp6_;
			_deleted_glyph_size = _tmp7_;
			_deleted_glyph_index = -1;
			while (TRUE) {
				gint _tmp8_;
				gint _tmp9_;
				gchar* deleted_glyph = NULL;
				GeeArrayList* _tmp10_;
				gpointer _tmp11_;
				const gchar* _tmp12_;
				gchar* _tmp13_;
				const gchar* _tmp14_;
				gchar* _tmp15_;
				GFile* _tmp16_ = NULL;
				const gchar* _tmp17_;
				const gchar* _tmp18_;
				GFile* _tmp19_;
				GFile* _tmp20_;
				GFile* _tmp21_;
				GFile* _tmp23_;
				gchar* _tmp24_;
				gchar* _tmp25_;
				const gchar* _tmp26_;
				gchar* _tmp27_;
				gchar* _tmp28_;
				_deleted_glyph_index = _deleted_glyph_index + 1;
				_tmp8_ = _deleted_glyph_index;
				_tmp9_ = _deleted_glyph_size;
				if (!(_tmp8_ < _tmp9_)) {
					break;
				}
				_tmp10_ = _deleted_glyph_list;
				_tmp11_ = gee_abstract_list_get ((GeeAbstractList*) _tmp10_, _deleted_glyph_index);
				deleted_glyph = (gchar*) _tmp11_;
				_tmp12_ = deleted_glyph;
				_tmp13_ = g_strdup (_tmp12_);
				_g_free0 (file_name);
				file_name = _tmp13_;
				_tmp14_ = file_name;
				_tmp15_ = bird_font_bird_font_part_get_subdir_name (self, _tmp14_);
				_g_free0 (glyph_dir_name);
				glyph_dir_name = _tmp15_;
				_tmp17_ = file_name;
				_tmp18_ = glyph_dir_name;
				_tmp19_ = bird_font_bird_font_part_get_destination_file (self, _tmp17_, "glyphs", _tmp18_, &_inner_error0_);
				_tmp16_ = _tmp19_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (deleted_glyph);
					goto __catch0_g_error;
				}
				_tmp20_ = _tmp16_;
				_tmp16_ = NULL;
				_g_object_unref0 (glyph_file);
				glyph_file = _tmp20_;
				_tmp21_ = glyph_file;
				if (g_file_query_exists (_tmp21_, NULL)) {
					GFile* _tmp22_;
					_tmp22_ = glyph_file;
					g_file_delete (_tmp22_, NULL, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_g_object_unref0 (_tmp16_);
						_g_free0 (deleted_glyph);
						goto __catch0_g_error;
					}
				}
				_tmp23_ = glyph_file;
				_tmp24_ = g_file_get_path (_tmp23_);
				_tmp25_ = (gchar*) _tmp24_;
				_tmp26_ = string_to_string (_tmp25_);
				_tmp27_ = g_strconcat (_tmp26_, "\n", NULL);
				_tmp28_ = _tmp27_;
				g_print ("%s", _tmp28_);
				_g_free0 (_tmp28_);
				_g_free0 (_tmp25_);
				_g_object_unref0 (_tmp16_);
				_g_free0 (deleted_glyph);
			}
		}
		_tmp30_ = self->priv->font;
		_tmp31_ = _tmp30_->full_name;
		_tmp32_ = string_to_string (_tmp31_);
		_tmp33_ = g_strconcat (_tmp32_, ".bfp", NULL);
		_tmp34_ = _tmp33_;
		_tmp35_ = bird_font_bird_font_part_create_file (self, _tmp34_, "", "", &_inner_error0_);
		_tmp36_ = _tmp35_;
		_g_free0 (_tmp34_);
		_tmp29_ = _tmp36_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp37_ = _tmp29_;
		_tmp29_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp37_;
		_tmp38_ = _data9_->bf;
		_tmp39_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp38_, _tmp39_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp40_ = _data9_->bf;
		_tmp41_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp40_, _tmp41_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp42_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp42_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp44_ = bird_font_bird_font_part_create_file (self, "description.bfp", "", "", &_inner_error0_);
		_tmp43_ = _tmp44_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp45_ = _tmp43_;
		_tmp43_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp45_;
		_tmp46_ = _data9_->bf;
		_tmp47_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp46_, _tmp47_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp48_ = _data9_->bf;
		_tmp49_ = _data9_->os;
		bird_font_bird_font_file_write_description (_tmp48_, _tmp49_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp50_ = _data9_->bf;
		_tmp51_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp50_, _tmp51_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp52_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp52_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp54_ = bird_font_bird_font_part_create_file (self, "lines.bfp", "", "", &_inner_error0_);
		_tmp53_ = _tmp54_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp55_ = _tmp53_;
		_tmp53_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp55_;
		_tmp56_ = _data9_->bf;
		_tmp57_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp56_, _tmp57_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp58_ = _data9_->bf;
		_tmp59_ = _data9_->os;
		bird_font_bird_font_file_write_lines (_tmp58_, _tmp59_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp60_ = _data9_->bf;
		_tmp61_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp60_, _tmp61_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp62_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp62_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp64_ = bird_font_bird_font_part_create_file (self, "settings.bfp", "", "", &_inner_error0_);
		_tmp63_ = _tmp64_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp65_ = _tmp63_;
		_tmp63_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp65_;
		_tmp66_ = _data9_->bf;
		_tmp67_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp66_, _tmp67_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp68_ = _data9_->bf;
		_tmp69_ = _data9_->os;
		bird_font_bird_font_file_write_settings (_tmp68_, _tmp69_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp70_ = _data9_->bf;
		_tmp71_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp70_, _tmp71_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp72_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp72_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp74_ = bird_font_bird_font_part_create_file (self, "spacing.bfp", "", "", &_inner_error0_);
		_tmp73_ = _tmp74_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp75_ = _tmp73_;
		_tmp73_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp75_;
		_tmp76_ = _data9_->bf;
		_tmp77_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp76_, _tmp77_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp78_ = _data9_->bf;
		_tmp79_ = _data9_->os;
		bird_font_bird_font_file_write_spacing_classes (_tmp78_, _tmp79_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp80_ = _data9_->bf;
		_tmp81_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp80_, _tmp81_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp82_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp82_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp84_ = bird_font_bird_font_part_create_file (self, "ligatures.bfp", "", "", &_inner_error0_);
		_tmp83_ = _tmp84_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp85_ = _tmp83_;
		_tmp83_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp85_;
		_tmp86_ = _data9_->bf;
		_tmp87_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp86_, _tmp87_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp88_ = _data9_->bf;
		_tmp89_ = _data9_->os;
		bird_font_bird_font_file_write_ligatures (_tmp88_, _tmp89_);
		_tmp90_ = _data9_->bf;
		_tmp91_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp90_, _tmp91_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp92_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp92_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp94_ = bird_font_bird_font_part_create_file (self, "alternates.bfp", "", "", &_inner_error0_);
		_tmp93_ = _tmp94_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp95_ = _tmp93_;
		_tmp93_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp95_;
		_tmp96_ = _data9_->bf;
		_tmp97_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp96_, _tmp97_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp98_ = _data9_->bf;
		_tmp99_ = _data9_->os;
		bird_font_bird_font_file_write_alternates (_tmp98_, _tmp99_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp100_ = _data9_->bf;
		_tmp101_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp100_, _tmp101_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp102_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp102_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp103_ = self->priv->font;
		_tmp104_ = _tmp103_->glyph_cache;
		bird_font_glyph_table_for_each (_tmp104_, ____lambda338__gfunc, _data9_);
		_tmp106_ = bird_font_bird_font_part_create_file (self, "kerning.bfp", "", "", &_inner_error0_);
		_tmp105_ = _tmp106_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp107_ = _tmp105_;
		_tmp105_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp107_;
		_tmp108_ = _data9_->bf;
		_tmp109_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp108_, _tmp109_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp110_ = _data9_->bf;
		_tmp111_ = _data9_->os;
		bird_font_bird_font_file_write_kerning (_tmp110_, _tmp111_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp112_ = _data9_->bf;
		_tmp113_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp112_, _tmp113_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp114_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp114_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp116_ = bird_font_bird_font_part_create_file (self, "images.bfp", "", "", &_inner_error0_);
		_tmp115_ = _tmp116_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp117_ = _tmp115_;
		_tmp115_ = NULL;
		_g_object_unref0 (_data9_->os);
		_data9_->os = _tmp117_;
		_tmp118_ = _data9_->bf;
		_tmp119_ = _data9_->os;
		bird_font_bird_font_file_write_root_tag (_tmp118_, _tmp119_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp115_);
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp120_ = _data9_->bf;
		_tmp121_ = _data9_->os;
		bird_font_bird_font_file_write_images (_tmp120_, _tmp121_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp115_);
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp122_ = _data9_->bf;
		_tmp123_ = _data9_->os;
		bird_font_bird_font_file_write_closing_root_tag (_tmp122_, _tmp123_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp115_);
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_tmp124_ = _data9_->os;
		g_output_stream_close ((GOutputStream*) _tmp124_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp115_);
			_g_object_unref0 (_tmp105_);
			_g_object_unref0 (_tmp93_);
			_g_object_unref0 (_tmp83_);
			_g_object_unref0 (_tmp73_);
			_g_object_unref0 (_tmp63_);
			_g_object_unref0 (_tmp53_);
			_g_object_unref0 (_tmp43_);
			_g_object_unref0 (_tmp29_);
			goto __catch0_g_error;
		}
		_g_object_unref0 (_tmp115_);
		_g_object_unref0 (_tmp105_);
		_g_object_unref0 (_tmp93_);
		_g_object_unref0 (_tmp83_);
		_g_object_unref0 (_tmp73_);
		_g_object_unref0 (_tmp63_);
		_g_object_unref0 (_tmp53_);
		_g_object_unref0 (_tmp43_);
		_g_object_unref0 (_tmp29_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp125_;
		const gchar* _tmp126_;
		gchar* _tmp127_;
		gchar* _tmp128_;
		GError* _tmp129_;
		const gchar* _tmp130_;
		const gchar* _tmp131_;
		gchar* _tmp132_;
		gchar* _tmp133_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp125_ = self->priv->root_directory;
		_tmp126_ = string_to_string (_tmp125_);
		_tmp127_ = g_strconcat ("Failed to save bfp files to ", _tmp126_, "\n", NULL);
		_tmp128_ = _tmp127_;
		g_warning ("BirdFontPart.vala:202: %s", _tmp128_);
		_g_free0 (_tmp128_);
		_tmp129_ = e;
		_tmp130_ = _tmp129_->message;
		_tmp131_ = string_to_string (_tmp130_);
		_tmp132_ = g_strconcat (_tmp131_, " \n", NULL);
		_tmp133_ = _tmp132_;
		g_warning ("BirdFontPart.vala:203: %s", _tmp133_);
		_g_free0 (_tmp133_);
		_data9_->_error_ = TRUE;
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp134_ = FALSE;
		_g_object_unref0 (glyph_file);
		_g_free0 (glyph_dir_name);
		_g_free0 (file_name);
		block9_data_unref (_data9_);
		_data9_ = NULL;
		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 _tmp134_;
	}
	result = !_data9_->_error_;
	_g_object_unref0 (glyph_file);
	_g_free0 (glyph_dir_name);
	_g_free0 (file_name);
	block9_data_unref (_data9_);
	_data9_ = NULL;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
bird_font_bird_font_part_copy_backgrounds (BirdFontBirdFontPart* self,
                                           const gchar* folder,
                                           GError** error)
{
	GFileInfo* info = NULL;
	GFileInfo* fi = NULL;
	GFileEnumerator* e = NULL;
	gchar* name = NULL;
	GFile* image_dir = NULL;
	BirdFontBackgroundImage* bg = NULL;
	GFile* found = NULL;
	GFile* parts = NULL;
	GFile* dest = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (folder != NULL);
	_tmp0_ = g_file_new_for_path (folder);
	_g_object_unref0 (image_dir);
	image_dir = _tmp0_;
	_tmp1_ = image_dir;
	if (g_file_query_exists (_tmp1_, NULL)) {
		GFileInfo* _tmp2_ = NULL;
		GFile* _tmp3_;
		const gchar* _tmp4_;
		GFileInfo* _tmp5_;
		GFileInfo* _tmp6_;
		GFileInfo* _tmp7_;
		GFileEnumerator* _tmp15_ = NULL;
		GFile* _tmp16_;
		const gchar* _tmp17_;
		GFileEnumerator* _tmp18_;
		GFileEnumerator* _tmp19_;
		_tmp3_ = image_dir;
		_tmp4_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
		_tmp5_ = g_file_query_info (_tmp3_, _tmp4_, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp2_ = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dest);
			_g_object_unref0 (parts);
			_g_object_unref0 (found);
			_g_object_unref0 (bg);
			_g_object_unref0 (image_dir);
			_g_free0 (name);
			_g_object_unref0 (e);
			_g_object_unref0 (fi);
			_g_object_unref0 (info);
			return;
		}
		_tmp6_ = _tmp2_;
		_tmp2_ = NULL;
		_g_object_unref0 (info);
		info = _tmp6_;
		_tmp7_ = info;
		if (g_file_info_get_file_type (_tmp7_) != G_FILE_TYPE_DIRECTORY) {
			GFile* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			const gchar* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			GError* _tmp14_;
			_tmp8_ = image_dir;
			_tmp9_ = g_file_get_path (_tmp8_);
			_tmp10_ = (gchar*) _tmp9_;
			_tmp11_ = string_to_string (_tmp10_);
			_tmp12_ = g_strconcat (_tmp11_, " is not a directory.", NULL);
			_tmp13_ = _tmp12_;
			g_warning ("BirdFontPart.vala:226: %s", _tmp13_);
			_g_free0 (_tmp13_);
			_g_free0 (_tmp10_);
			_tmp14_ = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOTDIR, "Not a directory.");
			_inner_error0_ = _tmp14_;
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp2_);
			_g_object_unref0 (dest);
			_g_object_unref0 (parts);
			_g_object_unref0 (found);
			_g_object_unref0 (bg);
			_g_object_unref0 (image_dir);
			_g_free0 (name);
			_g_object_unref0 (e);
			_g_object_unref0 (fi);
			_g_object_unref0 (info);
			return;
		}
		_tmp16_ = image_dir;
		_tmp17_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
		_tmp18_ = g_file_enumerate_children (_tmp16_, _tmp17_, 0, NULL, &_inner_error0_);
		_tmp15_ = _tmp18_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp2_);
			_g_object_unref0 (dest);
			_g_object_unref0 (parts);
			_g_object_unref0 (found);
			_g_object_unref0 (bg);
			_g_object_unref0 (image_dir);
			_g_free0 (name);
			_g_object_unref0 (e);
			_g_object_unref0 (fi);
			_g_object_unref0 (info);
			return;
		}
		_tmp19_ = _tmp15_;
		_tmp15_ = NULL;
		_g_object_unref0 (e);
		e = _tmp19_;
		while (TRUE) {
			GFileInfo* _tmp20_ = NULL;
			GFileEnumerator* _tmp21_;
			GFileInfo* _tmp22_;
			GFileInfo* _tmp23_;
			GFileInfo* _tmp24_;
			GFileInfo* _tmp25_;
			GFileInfo* _tmp26_;
			GFileInfo* _tmp27_;
			const gchar* _tmp28_;
			gchar* _tmp29_;
			GFileInfo* _tmp30_;
			const gchar* _tmp37_;
			_tmp21_ = e;
			_tmp22_ = g_file_enumerator_next_file (_tmp21_, NULL, &_inner_error0_);
			_tmp20_ = _tmp22_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (_tmp15_);
				_g_object_unref0 (_tmp2_);
				_g_object_unref0 (dest);
				_g_object_unref0 (parts);
				_g_object_unref0 (found);
				_g_object_unref0 (bg);
				_g_object_unref0 (image_dir);
				_g_free0 (name);
				_g_object_unref0 (e);
				_g_object_unref0 (fi);
				_g_object_unref0 (info);
				return;
			}
			_tmp23_ = _tmp20_;
			_tmp20_ = NULL;
			_g_object_unref0 (fi);
			fi = _tmp23_;
			_tmp24_ = fi;
			if (!(_tmp24_ != NULL)) {
				_g_object_unref0 (_tmp20_);
				break;
			}
			_tmp25_ = fi;
			_tmp26_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, g_file_info_get_type (), GFileInfo));
			_g_object_unref0 (info);
			info = _tmp26_;
			_tmp27_ = info;
			_tmp28_ = g_file_info_get_name (_tmp27_);
			_tmp29_ = g_strdup (_tmp28_);
			_g_free0 (name);
			name = _tmp29_;
			_tmp30_ = info;
			if (g_file_info_get_file_type (_tmp30_) == G_FILE_TYPE_DIRECTORY) {
				GFile* _tmp31_;
				const gchar* _tmp32_;
				GFile* _tmp33_;
				GFile* _tmp34_;
				gchar* _tmp35_;
				gchar* _tmp36_;
				_tmp31_ = image_dir;
				_tmp32_ = name;
				_tmp33_ = bird_font_get_child (_tmp31_, _tmp32_);
				_g_object_unref0 (found);
				found = _tmp33_;
				_tmp34_ = found;
				_tmp35_ = g_file_get_path (_tmp34_);
				_tmp36_ = (gchar*) _tmp35_;
				bird_font_bird_font_part_copy_backgrounds (self, _tmp36_, &_inner_error0_);
				_g_free0 (_tmp36_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (_tmp20_);
					_g_object_unref0 (_tmp15_);
					_g_object_unref0 (_tmp2_);
					_g_object_unref0 (dest);
					_g_object_unref0 (parts);
					_g_object_unref0 (found);
					_g_object_unref0 (bg);
					_g_object_unref0 (image_dir);
					_g_free0 (name);
					_g_object_unref0 (e);
					_g_object_unref0 (fi);
					_g_object_unref0 (info);
					return;
				}
			}
			_tmp37_ = name;
			if (g_str_has_suffix (_tmp37_, ".png")) {
				GFile* _tmp38_;
				const gchar* _tmp39_;
				GFile* _tmp40_;
				BirdFontFont* _tmp41_;
				GFile* _tmp42_;
				GFile* _tmp43_;
				GFile* _tmp44_;
				GFile* _tmp45_;
				const gchar* _tmp46_;
				GFile* _tmp47_;
				GFile* _tmp48_;
				gchar* _tmp49_;
				gchar* _tmp50_;
				BirdFontBackgroundImage* _tmp51_;
				BirdFontBackgroundImage* _tmp52_;
				BirdFontFont* _tmp53_;
				BirdFontBackgroundImage* _tmp54_;
				GFile* _tmp55_;
				_tmp38_ = image_dir;
				_tmp39_ = name;
				_tmp40_ = bird_font_get_child (_tmp38_, _tmp39_);
				_g_object_unref0 (found);
				found = _tmp40_;
				_tmp41_ = self->priv->font;
				_tmp42_ = bird_font_font_get_backgrounds_folder (_tmp41_);
				_tmp43_ = _tmp42_;
				_tmp44_ = bird_font_get_child (_tmp43_, "parts");
				_g_object_unref0 (parts);
				parts = _tmp44_;
				_g_object_unref0 (_tmp43_);
				_tmp45_ = parts;
				_tmp46_ = name;
				_tmp47_ = bird_font_get_child (_tmp45_, _tmp46_);
				_g_object_unref0 (dest);
				dest = _tmp47_;
				_tmp48_ = found;
				_tmp49_ = g_file_get_path (_tmp48_);
				_tmp50_ = (gchar*) _tmp49_;
				_tmp51_ = bird_font_background_image_new (_tmp50_);
				_g_object_unref0 (bg);
				bg = _tmp51_;
				_g_free0 (_tmp50_);
				_tmp52_ = bg;
				_tmp53_ = self->priv->font;
				bird_font_background_image_create_background_folders (_tmp52_, _tmp53_);
				_tmp54_ = bg;
				_tmp55_ = dest;
				bird_font_background_image_copy_if_new (_tmp54_, _tmp55_);
			}
			_g_object_unref0 (_tmp20_);
		}
		_g_object_unref0 (_tmp15_);
		_g_object_unref0 (_tmp2_);
	}
	_g_object_unref0 (dest);
	_g_object_unref0 (parts);
	_g_object_unref0 (found);
	_g_object_unref0 (bg);
	_g_object_unref0 (image_dir);
	_g_free0 (name);
	_g_object_unref0 (e);
	_g_object_unref0 (fi);
	_g_object_unref0 (info);
}

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;
}

static gchar*
bird_font_bird_font_part_get_first_number_in_unicode (BirdFontGlyph* g)
{
	gchar* s = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (g != NULL, NULL);
	_tmp0_ = bird_font_font_to_hex (g->unichar_code);
	s = _tmp0_;
	_tmp1_ = s;
	_tmp2_ = string_replace (_tmp1_, "U+", "");
	_g_free0 (s);
	s = _tmp2_;
	result = s;
	return result;
}

gchar*
bird_font_bird_font_part_get_glyph_base_file_name (BirdFontGlyph* g,
                                                   BirdFontGlyphMaster* master)
{
	gchar* s = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (g != NULL, NULL);
	g_return_val_if_fail (master != NULL, NULL);
	_tmp0_ = bird_font_bird_font_part_get_first_number_in_unicode (g);
	s = _tmp0_;
	_tmp1_ = s;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = g_strdup_printf ("%i", g->version_id);
	_tmp4_ = _tmp3_;
	_tmp5_ = bird_font_glyph_master_get_id (master);
	_tmp6_ = _tmp5_;
	_tmp7_ = string_to_string (_tmp6_);
	_tmp8_ = g_strconcat ("U+", _tmp2_, "_", _tmp4_, "_", _tmp7_, NULL);
	_g_free0 (s);
	s = _tmp8_;
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	result = s;
	return result;
}

static gunichar
string_get_char (const gchar* self,
                 glong index)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = g_utf8_get_char (((gchar*) self) + index);
	return result;
}

static gchar*
g_unichar_to_string (gunichar self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, 7);
	str = (gchar*) _tmp0_;
	g_unichar_to_utf8 (self, str);
	result = str;
	return result;
}

gchar*
bird_font_bird_font_part_get_subdir_name (BirdFontBirdFontPart* self,
                                          const gchar* file_name)
{
	gchar* d = NULL;
	gchar* _tmp0_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (file_name != NULL, NULL);
	_tmp0_ = g_strdup (file_name);
	d = _tmp0_;
	if (g_str_has_prefix (file_name, "U+")) {
		gchar* _tmp1_;
		_tmp1_ = string_replace (file_name, "U+", "");
		_g_free0 (d);
		d = _tmp1_;
	}
	_tmp2_ = d;
	_tmp3_ = g_unichar_to_string (string_get_char (_tmp2_, (glong) 0));
	result = (gchar*) _tmp3_;
	_g_free0 (d);
	return result;
}

static void
bird_font_bird_font_part_write_glyph (BirdFontBirdFontPart* self,
                                      BirdFontBirdFontFile* bf,
                                      BirdFontGlyphCollection* gc,
                                      BirdFontGlyphMaster* master,
                                      BirdFontGlyph* g,
                                      GError** error)
{
	gchar* file_name = NULL;
	gchar* dir_name = NULL;
	GDataOutputStream* os = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GDataOutputStream* _tmp3_ = NULL;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GDataOutputStream* _tmp9_;
	GDataOutputStream* _tmp10_;
	GDataOutputStream* _tmp11_;
	GDataOutputStream* _tmp12_;
	GDataOutputStream* _tmp13_;
	GDataOutputStream* _tmp14_;
	GDataOutputStream* _tmp15_;
	GDataOutputStream* _tmp16_;
	GDataOutputStream* _tmp17_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (bf != NULL);
	g_return_if_fail (gc != NULL);
	g_return_if_fail (master != NULL);
	g_return_if_fail (g != NULL);
	_tmp0_ = bird_font_bird_font_part_get_glyph_base_file_name (g, master);
	_g_free0 (file_name);
	file_name = _tmp0_;
	_tmp1_ = file_name;
	_tmp2_ = bird_font_bird_font_part_get_subdir_name (self, _tmp1_);
	_g_free0 (dir_name);
	dir_name = _tmp2_;
	_tmp4_ = file_name;
	_tmp5_ = string_to_string (_tmp4_);
	_tmp6_ = g_strconcat (_tmp5_, ".bfp", NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = dir_name;
	_tmp9_ = bird_font_bird_font_part_create_file (self, _tmp7_, "glyphs", _tmp8_, &_inner_error0_);
	_tmp10_ = _tmp9_;
	_g_free0 (_tmp7_);
	_tmp3_ = _tmp10_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_tmp11_ = _tmp3_;
	_tmp3_ = NULL;
	_g_object_unref0 (os);
	os = _tmp11_;
	_tmp12_ = os;
	bird_font_bird_font_file_write_root_tag (bf, _tmp12_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_tmp13_ = os;
	bird_font_bird_font_file_write_glyph_collection_start (bf, gc, master, _tmp13_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_tmp14_ = os;
	bird_font_bird_font_file_write_glyph (bf, g, _tmp14_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_tmp15_ = os;
	bird_font_bird_font_file_write_glyph_collection_end (bf, _tmp15_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_tmp16_ = os;
	bird_font_bird_font_file_write_closing_root_tag (bf, _tmp16_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_tmp17_ = os;
	g_output_stream_close ((GOutputStream*) _tmp17_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp3_);
		_g_object_unref0 (os);
		_g_free0 (dir_name);
		_g_free0 (file_name);
		return;
	}
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (os);
	_g_free0 (dir_name);
	_g_free0 (file_name);
}

static void
bird_font_bird_font_part_write_glyph_background_image (BirdFontBirdFontPart* self,
                                                       BirdFontBirdFontFile* bf,
                                                       BirdFontGlyphCollection* gc,
                                                       BirdFontGlyph* g,
                                                       GError** error)
{
	gchar* file_name = NULL;
	gchar* dir_name = NULL;
	BirdFontBackgroundImage* bg = NULL;
	GFile* file = NULL;
	BirdFontBackgroundImage* _tmp0_;
	BirdFontBackgroundImage* _tmp1_;
	gboolean _tmp2_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (bf != NULL);
	g_return_if_fail (gc != NULL);
	g_return_if_fail (g != NULL);
	_tmp0_ = bird_font_glyph_get_background_image (g);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		BirdFontBackgroundImage* _tmp3_;
		BirdFontBackgroundImage* _tmp4_;
		_tmp3_ = bird_font_glyph_get_background_image (g);
		_g_object_unref0 (bg);
		bg = G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, BIRD_FONT_TYPE_BACKGROUND_IMAGE, BirdFontBackgroundImage);
		_tmp4_ = bg;
		if (bird_font_background_image_is_valid (_tmp4_)) {
			BirdFontBackgroundImage* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			const gchar* _tmp8_;
			gchar* _tmp9_;
			const gchar* _tmp10_;
			gchar* _tmp11_;
			GFile* _tmp12_ = NULL;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			GFile* _tmp15_;
			GFile* _tmp16_;
			BirdFontBackgroundImage* _tmp17_;
			GFile* _tmp18_;
			_tmp5_ = bg;
			_tmp6_ = bird_font_background_image_get_sha1 (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = string_to_string (_tmp7_);
			_tmp9_ = g_strconcat (_tmp8_, ".png", NULL);
			_g_free0 (file_name);
			file_name = _tmp9_;
			_g_free0 (_tmp7_);
			_tmp10_ = file_name;
			_tmp11_ = bird_font_bird_font_part_get_subdir_name (self, _tmp10_);
			_g_free0 (dir_name);
			dir_name = _tmp11_;
			_tmp13_ = file_name;
			_tmp14_ = dir_name;
			_tmp15_ = bird_font_bird_font_part_get_destination_file (self, _tmp13_, "images", _tmp14_, &_inner_error0_);
			_tmp12_ = _tmp15_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (file);
				_g_object_unref0 (bg);
				_g_free0 (dir_name);
				_g_free0 (file_name);
				return;
			}
			_tmp16_ = _tmp12_;
			_tmp12_ = NULL;
			_g_object_unref0 (file);
			file = _tmp16_;
			_tmp17_ = bg;
			_tmp18_ = file;
			bird_font_background_image_copy_if_new (_tmp17_, _tmp18_);
			_g_object_unref0 (_tmp12_);
		}
	}
	_g_object_unref0 (file);
	_g_object_unref0 (bg);
	_g_free0 (dir_name);
	_g_free0 (file_name);
}

void
bird_font_bird_font_part_create_directory (BirdFontBirdFontPart* self,
                                           const gchar* directory,
                                           GError** error)
{
	GFile* dir = NULL;
	GFile* _tmp0_;
	GFile* bfp_dir = NULL;
	gint i = 0;
	BirdFontFont* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	GFile* _tmp24_;
	GFile* _tmp28_;
	gchar* _tmp29_;
	const gchar* _tmp30_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (directory != NULL);
	_tmp0_ = g_file_new_for_path (directory);
	dir = _tmp0_;
	i = 2;
	_tmp1_ = self->priv->font;
	_tmp2_ = bird_font_font_get_full_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_str_has_suffix (directory, _tmp3_);
	_g_free0 (_tmp3_);
	if (_tmp4_) {
		GFile* _tmp5_;
		GFile* _tmp6_;
		_tmp5_ = dir;
		_tmp6_ = _g_object_ref0 (_tmp5_);
		_g_object_unref0 (bfp_dir);
		bfp_dir = _tmp6_;
	} else {
		GFile* _tmp7_;
		BirdFontFont* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		GFile* _tmp11_;
		_tmp7_ = dir;
		_tmp8_ = self->priv->font;
		_tmp9_ = bird_font_font_get_full_name (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = bird_font_get_child (_tmp7_, _tmp10_);
		_g_object_unref0 (bfp_dir);
		bfp_dir = _tmp11_;
		_g_free0 (_tmp10_);
	}
	while (TRUE) {
		GFile* _tmp12_;
		GFile* _tmp13_;
		BirdFontFont* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		GFile* _tmp22_;
		gint _tmp23_;
		_tmp12_ = bfp_dir;
		if (!g_file_query_exists (_tmp12_, NULL)) {
			break;
		}
		_tmp13_ = dir;
		_tmp14_ = self->priv->font;
		_tmp15_ = bird_font_font_get_full_name (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = string_to_string (_tmp16_);
		_tmp18_ = g_strdup_printf ("%i", i);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_strconcat (_tmp17_, "_", _tmp19_, NULL);
		_tmp21_ = _tmp20_;
		_tmp22_ = bird_font_get_child (_tmp13_, _tmp21_);
		_g_object_unref0 (bfp_dir);
		bfp_dir = _tmp22_;
		_g_free0 (_tmp21_);
		_g_free0 (_tmp19_);
		_g_free0 (_tmp16_);
		_tmp23_ = i;
		i = _tmp23_ + 1;
	}
	_tmp24_ = dir;
	if (!g_file_query_exists (_tmp24_, NULL)) {
		GFile* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		_tmp25_ = dir;
		_tmp26_ = g_file_get_path (_tmp25_);
		_tmp27_ = (gchar*) _tmp26_;
		g_mkdir (_tmp27_, 0755);
		_g_free0 (_tmp27_);
	}
	_tmp28_ = bfp_dir;
	_tmp29_ = g_file_get_path (_tmp28_);
	_g_free0 (self->priv->root_directory);
	self->priv->root_directory = (gchar*) _tmp29_;
	_tmp30_ = self->priv->root_directory;
	g_mkdir (_tmp30_, 0755);
	_g_object_unref0 (bfp_dir);
	_g_object_unref0 (dir);
}

static void
bird_font_bird_font_part_find_all_parts (BirdFontBirdFontPart* self,
                                         const gchar* bfp_file,
                                         GError** error)
{
	GFile* start = NULL;
	GFile* _tmp0_;
	GFileInfo* info = NULL;
	GFile* root = NULL;
	GFileInfo* _tmp1_ = NULL;
	GFile* _tmp2_;
	const gchar* _tmp3_;
	GFileInfo* _tmp4_;
	GFileInfo* _tmp5_;
	GFileInfo* _tmp6_;
	GFile* _tmp9_ = NULL;
	GFile* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GFile* _tmp13_;
	GFile* _tmp14_;
	GFile* _tmp15_;
	GFile* _tmp16_;
	gchar* _tmp17_;
	const gchar* _tmp18_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (bfp_file != NULL);
	_tmp0_ = g_file_new_for_path (bfp_file);
	start = _tmp0_;
	_tmp2_ = start;
	_tmp3_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
	_tmp4_ = g_file_query_info (_tmp2_, _tmp3_, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
	_tmp1_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (root);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return;
	}
	_tmp5_ = _tmp1_;
	_tmp1_ = NULL;
	_g_object_unref0 (info);
	info = _tmp5_;
	_tmp6_ = info;
	if (g_file_info_get_file_type (_tmp6_) != G_FILE_TYPE_DIRECTORY) {
		GFile* _tmp7_;
		GFile* _tmp8_;
		_tmp7_ = start;
		_tmp8_ = g_file_get_parent (_tmp7_);
		_g_object_unref0 (start);
		start = G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, g_file_get_type (), GFile);
	}
	_tmp10_ = start;
	_tmp11_ = g_file_get_path (_tmp10_);
	_tmp12_ = (gchar*) _tmp11_;
	_tmp13_ = bird_font_bird_font_part_find_root (self, _tmp12_, &_inner_error0_);
	_tmp14_ = _tmp13_;
	_g_free0 (_tmp12_);
	_tmp9_ = _tmp14_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (root);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return;
	}
	_tmp15_ = _tmp9_;
	_tmp9_ = NULL;
	_g_object_unref0 (root);
	root = _tmp15_;
	_tmp16_ = root;
	_tmp17_ = g_file_get_path (_tmp16_);
	_g_free0 (self->priv->root_directory);
	self->priv->root_directory = (gchar*) _tmp17_;
	_tmp18_ = self->priv->root_directory;
	bird_font_bird_font_part_find_parts (self, _tmp18_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp9_);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (root);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return;
	}
	_g_object_unref0 (_tmp9_);
	_g_object_unref0 (_tmp1_);
	_g_object_unref0 (root);
	_g_object_unref0 (info);
	_g_object_unref0 (start);
}

static void
bird_font_bird_font_part_find_parts (BirdFontBirdFontPart* self,
                                     const gchar* directory,
                                     GError** error)
{
	GFile* start = NULL;
	GFile* _tmp0_;
	GFile* found = NULL;
	GFileInfo* info = NULL;
	GFileInfo* fi = NULL;
	GFileEnumerator* e = NULL;
	gchar* name = NULL;
	GFileInfo* _tmp1_ = NULL;
	GFile* _tmp2_;
	const gchar* _tmp3_;
	GFileInfo* _tmp4_;
	GFileInfo* _tmp5_;
	GFileInfo* _tmp6_;
	GFileEnumerator* _tmp11_ = NULL;
	GFile* _tmp12_;
	const gchar* _tmp13_;
	GFileEnumerator* _tmp14_;
	GFileEnumerator* _tmp15_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (directory != NULL);
	_tmp0_ = g_file_new_for_path (directory);
	start = _tmp0_;
	_tmp2_ = start;
	_tmp3_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
	_tmp4_ = g_file_query_info (_tmp2_, _tmp3_, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
	_tmp1_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (name);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (found);
		_g_object_unref0 (start);
		return;
	}
	_tmp5_ = _tmp1_;
	_tmp1_ = NULL;
	_g_object_unref0 (info);
	info = _tmp5_;
	_tmp6_ = info;
	if (g_file_info_get_file_type (_tmp6_) != G_FILE_TYPE_DIRECTORY) {
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GError* _tmp10_;
		_tmp7_ = string_to_string (directory);
		_tmp8_ = g_strconcat (_tmp7_, " is not a directory.", NULL);
		_tmp9_ = _tmp8_;
		g_warning ("BirdFontPart.vala:362: %s", _tmp9_);
		_g_free0 (_tmp9_);
		_tmp10_ = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOTDIR, "Not a directory.");
		_inner_error0_ = _tmp10_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp1_);
		_g_free0 (name);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (found);
		_g_object_unref0 (start);
		return;
	}
	_tmp12_ = start;
	_tmp13_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
	_tmp14_ = g_file_enumerate_children (_tmp12_, _tmp13_, 0, NULL, &_inner_error0_);
	_tmp11_ = _tmp14_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp1_);
		_g_free0 (name);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (found);
		_g_object_unref0 (start);
		return;
	}
	_tmp15_ = _tmp11_;
	_tmp11_ = NULL;
	_g_object_unref0 (e);
	e = _tmp15_;
	while (TRUE) {
		GFileInfo* _tmp16_ = NULL;
		GFileEnumerator* _tmp17_;
		GFileInfo* _tmp18_;
		GFileInfo* _tmp19_;
		GFileInfo* _tmp20_;
		GFileInfo* _tmp21_;
		GFileInfo* _tmp22_;
		GFileInfo* _tmp23_;
		const gchar* _tmp24_;
		gchar* _tmp25_;
		GFileInfo* _tmp26_;
		_tmp17_ = e;
		_tmp18_ = g_file_enumerator_next_file (_tmp17_, NULL, &_inner_error0_);
		_tmp16_ = _tmp18_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp11_);
			_g_object_unref0 (_tmp1_);
			_g_free0 (name);
			_g_object_unref0 (e);
			_g_object_unref0 (fi);
			_g_object_unref0 (info);
			_g_object_unref0 (found);
			_g_object_unref0 (start);
			return;
		}
		_tmp19_ = _tmp16_;
		_tmp16_ = NULL;
		_g_object_unref0 (fi);
		fi = _tmp19_;
		_tmp20_ = fi;
		if (!(_tmp20_ != NULL)) {
			_g_object_unref0 (_tmp16_);
			break;
		}
		_tmp21_ = fi;
		_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, g_file_info_get_type (), GFileInfo));
		_g_object_unref0 (info);
		info = _tmp22_;
		_tmp23_ = info;
		_tmp24_ = g_file_info_get_name (_tmp23_);
		_tmp25_ = g_strdup (_tmp24_);
		_g_free0 (name);
		name = _tmp25_;
		_tmp26_ = info;
		if (g_file_info_get_file_type (_tmp26_) == G_FILE_TYPE_DIRECTORY) {
			GFile* _tmp27_;
			const gchar* _tmp28_;
			GFile* _tmp29_;
			GFile* _tmp30_;
			gchar* _tmp31_;
			gchar* _tmp32_;
			_tmp27_ = start;
			_tmp28_ = name;
			_tmp29_ = bird_font_get_child (_tmp27_, _tmp28_);
			_tmp30_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, g_file_get_type (), GFile);
			_tmp31_ = g_file_get_path (_tmp30_);
			_tmp32_ = (gchar*) _tmp31_;
			bird_font_bird_font_part_find_parts (self, _tmp32_, &_inner_error0_);
			_g_free0 (_tmp32_);
			_g_object_unref0 (_tmp30_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				g_propagate_error (error, _inner_error0_);
				_g_object_unref0 (_tmp16_);
				_g_object_unref0 (_tmp11_);
				_g_object_unref0 (_tmp1_);
				_g_free0 (name);
				_g_object_unref0 (e);
				_g_object_unref0 (fi);
				_g_object_unref0 (info);
				_g_object_unref0 (found);
				_g_object_unref0 (start);
				return;
			}
		} else {
			const gchar* _tmp33_;
			_tmp33_ = name;
			if (g_str_has_suffix (_tmp33_, ".bfp")) {
				GFile* _tmp34_;
				const gchar* _tmp35_;
				GFile* _tmp36_;
				GeeArrayList* _tmp37_;
				GFile* _tmp38_;
				gchar* _tmp39_;
				gchar* _tmp40_;
				_tmp34_ = start;
				_tmp35_ = name;
				_tmp36_ = bird_font_get_child (_tmp34_, _tmp35_);
				_g_object_unref0 (found);
				found = _tmp36_;
				_tmp37_ = self->priv->parts;
				_tmp38_ = found;
				_tmp39_ = g_file_get_path (_tmp38_);
				_tmp40_ = (gchar*) _tmp39_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp37_, _tmp40_);
				_g_free0 (_tmp40_);
			}
		}
		_g_object_unref0 (_tmp16_);
	}
	_g_object_unref0 (_tmp11_);
	_g_object_unref0 (_tmp1_);
	_g_free0 (name);
	_g_object_unref0 (e);
	_g_object_unref0 (fi);
	_g_object_unref0 (info);
	_g_object_unref0 (found);
	_g_object_unref0 (start);
}

static GFile*
bird_font_bird_font_part_find_root (BirdFontBirdFontPart* self,
                                    const gchar* directory,
                                    GError** error)
{
	GFile* start = NULL;
	GFile* _tmp0_;
	GFileInfo* info = NULL;
	GFileInfo* fi = NULL;
	GFileEnumerator* e = NULL;
	GFileInfo* _tmp1_ = NULL;
	GFile* _tmp2_;
	const gchar* _tmp3_;
	GFileInfo* _tmp4_;
	GFileInfo* _tmp5_;
	GFileInfo* _tmp6_;
	GFileEnumerator* _tmp8_ = NULL;
	GFile* _tmp9_;
	const gchar* _tmp10_;
	GFileEnumerator* _tmp11_;
	GFileEnumerator* _tmp12_;
	GFile* _tmp22_;
	GFile* _tmp23_;
	GFile* _tmp24_;
	gboolean _tmp25_;
	GFile* _tmp27_ = NULL;
	GFile* _tmp28_;
	GFile* _tmp29_;
	GFile* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	GFile* _tmp33_;
	GFile* _tmp34_;
	GFile* _tmp35_;
	GError* _inner_error0_ = NULL;
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (directory != NULL, NULL);
	_tmp0_ = g_file_new_for_path (directory);
	start = _tmp0_;
	_tmp2_ = start;
	_tmp3_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
	_tmp4_ = g_file_query_info (_tmp2_, _tmp3_, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
	_tmp1_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return NULL;
	}
	_tmp5_ = _tmp1_;
	_tmp1_ = NULL;
	_g_object_unref0 (info);
	info = _tmp5_;
	_tmp6_ = info;
	if (g_file_info_get_file_type (_tmp6_) != G_FILE_TYPE_DIRECTORY) {
		GError* _tmp7_;
		g_warning ("BirdFontPart.vala:387: Not a directory.");
		_tmp7_ = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_NOTDIR, "Not a directory.");
		_inner_error0_ = _tmp7_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return NULL;
	}
	_tmp9_ = start;
	_tmp10_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
	_tmp11_ = g_file_enumerate_children (_tmp9_, _tmp10_, 0, NULL, &_inner_error0_);
	_tmp8_ = _tmp11_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return NULL;
	}
	_tmp12_ = _tmp8_;
	_tmp8_ = NULL;
	_g_object_unref0 (e);
	e = _tmp12_;
	while (TRUE) {
		GFileInfo* _tmp13_ = NULL;
		GFileEnumerator* _tmp14_;
		GFileInfo* _tmp15_;
		GFileInfo* _tmp16_;
		GFileInfo* _tmp17_;
		GFileInfo* _tmp18_;
		GFileInfo* _tmp19_;
		GFileInfo* _tmp20_;
		const gchar* _tmp21_;
		_tmp14_ = e;
		_tmp15_ = g_file_enumerator_next_file (_tmp14_, NULL, &_inner_error0_);
		_tmp13_ = _tmp15_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp8_);
			_g_object_unref0 (_tmp1_);
			_g_object_unref0 (e);
			_g_object_unref0 (fi);
			_g_object_unref0 (info);
			_g_object_unref0 (start);
			return NULL;
		}
		_tmp16_ = _tmp13_;
		_tmp13_ = NULL;
		_g_object_unref0 (fi);
		fi = _tmp16_;
		_tmp17_ = fi;
		if (!(_tmp17_ != NULL)) {
			_g_object_unref0 (_tmp13_);
			break;
		}
		_tmp18_ = fi;
		_tmp19_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, g_file_info_get_type (), GFileInfo));
		_g_object_unref0 (info);
		info = _tmp19_;
		_tmp20_ = info;
		_tmp21_ = g_file_info_get_name (_tmp20_);
		if (g_strcmp0 (_tmp21_, "description.bfp") == 0) {
			result = start;
			_g_object_unref0 (_tmp13_);
			_g_object_unref0 (_tmp8_);
			_g_object_unref0 (_tmp1_);
			_g_object_unref0 (e);
			_g_object_unref0 (fi);
			_g_object_unref0 (info);
			return result;
		}
		_g_object_unref0 (_tmp13_);
	}
	_tmp22_ = start;
	_tmp23_ = g_file_get_parent (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = _tmp24_ == NULL;
	_g_object_unref0 (_tmp24_);
	if (_tmp25_) {
		GError* _tmp26_;
		g_warning ("BirdFontPart.vala:400: description.bfp not found");
		_tmp26_ = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED, "description.bfp not found");
		_inner_error0_ = _tmp26_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp8_);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return NULL;
	}
	_tmp28_ = start;
	_tmp29_ = g_file_get_parent (_tmp28_);
	_tmp30_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, g_file_get_type (), GFile);
	_tmp31_ = g_file_get_path (_tmp30_);
	_tmp32_ = (gchar*) _tmp31_;
	_tmp33_ = bird_font_bird_font_part_find_root (self, _tmp32_, &_inner_error0_);
	_tmp34_ = _tmp33_;
	_g_free0 (_tmp32_);
	_g_object_unref0 (_tmp30_);
	_tmp27_ = _tmp34_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp8_);
		_g_object_unref0 (_tmp1_);
		_g_object_unref0 (e);
		_g_object_unref0 (fi);
		_g_object_unref0 (info);
		_g_object_unref0 (start);
		return NULL;
	}
	_tmp35_ = _tmp27_;
	_tmp27_ = NULL;
	result = _tmp35_;
	_g_object_unref0 (_tmp27_);
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (_tmp1_);
	_g_object_unref0 (e);
	_g_object_unref0 (fi);
	_g_object_unref0 (info);
	_g_object_unref0 (start);
	return result;
}

static GFile*
bird_font_bird_font_part_new_subdirectory (BirdFontBirdFontPart* self,
                                           GFile* d,
                                           const gchar* subdir,
                                           GError** error)
{
	GFileInfo* info = NULL;
	GFile* dir = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GError* _inner_error0_ = NULL;
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (d != NULL, NULL);
	g_return_val_if_fail (subdir != NULL, NULL);
	_tmp0_ = _g_object_ref0 (d);
	_g_object_unref0 (dir);
	dir = _tmp0_;
	_tmp1_ = dir;
	_tmp2_ = bird_font_get_child (_tmp1_, subdir);
	_g_object_unref0 (dir);
	dir = _tmp2_;
	_tmp3_ = dir;
	if (!g_file_query_exists (_tmp3_, NULL)) {
		GFile* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp4_ = dir;
		_tmp5_ = g_file_get_path (_tmp4_);
		_tmp6_ = (gchar*) _tmp5_;
		g_mkdir (_tmp6_, 0755);
		_g_free0 (_tmp6_);
	} else {
		GFileInfo* _tmp7_ = NULL;
		GFile* _tmp8_;
		const gchar* _tmp9_;
		GFileInfo* _tmp10_;
		GFileInfo* _tmp11_;
		GFileInfo* _tmp12_;
		_tmp8_ = dir;
		_tmp9_ = bird_font_bird_font_part_FILE_ATTRIBUTES;
		_tmp10_ = g_file_query_info (_tmp8_, _tmp9_, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp7_ = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dir);
			_g_object_unref0 (info);
			return NULL;
		}
		_tmp11_ = _tmp7_;
		_tmp7_ = NULL;
		_g_object_unref0 (info);
		info = _tmp11_;
		_tmp12_ = info;
		if (g_file_info_get_file_type (_tmp12_) != G_FILE_TYPE_DIRECTORY) {
			const gchar* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			GError* _tmp16_;
			GError* _tmp17_;
			_tmp13_ = string_to_string (subdir);
			_tmp14_ = g_strconcat ("Can't save font, ", _tmp13_, " is not a directory.", NULL);
			_tmp15_ = _tmp14_;
			_tmp16_ = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED, _tmp15_);
			_tmp17_ = _tmp16_;
			_g_free0 (_tmp15_);
			_inner_error0_ = _tmp17_;
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp7_);
			_g_object_unref0 (dir);
			_g_object_unref0 (info);
			return NULL;
		}
		_g_object_unref0 (_tmp7_);
	}
	result = dir;
	_g_object_unref0 (info);
	return result;
}

static GFile*
bird_font_bird_font_part_get_destination_file (BirdFontBirdFontPart* self,
                                               const gchar* name,
                                               const gchar* subdir1,
                                               const gchar* subdir2,
                                               GError** error)
{
	GFile* file = NULL;
	GFile* dir = NULL;
	const gchar* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	GFile* _tmp12_;
	GError* _inner_error0_ = NULL;
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (subdir1 != NULL, NULL);
	g_return_val_if_fail (subdir2 != NULL, NULL);
	_tmp0_ = self->priv->root_directory;
	_tmp1_ = g_file_new_for_path (_tmp0_);
	_g_object_unref0 (dir);
	dir = _tmp1_;
	if (g_strcmp0 (subdir1, "") != 0) {
		GFile* _tmp2_ = NULL;
		GFile* _tmp3_;
		GFile* _tmp4_;
		GFile* _tmp5_;
		_tmp3_ = dir;
		_tmp4_ = bird_font_bird_font_part_new_subdirectory (self, _tmp3_, subdir1, &_inner_error0_);
		_tmp2_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dir);
			_g_object_unref0 (file);
			return NULL;
		}
		_tmp5_ = _tmp2_;
		_tmp2_ = NULL;
		_g_object_unref0 (dir);
		dir = _tmp5_;
		_g_object_unref0 (_tmp2_);
	}
	if (g_strcmp0 (subdir2, "") != 0) {
		GFile* _tmp6_ = NULL;
		GFile* _tmp7_;
		GFile* _tmp8_;
		GFile* _tmp9_;
		_tmp7_ = dir;
		_tmp8_ = bird_font_bird_font_part_new_subdirectory (self, _tmp7_, subdir2, &_inner_error0_);
		_tmp6_ = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (dir);
			_g_object_unref0 (file);
			return NULL;
		}
		_tmp9_ = _tmp6_;
		_tmp6_ = NULL;
		_g_object_unref0 (dir);
		dir = _tmp9_;
		_g_object_unref0 (_tmp6_);
	}
	_tmp10_ = dir;
	_tmp11_ = bird_font_get_child (_tmp10_, name);
	_g_object_unref0 (file);
	file = _tmp11_;
	_tmp12_ = file;
	if (g_file_query_file_type (_tmp12_, 0, NULL) == G_FILE_TYPE_DIRECTORY) {
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		GError* _tmp16_;
		GError* _tmp17_;
		_tmp13_ = string_to_string (name);
		_tmp14_ = g_strconcat ("Can't save font, ", _tmp13_, " is a directory.", NULL);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_error_new_literal (G_FILE_ERROR, G_FILE_ERROR_FAILED, _tmp15_);
		_tmp17_ = _tmp16_;
		_g_free0 (_tmp15_);
		_inner_error0_ = _tmp17_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (dir);
		_g_object_unref0 (file);
		return NULL;
	}
	result = file;
	_g_object_unref0 (dir);
	return result;
}

static GDataOutputStream*
bird_font_bird_font_part_create_file (BirdFontBirdFontPart* self,
                                      const gchar* name,
                                      const gchar* subdir1,
                                      const gchar* subdir2,
                                      GError** error)
{
	GDataOutputStream* os = NULL;
	GFile* file = NULL;
	gchar* git_path = NULL;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFileOutputStream* _tmp5_ = NULL;
	GFile* _tmp6_;
	GFileOutputStream* _tmp7_;
	GDataOutputStream* _tmp8_;
	GError* _inner_error0_ = NULL;
	GDataOutputStream* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (subdir1 != NULL, NULL);
	g_return_val_if_fail (subdir2 != NULL, NULL);
	_tmp1_ = bird_font_bird_font_part_get_destination_file (self, name, subdir1, subdir2, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (git_path);
		_g_object_unref0 (file);
		_g_object_unref0 (os);
		return NULL;
	}
	_tmp2_ = _tmp0_;
	_tmp0_ = NULL;
	_g_object_unref0 (file);
	file = _tmp2_;
	_tmp3_ = file;
	if (g_file_query_exists (_tmp3_, NULL)) {
		GFile* _tmp4_;
		_tmp4_ = file;
		g_file_delete (_tmp4_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (_tmp0_);
			_g_free0 (git_path);
			_g_object_unref0 (file);
			_g_object_unref0 (os);
			return NULL;
		}
	}
	_tmp6_ = file;
	_tmp7_ = g_file_create (_tmp6_, G_FILE_CREATE_REPLACE_DESTINATION, NULL, &_inner_error0_);
	_tmp5_ = _tmp7_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp0_);
		_g_free0 (git_path);
		_g_object_unref0 (file);
		_g_object_unref0 (os);
		return NULL;
	}
	_tmp8_ = g_data_output_stream_new ((GOutputStream*) _tmp5_);
	_g_object_unref0 (os);
	os = _tmp8_;
	if (g_strcmp0 (subdir2, "") != 0) {
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp9_ = g_strconcat (subdir1, "/", NULL);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_strconcat (_tmp10_, subdir2, NULL);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strconcat (_tmp12_, "/", NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_strconcat (_tmp14_, name, NULL);
		_g_free0 (git_path);
		git_path = _tmp15_;
		_g_free0 (_tmp14_);
		_g_free0 (_tmp12_);
		_g_free0 (_tmp10_);
	} else {
		if (g_strcmp0 (subdir1, "") != 0) {
			gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			_tmp16_ = g_strconcat (subdir1, "/", NULL);
			_tmp17_ = _tmp16_;
			_tmp18_ = g_strconcat (_tmp17_, name, NULL);
			_g_free0 (git_path);
			git_path = _tmp18_;
			_g_free0 (_tmp17_);
		} else {
			gchar* _tmp19_;
			_tmp19_ = g_strdup (name);
			_g_free0 (git_path);
			git_path = _tmp19_;
		}
	}
	result = os;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp0_);
	_g_free0 (git_path);
	_g_object_unref0 (file);
	return result;
}

static void
bird_font_bird_font_part_class_init (BirdFontBirdFontPartClass * klass,
                                     gpointer klass_data)
{
	gchar* _tmp0_;
	bird_font_bird_font_part_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontBirdFontPart_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_bird_font_part_finalize;
	_tmp0_ = g_strdup ("standard::*");
	bird_font_bird_font_part_FILE_ATTRIBUTES = _tmp0_;
}

static void
bird_font_bird_font_part_instance_init (BirdFontBirdFontPart * self,
                                        gpointer klass)
{
	self->priv = bird_font_bird_font_part_get_instance_private (self);
}

static void
bird_font_bird_font_part_finalize (GObject * obj)
{
	BirdFontBirdFontPart * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_BIRD_FONT_PART, BirdFontBirdFontPart);
	_g_object_unref0 (self->priv->parts);
	_g_free0 (self->priv->root_directory);
	G_OBJECT_CLASS (bird_font_bird_font_part_parent_class)->finalize (obj);
}

/** BirdFontPart is a class for parsing .bfp files. The file format is 
 * identical to .bf but the font is split in many parts. Each part
 * contains a few elements and all parent nodes from the root node and
 * downwards. The .bfp files can be parsed in any order. The root directory
 * of a .bfp tree must have a file with the name "description.bfp", this file 
 * tells the parser that bfp files in parent directories should be excluded.
 */
static GType
bird_font_bird_font_part_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontBirdFontPartClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_bird_font_part_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontBirdFontPart), 0, (GInstanceInitFunc) bird_font_bird_font_part_instance_init, NULL };
	GType bird_font_bird_font_part_type_id;
	bird_font_bird_font_part_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontBirdFontPart", &g_define_type_info, 0);
	BirdFontBirdFontPart_private_offset = g_type_add_instance_private (bird_font_bird_font_part_type_id, sizeof (BirdFontBirdFontPartPrivate));
	return bird_font_bird_font_part_type_id;
}

GType
bird_font_bird_font_part_get_type (void)
{
	static volatile gsize bird_font_bird_font_part_type_id__once = 0;
	if (g_once_init_enter (&bird_font_bird_font_part_type_id__once)) {
		GType bird_font_bird_font_part_type_id;
		bird_font_bird_font_part_type_id = bird_font_bird_font_part_get_type_once ();
		g_once_init_leave (&bird_font_bird_font_part_type_id__once, bird_font_bird_font_part_type_id);
	}
	return bird_font_bird_font_part_type_id__once;
}

