Last active
March 27, 2022 17:17
-
-
Save KTibow/da990ea79afc38ffa7d2ec1c15fca980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
pygame.init() | |
width = 1024 | |
height = 1024 | |
screen = pygame.display.set_mode((width, height)) | |
bg = pygame.Surface((width, height), pygame.SRCALPHA) | |
font = pygame.font.SysFont("Ubuntu", 64) | |
for row_y in range(0, height, 64): | |
for col_x in range(0, width, 64): | |
# Find the correct character | |
char_index = (row_y // 64) * 16 + (col_x // 64) | |
char = chr(char_index) | |
print(col_x, row_y, char_index, char) | |
try: | |
# Add the character to the font map | |
char_img = font.render(char, True, (255, 255, 255)) | |
char_img.set_colorkey((0, 0, 0)) | |
char_dimen = char_img.get_rect() | |
char_dimen.bottomleft = (col_x, row_y + 64) | |
bg.blit(char_img, char_dimen) | |
except Exception as e: | |
print(e) | |
pass | |
# Save | |
pygame.image.save(bg, "result.png") | |
pygame.quit() |
Alternatively, just use the Smooth Font mod's config.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For 1.8.9.
You can change "Ubuntu" to whatever font you want.
To use, create a new resource pack (add the base icon +
pack.mcmeta
), then move the generatedresult.png
toassets/minecraft/textures/font/ascii.png
.