[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Jul 23 05:06:49 UTC 2018
docs/harfbuzz-sections.txt | 1
src/Makefile.am | 4
src/Makefile.sources | 2
src/dump-fon.cc | 555 ----------
src/gen-use-table.py | 10
src/hb-aat-fmtx-table.hh | 67 -
src/hb-aat-gcid-table.hh | 73 -
src/hb-aat-layout.cc | 2
src/hb-ot-layout-common-private.hh | 14
src/hb-ot-layout.cc | 86 +
src/hb-ot-layout.h | 8
src/hb-ot-shape-complex-use-table.cc | 4
src/hb-ot-shape-complex-use.cc | 21
test/shaping/data/in-house/fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf |binary
test/shaping/data/in-house/tests/use.tests | 5
15 files changed, 127 insertions(+), 725 deletions(-)
New commits:
commit 62fa7cd1ccff4d4448ef84f9cc146464672636aa
Author: David Corbett <corbett.dav at husky.neu.edu>
Date: Fri Apr 13 18:45:37 2018 -0400
Order Chakma split vowels in accordance with NFC
Fixes #1105.
diff --git a/src/gen-use-table.py b/src/gen-use-table.py
index e7c621ca..c742ebac 100755
--- a/src/gen-use-table.py
+++ b/src/gen-use-table.py
@@ -328,6 +328,9 @@ def map_to_use(data):
# TODO: https://github.com/harfbuzz/harfbuzz/pull/626
if U == 0xA8B4: UISC = Consonant_Medial
+ # TODO: https://github.com/harfbuzz/harfbuzz/issues/1105
+ if U == 0x11134: UISC = Gemination_Mark
+
values = [k for k,v in items if v(U,UISC,UGC)]
assert len(values) == 1, "%s %s %s %s" % (hex(U), UISC, UGC, values)
USE = values[0]
@@ -356,6 +359,13 @@ def map_to_use(data):
# https://github.com/roozbehp/unicode-data/issues/8
if U == 0x0A51: UIPC = Bottom
+ # TODO: https://github.com/harfbuzz/harfbuzz/pull/982
+ if UBlock == 'Chakma' and is_VOWEL (U, UISC, UGC):
+ if UIPC == Top:
+ UIPC = Bottom
+ elif UIPC == Bottom:
+ UIPC = Top
+
assert (UIPC in [Not_Applicable, Visual_Order_Left] or
USE in use_positions), "%s %s %s %s %s" % (hex(U), UIPC, USE, UISC, UGC)
diff --git a/src/hb-ot-shape-complex-use-table.cc b/src/hb-ot-shape-complex-use-table.cc
index 25f7bf42..9c796f05 100644
--- a/src/hb-ot-shape-complex-use-table.cc
+++ b/src/hb-ot-shape-complex-use-table.cc
@@ -510,8 +510,8 @@ static const USE_TABLE_ELEMENT_TYPE use_table[] = {
/* 11100 */ VMAbv, VMAbv, VMAbv, B, B, B, B, B, B, B, B, B, B, B, B, B,
/* 11110 */ B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B,
- /* 11120 */ B, B, B, B, B, B, B, VAbv, VAbv, VAbv, VBlw, VBlw, VPre, VAbv, VAbv, VAbv,
- /* 11130 */ VAbv, VBlw, VBlw, H, VAbv, O, B, B, B, B, B, B, B, B, B, B,
+ /* 11120 */ B, B, B, B, B, B, B, VBlw, VBlw, VBlw, VAbv, VAbv, VPre, VBlw, VAbv, VAbv,
+ /* 11130 */ VBlw, VAbv, VAbv, H, CMAbv, O, B, B, B, B, B, B, B, B, B, B,
/* 11140 */ O, O, O, O, B, VPst, VPst, O, O, O, O, O, O, O, O, O,
/* Mahajani */
diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc
index 66b95711..f8e86c9d 100644
--- a/src/hb-ot-shape-complex-use.cc
+++ b/src/hb-ot-shape-complex-use.cc
@@ -561,25 +561,6 @@ reorder (const hb_ot_shape_plan_t *plan,
}
static bool
-decompose_use (const hb_ot_shape_normalize_context_t *c,
- hb_codepoint_t ab,
- hb_codepoint_t *a,
- hb_codepoint_t *b)
-{
- switch (ab)
- {
- /* Chakma:
- * Special case where the Unicode decomp gives matras in the wrong order
- * for cluster validation.
- */
- case 0x1112Eu : *a = 0x11127u; *b= 0x11131u; return true;
- case 0x1112Fu : *a = 0x11127u; *b= 0x11132u; return true;
- }
-
- return (bool) c->unicode->decompose (ab, a, b);
-}
-
-static bool
compose_use (const hb_ot_shape_normalize_context_t *c,
hb_codepoint_t a,
hb_codepoint_t b,
@@ -602,7 +583,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_use =
nullptr, /* preprocess_text */
nullptr, /* postprocess_glyphs */
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
- decompose_use,
+ nullptr, /* decompose */
compose_use,
setup_masks_use,
nullptr, /* disable_otl */
diff --git a/test/shaping/data/in-house/fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf b/test/shaping/data/in-house/fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf
new file mode 100644
index 00000000..a1fef490
Binary files /dev/null and b/test/shaping/data/in-house/fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf differ
diff --git a/test/shaping/data/in-house/tests/use.tests b/test/shaping/data/in-house/tests/use.tests
index 172946c4..4b46620b 100644
--- a/test/shaping/data/in-house/tests/use.tests
+++ b/test/shaping/data/in-house/tests/use.tests
@@ -2,4 +2,9 @@
../fonts/4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf::U+1A48,U+1A58,U+1A25,U+1A48,U+1A58,U+1A25,U+1A6E,U+1A63:[uni1A48=0+1212|uni1A25=0+1912|uni1A58=0+0|uni1A48=3+1212|uni1A6E=3+0|uni1A25=3+1912|uni1A58=3+0|uni1A63=3+1212]
../fonts/f518eb6f6b5eec2946c9fbbbde44e45d46f5e2ac.ttf::U+1A48,U+1A58,U+1A25,U+1A48,U+1A58,U+1A25,U+1A6E,U+1A63:[uni1A48=0+1212|uni1A25=0+1912|uni1A58=0+0|uni1A48=3+1212|uni1A6E=3+1211|uni1A25=3+1912|uni1A58=3+0|uni1A63=3+1212]
../fonts/6ff0fbead4462d9f229167b4e6839eceb8465058.ttf:--font-funcs=ot:U+11103,U+11128:[u11103=0+837|u11128=0+0]
+../fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf::U+11124,U+1112E:[u11124=0+514|u11131=0+0|u11127=0+0]
+../fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf::U+11124,U+11131,U+11127:[u11124=0+514|u11131=0+0|u11127=0+0]
+../fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf::U+11124,U+11127,U+11131:[u11124=0+514|u11127=0+0|uni25CC=0+547|u11131=0+0]
+../fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf::U+11124,U+11134,U+11131:[u11124=0+514|u11134=0+0|u11131=0+0]
+../fonts/2a670df15b73a5dc75a5cc491bde5ac93c5077dc.ttf::U+11124,U+11131,U+11134:[u11124=0+514|u11131=0+0|uni25CC=0+547|u11134=0+0]
../fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf:--font-funcs=ft:U+11410,U+11442,U+11411,U+11440,U+11443,U+11410,U+11442,U+11411,U+11441,U+11443:[E_dv.alt=0+275|Ga.icd=0+367|Gha.diag=0 at 100,0+386|AA_dv.alt=0+208|Candrabindu=0 at 17,-8+0|E_dv.alt=5+275|Ga.icd=5+367|Gha.diag=5 at 100,0+386|AU_dv_part.alt=5+213|Candrabindu.sm=5 at -52,179+0]
commit 0c1b287b72e91e0898d75acb5d5acf1c6b9a7498
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sat Jul 21 21:14:48 2018 +0430
Add a new API, hb_ot_layout_get_feature_name_ids (#976)
This new API returns cvXX and ssXX related NameId, things like
featUiLabelNameId, featUiTooltipTextNameId, sampleTextNameId, ... of cvXX
and UINameId of ssXX, in a unified way.
However HarfBuzz currently doesn't expose an API for retrieving the actual
information associated with NameId from the `name` table and that should be
done separately.
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 5715d771..b93cd1d6 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -450,6 +450,7 @@ hb_ot_layout_collect_lookups
hb_ot_layout_feature_get_lookups
hb_ot_layout_feature_with_variations_get_lookups
hb_ot_layout_get_attach_points
+hb_ot_layout_get_feature_name_ids
hb_ot_layout_get_glyph_class
hb_ot_layout_get_glyphs_in_class
hb_ot_layout_get_ligature_carets
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 2ae1157d..21caf9e9 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -478,6 +478,20 @@ struct FeatureParams
return Null(FeatureParamsSize);
}
+ inline const FeatureParamsStylisticSet& get_stylistic_set_params (hb_tag_t tag) const
+ {
+ if ((tag & 0xFFFF0000u) == HB_TAG ('s','s','\0','\0')) /* ssXX */
+ return u.stylisticSet;
+ return Null(FeatureParamsStylisticSet);
+ }
+
+ inline const FeatureParamsCharacterVariants& get_character_variants_params (hb_tag_t tag) const
+ {
+ if ((tag & 0xFFFF0000u) == HB_TAG ('c','v','\0','\0')) /* cvXX */
+ return u.characterVariants;
+ return Null(FeatureParamsCharacterVariants);
+ }
+
private:
union {
FeatureParamsSize size;
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3a082307..3bfa1912 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -1016,6 +1016,24 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer)
OT::GPOS::position_finish_offsets (font, buffer);
}
+static const OT::FeatureParams&
+_get_gsubgpos_matched_feature_params (hb_face_t *face, hb_tag_t feature)
+{
+ const OT::GSUB &gsub = _get_gsub (face);
+ unsigned int gsub_num_features = gsub.get_feature_count ();
+ for (unsigned int i = 0; i < gsub_num_features; i++)
+ if (feature == gsub.get_feature_tag (i))
+ return gsub.get_feature (i).get_feature_params ();
+
+ const OT::GPOS &gpos = _get_gpos (face);
+ unsigned int gpos_num_features = gpos.get_feature_count ();
+ for (unsigned int i = 0; i < gpos_num_features; i++)
+ if (feature == gpos.get_feature_tag (i))
+ return gpos.get_feature (i).get_feature_params ();
+
+ return Null (OT::FeatureParams);
+}
+
/**
* hb_ot_layout_get_size_params:
*
@@ -1066,6 +1084,74 @@ hb_ot_layout_get_size_params (hb_face_t *face,
return false;
}
+/**
+ * hb_ot_layout_get_feature_name_ids:
+ * @face: #hb_face_t to work upon
+ * @feature: ssXX and cvXX tag
+ * @label_id: (out) (allow-none): The ‘name’ table name ID that specifies a string
+ * for a user-interface label for this feature. (May be NULL.)
+ * @tooltip_id: (out) (allow-none): The ‘name’ table name ID that specifies a string
+ * that an application can use for tooltip text for this
+ * feature. (May be NULL.)
+ * @sample_id: (out) (allow-none): The ‘name’ table name ID that specifies sample text
+ * that illustrates the effect of this feature. (May be NULL.)
+ * @num_named_parameters: (out) (allow-none): Number of named parameters. (May be zero.)
+ * @first_param_id: (out) (allow-none): The first ‘name’ table name ID used to specify
+ * strings for user-interface labels for the feature
+ * parameters. (Must be zero if numParameters is zero.)
+ *
+ * Return value: true if could find any feature with the tag, false otherwise
+ *
+ * Since: REPLACEME
+ **/
+hb_bool_t
+hb_ot_layout_get_feature_name_ids (hb_face_t *face,
+ hb_tag_t feature,
+ unsigned int *label_id, /* OUT. May be nullptr */
+ unsigned int *tooltip_id, /* OUT. May be nullptr */
+ unsigned int *sample_id, /* OUT. May be nullptr */
+ unsigned int *num_named_parameters, /* OUT. May be nullptr */
+ unsigned int *first_param_id /* OUT. May be nullptr */)
+{
+ const OT::FeatureParams &feature_params =
+ _get_gsubgpos_matched_feature_params (face, feature);
+ if (&feature_params != &Null (OT::FeatureParams))
+ {
+ const OT::FeatureParamsStylisticSet& ss_params =
+ feature_params.get_stylistic_set_params (feature);
+ if (&ss_params != &Null (OT::FeatureParamsStylisticSet)) /* ssXX */
+ {
+#define PARAM(a, A) if (a) *a = A
+ PARAM(label_id, ss_params.uiNameID);
+ // ssXX features don't have the rest
+ PARAM(tooltip_id, 0);
+ PARAM(sample_id, 0);
+ PARAM(num_named_parameters, 0);
+ PARAM(first_param_id, 0);
+ return true;
+ }
+ const OT::FeatureParamsCharacterVariants& cv_params =
+ feature_params.get_character_variants_params (feature);
+ if (&cv_params != &Null (OT::FeatureParamsCharacterVariants)) /* cvXX */
+ {
+ PARAM(label_id, cv_params.featUILableNameID);
+ PARAM(tooltip_id, cv_params.featUITooltipTextNameID);
+ PARAM(sample_id, cv_params.sampleTextNameID);
+ PARAM(num_named_parameters, cv_params.numNamedParameters);
+ PARAM(first_param_id, cv_params.firstParamUILabelNameID);
+ return true;
+ }
+ }
+
+ PARAM(label_id, 0);
+ PARAM(tooltip_id, 0);
+ PARAM(sample_id, 0);
+ PARAM(num_named_parameters, 0);
+ PARAM(first_param_id, 0);
+#undef PARAM
+ return false;
+}
+
/*
* Parts of different types are implemented here such that they have direct
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index 02787962..f8597673 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -322,6 +322,14 @@ hb_ot_layout_get_size_params (hb_face_t *face,
unsigned int *range_start, /* OUT. May be NULL */
unsigned int *range_end /* OUT. May be NULL */);
+HB_EXTERN hb_bool_t
+hb_ot_layout_get_feature_name_ids (hb_face_t *face,
+ hb_tag_t feature,
+ unsigned int *label_id /* OUT. May be NULL */,
+ unsigned int *tooltip_id /* OUT. May be NULL */,
+ unsigned int *sample_id /* OUT. May be NULL */,
+ unsigned int *num_named_parameters /* OUT. May be NULL */,
+ unsigned int *first_param_id /* OUT. May be NULL */);
/*
* BASE
commit 93b65d9fe331a217640069fad4159cb7c3ec35e6
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Tue Jul 17 23:29:16 2018 +0430
Remove dump-fon (#1100)
It had interesting stuffs like EXE parsing and
big-endian parsers but added in an attempt to find
a solution for #681 which later found not related.
diff --git a/src/Makefile.am b/src/Makefile.am
index 66594bbc..9e7fd299 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -374,15 +374,11 @@ dist_check_SCRIPTS += \
endif
check_PROGRAMS += \
- dump-fon \
dump-indic-data \
dump-khmer-data \
dump-myanmar-data \
dump-use-data \
$(NULL)
-dump_fon_SOURCES = dump-fon.cc
-dump_fon_CPPFLAGS = $(HBCFLAGS)
-dump_fon_LDADD = libharfbuzz.la $(HBLIBS)
dump_indic_data_SOURCES = dump-indic-data.cc hb-ot-shape-complex-indic-table.cc
dump_indic_data_CPPFLAGS = $(HBCFLAGS)
dump_indic_data_LDADD = libharfbuzz.la $(HBLIBS)
diff --git a/src/dump-fon.cc b/src/dump-fon.cc
deleted file mode 100644
index 40154094..00000000
--- a/src/dump-fon.cc
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright © 2018 Ebrahim Byagowi
- *
- * This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- */
-
-#include "hb-static.cc"
-#include <stdio.h>
-#include <stdlib.h>
-#include "hb-open-type-private.hh"
-
-template <typename Type, int Bytes> struct LEInt;
-
-template <typename Type>
-struct LEInt<Type, 1>
-{
- public:
- inline void set (Type V)
- {
- v = V;
- }
- inline operator Type (void) const
- {
- return v;
- }
- private: uint8_t v;
-};
-template <typename Type>
-struct LEInt<Type, 2>
-{
- public:
- inline void set (Type V)
- {
- v[1] = (V >> 8) & 0xFF;
- v[0] = (V ) & 0xFF;
- }
- inline operator Type (void) const
- {
- return (v[1] << 8)
- + (v[0] );
- }
- private: uint8_t v[2];
-};
-template <typename Type>
-struct LEInt<Type, 3>
-{
- public:
- inline void set (Type V)
- {
- v[2] = (V >> 16) & 0xFF;
- v[1] = (V >> 8) & 0xFF;
- v[0] = (V ) & 0xFF;
- }
- inline operator Type (void) const
- {
- return (v[2] << 16)
- + (v[1] << 8)
- + (v[0] );
- }
- private: uint8_t v[3];
-};
-template <typename Type>
-struct LEInt<Type, 4>
-{
- public:
- inline void set (Type V)
- {
- v[3] = (V >> 24) & 0xFF;
- v[2] = (V >> 16) & 0xFF;
- v[1] = (V >> 8) & 0xFF;
- v[0] = (V ) & 0xFF;
- }
- inline operator Type (void) const
- {
- return (v[3] << 24)
- + (v[2] << 16)
- + (v[1] << 8)
- + (v[0] );
- }
- private: uint8_t v[4];
-};
-
-template <typename Type, unsigned int Size>
-struct LEIntType
-{
- inline void set (Type i) { v.set (i); }
- inline operator Type(void) const { return v; }
- inline bool sanitize (OT::hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this)));
- }
- protected:
- LEInt<Type, Size> v;
- public:
- DEFINE_SIZE_STATIC (Size);
-};
-
-typedef LEIntType<uint8_t, 1> LEUINT8; /* 8-bit unsigned integer. */
-typedef LEIntType<int8_t, 1> LEINT8; /* 8-bit signed integer. */
-typedef LEIntType<uint16_t, 2> LEUINT16; /* 16-bit unsigned integer. */
-typedef LEIntType<int16_t, 2> LEINT16; /* 16-bit signed integer. */
-typedef LEIntType<uint32_t, 4> LEUINT32; /* 32-bit unsigned integer. */
-typedef LEIntType<int32_t, 4> LEINT32; /* 32-bit signed integer. */
-typedef LEIntType<uint32_t, 3> LEUINT24; /* 24-bit unsigned integer. */
-
-
-struct LE_FONTINFO16
-{
- inline bool sanitize (OT::hb_sanitize_context_t *c, unsigned int length) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) && c->check_range (this, length)));
- }
-
- // https://msdn.microsoft.com/en-us/library/cc194829.aspx
- enum charset_t
- {
- // dfCharSet possible values and the codepage they are indicating to
- ANSI = 0x00, // 1252
- DEFAULT = 0x01, //
- SYMBOL = 0x02, //
- SHIFTJIS = 0x80, // 932
- HANGUL = 0x81, // 949
- GB2312 = 0x86, // 936
- CHINESEBIG5 = 0x88, // 950
- GREEK = 0xA1, // 1253
- TURKISH = 0xA2, // 1254
- HEBREW = 0xB1, // 1255
- ARABIC = 0xB2, // 1256
- BALTIC = 0xBA, // 1257
- RUSSIAN = 0xCC, // 1251
- THAI = 0xDE, // 874
- EE = 0xEE, // 1250
- OEM = 0xFF //
- };
-
- inline const char* get_charset() const
- {
- switch (dfCharSet) {
- case ANSI: return "ISO8859";
- case DEFAULT: return "WinDefault";
- case SYMBOL: return "Symbol";
- case SHIFTJIS: return "JISX0208.1983";
- case HANGUL: return "MSHangul";
- case GB2312: return "GB2312.1980";
- case CHINESEBIG5: return "Big5";
- case GREEK: return "CP1253";
- case TURKISH: return "CP1254";
- case HEBREW: return "CP1255";
- case ARABIC: return "CP1256";
- case BALTIC: return "CP1257";
- case RUSSIAN: return "CP1251";
- case THAI: return "CP874";
- case EE: return "CP1250";
- case OEM: return "OEM";
- default: return "Unknown";
- }
- }
-
- inline unsigned int get_version () const
- {
- return dfVersion;
- }
-
- inline unsigned int get_weight () const
- {
- return dfWeight;
- }
-
- enum weight_t {
- DONTCARE = 0,
- THIN = 100,
- EXTRALIGHT = 200,
- ULTRALIGHT = 200,
- LIGHT = 300,
- NORMAL = 400,
- REGULAR = 400,
- MEDIUM = 500,
- SEMIBOLD = 600,
- DEMIBOLD = 600,
- BOLD = 700,
- EXTRABOLD = 800,
- ULTRABOLD = 800,
- HEAVY = 900,
- BLACK = 900
- };
-
- inline void dump () const
- {
- // With https://github.com/juanitogan/mkwinfont/blob/master/python/dewinfont.py help
- // Should be implemented differently eventually, but for now
- unsigned int ctstart;
- unsigned int ctsize;
- if (dfVersion == 0x200)
- {
- ctstart = 0x76;
- ctsize = 4;
- }
- else
- {
- return; // must of ".fon"s are version 2 and even dewinfont V1 implmentation doesn't seem correct
- ctstart = 0x94;
- ctsize = 6;
- }
- // unsigned int maxwidth = 0;
- for (unsigned int i = dfFirstChar; i < dfLastChar; ++i)
- {
- unsigned int entry = ctstart + ctsize * (i-dfFirstChar);
- unsigned int w = (uint16_t) OT::StructAtOffset<LEUINT16> (this, entry);
-
- unsigned int off;
- if (ctsize == 4)
- off = (uint16_t) OT::StructAtOffset<LEUINT16> (this, entry+2);
- else
- off = (uint32_t) OT::StructAtOffset<LEUINT32> (this, entry+2);
-
- unsigned int widthbytes = (w + 7) / 8;
- for (unsigned int j = 0; j < dfPixHeight; ++j)
- {
- for (unsigned int k = 0; k < widthbytes; ++k)
- {
- unsigned int bytepos = off + k * dfPixHeight + j;
- const uint8_t b = (uint8_t) OT::StructAtOffset<LEINT8> (this, bytepos);
- for (unsigned int a = 128; a > 0; a >>= 1)
- printf (b & a ? "x" : ".");
- }
- printf ("\n");
- }
- printf ("\n\n");
- }
- }
-
- protected:
- LEUINT16 dfVersion;
- LEUINT32 dfSize;
- LEUINT8 dfCopyright[60];
- LEUINT16 dfType;
- LEUINT16 dfPoints;
- LEUINT16 dfVertRes;
- LEUINT16 dfHorizRes;
- LEUINT16 dfAscent;
- LEUINT16 dfInternalLeading;
- LEUINT16 dfExternalLeading;
- LEUINT8 dfItalic;
- LEUINT8 dfUnderline;
- LEUINT8 dfStrikeOut;
- LEUINT16 dfWeight; // see weight_t
- LEUINT8 dfCharSet; // see charset_t
- LEUINT16 dfPixWidth;
- LEUINT16 dfPixHeight;
- LEUINT8 dfPitchAndFamily;
- LEUINT16 dfAvgWidth;
- LEUINT16 dfMaxWidth;
- LEUINT8 dfFirstChar;
- LEUINT8 dfLastChar;
- LEUINT8 dfDefaultChar;
- LEUINT8 dfBreakChar;
- LEUINT16 dfWidthBytes;
- LEUINT32 dfDevice;
- LEUINT32 dfFace;
- LEUINT32 dfBitsPointer;
- LEUINT32 dfBitsOffset;
- LEUINT8 dfReserved;
-// LEUINT32 dfFlags;
-// LEUINT16 dfAspace;
-// LEUINT16 dfBspace;
-// LEUINT16 dfCspace;
-// LEUINT32 dfColorPointer;
-// LEUINT32 dfReserved1[4];
- OT::UnsizedArrayOf<LEUINT8>
- dataZ;
- public:
- DEFINE_SIZE_ARRAY (118, dataZ);
-};
-
-struct NE_NAMEINFO
-{
- friend struct NE_TYPEINFO;
-
- inline bool sanitize (OT::hb_sanitize_context_t *c, const void *base, unsigned int shift) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- get_font (base, shift).sanitize (c, length << shift)));
- }
-
- inline const LE_FONTINFO16& get_font (const void *base, int shift) const
- {
- return OT::StructAtOffset<LE_FONTINFO16> (base, offset << shift);
- }
-
- enum resource_type_flag_t {
- NONE = 0x0000,
- MOVEABLE = 0x0010,
- PURE = 0x0020,
- PRELOAD = 0x0040
- };
-
- protected:
- LEUINT16 offset; // Should be shifted with alignmentShiftCount before use
- LEUINT16 length; // Should be shifted with alignmentShiftCount before use
- LEUINT16 flags; // resource_type_flag_t
- LEUINT16 id;
- LEUINT16 handle;
- LEUINT16 usage;
- public:
- DEFINE_SIZE_STATIC (12);
-};
-
-struct NE_TYPEINFO
-{
- inline bool sanitize (OT::hb_sanitize_context_t *c, const void *base, unsigned int shift) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) && resources.sanitize (c, count, base, shift));
- }
-
- inline unsigned int get_size (void) const
- { return 8 + count * NE_NAMEINFO::static_size; }
-
- inline const NE_TYPEINFO& next () const
- {
- const NE_TYPEINFO& next = OT::StructAfter<NE_TYPEINFO> (*this);
- if (type_id == 0)
- return Null(NE_TYPEINFO);
- return next;
- }
-
- inline const LE_FONTINFO16& get_font (unsigned int idx, const void *base, int shift) const
- {
- if (idx < count)
- return resources[idx].get_font (base, shift);
- return Null(LE_FONTINFO16);
- }
-
- inline unsigned int get_count () const
- {
- return count;
- }
-
- inline unsigned int get_type_id () const
- {
- return type_id;
- }
-
- enum type_id_t {
- CURSOR = 0x8001,
- BITMAP = 0x8002,
- ICON = 0x8003,
- MENU = 0x8004,
- DIALOG = 0x8005,
- STRING = 0x8006,
- FONT_DIRECTORY = 0x8007,
- FONT = 0x8008,
- ACCELERATOR_TABLE = 0x8009,
- RESOURCE_DATA = 0x800a,
- GROUP_CURSOR = 0x800c,
- GROUP_ICON = 0x800e,
- VERSION = 0x8010
- };
-
- protected:
- LEUINT16 type_id; // see type_id_t
- LEUINT16 count;
- LEUINT32 resloader;
- OT::UnsizedArrayOf<NE_NAMEINFO>
- resources;
- public:
- DEFINE_SIZE_ARRAY (8, resources);
-};
-
-struct NE_RESOURCE_TABLE
-{
- inline bool sanitize (OT::hb_sanitize_context_t *c, const void *base) const
- {
- TRACE_SANITIZE (this);
-
- if (!c->check_struct (this))
- return_trace (false);
-
- const NE_TYPEINFO* n = &chain;
- while (n != &Null(NE_TYPEINFO) && c->check_struct (n) && n->get_type_id () != 0)
- {
- if (n->get_type_id () == NE_TYPEINFO::FONT)
- return_trace (n->sanitize (c, base, alignmentShiftCount));
- n = &n->next();
- }
- return_trace (false);
- }
-
- inline unsigned int get_shift_value () const
- {
- return alignmentShiftCount;
- }
-
- inline const NE_TYPEINFO& get_fonts_entry () const
- {
- const NE_TYPEINFO* n = &chain;
- while (n != &Null(NE_TYPEINFO) && n->get_type_id () != 0)
- {
- if (n->get_type_id () == NE_TYPEINFO::FONT)
- return *n;
- n = &n->next();
- }
- return Null(NE_TYPEINFO);
- }
-
- protected:
- LEUINT16 alignmentShiftCount;
- NE_TYPEINFO chain;
- // It is followed by an array of OT::ArrayOf<LEUINT8, LEUINT8> chars;
- public:
- DEFINE_SIZE_MIN (2);
-};
-
-// https://github.com/wine-mirror/wine/blob/master/include/winnt.h#L2467
-struct LE_IMAGE_OS2_HEADER
-{
- inline bool sanitize (OT::hb_sanitize_context_t *c, const void *base) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) && (this+rsrctab).sanitize (c, base)));
- }
-
- inline const NE_RESOURCE_TABLE& get_resource_table () const
- {
- if (magic != 0x454E) // Only NE containers are support for now, NE == 0x454E
- return Null(NE_RESOURCE_TABLE);
- return this+rsrctab;
- }
-
- protected:
- LEUINT16 magic; /* 00 NE signature 'NE' */
- LEUINT8 ver; /* 02 Linker version number */
- LEUINT8 rev; /* 03 Linker revision number */
- LEUINT16 enttab; /* 04 Offset to entry table relative to NE */
- LEUINT16 cbenttab; /* 06 Length of entry table in bytes */
- LEUINT32 crc; /* 08 Checksum */
- LEUINT16 flags; /* 0c Flags about segments in this file */
- LEUINT16 autodata; /* 0e Automatic data segment number */
- LEUINT16 heap; /* 10 Initial size of local heap */
- LEUINT16 stack; /* 12 Initial size of stack */
- LEUINT32 csip; /* 14 Initial CS:IP */
- LEUINT32 sssp; /* 18 Initial SS:SP */
- LEUINT16 cseg; /* 1c # of entries in segment table */
- LEUINT16 cmod; /* 1e # of entries in module reference tab. */
- LEUINT16 cbnrestab; /* 20 Length of nonresident-name table */
- LEUINT16 segtab; /* 22 Offset to segment table */
- OT::OffsetTo<NE_RESOURCE_TABLE, LEUINT16>
- rsrctab; /* 24 Offset to resource table */
- LEUINT16 restab; /* 26 Offset to resident-name table */
- LEUINT16 modtab; /* 28 Offset to module reference table */
- LEUINT16 imptab; /* 2a Offset to imported name table */
- LEUINT32 nrestab; /* 2c Offset to nonresident-name table */
- LEUINT16 cmovent; /* 30 # of movable entry points */
- LEUINT16 align; /* 32 Logical sector alignment shift count */
- LEUINT16 cres; /* 34 # of resource segments */
- LEUINT8 exetyp; /* 36 Flags indicating target OS */
- LEUINT8 flagsothers; /* 37 Additional information flags */
- LEUINT16 pretthunks; /* 38 Offset to return thunks */
- LEUINT16 psegrefbytes; /* 3a Offset to segment ref. bytes */
- LEUINT16 swaparea; /* 3c Reserved by Microsoft */
- LEUINT16 expver; /* 3e Expected Windows version number */
- public:
- DEFINE_SIZE_STATIC (64);
-};
-
-struct LE_IMAGE_DOS_HEADER {
- inline bool sanitize (OT::hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) &&
- get_os2_header ().sanitize (c, this)));
- }
-
- inline const LE_IMAGE_OS2_HEADER& get_os2_header () const
- {
- return this+e_lfanew;
- }
-
- protected:
- LEUINT16 e_magic; // Magic number
- LEUINT16 e_cblp; // Bytes on last page of file
- LEUINT16 e_cp; // Pages in file
- LEUINT16 e_crlc; // Relocations
- LEUINT16 e_cparhdr; // Size of header in paragraphs
- LEUINT16 e_minalloc; // Minimum extra paragraphs needed
- LEUINT16 e_maxalloc; // Maximum extra paragraphs needed
- LEUINT16 e_ss; // Initial (relative) SS value
- LEUINT16 e_sp; // Initial SP value
- LEUINT16 e_csum; // Checksum
- LEUINT16 e_ip; // Initial IP value
- LEUINT16 e_cs; // Initial (relative) CS value
- LEUINT16 e_lfarlc; // File address of relocation table
- LEUINT16 e_ovno; // Overlay number
- LEUINT16 e_res_0; // Reserved words
- LEUINT16 e_res_1; // Reserved words
- LEUINT16 e_res_2; // Reserved words
- LEUINT16 e_res_3; // Reserved words
- LEUINT16 e_oemid; // OEM identifier (for e_oeminfo)
- LEUINT16 e_oeminfo; // OEM information; e_oemid specific
- LEUINT16 e_res2_0; // Reserved words
- LEUINT16 e_res2_1; // Reserved words
- LEUINT16 e_res2_2; // Reserved words
- LEUINT16 e_res2_3; // Reserved words
- LEUINT16 e_res2_4; // Reserved words
- LEUINT16 e_res2_5; // Reserved words
- LEUINT16 e_res2_6; // Reserved words
- LEUINT16 e_res2_7; // Reserved words
- LEUINT16 e_res2_8; // Reserved words
- LEUINT16 e_res2_9; // Reserved words
- OT::OffsetTo<LE_IMAGE_OS2_HEADER, LEUINT32>
- e_lfanew; // File address of new exe header
- public:
- DEFINE_SIZE_STATIC (64);
-};
-
-int main (int argc, char** argv) {
- hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
-
- OT::Sanitizer<LE_IMAGE_DOS_HEADER> sanitizer;
- hb_blob_t *font_blob = sanitizer.sanitize (blob);
- const LE_IMAGE_DOS_HEADER* dos_header = font_blob->as<LE_IMAGE_DOS_HEADER> ();
-
- const NE_RESOURCE_TABLE &rtable = dos_header->get_os2_header ().get_resource_table ();
- int shift = rtable.get_shift_value ();
- const NE_TYPEINFO& entry = rtable.get_fonts_entry ();
- for (unsigned int i = 0; i < entry.get_count (); ++i)
- {
- const LE_FONTINFO16& font = entry.get_font (i, dos_header, shift);
- printf ("version: %x, weight: %d, charset: %s\n", font.get_version (),
- font.get_weight (), font.get_charset ());
- // font.dump ();
- }
- return 0;
-}
commit d5cd47a69c40966b4d5b5aed87dd7ac6f070c37a
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Tue Jul 17 22:32:37 2018 +0430
Remove AAT's gcid/fmtx (#1099)
We are not going to use them, at least in the foreseeable future
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 0bc9e589..9fa926d4 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -93,8 +93,6 @@ HB_OT_sources = \
hb-aat-layout-morx-table.hh \
hb-aat-layout-trak-table.hh \
hb-aat-layout-private.hh \
- hb-aat-fmtx-table.hh \
- hb-aat-gcid-table.hh \
hb-aat-ltag-table.hh \
hb-ot-font.cc \
hb-ot-layout.cc \
diff --git a/src/hb-aat-fmtx-table.hh b/src/hb-aat-fmtx-table.hh
deleted file mode 100644
index aa82c88c..00000000
--- a/src/hb-aat-fmtx-table.hh
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright © 2018 Ebrahim Byagowi
- *
- * This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- */
-
-#ifndef HB_AAT_FMTX_TABLE_HH
-#define HB_AAT_FMTX_TABLE_HH
-
-#include "hb-aat-layout-common-private.hh"
-
-/*
- * fmtx -- Font Metrics
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6fmtx.html
- */
-#define HB_AAT_TAG_fmtx HB_TAG('f','m','t','x')
-
-
-namespace AAT {
-
-
-struct fmtx
-{
- static const hb_tag_t tableTag = HB_AAT_TAG_fmtx;
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this)));
- }
-
- FixedVersion<>version; /* Version (set to 0x00020000). */
- HBUINT32 glyphIndex; /* The glyph whose points represent the metrics. */
- HBUINT8 horizontalBefore; /* Point number for the horizontal ascent. */
- HBUINT8 horizontalAfter; /* Point number for the horizontal descent. */
- HBUINT8 horizontalCaretHead; /* Point number for the horizontal caret head. */
- HBUINT8 horizontalCaretBase; /* Point number for the horizontal caret base. */
- HBUINT8 verticalBefore; /* Point number for the vertical ascent. */
- HBUINT8 verticalAfter; /* Point number for the vertical descent. */
- HBUINT8 verticalCaretHead; /* Point number for the vertical caret head. */
- HBUINT8 verticalCaretBase; /* Point number for the vertical caret base. */
- public:
- DEFINE_SIZE_STATIC (16);
-};
-
-} /* namespace AAT */
-
-
-#endif /* HB_AAT_FMTX_TABLE_HH */
diff --git a/src/hb-aat-gcid-table.hh b/src/hb-aat-gcid-table.hh
deleted file mode 100644
index b48a2798..00000000
--- a/src/hb-aat-gcid-table.hh
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright © 2018 Ebrahim Byagowi
- *
- * This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- */
-
-#ifndef HB_AAT_GCID_TABLE_HH
-#define HB_AAT_GCID_TABLE_HH
-
-#include "hb-aat-layout-common-private.hh"
-
-/*
- * gcid -- Glyphs CIDs
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gcid.html
- */
-#define HB_AAT_TAG_gcid HB_TAG('g','c','i','d')
-
-
-namespace AAT {
-
-
-struct gcid
-{
- static const hb_tag_t tableTag = HB_AAT_TAG_gcid;
-
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- return_trace (likely (c->check_struct (this) && CIDs.sanitize (c)));
- }
-
- protected:
- HBUINT16 version; /* Version number (set to 0) */
- HBUINT16 format; /* Data format (set to 0) */
- HBUINT32 size; /* Size of the table, including header */
- HBUINT16 registry; /* The registry ID */
- HBUINT8 registryName[64];
- /* The registry name in ASCII */
- HBUINT16 order; /* The order ID */
- HBUINT8 orderName[64]; /* The order name in ASCII */
- HBUINT16 supplementVersion;
- /* The supplement version */
- ArrayOf<HBUINT16>
- CIDs; /* The CIDs for the glyphs in the font,
- * starting with glyph 0. If a glyph does not correspond
- * to a CID in the identified collection, 0xFFFF is used.
- * This should not exceed the number of glyphs in the font. */
- public:
- DEFINE_SIZE_ARRAY (144, CIDs);
-};
-
-} /* namespace AAT */
-
-
-#endif /* HB_AAT_GCID_TABLE_HH */
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index df6c38c4..696dd355 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -36,8 +36,6 @@
#include "hb-aat-layout-kerx-table.hh"
#include "hb-aat-layout-morx-table.hh"
#include "hb-aat-layout-trak-table.hh"
-#include "hb-aat-fmtx-table.hh" // Just so we compile it; unused otherwise.
-#include "hb-aat-gcid-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-ltag-table.hh" // Just so we compile it; unused otherwise.
/*
More information about the HarfBuzz
mailing list