aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS.md2
-rw-r--r--CONTRIBUTING.md4
-rwxr-xr-xMakefile.vars15
-rwxr-xr-xconfigure2
-rw-r--r--formats/BINARY1.md12
-rw-r--r--formats/SOURCE.md27
-rw-r--r--reference/characters.yml1
-rw-r--r--reference/main.yml2
-rwxr-xr-xtools/dumpbin.py48
-rwxr-xr-xtools/fontcharacter/__init__.py (renamed from tools/fontcharacter.py)42
-rwxr-xr-xtools/listsets.py31
-rwxr-xr-xtools/makebin.py79
13 files changed, 168 insertions, 98 deletions
diff --git a/.gitignore b/.gitignore
index 527119d..32ba708 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
/sets
.*.swp
+__pycache__
diff --git a/AUTHORS.md b/AUTHORS.md
index e8a1f75..52b6974 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -8,6 +8,6 @@ Thanks to the other contributors for making FONTCHARACTER great again:
Thanks to the following sources of information:
* Raw OS Data, extracted using a tool based on a technique found by
Simon Lothar;
-* "La Casio Graph100", by Olivier Coupelon (May, 2002);
+* “La Casio Graph100”, by Olivier Coupelon (May, 2002);
* Casetta's CASIO Token List, by Florian Birée (May, 2007);
* Various manuals from CASIO.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9ab7d25..982b1d4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,7 +13,7 @@ straight away...), so please try to concentrate on CASIO's sets first.
To achieve this, you can use my [Opcode Table C Extracting Tool][extract], and
the OSes on [Planète Casio's Bible][oses].
-## Mistake?
+## Any mistake?
You have tried using the reference, but it doesn't match the characters on
your calculator? Yes, it indeed could be a mistake, but it might as well be
a compatibility issue!
@@ -23,7 +23,7 @@ to correct the reference while not breaking everything (even though the
maintainers will probably be careful), that would be great!
Otherwise, you can try to contact the current project maintainer(s).
-You can find their details in `AUTHORS.md`.
+You can find their personal detail in `AUTHORS.md`.
[extract]: http://www.casiopeia.net/forum/viewtopic.php?p=14742#p14742
[oses]: http://bible.planet-casio.com/casio/os_boot_setup/
diff --git a/Makefile.vars b/Makefile.vars
index ea56264..4a8888a 100755
--- a/Makefile.vars
+++ b/Makefile.vars
@@ -45,5 +45,18 @@
# Remove a file.
RM := rm -f
+#*****************************************************************************#
+# Check for DESTDIR (add as prefix to installation root) #
+#*****************************************************************************#
+# Save original sets dir.
+ OISETDIR := $(ISETDIR)
+
+# Make it.
+define add-dest-dir
+ $1 = $(DESTDIR)$($1)
+endef
+$(if $(DESTDIR), $(foreach idir,\
+ISETDIR,\
+$(eval $(call add-dest-dir,$(idir)))))
-# Install a file.
+# End of file.
diff --git a/configure b/configure
index c98ed4d..d732bc8 100755
--- a/configure
+++ b/configure
@@ -18,7 +18,7 @@ no_unicode=
# Installation directories.
root=''
-prefix='${root}/usr'
+prefix='${root}/opt/p7-project'
setdir='${prefix}/share/casio-fontcharacter/'
#*****************************************************************************#
# Help message #
diff --git a/formats/BINARY1.md b/formats/BINARY1.md
index 527d11c..bd60a7f 100644
--- a/formats/BINARY1.md
+++ b/formats/BINARY1.md
@@ -101,9 +101,13 @@ calculated and given sizes should be checked.
Notice that bytes don't need to be in the same order than characters, and
can be indexed several times, which can lead to space optimizations.
-For example, if a character points to [0x01, 0x02] and another
-one points to [0x02, 0x03] (in any order), you can put [0x01, 0x02, 0x03] in
-the data pool, then make the first character point to the offset of this tab,
-and the second one point to the offset + 1 of this tab.
+For example, if a character points to [0x02, 0x03] and another
+one points to [0x01, 0x02] (in any order), you can put [0x01, 0x02, 0x03] in
+the data pool, then make the first character point to the offset + 1 of
+this tab, and the second one point to the offset of this tab.
+This system allows space optimizations to be done to this zone at build time,
+although optimizing this depends on the [shortest superstring][superstr]
+problem.
[picture.h]: https://github.com/PlaneteCasio/libcasio/blob/master/include/libcasio/picture.h
+[superstr]: https://en.wikipedia.org/wiki/Shortest_common_supersequence_problem
diff --git a/formats/SOURCE.md b/formats/SOURCE.md
index 49667b6..4c9f901 100644
--- a/formats/SOURCE.md
+++ b/formats/SOURCE.md
@@ -1,11 +1,21 @@
# Source format
-This format might change at any moment, as it is only written for maintainers
-and other contributors to this project. It is not versioned for the same
-reason. If you just want to use the reference, see the latest binary format.
+This format is yet to stabilize. If you just want to use the reference for
+conversions between FONTCHARACTER and other character sets (which should
+be managed by [libcasio][libcasio] anyway), check out the latest binary
+format (`BINARYx.md`).
YAML has been chosen to store the information, as it's a storage format that
a machine and a human can read and write quite easily.
+## Main file
+`main.yml` is the file containing the main information about the source
+reference. It only contains two fields for now:
+
+- `version` is the version of the source reference (`0.1` corresponds to this
+ version);
+- `source` is the link to the FONTCHARACTER reference's source repository,
+ managed through a VCS (Git, for that matter).
+
## Sets
A set is basically a pack of characters appeared at the same time on CASIO
calculators, or in an extension (alternative CASIO Basic
@@ -41,9 +51,9 @@ There are two systems of characters on CASIO calculators: Simon Lothar calls
them the "characters" and the "opcodes". The "characters" are simple characters
with a display, and the "opcodes", which are defined by a set of characters
(e.g. "Locate "). The two are described in two different tables on the
-calculator, but the two describe the same encoding, so that's why this reference
-considers all "characters" and "opcodes" as characters ("opcodes" are here
-called multi-characters).
+calculator, but the two describe the same encoding, so that's why this
+reference considers all "characters" and "opcodes" as characters ("opcodes"
+are here called multi-characters).
`characters.yml` is the file containing data about the characters. For each
character, the `code` field is its `FONTCHARACTER` code, the `name` field is
@@ -52,7 +62,8 @@ and the `category` field is the category(/subcategory) ID (see in the last
paragraph). If there is no category field, the category is "Other", with no
prefix.
-Flags is a list of flag strings. Current flags are:
+Flags is a list of flag strings. Current flags are:
+
* `nl`: the character should be followed by a newline;
* `esc`: the character's CTF token is escaped with a reverse solidus;
* `sep`: the character is a Basic separator;
@@ -161,3 +172,5 @@ If the file doesn't exist, the character is to be considered as blank.
Each existing file is a set of 256 tiles of `width * height` each. Each row is
the tiles going from `0xR0` to `0xRF`, where `0xR` is the row number
(0x0 to 0xF).
+
+[libcasio]: https://libcasio.planet-casio.com/
diff --git a/reference/characters.yml b/reference/characters.yml
index 0fd52ff..7a49f0a 100644
--- a/reference/characters.yml
+++ b/reference/characters.yml
@@ -77,6 +77,7 @@
name: Disp
category: Symbol
flags: [nl, sep]
+ unicode: [0x25E2]
tokens: {cat: "\\Disp", newcat: ["\\Disp\r", "\\Disp"], ctf: "_\n",
casemul: "\\xbb\r"}
id: disps
diff --git a/reference/main.yml b/reference/main.yml
new file mode 100644
index 0000000..a939fc2
--- /dev/null
+++ b/reference/main.yml
@@ -0,0 +1,2 @@
+version: "0.1"
+source: https://github.com/planetecasio/fontcharacter_reference
diff --git a/tools/dumpbin.py b/tools/dumpbin.py
index 3e8353b..1204fcd 100755
--- a/tools/dumpbin.py
+++ b/tools/dumpbin.py
@@ -1,19 +1,16 @@
#!/usr/bin/env python3
+""" Utility to dump data from a set binary file.
+ Mainly here to check that the format is correct for now.
+"""
+
import os, unicodedata
from functools import cmp_to_key
from argparse import ArgumentParser
-#*****************************************************************************#
-# Parse arguments #
-#*****************************************************************************#
-ap = ArgumentParser(description='FONTCHARACTER binary file dumper')
-
-ap.add_argument('--only-check', help='Should only check if the file is valid',
- action="store_true")
-ap.add_argument('input', help='The file which to dump the content.')
-args = ap.parse_args()
-#*****************************************************************************#
-# Decoding function #
-#*****************************************************************************#
+
+# ---
+# Decoding function.
+# ---
+
def frombytes(bnum):
if type(bnum) == int: return bnum
return int.from_bytes(bnum, byteorder='big', signed=False)
@@ -196,13 +193,24 @@ def decode_set(braw, only_check=True):
else:
print("ERROR: Unmanaged version 0x%02X!"%bmagic[8])
return 1
-#*****************************************************************************#
-# Main things #
-#*****************************************************************************#
-# Obtain the file.
-braw = open(args.input, "rb").read()
-
-# Decode it.
-exit(decode_set(braw, args.only_check))
+
+# ---
+# Main function.
+# ---
+
+if __name__ == '__main__':
+ # Parse the arguments.
+ ap = ArgumentParser(description='FONTCHARACTER binary file dumper')
+
+ ap.add_argument('--only-check', help='Should only check if the file is valid',
+ action="store_true")
+ ap.add_argument('input', help='The file which to dump the content.')
+ args = ap.parse_args()
+
+ # Obtain the file.
+ braw = open(args.input, "rb").read()
+
+ # Decode it.
+ exit(decode_set(braw, args.only_check))
# End of file.
diff --git a/tools/fontcharacter.py b/tools/fontcharacter/__init__.py
index 1542c77..ca92206 100755
--- a/tools/fontcharacter.py
+++ b/tools/fontcharacter/__init__.py
@@ -1,15 +1,19 @@
#!/usr/bin/env python3
+""" The FONTCHARACTER Python module is used for manipulating the source
+ and binary formats. See <../../formats/SOURCE.md> for more information.
+"""
+
import os, sys, string, yaml
# Sainitize for the `id` field
def sanitize_id(s):
return ''.join(ch for ch in s \
if ch in string.ascii_letters + string.digits)
-#*****************************************************************************#
-# Reference class #
-#*****************************************************************************#
+
class Reference:
- # Initialization
+ """ The FONTCHARACTER source object.
+ Loads the characters and corrects the data. """
+
def __init__(self, path, sets_only=False):
# Load sets
self.__load_sets(yaml.load(open(\
@@ -32,8 +36,9 @@ class Reference:
lead += [code >> 8]
self.sets[st]['leading'] = set(lead)
- # Utility to explore a category
def __explore_category(self, c, id, prefix, suffix):
+ """ Explore a category. """
+
# Iterate on things
id += c['id']
try: prefix = c['prefix'] + ' ' + prefix
@@ -49,8 +54,9 @@ class Reference:
for s in c['sub']:
self.__explore_category(s, id + '/', prefix, suffix)
- # Utility to explore sets
def __load_sets(self, raw):
+ """ Explore sets. """
+
self.default_set = ''
self.sets = {}
@@ -73,19 +79,22 @@ class Reference:
for parent, k in kids.items():
self.sets[parent]['kids'] += kids[parent]
- # Inherit character
def __inherit_character(self, id, code, inherit, pr):
- '''id: id of the set, code: code of the character,
- inherit: the set to inherit it from,
- pr: priority (starting from 0, the more it is, the further it is)'''
+ """ Inherit character.
+
+ `id`: id of the set, code: code of the character,
+ `inherit`: the set to inherit it from,
+ `pr`: priority (starting from 0, the more the further). """
+
if not self.sets[id]['characters'].get(code) \
or self.sets[id]['characters'][code]['_pr'] > pr:
self.sets[id]['characters'][code] = {'inherit': inherit, '_pr': pr}
for k in self.sets[id]['kids']:
self.__inherit_character(k, code, inherit, pr + 1)
- # Utility to load characters
def __load_characters(self, raw):
+ """ Load characters. """
+
# Main loop
for c in raw:
# Get the complete name
@@ -143,8 +152,9 @@ class Reference:
for code in st['characters'].keys():
self.__deduce_character_id(id, code)
- # Calculate a multi-character's id
def __deduce_character_id(self, id, code):
+ """ Calculate a multi-character's ID. """
+
char = self.sets[id]['characters'][code]
if char['_pr'] > 0 or char.get('id'): return
m = ""
@@ -161,16 +171,20 @@ class Reference:
m += c['id']
char['id'] = m
- # Get the list of sets
def list(self):
+ """ Get the list of sets. """
+
l = list(self.sets.keys())
l.remove(self.default_set)
return [self.default_set] + l
- # Get a set
def get(self, id = None):
+ """ Get a set. """
+
if type(id) != str:
id = self.default_set
st = self.sets[id]
st['id'] = id
return st
+
+# End of file.
diff --git a/tools/listsets.py b/tools/listsets.py
index 4f116c5..9e2cb47 100755
--- a/tools/listsets.py
+++ b/tools/listsets.py
@@ -1,21 +1,26 @@
#!/usr/bin/env python3
+""" Utility to list the available sets.
+ Mainly there for the Makefile to use it. """
+
import os
from argparse import ArgumentParser
from fontcharacter import Reference
-#*****************************************************************************#
-# Parse arguments #
-#*****************************************************************************#
-ap = ArgumentParser(description="FONTCHARACTER reference sets lister")
-ap.add_argument('--refpath', help='The reference path.', default=os.getcwd())
-args = ap.parse_args()
-#*****************************************************************************#
-# Main things #
-#*****************************************************************************#
-# Obtain the reference.
-ref = Reference(args.refpath, True)
+# ---
+# Main function.
+# ---
+
+if __name__ == '__main__':
+ # Parse the arguments.
+ ap = ArgumentParser(description="FONTCHARACTER reference sets lister")
+
+ ap.add_argument('--refpath', help='The reference path.', default=os.getcwd())
+ args = ap.parse_args()
+
+ # Obtain the reference.
+ ref = Reference(args.refpath, True)
-# List the sets.
-print('\n'.join(ref.list()))
+ # List the sets.
+ print('\n'.join(ref.list()))
# End of file.
diff --git a/tools/makebin.py b/tools/makebin.py
index ad033fc..a962f92 100755
--- a/tools/makebin.py
+++ b/tools/makebin.py
@@ -1,25 +1,14 @@
#!/usr/bin/env python3
+""" Utility to make the set binary files. """
+
import os, shutil
from argparse import ArgumentParser
from fontcharacter import Reference
-#*****************************************************************************#
-# Parse arguments #
-#*****************************************************************************#
-ap = ArgumentParser(description="FONTCHARACTER reference binary generator")
-
-ap.add_argument('--no-unicode', help='No Unicode equivalents?',
- action="store_true")
-ap.add_argument('--no-cat', help='No CAT tokens?', action="store_true")
-ap.add_argument('--no-newcat', help='No Newcat tokens?', action="store_true")
-ap.add_argument('--no-ctf', help='No CTF tokens?', action="store_true")
-ap.add_argument('--no-casemul', help="No Casemul tokens?", action="store_true")
-ap.add_argument('--output', '-o', help='The output directory path.',
- default=os.path.join(os.getcwd(), 'generated_sets'))
-ap.add_argument('--refpath', help='The reference path.', default=os.getcwd())
-args = ap.parse_args()
-#*****************************************************************************#
-# Function for encoding #
-#*****************************************************************************#
+
+# ---
+# Function for encoding.
+# ---
+
def tobytes(num, length):
return num.to_bytes(length, byteorder='big', signed=False)
def charbytes(char):
@@ -27,6 +16,7 @@ def charbytes(char):
def make_pool(pool):
# TODO: make this function optimize space, some day?
+
bdata = b''
offsets = []
for data in pool:
@@ -153,22 +143,41 @@ def encode_set(ref, fset):
+ tobytes(csum, 4) + tobytes(filesize, 4) + tobytes(datalen, 4)
return bheader + blead + bchars + bdata
-#*****************************************************************************#
-# Main things #
-#*****************************************************************************#
-# Obtain the reference.
-ref = Reference(args.refpath)
-
-# Make the directory.
-if os.path.isdir(args.output):
- shutil.rmtree(args.output)
-elif os.path.exists(args.output):
- os.remove(args.output)
-os.makedirs(args.output)
-
-# For each set, make the file.
-for set_name, set_val in map(lambda x: (x, ref.get(x)), ref.list()):
- with open(os.path.join(args.output, set_name + '.set'), 'wb') as f:
- f.write(encode_set(ref, set_val))
+
+# ---
+# Main function.
+# ---
+
+if __name__ == '__main__':
+ ap = ArgumentParser(description="FONTCHARACTER reference binary generator")
+
+ ap.add_argument('--no-unicode', help='No Unicode equivalents?',
+ action="store_true")
+ ap.add_argument('--no-cat', help='No CAT tokens?', action="store_true")
+ ap.add_argument('--no-newcat', help='No Newcat tokens?',
+ action="store_true")
+ ap.add_argument('--no-ctf', help='No CTF tokens?', action="store_true")
+ ap.add_argument('--no-casemul', help="No Casemul tokens?",
+ action="store_true")
+ ap.add_argument('--output', '-o', help='The output directory path.',
+ default=os.path.join(os.getcwd(), 'generated_sets'))
+ ap.add_argument('--refpath', help='The reference path.',
+ default=os.getcwd())
+ args = ap.parse_args()
+
+ # Obtain the reference.
+ ref = Reference(args.refpath)
+
+ # Make the directory.
+ if os.path.isdir(args.output):
+ shutil.rmtree(args.output)
+ elif os.path.exists(args.output):
+ os.remove(args.output)
+ os.makedirs(args.output)
+
+ # For each set, make the file.
+ for set_name, set_val in map(lambda x: (x, ref.get(x)), ref.list()):
+ with open(os.path.join(args.output, set_name + '.set'), 'wb') as f:
+ f.write(encode_set(ref, set_val))
# End of file.