[README] Add basic Megane and Tablegen docs
This commit is contained in:
parent
35ce1d8e19
commit
9fad3c41b2
1 changed files with 72 additions and 0 deletions
72
README.md
72
README.md
|
@ -60,3 +60,75 @@ AnimateFile("084b8.svg", "084b8-out.svg", AnimationSettings {
|
|||
.DelayBetweenStrokes = 50ms,
|
||||
});
|
||||
```
|
||||
|
||||
## Megane
|
||||
|
||||
A tiny library that loads the `kvg-index.json` into a dictionary to translate the UTF-8
|
||||
representation of kanji characters into the ID that kanjivg uses to refer to the characters.
|
||||
|
||||
Example usage:
|
||||
```cpp
|
||||
auto lookup = Megane::Megane("/path/to/kvg-index.json");
|
||||
auto id = lookup.GetCode("日"); // id should contain "065e5.svg"
|
||||
```
|
||||
|
||||
## Tablegen
|
||||
|
||||
This library generates a table of kanji images from a specified list with various configurable
|
||||
values. It's made up of the following interface:
|
||||
|
||||
```cpp
|
||||
std::string GeneratePage(const Settings& settings = Settings::Default());
|
||||
|
||||
void GeneratePage(const std::string& path, const Settings& settings = Settings::Default());
|
||||
|
||||
#ifdef TABLEGEN_EXPOSE_XML
|
||||
void GenerateAsChild(pugi::xml_node& node, const Settings& settings = Settings::Default());
|
||||
|
||||
pugi::xml_document GenerateDocument(const Settings& settings = Settings::Default());
|
||||
#endif
|
||||
```
|
||||
|
||||
The first function returns a serialized HTML document in a string
|
||||
(can return just the table by changing the `FullDocument` value in the settings).
|
||||
The second function dumps the same document inside a file at the specified path.
|
||||
The final two functions are hidden behing the `TABLEGEN_EXPOSE_XML` preprocessor flag, because they
|
||||
expose the library that Tablegen uses internally to generate the document. They let the user
|
||||
modify the XML tree before it gets serialized into the final document. The first of these functions
|
||||
takes in a reference to the node that will act as the parent of the generated table.
|
||||
The second function returns a whole XML document.
|
||||
|
||||
Some caveats:
|
||||
- `GenerateDocument` returns a `pugi::xml_document`, which cannot be assigned as a child
|
||||
of anothe node. You don't want to use this function if you plan to generate a full document
|
||||
with the table as a child (the `FullDocument` option isn't applicable in all cases either).
|
||||
- The default serialisation options do not generate a valid document, some specific options
|
||||
need to be set for the document to be valid (currently `pugi::format_no_escapes`,
|
||||
and `pugi::format_no_declaration`, but this is an implementation detail of the pugixml library).
|
||||
|
||||
The default settings generate a table with no characters (and horrible styling), you will need to
|
||||
specify custom settings like this for actual use:
|
||||
```cpp
|
||||
auto doc = GeneratePage({
|
||||
.FullDocument = Flag::Enable,
|
||||
.OverrideIndentLevel = Flag::Disable,
|
||||
.IndentLevel = 0,
|
||||
.TableWidth = 90,
|
||||
.TableMargin = 5,
|
||||
.TableItemWidth = 30,
|
||||
.TableItemPadding = 2,
|
||||
.TableItemColour = RGB::FromHex("#666666"),
|
||||
.LabelFontSize = 1.75,
|
||||
.LabelFontUnits = FontSizeUnits::Em,
|
||||
.ButtonColour = RGB::FromHex("#FF6347"),
|
||||
.ButtonHoverColour = RGB::FromHex("#FFA500"),
|
||||
.ButtonAnimationLength = 0.5,
|
||||
.CharactersPerRow = 3,
|
||||
.ImageFormat = "http://the.url/where/you/have/images/{}.svg",
|
||||
.AnimationFormat = "http://the.url/where/you/have/animations/{}.svg",
|
||||
.Characters = {
|
||||
/* The actual characters you want in the table, example: */
|
||||
{ .Label = "Day", .ImagePath = "%E6%97%A5", .AnimationPath = "%E6%97%A5", },
|
||||
},
|
||||
});
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue