Commit 98c6d51
tab width from font metrix
Changed files (4)
modifiedsrc/BackgroundSelection.valamodifiedsrc/CutBackgroundTool.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/TabBar.vala
Diff
@@ -104,13 +104,11 @@ class BackgroundSelection : FontDisplay { } private bool draw_thumbnail (string file, double x, double y, Context cr, int box_index) {- GlyphBackgroundImage bg = new GlyphBackgroundImage (file);- File thumbnail = bg.get_thumbnail_file (); Pixbuf pixbuf = new Pixbuf.from_file (file); ImageSurface img = new ImageSurface.for_data (pixbuf.get_pixels (), Format.ARGB32, pixbuf.get_width (), pixbuf.get_height (), pixbuf.get_rowstride ()); if (img.status () != Cairo.Status.SUCCESS) {- warning (@"Failed to load $file (height: $(pixbuf.get_height ()), width: $(pixbuf.get_width ()), stride: $(pixbuf.get_rowstride ()))");+ warning (@"Failed to load $file as gdk pixbuf. (height: $(pixbuf.get_height ()), width: $(pixbuf.get_width ()), stride: $(pixbuf.get_rowstride ()))"); return false; } @@ -112,7 +112,6 @@ class CutBackgroundTool : Tool { return fabs (y1 - y2); } - // Todo: nice gimp style crop void do_cut () { double x, y; int h, w;@@ -1446,11 +1446,11 @@ class GlyfTable : Table { fd.add_16 (tymax); fd.seek_end (); - print (@"\n"); - print (@"txmin: $txmin\n"); - print (@"tymin: $tymin\n"); - print (@"txmax: $txmax\n"); - print (@"tymax: $tymax\n"); + printd (@"\n"); + printd (@"txmin: $txmin\n"); + printd (@"tymin: $tymin\n"); + printd (@"txmax: $txmax\n"); + printd (@"tymax: $tymax\n"); // save this for head table if (this.xmin > txmin) this.xmin = txmin; @@ -1514,7 +1514,7 @@ class GlyfTable : Table { location_offsets.append (fd.length ()); process_glyph (g, fd); - print (@"loca fd.length (): $(fd.length ())\n"); + printd (@"loca fd.length (): $(fd.length ())\n"); } location_offsets.append (fd.length ()); // last entry in loca table is special @@ -1927,15 +1927,19 @@ class CmapTable : Table { platform = dis.read_ushort (); encoding = dis.read_ushort (); sub_offset = dis.read_ulong (); - + if (platform == 3 && encoding == 1) { printd (@"Parsing Unicode BMP (UCS-2) Platform: $platform Encoding: $encoding\n"); subtable = new CmapSubtableWindowsUnicode (); subtable.offset = offset + sub_offset; subtables.append (subtable); } else { - stderr.printf (@"Unknown encoding. Platform: $platform Encoding: $encoding.\n"); - } + stderr.printf (@"Unknown cmap format. Platform: $platform Encoding: $encoding.\n"); + } + + if (encoding == 3) { + warning ("Font contains a cmap table with the obsolete encoding 3."); + } } if (subtables.length () == 0) { @@ -4932,7 +4936,7 @@ public static uint16 largest_pow2 (uint16 max) { } void printd (string s) { - // print (s); + print (s); } } @@ -297,18 +297,26 @@ class TabBar : DrawingArea { } } - public void add_tab (FontDisplay display_item, double tab_width = 30, bool always_open = false) {+ public void add_tab (FontDisplay display_item, double tab_width = -1, bool always_open = false) {+ ImageSurface im = new ImageSurface (Format.RGB24, 0, 0);+ Context cr = new Context (im);+ TextExtents te;+ int s = (tabs.length () == 0) ? 0 : selected + 1; + if (tab_width < 0) {+ cr.text_extents (display_item.get_name (), out te);+ tab_width = te.width + 30;+ }+ tabs.insert (new Tab (display_item, tab_width, always_open), s); select_tab (s); } /** Returns true if the new item was added to the bar. */- public bool add_unique_tab (FontDisplay display_item, double tab_width = 30, bool always_open = false) {- + public bool add_unique_tab (FontDisplay display_item, double tab_width = -1, bool always_open = false) { bool i = select_tab_name (display_item.get_name ());- + if (!i) { add_tab (display_item, tab_width, always_open); return true;