home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / afmdiff.awk < prev    next >
Encoding:
AWK Script  |  2006-11-28  |  5.6 KB  |  152 lines

  1. #!/usr/bin/awk -f
  2. ###=====================================================================
  3. ### Read two Adobe Font Metric files, and compute tables of the
  4. ### differences in character repertoire, declared widths (WX), and
  5. ### bounding boxes.
  6. ###
  7. ### Usage:
  8. ###    awk -f afmdiff.awk file1.afm file2.afm
  9. ###
  10. ### Author:
  11. ###     Nelson H. F. Beebe
  12. ###     Center for Scientific Computing
  13. ###     University of Utah
  14. ###     Department of Mathematics, 322 INSCC
  15. ###     155 S 1400 E RM 233
  16. ###     Salt Lake City, UT 84112-0090
  17. ###     USA
  18. ###     Email: beebe@math.utah.edu, beebe@acm.org, beebe@computer.org,
  19. ###           beebe@ieee.org (Internet)
  20. ###     WWW URL: http://www.math.utah.edu/~beebe
  21. ###     Telephone: +1 801 581 5254
  22. ###     FAX: +1 801 585 1640, +1 801 581 4148
  23. ###
  24. ########################################################################
  25. ########################################################################
  26. ########################################################################
  27. ###                                                                  ###
  28. ###        awkdiff.awk: compare two Adobe Font Metric files          ###
  29. ###                                                                  ###
  30. ###              Copyright (C) 2000 Nelson H. F. Beebe               ###
  31. ###                                                                  ###
  32. ### This program is covered by the GNU General Public License (GPL), ###
  33. ### version 2 or later, available as the file COPYING in the program ###
  34. ### source distribution, and on the Internet at                      ###
  35. ###                                                                  ###
  36. ###               ftp://ftp.gnu.org/gnu/GPL                          ###
  37. ###                                                                  ###
  38. ###               http://www.gnu.org/copyleft/gpl.html               ###
  39. ###                                                                  ###
  40. ### This program is free software; you can redistribute it and/or    ###
  41. ### modify it under the terms of the GNU General Public License as   ###
  42. ### published by the Free Software Foundation; either version 2 of   ###
  43. ### the License, or (at your option) any later version.              ###
  44. ###                                                                  ###
  45. ### This program is distributed in the hope that it will be useful,  ###
  46. ### but WITHOUT ANY WARRANTY; without even the implied warranty of   ###
  47. ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    ###
  48. ### GNU General Public License for more details.                     ###
  49. ###                                                                  ###
  50. ### You should have received a copy of the GNU General Public        ###
  51. ### License along with this program; if not, write to the Free       ###
  52. ### Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,   ###
  53. ### MA 02111-1307 USA                                                ###
  54. ###                                                                  ###
  55. ### This program may also be distributed as part of AFPL             ###
  56. ### Ghostscript, under the terms of the Aladdin Free Public License  ###
  57. ### (the "License").                                                 ###
  58. ###                                                                  ###
  59. ### Every copy of AFPL Ghostscript must include a copy of the        ###
  60. ### License, normally in a plain ASCII text file named PUBLIC.  The  ###
  61. ### License grants you the right to copy, modify and redistribute    ###
  62. ### AFPL Ghostscript, but only under certain conditions              ###
  63. ### described in the License.  Among other things, the License       ###
  64. ### requires that the copyright notice and this notice be preserved  ###
  65. ### on all copies.                                                   ###
  66. ###                                                                  ###
  67. ########################################################################
  68. ########################################################################
  69. ########################################################################
  70. #
  71. # [29-Apr-2000]
  72. #=======================================================================
  73.  
  74. /^FontName/    { FontName[++NFontName] = $2 }
  75.  
  76.  
  77. /^C /        {
  78.             if (NFontName == 1)
  79.             CharName1[$8]++
  80.             if (NFontName == 2)
  81.             CharName2[$8]++
  82.         }
  83.  
  84.  
  85. /^C /        {
  86.             name = $8
  87.             if (name in WX)
  88.             {
  89.             if (WX[name] != $5)
  90.                 WXDIFF[name] = WX[name] - $5
  91.             }
  92.             else
  93.             WX[name] = $5
  94.         }
  95.  
  96.  
  97. /^C /        {
  98.             name = $8
  99.             bx = $13 - $11
  100.             if (name in BX)
  101.             {
  102.             if (BX[name] != bx)
  103.                 BXDIFF[name] = BX[name] - bx
  104.             }
  105.             else
  106.             BX[name] = bx
  107.         }
  108.  
  109.  
  110. /^C /        {
  111.             name = $8
  112.             by = $14 - $12
  113.             if (name in BY)
  114.             {
  115.             if (BY[name] != by)
  116.                 BYDIFF[name] = BY[name] - by
  117.             }
  118.             else
  119.             BY[name] = by
  120.         }
  121.  
  122.  
  123. END        {
  124.             Sortpipe = "sort -f | pr -c3 -w80 -l1 -t"
  125.             print "Comparison of AFM metrics in files:", ARGV[1], ARGV[2]
  126.             print "Font names:", FontName[1], FontName[2]
  127.             show_name_diffs(FontName[2],CharName2, FontName[1],CharName1)
  128.             show_name_diffs(FontName[1],CharName1, FontName[2],CharName2)
  129.             show_num_diffs("WX width differences", WXDIFF)
  130.             show_num_diffs("Bounding box width differences", BXDIFF)
  131.             show_num_diffs("Bounding box height differences",BYDIFF)
  132.         }
  133.  
  134. function show_name_diffs(font1,array1,font2,array2, name)
  135. {
  136.     print "\nChars from", font2, "missing from", font1 ":"
  137.     for (name in array2)
  138.     {
  139.     if (!(name in array1))
  140.         printf("%s\n", name) | Sortpipe
  141.     }
  142.     close(Sortpipe)
  143. }
  144.  
  145. function show_num_diffs(title,array, name)
  146. {
  147.     printf("\n%s:\n", title)
  148.     for (name in array)
  149.     printf("%-15s\t%4d\n", name, array[name]) | Sortpipe
  150.     close(Sortpipe)
  151. }
  152.