Re: [racket-users] racket/draw: how to extract the path from a font% object?

2020-04-02 Thread Matthew Butterick
The thorny issue that `fontconfig` handles is mapping from a high-level 
specification of a font (e.g., family, weight, slant) — that is, how a user 
would typically specify a font — to an actual font file on disk. 

The shortcoming with font filenames is that they don't reliably tell you 
anything about the font inside. So `fontconfig` digs out metadata from the file 
itself (IIUC) and uses this to guess which font file best suits your wishes. 
(Also, Racket ships with `fontconfig`, so it’s guaranteed to be available.)

Most of `fontland` is esoteric nonsense, but for the benefit of future list 
spelunkers, here's how I used `fontconfig` (badly, perhaps) to solve this 
problem:

https://github.com/mbutterick/fontland/blob/master/fontland/font-path.rkt


> On Apr 1, 2020, at 8:14 PM, David Storrs  wrote:
> 
> I knocked together a very minimal pure-Racket library for this so you
> don't have to FFI.  It won't give you all the bells and whistles, but
> it should be a good starting point.
> 
> https://pkgd.racket-lang.org/pkgn/package/font-finder
> 
> Docs:   https://github.com/dstorrs/font-finder/blob/master/README.md
> 
> Newly arrived on a package server near you.
> 
> ...where I note there is a newly-created package named 'fontland' that
> was put up by Matthew and probably does all this and more.  Doh.
> 
> Well, hopefully this helps a little bit.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/4D36EF85-1278-42CF-AEAF-86C8822FF064%40mbtype.com.


Re: [racket-users] racket/draw: how to extract the path from a font% object?

2020-04-01 Thread David Storrs
I knocked together a very minimal pure-Racket library for this so you
don't have to FFI.  It won't give you all the bells and whistles, but
it should be a good starting point.

https://pkgd.racket-lang.org/pkgn/package/font-finder

Docs:   https://github.com/dstorrs/font-finder/blob/master/README.md

Newly arrived on a package server near you.

...where I note there is a newly-created package named 'fontland' that
was put up by Matthew and probably does all this and more.  Doh.

Well, hopefully this helps a little bit.




On Wed, Apr 1, 2020 at 2:48 PM Matthew Butterick  wrote:
>
> The answer is you can't, through pure Racket, because Racket delegates the 
> nitty-gritty of font-file resolution to external font-handling libraries.
>
> It is possible, however, to call into the `fontconfig` library via the FFI 
> and make it do the heavy lifting of 1) scanning font directories to amass a 
> list of possible fonts and then 2) finding a match for a certain query 
> pattern, say a family name.
>
>
>
> On Mar 31, 2020, at 4:52 PM, Matthew Butterick  wrote:
>
> IIUC every `font%` object must correspond to a particular font file on disk.
>
> If so, given a `font%` object, how do I extract the path to that file?
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/C28B01B3-4772-4AA4-899C-78DADE7B8B2A%40mbtype.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoeWGa4M37BHYu82HbL0qk9xjuqMwRNT0J3_K%3DW2K3BP2g%40mail.gmail.com.


Re: [racket-users] racket/draw: how to extract the path from a font% object?

2020-04-01 Thread Matthew Butterick
The answer is you can't, through pure Racket, because Racket delegates the 
nitty-gritty of font-file resolution to external font-handling libraries.

It is possible, however, to call into the `fontconfig` library via the FFI and 
make it do the heavy lifting of 1) scanning font directories to amass a list of 
possible fonts and then 2) finding a match for a certain query pattern, say a 
family name.



> On Mar 31, 2020, at 4:52 PM, Matthew Butterick  wrote:
> 
> IIUC every `font%` object must correspond to a particular font file on disk.
> 
> If so, given a `font%` object, how do I extract the path to that file?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/C28B01B3-4772-4AA4-899C-78DADE7B8B2A%40mbtype.com.


[racket-users] racket/draw: how to extract the path from a font% object?

2020-03-31 Thread Matthew Butterick
IIUC every `font%` object must correspond to a particular font file on disk.

If so, given a `font%` object, how do I extract the path to that file?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/39ABE79E-4319-4B75-8BB4-B93694F7E203%40mbtype.com.