Skip to content

Commit 8eeace3

Browse files
Make sure only one copy of a background image is stored in the font file
1 parent ed8f36b commit 8eeace3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
birdfont (2.30.0) stable;
22

33
* Smaller .birdfont files
4+
* Make sure only one copy of a background image is stored in the font file.
45

56
-- Johan Mattsson <johan.mattsson.m@gmail.com> Tue Feb 8 03:03:27 CET 2022
67

libbirdfont/BirdFontFile.vala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ class BirdFontFile : GLib.Object {
2424
Font font;
2525

2626
public const int FORMAT_MAJOR = 2;
27-
public const int FORMAT_MINOR = 2;
27+
public const int FORMAT_MINOR = 3;
2828

2929
public const int MIN_FORMAT_MAJOR = 0;
3030
public const int MIN_FORMAT_MINOR = 0;
3131

3232
public bool has_svg_glyphs = false;
33+
34+
Gee.ArrayList<string> written_images = new Gee.ArrayList<string> ();
3335

3436
public BirdFontFile (Font f) {
3537
font = f;
@@ -252,6 +254,16 @@ class BirdFontFile : GLib.Object {
252254
}
253255

254256
public void write_image (DataOutputStream os, string sha1, string data) throws GLib.Error {
257+
if (written_images.contains (sha1)) {
258+
warning ("Font file already contains " + sha1);
259+
return;
260+
}
261+
262+
if (sha1 == "" || data == "") {
263+
warning ("No data in background image.");
264+
return;
265+
}
266+
255267
os.put_string (@"<background-image sha1=\"");
256268
os.put_string (sha1);
257269
os.put_string ("\" ");

0 commit comments

Comments
 (0)