ropensci / magick

Magic, madness, heaven, sin
https://docs.ropensci.org/magick
Other
452 stars 63 forks source link

Enabling fontconfig #245

Open nickborg94 opened 4 years ago

nickborg94 commented 4 years ago

Hello,

Apologies in advance if this does not belong here.

I'm trying to annotate several images using a specific font (Segoe Script). However, when I run:

install.packages("magick")
library(magick)

I get this in the console:

Linking to ImageMagick 6.9.9.14
Enabled features: cairo, freetype, fftw, ghostscript, lcms, pango, rsvg, webp
Disabled features: fontconfig, x11

My understanding is that fontconfig must be enabled to use custom fonts. I've searched a lot and haven't found a way to do this - I believe I would need a different version of magick, but every magick package I download always links me to ImageMagic 6.9.9.14 with fontconfig disabled.

Highly appreciate any assistance on this matter. Thanks in advance.

jeroen commented 4 years ago

Which OS are you on?

nickborg94 commented 4 years ago

Hi Jeroen,

I'm on Windows 10, using RStudio 1.2.5042 and R 4.0.0.

R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
jeroen commented 3 years ago

Fontconfig is only required on Linux, it shouldn't be needed on Windows. Can you try again with magick 2.5.0, to see if your font can now be found?

aljrico commented 3 years ago

I'm having the exact same issue. I can't use custom fonts.

I tried running devtools::install_version('magick', version = "2.5.0")

Then when I run str(magick::magick_config()) it says the following:

List of 22
 $ version           :Class 'numeric_version'  hidden list of 1
  ..$ : int [1:4] 6 9 11 34
 $ modules           : logi FALSE
 $ cairo             : logi TRUE
 $ fontconfig        : logi FALSE
 $ freetype          : logi TRUE
 $ fftw              : logi TRUE
 $ ghostscript       : logi TRUE
 $ jpeg              : logi TRUE
 $ lcms              : logi TRUE
 $ libopenjp2        : logi TRUE
 $ lzma              : logi TRUE
 $ pangocairo        : logi TRUE
 $ pango             : logi TRUE
 $ png               : logi TRUE
 $ rsvg              : logi TRUE
 $ tiff              : logi TRUE
 $ webp              : logi TRUE
 $ wmf               : logi FALSE
 $ x11               : logi FALSE
 $ xml               : logi TRUE
 $ zero-configuration: logi TRUE
 $ threads           : int 1

As you can see, fontconfig is still FALSE.

I'm using Windows 10, and this is what version outputs:

platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          4                           
minor          1.0                         
year           2021                        
month          05                          
day            18                          
svn rev        80317                       
language       R                           
version.string R version 4.1.0 (2021-05-18)
nickname       Camp Pontanezen 
JackDCornwall commented 2 years ago

Did anyone find a solution to this? I am unable to use certain fonts and my fontconfig is disabled on windows 10 even though i installed through CRAN

dwctran commented 1 year ago

i still have the same problem :(

jeroen commented 1 year ago

The Windows version of imagemagick doesn't use fontconfig. It gets the fonts from the MS Windows APIs.

MarkoKazimirovic commented 10 months ago

Still not working properly. The workaround is to make a .png with the desired font and then insert it back.

text_you_want <- ggplot(NULL, aes(x = 1, y = 1)) + ylim(0.8, 1.2) +
  theme_void() +
  annotate("text", 
           1,
           1.1,
           family = "Cinzel Decorative", 
           size = 85,
           color = "green",
           label = "I really want latter in this font in green color") 

ggsave(text_you_want ,
       filename = "text_you_want.png",
       w = 10,
       h = 2)

  img <- image_read("image_for_labeling.png")
  text_inset <- image_read("text_you_want.png")

  new_inset <- image_scale(text_inset, "x300") 

  img_ <- image_composite(img, 
                          new_inset, 
                          gravity = "south",
                          offset = "-1500+100")

  image_write(image = img_,
              path = "image_labeled.png")