Skip to content

Is it possible to include ttf-mscorefonts-installer package into the image file? #751

Closed

Description

@ddemidov

Activity

  1. ddemidov commented on Sep 27, 2016

    @ddemidov
    MemberAuthor

    Pinging @ndward

  2. added a commit that references this issue on Sep 27, 2016
  3. dlech commented on Sep 27, 2016

    @dlech
    Member

    We can. I think bitmap fonts look much better on the EV3 than TTFs though.

    http://stackoverflow.com/questions/12384838/using-fonts-in-pil-without-freetype#12388342

  4. dlech commented on Sep 27, 2016

    @dlech
    Member

    Ignore the part in the stack overflow link about converting ttf fonts. I just included it to give a hint on how PIL uses bitmap fonts.

  5. dlech commented on Sep 27, 2016

    @dlech
    Member

    Perhaps ev3dev-lang-python could use this tool to create some "built-in" fonts that look really good on the EV3.

  6. ddemidov commented on Sep 27, 2016

    @ddemidov
    MemberAuthor

    The biggest problem with this (at least for me) would be to choose what fonts and at what size to include into the library. But I agree having some defaults with a nice interface around them would be nice. @ndward, you played with TTF fonts on EV3, do you have any preference by now?

  7. ndward commented on Sep 29, 2016

    @ndward

    I only tried a couple of standard fonts: Arial, Courier_New and Verdana (Verdana didn't work). Courier_New is less attractive but has the big advantage of being fixed-width. Some examples (there are some odd characters included to test descenders and tiny artefacts caused by my lazy way of running scripts from SSH). It's a pity multiline and align aren't available.

    Arial 22:
    arial22

    Courier_New_Bold 22:
    courier_new_bold22

    Arial 38:
    arial38

    Arial_Bold 38:
    arialbold38

    Courier_New_Bold 32:
    courier_new_bold32

    Courier_New_Bold 42:
    courier_new_bold42

    (Courier_New is too skinny.)
    Here is the script I used:

    #!/usr/bin/env python3
    from ev3dev.ev3 import *
    from PIL import Image, ImageDraw, ImageFont  
    from time import sleep
    
    lcd = Screen()
    
    f = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf', 42)
    lcd.draw.text((2,0),  'This is_py', font=f)
    lcd.draw.text((2,40), 'Couriyr', font=f)
    lcd.draw.text((2,80), 'size_42 yh', font=f)
    '''
    f = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf', 38)
    lcd.draw.text((2,0),  'This is_py', font=f)
    lcd.draw.text((2,40), 'Arial_Bold', font=f)
    lcd.draw.text((2,80), 'size 38 yh', font=f)
    
    f = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf', 32)
    lcd.draw.text((2,0),  'Courier', font=f)
    lcd.draw.text((2,31), '_New_Bold', font=f)
    lcd.draw.text((2,62), 'font yhph', font=f)
    lcd.draw.text((2,93), 'size 32 y', font=f)
    '''
    lcd.update()
    
    sleep(12)  # for Brickman
    
  8. ndward commented on Sep 29, 2016

    @ndward

    The biggest problem with this (at least for me) would be to choose what fonts and at what size to include into the library.

    But aren't TrueType fonts scalable so one does not have to choose a size?

  9. ddemidov commented on Sep 29, 2016

    @ddemidov
    MemberAuthor

    My understanding is one needs to chose the exact size to render a truetype font into a bitmap (rasterized) font.

  10. dlech commented on Sep 29, 2016

    @dlech
    Member

    Truetype fonts will still look bad at sizes < 20 even if converted to a bitmap. I am suggesting that you use actual bitmap fonts that were created for fixed sizes. For example, most, if not all of the xfonts-* packages are bitmap fonts. xfonts-75dpi would be a good place to start. These packages ship the fonts in a .pcf format. However, there is a pcf2bdf tool to "decompile" them. to .bdf. Then use the info in the stackoverflow link above to convert the .bdf to a PIL font format.

    If you make this part of the build process for the ev3dev-lang-python project, then you can just ship the PIL format fonts and have good looking easy to use fonts.

  11. ddemidov commented on Sep 30, 2016

    @ddemidov
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions