#include "fonts.h"
// Global. Fonts

QFont garamond_6pt;
QFont garamond_7pt;
QFont garamond_8pt;
QFont garamond_9pt;
QFont garamond_10pt;
QFont garamond_11pt;
QFont garamond_12pt;
QFont garamond_13pt;
QFont garamond_14pt;
QFont garamond_15pt;
QFont garamond_16pt;

QFont trajan_6pt;
QFont trajan_7pt;
QFont trajan_8pt;
QFont trajan_9pt;
QFont trajan_10pt;
QFont trajan_11pt;
QFont trajan_12pt;

QFont crimson_6pt;
QFont crimson_7pt;
QFont crimson_8pt;
QFont crimson_9pt;
QFont crimson_10pt;
QFont crimson_11pt;
QFont crimson_12pt;
QFont crimson_13pt;
QFont crimson_14pt;
QFont crimson_15pt;
QFont crimson_16pt;

//10   11   13   16   17   19   20
int pixels_in_16_pt = 26;//14;
int pixels_in_15_pt = 24;//14;
int pixels_in_14_pt = 23;//14;
int pixels_in_13_pt = 21;//14;
int pixels_in_12_pt = 20;//14;
int pixels_in_11_pt = 18;//13;
int pixels_in_10_pt = 17;//12;
int pixels_in_9_pt = 16;//11;
int pixels_in_8_pt = 15;//9;
int pixels_in_7_pt = 11;//8;
int pixels_in_6_pt = 10;//7;

void constructFonts() {
    garamond_6pt = QFont("EB Garamond");
    garamond_7pt = QFont("EB Garamond");
    garamond_8pt = QFont("EB Garamond");
    garamond_9pt = QFont("EB Garamond");
    garamond_10pt = QFont("EB Garamond");
    garamond_11pt = QFont("EB Garamond");
    garamond_12pt = QFont("EB Garamond");
    garamond_13pt = QFont("EB Garamond");
    garamond_14pt = QFont("EB Garamond");
    garamond_15pt = QFont("EB Garamond");
    garamond_16pt = QFont("EB Garamond");

//    garamond_6pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_7pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_8pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_9pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_10pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_11pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_12pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_13pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_14pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_15pt.setStyleStrategy(QFont::PreferAntialias);
//    garamond_16pt.setStyleStrategy(QFont::PreferAntialias);

    garamond_6pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_7pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_8pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_9pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_10pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_11pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_12pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_13pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_14pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_15pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);
    garamond_16pt.setLetterSpacing(QFont::AbsoluteSpacing, 1);

    trajan_6pt = QFont("Trpro");
    trajan_7pt = QFont("Trpro");
    trajan_8pt = QFont("Trpro");
    trajan_9pt = QFont("Trpro");
    trajan_10pt = QFont("Trpro");
    trajan_11pt = QFont("Trpro");
    trajan_12pt = QFont("Trpro");

//    trajan_6pt.setStyleStrategy(QFont::PreferAntialias);
//    trajan_7pt.setStyleStrategy(QFont::PreferAntialias);
//    trajan_8pt.setStyleStrategy(QFont::PreferAntialias);
//    trajan_9pt.setStyleStrategy(QFont::PreferAntialias);
//    trajan_10pt.setStyleStrategy(QFont::PreferAntialias);
//    trajan_11pt.setStyleStrategy(QFont::PreferAntialias);
//    trajan_12pt.setStyleStrategy(QFont::PreferAntialias);

    crimson_6pt = QFont("Crimson Text");
    crimson_7pt = QFont("Crimson Text");
    crimson_8pt = QFont("Crimson Text");
    crimson_9pt = QFont("Crimson Text");
    crimson_10pt = QFont("Crimson Text");
    crimson_11pt = QFont("Crimson Text");
    crimson_12pt = QFont("Crimson Text");
    crimson_13pt = QFont("Crimson Text");
    crimson_14pt = QFont("Crimson Text");
    crimson_15pt = QFont("Crimson Text");
    crimson_16pt = QFont("Crimson Text");

//    crimson_6pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_7pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_8pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_9pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_10pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_11pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_12pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_13pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_14pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_15pt.setStyleStrategy(QFont::PreferAntialias);
//    crimson_16pt.setStyleStrategy(QFont::PreferAntialias);
}

void updateFonts(double coefficient) {
    pixels_in_16_pt = round(default_pixels_in_16_pt * coefficient + 0.0001);
    pixels_in_15_pt = round(default_pixels_in_15_pt * coefficient + 0.0001);
    pixels_in_14_pt = round(default_pixels_in_14_pt * coefficient + 0.0001);
    pixels_in_13_pt = round(default_pixels_in_13_pt * coefficient + 0.0001);
    pixels_in_12_pt = round(default_pixels_in_12_pt * coefficient + 0.0001);
    pixels_in_11_pt = round(default_pixels_in_11_pt * coefficient + 0.0001);
    pixels_in_10_pt = round(default_pixels_in_10_pt * coefficient + 0.0001);
    pixels_in_9_pt = round(default_pixels_in_9_pt * coefficient + 0.0001);
    pixels_in_8_pt = round(default_pixels_in_8_pt * coefficient + 0.0001);
    pixels_in_7_pt = round(default_pixels_in_7_pt * coefficient + 0.0001);
    pixels_in_6_pt = round(default_pixels_in_6_pt * coefficient + 0.0001);

    garamond_6pt.setPixelSize(pixels_in_6_pt);
    garamond_7pt.setPixelSize(pixels_in_7_pt);
    garamond_8pt.setPixelSize(pixels_in_8_pt);
    garamond_9pt.setPixelSize(pixels_in_9_pt);
    garamond_10pt.setPixelSize(pixels_in_10_pt);
    garamond_11pt.setPixelSize(pixels_in_11_pt);
    garamond_12pt.setPixelSize(pixels_in_12_pt);
    garamond_13pt.setPixelSize(pixels_in_13_pt);
    garamond_14pt.setPixelSize(pixels_in_14_pt);
    garamond_15pt.setPixelSize(pixels_in_14_pt);
    garamond_16pt.setPixelSize(pixels_in_14_pt);

    trajan_6pt.setPixelSize(pixels_in_6_pt);
    trajan_7pt.setPixelSize(pixels_in_7_pt);
    trajan_8pt.setPixelSize(pixels_in_8_pt);
    trajan_9pt.setPixelSize(pixels_in_9_pt);
    trajan_10pt.setPixelSize(pixels_in_10_pt);
    trajan_11pt.setPixelSize(pixels_in_11_pt);
    trajan_12pt.setPixelSize(pixels_in_12_pt);

    crimson_6pt.setPixelSize(pixels_in_6_pt);
    crimson_7pt.setPixelSize(pixels_in_7_pt);
    crimson_8pt.setPixelSize(pixels_in_8_pt);
    crimson_9pt.setPixelSize(pixels_in_9_pt);
    crimson_10pt.setPixelSize(pixels_in_10_pt);
    crimson_11pt.setPixelSize(pixels_in_11_pt);
    crimson_12pt.setPixelSize(pixels_in_12_pt);
    crimson_13pt.setPixelSize(pixels_in_13_pt);
    crimson_14pt.setPixelSize(pixels_in_14_pt);
    crimson_15pt.setPixelSize(pixels_in_14_pt);
    crimson_16pt.setPixelSize(pixels_in_14_pt);
}
