677 Commits

Author SHA1 Message Date
Ben Harris
492cea7bf1 Correct charstring stack accounting in emit_contour()
The first point doesn't count because it gets an rmoveto rather than an
rlineto.
2024-11-14 22:27:18 +00:00
Ben Harris
36a99e6005 Make aliases work again, inefficiently
This pulls the conditional that works out how to render a glyph into
it's own function, doglyph(), that also handles indirecting through
aliases.  Later maybe we'll properly use subroutines to share the
charstrings for aliased glyphs.
2024-11-14 22:27:18 +00:00
Ben Harris
82447229df Put the charstring cursor in a local variable 2024-11-14 22:27:18 +00:00
Ben Harris
e3eae733ee Combine successive rlineto operators
In a Type 2 charstring, an rlineto operator can take up to 24 pairs of
co-ordinates, so most contours need only one rmoveto and one rlineto.
2024-11-14 22:27:18 +00:00
Ben Harris
6f2fcc8799 Don't emit first point of a contour twice
Type 2 charstrings implicitly close each contour with a line, so there's
no need for us to explicitly do so.
2024-11-14 22:27:18 +00:00
Ben Harris
abb8dbbf27 Emit 'CFF ' and 'hmtx' tables for TTX (mostly)
The left sidebearings in 'hmtx' are not set yet, and there are (of
course) no hints, but the glyphs are the right shapes.
2024-11-14 22:27:18 +00:00
Ben Harris
932722f07d cmap fixup 2024-11-14 22:27:18 +00:00
Ben Harris
f1423c7124 Generate 'post' table for TTX 2024-11-14 22:27:18 +00:00
Ben Harris
b0cbe870b3 Generate 'cmap' table for TTX
TTX currently refuses to compile it, but I suspect that's because the
font still has no glyphs.
2024-11-14 22:27:18 +00:00
Ben Harris
75ad9bc479 Generate 'name' table for TTX 2024-11-14 22:27:18 +00:00
Ben Harris
030d9c36f9 Macros for the common TTX pattern <foo value='bar'/>
That makes things a little less verbose.
2024-11-14 22:27:18 +00:00
Ben Harris
d4d2223429 Generate 'OS/2' table for TTX 2024-11-14 22:27:18 +00:00
Ben Harris
29b33c20af Use constants for ascent, descent, etc
This way there won't be quite so many magic numbers in the font metrics.
2024-11-14 22:27:18 +00:00
Ben Harris
c354f9c3ac Generate 'maxp' table for TTX 2024-11-14 22:27:18 +00:00
Ben Harris
4e5727d371 Generate 'hhea' table for TTX 2024-11-14 22:27:18 +00:00
Ben Harris
9899c0e4a6 Generate 'head' table for TTX 2024-11-14 22:27:18 +00:00
Ben Harris
39d226c820 Minimal infrastructure for going via TTX rather than SFD
bedstead.c outputs an utterly minimal TTX file containing no tables, and
TTX compiles it into a similarly minimal OTF.  Which Ghostscript then
complains about.

FontForge is an impressive application, but it's not well-suited to
being part of a mechanical font-production pipeline.  The SFD format is
weird and rather difficult to generate, and FontForge imposes rather
more of its own opinions on the output than I'd like.

TTX is a lower-level format, and while it's a little bit weird, most of
it's weirdness comes from being a faithful representation of the
structure of an OpenType font.  Ideally I'd like something a little
higher-level, but a format that's too low-level is much easier to work
with than one that's too high-level.  The obvious alternative is UFO,
which is very popular but looks like being a pain to generate from plain
C.

