// File: /workspace/github_c_makefile_star2_O1/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 0x6a90
movq %rax, %rbx
testq %rax, %rax
jne 0xe35f
leaq 0x2df5(%rip), %rdi      # 0x1114a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70c6
movsd 0x8(%rsp), %xmm0
ucomisd 0x290b(%rip), %xmm0     # 0x10c78
jbe 0xe3b1
leaq 0x2de8(%rip), %r15      # 0x1115e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
leaq 0x2ddb(%rip), %rsi      # 0x11163
movq %rbx, %rdi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x6180
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10641(%rip)    # 0x1e9f0
jmp 0xe426
leaq 0x2da6(%rip), %rsi      # 0x1115e
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x61c0
testl %eax, %eax
je 0xe406
leaq 0x2d91(%rip), %rsi      # 0x11163
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x61c0
testl %eax, %eax
je 0xe40e
leaq 0x2d72(%rip), %rsi      # 0x1115e
movsd 0x288c(%rip), %xmm0     # 0x10c80
movq %rbx, %rdi
callq 0x6180
movsd 0x287c(%rip), %xmm0     # 0x10c80
jmp 0xe416
movsd 0x10(%rsp), %xmm0
jmp 0xe416
movsd 0x283a(%rip), %xmm0     # 0x10c50
movsd %xmm0, 0x105d2(%rip)    # 0x1e9f0
movsd %xmm0, 0x105aa(%rip)    # 0x1e9d0
leaq 0x102ab(%rip), %rdi     # 0x1e6d8
movq %rbx, %rsi
callq 0xea50
testl %eax, %eax
je 0xe44a
leaq 0x2d0a(%rip), %rdi      # 0x1114a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70c6
xorpd %xmm0, %xmm0
ucomisd 0x1059a(%rip), %xmm0    # 0x1e9f0
jbe 0xe49c
movq 0x102a9(%rip), %rdi     # 0x1e708
leaq 0x2cf8(%rip), %rsi      # 0x1115e
leaq 0x10(%rsp), %r15
xorl %edx, %edx
movq %r15, %rcx
callq 0x61c0
movsd (%r15), %xmm0
movsd %xmm0, 0x1056e(%rip)    # 0x1e9f0
movsd 0x8(%rsp), %xmm1
ucomisd 0x27e0(%rip), %xmm1     # 0x10c70
jne 0xe49c
jp 0xe49c
movsd %xmm0, 0x10534(%rip)    # 0x1e9d0
xorps %xmm0, %xmm0
cvtsi2ssl 0x10235(%rip), %xmm0 # 0x1e6dc
mulss 0x9961(%rip), %xmm0     # 0x17e10
callq 0x6880
cvttss2si %xmm0, %eax
xorps %xmm1, %xmm1
cvtsi2ssl 0x10215(%rip), %xmm1 # 0x1e6d8
movss %xmm1, 0x8(%rsp)
movl %eax, 0x1046d(%rip)     # 0x1e93c
movss 0x993d(%rip), %xmm0     # 0x17e14
movss %xmm0, 0x1c(%rsp)
mulss %xmm1, %xmm0
callq 0x6880
cvttss2si %xmm0, %eax
movss 0x1c(%rsp), %xmm0
addss 0x2808(%rip), %xmm0     # 0x10d00
movl %eax, 0x1043a(%rip)     # 0x1e938
mulss 0x8(%rsp), %xmm0
mulss 0x27f8(%rip), %xmm0     # 0x10d04
callq 0x6880
cvttss2si %xmm0, %eax
movl %eax, 0x10425(%rip)     # 0x1e940
leaq 0x2c46(%rip), %r15      # 0x11168
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movl $0x64, %edx
callq 0x6990
leaq 0x10224(%rip), %rdi     # 0x1e768
movq %rbx, %rsi
callq 0xea50
testl %eax, %eax
je 0xe561
leaq 0x2bf3(%rip), %rdi      # 0x1114a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70c6
leaq 0x2c06(%rip), %r15      # 0x1116e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6150
movq %rbx, %rdi
movq %r15, %rsi
movl $0xc8, %edx
callq 0x6990
leaq 0x10226(%rip), %rdi     # 0x1e7b0
movq %rbx, %rsi
callq 0xea50
testl %eax, %eax
je 0xe5a7
leaq 0x2bad(%rip), %rdi      # 0x1114a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70c6
leaq 0x2bba(%rip), %rsi      # 0x11168
movq %rbx, %rdi
callq 0x6150
leaq 0x10163(%rip), %rdi     # 0x1e720
movq %rbx, %rsi
callq 0xea50
testl %eax, %eax
je 0xe5da
leaq 0x2b7a(%rip), %rdi      # 0x1114a
movq %r14, %rsi
xorl %eax, %eax
callq 0x70c6
movq %rbx, %rdi
callq 0x6050
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq