[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/show-font a65e7a242a 27/54: Add more helpers to check f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/show-font a65e7a242a 27/54: Add more helpers to check for installed fonts |
Date: |
Tue, 10 Sep 2024 03:58:58 -0400 (EDT) |
branch: externals/show-font
commit a65e7a242ac4fe5d2b775a3b48222ed3598f9997
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add more helpers to check for installed fonts
Now we have an OS-agnostic backend in the form of 'x-family-fonts' and
one that works on Linux via fc-list. My goal is to have an OS-agnostic
implementation of the latter or, at least, have a function that does
the right thing on each platform.
---
show-font.el | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/show-font.el b/show-font.el
index 5f9a31f4dc..c722cb6e0c 100644
--- a/show-font.el
+++ b/show-font.el
@@ -33,7 +33,6 @@
;;; Code:
;; TODO 2024-08-24: Offer option to install missing font.
-;; TODO 2024-08-27: Make this package work with other operating systems.
(eval-when-compile (require 'cl-lib))
@@ -183,19 +182,31 @@ matched against the output of the `fc-scan' executable."
(car (split-string output ","))
output)))
-(defun show-font--get-installed-fonts (&optional attribute)
- "Get list of font families available on the system.
-With optional ATTRIBUTE use it instead of \"family\"."
+(defun show-font--get-installed-font-families (&optional full)
+ "Return list of installed font families names.
+With optional FULL, return the full XLFD representation instead."
+ (mapcar
+ (lambda (font)
+ (if full
+ (aref font 6)
+ (format "%s" (aref font 0))))
+ (x-family-fonts)))
+
+(defun show-font-installed-p (family)
+ "Return non-nil if font family FAMILY is installed on the system.
+FAMILY is a string like those of `show-font--get-installed-font-families'."
+ (member family (show-font--get-installed-font-families)))
+
+(defun show-font--get-installed-font-files ()
+ "Get list of font files available on the system."
(unless (executable-find "fc-list")
(error "Cannot find `fc-list' executable; will not find installed fonts"))
- (process-lines
- "fc-list"
- "-f"
- (format "%%{%s}\n" (or attribute "file"))))
-
-(defun show-font--installed-p (file)
- "Return non-nil if font FILE is installed on the system."
- (member file (show-font--get-installed-fonts)))
+ ;; TODO 2024-09-06: Make this work with other font backends.
+ (process-lines "fc-list" "-f" (format "%%{%s}\n" "file")))
+
+(defun show-font-installed-file-p (file)
+ "Return non-nil if FILE is among `show-font--get-installed-font-files'."
+ (member file (show-font--get-installed-font-files)))
;; TODO 2024-09-06: Maybe we can rewrite `show-font--get-pangram' in some
smart way to do this:
;;
- [elpa] externals/show-font 09ad971308 21/54: Update show-font-pangram doc string, (continued)
- [elpa] externals/show-font 09ad971308 21/54: Update show-font-pangram doc string, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 3be8056ae5 24/54: Stop using show-font-extensions-regexp; define regexp directly, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b1a9d8a5cc 07/54: Remove needless 'let' before the 'when-let', ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 2d04283d8e 31/54: Add revert-buffer-function for show-font-select-preview, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 7bd66d3105 39/54: Add FIXME to refine show-font-list output, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font ad30c77b06 42/54: Remove WIP notices, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 0f46562e42 51/54: Make sure to delete duplicates and sort fonts, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 683d5ab4d1 49/54: Mention links to the Info manual and web page in the defgroups, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font ff0251d565 19/54: Remove the function that shows the font from the major mode, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c8f889d12a 11/54: Define helper functions to get installed fonts and check for one among them, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font a65e7a242a 27/54: Add more helpers to check for installed fonts,
ELPA Syncer <=
- [elpa] externals/show-font 0d35840ce2 28/54: Rework show-font--prepare-text in light of commit 19a95c1, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 67eff98c59 30/54: Remove outdated comment, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font e654040756 32/54: Fix a typo, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 3695bfb838 38/54: Add error condition to show-font-select-preview, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 3056fc8aed 41/54: Add doc string to show-font-select-preview-history, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 8ef7327eb2 37/54: Remove clarified FIXME, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 7d2145e5bf 46/54: Write the show-font manual, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c66456b2f3 40/54: Autoload the show-font-list command, ELPA Syncer, 2024/09/10