// File: /workspace/github_c_makefile_star2_O2/odknt[P]st/x.c
// Function: xloadfonts
void
xloadfonts(const char *fontstr, double fontsize)
{
	FcPattern *pattern;
	double fontval;

	if (!(pattern = FcNameParse((const FcChar8 *)fontstr)))
		die("can't open font %s\n", fontstr);

	if (fontsize > 1) {
		FcPatternDel(pattern, FC_PIXEL_SIZE);
		FcPatternDel(pattern, FC_SIZE);
		FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
		usedfontsize = fontsize;
	} else {
		if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
				FcResultMatch) {
			usedfontsize = fontval;
		} else if (FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) ==
				FcResultMatch) {
			usedfontsize = -1;
		} else {
			/*
			 * Default font size is 12, if none given. This is to
			 * have a known usedfontsize value.
			 */
			FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
			usedfontsize = 12;
		}
		defaultfontsize = usedfontsize;
	}

	if (xloadfont(&dc.font, pattern))
		die("can't open font %s\n", fontstr);

	if (usedfontsize < 0) {
		FcPatternGetDouble(dc.font.match.pattern,
		                   FC_PIXEL_SIZE, 0, &fontval);
		usedfontsize = fontval;
		if (fontsize == 0)
			defaultfontsize = fontval;
	}

	/* Setting character width and height. */
	win.cw = ceilf(dc.font.width * cwscale);
	win.ch = ceilf(dc.font.height * chscale);
	win.cyo = ceilf(dc.font.height * (chscale - 1) / 2);

	FcPatternDel(pattern, FC_SLANT);
	FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
	if (xloadfont(&dc.ifont, pattern))
		die("can't open font %s\n", fontstr);

	FcPatternDel(pattern, FC_WEIGHT);
	FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
	if (xloadfont(&dc.ibfont, pattern))
		die("can't open font %s\n", fontstr);

	FcPatternDel(pattern, FC_SLANT);
	if (xloadfont(&dc.bfont, pattern))
		die("can't open font %s\n", fontstr);

	FcPatternDestroy(pattern);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdi, %r14
callq 0x6a80
movq %rax, %rbx
testq %rax, %rax
jne 0xd8a6
leaq 0x389e(%rip), %rdi      # 0x1113a
movq %r14, %rsi
xorl %eax, %eax
callq 0x6bf6
movsd 0x8(%rsp), %xmm0
ucomisd 0x33b4(%rip), %xmm0     # 0x10c68
jbe 0xd8f8
leaq 0x3891(%rip), %r15      # 0x1114e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
leaq 0x3884(%rip), %rsi      # 0x11153
movq %rbx, %rdi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x6180
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x110fa(%rip)    # 0x1e9f0
jmp 0xd96d
leaq 0x384f(%rip), %rsi      # 0x1114e
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x61c0
testl %eax, %eax
je 0xd94d
leaq 0x383a(%rip), %rsi      # 0x11153
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x61c0
testl %eax, %eax
je 0xd955
leaq 0x381b(%rip), %rsi      # 0x1114e
movsd 0x3335(%rip), %xmm0     # 0x10c70
movq %rbx, %rdi
callq 0x6180
movsd 0x3325(%rip), %xmm0     # 0x10c70
jmp 0xd95d
movsd 0x10(%rsp), %xmm0
jmp 0xd95d
movsd 0x32e3(%rip), %xmm0     # 0x10c40
movsd %xmm0, 0x1108b(%rip)    # 0x1e9f0
movsd %xmm0, 0x11063(%rip)    # 0x1e9d0
leaq 0x10d64(%rip), %rdi     # 0x1e6d8
movq %rbx, %rsi
callq 0xdfbe
testl %eax, %eax
je 0xd991
leaq 0x37b3(%rip), %rdi      # 0x1113a
movq %r14, %rsi
xorl %eax, %eax
callq 0x6bf6
xorpd %xmm0, %xmm0
ucomisd 0x11053(%rip), %xmm0    # 0x1e9f0
jbe 0xd9e3
movq 0x10d62(%rip), %rdi     # 0x1e708
leaq 0x37a1(%rip), %rsi      # 0x1114e
leaq 0x10(%rsp), %r15
xorl %edx, %edx
movq %r15, %rcx
callq 0x61c0
movsd (%r15), %xmm0
movsd %xmm0, 0x11027(%rip)    # 0x1e9f0
movsd 0x8(%rsp), %xmm1
ucomisd 0x3289(%rip), %xmm1     # 0x10c60
jne 0xd9e3
jp 0xd9e3
movsd %xmm0, 0x10fed(%rip)    # 0x1e9d0
cvtsi2ssl 0x10cf1(%rip), %xmm0 # 0x1e6dc
mulss 0xa41d(%rip), %xmm0     # 0x17e10
callq 0x6870
cvttss2si %xmm0, %eax
cvtsi2ssl 0x10cd4(%rip), %xmm1 # 0x1e6d8
movss %xmm1, 0x8(%rsp)
movl %eax, 0x10f2c(%rip)     # 0x1e93c
movss 0xa3fc(%rip), %xmm0     # 0x17e14
movss %xmm0, 0x1c(%rsp)
mulss %xmm1, %xmm0
callq 0x6870
cvttss2si %xmm0, %eax
movss 0x1c(%rsp), %xmm0
addss 0x32b7(%rip), %xmm0     # 0x10cf0
movl %eax, 0x10ef9(%rip)     # 0x1e938
mulss 0x8(%rsp), %xmm0
mulss 0x32a7(%rip), %xmm0     # 0x10cf4
callq 0x6870
cvttss2si %xmm0, %eax
movl %eax, 0x10ee4(%rip)     # 0x1e940
leaq 0x36f5(%rip), %r15      # 0x11158
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
pushq $0x64
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6980
leaq 0x10ce5(%rip), %rdi     # 0x1e768
movq %rbx, %rsi
callq 0xdfbe
testl %eax, %eax
je 0xdaa0
leaq 0x36a4(%rip), %rdi      # 0x1113a
movq %r14, %rsi
xorl %eax, %eax
callq 0x6bf6
leaq 0x36b7(%rip), %r15      # 0x1115e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movl $0xc8, %edx
callq 0x6980
leaq 0x10ce7(%rip), %rdi     # 0x1e7b0
movq %rbx, %rsi
callq 0xdfbe
testl %eax, %eax
je 0xdae6
leaq 0x365e(%rip), %rdi      # 0x1113a
movq %r14, %rsi
xorl %eax, %eax
callq 0x6bf6
leaq 0x366b(%rip), %rsi      # 0x11158
movq %rbx, %rdi
callq 0x6150
leaq 0x10c24(%rip), %rdi     # 0x1e720
movq %rbx, %rsi
callq 0xdfbe
testl %eax, %eax
je 0xdb19
leaq 0x362b(%rip), %rdi      # 0x1113a
movq %r14, %rsi
xorl %eax, %eax
callq 0x6bf6
movq %rbx, %rdi
callq 0x6050
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq