745 Commits

Author SHA1 Message Date
Ben Harris
3fbef4e3ee Something I missed from the 3.246 release notes
Too late for the actual release, sadly.
2024-11-24 20:15:05 +00:00
Ben Harris
894b5c2d4f Update version to 3.246
New major version for vendor and foundry IDs and removing Mac Roman
support.  Minor version indicates the sixth release of 2024.
bedstead-3.246
2024-11-24 17:03:50 +00:00
Ben Harris
5a136179a6 Adjust bitmap of supported code pages
I've removed the Turkish code pages because I don't have letters with
breves yet.  And I've removed the Latin-2 code pages because I haven't
come up with a good way to distinguish accented upper- and lower-case
'S'.
2024-11-23 20:03:36 +00:00
Ben Harris
dbf23d231f Remove some Unicode Character Range bits
I don't think Bedstead has enough coverage of these ranges to consider
them to be "functional":

47: Dingbats
62: Alphabetic Presentation Forms
68: Halfwidth and Fullwidth Forms
69: Specials
88: Musical Symbols + Byzantine + Ancient Greek
89: Mathematical Alphanumeric Symbols
2024-11-23 15:04:56 +00:00
Ben Harris
e06dad5579 Note what the various Unicode-range and code-page bits in 'OS/2' mean
I haven't actually checked whether they're right, though.
2024-11-22 14:17:55 +00:00
Ben Harris
c798bea1f3 Comment explaining sFamilyClass 2024-11-22 13:49:06 +00:00
Ben Harris
4e069eec5e Merge line-drawing changes into pre-release trunk 2024-11-21 21:02:49 +00:00
Ben Harris
a252182ee6 Musical stave characters should join to the left 2024-11-21 20:55:51 +00:00
Ben Harris
860f76c16f Separate flags for copying left column and top row
Having a way to specify that the half-brackets extend upwards but not
leftwards avoids all the rendering problems they were previously
suffering from.  And I've spotted the VT100 scan-line characters,
which should be extended to the left but not upwards.  Since the
middle scan-line is unified with a line-drawing character, they really
need to extend leftwards for symmetry, but extending scan-line 1
upwards would be a disaster.

So now there are two flags, JOIN_U and JOIN_L, to specify joining in
each direction.  I've renamed the both-directions flag as JOIN,
because it's not just specific to line-drawing any more.  I might
eventually want a JOIN_D to suppress hinting of the bottom edge of the
character, but I need to do some testing first.
2024-11-21 20:55:51 +00:00
Ben Harris
8974fd292c Turn on line-drawing mode on long brackets etc
It doesn't work quite properly: some characters hit the left side of the
character cell, so I might want to separate the joins-leftward and
joins-upward flags.
2024-11-21 20:55:51 +00:00
Ben Harris
664f000a59 Stop bold line-drawing characters overflowing character cell
In XLFD terms, Bedstead is a "character cell" font, where every
character fits entirely within its cell (defined by advance width,
ascent, and descent).  Bedstead Bold maintained this because it
thickened into the unused column to the left of each character.
However, combining the new continuous line-drawing with emboldening led
to bold line-drawing characters that extended beyond their character
cell.  This led FontForge to make the SPACING property of the BDF file
"M" (for monospace) rather the "C".

