[Pkg-fonts-devel] Bug#460945: ttf-sil-abyssinica: PLease strip the Latin range from the font in the udeb

Christian Perrier bubulle at debian.org
Tue Jan 15 19:44:36 UTC 2008


Package: ttf-sil-abyssinica
Version: 1.0-3
Severity: normal
Tags: patch

The D-I team wishes to keep extra fonts as small as possible. Therefore, we
decided to strip out the range of Latin characters from the fonts we need to
have in order to support more languages.

The attached patch will strip the Latin characters range out of the font, in
the udeb package only. It saves several dozens of kb for D-I.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages ttf-sil-abyssinica depends on:
ii  defoma                       0.11.10-0.1 Debian Font Manager -- automatic f

ttf-sil-abyssinica recommends no packages.

-- no debconf information
-------------- next part --------------
diff -Nru ttf-sil-abyssinica-1.0/debian/rules ttf-sil-abyssinica-1.0.new/debian/rules
--- ttf-sil-abyssinica-1.0/debian/rules	2008-01-08 18:46:45.299346188 +0100
+++ ttf-sil-abyssinica-1.0.new/debian/rules	2008-01-09 18:16:52.036547417 +0100
@@ -3,11 +3,17 @@
 build: build-stamp
 build-stamp:
 	touch build-stamp
+	chmod u+x debian/scripts/strip
+	chmod u+x debian/scripts/strip_glyphs.pe
+	# Strip the fonts for the udeb
+	mkdir TTF-stripped
+	debian/scripts/strip Abyssinica_SIL.ttf TTF-stripped/Abyssinica_SIL.ttf
 
 clean:
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp
+	rm -rf TTF-stripped
 	dh_clean
 
 install: build
diff -Nru ttf-sil-abyssinica-1.0/debian/rules~ ttf-sil-abyssinica-1.0.new/debian/rules~
--- ttf-sil-abyssinica-1.0/debian/rules~	1970-01-01 01:00:00.000000000 +0100
+++ ttf-sil-abyssinica-1.0.new/debian/rules~	2008-01-08 18:53:18.790315687 +0100
@@ -0,0 +1,44 @@
+#!/usr/bin/make -f
+
+build: build-stamp
+build-stamp:
+	touch build-stamp
+	chmod u+x debian/scripts/strip
+	chmod u+x debian/scripts/strip_glyphs.pe
+	# Strip the fonts for the udeb
+	mkdir TTF-stripped
+	debian/scripts/strip Abyssinica_SIL.ttf TTF-stripped/Abyssinica_SIL.ttf
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+	-rm -rf TTF-stripped
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_install
+	chmod 755 debian/bug/script
+
+
+binary-arch:
+
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs FONTLOG.txt
+	dh_installdocs
+	dh_compress
+	dh_installdefoma
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+
+.PHONY: build clean install binary-arch binary-indep binary
diff -Nru ttf-sil-abyssinica-1.0/debian/scripts/README.strip_glyphs ttf-sil-abyssinica-1.0.new/debian/scripts/README.strip_glyphs
--- ttf-sil-abyssinica-1.0/debian/scripts/README.strip_glyphs	1970-01-01 01:00:00.000000000 +0100
+++ ttf-sil-abyssinica-1.0.new/debian/scripts/README.strip_glyphs	2008-01-07 18:47:41.145527589 +0100
@@ -0,0 +1,18 @@
+strip_glyphs.pe is a fontforge script (syntax is documented at
+http://fontforge.sourceforge.net/scripting.html)
+
+Usage: "strip_glyphs.pe in out glyphs"
+
+It strips glyphs out of a font file; glyphs can be ranges
+or single code points.
+Code points can be expressed as integers or in unicode notation (i.e
+"u215") and ranges are separated by ":".
+
+As a practical example, this commands were used to eliminate
+Arabic glyphs from the freefont package:
+
+./strip_glyphs.pe FreeSerif.ttf FreeSerif_strip.ttf u60c:u6d4 ufb50:ufefe
+./strip_glyphs.pe FreeSansBold.ttf FreeSansBold_strip.ttf u617:u633
+
+Note that "in" and "out" can be the same file; in that case, obviously,
+"in" gets overwritten.
diff -Nru ttf-sil-abyssinica-1.0/debian/scripts/strip ttf-sil-abyssinica-1.0.new/debian/scripts/strip
--- ttf-sil-abyssinica-1.0/debian/scripts/strip	1970-01-01 01:00:00.000000000 +0100
+++ ttf-sil-abyssinica-1.0.new/debian/scripts/strip	2008-01-08 07:21:35.559513778 +0100
@@ -0,0 +1,54 @@
+#! /bin/bash
+
+exepath=$(dirname $0)
+strip=$exepath/strip_glyphs.pe
+
+if [ $# -ne 2 ] ; then
+	echo "Usage: $(basename $0) fontfile_in fontfile_out"
+	exit 0
+fi
+
+if [ ! -x "$strip" ] ; then
+	echo "Script not found: $strip"
+	exit 1
+fi
+
+if [ ! -f "$1" ] ; then
+	echo "File does not exist: $1"
+	exit 1
+fi
+if [ -z "$2" ] ; then
+	echo "You need to specify the output file"
+	exit 1
+fi
+
+ranges=""
+ranges="$ranges u0021:u02AF" # latin
+ranges="$ranges u0370:u03FF" # Greek and Coptic
+ranges="$ranges u0400:u052F" # Cyrilic
+ranges="$ranges u0530:u058F" # Armenian
+ranges="$ranges u0590:u05FF" # Hebrew
+ranges="$ranges uFB1D:uFB4F" # Hebrew 2
+ranges="$ranges u0600:u06FF" # Arabic
+ranges="$ranges u0700:u077F" # Syriac
+ranges="$ranges u0b00:u0b7f" # Oriya
+ranges="$ranges u0b80:u0bff" # Tamil
+#ranges="$ranges u0900:u097F" # Hindi
+#ranges="$ranges u0980:u099F" # Bengali
+#ranges="$ranges u0A00:u0CFF" # Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada
+ranges="$ranges u0D00:u0FFF" # Malayalam, Sinhala, Thai, Lao, Tibetan
+ranges="$ranges u10A0:u10FF" # Georgian
+ranges="$ranges u1EA0:u1EFF" # Vietnamese
+ranges="$ranges u1F00:u1FFF" # Greek Extended
+ranges="$ranges u2070:u209F" # Superscripts and Subscripts
+ranges="$ranges u2100:u21FF" # Letterlike, Number forms, Arrows
+ranges="$ranges u2200:u24FF" # Mathematical, Techical, Control, OCR
+ranges="$ranges u2580:u259F" # Block elements
+ranges="$ranges u2600:u26FF" # Miscellaneous Symbols
+ranges="$ranges u2700:u27BF" # Dingbats
+ranges="$ranges u3000:u30FF" # CJK Symbols and Punctuation
+#if ! echo $1 | grep -q Bold; then
+#      ranges="$ranges 65536:66002"   # Bengali conjuncts
+#fi
+
+$strip $1 $2 $ranges
diff -Nru ttf-sil-abyssinica-1.0/debian/scripts/strip_glyphs.pe ttf-sil-abyssinica-1.0.new/debian/scripts/strip_glyphs.pe
--- ttf-sil-abyssinica-1.0/debian/scripts/strip_glyphs.pe	1970-01-01 01:00:00.000000000 +0100
+++ ttf-sil-abyssinica-1.0.new/debian/scripts/strip_glyphs.pe	2008-01-07 18:47:41.145527589 +0100
@@ -0,0 +1,81 @@
+#! /usr/bin/fontforge 
+#
+#     Copyright (C) 2005 Davide Viti <zinosat at tiscali.it>
+#
+#     This program is free software; you can redistribute it and/or modify
+#     it under the terms of the GNU General Public License as published by
+#     the Free Software Foundation; either version 2 of the License, or
+#     (at your option) any later version.
+#
+#     This program is distributed in the hope that it will be useful,
+#     but WITHOUT ANY WARRANTY; without even the implied warranty of
+#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#     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, write to the Free
+#     Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+#     MA 02111-1307 USA
+#
+# "glyphs_to_remove" argument can be a single code point
+# or a range of codepoints separated by ":"
+#
+# code points can be specified both as integers and as unicode
+# you can also mix the two formats (i.e "48:u54")
+#
+# example: 
+#
+#      "strip_glyphs in.ttf out.ttf 12 u20 100:150 u200:u230 u300:65000"
+
+if ($argc < 4)
+   Print( "Usage: strip_glyphs in out glyphs_to_remove..." )
+   Quit()
+endif
+
+
+Open($1); shift
+Reencode("unicode")
+out = $1; shift
+
+#
+# Loop through the arguments and select the glyphs
+# which need to be cleared
+#
+while ($argc > 1)
+  len = Strlen($1)
+  colon_idx = Strstr($1, ":")
+
+  #  
+  # argument is a single glyph
+  #
+  if (colon_idx == -1)
+    if(Strstr($1, "u") == -1)
+       SelectMore(Strtol($1)) ## Integer
+    else
+       SelectMore($1) ## Unicode code point (i.e "u0027")
+    endif
+
+  #  
+  # argument is a range low:high
+  #
+  else      
+     low = Strsub($1, 0, colon_idx)
+     if(Strstr($1, "u") == -1)
+        low = Strtol(low) ## Integer
+     endif
+
+     high = Strsub($1, colon_idx+1, len)
+     if(Strstr($1, "u") == -1)
+        high = Strtol(high) ## Integer
+     endif
+   
+     SelectMore(low, high);
+  endif
+
+  shift
+endloop
+
+Clear()
+
+Generate(out, "")
+Quit()
diff -Nru ttf-sil-abyssinica-1.0/debian/ttf-sil-abyssinica-udeb.install ttf-sil-abyssinica-1.0.new/debian/ttf-sil-abyssinica-udeb.install
--- ttf-sil-abyssinica-1.0/debian/ttf-sil-abyssinica-udeb.install	2008-01-08 18:46:45.299346188 +0100
+++ ttf-sil-abyssinica-1.0.new/debian/ttf-sil-abyssinica-udeb.install	2008-01-08 07:19:38.065666900 +0100
@@ -1 +1 @@
-Abyssinica_SIL.ttf usr/share/fonts/truetype/ttf-sil-abyssinica
+TTF-stripped/Abyssinica_SIL.ttf usr/share/fonts/truetype/ttf-sil-abyssinica


More information about the Pkg-fonts-devel mailing list