Skip to content

Fix for #18 - Add Imagemagick V7 compatibility#19

Merged
set-soft merged 2 commits intoINTI-CMNB:masterfrom
Tony763:master
Jul 14, 2025
Merged

Fix for #18 - Add Imagemagick V7 compatibility#19
set-soft merged 2 commits intoINTI-CMNB:masterfrom
Tony763:master

Conversation

@Tony763
Copy link
Contributor

@Tony763 Tony763 commented Jul 11, 2025

Hello this PR add necessary changes for use of Imagemagick V7 with backward compatibility to V6. That way KiDiff can be used on newer versions of various distros and also on older.
Second commit introduce small check for availability of at least one of three fonts as helvetica was not available on my machine.

Also dropping Python 3.5 (EoL 2020) support could introduce f-string and make some parts of code more readable. Let me know if it would be accepted.

@Tony763 Tony763 changed the title Fix for #18 Fix for #18 - Add Imagemagick V7 compatibility Jul 11, 2025
@set-soft
Copy link
Member

Hi @Tony763 !
Thanks for the patch I'll merge it, but I have some problems with the fonts:

  1. The search for fonts looks for ['helvetica', 'Open-Sans-Regular', 'Roboto'], but the font name for 'helvetica' is "Helvetica", so it won't be detected.

  2. If I fix this I see magick fails to use the Helvetica font, some issue with Type 1 fonts?

$ identify -list font | grep -i helvetica
    family: Helvetica
  Font: Helvetica
    family: Helvetica
  Font: Helvetica-Bold
    family: Helvetica
  Font: Helvetica-BoldOblique
    family: Helvetica
  Font: Helvetica-Narrow
    family: Helvetica Narrow
  Font: Helvetica-Narrow-Bold
    family: Helvetica Narrow
  Font: Helvetica-Narrow-Oblique
    family: Helvetica Narrow
  Font: Helvetica-Oblique
    family: Helvetica
$ magick cache/9181e111ed09cc40ca1e2436772b7fbb172d06ef/0.png -font "Helvetica" -pointsize 30 -draw "text 10,30 \'Layer: F.Cu\'" pp.png
magick: unable to read font `Helvetica' @ error/annotate.c/RenderFreetype/1636.
$ cat /etc/ImageMagick-7/type.xml 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE typemap [
  <!ELEMENT typemap (type)+>
  <!ATTLIST typemap xmlns CDATA #FIXED ''>
  <!ELEMENT type EMPTY>
  <!ATTLIST type xmlns CDATA #FIXED '' encoding NMTOKEN #IMPLIED
    family CDATA #REQUIRED format NMTOKEN #REQUIRED foundry NMTOKEN #REQUIRED
    fullname CDATA #REQUIRED glyphs CDATA #REQUIRED metrics CDATA #REQUIRED
    name NMTOKEN #REQUIRED stretch NMTOKEN #REQUIRED style NMTOKEN #REQUIRED
    version CDATA #IMPLIED weight CDATA #REQUIRED>
]>
<!--
  ImageMagick font configuration.
-->
<typemap>
   <include file="type-ghostscript.xml" /> <include file="type-windows.xml" />
</typemap>
$ grep Helvetica /etc/ImageMagick-7/type-ghostscript.xml 
  <type name="fixed" fullname="Helvetica Regular" family="Helvetica" foundry="URW" weight="400" style="normal" stretch="normal" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019003l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019003l.pfb"/>
  <type name="Helvetica" fullname="Helvetica Regular" family="Helvetica" foundry="URW" weight="400" style="normal" stretch="normal" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019003l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019003l.pfb"/>
  <type name="Helvetica-Bold" fullname="Helvetica Bold" family="Helvetica" foundry="URW" weight="700" style="normal" stretch="normal" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019004l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019004l.pfb"/>
  <type name="Helvetica-Oblique" fullname="Helvetica Regular Italic" family="Helvetica" foundry="URW" weight="400" style="italic" stretch="normal" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019023l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019023l.pfb"/>
  <type name="Helvetica-BoldOblique" fullname="Helvetica Bold Italic" family="Helvetica" foundry="URW" weight="700" style="italic" stretch="normal" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019024l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019024l.pfb"/>
  <type name="Helvetica-Narrow" fullname="Helvetica Narrow" family="Helvetica Narrow" foundry="URW" weight="400" style="normal" stretch="condensed" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019043l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019043l.pfb"/>
  <type name="Helvetica-Narrow-Oblique" fullname="Helvetica Narrow Oblique" family="Helvetica Narrow" foundry="URW" weight="400" style="oblique" stretch="condensed" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019063l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019063l.pfb"/>
  <type name="Helvetica-Narrow-Bold" fullname="Helvetica Narrow Bold" family="Helvetica Narrow" foundry="URW" weight="700" style="normal" stretch="condensed" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019044l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019044l.pfb"/>
  <type name="Helvetica-Narrow-BoldOblique" fullname="Helvetica Narrow Bold Oblique" family="Helvetica Narrow" foundry="URW" weight="700" style="oblique" stretch="condensed" format="type1" metrics="/usr/share/fonts/type1/gsfonts/n019064l.afm" glyphs="/usr/share/fonts/type1/gsfonts/n019064l.pfb"/>

But identify says:

Font: Helvetica
    family: Helvetica
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/type1/urw-base35/NimbusSans-Regular.t1

So it looks like the config is fully broken

So I changed it a little bit

@set-soft set-soft merged commit 4fc346e into INTI-CMNB:master Jul 14, 2025
1 of 2 checks passed
@set-soft
Copy link
Member

Hi @Tony763 !

Also dropping Python 3.5 (EoL 2020) support could introduce f-string and make some parts of code more readable. Let me know if it would be accepted.

About this: There is no point in supporting Python < 3.7, so yes, I'll accept patches that needs >= 3.7
If you do it please send separated patches, i.e. don't mix f-strings patch with other change.

@Tony763
Copy link
Contributor Author

Tony763 commented Jul 15, 2025

I could not test Helvetica font family as I do not have them on my system, that was why I added other fonts which were listed as similar. Glad it works for you after some small changes.

Regarding f-strings, sure I will make PR just for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants