Re: ./install-font.sh without root access

2025-01-21 Thread Morten Bo Johansen
On 2025-01-20 Francesco Ariis wrote:

> how to convert .tff fonts to something usable by `groff`, without
> sudo access?

There is a shell script included on this page:

   https://technicallywewrite.com/2023/09/16/addfonts

which works fine. You need to set GROFF_FONT_PATH. Also note that you must
change line 42 of the script from

   textmap=$prefix/current/font/devps/generate/textmap

to

   textmap=$prefix/current/font/devps/generate/text.map

at least if you use a post-2022 version of groff.


Regards,
Morten




Re: ./install-font.sh without root access

2025-01-20 Thread G. Branden Robinson
At 2025-01-20T16:43:34-0600, G. Branden Robinson wrote:
> I'm attaching the current version of my "make-groff-fast" script,[1]
> which I run _all the time_.

Take a drink and/or claim your wager winnings.

Regards,
Branden
#!/bin/sh

set -e

: ${TAG:=HEAD}
: ${DESTDIR:=$HOME/groff-$TAG}

PROGNAME=${0##*/}
: ${CORES:=1}
COMMON_FLAGS="-Wall -Wextra -Wformat=2  \
-Wformat-overflow \
-Walloc-zero \
-Wstringop-overflow=4 \
-Wshadow=global -Wredundant-decls \
-Wunused \
-Wunused-parameter \
-fsanitize=signed-integer-overflow \
-fsanitize-undefined-trap-on-error \
-fstack-protector-strong -fno-common \
-fstack-clash-protection \
-ftrapv \
-funsigned-char \
-fvar-tracking-assignments  \
-flto=auto \
-O0 -Og \
-ggdb
-D_FORTIFY_SOURCE=2"
CFLAGS="$COMMON_FLAGS \
-Wmissing-prototypes \
-Wold-style-definition \
-Wstrict-prototypes  \
-Wold-style-declaration  \
-Wformat=2 -D_FORTIFY_SOURCE=2"
CXXFLAGS="$COMMON_FLAGS \
-fcheck-new \
-Wredundant-decls \
-std=c++98 -pedantic -pedantic-errors -Wformat=2 -D_FORTIFY_SOURCE=2"
export CFLAGS CXXFLAGS

if [ $# -gt 1 ]; then
echo "$PROGNAME: error: expected 0 or 1 arguments, got $#" >&2
exit 1
fi

if [ -n "$1" ]; then
if expr "$1" - 0 >/dev/null 2>&1; then
CORES=$1
else
echo "$PROGNAME: usage error: argument \"$1\" should be number of" \
"cores" >&2
exit 2
fi
fi

if ! test -f ./test-groff.in; then
echo "$PROGNAME: error: ./test-groff.in not found" >&2
exit 3
fi

set -x

if [ -n "$IN_TREE" ]
then
test -f Makefile && make distclean
else
test -d ./build && (cd build && make distclean)
test -d build && rm -r build
fi

./bootstrap

SOURCE_DIR=.

if [ $? -eq 0 ]
then
if [ -z "$IN_TREE" ]
then
SOURCE_DIR=..
mkdir build && \
cd build
fi
else
exit 1
fi

test $? -eq 0 \
&& $SOURCE_DIR/configure --prefix=$DESTDIR \
&& make -j $CORES check \
&& make install install-doc \
&& (cd $DESTDIR && find . -type f | sort) >| ../payload-$TAG.new \
&& diff -u $SOURCE_DIR/payload-$TAG $SOURCE_DIR/payload-$TAG.new \
&& make uninstall

# vim:set ai et sw=4 ts=4 tw=80:


signature.asc
Description: PGP signature


Re: ./install-font.sh without root access

2025-01-20 Thread G. Branden Robinson
At 2025-01-20T12:38:24-0500, T. Kurt Bond wrote:
> I always install a personal copy of groff in a directory that my user
> owns, ensure that is in the path before the location of the system
> groff, and never use root access for installing fonts.  I realize this
> may not be suitable for everyone.

I would emphasize that this works _really straightforwardly_ for anyone
willing to build groff from source.

I'm attaching the current version of my "make-groff-fast" script,[1]
which I run _all the time_.  The core idea is

./configure --prefix=$HOME/groff-HEAD

and I also have (the equivalent of)

PATH=$HOME/groff-HEAD/bin:$PATH

and

MANPATH=$HOME/groff-HEAD/share/man:$MANPATH

in my shell's startup scripts.

The script is long because it has evolved somewhat like a cactus.  It
has three features more casual users will probably want to take out.

1.  a giant pile of compiler options to designed to provoke them to
anger, inspired by Bjarni Ingi Gislason; this is to aid me in
keeping the code portable and correct

2.  the "PAYLOAD" file checking stuff, which alerts me to when I've
managed, sometimes on purpose, to change the set of files groff
installs

3.  the "make uninstall" call at the end; I have that so that I can be
confident that uninstalling works without error (I then run "make -C
build install" by hand afterward to put it back so that "groff HEAD"
is my daily driver)

Also the script is designed to build from a Git checkout.  If you use
only a distribution archive (like "groff-1.23.0.tar.gz"), then you'll
also need to take out the "make distclean" calls and, in the future,
depending on your preferences, the "bootstrap" call.  The last point is
covered in a discussion from last March.[2]

I hope the script is helpful to people, or at least provides insight
into some of the things I do to try to maintain groff's quality.

Regards,
Branden

[1] It's called "-fast" because a variant script performs a "make dist",
which is much slower because its nested build from a distribution
archive that it generates exercises only one CPU core.  I usually
run that only when I'm about to push commits, and want to make sure
I didn't screw the distribution archive up.

[2] https://lists.gnu.org/archive/html/groff/2024-03/msg00211.html


signature.asc
Description: PGP signature


Re: ./install-font.sh without root access

2025-01-20 Thread G. Branden Robinson
At 2025-01-20T18:15:48+0100, Francesco Ariis wrote:
> Hello groff users,
> 
> how to convert .tff fonts to something usable by `groff`, without
> sudo access?

In groff 1.23.0, both the grops(1) and gropdf(1) man pages document a
procedure for doing this.  It is admittedly more tedious than using
Peter Schaffter's convenient script.  The latter has doubtless prevented
many people from deserting groff in frustration.

> I am learning groff and I feel thee need to use a fonts with more
> glyphs than what standard fonts offer (e.g.: ◇ U+25C7, ❦ U+2766, etc.)

I have a brief aside for PDF users, but not ones with this exact
problem.  See the footnote.[1]

> I came around the excellent `install-font.sh` [1]. It seems to work
> when I have root access (it wrote files to /usr/share/groff/), but to
> I prefer to stay as user to experiment with options, different styles
> of fonts etc.
> 
> My idea is to have a local ./font/ folder and then include it in my
> groff invocation (I should do it via `-F`, right?).

You can either pass `-F` options to the formatter _and_ the output
driver (grops or gropdf), or set the GROFF_FONT_PATH environment
variable.  The latter is probably easier.

> I am not sure how to invoke ./install-font.sh without `su` or `sudo`
> though.

I don't know, either.  But I know what "text.enc" is.

> It complains about missing `text.enc`.

It's documented.

grops(1):
 /usr/share/groff/1.23.0/font/devps/text.enc
describes the encoding scheme used by most PostScript Type 1
fonts; the encoding directive of font description files for
the ps device refers to it.

If that file is where GNU troff(1) and grops(1) (or gropdf(1)) are told
to look for it, they should find it.

One of the necessary stages in the process is to run afmtodit(1).
A minor convenience added to that program for the forthcoming groff
1.24.0 release is that it records how it was invoked in the comment
header that it writes to the font description file.  For example, here's
the "U-TR" (Times Roman from the URW foundry) font description file
generated when building groff from Git.

$ head -n 5 build/font/devpdf/U-TR
# generated by GNU afmtodit (groff) version 1.23.0
#   AFM file: /usr/share/fonts/type1/gsfonts/n021003l.afm
#   map file: map/text.map
#   with options "-c -d DESC -e enc/text.enc -i 0 -m"
#

With that information it is easy to reconstruct the afmtodit command
line.  If your font is conventional, those same options may work for
your font as-is.  (I use FreeMono with xterm(1) myself.)

> Here is a log of what I see in the terminal:
> 
> f@x270:~/spool/groff/prova/cv/install-font$ ./install-font.sh -P out/ 
> FreeSerif.ttf
[snip]
> Leave blank to set name to 'FreeSerif':
>   =>FreeSerif assigned groff fontname 'FreeSerif'.
> 'text.enc' not found.  Aborting.

I'm afraid I'm unable to usefully support "install-font.sh" itself
(writing an alternative for non-interactive use by distribution
packages' maintainer scripts is on my long to-do list), but I feel like
the foregoing should be enough information to advance you toward a
solution.  All the way, I hope.

Regards,
Branden

[1] I thought briefly that maybe "just using the URW fonts" would be a
good enough solution.  But they lack the "WHITE DIAMOND" U+25C7 code
point, at least in the versions available to me.  Nevertheless, it
is sometimes the case that the URW fonts solve code point coverage
problems that the Adobe-compatible default fonts don't.

However in this case, both Adobe and URW have the "FLORAL HEART"
U+2766 and both lack U+25C7.  Nevertheless it seems like not a bad
time to remind people of the availability of the URW fonts in groff.

$ cat EXPERIMENTS/funny-symbols.groff
.nf
U+25C7 is \[u25C7]
U+2766 is \[u2766]

# Use Adobe-compatible default foundry.
$ groff -T pdf EXPERIMENTS/funny-symbols.groff >| 
EXPERIMENTS/missing-funny-symbols.pdf
troff:EXPERIMENTS/funny-symbols.groff:2: warning: special character 'u25C7' 
not defined

# Use URW foundry.
$ groff -T pdf -P -y -P U EXPERIMENTS/funny-symbols.groff >| 
EXPERIMENTS/funny-symbols.pdf
troff:EXPERIMENTS/funny-symbols.groff:2: warning: special character 'u25C7' 
not defined

In _this_ case, the output doesn't differ (apart from any cosmetic
distinctions between these metrically-compatible faces), but that
won't always be the case.  Hence why I evicted this observation into
a footnote.


signature.asc
Description: PGP signature


Re: ./install-font.sh without root access

2025-01-20 Thread T. Kurt Bond
I always install a personal copy of groff in a directory that my user owns,
ensure that is in the path before the location of the system groff, and
never use root access for installing fonts.  I realize this may not be
suitable for everyone.

T. Kurt Bond, tkurtb...@gmail.com, https://tkurtbond.github.io,
https://consp.org or gemini://consp.org, and https://tkb.tx0.org


On Mon, Jan 20, 2025 at 12:16 Francesco Ariis  wrote:

> Hello groff users,
>
> how to convert .tff fonts to something usable by `groff`, without
> sudo access?
>
> I am learning groff and I feel thee need to use a fonts with more
> glyphs than what standard fonts offer (e.g.: ◇ U+25C7, ❦ U+2766, etc.)
>
> I came around the excellent `install-font.sh` [1]. It seems to work when
> I have root access (it wrote files to /usr/share/groff/), but to I prefer
> to stay as user to experiment with options, different styles of fonts etc.
>
> My idea is to have a local ./font/ folder and then include it in my groff
> invocation (I should do it via `-F`, right?).
>
> I am not sure how to invoke ./install-font.sh without `su` or `sudo`
> though.
> It complains about missing `text.enc`.
> Here is a log of what I see in the terminal:
>
> f@x270:~/spool/groff/prova/cv/install-font$ ./install-font.sh -P out/
> FreeSerif.ttf
> Processing FreeSerif.ttf...
> Running fontforge...
> Program root: /usr
> Copyright (c) 2000-2024. See AUTHORS for Contributors.
>  License GPLv3+: GNU GPL version 3 or later <
> http://gnu.org/licenses/gpl.html>
>  with many parts BSD . Please read
> LICENSE.
>  Version: 20230101
>  Based on sources from 2024-03-15 20:41 UTC-D.
> This font contains both a 'kern' table and a 'GPOS' table.
>   The 'kern' table will only be read if there is no 'kern' feature in
> 'GPOS'.
> The glyph named Delta is mapped to U+0394.
> But its name indicates it should be mapped to U+2206.
> The glyph named Omega is mapped to U+03A9.
> But its name indicates it should be mapped to U+2126.
> The glyph named mu is mapped to U+03BC.
> But its name indicates it should be mapped to U+00B5.
> Done.
> Family name (default = FreeSerif):
>   =>FreeSerif (FreeSerif.ttf) assigned to family 'FreeSerif'.
> Enter +STYLE (eg +R, +I, +B, +BI), or a unique groff name for
> FreeSerif.
> Leave blank to set name to 'FreeSerif':
>   =>FreeSerif assigned groff fontname 'FreeSerif'.
> 'text.enc' not found.  Aborting.
> f@x270:~/spool/groff/prova/cv/install-font$ tree out/
> out/
> ├── site-font
> │   ├── devpdf
> │   │   └── text.enc
> │   ├── devps
> │   │   └── text.enc
> │   └── text.enc
> └── text.enc
>
> 4 directories, 4 files
>
> Any help or pointers appreciated!
> —F
>
> [1] https://www.schaffter.ca/mom/bin/install-font.sh
>
>


./install-font.sh without root access

2025-01-20 Thread Francesco Ariis
Hello groff users,

how to convert .tff fonts to something usable by `groff`, without
sudo access?

I am learning groff and I feel thee need to use a fonts with more
glyphs than what standard fonts offer (e.g.: ◇ U+25C7, ❦ U+2766, etc.)

I came around the excellent `install-font.sh` [1]. It seems to work when
I have root access (it wrote files to /usr/share/groff/), but to I prefer
to stay as user to experiment with options, different styles of fonts etc.

My idea is to have a local ./font/ folder and then include it in my groff
invocation (I should do it via `-F`, right?).

I am not sure how to invoke ./install-font.sh without `su` or `sudo` though.
It complains about missing `text.enc`.
Here is a log of what I see in the terminal:

f@x270:~/spool/groff/prova/cv/install-font$ ./install-font.sh -P out/ 
FreeSerif.ttf
Processing FreeSerif.ttf...
Running fontforge...
Program root: /usr
Copyright (c) 2000-2024. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later 

 with many parts BSD . Please read 
LICENSE.
 Version: 20230101
 Based on sources from 2024-03-15 20:41 UTC-D.
This font contains both a 'kern' table and a 'GPOS' table.
  The 'kern' table will only be read if there is no 'kern' feature in 
'GPOS'.
The glyph named Delta is mapped to U+0394.
But its name indicates it should be mapped to U+2206.
The glyph named Omega is mapped to U+03A9.
But its name indicates it should be mapped to U+2126.
The glyph named mu is mapped to U+03BC.
But its name indicates it should be mapped to U+00B5.
Done.
Family name (default = FreeSerif):
  =>FreeSerif (FreeSerif.ttf) assigned to family 'FreeSerif'.
Enter +STYLE (eg +R, +I, +B, +BI), or a unique groff name for FreeSerif.
Leave blank to set name to 'FreeSerif':
  =>FreeSerif assigned groff fontname 'FreeSerif'.
'text.enc' not found.  Aborting.
f@x270:~/spool/groff/prova/cv/install-font$ tree out/
out/
├── site-font
│   ├── devpdf
│   │   └── text.enc
│   ├── devps
│   │   └── text.enc
│   └── text.enc
└── text.enc

4 directories, 4 files

Any help or pointers appreciated!
—F

[1] https://www.schaffter.ca/mom/bin/install-font.sh