Hello community,

here is the log from the commit of package ttf-converter for openSUSE:Factory 
checked in at 2020-06-23 20:59:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ttf-converter (Old)
 and      /work/SRC/openSUSE:Factory/.ttf-converter.new.2956 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ttf-converter"

Tue Jun 23 20:59:49 2020 rev:2 rq:816307 version:1.0.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/ttf-converter/ttf-converter.changes      
2020-04-21 13:37:43.887966577 +0200
+++ /work/SRC/openSUSE:Factory/.ttf-converter.new.2956/ttf-converter.changes    
2020-06-23 20:59:50.748915770 +0200
@@ -1,0 +2,25 @@
+Mon Jun 22 09:54:07 UTC 2020 - [email protected]
+
+- Update to version 1.0.3:
+  * Bump version to 1.0.3
+  * Add a --force-monospaced argument instead of hardcoding
+    font names
+  * Fix print format
+  * Convert `BoldCond` subfamily to `Bold Condensed`
+
+-------------------------------------------------------------------
+Fri Jun 19 16:25:09 UTC 2020 - Antonio Larrosa <[email protected]>
+
+- Update to 1.0.2 (boo#1169444 #c41)
+  * Fixes for Monospaced fonts and force the Nimbus Mono L font
+    to be Monospaced
+  * Add a --version argument
+
+-------------------------------------------------------------------
+Fri Jun 19 11:25:07 UTC 2020 - Antonio Larrosa <[email protected]>
+
+- Update to 1.0.1 (boo#1169444 #c41)
+  * Fix subfamily names so the converted font's subfamily match
+    the original ones
+
+-------------------------------------------------------------------

Old:
----
  ttf-converter-1.0.tar.xz

New:
----
  ttf-converter-1.0.3.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ttf-converter.spec ++++++
--- /var/tmp/diff_new_pack.Lzd5aq/_old  2020-06-23 20:59:59.312944662 +0200
+++ /var/tmp/diff_new_pack.Lzd5aq/_new  2020-06-23 20:59:59.312944662 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           ttf-converter
-Version:        1.0
+Version:        1.0.3
 Release:        0
 Summary:        Python script that converts fonts to TrueType format
 License:        GPL-3.0-only

++++++ _service ++++++
--- /var/tmp/diff_new_pack.Lzd5aq/_old  2020-06-23 20:59:59.356944810 +0200
+++ /var/tmp/diff_new_pack.Lzd5aq/_new  2020-06-23 20:59:59.356944810 +0200
@@ -2,7 +2,7 @@
   <service name="tar_scm" mode="disabled">
     <param name="url">https://github.com/antlarr-suse/ttf-converter</param>
     <param name="filename">ttf-converter</param>
-    <param name="version">1.0</param>
+    <param name="version">1.0.3</param>
     <param name="scm">git</param>
     <param name="changesgenerate">enable</param>
   </service>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.Lzd5aq/_old  2020-06-23 20:59:59.376944878 +0200
+++ /var/tmp/diff_new_pack.Lzd5aq/_new  2020-06-23 20:59:59.380944891 +0200
@@ -1,4 +1,4 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/antlarr-suse/ttf-converter</param>
-              <param 
name="changesrevision">a2540b89cabccd914f70d2f3902ac7f3a6467b2d</param></service></servicedata>
\ No newline at end of file
+              <param 
name="changesrevision">6ec51ca498265a020d1d66f1e7b1ba32b9ee4ea7</param></service></servicedata>
\ No newline at end of file

++++++ ttf-converter-1.0.tar.xz -> ttf-converter-1.0.3.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ttf-converter-1.0/ttf-converter 
new/ttf-converter-1.0.3/ttf-converter
--- old/ttf-converter-1.0/ttf-converter 2020-04-20 09:37:21.000000000 +0200
+++ new/ttf-converter-1.0.3/ttf-converter       2020-06-22 11:52:52.000000000 
+0200
@@ -23,6 +23,7 @@
 import os.path
 import argparse
 import math
+import psMat
 from glob import glob
 
 
@@ -127,7 +128,91 @@
     return True
 
 
-def convert_font(input_filename, output_filename=None, output_dir='.'):
+def fix_subfamily(font):
+    sfnt_names = list(font.sfnt_names)
+    subfamily_index = [x[1] for x in sfnt_names].index('SubFamily')
+    translations = {'BoldCond': 'Bold Condensed',
+                    'BoldCondItal': 'Bold Condensed Italic',
+                    'BoldItal': 'Bold Italic',
+                    'BoldItalic': 'Bold Italic',
+                    'BoldOblique': 'Bold Oblique',
+                    'BookObli': 'Book Oblique',
+                    'DemiObli': 'Demi Oblique',
+                    'DemiBold': 'Demi Bold',
+                    'DemiBoldItal': 'Demi Bold Italic',
+                    'LighItal': 'Light Italic',
+                    'MediItal': 'Medium Italic',
+                    'ReguCond': 'Regular Condensed',
+                    'ReguCondItal': 'Regular Condensed Italic',
+                    'ReguItal': 'Regular Italic',
+                    'ReguObli': 'Regular Oblique',
+                    'StandardSymL': 'Regular'}
+    # The last one is for the Standard Symbols L font
+
+    try:
+        new_value = translations[sfnt_names[subfamily_index][2]]
+    except KeyError:
+        # Nothing to fix
+        return
+
+    print(f'Fixing subfamily: Renaming {sfnt_names[subfamily_index][2]} '
+          f'to {new_value}.')
+    sfnt_names[subfamily_index] = (sfnt_names[subfamily_index][0:2] +
+                                   (new_value,))
+    font.sfnt_names = tuple(sfnt_names)
+
+
+def fix_monospaced_font(font):
+    glyphs = list(font.glyphs())
+    max_width = max(x.width for x in glyphs)
+    wrong_width_glyphs = [x for x in glyphs if x.width != max_width]
+    wrong_width_count = len(wrong_width_glyphs)
+
+    if wrong_width_count == 0:
+        print('This is a Monospaced font.')
+    else:
+        bad_glyph = wrong_width_glyphs[0]
+        if (wrong_width_count == 1 and
+            bad_glyph.unicode == -1 and
+                bad_glyph.glyphname == '.null'):
+            print('This is a Monospaced font with a .null bad glyph. '
+                  'Fixing...')
+            font.removeGlyph(bad_glyph)
+        else:
+            if wrong_width_count <= 5:
+                print('This is a Monospaced font except for '
+                      f'{wrong_width_count} glyphs:')
+                for glyph in wrong_width_glyphs:
+                    print(f'{glyph.glyphname} ({glyph.unicode}): '
+                          '{glyph.width}')
+
+
+def force_monospaced_font(font):
+    glyphs = list(font.glyphs())
+    widths = [x.width for x in glyphs]
+    width = max(set(widths), key=widths.count)
+
+    try:
+        _null = [x for x in glyphs if x.glyphname == '.null'][0]
+    except IndexError:
+        _null = font.createChar(-1, '.null')
+        _null.width = width
+    glyphs = list(font.glyphs())
+    for idx, glyph in enumerate(glyphs):
+        if glyph.glyphname in ('.notdef', '.null', 'nonmarkingreturn'):
+            glyph.width = width
+            continue
+        if glyph.width == width:
+            print(f'Width of {glyph.glyphname} is ok')
+            continue
+        print(f'Fixing width of {glyph.glyphname} from {glyph.width} to ',
+              end='')
+        glyph.transform(psMat.scale(width/glyph.width))
+        print(f'{glyph.width}... done')
+
+
+def convert_font(input_filename, output_filename=None, output_dir='.',
+                 force_monospaced=False):
     font = fontforge.open(input_filename)
 
     if not output_filename:
@@ -140,6 +225,13 @@
 
     fix_font(font)
 
+    fix_subfamily(font)
+
+    if force_monospaced:
+        force_monospaced_font(font)
+    else:
+        fix_monospaced_font(font)
+
     font.generate(output_filename, flags=("opentype",))
 
     print('ok')
@@ -159,10 +251,16 @@
                         help='Output directory for generated files')
     parser.add_argument('input_files', nargs='*', default=[],
                         help='Input files')
+    parser.add_argument('--force-monospaced', action="store_true",
+                        help='Force the output font to be monospaced by '
+                        'resizing glyphs if needed')
+    parser.add_argument('--version', action='version',
+                        version='%(prog)s 1.0.3')
 
     args = parser.parse_args()
 
     input_files = set(args.input_files)
+    force_monospaced = args.force_monospaced
     if args.input_dir:
         input_files.update(get_input_files_from_directory(args.input_dir))
 
@@ -178,7 +276,8 @@
         print('--------')
         try:
             convert_font(input_file,
-                         output_dir=args.output_dir)
+                         output_dir=args.output_dir,
+                         force_monospaced=force_monospaced)
         except SkipFont:
             print(f'Skipping font {input_file}')
             skipped_filenames.append(input_file)


Reply via email to