fontina-windows 0.1.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/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/fontina-windows.gemspec +27 -0
- data/lib/fontina/windows/install.rb +8 -0
- data/lib/fontina/windows/marshal.rb +42 -0
- data/lib/fontina/windows/meta_package.rb +36 -0
- data/lib/fontina/windows/package.rb +34 -0
- data/lib/fontina/windows/version.rb +7 -0
- data/lib/fontina/windows/win32/advapi32.rb +72 -0
- data/lib/fontina/windows/win32/constants.rb +32 -0
- data/lib/fontina/windows/win32/dlload.rb +30 -0
- data/lib/fontina/windows/win32/error.rb +37 -0
- data/lib/fontina/windows/win32/gdi32.rb +12 -0
- data/lib/fontina/windows/win32/kernel32.rb +18 -0
- data/lib/fontina/windows/win32/shell32.rb +12 -0
- data/lib/fontina/windows/win32/user32.rb +10 -0
- data/lib/fontina/windows/win32.rb +19 -0
- data/lib/fontina/windows.rb +61 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 475183ef6216f5b7b1f72b687c2f026965f9fb80
|
4
|
+
data.tar.gz: 2f7e6de102596e7bffe1490d62e0c6195990e06b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7246fcbec02d446b3b98a73aacf34b8d7f7e83ee4588d11d6cbe30fc50289281fd03be88f35c5d0704f454708a9978c8a0f08e29abd49d5d7ec82ce113404dff
|
7
|
+
data.tar.gz: 9af0184ecfe4375d2756c080b3fc8707d38b1cd973c83867c430eb4ac18d57dbd899b904b25025f0167d2f537511a392763285646783310074362d86154f4c98
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Michael Petter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Fontina Windows Extensions
|
2
|
+
|
3
|
+
[ ](https://rubygems.org/gems/fontina-windows)
|
4
|
+
[](https://travis-ci.org/michaeljpetter/fontina-windows)
|
5
|
+
|
6
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fontina/windows`. To experiment with that code, run `bin/console` for an interactive prompt.
|
7
|
+
|
8
|
+
TODO: Delete this and the text above, and describe your gem
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'fontina-windows'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install fontina-windows
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
TODO: Write usage instructions here
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it ( https://github.com/michaeljpetter/fontina-windows/fork )
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create a new Pull Request
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'lib/fontina/windows/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'fontina-windows'
|
5
|
+
gem.version = Fontina::Windows::VERSION
|
6
|
+
gem.author = 'Michael Petter'
|
7
|
+
gem.email = 'michaeljpetter@gmail.com'
|
8
|
+
|
9
|
+
gem.summary = 'A cheesy windows font extension'
|
10
|
+
gem.description = <<-END
|
11
|
+
Installs font files in Windows.
|
12
|
+
END
|
13
|
+
gem.homepage = 'http://github.com/michaeljpetter/fontina-windows'
|
14
|
+
gem.license = 'MIT'
|
15
|
+
|
16
|
+
gem.platform = Gem::Platform::RUBY
|
17
|
+
gem.files = Dir.glob %w(lib/**/* Gemfile *.gemspec LICENSE* README*)
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
|
+
gem.add_dependency 'fontina', '>= 0.2.1'
|
21
|
+
gem.add_dependency 'mores', '>= 0.1.5'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'bundler', '~> 1.7'
|
24
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
gem.add_development_dependency 'rspec', '~> 3.4'
|
26
|
+
gem.add_development_dependency 'rspec-its', '~> 1.2'
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fontina::Windows
|
2
|
+
|
3
|
+
module Marshal
|
4
|
+
BYTE = Encoding::BINARY
|
5
|
+
WCHAR = Encoding::UTF_16LE
|
6
|
+
|
7
|
+
private_constant *constants
|
8
|
+
module_function
|
9
|
+
|
10
|
+
define_method :dword, &(
|
11
|
+
Class.new(String) do
|
12
|
+
def initialize(i)
|
13
|
+
super [i].pack('V')
|
14
|
+
end
|
15
|
+
def to_i
|
16
|
+
unpack('V')[0]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
).method(:new)
|
20
|
+
|
21
|
+
alias_method :pvoid, :dword
|
22
|
+
module_function :pvoid
|
23
|
+
|
24
|
+
def byte(n)
|
25
|
+
n.chr BYTE
|
26
|
+
end
|
27
|
+
|
28
|
+
def wchar(n)
|
29
|
+
n.chr WCHAR
|
30
|
+
end
|
31
|
+
|
32
|
+
def wstr(s)
|
33
|
+
s.encode WCHAR unless s.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
def wstr!(s)
|
37
|
+
s.force_encoding WCHAR unless s.nil?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
private_constant :Marshal
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fontina
|
2
|
+
module Windows
|
3
|
+
|
4
|
+
module MetaPackage
|
5
|
+
include Marshal
|
6
|
+
Fontina::MetaPackage.include self
|
7
|
+
|
8
|
+
def registered_name
|
9
|
+
@registered_name ||= begin
|
10
|
+
name = package.preferred_name \
|
11
|
+
? wstr(package.preferred_name.name)
|
12
|
+
: package.fonts.map { |f| wstr(f.preferred_name.name) }.join(wstr(' & '))
|
13
|
+
|
14
|
+
[Formats::OpenType].include?(format) \
|
15
|
+
? name + wstr(' (TrueType)')
|
16
|
+
: name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def install
|
21
|
+
conflicts = Windows.registered_fonts
|
22
|
+
.find_all { |(name, path)| (name == registered_name) ^ (path == file.filename) }
|
23
|
+
fail "Conflicting registrations found: #{conflicts.to_h}" unless conflicts.empty?
|
24
|
+
|
25
|
+
File.write File.join(Windows.fonts_directory, file.filename), file.content
|
26
|
+
|
27
|
+
unless (count = Windows.add_font_resource file.filename) == package.fonts.length
|
28
|
+
fail "Windows reported #{count} fonts added (expected: #{package.fonts.length})"
|
29
|
+
end
|
30
|
+
|
31
|
+
Windows.register_font registered_name, file.filename
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fontina
|
2
|
+
|
3
|
+
module Windows::QualifiedName
|
4
|
+
QualifiedName.include self
|
5
|
+
|
6
|
+
PRIMARY = /^[^-]*/
|
7
|
+
private_constant :PRIMARY
|
8
|
+
|
9
|
+
def score
|
10
|
+
@score ||=
|
11
|
+
case platform
|
12
|
+
when :unicode then 3
|
13
|
+
when :mac then 5 if language == Windows.system_language[PRIMARY]
|
14
|
+
when :windows
|
15
|
+
if language == Windows.system_language then 7
|
16
|
+
elsif language[PRIMARY] == Windows.system_language[PRIMARY] then 6
|
17
|
+
elsif language == 'en-US' then 2
|
18
|
+
else 1
|
19
|
+
end
|
20
|
+
end || 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Windows::PreferredName
|
25
|
+
Font.include self
|
26
|
+
Package.include self
|
27
|
+
|
28
|
+
def preferred_name
|
29
|
+
@preferred_name = names.max_by &:score unless defined? @preferred_name
|
30
|
+
@preferred_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Fontina::Windows::Win32
|
2
|
+
|
3
|
+
dlload :Advapi32 do
|
4
|
+
extern 'long RegOpenKeyExW(PVOID, LPCSTR, DWORD, DWORD, PVOID*)' \
|
5
|
+
do |hkey, subkey, sam, options: 0|
|
6
|
+
result = pvoid(NULL)
|
7
|
+
Error.check super(hkey, wstr(subkey), options, sam, result)
|
8
|
+
result.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
extern 'long RegCloseKey(PVOID)' \
|
12
|
+
do |*_|
|
13
|
+
Error.check super(*_)
|
14
|
+
end
|
15
|
+
|
16
|
+
extern 'long RegQueryInfoKeyW(PVOID, LPSTR, DWORD*, DWORD*, DWORD*, DWORD*, DWORD*, DWORD*, DWORD*, DWORD*, DWORD*, DWORD64*)' \
|
17
|
+
do |hkey|
|
18
|
+
subkey_count = dword(NULL)
|
19
|
+
max_subkey_len = dword(NULL)
|
20
|
+
value_count = dword(NULL)
|
21
|
+
max_name_len = dword(NULL)
|
22
|
+
max_data_len = dword(NULL)
|
23
|
+
Error.check super(hkey, NULL, NULL, NULL, subkey_count, max_subkey_len, NULL, value_count, max_name_len, max_data_len, NULL, NULL)
|
24
|
+
const_get(:RegQueryInfoKeyResult)[
|
25
|
+
subkey_count.to_i, max_subkey_len.to_i, value_count.to_i, max_name_len.to_i, max_data_len.to_i
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
const_set :RegQueryInfoKeyResult, Mores::ImmutableStruct.new(
|
30
|
+
*%i[subkey_count max_subkey_len value_count max_name_len max_data_len],
|
31
|
+
strict: true
|
32
|
+
)
|
33
|
+
|
34
|
+
extern 'long RegEnumValueW(PVOID, DWORD, LPSTR, DWORD*, DWORD*, DWORD*, BYTE*, DWORD*)' \
|
35
|
+
do |hkey, index, name_len: 16383, data_len: nil|
|
36
|
+
name, name_len = wchar(0) * name_len, dword(name_len)
|
37
|
+
type = dword(NULL)
|
38
|
+
data, data_len = data_len ? [byte(0) * data_len, dword(data_len)] : [NULL, dword(NULL)]
|
39
|
+
Error.check super(hkey, index, name, name_len, NULL, type, data, data_len)
|
40
|
+
const_get(:RegEnumValueResult)[
|
41
|
+
name[0, name_len.to_i], type.to_i, (data[0, data_len.to_i] unless NULL == data), data_len.to_i
|
42
|
+
]
|
43
|
+
end
|
44
|
+
|
45
|
+
const_set :RegEnumValueResult, Mores::ImmutableStruct.new(
|
46
|
+
*%i[name type data data_len],
|
47
|
+
strict: true
|
48
|
+
)
|
49
|
+
|
50
|
+
extern 'long RegGetValueW(PVOID, LPCSTR, LPCSTR, DWORD, DWORD*, BYTE*, DWORD*)' \
|
51
|
+
do |hkey, subkey, name, flags: RRF_RT_ANY, data_len: nil|
|
52
|
+
type = dword(NULL)
|
53
|
+
data, data_len = data_len ? [byte(0) * data_len, dword(data_len)] : [NULL, dword(NULL)]
|
54
|
+
Error.check super(hkey, wstr(subkey), wstr(name), flags, type, data, data_len)
|
55
|
+
const_get(:RegGetValueResult)[
|
56
|
+
type.to_i, (data[0, data_len.to_i] unless NULL == data), data_len.to_i
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
const_set :RegGetValueResult, Mores::ImmutableStruct.new(
|
61
|
+
*%i[type data data_len],
|
62
|
+
strict: true
|
63
|
+
)
|
64
|
+
|
65
|
+
extern 'long RegSetValueExW(PVOID, LPCSTR, DWORD, DWORD, BYTE*, DWORD)' \
|
66
|
+
do |hkey, name, type, data|
|
67
|
+
data_len = data ? data.bytesize : 0
|
68
|
+
Error.check super(hkey, wstr(name), 0, type, data, data_len)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fontina::Windows::Win32
|
2
|
+
|
3
|
+
NULL = 0
|
4
|
+
MAX_PATH = 260
|
5
|
+
|
6
|
+
ERROR_SUCCESS = 0
|
7
|
+
ERROR_MORE_DATA = 234
|
8
|
+
ERROR_NO_MORE_ITEMS = 259
|
9
|
+
|
10
|
+
FORMAT_MESSAGE_FROM_SYSTEM = 0x1000
|
11
|
+
FORMAT_MESSAGE_IGNORE_INSERTS = 0x0200
|
12
|
+
|
13
|
+
HWND_BROADCAST = 0xffff
|
14
|
+
|
15
|
+
WM_FONTCHANGE = 0x001d
|
16
|
+
|
17
|
+
CSIDL_FONTS = 0x0014
|
18
|
+
|
19
|
+
SHGFP_TYPE_CURRENT = 0
|
20
|
+
SHGFP_TYPE_DEFAULT = 1
|
21
|
+
|
22
|
+
HKEY_LOCAL_MACHINE = 0x80000002
|
23
|
+
|
24
|
+
KEY_READ = 0x20019
|
25
|
+
KEY_WRITE = 0x20006
|
26
|
+
|
27
|
+
REG_SZ = 1
|
28
|
+
|
29
|
+
RRF_RT_ANY = 0x0000ffff
|
30
|
+
RRF_RT_REG_SZ = 0x00000002
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fontina::Windows
|
2
|
+
|
3
|
+
module Win32
|
4
|
+
def self.dlload(name)
|
5
|
+
const_set(name, Module.new do
|
6
|
+
extend Importer
|
7
|
+
dlload "#{name}.dll"
|
8
|
+
include Fiddle::Win32Types
|
9
|
+
|
10
|
+
instance_eval &Proc.new if block_given?
|
11
|
+
end)
|
12
|
+
end
|
13
|
+
|
14
|
+
module Importer
|
15
|
+
include Fiddle::Importer
|
16
|
+
include Marshal
|
17
|
+
|
18
|
+
def extern(*)
|
19
|
+
super.tap { |fn| decorators.send(:define_method, fn.name, &Proc.new) if block_given? }
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def decorators
|
25
|
+
@decorators ||= Module.new.tap { |m| singleton_class.prepend m }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fontina::Windows::Win32
|
2
|
+
|
3
|
+
class Error < StandardError
|
4
|
+
attr_reader :code
|
5
|
+
|
6
|
+
def initialize(code)
|
7
|
+
@code = code
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
@message ||= begin
|
12
|
+
Kernel32.FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, code, 1024).rstrip
|
13
|
+
rescue Error
|
14
|
+
'0x%04x' % code
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def raise_last
|
20
|
+
raise new Kernel32.GetLastError()
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_last
|
24
|
+
check Kernel32.GetLastError()
|
25
|
+
end
|
26
|
+
|
27
|
+
def check(code)
|
28
|
+
raise new code unless ERROR_SUCCESS == code
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_hr(code)
|
32
|
+
raise new code unless 0 == code[31]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fontina::Windows::Win32
|
2
|
+
|
3
|
+
dlload :Kernel32 do
|
4
|
+
extern 'DWORD GetLastError()'
|
5
|
+
|
6
|
+
extern 'DWORD FormatMessageW(DWORD, PVOID, DWORD, DWORD, LPSTR, DWORD, PVOID)' \
|
7
|
+
do |flags, message_id, len, source: NULL, language_id: 0|
|
8
|
+
flags |= FORMAT_MESSAGE_IGNORE_INSERTS
|
9
|
+
buffer = wchar(0) * len
|
10
|
+
len = super(flags, source, message_id, language_id, buffer, len, NULL)
|
11
|
+
Error.raise_last if 0 == len
|
12
|
+
buffer[0, len]
|
13
|
+
end
|
14
|
+
|
15
|
+
extern 'WORD GetSystemDefaultUILanguage()'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Fontina::Windows::Win32
|
2
|
+
|
3
|
+
dlload :Shell32 do
|
4
|
+
extern 'long SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPSTR)' \
|
5
|
+
do |folder, token: NULL, flags: SHGFP_TYPE_CURRENT|
|
6
|
+
path = wchar(0) * MAX_PATH
|
7
|
+
Error.check_hr super(NULL, folder, token, flags, path)
|
8
|
+
path.rstrip
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
%w[
|
2
|
+
constants
|
3
|
+
dlload
|
4
|
+
error
|
5
|
+
kernel32
|
6
|
+
user32
|
7
|
+
shell32
|
8
|
+
gdi32
|
9
|
+
advapi32
|
10
|
+
].each { |file| require_relative "win32/#{file}" }
|
11
|
+
|
12
|
+
module Fontina::Windows
|
13
|
+
|
14
|
+
module Win32
|
15
|
+
private_constant *constants
|
16
|
+
end
|
17
|
+
private_constant :Win32
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
%w[
|
2
|
+
fontina
|
3
|
+
fiddle
|
4
|
+
fiddle/types
|
5
|
+
].each { |lib| require lib }
|
6
|
+
|
7
|
+
%w[
|
8
|
+
version
|
9
|
+
language_codes
|
10
|
+
marshal
|
11
|
+
win32
|
12
|
+
package
|
13
|
+
meta_package
|
14
|
+
install
|
15
|
+
].each { |file| require "fontina/windows/#{file}" }
|
16
|
+
|
17
|
+
module Fontina::Windows
|
18
|
+
include Win32
|
19
|
+
extend Marshal
|
20
|
+
|
21
|
+
def self.system_language
|
22
|
+
@system_language ||= LANGUAGE_CODES.fetch Kernel32.GetSystemDefaultUILanguage()
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.fonts_directory
|
26
|
+
@fonts_directory ||= Shell32.SHGetFolderPathW(CSIDL_FONTS).encode('filesystem').freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.registered_fonts
|
30
|
+
key = Advapi32.RegOpenKeyExW(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', KEY_READ)
|
31
|
+
begin
|
32
|
+
Advapi32.RegQueryInfoKeyW(key)
|
33
|
+
.tap do |info|
|
34
|
+
break info.value_count.times.map do |i|
|
35
|
+
Advapi32.RegEnumValueW(key, i, name_len: info.max_name_len + 1, data_len: info.max_data_len)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
.reject { |value| value.type != REG_SZ }
|
39
|
+
.map { |value| [value.name, wstr!(value.data).rstrip.encode('filesystem')] }
|
40
|
+
.to_h
|
41
|
+
ensure
|
42
|
+
Advapi32.RegCloseKey(key)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.add_font_resource(path)
|
47
|
+
Gdi32.AddFontResourceW(path).tap do |count|
|
48
|
+
User32.PostMessageW(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) if 0 < count
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.register_font(name, path)
|
53
|
+
key = Advapi32.RegOpenKeyExW(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', KEY_WRITE)
|
54
|
+
begin
|
55
|
+
Advapi32.RegSetValueExW(key, name, REG_SZ, wstr(path) + wchar(0))
|
56
|
+
ensure
|
57
|
+
Advapi32.RegCloseKey(key)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fontina-windows
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Petter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fontina
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mores
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
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: rspec-its
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
97
|
+
description: |2
|
98
|
+
Installs font files in Windows.
|
99
|
+
email: michaeljpetter@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- fontina-windows.gemspec
|
108
|
+
- lib/fontina/windows.rb
|
109
|
+
- lib/fontina/windows/install.rb
|
110
|
+
- lib/fontina/windows/marshal.rb
|
111
|
+
- lib/fontina/windows/meta_package.rb
|
112
|
+
- lib/fontina/windows/package.rb
|
113
|
+
- lib/fontina/windows/version.rb
|
114
|
+
- lib/fontina/windows/win32.rb
|
115
|
+
- lib/fontina/windows/win32/advapi32.rb
|
116
|
+
- lib/fontina/windows/win32/constants.rb
|
117
|
+
- lib/fontina/windows/win32/dlload.rb
|
118
|
+
- lib/fontina/windows/win32/error.rb
|
119
|
+
- lib/fontina/windows/win32/gdi32.rb
|
120
|
+
- lib/fontina/windows/win32/kernel32.rb
|
121
|
+
- lib/fontina/windows/win32/shell32.rb
|
122
|
+
- lib/fontina/windows/win32/user32.rb
|
123
|
+
homepage: http://github.com/michaeljpetter/fontina-windows
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.4.8
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: A cheesy windows font extension
|
147
|
+
test_files: []
|