diff -cr lib.org/pdf/writer/cidsysteminfo.rb lib/pdf/writer/cidsysteminfo.rb
*** lib.org/pdf/writer/cidsysteminfo.rb	Thu Jan  1 23:42:12 2004
--- lib/pdf/writer/cidsysteminfo.rb	Thu Jan  1 21:42:55 2004
***************
*** 0 ****
--- 1,14 ----
+ module PDF
+   class Writer
+     class CIDSystemInfo < PDF::Writer::WriterObject
+       def initialize(parent)
+         super(parent)
+       end
+ 
+       def to_s
+         res = "\n#{@id} 0 obj\n<< /Registry (Adobe) /Ordering (Japan1) /Supplement 2"
+         res << ">>\nendobj"
+       end
+     end
+   end
+ end
diff -cr lib.org/pdf/writer/font.rb lib/pdf/writer/font.rb
*** lib.org/pdf/writer/font.rb	Wed Sep 17 12:30:00 2003
--- lib/pdf/writer/font.rb	Thu Jan  1 23:03:21 2004
***************
*** 10,15 ****
--- 10,18 ----
          @name     = name
          @subtype  = subtype
          @encoding = encoding
+         if /(Ryumin|GothicBBB)/ =~ name
+           @cid_sinfo = PDF::Writer::CIDSystemInfo.new(parent)
+         end
  
          @font_id  = @parent.generate_font_id
  
***************
*** 29,34 ****
--- 32,38 ----
          # none, +nil+
        attr_accessor :encoding
        attr_reader :encodingDictionary
+       attr_accessor :fontbbox # ?
        def encodingDictionary=(ed)
          @encodingDictionary = ed
        end
***************
*** 46,53 ****
        end
  
        def to_s
!         res = "\n#{@id} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n"
!         res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n"
          if @encodingDictionary.nil?
            res << "/Encoding /#{@encoding}\n"
          else
--- 50,66 ----
        end
  
        def to_s
!         if /(Ryumin|GothicBBB)/ =~ @name
!           res = "\n#{@id} 0 obj\n<< /Type /Font\n/Subtype /Type0\n"
!           res << "/Name /F#{@font_id}\n/BaseFont /#{@name}-#{@encoding}\n"
!           res << "/DescendantFonts [<</CIDSystemInfo #{@cid_sinfo.id} 0 R /BaseFont /#{@name} /Type /Font /DW 1000 /Subtype /CIDFontType0"
!           res << " /FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil?
!           res << " /W [231 389 500 631 [500]]>>]\n"
!         else
!           res = "\n#{@id} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n"
!           res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n"
!           res << "/FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil?
!         end
          if @encodingDictionary.nil?
            res << "/Encoding /#{@encoding}\n"
          else
***************
*** 56,62 ****
          res << "/FirstChar #{@firstchar}\n" unless @firstchar.nil?
          res << "/LastChar #{@lastchar}\n" unless @lastchar.nil?
          res << "/Widths #{@firstchar} 0 R\n" unless @firstchar.nil?
-         res << "/FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil?
          res << ">>\nendobj"
        end
      end
--- 69,74 ----
diff -cr lib.org/pdf/writer/fontdescriptor.rb lib/pdf/writer/fontdescriptor.rb
*** lib.org/pdf/writer/fontdescriptor.rb	Wed Sep 17 12:30:00 2003
--- lib/pdf/writer/fontdescriptor.rb	Thu Jan  1 22:46:34 2004
***************
*** 6,21 ****
        # StemH, XHeight, CharSet, FontFile, FontFile2, FontFile3, FontBBox, or
        # FontName.
      class FontDescriptor < PDF::Writer::WriterObject
!       def initialize(parent, options = nil)
          super(parent)
  
          @options = options
        end
  
        attr_reader :options
  
        def to_s
          res = "\n#{@id} 0 obj\n<< /Type /FontDescriptor\n"
          @options.each do |k, v|
            res << "/#{k} #{v}\n" if %w{Ascent CapHeight Descent Flags ItalicAngle StemV AvgWidth Leading MaxWidth MissingWidth StemH XHeight CharSet}.include?(k)
            res << "/#{k} #{v} 0 R\n" if %w{FontFile FontFile2 FontFile3}.include?(k)
--- 6,33 ----
        # StemH, XHeight, CharSet, FontFile, FontFile2, FontFile3, FontBBox, or
        # FontName.
      class FontDescriptor < PDF::Writer::WriterObject
!       def initialize(parent, options = nil, fontname = nil)
          super(parent)
  
          @options = options
+         @fontname = fontname
        end
  
        attr_reader :options
  
        def to_s
          res = "\n#{@id} 0 obj\n<< /Type /FontDescriptor\n"
+         if /Ryumin/ =~ @fontname
+           res << "/Style <</Panose <010502020300000000000000>>> /XHeight 450 /FontBBox [-170 -331 1024 903] /Descent -241 /FontName /Ryumin-Light /CapHeight 709 /Flags 6 /ItalicAngle 0 /Ascent 723 /StemV 69>>\n"
+         elsif /GothicBBB/ =~ @fontname
+           res << "/Style <</Panose <0801020b0500000000000000>>> /XHeight 553 /FontBBox [-174 -268 1001 944] /Descent -271 /FontName /GothicBBB-Medium /CapHeight 737 /Flags 4 /ItalicAngle 0 /Ascent 752 /StemV 99>>\n"
+         end
+ 
+         unless @options # Ryumin or GothicBBB
+           res << "\nendobj"
+           return res
+         end
+ 
          @options.each do |k, v|
            res << "/#{k} #{v}\n" if %w{Ascent CapHeight Descent Flags ItalicAngle StemV AvgWidth Leading MaxWidth MissingWidth StemH XHeight CharSet}.include?(k)
            res << "/#{k} #{v} 0 R\n" if %w{FontFile FontFile2 FontFile3}.include?(k)
diff -cr lib.org/pdf/writer.rb lib/pdf/writer.rb
*** lib.org/pdf/writer.rb	Wed Sep 17 12:30:00 2003
--- lib/pdf/writer.rb	Thu Jan  1 23:11:53 2004
***************
*** 15,20 ****
--- 15,21 ----
  require 'pdf/writer/encryption'
  require 'pdf/writer/font'
  require 'pdf/writer/fontdescriptor'
+ require 'pdf/writer/cidsysteminfo'
  require 'pdf/writer/fontencoding'
  require 'pdf/writer/image'
  require 'pdf/writer/info'
***************
*** 242,247 ****
--- 243,264 ----
        # 0->255 and character names.
      def select_font(fontname, encoding = nil, set = true)
        if @fonts[fontname].nil?
+         if /(Ryumin|GothicBBB)/ =~ fontname
+           wfo = PDF::Writer::Font.new(self, fontname, encoding)
+           fdsc = PDF::Writer::FontDescriptor.new(self, nil, fontname)
+           wfo.fontdescriptor = fdsc.id
+ 
+           @fonts[fontname] = wfo
+           # from PDFJ
+           if /Ryumin/ =~ fontname
+             @fonts[fontname].fontbbox = [-170,-331,1024,903]
+           else # GothicBBB 
+             @fonts[fontname].fontbbox = [-174,-268,1001,944]
+           end
+         end
+       end
+ 
+       if @fonts[fontname].nil?
          font = open_font(fontname) # load the file
          if @fonts[fontname]
            name = File.basename(fontname).gsub(/\.afm$/, "")
***************
*** 801,807 ****
  
        if start < text.size
          part = text[start..-1]
!         t = " /F#{pw_font(@current_font).font_id} %.1f Tf (#{PDF.escape(part.chomp)}) Tj"
          @current_contents << (t % size)
        end
        @current_contents << " ET"
--- 818,850 ----
  
        if start < text.size
          part = text[start..-1]
!         #t = " /F#{pw_font(@current_font).font_id} %.1f Tf (#{PDF.escape(part.chomp)}) Tj"
!         if /(Ryumin|GothicBBB)/ =~ @current_font
!           require "jcode"
!           hex = ""; pre_c = :START; now_c = :START
!           PDF.escape(part.chomp).each_char do |c|
!             if c.size > 1
!               now_c = :JA
!               hex << ")" if pre_c == :ASCII
!               hex << "<" if pre_c != :JA
!               c.each_byte {|x| hex << (sprintf "%x", x)}
!             else
!               now_c = :ASCII
!               hex << ">" if pre_c == :JA
!               hex << "(" if pre_c != :ASCII
!               hex << c
!             end
!             pre_c = now_c
!           end
!           hex << ">" if pre_c == :JA
!           hex << ")" if pre_c == :ASCII
! 
!           #PDF.escape(part.chomp).each_byte {|c| hex << (sprintf "%x", c)}
!           #t = " /F#{pw_font(@current_font).font_id} %.1f Tf [<#{hex}>] TJ"
!           t = " /F#{pw_font(@current_font).font_id} %.1f Tf [#{hex}] TJ"
!         else
!           t = " /F#{pw_font(@current_font).font_id} %.1f Tf (#{PDF.escape(part.chomp)}) Tj"
!         end
          @current_contents << (t % size)
        end
        @current_contents << " ET"
***************
*** 895,901 ****
        return "" if width <= 0
  
        w = brk = brkw = 0
!       cf = @current_font
        tw = width / size * 1000
  
        i = -1
--- 938,948 ----
        return "" if width <= 0
  
        w = brk = brkw = 0
!       if /(Ryumin|GothicBBB)/ =~ @current_font
!         cf = "pdf/fonts/Helvetica"
!       else
!         cf = @current_font
!       end
        tw = width / size * 1000
  
        i = -1