Looking to the future, I like the idea of a variable version of
Bedstead, and neither SFD nor UFO seems to support that very well.  In
UFO's case, it seems that the convention is to create UFOs at various
points in the design space and then have a tool interpolate between
them, which seems wrong when they're all procedurally generated from the
same source.  TTX will allow me to directly generate the variation
tables, if I can understand how they work.
2024-11-14 22:27:18 +00:00
Ben Harris
fb7797fe46 Wibblings about version numbers 2024-11-14 22:26:03 +00:00
Ben Harris
a625952522 Fontmap is required by .bdf.ps files 2024-11-10 09:30:35 +00:00
Ben Harris
90bc582e16 Add DEFAULT_CHAR to BDF
Also sort properties into the order they appear in the XLFD spec.
2024-11-10 09:30:35 +00:00
Ben Harris
1fd2576cfa Correct weight and width names in BDF
They shouldn't have leading spaces.
2024-11-10 09:30:35 +00:00
Ben Harris
9c6e156d80 Add FACE_NAME property to BDF 2024-11-10 09:30:35 +00:00
Ben Harris
305d15129d Add FONT_VERSION property to BDF 2024-11-10 09:30:35 +00:00
Ben Harris
a89d0efedd Switch build system to generating BDF via PostScript
As far as I can see, the new BDF files are now as good as the
FontForge-generated ones.
2024-11-10 09:30:35 +00:00
Ben Harris
ca7fa3a80d Add support for choosing font size and weight in BDF generation 2024-11-10 09:30:32 +00:00
Ben Harris
4c81bfa249 More BDF properties and a proper XLFD name 2024-11-10 09:29:36 +00:00
Ben Harris
4b972f1bee Rough Makefile bits for new BDF generation 2024-11-10 09:29:36 +00:00
Ben Harris
46a5c05885 Add rough support for generating BDF without FontForge
This is extremely silly, but it's actually quite functional and
surprisingly compact.  bedstead.c gains the ability to generate a
PostScript file that emits a BDF file rendering each glyph into an image
and then dumping the image in hex.

I still need to get the font metadata right, which is my main reason for
wanting to get away from FontForge, but that shouldn't be difficult.
And the Makefile needs to be updated to make this work properly.  But
the bitmaps are coming out correctly.
2024-11-10 09:29:29 +00:00
Ben Harris
c2e45853f7 Use EXIT_SUCCESS and EXIT_FAILURE
This is a bit of C pedantry.  POSIX requires that an exit status of
zero is success and non-zero is failure, but the C standard says no
such thing.  Instead it provides EXIT_SUCCESS and EXIT_FAILURE.  Since
Bedstead aspires to work on non-POSIX systems, it should use the
defined constants.  Also removing magic numbers is a good thing.
2024-11-10 09:27:31 +00:00
Ben Harris
cba03ce5fd Make it safe to call fullname_to_fontname() twice 2024-11-10 09:23:15 +00:00
Ben Harris
4db0ea6bc1 Another capital esszett link 2024-11-10 09:22:21 +00:00
Ben Harris
79cbd69c83 Map the .notdef character at U+F1FF
It should be the DEFAULT_CHAR in BDF, but that needs it to have an
encoding.  U+2395 APL FUNCTIONAL SYMBOL QUAD happens to look
identical, but I don't think I should rely on that.
2024-11-01 20:36:23 +00:00
Ben Harris
602c0aba1b Correct Wdieresis small-cap
Wdieresis.sc is obviously wrong: a capital shouldn't have an 'smcp'
mapping.  A 'c2sc' mapping for that character would also be wrong
because it's already squashed to fit under its accent.  On the other
hand, there should be a wdieresis.sc that maps to the upper-case,
because the characters are slightly different.

Wdieresis.sc is retained as a compatibility alias (for Wdieresis),
just in case.
2024-10-29 22:39:04 +00:00
Ben Harris
c08373b172 SAA5050 reverse-engineering links 2024-10-29 10:57:43 +00:00
Ben Harris
6863a1cf39 Add headings in NOTES 2024-10-29 10:57:36 +00:00
Ben Harris
b7a13dd61b Move dot in Ldot and corresponding small cap leftwards
It should be centred between the uprights of the Ls, and that makes it
so.  Sadly, it's not possible to do the same for the lower-case.

