Method: #CheckTTF

Defined in:
lib/makefont.rb

#CheckTTF(file) ⇒ Object



1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
# File 'lib/makefont.rb', line 1590

def CheckTTF(file)

    rl = false
    pp = false
    e  = false

    # Check if font license allows embedding
    File.open(file, 'rb') do |f|

        # Extract number of tables
        f.seek(4, IO::SEEK_CUR)
	nb = ReadShort(f)
        f.seek(6, IO::SEEK_CUR)

        # Seek OS/2 table
	found = false
        0.upto(nb - 1) do |i|
            if f.read(4) == 'OS/2' then
                found = true
                break
            end

           f.seek(12, IO::SEEK_CUR)
        end

	if ! found then
            return
        end

        f.seek(4, IO::SEEK_CUR)
        offset = ReadLong(f)
        f.seek(offset, IO::SEEK_SET)

        # Extract fsType flags
        f.seek(8, IO::SEEK_CUR)
	fsType = ReadShort(f)

	rl = (fsType & 0x02) != 0
	pp = (fsType & 0x04) != 0
	e  = (fsType & 0x08) != 0
    end

    if rl && ( ! pp) && ( ! e) then
        puts 'Warning: font license does not allow embedding'
    end
end