Git Product home page Git Product logo

Comments (5)

ArchangeGabriel avatar ArchangeGabriel commented on August 10, 2024

Duplicate: #182

from umatrix.

levicki avatar levicki commented on August 10, 2024

Which is a duplicate of #46, an almost four year old issue. Is it impossible to fix?

I see Raymond's comment about browser rendering the text and uMatrix not knowing it will be cut, but it seems to be possible to check the text width in pixels by using invisible DIV:

https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript

I am not sure how much that would slow the rendering though?

from umatrix.

theWalkingDuck avatar theWalkingDuck commented on August 10, 2024

A clean solution would be adding a title attribute whenever the host name exceeds a certain length.

<div title="bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com" class="matCell ....">
	<b>bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com</b> 
</div>

from umatrix.

uBlock-user avatar uBlock-user commented on August 10, 2024

gorhill/httpswitchboard#133 (comment)

from umatrix.

levicki avatar levicki commented on August 10, 2024

Well it turns out that in HTML5 you can use canvas to measure text width:

function getTextWidth(text, font) {
    // if given, use cached canvas for better performance
    // else, create new canvas
    var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
    var context = canvas.getContext("2d");
    context.font = font;
    var metrics = context.measureText(text);
    return metrics.width;
};
...
getTextWidth("bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com", "bold 12pt arial");

This shouldn't slow down the popup, @gorhill what do you think Raymond?

from umatrix.

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.