ocodo / ClockFace-font

Icon font for displaying the time

Home Page:https://ocodo.github.io/ClockFace-font/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: suggestions on application of the font?

mclearc opened this issue · comments

This font is great -- and a cool idea. I'm not entirely sure how to apply it to something like the modeline though. I assume creating an alist of names and unicode and then maybe something like all-the-icons for applying it. But is there an easier way to create the alist other than copy/paste?

It would be best if it had it's own propertize feature to make it easy to use. I can do that too.

Probably simplest to give the function a time and it gives you the right icon.

  • Create an Emacs face defface that uses the font.
  • Supply the font as part of a package. (I'll create a clean repo for that on Emacsfodder)
    • Package to include everything needed to use it in any context.
      • Most importantly, a defun which makes a propertized string, which uses the defface defined above, and can accept time args. Simplest if it can be hour. min, min-rounding (any multiple of 5)... something like that.

The repo is very unorganized at the moment, I've been working out a way to systematically draw the SVG / convert it to single outline so it's very easy to create variations / tweak a design
and push a new version of an icon set.

https://gitter.im/ocodo# should let you in. // Although I'm not packing up for the day. More tomorrow.

Hi @mclearc just uploaded the latest variations.

https://ocodo.github.io/ClockFace-font

I can get these ready for use in Emacs shortly. I think the steps above are ok.

BTW the alist is of little to no use. We can map approx time (5min intervals) directly to a unicode value. I don't think there is much use for a name like clock-00-00 when you can just get the correct icon by supplying hour and minute.

These look fantastic!

I'm adding a workflow to generate the fonts using GitHub actions.

The load out is essentially:

  • Ubuntu latest

Dependencies:

  • fontforge
  • inkscape

Then a set of SVG files (single path glyphs) can be in a folder, and an icon font will be defined by

  • Name
  • Date
  • Copyright
  • EM (WIDTH)
  • ASCENT
  • DESCENT
  • SVG Folder

FYI there's a typo in the function clockface-icons-now-unicode -- it references the non-existent clockicon... function instead of clockface-icon....

Also -- I'm not seeing the function work with the icons to display time in the modeline (though emacs definitely is picking up the icons). I instead get a number, like "59500". Maybe I've installed them wrong? (I'm on macos and just add the ttf fonts to FontBook).

Have a look at my branch of lambda line

display-time-on-modeline

The number you're getting is the decimal glyph id

We use

(char-to-string unicode-glyph-id) 

To get the Unicode glpyh/char and then apply the font family to show the clock face (which is prototyped in my branch)

Perfect -- that works!

Btw have you got a good method of resetting/reloading the modeline?

I have to restart Emacs after recompiling to be sure I'm getting it to update properly (or I'm just doing it wrong!)

Btw have you got a good method of resetting/reloading the modeline?

a combination of (force-mode-line-update) and reverting buffers usually works.

I'm getting some wierd glyph collisions that, I don't understand at all.

To work around it I'm going to shift to a different Unicode PUA (Private Use Area) starting at 0xF0000 which looks empty.

I'll post again when it's done, I'll need to update all the documentation and regenerate the fonts.

Fonts regenerated new range 0xF0000..0xF008F

(set-fontset-font "fontset-default"
                      (cons (decode-char 'ucs #xF0000)
                            (decode-char 'ucs #xF008F))
                      "ClockFace")

This can be used to make the range #xF0000..#xF008F use ClockFace

Pushed an update, unicode char selection fixed.

Notes:

  • Using Doom Emacs, the fontsets are messed with on every text scale / zoom action.

  • On a clean config (emacs -Q) setting the fontset as above, makes everything work.

I literally just discovered fontsets in Emacs. If you have any insights on this, please share.

I think using this range should be fine, it's one of the unicode private user areas, so other icons may use it in future. For now nothing in all-the-icons goes up this far. (Although it's possible that I missed something!)

Anyway, once we've put the fontset in place, we're done with regular configs, Spacemacs or others may also do things with Fontsets, but I think that's entirely outside the scope of Lambda line, but that's really your call.

I think opening an issue here for "Doom Emacs + text scaling breaks the clock icon" should be sufficient. I expect there's some redisplay hook that's resetting the default fontset.

I will also try setting a custom fontset for the clock icon and see how that plays, if we're lucky it'll clean up everything. (I'll go do that now!)

Ok, setting a custom fontset doesn't give the expected result, and the general advice seems to be add to the fontset-default so I've included it in the time function so that it reverts if some external thing (Doom Emacs) clobbers it.

I Will add a check to only trigger that if it's needed, I expect it'll have unintented results if it's called a bunch of times (it's already frozen once) updating a table which has 1.5m entries per font, doesn't make me think pinging it all over the place is all that great.

Ok, I think all that's needed is a one time call of this form.

(set-fontset-font "fontset-default"
                      (cons (decode-char 'ucs #xF0000)
                            (decode-char 'ucs #xF008F))
                      "ClockFace")

Doom does screw it up, but the font handling is a rabbit hole I have no patience for now.

I managed to mess up time decoding in the earlier push, but that's fixed now.

The only thing to decide is where to put the fontset form. If it's on a system that isn't running Doom, it should only be needed to run once at startup.

(defun lambda-line-setup-clockface-icons () 
  "Add clockface unicode icons into the default fontset."
  (interactive)
  (set-fontset-font
    "fontset-default"
    (cons (decode-char 'ucs #xF0000)
          (decode-char 'ucs #xF008F))
    "ClockFace")

I'll add this and put a mention of it in README tomorrow. The PR should be ready to go after that.

Note: It'll be worth making this extended functionality.

  • if we don't have a ClockFace font available, we should fetch the fonts .zip and install them during lambda-line-setup-clockface-icons

Looks great! Seems like I can close this issue now too.