diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2020-01-14 20:52:18 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2020-01-14 20:52:18 +0000 |
commit | 735d1846d5f5f81e95fa0c89a8507adade2e6c3c (patch) | |
tree | 03cfb9442779215eb7d276143530cb475b680a8a | |
parent | 4aaddf8adfdbfd05ba2e5066823044debb02f676 (diff) |
Update to fonttosfnt 1.1.0
-rw-r--r-- | app/fonttosfnt/ChangeLog | 113 | ||||
-rw-r--r-- | app/fonttosfnt/Makefile.am | 2 | ||||
-rw-r--r-- | app/fonttosfnt/Makefile.in | 3 | ||||
-rw-r--r-- | app/fonttosfnt/README | 24 | ||||
-rw-r--r-- | app/fonttosfnt/README.md | 16 | ||||
-rw-r--r-- | app/fonttosfnt/compile | 10 | ||||
-rw-r--r-- | app/fonttosfnt/configure | 30 | ||||
-rw-r--r-- | app/fonttosfnt/configure.ac | 2 | ||||
-rw-r--r-- | app/fonttosfnt/fonttosfnt.c | 10 | ||||
-rw-r--r-- | app/fonttosfnt/man/fonttosfnt.man | 10 | ||||
-rw-r--r-- | app/fonttosfnt/read.c | 97 | ||||
-rw-r--r-- | app/fonttosfnt/struct.c | 4 | ||||
-rw-r--r-- | app/fonttosfnt/util.c | 21 |
13 files changed, 266 insertions, 76 deletions
diff --git a/app/fonttosfnt/ChangeLog b/app/fonttosfnt/ChangeLog index 4170af802..c5e54d94d 100644 --- a/app/fonttosfnt/ChangeLog +++ b/app/fonttosfnt/ChangeLog @@ -1,3 +1,116 @@ +commit 1d757ff6fa30079790fc44b141f6d0e4d5411f13 +Author: Peter Hutterer <peter.hutterer@who-t.net> +Date: Mon Jan 6 12:55:31 2020 +1000 + + Bump to 1.1.0 + + Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> + +commit bdcb892975de167b3d4258859234f0abe375f236 +Author: Jouke Witteveen <j.witteveen@gmail.com> +Date: Fri Aug 2 14:03:15 2019 +0200 + + Accept a BDF font on stdin + + This makes it easier to transition from bdftopcf. + Although an OTB file could include fonts from multiple BDF sources, that + functionality is not currently implemented for fonts read from stdin. + + Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> + +commit 0006f577898129c0c5d5e0996026641605705e08 +Author: Jouke Witteveen <j.witteveen@gmail.com> +Date: Fri Aug 2 11:43:56 2019 +0200 + + Mention .otb as an extension + + The OTB (OpenType Bitmap) extension has found some traction, so suggest + that. + + Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> + +commit cb4b8760f829040eb4b2fb314df5b6194230a237 +Author: Jouke Witteveen <j.witteveen@gmail.com> +Date: Fri Aug 2 11:41:59 2019 +0200 + + Correct a string literal + + Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com> + +commit d06059ef2a85df3c70f3c0b77364b4c49837f331 +Author: Peng Wu <alexepico@gmail.com> +Date: Wed Oct 9 14:20:22 2019 +0800 + + Round font size to integer value when reading bitmap font + + Some fonts have a ppem value like 11.9, this patch adds integer rounding to + convert those ppem value to 12 instead of 11. + +commit cfb4d64e1b90a28693fd700f4abf0f55d969f4f6 +Author: Ryan Farley <ryan.farley@gmx.com> +Date: Sat Aug 31 06:42:24 2019 -0500 + + allow ISO-646.1991-IRV as well, adobe standard for bdf + + Allow for BDF file with no specified encoding to be read as Adobe + Standard (per freetype's BDF driver), and handle any Unicode-equivalent + encoding without changing the encoding name. + +commit 5d446a02a7422d3a61f74b8d1c28b7b551ea06fd +Author: Ryan Farley <ryan.farley@gmx.com> +Date: Tue Aug 20 03:16:22 2019 -0500 + + let freetype handle ISO-8859-1 mapping + + https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#ft_encoding + indicates that ISO-8859-1 is automatically mapped to Unicode for BDF and + PCF fonts -- trying to use FT_Select_Charmap() with FT_ENCODING_NONE + leads to an error for such fonts. + +commit 6fc84fb2c0d4ac0b3b66330057bb90418cc1eb28 +Author: Ryan Farley <ryan.farley@gmx.com> +Date: Fri Aug 30 09:43:50 2019 -0500 + + check for freetype NULL atoms + + Freetype uses NULL to represent an empty string when retrieving a BDF + property -- check for this in addition to an actual error + +commit c214ab0d7deae30acdf90933ed14b223118dcf67 +Author: Maya Rashish <maya@NetBSD.org> +Date: Thu Jan 10 20:49:28 2019 +0200 + + Avoid undefined behaviour + + Left shifting a negative is undefined. + For consistency, use the equivalent form of multiplication for the + positive numbers as well. + +commit 8e34a2aa7c4dea5aa07dc08a40dacd90e2148a89 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Wed Nov 21 16:46:19 2018 -0800 + + Update configure.ac bug URL for gitlab migration + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit 46d4900c2dbed1c7a632dc34a4ef952a9cdda8eb +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Nov 16 19:53:06 2018 -0800 + + Update README for gitlab migration + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit ec6f334152badff475d2a8c465dfdbf740f148d0 +Author: Peter Hutterer <peter.hutterer@who-t.net> +Date: Wed Oct 31 14:37:24 2018 +1000 + + Mark vsprintf_alloc as printf-like function + + Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> + Reviewed-by: Eric Anholt <eric@anholt.net> + commit 7f8d7ecf0379ebc5386ee27f385a2ca564d6decb Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Tue Jul 31 11:36:54 2018 +1000 diff --git a/app/fonttosfnt/Makefile.am b/app/fonttosfnt/Makefile.am index 29169b15f..23446b47d 100644 --- a/app/fonttosfnt/Makefile.am +++ b/app/fonttosfnt/Makefile.am @@ -49,3 +49,5 @@ ChangeLog: $(CHANGELOG_CMD) dist-hook: ChangeLog INSTALL + +EXTRA_DIST = README.md diff --git a/app/fonttosfnt/Makefile.in b/app/fonttosfnt/Makefile.in index 7835a1a12..adf7d8da3 100644 --- a/app/fonttosfnt/Makefile.in +++ b/app/fonttosfnt/Makefile.in @@ -75,7 +75,7 @@ bin_PROGRAMS = fonttosfnt$(EXEEXT) @NEED_SETENV_TRUE@am__append_1 = env.c @NEED_SETENV_TRUE@am__append_2 = -DNEED_SETENV subdir = . -DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ +DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ compile config.guess config.sub depcomp install-sh missing @@ -322,6 +322,7 @@ fonttosfnt_LDADD = $(FONTTOSFNT_LIBS) -lm fonttosfnt_SOURCES = fonttosfnt.c fonttosfnt.h read.c struct.c util.c \ write.c $(am__append_1) MAINTAINERCLEANFILES = ChangeLog INSTALL +EXTRA_DIST = README.md all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff --git a/app/fonttosfnt/README b/app/fonttosfnt/README deleted file mode 100644 index fa3ad0876..000000000 --- a/app/fonttosfnt/README +++ /dev/null @@ -1,24 +0,0 @@ -fonttosfnt wraps a set of bdf or pcf bitmap fonts in a sfnt (TrueType or -OpenType) wrapper. - -All questions regarding this software should be directed at the -Xorg mailing list: - - http://lists.freedesktop.org/mailman/listinfo/xorg - -Please submit bug reports to the Xorg bugzilla: - - https://bugs.freedesktop.org/enter_bug.cgi?product=xorg - -The master development code repository can be found at: - - https://gitlab.freedesktop.org/xorg/app/fonttosfnt.git - -For patch submission instructions, see: - - http://www.x.org/wiki/Development/Documentation/SubmittingPatches - -For more information on the git code manager, see: - - http://wiki.x.org/wiki/GitPage - diff --git a/app/fonttosfnt/README.md b/app/fonttosfnt/README.md new file mode 100644 index 000000000..c47925bb8 --- /dev/null +++ b/app/fonttosfnt/README.md @@ -0,0 +1,16 @@ +fonttosfnt wraps a set of bdf or pcf bitmap fonts in a sfnt (TrueType or +OpenType) wrapper. + +All questions regarding this software should be directed at the +Xorg mailing list: + + https://lists.x.org/mailman/listinfo/xorg + +The master development code repository can be found at: + + https://gitlab.freedesktop.org/xorg/app/fonttosfnt.git + +For patch submission instructions, see: + + https://www.x.org/wiki/Development/Documentation/SubmittingPatches + diff --git a/app/fonttosfnt/compile b/app/fonttosfnt/compile index ee7d09c06..96fe54c1b 100644 --- a/app/fonttosfnt/compile +++ b/app/fonttosfnt/compile @@ -1,9 +1,9 @@ -#!/bin/sh +#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2016-01-11.22; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -340,7 +340,7 @@ exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/app/fonttosfnt/configure b/app/fonttosfnt/configure index c5db4b0dd..540a8f7c0 100644 --- a/app/fonttosfnt/configure +++ b/app/fonttosfnt/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for fonttosfnt 1.0.5. +# Generated by GNU Autoconf 2.69 for fonttosfnt 1.1.0. # -# Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>. +# Report bugs to <https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues>. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -267,7 +267,7 @@ fi $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: https://bugs.freedesktop.org/enter_bug.cgi?product=xorg +$0: https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do @@ -581,9 +581,9 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='fonttosfnt' PACKAGE_TARNAME='fonttosfnt' -PACKAGE_VERSION='1.0.5' -PACKAGE_STRING='fonttosfnt 1.0.5' -PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg' +PACKAGE_VERSION='1.1.0' +PACKAGE_STRING='fonttosfnt 1.1.0' +PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues' PACKAGE_URL='' ac_unique_file="Makefile.am" @@ -1313,7 +1313,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures fonttosfnt 1.0.5 to adapt to many kinds of systems. +\`configure' configures fonttosfnt 1.1.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1383,7 +1383,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of fonttosfnt 1.0.5:";; + short | recursive ) echo "Configuration of fonttosfnt 1.1.0:";; esac cat <<\_ACEOF @@ -1429,7 +1429,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>. +Report bugs to <https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues>. _ACEOF ac_status=$? fi @@ -1492,7 +1492,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -fonttosfnt configure 1.0.5 +fonttosfnt configure 1.1.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1816,7 +1816,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by fonttosfnt $as_me 1.0.5, which was +It was created by fonttosfnt $as_me 1.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2645,7 +2645,7 @@ fi # Define the identity of the package. PACKAGE='fonttosfnt' - VERSION='1.0.5' + VERSION='1.1.0' cat >>confdefs.h <<_ACEOF @@ -11144,7 +11144,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by fonttosfnt $as_me 1.0.5, which was +This file was extended by fonttosfnt $as_me 1.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11204,13 +11204,13 @@ $config_headers Configuration commands: $config_commands -Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>." +Report bugs to <https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -fonttosfnt config.status 1.0.5 +fonttosfnt config.status 1.1.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/app/fonttosfnt/configure.ac b/app/fonttosfnt/configure.ac index d5e9610cb..2e2006392 100644 --- a/app/fonttosfnt/configure.ac +++ b/app/fonttosfnt/configure.ac @@ -23,7 +23,7 @@ dnl Process this file with autoconf to create configure. # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT(fonttosfnt,[1.0.5], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],fonttosfnt) +AC_INIT(fonttosfnt,[1.1.0], [https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues],fonttosfnt) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) diff --git a/app/fonttosfnt/fonttosfnt.c b/app/fonttosfnt/fonttosfnt.c index 78c6b7e82..062ef3ed4 100644 --- a/app/fonttosfnt/fonttosfnt.c +++ b/app/fonttosfnt/fonttosfnt.c @@ -39,8 +39,8 @@ usage(void) { fprintf(stderr, "Usage:\n"); fprintf(stderr, - "fonttosfnt [ -v ] [ -c ] [ -b ] [ -r ] [ -g n ] [ -m n ] -o font.ttf " - "[ -- ] font ...\n"); + "fonttosfnt [ -v ] [ -c ] [ -b ] [ -r ] [ -g n ] [ -m n ] -o font.otb " + "[ -- ] [ font ] ...\n"); } int @@ -106,7 +106,11 @@ main(int argc, char **argv) font = makeFont(); - while(i < argc) { + if(i == argc) { + rc = readFile(NULL, font); + if(rc != 0) + exit(1); + } else while(i < argc) { rc = readFile(argv[i], font); if(rc != 0) exit(1); diff --git a/app/fonttosfnt/man/fonttosfnt.man b/app/fonttosfnt/man/fonttosfnt.man index 4b05058cf..473b87c0d 100644 --- a/app/fonttosfnt/man/fonttosfnt.man +++ b/app/fonttosfnt/man/fonttosfnt.man @@ -1,21 +1,23 @@ .\" $XFree86$ .TH FONTTOSFNT 1 __vendorversion__ .SH NAME -fonttosfnt \- Wrap a bitmap font in a sfnt (TrueType) wrapper +fonttosfnt \- Wrap a bitmap font in a sfnt (OpenType) wrapper .SH SYNOPSIS .B fonttosfnt [ .I options ] .B \-o -.I file.ttf +.I file.otb [ .B \-\- -] -.IR font ... +] [ +.IR font +] ... .SH DESCRIPTION Wrap a bitmap font or a set of bitmap fonts in a sfnt (TrueType or OpenType) wrapper. +If no font is specified, a BDF font is read from standard input (stdin). .SH OPTIONS .TP .B \-v diff --git a/app/fonttosfnt/read.c b/app/fonttosfnt/read.c index 632c7e7a6..a22ce4130 100644 --- a/app/fonttosfnt/read.c +++ b/app/fonttosfnt/read.c @@ -27,6 +27,7 @@ THE SOFTWARE. #include <ft2build.h> #include FT_FREETYPE_H +#include FT_MODULE_H #include FT_BDF_H #include "X11/Xos.h" #include "fonttosfnt.h" @@ -36,6 +37,8 @@ THE SOFTWARE. #define CEIL2(x, y) (FLOOR2((x) + (y) - 1, (y))) #define FT_Pos_DOWN(x) (FLOOR2((x),64)) #define FT_Pos_UP(x) (CEIL2((x), 64)) +#define MIN(x, y) (((x) <= (y)) ? (x) : (y)) +#define STREAM_FILE(stream) ((FILE*)stream->descriptor.pointer) static int ft_inited = 0; static FT_Library ft_library; @@ -55,15 +58,50 @@ FT_Ensure_Inited(void) return 0; } +static unsigned long +forwardRead(FT_Stream stream, unsigned long offset, unsigned char *buffer, + unsigned long count) { + unsigned char skip_buffer[BUFSIZ]; + unsigned long skip_count; + FILE *file = STREAM_FILE(stream); + + /* We may be asked to skip forward, but by not doing so we increase our + chance of survival. */ + if(count == 0) + return ferror(file) == 0 ? 0 : 1; + + if(offset < stream->pos) { + fprintf(stderr, "Cannot move backward in input stream.\n"); + return 0; + } + while((skip_count = MIN(BUFSIZ, offset - stream->pos))) { + if(fread(skip_buffer, sizeof(*skip_buffer), skip_count, file) < + skip_count) + return 0; + stream->pos += sizeof(*skip_buffer) * skip_count; + } + + return (unsigned long)fread(buffer, sizeof(*buffer), count, file); +} + +static void +streamClose(FT_Stream stream) { + fclose(STREAM_FILE(stream)); + stream->descriptor.pointer = NULL; + stream->size = 0; +} + int readFile(char *filename, FontPtr font) { int j, k, index; int rc; + FT_Open_Args input = { 0 }; FT_Face face; StrikePtr strike; BitmapPtr bitmap; int symbol = 0; + int force_unicode = 1; char *encoding_name = NULL; FontMapPtr mapping = NULL; FontMapReversePtr reverse = NULL; @@ -73,12 +111,38 @@ readFile(char *filename, FontPtr font) if(rc != 0) return rc; - rc = FT_New_Face(ft_library, filename, 0, &face); + if(filename != NULL) { + input.pathname = filename; + input.flags = FT_OPEN_PATHNAME; + } else { + input.flags = FT_OPEN_STREAM | FT_OPEN_DRIVER; + input.driver = FT_Get_Module(ft_library, "bdf"); + input.stream = calloc(1, sizeof(FT_StreamRec)); + if(input.stream == NULL) + return -1; + + input.stream->size = 0x7FFFFFFF; + input.stream->descriptor.pointer = stdin; + input.stream->read = forwardRead; + input.stream->close = streamClose; + } + rc = FT_Open_Face(ft_library, &input, 0, &face); if(rc != 0) { - fprintf(stderr, "Couldn't open face %s.\n", filename); + fprintf(stderr, "Couldn't open face %s.\n", + filename ? filename : "<stdin>"); return -1; } + /* FreeType will insist on encodings which are simple subsets of unicode + * to be read as unicode regardless of what we call them. */ + for(j = 0; j < face->num_charmaps; ++j) { + if((face->charmaps[j]->encoding == ft_encoding_none) || + (face->charmaps[j]->encoding == ft_encoding_adobe_standard)) { + force_unicode = 0; + break; + } + } + encoding_name = faceEncoding(face); if(encoding_name == NULL) { symbol = 1; @@ -99,8 +163,8 @@ readFile(char *filename, FontPtr font) if(verbose_flag) { fprintf(stderr, "%s %s %s: %d sizes%s\n", - filename, face->family_name, face->style_name, - face->num_fixed_sizes, + filename ? filename : "<stdin>", + face->family_name, face->style_name, face->num_fixed_sizes, symbol ? " (symbol)" : ""); } @@ -185,7 +249,7 @@ readFile(char *filename, FontPtr font) font->names[i].size = 2 * strlen(XVENDORNAMESHORT " converted bitmap font"); font->names[i].value = makeUTF16(XVENDORNAMESHORT - "X converted bitmap font"); + " converted bitmap font"); i++; #ifdef __VENDORWEBSUPPORT__ font->names[i].nid = 11; @@ -225,10 +289,16 @@ readFile(char *filename, FontPtr font) return -1; } - if(!symbol && !mapping) + if((!symbol && !mapping) || force_unicode) { rc = FT_Select_Charmap(face, ft_encoding_unicode); - else + } else { rc = FT_Select_Charmap(face, ft_encoding_none); + if(rc != 0) { + /* BDF will default to Adobe Standard even for nonstandard + * encodings, so try that as a last resort. */ + rc = FT_Select_Charmap(face, ft_encoding_adobe_standard); + } + } if(rc != 0) { fprintf(stderr, "Couldn't select character map: %x.\n", rc); return -1; @@ -238,20 +308,20 @@ readFile(char *filename, FontPtr font) if(verbose_flag) fprintf(stderr, "size %d: %dx%d\n", i, - (int)(face->available_sizes[i].x_ppem >> 6), - (int)(face->available_sizes[i].y_ppem >> 6)); + (int)((face->available_sizes[i].x_ppem + 32) >> 6), + (int)((face->available_sizes[i].y_ppem + 32) >> 6)); rc = FT_Set_Pixel_Sizes(face, - face->available_sizes[i].x_ppem >> 6, - face->available_sizes[i].y_ppem >> 6); + (face->available_sizes[i].x_ppem + 32) >> 6, + (face->available_sizes[i].y_ppem + 32) >> 6); if(rc != 0) { fprintf(stderr, "Couldn't set size.\n"); return -1; } strike = makeStrike(font, - face->available_sizes[i].x_ppem >> 6, - face->available_sizes[i].y_ppem >> 6); + (face->available_sizes[i].x_ppem + 32) >> 6, + (face->available_sizes[i].y_ppem + 32) >> 6); if(strike == NULL) { fprintf(stderr, "Couldn't allocate strike.\n"); return -1; @@ -292,6 +362,7 @@ readFile(char *filename, FontPtr font) } FT_Done_Face(face); + free(input.stream); j = 0; for(int i = 0; i < FONT_CODES; i++) { diff --git a/app/fonttosfnt/struct.c b/app/fonttosfnt/struct.c index c0a3adda3..294f498c1 100644 --- a/app/fonttosfnt/struct.c +++ b/app/fonttosfnt/struct.c @@ -491,8 +491,8 @@ fontMetrics(FontPtr font, { int i, rc; int max_awidth = 0; - int min_x = 10000 << 16, min_y = 10000 << 16; - int max_x = -10000 << 16, max_y = -10000 << 16; + int min_x = 10000 * 65536, min_y = 10000 * 65536; + int max_x = -10000 * 65536, max_y = -10000 * 65536; for(i = 0; i < FONT_CODES; i++) { int awidth, x0, y0, x1, y1; rc = glyphMetrics(font, i, &awidth, &x0, &y0, &x1, &y1); diff --git a/app/fonttosfnt/util.c b/app/fonttosfnt/util.c index 81c0489b9..bcbfa2f5b 100644 --- a/app/fonttosfnt/util.c +++ b/app/fonttosfnt/util.c @@ -37,6 +37,7 @@ THE SOFTWARE. #include FT_FREETYPE_H #include FT_BDF_H #include "X11/Xos.h" +#include "X11/Xfuncproto.h" /* for _X_ATTRIBUTE_PRINTF */ #include "fonttosfnt.h" #ifdef NEED_SNPRINTF @@ -80,6 +81,7 @@ sprintf_alloc(const char *f, ...) } #if HAVE_VASPRINTF +_X_ATTRIBUTE_PRINTF(1, 0) char* vsprintf_alloc(const char *f, va_list args) { @@ -92,6 +94,7 @@ vsprintf_alloc(const char *f, va_list args) return r; } #else +_X_ATTRIBUTE_PRINTF(1, 0) char* vsprintf_alloc(const char *f, va_list args) { @@ -124,7 +127,7 @@ vsprintf_alloc(const char *f, va_list args) } #endif -/* Build a UTF-16 string from a Latin-1 string. +/* Build a UTF-16 string from a Latin-1 string. Result is not NUL-terminated. */ char * makeUTF16(const char *string) @@ -238,7 +241,7 @@ faceFoundry(FT_Face face) BDF_PropertyRec prop; rc = FT_Get_BDF_Property(face, "FOUNDRY", &prop); - if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) { + if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom) { if(strcasecmp(prop.u.atom, "adobe") == 0) return makeName("ADBE"); else if(strcasecmp(prop.u.atom, "agfa") == 0) @@ -283,7 +286,7 @@ faceFoundry(FT_Face face) /* For now */ return makeName("UNKN"); } - + int faceWeight(FT_Face face) @@ -291,7 +294,7 @@ faceWeight(FT_Face face) int rc; BDF_PropertyRec prop; rc = FT_Get_BDF_Property(face, "WEIGHT_NAME", &prop); - if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) { + if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom) { if(strcasecmp(prop.u.atom, "thin") == 0) return 100; else if(strcasecmp(prop.u.atom, "extralight") == 0) @@ -320,7 +323,7 @@ faceWidth(FT_Face face) int rc; BDF_PropertyRec prop; rc = FT_Get_BDF_Property(face, "SETWIDTH_NAME", &prop); - if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) { + if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom) { if(strcasecmp(prop.u.atom, "ultracondensed") == 0) return 1; else if(strcasecmp(prop.u.atom, "extracondensed") == 0) @@ -357,7 +360,7 @@ faceItalicAngle(FT_Face face) } rc = FT_Get_BDF_Property(face, "SLANT", &prop); - if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) { + if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom) { if(strcasecmp(prop.u.atom, "i") == 0 || strcasecmp(prop.u.atom, "s") == 0) return -30 * TWO_SIXTEENTH; @@ -377,7 +380,7 @@ faceFlags(FT_Face face) if(faceWeight(face) >= 650) flags |= FACE_BOLD; rc = FT_Get_BDF_Property(face, "SLANT", &prop); - if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) { + if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM && prop.u.atom) { if(strcasecmp(prop.u.atom, "i") == 0 || strcasecmp(prop.u.atom, "s") == 0) flags |= FACE_ITALIC; @@ -397,10 +400,12 @@ faceEncoding(FT_Face face) rc = FT_Get_BDF_Property(face, "CHARSET_ENCODING", &p2); if(rc != 0 || p2.type != BDF_PROPERTY_TYPE_ATOM) return NULL; + if(!(p1.u.atom && p2.u.atom)) + return NULL; return sprintf_alloc("%s-%s", p1.u.atom, p2.u.atom); } - + int degreesToFraction(int deg, int *num, int *den) { |