And adjusted the Windows attrstr.cpp to boot. Now to rewrite the example and test.
This commit is contained in:
parent
4e6ccc05f1
commit
2f73df09e3
|
@ -32,6 +32,7 @@ _UI_ENUM(uiAttribute) {
|
||||||
// TODO document that the color in the case we don't specify it is the text color
|
// TODO document that the color in the case we don't specify it is the text color
|
||||||
uiAttributeUnderlineColor, // enum uiDrawUnderlineColor
|
uiAttributeUnderlineColor, // enum uiDrawUnderlineColor
|
||||||
|
|
||||||
|
// TODO note that for the purpose of uiAttributedString two sets of features are only the same (and thus their attributes are merged) only if the pointers are the same; whether the tag sets are the same only become relevant to uiDrawTextLayout
|
||||||
uiAttributeFeatures, // object of type uiOpenTypeFeatures
|
uiAttributeFeatures, // object of type uiOpenTypeFeatures
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
#include "uipriv_windows.hpp"
|
#include "uipriv_windows.hpp"
|
||||||
#include "draw.hpp"
|
#include "draw.hpp"
|
||||||
|
|
||||||
|
// TODO this whole file needs cleanup
|
||||||
|
|
||||||
// we need to combine color and underline style into one unit for IDWriteLayout::SetDrawingEffect()
|
// we need to combine color and underline style into one unit for IDWriteLayout::SetDrawingEffect()
|
||||||
// we also need to collect all the OpenType features and background blocks and add them all at once
|
// we also need to collect all the OpenType features and background blocks and add them all at once
|
||||||
// TODO(TODO does not seem to apply here) this is the wrong approach; it causes Pango to end runs early, meaning attributes like the ligature attributes never get applied properly
|
// TODO(TODO does not seem to apply here?) this is the wrong approach; it causes Pango to end runs early, meaning attributes like the ligature attributes never get applied properly
|
||||||
// TODO contextual alternates override ligatures?
|
// TODO contextual alternates override ligatures?
|
||||||
// TODO rename this struct to something that isn't exclusively foreach-ing?
|
// TODO rename this struct to something that isn't exclusively foreach-ing?
|
||||||
struct foreachParams {
|
struct foreachParams {
|
||||||
|
@ -38,25 +40,22 @@ static void ensureEffectsInRange(struct foreachParams *p, size_t start, size_t e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ensureFeaturesInRange(struct foreachParams *p, size_t start, size_t end)
|
static void setFeaturesInRange(struct foreachParams *p, size_t start, size_t end, uiOpenTypeFeatures *otf)
|
||||||
{
|
{
|
||||||
|
IDWriteTypography *dt;
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t *key;
|
|
||||||
IDWriteTypography *t;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
|
dt = otfToDirectWrite(otf);
|
||||||
for (i = start; i < end; i++) {
|
for (i = start; i < end; i++) {
|
||||||
// don't create redundant entries; see below
|
// don't create redundant entries; see below
|
||||||
|
// TODO explain this more clearly (surrogate pairs)
|
||||||
if (!isCodepointStart(p->s[i]))
|
if (!isCodepointStart(p->s[i]))
|
||||||
continue;
|
continue;
|
||||||
t = (*(p->features))[i];
|
dt->AddRef();
|
||||||
if (t != NULL)
|
(*(p->features))[i] = dt;
|
||||||
continue;
|
|
||||||
hr = dwfactory->CreateTypography(&t);
|
|
||||||
if (hr != S_OK)
|
|
||||||
logHRESULT(L"error creating IDWriteTypography", hr);
|
|
||||||
(*(p->features))[i] = t;
|
|
||||||
}
|
}
|
||||||
|
// and release the initial reference
|
||||||
|
dt->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
static backgroundFunc mkBackgroundFunc(size_t start, size_t end, double r, double g, double b, double a)
|
static backgroundFunc mkBackgroundFunc(size_t start, size_t end, double r, double g, double b, double a)
|
||||||
|
@ -73,38 +72,6 @@ static backgroundFunc mkBackgroundFunc(size_t start, size_t end, double r, doubl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct otParam {
|
|
||||||
struct foreachParams *p;
|
|
||||||
size_t start;
|
|
||||||
size_t end;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void doOpenType(const char *featureTag, uint32_t param, void *data)
|
|
||||||
{
|
|
||||||
struct otParam *p = (struct otParam *) data;
|
|
||||||
size_t i;
|
|
||||||
IDWriteTypography *t;
|
|
||||||
DWRITE_FONT_FEATURE feature;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
feature.nameTag = (DWRITE_FONT_FEATURE_TAG) DWRITE_MAKE_OPENTYPE_TAG(
|
|
||||||
featureTag[0],
|
|
||||||
featureTag[1],
|
|
||||||
featureTag[2],
|
|
||||||
featureTag[3]);
|
|
||||||
feature.parameter = param;
|
|
||||||
ensureFeaturesInRange(p->p, p->start, p->end);
|
|
||||||
for (i = p->start; i < p->end; i++) {
|
|
||||||
// don't use redundant entries; see below
|
|
||||||
if (!isCodepointStart(p->p->s[i]))
|
|
||||||
continue;
|
|
||||||
t = (*(p->p->features))[i];
|
|
||||||
hr = t->AddFontFeature(feature);
|
|
||||||
if (hr != S_OK)
|
|
||||||
logHRESULT(L"error adding feature to IDWriteTypography", hr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t start, size_t end, void *data)
|
static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t start, size_t end, void *data)
|
||||||
{
|
{
|
||||||
struct foreachParams *p = (struct foreachParams *) data;
|
struct foreachParams *p = (struct foreachParams *) data;
|
||||||
|
@ -112,7 +79,6 @@ static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t
|
||||||
WCHAR *wfamily;
|
WCHAR *wfamily;
|
||||||
size_t ostart, oend;
|
size_t ostart, oend;
|
||||||
BOOL hasUnderline;
|
BOOL hasUnderline;
|
||||||
struct otParam op;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
ostart = start;
|
ostart = start;
|
||||||
|
@ -229,14 +195,12 @@ static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
cae uiAttributeOpenTypeFeatures:
|
||||||
// handle typographic features
|
setFeaturesInRange(p, start, end, (uiOpenTypeFeatures *) (spec->Value));
|
||||||
op.p = p;
|
|
||||||
op.start = start;
|
|
||||||
op.end = end;
|
|
||||||
// TODO check if unhandled and complain
|
|
||||||
specToOpenType(spec, doOpenType, &op);
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
// TODO complain
|
||||||
|
;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ void uiOpenTypeFeaturesForEach(uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO wait, is this function even necessary? how do we unify attributes??
|
|
||||||
int uiOpenTypeFeaturesEqual(uiOpenTypeFeatures *a, uiOpenTypeFeatures *b)
|
int uiOpenTypeFeaturesEqual(uiOpenTypeFeatures *a, uiOpenTypeFeatures *b)
|
||||||
{
|
{
|
||||||
// TODO make sure this is correct
|
// TODO make sure this is correct
|
||||||
|
|
Loading…
Reference in New Issue