#1 Include some patch from upstream merge requests
Closed 4 years ago by pwu. Opened 4 years ago by pwu.
rpms/ pwu/xorg-x11-font-utils fonttosfnt  into  master

@@ -0,0 +1,37 @@ 

+ commit 36db49ad1c39ecd950d151540181284ee61b9d86

+ Author: Peng Wu <alexepico@gmail.com>

+ Date:   Wed Oct 9 14:20:22 2019 +0800

+ 

+     Improve guess font size when read bitmap font

+ 

+ diff --git a/read.c b/read.c

+ index 85c7f00..ddd341d 100644

+ --- a/read.c

+ +++ b/read.c

+ @@ -304,20 +304,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;

@@ -0,0 +1,670 @@ 

+ From ec6f334152badff475d2a8c465dfdbf740f148d0 Mon Sep 17 00:00:00 2001

+ From: Peter Hutterer <peter.hutterer@who-t.net>

+ Date: Wed, 31 Oct 2018 14:37:24 +1000

+ Subject: [PATCH app/fonttosfnt 01/10] Mark vsprintf_alloc as printf-like

+  function

+ 

+ Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

+ Reviewed-by: Eric Anholt <eric@anholt.net>

+ ---

+  util.c | 3 +++

+  1 file changed, 3 insertions(+)

+ 

+ diff --git a/util.c b/util.c

+ index 81c0489..5a23eeb 100644

+ --- a/util.c

+ +++ b/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)

+  {

+ -- 

+ 2.21.0

+ 

+ 

+ From 46d4900c2dbed1c7a632dc34a4ef952a9cdda8eb Mon Sep 17 00:00:00 2001

+ From: Alan Coopersmith <alan.coopersmith@oracle.com>

+ Date: Fri, 16 Nov 2018 19:53:06 -0800

+ Subject: [PATCH app/fonttosfnt 02/10] Update README for gitlab migration

+ 

+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

+ ---

+  Makefile.am |  2 ++

+  README      | 24 ------------------------

+  README.md   | 16 ++++++++++++++++

+  3 files changed, 18 insertions(+), 24 deletions(-)

+  delete mode 100644 README

+  create mode 100644 README.md

+ 

+ diff --git a/Makefile.am b/Makefile.am

+ index 29169b1..23446b4 100644

+ --- a/Makefile.am

+ +++ b/Makefile.am

+ @@ -49,3 +49,5 @@ ChangeLog:

+  	$(CHANGELOG_CMD)

+  

+  dist-hook: ChangeLog INSTALL

+ +

+ +EXTRA_DIST = README.md

+ diff --git a/README b/README

+ deleted file mode 100644

+ index fa3ad08..0000000

+ --- a/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/README.md b/README.md

+ new file mode 100644

+ index 0000000..c47925b

+ --- /dev/null

+ +++ b/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

+ +

+ -- 

+ 2.21.0

+ 

+ 

+ From 8e34a2aa7c4dea5aa07dc08a40dacd90e2148a89 Mon Sep 17 00:00:00 2001

+ From: Alan Coopersmith <alan.coopersmith@oracle.com>

+ Date: Wed, 21 Nov 2018 16:46:19 -0800

+ Subject: [PATCH app/fonttosfnt 03/10] Update configure.ac bug URL for gitlab

+  migration

+ 

+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

+ ---

+  configure.ac | 2 +-

+  1 file changed, 1 insertion(+), 1 deletion(-)

+ 

+ diff --git a/configure.ac b/configure.ac

+ index d5e9610..6ba1e7a 100644

+ --- a/configure.ac

+ +++ b/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.0.5], [https://gitlab.freedesktop.org/xorg/app/fonttosfnt/issues],fonttosfnt)

+  AC_CONFIG_SRCDIR([Makefile.am])

+  AC_CONFIG_HEADERS([config.h])

+  

+ -- 

+ 2.21.0

+ 

+ 

+ From c214ab0d7deae30acdf90933ed14b223118dcf67 Mon Sep 17 00:00:00 2001

+ From: Maya Rashish <maya@NetBSD.org>

+ Date: Thu, 10 Jan 2019 20:49:28 +0200

+ Subject: [PATCH app/fonttosfnt 04/10] Avoid undefined behaviour

+ 

+ Left shifting a negative is undefined.

+ For consistency, use the equivalent form of multiplication for the

+ positive numbers as well.

+ ---

+  struct.c | 4 ++--

+  1 file changed, 2 insertions(+), 2 deletions(-)

+ 

+ diff --git a/struct.c b/struct.c

+ index c0a3add..294f498 100644

+ --- a/struct.c

+ +++ b/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);

+ -- 

+ 2.21.0

+ 

+ 

+ From 6fc84fb2c0d4ac0b3b66330057bb90418cc1eb28 Mon Sep 17 00:00:00 2001

+ From: Ryan Farley <ryan.farley@gmx.com>

+ Date: Fri, 30 Aug 2019 09:43:50 -0500

+ Subject: [PATCH app/fonttosfnt 05/10] 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

+ ---

+  util.c | 18 ++++++++++--------

+  1 file changed, 10 insertions(+), 8 deletions(-)

+ 

+ diff --git a/util.c b/util.c

+ index 5a23eeb..bcbfa2f 100644

+ --- a/util.c

+ +++ b/util.c

+ @@ -127,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)

+ @@ -241,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)

+ @@ -286,7 +286,7 @@ faceFoundry(FT_Face face)

+      /* For now */

+      return makeName("UNKN");

+  }

+ -    

+ +

+  

+  int

+  faceWeight(FT_Face face)

+ @@ -294,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)

+ @@ -323,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)

+ @@ -360,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;

+ @@ -380,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;

+ @@ -400,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)

+  {

+ -- 

+ 2.21.0

+ 

+ 

+ From 5f6f3a2a6baf9a1e4053fc9130a8bf47ca49222d Mon Sep 17 00:00:00 2001

+ From: Ryan Farley <ryan.farley@gmx.com>

+ Date: Tue, 20 Aug 2019 03:16:22 -0500

+ Subject: [PATCH app/fonttosfnt 06/10] 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.

+ ---

+  read.c | 5 ++++-

+  1 file changed, 4 insertions(+), 1 deletion(-)

+ 

+ diff --git a/read.c b/read.c

+ index 632c7e7..5e80cc5 100644

+ --- a/read.c

+ +++ b/read.c

+ @@ -79,10 +79,13 @@ readFile(char *filename, FontPtr font)

+          return -1;

+      }

+  

+ +    /* FreeType will handle Unicode and automatically map ISO-8859-1 to

+ +     * Unicode for us -- everything else needs a mapping */

+      encoding_name = faceEncoding(face);

+      if(encoding_name == NULL) {

+          symbol = 1;

+ -    } else if(strcasecmp(encoding_name, "iso10646-1") != 0) {

+ +    } else if((strcasecmp(encoding_name, "iso10646-1") != 0) &&

+ +              (strcasecmp(encoding_name, "iso8859-1") != 0)) {

+          if(reencode_flag)

+              mapping = FontEncMapFind(encoding_name,

+                                       FONT_ENCODING_UNICODE, 0, 0, NULL);

+ -- 

+ 2.21.0

+ 

+ 

+ From fc20e78df901d9c334de9ce8f34bb01ffd081fd5 Mon Sep 17 00:00:00 2001

+ From: Ryan Farley <ryan.farley@gmx.com>

+ Date: Sat, 31 Aug 2019 06:42:24 -0500

+ Subject: [PATCH app/fonttosfnt 07/10] 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.

+ ---

+  read.c | 26 ++++++++++++++++++++------

+  1 file changed, 20 insertions(+), 6 deletions(-)

+ 

+ diff --git a/read.c b/read.c

+ index 5e80cc5..05f7b4f 100644

+ --- a/read.c

+ +++ b/read.c

+ @@ -64,6 +64,7 @@ readFile(char *filename, FontPtr font)

+      StrikePtr strike;

+      BitmapPtr bitmap;

+      int symbol = 0;

+ +    int force_unicode = 1;

+      char *encoding_name = NULL;

+      FontMapPtr mapping = NULL;

+      FontMapReversePtr reverse = NULL;

+ @@ -79,13 +80,20 @@ readFile(char *filename, FontPtr font)

+          return -1;

+      }

+  

+ -    /* FreeType will handle Unicode and automatically map ISO-8859-1 to

+ -     * Unicode for us -- everything else needs a mapping */

