6665751 fonts.conf needs to be updated for Japanese IPAfont
authorAlan Coopersmith <Alan.Coopersmith@Sun.COM>
Thu, 21 Feb 2008 16:16:15 -0800
changeset 322 f924bf1395e5
parent 321 c1cb7591d690
child 323 19895a0cc743
6665751 fonts.conf needs to be updated for Japanese IPAfont
open-src/lib/fontconfig/fix-fonts.conf.pl
open-src/lib/fontconfig/fonts.conf.append
--- a/open-src/lib/fontconfig/fix-fonts.conf.pl	Thu Feb 21 14:38:58 2008 -0800
+++ b/open-src/lib/fontconfig/fix-fonts.conf.pl	Thu Feb 21 16:16:15 2008 -0800
@@ -1,6 +1,6 @@
 #!/usr/perl5/bin/perl -w
 #
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,13 +28,13 @@
 # or other dealings in this Software without prior written authorization
 # of the copyright holder.
 #
-# ident	"@(#)fix-fonts.conf.pl	1.8	07/09/14 SMI"
+# ident	"@(#)fix-fonts.conf.pl	1.9	08/02/21 SMI"
 #
 # This script performs a number of customizations to the fonts.conf shipped
 # with Solaris, including:
 #   - adding all the locale specific dirs listed in fontdirs file to the font path
 #   - append additional settings from fonts.conf.append file just before closing </fontdir>
-#   - Japanese customization requested in bug 5028919 - replace Kochi fonts with Sun fonts
+#   - Japanese customization requested in bugs 5028919 & 6665751
 
 
 require 5.005;                          # minimal Perl version required
@@ -52,6 +52,14 @@
 my $appended = 0;
 my $preuserconf = 0;
 
