// File: /workspace/github_c_makefile_star2_O3/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 0x6a70
movq %rax, %rbx
testq %rax, %rax
jne 0xe9da
leaq 0x379a(%rip), %rdi      # 0x1216a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70a6
movsd 0x8(%rsp), %xmm0
ucomisd 0x32b0(%rip), %xmm0     # 0x11c98
jbe 0xea2c
leaq 0x378d(%rip), %r15      # 0x1217e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
leaq 0x3780(%rip), %rsi      # 0x12183
movq %rbx, %rdi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x6180
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10fb6(%rip)    # 0x1f9e0
jmp 0xeaa1
leaq 0x374b(%rip), %rsi      # 0x1217e
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x61c0
testl %eax, %eax
je 0xea81
leaq 0x3736(%rip), %rsi      # 0x12183
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x61c0
testl %eax, %eax
je 0xea89
leaq 0x3717(%rip), %rsi      # 0x1217e
movsd 0x3231(%rip), %xmm0     # 0x11ca0
movq %rbx, %rdi
callq 0x6180
movsd 0x3221(%rip), %xmm0     # 0x11ca0
jmp 0xea91
movsd 0x10(%rsp), %xmm0
jmp 0xea91
movsd 0x31df(%rip), %xmm0     # 0x11c70
movsd %xmm0, 0x10f47(%rip)    # 0x1f9e0
movsd %xmm0, 0x10f1f(%rip)    # 0x1f9c0
leaq 0x10c20(%rip), %rdi     # 0x1f6c8
movq %rbx, %rsi
callq 0xf0b0
testl %eax, %eax
je 0xeac5
leaq 0x36af(%rip), %rdi      # 0x1216a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70a6
xorpd %xmm0, %xmm0
ucomisd 0x10f0f(%rip), %xmm0    # 0x1f9e0
jbe 0xeb17
movq 0x10c1e(%rip), %rdi     # 0x1f6f8
leaq 0x369d(%rip), %rsi      # 0x1217e
leaq 0x10(%rsp), %r15
xorl %edx, %edx
movq %r15, %rcx
callq 0x61c0
movsd (%r15), %xmm0
movsd %xmm0, 0x10ee3(%rip)    # 0x1f9e0
movsd 0x8(%rsp), %xmm1
ucomisd 0x3185(%rip), %xmm1     # 0x11c90
jne 0xeb17
jp 0xeb17
movsd %xmm0, 0x10ea9(%rip)    # 0x1f9c0
xorps %xmm0, %xmm0
cvtsi2ssl 0x10baa(%rip), %xmm0 # 0x1f6cc
mulss 0xa2d6(%rip), %xmm0     # 0x18e00
callq 0x6860
cvttss2si %xmm0, %eax
xorps %xmm1, %xmm1
cvtsi2ssl 0x10b8a(%rip), %xmm1 # 0x1f6c8
movss %xmm1, 0x8(%rsp)
movl %eax, 0x10de2(%rip)     # 0x1f92c
movss 0xa2b2(%rip), %xmm0     # 0x18e04
movss %xmm0, 0x1c(%rsp)
mulss %xmm1, %xmm0
callq 0x6860
cvttss2si %xmm0, %eax
movss 0x1c(%rsp), %xmm0
addss 0x31ad(%rip), %xmm0     # 0x11d20
movl %eax, 0x10daf(%rip)     # 0x1f928
mulss 0x8(%rsp), %xmm0
mulss 0x319d(%rip), %xmm0     # 0x11d24
callq 0x6860
cvttss2si %xmm0, %eax
movl %eax, 0x10d9a(%rip)     # 0x1f930
leaq 0x35eb(%rip), %r15      # 0x12188
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movl $0x64, %edx
callq 0x6970
leaq 0x10b99(%rip), %rdi     # 0x1f758
movq %rbx, %rsi
callq 0xf0b0
testl %eax, %eax
je 0xebdc
leaq 0x3598(%rip), %rdi      # 0x1216a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70a6
leaq 0x35ab(%rip), %r15      # 0x1218e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movl $0xc8, %edx
callq 0x6970
leaq 0x10b9b(%rip), %rdi     # 0x1f7a0
movq %rbx, %rsi
callq 0xf0b0
testl %eax, %eax
je 0xec22
leaq 0x3552(%rip), %rdi      # 0x1216a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70a6
leaq 0x355f(%rip), %rsi      # 0x12188
movq %rbx, %rdi
callq 0x6150
leaq 0x10ad8(%rip), %rdi     # 0x1f710
movq %rbx, %rsi
callq 0xf0b0
testl %eax, %eax
je 0xec55
leaq 0x351f(%rip), %rdi      # 0x1216a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70a6
movq %rbx, %rdi
callq 0x6050
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq