From eb3e06dccf913ce26dd7c002eccbe12a44c32600 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Wed, 8 Jun 2005 18:02:12 +0000 Subject: [PATCH] Fixed fontdir handling. --- ChangeLog | 3 ++- lib/redact/part.rb | 24 +++++++++++++++++++----- lib/redact/redact.rb | 14 ++------------ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02d29b8..de6f586 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ -- -$Id: ChangeLog 44 2005-06-08 17:35:49Z tilman $ +$Id: ChangeLog 45 2005-06-08 18:02:12Z tilman $ ++ 2005-06-08 Tilman Sauerbeck (tilman at code-monkey de) @@ -8,6 +8,7 @@ $Id: ChangeLog 44 2005-06-08 17:35:49Z tilman $ Redact::OPTIONS * lib/redact/redact.rb, TODO: Added support for the --image_dir and --font_dir command line switches + * lib/redact/{redact,app}.rb: Fixed fontdir handling 2005-05-29 Tilman Sauerbeck (tilman at code-monkey de) * Rakefile: Use FileUtils.mkdir_p to create the destination diff --git a/lib/redact/part.rb b/lib/redact/part.rb index 706761a..0150a35 100644 --- a/lib/redact/part.rb +++ b/lib/redact/part.rb @@ -1,5 +1,5 @@ #-- -# $Id: part.rb 32 2005-04-24 09:18:07Z tilman $ +# $Id: part.rb 45 2005-06-08 18:02:12Z tilman $ # # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # @@ -525,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) @@ -566,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 diff --git a/lib/redact/redact.rb b/lib/redact/redact.rb index d0da5d7..6b505f2 100644 --- a/lib/redact/redact.rb +++ b/lib/redact/redact.rb @@ -1,5 +1,5 @@ #-- -# $Id: redact.rb 44 2005-06-08 17:35:49Z tilman $ +# $Id: redact.rb 45 2005-06-08 18:02:12Z tilman $ # # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # @@ -145,7 +145,7 @@ module Redact attr_reader :filename def initialize(filename) - @filename = find_font(filename.to_str).freeze + @filename = filename.to_str.dup.freeze end protected @@ -156,16 +156,6 @@ module Redact def to_eet_properties {"entry" => [@filename]} end - - private - def find_font(file) - [".", OPTIONS.font_dir].each do |d| - f2 = File.join(d, file) - return f2 if File.file?(f2) - end - - nil - end end class ImageDirectory < Array # :nodoc: -- 2.30.2