+# Prints a line with text substituted
+# Arguments: input line, text to replace, new text
+sub print_substitute_line {
+  my ($line, $oldtext, $newtext) = @_;
+  $line =~ s|$oldtext|$newtext|;
+  print $line;
+}
+
 while ($line = <>) {
   # keep track of if we're in an <alias>...</alias> block and if so which one
   if ($inalias == 0) {
@@ -73,13 +81,11 @@
 
     open(FONTDIRLIST, "<fontdirs") || die "Cannot open file fontdirs";
     while ($fontdir = <FONTDIRLIST>) {
-      $newline = $line;
       chomp($fontdir);
       # skip if line is blank or commented out
       next if ($fontdir =~ /^\s*$/);
       next if ($fontdir =~ /^\s*\#/);
-      $newline =~ s|--font-dirs-go-here--|$fontdir|;
-      print $newline;
+      print_substitute_line($line, '--font-dirs-go-here--', $fontdir);
     }
     close(FONTDIRLIST);
     $fontdirsreplaced++;
@@ -110,91 +116,68 @@
   # Replace Kochi Mincho fonts with Sun Mincho fonts
   # Add additional Sun CJK fonts
   if ($line =~ m|<family>Kochi Mincho</family>|) {
-    $newline = $line;
-    $newline =~ s|Kochi Mincho|HG-PMinchoL-Sun|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Mincho|HG-MinchoL-Sun|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Mincho|FZSongTi|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Mincho|FZMingTi|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Mincho|KacstQurn|;
-    print $newline;
-    $line =~ s|Kochi Mincho|SunDotum|;
+    print_substitute_line($line, 'Kochi Mincho', 'HG-PMinchoL-Sun');
+    print_substitute_line($line, 'Kochi Mincho', 'HG-MinchoL-Sun');
+    print_substitute_line($line, 'Kochi Mincho', 'IPAPMincho');
+    print_substitute_line($line, 'Kochi Mincho', 'IPAMincho');
+    print_substitute_line($line, 'Kochi Mincho', 'IPAGothic');
+    print_substitute_line($line, 'Kochi Mincho', 'FZSongTi');
+    print_substitute_line($line, 'Kochi Mincho', 'FZMingTi');
+    print_substitute_line($line, 'Kochi Mincho', 'KacstQurn');
+    print_substitute_line($line, 'Kochi Mincho', 'SunDotum');
     $kochifontsreplaced++;
-    # Fall through to print $line at end
+    next;
   }
   # Replace Kochi Gothic fonts with Sun Gothic fonts
   # Add additional Sun CJK fonts
   if ($line =~ m|<family>Kochi Gothic</family>|) {
-    $newline = $line;
     if ($aliasfamily ne "monospace") {
-        $newline =~ s|Kochi Gothic|HG-PGothicB-Sun|;
+      print_substitute_line($line, 'Kochi Gothic', 'HG-PGothicB-Sun');
+      print_substitute_line($line, 'Kochi Gothic', 'HG-GothicB-Sun');
+      print_substitute_line($line, 'Kochi Gothic', 'IPAPGothic');
+      print_substitute_line($line, 'Kochi Gothic', 'IPAGothic');
     } else {
-        $newline =~ s|Kochi Gothic|HG-GothicB-Sun|;
-    }
-    print $newline;
-    $newline = $line;
-    if ($aliasfamily ne "monospace") {
-        $newline =~ s|Kochi Gothic|HG-GothicB-Sun|;
-    } else {
-        $newline =~ s|Kochi Gothic|HG-MinchoL-Sun|;
+      print_substitute_line($line, 'Kochi Gothic', 'HG-GothicB-Sun');
+      print_substitute_line($line, 'Kochi Gothic', 'HG-MinchoL-Sun');
+      print_substitute_line($line, 'Kochi Gothic', 'IPAGothic');
+      print_substitute_line($line, 'Kochi Gothic', 'IPAMincho');
     }
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Gothic|FZSongTi|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Gothic|FZMingTi|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|Kochi Gothic|KacstQurn|;
-    print $newline;
+    print_substitute_line($line, 'Kochi Gothic', 'FZSongTi');
+    print_substitute_line($line, 'Kochi Gothic', 'FZMingTi');
+    print_substitute_line($line, 'Kochi Gothic', 'KacstQurn');
     if ($aliasfamily ne "monospace") {
-      $line =~ s|Kochi Gothic|SunDotum|;
+      print_substitute_line($line, 'Kochi Gothic', 'SunDotum');
     } else {
-      $line =~ s|Kochi Gothic|SunDotumChe|;
+      print_substitute_line($line, 'Kochi Gothic', 'SunDotumChe');
     }
     $kochifontsreplaced++;
-    # Fall through to print $line at end
+    next;
   }
   # Add additional entries to monospace faces list
   if ($line =~ m|<default><family>monospace</family></default>| ) {
-    $newline = $line;
-    $newline =~ s|<default><family>monospace</family></default>|<family>KacstQurn</family>|;
-    print $newline;
-    $newline = $line;
-    $newline =~ s|<default><family>monospace</family></default>|<family>SunDotumChe</family>|;
-    print $newline;
+    print_substitute_line($line, 
+			  '<default><family>monospace</family></default>',
+			  '<family>KacstQurn</family>');
+    print_substitute_line($line, 
+			  '<default><family>monospace</family></default>',
+			  '<family>SunDotumChe</family>');
   }
   # Add Arial before Bitstream Vera Sans
   if ($line =~ m|<family>Bitstream Vera Sans</family>| ) {
-    $newline = $line;
-    $newline =~ s|Bitstream Vera Sans|Arial|;
-    print $newline;
+    print_substitute_line($line, 'Bitstream Vera Sans', 'Arial');
   }
   # Add Lucida Bright before Bitstream Vera Serif
   if ($line =~ m|<family>Bitstream Vera Serif</family>| ) {
-    $newline = $line;
-    $newline =~ s|Bitstream Vera Serif|Lucida Bright|;
-    print $newline;
+    print_substitute_line($line, 'Bitstream Vera Serif', 'Lucida Bright');
   }
-  # Add Lucida Sans Typewriter before Bitstream Vera Serif
+  # Add Lucida Sans Typewriter before Bitstream Vera Sans Mono
   if ($line =~ m|<family>Bitstream Vera Sans Mono</family>| ) {
-    $newline = $line;
-    $newline =~ s|Bitstream Vera Sans Mono|Lucida Sans Typewriter|;
-    print $newline;
+    print_substitute_line($line, 'Bitstream Vera Sans Mono', 
+			  'Lucida Sans Typewriter');
   }
   # Add DejaVu entries before Bitstream Vera
   if ($line =~ m|<family>Bitstream Vera.*</family>|) {
-    $newline = $line;
-    $newline =~ s|Bitstream Vera|DejaVu|;
-    print $newline;
+    print_substitute_line($line, 'Bitstream Vera', 'DejaVu');
   }
   # Add EUDC fonts to preferred fonts lists (bug 6195182)
   if (($line =~ m|<family>Bitstream Vera|) && 
--- a/open-src/lib/fontconfig/fonts.conf.append	Thu Feb 21 14:38:58 2008 -0800
+++ b/open-src/lib/fontconfig/fonts.conf.append	Thu Feb 21 16:16:15 2008 -0800
@@ -82,6 +82,96 @@
 	</edit>
 </match>
 
+<match target="font">
+	<test name="family">
+		<string>IPAGothic</string>
+		<string>IPAPGothic</string>
+		<string>IPAUIGothic</string>
+		<string>IPAMincho</string>
+		<string>IPAPMincho</string>
+	</test>
+	<edit name="globaladvance" mode="assign">
+		<bool>false</bool>
+	</edit>
+</match>
+
+<!--
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>IPAGothic</string>
+		<string>IPAPGothic</string>
+		<string>IPAUIGothic</string>
+		<string>IPAMincho</string>
+		<string>IPAPMincho</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>11</double>
+	</test>
+	<test name="pixelsize" compare="less_eq">
+		<double>13</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+	<edit name="pixelsize" mode="assign">
+		<double>12</double>
+	</edit>
+</match>
+
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>IPAGothic</string>
+		<string>IPAPGothic</string>
+		<string>IPAUIGothic</string>
+		<string>IPAMincho</string>
+		<string>IPAPMincho</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>13</double>
+	</test>
+	<test name="pixelsize" compare="less_eq">
+		<double>15</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+	<edit name="pixelsize" mode="assign">
+		<double>14</double>
+	</edit>
+</match>
+
+<match target="font">
+	<test name="prefer_bitmap">
+		<bool>true</bool>
+	</test>
+	<test name="family">
+		<string>IPAGothic</string>
+		<string>IPAPGothic</string>
+		<string>IPAUIGothic</string>
+		<string>IPAMincho</string>
+		<string>IPAPMincho</string>
+	</test>
+	<test name="pixelsize" compare="more_eq">
+		<double>15</double>
+	</test>
+	<test name="pixelsize" compare="less_eq">
+		<double>17</double>
+	</test>
+	<edit name="antialias" mode="assign">
+		<bool>false</bool>
+	</edit>
+	<edit name="pixelsize" mode="assign">
+		<double>16</double>
+	</edit>
+</match>
+-->
+
 <!--
  Artificial bold for fonts without an bold version
  -->