Commit 68dd563
parse ucd in background thread
Changed files (4)
modifiedbirdfont/Main.valamodifiedlibbirdfont/CharDatabaseParser.valamodifiedlibbirdfont/DefaultCharactersSet.valamodifiedlibbirdfont/RectangleTool.vala
Diff
@@ -29,6 +29,12 @@ public static int main (string[] arg) { MainWindow window; string file; BirdFont.BirdFont birdfont = new BirdFont.BirdFont ();+ CharDatabaseParser db = new CharDatabaseParser ();+ unowned Thread<int> db_thread;+ Mutex database_mutex = Mutex ();+ Cond main_loop_idle = new Cond ();+ bool in_idle = false;+ birdfont.init (arg, null); Gtk.init (ref arg);@@ -46,6 +52,34 @@ public static int main (string[] arg) { MainWindow.file_tab.load_font (file); } + try {+ db_thread = Thread.create<int> (db.load, false);+ + // wait until main loop is done+ db.sync.connect (() => {+ database_mutex.lock ();+ IdleSource idle = new IdleSource ();+ in_idle = false;+ + idle.set_callback (() => {+ database_mutex.lock ();+ in_idle = true;+ main_loop_idle.broadcast ();+ database_mutex.unlock ();+ return false;+ });+ idle.attach (null);+ + while (!in_idle) {+ main_loop_idle.wait (database_mutex);+ }+ + database_mutex.unlock ();+ });+ } catch (GLib.Error e) {+ warning (e.message);+ }+ Gtk.main (); return 0;@@ -18,7 +18,9 @@ namespace BirdFont { public class CharDatabaseParser : GLib.Object { - signal void sync ();+ public signal void sync ();+ + GlyphRange utf8 = new GlyphRange (); public CharDatabaseParser () { }@@ -57,12 +59,13 @@ public class CharDatabaseParser : GLib.Object { ch = Font.to_unichar ("U+" + unicode_hex.down ()); Idle.add (() => {- CharDatabase.full_unicode_range.add_single (ch); CharDatabase.entries.set (unicode_hex, data); return false; }); sync (); + utf8.add_single (ch);+ foreach (string s in e) { r = s.split ("\n"); foreach (string t in r) { @@ -134,9 +137,12 @@ public class CharDatabaseParser : GLib.Object { IdleSource idle = new IdleSource (); idle.set_callback (() => {+ CharDatabase.full_unicode_range = utf8; CharDatabase.show_loading_message (); CharDatabase.database_is_loaded = true; ProgressBar.set_progress (0);+ + print (utf8.get_all_ranges ()); return false; }); idle.attach (null);@@ -261,8 +261,12 @@ public class DefaultCharacterSet { CharDatabase.get_full_unicode (gr); if (gr.get_length () == 0) {- warning ("No items obtained from UCD.");- gr.add_range ('\0', (unichar) 0xFFF8);+ try {+ gr.parse_ranges ("null-ͷ ͺ-; ΄-Ί Ό Ύ-Ρ Σ-ԧ Ա-Ֆ ՙ-՟ ա-և ։-֊ ֏ ֑-ׇ א-ת װ-״ - ؆-؛ ؞-܍ -݊ ݍ-ޱ ߀-ߺ ࠀ-࠭ ࠰-࠾ ࡀ-࡛ ࡞ ࢠ ࢢ-ࢬ ࣤ-ࣾ ऀ-ॷ ॹ-ॿ ঁ-ঃ অ-ঌ এ-ঐ ও-ন প-র ল শ-হ ়-ৄ ে-ৈ ো-ৎ ৗ ড়-ঢ় য়-৻ ਁ-ਃ ਅ-ਊ ਏ-ਐ ਓ-ਨ ਪ-ਰ ਲ-ਲ਼ ਵ-ਸ਼ ਸ-ਹ ਼ ਾ-ੂ ੇ-ੈ ੋ-੍ ੑ ਖ਼-ੜ ਫ਼ -ੵ ઁ-ઃ અ-ઍ એ-ઑ ઓ-ન પ-ર લ-ળ વ-હ ઼-ૅ ે-ૉ ો-્ ૐ ૠ-૱ ଁ-ଃ ଅ-ଌ ଏ-ଐ ଓ-ନ ପ-ର ଲ-ଳ ଵ-ହ ଼-ୄ େ-ୈ ୋ-୍ ୖ-ୗ ଡ଼-ଢ଼ ୟ-୷ ஂ-ஃ அ-ஊ எ-ஐ ஒ-க ங-ச ஜ ஞ-ட ண-த ந-ப ம-ஹ ா-ூ ெ-ை ொ-் ௐ ௗ -௺ ఁ-ః అ-ఌ ఎ-ఐ ఒ-న ప-ళ వ-హ ఽ-ౄ ె-ై ొ-్ ౕ-ౖ ౘ-ౙ ౠ-౯ ౸-౿ ಂ-ಃ ಅ-ಌ ಎ-ಐ ಒ-ನ ಪ-ಳ ವ-ಹ ಼-ೄ ೆ-ೈ ೊ-್ ೕ-ೖ ೞ ೠ-೯ ೱ-ೲ ം-ഃ അ-ഌ എ-ഐ ഒ-ഺ ഽ-ൄ െ-ൈ ൊ-ൎ ൗ ൠ-൵ ൹-ൿ ං-ඃ අ-ඖ ක-න ඳ-ර ල ව-ෆ ් ා-ු ූ ෘ-ෟ ෲ-෴ ก-ฺ ฿-๛ ກ-ຂ ຄ ງ-ຈ ຊ ຍ ດ-ທ ນ-ຟ ມ-ຣ ລ ວ ສ-ຫ ອ-ູ ົ-ຽ ເ-ໄ ໆ ່-ໍ ໐-໙ ໜ-ໟ ༀ-ཇ ཉ-ཬ ཱ-ྗ ྙ-ྼ ྾-࿌ ࿎-࿚ က-Ⴥ Ⴧ Ⴭ ა-ቈ ቊ-ቍ ቐ-ቖ ቘ ቚ-ቝ በ-ኈ ኊ-ኍ ነ-ኰ ኲ-ኵ ኸ-ኾ ዀ ዂ-ዅ ወ-ዖ ዘ-ጐ ጒ-ጕ ጘ-ፚ ፝-፼ ᎀ-᎙ Ꭰ-Ᏼ ᐀-᚜ ᚠ-ᛰ ᜀ-ᜌ ᜎ-᜔ ᜠ-᜶ ᝀ-ᝓ ᝠ-ᝬ ᝮ-ᝰ ᝲ-ᝳ ក-៝ ០-៩ ៰-៹ ᠀- ᠐-᠙ ᠠ-ᡷ ᢀ-ᢪ ᢰ-ᣵ ᤀ-ᤜ ᤠ-ᤫ ᤰ-᤻ ᥀ ᥄-ᥭ ᥰ-ᥴ ᦀ-ᦫ ᦰ-ᧉ ᧐-᧚ ᧞-ᨛ ᨞-ᩞ ᩠-᩼ ᩿-᪉ ᪐-᪙ ᪠-᪭ ᬀ-ᭋ ᭐-᭼ ᮀ-᯳ ᯼-᰷ ᰻-᱉ ᱍ-᱿ ᳀-᳇ ᳐-ᳶ ᴀ-ᷦ ᷼-ἕ Ἐ-Ἕ ἠ-ὅ Ὀ-Ὅ ὐ-ὗ Ὑ Ὓ Ὕ Ὗ-ώ ᾀ-ᾴ ᾶ-ῄ ῆ-ΐ ῖ-Ί ῝-` ῲ-ῴ ῶ-῾ - -₎ ₐ-ₜ ₠-₹ ⃐-⃰ ℀-↉ ←-⏳ ␀-␦ ⑀-⑊ ①-⛿ ✁-⭌ ⭐-⭙ Ⰰ-Ⱞ ⰰ-ⱞ Ⱡ-ⳳ ⳹-ⴥ ⴧ ⴭ ⴰ-ⵧ ⵯ-⵰ ⵿-ⶖ ⶠ-ⶦ ⶨ-ⶮ ⶰ-ⶶ ⶸ-ⶾ ⷀ-ⷆ ⷈ-ⷎ ⷐ-ⷖ ⷘ-ⷞ ⷠ-⸻ ⺀-⺙ ⺛-⻳ ⼀-⿕ ⿰-⿻ -〿 ぁ-ゖ ゙-ヿ ㄅ-ㄭ ㄱ-ㆎ ㆐-ㆺ ㇀-㇣ ㇰ-㈞ ㈠-㋾ ㌀-㏿ ䷀-䷿ ꀀ-ꒌ ꒐-꓆ ꓐ-ꘫ Ꙁ-ꚗ ꚟ-꛷ ꜀-ꞎ Ꞑ-ꞓ Ꞡ-Ɦ ꟸ-꠫ ꠰-꠹ ꡀ-꡷ ꢀ-꣄ ꣎-꣙ ꣠-ꣻ ꤀-꥓ ꥟-ꥼ ꦀ-꧍ ꧏ-꧙ ꧞-꧟ ꨀ-ꨶ ꩀ-ꩍ ꩐-꩙ ꩜-ꩻ ꪀ-ꫂ ꫛ-꫶ ꬁ-ꬆ ꬉ-ꬎ ꬑ-ꬖ ꬠ-ꬦ ꬨ-ꬮ ꯀ-꯭ ꯰-꯹ ힰ-ퟆ ퟋ-ퟻ 豈-舘 並-龎 ff-st ﬓ-ﬗ יִ-זּ טּ-לּ מּ נּ-סּ ףּ-פּ צּ-﯁ ﯓ-﴿ ﵐ-ﶏ ﶒ-ﷇ ﷰ-﷽ ︀-︙ ︠-︦ ︰-﹒ ﹔-﹦ ﹨-﹫ ﹰ-ﹴ ﹶ-ﻼ !-ᄒ ᅡ-ᅦ ᅧ-ᅬ ᅭ-ᅲ ᅳ-ᅵ ¢-₩ │-○ -� 𐀀-𐀋 𐀍-𐀦 𐀨-𐀺 𐀼-𐀽 𐀿-𐁍 𐁐-𐁝 𐂀-𐃺 𐄀-𐄂 𐄇-𐄳 𐄷-𐆊 𐆐-𐆛 𐇐-𐇽 𐊀-𐊜 𐊠-𐋐 𐌀-𐌞 𐌠-𐌣 𐌰-𐍊 𐎀-𐎝 𐎟-𐏃 𐏈-𐏕 𐐀-𐒝 𐒠-𐒩 𐠀-𐠅 𐠈 𐠊-𐠵 𐠷-𐠸 𐠼 𐠿-𐡕 𐡗-𐡟 𐤀-𐤛 𐤟-𐤹 𐤿 𐦀-𐦷 𐦾-𐦿 𐨀-𐨃 𐨅-𐨆 𐨌-𐨓 𐨕-𐨗 𐨙-𐨳 𐨸-𐨺 𐨿-𐩇 𐩐-𐩘 𐩠-𐩿 𐬀-𐬵 𐬹-𐭕 𐭘-𐭲 𐭸-𐭿 𐰀-𐱈 𐹠-𐹾 𑀀-𑁍 𑁒-𑁯 𑂀-𑃁 𑃐-𑃨 𑃰-𑃹 𑄀-𑄴 𑄶-𑅃 𑆀-𑇈 𑇐-𑇙 𑚀-𑚷 𑛀-𑛉 𒀀-𒍮 𒐀-𒑢 𒑰-𒑳 𓀀-𓐮 𖠀-𖨸 𖼀-𖽄 𖽐-𖽾 𖾏-𖾟 𛀀-𛀁 𝀀-𝃵 𝄀-𝄦 𝄩-𝇝 𝈀-𝉅 𝌀-𝍖 𝍠-𝍱 𝐀-𝚥 𝚨-𝟋 𝟎-𝟿 𞸀-𞸃 𞸅-𞸟 𞸡-𞸢 𞸤 𞸧 𞸩-𞸲 𞸴-𞸷 𞸹 𞸻 𞹂 𞹇 𞹉 𞹋 𞹍-𞹏 𞹑-𞹒 𞹔 𞹗 𞹙 𞹛 𞹝 𞹟 𞹡-𞹢 𞹤 𞹧-𞹪 𞹬-𞹲 𞹴-𞹷 𞹹-𞹼 𞹾 𞺀-𞺉 𞺋-𞺛 𞺡-𞺣 𞺥-𞺩 𞺫-𞺻 𞻰-𞻱 🀀-🀫 🀰-🂓 🂠-🂮 🂱-🂾 🃁-🃏 🃑-🃟 🄀-🄊 🄐-🄮 🄰-🅫 🅰-🆚 🇦-🈂 🈐-🈺 🉀-🉈 🉐-🉑 🌀-🌠 🌰-🌵 🌷-🍼 🎀-🎓 🎠-🏄 🏆-🏊 🏠-🏰 🐀-🐾 👀 👂-📷 📹-📼 🔀-🔽 🕀-🕃 🕐-🕧 🗻-🙀 🙅-🙏 🚀-🛅 🜀-🝳 丽-𪘀 - 󠄀-󠇯");+ } catch (MarkupError e) {+ warning (e.message);+ gr.add_range ('\0', (unichar) 0xFFF8);+ } } } @@ -79,7 +79,7 @@ public class RectangleTool : Tool { e.recalculate_linear_handles (); } - MainWindow.get_glyph_canvas ().redraw ();+ GlyphCanvas.redraw (); } }