• Login
Community
  • Login

Can you use separate fonts for separate documents?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 342 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    Dušan Majaković
    last edited by Oct 5, 2022, 7:14 PM

    Hi, NP++ team!

    Right now I have two documents that I’m working on:

    One uses the default “Courier New” font,

    and the other uses “Nato Sans Math” font for (as you can guess) mathematical notes which contain lots of mathematical symbols and formulas.

    Since I usually have multiple documents open in various tabs in the Notepad++ window, I’m wondering, is it possible to set a default font style for each document that I’m working on, so that I don’t have to switch back and forth between each font each time I’m done with one document, and move over to another?

    P 1 Reply Last reply Oct 5, 2022, 8:07 PM Reply Quote 0
    • P
      PeterJones @Dušan Majaković
      last edited by Oct 5, 2022, 8:07 PM

      @Dušan-Majaković ,

      Not directly. Text styling is defined by the active lexer (programming language syntax highlighting) using values from Style Configurator or UDL definition, not on a per-file basis: it’s effectively based on file type, not specific file.

      However, if your “other” file has a unique extension, or if you were otherwise willing to override the Language lexer for that file, then you could define a NatoSansMath User Defined Language (UDL): if it has a specific extension (like .math), then you can set the UDL’s extension to math , and from then on, all *.math files will open with that UDL. If you don’t have a unique extension, then you would just manually select Language > NatoSansMath for that file… and until you close the file, Notepad++ will remember the UDL applied.

      Inside that UDL definition, you could use the Default style to set the font for that language type.
      37d6b80c-df43-477e-a57f-b9530ac6e3b6-image.png
      You could also style numbers and operators differently from other text (for example, a different color) to make the mathematical operators stick out. (Please note: User Defined Language doesn’t have a concept of unicode, unfortunately, so you cannot use it to change the color of non-ASCII operators or symbols, sorry. If that’s important, ask about the workaround)

      • Online Usermanual overview of UDL: https://npp-user-manual.org/docs/user-defined-language-system/
      • Details of each UDL field: https://ivan-radic.github.io/udl-documentation/
      D 1 Reply Last reply Oct 6, 2022, 4:29 PM Reply Quote 3
      • D
        Dušan Majaković @PeterJones
        last edited by Oct 6, 2022, 4:29 PM

        @PeterJones

        Thank you for the reply, Peter!

        Renaming the math document to a .math extension is actually a brilliant idea, as I can still see human-readable text even when the extension is changed.

        Now, what I don’t know how to do is how to define NatoSansMath UDL just for this particular file extension.

        When I go to Settings > Style Configurator, I can’t see anything about defining UDL for a specific file extension.

        How exactly does one do this?

        P 1 Reply Last reply Oct 6, 2022, 5:22 PM Reply Quote 0
        • P
          PeterJones @Dušan Majaković
          last edited by Oct 6, 2022, 5:22 PM

          @Dušan-Majaković ,

          by using the Language > User Define Language > Define Your Language interface, as documented in the UDL section of the User Manual that I already linked you to.

          D 1 Reply Last reply Oct 6, 2022, 9:48 PM Reply Quote 2
          • D
            Dušan Majaković @PeterJones
            last edited by Oct 6, 2022, 9:48 PM

            @PeterJones

            Done! I finally got it to work!

            Thank you so much for the help!

            1 Reply Last reply Reply Quote 0
            3 out of 5
            • First post
              3/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors