Skip to content

Commit 8542664

Browse files
committed
Tweak glyf table html generation
- Exclude glyphs that are empty and also have no referring character. - Allow calling method to specify how many glyphs to generate.
1 parent 41489fb commit 8542664

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/FontLib/Table/Type/glyf.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getGlyphIDs($gids = array()) {
4848
return array_unique(array_merge($gids, $glyphIDs));
4949
}
5050

51-
public function toHTML() {
51+
public function toHTML($n = 500) {
5252
$max = 160;
5353
$font = $this->getFont();
5454

@@ -74,8 +74,6 @@ public function toHTML() {
7474
$height = round($height / $ratio);
7575
}
7676

77-
$n = 500;
78-
7977
$s = "<h3>" . "Only the first $n simple glyphs are shown (" . count($this->data) . " total)
8078
<div class='glyph-view simple'>Simple glyph</div>
8179
<div class='glyph-view composite'>Composite glyph</div>
@@ -111,6 +109,11 @@ public function toHTML() {
111109
$name = isset($names[$g]) ? $names[$g] : sprintf("uni%04x", $char);
112110
$char = $char ? "&#{$glyphIndexArray[$g]};" : "";
113111

112+
if ($char === "" && empty($shape["SVGContours"])) {
113+
$n++;
114+
continue;
115+
}
116+
114117
$s .= "<div class='glyph-view $type' id='glyph-$g'>
115118
<span class='glyph-id'>$g</span>
116119
<span class='char'>$char</span>

0 commit comments

Comments
 (0)