summaryrefslogtreecommitdiff
path: root/src/FontFamily.java
blob: cff4f87ca40e10c0f14af7acdfbfda3aa481711b (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import java.util.ArrayList;
import java.util.HashMap;

/*
 * @author
 * Kian Agheli
 * 
 * References:
 * 
 * Date:
 * 2024-05-08
 * 
 * Purpose of class:
 * Store and operate on font family metadata.
 */

public class FontFamily {
	/* JSONReader from which metadata is pulled. */
	private JSONReader metadata;
	/* Taken from first line of METADATA.pb */
	private String familyName;
	/* Taken from fonts/tags/all/families.csv */
	private HashMap<String,Integer> styles;
	/* Taken from top level of METADATA.pb */
	private String dateAdded;
	/* Unicode ranges. */
	private String[] subsets;
	private String designer;
	/* total views, 7day views, 30day views, 90day views, year views.
	Taken from popularity.json. */
	private HashMap<String,Long> views;
	private String license;
	private String category;
	/* popularity.json and families.csv are shared among all families.
	Have their associated objects passed from outside. */

	/**
	 * Constructor.
	 */
	public FontFamily(JSONReader metadata, JSONReader popularity, CSVReader styles) {
		this.metadata = metadata;
		parseMetadata(metadata);
		parsePopularity(popularity);
		parseStyles(styles);
	}

	/**
	 * Parse metadata.
	 */
	private void parseMetadata(JSONReader metadata) {
		familyName = metadata.get("name");
		dateAdded = metadata.get("date_added");
		subsets = metadata.getAll("subsets");
		designer = metadata.get("designer");
		license = metadata.get("license");
		category = metadata.get("category");
	}

	/**
	 * Parse popularity.
	 */
	private void parsePopularity(JSONReader popularity) {
	}

	/**
	 * Parse styles.
	 */
	private void parseStyles(CSVReader styles) {
	}
	
	public String getFamilyName() {
		return familyName;
	}
	public String[] getSubsets() {
		return subsets;
	}
}