Inspired by various Andoid themes on xda-developers, I wanted text only icons.
I started whipping up icons in Photoshop, but it was a pain to try new fonts (yes I know PS has scripting...).
So I created a python script to generate a series of icons and zip them up.
The script uses Python Image Library, to render separate transparent PNG files.
from PIL import Image, ImageDraw, ImageFont
import zipfile
import os
class iconpack:
def __init__(self, zipfsp, fontfsp, fontsize, height, width):
self.zip=zipfile.ZipFile(zipfsp, mode='w') # create the zip file
self.fontfsp=fontfsp
self.fontsize=fontsize
self.h=height
self.w=width
def addicon(self,lines):
iconfsp=self.render(lines)
self.zip.write(iconfsp) # add the icon tot he zip file
os.remove(iconfsp) # delete the remaining icon file
def render(self, lines):
im =Image.new("RGBA",(self.w,self.h),(0,0,0,0)) # adjust the 4th zero to adjust transparency
draw = ImageDraw.Draw(im)
font = ImageFont.truetype(self.fontfsp,self.fontsize) # the font file needs to be accessible
y=0
for line in lines:
rendered_hw=font.getsize(line) # figure out how wide the rendered text will be
x=im.size[0]/2-(rendered_hw[0]/2) # so we can centre it
draw.text((x,y), line, font=font)
y+=rendered_hw[1]-5 # adust the gap between the lines
# write image file
iconfsp=lines[0]+"_"+lines[1]+".png"
im.save(iconfsp, "png")
del im
return iconfsp
# II saw an iconpack on xda which used 46x81, on the shoulders of giants, etc
# zipfile, font file, font size, width and height
ip=iconpack('DroidSans.zip','DroidSans.ttf',23,46,81)
ip.addicon(["Inter", "Webs"])
ip.addicon(["My", "Email"])
ip.addicon(["Work", "Email"])
ip.addicon(["Snap", "Shot"])
ip.addicon(["Pod", "Casts"])
ip.addicon(["Audio", "Books"])
ip.addicon(["The", "Mrs"])
ip.addicon(["Bar", "Code"])
ip.addicon(["Four", "Square"])
ip.addicon(["SMS", ""])
ip.addicon(["Maps", ""])
ip.addicon(["Reddit", "is fun"])
Here's hows the icons turned out. I tried a few fonts from FontSpace, but settled on DroidSans.
7 comments:
Great thanks for these!
Alex
good article written by you nice blog Hindbiz
Thank you very much for your great information. It really makes me happy and I am satisfied with the arrangement of your post. You are really a talented person I have ever seen. I will keep following you forever. If you have time you can check how to make the most of your netflix subscription
your article is awesome always follow your blog and found most interesting topics I also start a blog on How to download,update and manage apps from the Google Play Store.
This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. !And also found, keep you visa card safe
Your posts are really helpful to me. Its easy to understand and informative. And you can also check Winrar a software for Creating self-extract files and Backup your files.
I write copy for the digital world and love creating material that converts – from short SEO-optimized landing pages, to complete website reels.
My specialty is using data and research to tell an authentic story in a relatable and engaging way ,
Here is my work How to get free robux
Post a Comment