Commit Graph

754 Commits

Author SHA1 Message Date
Isaiah Odhner
601e50d5b5 Give error if you try to load HTML/SVG
- DRY: Make decode_based_on_file_extension use format_from_extension.
- If you try to load .html, .htm, .svg, (or ._rich_console_markup) file,
  show an error instead of loading as text. The text would be much
  larger than a document you saved in this format, and it wouldn't give
  you what you expect, unless you're wanting to load an arbitrary text
  file for viewing, and for some reason choose this program to do it.
2023-05-17 00:57:23 -04:00
Isaiah Odhner
259ce5f311 Remove redundant assignment 2023-05-17 00:30:55 -04:00
Isaiah Odhner
51125cc08a Improve documentation of FIGletFontWriter 2023-05-17 00:26:59 -04:00
Isaiah Odhner
6316513cd3 Document Layout enum values 2023-05-17 00:11:58 -04:00
Isaiah Odhner
97bcdbc344 Add validation to FIGletFontWriter 2023-05-16 23:53:45 -04:00
Isaiah Odhner
4589d9a147 Clarify _fixFigChars with comments
Within the span of like a day I forgot that FIGlet fonts can be
proportional and came back to this code and was confused why charWidth
needs to be a dictionary. Well it doesn't NEED to be, it could be
implemented differently, for instance by fixing the height first,
it wouldn't need to calculate a number of spaces for the blank lines —
but how it's implemented, the width fixup could be disabled, and the
height fixup would still work. So even though the code would be a little
simpler, I'm not sure it would be better that way.
2023-05-16 23:53:45 -04:00
Isaiah Odhner
ca5a51bb6c Dissolve blankLines function 2023-05-16 23:45:02 -04:00
Isaiah Odhner
a833fc3be8 Dissolve spacePad function 2023-05-16 23:45:02 -04:00
Isaiah Odhner
33aa786d9f Mark missed method as private 2023-05-16 23:45:02 -04:00
Isaiah Odhner
425a15293c Use an enum for layout options 2023-05-16 23:45:02 -04:00
Isaiah Odhner
e17aeae948 Move license text and add dunders 2023-05-16 22:18:56 -04:00
Isaiah Odhner
323503884f Move FIGletFontWriter to a file 2023-05-16 20:48:53 -04:00
Isaiah Odhner
8c69e5a8ef Add MIT license to FIGletFontWriter
I obtained permission from the author over email :)

