Commits

Anonymous committed 053e9bf

Richer FreeType module examples.

  • Participants
  • Parent commits 4a49765
  • Branches pgreloaded

Comments (0)

Files changed (1)

examples/freetype/sdlfont.py

 except ImportError:
     print ("No pygame2.freetype support")
     sys.exit ()
-    
+
+colors = {
+    "grey_light"    :   pygame2.Color(200, 200, 200),
+    "grey_dark"     :   pygame2.Color(100, 100, 100),
+    "green"         :   pygame2.Color(50, 255, 63),
+    "red"           :   pygame2.Color(220, 30, 30),
+    "blue"          :   pygame2.Color(50, 75, 245)
+}
 
 def run():
     video.init ()
     fontdir = os.path.dirname (os.path.abspath (__file__))
     font = freetype.Font (os.path.join (fontdir, "sans.ttf"))
 
-    screen = video.set_mode (640, 480)
-    screen.fill (pygame2.Color (200, 200, 200))
-    w, h, _ = font.render("Hello", pygame2.Color(100, 100, 100), None, screen, 100, 100, ptsize=48, style=ftconstants.STYLE_BOLD)
+    screen = video.set_mode (800, 600)
+    screen.fill (colors["grey_light"])
 
-    w, h, _ = font.render("World", pygame2.Color(200, 100, 100), pygame2.Color(255, 0xCC, 0), screen, 100, 200, ptsize=48, vertical = False, rotation = -73, antialias = True)
+    font.render("Hello World", colors["red"], None, screen, 32, 32, ptsize=64, style=ftconstants.STYLE_BOLD)
+    font.render("do it now with this...", colors["grey_dark"], colors["green"], screen, 32, 128, ptsize=64)
+    font.render("Vertical?", colors["blue"], None, screen, 32, 190, ptsize=32, vertical=True)
+    font.render("Let's spin!", colors["red"], None, screen, 64, 190, ptsize=48, rotation=55)
+    font.render("All around!", colors["green"], None, screen, 150, 270, ptsize=48, rotation=-55)
+    font.render("and BLEND", pygame2.Color(255, 0, 0, 128), None, screen, 250, 220, ptsize=64)
+    font.render("or BLAND!", pygame2.Color(0, 0xCC, 28, 128), None, screen, 258, 237, ptsize=64)
+    font.render("I \u2665 Unicode", pygame2.Color(0, 0xCC, 0xDD), None, screen, 298, 320, ptsize=64)
+    font.render("\u2665", colors["grey_light"], colors["red"], screen, 480, 32, ptsize=148)
+    font.render("...yes, this is a SDL surface", pygame2.Color(0, 0, 0), None, screen, 380, 380, ptsize=24)
 
 
-#    w, g, buf = font.render("Hello World, Jay",
-#            pygame2.Color(100, 200, 32),
-#            pygame2.Color(240, 40, 100),
-#            None, ptsize = 32)
-
-#    screen.blit (buf, (5, 100))
     screen.flip ()
 
     okay = True