mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01:00
Hide unicode directional control characters
They shouldn't be looked up in the font and displayed under any circumstances.
This commit is contained in:
parent
45ec77973b
commit
2003eed2a5
3 changed files with 31 additions and 8 deletions
|
@ -1074,6 +1074,12 @@ static int print_char(
|
|||
{
|
||||
/* Draws the glyph for a codepoint at x,y.
|
||||
* Returns the amount of pixels to advance the cursor. */
|
||||
if (is_directional_character(codepoint) || is_joiner(codepoint))
|
||||
{
|
||||
// Some characters should be completely invisible
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Font* f_glyph;
|
||||
GlyphInfo* glyph = find_glyphinfo(f, codepoint, &f_glyph);
|
||||
if (glyph == NULL)
|
||||
|
|
|
@ -263,6 +263,25 @@ void bidi_destroy(void)
|
|||
}
|
||||
|
||||
|
||||
bool is_directional_character(const uint32_t codepoint)
|
||||
{
|
||||
// LEFT-TO-RIGHT MARK and RIGHT-TO-LEFT MARK
|
||||
if (codepoint == 0x200E || codepoint == 0x200F) return true;
|
||||
|
||||
// Some other directional formatting: LRE, RLE, PDF, RLO, LRO
|
||||
if (codepoint >= 0x202A && codepoint <= 0x202E) return true;
|
||||
|
||||
// The more recent isolates: LRI, RLI, FSI, PDI
|
||||
if (codepoint >= 0x2066 && codepoint <= 0x2069) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_joiner(const uint32_t codepoint)
|
||||
{
|
||||
return codepoint == 0x200C || codepoint == 0x200D;
|
||||
}
|
||||
|
||||
bool bidi_should_transform(const char* text)
|
||||
{
|
||||
/* Just as an optimization, only run the whole bidi machinery if the
|
||||
|
@ -278,14 +297,8 @@ bool bidi_should_transform(const char* text)
|
|||
// Extended Arabic B and A
|
||||
if (ch >= 0x870 && ch <= 0x8FF) return true;
|
||||
|
||||
// LEFT-TO-RIGHT MARK and RIGHT-TO-LEFT MARK
|
||||
if (ch == 0x200E || ch == 0x200F) return true;
|
||||
|
||||
// Some other directional formatting: LRE, RLE, PDF, RLO, LRO
|
||||
if (ch >= 0x202A && ch <= 0x202E) return true;
|
||||
|
||||
// The more recent isolates: LRI, RLI, FSI, PDI
|
||||
if (ch >= 0x2066 && ch <= 0x2069) return true;
|
||||
// Any directional control character
|
||||
if (is_directional_character(ch)) return true;
|
||||
|
||||
// Hebrew presentation forms
|
||||
if (ch >= 0xFB1D && ch <= 0xFB4F) return true;
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
#ifndef FONTBIDI_H
|
||||
#define FONTBIDI_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace font
|
||||
{
|
||||
|
||||
void bidi_init(void);
|
||||
void bidi_destroy(void);
|
||||
bool is_directional_character(uint32_t codepoint);
|
||||
bool is_joiner(uint32_t codepoint);
|
||||
bool bidi_should_transform(const char* text);
|
||||
const char* bidi_transform(const char* text);
|
||||
|
||||
|
|
Loading…
Reference in a new issue