summaryrefslogtreecommitdiff
path: root/rufl_character_set_test.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2005-01-08 21:02:32 +0000
committerJames Bursa <james@netsurf-browser.org>2005-01-08 21:02:32 +0000
commitc4580a33f78825e385626610fbbff9a675b248a4 (patch)
treed4ab197d183e4a917202415cb7bd44b75d5c7866 /rufl_character_set_test.c
downloadlibrufl-c4580a33f78825e385626610fbbff9a675b248a4.tar.gz
librufl-c4580a33f78825e385626610fbbff9a675b248a4.tar.bz2
[project @ 2005-01-08 21:02:32 by bursa]
Initial version of RISC OS Unicode font library. Require Unicode (RO5) Font Manager. svn path=/import/rufl/; revision=2443
Diffstat (limited to 'rufl_character_set_test.c')
-rw-r--r--rufl_character_set_test.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/rufl_character_set_test.c b/rufl_character_set_test.c
new file mode 100644
index 0000000..7134772
--- /dev/null
+++ b/rufl_character_set_test.c
@@ -0,0 +1,36 @@
+/*
+ * This file is part of RUfl
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ * Copyright 2005 James Bursa <james@semichrome.net>
+ */
+
+#include "rufl_internal.h"
+
+
+/**
+ * Test if a character set contains a character.
+ *
+ * \param c character code
+ * \return true if present, false if absent
+ */
+
+bool rufl_character_set_test(struct rufl_character_set *charset,
+ unsigned int c)
+{
+ unsigned int block = c >> 8;
+ unsigned int byte = (c >> 3) & 31;
+ unsigned int bit = c & 7;
+
+ if (256 < block)
+ return false;
+
+ if (charset->index[block] == BLOCK_EMPTY)
+ return false;
+ else if (charset->index[block] == BLOCK_FULL)
+ return true;
+ else {
+ unsigned char z = charset->block[charset->index[block]][byte];
+ return z & (1 << bit);
+ }
+}