21

Is there a way to find name of fonts used within Gimp .xcf file?

1
  • Found out how... open it with something like scite or notepad++... Will answer my question in seven hours...
    – jaksco
    Commented Jun 18, 2011 at 17:26

3 Answers 3

12

From a linux console

grep -aPo 'font "(.*?)"' file.xcf

Sample output:

$ grep -aPo 'font "(.*?)"' file.xcf 
font "HP Simplified Italic"
font "Freehand521 BT"
font "Freehand521 BT"

Also you can look at the xcf with nano:

nano file.xcf
5
  • 1
    This didn't work for me on OS X. I'm sure there is some different syntax for grep that I'm missing.
    – user53251
    Commented Mar 27, 2019 at 4:29
  • In this case the simplest thing to do is to open the xcf with a text editor and look for font " lines Commented Sep 13, 2019 at 11:29
  • For some reason it lists some fonts, but not the ones that are being used in my file. I'm not sure why
    – Kevin
    Commented Dec 13, 2019 at 1:47
  • If you have transferred the .xcf file to a system that does not have the used fonts installed you can nano or vim the .xcf file and it will show you which font is used for which spans of text; ex: <span font=\"Font Name\"</span>
    – ma77c
    Commented Jan 11, 2020 at 17:15
  • On MacOS, you can use grep -aEo 'font "......' file.xcf.
    – rhs
    Commented Jul 27 at 10:04
17

Apart from opening the file in a text editor, I found another way to do so from within GIMP, mentioned in a German GIMP forum.

This is a Python script that can be executed from the GIMP's built-in Python console:

for image in gimp.image_list():
  for layer in image.layers:
    try:
      layer.parasite_find('gimp-text-layer').data
    except AttributeError:
      pass

It runs across all images loaded, across all layers, and dumps the data of all text layers, including font names.

2
  • I'd never used the gimp python console (or much python at all) before so I had to figure this out...I had to indent by four spaces per indentation stop or I got a syntax error.
    – Matthew
    Commented Aug 8, 2012 at 16:55
  • 2
    Same. I copypasta'd into text editor, removed dots (...) from each line, copypasta'd into GIMP > Filters > Python-Fu -> Console then hit enter two or three times to make it work. Success! Commented May 8, 2014 at 23:50
1

The accepted answer didn't work for me on Mac, so here's a solution that works with macOS grep:

grep -a 'font \"' file.xcf | sort | uniq -c

Tested with Grep version "grep (BSD grep) 2.5.1-FreeBSD". Sample output:

$ grep -a 'font \"' file.xcf | sort | uniq -c
   1 (font "Alison Ultra-Light")
  11 (font "Ambient")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .