diff --git a/Resources/ArchitectsDaughter.ttf b/Resources/ArchitectsDaughter.ttf new file mode 100644 index 0000000..e87c526 Binary files /dev/null and b/Resources/ArchitectsDaughter.ttf differ diff --git a/chatanalyzer/analyzing.py b/chatanalyzer/analyzing.py index ad6dca7..746ef42 100644 --- a/chatanalyzer/analyzing.py +++ b/chatanalyzer/analyzing.py @@ -56,6 +56,7 @@ def make_wordcloud(WORDS_IN_CHAT): wordcloud = WordCloud(width = 2000, height = 2000, background_color = None, mode="RGBA", + font_path=f"{RESOURCE_LOCATION}/ArchitectsDaughter.ttf", prefer_horizontal=1, mask = img_mask, # relative_scaling=1, @@ -82,7 +83,8 @@ def make_timeline(participants): "title": {"text": "Timeline of Messages", "xanchor": "center", "x": 0.5, - "font": {"color": "white"}}, + "font": {"color": "white", + "family": "Architects Daughter"}}, "xaxis": {"showgrid": False, "title": "", "color": "white"}, @@ -90,6 +92,7 @@ def make_timeline(participants): "nticks": 2, "title": "", "color": "white"}, + "font": {"family": "Architects Daughter"}, "paper_bgcolor": 'rgba(0,0,0,0)', "plot_bgcolor": 'rgba(0,0,0,0)' }) @@ -108,6 +111,7 @@ def make_barchart(participants, WORDS_IN_CHAT): for p in participants: df_c = pd.DataFrame({"message": [], "counts": [], "sender": []}) df_p = p.words.loc[p.words['message'].isin(list(words.keys()))] + df_c.plot() words_count = df_p['message'].value_counts().sort_index() df_c = words_count.rename_axis('message').reset_index(name='counts') @@ -125,7 +129,8 @@ def make_barchart(participants, WORDS_IN_CHAT): "bargap": 0.5, "title": {"text": "MOST USED WORDS", "x": 0.5, - "font": {"color": "white"}}, + "font": {"color": "white", + "family": "Architects Daughter"}}, "xaxis": {"showgrid": False, "title": "", "nticks": 5, @@ -135,6 +140,7 @@ def make_barchart(participants, WORDS_IN_CHAT): "categoryorder": "sum ascending", "title": {"text": ""}, "color": "white"}, + "font": {"family": "Architects Daughter"}, "paper_bgcolor": 'rgba(255,255,255,0)', "plot_bgcolor": 'rgba(255,255,255,0)' }) diff --git a/chatanalyzer/make_final.py b/chatanalyzer/make_final.py index 150ff67..e633309 100644 --- a/chatanalyzer/make_final.py +++ b/chatanalyzer/make_final.py @@ -7,20 +7,21 @@ RESOURCE_LOCATION = f"{path.abspath('Resources')}" def generate_images_from_text(x, y, txt): fontsize = 1 # starting font size + font =f"{RESOURCE_LOCATION}/ArchitectsDaughter.ttf" img = Image.new('RGBA', (x, y), (0, 0, 0, 0)) # portion of image width you want text width to be img_fraction = 0.80 - fnt = ImageFont.truetype('/home/koma52/.fonts/Ubuntu.ttf', fontsize) + fnt = ImageFont.truetype(font, fontsize) while fnt.getbbox(str(txt))[2] - fnt.getbbox(str(txt))[0] < img_fraction*img.size[0]: # iterate until the text size is just larger than the criteria fontsize += 1 - fnt = ImageFont.truetype("/home/koma52/.fonts/Ubuntu.ttf", fontsize) + fnt = ImageFont.truetype(font, fontsize) # optionally de-increment to be sure it is less than criteria fontsize -= 1 - fnt = ImageFont.truetype("/home/koma52/.fonts/Ubuntu.ttf", fontsize) + fnt = ImageFont.truetype(font, fontsize) d = ImageDraw.Draw(img) d.text((x/2,y/2), str(txt), font=fnt, fill=(255,255,255), anchor="mm") diff --git a/requirements.txt b/requirements.txt index 0511c96..07106a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ pandas wordcloud numpy plotly -kaleido \ No newline at end of file +kaleido +emoji \ No newline at end of file