| 9 | import static io.github.humbleui.skija.test.runner.TestRunner.*; |
| 10 | |
| 11 | public class TypefaceTest implements Executable { |
| 12 | @Override |
| 13 | public void execute() throws Exception { |
| 14 | Typeface inter = FontMgr.getDefault().makeFromFile("fonts/InterHinted-Regular.ttf"); |
| 15 | Typeface interV = FontMgr.getDefault().makeFromFile("fonts/Inter-V.ttf"); |
| 16 | Typeface jbMono = FontMgr.getDefault().makeFromFile("fonts/JetBrainsMono-Regular.ttf"); |
| 17 | Typeface jbMonoBold = FontMgr.getDefault().makeFromData(Data.makeFromFileName("fonts/JetBrainsMono-Bold.ttf")); |
| 18 | |
| 19 | assertEquals(FontStyle.NORMAL, inter.getFontStyle()); |
| 20 | assertEquals(false, inter.isBold()); |
| 21 | assertEquals(false, inter.isItalic()); |
| 22 | |
| 23 | assertEquals(FontStyle.BOLD, jbMonoBold.getFontStyle()); |
| 24 | assertEquals(true, jbMonoBold.isBold()); |
| 25 | assertEquals(false, jbMonoBold.isItalic()); |
| 26 | |
| 27 | assertEquals(false, inter.isFixedPitch()); |
| 28 | assertEquals(true, jbMono.isFixedPitch()); |
| 29 | |
| 30 | assertArrayEquals(null, inter.getVariationAxes()); |
| 31 | assertArrayEquals(null, inter.getVariations()); |
| 32 | |
| 33 | var axes = new FontVariationAxis[] { new FontVariationAxis("wght", 100f, 400f, 900f), |
| 34 | new FontVariationAxis("slnt", -10f, 0f, 0f) }; |
| 35 | assertArrayEquals(axes, interV.getVariationAxes()); |
| 36 | if (OperatingSystem.CURRENT != OperatingSystem.LINUX) |
| 37 | assertArrayEquals(FontVariation.parse("wght=400 slnt=0"), interV.getVariations()); |
| 38 | |
| 39 | Typeface inter500 = interV.makeClone(new FontVariation("wght", 500)); |
| 40 | assertNotEquals(inter500, interV); |
| 41 | assertArrayEquals(FontVariation.parse("wght=500 slnt=0"), inter500.getVariations()); |
| 42 | |
| 43 | Typeface inter400 = interV.makeClone(new FontVariation("wght", 400)); |
| 44 | // assertEquals(inter400, interV); |
| 45 | |
| 46 | assertNotEquals(inter.getUniqueId(), interV.getUniqueId()); |
| 47 | assertNotEquals(inter, interV); |
| 48 | |
| 49 | if (OperatingSystem.CURRENT != OperatingSystem.LINUX) |
| 50 | assertEquals("Arial", FontMgr.getDefault().matchFamilyStyle("Arial", FontStyle.NORMAL).getFamilyName()); |
| 51 | |
| 52 | int[] Skia = new int[] { 83, 107, 105, 97 }; |
| 53 | assertArrayEquals(new short[] { 394, 713, 677, 503 }, inter.getUTF32Glyphs(Skia)); |
| 54 | assertArrayEquals(new short[] { 394, 713, 677, 503 }, inter.getStringGlyphs("Skia")); |
| 55 | assertEquals(Short.valueOf((short) 394), inter.getUTF32Glyph(83)); |
| 56 | |
| 57 | assertEquals(2548, interV.getGlyphsCount()); |
| 58 | |
| 59 | assertEquals(17, inter.getTablesCount()); |
| 60 | // assertArrayEquals(null, inter.getTableTags()); |
| 61 | assertArrayEquals(new String[] {"GDEF", "GPOS", "GSUB", "OS/2", "cmap", "cvt ", "fpgm", "gasp", "glyf", "head", "hhea", "hmtx", "loca", "maxp", "name", "post", "prep"}, inter.getTableTags()); |
| 62 | |
| 63 | assertEquals(true, inter.getTableData("loca").getSize() > 0); |
| 64 | |
| 65 | assertEquals(2816, inter.getUnitsPerEm()); |
| 66 | |
| 67 | assertArrayEquals(null, jbMono.getKerningPairAdjustments(null)); |
| 68 | assertArrayEquals(null, jbMono.getKerningPairAdjustments(jbMono.getStringGlyphs("TAV"))); |
nothing calls this directly
no outgoing calls
no test coverage detected