The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

OverView.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/OverView.vala.
Merge ../birdfont-2.x
1 /* 2 Copyright (C) 2012 - 2016 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 using SvgBird; 17 18 namespace BirdFont { 19 20 /** A display with all glyphs present in this font. */ 21 public class OverView : FontDisplay { 22 public WidgetAllocation allocation = new WidgetAllocation (); 23 24 public OverViewItem selected_item = new OverViewItem (); 25 26 public Gee.ArrayList<GlyphCollection> copied_glyphs = new Gee.ArrayList<GlyphCollection> (); 27 public Gee.ArrayList<GlyphCollection> selected_items = new Gee.ArrayList<GlyphCollection> (); 28 29 int selected = 0; 30 int first_visible = 0; 31 int rows = 0; 32 int items_per_row = 0; 33 34 double view_offset_y = 0; 35 double view_offset_x = 0; 36 37 public signal void open_new_glyph_signal (unichar c); 38 public signal void open_glyph_signal (GlyphCollection c); 39 40 public GlyphRange glyph_range { 41 get { 42 return _glyph_range; 43 } 44 45 set { 46 _glyph_range = value; 47 } 48 } 49 50 GlyphRange _glyph_range; 51 52 string search_query = ""; 53 54 public Gee.ArrayList<OverViewItem> visible_items = new Gee.ArrayList<OverViewItem> (); 55 56 /** List of undo commands. */ 57 public Gee.ArrayList<OverViewUndoItem> undo_items = new Gee.ArrayList<OverViewUndoItem> (); 58 public Gee.ArrayList<OverViewUndoItem> redo_items = new Gee.ArrayList<OverViewUndoItem> (); 59 60 /** Show all characters that has been drawn. */ 61 public bool all_available { 62 set { 63 _all_available = value; 64 update_item_list (); 65 } 66 67 get { 68 return _all_available; 69 } 70 } 71 72 bool _all_available = false; 73 74 /** Show unicode database info. */ 75 CharacterInfo? character_info = null; 76 77 double scroll_size = 1; 78 const double UCD_LINE_HEIGHT = 17 * 1.3; 79 80 private bool update_scheduled = true; 81 82 public OverView (GlyphRange? range = null, 83 bool open_selected = true, bool default_character_set = true) { 84 85 GlyphRange gr; 86 87 if (range == null) { 88 gr = new GlyphRange (); 89 set_current_glyph_range (gr); 90 } 91 92 if (open_selected) { 93 this.open_glyph_signal.connect ((glyph_collection) => { 94 TabBar tabs = MainWindow.get_tab_bar (); 95 string n = glyph_collection.get_current ().name; 96 bool selected = tabs.select_char (n); 97 98 GlyphTab glyph_tab; 99 100 if (!selected) { 101 glyph_tab = new GlyphTab (glyph_collection); 102 tabs.add_tab (glyph_tab, true, glyph_collection); 103 set_glyph_zoom (glyph_collection); 104 PenTool.update_orientation (); 105 } 106 107 if (glyph_collection.get_name () == ".notdef") { 108 Font font = BirdFont.get_current_font (); 109 if (!font.has_glyph (".notdef")) { 110 font.add_glyph_collection (glyph_collection); 111 } 112 } 113 }); 114 115 this.open_new_glyph_signal.connect ((character) => { 116 // ignore control characters 117 if (character <= 0x1F) { 118 return; 119 } 120 121 create_new_glyph (character); 122 }); 123 } 124 125 if (default_character_set) { 126 IdleSource idle = new IdleSource (); 127 128 idle.set_callback (() => { 129 use_default_character_set (); 130 selected_canvas (); 131 return false; 132 }); 133 134 idle.attach (null); 135 } 136 137 update_item_list (); 138 update_scrollbar (); 139 reset_zoom (); 140 } 141 142 public Glyph? get_selected_glyph () { 143 if (selected_items.size == 0) { 144 return null; 145 } 146 147 return selected_items.get (0).get_current (); 148 } 149 150 public void select_all_glyphs () { 151 Font f; 152 GlyphCollection? glyphs; 153 154 f = BirdFont.get_current_font (); 155 156 for (int index = 0; index < f.length (); index++) { 157 glyphs = f.get_glyph_collection_index ((uint32) index); 158 return_if_fail (glyphs != null); 159 160 selected_items.add ((!) glyphs); 161 } 162 163 foreach (OverViewItem item in visible_items) { 164 item.selected = item.glyphs != null; 165 } 166 167 GlyphCanvas.redraw (); 168 } 169 170 public void use_default_character_set () { 171 GlyphRange gr = new GlyphRange (); 172 all_available = false; 173 DefaultCharacterSet.use_default_range (gr); 174 set_current_glyph_range (gr); 175 OverviewTools.update_overview_characterset (); 176 FontDisplay.dirty_scrollbar = true; 177 } 178 179 public GlyphCollection create_new_glyph (unichar character) { 180 StringBuilder name = new StringBuilder (); 181 TabBar tabs = MainWindow.get_tab_bar (); 182 bool selected; 183 Glyph glyph; 184 GlyphCollection glyph_collection; 185 GlyphCanvas canvas; 186 GlyphTab glyph_tab; 187 188 glyph_collection = MainWindow.get_current_glyph_collection (); 189 name.append_unichar (character); 190 selected = tabs.select_char (name.str); 191 192 if (!selected) { 193 glyph_collection = add_character_to_font (character); 194 glyph_tab = new GlyphTab (glyph_collection); 195 glyph = glyph_collection.get_current (); 196 glyph.layers.add_layer (new Layer ()); 197 tabs.add_tab (glyph_tab, true, glyph_collection); 198 199 selected_items.add (glyph_collection); 200 201 canvas = MainWindow.get_glyph_canvas (); 202 canvas.set_current_glyph_collection (glyph_collection); 203 204 set_glyph_zoom (glyph_collection); 205 } else { 206 warning ("Glyph is already open"); 207 } 208 209 OverviewTools.update_overview_characterset (); 210 return glyph_collection; 211 } 212 213 public GlyphCollection add_empty_character_to_font (unichar character, bool unassigned, string name) { 214 return add_character_to_font (character, true, unassigned); 215 } 216 217 public GlyphCollection add_character_to_font (unichar character, bool empty = false, 218 bool unassigned = false, string glyph_name = "") { 219 StringBuilder name = new StringBuilder (); 220 Font font = BirdFont.get_current_font (); 221 GlyphCollection? fg; 222 Glyph glyph; 223 GlyphCollection glyph_collection; 224 225 if (glyph_name == "") { 226 name.append_unichar (character); 227 } else { 228 name.append (glyph_name); 229 } 230 231 if (all_available) { 232 fg = font.get_glyph_collection_by_name (name.str); 233 } else { 234 fg = font.get_glyph_collection (name.str); 235 } 236 237 if (fg != null) { 238 glyph_collection = (!) fg; 239 } else { 240 glyph_collection = new GlyphCollection (character, name.str); 241 242 if (!empty) { 243 glyph = new Glyph (name.str, !unassigned ? character : '\0'); 244 glyph_collection.add_master (new GlyphMaster ()); 245 glyph_collection.insert_glyph (glyph, true); 246 } 247 248 font.add_glyph_collection (glyph_collection); 249 } 250 251 glyph_collection.set_unassigned (unassigned); 252 253 return glyph_collection; 254 } 255 256 public static void search () { 257 OverView ow = MainWindow.get_overview (); 258 TextListener listener = new TextListener (t_("Search"), ow.search_query, t_("Filter")); 259 260 listener.signal_text_input.connect ((text) => { 261 OverView o = MainWindow.get_overview (); 262 o.search_query = text; 263 }); 264 265 listener.signal_submit.connect (() => { 266 OverView o = MainWindow.get_overview (); 267 string q = o.search_query; 268 269 if (q.char_count () > 1) { 270 q = q.down (); 271 } 272 273 GlyphRange r = CharDatabase.search (q); 274 o.set_current_glyph_range (r); 275 MainWindow.get_tab_bar ().select_tab_name ("Overview"); 276 277 TextListener tl = new TextListener (t_("Search"), o.search_query, t_("Filter")); 278 TabContent.show_text_input (tl); 279 }); 280 281 TabContent.show_text_input (listener); 282 } 283 284 public Glyph? get_current_glyph () { 285 OverViewItem oi = selected_item; 286 if (oi.glyphs != null) { 287 return ((!) oi.glyphs).get_current (); 288 } 289 return null; 290 } 291 292 public void set_glyph_zoom (GlyphCollection glyphs) { 293 GlyphCanvas canvas; 294 canvas = MainWindow.get_glyph_canvas (); 295 canvas.set_current_glyph_collection (glyphs); 296 Toolbox tools = MainWindow.get_toolbox (); 297 ZoomTool z = (ZoomTool) tools.get_tool ("zoom_tool"); 298 z.store_current_view (); 299 glyphs.get_current ().default_zoom (); 300 z.store_current_view (); 301 OverViewItem.reset_label (); 302 } 303 304 public double get_height () { 305 double l; 306 Font f; 307 308 if (rows == 0) { 309 return 0; 310 } 311 312 if (all_available) { 313 f = BirdFont.get_current_font (); 314 l = f.length (); 315 } else { 316 l = glyph_range.length (); 317 } 318 319 return 2.0 * OverViewItem.height * (l / rows); 320 } 321 322 public bool selected_char_is_visible () { 323 return first_visible <= selected <= first_visible + items_per_row * rows; 324 } 325 326 public override bool has_scrollbar () { 327 return true; 328 } 329 330 public bool all_characters_in_view () { 331 double length; 332 Font f; 333 334 if (all_available) { 335 f = BirdFont.get_current_font (); 336 length = f.length (); 337 } else { 338 length = glyph_range.length (); 339 } 340 341 return length < items_per_row * rows; 342 } 343 344 public void move_up () { 345 first_visible -= items_per_row; 346 selected += items_per_row; 347 348 if (first_visible < 0) { 349 selected -= items_per_row; 350 first_visible = 0; 351 view_offset_y = 0; 352 } 353 } 354 355 public void move_down () { 356 if (!at_bottom ()) { 357 first_visible += items_per_row; 358 selected -= items_per_row; 359 } 360 } 361 362 public override void scroll_wheel (double x, double y, double dx, double dy) { 363 double pixel_delta = 3 * dy; 364 365 if (dy > 0) { 366 view_offset_y += pixel_delta; 367 368 while (view_offset_y > 0) { 369 view_offset_y -= OverViewItem.height; 370 move_up (); 371 } 372 } else { 373 if (at_bottom ()) { 374 if (view_offset_y > -2 * OverViewItem.height && !all_characters_in_view ()) { 375 view_offset_y += pixel_delta; 376 } 377 } else { 378 view_offset_y += pixel_delta; 379 while (view_offset_y < -OverViewItem.height) { 380 view_offset_y += OverViewItem.height; 381 move_down (); 382 } 383 } 384 } 385 386 if (view_offset_y < -2 * OverViewItem.height) { 387 view_offset_y = -2 * OverViewItem.height; 388 } 389 390 update_item_list (); 391 update_scrollbar (); 392 hide_menu (); 393 GlyphCanvas.redraw (); 394 } 395 396 public override void selected_canvas () { 397 OverviewTools.update_overview_characterset (); 398 KeyBindings.set_require_modifier (true); 399 update_scrollbar (); 400 update_zoom_bar (); 401 update_item_list (); 402 selected_item = get_selected_item (); 403 GlyphCanvas.redraw (); 404 } 405 406 public void update_zoom_bar () { 407 double z = OverViewItem.width / OverViewItem.DEFAULT_WIDTH - 0.5; 408 Toolbox.overview_tools.zoom_bar.set_zoom (z); 409 Toolbox.redraw_tool_box (); 410 update_item_list (); 411 } 412 413 public void set_zoom (double zoom) { 414 double z = zoom + 0.5; 415 OverViewItem.glyph_scale = 1; 416 OverViewItem.width = OverViewItem.DEFAULT_WIDTH * z; 417 OverViewItem.height = OverViewItem.DEFAULT_HEIGHT * z; 418 OverViewItem.margin = OverViewItem.DEFAULT_MARGIN * z; 419 update_item_list (); 420 OverViewItem.reset_label (); 421 GlyphCanvas.redraw (); 422 } 423 424 public override void zoom_min () { 425 OverViewItem.width = OverViewItem.DEFAULT_WIDTH * 0.5; 426 OverViewItem.height = OverViewItem.DEFAULT_HEIGHT * 0.5; 427 OverViewItem.margin = OverViewItem.DEFAULT_MARGIN * 0.5; 428 update_item_list (); 429 OverViewItem.reset_label (); 430 GlyphCanvas.redraw (); 431 update_zoom_bar (); 432 } 433 434 public override void reset_zoom () { 435 OverViewItem.width = OverViewItem.DEFAULT_WIDTH; 436 OverViewItem.height = OverViewItem.DEFAULT_HEIGHT; 437 OverViewItem.margin = OverViewItem.DEFAULT_MARGIN; 438 update_item_list (); 439 OverViewItem.reset_label (); 440 GlyphCanvas.redraw (); 441 update_zoom_bar (); 442 } 443 444 public override void zoom_max () { 445 OverViewItem.width = allocation.width; 446 OverViewItem.height = allocation.height; 447 update_item_list (); 448 OverViewItem.reset_label (); 449 GlyphCanvas.redraw (); 450 } 451 452 public override void zoom_in () { 453 OverViewItem.width *= 1.1; 454 OverViewItem.height *= 1.1; 455 OverViewItem.margin *= 1.1; 456 update_item_list (); 457 OverViewItem.reset_label (); 458 GlyphCanvas.redraw (); 459 update_zoom_bar (); 460 } 461 462 public override void zoom_out () { 463 OverViewItem.width *= 0.9; 464 OverViewItem.height *= 0.9; 465 OverViewItem.margin *= 0.9; 466 update_item_list (); 467 OverViewItem.reset_label (); 468 GlyphCanvas.redraw (); 469 update_zoom_bar (); 470 } 471 472 public override void store_current_view () { 473 } 474 475 public override void restore_last_view () { 476 } 477 478 public override void next_view () { 479 } 480 481 public override string get_label () { 482 return t_("Overview"); 483 } 484 485 public override string get_name () { 486 return "Overview"; 487 } 488 489 public void display_all_available_glyphs () { 490 all_available = true; 491 492 view_offset_y = 0; 493 first_visible = 0; 494 selected = 0; 495 496 update_item_list (); 497 selected_item = get_selected_item (); 498 GlyphCanvas.redraw (); 499 } 500 501 OverViewItem get_selected_item () { 502 if (visible_items.size == 0) { 503 return new OverViewItem (); 504 } 505 506 if (!(0 <= selected < visible_items.size)) { 507 return selected_item; 508 } 509 510 return visible_items.get (selected); 511 } 512 513 int get_items_per_row () { 514 int i = 1; 515 double tab_with = allocation.width - 30; // 30 px for the scroll bar 516 OverViewItem.margin = OverViewItem.width * 0.1; 517 double l = OverViewItem.margin + OverViewItem.full_width (); 518 519 while (l <= tab_with) { 520 l += OverViewItem.full_width (); 521 i++; 522 } 523 524 return i - 1; 525 } 526 527 public void update_item_list () { 528 update_scheduled = true; 529 } 530 531 public void process_item_list_update () { 532 string character_string; 533 Font font = BirdFont.get_current_font (); 534 GlyphCollection? glyphs = null; 535 uint32 index; 536 OverViewItem item; 537 double x, y; 538 unichar character; 539 Glyph glyph; 540 double tab_with; 541 int item_list_length; 542 int visible_size; 543 544 tab_with = allocation.width - 30; // scrollbar 545 546 items_per_row = get_items_per_row (); 547 rows = (int) (allocation.height / OverViewItem.full_height ()) + 2; 548 549 item_list_length = items_per_row * rows; 550 visible_items.clear (); 551 552 index = (uint32) first_visible; 553 x = OverViewItem.margin; 554 y = OverViewItem.margin; 555 556 if (all_available) { 557 uint font_length = font.length (); 558 int i; 559 560 for (i = 0; i < item_list_length && index < font_length; i++) { 561 glyphs = font.get_glyph_collection_index ((uint32) index); 562 return_if_fail (glyphs != null); 563 564 glyph = ((!) glyphs).get_current (); 565 character_string = glyph.name; 566 character = glyph.unichar_code; 567 568 item = new OverViewItem (); 569 item.set_character (character); 570 item.set_glyphs (glyphs); 571 item.generate_graphics (); 572 item.selected = (selected_items.index_of ((!) glyphs) != -1); 573 574 visible_items.add (item); 575 index++; 576 } 577 578 if (i < item_list_length && !font.has_glyph (".notdef")) { 579 item = new OverViewItem (); 580 item.set_glyphs (font.get_notdef_character ()); 581 item.generate_graphics (false); 582 item.version_menu = null; 583 item.selected = (selected_items.index_of ((!) glyphs) != -1); 584 visible_items.add (item); 585 } 586 } else { 587 uint32 glyph_range_size = glyph_range.get_length (); 588 589 uint max_length = glyph_range.length () - first_visible; 590 591 if (item_list_length > max_length) { 592 item_list_length = (int) max_length; 593 } 594 595 for (int i = 0; i < item_list_length && index < glyph_range_size; i++) { 596 item = new OverViewItem (); 597 visible_items.add (item); 598 } 599 600 index = (uint32) first_visible; 601 visible_size = visible_items.size; 602 for (int i = 0; i < visible_size; i++) { 603 item = visible_items.get (i); 604 character = glyph_range.get_character ((uint32) index); 605 item.set_character (character); 606 index++; 607 } 608 609 visible_size = visible_items.size; 610 for (int i = 0; i < visible_size; i++) { 611 item = visible_items.get (i); 612 glyphs = font.get_glyph_collection_by_name ((!) item.character.to_string ()); 613 item.set_glyphs (glyphs); 614 615 if (glyphs != null) { 616 item.selected = (selected_items.index_of ((!) glyphs) != -1); 617 } 618 } 619 620 for (int i = 0; i < visible_size; i++) { 621 item = visible_items.get (i); 622 item.generate_graphics (); 623 } 624 } 625 626 x = OverViewItem.margin; 627 y = OverViewItem.margin; 628 629 visible_size = visible_items.size; 630 double full_width = OverViewItem.full_width (); 631 632 for (int i = 0; i < visible_size; i++) { 633 item = visible_items.get (i); 634 635 if (all_available) { 636 glyphs = font.get_glyph_collection_index ((uint32) i); 637 } else { 638 glyphs = font.get_glyph_collection_by_name ((!) item.character.to_string ()); 639 } 640 641 if (glyphs != null) { 642 int selected_index = selected_items.index_of ((!) glyphs); 643 item.selected = (selected_index != -1); 644 } 645 646 item.adjust_scale (); 647 648 item.x = x + view_offset_x; 649 item.y = y + view_offset_y; 650 651 x += full_width; 652 653 if (x + full_width >= tab_with) { 654 x = OverViewItem.margin; 655 y += OverViewItem.full_height (); 656 } 657 } 658 659 update_scheduled = false; 660 } 661 662 public override void draw (WidgetAllocation allocation, Context cr) { 663 if (update_scheduled 664 || this.allocation.width != allocation.width 665 || this.allocation.height != allocation.height 666 || this.allocation.width == 0) { 667 this.allocation = allocation; 668 process_item_list_update (); 669 } 670 671 this.allocation = allocation; 672 673 // clear canvas 674 cr.save (); 675 Theme.color (cr, "Background 1"); 676 cr.rectangle (0, 0, allocation.width, allocation.height); 677 cr.fill (); 678 cr.restore (); 679 680 foreach (OverViewItem i in visible_items) { 681 i.draw (allocation, cr); 682 } 683 684 if (unlikely (visible_items.size == 0)) { 685 draw_empty_canvas (allocation, cr); 686 } 687 688 if (unlikely (character_info != null)) { 689 draw_character_info (cr); 690 } 691 } 692 693 void draw_empty_canvas (WidgetAllocation allocation, Context cr) { 694 Text t; 695 cr.save (); 696 t = new Text ("No glyphs in this view.", 24); 697 Theme.text_color (t, "Text Foreground"); 698 t.widget_x = 40; 699 t.widget_y = 30; 700 t.draw (cr); 701 cr.restore (); 702 } 703 704 public void scroll_rows (int row_adjustment) { 705 for (int i = 0; i < row_adjustment; i++) { 706 scroll (-OverViewItem.height); 707 } 708 709 for (int i = 0; i > row_adjustment; i--) { 710 scroll (OverViewItem.height); 711 } 712 } 713 714 public void scroll_adjustment (double pixel_adjustment) { 715 double l; 716 Font f; 717 718 if (all_available) { 719 f = BirdFont.get_current_font (); 720 l = f.length (); 721 } else { 722 l = glyph_range.length (); 723 } 724 725 if (first_visible <= 0) { 726 return; 727 } 728 729 if (first_visible + rows * items_per_row >= l) { 730 return; 731 } 732 733 scroll ((int64) pixel_adjustment); 734 } 735 736 void scroll_to_position (int64 r) { 737 if (r < 0) { 738 scroll_top (); 739 return; 740 } 741 742 selected -= (int) (r - first_visible); 743 first_visible = (int) r; 744 update_item_list (); 745 } 746 747 public override void scroll_to (double position) requires (items_per_row > 0) { 748 double r; 749 int nrows; 750 Font f; 751 752 if (all_available) { 753 f = BirdFont.get_current_font (); 754 nrows = (int) (f.length () / items_per_row); 755 } else { 756 nrows = (int) (glyph_range.length () / items_per_row); 757 } 758 759 view_offset_y = 0; 760 r = (int64) (position * (nrows - rows + 3)); // 3 invisible rows 761 r *= items_per_row; 762 763 scroll_to_position ((int64) r); 764 update_item_list (); 765 GlyphCanvas.redraw (); 766 } 767 768 private void scroll (double pixel_adjustment) { 769 if (first_visible < 0 && pixel_adjustment < 0) { 770 scroll_top (); 771 return; 772 } 773 774 view_offset_y += pixel_adjustment; 775 776 if (view_offset_y >= 0) { 777 while (view_offset_y > OverViewItem.height) { 778 view_offset_y -= OverViewItem.height; 779 first_visible -= items_per_row; 780 } 781 782 first_visible -= items_per_row; 783 view_offset_y -= OverViewItem.height; 784 } else if (view_offset_y < -OverViewItem.height) { 785 view_offset_y = 0; 786 first_visible += items_per_row; 787 } 788 789 update_item_list (); 790 } 791 792 public void scroll_top () { 793 first_visible = 0; 794 view_offset_y = 0; 795 796 update_item_list (); 797 798 if (visible_items.size != 0) { 799 selected_item = get_selected_item (); 800 } 801 } 802 803 /** Returns true if the selected glyph is at the last row. */ 804 private bool last_row () { 805 return visible_items.size - selected <= items_per_row; 806 } 807 808 public void key_down () { 809 Font f = BirdFont.get_current_font (); 810 int64 len = (all_available) ? f.length () : glyph_range.length (); 811 812 if (at_bottom () && last_row ()) { 813 return; 814 } 815 816 selected += items_per_row; 817 818 if (selected >= items_per_row * rows) { 819 first_visible += items_per_row; 820 selected -= items_per_row; 821 } 822 823 if (first_visible + selected >= len) { 824 selected = (int) (len - first_visible - 1); 825 826 if (selected < items_per_row * (rows - 1)) { 827 first_visible -= items_per_row; 828 selected += items_per_row; 829 } 830 } 831 832 if (selected >= visible_items.size) { 833 selected = (int) (visible_items.size - 1); 834 } 835 836 selected_item = get_selected_item (); 837 update_item_list (); 838 } 839 840 public void key_right () { 841 Font f = BirdFont.get_current_font (); 842 int64 len = (all_available) ? f.length () : glyph_range.length (); 843 844 if (at_bottom () && first_visible + selected + 1 >= len) { 845 selected = (int) (visible_items.size - 1); 846 selected_item = get_selected_item (); 847 return; 848 } 849 850 selected += 1; 851 852 if (selected >= items_per_row * rows) { 853 first_visible += items_per_row; 854 selected -= items_per_row; 855 selected -= 1; 856 } 857 858 if (first_visible + selected > len) { 859 first_visible -= items_per_row; 860 selected = (int) (len - first_visible - 1); 861 selected_item = get_selected_item (); 862 } 863 update_item_list (); 864 } 865 866 public void key_up () { 867 selected -= items_per_row; 868 869 if (selected < 0) { 870 first_visible -= items_per_row; 871 selected += items_per_row; 872 } 873 874 if (first_visible < 0) { 875 first_visible = 0; 876 } 877 update_item_list (); 878 } 879 880 public void key_left () { 881 selected -= 1; 882 883 if (selected < 0) { 884 first_visible -= items_per_row; 885 selected += items_per_row; 886 selected += 1; 887 } 888 889 if (first_visible < 0) { 890 scroll_top (); 891 } 892 update_item_list (); 893 } 894 895 public string get_selected_char () { 896 Font f; 897 Glyph? g; 898 899 if (all_available) { 900 f = BirdFont.get_current_font (); 901 g = f.get_glyph_index (selected); 902 return_val_if_fail (g != null, "".dup ()); 903 return ((!) g).get_name (); 904 } 905 906 return glyph_range.get_char (selected); 907 } 908 909 public override void key_press (uint keyval) { 910 hide_menu (); 911 update_item_list (); 912 GlyphCanvas.redraw (); 913 914 if (KeyBindings.has_ctrl () || KeyBindings.has_logo ()) { 915 return; 916 } 917 918 switch (keyval) { 919 case Key.ENTER: 920 open_current_glyph (); 921 return; 922 923 case Key.UP: 924 get_selected_item ().selected = false; 925 926 key_up (); 927 selected_item = get_selected_item (); 928 929 selected_items.clear (); 930 if (selected_item.glyphs != null) { 931 selected_items.add ((!) selected_item.glyphs); 932 } 933 934 update_scrollbar (); 935 return; 936 937 case Key.RIGHT: 938 get_selected_item ().selected = false; 939 940 key_right (); 941 selected_item = get_selected_item (); 942 943 selected_items.clear (); 944 if (selected_item.glyphs != null) { 945 selected_items.add ((!) selected_item.glyphs); 946 } 947 948 update_scrollbar (); 949 return; 950 951 case Key.LEFT: 952 get_selected_item ().selected = false; 953 954 key_left (); 955 selected_item = get_selected_item (); 956 957 selected_items.clear (); 958 if (selected_item.glyphs != null) { 959 selected_items.add ((!) selected_item.glyphs); 960 } 961 962 update_scrollbar(); 963 return; 964 965 case Key.DOWN: 966 get_selected_item ().selected = false; 967 968 key_down (); 969 selected_item = get_selected_item (); 970 971 selected_items.clear (); 972 if (selected_item.glyphs != null) { 973 selected_items.add ((!) selected_item.glyphs); 974 } 975 976 update_scrollbar (); 977 return; 978 979 case Key.PG_UP: 980 get_selected_item ().selected = false; 981 982 for (int i = 0; i < rows; i++) { 983 key_up (); 984 } 985 selected_item = get_selected_item (); 986 987 selected_items.clear (); 988 if (selected_item.glyphs != null) { 989 selected_items.add ((!) selected_item.glyphs); 990 } 991 992 update_scrollbar (); 993 return; 994 995 case Key.PG_DOWN: 996 get_selected_item ().selected = false; 997 998 for (int i = 0; i < rows; i++) { 999 key_down (); 1000 } 1001 selected_item = get_selected_item (); 1002 1003 selected_items.clear (); 1004 if (selected_item.glyphs != null) { 1005 selected_items.add ((!) selected_item.glyphs); 1006 } 1007 1008 update_scrollbar (); 1009 return; 1010 1011 case Key.DEL: 1012 delete_selected_glyph (); 1013 selected_item = get_selected_item (); 1014 return; 1015 1016 case Key.BACK_SPACE: 1017 delete_selected_glyph (); 1018 selected_item = get_selected_item (); 1019 return; 1020 } 1021 1022 if (!KeyBindings.has_ctrl () && !KeyBindings.has_logo ()) { 1023 scroll_to_char (keyval); 1024 } 1025 1026 selected_item = get_selected_item (); 1027 1028 selected_items.clear (); 1029 if (selected_item.glyphs != null) { 1030 selected_items.add ((!) selected_item.glyphs); 1031 } 1032 1033 update_item_list (); 1034 GlyphCanvas.redraw (); 1035 } 1036 1037 public void delete_selected_glyph () { 1038 Font font = BirdFont.get_current_font (); 1039 OverViewUndoItem undo_item = new OverViewUndoItem (); 1040 1041 undo_item.alternate_sets = font.alternates.copy (); 1042 1043 foreach (GlyphCollection g in selected_items) { 1044 undo_item.glyphs.add (g.copy ()); 1045 } 1046 store_undo_items (undo_item); 1047 1048 foreach (GlyphCollection glyph_collection in selected_items) { 1049 font.delete_glyph (glyph_collection); 1050 string name = glyph_collection.get_name (); 1051 MainWindow.get_tab_bar ().close_background_tab_by_name (name); 1052 } 1053 1054 update_item_list (); 1055 GlyphCanvas.redraw (); 1056 } 1057 1058 public override void undo () { 1059 Font font = BirdFont.get_current_font (); 1060 OverViewUndoItem previous_collection; 1061 1062 if (undo_items.size == 0) { 1063 return; 1064 } 1065 1066 previous_collection = undo_items.get (undo_items.size - 1); 1067 redo_items.add (get_current_state (previous_collection)); 1068 1069 // remove the old glyph and add the new one 1070 foreach (GlyphCollection g in previous_collection.glyphs) { 1071 font.delete_glyph (g); 1072 1073 if (g.length () > 0) { 1074 font.add_glyph_collection (g); 1075 } 1076 1077 TabBar tabs = MainWindow.get_tab_bar (); 1078 Tab? tab = tabs.get_tab (g.get_name ()); 1079 1080 if (tab != null) { 1081 Tab t = (!) tab; 1082 set_glyph_zoom (g); 1083 t.set_glyph_collection (g); 1084 t.set_display (new GlyphTab (g)); 1085 } 1086 } 1087 1088 Font f = BirdFont.get_current_font (); 1089 f.alternates = previous_collection.alternate_sets.copy (); 1090 1091 undo_items.remove_at (undo_items.size - 1); 1092 GlyphCanvas.redraw (); 1093 } 1094 1095 public override void redo () { 1096 Font font = BirdFont.get_current_font (); 1097 OverViewUndoItem previous_collection; 1098 1099 if (redo_items.size == 0) { 1100 return; 1101 } 1102 1103 previous_collection = redo_items.get (redo_items.size - 1); 1104 undo_items.add (get_current_state (previous_collection)); 1105 1106 // remove the old glyph and add the new one 1107 foreach (GlyphCollection g in previous_collection.glyphs) { 1108 font.delete_glyph (g); 1109 font.add_glyph_collection (g); 1110 1111 TabBar tabs = MainWindow.get_tab_bar (); 1112 Tab? tab = tabs.get_tab (g.get_name ()); 1113 1114 if (tab != null) { 1115 Tab t = (!) tab; 1116 set_glyph_zoom (g); 1117 t.set_glyph_collection (g); 1118 t.set_display (new GlyphTab (g)); 1119 } 1120 } 1121 font.alternates = previous_collection.alternate_sets.copy (); 1122 1123 redo_items.remove_at (redo_items.size - 1); 1124 GlyphCanvas.redraw (); 1125 } 1126 1127 public OverViewUndoItem get_current_state (OverViewUndoItem previous_collection) { 1128 GlyphCollection? gc; 1129 OverViewUndoItem ui = new OverViewUndoItem (); 1130 Font font = BirdFont.get_current_font (); 1131 1132 ui.alternate_sets = font.alternates.copy (); 1133 1134 foreach (GlyphCollection g in previous_collection.glyphs) { 1135 gc = font.get_glyph_collection (g.get_name ()); 1136 1137 if (gc != null) { 1138 ui.glyphs.add (((!) gc).copy ()); 1139 } else { 1140 ui.glyphs.add (new GlyphCollection (g.get_unicode_character (), g.get_name ())); 1141 } 1142 } 1143 1144 return ui; 1145 } 1146 1147 public void store_undo_state (GlyphCollection gc) { 1148 OverViewUndoItem i = new OverViewUndoItem (); 1149 Font f = BirdFont.get_current_font (); 1150 i.alternate_sets = f.alternates.copy (); 1151 i.glyphs.add (gc); 1152 store_undo_items (i); 1153 } 1154 1155 public void store_undo_items (OverViewUndoItem i) { 1156 undo_items.add (i); 1157 redo_items.clear (); 1158 } 1159 1160 bool select_visible_glyph (string name) { 1161 int i = 0; 1162 1163 foreach (OverViewItem o in visible_items) { 1164 if (o.get_name () == name) { 1165 selected = i; 1166 selected_item = get_selected_item (); 1167 1168 if (selected_item.y > allocation.height - OverViewItem.height) { 1169 view_offset_y -= (selected_item.y + OverViewItem.height) - allocation.height; 1170 } 1171 1172 if (selected_item.y < 0) { 1173 view_offset_y = 0; 1174 } 1175 1176 return true; 1177 } 1178 1179 if (i > 1000) { 1180 warning ("selected character not found"); 1181 return true; 1182 } 1183 1184 i++; 1185 } 1186 1187 return false; 1188 } 1189 1190 public void scroll_to_char (unichar c) { 1191 StringBuilder s = new StringBuilder (); 1192 1193 if (is_modifier_key (c)) { 1194 return; 1195 } 1196 1197 s.append_unichar (c); 1198 scroll_to_glyph (s.str); 1199 } 1200 1201 public void scroll_to_glyph (string name) { 1202 GlyphRange gr = glyph_range; 1203 int i, r, index; 1204 string ch; 1205 Font font = BirdFont.get_current_font (); 1206 GlyphCollection? glyphs = null; 1207 Glyph glyph; 1208 1209 index = -1; 1210 1211 if (items_per_row <= 0) { 1212 return; 1213 } 1214 1215 ch = name; 1216 1217 // selected char is visible 1218 if (select_visible_glyph (ch)) { 1219 return; 1220 } 1221 1222 // scroll to char 1223 if (all_available) { 1224 1225 // don't search for glyphs in huge CJK fonts 1226 if (font.length () > 500) { 1227 r = 0; 1228 } else { 1229 // FIXME: too slow 1230 for (r = 0; r < font.length (); r += items_per_row) { 1231 for (i = 0; i < items_per_row && i < font.length (); i++) { 1232 glyphs = font.get_glyph_collection_index ((uint32) r + i); 1233 return_if_fail (glyphs != null); 1234 glyph = ((!) glyphs).get_current (); 1235 1236 if (glyph.name == ch) { 1237 index = i; 1238 } 1239 } 1240 1241 if (index > -1) { 1242 break; 1243 } 1244 } 1245 } 1246 } else { 1247 1248 if (ch.char_count () > 1) { 1249 warning ("Can't scroll to ligature in this view"); 1250 return; 1251 } 1252 1253 for (r = 0; r < gr.length (); r += items_per_row) { 1254 for (i = 0; i < items_per_row; i++) { 1255 if (gr.get_char (r + i) == ch) { 1256 index = i; 1257 } 1258 } 1259 1260 if (index > -1) { 1261 break; 1262 } 1263 } 1264 } 1265 1266 if (index > -1) { 1267 first_visible = r; 1268 process_item_list_update (); 1269 update_item_list (); 1270 select_visible_glyph (ch); 1271 } 1272 } 1273 1274 public override void double_click (uint button, double ex, double ey) 1275 requires (!is_null (visible_items) && !is_null (allocation)) { 1276 1277 return_if_fail (!is_null (this)); 1278 1279 foreach (OverViewItem i in visible_items) { 1280 if (i.double_click (button, ex, ey)) { 1281 open_overview_item (i); 1282 } 1283 } 1284 1285 GlyphCanvas.redraw (); 1286 } 1287 1288 public void open_overview_item (OverViewItem i) { 1289 if (i.glyphs != null) { 1290 open_glyph_signal ((!) i.glyphs); 1291 ((!) i.glyphs).get_current ().close_path (); 1292 } else { 1293 open_new_glyph_signal (i.character); 1294 } 1295 } 1296 1297 public void set_character_info (CharacterInfo i) { 1298 character_info = i; 1299 } 1300 1301 public int get_selected_index () { 1302 GlyphCollection gc; 1303 int index = 0; 1304 1305 if (selected_items.size == 0) { 1306 return 0; 1307 } 1308 1309 gc = selected_items.get (0); 1310 1311 foreach (OverViewItem i in visible_items) { 1312 if (i.glyphs != null && gc == ((!) i.glyphs)) { 1313 break; 1314 } 1315 1316 index++; 1317 } 1318 1319 return index; 1320 } 1321 1322 public void hide_menu () { 1323 foreach (OverViewItem i in visible_items) { 1324 i.hide_menu (); 1325 } 1326 } 1327 1328 public override void button_press (uint button, double x, double y) { 1329 OverViewItem selected_item; 1330 int index = 0; 1331 int selected_index = -1; 1332 bool update = false; 1333 1334 if (character_info != null) { 1335 character_info = null; 1336 GlyphCanvas.redraw (); 1337 return; 1338 } 1339 1340 if (!KeyBindings.has_shift ()) { 1341 selected_items.clear (); 1342 } 1343 1344 for (int j = 0; j < visible_items.size; j++) { 1345 selected_item = visible_items.get (j); 1346 1347 if (selected_item.click (button, x, y)) { 1348 selected = index; 1349 selected_item = get_selected_item (); 1350 1351 if (KeyBindings.has_shift ()) { 1352 if (selected_item.glyphs != null) { 1353 selected_index = selected_items.index_of ((!) selected_item.glyphs); 1354 if (selected_index == -1) { 1355 selected_items.add ((!) selected_item.glyphs); 1356 } else { 1357 return_if_fail (0 <= selected_index < selected_items.size); 1358 selected_items.remove_at (selected_index); 1359 selected = get_selected_index (); 1360 selected_item = get_selected_item (); 1361 } 1362 } 1363 1364 update = true; 1365 } else { 1366 selected_items.clear (); 1367 if (selected_item.glyphs != null) { 1368 selected_items.add ((!) selected_item.glyphs); 1369 } 1370 } 1371 1372 if (!is_null (selected_item.version_menu)) { 1373 update = !((!) selected_item.version_menu).menu_visible; 1374 } else { 1375 update = true; 1376 } 1377 } 1378 index++; 1379 } 1380 1381 if (update) { 1382 update_item_list (); 1383 } 1384 1385 GlyphCanvas.redraw (); 1386 } 1387 1388 /** Returns true if overview shows the last character. */ 1389 private bool at_bottom () { 1390 Font f; 1391 double t = rows * items_per_row + first_visible; 1392 1393 if (all_available) { 1394 f = BirdFont.get_current_font (); 1395 return t >= f.length (); 1396 } 1397 1398 return t >= glyph_range.length (); 1399 } 1400 1401 public void set_current_glyph_range (GlyphRange range) { 1402 GlyphRange? current = glyph_range; 1403 string c; 1404 1405 if (current != null) { 1406 c = glyph_range.get_char (selected); 1407 } 1408 1409 all_available = false; 1410 1411 glyph_range = range; 1412 scroll_top (); 1413 1414 // TODO: scroll down to c 1415 update_item_list (); 1416 selected_item = get_selected_item (); 1417 1418 GlyphCanvas.redraw (); 1419 } 1420 1421 public void select_next_glyph () { 1422 key_right (); 1423 } 1424 1425 public void open_current_glyph () { 1426 open_overview_item (selected_item); 1427 } 1428 1429 public override void update_scrollbar () { 1430 Font f; 1431 double nrows = 0; 1432 double pos = 0; 1433 double size; 1434 double visible_rows; 1435 1436 if (rows == 0) { 1437 MainWindow.set_scrollbar_size (0); 1438 MainWindow.set_scrollbar_position (0); 1439 } else { 1440 if (all_available) { 1441 f = BirdFont.get_current_font (); 1442 nrows = Math.floor ((f.length ()) / rows); 1443 size = f.length (); 1444 } else { 1445 nrows = Math.floor ((glyph_range.length ()) / rows); 1446 size = glyph_range.length (); 1447 } 1448 1449 if (nrows <= 0) { 1450 nrows = 1; 1451 } 1452 1453 visible_rows = allocation.height / OverViewItem.height; 1454 scroll_size = visible_rows / nrows; 1455 MainWindow.set_scrollbar_size (scroll_size); 1456 pos = first_visible / (nrows * items_per_row - visible_rows * items_per_row); 1457 MainWindow.set_scrollbar_position (pos); 1458 } 1459 } 1460 1461 /** Display one entry from the Unicode Character Database. */ 1462 void draw_character_info (Context cr) 1463 requires (character_info != null) { 1464 double x, y, w, h; 1465 int i; 1466 string unicode_value, unicode_description; 1467 string[] column; 1468 string entry; 1469 int len = 0; 1470 int length = 0; 1471 bool see_also = false; 1472 WidgetAllocation allocation = MainWindow.get_overview ().allocation; 1473 string name; 1474 string[] lines; 1475 double character_start; 1476 double character_height; 1477 1478 entry = ((!)character_info).get_entry (); 1479 lines = entry.split ("\n"); 1480 1481 foreach (string line in entry.split ("\n")) { 1482 len = line.char_count (); 1483 if (len > length) { 1484 length = len; 1485 } 1486 } 1487 1488 x = allocation.width * 0.1; 1489 y = allocation.height * 0.1; 1490 w = allocation.width * 0.9 - x; 1491 h = allocation.height * 0.9 - y; 1492 1493 if (w < 8 * length) { 1494 w = 8 * length; 1495 x = (allocation.width - w) / 2.0; 1496 } 1497 1498 if (x < 0) { 1499 x = 2; 1500 } 1501 1502 // background 1503 cr.save (); 1504 Theme.color_opacity (cr, "Background 1", 0.98); 1505 cr.rectangle (x, y, w, h); 1506 cr.fill (); 1507 cr.restore (); 1508 1509 cr.save (); 1510 Theme.color_opacity (cr, "Foreground 1", 0.98); 1511 cr.set_line_width (2); 1512 cr.rectangle (x, y, w, h); 1513 cr.stroke (); 1514 cr.restore (); 1515 1516 // database entry 1517 1518 if (((!)character_info).is_ligature ()) { 1519 name = ((!)character_info).get_name (); 1520 draw_info_line (name, cr, x, y, 0); 1521 } else { 1522 i = 0; 1523 foreach (string line in lines) { 1524 if (i == 0) { 1525 column = line.split ("\t"); 1526 return_if_fail (column.length == 2); 1527 unicode_value = "U+" + column[0]; 1528 unicode_description = column[1]; 1529 1530 draw_info_line (unicode_description, cr, x, y, i); 1531 i++; 1532 1533 draw_info_line (unicode_value, cr, x, y, i); 1534 i++; 1535 } else { 1536 1537 if (line.has_prefix ("\t*")) { 1538 draw_info_line (line.replace ("\t*", "•"), cr, x, y, i); 1539 i++; 1540 } else if (line.has_prefix ("\tx (")) { 1541 if (!see_also) { 1542 i++; 1543 draw_info_line (t_("See also:"), cr, x, y, i); 1544 i++; 1545 see_also = true; 1546 } 1547 1548 draw_info_line (line.replace ("\tx (", "•").replace (")", ""), cr, x, y, i); 1549 i++; 1550 } else { 1551 i++; 1552 } 1553 } 1554 } 1555 1556 character_start = y + 10 + i * UCD_LINE_HEIGHT; 1557 character_height = h - character_start; 1558 draw_fallback_character (cr, x, character_start, character_height); 1559 } 1560 } 1561 1562 /** Fallback character in UCD info. */ 1563 void draw_fallback_character (Context cr, double x, double y, double height) 1564 requires (character_info != null) { 1565 unichar c = ((!)character_info).unicode; 1566 1567 cr.save (); 1568 Text character = new Text (); 1569 character.set_use_cache (false); 1570 Theme.text_color (character, "Foreground 1"); 1571 character.set_text ((!) c.to_string ()); 1572 character.set_font_size (height); 1573 character.draw_at_top (cr, x + 10, y); 1574 cr.restore (); 1575 } 1576 1577 void draw_info_line (string line, Context cr, double x, double y, int row) { 1578 Text ucd_entry = new Text (line); 1579 cr.save (); 1580 Theme.text_color (ucd_entry, "Foreground 1"); 1581 ucd_entry.widget_x = 10 + x; 1582 ucd_entry.widget_y = 10 + y + row * UCD_LINE_HEIGHT; 1583 ucd_entry.draw (cr); 1584 cr.restore (); 1585 } 1586 1587 public void paste () { 1588 GlyphCollection gc; 1589 GlyphCollection? c; 1590 Glyph glyph; 1591 uint32 index; 1592 int i; 1593 int skip = 0; 1594 int s; 1595 string character_string; 1596 Gee.ArrayList<GlyphCollection> glyps; 1597 Font f; 1598 OverViewUndoItem undo_item; 1599 1600 f = BirdFont.get_current_font (); 1601 gc = new GlyphCollection ('\0', ""); 1602 glyps = new Gee.ArrayList<GlyphCollection> (); 1603 1604 copied_glyphs.sort ((a, b) => { 1605 return (int) ((GlyphCollection) a).get_unicode_character () 1606 - (int) ((GlyphCollection) b).get_unicode_character (); 1607 }); 1608 1609 index = (uint32) first_visible + selected; 1610 for (i = 0; i < copied_glyphs.size; i++) { 1611 if (all_available) { 1612 if (f.length () == 0) { 1613 c = add_empty_character_to_font (copied_glyphs.get (i).get_unicode_character (), 1614 copied_glyphs.get (i).is_unassigned (), 1615 copied_glyphs.get (i).get_name ()); 1616 } else if (index >= f.length ()) { 1617 // FIXME: duplicated unicodes? 1618 c = add_empty_character_to_font (copied_glyphs.get (i).get_unicode_character (), 1619 copied_glyphs.get (i).is_unassigned (), 1620 copied_glyphs.get (i).get_name ()); 1621 } else { 1622 c = f.get_glyph_collection_index ((uint32) index); 1623 } 1624 1625 if (c == null) { 1626 c = add_empty_character_to_font (copied_glyphs.get (i).get_unicode_character (), 1627 copied_glyphs.get (i).is_unassigned (), 1628 copied_glyphs.get (i).get_name ()); 1629 } 1630 1631 return_if_fail (c != null); 1632 gc = (!) c; 1633 } else { 1634 if (i != 0) { 1635 s = (int) copied_glyphs.get (i).get_unicode_character (); 1636 s -= (int) copied_glyphs.get (i - 1).get_unicode_character (); 1637 s -= 1; 1638 skip += s; 1639 } 1640 1641 character_string = glyph_range.get_char ((uint32) (index + skip)); 1642 c = f.get_glyph_collection_by_name (character_string); 1643 1644 if (c == null) { 1645 gc = add_empty_character_to_font (character_string.get_char (), 1646 copied_glyphs.get (i).is_unassigned (), 1647 copied_glyphs.get (i).get_name ()); 1648 } else { 1649 gc = (!) c; 1650 } 1651 } 1652 1653 glyps.add (gc); 1654 index++; 1655 } 1656 1657 undo_item = new OverViewUndoItem (); 1658 undo_item.alternate_sets = f.alternates.copy (); 1659 foreach (GlyphCollection g in glyps) { 1660 undo_item.glyphs.add (g.copy ()); 1661 } 1662 store_undo_items (undo_item); 1663 1664 if (glyps.size != copied_glyphs.size) { 1665 warning ("glyps.size != copied_glyphs.size"); 1666 return; 1667 } 1668 1669 if (copied_glyphs.size < i) { 1670 warning ("Array index out of bounds."); 1671 return; 1672 } 1673 1674 i = 0; 1675 foreach (GlyphCollection g in glyps) { 1676 glyph = copied_glyphs.get (i).get_current ().copy (); 1677 glyph.version_id = (glyph.version_id == -1 || g.length () == 0) ? 1 : g.get_last_id () + 1; 1678 glyph.unichar_code = g.get_unicode_character (); 1679 1680 if (!g.is_unassigned ()) { 1681 glyph.name = (!) glyph.unichar_code.to_string (); 1682 } else { 1683 glyph.name = g.get_name (); 1684 } 1685 1686 g.insert_glyph (glyph, true); 1687 i++; 1688 } 1689 1690 f.touch (); 1691 } 1692 1693 public class OverViewUndoItem { 1694 public AlternateSets alternate_sets = new AlternateSets (); 1695 public Gee.ArrayList<GlyphCollection> glyphs = new Gee.ArrayList<GlyphCollection> (); 1696 } 1697 } 1698 1699 } 1700