ropod7 / pyboard_drive

22 stars 11 forks source link

Bugs fixed and features added. #28

Closed ropod7 closed 8 years ago

mchobby commented 8 years ago

Hi Roman, I thing than " Added 'null' key " is not a good idea because generator software cannot guest what it should generate for 'null'. This introduces human action on font files whereas it is fully automated at the moment.

May I suggest an hard coded drawLine() instructions in the printing/rendering routine when the character is missing in the font? This would preserve the automated ft-generator (I'm planning to produce other fonts when fonts will be encoded inside binary font files). This would also avoids human update in the Arial_14.py file (and the other).

ropod7 commented 8 years ago

We may change empty keys with something. Shore You may suggest. Thanks.

mchobby commented 8 years ago

Why not drawing an white box or white rectangle? (with font height and font height). In normal operation, user would not print missing characters... and drawing a box will indicates an issue with a missing character in the font. Such approach would also make sense for the Windings (Glyphs) fonts where character availability is very unpredictable.

I would suggest the printChar() to take it in charge himself. So it would work properly with all fonts.

Here a suggestion with meta code.

    def printChar(self, char, x, y, cont=False, scale=None):
        if not scale:
            scale = self._fontscale
        font = self._font
        if self.portrait != ILI._portrait:
            self.portrait = ILI._portrait
        self._fontscale = scale = 5 if scale > 5 else scale
        index = ord(char)
        height = font['height']
        try:
            chrwidth = len(font[index]) * scale
            data = font[index]
        except KeyError:
            data = None 
            chrwidth =  font['width'] * scale
        X = self.TFTHEIGHT - y - (height * scale) + scale
        Y = x
        self._char_orientation()
        # Garbage collection
        self._gcCollect()
        if data == None:
             drawing the rectangle here
        else:
            self._fill_bicolor(data, X, Y, chrwidth, height, scale=scale)
        if not cont:
            self._graph_orientation()
ropod7 commented 8 years ago

It's true. I will fix that.