Skip to content

[Feature request]: Context-aware punctuation #297

Open

Description

@mupastir

What feature are you proposing?

Is there any plans for adding context-aware punctuation?

Image

Activity

  1. bebraw commented on Feb 28, 2025

    @bebraw
    Contributor

    We discussed this issue and we would need a few examples to consider what it might look like. Here's a couple I generated using ChatGPT:

    def factorial(n: int) -> int:
        result = 1
        for i in range(1, n + 1):
            result *= i  # Multiplication (*)
        return result
    
    print(factorial(5))  # Output: 120
    const mathOps = {
        add: (a, b) => a + b,  // Addition (+)
        subtract: (a, b) => a - b,  // Subtraction (-)
        multiply: (a, b) => a * b   // Multiplication (*)
    };
    
    console.log(mathOps.add(10, 5));  // 15
    console.log(mathOps.subtract(10, 5));  // 5
    console.log(mathOps.multiply(10, 5));  // 50
    #include <stdio.h>
    
    typedef struct {
        int x;
        int y;
    } Point;
    
    void scale(Point *p, int factor) {
        p->x *= factor;  // Multiplication (*)
        p->y *= factor;  
    }
    
    int main() {
        Point p = {3, 4};
        scale(&p, 2);
        printf("Scaled Point: %d, %d\n", p.x, p.y);
        return 0;
    }
    struct Rectangle {
        width: i32,
        height: i32,
    }
    
    impl Rectangle {
        fn area(&self) -> i32 {
            self.width * self.height  // Multiplication (*)
        }
    }
    
    fn main() {
        let rect = Rectangle { width: 10, height: 5 };
        println!("Area: {}", rect.area());  // 50
    }
    package main
    
    import "fmt"
    
    func add(a, b int) int {
        return a + b  // Addition (+)
    }
    
    func main() {
        fmt.Println("Sum:", add(10, 5))
    }
  2. MarcusSterz commented on Mar 5, 2025

    @MarcusSterz

    @bebraw I would need bad vs good examples. Also a list which symbols should have a .case alternative. Right now the mathematical and relevant punctuation symbols are fine-tuned to match each other.

  3. bebraw commented on Mar 5, 2025

    @bebraw
    Contributor

    @mupastir Can you help with the research for this feature? Examples from other fonts implementing the feature well would be highly useful. Also see Marcus' notes above.

  4. mupastir commented on Mar 5, 2025

    @mupastir
    Author

    @bebraw Yeah, sure! I'll prepare some examples and post them there.

  5. mupastir commented on Mar 5, 2025

    @mupastir
    Author

    @bebraw @MarcusSterz

    What I proposed in this PR is actually what I saw in FiraCode, that's why I show only the examples I see from this font.

    Image

    As I see it, context awareness is applied to capital letters only if they stand close without any space symbols.

    Image

    But for * symbol it works another way. It sticks to the baseline when it stands before any other symbol.

    Image Image

    Let me know if I provided not relevant or not enough info.

  6. MarcusSterz commented on Mar 5, 2025

    @MarcusSterz

    @mupastir @bebraw I am sorry, I still don’t get what the issue is. We have a colon.case and the default asterisk is as big and low as in your examples.
    Please provide a list and what you wish to change regarding the current state in terms of design and behaviour.

  7. mupastir commented on Mar 10, 2025

    @mupastir
    Author

    Sorry, I'm not deep into fonts its definitions, and inner implementations. All I just suggested and as I see it symbols of colon, asterisk, plus, minus would be centered by the height of symbols surrounding them. If there are capitalized symbols around colon, colon should be centered by the height of those symbols. I attached the image to the original PR message.

  8. mupastir commented on Mar 10, 2025

    @mupastir
    Author

    If this suggestion does not align with the project’s goals, feel free to close the PR. I appreciate your time and consideration!

  9. okonet commented on Mar 10, 2025

    @okonet

    @mupastir thanks for bringing this up. We will discuss this internally and get back to you. I think we have enough information now. Thanks!

  10. bebraw commented on Mar 14, 2025

    @bebraw
    Contributor

    We discussed this in detail. It seems the behavior of : and * can be improved since those are used in combinations common in programming. It feels like + and - are rare in the combinations visible in examples (usually there's whitespace in between). Based on this, we'll look into improving spacing around : and * as per your suggestion since it feels like there's something to improve.

  11. bebraw commented on Mar 14, 2025

    @bebraw
    Contributor

    I actually found a counterpoint for -: kebab case (CC @MarcusSterz). That's used commonly in CSS.

  12. MarcusSterz commented on Apr 25, 2025

    @MarcusSterz

    @mupastir @bebraw @okonet The change from default colon/asterisk to colon.uc/astrerisk.uc (uc = uppercase) is now automated, so that it switches to .uc when the colon is neighboured by two uppercase letters. Please let me know if that would work for you?

    Image
  13. okonet commented on Apr 28, 2025

    @okonet

    Looking good! Can you take a look at - as well since it is commonly used in kebab-cased words kebab-case or KEBAB-CASE

  14. MarcusSterz commented on Apr 28, 2025

    @MarcusSterz

    Looking good! Can you take a look at - as well since it is commonly used in kebab-cased words kebab-case or KEBAB-CASE

    You want the hyphen to move up and down as well? Whats with mixed cases like Middle-Class? I am still reluctant since variants likes these also alsways create inconsistencies.

  15. okonet commented on Apr 28, 2025

    @okonet

    Yeah let's leave it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions