File 0010-Add-warnings-when-wrapping-multiple-fonts-and-on-PCF.patch of Package fonttosfnt.20912
From f860f76b4f3d5b7c604eafaea3460ca3ed2f23d1 Mon Sep 17 00:00:00 2001
From: Christopher Zimmermann <madroach@gmerlin.de>
Date: Sat, 18 Jul 2020 08:39:01 +0200
Subject: [PATCH 10/14] Add warnings when wrapping multiple fonts and on PCF
fonts
---
fonttosfnt.c | 6 ++++++
read.c | 12 +++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/fonttosfnt.c b/fonttosfnt.c
index 062ef3e..3d865d1 100644
--- a/fonttosfnt.c
+++ b/fonttosfnt.c
@@ -106,6 +106,12 @@ main(int argc, char **argv)
font = makeFont();
+ if(argc - i > 1)
+ fprintf(stderr,
+ "You are requesting to put more than one font into a single OpenType font.\n"
+ "This is not recommended. The global font metrics will not match every font face.\n"
+ "Rather create an OpenType font collection\n");
+
if(i == argc) {
rc = readFile(NULL, font);
if(rc != 0)
diff --git a/read.c b/read.c
index db79a59..67716a0 100644
--- a/read.c
+++ b/read.c
@@ -29,6 +29,7 @@ THE SOFTWARE.
#include FT_FREETYPE_H
#include FT_MODULE_H
#include FT_BDF_H
+#include FT_FONT_FORMATS_H
#include "X11/Xos.h"
#include "fonttosfnt.h"
#include "X11/fonts/fontenc.h"
@@ -102,7 +103,7 @@ readFile(char *filename, FontPtr font)
BitmapPtr bitmap;
int symbol = 0;
int force_unicode = 1;
- char *encoding_name = NULL;
+ const char *encoding_name, *file_format;
FontMapPtr mapping = NULL;
FontMapReversePtr reverse = NULL;
@@ -133,6 +134,15 @@ readFile(char *filename, FontPtr font)
return -1;
}
+ file_format = FT_Get_Font_Format(face);
+ if(strcmp(file_format, "BDF") != 0)
+ fprintf(stderr,
+ "font file %s is of %s format.\n"
+ "It's recommended to convert directly from a BDF font.\n"
+ "Some font properties may get lost when converting via a PCF font.\n",
+ filename ? filename : "<stdin>",
+ file_format);
+
/* 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) {
--
2.28.0