This commit simply clips the X co-ordinate of points in a bolded
character at zero.  That's safe because line-drawing characters are
guaranteed not to be doing anything diagonal in the left-most column.
This is slightly ugly, in that the bold characters aren't quite so
algorithmically derived from the non-bold ones, but in most cases
there'll be another line-drawing character to the left anyway.
2024-11-21 20:55:51 +00:00
Ben Harris
013500fc79 Make line-drawing characters join up
This is done my duplicating the top row of pixels upwards and the left
column leftwards.  This is analogous to what MDA and other IBMish
adaptors do to expand eight-pixel wide characters to nine pixels on screen.
2024-11-21 20:55:51 +00:00
Ben Harris
0a15904d82 Increase version number for a potential pre-release 2024-11-20 20:17:55 +00:00
Ben Harris
769c6f5c3c Turn on the ForceBold flag for bold fonts
As far as I can tell, FreeType ignores it, but I may as well turn it
on in case something pays attention.
2024-11-20 20:06:02 +00:00
Ben Harris
39d7e7fbdc Slightly ugly hack to bias middle stems upwards
By default, FreeType 2.12.1 prefers to move the middle stems of
characters like 'B' and 'e' downwards, which is ugly.  By applying a
tiny tweak to the "hstem" commands for such stems we can persuade
FreeType to move them upwards instead.  This wasn't a problem when we
were using FontForge because FontForge didn't use proper stem hints on
the baseline.
2024-11-20 14:25:46 +00:00
Ben Harris
9a1a2e4966 Fix vertical stem hints on bold condensed fonts
The weight needed to be adjusted to allow for the change in width.
2024-11-19 23:40:54 +00:00
Ben Harris
534a4a311a Correct bold outlines
The weight-changing code in adjust_weight() depended on the direction
that outlines were drawn in, so when I changed the direction to match
that required by CFF, it started lightening the font when it should have
been boldening it.  A lot of swapping "next" and "prev" has corrected
that.
2024-11-19 23:40:00 +00:00
Ben Harris
d4d05a4a73 Fix left and right edge hints at non-default widths
The magic numbers -21 and -20 shouldn't be scaled when the width of the
characters changes.  The easiest way to fix this is to switch to
calculating the hints in actual font units.  Only now of course that
will get bold fonts wrong...
2024-11-19 23:40:00 +00:00
Ben Harris
3434aa062f Quell a few compiler warnings 2024-11-19 23:40:00 +00:00
Ben Harris
05decf272d Remove glyph footprint comment from XML output
It was only there for debugging and isn't generally helpful.
2024-11-19 23:40:00 +00:00
Ben Harris
86a5b35d0b An idea about version numbers 2024-11-19 23:40:00 +00:00
Ben Harris
60df8ac6a6 Support cntrmask and hintmask operators in editor 2024-11-19 23:40:00 +00:00
Ben Harris
a0cbdb9d05 Skip XML comments when reading charstrings in editor 2024-11-19 23:40:00 +00:00
Ben Harris
5e46500fb8 Emit cntrmask operators 2024-11-19 23:40:00 +00:00
Ben Harris
cf28bd71ef Counter-mask support in select_hints()
It detects evenly-spaced runs of at least three stems, which is a
surprisingly fiddly thing to code.
2024-11-18 23:29:57 +00:00
Ben Harris
52c2ad5e93 Use self-explanatory constants to specify alignment zones
This adds ALEFHEIGHT for the height of Hebrew letters.
2024-11-18 14:13:15 +00:00
Ben Harris
f273f0e98e Remove lower alignment zone at +1 pixel
I think I added it because a lot of mathematical operators (like '+')
have their bottom edge there.  But such operators don't really need
their bottom edges aligned: it's much more important that they should
have their proper shapes and should have their centre lines aligned.

