fontsfontforge

Automatically generate italic fonts from a given typeface


I'm currently building a FontForge script which converts the Cantarell set of fonts for use as webfonts. However, Cantarell doesn't actually feature oblique/italic versions of the fonts, and I prefer to automatically generate them through FontForge. I tried using foreach to select all glyphs and Italic() to generate italic versions for each of the glyphs. However, the results are still the same as the original fonts.

#!/usr/bin/fontforge
FONT_NAME = "Cantarell"
VARIANTS = ["Bold", "ExtraBold", "Light", "Regular", "Thin"]
i = 0

while (i < SizeOf(VARIANTS))
  FILE_NAME = "fonts/" + FONT_NAME + "-" + VARIANTS[i] + ".otf"
  FILE_NAME_ITALIC = "fonts/" + FONT_NAME + "-" + VARIANTS[i] + "Italic.otf"
  Print(FILE_NAME)
  Open(FILE_NAME)
  Generate(FILE_NAME:r + ".svg")
  Generate(FILE_NAME:r + ".eot")
  Generate(FILE_NAME:r + ".ttf")
  Generate(FILE_NAME:r + ".woff")
  Generate(FILE_NAME:r + ".woff2")
  foreach
    Italic()
  endloop
  Generate(FILE_NAME_ITALIC)
  Generate(FILE_NAME_ITALIC:r + ".svg")
  Generate(FILE_NAME_ITALIC:r + ".eot")
  Generate(FILE_NAME_ITALIC:r + ".ttf")
  Generate(FILE_NAME_ITALIC:r + ".woff")
  Generate(FILE_NAME_ITALIC:r + ".woff2")
  i = i + 1
endloop

enter image description here

Notes


Solution

  • Try

    SelectAll()
    Italic(15)
    

    instead of foreach-loop. Maybe Skew() instead of Italic() Method is better choice. I don't know the differeces of theese two. 15 is the number of degrees to skew.