cmu-cs-academy / desktop-cmu-graphics

BSD 3-Clause "New" or "Revised" License
15 stars 9 forks source link

Enables fonts other than Arial and Courier New #52

Closed shawnsihyunlee closed 9 months ago

shawnsihyunlee commented 9 months ago

This change allows users to use fonts other than Arial and Courier New. This is achieved by changing getFont() in shape_logic.py to actually use the baseFontName argument, whereas currently it forces users to use Arial if baseFontName is not one of several predefined fonts. This decision was likely made for avoiding compatibility issues, but the change allows students larger freedom in designing their offline projects.

schmave commented 9 months ago

Thanks @shawnsihyunlee! This looks reasonable. What happens if you try to use a font that doesn't exist on your computer? Is there an error or does it fallback to some other font? If there's an error, is the error easy to understand?

shawnsihyunlee commented 9 months ago

It seems to just fall back to Arial or some default font! No errors that lead to a crash or anything.

schmave commented 9 months ago

Terrific! I'll merge this and let you know when a new version is live on pypi.

schmave commented 9 months ago

The new version that includes your change (1.1.27) is live on PyPI now, so it can be installed via pip: https://pypi.org/project/cmu-graphics/#history

The zip file linked from our website is also updated. https://academy.cs.cmu.edu/desktop

schmave commented 9 months ago

Thanks again for your contribution!

schmave commented 9 months ago

Screenshot 2023-11-21 at 4 18 53 PM

(I just double checked and this worked for me once I upgraded the library.)

from cmu_graphics import *

def onMousePress(x, y):
    Label('Hello, world!', x, y, font='Academy Engraved LET', size=64)

cmu_graphics.run()