diff options
author | Bernhard Haumacher <[email protected]> | 2020-05-09 14:13:46 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-03 01:44:13 +0100 |
commit | a71ee81c72baa1c4d6a58220df7733acca499166 (patch) | |
tree | 8b7c6920e894fab1f7e2b757af65cc578ff57de9 /src/jogl/classes/jogamp/graph | |
parent | d5880b4ba4a3fec40647960682aead03a977b9ad (diff) |
Getters for macStyle bits, enhanced docu for fontDirectionHint.
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
-rw-r--r-- | src/jogl/classes/jogamp/graph/font/typecast/ot/Bits.java | 44 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java | 122 |
2 files changed, 150 insertions, 16 deletions
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/Bits.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/Bits.java new file mode 100644 index 000000000..d79d8b169 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/Bits.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2020 Business Operation Systems GmbH. All Rights Reserved. + */ +package jogamp.graph.font.typecast.ot; + +/** + * Utilities for bit manipulations. + * + * @author <a href="mailto:[email protected]">Bernhard Haumacher</a> + */ +public class Bits { + + /** + * Checks whether the bit with the given number is set. + */ + public static boolean bit(int bitSet, int n) { + return (bitSet & mask(n)) > 0; + } + + /** + * Sets or clears the the bit with the given index in the given bit set + * depending on the given boolean value. + */ + public static short bit(short bitSet, int n, boolean value) { + return (short)bit((int)bitSet, n, value); + } + + /** + * Sets or clears the the bit with the given index in the given bit set + * depending on the given boolean value. + */ + public static int bit(int bitSet, int n, boolean value) { + if (value) { + return (bitSet | mask(n)); + } else { + return (bitSet & mask(n)); + } + } + + private static int mask(int n) { + return 0x01 << n; + } + +} diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java index 7bd267460..8bb4661fc 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java @@ -53,6 +53,7 @@ package jogamp.graph.font.typecast.ot.table; import java.io.DataInput; import java.io.IOException; +import jogamp.graph.font.typecast.ot.Bits; import jogamp.graph.font.typecast.ot.Fixed; import jogamp.graph.font.typecast.ot.LongDateTime; @@ -92,6 +93,36 @@ public class HeadTable implements Table { public static final short GLYPH_DATA_FORMAT = 0; /** + * 0: Fully mixed directional glyphs; + * @see #getFontDirectionHint() + */ + public static final short FONT_DIRECTION_MIXED = 0; + + /** + * 1: Only strongly left to right; + * @see #getFontDirectionHint() + */ + public static final short FONT_DIRECTION_LEFT_TO_RIGHT = 1; + + /** + * 2: Like 1 but also contains neutrals; + * @see #getFontDirectionHint() + */ + public static final short FONT_DIRECTION_LEFT_TO_RIGHT_AND_NEUTRAL = 2; + + /** + * -1: Only strongly right to left; + * @see #getFontDirectionHint() + */ + public static final short FONT_DIRECTION_RIGHT_TO_LEFT = -1; + + /** + * -2: Like -1 but also contains neutrals. + * @see #getFontDirectionHint() + */ + public static final short FONT_DIRECTION_RIGHT_TO_LEFT_AND_NEUTRAL = -2; + + /** * @see #getMajorVersion() */ private int _majorVersion = MAJOR_VERSION; @@ -169,7 +200,7 @@ public class HeadTable implements Table { /** * @see #getFontDirectionHint() */ - private short _fontDirectionHint; + private short _fontDirectionHint = FONT_DIRECTION_LEFT_TO_RIGHT_AND_NEUTRAL; /** * @see #getIndexToLocFormat() @@ -412,6 +443,8 @@ public class HeadTable implements Table { /** * uint16 * + * Contains information concerning the nature of the font patterns. + * * Bit 0: Bold (if set to 1); * * Bit 1: Italic (if set to 1) @@ -428,16 +461,77 @@ public class HeadTable implements Table { * * Bits 7–15: Reserved (set to 0). * - * Note that the macStyle bits must agree with the OS/2 table fsSelection - * bits. The fsSelection bits are used over the macStyle bits in Microsoft - * Windows. The PANOSE values and 'post' table values are ignored for - * determining bold or italic fonts. + * Note that the macStyle bits must agree with the OS/2 table + * {@link Os2Table#getSelection() fsSelection} bits. The fsSelection bits + * are used over the macStyle bits in Microsoft Windows. The PANOSE values + * and 'post' table values are ignored for determining bold or italic fonts. */ public short getMacStyle() { return _macStyle; } + + /** + * Whether the glyphs are emboldened. + * + * @see #getMacStyle() + */ + public boolean isMacBold() { + return Bits.bit(_macStyle, 0); + } /** + * Font contains italic or oblique glyphs, otherwise they are upright. + * + * @see #getMacStyle() + */ + public boolean isMacItalic() { + return Bits.bit(_macStyle, 1); + } + + /** + * Glyphs are underscored. + * + * @see #getMacStyle() + */ + public boolean isMacUnderline() { + return Bits.bit(_macStyle, 2); + } + + /** + * Outline (hollow) glyphs, otherwise they are solid. + * + * @see #getMacStyle() + */ + public boolean isMacOutline() { + return Bits.bit(_macStyle, 3); + } + + /** + * Whether the font has shadow. + * + * @see #getMacStyle() + */ + public boolean isMacShadow() { + return Bits.bit(_macStyle, 4); + } + + /** + * Whether the font is condensed. + * + * @see #getMacStyle() + */ + public boolean isMacCondensed() { + return Bits.bit(_macStyle, 5); + } + + /** + * @see #getMacStyle() + */ + public boolean isMacExtended() { + return Bits.bit(_macStyle, 6); + } + + /** * uint16 * * Smallest readable size in pixels. @@ -449,17 +543,7 @@ public class HeadTable implements Table { /** * int16 * - * Deprecated (Set to 2). - * - * 0: Fully mixed directional glyphs; - * - * 1: Only strongly left to right; - * - * 2: Like 1 but also contains neutrals; - * - * -1: Only strongly right to left; - * - * -2: Like -1 but also contains neutrals. + * Deprecated (Set to {@link #FONT_DIRECTION_LEFT_TO_RIGHT_AND_NEUTRAL}). * * (A neutral character has no inherent directionality; it is not a * character with zero (0) width. Spaces and punctuation are examples of @@ -468,6 +552,12 @@ public class HeadTable implements Table { * letters (right-to-left) have directionality. In a “normal” Roman font * where spaces and punctuation are present, the font direction hints should * be set to two (2).) + * + * @see #FONT_DIRECTION_MIXED + * @see #FONT_DIRECTION_LEFT_TO_RIGHT + * @see #FONT_DIRECTION_LEFT_TO_RIGHT_AND_NEUTRAL + * @see #FONT_DIRECTION_RIGHT_TO_LEFT + * @see #FONT_DIRECTION_RIGHT_TO_LEFT_AND_NEUTRAL */ public short getFontDirectionHint() { return _fontDirectionHint; |