Skip to content

Commit 32da8ec

Browse files
authored
Merge pull request #73 from mmalecot/dev
v0.27.0
2 parents bb09c0f + c5d0a23 commit 32da8ec

File tree

10 files changed

+47
-3
lines changed

10 files changed

+47
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Version 0.27.0 (2025-05-09)
2+
3+
## New formats support
4+
5+
- FIGlet Font (FLF)
6+
- TrueType Collection (TTC)
7+
18
# Version 0.26.0 (2024-11-07)
29

310
## API

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "file-format"
3-
version = "0.26.0"
3+
version = "0.27.0"
44
authors = ["Mickaël Malécot <mickael.malecot@gmail.com>"]
5-
edition = "2021"
5+
edition = "2024"
66
description = "Crate for determining the file format of a given file or stream."
77
license = "MIT/Apache-2.0"
88
readme = "README.md"
@@ -12,7 +12,7 @@ homepage = "https://github.com/mmalecot/file-format"
1212
repository = "https://github.com/mmalecot/file-format"
1313
documentation = "https://docs.rs/file-format"
1414
exclude = ["/.github", "/examples", "/fixtures", "/tests", ".gitattributes", ".gitignore"]
15-
rust-version = "1.60.0"
15+
rust-version = "1.85.0"
1616

1717
[features]
1818
## Reader features

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,11 @@ identification.
253253
- BMFont ASCII (FNT)
254254
- BMFont Binary (FNT)
255255
- Embedded OpenType (EOT)
256+
- FIGlet Font (FLF)
256257
- Glyphs
257258
- OpenType (OTF)
258259
- TrueType (TTF)
260+
- TrueType Collection (TTC)
259261
- Web Open Font Format (WOFF)
260262
- Web Open Font Format 2 (WOFF2)
261263

fixtures/font/sample.flf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flf2a$ 6 5 16 15 16

fixtures/font/sample.ttc

6 Bytes
Binary file not shown.

src/formats.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,13 @@ formats! {
768768
extension = "fbz"
769769
kind = Ebook
770770

771+
format = FigletFont
772+
name = "FIGlet Font"
773+
short_name = "FLF"
774+
media_type = "application/x-figlet"
775+
extension = "flf"
776+
kind = Font
777+
771778
format = Filmbox
772779
name = "Filmbox"
773780
short_name = "FBX"
@@ -2686,6 +2693,13 @@ formats! {
26862693
extension = "ttf"
26872694
kind = Font
26882695

2696+
format = TruetypeCollection
2697+
name = "TrueType Collection"
2698+
short_name = "TTC"
2699+
media_type = "font/collection"
2700+
extension = "ttc"
2701+
kind = Font
2702+
26892703
format = UltimateSoundtrackerModule
26902704
name = "Ultimate Soundtracker Module"
26912705
short_name = "MOD"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl From<&[u8]> for FileFormat {
330330

331331
/// A kind of file format.
332332
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
333+
#[non_exhaustive]
333334
pub enum Kind {
334335
/// Files and directories stored in a single, possibly compressed, archive.
335336
Archive,

src/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ macro_rules! formats {
2323
} => {
2424
/// A file format.
2525
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
26+
#[non_exhaustive]
2627
pub enum FileFormat {
2728
$(
2829
#[doc=concat!($name, $(" (", $short_name, ")",)? ".")]

src/signatures.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ signatures! {
900900
value = b"\x01\x00\x02" offset = 8, b"LP" offset = 34
901901
value = b"\x02\x00\x02" offset = 8, b"LP" offset = 34
902902

903+
format = FigletFont
904+
value = b"flf2a"
905+
903906
format = GoogleDraco
904907
value = b"DRACO"
905908

@@ -984,6 +987,9 @@ signatures! {
984987
format = Truetype
985988
value = b"\x00\x01\x00\x00\x00"
986989

990+
format = TruetypeCollection
991+
value = b"ttcf\x00"
992+
987993
format = VirtualMachineDisk
988994
value = b"COWD\x01"
989995
value = b"KDMV\x01"

tests/font.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ fn test_embedded_opentype() {
1818
assert_eq!(fmt, FileFormat::EmbeddedOpentype);
1919
}
2020

21+
#[test]
22+
fn test_figlet_font() {
23+
let fmt = FileFormat::from_file("fixtures/font/sample.flf").unwrap();
24+
assert_eq!(fmt, FileFormat::FigletFont);
25+
}
26+
2127
#[test]
2228
fn test_glyphs() {
2329
let fmt = FileFormat::from_file("fixtures/font/sample.glyphs").unwrap();
@@ -36,6 +42,12 @@ fn test_truetype() {
3642
assert_eq!(fmt, FileFormat::Truetype);
3743
}
3844

45+
#[test]
46+
fn test_truetype_collection() {
47+
let fmt = FileFormat::from_file("fixtures/font/sample.ttc").unwrap();
48+
assert_eq!(fmt, FileFormat::TruetypeCollection);
49+
}
50+
3951
#[test]
4052
fn test_web_open_font_format() {
4153
let fmt = FileFormat::from_file("fixtures/font/sample.woff").unwrap();

0 commit comments

Comments
 (0)