drawchar.c (1057B)
1 /* 2 * drawchar.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 <gd.h> 16 17 #include "drawchar.h" 18 19 void 20 drawchar(gdImagePtr im, const uint8_t *font_data, uint32_t bits, 21 uint32_t height, uint32_t column, uint32_t row, 22 uint32_t background, uint32_t foreground, uint8_t character) 23 { 24 uint32_t x, y; 25 26 gdImageFilledRectangle(im, column * bits, row*height, column * bits + 27 bits - 1, row * height + height - 1, background); 28 29 for (y = 0; y < height; y++) { 30 for (x = 0; x < bits; x++) { 31 32 if (font_data[y+character*height] & (0x80 >> x)) { 33 gdImageSetPixel(im, column * bits + x, 34 row*height + y, foreground); 35 36 if (bits == 9 && x == 7 && 37 character > 191 && character < 224) 38 gdImageSetPixel(im, column * bits + 8, 39 row * height + y, foreground); 40 } 41 } 42 } 43 }