Giter Site home page Giter Site logo

bitmap2ttf's People

Contributors

ali1234 avatar codeman38 avatar dfrunza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bitmap2ttf's Issues

Converting Tewi.bdf to ttf

Hello, I'm having some troubles understanding on how this works. I have a font called Tewi in bdf format. I'd like to convert it to ttf. I used convert.py tewi.bdf and its output was outliner.pyc. I've tried doing outliner.py outliner.pyc and outliner.py tewi.bdf and I get IOError: cannot identify image file 'outliner.pyc (or tewi.bdf)'

What am I doing wrong? Do I need to use Font Forge in some way? Thanks.

Exception: Inconsistent ascent and descent. This case is not handled yet. Please report a bug

Hi,
I got the exception when would like to run pcftottf, log as below:
adam@adam-HP-280-Pro-G2-MT:~/works/android/tools/bitmap2ttf/bitmap2ttf-master-3.8$ pipenv run pcftottf zpix.pcf zpix.ttf Traceback (most recent call last): File "/home/adam/.local/share/virtualenvs/bitmap2ttf-master-3.8-45YaeVfq/bin/pcftottf", line 33, in <module> sys.exit(load_entry_point('bitmap2ttf', 'console_scripts', 'pcftottf')()) File "/home/adam/.local/share/virtualenvs/bitmap2ttf-master-3.8-45YaeVfq/lib/python3.8/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/home/adam/.local/share/virtualenvs/bitmap2ttf-master-3.8-45YaeVfq/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/adam/.local/share/virtualenvs/bitmap2ttf-master-3.8-45YaeVfq/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/adam/.local/share/virtualenvs/bitmap2ttf-master-3.8-45YaeVfq/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/adam/works/android/tools/bitmap2ttf/bitmap2ttf-master-3.8/bitmap2ttf/convert.py", line 109, in _convert glyphs, _ascent, _descent = f(*args, **kwargs) File "/home/adam/works/android/tools/bitmap2ttf/bitmap2ttf-master-3.8/bitmap2ttf/pcftottf.py", line 87, in pcftottf f = PcfFontFileUnicode(pcffont) File "/home/adam/works/android/tools/bitmap2ttf/bitmap2ttf-master-3.8/bitmap2ttf/pcftottf.py", line 56, in __init__ raise Exception('Inconsistent ascent and descent. This case is not handled yet. Please report a bug') Exception: Inconsistent ascent and descent. This case is not handled yet. Please report a bug

respecting bbox? (and BDF to TTF converter)

I'm finding a way that can respecting bbox since fontforge will trim the bitmap.

bdftottf.py:

try:
    from PIL.BdfFontFile import *
except ImportError:
    from BdfFontFile import *

class BdfFontFileUnicode(FontFile.FontFile):

    def __init__(self, fp):

        FontFile.FontFile.__init__(self)

        s = fp.readline()
        if s[:13] != "STARTFONT 2.1":
            raise SyntaxError, "not a valid BDF file"

        props = {}
        comments = []

        while 1:
            s = fp.readline()
            if not s or s[:13] == "ENDPROPERTIES":
                break
            i = string.find(s, " ")
            props[s[:i]] = s[i+1:-1]
            if s[:i] in ["COMMENT", "COPYRIGHT"]:
                if string.find(s, "LogicalFontDescription") < 0:
                    comments.append(s[i+1:-1])

        font = string.split(props["FONT"], "-")

        font[4] = bdf_slant[string.upper(font[4])]
        font[11] = bdf_spacing[string.upper(font[11])]

        ascent = int(props["FONT_ASCENT"])
        descent = int(props["FONT_DESCENT"])

        fontname = string.join(font[1:], ";")

        # print "#", fontname
        # for i in comments:
        #       print "#", i

        self.glyph = {}

        font = []
        while 1:
            c = bdf_char(fp)
            if not c:
                break
            id, ch, (xy, dst, src), im = c
            if ch >= 0: # and ch < len(self.glyph):
                self.glyph[ch] = xy, dst, src, im

if __name__ == '__main__':
    import sys
    from convert import convert
    for filename in sys.argv[1:]:
        p = BdfFontFileUnicode(file(filename))
        glyphmap = {}
        for k,v in p.glyph.iteritems():
            print k,v
            glyphmap[k] = v[3]
        convert(glyphmap, filename[:-4])

Space character width

I'm trying to convert the Tamsyn 8x15 font (or its derivative Tamzen) for use with Sublime Text, but the resulting TTF has the space character come out the wrong size. Hard tabs line up correctly with the text, but single spaces do not:

space_width

I'm not sure whether this is a bug in the font definition, in bitmap2ttf, or in Sublime Text. Other editors don't seem to have this bug, using the same TTF file. Does anybody know how to fix it?

Edit: all metrics returned from self._load_metrics() are the same exact tuple (8, 15, 0, 8, 8, 12, 3, 0) and all SetWidth(%d) generated by convert.py have the same width (533). I really can't see what's causing this issue.

How to use please ?

1672296125175

Clearly confirm that there is already "import convert"
But it shows "no model convert"

I want to convert .bmp to ttf
Can anyone help me?

ValueError: not enough image data

Just wanted to start by thanking you for making this. Very cool utility.

I've successfully used this to convert a .pcf font from gohufont into a ttf.

However I am now trying to convert from a fontforge file New York.sfd into a non bitmapped ttf.

My workflow is to save out a .bdf from the .sfd. I then use bdftopcf to convert the bdf file into pcf.

Unfortunately, there is something wrong with the resulting pcf. I can open it with fontforge and view all the glyphs - everything looks fine. But I get this error when running your script.

Traceback (most recent call last):
  File "pcftottf.py", line 88, in <module>
    p = PcfFontFileUnicode(file(filename))
  File "pcftottf.py", line 38, in __init__
    bitmaps = self._load_bitmaps(metrics)
  File "/usr/local/lib/python2.7/site-packages/PIL/PcfFontFile.py", line 225, in _load_bitmaps
    Image.frombytes("1", (x, y), data[b:e], "raw", mode, pad(x))
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 2100, in frombytes
    im.frombytes(data, decoder_name, args)
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 742, in frombytes
    raise ValueError("not enough image data")
ValueError: not enough image data

Any idea what is going on here? I have no clue where to start writing my own loader, so any tips on converting the type would be greatly appreciated.

thanks!

PIL ValueError: tile cannot extend outside image

Hello. Your project is awesome and I was amazed that it actually works.

I am trying to convert artwiz fonts (which are in pcf format) to ttf, and for some of them it shows the error in the title.
Trace is this:

 Traceback (most recent call last):
  File "./pcftottf.py", line 88, in <module>
    p = PcfFontFileUnicode(file(filename))
  File "./pcftottf.py", line 38, in __init__
    bitmaps = self._load_bitmaps(metrics)
  File "/usr/lib64/python2.7/site-packages/PIL/PcfFontFile.py", line 223, in _load_bitmaps
    Image.frombytes("1", (x, y), data[b:e], "raw", mode, pad(x))
  File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 1825, in frombytes
    im.frombytes(data, decoder_name, args)
  File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 601, in frombytes
    d.setimage(self.im)
ValueError: tile cannot extend outside image

Do you know whats possibly going on? For some other files, it works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.