Minor code cleanup. Not sure what to do next...
This commit is contained in:
parent
1d40ab659c
commit
1e31ef24c6
|
@ -3,27 +3,13 @@
|
||||||
|
|
||||||
// TODO pango alpha attributes turn 0 into 65535 :|
|
// TODO pango alpha attributes turn 0 into 65535 :|
|
||||||
|
|
||||||
// we need to collect all the background blocks and add them all at once
|
// TODO make this name less generic?
|
||||||
// TODO rename this struct to something that isn't exclusively foreach-ing?
|
|
||||||
struct foreachParams {
|
struct foreachParams {
|
||||||
const char *s;
|
|
||||||
PangoAttrList *attrs;
|
PangoAttrList *attrs;
|
||||||
// TODO use pango's built-in background attribute?
|
// TODO use pango's built-in background attribute?
|
||||||
GPtrArray *backgroundClosures;
|
GPtrArray *backgroundClosures;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO merge this into the main function below
|
|
||||||
static PangoAttribute *mkFeaturesAttribute(const uiOpenTypeFeatures *otf)
|
|
||||||
{
|
|
||||||
char *s;
|
|
||||||
PangoAttribute *attr;
|
|
||||||
|
|
||||||
s = otfToPangoCSSString(otf);
|
|
||||||
attr = FUTURE_pango_attr_font_features_new(s);
|
|
||||||
g_free(s);
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct closureParams {
|
struct closureParams {
|
||||||
size_t start;
|
size_t start;
|
||||||
size_t end;
|
size_t end;
|
||||||
|
@ -63,7 +49,7 @@ static GClosure *mkBackgroundClosure(size_t start, size_t end, double r, double
|
||||||
p->g = g;
|
p->g = g;
|
||||||
p->b = b;
|
p->b = b;
|
||||||
p->a = a;
|
p->a = a;
|
||||||
closure = (GClosure *) g_cclosure_new(G_CALLBACK(backgroundClosure), p, freeClosureParams);
|
closure = g_cclosure_new(G_CALLBACK(backgroundClosure), p, freeClosureParams);
|
||||||
// TODO write a specific marshaler
|
// TODO write a specific marshaler
|
||||||
// TODO or drop the closure stuff entirely
|
// TODO or drop the closure stuff entirely
|
||||||
g_closure_set_marshal(closure, g_cclosure_marshal_generic);
|
g_closure_set_marshal(closure, g_cclosure_marshal_generic);
|
||||||
|
@ -84,6 +70,7 @@ static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t
|
||||||
struct foreachParams *p = (struct foreachParams *) data;
|
struct foreachParams *p = (struct foreachParams *) data;
|
||||||
GClosure *closure;
|
GClosure *closure;
|
||||||
PangoUnderline underline;
|
PangoUnderline underline;
|
||||||
|
char *featurestr;
|
||||||
|
|
||||||
switch (spec->Type) {
|
switch (spec->Type) {
|
||||||
case uiAttributeFamily:
|
case uiAttributeFamily:
|
||||||
|
@ -168,7 +155,10 @@ static int processAttribute(uiAttributedString *s, uiAttributeSpec *spec, size_t
|
||||||
break;
|
break;
|
||||||
case uiAttributeFeatures:
|
case uiAttributeFeatures:
|
||||||
// TODO handle NULLs properly on all platforms
|
// TODO handle NULLs properly on all platforms
|
||||||
addattr(p, start, end, mkFeaturesAttribute(spec->Features));
|
featurestr = otfToPangoCSSString(spec->Features);
|
||||||
|
addattr(p, start, end,
|
||||||
|
FUTURE_pango_attr_font_features_new(featurestr));
|
||||||
|
g_free(featurestr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO complain
|
// TODO complain
|
||||||
|
@ -186,7 +176,6 @@ PangoAttrList *attrstrToPangoAttrList(uiDrawTextLayoutParams *p, GPtrArray **bac
|
||||||
{
|
{
|
||||||
struct foreachParams fep;
|
struct foreachParams fep;
|
||||||
|
|
||||||
fep.s = uiAttributedStringString(p->String);
|
|
||||||
fep.attrs = pango_attr_list_new();
|
fep.attrs = pango_attr_list_new();
|
||||||
fep.backgroundClosures = g_ptr_array_new_with_free_func(unrefClosure);
|
fep.backgroundClosures = g_ptr_array_new_with_free_func(unrefClosure);
|
||||||
uiAttributedStringForEachAttribute(p->String, processAttribute, &fep);
|
uiAttributedStringForEachAttribute(p->String, processAttribute, &fep);
|
||||||
|
|
Loading…
Reference in New Issue