[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. cb80ff8c06e34e34cd88cee1e2ba8b569d27ef4f

Eugeniy Meshcheryakov eugen at debian.org
Wed Apr 2 12:16:52 UTC 2008


The following commit has been merged in the master branch:
commit 89ce31414aa0e75058c4038508d781a7b9a14140
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Apr 2 14:03:51 2008 +0200

    remove conv.rb - we have C++ import filter now

diff --git a/scripts/conv.rb b/scripts/conv.rb
deleted file mode 100755
index 01c0eea..0000000
--- a/scripts/conv.rb
+++ /dev/null
@@ -1,458 +0,0 @@
-# Fontforge SFD import filter
-
-require 'xml/libxml'
-
-@@glyphs = []
-
-def decode_instrs(instrs, count)
-  Fe::ttidecode(Fe::decode_ascii85(instrs, count))
-end
-
-def decode_ff_utf7(s)
-  # FIXME does this work with Estonian locale?
-  s.gsub /\+[0-9A-Za-z\+\/]*-?/ do |part|
-    part[1..-1].chomp("-").unpack("m*").first.unpack("n*").pack("U*").chomp("\0")
-  end
-end
-
-def read_file(f, doc)
-  lookupstbl = nil
-
-  doc.root << face = XML::Node.new("font-face");
-
-  f.each do |line|
-    if line.strip == 'EndSplineFont'
-      break
-    else
-      tag, value = line.split ': ', 2
-
-      if tag == 'BeginChars'
-	read_glyphs(f, doc)
-      elsif (tag == "Copyright")
-	doc.root << XML::Node.new("copyright", value.chomp.gsub(/\\n/, "\n")) # FIXME
-      elsif (tag == "Version")
-	doc.root["font-version"] = value.strip
-      elsif (tag == "FullName")
-	face["font-name"] = value.strip
-      elsif (tag == "FamilyName")
-	face["font-family"] = value.strip
-      elsif (tag == "Weight")
-	face["font-weight"] = value.strip
-      elsif (tag == 'Ascent')
-	face["ascent"] = value.strip
-      elsif (tag == "Descent")
-	face["descent"] = value.strip
-      elsif (tag == "ItalicAngle")
-	face["italic-angle"] = value.strip
-      elsif (tag == "UnderlinePosition")
-	face["underline-position"] = value.strip
-      elsif (tag == "UnderlineWidth")
-	face["underline-thickness"] = value.strip
-      elsif (tag == "Panose")
-	face["panose"] = value.strip
-      elsif (tag == "TtfTable")
-	data = read_ttf_table(f)
-	tname, nbytes = value.strip.split(/ +/, 2)
-	case tname
-	when "fpgm"
-	  doc.root << (XML::Node.new("fpgm") << XML::Node.new("tti", decode_instrs(data, nbytes.to_i)))
-	when "prep"
-	  doc.root << (XML::Node.new("prep") << XML::Node.new("tti", decode_instrs(data, nbytes.to_i)))
-	when "cvt"
-	  raise("Bad cvt table: nbytes = #{nbytes}") if (nbytes.to_i % 2 != 0)
-	  doc.root << cvt = XML::Node.new("cvt")
-	  Fe::decode_ascii85(data, nbytes.to_i).unpack("n*").each do |v|
-	    cvt << cv = XML::Node.new("cv")
-	    cv["v"] = v.to_s
-	  end
-	when "maxp"
-	  raise("Bad maxp table nbytes = #{nbytes}") if (nbytes.to_i != 32)
-	  maxpTable = Fe::decode_ascii85(data, nbytes.to_i).unpack("n*");
-	  maxZones = maxpTable[7];
-	  maxTwilightPoints = maxpTable[8];
-	  maxStorage = maxpTable[9];
-	  maxFDEFs = maxpTable[10];
-	  maxIDEFs = maxpTable[11];
-	  maxStackDepth = maxpTable[12];
-	  doc.root << maxp = XML::Node.new("maxp");
-	  maxp["zones"] = maxZones.to_s;
-	  maxp["twilight"] = maxTwilightPoints.to_s;
-	  maxp["storage"] = maxStorage.to_s;
-	  maxp["funcs"] = maxFDEFs.to_s;
-	  maxp["instrs"] = maxIDEFs.to_s;
-	  maxp["stack"] = maxStackDepth.to_s;
-	else
-	  raise "Unknown truetype table: #{tname}"
-	end
-      elsif tag == 'Lookup'
-	if (!lookupstbl)
-	  #XXX doc.root << lookupstbl = XML::Node.new("lookups")
-	  lookupstbl = XML::Node.new("lookups")
-	end
-	lookupstbl << decode_lookup(value)
-      elsif tag == 'AnchorClass2'
-	# XXX doc.root << anchors = XML::Node.new("anchors")
-	anchors = XML::Node.new("anchors")
-	value.scan(/"([^"]*)"\s*"([^"]*)"/) do |mark|
-	  anchors << anchor = XML::Node.new("anchor")
-	  anchor["name"] = decode_ff_utf7(mark[0])
-	  anchor["lookup"] = decode_ff_utf7(mark[1])
-	end
-      elsif tag == 'LangName'
-	_, langnum, content = value.match(/^\s*([\w]+)\s*(.*)$/).to_a
-	# XXX doc.root << ttfstrings = XML::Node.new("strings")
-	ttfstrings = XML::Node.new("strings")
-	ttfstrings["langid"] = langnum # FIXME use ISO names here
-	strid = 0
-	content.scan(/"([^"]*)"/) do |s|
-	  if s[0] != ''
-	    ttfstrings << st = XML::Node.new("string", decode_ff_utf7(s[0]))
-	    st["id"] = strid.to_s
-	  end
-	  strid += 1
-	end
-      elsif tag == 'MarkAttachClasses'
-	# skip them
-	(value.to_i - 1).times do f.readline end
-      elsif tag == 'KernClass2'
-	# XXX doc.root << decode_kernclass(value, f);
-	decode_kernclass(value, f);
-      elsif tag == 'ChainSub2'
-	decode_chainsub(value, f)
-	# XXX doc.root << decode_chainsub(value, f)
-      end
-    end
-  end
-end
-
-def decode_glyphslist(s)
-  glyphs = s.strip.split(' ')[1..-1]
-  glyphs.each do |g|
-    e = XML::Node.new("g")
-    e["name"] = g
-    yield e
-  end
-end
-
-def decode_chainsub(value, f)
-  _, t, lookup, nclasses, nbclasses, nfclasses, nsubs = /^\s*(\w+)\s*"([^"]*)"\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/.match(value).to_a
-  subs = XML::Node.new("chained-subs")
-  subs["lookup"] = decode_ff_utf7(lookup)
-  if nclasses.to_i > 0
-    subs << match_classes = XML::Node.new("match-classes")
-    (nclasses.to_i - 1).times do
-      match_classes << cl = XML::Node.new("glyph-class")
-      pfx, v = f.readline.split(': ', 2)
-      raise "File format error" if pfx.strip != 'Class' 
-      decode_glyphslist(v) {|e| cl << e}
-    end
-  end
-  if nbclasses.to_i > 0
-    subs << back_classes = XML::Node.new("back-classes")
-    (nbclasses.to_i - 1).times do
-      back_classes << cl = XML::Node.new("glyph-class")
-      pfx, v = f.readline.split(': ', 2)
-      raise "File format error" if pfx.strip != 'BClass'
-      decode_glyphslist(v) {|e| cl << e}
-    end
-  end
-  if nfclasses.to_i > 0
-    subs << forward_classes = XML::Node.new("forward-classes")
-    (nfclasses.to_i - 1).times do
-      forward_classes << cl = XML::Node.new("glyph-class")
-      pfx, v = f.readline.split(': ', 2)
-      raise "File format error" if pfx.strip != 'FClass'
-      decode_glyphslist(v) {|e| cl << e}
-    end
-  end
-  subs
-end
-
-def decode_kernclass(value, f)
-  _, first, second, name = /^\s*(\d+\+?)\s+(\d+)\s*"([^"]*)"/.match(value).to_a
-  kern = XML::Node.new("kern-table")
-  kern["lookup"] = decode_ff_utf7(name)
-  kern << char1 = XML::Node.new("char1")
-  raise "Not implemented: + after char1 in KernClass2" if first =~ /\+$/
-  (first.to_i - 1).times do
-    char1 << klass = XML::Node.new("glyph-class")
-    decode_glyphslist(f.readline.strip) {|e| klass << e}
-  end
-  kern << char2 = XML::Node.new("char2")
-  (second.to_i - 1).times do
-    char2 << klass = XML::Node.new("glyph-class")
-    decode_glyphslist(f.readline.strip) {|e| klass << e}
-  end
-  # read the data
-  l = f.readline
-  i = 0
-  l.scan(/(\w+)\s*(\{[^}]*\})?/) do |ent|
-    i += 1
-    val = ent[0].to_i
-    dev = ent[1][1..-2]
-    if val != 0 || (dev && dev != '')
-      kern << p = XML::Node.new("kern")
-      p["c1"] = (i / first.to_i).to_s
-      p["c2"] = (i % first.to_i).to_s
-      p["k"] = val.to_s if val
-      p["adj"] = dev if (dev && dev != '')
-    end
-  end
-  raise "Bad kerning table: #{i} entries instead of #{first.to_i * second.to_i}" if i != first.to_i * second.to_i
-  kern
-end
-
-def decode_lookup(value)
-  # FIXME use flags too
-  _, flag1, flag2, flag3, lookupname, lookups, data = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+"([^"]+)"\s*\{([^}]*)\}\s*\[([^\]]*)\]/.match(value).to_a
-  l = XML::Node.new("lookup")
-  l["name"] = decode_ff_utf7(lookupname)
-  lookups.scan(/"([^"]*)"/) do |sublookup|
-    l << sl = XML::Node.new("subtable")
-    sl["name"] = decode_ff_utf7(sublookup[0])
-  end
-  data.scan(/'([^']*)'\s*\(([^)]*)\)/) do |x|
-    l << lmeta = XML::Node.new("feature")
-    lmeta["type"] = x[0];
-    x[1].scan(/'([^']*)'\s*<([^>]*)>/) do |scr|
-      script = scr[0].strip
-      langs = scr[1]
-      lmeta << s = XML::Node.new("script")
-      s["name"] = script
-      langs.scan(/'([^']*)'/) do |ll|
-	s << lng = XML::Node.new("language")
-	lng["name"] = ll[0].strip
-      end
-    end
-  end
-  l
-end
-
-def read_glyphs(f, doc)
-  f.each do |line|
-    if line.strip == 'EndChars'
-      break
-    else
-      tag, value = line.split ': ', 2
-      if tag == 'StartChar'
-	gl = read_glyph(f, value.strip)
-	@@glyphs[gl[:idx]] = gl
-      else
-	raise "malformed line: #{tag}"
-      end
-    end
-  end
-end
-
-def read_glyph(f, gname)
-  flags = nil
-  width = nil
-  content = []
-  ninstrs = nil
-  instrs = nil
-  color = nil
-  comment = nil
-  unival = nil
-  idx = nil
-
-  f.each do |line|
-    if line.strip == 'EndChar'
-      break
-    elsif line.strip == 'Fore'
-      content << read_splineset(f)
-    else
-      tag, value = line.split ': ', 2
-      if tag == 'TtfInstrs'
-	ninstrs = value.to_i
-	instrs = read_ttf_table(f)
-      elsif tag == 'Flags'
-	flags = value.strip
-      elsif tag == 'Width'
-	width = value.to_i
-      elsif tag == 'Refer'
-	content << {:type => :refer, :data => value.strip.split(/ +/)}
-      elsif tag == 'Colour'
-	color = value.strip.hex
-      elsif tag == 'Comment'
-	comment = decode_ff_utf7((/"([^"]*)"/.match(value))[1])
-      elsif tag == 'Encoding'
-	_, unicode, idx = value.strip.split
-	unival = "%X"%unicode.to_i if unicode.to_i != -1
-      end
-    end
-  end
-  {
-    :name => gname, :flags => flags, :width => width, :content => content,
-    :ninstrs => ninstrs, :instrs => instrs, :color => color, :comment => comment,
-    :unival => unival, :idx => idx.to_i
-  }
-end
-
-def read_ttf_table(f)
-  content = ''
-
-  f.each do |line|
-    if line.strip == "EndTtf"
-      break
-    else
-      content += line.strip
-    end
-  end
-  content
-end
-
-def read_splineset(f)
-  content = ''
-
-  f.each do |line|
-    if line.strip == "EndSplineSet"
-      break
-    else
-      content += line
-    end
-  end
-  {:type => :fore, :data => content}
-end
-
-def contour_to_xml(s)
-  contours = []
-  curcnt = nil
-  lastpt = nil
-  last_in = false
-  firstpt = nil
-
-  lines = s.split("\n")
-  lines.each do |l|
-    a = l.strip.split
-    if a[2] == 'm'
-      # new contour
-      if curcnt
-	open = true
-	if lastpt == firstpt and curcnt.size > 1
-	  #closed contour
-	  open = false
-	end
-	if last_in
-	  newcnt = [curcnt[-1]]
-	  curcnt[1..-2].each do |e| newcnt << e end
-	  curcnt = newcnt
-	end
-	if !open and curcnt[0] == curcnt[-1]
-	  # remove duplicate points
-	  curcnt = curcnt[0..-2]
-	end
-	contours << [curcnt, open]
-      end
-      curcnt = [[a[0], a[1], true]]
-      lastpt = [a[0], a[1], true]
-      firstpt = [a[0], a[1], true]
-      last_in = false
-    elsif a[2] == 'l'
-      # lineto
-      # FIXME cannot be interpolated?
-      curcnt << [a[0], a[1], true]
-      lastpt = [a[0], a[1], true]
-      last_in = false
-    elsif a[6] == 'c'
-      # curveto
-      flags = a[7].split(",")
-      # this only works for valid truetype splines
-      curcnt << [a[0], a[1], false]
-      last_in = true
-      if (flags[0].to_i & 0x80 == 0)
-	# point is not interpolated
-	curcnt << [a[4], a[5], true]
-	last_in = false
-      end
-      lastpt = [a[4], a[5], true]
-    end
-  end
-  if curcnt
-    open = true
-    if lastpt == firstpt and curcnt.size > 1
-      #closed contour
-      open = false
-    end
-    if last_in
-      newcnt = [curcnt[-1]]
-      curcnt[1..-2].each do |e| newcnt << e end
-      curcnt = newcnt
-    end
-    if !open and curcnt[0] == curcnt[-1]
-      # remove duplicate points
-      curcnt = curcnt[0..-2]
-    end
-
-    contours << [curcnt, open]
-  end
-  contours.each do |c|
-    cont = XML::Node.new("contour")
-    if c[1] then
-      cont["open"] = "1"
-    end
-    c[0].each do |p|
-      cont << pt = XML::Node.new("pt")
-      pt["x"] = p[0]
-      pt["y"] = p[1]
-      pt["on"] = "no" unless p[2]
-    end
-    yield cont
-  end
-end
-
-doc = XML::Document.new
-doc.encoding = "UTF-8"
-doc.root = XML::Node.new("font")
-doc.root["version"] = "1.0"
-doc.root["xmlns"] = 'http://people.debian.org/~eugen/fondue/2007'
-
-File.open('DejaVuSans.sfd', 'r') do |f|
-  read_file(f, doc)
-end
-
-doc.root << glyphs_element = XML::Node.new("glyphs")
-
-@@glyphs.each do |g|
-  if g
-    glyphs_element << glyph_element = XML::Node.new("glyph")
-    glyph_element["glyph-name"] = g[:name]
-
-    if g[:flags] =~ /W/
-      glyph_element["horiz-adv-x"] = g[:width].to_s
-    end
-    if g[:ninstrs]
-      glyph_element << XML::Node.new("tti", decode_instrs(g[:instrs], g[:ninstrs]))
-    end
-    if g[:color]
-      glyph_element["color"] = "#{'#%06x'%g[:color]}"
-    end
-    if g[:comment]
-      glyph_element << XML::Node.new("comment", g[:comment])
-    end
-    if g[:unival]
-      glyph_element["u"] = g[:unival]
-    end
-    if !g[:content].empty?
-      glyph_element << cont = XML::Node.new("content")
-      g[:content].each do |ent|
-	if ent[:type] == :refer
-	  # XXX use transformation matrix
-	  data = ent[:data]
-	  idx = data[0].to_i
-	  off = data[7..8]
-	  flags = data[10].to_i
-	  cont << r = XML::Node.new("ref")
-	  r["g"] = @@glyphs[idx][:name]
-	  r["x"] = off[0] unless off[0] == '0'
-	  r["y"] = off[1] unless off[1] == '0'
-	else
-	  contour_to_xml(ent[:data]) {|c| cont << c}
-	end
-      end
-    end
-  end
-end
-
-doc.save("1.xml", true)
-
-# vim:sw=2
diff --git a/scripts/scripts.rules b/scripts/scripts.rules
index 2616bcb..9eaf24a 100644
--- a/scripts/scripts.rules
+++ b/scripts/scripts.rules
@@ -1,6 +1,3 @@
-rubyscriptsdir = $(datarootdir)/fe/scripts
-dist_rubyscripts_DATA = scripts/conv.rb
-
 dist_noinst_DATA = scripts/format.xsl
 
 ## vim:ft=automake

-- 
Fondue Font Editor



More information about the fondue-commits mailing list