File: font.go

package info (click to toggle)
golang-gopkg-h2non-filetype.v1 1.1.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie, trixie-backports
  • size: 208 kB
  • sloc: makefile: 4
file content (45 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package matchers

var (
	TypeWoff  = newType("woff", "application/font-woff")
	TypeWoff2 = newType("woff2", "application/font-woff")
	TypeTtf   = newType("ttf", "application/font-sfnt")
	TypeOtf   = newType("otf", "application/font-sfnt")
)

var Font = Map{
	TypeWoff:  Woff,
	TypeWoff2: Woff2,
	TypeTtf:   Ttf,
	TypeOtf:   Otf,
}

func Woff(buf []byte) bool {
	return len(buf) > 7 &&
		buf[0] == 0x77 && buf[1] == 0x4F &&
		buf[2] == 0x46 && buf[3] == 0x46 &&
		buf[4] == 0x00 && buf[5] == 0x01 &&
		buf[6] == 0x00 && buf[7] == 0x00
}

func Woff2(buf []byte) bool {
	return len(buf) > 7 &&
		buf[0] == 0x77 && buf[1] == 0x4F &&
		buf[2] == 0x46 && buf[3] == 0x32 &&
		buf[4] == 0x00 && buf[5] == 0x01 &&
		buf[6] == 0x00 && buf[7] == 0x00
}

func Ttf(buf []byte) bool {
	return len(buf) > 4 &&
		buf[0] == 0x00 && buf[1] == 0x01 &&
		buf[2] == 0x00 && buf[3] == 0x00 &&
		buf[4] == 0x00
}

func Otf(buf []byte) bool {
	return len(buf) > 4 &&
		buf[0] == 0x4F && buf[1] == 0x54 &&
		buf[2] == 0x54 && buf[3] == 0x4F &&
		buf[4] == 0x00
}