libansilove

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

fonts.c (4740B)


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