fuhsjr00 / bug.n

Tiling Window Manager for Windows
GNU General Public License v3.0
3.36k stars 214 forks source link

Use icon fonts in views name #222

Open Robindubois0 opened 5 years ago

Robindubois0 commented 5 years ago

Is it possible to use icon fonts like font awesome in the view name? I don't find anything about changing the fonts in the documentation. I know that autohotkey allows it but it's too complicated to find which file to modify in bug.n to achieve this. Can someone point me in the right direction?

Thanks in anticipation

eidetic-av commented 5 years ago

I've been using unicode characters and for view names you can just change this in the config file.

For example, Config_viewNames=▲;■;👽 works fine if you save the config file in UTF-8.

For font awesome set the font (Config_fontName) and you can copy the desired unicode symbol from their website. You might need to patch font-awesome onto a different font if you want a different font for other text.

Robindubois0 commented 5 years ago

Thanks eidetic-av ! My config.ini was saved in UTF-8 without bom. I changed it to UTF-8 and now it works as you said. I have to patch it onto a different font. Does that mean that there is no way to use more than one font in the status bar?

eidetic-av commented 5 years ago

No you can use many fonts -- you're right it would be way easier to change fonts rather than patch one together.

I've added to my Config.ahk: Config_viewFontName := "Lucida Console"

And modify Bar.ahk to switch to this newly defined font before it draws the view labels (around line 48):

  ;; Set font to Config_viewFontName specified in config.ini
  Gui, Font, c%Config_fontColor_#1_#3% s%Config_fontSize%, %Config_viewFontName%

  ;; Create all the view names
  Loop, % Config_viewCount {
    w := Bar_getTextWidth(" " Config_viewNames_#%A_Index% " ")
    Bar_addElement(m, "view_#" A_Index, " " Config_viewNames_#%A_Index% " ", x1, y1, w, Config_backColor_#1_#1, Config_foreColor_#1_#1, Config_fontColor_#1_#1)
    titleWidth -= w
    x1 += w
  }

  ;; Set font back to Config_fontName for drawing the rest of the bar
  Gui, Font, c%Config_fontColor_#1_#3% s%Config_fontSize%, %Config_fontName%

Now when you set the new property Config_viewFontName in your config.ini, it will only affect the font that displays the views!

You could also do a similar thing for font size and colours... time to get creative!

Robindubois0 commented 5 years ago

Thanks again! That is exactly what I was looking for.