libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

fonts.c (4696B)


      1 /*
      2  * fonts.c
      3  * libansilove 1.2.7
      4  * https://www.ansilove.org
      5  *
      6  * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus
      7  * All rights reserved.
      8  *
      9  * libansilove is licensed under the BSD 2-Clause License.
     10  * See LICENSE file for details.
     11  */
     12 
     13 #include "ansilove.h"
     14 #include "fonts.h"
     15 
     16 #include "fonts/font_pc_80x25.h"
     17 #include "fonts/font_pc_80x50.h"
     18 #include "fonts/font_pc_baltic.h"
     19 #include "fonts/font_pc_cyrillic.h"
     20 #include "fonts/font_pc_french_canadian.h"
     21 #include "fonts/font_pc_greek.h"
     22 #include "fonts/font_pc_greek869.h"
     23 #include "fonts/font_pc_hebrew.h"
     24 #include "fonts/font_pc_icelandic.h"
     25 #include "fonts/font_pc_latin1.h"
     26 #include "fonts/font_pc_latin2.h"
     27 #include "fonts/font_pc_nordic.h"
     28 #include "fonts/font_pc_portuguese.h"
     29 #include "fonts/font_pc_russian.h"
     30 #include "fonts/font_pc_terminus.h"
     31 #include "fonts/font_pc_turkish.h"
     32 #include "fonts/font_amiga_microknight.h"
     33 #include "fonts/font_amiga_microknight_plus.h"
     34 #include "fonts/font_amiga_mosoul.h"
     35 #include "fonts/font_amiga_pot_noodle.h"
     36 #include "fonts/font_amiga_topaz_1200.h"
     37 #include "fonts/font_amiga_topaz_1200_plus.h"
     38 #include "fonts/font_amiga_topaz_500.h"
     39 #include "fonts/font_amiga_topaz_500_plus.h"
     40 
     41 void
     42 select_font(struct fontStruct *fontData, int font)
     43 {
     44 	switch (font) {
     45 	case ANSILOVE_FONT_CP437_80x50:
     46 		fontData->font_data = font_pc_80x50;
     47 		fontData->width = 9;
     48 		fontData->height = 8;
     49 		break;
     50 	case ANSILOVE_FONT_CP737:
     51 		fontData->font_data = font_pc_greek;
     52 		fontData->width = 9;
     53 		fontData->height = 16;
     54 		break;
     55 	case ANSILOVE_FONT_CP775:
     56 		fontData->font_data = font_pc_baltic;
     57 		fontData->width = 9;
     58 		fontData->height = 16;
     59 		break;
     60 	case ANSILOVE_FONT_CP850:
     61 		fontData->font_data = font_pc_latin1;
     62 		fontData->width = 9;
     63 		fontData->height = 16;
     64 		break;
     65 	case ANSILOVE_FONT_CP852:
     66 		fontData->font_data = font_pc_latin2;
     67 		fontData->width = 9;
     68 		fontData->height = 16;
     69 		break;
     70 	case ANSILOVE_FONT_CP855:
     71 		fontData->font_data = font_pc_cyrillic;
     72 		fontData->width = 9;
     73 		fontData->height = 16;
     74 		break;
     75 	case ANSILOVE_FONT_CP857:
     76 		fontData->font_data = font_pc_turkish;
     77 		fontData->width = 9;
     78 		fontData->height = 16;
     79 		break;
     80 	case ANSILOVE_FONT_CP860:
     81 		fontData->font_data = font_pc_portuguese;
     82 		fontData->width = 9;
     83 		fontData->height = 16;
     84 		break;
     85 	case ANSILOVE_FONT_CP861:
     86 		fontData->font_data = font_pc_icelandic;
     87 		fontData->width = 9;
     88 		fontData->height = 16;
     89 		break;
     90 	case ANSILOVE_FONT_CP862:
     91 		fontData->font_data = font_pc_hebrew;
     92 		fontData->width = 9;
     93 		fontData->height = 16;
     94 		break;
     95 	case ANSILOVE_FONT_CP863:
     96 		fontData->font_data = font_pc_french_canadian;
     97 		fontData->width = 9;
     98 		fontData->height = 16;
     99 		break;
    100 	case ANSILOVE_FONT_CP865:
    101 		fontData->font_data = font_pc_nordic;
    102 		fontData->width = 9;
    103 		fontData->height = 16;
    104 		break;
    105 	case ANSILOVE_FONT_CP866:
    106 		fontData->font_data = font_pc_russian;
    107 		fontData->width = 9;
    108 		fontData->height = 16;
    109 		break;
    110 	case ANSILOVE_FONT_CP869:
    111 		fontData->font_data = font_pc_greek_869;
    112 		fontData->width = 9;
    113 		fontData->height = 16;
    114 		break;
    115 	case ANSILOVE_FONT_TERMINUS:
    116 		fontData->font_data = font_pc_terminus;
    117 		fontData->width = 9;
    118 		fontData->height = 16;
    119 		break;
    120 	case ANSILOVE_FONT_MICROKNIGHT:
    121 		fontData->isAmigaFont = true;
    122 		fontData->font_data = font_amiga_microknight;
    123 		fontData->width = 8;
    124 		fontData->height = 16;
    125 		break;
    126 	case ANSILOVE_FONT_MICROKNIGHT_PLUS:
    127 		fontData->isAmigaFont = true;
    128 		fontData->font_data = font_amiga_microknight_plus;
    129 		fontData->width = 8;
    130 		fontData->height = 16;
    131 		break;
    132 	case ANSILOVE_FONT_MOSOUL:
    133 		fontData->isAmigaFont = true;
    134 		fontData->font_data = font_amiga_mosoul;
    135 		fontData->width = 8;
    136 		fontData->height = 16;
    137 		break;
    138 	case ANSILOVE_FONT_POT_NOODLE:
    139 		fontData->isAmigaFont = true;
    140 		fontData->font_data = font_amiga_pot_noodle;
    141 		fontData->width = 8;
    142 		fontData->height = 16;
    143 		break;
    144 	case ANSILOVE_FONT_TOPAZ:
    145 		fontData->isAmigaFont = true;
    146 		fontData->font_data = font_amiga_topaz_1200;
    147 		fontData->width = 8;
    148 		fontData->height = 16;
    149 		break;
    150 	case ANSILOVE_FONT_TOPAZ_PLUS:
    151 		fontData->isAmigaFont = true;
    152 		fontData->font_data = font_amiga_topaz_1200_plus;
    153 		fontData->width = 8;
    154 		fontData->height = 16;
    155 		break;
    156 	case ANSILOVE_FONT_TOPAZ500:
    157 		fontData->isAmigaFont = true;
    158 		fontData->font_data = font_amiga_topaz_500;
    159 		fontData->width = 8;
    160 		fontData->height = 16;
    161 		break;
    162 	case ANSILOVE_FONT_TOPAZ500_PLUS:
    163 		fontData->isAmigaFont = true;
    164 		fontData->font_data = font_amiga_topaz_500_plus;
    165 		fontData->width = 8;
    166 		fontData->height = 16;
    167 		break;
    168 	default:
    169 		/* in all other cases use the standard DOS font */
    170 		fontData->font_data = font_pc_80x25;
    171 		fontData->width = 9;
    172 		fontData->height = 16;
    173 		break;
    174 	}
    175 }