google-code-export / tovid

Automatically exported from code.google.com/p/tovid
1 stars 0 forks source link

[PATCHES INCLUDED] tovid menu - Webdings not found/ImageMagick Version incorrect #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I think that I've uncovered a small can of worms when I try to use
"-button-font Webdings" on my "tovid menu" command line, using tovid 0.33.

I see this message:
=========================================================
Button: "Webdings" does not appear to be either a font file or registered with 
ImageMagick.
A similarly-named font was not found. Sorry!
The font "/mnt/sda9/usr/share/fonts/TTF/calibrib.ttf" will be used instead.
=========================================================

But my ImageMagick knows about the Webdings font: 
convert -list font | grep Webdings
  Font: Webdings
    family: Webdings
    glyphs: /space/old/hdb9/home/dad/.wine/drive_c/windows/fonts/Webdings.TTF

I have ImageMagick 6.6.1-9 2010-05-17 Q16 http://www.imagemagick.org

And the good news - I have made some fixes...

The problem starts in tovid-init test_version() where the version of 
ImageMagick is checked for being < 6.3.5.7. This test doesn't seem to
work correctly. Instead of comparing each digit of the version, I
build up a more complete version number. e.g. 6.3.5.7 becomes
6357, 6.6.1.9 becomes 6619. Then the test works properly.
###########################################################
--- original/tovid-init 2010-06-02 00:09:39.000000000 +0100
+++ new/tovid-init      2010-10-05 20:02:32.000000000 +0100
@@ -432,7 +432,11 @@
     IFS=$OIFS
     for i in ${!test_version[@]}; do
         [[ -z ${version[i]} ]] && version[i]=0
-       (( ${version[i]} < ${test_version[i]} )) && return 1
+       VERSION=$(( VERSION * 10 ))
+       VERSION=$(( VERSION + version[i] ))
+       TEST_VERSION=$(( TEST_VERSION * 10 ))
+       TEST_VERSION=$(( TEST_VERSION + test_version[i] ))
+       (( ${VERSION} < ${TEST_VERSION} )) && return 1
     done
     return 0
 }
###########################################################
(Not sure if this will fail in the 22nd Century when ImageMagick 10 arrives!).

Then there is a problem in makemenu. The check if ImageMagick knows 
about the font "Webdings" seems to fail.
Lines 492/493 are:
        USE_BUTTON_FONT=$( convert -list $IM_LISTARG | \
        grep -m 1 "$BUTTON_FONT" | awk '{print $1}' )

Using my values for the variables, this becomes:
convert -list font | \
        grep -m 1 "Webdings" | awk '{print $1}'
This returns:
Font:
when executed with ImageMagick 6.6.1-9.

But with a tiny change all is OK:
convert -list font | \
        grep -m 1 "Webdings" | awk '{print $2}'
returns:
Webdings

Maybe the output from "convert -list font" has changed at some time.

Anyway, there are four instances of this construct in makemenu and I
changed them all from {print $1} to {print $2} and all seems OK for
me, but I'm not sure I've tested all possible combinations.

###########################################################
--- original/makemenu   2010-05-18 07:07:34.000000000 +0100                     

+++ new/makemenu        2010-10-05 20:35:19.000000000 +0100                     

@@ -458,14 +458,14 @@                                                           

     # Check to see if the given font name is available in ImageMagick                                                
     # (only return the first exact match)                                                                            
     USE_TITLE_FONT=$( convert -list $IM_LISTARG | \                                                                  
-    grep -m 1 "$TITLE_FONT" | awk '{print $1}' )                               

+    grep -m 1 "$TITLE_FONT" | awk '{print $2}' )                               

    # If not available, try to use something similar                                                                  
     if test -z $USE_TITLE_FONT ; then                                                                                
         echo $SEPARATOR                                                                                              
         echo "Font: \"$TITLE_FONT\" does not appear to be either a font file or registered with ImageMagick."        
         USE_TITLE_FONT=$( convert -list $IM_LISTARG | \
-        grep -i -m 1 "${TITLE_FONT:0:20}" | awk '{print $1}' )
+        grep -i -m 1 "${TITLE_FONT:0:20}" | awk '{print $2}' )

         # If a similarly-named one does't exist, default to Helvetica
         if test -z "$USE_TITLE_FONT"; then
@@ -490,14 +490,14 @@
         # Check to see if the given button font is available in ImageMagick
         # (only return the first exact match)
         USE_BUTTON_FONT=$( convert -list $IM_LISTARG | \
-        grep -m 1 "$BUTTON_FONT" | awk '{print $1}' )
+        grep -m 1 "$BUTTON_FONT" | awk '{print $2}' )

         # If not available, try to use something similar
         if test -z $USE_BUTTON_FONT ; then
             echo $SEPARATOR
             echo "Button: \"$BUTTON_FONT\" does not appear to be either a font file or registered with ImageMagick."
             USE_BUTTON_FONT=$( convert -list $IM_LISTARG | \
-            grep -i -m 1 "${BUTTON_FONT:0:20}" | awk '{print $1}' )
+            grep -i -m 1 "${BUTTON_FONT:0:20}" | awk '{print $2}' )

             # If a similarly-named one does't exist, default to Helvetica
             if test -z "$USE_BUTTON_FONT"; then
###########################################################

I've attached a file containing both patches. Some of the lines are quite
long, and I'm not sure if they're displayed correctly here.

Cheers,
Peter

Original issue reported on code.google.com by peter.gr...@gmail.com on 5 Oct 2010 at 8:06

Attachments:

GoogleCodeExporter commented 9 years ago
Hi. Thanks for your report.
Looking at test_version() it is difficult to see how this came to be commited, 
it is so obviously broken, and would fail the simplest test case.  I suspect a 
line was deleted at some point in error.  It needs to 'return 0' if any value 
in the version string is greater than the test case value.  See the patch I 
have attached for a version that I think would survive version numbers above 9. 
 (this function needs to be generic, as transcode and potentially others are 
tested against it).

With respect to makemenu, the fix needs to be compatible with other imagemagick 
versions, so makemenu tests for the version # and prints the correct field.  
Please test the patch I have attached against your imagemagick version.

thanks !
grepper

Original comment by grepper@gmail.com on 8 Oct 2010 at 3:52

Attachments:

GoogleCodeExporter commented 9 years ago
Hi grepper,
Have tested your patches in tovid-init.in_and_makemenu.diff and they work fine 
for me.
Cheers,
Peter

Original comment by peter.gr...@gmail.com on 9 Oct 2010 at 12:57

GoogleCodeExporter commented 9 years ago

Original comment by grepper@gmail.com on 16 Oct 2010 at 10:34