fontisan 0.4.28 → 0.4.29
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80a76c3d84f5bbd6f7750df7505b1d7c5c3e6f4396ebefe3238705cef8dece02
|
|
4
|
+
data.tar.gz: 96fa6ad2df65fd9e1c4ecaa1b15f1948b05537d63b708e4fde8ce9b72809cc0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8718892c5630fb4e3371e42d5cf942a1080d1dc7f54213d55ef778d897c6a46ae276739045c353e7ea76a1241709b27564b5983458ae21557d1192b86b004abc
|
|
7
|
+
data.tar.gz: 1831e3bdc8f2715559a41f036b2e6f20a54d5e941192fa1620fad0b3331c2fa0acc7495e61c1eebfa0e3c939d22fcbd852eddbf86a22b5b12604fed378bb0b06
|
data/docs/guide/cli/subset.md
CHANGED
|
@@ -93,9 +93,9 @@ The `--profile` option controls which font tables the subset retains. The right
|
|
|
93
93
|
|
|
94
94
|
| Profile | When to use | Notable tables dropped |
|
|
95
95
|
|---------|-------------|------------------------|
|
|
96
|
-
| `pdf` (default) | PDF embedding, smallest valid output | GSUB, GPOS
|
|
97
|
-
| `web` | Browser/web font, **retains color-emoji bitmaps** | nothing that browsers need |
|
|
98
|
-
| `minimal` | Absolute smallest core that still renders | glyf/loca,
|
|
96
|
+
| `pdf` (default) | PDF embedding, smallest valid output | GSUB, GPOS |
|
|
97
|
+
| `web` | Browser/web font, **retains color-emoji bitmaps + CFF outlines** | nothing that browsers need |
|
|
98
|
+
| `minimal` | Absolute smallest core that still renders | glyf/loca, CFF/CFF2, GSUB/GPOS |
|
|
99
99
|
| `full` | Lossless re-export | (none) |
|
|
100
100
|
|
|
101
101
|
```bash
|
|
@@ -38,7 +38,7 @@ pdf:
|
|
|
38
38
|
- post
|
|
39
39
|
- loca
|
|
40
40
|
- glyf
|
|
41
|
-
- CFF
|
|
41
|
+
- "CFF "
|
|
42
42
|
- CFF2
|
|
43
43
|
|
|
44
44
|
# Web Profile: Tables required for web font usage
|
|
@@ -55,7 +55,7 @@ web:
|
|
|
55
55
|
- post
|
|
56
56
|
- loca
|
|
57
57
|
- glyf
|
|
58
|
-
- CFF
|
|
58
|
+
- "CFF "
|
|
59
59
|
- CFF2
|
|
60
60
|
- GSUB
|
|
61
61
|
- GPOS
|
|
@@ -98,7 +98,7 @@ full:
|
|
|
98
98
|
- GDEF
|
|
99
99
|
- BASE
|
|
100
100
|
- JSTF
|
|
101
|
-
- CFF
|
|
101
|
+
- "CFF "
|
|
102
102
|
- CFF2
|
|
103
103
|
- VORG
|
|
104
104
|
- kern
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fontisan
|
|
4
|
+
module Subset
|
|
5
|
+
module TableStrategy
|
|
6
|
+
# CFF (Compact Font Format) subsetter strategy.
|
|
7
|
+
#
|
|
8
|
+
# Subsets CFF tables by routing through the UFO model:
|
|
9
|
+
#
|
|
10
|
+
# source font → Ufo::Convert::FromBinData → UFO (with contours)
|
|
11
|
+
# → filter glyphs to mapping →
|
|
12
|
+
# → Ufo::Compile::Cff.build → new CFF bytes
|
|
13
|
+
#
|
|
14
|
+
# This is the architecturally preferred path: the UFO model is
|
|
15
|
+
# the canonical representation, CFF is a serialization. The
|
|
16
|
+
# strategy reuses the existing compile pipeline rather than
|
|
17
|
+
# reimplementing CFF INDEX arithmetic.
|
|
18
|
+
#
|
|
19
|
+
# Glyphs not in the mapping are dropped from the UFO before
|
|
20
|
+
# compilation. The Cff.build pipeline generates the correct
|
|
21
|
+
# charset (GID → SID mapping) from the retained glyph names.
|
|
22
|
+
#
|
|
23
|
+
# See TODO #15 for the full design rationale and the CFF2
|
|
24
|
+
# extension path.
|
|
25
|
+
class Cff
|
|
26
|
+
# @param context [SubsetContext]
|
|
27
|
+
# @param tag [String] "CFF "
|
|
28
|
+
# @param table [Object] parsed CFF table (unused — we work
|
|
29
|
+
# from the source font directly)
|
|
30
|
+
# @return [String] subset CFF table bytes
|
|
31
|
+
def self.call(context:, tag:, table:)
|
|
32
|
+
source_font = context.font
|
|
33
|
+
mapping = context.mapping
|
|
34
|
+
|
|
35
|
+
ufo = Ufo::Convert::FromBinData.convert(source_font)
|
|
36
|
+
filter_ufo_glyphs!(ufo, mapping)
|
|
37
|
+
|
|
38
|
+
# Rename the first glyph (source GID 0) to .notdef so the
|
|
39
|
+
# CFF compiler's charset generation produces a valid .notdef
|
|
40
|
+
# entry at GID 0.
|
|
41
|
+
first_name = ufo.glyphs.keys.first
|
|
42
|
+
if first_name && first_name != ".notdef"
|
|
43
|
+
notdef = ufo.glyphs.delete(first_name)
|
|
44
|
+
notdef = Ufo::Glyph.new(name: ".notdef") if notdef.nil?
|
|
45
|
+
ufo.glyphs[".notdef"] = notdef
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
glyphs = ufo.layers.default_layer.each.to_a
|
|
49
|
+
Fontisan::Ufo::Compile::Cff.build(ufo, glyphs: glyphs)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Drop glyphs from the UFO that are not in the mapping's
|
|
53
|
+
# new-id set. Keeps .notdef (GID 0) regardless of mapping.
|
|
54
|
+
#
|
|
55
|
+
# @param ufo [Ufo::Font]
|
|
56
|
+
# @param mapping [GlyphMapping]
|
|
57
|
+
def self.filter_ufo_glyphs!(ufo, mapping)
|
|
58
|
+
retained_old_ids = Set.new(mapping.old_ids)
|
|
59
|
+
|
|
60
|
+
# The UFO doesn't carry GID info after conversion; we rely
|
|
61
|
+
# on the mapping's old_ids. Since the UFO was converted
|
|
62
|
+
# from the same source font, the UFO glyph order matches
|
|
63
|
+
# the source GID order. So GID N in the source = Nth glyph
|
|
64
|
+
# added to the UFO default layer.
|
|
65
|
+
all_names = ufo.glyphs.keys
|
|
66
|
+
names_to_keep = all_names.each_with_index.with_object(Set.new) do |(name, gid), keep|
|
|
67
|
+
keep << name if retained_old_ids.include?(gid)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Always keep .notdef
|
|
71
|
+
names_to_keep << ".notdef" if all_names.any?(".notdef")
|
|
72
|
+
|
|
73
|
+
ufo.glyphs.select! { |name, _| names_to_keep.include?(name) }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Ensure .notdef is present at GID 0. The CFF compiler
|
|
77
|
+
# expects it.
|
|
78
|
+
#
|
|
79
|
+
# @param ufo [Ufo::Font]
|
|
80
|
+
def self.ensure_notdef_present!(ufo)
|
|
81
|
+
return if ufo.glyphs.key?(".notdef")
|
|
82
|
+
|
|
83
|
+
notdef = Ufo::Glyph.new(name: ".notdef")
|
|
84
|
+
notdef.width = 0
|
|
85
|
+
ufo.layers.default_layer.add(notdef)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private_class_method :filter_ufo_glyphs!, :ensure_notdef_present!
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -16,6 +16,7 @@ module Fontisan
|
|
|
16
16
|
module TableStrategy
|
|
17
17
|
autoload :Cblc, "fontisan/subset/table_strategy/cblc"
|
|
18
18
|
autoload :Cbdt, "fontisan/subset/table_strategy/cbdt"
|
|
19
|
+
autoload :Cff, "fontisan/subset/table_strategy/cff"
|
|
19
20
|
autoload :Cmap, "fontisan/subset/table_strategy/cmap"
|
|
20
21
|
autoload :ColorBitmapPlacement,
|
|
21
22
|
"fontisan/subset/table_strategy/color_bitmap_placement"
|
|
@@ -55,6 +56,7 @@ module Fontisan
|
|
|
55
56
|
"name" => :Name,
|
|
56
57
|
"head" => :Head,
|
|
57
58
|
"OS/2" => :Os2,
|
|
59
|
+
"CFF " => :Cff,
|
|
58
60
|
"CBDT" => :Cbdt,
|
|
59
61
|
"CBLC" => :Cblc,
|
|
60
62
|
}.freeze
|
data/lib/fontisan/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fontisan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.29
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -485,6 +485,7 @@ files:
|
|
|
485
485
|
- lib/fontisan/subset/table_strategy.rb
|
|
486
486
|
- lib/fontisan/subset/table_strategy/cbdt.rb
|
|
487
487
|
- lib/fontisan/subset/table_strategy/cblc.rb
|
|
488
|
+
- lib/fontisan/subset/table_strategy/cff.rb
|
|
488
489
|
- lib/fontisan/subset/table_strategy/cmap.rb
|
|
489
490
|
- lib/fontisan/subset/table_strategy/color_bitmap_placement.rb
|
|
490
491
|
- lib/fontisan/subset/table_strategy/color_bitmap_strike_plan.rb
|