MCPcopy Create free account
hub / github.com/JetBrains/skija / execute

Method execute

tests/java/FontMgrTest.java:15–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14public class FontMgrTest implements Executable {
15 @Override
16 public void execute() throws Exception {
17 // FontManager
18 TypefaceFontProvider fm = new TypefaceFontProvider();
19 Typeface jbMono = Typeface.makeFromFile("fonts/JetBrainsMono-Regular.ttf", 0);
20 fm.registerTypeface(jbMono);
21 Typeface jbMonoBold = Typeface.makeFromFile("fonts/JetBrainsMono-Bold.ttf", 0);
22 fm.registerTypeface(jbMonoBold);
23 Typeface inter = Typeface.makeFromFile("fonts/InterHinted-Regular.ttf", 0);
24 fm.registerTypeface(inter, "Interface");
25
26 assertEquals(2, fm.getFamiliesCount());
27 assertEquals("JetBrains Mono", fm.getFamilyName(0));
28 assertEquals("Interface", fm.getFamilyName(1));
29
30 try (var ss = fm.makeStyleSet(0)) {
31 assertEquals(0, ss.count()); // ?
32 }
33
34 try (var ss = fm.makeStyleSet(1)) {
35 assertEquals(0, ss.count()); // ?
36 }
37
38 // FontStyleSet
39 try (var ss = fm.matchFamily("JetBrains Mono")) {
40 assertEquals(2, ss.count());
41 assertEquals(FontStyle.NORMAL, ss.getStyle(0));
42 assertEquals("JetBrains Mono", ss.getStyleName(0));
43
44 assertEquals(FontStyle.BOLD, ss.getStyle(1));
45 assertEquals("JetBrains Mono", ss.getStyleName(1));
46
47 assertEquals(2, jbMono.getRefCount());
48 try (var face = ss.getTypeface(0)) {
49 assertEquals(3, jbMono.getRefCount());
50 assertEquals(jbMono, face);
51 }
52 assertEquals(2, jbMono.getRefCount());
53
54 assertEquals(2, jbMonoBold.getRefCount());
55 try (var face = ss.getTypeface(1)) {
56 assertEquals(3, jbMonoBold.getRefCount());
57 assertEquals(jbMonoBold, face);
58 }
59 assertEquals(2, jbMonoBold.getRefCount());
60
61 assertEquals(2, jbMono.getRefCount());
62 try (var face = ss.matchStyle(FontStyle.NORMAL)) {
63 assertEquals(3, jbMono.getRefCount());
64 assertEquals(jbMono, face);
65 }
66 assertEquals(2, jbMono.getRefCount());
67
68 assertEquals(2, jbMonoBold.getRefCount());
69 try (var face = ss.matchStyle(FontStyle.BOLD)) {
70 assertEquals(3, jbMonoBold.getRefCount());
71 assertEquals(jbMonoBold, face);
72 }

Callers

nothing calls this directly

Calls 15

makeFromFileMethod · 0.95
registerTypefaceMethod · 0.95
makeFromFileNameMethod · 0.95
assertEqualsMethod · 0.80
getFamiliesCountMethod · 0.80
makeStyleSetMethod · 0.80
countMethod · 0.80
matchFamilyMethod · 0.80
getStyleMethod · 0.80
getStyleNameMethod · 0.80
getRefCountMethod · 0.80
matchStyleMethod · 0.80

Tested by

no test coverage detected