bdf2sfd

BDF to SFD converter, allowing to vectorize bitmap fonts
Log | Files | Refs | README | LICENSE

commit e5b1be97b07df3f5bbee4a7b516c8b92540abe80
parent dee05c8c8ccabcfeaa57e808b354600303e33ab3
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri,  7 Feb 2020 10:50:04 +0100

Rename the tool to 'bdf2sfd' instead, sounds more natural.

Diffstat:
M.travis.yml | 4++--
MAUTHORS | 2+-
MCMakeLists.txt | 18+++++++++---------
MREADME.md | 20++++++++++----------
Abdf2sfd.1 | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dbdftosfd.1 | 61-------------------------------------------------------------
Asrc/bdf2sfd.c | 292+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/bdftosfd.c | 292-------------------------------------------------------------------------------
Msrc/config.h | 8++++----
Msrc/header.c | 6+++---
Msrc/header.h | 6+++---
Msrc/parse.c | 6+++---
Msrc/parse.h | 6+++---
Msrc/polygon.c | 6+++---
Msrc/polygon.h | 6+++---
15 files changed, 397 insertions(+), 397 deletions(-)

diff --git a/.travis.yml b/.travis.yml @@ -24,13 +24,13 @@ script: cmake . && make env: global: - # travis encrypt -r fcambus/bdftosfd encrypt COVERITY_SCAN_TOKEN=token + # travis encrypt -r fcambus/bdf2sfd encrypt COVERITY_SCAN_TOKEN=token - secure: "CTz2UoYRBV1Jj+yrwwh+uuj6Ip1BaVwjefvJ4RfJdfCy6KTa7D9IXOmo7w0EPfyPkmemB8T9z17OzyT7r/+9/kupBGxFU7sPuPytn0Cq7AJ1W7Thag0b+yxhjq3ZxVwQrj4rBHtqQ6GTXXiTYWlBx2ZpbeDdEm8NY0R9Cdvcs0MCOElG4r/6FHUePQ+deNtlDCb+7hL5Bc8E34nnamKht3z0gtQ+OGpQ6qkTH42anYIhebHlW9tQv7oWqN8U2/B4HgvOPjSAIVNuaMJCy2AUsD+Ux0Ks6qJgDwvIl6eGVM/BBJi44dUUcBzW8uRxlueg+xqtIF0hasMxD7TKZaw03EypDWMKva9wresfRB6PnUpOawwSiskVTgXoa/d/YHU39BFRp8EUpDqPEanqhOqh598uQ8wjCsnX7KR8kegW5a3EjlnDgZb76O8q24irNa24rty2rV9GNAuUEmAZycaJCC27DFBcLcRQKgAc+hJPFAeF4CH8NhB4vOHJI9MXhxHqRNPd01yej2JC85ZC6+xbkGYqk/iiydkU6f5iYsx77RQKkiQM/1o9W1aN/yc156B3iZil3urlIvMSTcqO/w7DX0mLBSajGdTSWl4no8UuScl+rE/i1olgwwcj2kI/i00JfQMnjdqyWM7+ARdTT9i1DEXrQN31i6CfK8nRkYmV3uM=" addons: coverity_scan: project: - name: "fcambus/bdftosfd" + name: "fcambus/bdf2sfd" version: 1.0.0 description: "BDF to SFD converter" notification_email: fred@statdns.com diff --git a/AUTHORS b/AUTHORS @@ -1,4 +1,4 @@ -bdftosfd is developed by: +bdf2sfd is developed by: Frederic Cambus <fred AT statdns DOT com> diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -1,18 +1,18 @@ # -# bdftosfd +# bdf2sfd # Copyright (c) 2019-2020, Frederic Cambus -# https://github.com/fcambus/bdftosfd +# https://github.com/fcambus/bdf2sfd # # Created: 2019-11-21 # Last Updated: 2020-02-06 # -# bdftosfd is released under the BSD 2-Clause license +# bdf2sfd is released under the BSD 2-Clause license # See LICENSE file for details # cmake_minimum_required (VERSION 2.6) -project(bdftosfd C) +project(bdf2sfd C) include(CheckFunctionExists) include(GNUInstallDirs) @@ -26,7 +26,7 @@ check_function_exists(strtonum HAVE_STRTONUM) include_directories("compat") set(CMAKE_BUILD_TYPE Release) -set(SRC src/bdftosfd.c src/header.c src/parse.c src/polygon.c) +set(SRC src/bdf2sfd.c src/header.c src/parse.c src/polygon.c) if(NOT HAVE_PLEDGE) set (SRC ${SRC} compat/pledge.c) @@ -37,10 +37,10 @@ if(NOT HAVE_STRTONUM) endif() add_definitions(-Wall -Wextra -std=c99 -pedantic) -add_executable(bdftosfd ${SRC}) +add_executable(bdf2sfd ${SRC}) -install(TARGETS bdftosfd DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES bdftosfd.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/) +install(TARGETS bdf2sfd DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES bdf2sfd.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/) enable_testing() -add_test(bdftosfd bdftosfd) +add_test(bdf2sfd bdf2sfd) diff --git a/README.md b/README.md @@ -1,6 +1,6 @@ -# bdftosfd +# bdf2sfd -bdftosfd is a [BDF][1] to [SFD][2] converter, allowing to vectorize bitmap +bdf2sfd is a [BDF][1] to [SFD][2] converter, allowing to vectorize bitmap fonts. It works by converting each pixel of a glyph to a polygon, which produces large and unoptimized SFD files which should be post-processed using [FontForge][3]. @@ -11,7 +11,7 @@ curently working on making it a general purpose converter. ## Dependencies -bdftosfd uses the `CMake` build system and does not requires any external +bdf2sfd uses the `CMake` build system and does not requires any external dependencies. mkdir build @@ -19,14 +19,14 @@ dependencies. cmake .. make -bdftosfd has been successfully built and tested on OpenBSD, NetBSD, FreeBSD, +bdf2sfd has been successfully built and tested on OpenBSD, NetBSD, FreeBSD, and Linux with both Clang and GCC. ## Usage - bdftosfd [-hv] [-f name] file + bdf2sfd [-hv] [-f name] file -If file is a single dash (`-'), bdftosfd reads from the standard input. +If file is a single dash (`-'), bdf2sfd reads from the standard input. The options are as follows: @@ -34,7 +34,7 @@ The options are as follows: -h Display usage. -v Display version. -bdftosfd outputs SFD data to **stdout**. +bdf2sfd outputs SFD data to **stdout**. ### Post-processing @@ -42,18 +42,18 @@ bdftosfd outputs SFD data to **stdout**. ## License -bdftosfd is released under the BSD 2-Clause license. See `LICENSE` file for +bdf2sfd is released under the BSD 2-Clause license. See `LICENSE` file for details. ## Author -bdftosfd is developed by Frederic Cambus. +bdf2sfd is developed by Frederic Cambus. - Site: https://www.cambus.net ## Resources -GitHub: https://github.com/fcambus/bdftosfd +GitHub: https://github.com/fcambus/bdf2sfd [1]: https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format [2]: https://fontforge.org/en-US/documentation/developers/sfdformat/ diff --git a/bdf2sfd.1 b/bdf2sfd.1 @@ -0,0 +1,61 @@ +.\" +.\" Copyright (c) 2019-2020, Frederic Cambus +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are met: +.\" +.\" * Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" +.\" * Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd $Mdocdate: February 7 2020 $ +.Dt BDF2SFD 1 +.Os +.Sh NAME +.Nm bdf2sfd +.Nd BDF to SFD converter +.Sh SYNOPSIS +.Nm +.Op Fl hv +.Op Fl f Ar name +.Ar file +.Sh DESCRIPTION +.Nm +is a BDF to SFD converter. +.Pp +If +.Ar file +is a single dash (`-'), +.Nm +reads from the standard input. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl f Ar name +Specify font name. +.It Fl h +Display usage. +.It Fl v +Display version. +.El + +.Sh AUTHORS +.Nm +was written by +.An Frederic Cambus . diff --git a/bdftosfd.1 b/bdftosfd.1 @@ -1,61 +0,0 @@ -.\" -.\" Copyright (c) 2019-2020, Frederic Cambus -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions are met: -.\" -.\" * Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" -.\" * Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: January 30 2020 $ -.Dt BDFTOSFD 1 -.Os -.Sh NAME -.Nm bdftosfd -.Nd BDF to SFD converter -.Sh SYNOPSIS -.Nm -.Op Fl hv -.Op Fl f Ar name -.Ar file -.Sh DESCRIPTION -.Nm -is a BDF to SFD converter. -.Pp -If -.Ar file -is a single dash (`-'), -.Nm -reads from the standard input. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl f Ar name -Specify font name. -.It Fl h -Display usage. -.It Fl v -Display version. -.El - -.Sh AUTHORS -.Nm -was written by -.An Frederic Cambus . diff --git a/src/bdf2sfd.c b/src/bdf2sfd.c @@ -0,0 +1,292 @@ +/* + * bdf2sfd + * Copyright (c) 2019-2020, Frederic Cambus + * https://github.com/fcambus/bdf2sfd + * + * Created: 2019-11-21 + * Last Updated: 2020-02-06 + * + * bdf2sfd is released under the BSD 2-Clause license + * See LICENSE file for details + */ + +#define _XOPEN_SOURCE 600 +#define _POSIX_C_SOURCE 199309L +#define _POSIX_SOURCE + +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <err.h> +#include <getopt.h> +#include <inttypes.h> +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> +#include <string.h> +#include <time.h> + +#include "compat.h" +#include "config.h" +#include "header.h" +#include "parse.h" +#include "polygon.h" + +struct timespec begin, end, elapsed; + +char lineBuffer[LINE_LENGTH_MAX]; + +FILE *bdfFile; +struct stat bdfFileStat; + +const char *errstr; + +int8_t getoptFlag; + +char *intputFile; + +uint64_t glyphes; +double runtime; + +void +displayUsage() +{ + printf("USAGE: bdf2sfd [options] inputfile\n\n" \ + "Options are:\n\n" \ + " -h Display usage\n" \ + " -v Display version\n"); +} + +int +main(int argc, char *argv[]) +{ + bool readglyph = false; + + char *value = NULL; + + uint32_t height = 0, width = 0; + uint32_t ascent = 0, descent = 0; + + int key; + int32_t x = 0, y = 0; + uint32_t mask = 0; + uint32_t xlength = 64, ylength = 64; /* Default values for 8x16 fonts */ + + struct fontinfo font; + memset(&font, 0, sizeof(struct fontinfo)); + + if (pledge("stdio rpath", NULL) == -1) { + err(EXIT_FAILURE, "pledge"); + } + + while ((getoptFlag = getopt(argc, argv, "f:hv")) != -1) { + switch (getoptFlag) { + case 'f': + font.name = optarg; + break; + + case 'h': + displayUsage(); + return EXIT_SUCCESS; + + case 'v': + printf("%s\n", VERSION); + return EXIT_SUCCESS; + } + } + + if (optind < argc) { + intputFile = argv[optind]; + } else { + displayUsage(); + return EXIT_SUCCESS; + } + + argc -= optind; + argv += optind; + + /* Starting timer */ + clock_gettime(CLOCK_MONOTONIC, &begin); + + /* Open BDF file */ + if (!strcmp(intputFile, "-")) { + /* Read from standard input */ + bdfFile = stdin; + } else { + /* Attempt to read from file */ + if (!(bdfFile = fopen(intputFile, "r"))) { + perror("Can't open BDF file"); + return EXIT_FAILURE; + } + } + + /* Get BDF file size */ + if (fstat(fileno(bdfFile), &bdfFileStat)) { + perror("Can't stat BDF file"); + return EXIT_FAILURE; + } + + while (fgets(lineBuffer, LINE_LENGTH_MAX, bdfFile)) { + if (!*lineBuffer) + continue; + + key = parseLine(lineBuffer); + + switch(key) { + case FAMILY_NAME: + if (!font.name) { + value = strtok(NULL, "\n"); + + if (value) + font.name = strdup(value); + } + + continue; + + case COPYRIGHT: + value = strtok(NULL, "\n"); + + if (value) + font.copyright = strdup(value); + + continue; + + case FONTBOUNDINGBOX: + value = strtok(NULL, " \t"); + + if (value) + width = strtonum(value, 0, 32, &errstr); + + if (errstr) + errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); + + value = strtok(NULL, " \t"); + + if (value) + height = strtonum(value, 0, 64, &errstr); + + if (errstr) + errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); + + if (!width || !height) + errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); + + xlength = 512 / width; + ylength = 1024 / height; + + mask = 1 << (stride[width] * 8 - 1); + + continue; + + case FONT_ASCENT: + value = strtok(NULL, "\n"); + + if (value) + ascent = strtonum(value, 0, 64, &errstr); + + if (!errstr) + font.ascent = ascent * ylength; + else + errx(EXIT_FAILURE, "Invalid value for FONT_ASCENT."); + + continue; + + case FONT_DESCENT: + value = strtok(NULL, "\n"); + + if (value) + descent = strtonum(value, 0, 64, &errstr); + + if (!errstr) + font.descent = descent * ylength; + else + errx(EXIT_FAILURE, "Invalid value for FONT_DESCENT."); + + continue; + + case FONT_VERSION: + value = strtok(NULL, "\n"); + + if (value) + font.version = strdup(value); + + continue; + + case CHARS: + font.chars = strtok(NULL, " \n"); + + if (font.chars) + header(stdout, &font); + else + errx(EXIT_FAILURE, "Invalid value for CHARS."); + + continue; + + case STARTCHAR: + fprintf(stdout, "StartChar:"); + + value = strtok(NULL, "\n"); + + while (value) { + fprintf(stdout, " %s\n", value); + value = strtok(NULL, " \n"); + } + + continue; + + case ENCODING: + value = strtok(NULL, " \n"); + + if (value) + fprintf(stdout, "\nEncoding: %s %s %s\n", value, value, value); + + continue; + + case BITMAP: + fprintf(stdout, "Width: 512\n" + "Flags: HW\n" + "LayerCount: 2\n" + "Fore\n" + "SplineSet\n"); + + y = font.ascent; + readglyph = true; + glyphes++; + + continue; + + case ENDCHAR: + fprintf(stdout, "EndSplineSet\n" + "EndChar\n\n"); + + readglyph = false; + continue; + } + + if (readglyph) { + uint32_t row = strtoul(lineBuffer, NULL, 16); + + polygon(row, mask, width, x, y, xlength, ylength); + + y -= ylength; + } + } + + fprintf(stdout, "EndChars\n" + "EndSplineFont\n"); + + /* Stopping timer */ + clock_gettime(CLOCK_MONOTONIC, &end); + + timespecsub(&end, &begin, &elapsed); + runtime = elapsed.tv_sec + elapsed.tv_nsec / 1E9; + + /* Printing results */ + fprintf(stderr, "Processed %" PRIu64 " glyphes in %f seconds.\n", glyphes, runtime); + + /* Clean up */ + fclose(bdfFile); + + return EXIT_SUCCESS; +} diff --git a/src/bdftosfd.c b/src/bdftosfd.c @@ -1,292 +0,0 @@ -/* - * bdftosfd - * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd - * - * Created: 2019-11-21 - * Last Updated: 2020-02-06 - * - * bdftosfd is released under the BSD 2-Clause license - * See LICENSE file for details - */ - -#define _XOPEN_SOURCE 600 -#define _POSIX_C_SOURCE 199309L -#define _POSIX_SOURCE - -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/types.h> -#include <err.h> -#include <getopt.h> -#include <inttypes.h> -#include <stdbool.h> -#include <stdlib.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> -#include <time.h> - -#include "compat.h" -#include "config.h" -#include "header.h" -#include "parse.h" -#include "polygon.h" - -struct timespec begin, end, elapsed; - -char lineBuffer[LINE_LENGTH_MAX]; - -FILE *bdfFile; -struct stat bdfFileStat; - -const char *errstr; - -int8_t getoptFlag; - -char *intputFile; - -uint64_t glyphes; -double runtime; - -void -displayUsage() -{ - printf("USAGE: bdftosfd [options] inputfile\n\n" \ - "Options are:\n\n" \ - " -h Display usage\n" \ - " -v Display version\n"); -} - -int -main(int argc, char *argv[]) -{ - bool readglyph = false; - - char *value = NULL; - - uint32_t height = 0, width = 0; - uint32_t ascent = 0, descent = 0; - - int key; - int32_t x = 0, y = 0; - uint32_t mask = 0; - uint32_t xlength = 64, ylength = 64; /* Default values for 8x16 fonts */ - - struct fontinfo font; - memset(&font, 0, sizeof(struct fontinfo)); - - if (pledge("stdio rpath", NULL) == -1) { - err(EXIT_FAILURE, "pledge"); - } - - while ((getoptFlag = getopt(argc, argv, "f:hv")) != -1) { - switch (getoptFlag) { - case 'f': - font.name = optarg; - break; - - case 'h': - displayUsage(); - return EXIT_SUCCESS; - - case 'v': - printf("%s\n", VERSION); - return EXIT_SUCCESS; - } - } - - if (optind < argc) { - intputFile = argv[optind]; - } else { - displayUsage(); - return EXIT_SUCCESS; - } - - argc -= optind; - argv += optind; - - /* Starting timer */ - clock_gettime(CLOCK_MONOTONIC, &begin); - - /* Open BDF file */ - if (!strcmp(intputFile, "-")) { - /* Read from standard input */ - bdfFile = stdin; - } else { - /* Attempt to read from file */ - if (!(bdfFile = fopen(intputFile, "r"))) { - perror("Can't open BDF file"); - return EXIT_FAILURE; - } - } - - /* Get BDF file size */ - if (fstat(fileno(bdfFile), &bdfFileStat)) { - perror("Can't stat BDF file"); - return EXIT_FAILURE; - } - - while (fgets(lineBuffer, LINE_LENGTH_MAX, bdfFile)) { - if (!*lineBuffer) - continue; - - key = parseLine(lineBuffer); - - switch(key) { - case FAMILY_NAME: - if (!font.name) { - value = strtok(NULL, "\n"); - - if (value) - font.name = strdup(value); - } - - continue; - - case COPYRIGHT: - value = strtok(NULL, "\n"); - - if (value) - font.copyright = strdup(value); - - continue; - - case FONTBOUNDINGBOX: - value = strtok(NULL, " \t"); - - if (value) - width = strtonum(value, 0, 32, &errstr); - - if (errstr) - errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); - - value = strtok(NULL, " \t"); - - if (value) - height = strtonum(value, 0, 64, &errstr); - - if (errstr) - errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); - - if (!width || !height) - errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); - - xlength = 512 / width; - ylength = 1024 / height; - - mask = 1 << (stride[width] * 8 - 1); - - continue; - - case FONT_ASCENT: - value = strtok(NULL, "\n"); - - if (value) - ascent = strtonum(value, 0, 64, &errstr); - - if (!errstr) - font.ascent = ascent * ylength; - else - errx(EXIT_FAILURE, "Invalid value for FONT_ASCENT."); - - continue; - - case FONT_DESCENT: - value = strtok(NULL, "\n"); - - if (value) - descent = strtonum(value, 0, 64, &errstr); - - if (!errstr) - font.descent = descent * ylength; - else - errx(EXIT_FAILURE, "Invalid value for FONT_DESCENT."); - - continue; - - case FONT_VERSION: - value = strtok(NULL, "\n"); - - if (value) - font.version = strdup(value); - - continue; - - case CHARS: - font.chars = strtok(NULL, " \n"); - - if (font.chars) - header(stdout, &font); - else - errx(EXIT_FAILURE, "Invalid value for CHARS."); - - continue; - - case STARTCHAR: - fprintf(stdout, "StartChar:"); - - value = strtok(NULL, "\n"); - - while (value) { - fprintf(stdout, " %s\n", value); - value = strtok(NULL, " \n"); - } - - continue; - - case ENCODING: - value = strtok(NULL, " \n"); - - if (value) - fprintf(stdout, "\nEncoding: %s %s %s\n", value, value, value); - - continue; - - case BITMAP: - fprintf(stdout, "Width: 512\n" - "Flags: HW\n" - "LayerCount: 2\n" - "Fore\n" - "SplineSet\n"); - - y = font.ascent; - readglyph = true; - glyphes++; - - continue; - - case ENDCHAR: - fprintf(stdout, "EndSplineSet\n" - "EndChar\n\n"); - - readglyph = false; - continue; - } - - if (readglyph) { - uint32_t row = strtoul(lineBuffer, NULL, 16); - - polygon(row, mask, width, x, y, xlength, ylength); - - y -= ylength; - } - } - - fprintf(stdout, "EndChars\n" - "EndSplineFont\n"); - - /* Stopping timer */ - clock_gettime(CLOCK_MONOTONIC, &end); - - timespecsub(&end, &begin, &elapsed); - runtime = elapsed.tv_sec + elapsed.tv_nsec / 1E9; - - /* Printing results */ - fprintf(stderr, "Processed %" PRIu64 " glyphes in %f seconds.\n", glyphes, runtime); - - /* Clean up */ - fclose(bdfFile); - - return EXIT_SUCCESS; -} diff --git a/src/config.h b/src/config.h @@ -1,19 +1,19 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-01-28 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */ #ifndef CONFIG_H #define CONFIG_H -#define VERSION "bdftosfd 1.0.0" +#define VERSION "bdf2sfd 1.0.0" enum { LINE_LENGTH_MAX = 65536 diff --git a/src/header.c b/src/header.c @@ -1,12 +1,12 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-01-20 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */ diff --git a/src/header.h b/src/header.h @@ -1,12 +1,12 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-01-21 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */ diff --git a/src/parse.c b/src/parse.c @@ -1,12 +1,12 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-02-06 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */ diff --git a/src/parse.h b/src/parse.h @@ -1,12 +1,12 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-02-06 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */ diff --git a/src/polygon.c b/src/polygon.c @@ -1,12 +1,12 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-02-06 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */ diff --git a/src/polygon.h b/src/polygon.h @@ -1,12 +1,12 @@ /* - * bdftosfd + * bdf2sfd * Copyright (c) 2019-2020, Frederic Cambus - * https://github.com/fcambus/bdftosfd + * https://github.com/fcambus/bdf2sfd * * Created: 2019-11-21 * Last Updated: 2020-02-06 * - * bdftosfd is released under the BSD 2-Clause license + * bdf2sfd is released under the BSD 2-Clause license * See LICENSE file for details */