Skip to content

🐞 Line number font is incorrect #58

Description

@austincondiff

The line number font does not align with Xcode.

image

Left: Xcode | Right: CodeEdit

The font needs to be sans-serif, narrower, with the color less prominent.

Activity

  1. lukepistrol commented on Oct 3, 2022

    @lukepistrol
    Member

    Just want to leave this here. Did some research a while back and this might help:

    private var lineGutterFont: NSFont {
        let fontSize: Double = 10
    
        // TODO: calculate the font size depending on the editors font size.
        let font = NSFont.monospacedSystemFont(ofSize: fontSize, weight: .medium)
    
        let alt0NoSlash: [NSFontDescriptor.FeatureKey: Int] = [
            .selectorIdentifier: 6,
            .typeIdentifier: kStylisticAlternativesType,
        ]
    
        let alt1NoSerif: [NSFontDescriptor.FeatureKey: Int] = [
            .selectorIdentifier: 8,
            .typeIdentifier: kStylisticAlternativesType,
        ]
    
        let descriptor = font.fontDescriptor.addingAttributes([.featureSettings: [alt0NoSlash, alt1NoSerif]])
    
        return NSFont(descriptor: descriptor, size: 0) ?? font
    }
  2. austincondiff commented on Oct 3, 2022

    @austincondiff
    CollaboratorAuthor

    That gets me the alternate characters like the open 4 however I still need to be able to reduce the width and tracking. Any idea how I might do that?

  3. lukepistrol commented on Oct 3, 2022

    @lukepistrol
    Member

    That gets me the alternate characters like the open 4 however I still need to be able to reduce the width and tracking. Any idea how I might do that?

    Maybe something here

  4. ben-p-commits commented on Jan 4, 2023

    @ben-p-commits
    Contributor

    @austincondiff, @lukepistrol - I believe the font you're looking for is actually sneakily bundled into Xcode.

    take a look in: /Applications/Xcode.app/Contents/SharedFrameworks/DVTUserInterfaceKit.framework/Versions/A/Resources/Fonts

    and say hello to this little guy:
    XcodeDigits-regular.ttf

    image

    I would guess that it's proprietary.

  5. austincondiff commented on Jan 5, 2023

    @austincondiff
    CollaboratorAuthor

    I am aware of Xcode Digits after digging through the app contents. I have thought about sneaking it in, but probably not as I think you are right in that it might be proprietary (not clear if it is or isn't). I think we can get a look like this with the SF variable font (not sure if we can use it now or if we need to wait).

  6. ben-p-commits commented on Jan 6, 2023

    @ben-p-commits
    Contributor

    Looks like variable fonts are only available in OS 13+...

    https://developer.apple.com/documentation/appkit/nsfont/width?changes=latest_3_5_2

  7. austincondiff commented on Jan 6, 2023

    @austincondiff
    CollaboratorAuthor

    We will be using ExtensionKit and the new form style in Settings. The though it once we are out of beta, 13 will be standard by that point. So I'd say let's try to achieve the same look with variable fonts!

  8. austincondiff commented on Feb 16, 2023

    @austincondiff
    CollaboratorAuthor

    @ben-p-commits we will be increasing our minimum target to macOS 13 if you wanted to take a stab at doing this via variable fonts.

  9. moved this from 🆕 New to 📋 Todo in CodeEdit Projecton Feb 16, 2023
  10. ben-p-commits commented on Feb 17, 2023

    @ben-p-commits
    Contributor
  11. 2 remaining items

  12. austincondiff commented on Mar 16, 2023

    @austincondiff
    CollaboratorAuthor

    @Eliulm would you like to try to include this in your PR (#163) or should we tackle this later?

    If so let me know. You might look at variable fonts as mentioned.

  13. Eliulm commented on Mar 16, 2023

    @Eliulm
    Contributor

    @austincondiff Yeah, I will see what I can do.

  14. austincondiff commented on Mar 17, 2023

    @austincondiff
    CollaboratorAuthor

    @Eliulm it looks like #163 was merged. Feel free to open a separate PR.

  15. Eliulm commented on Mar 18, 2023

    @Eliulm
    Contributor

    So I looked into it and found that apple only ships the SF Pro font as a variable font. This means that it is the only font where I can adjust the glyph width, as far as I know. However, the problem with that font is, that It does not have the open four:
    image
    The SF Mono font has the open four, but the problem there is, as you pointed out before, that the glyphs are a bit wider than the Xcode digits font:
    Screenshot 2023-03-18 at 13 58 49
    Screenshot 2023-03-18 at 14 01 25
    As of now, I do not know, how I could change that :/

  16. austincondiff commented on Mar 18, 2023

    @austincondiff
    CollaboratorAuthor

    The open 4 is an alternate character.

    Screen.Recording.2023-03-18.at.11.55.11.AM.mov

    I forget how, but there is a way to do this in Swift.

  17. Eliulm commented on Mar 21, 2023

    @Eliulm
    Contributor

    I have found the stylistic set, that uses the open four. However, it also uses zero with a slash. I have tried all other stylistic sets, but none have the zero with a slash and the open four at the same time. This is how it currently looks like now:
    (Xcode left, CE right)
    ruler_comparison
    I also made the ruler font size dependent on the text font size:

    var rulerFont: NSFont {
            let fontSize: Double = (font.pointSize - 1) + 0.7 // 11.7 @ 12font and 1,7 lineheight
            let fontAdvance: Double = font.pointSize * 0.49 + 0.6
            let fontWeight = NSFont.Weight(rawValue: 0.0005)
            let fontWidth = NSFont.Width(rawValue: -0.13)
    
            let font = NSFont.systemFont(ofSize: fontSize, weight: fontWeight, width: fontWidth)
    
            /// Set the 4 to open four and alter the shape of 6 and 9
            let alt469: [NSFontDescriptor.FeatureKey: Int] = [
                .selectorIdentifier: 12,
                .typeIdentifier: kStylisticAlternativesType
            ]
    
            /// Make all digits monospaced
            let monoSpaceDigits: [NSFontDescriptor.FeatureKey: Int] = [
                .selectorIdentifier: 0,
                .typeIdentifier: kNumberSpacingType
            ]
    
            let features = [alt469, monoSpaceDigits]
            let descriptor = font.fontDescriptor.addingAttributes([.featureSettings: features, .fixedAdvance: fontAdvance])
            return NSFont(descriptor: descriptor, size: 0) ?? font
        }
  18. thecoolwinter commented on Mar 22, 2023

    @thecoolwinter
    Collaborator

    @Eliulm It looks like your alt469 is enabling the high legibility setting (kStylisticAltSixOnSelector = 12) which enables the slashed 0. You'll have to add the alt 4 and alt 6 and 9 separately using their respective keys:

    let alt4: [NSFontDescriptor.FeatureKey: Int] = [
        .selectorIdentifier: kStylisticAltOneOnSelector,
        .typeIdentifier: kStylisticAlternativesType
    ]
    
    let alt6and9: [NSFontDescriptor.FeatureKey: Int] = [
        .selectorIdentifier: kStylisticAltTwoOnSelector,
        .typeIdentifier: kStylisticAlternativesType
    ]

    Left: Xcode, Right: CE
    Screenshot 2023-03-22 at 1 26 50 PM

  19. Eliulm commented on Mar 22, 2023

    @Eliulm
    Contributor

    @thecoolwinter Awesome, thank you!

  20. austincondiff commented on Mar 26, 2023

    @austincondiff
    CollaboratorAuthor

    @Eliulm how are we looking with this?

  21. Eliulm commented on Mar 26, 2023

    @Eliulm
    Contributor

    Done, going to create a PR soon

  22. moved this from 🏃‍♂️ In Progress to 🏁 Complete in CodeEdit Projecton Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

UIbugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions