google / fonts

Font files available from Google Fonts, and a public issue tracker for all things Google Fonts
https://fonts.google.com
18.17k stars 2.61k forks source link

Corben-Bold.ttf is blank as of 5b1755d5a63bd199951e9b9a7a6d16c0d18842ad #132

Closed matthewwardrop closed 7 years ago

matthewwardrop commented 9 years ago

In case you are unaware, as of commit 5b1755d5a63bd199951e9b9a7a6d16c0d18842ad, Corben-Bold.ttf is completely blank. I don't know enough about font generation to know why this might be, but perhaps its worth looking into. :).

davelab6 commented 9 years ago

Could you describe how to reproduce this blankness? :)

screen shot 2015-10-07 at 15 13 47
matthewwardrop commented 9 years ago

Hmmm... If you cannot reproduce it, that is odd indeed.

I used GNOME's font viewer, and see no character samples (but do for all other fonts).

Additionally, I attempt to render the font using the PIL for Python, and again see nothing (that's how I discovered the problem). The same happens on other Linux boxes also; though I have not tested on other operating systems.

m4rc1e commented 8 years ago

Are you sure you're using PIL correctly. I have no problems with this font with PIL.

Here's some test code.

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw 
img = Image.open('test.png')
draw = ImageDraw.Draw(img)
# font = ImageFont.truetype(<font-file>, <font-size>)
font = ImageFont.truetype("/Users/marc/Library/Fonts/Corben-Bold.ttf", 160)
# draw.text((x, y),"Sample Text",(r,g,b))
draw.text((0, 0),"Sample Text",(255,255,255),font=font)
img.save('test-out.jpg')

test-out

Cheers, Marc

graphicore commented 8 years ago

I was trying this on my Xubuntu machine

In [11]: import PIL

In [12]: PIL.VERSION
Out[12]: '1.1.7'

In [13]: PIL.PILLOW_VERSION
Out[13]: '3.1.2'

The script is similar to Marcs:

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
img = Image.new('RGB', (512, 512))
draw = ImageDraw.Draw(img)
# font = ImageFont.truetype(<font-file>, <font-size>)
font = ImageFont.truetype("/home/commander/Projekte/fontdev/googlefonts/fonts/ofl/corben/Corben-Bold.ttf", 160)
# draw.text((x, y),"Sample Text",(r,g,b))
draw.text((0, 0),"Sample Text",fill=(255,255,255),font=font)
img.save('test-out.jpg')

Though, getting an error:

$ python tst.py 
Traceback (most recent call last):
  File "tst.py", line 9, in <module>
    draw.text((0, 0),"Sample Text",fill=(255,255,255),font=font)
  File "/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 255, in text
    mask, offset = font.getmask2(text, self.fontmode)
  File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 151, in getmask2
    size, offset = self.font.getsize(text)
IOError: invalid reference

Which is probably the same problem as in googlefonts/fontbakery#705

Update: Corben-Regular.ttf is working

graphicore commented 8 years ago

Ok, using a virtualenv with python 3.5 and current pillow from pip:

Python 3.5.2 (default, Jul  5 2016, 12:43:10) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> PIL.VERSION
'1.1.7'
>>> PIL.PILLOW_VERSION
'3.3.1' 

I get a the same error message but an OSError instead of an IOError:

$ python tst.py 
Traceback (most recent call last):
  File "tst.py", line 9, in <module>
    draw.text((0, 0),"Sample Text",fill=(255,255,255),font=font)
  File "/home/commander/Projekte/fontdev/googlefonts/fonts/venv/lib/python3.5/site-packages/PIL/ImageDraw.py", line 233, in text
    mask, offset = font.getmask2(text, self.fontmode)
  File "/home/commander/Projekte/fontdev/googlefonts/fonts/venv/lib/python3.5/site-packages/PIL/ImageFont.py", line 151, in getmask2
    size, offset = self.font.getsize(text)
OSError: invalid reference

The error seems to come from within a freetype wrapping C module ("PIL FreeType Driver") _imagingft.c which implements the font_getsize function.

So, yeah, it seems like FreeType is somehow unhappy with the font. Since other fonts work with this script, it'd be nice to find out what goes wrong with Corben-Bold.

graphicore commented 8 years ago

Allright, here's the deal:

The Corben-Bold from 5b1755d lacks the fpgm Table which is apparently required by its prep Table

Using ttx I was able to make a TTF that works in the case above by:

a) removing the prep table

or b) copying the fpgm table from Corbin-Bold.ttf` pre 5b1755d

or c) run ttfautohint on it, just with the default values i.e. ttfautohint ../ofl/corben/Corben-Bold.ttf Corben-Bold.ttf

graphicore commented 8 years ago

How to fix this?

A) Use the ttfautohint approach from above

or B) I can't find other source repositories but there are sources for these files in old-googlefontdirectory, should we upgrade to new repo-style and Glyphs?

@davelab6 also, but a bit offtopic: Corben-Bold.ttf has many more glyphs (552) than Corben-Regular.ttf (356) seems like Bold has a set of small caps and some nice display-type ligatures with swashes and such.

These names are in Regular but not in Bold: DZ Dz Ebreve IJ Ibreve Ldotaccent Obreve dotaccentcmb dotlessj f_j ff ffi ffl fi fl foursuperior ij ldot mu onesuperior s.alt threesuperior twosuperior uni030F uni0311 uni0326

These names are in Bold but not in Regular: Dcroat Eng Hbar S.alt Scommaaccent Tbar Wacute Wdieresis Wgrave Ygrave a.sc aacute.sc abreve.sc acircumflex.sc adieresis.sc ae.sc afii00208 agrave.sc amacron.sc aogonek.sc aring.sc atilde.sc b.sc c.sc cacute.sc ccaron.sc ccedilla.sc ccircumflex.sc cdotaccent.sc commaaccent d.sc dcaron.sc dcroat dcroat#1 dcroat.sc dotlessi.sc e.sc eacute.sc ebreve.sc ecaron.sc ecircumflex.sc edieresis.sc edotaccent.sc egrave.sc eight.old emacron.sc eng eng.sc eogonek.sc eth.sc f.sc f_f.sc f_f_i.sc f_f_l.sc f_i f_i.sc f_l f_l.sc five.old four.old g.sc gbreve.sc gcaron gcaron.sc gcircumflex.sc gcommaaccent gcommaaccent.sc gdotaccent.sc h.sc hbar.sc hcircumflex.sc i.sc iacute.sc ibreve.sc icircumflex.sc idieresis.sc igrave.sc imacron.sc iogonek.sc itilde.sc j.sc jcircumflex.sc k.sc kcommaaccent.sc l.sc lacute.sc lcaron.sc lcommaaccent.sc lslash.sc m.sc minus n.sc nacute.sc ncaron.sc ncommaaccent.sc nine.old ntilde.sc o.sc oacute.sc obreve.sc ocircumflex.sc odieresis.sc oe.sc ograve.sc ohungarumlaut.sc omacron.sc one.old oslash.sc otilde.sc p.sc perthousand q.sc r.sc racute.sc rcaron.sc rcommaaccent.sc s.sc s_b s_f s_k s_p s_t_i sacute.sc scaron.sc scedilla.sc scircumflex.sc scommaaccent scommaaccent.sc sdotaccent.sc seven.old six.old t.sc t_f t_t t_t.sc tbar tbar.sc tcaron.sc tcommaaccent.sc thorn.sc three.old two.old u.sc uacute.sc ubreve.sc ucircumflex.sc udieresis.sc ugrave.sc uhungarumlaut.sc umacron.sc uni00B2 uni00B3 uni00B5 uni00B9 uni01EA uni01EB uni01EB.sc uni01F5 uni01F5.sc uni021A uni021B uni021B.sc uni1E02 uni1E03 uni1E03.sc uni1E0A uni1E0B uni1E0B.sc uni1E1E uni1E1F uni1E1F.sc uni1E40 uni1E41 uni1E41.sc uni1E45 uni1E45.sc uni1E56 uni1E57 uni1E60 uni1E61 uni1E61.sc uni1E62 uni1E62.sc uni1E63 uni1E63.sc uni1E6A uni1E6A.sc uni1E6B uni1E6B.sc uni1E8F uni1E8F.sc uni1E91 uni1E91.sc uniFB00 uniFB01 uniFB02 uniFB03 uniFB04 uogonek.sc uring.sc utilde.sc v.sc w.sc wacute wacute.sc wcircumflex.sc wdieresis wdieresis.sc wgrave wgrave.sc x.sc y.sc yacute.sc ycircumflex.sc ydieresis.sc ygrave ygrave.sc z.sc zacute.sc zcaron.sc zdotaccent.sc zero.old

matthewwardrop commented 7 years ago

Completely forgot about this! Thanks so much for sorting it out!~