Now I can go ahead and merge this code in.
2023-05-16 20:45:09 -04:00
Isaiah Odhner
7f6a6211ad Add Open Font License to NanoTiny 2023-05-16 20:14:18 -04:00
Isaiah Odhner
a4c0fd7546 Clarify docstring 2023-05-16 20:14:18 -04:00
Isaiah Odhner
f00bf63fed Ignore .flf files for spell checking (even though there's no issues) 2023-05-16 20:14:18 -04:00
Isaiah Odhner
6d1b864865 Remove simplistic text format font files 2023-05-16 20:14:18 -04:00
Isaiah Odhner
6c3c34d3ac Move font files to folder 2023-05-16 20:14:18 -04:00
Isaiah Odhner
b74914e841 Don't pass parameters that are auto-calculated 2023-05-16 20:14:18 -04:00
Isaiah Odhner
a65192d49c Make all parameters of FIGletFontWriter() optional 2023-05-16 20:14:18 -04:00
Isaiah Odhner
93ef354ec6 Remove fontName parameter, since it's unused 2023-05-16 20:14:18 -04:00
Isaiah Odhner
78d0c5fae7 Add version number to font comments 2023-05-16 20:14:18 -04:00
Isaiah Odhner
13e59cacc1 Improve NanoTiny FIGlet fonts for standalone usage 2023-05-16 20:14:18 -04:00
Isaiah Odhner
27df15487e Mark methods as private 2023-05-16 20:14:17 -04:00
Isaiah Odhner
e2c5fc9af5 Add docstrings to FIGletFontWriter 2023-05-16 20:14:17 -04:00
Isaiah Odhner
f89a2353ec Minimize vRule list length 2023-05-16 20:14:17 -04:00
Isaiah Odhner
838fb5d540 Make caseInsensitive a parameter 2023-05-16 20:14:17 -04:00
Isaiah Odhner
e1245aa9e9 Load FIGlet font format 2023-05-16 20:14:17 -04:00
Isaiah Odhner
8b6a1586ef Remove irrelevant code 2023-05-16 20:14:00 -04:00
Isaiah Odhner
024120bc42 Generate FIGlet fonts of NanoTiny 2023-05-16 20:14:00 -04:00
Isaiah Odhner
a1365d1a32 Delete VS Code workspace, as it's no longer helpful to me
I created the workspace in order to be able to quickly search within
the textual library as easily as my own code, but now that I'm using
a virtual environment, I can search within all my dependencies easily,
and they're lower priority, being in a subfolder, which is what I want.
It was annoying when typing "README" and the top result being
"richreadme.md" from textual. So this is a much improved situation!
2023-05-16 15:29:22 -04:00
Isaiah Odhner
14ba281ec3 Add a command to view all sample files 2023-05-16 15:19:23 -04:00
Isaiah Odhner
400c6b4251 Automatically add .ans file extension when bare filename is entered
This applies to Save As and Copy To dialogs, but not the CLI.
2023-05-16 14:43:01 -04:00
Isaiah Odhner
cdf30c49f9 Fix 103 type checker errors by annotating height (and not width) 2023-05-16 14:43:01 -04:00
Isaiah Odhner
e045e6e9f9 Handle backup files (*~) when guessing format from file extension 2023-05-16 14:42:23 -04:00
Isaiah Odhner
9f9974fc48 Generalize --recode-samples to look for files of all types, recursively 2023-05-16 14:42:23 -04:00
Isaiah Odhner
62e313c2db Ignore temporary backup files (*~) 2023-05-16 14:35:00 -04:00
Isaiah Odhner
1a9c079f7e Use format IDs for custom formats; show "Unknown file extension" instead of assuming ANSI 2023-05-16 14:35:00 -04:00
Isaiah Odhner
f5d97912b6 Design transparent/opaque options UI ANSI art
This is a first draft (or first 13 versions) of an ANSI art rendition of
MS Paint's transparent/opaque option selector used for the Select and
Text tools.

A somewhat silly smattering of notes:

- Emoji representation: 🛢️🔴🧊 or 🛢️🔴🟩
- More symbols considered (and some used):
  ⛀⛁⛃🛢️⬬
  ▰𝄰ᐟ⸍⸝🧊
  ╭╮🔴⏺◖◗
  ╰╯
- The red circle seems really unreliable so I don't think I can use it.
- Overlapping the red circle/sphere object is hard to represent!
- I managed to get something fairly legible in Ubuntu's terminal,
  not so much in VS Code. VS Code is harder; I might've modified some
  settings, I don't know, but it doesn't handle semigraphics as well,
  at least not on my computer. But...
- At least if you've used MS Paint before, you can recognize the general
  color/shape profile of the icons, if not parse out what the icons are
  meant to represent if you'd never looked closely at them before.
- I'm not sure if v12 or v13 is better. I moved the right border to the
  right a bit by making it Braille, but should the corners extend
  further right then (with two dots), or mirror the left border by using
  a single dot Braille character?
2023-05-16 02:47:32 -04:00
Isaiah Odhner
004700ad57 Add more unicode alternatives 2023-05-16 02:30:10 -04:00
Isaiah Odhner
79cbeb9e30 Fix corrupted upper left pixel in sample file
(This bug has since been fixed.)
2023-05-16 02:30:10 -04:00
Isaiah Odhner
7bc86bc483 Fix error handling for decode_based_on_file_extension
- UnicodeDecodeError was caught in a more general error handler;
  now it's allowed to reach the more specific handler.
- UnidentifiedImageError and FormatReadNotSupported were missing return;
  now it's not caught there so it doesn't need to, as the exception will
  interrupt the control flow.
2023-05-15 16:05:10 -04:00
Isaiah Odhner
9ad1933310 Improve error handling for unsupported format reading/writing 2023-05-15 15:42:41 -04:00
Isaiah Odhner
1cd6b24e33 Don't close Copy To dialog if there's an error 2023-05-15 15:05:03 -04:00
Isaiah Odhner
c24c164004 Add error handling to Save As for encode_based_on_file_extension 2023-05-15 15:03:58 -04:00
Isaiah Odhner
9653bfd9d8 Handle file extensions vs PIL format IDs
They usually correspond very closely, like .png -> PNG, but are
are more distinct for some formats, like .jp2 -> JPEG2000.

- Handle formats like JPEG2000 that differ in name from the extension.
- Bring my own file ext handling in line with PIL: use dotted lowercase.
- Raise an exception when a file format is detected but not supporting
  for reading or for writing, depending on the attempted operation.
2023-05-15 15:03:42 -04:00
Isaiah Odhner
1176fcee73 Save WebP files losslessly 2023-05-15 14:23:55 -04:00
Isaiah Odhner
4dbaf5145e Open and save image files with Pillow 2023-05-15 00:46:08 -04:00
Isaiah Odhner
e1185a0c21 Add spellings and adjust spell checker configuration 2023-05-15 00:15:49 -04:00
Isaiah Odhner
26e077bce3 Unify docstring formatting according to PEP 257
I used this regexp to search for multi-line docstrings: """.*(?<!""")\n

Here's a regexp to search for class docstrings: class .*\n\s*"""
in case that's useful later.
2023-05-15 00:15:49 -04:00