I am trying to do some dynamic programming based on the number of characters in a sentence. Which letter of the English alphabet takes up the most pixels on the screen?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
It depends on the font. Crossed zero for example takes up considerably more than a regular one.
But if one could put up a guess, I'd go with X or B.
How about a programmatic solution?
Arial 30px in Chrome - W wins.
It also depends on the font. I did this 1 or 2 years ago with Processing and Helvetica and it is ILJTYFVCPAXUZKHSEDORGNBQMW in order of increasing pixels. The idea is to draw the text on a canvas with the font you are looking at, count the pixels, then sort with a HashMap or Dictionary.
Of course, this might not be directly relavant to your use as this calculates pixel area rather than just width. Might be a little overkill too.
A solution to calculate the widths of fonts a bit like the solution posted by xxx was posted by Alex Michael on his blog (which funnily enough linked me here).
Summary:
Original Post: http://alexmic.net/letter-pixel-count/
Code:
I know the accepted answer here is W, W is for WIN.
However, in this case, W is also for Width. The case study used employed a simple width test to examine pixels, but it was only the width, not the total pixel count. As an easy counter example, the accepted answer assumes that O and Q take up the same amount of pixels, yet they only take up the same amount of space.
Thus, W takes up the most space. But, is it all the pixels it's cracked up to be?
Let's get some empirical data. I created imgur images from the following B, M and W. I then analyzed their pixel count (see below), here are the results:
B : 114 pixels
M : 150 pixels
W : 157 pixels
Here is how I fed them into canvas and analyzed the raw pixel data from the images.