distorted-floor 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +661 -0
- data/README.md +32 -0
- data/bin/distorted-floor +16 -0
- data/bin/repl +14 -0
- data/bin/setup +8 -0
- data/font/1252/LICENSE/MoreLessPerfectDOSVGA437/img/Less_Perfect_DOS_VGA.png +0 -0
- data/font/1252/LICENSE/MoreLessPerfectDOSVGA437/img/More_Perfect_DOS_VGA.png +0 -0
- data/font/1252/LICENSE/MoreLessPerfectDOSVGA437/img/Perfect_DOS_VGA.png +0 -0
- data/font/1252/LICENSE/MoreLessPerfectDOSVGA437/less_more_perfect_dos_vga_437.html +52 -0
- data/font/1252/LICENSE/PerfectDOSVGA437/font-comment.php@file=perfect_dos_vga_437.html +5 -0
- data/font/1252/LessPerfectDOSVGA.ttf +0 -0
- data/font/1252/MorePerfectDOSVGA.ttf +0 -0
- data/font/1252/Perfect DOS VGA 437 Win.ttf +0 -0
- data/font/437/Perfect DOS VGA 437.ttf +0 -0
- data/font/437/dos437.txt +72 -0
- data/font/65001/Anonymous Pro B.ttf +0 -0
- data/font/65001/Anonymous Pro BI.ttf +0 -0
- data/font/65001/Anonymous Pro I.ttf +0 -0
- data/font/65001/Anonymous Pro.ttf +0 -0
- data/font/65001/LICENSE/AnonymousPro/FONTLOG.txt +45 -0
- data/font/65001/LICENSE/AnonymousPro/OFL-FAQ.txt +235 -0
- data/font/65001/LICENSE/AnonymousPro/OFL.txt +94 -0
- data/font/65001/LICENSE/AnonymousPro/README.txt +55 -0
- data/font/850/ProFont-Bold-01/LICENSE +22 -0
- data/font/850/ProFont-Bold-01/readme.txt +28 -0
- data/font/850/ProFontWindows-Bold.ttf +0 -0
- data/font/850/ProFontWindows.ttf +0 -0
- data/font/850/Profont/LICENSE +22 -0
- data/font/850/Profont/readme.txt +31 -0
- data/font/932/LICENSE/README-ttf.txt +213 -0
- data/font/932/mona.ttf +0 -0
- data/lib/distorted-floor/checking_you_out.rb +78 -0
- data/lib/distorted-floor/click_again.rb +406 -0
- data/lib/distorted-floor/element_of_media/change.rb +114 -0
- data/lib/distorted-floor/element_of_media/compound.rb +120 -0
- data/lib/distorted-floor/element_of_media.rb +2 -0
- data/lib/distorted-floor/error_code.rb +55 -0
- data/lib/distorted-floor/floor.rb +17 -0
- data/lib/distorted-floor/invoker.rb +100 -0
- data/lib/distorted-floor/media_molecule/font.rb +200 -0
- data/lib/distorted-floor/media_molecule/image.rb +33 -0
- data/lib/distorted-floor/media_molecule/pdf.rb +45 -0
- data/lib/distorted-floor/media_molecule/svg.rb +46 -0
- data/lib/distorted-floor/media_molecule/text.rb +247 -0
- data/lib/distorted-floor/media_molecule/video.rb +21 -0
- data/lib/distorted-floor/media_molecule.rb +58 -0
- data/lib/distorted-floor/modular_technology/gstreamer.rb +175 -0
- data/lib/distorted-floor/modular_technology/pango.rb +90 -0
- data/lib/distorted-floor/modular_technology/ttfunk.rb +48 -0
- data/lib/distorted-floor/modular_technology/vips/ffi.rb +66 -0
- data/lib/distorted-floor/modular_technology/vips/load.rb +174 -0
- data/lib/distorted-floor/modular_technology/vips/operatio$.rb +268 -0
- data/lib/distorted-floor/modular_technology/vips/save.rb +135 -0
- data/lib/distorted-floor/modular_technology/vips.rb +17 -0
- data/lib/distorted-floor/monkey_business/encoding.rb +374 -0
- data/lib/distorted-floor/monkey_business/hash.rb +18 -0
- data/lib/distorted-floor/monkey_business/set.rb +15 -0
- data/lib/distorted-floor/monkey_business/string.rb +6 -0
- data/lib/distorted-floor.rb +2 -0
- metadata +215 -0
@@ -0,0 +1,374 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
## Adds better support to Ruby's Encoding class for IBM/Microsoft-style numeric codepage IDs:
|
4
|
+
# - Adds a `:code_page` method on any instance of Encoding, returning the Integer codepage ID.
|
5
|
+
# - Adds a `:page_code` singleton method on :Encoding, returning the Encoding instance for any Integer codepage ID.
|
6
|
+
# - Patches Encoding::find() to add Integer and numeric-String find() support using :page_code.
|
7
|
+
# - Adds a `:code_page_orphans` singleton method on :Encoding, returning a Set of built-in Encodings that
|
8
|
+
# do not have a corresponding built-in `:CP<####>` name/constant.
|
9
|
+
# - Includes many additional numeric codepage IDs based on information
|
10
|
+
# from IANA, Unicode Consortium, OS vendors, and some of my own speculation.
|
11
|
+
|
12
|
+
## This is similar in effect (but not in implementation) to the 'encoding-codepage' Gem:
|
13
|
+
# https://github.com/ConradIrwin/encoding-codepage
|
14
|
+
# My choice of method name `:code_page` was intentional to avoid conflict with this Gem's `:codepage`.
|
15
|
+
|
16
|
+
|
17
|
+
## Notes-To-Self about Encoding (the class I'm patching) and encodings in general:
|
18
|
+
|
19
|
+
## Unicode Normalization Forms
|
20
|
+
#
|
21
|
+
# - Canonical composed (NFC) and decomposed (NFD) forms.
|
22
|
+
# - Non-canonical composed (NFKC) and decomposed (NFKD) forms.
|
23
|
+
#
|
24
|
+
# "For example, form C uses the single Unicode code point "Ä" (U+00C4),
|
25
|
+
# while form D uses ("A" + "¨", that is U+0041 U+0308).
|
26
|
+
# These render identically, because "¨" (U+0308) is a combining character."
|
27
|
+
#
|
28
|
+
# http://www.unicode.org/faq/normalization.html
|
29
|
+
# http://www.unicode.org/reports/tr15/
|
30
|
+
# https://docs.microsoft.com/en-us/windows/win32/intl/using-unicode-normalization-to-represent-strings
|
31
|
+
# https://en.wikipedia.org/wiki/Precomposed_character
|
32
|
+
# https://en.wikipedia.org/wiki/Unicode_equivalence
|
33
|
+
#
|
34
|
+
# HFS+ is a notable outlier among filesystems by requiring decomposed form (actually 'UTF-8-Mac' variant).
|
35
|
+
|
36
|
+
## Ruby includes a lot of the desired codepoint ID data built-in,
|
37
|
+
# but in the form of String alias names for Encoding instances,
|
38
|
+
# e.g. KOI8-R is also codepage 878:
|
39
|
+
#
|
40
|
+
# irb> Encoding::KOI8_R.names
|
41
|
+
# => ["KOI8-R", "CP878"]
|
42
|
+
#
|
43
|
+
# irb> Encoding::KOI8_R.names.any?{ |n| n =~ /^(CP|IBM|Windows[-_])(?<code_page>\d{3,}$)/ }
|
44
|
+
# => true
|
45
|
+
# irb> Regexp.last_match
|
46
|
+
# => #<MatchData "CP878" code_page:"878">
|
47
|
+
#
|
48
|
+
# My code defers to this built-in data where possible instead of doing
|
49
|
+
# a complete import of the Microsoft identifiers like the Gem.
|
50
|
+
|
51
|
+
|
52
|
+
## Some encodings have both generic and vendor-prefixed names,
|
53
|
+
## and some are canonically one or the other, e.g.:
|
54
|
+
#
|
55
|
+
# irb> Encoding::IBM437
|
56
|
+
# => #<Encoding:IBM437>
|
57
|
+
# irb> Encoding::CP437
|
58
|
+
# => #<Encoding:IBM437>
|
59
|
+
#
|
60
|
+
# irb> Encoding::IBM850
|
61
|
+
# => #<Encoding:CP850>
|
62
|
+
# irb> Encoding::CP850
|
63
|
+
# => #<Encoding:CP850>
|
64
|
+
|
65
|
+
|
66
|
+
class Encoding
|
67
|
+
|
68
|
+
# Define a Regexp to match and extract Ruby's built-in numeric codepage IDs
|
69
|
+
# from thir Encoding's names.
|
70
|
+
#
|
71
|
+
# Using IGNORECASE to handle the duplicate differing-capitalization constants,
|
72
|
+
# e.g. Encoding::WINDOWS_31J and Encoding::Windows_31J both exist and are equivalent.
|
73
|
+
#
|
74
|
+
# Worth mentioning since this file deals with Encoding,
|
75
|
+
# but the Regexp itself also has an internal Encoding that can be changed
|
76
|
+
# if I had any reason to (I don't):
|
77
|
+
# https://ruby-doc.org/core/Regexp.html#class-Regexp-label-Encoding
|
78
|
+
CODE_PAGE_ENCODING_NAME = Regexp.new('^(CP|IBM|Windows[-_])(?<code_page>\d{3,}$)', Regexp::IGNORECASE)
|
79
|
+
|
80
|
+
# Data sources:
|
81
|
+
# https://www.aivosto.com/articles/charsets-codepages.html
|
82
|
+
# https://developer.apple.com/documentation/coreservices/1400434-ms-dos_and_windows_text_encodings
|
83
|
+
# https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
|
84
|
+
# https://en.wikipedia.org/wiki/CCSID
|
85
|
+
# https://github.com/SheetJS/js-codepage/blob/master/codepage.md
|
86
|
+
# https://i18nqa.com/debug/table-iso8859-1-vs-windows-1252.html
|
87
|
+
# https://www.gammon.com.au/unicode/
|
88
|
+
ADDITIONAL_ENCODING_CODE_PAGE_IDS = {
|
89
|
+
|
90
|
+
# Burgerland :911:
|
91
|
+
Encoding::US_ASCII => 20127,
|
92
|
+
|
93
|
+
# Unicode
|
94
|
+
Encoding::UTF_16LE => 1200,
|
95
|
+
Encoding::UTF_16BE => 1201,
|
96
|
+
Encoding::UTF_32LE => 12000,
|
97
|
+
Encoding::UTF_32BE => 12001,
|
98
|
+
|
99
|
+
## 245
|
100
|
+
#
|
101
|
+
# Code Page 932 is Windows-31J, but I want to provide fallback mapping
|
102
|
+
# between 932 and Shift_JIS to handle detected-text or `encoding` arguments
|
103
|
+
# that return Shift_JIS since that naming is much much more well-known than 31J.
|
104
|
+
Encoding::SHIFT_JIS => 932,
|
105
|
+
# https://referencesource.microsoft.com/#mscorlib/system/text/eucjpencoding.cs
|
106
|
+
# https://www.redmine.org/issues/29442
|
107
|
+
# https://www.sljfaq.org/afaq/encodings.html
|
108
|
+
# https://uic.jp/charset/
|
109
|
+
# http://www.monyo.com/technical/samba/docs/Japanese-HOWTO-3.0.en.txt
|
110
|
+
Encoding::EUC_JP_MS => 20932,
|
111
|
+
Encoding::EUC_JP => 51932,
|
112
|
+
# Encoding:EUC-JIS-2004 dunno
|
113
|
+
#
|
114
|
+
# https://www.debian.org/doc/manuals/intro-i18n/ch-coding.en.html 3.2: Stateless and Stateful
|
115
|
+
# TL;DR: Stateful uses an escape sequence to switch charset;
|
116
|
+
# Stateless have all-unique codepoints.
|
117
|
+
# Normal ISO-2022-JP is stateful.
|
118
|
+
# "For example, in ISO 2022-JP, two bytes of 0x24 0x2c may mean a Japanese Hiragana character 'が'
|
119
|
+
# or two ASCII character of '$' and ',' according to the shift state."
|
120
|
+
# Encoding::STATELESS_ISO_2022_JP
|
121
|
+
#
|
122
|
+
# Mobile operator specific encodings that I have no numeric IDs for rn:
|
123
|
+
# Encoding:UTF8-DoCoMo
|
124
|
+
# Encoding:SJIS-DoCoMo
|
125
|
+
# Encoding:UTF8-KDDI
|
126
|
+
# Encoding:SJIS-KDDI
|
127
|
+
# Encoding:stateless-ISO-2022-JP-KDDI
|
128
|
+
# Encoding:UTF8-SoftBank
|
129
|
+
# Encoding:SJIS-SoftBank
|
130
|
+
|
131
|
+
## CHY-NAH
|
132
|
+
#
|
133
|
+
# https://en.wikipedia.org/wiki/Code_page_903
|
134
|
+
Encoding::GB1988 => 903,
|
135
|
+
#
|
136
|
+
## Hong Kong Supplementary Character Set
|
137
|
+
# The Windows version of this seems to be the built-in CP951:
|
138
|
+
# https://web.archive.org/web/20160402215421/https://blogs.msdn.microsoft.com/shawnste/2007/03/12/cp-951-hkscs/
|
139
|
+
# https://web.archive.org/web/20141129233053/http://www-01.ibm.com/software/globalization/ccsid/ccsid5471.html
|
140
|
+
Encoding::BIG5_HKSCS => 5417,
|
141
|
+
#
|
142
|
+
# The 936 postfix is a reference to the standard Windows Chinese encoding being CP936 / GBK.
|
143
|
+
# "GB2312 is the registered internet name for EUC-CN, which is its usual encoded form."
|
144
|
+
Encoding::GB2312 => 20936,
|
145
|
+
Encoding::GB12345 => 51936,
|
146
|
+
#Encoding:GB2312_HZ => 52936, # Doesn't exist in Ruby
|
147
|
+
Encoding::GB18030 => 54936,
|
148
|
+
|
149
|
+
|
150
|
+
## Asia At Odd Hours
|
151
|
+
#
|
152
|
+
# I always wondered if the "Gravitational Pull of Pepsi" logo came from
|
153
|
+
# them wanting it to look less like the Korean flag.
|
154
|
+
# The traditional Korean Windows Code Page is CP949, available in Ruby
|
155
|
+
# but not under any other name aliases.
|
156
|
+
# IBM uses CP1363, not in Ruby.
|
157
|
+
Encoding::EUC_KR => 51949,
|
158
|
+
#
|
159
|
+
# ROC me now
|
160
|
+
Encoding::EUC_TW => 51950,
|
161
|
+
# Unicode 補完計畫 / Unicode-At-On is a Big5 variant once popular in Taiwan:
|
162
|
+
# https://lists.gnu.org/archive/html/bug-gnu-libiconv/2010-11/msg00007.html
|
163
|
+
# https://lists.w3.org/Archives/Public/public-html-ig-zh/2012Apr/0061.html
|
164
|
+
# Encoding::BIG5_UAO
|
165
|
+
#
|
166
|
+
# CP950 (available in Ruby) is the code page used on Windows under the name "big5',
|
167
|
+
# but I want to map the generic Big5 Encoding to 950 as well to handle
|
168
|
+
# detected and specified encodings by that name.
|
169
|
+
# "The major difference between Windows code page 950 and "common" (non-vendor-specific) Big5
|
170
|
+
# is the incorporation of a subset of the ETEN extensions to Big5 at 0xF9D6 through 0xF9FE
|
171
|
+
# (comprising the seven Chinese characters 碁, 銹, 裏, 墻, 恒, 粧, and 嫺,
|
172
|
+
# followed by 34 box drawing characters and block elements)."
|
173
|
+
Encoding::Big5 => 950,
|
174
|
+
#
|
175
|
+
# Encoding::TIS_620 is the base Thai 8-bit encoding standard that is apparently
|
176
|
+
# never actually used in the wild.
|
177
|
+
# ISO-8859-11 is identical to it with the sole exception "that ISO/IEC 8859-11
|
178
|
+
# allocates non-breaking space to code 0xA0, while TIS-620 leaves it undefined."
|
179
|
+
# "The Microsoft Windows code page 874 as well as the code page used in the
|
180
|
+
# Thai version of the Apple Macintosh, MacThai,
|
181
|
+
# are variants of TIS-620 — incompatible with each other, however."
|
182
|
+
|
183
|
+
|
184
|
+
# Eastern Yurp
|
185
|
+
#Encoding::KOI8_R => 20866,
|
186
|
+
Encoding::KOI8_U => 21866,
|
187
|
+
|
188
|
+
## ISO/IEC 8859 (8-bit) encoding family
|
189
|
+
#
|
190
|
+
Encoding::ISO_8859_1 => 28591, # West European languages (Latin-1)
|
191
|
+
Encoding::ISO_8859_2 => 28592, # Central and East European languages (Latin-2)
|
192
|
+
Encoding::ISO_8859_3 => 28593, # Southeast European and miscellaneous languages (Latin-3)
|
193
|
+
Encoding::ISO_8859_4 => 28594, # Scandinavian/Baltic languages (Latin-4)
|
194
|
+
Encoding::ISO_8859_5 => 28595, # Latin/Cyrillic
|
195
|
+
Encoding::ISO_8859_6 => 28596, # Latin/Arabic
|
196
|
+
Encoding::ISO_8859_7 => 28597, # Latin/Greek
|
197
|
+
Encoding::ISO_8859_8 => 28598, # Latin/Hebrew
|
198
|
+
Encoding::ISO_8859_9 => 28599, # Latin-1 modification for Turkish (Latin-5)
|
199
|
+
#
|
200
|
+
# ISO-8859-10 covers Nordic languages better than ISO_8859_4.
|
201
|
+
# Wikipedia says this has been assigned in Windows as 28600 even though Microsoft's
|
202
|
+
# page doesn't list it now in 2020, but w/e.
|
203
|
+
# IBM assigned it as CP919.
|
204
|
+
Encoding::ISO_8859_10 => 28600, # Lappish/Nordic/Eskimo languages (Latin-6)
|
205
|
+
#
|
206
|
+
# Wikipedia says this is assigned, but same deal.
|
207
|
+
Encoding::ISO_8859_11 => 28601, # Latin/Thai
|
208
|
+
#
|
209
|
+
# Intended Celtic encoding abandoned in 1997 in favor of ISO_8859_14:
|
210
|
+
# Encoding::ISO_8859_12 => 28602,
|
211
|
+
#
|
212
|
+
Encoding::ISO_8859_13 => 28603, # Baltic Rim languages (Latin-7)
|
213
|
+
Encoding::ISO_8859_14 => 28604, # Celtic (Latin-8)
|
214
|
+
Encoding::ISO_8859_15 => 28605, # West European languages (Latin-9)
|
215
|
+
Encoding::ISO_8859_16 => 28606, # Romanian (Latin-10)
|
216
|
+
|
217
|
+
# Apple encodings
|
218
|
+
#
|
219
|
+
# UTF8_MAC is the encoding Mac OS X uses on HFS+ filesystems and is a variant of UTF-8-NFD.
|
220
|
+
# https://web.archive.org/web/20140812023313/http://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html
|
221
|
+
# "Mac OS Extended (HFS+) uses canonically decomposed Unicode 3.2 in UTF-16 format,
|
222
|
+
# which consists of a sequence of 16-bit codes.
|
223
|
+
# (Characters in the ranges U2000-U2FFF, UF900-UFA6A, and U2F800-U2FA1D are not decomposed.)"
|
224
|
+
#
|
225
|
+
# There isn't a good Microsoft-style ID I can assign to it, so this is just FYI.
|
226
|
+
|
227
|
+
# Classic Mac encodings
|
228
|
+
#
|
229
|
+
# https://en.wikipedia.org/wiki/Category:Mac_OS_character_encodings
|
230
|
+
# http://mirror.informatimago.com/next/developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.1b.html
|
231
|
+
#
|
232
|
+
# MacRoman pre-OS-8.5 has the "Universal currency symbol" at 0xDB,
|
233
|
+
# while 8.5 and later replace it with the (then-new) Euro symbol:
|
234
|
+
# https://en.wikipedia.org/wiki/Currency_sign_(typography)
|
235
|
+
Encoding::MACROMAN => 10000,
|
236
|
+
#
|
237
|
+
# "Shift-JIS with JIS Roman modifications, extra 1-byte characters, 2-byte Apple extensions,
|
238
|
+
# and some vertical presentation forms in the range 0xEB40--0xEDFE ("ku plus 84")."
|
239
|
+
# Ruby also defines Encoding::MACJAPAN but it's the same Encoding.
|
240
|
+
Encoding::MACJAPANESE => 10001,
|
241
|
+
#
|
242
|
+
# The following encodings are not defined in Ruby's Encoding class,
|
243
|
+
# but I'm listing them here for completeness' sake.
|
244
|
+
# MACCHINESETRAD => 10002,
|
245
|
+
# MACKOREAN => 10003,
|
246
|
+
# MACARABIC => 10004,
|
247
|
+
# MACHEBREW => 10005,
|
248
|
+
# MACGREEK => 10006,
|
249
|
+
# MACCYRILLIC => 10007,
|
250
|
+
# MACHINESESIMP => 10008,
|
251
|
+
#
|
252
|
+
# Unlike MacJapan/MacJapanese, MacRomania is something different than MacRoman.
|
253
|
+
Encoding::MACROMANIA => 10010,
|
254
|
+
#
|
255
|
+
Encoding::MACUKRAINE => 10017,
|
256
|
+
Encoding::MACTHAI => 10021,
|
257
|
+
Encoding::MACCENTEURO => 10029,
|
258
|
+
Encoding::MACICELAND => 10079,
|
259
|
+
Encoding::MACTURKISH => 10081,
|
260
|
+
Encoding::MACCROATIAN => 10082,
|
261
|
+
|
262
|
+
} # ADDITIONAL_ENCODING_CODE_PAGE_IDS
|
263
|
+
|
264
|
+
# TODO: Mac OS Script Codes http://www.mods.com.au/budapi/mac_language_codes.htm
|
265
|
+
|
266
|
+
# Box-drawing characters for various Encodings, including single/double pipe characters,
|
267
|
+
# area-sharing characters, and basically anything that could/would be used for art direction
|
268
|
+
# in an NFO file or oldschool DOS-style interface: https://en.wikipedia.org/wiki/Box-drawing_character
|
269
|
+
#
|
270
|
+
# These will be used as the hints for our own supplementary String-encoding detection
|
271
|
+
# since ICU has a hard time differentiating e.g. IBM437/ISO8859 when rendering text files,
|
272
|
+
# so we can look for the presence of certain combinations of these characters to help guess.
|
273
|
+
OOBE = {
|
274
|
+
Encoding::IBM437 => (0xB3..0xDA), # 'murca
|
275
|
+
Encoding::CP850 => [
|
276
|
+
(0xB3..0xB4), # IBM437 equivalent for Europe. Replaces some box drawing characters
|
277
|
+
(0xB9..0xBC), # with additional printable letters with diacritic marks.
|
278
|
+
(0xBF..0xC5), # CP850 has the same printable letters as ISO-8859-1 but incompatibly.
|
279
|
+
(0xC8..0xCE), # ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CP00850.pdf
|
280
|
+
(0xD9..0xDA), # ftp://ftp.software.ibm.com/software/globalization/gcoc/attachments/CP00850.txt
|
281
|
+
].reduce(&:chain),
|
282
|
+
Encoding::UTF_8 => [
|
283
|
+
(0x2500..0x257F), # https://www.unicode.org/charts/PDF/U2500.pdf
|
284
|
+
(0x2580..0x259F), # https://www.unicode.org/charts/PDF/U2580.pdf
|
285
|
+
[
|
286
|
+
(0x1FB00..0x1FB3B), # Block mosaic terminal graphic characters
|
287
|
+
(0x1FB3C..0x1FB6F), # Smooth mosaic terminal graphic characters
|
288
|
+
(0x1FB70..0x1FB8B), # Block elements
|
289
|
+
(0x1FB3C..0x1FB94), # Rectangular shade characters
|
290
|
+
(0x1FB95..0x1FB99), # Fill characters
|
291
|
+
(0x1FB9A..0x1FB9B), # Smooth mosaic terminal graphic characters
|
292
|
+
(0x1FB9C..0x1FB9F), # Triangular shade characters
|
293
|
+
(0x1FBA0..0x1FBAE), # Character cell diagonals
|
294
|
+
(0x1FBAE..0x1FBAE), # Light solid line with stroke
|
295
|
+
# Skipping the rest of the Symbols for Legacy Computing block
|
296
|
+
# since it consists of terminal graphics, arrows, and segmented digits.
|
297
|
+
].reduce(&:chain), # https://www.unicode.org/charts/PDF/U1FB00.pdf
|
298
|
+
].reduce(&:chain),
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
# Example Strings for various Encodings, used for things such as font previews.
|
303
|
+
# These are more language-specific than Encoding-specific, but I don't have
|
304
|
+
# any better way to index them for now.
|
305
|
+
PANGRAMS = {
|
306
|
+
Encoding::ISO_8859_1 => [
|
307
|
+
],
|
308
|
+
# Celtic languages, such as Irish, Manx, Scottish Gaelic, Welsh, Cornish, and Breton.
|
309
|
+
Encoding::ISO_8859_14 => [
|
310
|
+
'Parciais fy jac codi baw hud llawn dŵr ger tŷ Mabon.', # Welsh
|
311
|
+
],
|
312
|
+
Encoding::ISO_8859_15 => [
|
313
|
+
'Buvez de ce whisky que le patron juge fameux.',
|
314
|
+
],
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
# Returns a Hash of the built-in-orphan Encodings we now have codepage IDs for,
|
319
|
+
# e.g. {#<Encoding:US-ASCII>=>20127, #<Encoding:UTF-16BE>=>1201, #<Encoding:UTF-16LE>=>1200}
|
320
|
+
def self.adopted_encoding_code_page_ids
|
321
|
+
@@adopted_encoding_code_page_ids ||= self::code_page_orphans.select{ |e|
|
322
|
+
if self::ADDITIONAL_ENCODING_CODE_PAGE_IDS.has_key?(e)
|
323
|
+
# irb> Encoding.const_defined?('CP932')
|
324
|
+
# => true
|
325
|
+
not Encoding::const_defined?("CP#{self::ADDITIONAL_ENCODING_CODE_PAGE_IDS[e]}")
|
326
|
+
else
|
327
|
+
false
|
328
|
+
end
|
329
|
+
}.map{ |e|
|
330
|
+
[e, self::ADDITIONAL_ENCODING_CODE_PAGE_IDS[e]]
|
331
|
+
}.to_h
|
332
|
+
end
|
333
|
+
|
334
|
+
# Returns a Set of built-in Encodings whose :names /!\ DO NOT /!\ contain a usable
|
335
|
+
# numeric codepage ID, as matched by our Regexp.
|
336
|
+
def self.code_page_orphans
|
337
|
+
Encoding.list.select{ |c|
|
338
|
+
c.respond_to?(:names) ? (not c.names.any?{|n| CODE_PAGE_ENCODING_NAME.match(n)}) : false
|
339
|
+
}.to_set
|
340
|
+
end
|
341
|
+
|
342
|
+
# Returns the Encoding instance of any Integer codepage ID.
|
343
|
+
def self.page_code(code_page_id)
|
344
|
+
# Every canonically-Windows*/IBM*-named Encoding seems to also have a 'CP<whatever>' equivalent.
|
345
|
+
Encoding::find("CP#{code_page_id}") rescue nil
|
346
|
+
end
|
347
|
+
|
348
|
+
# Returns the Integer codepage ID of any Encoding instance.
|
349
|
+
def code_page
|
350
|
+
Encoding::adopted_encoding_code_page_ids.fetch(
|
351
|
+
self,
|
352
|
+
self.names.any?{ |n| CODE_PAGE_ENCODING_NAME.match(n) } ? Regexp.last_match['code_page'.freeze].to_i : nil
|
353
|
+
)
|
354
|
+
end
|
355
|
+
|
356
|
+
# Patch the Encoding::find() method to support taking Integer and numeric-String arguments
|
357
|
+
# in addition to the Symbol and canonical-String args it usually supports.
|
358
|
+
find_you_again = singleton_method(:find)
|
359
|
+
define_singleton_method(:find) do |code_page_id|
|
360
|
+
begin
|
361
|
+
if code_page_id.is_a?(Integer)
|
362
|
+
Encoding::page_code(code_page_id)
|
363
|
+
elsif code_page_id.to_s.to_i > 0 # Chain :to_s to support Symbols too
|
364
|
+
# String#to_i returns 0 for any non-entirely-numeric String
|
365
|
+
Encoding::page_code(code_page_id.to_i)
|
366
|
+
else
|
367
|
+
find_you_again.(code_page_id.to_s)
|
368
|
+
end
|
369
|
+
rescue RuntimeError => e
|
370
|
+
find_you_again.(code_page_id.to_s)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
|
5
|
+
# Complement Ruby::YAML behavior, where usage of Set syntax
|
6
|
+
# returns a Hash with all-nil values.
|
7
|
+
# Calling :to_set on a Hash with all-nil values should return
|
8
|
+
# a Set of the Hash's keys.
|
9
|
+
this_old_set = instance_method(:to_set)
|
10
|
+
define_method(:to_set) do
|
11
|
+
if self.values.all?{ |v| v.nil? }
|
12
|
+
self.keys.to_set
|
13
|
+
else
|
14
|
+
this_old_set.bind(self).()
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
# Override Set.to_hash to complement Ruby::YAML's Set implementation,
|
4
|
+
# where the YAML Set syntax returns a Hash with all-nil values,
|
5
|
+
# at least without some decorator sugar in the YAML itself:
|
6
|
+
# https://rhnh.net/2011/01/31/yaml-tutorial/
|
7
|
+
#
|
8
|
+
# Since Set is implemented using a Hash internally I think it makes
|
9
|
+
# more sense for Set.to_hash to return a Hash with all-nil values
|
10
|
+
# with keys matching the contents of the original Set.
|
11
|
+
class Set
|
12
|
+
def to_hash
|
13
|
+
Hash[self.map { |s| [s, nil] }]
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: distorted-floor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- okeeblow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: checking-you-out
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xross-the-xoul
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-vips
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: svg_optimizer
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.2.5
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gstreamer
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: hexapdf
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.13'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ffi-icu
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.3'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ttfunk
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.6'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.6'
|
125
|
+
description: Ruby implementation of core file-format operations used by DistorteD-Jekyll.
|
126
|
+
email:
|
127
|
+
- root@cooltrainer.org
|
128
|
+
executables:
|
129
|
+
- distorted-floor
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- LICENSE
|
134
|
+
- README.md
|
135
|
+
- bin/distorted-floor
|
136
|
+
- bin/repl
|
137
|
+
- bin/setup
|
138
|
+
- font/1252/LICENSE/MoreLessPerfectDOSVGA437/img/Less_Perfect_DOS_VGA.png
|
139
|
+
- font/1252/LICENSE/MoreLessPerfectDOSVGA437/img/More_Perfect_DOS_VGA.png
|
140
|
+
- font/1252/LICENSE/MoreLessPerfectDOSVGA437/img/Perfect_DOS_VGA.png
|
141
|
+
- font/1252/LICENSE/MoreLessPerfectDOSVGA437/less_more_perfect_dos_vga_437.html
|
142
|
+
- font/1252/LICENSE/PerfectDOSVGA437/font-comment.php@file=perfect_dos_vga_437.html
|
143
|
+
- font/1252/LessPerfectDOSVGA.ttf
|
144
|
+
- font/1252/MorePerfectDOSVGA.ttf
|
145
|
+
- font/1252/Perfect DOS VGA 437 Win.ttf
|
146
|
+
- font/437/Perfect DOS VGA 437.ttf
|
147
|
+
- font/437/dos437.txt
|
148
|
+
- font/65001/Anonymous Pro B.ttf
|
149
|
+
- font/65001/Anonymous Pro BI.ttf
|
150
|
+
- font/65001/Anonymous Pro I.ttf
|
151
|
+
- font/65001/Anonymous Pro.ttf
|
152
|
+
- font/65001/LICENSE/AnonymousPro/FONTLOG.txt
|
153
|
+
- font/65001/LICENSE/AnonymousPro/OFL-FAQ.txt
|
154
|
+
- font/65001/LICENSE/AnonymousPro/OFL.txt
|
155
|
+
- font/65001/LICENSE/AnonymousPro/README.txt
|
156
|
+
- font/850/ProFont-Bold-01/LICENSE
|
157
|
+
- font/850/ProFont-Bold-01/readme.txt
|
158
|
+
- font/850/ProFontWindows-Bold.ttf
|
159
|
+
- font/850/ProFontWindows.ttf
|
160
|
+
- font/850/Profont/LICENSE
|
161
|
+
- font/850/Profont/readme.txt
|
162
|
+
- font/932/LICENSE/README-ttf.txt
|
163
|
+
- font/932/mona.ttf
|
164
|
+
- lib/distorted-floor.rb
|
165
|
+
- lib/distorted-floor/checking_you_out.rb
|
166
|
+
- lib/distorted-floor/click_again.rb
|
167
|
+
- lib/distorted-floor/element_of_media.rb
|
168
|
+
- lib/distorted-floor/element_of_media/change.rb
|
169
|
+
- lib/distorted-floor/element_of_media/compound.rb
|
170
|
+
- lib/distorted-floor/error_code.rb
|
171
|
+
- lib/distorted-floor/floor.rb
|
172
|
+
- lib/distorted-floor/invoker.rb
|
173
|
+
- lib/distorted-floor/media_molecule.rb
|
174
|
+
- lib/distorted-floor/media_molecule/font.rb
|
175
|
+
- lib/distorted-floor/media_molecule/image.rb
|
176
|
+
- lib/distorted-floor/media_molecule/pdf.rb
|
177
|
+
- lib/distorted-floor/media_molecule/svg.rb
|
178
|
+
- lib/distorted-floor/media_molecule/text.rb
|
179
|
+
- lib/distorted-floor/media_molecule/video.rb
|
180
|
+
- lib/distorted-floor/modular_technology/gstreamer.rb
|
181
|
+
- lib/distorted-floor/modular_technology/pango.rb
|
182
|
+
- lib/distorted-floor/modular_technology/ttfunk.rb
|
183
|
+
- lib/distorted-floor/modular_technology/vips.rb
|
184
|
+
- lib/distorted-floor/modular_technology/vips/ffi.rb
|
185
|
+
- lib/distorted-floor/modular_technology/vips/load.rb
|
186
|
+
- lib/distorted-floor/modular_technology/vips/operatio$.rb
|
187
|
+
- lib/distorted-floor/modular_technology/vips/save.rb
|
188
|
+
- lib/distorted-floor/monkey_business/encoding.rb
|
189
|
+
- lib/distorted-floor/monkey_business/hash.rb
|
190
|
+
- lib/distorted-floor/monkey_business/set.rb
|
191
|
+
- lib/distorted-floor/monkey_business/string.rb
|
192
|
+
homepage: https://cooltrainer.org
|
193
|
+
licenses:
|
194
|
+
- AGPL-3.0
|
195
|
+
metadata: {}
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 3.1.0
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
requirements: []
|
211
|
+
rubygems_version: 3.3.3
|
212
|
+
signing_key:
|
213
|
+
specification_version: 4
|
214
|
+
summary: Multimedia toolkit core.
|
215
|
+
test_files: []
|