This only slightly improves the rendering of '+' in FreeType 2.12.1:
it's still asymmetric but the asymmetry is in a better direction.
Moreover, some glyphs with descenders like "section" are substantially
improved.
2024-11-18 14:09:43 +00:00
Ben Harris
b74582bccc More-or-less functional edge hints
This gets me to the milestone where the new version isn't uniformly
worse than the old one when rendered by FreeType at 10.5 ppem (the
worst size I've found).

The big problem I still have is that letters with three horizontal
stems (like 'B') get their middle stem rounded down in this version
and up in 002.009.  I think this is because FontForge generates and
edge hint and not a stem hint at the bottom of the character, which
also makes bottom stems rather fuzzy.  This version gives sharper
stems, but the characters all end up looking top-heavy.
2024-11-17 14:03:47 +00:00
Ben Harris
347dcfd579 Support for edge hints in select_hints()
Which demonstrated plenty of bugs in the code generating them.
Currently edge hints only appear in a helpful comment.
2024-11-17 13:43:08 +00:00
Ben Harris
15b8a9a584 Process pixels in raster order
If we're imitating a CRT character generator, obviously we should
process pixels line-by-line, not column-by-column.  But that means
writing "for (y ...)" before "for (x ...)" which isn't the instinctive
way I did it.

So now that's corrected and the Y loops are outside the X loops, which
should make any debugging output easier to follow.  This has been
confirmed not to change FreeType rendering at 10.5 ppem.
2024-11-17 10:11:23 +00:00
Ben Harris
86f186342a Reverse (almost) all the paths
Type 1 fonts (and by extension CFF fonts) are required to have their
outer contours go counter-clockwise.  Bedstead has always generated
outlines clockwise and depended on FontForge to correct them.  Now
they're generated counter-clockwise as is proper, which will be fine
until I decide I want TrueType outlines instead.

This makes no difference to FreeType's rendering at either 20 ppem or
10.5 ppem
2024-11-17 09:36:54 +00:00
Ben Harris
f234538428 Switch hhints loop in emit_hints() so it counts forwards
Now that it only touches the input array once, it's much simpler to do
the y-axis inversion there.
2024-11-16 23:39:30 +00:00
Ben Harris
1ad04e13fa Some infrastructure towards edge hints
There are places to record them now, but they're ignored by
select_hints() and emit_hints().
2024-11-16 23:33:30 +00:00
Ben Harris
30d226f30f Separate selecting usable hints from emitting them
Now there's a select_hints() function that decides what hints should
be emitted, and emit_hints() just handles putting those hints into a
charstring.  I hope this will make each function reasonably simple.
Importantly, it means that select_hints() can be called twice, once
for horizontal stems and once for vertical ones.
2024-11-16 18:58:41 +00:00
Ben Harris
1459c8cf93 Change version number so pre-release fonts are distinguishable 2024-11-16 14:41:43 +00:00
Ben Harris
891129f1f4 Correct baseline of BDF fonts 2024-11-16 14:40:47 +00:00
Ben Harris
be223879a1 Pass --no-recalc-timestamp to TTX
Without that, it updates the "modified" field in the 'head' table,
which makes builds unreproducible.
2024-11-16 11:53:04 +00:00
Ben Harris
ac1a68d964 Emit OpenType tables in a more logical order
TTX doesn't actually care what order we emit tables in: it will always
put them into the recommended order.  So I've made the order something
that works correctly and that doesn't look too silly in TTX's console
output.
2024-11-16 11:53:04 +00:00
Ben Harris
62d562879a Update Web page for new generation procedure 2024-11-16 11:53:04 +00:00
Ben Harris
290c8032b6 Correct cap height in font headers 2024-11-16 11:53:04 +00:00
Ben Harris
3c333a8790 Put version number in glyph complement PDF
Now that we've got the version number in a constant, this is
convenient.
2024-11-16 11:53:04 +00:00
Ben Harris
650103b465 Extract version number from C file, not nonexistent SFD 2024-11-16 11:53:04 +00:00
Ben Harris
62ba3a3307 Correct ordering of stem hints
The spec for Type 2 charstrings requires that all hstem hints must
occur before all vstem hints.
2024-11-14 23:31:36 +00:00
Ben Harris
59a535c335 Ignore stem hints in editor
Though it would be neat if it could display them.
2024-11-14 23:31:36 +00:00
Ben Harris
c93160c507 Add .DELETE_ON_ERROR target to Makefile
That ensures that output files of a rule get properly deleted if the
recipe fails, which is almost always correct.
2024-11-14 23:31:36 +00:00
Ben Harris
b8abf30fcd Make the processing of SOURCE_DATE_EPOCH safe
And explain in excruciating detail why it's safe.  It's only actually
safe on systems (like POSIX ones) where time_t is an integer type, but
I think that's good enough for me.
2024-11-14 22:27:18 +00:00
Ben Harris
c924855103 Support SOURCE_DATE_EPOCH
If set, it is used to set the "created" and "modified" fields in the
OpenType 'head' table.  This means that builds of Bedstead can be
reproducible.

The current code just casts the "long long" interpretation of the
environment variable into a time_t.  This is potentially undefined
behaviour, because time_t might be a signed integer type smaller than
"long long".  But I can't find a way to properly range-check it.  Even
in POSIX, where time_t is required to be an integer type, there
doesn't seem to be a constant that specifies its range.
2024-11-14 22:27:18 +00:00
Ben Harris
4254bff53a Generate stem hints
These are generated from the glyph bitmap by a similar
pattern-matching arrangement that generates the outline.  Then, like
emit_path(), there's an emit_hints() that turns them into valid
charstrings.  The handling of overlapping hints could be cleverer: at
the moment we emit the leftmost-possible set of hints, but we collect
a histogram of where hints are needed so could instead emit the most
useful.  Or even try to do hint substitution.

This makes the Bedstead Web page at 90% zoom much prettier than
before, but it's not as good as the FontForge auto-hinter managed.
Edge hints and counter hints will probably help.
2024-11-14 22:27:18 +00:00
Ben Harris
e572e11b12 Use my own, officially assigned, achVendID
The assignment is recorded at
<https://learn.microsoft.com/en-gb/typography/vendors/>.

This branch is destined to be the next major version of Bedstead, so
it's a sensible place to make this change.
2024-11-14 22:27:18 +00:00
Ben Harris
259b718c9f Constants for 'OS/2' achVendID and XLFD/BDF FOUNDRY 2024-11-14 22:27:18 +00:00