+ +    /* 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;

+ -    } else if((strcasecmp(encoding_name, "iso10646-1") != 0) &&

+ -              (strcasecmp(encoding_name, "iso8859-1") != 0)) {

+ +    } else if(strcasecmp(encoding_name, "iso10646-1") != 0) {

+          if(reencode_flag)

+              mapping = FontEncMapFind(encoding_name,

+                                       FONT_ENCODING_UNICODE, 0, 0, NULL);

+ @@ -228,10 +236,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;

+ -- 

+ 2.21.0

+ 

+ 

+ From e7678eed438063033ae92d35be310c69eed9b601 Mon Sep 17 00:00:00 2001

+ From: Jouke Witteveen <j.witteveen@gmail.com>

+ Date: Fri, 2 Aug 2019 11:41:59 +0200

+ Subject: [PATCH app/fonttosfnt 08/10] Correct a string literal

+ 

+ Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com>

+ ---

+  read.c | 2 +-

+  1 file changed, 1 insertion(+), 1 deletion(-)

+ 

+ diff --git a/read.c b/read.c

+ index 05f7b4f..0fbb1b3 100644

+ --- a/read.c

+ +++ b/read.c

+ @@ -196,7 +196,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;

+ -- 

+ 2.21.0

+ 

+ 

+ From c9b14c6dc04ab738e83dbf9d692560d5e28420c4 Mon Sep 17 00:00:00 2001

+ From: Jouke Witteveen <j.witteveen@gmail.com>

+ Date: Fri, 2 Aug 2019 11:43:56 +0200

+ Subject: [PATCH app/fonttosfnt 09/10] Modernize defaults

+ 

+ The OTB (OpenType Bitmap) extension has found some traction, so suggest

+ that.

+ 

+ FreeType no longer has the bug that forced suboptimal defaults for the

+ generation of scalable glyphs.

+ 

+ Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com>

+ ---

+  fonttosfnt.c       |  4 ++--

+  man/fonttosfnt.man | 12 ++++++------

+  2 files changed, 8 insertions(+), 8 deletions(-)

+ 

+ diff --git a/fonttosfnt.c b/fonttosfnt.c

+ index 78c6b7e..55eb18e 100644

+ --- a/fonttosfnt.c

+ +++ b/fonttosfnt.c

+ @@ -29,7 +29,7 @@ THE SOFTWARE.

+  

+  int verbose_flag = 0;

+  int reencode_flag = 1;

+ -int glyph_flag = 2;

+ +int glyph_flag = 1;

+  int metrics_flag = 1;

+  int crop_flag = 1;

+  int bit_aligned_flag = 1;

+ @@ -39,7 +39,7 @@ usage(void)

+  {

+      fprintf(stderr, "Usage:\n");

+      fprintf(stderr, 

+ -            "fonttosfnt [ -v ] [ -c ] [ -b ] [ -r ] [ -g n ] [ -m n ] -o font.ttf "

+ +            "fonttosfnt [ -v ] [ -c ] [ -b ] [ -r ] [ -g n ] [ -m n ] -o font.otb "

+              "[ -- ] font ...\n");

+  }

+  

+ diff --git a/man/fonttosfnt.man b/man/fonttosfnt.man

+ index 4b05058..35ab974 100644

+ --- a/man/fonttosfnt.man

+ +++ b/man/fonttosfnt.man

+ @@ -1,14 +1,14 @@

+  .\" $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 \-\-

+  ]

+ @@ -40,13 +40,13 @@ Set the type of scalable glyphs that we write.  If

+  is 0, no scalable glyphs are written; this is legal but confuses

+  most current software.  If

+  .I n

+ -is 1, a single scalable glyph (the undefined glyph) is written; this

+ -is recommended, but triggers a bug in current versions of

+ +is 1 (the default), a single scalable glyph (the undefined glyph) is written;

+ +this triggers a bug in ancient versions of

+  .BR FreeType .

+  If

+  .I n

+ -is 2 (the default), a sufficiently high number of blank glyphs are

+ -written, which works with

+ +is 2, a sufficiently high number of blank glyphs are

+ +written, which works with all versions of

+  .B FreeType

+  but increases file size.

+  .TP

+ -- 

+ 2.21.0

+ 

+ 

+ From 3ba10f7635562a98c319d97392381e9542197863 Mon Sep 17 00:00:00 2001

+ From: Jouke Witteveen <j.witteveen@gmail.com>

+ Date: Fri, 2 Aug 2019 14:03:15 +0200

+ Subject: [PATCH app/fonttosfnt 10/10] Accept a BDF font on stdin

+ 

+ This makes it easier to transition from bdftopcf.

+ 

+ Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com>

+ ---

+  fonttosfnt.c       |  8 +++++--

+  man/fonttosfnt.man |  6 +++--

+  read.c             | 58 ++++++++++++++++++++++++++++++++++++++++++----

+  3 files changed, 64 insertions(+), 8 deletions(-)

+ 

+ diff --git a/fonttosfnt.c b/fonttosfnt.c

+ index 55eb18e..d8caad5 100644

+ --- a/fonttosfnt.c

+ +++ b/fonttosfnt.c

+ @@ -40,7 +40,7 @@ usage(void)

+      fprintf(stderr, "Usage:\n");

+      fprintf(stderr, 

+              "fonttosfnt [ -v ] [ -c ] [ -b ] [ -r ] [ -g n ] [ -m n ] -o font.otb "

+ -            "[ -- ] font ...\n");

+ +            "[ -- ] [ 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/man/fonttosfnt.man b/man/fonttosfnt.man

+ index 35ab974..b402efd 100644

+ --- a/man/fonttosfnt.man

+ +++ b/man/fonttosfnt.man

+ @@ -11,11 +11,13 @@ fonttosfnt \- Wrap a bitmap font in a sfnt (OpenType) wrapper

+  .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/read.c b/read.c

+ index 0fbb1b3..85c7f00 100644

+ --- a/read.c

+ +++ b/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,7 @@ 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 STREAM_FILE(stream) ((FILE*)stream->descriptor.pointer)

+  

+  static int ft_inited = 0;

+  static FT_Library ft_library;

+ @@ -55,11 +57,42 @@ FT_Ensure_Inited(void)

+      return 0;

+  }

+  

+ +static unsigned long

+ +forwardRead(FT_Stream stream, unsigned long offset, unsigned char* buffer,

+ +          unsigned long 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(stream->pos < offset) {

+ +        if(getc(file) < 0)

+ +            return 0;

+ +        stream->pos++;

+ +    }

+ +

+ +    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;

+ @@ -74,9 +107,25 @@ 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;

+      }

+  

+ @@ -110,8 +159,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)" : "");

+      }

+  

+ @@ -309,6 +358,7 @@ readFile(char *filename, FontPtr font)

+      }

+  

+      FT_Done_Face(face);

+ +    free(input.stream);

+  

+      j = 0;

+      for(int i = 0; i < FONT_CODES; i++) {

+ -- 

+ 2.21.0

+ 

file modified
+12 -1
@@ -11,7 +11,7 @@ 

  Name:       xorg-x11-font-utils

  Epoch:      1

  Version:    7.5

- Release:    42%{?dist}

+ Release:    43%{?dist}

  License:    MIT

  URL:        http://www.x.org

  
@@ -25,6 +25,8 @@ 

  Source6:    xorg-x11-fonts-update-dirs.1

  

  Patch0:     mkfontscale-examine-all-encodings.patch

+ Patch1:     fonttosfnt-merge-request.patch

+ Patch2:     fonttosfnt-improve-font-size.patch

  

  BuildRequires:  libtool

  BuildRequires:  pkgconfig(fontenc)
@@ -51,6 +53,10 @@ 

  pushd mkfontscale-*

  %patch0 -p1 -b .all-encodings

  popd

+ pushd fonttosfnt-*

+ %patch1 -p1 -b .merge-request

+ %patch2 -p1 -b .improve-size

+ popd

  

  %build

  # Build all apps
@@ -115,6 +121,11 @@ 

  %{_x11fontdir}/util/map-*

  

  %changelog

+ * Fri Sep 27 2019 Peng Wu <pwu@redhat.com> - 1:7.5-43

+ - Include some patch from upstream merge requests

+ - Add fonttosfnt-merge-request.patch

+ - Add fonttosfnt-improve-font-size.patch

+ 

  * Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:7.5-42

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

  

Add fonttosfnt-merge-request.patch
Add fonttosfnt-improve-font-size.patch

Currently we plan to convert bitmap fonts to OpenType font format
by fonttosfnt.

These patches help the font conversion.

Please review this pull request, thanks!

Thanks, I saw the update in Fedora 31.

Pull-Request has been closed by pwu

4 years ago