Use standard types instead Windows favourites ones
This commit is contained in:
parent
adf20ba0d1
commit
63ee9ca5d8
@ -342,16 +342,16 @@ public:
|
|||||||
// results.
|
// results.
|
||||||
struct Run
|
struct Run
|
||||||
{
|
{
|
||||||
UINT32 mTextStart; // starting text position of this run
|
uint32_t mTextStart; // starting text position of this run
|
||||||
UINT32 mTextLength; // number of contiguous code units covered
|
uint32_t mTextLength; // number of contiguous code units covered
|
||||||
UINT32 mGlyphStart; // starting glyph in the glyphs array
|
uint32_t mGlyphStart; // starting glyph in the glyphs array
|
||||||
UINT32 mGlyphCount; // number of glyphs associated with this run of
|
uint32_t mGlyphCount; // number of glyphs associated with this run of
|
||||||
// text
|
// text
|
||||||
DWRITE_SCRIPT_ANALYSIS mScript;
|
DWRITE_SCRIPT_ANALYSIS mScript;
|
||||||
UINT8 mBidiLevel;
|
uint8_t mBidiLevel;
|
||||||
bool mIsSideways;
|
bool mIsSideways;
|
||||||
|
|
||||||
inline bool ContainsTextPosition(UINT32 aTextPosition) const
|
inline bool ContainsTextPosition(uint32_t aTextPosition) const
|
||||||
{
|
{
|
||||||
return aTextPosition >= mTextStart
|
return aTextPosition >= mTextStart
|
||||||
&& aTextPosition < mTextStart + mTextLength;
|
&& aTextPosition < mTextStart + mTextLength;
|
||||||
@ -362,7 +362,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TextAnalysis(const wchar_t* text,
|
TextAnalysis(const wchar_t* text,
|
||||||
UINT32 textLength,
|
uint32_t textLength,
|
||||||
const wchar_t* localeName,
|
const wchar_t* localeName,
|
||||||
DWRITE_READING_DIRECTION readingDirection)
|
DWRITE_READING_DIRECTION readingDirection)
|
||||||
: mText(text)
|
: mText(text)
|
||||||
@ -406,9 +406,9 @@ public:
|
|||||||
|
|
||||||
// IDWriteTextAnalysisSource implementation
|
// IDWriteTextAnalysisSource implementation
|
||||||
|
|
||||||
IFACEMETHODIMP GetTextAtPosition(UINT32 textPosition,
|
IFACEMETHODIMP GetTextAtPosition(uint32_t textPosition,
|
||||||
OUT WCHAR const** textString,
|
OUT wchar_t const** textString,
|
||||||
OUT UINT32* textLength)
|
OUT uint32_t* textLength)
|
||||||
{
|
{
|
||||||
if (textPosition >= mTextLength) {
|
if (textPosition >= mTextLength) {
|
||||||
// No text at this position, valid query though.
|
// No text at this position, valid query though.
|
||||||
@ -422,9 +422,9 @@ public:
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFACEMETHODIMP GetTextBeforePosition(UINT32 textPosition,
|
IFACEMETHODIMP GetTextBeforePosition(uint32_t textPosition,
|
||||||
OUT WCHAR const** textString,
|
OUT wchar_t const** textString,
|
||||||
OUT UINT32* textLength)
|
OUT uint32_t* textLength)
|
||||||
{
|
{
|
||||||
if (textPosition == 0 || textPosition > mTextLength) {
|
if (textPosition == 0 || textPosition > mTextLength) {
|
||||||
// Either there is no text before here (== 0), or this
|
// Either there is no text before here (== 0), or this
|
||||||
@ -442,15 +442,15 @@ public:
|
|||||||
IFACEMETHODIMP_(DWRITE_READING_DIRECTION)
|
IFACEMETHODIMP_(DWRITE_READING_DIRECTION)
|
||||||
GetParagraphReadingDirection() { return mReadingDirection; }
|
GetParagraphReadingDirection() { return mReadingDirection; }
|
||||||
|
|
||||||
IFACEMETHODIMP GetLocaleName(UINT32 textPosition,
|
IFACEMETHODIMP GetLocaleName(uint32_t textPosition,
|
||||||
UINT32* textLength,
|
uint32_t* textLength,
|
||||||
WCHAR const** localeName) {
|
wchar_t const** localeName) {
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFACEMETHODIMP
|
IFACEMETHODIMP
|
||||||
GetNumberSubstitution(UINT32 textPosition,
|
GetNumberSubstitution(uint32_t textPosition,
|
||||||
OUT UINT32* textLength,
|
OUT uint32_t* textLength,
|
||||||
OUT IDWriteNumberSubstitution** numberSubstitution)
|
OUT IDWriteNumberSubstitution** numberSubstitution)
|
||||||
{
|
{
|
||||||
// We do not support number substitution.
|
// We do not support number substitution.
|
||||||
@ -463,8 +463,8 @@ public:
|
|||||||
// IDWriteTextAnalysisSink implementation
|
// IDWriteTextAnalysisSink implementation
|
||||||
|
|
||||||
IFACEMETHODIMP
|
IFACEMETHODIMP
|
||||||
SetScriptAnalysis(UINT32 textPosition,
|
SetScriptAnalysis(uint32_t textPosition,
|
||||||
UINT32 textLength,
|
uint32_t textLength,
|
||||||
DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis)
|
DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis)
|
||||||
{
|
{
|
||||||
SetCurrentRun(textPosition);
|
SetCurrentRun(textPosition);
|
||||||
@ -478,22 +478,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
IFACEMETHODIMP
|
IFACEMETHODIMP
|
||||||
SetLineBreakpoints(UINT32 textPosition,
|
SetLineBreakpoints(uint32_t textPosition,
|
||||||
UINT32 textLength,
|
uint32_t textLength,
|
||||||
const DWRITE_LINE_BREAKPOINT* lineBreakpoints) { return S_OK; }
|
const DWRITE_LINE_BREAKPOINT* lineBreakpoints) { return S_OK; }
|
||||||
|
|
||||||
IFACEMETHODIMP SetBidiLevel(UINT32 textPosition,
|
IFACEMETHODIMP SetBidiLevel(uint32_t textPosition,
|
||||||
UINT32 textLength,
|
uint32_t textLength,
|
||||||
UINT8 explicitLevel,
|
uint8_t explicitLevel,
|
||||||
UINT8 resolvedLevel) { return S_OK; }
|
uint8_t resolvedLevel) { return S_OK; }
|
||||||
|
|
||||||
IFACEMETHODIMP
|
IFACEMETHODIMP
|
||||||
SetNumberSubstitution(UINT32 textPosition,
|
SetNumberSubstitution(uint32_t textPosition,
|
||||||
UINT32 textLength,
|
uint32_t textLength,
|
||||||
IDWriteNumberSubstitution* numberSubstitution) { return S_OK; }
|
IDWriteNumberSubstitution* numberSubstitution) { return S_OK; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Run *FetchNextRun(IN OUT UINT32* textLength)
|
Run *FetchNextRun(IN OUT uint32_t* textLength)
|
||||||
{
|
{
|
||||||
// Used by the sink setters, this returns a reference to the next run.
|
// Used by the sink setters, this returns a reference to the next run.
|
||||||
// Position and length are adjusted to now point after the current run
|
// Position and length are adjusted to now point after the current run
|
||||||
@ -515,7 +515,7 @@ protected:
|
|||||||
return origRun;
|
return origRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCurrentRun(UINT32 textPosition)
|
void SetCurrentRun(uint32_t textPosition)
|
||||||
{
|
{
|
||||||
// Move the current run to the given position.
|
// Move the current run to the given position.
|
||||||
// Since the analyzers generally return results in a forward manner,
|
// Since the analyzers generally return results in a forward manner,
|
||||||
@ -536,7 +536,7 @@ protected:
|
|||||||
// of our runs");
|
// of our runs");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitCurrentRun(UINT32 splitPosition)
|
void SplitCurrentRun(uint32_t splitPosition)
|
||||||
{
|
{
|
||||||
if (!mCurrentRun) {
|
if (!mCurrentRun) {
|
||||||
//NS_ASSERTION(false, "SplitCurrentRun called without current run.");
|
//NS_ASSERTION(false, "SplitCurrentRun called without current run.");
|
||||||
@ -558,7 +558,7 @@ protected:
|
|||||||
mCurrentRun->nextRun = newRun;
|
mCurrentRun->nextRun = newRun;
|
||||||
|
|
||||||
// Adjust runs' text positions and lengths.
|
// Adjust runs' text positions and lengths.
|
||||||
UINT32 splitPoint = splitPosition - mCurrentRun->mTextStart;
|
uint32_t splitPoint = splitPosition - mCurrentRun->mTextStart;
|
||||||
newRun->mTextStart += splitPoint;
|
newRun->mTextStart += splitPoint;
|
||||||
newRun->mTextLength -= splitPoint;
|
newRun->mTextLength -= splitPoint;
|
||||||
mCurrentRun->mTextLength = splitPoint;
|
mCurrentRun->mTextLength = splitPoint;
|
||||||
@ -569,9 +569,9 @@ protected:
|
|||||||
// Input
|
// Input
|
||||||
// (weak references are fine here, since this class is a transient
|
// (weak references are fine here, since this class is a transient
|
||||||
// stack-based helper that doesn't need to copy data)
|
// stack-based helper that doesn't need to copy data)
|
||||||
UINT32 mTextLength;
|
uint32_t mTextLength;
|
||||||
const WCHAR* mText;
|
const wchar_t* mText;
|
||||||
const WCHAR* mLocaleName;
|
const wchar_t* mLocaleName;
|
||||||
DWRITE_READING_DIRECTION mReadingDirection;
|
DWRITE_READING_DIRECTION mReadingDirection;
|
||||||
|
|
||||||
// Current processing state.
|
// Current processing state.
|
||||||
@ -640,7 +640,7 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
|
|||||||
|
|
||||||
#define utf16_index() var1.u32
|
#define utf16_index() var1.u32
|
||||||
|
|
||||||
ALLOCATE_ARRAY(WCHAR, textString, buffer->len * 2);
|
ALLOCATE_ARRAY(wchar_t, textString, buffer->len * 2);
|
||||||
|
|
||||||
unsigned int chars_len = 0;
|
unsigned int chars_len = 0;
|
||||||
for (unsigned int i = 0; i < buffer->len; i++)
|
for (unsigned int i = 0; i < buffer->len; i++)
|
||||||
@ -684,7 +684,7 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
|
|||||||
* but we never attempt to shape a word longer than 64K characters
|
* but we never attempt to shape a word longer than 64K characters
|
||||||
* in a single gfxShapedWord, so we cannot exceed that limit.
|
* in a single gfxShapedWord, so we cannot exceed that limit.
|
||||||
*/
|
*/
|
||||||
UINT32 textLength = buffer->len;
|
uint32_t textLength = buffer->len;
|
||||||
|
|
||||||
TextAnalysis analysis(textString, textLength, NULL, readingDirection);
|
TextAnalysis analysis(textString, textLength, NULL, readingDirection);
|
||||||
TextAnalysis::Run *runHead;
|
TextAnalysis::Run *runHead;
|
||||||
@ -702,8 +702,8 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 maxGlyphCount = 3 * textLength / 2 + 16;
|
uint32_t maxGlyphCount = 3 * textLength / 2 + 16;
|
||||||
UINT32 glyphCount;
|
uint32_t glyphCount;
|
||||||
bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
|
bool isRightToLeft = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
|
||||||
|
|
||||||
const wchar_t localeName[20] = {0};
|
const wchar_t localeName[20] = {0};
|
||||||
@ -729,11 +729,11 @@ _hb_directwrite_shape(hb_shape_plan_t *shape_plan,
|
|||||||
}
|
}
|
||||||
const DWRITE_TYPOGRAPHIC_FEATURES* dwFeatures =
|
const DWRITE_TYPOGRAPHIC_FEATURES* dwFeatures =
|
||||||
(const DWRITE_TYPOGRAPHIC_FEATURES*) &singleFeatures;
|
(const DWRITE_TYPOGRAPHIC_FEATURES*) &singleFeatures;
|
||||||
const UINT32 featureRangeLengths[] = { textLength };
|
const uint32_t featureRangeLengths[] = { textLength };
|
||||||
|
|
||||||
retry_getglyphs:
|
retry_getglyphs:
|
||||||
UINT16* clusterMap = (UINT16*) malloc (maxGlyphCount * sizeof (UINT16));
|
uint16_t* clusterMap = (uint16_t*) malloc (maxGlyphCount * sizeof (uint16_t));
|
||||||
UINT16* glyphIndices = (UINT16*) malloc (maxGlyphCount * sizeof (UINT16));
|
uint16_t* glyphIndices = (uint16_t*) malloc (maxGlyphCount * sizeof (uint16_t));
|
||||||
DWRITE_SHAPING_TEXT_PROPERTIES* textProperties = (DWRITE_SHAPING_TEXT_PROPERTIES*)
|
DWRITE_SHAPING_TEXT_PROPERTIES* textProperties = (DWRITE_SHAPING_TEXT_PROPERTIES*)
|
||||||
malloc (maxGlyphCount * sizeof (DWRITE_SHAPING_TEXT_PROPERTIES));
|
malloc (maxGlyphCount * sizeof (DWRITE_SHAPING_TEXT_PROPERTIES));
|
||||||
DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProperties = (DWRITE_SHAPING_GLYPH_PROPERTIES*)
|
DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProperties = (DWRITE_SHAPING_GLYPH_PROPERTIES*)
|
||||||
@ -761,7 +761,7 @@ retry_getglyphs:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLOAT* glyphAdvances = (FLOAT*) malloc (maxGlyphCount * sizeof (FLOAT));
|
float* glyphAdvances = (float*) malloc (maxGlyphCount * sizeof (float));
|
||||||
DWRITE_GLYPH_OFFSET* glyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
DWRITE_GLYPH_OFFSET* glyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
||||||
malloc(maxGlyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
malloc(maxGlyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
||||||
|
|
||||||
@ -815,10 +815,10 @@ retry_getglyphs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: get lineWith from somewhere
|
// TODO: get lineWith from somewhere
|
||||||
FLOAT lineWidth = 60000;
|
float lineWidth = 60000;
|
||||||
|
|
||||||
FLOAT* justifiedGlyphAdvances =
|
float* justifiedGlyphAdvances =
|
||||||
(FLOAT*) malloc (maxGlyphCount * sizeof (FLOAT));
|
(float*) malloc (maxGlyphCount * sizeof (float));
|
||||||
DWRITE_GLYPH_OFFSET* justifiedGlyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
DWRITE_GLYPH_OFFSET* justifiedGlyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
||||||
malloc (glyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
malloc (glyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
||||||
hr = analyzer->JustifyGlyphAdvances (lineWidth, glyphCount, justificationOpportunities,
|
hr = analyzer->JustifyGlyphAdvances (lineWidth, glyphCount, justificationOpportunities,
|
||||||
@ -843,12 +843,12 @@ retry_getglyphs:
|
|||||||
if (justificationCharacter != 32)
|
if (justificationCharacter != 32)
|
||||||
{
|
{
|
||||||
retry_getjustifiedglyphs:
|
retry_getjustifiedglyphs:
|
||||||
UINT16* modifiedClusterMap = (UINT16*) malloc (maxGlyphCount * sizeof (UINT16));
|
uint16_t* modifiedClusterMap = (uint16_t*) malloc (maxGlyphCount * sizeof (uint16_t));
|
||||||
UINT16* modifiedGlyphIndices = (UINT16*) malloc (maxGlyphCount * sizeof (UINT16));
|
uint16_t* modifiedGlyphIndices = (uint16_t*) malloc (maxGlyphCount * sizeof (uint16_t));
|
||||||
FLOAT* modifiedGlyphAdvances = (FLOAT*) malloc (maxGlyphCount * sizeof (FLOAT));
|
float* modifiedGlyphAdvances = (float*) malloc (maxGlyphCount * sizeof (float));
|
||||||
DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets = (DWRITE_GLYPH_OFFSET*)
|
||||||
malloc (maxGlyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
malloc (maxGlyphCount * sizeof (DWRITE_GLYPH_OFFSET));
|
||||||
UINT32 actualGlyphsCount;
|
uint32_t actualGlyphsCount;
|
||||||
hr = analyzer->GetJustifiedGlyphs (fontFace, fontEmSize, runHead->mScript,
|
hr = analyzer->GetJustifiedGlyphs (fontFace, fontEmSize, runHead->mScript,
|
||||||
textLength, glyphCount, maxGlyphCount, clusterMap, glyphIndices,
|
textLength, glyphCount, maxGlyphCount, clusterMap, glyphIndices,
|
||||||
glyphAdvances, justifiedGlyphAdvances, justifiedGlyphOffsets,
|
glyphAdvances, justifiedGlyphAdvances, justifiedGlyphOffsets,
|
||||||
|
Loading…
Reference in New Issue
Block a user