#!/bin/bash



testfont() {
    font=$1
    property=$2
    expected_file=$3

    actual=`fc-match "${font}" "${property}"`
    expected=":${property}=$(echo ${expected_file} | sed 's/_/\\_/')"
    #echo $actual
    #echo $expected
    test "${expected}" = "${actual}" || \
        echo "Test failed: For '${font}' ${property}, '${expected}' is expected, but actual: '${actual}'" >&2
}

# check file

testfont "D2Coding ligature"            file "/usr/share/fonts/truetype/nanum/D2Coding-Ver1.3.2-20180524-ligature.ttf"
testfont "D2Coding ligature:bold"       file "/usr/share/fonts/truetype/nanum/D2CodingBold-Ver1.3.2-20180524-ligature.ttf"
testfont "NanumBarunGothic YetHangul"   file "/usr/share/fonts/truetype/nanum/NanumBarunGothic-YetHangul.ttf"
testfont "NanumBarunGothic"             file "/usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf"
testfont "NanumBarunGothic:bold"        file "/usr/share/fonts/truetype/nanum/NanumBarunGothicBold.ttf"
testfont "NanumBarunGothic:light"       file "/usr/share/fonts/truetype/nanum/NanumBarunGothicLight.ttf"
testfont "NanumBarunGothic:ultralight"  file "/usr/share/fonts/truetype/nanum/NanumBarunGothicUltraLight.ttf"
testfont "NanumBarunpen:bold"           file "/usr/share/fonts/truetype/nanum/NanumBarunpenB.ttf"
testfont "NanumBarunpen"                file "/usr/share/fonts/truetype/nanum/NanumBarunpenR.ttf"
testfont "Nanum Brush Script"           file "/usr/share/fonts/truetype/nanum/NanumBrush.ttf"
testfont "NanumGothic"                  file "/usr/share/fonts/truetype/nanum/NanumGothic.ttf"
testfont "NanumGothic:bold"             file "/usr/share/fonts/truetype/nanum/NanumGothicBold.ttf"
testfont "NanumGothic:extrabold"        file "/usr/share/fonts/truetype/nanum/NanumGothicExtraBold.ttf"
testfont "NanumGothic:light"            file "/usr/share/fonts/truetype/nanum/NanumGothicLight.ttf"
testfont "NanumGothic Eco"              file "/usr/share/fonts/truetype/nanum/NanumGothicEco.ttf"
testfont "NanumGothic Eco:bold"         file "/usr/share/fonts/truetype/nanum/NanumGothicEcoBold.ttf"
testfont "NanumGothic Eco:extrabold"    file "/usr/share/fonts/truetype/nanum/NanumGothicEcoExtraBold.ttf"
testfont "NanumMyeongjo YetHangul"      file "/usr/share/fonts/truetype/nanum/NanumMyeongjo-YetHangul.ttf"
testfont "NanumMyeongjo"                file "/usr/share/fonts/truetype/nanum/NanumMyeongjo.ttf"
testfont "NanumMyeongjo:bold"           file "/usr/share/fonts/truetype/nanum/NanumMyeongjoBold.ttf"
testfont "NanumMyeongjo:extrabold"      file "/usr/share/fonts/truetype/nanum/NanumMyeongjoExtraBold.ttf"
testfont "NanumMyeongjo Eco"            file "/usr/share/fonts/truetype/nanum/NanumMyeongjoEco.ttf"
testfont "NanumMyeongjo Eco:bold"       file "/usr/share/fonts/truetype/nanum/NanumMyeongjoEcoBold.ttf"
testfont "NanumMyeongjo Eco:extrabold"  file "/usr/share/fonts/truetype/nanum/NanumMyeongjoEcoExtraBold.ttf"
testfont "Nanum Pen Script"             file "/usr/share/fonts/truetype/nanum/NanumPen.ttf"
testfont "NanumSquare"                  file "/usr/share/fonts/truetype/nanum/NanumSquareR.ttf"
testfont "NanumSquare:bold"             file "/usr/share/fonts/truetype/nanum/NanumSquareB.ttf"
testfont "NanumSquare:extrabold"        file "/usr/share/fonts/truetype/nanum/NanumSquareEB.ttf"
testfont "NanumSquare:light"            file "/usr/share/fonts/truetype/nanum/NanumSquareL.ttf"
testfont "NanumSquare Neo variable"     file "/usr/share/fonts/truetype/nanum/NanumSquareNeo-Variable.ttf"
testfont "NanumSquare Neo:light"        file "/usr/share/fonts/truetype/nanum/NanumSquareNeo-aLt.ttf"
testfont "NanumSquare Neo:regular"      file "/usr/share/fonts/truetype/nanum/NanumSquareNeo-bRg.ttf"
testfont "NanumSquare Neo:bold"         file "/usr/share/fonts/truetype/nanum/NanumSquareNeo-cBd.ttf"
testfont "NanumSquare Neo:extrabold"    file "/usr/share/fonts/truetype/nanum/NanumSquareNeo-dEb.ttf"
testfont "NanumSquare Neo:heavy"        file "/usr/share/fonts/truetype/nanum/NanumSquareNeo-eHv.ttf"
testfont "NanumSquareRound:bold"        file "/usr/share/fonts/truetype/nanum/NanumSquareRoundB.ttf"
testfont "NanumSquareRound:extrabold"   file "/usr/share/fonts/truetype/nanum/NanumSquareRoundEB.ttf"
testfont "NanumSquareRound:light"       file "/usr/share/fonts/truetype/nanum/NanumSquareRoundL.ttf"
testfont "NanumSquareRound:regular"     file "/usr/share/fonts/truetype/nanum/NanumSquareRoundR.ttf"
testfont "NanumSquare_ac:bold"          file "/usr/share/fonts/truetype/nanum/NanumSquare_acB.ttf"
testfont "NanumSquare_ac:extrabold"     file "/usr/share/fonts/truetype/nanum/NanumSquare_acEB.ttf"
testfont "NanumSquare_ac:light"         file "/usr/share/fonts/truetype/nanum/NanumSquare_acL.ttf"
testfont "NanumSquare_ac:regular"       file "/usr/share/fonts/truetype/nanum/NanumSquare_acR.ttf"
testfont "NanumHuman TTF"               file "/usr/share/fonts/truetype/nanum/NanumHumanRegular.ttf"
testfont "NanumHuman TTF:extralight"    file "/usr/share/fonts/truetype/nanum/NanumHumanEL.ttf"
testfont "NanumHuman TTF:extrabold"     file "/usr/share/fonts/truetype/nanum/NanumHumanEB.ttf"
testfont "NanumHuman TTF:heavy"         file "/usr/share/fonts/truetype/nanum/NanumHumanHeavy.ttf"
testfont "NanumHuman TTF:bold"          file "/usr/share/fonts/truetype/nanum/NanumHumanBold.ttf"
testfont "NanumHuman TTF:light"         file "/usr/share/fonts/truetype/nanum/NanumHumanLight.ttf"

# check weight

testfont "NanumSquare Neo:bold"        weight "200"
testfont "NanumMyeongjo:bold"          weight "200"
testfont "NanumMyeongjo:extrabold"     weight "205"
testfont "NanumGothic:bold"            weight "200"
testfont "NanumGothic:extrabold"       weight "205"
testfont "NanumBarunGothic:bold"       weight "200"
testfont "NanumBarunGothic:ultralight" weight "40"
testfont "NanumGothic Eco:bold"        weight "200"
testfont "NanumMyeongjo Eco:bold"      weight "200"
testfont "NanumHuman TTF:bold"         weight "200"

# check style

testfont "D2Coding ligature:bold"      style "Bold"
testfont "NanumGothic:extrabold"       style "ExtraBold"
testfont "NanumMyeongjo:extrabold"     style "ExtraBold"
testfont "NanumSquare:light"           style "Light"
testfont "NanumSquare:bold"            style "Bold"
testfont "NanumSquare:extrabold"       style "ExtraBold"
testfont "NanumSquare Neo:bold"        style "Bold"
testfont "NanumSquare Neo:extrabold"   style "ExtraBold"
testfont "NanumSquare Neo:light"       style "Light"
testfont "NanumSquare Neo:heavy"       style "Heavy"
testfont "NanumHuman TTF:extrabold"    style "ExtraBold"
