[dwrite] Remove ifdefs without breaking execution on old Windows versions
This commit is contained in:
parent
6b861dbd8b
commit
f3f0ea980a
|
@ -25,11 +25,7 @@
|
|||
#define HB_SHAPER directwrite
|
||||
#include "hb-shaper-impl-private.hh"
|
||||
|
||||
#ifndef HB_DIRECTWRITE_EXPERIMENTAL_JUSTIFICATION
|
||||
#include <DWrite.h>
|
||||
#else
|
||||
#include <DWrite_1.h>
|
||||
#endif
|
||||
|
||||
#include "hb-directwrite.h"
|
||||
|
||||
|
@ -156,7 +152,6 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face)
|
|||
(IUnknown**) &dwriteFactory
|
||||
);
|
||||
|
||||
|
||||
HRESULT hr;
|
||||
hb_blob_t* blob = hb_face_reference_blob (face);
|
||||
IDWriteFontFileStream *fontFileStream = new DWriteFontFileStream (
|
||||
|
@ -377,7 +372,8 @@ public:
|
|||
|
||||
IFACEMETHODIMP GetLocaleName(uint32_t textPosition,
|
||||
uint32_t* textLength,
|
||||
wchar_t const** localeName) {
|
||||
wchar_t const** localeName)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -402,7 +398,8 @@ public:
|
|||
{
|
||||
SetCurrentRun(textPosition);
|
||||
SplitCurrentRun(textPosition);
|
||||
while (textLength > 0) {
|
||||
while (textLength > 0)
|
||||
{
|
||||
Run *run = FetchNextRun(&textLength);
|
||||
run->mScript = *scriptAnalysis;
|
||||
}
|
||||
|
@ -435,10 +432,12 @@ protected:
|
|||
Run *origRun = mCurrentRun;
|
||||
// Split the tail if needed (the length remaining is less than the
|
||||
// current run's size).
|
||||
if (*textLength < mCurrentRun->mTextLength) {
|
||||
if (*textLength < mCurrentRun->mTextLength)
|
||||
{
|
||||
SplitCurrentRun (mCurrentRun->mTextStart + *textLength);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// Just advance the current run.
|
||||
mCurrentRun = mCurrentRun->nextRun;
|
||||
}
|
||||
|
@ -455,12 +454,14 @@ protected:
|
|||
// this will usually just return early. If not, find the
|
||||
// corresponding run for the text position.
|
||||
|
||||
if (mCurrentRun && mCurrentRun->ContainsTextPosition(textPosition)) {
|
||||
if (mCurrentRun && mCurrentRun->ContainsTextPosition (textPosition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Run *run = &mRunHead; run; run = run->nextRun) {
|
||||
if (run->ContainsTextPosition(textPosition)) {
|
||||
if (run->ContainsTextPosition (textPosition))
|
||||
{
|
||||
mCurrentRun = run;
|
||||
return;
|
||||
}
|
||||
|
@ -471,13 +472,15 @@ protected:
|
|||
|
||||
void SplitCurrentRun(uint32_t splitPosition)
|
||||
{
|
||||
if (!mCurrentRun) {
|
||||
if (!mCurrentRun)
|
||||
{
|
||||
//NS_ASSERTION(false, "SplitCurrentRun called without current run.");
|
||||
// Shouldn't be calling this when no current run is set!
|
||||
return;
|
||||
}
|
||||
// Split the current run.
|
||||
if (splitPosition <= mCurrentRun->mTextStart) {
|
||||
if (splitPosition <= mCurrentRun->mTextStart)
|
||||
{
|
||||
// No need to split, already the start of a run
|
||||
// or before it. Usually the first.
|
||||
return;
|
||||
|
@ -536,14 +539,8 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
|
|||
IDWriteFactory *dwriteFactory = face_data->dwriteFactory;
|
||||
IDWriteFontFace *fontFace = face_data->fontFace;
|
||||
|
||||
#ifndef HB_DIRECTWRITE_EXPERIMENTAL_JUSTIFICATION
|
||||
IDWriteTextAnalyzer* analyzer;
|
||||
dwriteFactory->CreateTextAnalyzer(&analyzer);
|
||||
#else
|
||||
IDWriteTextAnalyzer* analyzer0;
|
||||
dwriteFactory->CreateTextAnalyzer (&analyzer0);
|
||||
IDWriteTextAnalyzer1* analyzer = (IDWriteTextAnalyzer1*) analyzer0;
|
||||
#endif
|
||||
|
||||
unsigned int scratch_size;
|
||||
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
|
@ -717,12 +714,19 @@ retry_getglyphs:
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef HB_DIRECTWRITE_EXPERIMENTAL_JUSTIFICATION
|
||||
// TODO: get lineWith from somewhere
|
||||
float lineWidth = 0;
|
||||
|
||||
IDWriteTextAnalyzer1* analyzer1;
|
||||
analyzer->QueryInterface (&analyzer1);
|
||||
|
||||
if (analyzer1 && lineWidth)
|
||||
{
|
||||
|
||||
DWRITE_JUSTIFICATION_OPPORTUNITY* justificationOpportunities =
|
||||
(DWRITE_JUSTIFICATION_OPPORTUNITY*)
|
||||
malloc (maxGlyphCount * sizeof (DWRITE_JUSTIFICATION_OPPORTUNITY));
|
||||
hr = analyzer->GetJustificationOpportunities (fontFace, fontEmSize,
|
||||
hr = analyzer1->GetJustificationOpportunities (fontFace, fontEmSize,
|
||||
runHead->mScript, textLength, glyphCount, textString, clusterMap,
|
||||
glyphProperties, justificationOpportunities);
|
||||
|
||||
|
@ -732,14 +736,11 @@ retry_getglyphs:
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: get lineWith from somewhere
|
||||
float lineWidth = 60000;
|
||||
|
||||
float* justifiedGlyphAdvances =
|
||||
(float*) malloc (maxGlyphCount * sizeof (float));
|
||||
DWRITE_GLYPH_OFFSET* justifiedGlyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
||||
malloc (glyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
||||
hr = analyzer->JustifyGlyphAdvances (lineWidth, glyphCount, justificationOpportunities,
|
||||
hr = analyzer1->JustifyGlyphAdvances (lineWidth, glyphCount, justificationOpportunities,
|
||||
glyphAdvances, glyphOffsets, justifiedGlyphAdvances, justifiedGlyphOffsets);
|
||||
|
||||
if (FAILED (hr))
|
||||
|
@ -749,7 +750,7 @@ retry_getglyphs:
|
|||
}
|
||||
|
||||
DWRITE_SCRIPT_PROPERTIES scriptProperties;
|
||||
hr = analyzer->GetScriptProperties (runHead->mScript, &scriptProperties);
|
||||
hr = analyzer1->GetScriptProperties (runHead->mScript, &scriptProperties);
|
||||
if (FAILED (hr))
|
||||
{
|
||||
FAIL("Analyzer failed to get script properties.");
|
||||
|
@ -767,7 +768,7 @@ retry_getjustifiedglyphs:
|
|||
DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
||||
malloc (maxGlyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
||||
uint32_t actualGlyphsCount;
|
||||
hr = analyzer->GetJustifiedGlyphs (fontFace, fontEmSize, runHead->mScript,
|
||||
hr = analyzer1->GetJustifiedGlyphs (fontFace, fontEmSize, runHead->mScript,
|
||||
textLength, glyphCount, maxGlyphCount, clusterMap, glyphIndices,
|
||||
glyphAdvances, justifiedGlyphAdvances, justifiedGlyphOffsets,
|
||||
glyphProperties, &actualGlyphsCount, modifiedClusterMap, modifiedGlyphIndices,
|
||||
|
@ -816,7 +817,7 @@ retry_getjustifiedglyphs:
|
|||
|
||||
free (justificationOpportunities);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Ok, we've got everything we need, now compose output buffer,
|
||||
* very, *very*, carefully! */
|
||||
|
|
Loading…
Reference in New Issue