[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Mar 26 08:08:19 UTC 2018
.circleci/config.yml | 13 ++++
src/Makefile.sources | 2
src/dev-run.sh | 5 +
src/hb-aat-layout-fmtx-table.hh | 67 ++++++++++++++++++++++
src/hb-aat-layout-kerx-table.hh | 4 -
src/hb-aat-layout-ltag-table.hh | 80 +++++++++++++++++++++++++++
src/hb-aat-layout-morx-table.hh | 4 -
src/hb-aat-layout.cc | 4 +
src/hb-directwrite.cc | 118 +++++++++++++++-------------------------
9 files changed, 219 insertions(+), 78 deletions(-)
New commits:
commit 158f2810b2868c7398dc80cbb089b88a566ce99e
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Mon Mar 26 12:04:30 2018 +0430
[aat/ltag] Implement the table parsing (#911)
diff --git a/src/Makefile.sources b/src/Makefile.sources
index cfd2b61a..abf1bf49 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -82,7 +82,9 @@ HB_OT_sources = \
hb-aat-layout.cc \
hb-aat-layout-common-private.hh \
hb-aat-layout-ankr-table.hh \
+ hb-aat-layout-fmtx-table.hh \
hb-aat-layout-kerx-table.hh \
+ hb-aat-layout-ltag-table.hh \
hb-aat-layout-morx-table.hh \
hb-aat-layout-trak-table.hh \
hb-aat-layout-private.hh \
diff --git a/src/hb-aat-layout-fmtx-table.hh b/src/hb-aat-layout-fmtx-table.hh
index a1e5cfcd..4ce81d36 100644
--- a/src/hb-aat-layout-fmtx-table.hh
+++ b/src/hb-aat-layout-fmtx-table.hh
@@ -27,19 +27,19 @@
#include "hb-aat-layout-common-private.hh"
-#define HB_AAT_TAG_FMTX HB_TAG('f','m','t','x')
+#define HB_AAT_TAG_fmtx HB_TAG('f','m','t','x')
namespace AAT {
/*
- * fmtx -- Font Metrics
+ * fmtx -- Font metrics
*/
struct fmtx
{
- static const hb_tag_t tableTag = HB_AAT_TAG_FMTX;
+ static const hb_tag_t tableTag = HB_AAT_TAG_fmtx;
inline bool sanitize (hb_sanitize_context_t *c) const
{
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index ce7ca105..d0624ecc 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -31,7 +31,7 @@
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common-private.hh"
-#define HB_AAT_TAG_KERX HB_TAG('k','e','r','x')
+#define HB_AAT_TAG_kerx HB_TAG('k','e','r','x')
namespace AAT {
@@ -284,7 +284,7 @@ struct SubtableGlyphCoverageArray
struct kerx
{
- static const hb_tag_t tableTag = HB_AAT_TAG_KERX;
+ static const hb_tag_t tableTag = HB_AAT_TAG_kerx;
inline bool apply (hb_aat_apply_context_t *c, const AAT::ankr *ankr) const
{
diff --git a/src/hb-aat-layout-ltag-table.hh b/src/hb-aat-layout-ltag-table.hh
new file mode 100644
index 00000000..62eaf203
--- /dev/null
+++ b/src/hb-aat-layout-ltag-table.hh
@@ -0,0 +1,80 @@
+/*
+ * 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_LAYOUT_LTAG_TABLE_HH
+#define HB_AAT_LAYOUT_LTAG_TABLE_HH
+
+#include "hb-aat-layout-common-private.hh"
+
+#define HB_AAT_TAG_ltag HB_TAG('l','t','a','g')
+
+
+namespace AAT {
+
+struct FTStringRange
+{
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ tag (base).sanitize (c, length));
+ }
+
+ protected:
+ OffsetTo<UnsizedArrayOf<HBUINT8> >
+ tag; /* Offset from the start of the table to
+ the beginning of the string */
+ HBUINT16 length; /* String length (in bytes) */
+ public:
+ DEFINE_SIZE_STATIC (4);
+};
+
+/*
+ * ltag -- Language tags
+ */
+
+struct ltag
+{
+ static const hb_tag_t tableTag = HB_AAT_TAG_ltag;
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ tagRanges.sanitize (c, this));
+ }
+
+ protected:
+ HBUINT32 version;/* Table version; currently 1 */
+ HBUINT32 flags; /* Table flags; currently none defined */
+ ArrayOf<FTStringRange, HBUINT32>
+ tagRanges; /* Range for each tag's string */
+ public:
+ DEFINE_SIZE_ARRAY (12, tagRanges);
+};
+
+} /* namespace AAT */
+
+
+#endif /* HB_AAT_LAYOUT_LTAG_TABLE_HH */
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index 4cc28242..2ec25893 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -30,7 +30,7 @@
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common-private.hh"
-#define HB_AAT_TAG_MORX HB_TAG('m','o','r','x')
+#define HB_AAT_TAG_morx HB_TAG('m','o','r','x')
namespace AAT {
@@ -677,7 +677,7 @@ struct Chain
struct morx
{
- static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
+ static const hb_tag_t tableTag = HB_AAT_TAG_morx;
inline void apply (hb_aat_apply_context_t *c) const
{
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index 878cec64..ab743733 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -31,7 +31,7 @@
#include "hb-aat-layout-common-private.hh"
#include "hb-open-type-private.hh"
-#define HB_AAT_TAG_TRAK HB_TAG('t','r','a','k')
+#define HB_AAT_TAG_trak HB_TAG('t','r','a','k')
namespace AAT {
@@ -135,7 +135,7 @@ struct TrackData
struct trak
{
- static const hb_tag_t tableTag = HB_AAT_TAG_TRAK;
+ static const hb_tag_t tableTag = HB_AAT_TAG_trak;
inline bool sanitize (hb_sanitize_context_t *c) const
{
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index a22b270e..61792f92 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -33,6 +33,7 @@
#include "hb-aat-layout-ankr-table.hh"
#include "hb-aat-layout-fmtx-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-kerx-table.hh"
+#include "hb-aat-layout-ltag-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-morx-table.hh"
#include "hb-aat-layout-trak-table.hh"
@@ -111,7 +112,7 @@ _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr)
// {
// OT::Sanitizer<AAT::morx> sanitizer;
// sanitizer.set_num_glyphs (face->get_num_glyphs ());
-// hb_blob_t *morx_blob = sanitizer.sanitize (face->reference_table (HB_AAT_TAG_MORX));
+// hb_blob_t *morx_blob = sanitizer.sanitize (face->reference_table (HB_AAT_TAG_morx));
// OT::Sanitizer<AAT::morx>::lock_instance (morx_blob);
// if (0)
commit 9eee38a55cdcbfd34b530dcc8defff84057a9eb2
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sun Mar 25 23:56:02 2018 +0430
[aat/fmtx] Implement the table parsing (#910)
diff --git a/src/hb-aat-layout-fmtx-table.hh b/src/hb-aat-layout-fmtx-table.hh
new file mode 100644
index 00000000..a1e5cfcd
--- /dev/null
+++ b/src/hb-aat-layout-fmtx-table.hh
@@ -0,0 +1,67 @@
+/*
+ * 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_LAYOUT_FMTX_TABLE_HH
+#define HB_AAT_LAYOUT_FMTX_TABLE_HH
+
+#include "hb-aat-layout-common-private.hh"
+
+#define HB_AAT_TAG_FMTX HB_TAG('f','m','t','x')
+
+
+namespace AAT {
+
+
+/*
+ * fmtx -- Font Metrics
+ */
+
+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 (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_LAYOUT_FMTX_TABLE_HH */
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index ab743733..878cec64 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -31,7 +31,7 @@
#include "hb-aat-layout-common-private.hh"
#include "hb-open-type-private.hh"
-#define HB_AAT_TAG_trak HB_TAG('t','r','a','k')
+#define HB_AAT_TAG_TRAK HB_TAG('t','r','a','k')
namespace AAT {
@@ -135,7 +135,7 @@ struct TrackData
struct trak
{
- static const hb_tag_t tableTag = HB_AAT_TAG_trak;
+ static const hb_tag_t tableTag = HB_AAT_TAG_TRAK;
inline bool sanitize (hb_sanitize_context_t *c) const
{
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index 45268e3e..a22b270e 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -31,6 +31,7 @@
#include "hb-aat-layout-private.hh"
#include "hb-aat-layout-ankr-table.hh"
+#include "hb-aat-layout-fmtx-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-kerx-table.hh"
#include "hb-aat-layout-morx-table.hh"
#include "hb-aat-layout-trak-table.hh"
commit 1d3f4f835175c658c63e96be12052b80d27cf6fa
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sun Mar 25 18:45:50 2018 +0430
[ci] Add a build only apple-gcc-4.2 i686 bot
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 19beeeea..73d33271 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -15,6 +15,18 @@ jobs:
- run: make 2>&1 | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'
- run: make check || .ci/fail.sh
+ macos-notest-apple-gcc-i686-4.2:
+ macos:
+ xcode: "8.3.3"
+ steps:
+ - checkout
+ - run: brew update-reset
+ - run: brew install wget pkg-config libtool ragel
+ - run: wget https://packages.macports.org/apple-gcc42/apple-gcc42-5666.3_15+universal.darwin_15.i386-x86_64.tbz2 && tar zxvf apple-gcc42-5666.3_15+universal.darwin_15.i386-x86_64.tbz2
+ - run: CPP=$PWD/opt/local/bin/i686-apple-darwin15-cpp-apple-4.2.1 CC=$PWD/opt/local/bin/i686-apple-darwin15-gcc-apple-4.2.1 CXX=$PWD/opt/local/bin/i686-apple-darwin15-g++-apple-4.2.1 ./autogen.sh
+ # Ignoring assembler complains, https://stackoverflow.com/a/39867021
+ - run: make 2>&1 | grep -v -e '^/var/folders/*' -e '^[[:space:]]*\.section' -e '^[[:space:]]*\^[[:space:]]*~*'
+
distcheck:
docker:
- image: ubuntu:17.10
@@ -178,6 +190,7 @@ workflows:
jobs:
# macOS
- macos-llvm-gcc-4.2
+ - macos-notest-apple-gcc-i686-4.2
# both autotools and cmake
- distcheck
commit fe18c471a4aee1f6eba62383b64f0a8969cbc6ea
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sun Mar 25 18:19:23 2018 +0430
[dwrite] minor
diff --git a/src/dev-run.sh b/src/dev-run.sh
index e7d0973b..82de6888 100755
--- a/src/dev-run.sh
+++ b/src/dev-run.sh
@@ -1,8 +1,9 @@
#!/bin/bash
# Suggested setup to use the script:
# (on the root of the project)
-# $ NOCONFIGURE=1 ./autogen.sh --with-freetype --with-glib --with-gobject --with-cairo
-# $ mkdir build && cd build && ../configure && make -j5 && cd ..
+# $ NOCONFIGURE=1 ./autogen.sh && mkdir build && cd build
+# $ ../configure --with-freetype --with-glib --with-gobject --with-cairo
+# $ make -j5 && cd ..
# $ src/dev-run.sh [FONT-FILE] [TEXT]
#
# Or, using cmake:
diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc
index f1277277..3175fe05 100644
--- a/src/hb-directwrite.cc
+++ b/src/hb-directwrite.cc
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright © 2015-2018 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
@@ -71,7 +71,7 @@ public:
// IDWriteFontFileLoader methods
virtual HRESULT STDMETHODCALLTYPE CreateStreamFromKey (void const* fontFileReferenceKey,
- UINT32 fontFileReferenceKeySize,
+ uint32_t fontFileReferenceKeySize,
OUT IDWriteFontFileStream** fontFileStream)
{
*fontFileStream = mFontFileStream;
@@ -103,9 +103,8 @@ public:
OUT void** fragmentContext)
{
// We are required to do bounds checking.
- if (fileOffset + fragmentSize > mSize) {
+ if (fileOffset + fragmentSize > mSize)
return E_FAIL;
- }
// truncate the 64 bit fileOffset to size_t sized index into mData
size_t index = static_cast<size_t> (fileOffset);
@@ -135,7 +134,8 @@ public:
* shaper face data
*/
-struct hb_directwrite_shaper_face_data_t {
+struct hb_directwrite_shaper_face_data_t
+{
IDWriteFactory *dwriteFactory;
IDWriteFontFile *fontFile;
IDWriteFontFileStream *fontFileStream;
@@ -179,20 +179,16 @@ _hb_directwrite_shaper_face_data_create (hb_face_t *face)
return nullptr; \
} HB_STMT_END;
- if (FAILED (hr)) {
+ if (FAILED (hr))
FAIL ("Failed to load font file from data!");
- return nullptr;
- }
BOOL isSupported;
DWRITE_FONT_FILE_TYPE fileType;
DWRITE_FONT_FACE_TYPE faceType;
- UINT32 numberOfFaces;
+ uint32_t numberOfFaces;
hr = fontFile->Analyze (&isSupported, &fileType, &faceType, &numberOfFaces);
- if (FAILED (hr) || !isSupported) {
+ if (FAILED (hr) || !isSupported)
FAIL ("Font file is not supported.");
- return nullptr;
- }
#undef FAIL
@@ -217,7 +213,8 @@ _hb_directwrite_shaper_face_data_destroy (hb_directwrite_shaper_face_data_t *dat
data->fontFace->Release ();
if (data->fontFile)
data->fontFile->Release ();
- if (data->dwriteFactory) {
+ if (data->dwriteFactory)
+ {
if (data->fontFileLoader)
data->dwriteFactory->UnregisterFontFileLoader (data->fontFileLoader);
data->dwriteFactory->Release ();
@@ -237,7 +234,8 @@ _hb_directwrite_shaper_face_data_destroy (hb_directwrite_shaper_face_data_t *dat
* shaper font data
*/
-struct hb_directwrite_shaper_font_data_t {
+struct hb_directwrite_shaper_font_data_t
+{
};
hb_directwrite_shaper_font_data_t *
@@ -324,9 +322,11 @@ public:
, mReadingDirection (readingDirection)
, mCurrentRun (nullptr) { };
- ~TextAnalysis () {
+ ~TextAnalysis ()
+ {
// delete runs, except mRunHead which is part of the TextAnalysis object
- for (Run *run = mRunHead.nextRun; run;) {
+ for (Run *run = mRunHead.nextRun; run;)
+ {
Run *origRun = run;
run = run->nextRun;
delete origRun;
@@ -334,7 +334,8 @@ public:
}
STDMETHODIMP GenerateResults (IDWriteTextAnalyzer* textAnalyzer,
- Run **runHead) {
+ Run **runHead)
+ {
// Analyzes the text using the script analyzer and returns
// the result as a series of runs.
@@ -350,9 +351,8 @@ public:
mCurrentRun = &mRunHead;
// Call each of the analyzers in sequence, recording their results.
- if (SUCCEEDED (hr = textAnalyzer->AnalyzeScript (this, 0, mTextLength, this))) {
+ if (SUCCEEDED (hr = textAnalyzer->AnalyzeScript (this, 0, mTextLength, this)))
*runHead = &mRunHead;
- }
return hr;
}
@@ -363,12 +363,14 @@ public:
OUT wchar_t const** textString,
OUT uint32_t* textLength)
{
- if (textPosition >= mTextLength) {
+ if (textPosition >= mTextLength)
+ {
// No text at this position, valid query though.
*textString = nullptr;
*textLength = 0;
}
- else {
+ else
+ {
*textString = mText + textPosition;
*textLength = mTextLength - textPosition;
}
@@ -379,13 +381,15 @@ public:
OUT wchar_t const** textString,
OUT uint32_t* textLength)
{
- if (textPosition == 0 || textPosition > mTextLength) {
+ if (textPosition == 0 || textPosition > mTextLength)
+ {
// Either there is no text before here (== 0), or this
// is an invalid position. The query is considered valid though.
*textString = nullptr;
*textLength = 0;
}
- else {
+ else
+ {
*textString = mText;
*textLength = textPosition;
}
@@ -458,14 +462,10 @@ protected:
// Split the tail if needed (the length remaining is less than the
// current run's size).
if (*textLength < mCurrentRun->mTextLength)
- {
SplitCurrentRun (mCurrentRun->mTextStart + *textLength);
- }
else
- {
// Just advance the current run.
mCurrentRun = mCurrentRun->nextRun;
- }
*textLength -= origRun->mTextLength;
// Return a reference to the run that was just current.
@@ -480,17 +480,14 @@ protected:
// corresponding run for the text position.
if (mCurrentRun && mCurrentRun->ContainsTextPosition (textPosition))
- {
return;
- }
- for (Run *run = &mRunHead; run; run = run->nextRun) {
+ for (Run *run = &mRunHead; run; run = run->nextRun)
if (run->ContainsTextPosition (textPosition))
{
mCurrentRun = run;
return;
}
- }
//NS_NOTREACHED ("We should always be able to find the text position in one \
// of our runs");
}
@@ -592,25 +589,23 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
textString[chars_len++] = c;
else if (unlikely (c > 0x10FFFFu))
textString[chars_len++] = 0xFFFDu;
- else {
+ else
+ {
textString[chars_len++] = 0xD800u + ((c - 0x10000u) >> 10);
textString[chars_len++] = 0xDC00u + ((c - 0x10000u) & ((1u << 10) - 1));
}
}
ALLOCATE_ARRAY (WORD, log_clusters, chars_len);
- // if (num_features)
+ /* Need log_clusters to assign features. */
+ chars_len = 0;
+ for (unsigned int i = 0; i < buffer->len; i++)
{
- /* Need log_clusters to assign features. */
- chars_len = 0;
- for (unsigned int i = 0; i < buffer->len; i++)
- {
- hb_codepoint_t c = buffer->info[i].codepoint;
- unsigned int cluster = buffer->info[i].cluster;
- log_clusters[chars_len++] = cluster;
- if (hb_in_range (c, 0x10000u, 0x10FFFFu))
- log_clusters[chars_len++] = cluster; /* Surrogates. */
- }
+ hb_codepoint_t c = buffer->info[i].codepoint;
+ unsigned int cluster = buffer->info[i].cluster;
+ log_clusters[chars_len++] = cluster;
+ if (hb_in_range (c, 0x10000u, 0x10FFFFu))
+ log_clusters[chars_len++] = cluster; /* Surrogates. */
}
// TODO: Handle TEST_DISABLE_OPTIONAL_LIGATURES
@@ -638,10 +633,7 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
} HB_STMT_END;
if (FAILED (hr))
- {
FAIL ("Analyzer failed to generate results.");
- return false;
- }
uint32_t maxGlyphCount = 3 * textLength / 2 + 16;
uint32_t glyphCount;
@@ -654,21 +646,23 @@ _hb_directwrite_shape_full (hb_shape_plan_t *shape_plan,
hb_language_to_string (buffer->props.language), 20);
}
- DWRITE_TYPOGRAPHIC_FEATURES singleFeatures;
- singleFeatures.featureCount = num_features;
+ // TODO: it does work but doesn't care about ranges
+ DWRITE_TYPOGRAPHIC_FEATURES typographic_features;
+ typographic_features.featureCount = num_features;
if (num_features)
{
- singleFeatures.features = new DWRITE_FONT_FEATURE[num_features];
+ typographic_features.features = new DWRITE_FONT_FEATURE[num_features];
for (unsigned int i = 0; i < num_features; ++i)
{
- singleFeatures.features[i].nameTag = (DWRITE_FONT_FEATURE_TAG)
+ typographic_features.features[i].nameTag = (DWRITE_FONT_FEATURE_TAG)
hb_uint32_swap (features[i].tag);
- singleFeatures.features[i].parameter = features[i].value;
+ typographic_features.features[i].parameter = features[i].value;
}
}
const DWRITE_TYPOGRAPHIC_FEATURES* dwFeatures =
- (const DWRITE_TYPOGRAPHIC_FEATURES*) &singleFeatures;
+ (const DWRITE_TYPOGRAPHIC_FEATURES*) &typographic_features;
const uint32_t featureRangeLengths[] = { textLength };
+ //
uint16_t* clusterMap = new uint16_t[textLength];
DWRITE_SHAPING_TEXT_PROPERTIES* textProperties =
@@ -693,10 +687,7 @@ retry_getglyphs:
goto retry_getglyphs;
}
if (FAILED (hr))
- {
FAIL ("Analyzer failed to get glyphs.");
- return false;
- }
float* glyphAdvances = new float[maxGlyphCount];
DWRITE_GLYPH_OFFSET* glyphOffsets = new DWRITE_GLYPH_OFFSET[maxGlyphCount];
@@ -730,10 +721,7 @@ retry_getglyphs:
glyphAdvances, glyphOffsets);
if (FAILED (hr))
- {
FAIL ("Analyzer failed to get glyph placements.");
- return false;
- }
IDWriteTextAnalyzer1* analyzer1;
analyzer->QueryInterface (&analyzer1);
@@ -748,10 +736,7 @@ retry_getglyphs:
glyphProperties, justificationOpportunities);
if (FAILED (hr))
- {
FAIL ("Analyzer failed to get justification opportunities.");
- return false;
- }
float* justifiedGlyphAdvances = new float[maxGlyphCount];
DWRITE_GLYPH_OFFSET* justifiedGlyphOffsets = new DWRITE_GLYPH_OFFSET[glyphCount];
@@ -759,18 +744,12 @@ retry_getglyphs:
glyphAdvances, glyphOffsets, justifiedGlyphAdvances, justifiedGlyphOffsets);
if (FAILED (hr))
- {
FAIL ("Analyzer failed to get justified glyph advances.");
- return false;
- }
DWRITE_SCRIPT_PROPERTIES scriptProperties;
hr = analyzer1->GetScriptProperties (runHead->mScript, &scriptProperties);
if (FAILED (hr))
- {
FAIL ("Analyzer failed to get script properties.");
- return false;
- }
uint32_t justificationCharacter = scriptProperties.justificationCharacter;
// if a script justificationCharacter is not space, it can have GetJustifiedGlyphs
@@ -801,10 +780,7 @@ retry_getglyphs:
goto retry_getjustifiedglyphs;
}
if (FAILED (hr))
- {
FAIL ("Analyzer failed to get justified glyphs.");
- return false;
- }
delete [] clusterMap;
delete [] glyphIndices;
@@ -896,7 +872,7 @@ retry_getglyphs:
delete [] glyphOffsets;
if (num_features)
- delete [] singleFeatures.features;
+ delete [] typographic_features.features;
/* Wow, done! */
return true;
More information about the HarfBuzz
mailing list