[gd_scene load_steps=54 format=2]

[ext_resource path="res://icons/ic_font_download_black_18dp.png" type="Texture" id=1]
[ext_resource path="res://icons/ic_format_size_black_18dp.png" type="Texture" id=2]
[ext_resource path="res://icons/ic_format_bold_black_18dp.png" type="Texture" id=3]
[ext_resource path="res://icons/ic_format_italic_black_18dp.png" type="Texture" id=4]
[ext_resource path="res://icons/ic_format_underlined_black_18dp.png" type="Texture" id=5]
[ext_resource path="res://icons/ic_format_overlined_black_18dp.png" type="Texture" id=6]
[ext_resource path="res://icons/ic_strikethrough_s_black_18dp.png" type="Texture" id=7]
[ext_resource path="res://icons/ic_format_align_left_black_18dp.png" type="Texture" id=8]
[ext_resource path="res://icons/ic_format_align_center_black_18dp.png" type="Texture" id=9]
[ext_resource path="res://icons/ic_format_align_right_black_18dp.png" type="Texture" id=10]
[ext_resource path="res://icons/ic_format_align_justify_black_18dp.png" type="Texture" id=11]
[ext_resource path="res://icons/ic_format_color_reset_black_18dp.png" type="Texture" id=12]
[ext_resource path="res://icons/ic_cancel_18pt.png" type="Texture" id=13]
[ext_resource path="res://icons/dng_crect_black_18dp.png" type="Texture" id=14]
[ext_resource path="res://icons/dng_lbrk_black_18dp.png" type="Texture" id=15]
[ext_resource path="res://icons/dng_jbrk_black_18dp.png" type="Texture" id=16]
[ext_resource path="res://icons/dng_wbrk_black_18dp.png" type="Texture" id=17]
[ext_resource path="res://icons/dng_cprev_black_18dp.png" type="Texture" id=18]
[ext_resource path="res://icons/ic_create_16pt.png" type="Texture" id=19]
[ext_resource path="res://icons/ic_folder_open_black_18dp.png" type="Texture" id=20]
[ext_resource path="res://icons/ic_save_black_18dp.png" type="Texture" id=21]
[ext_resource path="res://icons/ic_format_indent_increase_black_18dp.png" type="Texture" id=22]
[ext_resource path="res://icons/ic_format_indent_decrease_black_18dp.png" type="Texture" id=23]
[ext_resource path="res://icons/ic_wallpaper_black_18dp.png" type="Texture" id=24]
[ext_resource path="res://icons/ic_format_line_spacing_black_18dp.png" type="Texture" id=25]
[ext_resource path="res://icons/ic_format_textdirection_l_to_r_black_18dp.png" type="Texture" id=26]
[ext_resource path="res://icons/ic_wrap_text_black_18dp.png" type="Texture" id=27]
[ext_resource path="res://icons/ic_vertical_align_top_black_18dp.png" type="Texture" id=28]
[ext_resource path="res://icons/ic_vertical_align_center_black_18dp.png" type="Texture" id=29]
[ext_resource path="res://icons/ic_vertical_align_bottom_black_18dp.png" type="Texture" id=30]
[ext_resource path="res://icons/ic_bookmark_border_black_18dp.png" type="Texture" id=31]
[ext_resource path="res://icons/ic_photo_size_select_large_black_18dp.png" type="Texture" id=32]
[ext_resource path="res://icons/ic_language_black_18dp.png" type="Texture" id=33]
[ext_resource path="res://icons/ic_format_color_text_black_18dp.png" type="Texture" id=34]
[ext_resource path="res://icons/ic_border_color_black_18dp.png" type="Texture" id=35]
[ext_resource path="res://icons/ic_format_color_outline_black_18dp.png" type="Texture" id=36]
[ext_resource path="res://icons/ic_format_color_fill_black_18dp.png" type="Texture" id=37]
[ext_resource path="res://icons/ic_format_color_doc_fill_black_18dp.png" type="Texture" id=38]
[ext_resource path="res://Panel.gd" type="Script" id=39]
[ext_resource path="res://Panel2.gd" type="Script" id=40]

[sub_resource type="GDScript" id=1]
script/source = "extends Control

# Called when the node enters the scene tree for the first time.
var font_fml = []

func _onresize():
	$FormatToolbar.rect_size.x = get_viewport_rect().size.x
	$StatBar.rect_size.x = get_viewport_rect().size.x
	$StatBar.rect_position.y =  get_viewport_rect().size.y - $StatBar.rect_size.y

	$HScrollBar.rect_position.y = get_viewport_rect().size.y - $StatBar.rect_size.y - $HScrollBar.rect_size.y - 5
	$HScrollBar.rect_size.x = get_viewport_rect().size.x - 20

	$VScrollBar.rect_position.x = get_viewport_rect().size.x - 5 - $VScrollBar.rect_size.x
	if $FormatToolbar/W.visible:
		$VScrollBar.rect_position.y = 405
		$VScrollBar.rect_size.y = get_viewport_rect().size.y - 405 - $StatBar.rect_size.y - $HScrollBar.rect_size.y - 10
	else:
		$VScrollBar.rect_position.y = 115
		$VScrollBar.rect_size.y = get_viewport_rect().size.y - 115 - $StatBar.rect_size.y - $HScrollBar.rect_size.y - 10

	$FormatToolbar/W.rect_position.x = get_viewport_rect().size.x - $FormatToolbar/W.rect_size.x
	
	$ScrollContainer.rect_position.y = get_viewport_rect().size.y - 55 - $ScrollContainer.rect_size.y
	$ScrollContainer.rect_size.x = get_viewport_rect().size.x - 35

func _on_HScrollBar_value_changed(value):
	$TLRichTextEdit.rect_position.x = 5 - value

func _on_VScrollBar_value_changed(value):
	$TLRichTextEdit.rect_position.y = 115 - value

var update = false

func _cursorchange():
	var p = $TLRichTextEdit.get_selection().get_start_para()
	var o = $TLRichTextEdit.get_selection().get_start_offset()

	update = true

	$TLRichTextEdit.rect_size = $TLRichTextEdit.get_minimum_size() + Vector2(5, 5)

	var cps = $TLRichTextEdit.get_caret_position() + $TLRichTextEdit.rect_position
	var miny = 115
	var maxy = get_viewport_rect().size.y - 10 - $HScrollBar.rect_size.y - $StatBar.rect_size.y - $TLRichTextEdit.get_paragraph(p).get_string().get_height()

	var minx = 5
	var maxx = get_viewport_rect().size.x - 10 - $VScrollBar.rect_size.x

	if cps.x > maxx:
		$TLRichTextEdit.rect_position.x = (maxx - $TLRichTextEdit.get_caret_position().x)
	elif cps.x < minx:
		$TLRichTextEdit.rect_position.x = (minx - $TLRichTextEdit.get_caret_position().x)

	if cps.y > maxy:
		$TLRichTextEdit.rect_position.y = (maxy - $TLRichTextEdit.get_caret_position().y)
	elif cps.y < miny:
		$TLRichTextEdit.rect_position.y = (miny - $TLRichTextEdit.get_caret_position().y)

	$HScrollBar.max_value = $TLRichTextEdit.rect_size.x - maxx + 5;
	$HScrollBar.value = 5 - $TLRichTextEdit.rect_position.x;

	$VScrollBar.max_value = $TLRichTextEdit.rect_size.y - maxy + 115;
	$VScrollBar.value = 115 - $TLRichTextEdit.rect_position.y;

	$StatBar/P.text = \"Paragraph: %d of %d\" % [p + 1, $TLRichTextEdit.get_paragraphs()]
	$StatBar/W.text = \"%d words, %d lines, %d characters\" % [$TLRichTextEdit.get_paragraph(p).get_word_bounds().size() + 1, $TLRichTextEdit.get_paragraph(p).get_line_bounds().size(), $TLRichTextEdit.get_paragraph(p).get_string().length()]

	var f = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, o) else $TLRichTextEdit.get_paragraph(p).get_string().get_base_font()
	for i in range(font_fml.size()):
		if f == font_fml[i]:
			$FormatToolbar/FontFamily.select(i)

	var s = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_SIZE, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_SIZE, o) else $TLRichTextEdit.get_paragraph(p).get_string().get_base_font_size()
	for i in range($FormatToolbar/FontSize.get_item_count()):
		if $FormatToolbar/FontSize.get_item_text(i).to_int() == s:
			$FormatToolbar/FontSize.select(i)

	var st = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_STYLE, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_STYLE, o) else $TLRichTextEdit.get_paragraph(p).get_string().get_base_font_style()
	$FormatToolbar/StyleItalic.pressed = (st == \"Italic\") or (st == \"BoldItalic\")
	$FormatToolbar/StyleBold.pressed = (st == \"Bold\") or (st == \"BoldItalic\")

	$FormatToolbar/FontFtr.text = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_FEATURES, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_FEATURES, o) else \"\"
	$FormatToolbar/Lang.text = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_LANGUAGE, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_LANGUAGE, o) else \"\"

	$FormatToolbar/StyleUnderline.pressed = ($TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH, o) else 0) > 0
	$FormatToolbar/StyleUnderline/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_COLOR, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_COLOR, o) else Color(0, 0, 1)
	$FormatToolbar/StyleUnderline/SpinBox.value = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH, o) else 1

	$FormatToolbar/StyleOver.pressed = ($TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH, o) else 0) > 0
	$FormatToolbar/StyleOver/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_COLOR, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_COLOR, o) else Color(0, 0, 1)
	$FormatToolbar/StyleOver/SpinBox.value = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH, o) else 1

	$FormatToolbar/StyleStrike.pressed = ($TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH, o) else 0) > 0
	$FormatToolbar/StyleStrike/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_COLOR, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_COLOR, o) else Color(0, 0, 1)
	$FormatToolbar/StyleStrike/SpinBox.value = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH, o) else 1

	$FormatToolbar/TextCol/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_COLOR, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_COLOR, o) else Color(0, 0, 0)
	$FormatToolbar/HlColor/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_HIGHLIGHT_COLOR, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_HIGHLIGHT_COLOR, o) else Color(1, 1, 0)
	$FormatToolbar/OutColor/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OUTLINE_COLOR, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_OUTLINE_COLOR, o) else Color(1, 1, 1, 0)

	$FormatToolbar/BackColor/ColorPickerButton.color = $TLRichTextEdit.get_paragraph(p).get_back_color()

	$FormatToolbar/Width.value = $TLRichTextEdit.get_paragraph(p).get_width()
	$FormatToolbar/Dir.select($TLRichTextEdit.get_paragraph(p).get_string().get_base_direction())
	$FormatToolbar/JstMode.select($TLRichTextEdit.get_paragraph(p).get_jst_flags() - 1)
	$FormatToolbar/BrkMode.select($TLRichTextEdit.get_paragraph(p).get_brk_flags() - 1)

	$FormatToolbar/LineSpace.value = $TLRichTextEdit.get_paragraph(p).get_line_spacing()

	$FormatToolbar/HalL.pressed = ($TLRichTextEdit.get_paragraph(p).get_halign()) == TLShapedParagraph.PARA_HALIGN_LEFT
	$FormatToolbar/HalC.pressed = ($TLRichTextEdit.get_paragraph(p).get_halign()) == TLShapedParagraph.PARA_HALIGN_CENTER
	$FormatToolbar/HalR.pressed = ($TLRichTextEdit.get_paragraph(p).get_halign()) == TLShapedParagraph.PARA_HALIGN_RIGHT
	$FormatToolbar/HalJ.pressed = ($TLRichTextEdit.get_paragraph(p).get_halign()) == TLShapedParagraph.PARA_HALIGN_FILL
	
	$FormatToolbar/ValT.pressed = ($TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, o) else TLShapedAttributedString.TEXT_VALIGN_CENTER) == TLShapedAttributedString.TEXT_VALIGN_TOP
	$FormatToolbar/ValC.pressed = ($TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, o) else TLShapedAttributedString.TEXT_VALIGN_CENTER) == TLShapedAttributedString.TEXT_VALIGN_CENTER
	$FormatToolbar/ValB.pressed = ($TLRichTextEdit.get_paragraph(p).get_string().get_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, o) if $TLRichTextEdit.get_paragraph(p).get_string().has_attribute(TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, o) else TLShapedAttributedString.TEXT_VALIGN_CENTER) == TLShapedAttributedString.TEXT_VALIGN_BOTTOM

	update = false

