X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=lib%2Fredact%2Fpart.rb;h=0150a354cc185da8851d24e5ebfddb293498b691;hb=eb3e06dccf913ce26dd7c002eccbe12a44c32600;hp=974a6bec8ba47d8bc7720039582b2541e56ad61a;hpb=1c7f10346bf5a3639736d9179a492d01c2a4d127;p=redact.git diff --git a/lib/redact/part.rb b/lib/redact/part.rb index 974a6be..0150a35 100644 --- a/lib/redact/part.rb +++ b/lib/redact/part.rb @@ -1,5 +1,5 @@ #-- -# $Id: part.rb 29 2005-04-16 15:59:07Z tilman $ +# $Id: part.rb 45 2005-06-08 18:02:12Z tilman $ # # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # @@ -216,7 +216,12 @@ module Redact end def to=(part) - @to_id = [].fill(part.nil? ? -1 : part.id, 0..1) + self.set_to(part) + end + + def set_to(part_x, part_y = part_x) + @to_id = [part_x.nil? ? -1 : part_x.id, + part_y.nil? ? -1 : part_y.id] end end @@ -520,13 +525,17 @@ module Redact f = f.to_str.strip md = f.match(/.*\.ttf$/) unless md.nil? - found = EDJE.font_dir.find { |font| font.filename == f } + f2 = find_font(f) + raise(RedactError, "cannot find font - #{f}") if f2.nil? + + found = EDJE.font_dir.find { |font| font.filename == f2 } if found.nil? - EDJE.font_dir << FontDirectoryEntry.new(f) + EDJE.font_dir << FontDirectoryEntry.new(f2) + @font = EDJE.font_dir.last.filename end + else + @font = f end - - @font = f end def outline_color=(c) @@ -561,5 +570,15 @@ module Redact "text.id_source" => [@text_id_source], "text.id_text_source" => [@text_id_text_source]}) end + + private + def find_font(file) + [".", OPTIONS.font_dir].each do |d| + f2 = File.join(d, file) + return Pathname.new(f2).cleanpath.to_s if File.file?(f2) + end + + nil + end end end