Skip to content

Overlapping styles rendered wrong #274

@LexaGV

Description

@LexaGV

When you use 2+ styles over one place, first style takes precedence and all overlapped text is rendered using first style only. Obviously resulting style must be "common" style, computed from all applied ones.

Say, if we have ASP code, logical approach is to use style1 (e.g. yellow BG) for everything between <% %> and style2 (e.g. bold font) to highlight keywords inside <% %>. Then keyword will be bold font on yellow background.

In case of conflicting styles (say, two different BG), last applied should be used. Same with "bold": if first applied style had "bold" flag and second - "normal", last "normal" style should be used.

The last case shows limitation of using System.Drawing.FontStyle for styles:
Say, for text we applied style1 (which has just flag "bold") and style2 (which has just "italic"). How FCTB will compute final style: use bold+italic or clear previous bold and use just italic? Answer: both cases are legal and only programmer decides which to use. And it can be achieved only by new approach - each "alternation" of style should have additional flag "I don't care". Idea:

FCTBStyle
{
    public bool? IsBold;
    public bool? IsItalic;
}

So when you define style, you can explicitly say, what to do with conflicting styles:

IsBold = null, IsItalic = true ⇒ bold can be any value, italic must be applied
IsBold = false, IsItalic = true ⇒ bold style should be removed, italic applied

This way we can create flexible system of styles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions