mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-28 17:20:22 +00:00
Add Printer Font ASCII to recognised PostScript extensions (#3734)
* Register Adobe Type 1 fonts as PostScript files * Add logic for recognising generated PFA files * Extend list of PostScript generators
This commit is contained in:
@@ -244,7 +244,11 @@ module Linguist
|
||||
#
|
||||
# Returns true or false.
|
||||
def generated_postscript?
|
||||
return false unless ['.ps', '.eps'].include? extname
|
||||
return false unless ['.ps', '.eps', '.pfa'].include? extname
|
||||
|
||||
# Type 1 and Type 42 fonts converted to PostScript are stored as hex-encoded byte streams; these
|
||||
# streams are always preceded the `eexec` operator (if Type 1), or the `/sfnts` key (if Type 42).
|
||||
return true if data =~ /(\n|\r\n|\r)\s*(?:currentfile eexec\s+|\/sfnts\s+\[\1<)\h{8,}\1/
|
||||
|
||||
# We analyze the "%%Creator:" comment, which contains the author/generator
|
||||
# of the file. If there is one, it should be in one of the first few lines.
|
||||
@@ -254,10 +258,12 @@ module Linguist
|
||||
# Most generators write their version number, while human authors' or companies'
|
||||
# names don't contain numbers. So look if the line contains digits. Also
|
||||
# look for some special cases without version numbers.
|
||||
return creator =~ /[0-9]/ ||
|
||||
creator.include?("mpage") ||
|
||||
creator.include?("draw") ||
|
||||
creator.include?("ImageMagick")
|
||||
return true if creator =~ /[0-9]|draw|mpage|ImageMagick|inkscape|MATLAB/ ||
|
||||
creator =~ /PCBNEW|pnmtops|\(Unknown\)|Serif Affinity|Filterimage -tops/
|
||||
|
||||
# EAGLE doesn't include a version number when it generates PostScript.
|
||||
# However, it does prepend its name to the document's "%%Title" field.
|
||||
!!creator.include?("EAGLE") and lines[0..4].find {|line| line =~ /^%%Title: EAGLE Drawing /}
|
||||
end
|
||||
|
||||
def generated_go?
|
||||
|
||||
@@ -3325,6 +3325,7 @@ PostScript:
|
||||
extensions:
|
||||
- ".ps"
|
||||
- ".eps"
|
||||
- ".pfa"
|
||||
tm_scope: source.postscript
|
||||
aliases:
|
||||
- postscr
|
||||
|
||||
78
samples/PostScript/lambda.pfa
Normal file
78
samples/PostScript/lambda.pfa
Normal file
@@ -0,0 +1,78 @@
|
||||
%!PS-AdobeFont-1.0: Greek_Lambda_Character-Regular 020.017
|
||||
%%Title: Greek_Lambda_Character-Regular
|
||||
%Version: 020.017
|
||||
%%CreationDate: Sun Jul 23 23:14:02 2017
|
||||
%%Creator: John Gardner /ThatGuyLinguistWatchersAreSickOf
|
||||
%Copyright: NONE. NADA. PUBLIC DOMAIN, BOI
|
||||
% Generated by FontForge 20170719 (http://fontforge.sf.net/)
|
||||
%%EndComments
|
||||
|
||||
10 dict begin
|
||||
/FontType 1 def
|
||||
/FontMatrix [0.000488281 0 0 0.000488281 0 0 ]readonly def
|
||||
/FontName /Greek_Lambda_Character-Regular def
|
||||
/FontBBox {68 -362 1158 1556 }readonly def
|
||||
/PaintType 0 def
|
||||
/FontInfo 11 dict dup begin
|
||||
/version (020.017) readonly def
|
||||
/Notice (NONE. NADA. PUBLIC DOMAIN, BOI) readonly def
|
||||
/FullName (Greek_Lambda_Character Regular) readonly def
|
||||
/FamilyName (Greek_Lambda_Character) readonly def
|
||||
/Weight (Regular) readonly def
|
||||
/FSType 8 def
|
||||
/ItalicAngle 0 def
|
||||
/isFixedPitch false def
|
||||
/UnderlinePosition -175 def
|
||||
/UnderlineThickness 90 def
|
||||
/ascent 1556 def
|
||||
end readonly def
|
||||
/Encoding 256 array
|
||||
0 1 255 { 1 index exch /.notdef put} for
|
||||
dup 13/uni000D put
|
||||
dup 32/space put
|
||||
readonly def
|
||||
currentdict end
|
||||
currentfile eexec
|
||||
743F8413F3636CA85A9FFEFB50B4BB27302A5F6C876586CCC1670A7EF5521E6ADE15AAB4
|
||||
DD2DDDB83735311FC63DB80D2C96AECFA05BB67F865EA35934B4B79A203A8DD489B09C79
|
||||
FF6EB9DBCFD889C3E73F8C94BC342AF671D6F688870A62EE1A0DF216E150FFEC64A8C2B7
|
||||
509AD05C011599C1AD84E6C4B668E07EA219BD72663D8AF4CA8EC8E23AA90DE90BE940C6
|
||||
6DB849CEDB3B64961365A7CCE47F4FC9E30FDEE4B14B90C2E0D8C344EBC974EABF417B3D
|
||||
28251A78ACEE2BFC4212B1E3E9C7EBC3262821EE98E538713C64DF0BC13C19337B1307DE
|
||||
427F2C8C4FF2126B9FF99DDDFB332AF3EBCD23349171C5C7E66B1C53EF39C35516C0DC7D
|
||||
D6F70D59C28603519559B710C0128C22BA268D330AE02690534939E5B58BAAB00A59B0E6
|
||||
E515E80A04F2B315A00FB1CA49A4B0259167BBA9852544092955FE0883DBCD89B739AA94
|
||||
8C6277B54019E9870B44E5A998F0F2175545F602CC4630E4BE01E35F4CEFDD7D1B737358
|
||||
1B2D6F612B23AFAF221AB18CD868E7548EE5064762971F8868940F26134CA7BB40734220
|
||||
06EEBE10B5F5251FE36B0E794D8B0D7AC814F4C30BB5A0435C203748B40217BEAF506328
|
||||
D30E9417382B228FF6DF97A71135B613CC3EF4CDD8276711842C3DB0D31A25883544FFF5
|
||||
D8719874AD10816F3EB272D5C245440127B9F2967DC46EAF4BED77FF2C2585A355EB586E
|
||||
09BE8BA3D104EA174EA004DCE00066F7606EEF55376E332566235B8F4283D63E2AE5F2E3
|
||||
6A6940BED4FA83C6E82C444B2D790BAA36E641908C61F6409CA09D9723B2F169BE42B166
|
||||
5E704AA69D594B2A22C631D030029B772C3C200A0A483A13403E2EF19274B73860FFEA37
|
||||
521C65865A79A5429EED01C0F95AB6F66F030BF14CCB42A6DA2435B74135BB5D35EF6DC6
|
||||
FE48D29690417795B9D7AA2A3D66B7A175F8B6C23AFB5A472343C2DFDCC242C27033DD6F
|
||||
B65B1CD5DC29B9DA455FAAC3A9408BB9B61C2B701741C34CE88EBFF05B7045CBEAC8788E
|
||||
548F0E642277D4F9AED30A3431070805910970243FD069130D641AFAE28754B1355618B8
|
||||
706D163027980F2A76A59E0B9D2FB92BF17943129A8A6FB15CBF6D376C464329E24A118B
|
||||
8E38987CDD4CD5F214B26D65BEEDB2ECD7502861747089298A653654062A3AD5AC4FC4AF
|
||||
5DEF7BDD4C5CDBC828A1F12235F68522B45BE0C2D6FB663B51E76BF559815F41C25EC7F8
|
||||
17A92B9E139F3E6D27A8512A261EE576459DE603F386516E46B8326574E900101A8D49C9
|
||||
E8798E734F56C4E2D78B14D6B14E96F3523F3F34464235C96F94609852F90A0A1B51CE14
|
||||
25EC76E65E5D1C5D2EEC730FC438F4083A806C67D0A1566D0E6EF70DC38E64DCA44DFA66
|
||||
20073E848BDFDB2B793AFE29B47917D87CB8320F48A7C083CAAD2CA20C25D705D78B33D5
|
||||
A5EAB8C671A57BBC3C896DE54C71B8F860B640B7C30199A2443353E3727FA99C168DB4E8
|
||||
ABE021B7DDB526E30B2075028BD8D387D32E025E458D05E3A25B9BC94ED54F7A0FCA3D61
|
||||
604D2F49A205CBDF5FBDD5D3E1D31C6F7310CC155982689FA1F5723DDAE2EDEB5E69F03C
|
||||
4CCDBBCB348E57AF222744A07DCCE69236EB29499A87C0A201EDD6A402EA23C035732184
|
||||
339049E8C101388304CD20EAA8554A9B6E4F2B126A0593F4401992E73F7BFEF89DE3DFDE
|
||||
DA548E3EE05D5B4EE0D114F916
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
cleartomark
|
||||
@@ -94,5 +94,8 @@ class TestGenerated < Minitest::Test
|
||||
|
||||
# roxygen2
|
||||
generated_sample_loading_data("R/import.Rd")
|
||||
|
||||
# PostScript
|
||||
generated_sample_loading_data("PostScript/lambda.pfa")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user