From bad2325323310832b17288bd883d85f2c95a4f19 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 6 Nov 2017 23:58:12 -0500 Subject: [PATCH] More attributed string API work. Of note, decided to make each type of attribute have its own field in uiAttributeSpec, to make thinking about what to do next easier (and because why not). --- checklist_attrstr | 1 + ui_attrstr.h | 38 ++++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/checklist_attrstr b/checklist_attrstr index b4b86278..14dd4580 100644 --- a/checklist_attrstr +++ b/checklist_attrstr @@ -6,3 +6,4 @@ overlapping attributes of different types do not split each other overlapping attributes of the same type but different values do split empty string is allowed empty string cannot have attributes +font family names are case-insensitive both in attributes and in descriptors diff --git a/ui_attrstr.h b/ui_attrstr.h index 3f8d9f0e..b74f7408 100644 --- a/ui_attrstr.h +++ b/ui_attrstr.h @@ -1,29 +1,25 @@ // uiAttribute specifies the types of possible attributes that can be -// applied to a uiAttributedString. For every byte in the +// applied to a uiAttributedString. For every Unicode codepoint 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 - // applied to. Use the Family field of uiAttributeSpec. - // TODO this is case-insensitive on all platforms; codify this + // applied to. Font family names are case-insensitive. Use the + // Family field of uiAttributeSpec. uiAttributeFamily, // uiAttributeSize changes the size of the text it is applied to, - // in typographical points. Use the Double field of - // uiAttributeSpec. + // in typographical points. Use the Size field of uiAttributeSpec. uiAttributeSize, // uiAttributeWeight changes the weight of the text it is applied - // to. Use the Value field of uiAttributeSpec and the - // uiDrawTextWeight constants. + // to. Use the Weight field of uiAttributeSpec. uiAttributeWeight, // uiAttributeItalic changes the italicness of the text it is applied - // to. Use the Value field of uiAttributeSpec and the - // uiDrawTextItalic constants. + // to. Use the Italic field of uiAttributeSpec. uiAttributeItalic, // uiAttributeStretch changes the stretch of the text it is applied - // to. Use the Value field of uiAttributeSpec and the - // uiDrawTextStretch constants. + // to. Use the Stretch field of uiAttributeSpec. uiAttributeStretch, // uiAttributeColor changes the color of the text it is applied to. // Use the R, G, B, and A fields of uiAttributeSpec. @@ -33,16 +29,18 @@ _UI_ENUM(uiAttribute) { uiAttributeBackground, // uiAttributeUnderline changes the underline style of the text - // it is applied to. Use the Value field of uiAttributeSpec and the - // uiDrawUnderlineStyle constants. + // it is applied to. Use the UnderlineStyle field of + // uiAttributeSpec. uiAttributeUnderline, // uiAttributeUnderlineColor changes the color of any underline // on the text it is applied to, regardless of the style. Use the - // Value field of uiAttributeSpec and the uiDrawUnderlineColor - // constants (refer to its documentation for more information). + // UnderlineColor field of uiAttributeSpec, and also the R, G, B, + // and A fields if specifying uiDrawUnderlineColorCustom. // // If an underline style is applied but no underline color is - // specified, the text color is used instead. + // specified, the text color is used instead. If an underline color + // is specified without an underline style, the underline color + // attribute is ignored, but not elided. uiAttributeUnderlineColor, // uiAttributeFeatures changes the OpenType features of the @@ -146,12 +144,16 @@ typedef struct uiAttributeSpec uiAttributeSpec; struct uiAttributeSpec { uiAttribute Type; const char *Family; - uintptr_t Value; - double Double; + double Size; + uiDrawTextWeight Weight; + uiDrawTextItalic Italic; + uiDrawTextStretch Stretch; double R; double G; double B; double A; + uiDrawUnderlineStyle UnderlineStyle; + uiDrawUnderlineColor UnderlineColor; const uiOpenTypeFeatures *Features; };