Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

strip extended characters from postscript names

This is extreme, but TTF fonts are _supposed_ to have ASCII
postscript names anyway...
  • Loading branch information...
commit c5a8171a6721adea44c1db338306ee1dcdd504f8 1 parent 158a82a
@jamis jamis authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/ttfunk/table/name.rb
View
8 lib/ttfunk/table/name.rb
@@ -14,6 +14,12 @@ def initialize(text, platform_id, encoding_id, language_id)
@encoding_id = encoding_id
@language_id = language_id
end
+
+ def strip_extended
+ stripped = gsub(/[\x00-\x19\x80-\xff]/n, "")
+ stripped = "[not-postscript]" if stripped.empty?
+ return stripped
+ end
end
attr_reader :strings
@@ -100,7 +106,7 @@ def parse!
@unique_subfamily = @strings[3]
@font_name = @strings[4]
@version = @strings[5]
- @postscript_name = @strings[6].first # should only be ONE postscript name
+ @postscript_name = @strings[6].first.strip_extended # should only be ONE postscript name
@trademark = @strings[7]
@manufacturer = @strings[8]
@designer = @strings[9]
Please sign in to comment.
Something went wrong with that request. Please try again.