Also add a relevant link to NOTES.
2024-10-29 00:42:27 +00:00
Ben Harris
3653fab92e Some thoughts on UnitsPerEm 2024-10-28 15:05:11 +00:00
Ben Harris
be0055420f Explicitly set OS2Vendor to 'PfEd'
That's the default value that FontForge uses.  I'd like to change it,
but fontconfig makes it available to applications as "foundry" and I
somehow ended up with Emacs recording that in its configuration.  So if
I'm going to make that change I think it should go with a major version
bump.

But at least I can make sure it doesn't change unexpectedly and give
myself somewhere to make the change when it comes.
2024-10-27 11:56:30 +00:00
Ben Harris
b2bda72f72 Stop dopalt() reading off the end of the character bitmap
Spotted by GCC -Warray-bounds.
2024-10-26 19:00:39 +01:00
Ben Harris
e129bcd034 Update editor to emit the new style of character bitmap 2024-10-26 18:58:25 +01:00
Ben Harris
e303c792d3 Switch to using string constants for character bitmaps
Future versions of C are likely to make octal integer constants
obsolescent.  Switching to something non-obsolete seems wise, and also
using octal character constants saves eight characters per line that I
can use for other things.

I did consider just using one character per row, but I think that might
be a little too hard to read.
2024-10-26 16:25:14 +01:00
Ben Harris
a1715eff49 Tidy up Creative-Commons-related verbiage in HACKING
Specifically, "declaration" is not a usual noun for CC0, and "Creative
Commons" isn't usually followed by "Corporation".
2024-10-24 00:01:29 +01:00
Ben Harris
77efacaa0a Add some SPDX-License-Identifier headers
In places where they don't get in the way.
2024-10-24 00:01:26 +01:00
Ben Harris
32079c7b75 Make co-ordinate systems more sensible
The SAA5050 character images appear at the bottom-right corner of the
character cell, with a blank pixel to the top and the left.  This can
be seen if you put am alphanumeric character and a mosaic graphics
character side-by-side, since mosaic graphics characters fill the
entire character cell.

However, when I first made Bedstead, I put the character images in the
top-right corner, and the co-ordinate system matched that.  When I
fixed this in 2013 (commit 7bea0c6fadc35de50ea08eb184d4b15a7b411ef3),
I just did it by adjusting the final transformation of the vector
co-ordinates, leaving all the internal co-ordinate systems intact.
This was visible when I added mosaic graphics, which had to be offset
by one pixel to compensate.

Now I've finally corrected the problem somewhat properly.  Pixel
co-ordinates count from (0,0) in the top-left corner of the character
cell.  Vector co-ordinates count from (0,0) in the bottom-left corner
and are offset to the baseline on emission.  The conversion between
the two forms is still weirdly spread all over the place though.
2024-10-21 09:31:57 +01:00
Ben Harris
6bac55c65b Update version to 002.009
This release is just to give the Debian build a more sensible base to
work from.
bedstead-002.009
2024-10-19 21:02:11 +01:00
Ben Harris
13228ac77e State default author/licence in HACKING
Now that all the files are either mine or have other explicitly stated
authorship.
2024-10-13 16:09:28 +01:00
Ben Harris
ea66bc5fbe Update HACKING document for editor changes 2024-10-13 15:06:41 +01:00
Simon Tatham
d523da3671 editor: miscellaneous source cleanups.
Apparently I didn't know about chained comparisons when I wrote this
code, so I didn't take the opportunity to write '0 <= x < limit'.

Also, removed the wildcard import from tkinter, replacing it with
explicit references to the things needed. There weren't that many of
them, so I think the 'import *' didn't gain much.
2024-10-13 15:04:53 +01:00
Simon Tatham
67290ddd01 editor: better error message on paste failure.
Apparently I was incredibly lazy at some point in the past and forgot
to say what the problem was when the paste data couldn't be matched
against the regex.
2024-10-13 15:04:53 +01:00
Simon Tatham
4ce96879d8 editor: better ways to find the bedstead executable.
Previously the editor just expected to find it in your cwd. Now by
default it looks in the same directory as its own script, which means
you can run it from some other directory.

Also, I've provided a command-line option to override the default, in
case you keep the executable somewhere else again.
2024-10-13 15:04:53 +01:00