Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageMagick: unable to read font 'Helvetica' #1380

Closed
tbcooney opened this issue Apr 3, 2023 · 1 comment
Closed

ImageMagick: unable to read font 'Helvetica' #1380

tbcooney opened this issue Apr 3, 2023 · 1 comment

Comments

@tbcooney
Copy link

tbcooney commented Apr 3, 2023

Description

ImageMagick suddenly began to raise an Magick::ImageMagickError stating that it is unable to read font 'Helvetica' @ error/annotate.c/RenderFreetype/1396 when running a unit test for a Ruby on Rails app through CI using GitHub Actions. This is raised when installing either gsfonts or ghostscript. The unit test previously passed and it was only in the last 4 days that the error started to be raised.

The ImageMagick package is looking for the font installation in the /usr/local so in the CI workflow we install the font paths to make Github Actions pass.

First to see what fonts are installed, I ran this command locally:

convert -list font

For Helvetica it shown under the usr/local path:

Font: fixed
    family: Helvetica
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/local/share/ghostscript/fonts/n019003l.pfb

In Github Actions there will be no such path, so it seems that ghostscript fonts (or gsfonts) must be included.

- name: Install dependencies
  run: |
    sudo apt-get install -y -qq libvips ghostscript imagemagick
    yarn install --frozen-lockfile

Again, this unit test previously passed and it was only in the last 4 days that the error started to be raised.

Steps to Reproduce

We have a service that contains two actions for drawing something on an image. The class is being instantiated in the following way:

class AnnotateSignature
  attr_reader :text
  private :text

  def initialize(text)
    @text = text
  end

  def annotate(*args)
    draw.annotate(*args, text)
  end

  private

  def draw
    Magick::Draw.new.tap do |text|
      text.font = "Helvetica"
      text.pointsize = 38
      text.font_weight = Magick::BoldWeight
      text.fill = "black"
      text.gravity = Magick::SouthGravity
    end
  end
end

System Configuration

  • ImageMagick version: Latest
  • RMagick version: 4.2.5
  • Ruby version: 3.1.1
  • Environment (Operating system, version and so on): Ubuntu-latest
  • Additional information: CI workflow via GitHub Actions
@Watson1978
Copy link
Member

Sounds this is related to runner image of github action.
I think the creation of the image needs to be properly updated.

Feel free to reopen if you have any problem yet.

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

No branches or pull requests

2 participants