What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

CSS To Fix Font Aspect Ratio to 1:1

SgtScott

New member
Joined
Dec 3, 2023
Messages
2
Reaction score
0
HTML Coins
0
I wrote a VB.Net program that lets you load any small image and then converts that image to ASCII art as HTML. I currently write the HTML as (for example):

Code:
<html>
<head>
<body bgcolor = "#000000">
<pre><font face = "Courier New" size ="1">
<font color = "#660099">&#70;</font><font color = "#660066">&#118;</font><font color = "#660066">&#118;</font>...

and then end the file with:

Code:
...<font color = "#002B00">&#58;</font><font color = "#660066">&#118;</font><font color = "#660099">&#70;</font>
</pre>
</body>
</html>

It simply copies the color image loaded and makes a grayscale copy and then based on that value, picks an ASCII character (I have 92 characters all weighted from darkest to lightest) mapped to a gray shade value 0 to 255.

Then with the original color image I take the RGB and convert it to <font color = "#RRGGBB>&#ASC Value</font>.

and this works well EXCEPT Courier New is slightly taller that it is wide so my ASCII art looks a bit stretched. I could change my code to "squash" the image before rendering the HTML, but I wondered if instead there was a CSS statement that could make Courier New (or any fixed width font) to have a 1 to 1 aspect ratio when displayed?

Thank you
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back