Code Monkey home page Code Monkey logo

Comments (2)

tocsoft avatar tocsoft commented on June 1, 2024

When the TabWidth is set to 0, any line containing a tab will be cut off following the tab.

This is a bug and I've split this out into issue #32

When the TabWidth is greater than 1, the actual drawn TabWidth will be 1 too small.

The way the library is currently setup is that tabs work as a series of Tab stops at tab width boundaries, with a minimum width of one space.

I'll layout a couple of examples to illustrate: where 'X' = 5px & space = 10px and tabwidth = 4 (measured in space widths) therefore tabs will stop every 40px.

so take the text 'x' 'x' 'x' '\t' 'x' for example based on the measurements above it would end up as 45px wide, this would breaking down to this:

  • 5px for the first x (moving us to 5px along)
  • 5px for the second x (moving us to 10px along)
  • 5px for the third x (moving us to 15px along)
  • 25px for the \t (moving us along to 40px) as tabs move >= space width but stopping at a 'tab stop'
  • 5px for last x (moving us to 45px)

now on the other hand 'x' 'x' 'x' '\t' '\t' 'x' would end up as 85px;

  • 5px for the first x (moving us to 5px along)
  • 5px for the second x (moving us to 10px along)
  • 5px for the third x (moving us to 15px along)
  • 25px for the \t (moving us along to 40px) as tabs move >= space width but stopping at a 'tab stop'
  • 40px for the \t (moving us along to 80px) moveing us one space forward then continuing forward until it hits a tab stop
  • 5px for last x (moving us to 85px)

Hope the clarifies how calculated tab widths end up being calculated.

Basically its not directly equatable of 1 tab character will always be the same exact width.

In conclusion tabs are currently working as designed (except for bugs as noted), and this tab rendering mechanism is consistent with other text rendering software, Word does it, even Notepad does.

Measuring strings starting or ending with a tab ignores those tabs.

This is a bug and I've split this out into issue #33

from fonts.

tocsoft avatar tocsoft commented on June 1, 2024

So i'm closing this and will track the other 2 issues separately

from fonts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.