mirror of
https://github.com/skishore/makemeahanzi.git
synced 2025-11-02 21:41:28 +08:00
Prepare to load missing radicals
This commit is contained in:
@ -6,6 +6,11 @@ var FONT_LOADED_PROGRESS = 0.1;
|
|||||||
|
|
||||||
Template.controls.events({
|
Template.controls.events({
|
||||||
'click #reload-button': function() {
|
'click #reload-button': function() {
|
||||||
|
const characters_to_save =
|
||||||
|
new Set(Object.keys(cjklib.radicals.radical_to_index_map)
|
||||||
|
.filter((radical) => !cjklib.gb2312[radical]));
|
||||||
|
const characters_found = new Set;
|
||||||
|
|
||||||
Session.set('progress.value', 0);
|
Session.set('progress.value', 0);
|
||||||
opentype.load('arphic/UKaiCN.ttf', function(err, font) {
|
opentype.load('arphic/UKaiCN.ttf', function(err, font) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -17,12 +22,16 @@ Template.controls.events({
|
|||||||
|
|
||||||
for (var i = 0; i < font.glyphs.length; i++) {
|
for (var i = 0; i < font.glyphs.length; i++) {
|
||||||
var glyph = font.glyphs.glyphs[i];
|
var glyph = font.glyphs.glyphs[i];
|
||||||
if (CODEPOINTS[0] <= glyph.unicode && glyph.unicode <= CODEPOINTS[1]) {
|
const unicode = String.fromCodePoint(glyph.unicode || 0);
|
||||||
|
if (characters_to_save.has(unicode)) {
|
||||||
var name = 'uni' + glyph.unicode.toString(16).toUpperCase();
|
var name = 'uni' + glyph.unicode.toString(16).toUpperCase();
|
||||||
glyphs_to_save.push({name: name, path: glyph.path.commands});
|
glyphs_to_save.push({name: name, path: glyph.path.commands});
|
||||||
|
characters_found.add(unicode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Missing radicals:', Array.from(characters_to_save).filter(
|
||||||
|
(x) => !characters_found.has(x)));
|
||||||
save_glyphs(glyphs_to_save);
|
save_glyphs(glyphs_to_save);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -544,7 +544,7 @@ this.get_glyph_render_data = function(glyph, manual_bridges, classifier) {
|
|||||||
var strokes = extract_strokes(
|
var strokes = extract_strokes(
|
||||||
paths, endpoints, manual_bridges || bridges, log);
|
paths, endpoints, manual_bridges || bridges, log);
|
||||||
var character = String.fromCodePoint(parseInt(glyph.name.substr(3), 16));
|
var character = String.fromCodePoint(parseInt(glyph.name.substr(3), 16));
|
||||||
var expected = cjklib.stroke_counts[character];
|
var expected = cjklib.getCharacterData(character).strokes;
|
||||||
log.push(['success', 'For character: ' +
|
log.push(['success', 'For character: ' +
|
||||||
String.fromCodePoint(parseInt(glyph.name.substr(3), 16))]);
|
String.fromCodePoint(parseInt(glyph.name.substr(3), 16))]);
|
||||||
if (expected === undefined) {
|
if (expected === undefined) {
|
||||||
|
|||||||
Reference in New Issue
Block a user