Git Product home page Git Product logo

Comments (3)

arp242 avatar arp242 commented on May 18, 2024 1

My first thought would be to say that this is out-of-scope for uni. I think a "query font information from the commandline" would be a neat tool, but I'm not sure if it should be integrated in here. While Unicode and fonts are related, they're quite different domains.

With a hypothetical glyph tool you could do something like:

$ uni -q p U+2042 | glyph

I don't know if something like that exists, but it shouldn't be too hard to modify your Perl example to read from stdin.

You can get the same information with fc-cat by the way, which includes the charset ranges.

Maybe I'll write the glyph tool, or maybe I'll change my mind and add it uni anyway ... I'll have a think about it. We'll need configurable columns first anyway.

from uni.

khughitt avatar khughitt commented on May 18, 2024

@arp242 That is totally reasonable. Having that sort of functionality would be very useful for tasks relating to configuring polybar, powerline, etc. applications which tend to use unicode glyphs that are often highly font-specific, however, that doesn't mean that uni necessarily the best place to support such a feature.

Thanks for the suggestion regarding fc-cat! That is one of the fontconfig tools I hadn't looked at before.

Sounds good though -- I'll leave the issue open for now.

from uni.

arp242 avatar arp242 commented on May 18, 2024

I looked a bit at this today, and it's kinda hard to get a good overview of this as far as I can tell. One of the bigger problems is that I can't figure out how to determine if a font supports a particular emoji (only codepoints, but emojis consist of more than one codepoint).

Adding a font parsing library would be too much IMO, not in the least because many of them only deal with one particular font, so to support TrueType, OpenType, Type1, raster fonts, etc. and it would require adding list of libraries; I also can't really figure out how to get this information from reading the docs and many libraries for Go seem unfinished and unmaintained.

In short, the entire thing would be a project into itself. It's extremely unlikely I'll ever do this, so I figure I might as well close this.

I did manage to cook up a little script for fc-cat (but it doesn't deal with emojis); not very polished but I figured I might as well post it here. If someone can figure out how to get the emoji data from this too then I don't mind adding it to the repo, but I'd rather not add something half-working.

#!/bin/sh

set -euC

font="$(fc-cat 2>&1 | grep -Ei '^"dejavusansmono.ttf[^"]*?"')"
charset="$(printf "$font" | grep -Eo 'charset=[a-f0-9 -]+')"
charset="${charset#charset=}"

char=2e22
#char=2e1f
#char=6e1f

char_dec=$(printf '%d' "0x$char")
IFS=" "
for c in $charset; do
	case "$c" in
		*-*)
			start="$(printf '%d' 0x${c%-*})"
			end="$(printf '%d' 0x${c#*-})"
			if [ $char_dec -ge $start ] && [ $char_dec -le $end ]; then
				echo "U+$char is supported by this font"
				exit 0
			fi
			;;
		*)
			if [ "$char" = "$c" ]; then
				echo "U+$char is supported by this font"
				exit 0
			fi
			;;
	esac
done

echo "U+$char is NOT supported by this font"
exit 1

from uni.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.