1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Reinstate as much of the Windows font-linking behaviour as I can

easily manage, by adopting a hybrid approach to Unicode text
display. The old approach of simply calling ExtTextOutW provided
font linking without us having to lift a finger, but didn't do the
right thing when it came to bidirectional or Arabic-shaped text.
Arabeyes' replacement exact_textout() supported the latter, but
turned out to break the former (with no warning from the Windows API
documentation, so it's not their fault).

So now I've got a second wrapper layer called general_textout(),
which splits the input string into substrings based on bidi
character class. Any character liable to cause bidi or shaping
behaviour if fed straight to ExtTextOutW is instead fed through
Arabeyes' exact_textout(), but the rest is fed straight to
ExtTextOutW as it used to be.

The effect appears to be that font linking is restored for all
characters _except_ Arabic and other bidi scripts, which means in
particular that we are no longer in a state of regression over 0.57.
(0.57 would have done font linking on Arabic as well, but would also
have misbidied it, so we've merely exchanged one failure mode for
another slightly less harmful one in that situation.)

[originally from svn r6910]
This commit is contained in:
Simon Tatham
2006-11-18 15:10:48 +00:00
parent 53843b7392
commit 230d400ddc
3 changed files with 120 additions and 6 deletions

View File

@ -877,6 +877,40 @@ unsigned char getType(int ch)
return ON;
}
/*
* Function exported to front ends to allow them to identify
* bidi-active characters (in case, for example, the platform's
* text display function can't conveniently be prevented from doing
* its own bidi and so special treatment is required for characters
* that would cause the bidi algorithm to activate).
*
* This function is passed a single Unicode code point, and returns
* nonzero if the presence of this code point can possibly cause
* the bidi algorithm to do any reordering. Thus, any string
* composed entirely of characters for which is_rtl() returns zero
* should be safe to pass to a bidi-active platform display
* function without fear.
*
* (is_rtl() must therefore also return true for any character
* which would be affected by Arabic shaping, but this isn't
* important because all such characters are right-to-left so it
* would have flagged them anyway.)
*/
int is_rtl(int c)
{
/*
* After careful reading of the Unicode bidi algorithm (URL as
* given at the top of this file) I believe that the only
* character classes which can possibly cause trouble are R,
* AL, RLE and RLO. I think that any string containing no
* character in any of those classes will be displayed
* uniformly left-to-right by the Unicode bidi algorithm.
*/
const int mask = (1<<R) | (1<<AL) | (1<<RLE) | (1<<RLO);
return mask & (1 << (getType(c)));
}
/*
* The most significant 2 bits of each level are used to store
* Override status of each character