func _ready():
	var data_loader = TLICUDataLoader.new()
	data_loader.load(\"res://fonts/icudt67l.dat\")

	get_tree().get_root().connect(\"size_changed\", self, \"_onresize\")
	$TLRichTextEdit.connect(\"cursor_changed\", self, \"_cursorchange\")
	_onresize()

	var ms_rg = TLDynamicFontFace.new()
	ms_rg.load(\"res://fonts/Montserrat-Regular.ttf\")
	var ms_it = TLDynamicFontFace.new()
	ms_it.load(\"res://fonts/Montserrat-Italic.ttf\")
	var ms_bl = TLDynamicFontFace.new()
	ms_bl.load(\"res://fonts/Montserrat-Black.ttf\")
	var ms_bi = TLDynamicFontFace.new()
	ms_bi.load(\"res://fonts/Montserrat-BlackItalic.ttf\")

	var ms_fam = TLFontFamily.new()
	ms_fam.add_face(\"Regular\", ms_rg)
	ms_fam.add_face(\"Italic\", ms_it)
	ms_fam.add_face(\"Bold\", ms_bl)
	ms_fam.add_face(\"BoldItalic\", ms_bi)

	font_fml.append(ms_fam)
	$FormatToolbar/FontFamily.add_item(\"Montserrat\")

	var nt_rg = TLDynamicFontFace.new()
	nt_rg.load(\"res://fonts/NotoSans-Regular.ttf\")
	var nt_it = TLDynamicFontFace.new()
	nt_it.load(\"res://fonts/NotoSans-Italic.ttf\")
	var nt_bl = TLDynamicFontFace.new()
	nt_bl.load(\"res://fonts/NotoSans-Bold.ttf\")
	var nt_bi = TLDynamicFontFace.new()
	nt_bi.load(\"res://fonts/NotoSans-BoldItalic.ttf\")

	var nt_em = TLDynamicFontFace.new()
	nt_em.load(\"res://fonts/NotoColorEmoji-subset.ttf\")

	var nt_ar = TLDynamicFontFace.new()
	nt_ar.load(\"res://fonts/NotoNaskhArabic-Regular.ttf\")
	var nt_ab = TLDynamicFontFace.new()
	nt_ab.load(\"res://fonts/NotoNaskhArabic-Bold.ttf\")

	var nt_tr = TLDynamicFontFace.new()
	nt_tr.load(\"res://fonts/NotoSerifThai-Regular.ttf\")
	var nt_tb = TLDynamicFontFace.new()
	nt_tb.load(\"res://fonts/NotoSerifThai-Bold.ttf\")

	var nt_fam = TLFontFamily.new()
	nt_fam.add_face(\"Regular\", nt_rg)
	nt_fam.add_face(\"Regular\", nt_em)
	nt_fam.add_face_for_script(\"Regular\", nt_ar, \"ARAB\")
	nt_fam.add_face_for_script(\"Regular\", nt_tr, \"THAI\")
	nt_fam.add_face(\"Italic\", nt_it)
	nt_fam.add_face_for_script(\"Italic\", nt_ar, \"ARAB\")
	nt_fam.add_face_for_script(\"Italic\", nt_tr, \"THAI\")
	nt_fam.add_face(\"Bold\", nt_bl)
	nt_fam.add_face_for_script(\"Bold\", nt_ab, \"ARAB\")
	nt_fam.add_face_for_script(\"Bold\", nt_tb, \"THAI\")
	nt_fam.add_face(\"BoldItalic\", nt_bi)
	nt_fam.add_face_for_script(\"BoldItalic\", nt_ab, \"ARAB\")
	nt_fam.add_face_for_script(\"BoldItalic\", nt_tb, \"THAI\")

	font_fml.append(nt_fam)
	$FormatToolbar/FontFamily.add_item(\"Noto Sans (+Thai +Naskh)\")

	var nt_ar_bm = TLBitmapFontFace.new()
	nt_ar_bm.load(\"res://fonts/NotoNaskhArabicUI.fnt\")

	var nt_rg_bm = TLBitmapFontFace.new()
	nt_rg_bm.load(\"res://fonts/NotoSansRegular.fnt\")

	var nt_fam_bm = TLFontFamily.new()
	nt_fam_bm.add_face(\"Regular\", nt_rg_bm)
	nt_fam_bm.add_face_for_script(\"Regular\", nt_ar_bm, \"ARAB\")
	nt_fam_bm.add_face(\"Italic\", nt_rg_bm)
	nt_fam_bm.add_face_for_script(\"Italic\", nt_ar_bm, \"ARAB\")
	nt_fam_bm.add_face(\"Bold\", nt_rg_bm)
	nt_fam_bm.add_face_for_script(\"Bold\", nt_ar_bm, \"ARAB\")
	nt_fam_bm.add_face(\"BoldItalic\", nt_rg_bm)
	nt_fam_bm.add_face_for_script(\"BoldItalic\", nt_ar_bm, \"ARAB\")

	font_fml.append(nt_fam_bm)
	$FormatToolbar/FontFamily.add_item(\"Noto Sans (+Naskh bitmap)\")

	var nt_ar_ns = TLDynamicFontFace.new()
	nt_ar_ns.load(\"res://fonts/NotoNastaliqUrdu-Regular.ttf\")

	var nt_fam_ns = TLFontFamily.new()
	nt_fam_ns.add_face(\"Regular\", nt_rg)
	nt_fam_ns.add_face_for_script(\"Regular\", nt_ar_ns, \"ARAB\")
	nt_fam_ns.add_face(\"Italic\", nt_it)
	nt_fam_ns.add_face_for_script(\"Italic\", nt_ar_ns, \"ARAB\")
	nt_fam_ns.add_face(\"Bold\", nt_bl)
	nt_fam_ns.add_face_for_script(\"Bold\", nt_ar_ns, \"ARAB\")
	nt_fam_ns.add_face(\"BoldItalic\", nt_bi)
	nt_fam_ns.add_face_for_script(\"BoldItalic\", nt_ar_ns, \"ARAB\")

	font_fml.append(nt_fam_ns)
	$FormatToolbar/FontFamily.add_item(\"Noto Sans (+Nastaliq)\")

	var cn_rg = TLDynamicFontFace.new()
	cn_rg.load(\"res://fonts/ComicNeue-Regular.otf\")
	var cn_it = TLDynamicFontFace.new()
	cn_it.load(\"res://fonts/ComicNeue-Oblique.otf\")
	var cn_bl = TLDynamicFontFace.new()
	cn_bl.load(\"res://fonts/ComicNeue-Bold.otf\")
	var cn_bi = TLDynamicFontFace.new()
	cn_bi.load(\"res://fonts/ComicNeue-BoldOblique.otf\")

	var cn_fam = TLFontFamily.new()
	cn_fam.add_face(\"Regular\", cn_rg)
	cn_fam.add_face(\"Italic\", cn_it)
	cn_fam.add_face(\"Bold\", cn_bl)
	cn_fam.add_face(\"BoldItalic\", cn_bi)

	font_fml.append(cn_fam)
	$FormatToolbar/FontFamily.add_item(\"Comic Neue\")

	var aw_rg = TLDynamicFontFace.new()
	aw_rg.load(\"res://fonts/AwamiNastaliq-Regular.ttf\")

	var aw_fam = TLFontFamily.new()
	aw_fam.add_face(\"Regular\", aw_rg)
	aw_fam.add_face(\"Italic\", aw_rg)
	aw_fam.add_face(\"Bold\", aw_rg)
	aw_fam.add_face(\"BoldItalic\", aw_rg)

	font_fml.append(aw_fam)
	$FormatToolbar/FontFamily.add_item(\"Awami (Nastaliq, Graphite)\")

	#FULL NOTRO REGULAR
	var nt_fam_full = TLFontFamily.new()

	var ms_rg_base = TLDynamicFontFace.new()
	ms_rg_base.load(\"res://fonts/NotoFull/NotoSans-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_base)

	var ms_rg_aghm = TLDynamicFontFace.new()
	ms_rg_aghm.load(\"res://fonts/NotoFull/NotoSansCaucasianAlbanian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_aghm, \"aghm\")

	var ms_rg_ahom = TLDynamicFontFace.new()
	ms_rg_ahom.load(\"res://fonts/NotoFull/NotoSerifAhom-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_ahom, \"ahom\")

	var ms_rg_bhks = TLDynamicFontFace.new()
	ms_rg_bhks.load(\"res://fonts/NotoFull/NotoSansBhaiksuki-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_bhks, \"bhks\")

	var ms_rg_dupl = TLDynamicFontFace.new()
	ms_rg_dupl.load(\"res://fonts/NotoFull/NotoSansDuployan-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_dupl, \"dupl\")

	var ms_rg_elba = TLDynamicFontFace.new()
	ms_rg_elba.load(\"res://fonts/NotoFull/NotoSansElbasan-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_elba, \"elba\")

	var ms_rg_gran = TLDynamicFontFace.new()
	ms_rg_gran.load(\"res://fonts/NotoFull/NotoSansGrantha-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_gran, \"gran\")

	var ms_rg_hatr = TLDynamicFontFace.new()
	ms_rg_hatr.load(\"res://fonts/NotoFull/NotoSansHatran-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_hatr, \"hatr\")

	var ms_rg_hmng = TLDynamicFontFace.new()
	ms_rg_hmng.load(\"res://fonts/NotoFull/NotoSansPahawhHmong-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_hmng, \"hmng\")

	var ms_rg_hung = TLDynamicFontFace.new()
	ms_rg_hung.load(\"res://fonts/NotoFull/NotoSansOldHungarian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_hung, \"hung\")

	var ms_rg_khoj = TLDynamicFontFace.new()
	ms_rg_khoj.load(\"res://fonts/NotoFull/NotoSansKhojki-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_khoj, \"khoj\")

	var ms_rg_mahj = TLDynamicFontFace.new()
	ms_rg_mahj.load(\"res://fonts/NotoFull/NotoSansMahajani-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mahj, \"mahj\")

	var ms_rg_mani = TLDynamicFontFace.new()
	ms_rg_mani.load(\"res://fonts/NotoFull/NotoSansManichaean-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mani, \"mani\")

	var ms_rg_marc = TLDynamicFontFace.new()
	ms_rg_marc.load(\"res://fonts/NotoFull/NotoSansMarchen-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_marc, \"marc\")

	var ms_rg_mend = TLDynamicFontFace.new()
	ms_rg_mend.load(\"res://fonts/NotoFull/NotoSansMendeKikakui-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mend, \"mend\")

	var ms_rg_modi = TLDynamicFontFace.new()
	ms_rg_modi.load(\"res://fonts/NotoFull/NotoSansModi-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_modi, \"modi\")

	var ms_rg_mero = TLDynamicFontFace.new()
	ms_rg_mero.load(\"res://fonts/NotoFull/NotoSansMeroitic-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mero, \"mero\")

	var ms_rg_mroo = TLDynamicFontFace.new()
	ms_rg_mroo.load(\"res://fonts/NotoFull/NotoSansMro-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mroo, \"mroo\")

	var ms_rg_mult = TLDynamicFontFace.new()
	ms_rg_mult.load(\"res://fonts/NotoFull/NotoSansMultani-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mult, \"mult\")

	var ms_rg_narb = TLDynamicFontFace.new()
	ms_rg_narb.load(\"res://fonts/NotoFull/NotoSansOldNorthArabian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_narb, \"narb\")

	var ms_rg_nbat = TLDynamicFontFace.new()
	ms_rg_nbat.load(\"res://fonts/NotoFull/NotoSansNabataean-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_nbat, \"nbat\")

	var ms_rg_newa = TLDynamicFontFace.new()
	ms_rg_newa.load(\"res://fonts/NotoFull/NotoSansNewa-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_newa, \"newa\")

	var ms_rg_palm = TLDynamicFontFace.new()
	ms_rg_palm.load(\"res://fonts/NotoFull/NotoSansPalmyrene-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_palm, \"palm\")

	var ms_rg_pauc = TLDynamicFontFace.new()
	ms_rg_pauc.load(\"res://fonts/NotoFull/NotoSansPauCinHau-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_pauc, \"pauc\")

	var ms_rg_perm = TLDynamicFontFace.new()
	ms_rg_perm.load(\"res://fonts/NotoFull/NotoSansOldPermic-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_perm, \"perm\")

	var ms_rg_phlp = TLDynamicFontFace.new()
	ms_rg_phlp.load(\"res://fonts/NotoFull/NotoSansPsalterPahlavi-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_phlp, \"phlp\")

	var ms_rg_plrd = TLDynamicFontFace.new()
	ms_rg_plrd.load(\"res://fonts/NotoFull/NotoSansMiao-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_plrd, \"plrd\")

	var ms_rg_shrd = TLDynamicFontFace.new()
	ms_rg_shrd.load(\"res://fonts/NotoFull/NotoSansSharada-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_shrd, \"shrd\")

	var ms_rg_sind = TLDynamicFontFace.new()
	ms_rg_sind.load(\"res://fonts/NotoFull/NotoSansKhudawadi-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_sind, \"sind\")

	var ms_rg_sora = TLDynamicFontFace.new()
	ms_rg_sora.load(\"res://fonts/NotoFull/NotoSansSoraSompeng-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_sora, \"sora\")

	var ms_rg_takr = TLDynamicFontFace.new()
	ms_rg_takr.load(\"res://fonts/NotoFull/NotoSansTakri-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_takr, \"takr\")

	var ms_rg_tirh = TLDynamicFontFace.new()
	ms_rg_tirh.load(\"res://fonts/NotoFull/NotoSansTirhuta-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_tirh, \"tirh\")

	var ms_rg_wara = TLDynamicFontFace.new()
	ms_rg_wara.load(\"res://fonts/NotoFull/NotoSansWarangCiti-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_wara, \"wara\")

	var ms_rg_hluw = TLDynamicFontFace.new()
	ms_rg_hluw.load(\"res://fonts/NotoFull/NotoSansAnatolianHieroglyphs-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_hluw, \"hluw\")

	var ms_rg_mymr = TLDynamicFontFace.new()
	ms_rg_mymr.load(\"res://fonts/NotoFull/NotoSansMyanmar-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_mymr)

	var ms_rg_telu = TLDynamicFontFace.new()
	ms_rg_telu.load(\"res://fonts/NotoFull/NotoSansTelugu-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_telu)

	var ms_rg_guru = TLDynamicFontFace.new()
	ms_rg_guru.load(\"res://fonts/NotoFull/NotoSansGurmukhi-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_guru)

	var ms_rg_orya = TLDynamicFontFace.new()
	ms_rg_orya.load(\"res://fonts/NotoFull/NotoSansOriya-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_orya)

	var ms_rg_thai = TLDynamicFontFace.new()
	ms_rg_thai.load(\"res://fonts/NotoFull/NotoSansThai-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_thai)

	var ms_rg_knda = TLDynamicFontFace.new()
	ms_rg_knda.load(\"res://fonts/NotoFull/NotoSansKannada-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_knda)

	var ms_rg_osge = TLDynamicFontFace.new()
	ms_rg_osge.load(\"res://fonts/NotoFull/NotoSansOsage-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_osge, \"osge\")

	var ms_rg_tibt = TLDynamicFontFace.new()
	ms_rg_tibt.load(\"res://fonts/NotoFull/NotoSansTibetan-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_tibt)

	var ms_rg_mlym = TLDynamicFontFace.new()
	ms_rg_mlym.load(\"res://fonts/NotoFull/NotoSansMalayalam-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_mlym)

	var ms_rg_sinh = TLDynamicFontFace.new()
	ms_rg_sinh.load(\"res://fonts/NotoFull/NotoSansSinhala-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_sinh)

	var ms_rg_taml = TLDynamicFontFace.new()
	ms_rg_taml.load(\"res://fonts/NotoFull/NotoSansTamil-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_taml)

	var ms_rg_adlm = TLDynamicFontFace.new()
	ms_rg_adlm.load(\"res://fonts/NotoFull/NotoSansAdlam-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_adlm, \"adlm\")

	var ms_rg_hani = TLDynamicFontFace.new()
	ms_rg_hani.load(\"res://fonts/NotoFull/NotoSansCJKjp-Regular.otf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_hani)

	var ms_rg_deva = TLDynamicFontFace.new()
	ms_rg_deva.load(\"res://fonts/NotoFull/NotoSansDevanagari-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_deva)

	var ms_rg_khar = TLDynamicFontFace.new()
	ms_rg_khar.load(\"res://fonts/NotoFull/NotoSansKharoshthi-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_khar)

	var ms_rg_arab = TLDynamicFontFace.new()
	ms_rg_arab.load(\"res://fonts/NotoFull/NotoSansArabic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_arab)

	var ms_rg_cans = TLDynamicFontFace.new()
	ms_rg_cans.load(\"res://fonts/NotoFull/NotoSansCanadianAboriginal-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_cans)

	var ms_rg_ethi = TLDynamicFontFace.new()
	ms_rg_ethi.load(\"res://fonts/NotoFull/NotoSansEthiopic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_ethi)

	var ms_rg_khmr = TLDynamicFontFace.new()
	ms_rg_khmr.load(\"res://fonts/NotoFull/NotoSansKhmer-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_khmr)

	var ms_rg_armn = TLDynamicFontFace.new()
	ms_rg_armn.load(\"res://fonts/NotoFull/NotoSansArmenian-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_armn)

	var ms_rg_cakm = TLDynamicFontFace.new()
	ms_rg_cakm.load(\"res://fonts/NotoFull/NotoSansChakma-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_cakm, \"cakm\")

	var ms_rg_geor = TLDynamicFontFace.new()
	ms_rg_geor.load(\"res://fonts/NotoFull/NotoSansGeorgian-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_geor)

	var ms_rg_laoo = TLDynamicFontFace.new()
	ms_rg_laoo.load(\"res://fonts/NotoFull/NotoSansLao-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_laoo)

	var ms_rg_beng = TLDynamicFontFace.new()
	ms_rg_beng.load(\"res://fonts/NotoFull/NotoSansBengali-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_beng)

	var ms_rg_cher = TLDynamicFontFace.new()
	ms_rg_cher.load(\"res://fonts/NotoFull/NotoSansCherokee-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_cher)

	var ms_rg_gujr = TLDynamicFontFace.new()
	ms_rg_gujr.load(\"res://fonts/NotoFull/NotoSansGujarati-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_gujr)

	var ms_rg_buhd = TLDynamicFontFace.new()
	ms_rg_buhd.load(\"res://fonts/NotoFull/NotoSansBuhid-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_buhd)

	var ms_rg_dsrt = TLDynamicFontFace.new()
	ms_rg_dsrt.load(\"res://fonts/NotoFull/NotoSansDeseret-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_dsrt)

	var ms_rg_hebr = TLDynamicFontFace.new()
	ms_rg_hebr.load(\"res://fonts/NotoFull/NotoSansHebrew-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_hebr)

	var ms_rg_avst = TLDynamicFontFace.new()
	ms_rg_avst.load(\"res://fonts/NotoFull/NotoSansAvestan-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_avst, \"avst\")

	var ms_rg_bali = TLDynamicFontFace.new()
	ms_rg_bali.load(\"res://fonts/NotoFull/NotoSansBalinese-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_bali)

	var ms_rg_bamu = TLDynamicFontFace.new()
	ms_rg_bamu.load(\"res://fonts/NotoFull/NotoSansBamum-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_bamu, \"bamu\")

	var ms_rg_batk = TLDynamicFontFace.new()
	ms_rg_batk.load(\"res://fonts/NotoFull/NotoSansBatak-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_batk, \"batk\")

	var ms_rg_brah = TLDynamicFontFace.new()
	ms_rg_brah.load(\"res://fonts/NotoFull/NotoSansBrahmi-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_brah, \"brah\")

	var ms_rg_bugi = TLDynamicFontFace.new()
	ms_rg_bugi.load(\"res://fonts/NotoFull/NotoSansBuginese-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_bugi)

	var ms_rg_cari = TLDynamicFontFace.new()
	ms_rg_cari.load(\"res://fonts/NotoFull/NotoSansCarian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_cari, \"cari\")

	var ms_rg_copt = TLDynamicFontFace.new()
	ms_rg_copt.load(\"res://fonts/NotoFull/NotoSansCoptic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_copt)

	var ms_rg_xsux = TLDynamicFontFace.new()
	ms_rg_xsux.load(\"res://fonts/NotoFull/NotoSansCuneiform-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_xsux)

	var ms_rg_cprt = TLDynamicFontFace.new()
	ms_rg_cprt.load(\"res://fonts/NotoFull/NotoSansCypriot-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_cprt)

	var ms_rg_egyp = TLDynamicFontFace.new()
	ms_rg_egyp.load(\"res://fonts/NotoFull/NotoSansEgyptianHieroglyphs-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_egyp, \"egyp\")

	var ms_rg_glag = TLDynamicFontFace.new()
	ms_rg_glag.load(\"res://fonts/NotoFull/NotoSansGlagolitic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_glag)

	var ms_rg_goth = TLDynamicFontFace.new()
	ms_rg_goth.load(\"res://fonts/NotoFull/NotoSansGothic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_goth)

	var ms_rg_hano = TLDynamicFontFace.new()
	ms_rg_hano.load(\"res://fonts/NotoFull/NotoSansHanunoo-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_hano)

	var ms_rg_armi = TLDynamicFontFace.new()
	ms_rg_armi.load(\"res://fonts/NotoFull/NotoSansImperialAramaic-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_armi, \"armi\")

	var ms_rg_phli = TLDynamicFontFace.new()
	ms_rg_phli.load(\"res://fonts/NotoFull/NotoSansInscriptionalPahlavi-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_phli, \"phli\")

	var ms_rg_prti = TLDynamicFontFace.new()
	ms_rg_prti.load(\"res://fonts/NotoFull/NotoSansInscriptionalParthian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_prti, \"prti\")

	var ms_rg_java = TLDynamicFontFace.new()
	ms_rg_java.load(\"res://fonts/NotoFull/NotoSansJavanese-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_java, \"java\")

	var ms_rg_kthi = TLDynamicFontFace.new()
	ms_rg_kthi.load(\"res://fonts/NotoFull/NotoSansKaithi-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_kthi, \"kthi\")

	var ms_rg_kali = TLDynamicFontFace.new()
	ms_rg_kali.load(\"res://fonts/NotoFull/NotoSansKayahLi-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_kali)

	var ms_rg_lepc = TLDynamicFontFace.new()
	ms_rg_lepc.load(\"res://fonts/NotoFull/NotoSansLepcha-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_lepc)

	var ms_rg_limb = TLDynamicFontFace.new()
	ms_rg_limb.load(\"res://fonts/NotoFull/NotoSansLimbu-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_limb)

	var ms_rg_lina = TLDynamicFontFace.new()
	ms_rg_lina.load(\"res://fonts/NotoFull/NotoSansLinearA-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_lina, \"lina\")

	var ms_rg_linb = TLDynamicFontFace.new()
	ms_rg_linb.load(\"res://fonts/NotoFull/NotoSansLinearB-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_linb)

	var ms_rg_lisu = TLDynamicFontFace.new()
	ms_rg_lisu.load(\"res://fonts/NotoFull/NotoSansLisu-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_lisu, \"lisu\")

	var ms_rg_lyci = TLDynamicFontFace.new()
	ms_rg_lyci.load(\"res://fonts/NotoFull/NotoSansLycian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_lyci, \"lyci\")

	var ms_rg_lydi = TLDynamicFontFace.new()
	ms_rg_lydi.load(\"res://fonts/NotoFull/NotoSansLydian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_lydi, \"lydi\")

	var ms_rg_mand = TLDynamicFontFace.new()
	ms_rg_mand.load(\"res://fonts/NotoFull/NotoSansMandaic-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mand, \"mand\")

	var ms_rg_mtei = TLDynamicFontFace.new()
	ms_rg_mtei.load(\"res://fonts/NotoFull/NotoSansMeeteiMayek-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_mtei, \"mtei\")

	var ms_rg_mong = TLDynamicFontFace.new()
	ms_rg_mong.load(\"res://fonts/NotoFull/NotoSansMongolian-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_mong)

	var ms_rg_nkoo = TLDynamicFontFace.new()
	ms_rg_nkoo.load(\"res://fonts/NotoFull/NotoSansNKo-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_nkoo)

	var ms_rg_talu = TLDynamicFontFace.new()
	ms_rg_talu.load(\"res://fonts/NotoFull/NotoSansNewTaiLue-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_talu)

	var ms_rg_ogam = TLDynamicFontFace.new()
	ms_rg_ogam.load(\"res://fonts/NotoFull/NotoSansOgham-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_ogam)

	var ms_rg_olck = TLDynamicFontFace.new()
	ms_rg_olck.load(\"res://fonts/NotoFull/NotoSansOlChiki-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_olck)

	var ms_rg_ital = TLDynamicFontFace.new()
	ms_rg_ital.load(\"res://fonts/NotoFull/NotoSansOldItalic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_ital)

	var ms_rg_xpeo = TLDynamicFontFace.new()
	ms_rg_xpeo.load(\"res://fonts/NotoFull/NotoSansOldPersian-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_xpeo)

	var ms_rg_sarb = TLDynamicFontFace.new()
	ms_rg_sarb.load(\"res://fonts/NotoFull/NotoSansOldSouthArabian-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_sarb, \"sarb\")

	var ms_rg_orkh = TLDynamicFontFace.new()
	ms_rg_orkh.load(\"res://fonts/NotoFull/NotoSansOldTurkic-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_orkh, \"orkh\")

	var ms_rg_osma = TLDynamicFontFace.new()
	ms_rg_osma.load(\"res://fonts/NotoFull/NotoSansOsmanya-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_osma)

	var ms_rg_phag = TLDynamicFontFace.new()
	ms_rg_phag.load(\"res://fonts/NotoFull/NotoSansPhagsPa-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_phag, \"phag\")

	var ms_rg_phnx = TLDynamicFontFace.new()
	ms_rg_phnx.load(\"res://fonts/NotoFull/NotoSansPhoenician-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_phnx, \"phnx\")

	var ms_rg_rjng = TLDynamicFontFace.new()
	ms_rg_rjng.load(\"res://fonts/NotoFull/NotoSansRejang-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_rjng)

	var ms_rg_runr = TLDynamicFontFace.new()
	ms_rg_runr.load(\"res://fonts/NotoFull/NotoSansRunic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_runr)

	var ms_rg_samr = TLDynamicFontFace.new()
	ms_rg_samr.load(\"res://fonts/NotoFull/NotoSansSamaritan-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_samr, \"samr\")

	var ms_rg_saur = TLDynamicFontFace.new()
	ms_rg_saur.load(\"res://fonts/NotoFull/NotoSansSaurashtra-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_saur)

	var ms_rg_shaw = TLDynamicFontFace.new()
	ms_rg_shaw.load(\"res://fonts/NotoFull/NotoSansShavian-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_shaw)

	var ms_rg_sund = TLDynamicFontFace.new()
	ms_rg_sund.load(\"res://fonts/NotoFull/NotoSansSundanese-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_sund)

	var ms_rg_sylo = TLDynamicFontFace.new()
	ms_rg_sylo.load(\"res://fonts/NotoFull/NotoSansSylotiNagri-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_sylo)

	var ms_rg_syrc = TLDynamicFontFace.new()
	ms_rg_syrc.load(\"res://fonts/NotoFull/NotoSansSyriacEastern-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_syrc)

	var ms_rg_tglg = TLDynamicFontFace.new()
	ms_rg_tglg.load(\"res://fonts/NotoFull/NotoSansTagalog-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_tglg)

	var ms_rg_tagb = TLDynamicFontFace.new()
	ms_rg_tagb.load(\"res://fonts/NotoFull/NotoSansTagbanwa-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_tagb)

	var ms_rg_tale = TLDynamicFontFace.new()
	ms_rg_tale.load(\"res://fonts/NotoFull/NotoSansTaiLe-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_tale)

	var ms_rg_lana = TLDynamicFontFace.new()
	ms_rg_lana.load(\"res://fonts/NotoFull/NotoSansTaiTham-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_lana, \"lana\")

	var ms_rg_tavt = TLDynamicFontFace.new()
	ms_rg_tavt.load(\"res://fonts/NotoFull/NotoSansTaiViet-Regular.ttf\")
	nt_fam_full.add_face_for_script(\"Regular\", ms_rg_tavt, \"tavt\")

	var ms_rg_thaa = TLDynamicFontFace.new()
	ms_rg_thaa.load(\"res://fonts/NotoFull/NotoSansThaana-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_thaa)

	var ms_rg_tfng = TLDynamicFontFace.new()
	ms_rg_tfng.load(\"res://fonts/NotoFull/NotoSansTifinagh-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_tfng)

	var ms_rg_ugar = TLDynamicFontFace.new()
	ms_rg_ugar.load(\"res://fonts/NotoFull/NotoSansUgaritic-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_ugar)

	var ms_rg_vaii = TLDynamicFontFace.new()
	ms_rg_vaii.load(\"res://fonts/NotoFull/NotoSansVai-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_vaii)

	var ms_rg_yiii = TLDynamicFontFace.new()
	ms_rg_yiii.load(\"res://fonts/NotoFull/NotoSansYi-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_yiii)

	var ms_rg_cham = TLDynamicFontFace.new()
	ms_rg_cham.load(\"res://fonts/NotoFull/NotoSansCham-Regular.ttf\")
	nt_fam_full.add_face(\"Regular\", ms_rg_cham)

	font_fml.append(nt_fam_full)
	$FormatToolbar/FontFamily.add_item(\"Noto Sans (+Full, Reg)\")

	##END

	$TLRichTextEdit.get_paragraph(0).get_string().set_base_font(nt_fam)
	$TLRichTextEdit.get_paragraph(0).get_string().set_base_font_style(\"Regular\")

	$FormatToolbar/FontFamily.select(2)

	#embedded images
	$FormatToolbar/InsertImage.add_item(\"Godot icon\")
	$FormatToolbar/InsertImage.add_item(\"Godot old icon\")
	$FormatToolbar/InsertImage.add_item(\"Godot ancient icon\")

	$FormatToolbar/InsertImage.set_item_metadata(0, load(\"res://icon_new.png\"))
	$FormatToolbar/InsertImage.set_item_metadata(1, load(\"res://icon_old.png\"))
	$FormatToolbar/InsertImage.set_item_metadata(2, load(\"res://icon_older.png\"))

	#font sizes
	var s = 6;
	while (s < 16):
		$FormatToolbar/FontSize.add_item(\"%d\" % s)
		s = s + 1
	while (s < 28):
		$FormatToolbar/FontSize.add_item(\"%d\" % s)
		s = s + 2
	while (s < 48):
		$FormatToolbar/FontSize.add_item(\"%d\" % s)
		s = s + 4
	while (s < 72):
		$FormatToolbar/FontSize.add_item(\"%d\" % s)
		s = s + 6
	while (s <= 96):
		$FormatToolbar/FontSize.add_item(\"%d\" % s)
		s = s + 8
	$FormatToolbar/FontSize.select(6)

	$FormatToolbar/Dir.add_item(\"LTR\")
	$FormatToolbar/Dir.add_item(\"RTL\")
	$FormatToolbar/Dir.add_item(\"Locale\")
	$FormatToolbar/Dir.add_item(\"Auto\")

	$FormatToolbar/BrkMode.add_item(\"No autobreak\")
	$FormatToolbar/BrkMode.add_item(\"Words\")
	$FormatToolbar/BrkMode.add_item(\"Graphemes\")
	$FormatToolbar/BrkMode.select(2)
	
	$FormatToolbar/JstMode.add_item(\"Kashidas/spaces\")
	$FormatToolbar/JstMode.add_item(\"Kashidas\")
	$FormatToolbar/JstMode.add_item(\"Spaces\")

func _on_FontFamily_item_selected(ID):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, font_fml[ID])

func _on_FontSize_item_selected(ID):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_SIZE, $FormatToolbar/FontSize.get_item_text(ID).to_int())

func _on_FontFtr_text_entered(new_text):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_FEATURES, new_text)

func _on_Style_toggled(button_pressed):
	if (update):
		return
	if $FormatToolbar/StyleBold.pressed and $FormatToolbar/StyleItalic.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_STYLE, \"BoldItalic\")
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, font_fml[$FormatToolbar/FontFamily.selected])
	elif $FormatToolbar/StyleBold.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_STYLE, \"Bold\")
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, font_fml[$FormatToolbar/FontFamily.selected])
	elif $FormatToolbar/StyleItalic.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_STYLE, \"Italic\")
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, font_fml[$FormatToolbar/FontFamily.selected])
	else:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT_STYLE, \"Regular\")
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_FONT, font_fml[$FormatToolbar/FontFamily.selected])

func _on_SpinBoxUnder_value_changed(value):
	if (update):
		return
	if $FormatToolbar/StyleUnderline.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH, value)

func _on_SpinBoxOver_value_changed(value):
	if (update):
		return
	if $FormatToolbar/StyleOver.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH, value)

func _on_SpinBoxStrike_value_changed(value):
	if (update):
		return
	if $FormatToolbar/StyleStrike.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH, value)

func _on_StyleUnderline_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_COLOR, $FormatToolbar/StyleUnderline/ColorPickerButton.color)
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH, $FormatToolbar/StyleUnderline/SpinBox.value)
	else:
		$TLRichTextEdit.remove_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_COLOR)
		$TLRichTextEdit.remove_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_WIDTH)

func _on_StyleUnderlineColorPickerButton_color_changed(color):
	if (update):
		return
	if $FormatToolbar/StyleUnderline.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_UNDERLINE_COLOR, color)

func _on_StyleOver_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_COLOR, $FormatToolbar/StyleOver/ColorPickerButton.color)
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH, $FormatToolbar/StyleOver/SpinBox.value)
	else:
		$TLRichTextEdit.remove_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_COLOR)
		$TLRichTextEdit.remove_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_WIDTH)

func _on_StyleOverColorPickerButton_color_changed(color):
	if (update):
		return
	if $FormatToolbar/StyleOver.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OVERLINE_COLOR, color)

func _on_StyleStrike_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_COLOR, $FormatToolbar/StyleStrike/ColorPickerButton.color)
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH, $FormatToolbar/StyleStrike/SpinBox.value)
	else:
		$TLRichTextEdit.remove_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_COLOR)
		$TLRichTextEdit.remove_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_WIDTH)

func _on_StyleStrikeColorPickerButton_color_changed(color):
	if (update):
		return
	if $FormatToolbar/StyleStrike.pressed:
		$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_STRIKETHROUGH_COLOR, color)

func _on_HalL_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.set_paragraph_halign($TLRichTextEdit.get_selection(), TLShapedParagraph.PARA_HALIGN_LEFT)

func _on_HalC_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.set_paragraph_halign($TLRichTextEdit.get_selection(), TLShapedParagraph.PARA_HALIGN_CENTER)

func _on_HalR_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.set_paragraph_halign($TLRichTextEdit.get_selection(), TLShapedParagraph.PARA_HALIGN_RIGHT)

func _on_HalJ_toggled(button_pressed):
	if (update):
		return
	if button_pressed:
		$TLRichTextEdit.set_paragraph_halign($TLRichTextEdit.get_selection(),TLShapedParagraph.PARA_HALIGN_FILL)

func _on_TextColorPickerButton_color_changed(color):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_COLOR, color)

func _on_HlColorPickerButton_color_changed(color):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_HIGHLIGHT_COLOR, color)

func _on_BackColorPickerButton_color_changed(color):
	if (update):
		return
	$TLRichTextEdit.set_paragraph_back_color($TLRichTextEdit.get_selection(),color)

func _on_ClearFMT_pressed():
	if (update):
		return
	$TLRichTextEdit.remove_attributes($TLRichTextEdit.get_selection())

func _on_Dir_item_selected(ID):
	if (update):
		return
	var f = $TLRichTextEdit.get_selection().get_start_para()
	var l = $TLRichTextEdit.get_selection().get_end_para()
	for i in range(f, l + 1):
		$TLRichTextEdit.get_paragraph(i).get_string().set_base_direction(ID)

func _on_BrkMode_item_selected(ID):
	if (update):
		return
	$TLRichTextEdit.set_paragraph_brk_flags($TLRichTextEdit.get_selection(), ID + 1)

func _on_JstMode_item_selected(ID):
	if (update):
		return
	$TLRichTextEdit.set_paragraph_jst_flags($TLRichTextEdit.get_selection(), ID + 1)

func _on_ValT_toggled(button_pressed):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, TLShapedAttributedString.TEXT_VALIGN_TOP)

func _on_ValC_toggled(button_pressed):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, TLShapedAttributedString.TEXT_VALIGN_CENTER)

func _on_ValB_toggled(button_pressed):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_VALIGN, TLShapedAttributedString.TEXT_VALIGN_BOTTOM)

func _on_DecW_pressed():
	if (update):
		return
	var f = $TLRichTextEdit.get_selection().get_start_para()
	var l = $TLRichTextEdit.get_selection().get_end_para()
	for i in range(f, l + 1):
		$TLRichTextEdit.get_paragraph(i).set_indent($TLRichTextEdit.get_paragraph(i).get_indent() + 10)

func _on_IncW_pressed():
	if (update):
		return
	var f = $TLRichTextEdit.get_selection().get_start_para()
	var l = $TLRichTextEdit.get_selection().get_end_para()
	for i in range(f, l + 1):
		$TLRichTextEdit.get_paragraph(i).set_indent($TLRichTextEdit.get_paragraph(i).get_indent() - 10)

func _on_Lang_text_entered(new_text):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_LANGUAGE, new_text)

func _on_InsertImage_item_selected(ID):
	if (update):
		return
	$TLRichTextEdit.replace_text($TLRichTextEdit.get_selection(), \"?\")
	$TLRichTextEdit.get_selection().set_start_offset($TLRichTextEdit.get_selection().get_start_offset() - 1)
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_REPLACEMENT_IMAGE, $FormatToolbar/InsertImage.get_item_metadata(ID))
	$TLRichTextEdit.get_selection().set_start_offset($TLRichTextEdit.get_selection().get_end_offset())

func _on_New_pressed():
	if (update):
		return
	$TLRichTextEdit.clear()
	$TLRichTextEdit.get_paragraph(0).get_string().set_base_font(font_fml[1])
	$TLRichTextEdit.get_paragraph(0).get_string().set_base_font_style(\"Regular\")

func _print_err():
	print(\"Invalid file..\")

func _on_Load_pressed():
	if (update):
		return
	$FileDialogLoad.popup()
	
func _on_FileDialogLoad_file_selected(path):
	$TLRichTextEdit.clear()
	$TLRichTextEdit.get_paragraph(0).get_string().set_base_font(font_fml[1])
	$TLRichTextEdit.get_paragraph(0).get_string().set_base_font_style(\"Regular\")

	var loadfile = File.new()
	loadfile.open(path, File.READ)
	if loadfile.get_8() != 0x47:
		_print_err()
		return
	if loadfile.get_8() != 0x44:
		_print_err()
		return
	if loadfile.get_8() != 0x52:
		_print_err()
		return
	if loadfile.get_8() != 0x54:
		_print_err()
		return
	if loadfile.get_8() != 0x46:
		_print_err()
		return
	if loadfile.get_8() != 0x00:
		_print_err()
		return
	if loadfile.get_8() != 0x01:
		_print_err()
		return
	var para_count = loadfile.get_64()
	for i in range(para_count):
		var utf16_size = loadfile.get_64()
		var utf16 = loadfile.get_buffer(utf16_size)
		if i > 0:
			$TLRichTextEdit.insert_paragraph(null, i)
		$TLRichTextEdit.get_paragraph(i).get_string().set_utf16(utf16)
		var para = parse_json(loadfile.get_pascal_string())
		#IDs to refs
		if !para[\"base_font\"].begins_with(\"CTL_DEMO_FONT_\"):
			_print_err()
			return
		para[\"base_font\"] = font_fml[para[\"base_font\"].trim_prefix(\"CTL_DEMO_FONT_\").to_int()]
		$TLRichTextEdit.get_paragraph(i).set_width(para[\"width\"])
		$TLRichTextEdit.get_paragraph(i).set_indent(para[\"indent\"])
		$TLRichTextEdit.get_paragraph(i).set_back_color(para[\"back_color\"])
		$TLRichTextEdit.get_paragraph(i).set_line_spacing(para[\"line_spacing\"])
		$TLRichTextEdit.get_paragraph(i).get_string().set_base_direction(para[\"base_direction\"])
		$TLRichTextEdit.get_paragraph(i).get_string().set_base_font(para[\"base_font\"])
		$TLRichTextEdit.get_paragraph(i).get_string().set_base_font_style(para[\"base_font_style\"])
		$TLRichTextEdit.get_paragraph(i).get_string().set_base_font_size(para[\"font_font_size\"])
		$TLRichTextEdit.get_paragraph(i).set_brk_flags(para[\"brk_flags\"])
		$TLRichTextEdit.get_paragraph(i).set_jst_flags(para[\"jst_flags\"])
		$TLRichTextEdit.get_paragraph(i).set_halign(para[\"halign\"])
		for a in range(para[\"attributes\"].size()):
			if para[\"attributes\"][a].has(\"format\"):
				if para[\"attributes\"][a][\"format\"].has(\"font\"):
					if !para[\"attributes\"][a][\"format\"][\"font\"].begins_with(\"CTL_DEMO_FONT_\"):
						_print_err()
						return
					para[\"attributes\"][a][\"format\"][\"font\"] = font_fml[para[\"attributes\"][a][\"format\"][\"font\"].trim_prefix(\"CTL_DEMO_FONT_\").to_int()]
				if para[\"attributes\"][a][\"format\"].has(\"repl_image\"):
					if !para[\"attributes\"][a][\"format\"][\"repl_image\"].begins_with(\"CTL_DEMO_RIMG_\"):
						_print_err()
						return
					para[\"attributes\"][a][\"format\"][\"repl_image\"] = $FormatToolbar/InsertImage.get_item_metadata(para[\"attributes\"][a][\"format\"][\"repl_image\"].trim_prefix(\"CTL_DEMO_RIMG_\").to_int())
		$TLRichTextEdit.get_paragraph(i).get_string().load_attributes_dict(para[\"attributes\"])
		loadfile.get_8()
		loadfile.get_8()
	#todo set caret and selection

func _on_Save_pressed():
	if (update):
		return
	$FileDialogSave.popup()

func _on_FileDialogSave_file_selected(path):
	var savefile = File.new()
	savefile.open(path, File.WRITE)
	#magic
	savefile.store_8(0x47)
	savefile.store_8(0x44)
	savefile.store_8(0x52)
	savefile.store_8(0x54)
	savefile.store_8(0x46)
	#version
	savefile.store_8(0x00)
	savefile.store_8(0x01)
	#paragraph count
	savefile.store_64($TLRichTextEdit.get_paragraphs())
	for i in range($TLRichTextEdit.get_paragraphs()):
		var para = {}
		var utf16 = $TLRichTextEdit.get_paragraph(i).get_string().get_utf16()
		savefile.store_64(utf16.size())
		savefile.store_buffer(utf16)
		para[\"width\"] = $TLRichTextEdit.get_paragraph(i).get_width()
		para[\"indent\"] = $TLRichTextEdit.get_paragraph(i).get_indent()
		para[\"back_color\"] = $TLRichTextEdit.get_paragraph(i).get_back_color().to_html()
		para[\"line_spacing\"] = $TLRichTextEdit.get_paragraph(i).get_line_spacing()
		para[\"base_direction\"] = $TLRichTextEdit.get_paragraph(i).get_string().get_base_direction()
		for j in range(font_fml.size()):
			if $TLRichTextEdit.get_paragraph(i).get_string().get_base_font() == font_fml[j]:
				para[\"base_font\"] = \"CTL_DEMO_FONT_%d\" % [j]
				break
		para[\"base_font_style\"] = $TLRichTextEdit.get_paragraph(i).get_string().get_base_font_style()
		para[\"font_font_size\"] = $TLRichTextEdit.get_paragraph(i).get_string().get_base_font_size()
		para[\"brk_flags\"] = $TLRichTextEdit.get_paragraph(i).get_brk_flags()
		para[\"jst_flags\"] = $TLRichTextEdit.get_paragraph(i).get_jst_flags()
		para[\"halign\"] = $TLRichTextEdit.get_paragraph(i).get_halign()
		para[\"attributes\"] = $TLRichTextEdit.get_paragraph(i).get_string().save_attributes_dict()
		#replace refs with IDs
		for a in range(para[\"attributes\"].size()):
			if para[\"attributes\"][a].has(\"format\"):
				if para[\"attributes\"][a][\"format\"].has(\"font\"):
					for j in range(font_fml.size()):
						if para[\"attributes\"][a][\"format\"][\"font\"] == font_fml[j]:
							para[\"attributes\"][a][\"format\"][\"font\"] = \"CTL_DEMO_FONT_%d\" % [j]
							break
				if para[\"attributes\"][a][\"format\"].has(\"repl_image\"):
					for j in range($FormatToolbar/InsertImage.get_item_count()):
						if para[\"attributes\"][a][\"format\"][\"repl_image\"] == $FormatToolbar/InsertImage.get_item_metadata(j):
							para[\"attributes\"][a][\"format\"][\"repl_image\"] = \"CTL_DEMO_RIMG_%d\" % [j]
							break
		savefile.store_pascal_string(to_json(para))
		savefile.store_8(00)
		savefile.store_8(00)
	#todo save caret and selection

func _on_Width_value_changed(value):
	if (update):
		return
	$TLRichTextEdit.set_paragraph_width($TLRichTextEdit.get_selection(), value)

func _on_ClearFMT2_pressed():
	if (update):
		return
	$TLRichTextEdit.set_paragraph_width($TLRichTextEdit.get_selection(), -1.0)

func _on_LineSpace_value_changed(value):
	if (update):
		return
	$TLRichTextEdit.set_paragraph_line_spacing($TLRichTextEdit.get_selection(), value)

func _on_Color2PickerButton_color_changed(color):
	if (update):
		return
	$TLRichTextEdit.set_back_color(color)

func _on_ParaSpace_value_changed(value):
	if (update):
		return
	$TLRichTextEdit.set_paragraph_spacing(value)

func _on_ColorPickerButton_color_changed(color):
	if (update):
		return
	$TLRichTextEdit.add_attribute($TLRichTextEdit.get_selection(), TLShapedAttributedString.TEXT_ATTRIBUTE_OUTLINE_COLOR, color)

func _on_TLRichTextEdit_gui_input(event):
	if (update):
		return
	if event is InputEventMouseMotion:
		$StatBar/X.text = $TLRichTextEdit.get_cluster_debug_info_hit_test(event.position)
		var r = $TLRichTextEdit.get_cluster_rect_hit_test(event.position)
		$TLRichTextEdit/Panel.rect_position = r.position
		$TLRichTextEdit/Panel.rect_size = r.size
		$FormatToolbar/W/Panel.gldata = $TLRichTextEdit.get_cluster_glyphs_hit_test(event.position)
		$FormatToolbar/W/Panel.update()
		$ScrollContainer/PanelDbgD.point = event.position
		$ScrollContainer/PanelDbgD.update()

func _on_DEbug_toggled(button_pressed):
	$TLRichTextEdit/Panel.visible = button_pressed

func _on_DebugLBrk_toggled(button_pressed):
	$ScrollContainer/PanelDbgD.brk = button_pressed
	$ScrollContainer/PanelDbgD.update()

func _on_DebugJBrk_toggled(button_pressed):
	$ScrollContainer/PanelDbgD.jst = button_pressed
	$ScrollContainer/PanelDbgD.update()

func _on_DebugJBrk2_toggled(button_pressed):
	$FormatToolbar/W.visible = button_pressed
	if $FormatToolbar/W.visible:
		$VScrollBar.rect_position.y = 405
		$VScrollBar.rect_size.y = get_viewport_rect().size.y - 405 - $StatBar.rect_size.y - $HScrollBar.rect_size.y - 10
	else:
		$VScrollBar.rect_position.y = 115
		$VScrollBar.rect_size.y = get_viewport_rect().size.y - 115 - $StatBar.rect_size.y - $HScrollBar.rect_size.y - 10

func _on_DebugDdr_toggled(button_pressed):
	$FormatToolbar/DebugLBrk.disabled = !button_pressed
	$FormatToolbar/DebugJBrk.disabled = !button_pressed
	$ScrollContainer.visible = button_pressed
	$ScrollContainer/PanelDbgD.update()

func _on_Button_pressed():
	$FormatToolbar/W.visible = false
	$FormatToolbar/DebugJBrk2.pressed = false
"

[sub_resource type="StyleBoxFlat" id=2]
content_margin_left = 6.0
content_margin_right = 6.0
bg_color = Color( 0.376471, 0.376471, 0.376471, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.0509804, 0.00784314, 0.827451, 1 )

[sub_resource type="StyleBoxFlat" id=3]
content_margin_left = 6.0
content_margin_right = 6.0
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.0235294, 0.0117647, 0.176471, 1 )

[sub_resource type="StyleBoxFlat" id=4]
content_margin_left = 6.0
content_margin_right = 6.0
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0, 0, 0, 1 )

[sub_resource type="StyleBoxFlat" id=5]
content_margin_left = 6.0
content_margin_right = 6.0
bg_color = Color( 0.254902, 0.254902, 0.254902, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0, 0, 0, 1 )

[sub_resource type="StyleBoxFlat" id=6]
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.0392157, 0.0313726, 0.141176, 1 )

[sub_resource type="StyleBoxFlat" id=7]
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0, 0, 0, 1 )

[sub_resource type="StyleBoxFlat" id=8]
bg_color = Color( 0.254902, 0.254902, 0.254902, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.0588235, 0.0862745, 0.741176, 1 )

[sub_resource type="StyleBoxFlat" id=9]
bg_color = Color( 0.376471, 0.376471, 0.376471, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.027451, 0, 0.486275, 1 )

[sub_resource type="StyleBoxFlat" id=10]
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0, 0, 0, 1 )

[sub_resource type="Theme" id=11]
Button/styles/focus = SubResource( 2 )
Button/styles/hover = SubResource( 3 )
Button/styles/normal = SubResource( 4 )
Button/styles/pressed = SubResource( 5 )
ColorPickerButton/styles/hover = SubResource( 6 )
ColorPickerButton/styles/normal = SubResource( 7 )
ColorPickerButton/styles/pressed = SubResource( 8 )
LineEdit/colors/font_color = Color( 0, 0, 0, 1 )
LineEdit/styles/focus = SubResource( 9 )
LineEdit/styles/normal = SubResource( 10 )

[sub_resource type="ButtonGroup" id=12]

[sub_resource type="ButtonGroup" id=13]

[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 1200, 400 )
script = SubResource( 1 )

[node name="TLRichTextEdit" type="TLRichTextEdit" parent="."]
margin_left = 5.0
margin_top = 115.0
margin_right = 1195.0
margin_bottom = 765.0
back_color = Color( 1, 1, 1, 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Panel" type="Panel" parent="TLRichTextEdit"]
visible = false
modulate = Color( 1, 1, 1, 0.498039 )
margin_right = 40.0
margin_bottom = 40.0
mouse_filter = 1

[node name="FormatToolbar" type="ColorRect" parent="."]
margin_right = 1200.0
margin_bottom = 110.0
theme = SubResource( 11 )
color = Color( 0.423529, 0.423529, 0.423529, 1 )

[node name="FontFamily" type="OptionButton" parent="FormatToolbar"]
margin_left = 5.0
margin_top = 40.0
margin_right = 235.0
margin_bottom = 70.0
hint_tooltip = "Font Family"
focus_mode = 0
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect2" type="TextureRect" parent="FormatToolbar/FontFamily"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 1 )
stretch_mode = 4

[node name="FontSize" type="OptionButton" parent="FormatToolbar"]
margin_left = 244.0
margin_top = 40.0
margin_right = 334.0
margin_bottom = 70.0
hint_tooltip = "Font size"
focus_mode = 0
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect2" type="TextureRect" parent="FormatToolbar/FontSize"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 2 )
stretch_mode = 4

[node name="StyleBold" type="Button" parent="FormatToolbar"]
margin_left = 664.0
margin_top = 40.0
margin_right = 694.0
margin_bottom = 70.0
hint_tooltip = "Bold"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 3 )

[node name="StyleItalic" type="Button" parent="FormatToolbar"]
margin_left = 694.0
margin_top = 40.0
margin_right = 724.0
margin_bottom = 70.0
hint_tooltip = "Italic"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 4 )

[node name="StyleUnderline" type="Button" parent="FormatToolbar"]
margin_left = 734.0
margin_top = 40.0
margin_right = 764.0
margin_bottom = 70.0
hint_tooltip = "Underline"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 5 )

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/StyleUnderline"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Underline color"
focus_mode = 0
color = Color( 0, 0, 1, 1 )

[node name="SpinBox" type="SpinBox" parent="FormatToolbar/StyleUnderline"]
margin_left = 50.0
margin_right = 116.0
margin_bottom = 30.0
min_value = 1.0
max_value = 20.0
value = 1.0
align = 1

[node name="StyleOver" type="Button" parent="FormatToolbar"]
margin_left = 850.0
margin_top = 40.0
margin_right = 880.0
margin_bottom = 70.0
hint_tooltip = "Overline"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 6 )

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/StyleOver"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Overline color"
focus_mode = 0
color = Color( 0.0313726, 0, 1, 1 )

[node name="SpinBox" type="SpinBox" parent="FormatToolbar/StyleOver"]
margin_left = 50.0
margin_right = 116.0
margin_bottom = 30.0
min_value = 1.0
max_value = 20.0
value = 1.0
align = 1

[node name="StyleStrike" type="Button" parent="FormatToolbar"]
margin_left = 966.0
margin_top = 40.0
margin_right = 996.0
margin_bottom = 70.0
hint_tooltip = "Strikethrough"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 7 )

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/StyleStrike"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Strikethrough color"
focus_mode = 0
color = Color( 0, 0, 1, 1 )

[node name="SpinBox" type="SpinBox" parent="FormatToolbar/StyleStrike"]
margin_left = 50.0
margin_right = 116.0
margin_bottom = 30.0
min_value = 1.0
max_value = 20.0
value = 1.0
align = 1

[node name="HalL" type="Button" parent="FormatToolbar"]
margin_left = 495.0
margin_top = 75.0
margin_right = 525.0
margin_bottom = 105.0
hint_tooltip = "Align left"
focus_mode = 0
toggle_mode = true
pressed = true
group = SubResource( 12 )
icon = ExtResource( 8 )

[node name="HalC" type="Button" parent="FormatToolbar"]
margin_left = 525.0
margin_top = 75.0
margin_right = 555.0
margin_bottom = 105.0
hint_tooltip = "Align center"
focus_mode = 0
toggle_mode = true
group = SubResource( 12 )
icon = ExtResource( 9 )

[node name="HalR" type="Button" parent="FormatToolbar"]
margin_left = 555.0
margin_top = 75.0
margin_right = 585.0
margin_bottom = 105.0
hint_tooltip = "Align right"
focus_mode = 0
toggle_mode = true
group = SubResource( 12 )
icon = ExtResource( 10 )

[node name="HalJ" type="Button" parent="FormatToolbar"]
margin_left = 585.0
margin_top = 75.0
margin_right = 615.0
margin_bottom = 105.0
hint_tooltip = "Justified"
focus_mode = 0
toggle_mode = true
group = SubResource( 12 )
icon = ExtResource( 11 )

[node name="ClearFMT" type="Button" parent="FormatToolbar"]
margin_left = 734.0
margin_top = 5.0
margin_right = 764.0
margin_bottom = 35.0
hint_tooltip = "Clear formatting"
focus_mode = 0
icon = ExtResource( 12 )

[node name="ClearFMT2" type="Button" parent="FormatToolbar"]
margin_left = 1036.0
margin_top = 75.0
margin_right = 1066.0
margin_bottom = 105.0
hint_tooltip = "Reset paragraph width"
focus_mode = 0
icon = ExtResource( 13 )

[node name="DebugRect" type="Button" parent="FormatToolbar"]
margin_left = 888.0
margin_top = 5.0
margin_right = 918.0
margin_bottom = 35.0
hint_tooltip = "Debug: Display cluster rect"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 14 )

[node name="DebugLBrk" type="Button" parent="FormatToolbar"]
margin_left = 1036.0
margin_top = 5.0
margin_right = 1066.0
margin_bottom = 35.0
hint_tooltip = "Debug: Display line break points"
focus_mode = 0
disabled = true
toggle_mode = true
icon = ExtResource( 15 )

[node name="DebugJBrk" type="Button" parent="FormatToolbar"]
margin_left = 1004.0
margin_top = 5.0
margin_right = 1034.0
margin_bottom = 35.0
hint_tooltip = "Debug: Display word break points"
focus_mode = 0
disabled = true
toggle_mode = true
icon = ExtResource( 16 )

[node name="DebugDdr" type="Button" parent="FormatToolbar"]
margin_left = 966.0
margin_top = 5.0
margin_right = 996.0
margin_bottom = 35.0
hint_tooltip = "Debug: Display string info"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 17 )

[node name="DebugJBrk2" type="Button" parent="FormatToolbar"]
margin_left = 920.0
margin_top = 5.0
margin_right = 950.0
margin_bottom = 35.0
hint_tooltip = "Debug: Cluster preview"
focus_mode = 0
toggle_mode = true
icon = ExtResource( 18 )

[node name="New" type="Button" parent="FormatToolbar"]
margin_left = 5.0
margin_top = 5.0
margin_right = 35.0
margin_bottom = 35.0
hint_tooltip = "New"
focus_mode = 0
enabled_focus_mode = 0
icon = ExtResource( 19 )

[node name="Load" type="Button" parent="FormatToolbar"]
margin_left = 35.0
margin_top = 5.0
margin_right = 65.0
margin_bottom = 35.0
hint_tooltip = "Load..."
focus_mode = 0
enabled_focus_mode = 0
icon = ExtResource( 20 )

[node name="Save" type="Button" parent="FormatToolbar"]
margin_left = 65.0
margin_top = 5.0
margin_right = 95.0
margin_bottom = 35.0
hint_tooltip = "Save as..."
focus_mode = 0
icon = ExtResource( 21 )

[node name="DecW" type="Button" parent="FormatToolbar"]
margin_left = 35.0
margin_top = 75.0
margin_right = 65.0
margin_bottom = 105.0
hint_tooltip = "Increase indent"
focus_mode = 0
icon = ExtResource( 22 )

[node name="IncW" type="Button" parent="FormatToolbar"]
margin_left = 5.0
margin_top = 75.0
margin_right = 35.0
margin_bottom = 105.0
hint_tooltip = "Decrease indent"
focus_mode = 0
icon = ExtResource( 23 )

[node name="InsertImage" type="OptionButton" parent="FormatToolbar"]
margin_left = 264.0
margin_top = 5.0
margin_right = 462.0
margin_bottom = 35.0
hint_tooltip = "Image"
focus_mode = 0
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect3" type="TextureRect" parent="FormatToolbar/InsertImage"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 24 )
stretch_mode = 4

[node name="LineSpace" type="SpinBox" parent="FormatToolbar"]
margin_left = 205.0
margin_top = 75.0
margin_right = 295.0
margin_bottom = 105.0
hint_tooltip = "Line spacing"
min_value = 0.1
max_value = 5.0
step = 0.1
value = 1.0
align = 2

[node name="TextureRect4" type="TextureRect" parent="FormatToolbar/LineSpace"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 25 )
stretch_mode = 4

[node name="ParaSpace" type="SpinBox" parent="FormatToolbar"]
margin_left = 160.0
margin_top = 5.0
margin_right = 250.0
margin_bottom = 35.0
hint_tooltip = "Paragraph spacing"
value = 2.0
align = 2

[node name="TextureRect4" type="TextureRect" parent="FormatToolbar/ParaSpace"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 25 )
stretch_mode = 4

[node name="Dir" type="OptionButton" parent="FormatToolbar"]
margin_left = 75.0
margin_top = 75.0
margin_right = 195.0
margin_bottom = 105.0
hint_tooltip = "Paragraph base direction"
focus_mode = 0
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect3" type="TextureRect" parent="FormatToolbar/Dir"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 26 )
stretch_mode = 4

[node name="BrkMode" type="OptionButton" parent="FormatToolbar"]
margin_left = 305.0
margin_top = 75.0
margin_right = 485.0
margin_bottom = 105.0
hint_tooltip = "Paragraph line break mode"
focus_mode = 0
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect4" type="TextureRect" parent="FormatToolbar/BrkMode"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 27 )
stretch_mode = 4

[node name="JstMode" type="OptionButton" parent="FormatToolbar"]
margin_left = 625.0
margin_top = 75.0
margin_right = 805.0
margin_bottom = 105.0
hint_tooltip = "Paragraph justification mode"
focus_mode = 0
custom_colors/font_color = Color( 0, 0, 0, 1 )
custom_colors/font_color_hover = Color( 0, 0, 0, 1 )
custom_colors/font_color_pressed = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect5" type="TextureRect" parent="FormatToolbar/JstMode"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 11 )
stretch_mode = 4

[node name="ValT" type="Button" parent="FormatToolbar"]
margin_left = 472.0
margin_top = 5.0
margin_right = 502.0
margin_bottom = 35.0
hint_tooltip = "Align top"
focus_mode = 0
toggle_mode = true
group = SubResource( 13 )
icon = ExtResource( 28 )

[node name="ValC" type="Button" parent="FormatToolbar"]
margin_left = 502.0
margin_top = 5.0
margin_right = 532.0
margin_bottom = 35.0
hint_tooltip = "Align baseline"
focus_mode = 0
toggle_mode = true
pressed = true
group = SubResource( 13 )
icon = ExtResource( 29 )

[node name="ValB" type="Button" parent="FormatToolbar"]
margin_left = 532.0
margin_top = 5.0
margin_right = 562.0
margin_bottom = 35.0
hint_tooltip = "Align bottom"
focus_mode = 0
toggle_mode = true
group = SubResource( 13 )
icon = ExtResource( 30 )

[node name="FontFtr" type="LineEdit" parent="FormatToolbar"]
margin_left = 344.0
margin_top = 40.0
margin_right = 524.0
margin_bottom = 70.0
hint_tooltip = "Font OpenType features"
focus_mode = 1
custom_colors/font_color = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect" type="TextureRect" parent="FormatToolbar/FontFtr"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 31 )
stretch_mode = 4

[node name="Width" type="SpinBox" parent="FormatToolbar"]
margin_left = 865.0
margin_top = 75.0
margin_right = 1005.0
margin_bottom = 105.0
hint_tooltip = "Paragraph width"
min_value = -1.0
max_value = 1000.0
value = -1.0
align = 2

[node name="TextureRect" type="TextureRect" parent="FormatToolbar/Width"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 32 )
stretch_mode = 4

[node name="Lang" type="LineEdit" parent="FormatToolbar"]
margin_left = 534.0
margin_top = 40.0
margin_right = 654.0
margin_bottom = 70.0
hint_tooltip = "Language"
focus_mode = 1
custom_colors/font_color = Color( 0, 0, 0, 1 )
align = 1

[node name="TextureRect" type="TextureRect" parent="FormatToolbar/Lang"]
margin_right = 30.0
margin_bottom = 30.0
texture = ExtResource( 33 )
stretch_mode = 4

[node name="TextCol" type="TextureRect" parent="FormatToolbar"]
margin_left = 575.0
margin_top = 5.0
margin_right = 605.0
margin_bottom = 35.0
hint_tooltip = "Text color"
texture = ExtResource( 34 )
stretch_mode = 4

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/TextCol"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Text color"
focus_mode = 0

[node name="HlColor" type="TextureRect" parent="FormatToolbar"]
margin_left = 625.0
margin_top = 5.0
margin_right = 655.0
margin_bottom = 35.0
hint_tooltip = "Highlight color"
texture = ExtResource( 35 )
stretch_mode = 4

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/HlColor"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Highlight color"
focus_mode = 0
color = Color( 0.784314, 0.784314, 0.0784314, 1 )

[node name="OutColor" type="TextureRect" parent="FormatToolbar"]
margin_left = 675.0
margin_top = 5.0
margin_right = 705.0
margin_bottom = 35.0
hint_tooltip = "Outline color"
texture = ExtResource( 36 )
stretch_mode = 4

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/OutColor"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Outline color"
color = Color( 1, 1, 1, 0 )

[node name="BackColor" type="TextureRect" parent="FormatToolbar"]
margin_left = 810.0
margin_top = 75.0
margin_right = 840.0
margin_bottom = 105.0
hint_tooltip = "Paragraph background color"
texture = ExtResource( 37 )
stretch_mode = 4

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/BackColor"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Paragraph background color"
focus_mode = 0
color = Color( 1, 1, 1, 1 )

[node name="Panel3" type="ColorRect" parent="FormatToolbar"]
margin_left = 100.0
margin_top = 10.0
margin_right = 103.0
margin_bottom = 30.0
color = Color( 0.54902, 0.54902, 0.54902, 1 )

[node name="Panel4" type="ColorRect" parent="FormatToolbar"]
margin_left = 255.0
margin_top = 10.0
margin_right = 258.0
margin_bottom = 30.0
color = Color( 0.54902, 0.54902, 0.54902, 1 )

[node name="Panel5" type="ColorRect" parent="FormatToolbar"]
margin_left = 568.0
margin_top = 10.0
margin_right = 571.0
margin_bottom = 30.0
color = Color( 0.54902, 0.54902, 0.54902, 1 )

[node name="BackColor2" type="TextureRect" parent="FormatToolbar"]
margin_left = 105.0
margin_top = 5.0
margin_right = 135.0
margin_bottom = 35.0
hint_tooltip = "Document background color"
texture = ExtResource( 38 )
stretch_mode = 4

[node name="ColorPickerButton" type="ColorPickerButton" parent="FormatToolbar/BackColor2"]
margin_left = 30.0
margin_right = 50.0
margin_bottom = 30.0
hint_tooltip = "Document background color"
focus_mode = 0
color = Color( 1, 1, 1, 0.5 )

[node name="W" type="ScrollContainer" parent="FormatToolbar"]
visible = false
margin_left = 1082.0
margin_right = 1570.0
margin_bottom = 394.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Panel" type="ColorRect" parent="FormatToolbar/W"]
margin_right = 5000.0
margin_bottom = 380.0
rect_min_size = Vector2( 5000, 380 )
color = Color( 0, 0, 0, 1 )
script = ExtResource( 39 )

[node name="HSlider" type="HSlider" parent="FormatToolbar/W/Panel"]
margin_left = 5.0
margin_top = 5.0
margin_right = 205.0
margin_bottom = 21.0
hint_tooltip = "Preview scale"
min_value = 1.0
max_value = 10.0
step = 0.5
value = 3.0

[node name="Button" type="Button" parent="FormatToolbar/W/Panel"]
margin_left = 462.0
margin_top = 4.0
margin_right = 481.0
margin_bottom = 20.0
text = "x"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="StatBar" type="ColorRect" parent="."]
margin_top = 780.0
margin_right = 1200.0
margin_bottom = 800.0
color = Color( 0.423529, 0.423529, 0.423529, 1 )

[node name="P" type="Label" parent="StatBar"]
margin_right = 155.0
margin_bottom = 20.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "-"
align = 1
valign = 1

[node name="Panel1" type="ColorRect" parent="StatBar"]
margin_left = 157.0
margin_right = 160.0
margin_bottom = 20.0
color = Color( 0.54902, 0.54902, 0.54902, 1 )

[node name="W" type="Label" parent="StatBar"]
margin_left = 160.0
margin_right = 415.0
margin_bottom = 20.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "-"
align = 1
valign = 1

[node name="X" type="Label" parent="StatBar"]
margin_left = 425.0
margin_right = 1455.0
margin_bottom = 20.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "-"
valign = 1

[node name="Panel2" type="ColorRect" parent="StatBar"]
margin_left = 415.0
margin_right = 418.0
margin_bottom = 20.0
color = Color( 0.54902, 0.54902, 0.54902, 1 )

[node name="FileDialogSave" type="FileDialog" parent="."]
margin_left = 157.0
margin_top = 190.0
margin_right = 1035.0
margin_bottom = 700.0
access = 2
filters = PoolStringArray( "*.gdrtf;Rich Text" )
current_dir = "/Volumes/Seagate/SDK/godot_sdk/native_modules/godot_tl/demos/input_builtin"
current_path = "/Volumes/Seagate/SDK/godot_sdk/native_modules/godot_tl/demos/input_builtin/"

[node name="FileDialogLoad" type="FileDialog" parent="."]
margin_left = 157.0
margin_top = 190.0
margin_right = 1035.0
margin_bottom = 700.0
window_title = "Open a File"
mode = 0
access = 2
filters = PoolStringArray( "*.gdrtf;Rich Text" )
current_dir = "/Volumes/Seagate/SDK/godot_sdk/native_modules/godot_tl/demos/input_builtin"
current_path = "/Volumes/Seagate/SDK/godot_sdk/native_modules/godot_tl/demos/input_builtin/"

[node name="HScrollBar" type="HScrollBar" parent="."]
margin_left = 5.0
margin_top = 675.0
margin_right = 1150.0
margin_bottom = 687.0
step = 1.0

[node name="VScrollBar" type="VScrollBar" parent="."]
margin_left = 1168.0
margin_top = 305.0
margin_right = 1180.0
margin_bottom = 767.0
step = 1.0

[node name="ScrollContainer" type="ScrollContainer" parent="."]
visible = false
margin_left = 15.0
margin_top = 550.0
margin_right = 1280.0
margin_bottom = 765.0

[node name="PanelDbgD" type="ColorRect" parent="ScrollContainer"]
margin_right = 5000.0
margin_bottom = 200.0
rect_min_size = Vector2( 5000, 200 )
rect_clip_content = true
color = Color( 0.752941, 0.752941, 0.752941, 1 )
script = ExtResource( 40 )

[node name="Label" type="Label" parent="ScrollContainer/PanelDbgD"]
margin_left = 5.0
margin_top = 30.0
margin_right = 53.0
margin_bottom = 44.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Glyphs:"

[node name="Label3" type="Label" parent="ScrollContainer/PanelDbgD"]
margin_left = 5.0
margin_top = 67.0
margin_right = 63.0
margin_bottom = 81.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Pos (S/E):"

[node name="Label5" type="Label" parent="ScrollContainer/PanelDbgD"]
margin_left = 5.0
margin_top = 95.0
margin_right = 53.0
margin_bottom = 109.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Gl. Idx:"

[node name="Label4" type="Label" parent="ScrollContainer/PanelDbgD"]
margin_left = 5.0
margin_top = 155.0
margin_right = 53.0
margin_bottom = 169.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Pos:"

[node name="Label2" type="Label" parent="ScrollContainer/PanelDbgD"]
margin_left = 5.0
margin_top = 129.0
margin_right = 52.0
margin_bottom = 143.0
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Source:"

[node name="Panel" type="Panel" parent="ScrollContainer/PanelDbgD"]
margin_top = 119.0
margin_right = 10000.0
margin_bottom = 121.0
[connection signal="gui_input" from="TLRichTextEdit" to="." method="_on_TLRichTextEdit_gui_input"]
[connection signal="item_selected" from="FormatToolbar/FontFamily" to="." method="_on_FontFamily_item_selected"]
[connection signal="item_selected" from="FormatToolbar/FontSize" to="." method="_on_FontSize_item_selected"]
[connection signal="toggled" from="FormatToolbar/StyleBold" to="." method="_on_Style_toggled"]
[connection signal="toggled" from="FormatToolbar/StyleItalic" to="." method="_on_Style_toggled"]
[connection signal="toggled" from="FormatToolbar/StyleUnderline" to="." method="_on_StyleUnderline_toggled"]
[connection signal="color_changed" from="FormatToolbar/StyleUnderline/ColorPickerButton" to="." method="_on_StyleUnderlineColorPickerButton_color_changed"]
[connection signal="value_changed" from="FormatToolbar/StyleUnderline/SpinBox" to="." method="_on_SpinBoxUnder_value_changed"]
[connection signal="toggled" from="FormatToolbar/StyleOver" to="." method="_on_StyleOver_toggled"]
[connection signal="color_changed" from="FormatToolbar/StyleOver/ColorPickerButton" to="." method="_on_StyleOverColorPickerButton_color_changed"]
[connection signal="value_changed" from="FormatToolbar/StyleOver/SpinBox" to="." method="_on_SpinBoxOver_value_changed"]
[connection signal="toggled" from="FormatToolbar/StyleStrike" to="." method="_on_StyleStrike_toggled"]
[connection signal="color_changed" from="FormatToolbar/StyleStrike/ColorPickerButton" to="." method="_on_StyleStrikeColorPickerButton_color_changed"]
[connection signal="value_changed" from="FormatToolbar/StyleStrike/SpinBox" to="." method="_on_SpinBoxStrike_value_changed"]
[connection signal="toggled" from="FormatToolbar/HalL" to="." method="_on_HalL_toggled"]
[connection signal="toggled" from="FormatToolbar/HalC" to="." method="_on_HalC_toggled"]
[connection signal="toggled" from="FormatToolbar/HalR" to="." method="_on_HalR_toggled"]
[connection signal="toggled" from="FormatToolbar/HalJ" to="." method="_on_HalJ_toggled"]
[connection signal="pressed" from="FormatToolbar/ClearFMT" to="." method="_on_ClearFMT_pressed"]
[connection signal="pressed" from="FormatToolbar/ClearFMT2" to="." method="_on_ClearFMT2_pressed"]
[connection signal="toggled" from="FormatToolbar/DebugRect" to="." method="_on_DEbug_toggled"]
[connection signal="toggled" from="FormatToolbar/DebugLBrk" to="." method="_on_DebugLBrk_toggled"]
[connection signal="toggled" from="FormatToolbar/DebugJBrk" to="." method="_on_DebugJBrk_toggled"]
[connection signal="toggled" from="FormatToolbar/DebugDdr" to="." method="_on_DebugDdr_toggled"]
[connection signal="toggled" from="FormatToolbar/DebugJBrk2" to="." method="_on_DebugJBrk2_toggled"]
[connection signal="pressed" from="FormatToolbar/New" to="." method="_on_New_pressed"]
[connection signal="pressed" from="FormatToolbar/Load" to="." method="_on_Load_pressed"]
[connection signal="pressed" from="FormatToolbar/Save" to="." method="_on_Save_pressed"]
[connection signal="pressed" from="FormatToolbar/DecW" to="." method="_on_DecW_pressed"]
[connection signal="pressed" from="FormatToolbar/IncW" to="." method="_on_IncW_pressed"]
[connection signal="item_selected" from="FormatToolbar/InsertImage" to="." method="_on_InsertImage_item_selected"]
[connection signal="value_changed" from="FormatToolbar/LineSpace" to="." method="_on_LineSpace_value_changed"]
[connection signal="value_changed" from="FormatToolbar/ParaSpace" to="." method="_on_ParaSpace_value_changed"]
[connection signal="item_selected" from="FormatToolbar/Dir" to="." method="_on_Dir_item_selected"]
[connection signal="item_selected" from="FormatToolbar/BrkMode" to="." method="_on_BrkMode_item_selected"]
[connection signal="item_selected" from="FormatToolbar/JstMode" to="." method="_on_JstMode_item_selected"]
[connection signal="toggled" from="FormatToolbar/ValT" to="." method="_on_ValT_toggled"]
[connection signal="toggled" from="FormatToolbar/ValC" to="." method="_on_ValC_toggled"]
[connection signal="toggled" from="FormatToolbar/ValB" to="." method="_on_ValB_toggled"]
[connection signal="text_entered" from="FormatToolbar/FontFtr" to="." method="_on_FontFtr_text_entered"]
[connection signal="value_changed" from="FormatToolbar/Width" to="." method="_on_Width_value_changed"]
[connection signal="text_entered" from="FormatToolbar/Lang" to="." method="_on_Lang_text_entered"]
[connection signal="color_changed" from="FormatToolbar/TextCol/ColorPickerButton" to="." method="_on_TextColorPickerButton_color_changed"]
[connection signal="color_changed" from="FormatToolbar/HlColor/ColorPickerButton" to="." method="_on_HlColorPickerButton_color_changed"]
[connection signal="color_changed" from="FormatToolbar/OutColor/ColorPickerButton" to="." method="_on_ColorPickerButton_color_changed"]
[connection signal="color_changed" from="FormatToolbar/BackColor/ColorPickerButton" to="." method="_on_BackColorPickerButton_color_changed"]
[connection signal="color_changed" from="FormatToolbar/BackColor2/ColorPickerButton" to="." method="_on_Color2PickerButton_color_changed"]
[connection signal="value_changed" from="FormatToolbar/W/Panel/HSlider" to="FormatToolbar/W/Panel" method="_on_HSlider_value_changed"]
[connection signal="pressed" from="FormatToolbar/W/Panel/Button" to="." method="_on_Button_pressed"]
[connection signal="file_selected" from="FileDialogSave" to="." method="_on_FileDialogSave_file_selected"]
[connection signal="file_selected" from="FileDialogLoad" to="." method="_on_FileDialogLoad_file_selected"]
[connection signal="value_changed" from="HScrollBar" to="." method="_on_HScrollBar_value_changed"]
[connection signal="value_changed" from="VScrollBar" to="." method="_on_VScrollBar_value_changed"]
