// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/graphics/backends/cairo/fontcairo.cpp
// Function: smooth::GUI::FontCairo::GetTextSize(smooth::String const&) const
S::GUI::Size S::GUI::FontCairo::GetTextSize(const String &iText) const
{
	if (iText == NIL) return Size();

	String	 text	    = iText;
	Int	 textLength = text.Length();

	/* Set up Cairo font and calculate text size.
	 */
	Float		 dpi	 = Surface().GetSurfaceDPI();

	cairo_surface_t	*surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
	cairo_t		*context = cairo_create(surface);

	PangoLayout		*layout	= pango_cairo_create_layout(context);
	PangoFontDescription	*desc	= pango_font_description_from_string(String(fontName)
									    .Append(" ")
									    .Append(fontStyle & Font::Italic ? "Italic " : "")
									    .Append(fontWeight >= Font::Bold ? "Bold " : "")
									    .Append(String::FromInt(Math::Round(fontSize * dpi / 96.0))));

	if (textLength > 0) pango_layout_set_text(layout, text.ConvertTo("UTF-8"), -1);

	pango_layout_set_font_description(layout, desc);
	pango_font_description_free(desc);

	int	 x = 0;
	int	 y = 0;

	pango_layout_get_pixel_size(layout, &x, &y);

	g_object_unref(layout);

	cairo_destroy(context);
	cairo_surface_destroy(surface);

	return Size(x, y - 2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movq %rdi, %r12
xorl %ebx, %ebx
movq %rsi, %rdi
xorl %esi, %esi
callq 0x56280
testb %al, %al
jne 0xbd48b
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x58280
movq %rbx, %rdi
callq 0x58370
movl %eax, %ebx
leaq 0x28(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x58340
movl %ebx, 0xc(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x59c60
movl %eax, %r13d
leaq 0x10(%rsp), %rdi
callq 0x58d90
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x581c0
movq %rax, %r14
movq %rax, %rdi
callq 0x592f0
movq %rax, 0x40(%rsp)
movq %rax, %rdi
callq 0x599c0
movq %rax, %r15
leaq 0x10(%r12), %rsi
leaq 0x10(%rsp), %rdi
callq 0x58280
leaq 0x5b1be(%rip), %rsi     # 0x118490
leaq 0x28(%rsp), %rdi
callq 0x58c40
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x573e0
movq %rax, %rbp
movq 0xa4c63(%rip), %rax     # 0x161f58
movzwl (%rax), %eax
testw %ax, 0x3a(%r12)
leaq 0x44623(%rip), %rbx     # 0x101928
leaq 0x46241(%rip), %rsi     # 0x10354d
cmoveq %rbx, %rsi
leaq 0x78(%rsp), %rdi
callq 0x58c40
leaq 0x78(%rsp), %rsi
movq %rbp, %rdi
callq 0x573e0
movq %rax, %rbp
movzwl 0x38(%r12), %eax
movq 0xa4111(%rip), %rcx     # 0x161448
cmpw (%rcx), %ax
leaq 0x46214(%rip), %rsi     # 0x103555
cmovlq %rbx, %rsi
leaq 0x60(%rsp), %rdi
callq 0x58c40
leaq 0x60(%rsp), %rsi
movq %rbp, %rdi
callq 0x573e0
movq %rax, %rbp
movq %r14, %rbx
movswl %r13w, %eax
cvtsi2sd %eax, %xmm0
movswl 0xa(%r12), %eax
cvtsi2sd %eax, %xmm1
mulsd %xmm0, %xmm1
divsd 0x26190(%rip), %xmm1    # 0xe3510
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
leaq 0x265dc(%rip), %rcx     # 0xe3970
addsd (%rcx,%rax,8), %xmm1
cvttsd2si %xmm1, %rsi
leaq 0x48(%rsp), %rdi
callq 0x57e80
leaq 0x48(%rsp), %rsi
movq %rbp, %rdi
callq 0x573e0
movq 0x40(%rsp), %r14
movq %rax, %rdi
callq 0x598d0
movq %rax, %rdi
callq 0x563f0
movq %rax, %r12
leaq 0x48(%rsp), %rdi
callq 0x5a588
leaq 0x60(%rsp), %rdi
callq 0x5a588
leaq 0x78(%rsp), %rdi
callq 0x5a588
leaq 0x28(%rsp), %rdi
callq 0x5a588
leaq 0x10(%rsp), %rdi
callq 0x5a588
cmpl $0x0, 0xc(%rsp)
jle 0xbd428
leaq 0x44db9(%rip), %rsi     # 0x1021c6
leaq 0x90(%rsp), %rdi
callq 0x58b90
pushq $-0x1
popq %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x560c0
movq %r15, %rdi
movq %r12, %rsi
callq 0x571c0
movq %r12, %rdi
callq 0x59960
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x28(%rsp), %rdx
andl $0x0, (%rdx)
movq %r15, %rdi
callq 0x57960
movq %r15, %rdi
callq 0x59790
movq %r14, %rdi
callq 0x59ec0
movq %rbx, %rdi
callq 0x58850
movl 0x10(%rsp), %r14d
movl 0x28(%rsp), %ebx
addl $-0x2, %ebx
leaq 0x90(%rsp), %rdi
callq 0x5a588
shlq $0x20, %rbx
orq %r14, %rbx
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbd4a2
movq %rax, %rbx
jmp 0xbd4e2
jmp 0xbd4a9
movq %rax, %rbx
jmp 0xbd4ec
jmp 0xbd4b0
movq %rax, %rbx
jmp 0xbd4f6
movq %rax, %rbx
jmp 0xbd500
jmp 0xbd50e
jmp 0xbd50e
jmp 0xbd50e
jmp 0xbd50e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x58d90
jmp 0xbd511
jmp 0xbd50e
jmp 0xbd50e
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5a588
leaq 0x60(%rsp), %rdi
callq 0x5a588
leaq 0x78(%rsp), %rdi
callq 0x5a588
leaq 0x28(%rsp), %rdi
callq 0x5a588
leaq 0x10(%rsp), %rdi
callq 0x5a588
jmp 0xbd511
jmp 0xbd50e
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x58260
nop