MCPcopy Create free account
hub / github.com/HumbleUI/Skija / base

Method base

tests/java/FontMgrTest.java:28–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 }
27
28 public void base() {
29 // FontManager
30 TypefaceFontProvider fm = new TypefaceFontProvider();
31 Typeface jbMono = FontMgr.getDefault().makeFromFile("fonts/JetBrainsMono-Regular.ttf", 0);
32 fm.registerTypeface(jbMono);
33 Typeface jbMonoBold = FontMgr.getDefault().makeFromFile("fonts/JetBrainsMono-Bold.ttf", 0);
34 fm.registerTypeface(jbMonoBold);
35 Typeface inter = FontMgr.getDefault().makeFromFile("fonts/InterHinted-Regular.ttf", 0);
36 fm.registerTypeface(inter, "Interface");
37
38 assertEquals(2, fm.getFamiliesCount());
39 assertEquals("JetBrains Mono", fm.getFamilyName(0));
40 assertEquals("Interface", fm.getFamilyName(1));
41
42 try (var ss = fm.makeStyleSet(0)) {
43 assertEquals(2, ss.count()); // ?
44 }
45
46 try (var ss = fm.makeStyleSet(1)) {
47 assertEquals(1, ss.count()); // ?
48 }
49
50 // FontStyleSet
51 try (var ss = fm.matchFamily("JetBrains Mono")) {
52 assertEquals(2, ss.count());
53 assertEquals(FontStyle.NORMAL, ss.getStyle(0));
54 assertEquals("JetBrains Mono", ss.getStyleName(0));
55
56 assertEquals(FontStyle.BOLD, ss.getStyle(1));
57 assertEquals("JetBrains Mono", ss.getStyleName(1));
58
59 assertEquals(2, jbMono.getRefCount());
60 try (var face = ss.getTypeface(0)) {
61 assertEquals(3, jbMono.getRefCount());
62 assertEquals(jbMono, face);
63 }
64 assertEquals(2, jbMono.getRefCount());
65
66 assertEquals(2, jbMonoBold.getRefCount());
67 try (var face = ss.getTypeface(1)) {
68 assertEquals(3, jbMonoBold.getRefCount());
69 assertEquals(jbMonoBold, face);
70 }
71 assertEquals(2, jbMonoBold.getRefCount());
72
73 assertEquals(2, jbMono.getRefCount());
74 try (var face = ss.matchStyle(FontStyle.NORMAL)) {
75 assertEquals(3, jbMono.getRefCount());
76 assertEquals(jbMono, face);
77 }
78 assertEquals(2, jbMono.getRefCount());
79
80 assertEquals(2, jbMonoBold.getRefCount());
81 try (var face = ss.matchStyle(FontStyle.BOLD)) {
82 assertEquals(3, jbMonoBold.getRefCount());
83 assertEquals(jbMonoBold, face);
84 }
85 assertEquals(2, jbMonoBold.getRefCount());

Callers

nothing calls this directly

Calls 15

getDefaultMethod · 0.95
registerTypefaceMethod · 0.95
makeFromFileNameMethod · 0.95
assertEqualsMethod · 0.80
getFamiliesCountMethod · 0.80
makeStyleSetMethod · 0.80
matchFamilyMethod · 0.80
getStyleMethod · 0.80
getStyleNameMethod · 0.80
getRefCountMethod · 0.80
matchStyleMethod · 0.80
assertNotNullMethod · 0.80

Tested by

no test coverage detected