| 6 | import org.jetbrains.skija.impl.*; |
| 7 | |
| 8 | public class Typeface extends RefCnt { |
| 9 | static { Library.staticLoad(); } |
| 10 | |
| 11 | /** |
| 12 | * @return the typeface’s intrinsic style attributes |
| 13 | */ |
| 14 | public FontStyle getFontStyle() { |
| 15 | try { |
| 16 | Stats.onNativeCall(); |
| 17 | return new FontStyle(_nGetFontStyle(_ptr)); |
| 18 | } finally { |
| 19 | Reference.reachabilityFence(this); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @return true if {@link #getFontStyle()} has the bold bit set |
| 25 | */ |
| 26 | public boolean isBold() { |
| 27 | return getFontStyle().getWeight() >= FontWeight.SEMI_BOLD; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @return true if {@link #getFontStyle()} has the italic bit set |
| 32 | */ |
| 33 | public boolean isItalic() { |
| 34 | return getFontStyle().getSlant() != FontSlant.UPRIGHT; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * This is a style bit, advance widths may vary even if this returns true. |
| 39 | * @return true if the typeface claims to be fixed-pitch |
| 40 | */ |
| 41 | public boolean isFixedPitch() { |
| 42 | try { |
| 43 | Stats.onNativeCall(); |
| 44 | return _nIsFixedPitch(_ptr); |
| 45 | } finally { |
| 46 | Reference.reachabilityFence(this); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * It is possible the number of axes can be retrieved but actual position cannot. |
| 52 | * @return the variation coordinates describing the position of this typeface in design variation space, null if there’s no variations |
| 53 | */ |
| 54 | @Nullable |
| 55 | public FontVariation[] getVariations() { |
| 56 | try { |
| 57 | Stats.onNativeCall(); |
| 58 | return _nGetVariations(_ptr); |
| 59 | } finally { |
| 60 | Reference.reachabilityFence(this); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * It is possible the number of axes can be retrieved but actual position cannot. |
nothing calls this directly
no test coverage detected