From: Werner LEMBERG <wl@gnu.org>
To: eliz@gnu.org
Cc: 33885@debbugs.gnu.org
Subject: bug#33885: 27.0.50; PUA character makes emacs crash
Date: Fri, 28 Dec 2018 18:03:11 +0100 (CET) [thread overview]
Message-ID: <20181228.180311.772225120008653742.wl@gnu.org> (raw)
In-Reply-To: <83tvix64zw.fsf@gnu.org>
>> (2) Improve the heuristics to get sensible global ascent and
>> descent values of a font. In particular, use the FreeType
>> library to access a TrueType's or OpenType's `OS/2' table and
>> compare its vertical metrics values with the `hhea' data to
>> eliminate bugs in the font – sign problems with `descent' do
>> happen especially in older fonts that were either designed for
>> Apple or for Windows, and the fields for the `other' OS were
>> filled out arbitrarily, more or less.
>
> I'd appreciate more details on how this could be done. I'm no
> expert on fonts nor on FreeType, and last I checked we have no one
> else.
A possible workflow.
(0) Check that we have an SFNT font (which means either TrueType or
OpenType):
if (FT_IS_SFNT(ft_face))
...
(1) Use
TT_OS2* os2_table;
os2_table = (TT_OS2)FT_Get_Sfnt_Table(ft_face, FT_SFNT_OS2);
to extract the `OS/2' table data from an existing `FT_Face' object
for a given font. We are interested in the fields
fsSelection
sTypoAscender
sTypoDescender
sTypoLineGap
usWinAscent
usWinDescent
of FreeType's `TT_OS2' structure and in
ascent
descent
of xft's `XftFont' structure; the latter is based on the
`ascender' and `descender' fields of an OpenType font's `hhea'
table (with `descent' having the opposite sign of of `descender').
[Since `XftFont' doesn't provide `hhea's `lineGap' value it
probably makes sense to use `FT_Get_Sfnt_Table' also to access
this value.]
(2) Check that
sTypoAscender - sTypoDescender > 0
ascent + descent > 0
usWinAscent + usWinDescent > 0
and filter out the value pairs that don't fit. For example, I've
seen fonts where `sTypo*' values were all zero.
(3) Check that
-sign(descent) == sign(sTypoDescender) == -sign(usWinDescent)
If this holds, use `usWin*' or `sTypo*' values, depending on bit 7
of `fsSelection'. Maybe use `ascent/descent' if on a Mac.
If this doesn't hold, try to sanitize the not-fitting value.
Werner
next prev parent reply other threads:[~2018-12-28 17:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-27 8:54 bug#33885: 27.0.50; PUA character makes emacs crash Werner LEMBERG
2018-12-27 10:36 ` Eli Zaretskii
2018-12-27 11:33 ` Eli Zaretskii
2018-12-28 8:33 ` Werner LEMBERG
2018-12-28 9:16 ` Eli Zaretskii
2018-12-28 12:38 ` Werner LEMBERG
2018-12-28 13:30 ` Eli Zaretskii
2018-12-28 14:58 ` Werner LEMBERG
2018-12-28 15:33 ` Eli Zaretskii
2018-12-28 17:03 ` Werner LEMBERG [this message]
2018-12-28 17:06 ` Werner LEMBERG
2018-12-28 19:15 ` Eli Zaretskii
2022-02-12 8:42 ` Lars Ingebrigtsen
2022-02-12 8:57 ` Eli Zaretskii
2022-03-12 22:43 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181228.180311.772225120008653742.wl@gnu.org \
--to=wl@gnu.org \
--cc=33885@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).