From e6ee2b0dbd2b94618fea200405b41bb549537f8b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 18 Jun 2017 20:10:42 -0400 Subject: [PATCH] Some TODO elminiation (for once). One TODO got reshuffled. --- darwin/opentype.m | 1 + ui.h | 3 +++ ui_attrstr.h | 22 ++++++++++++++++------ unix/opentype.c | 1 + windows/opentype.cpp | 3 +-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/darwin/opentype.m b/darwin/opentype.m index 46bdaf19..1a2f3ab1 100644 --- a/darwin/opentype.m +++ b/darwin/opentype.m @@ -47,6 +47,7 @@ void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, c NSNumber *tn; tn = mkMapObject(mkTag(a, b, c, d)); + // documented as doing nothing if tn is not in otf->tags [otf->tags removeObjectForKey:tn]; } diff --git a/ui.h b/ui.h index 72e5eaef..1a875cab 100644 --- a/ui.h +++ b/ui.h @@ -2,6 +2,9 @@ // TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls +// TODOs +// - make getters that return whether something exists accept a NULL pointer to discard the value (and thus only return that the thing exists?) + #ifndef __LIBUI_UI_H__ #define __LIBUI_UI_H__ diff --git a/ui_attrstr.h b/ui_attrstr.h index 0024442c..835cee39 100644 --- a/ui_attrstr.h +++ b/ui_attrstr.h @@ -19,7 +19,10 @@ // layout-specific properties. typedef struct uiAttributedString uiAttributedString; -// TODO either here or above, say that only one attribute can be applied per attribute type per character +// uiAttribute specifies the types of possible attributes that can be +// applied to a uiAttributedString. For every byte in the +// uiAttributedString, at most one value of each attribute type can +// be applied. // TODO just make a separate field in uiAttributeSpec for everything? or make attribute objects opaque instead? _UI_ENUM(uiAttribute) { // uiAttributeFamily changes the font family of the text it is @@ -64,7 +67,7 @@ _UI_ENUM(uiAttribute) { // uiAttributeFeatures changes the OpenType features of the // text it is applied to. Use the Features field of uiAttributeSpec. - uiAttributeFeatures, // use Features + uiAttributeFeatures, }; _UI_ENUM(uiDrawUnderlineStyle) { @@ -124,15 +127,22 @@ _UI_EXTERN uiOpenTypeFeatures *uiOpenTypeFeaturesClone(const uiOpenTypeFeatures _UI_EXTERN void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value); // uiOpenTypeFeaturesRemove() removes the given feature tag -// and value from otf. -// TODO what happens if the tag isn't there? +// and value from otf. If the tag is not present in otf, +// uiOpenTypeFeaturesRemove() does nothing. _UI_EXTERN void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d); // uiOpenTypeFeaturesGet() determines whether the given feature // tag is present in otf. If it is, *value is set to the tag's value and // nonzero is returned. Otherwise, zero is returned. -// TODO zero-fill value unconditionally? and if so, to other functions in libui -// TODO allow NULL for value? and throughout libui? +// +// Note that if uiOpenTypeFeaturesGet() returns zero, value isn't +// changed. This is important: if a feature is not present in a +// uiOpenTypeFeatures, the feature is NOT treated as if its +// value was zero anyway. Script-specific font shaping rules and +// font-specific feature settings may use a different default value +// for a feature. You should likewise not treat a missing feature as +// having a value of zero either. Instead, a missing feature should +// be treated as having some unspecified default value. // TODO const-correct this function (can we do that given the members of the struct on some platforms being full blown objects that may or may not themselves be const-correct?) _UI_EXTERN int uiOpenTypeFeaturesGet(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value); diff --git a/unix/opentype.c b/unix/opentype.c index 79b1d93a..764da50a 100644 --- a/unix/opentype.c +++ b/unix/opentype.c @@ -56,6 +56,7 @@ void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d) { + // will just return FALSE if the tag is not in otf->tags (half-documented as such), so we can use it safely g_hash_table_remove(otf->tags, mkTag(a, b, c, d)); } diff --git a/windows/opentype.cpp b/windows/opentype.cpp index 89b5913c..8fc37175 100644 --- a/windows/opentype.cpp +++ b/windows/opentype.cpp @@ -39,10 +39,9 @@ void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char (*(otf->tags))[mktag(a, b, c, d)] = value; } -// TODO what should happen if a/b/c/d isn't defined? -// TODO what does std::map do if a/b/c/d isn't defined? void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d) { + // this will just return 0 if nothing was removed (if I'm reading the help pages I've found correctly) otf->tags->erase(mktag(a, b, c, d)); }