summaryrefslogtreecommitdiff
path: root/vdrsymbols/insert_vdr_symbols.pe
blob: f750f592c8e0d9c3393fbf6bb3b78b24ab720cc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/fontforge

# This is a small FontForge script that extracts symbols from <source font>
# starting at unicode position "uni_from" until "uni_to" and copies them to
# the same positions in <destination font>.
#
# The <destination font> infos will be modified:
# "VDR" will be prepended to fontname, fontfamily, fullname and its filename.
# The suffix will be changed to ".ttf" and a truetype font will be exported.
# Because of these changes you shouldn't reuse a generated font as
# <destination font> (it'll lead to "VDRVDRVDRVDRMyMegaFont.ttf").
#
# You can use "--insert-for-old-plugins" to generate a font that also has the VDR
# symbols at the positions they used to be (128-134, 239, 244, 245, 249-251,
# 253, 255). This is only useful for old plugins/patches that expect them there.
#
# You can use "--insert-iso" to generate a font that also has the VDR symbols at
# the positions 128 to 146. These can be used by recent plugins like ExtRecMenu v1.2,
# NordlichtsEPG v0.9.

uni_from = 0ue000
uni_to   = 0ue01c
iso_from = 128
iso_to   = 156

insert_iso = 0
insert_for_old_plugins = 0
file_from = ""
file_to   = ""
export_only = 0
gen_default = 0
gen_default_bold = 0

while ( $argc > 1 )
  temp = $1

  if ( temp == "--insert-iso" )
		if ( insert_for_old_plugins == 1 )
			Print()
			Print("Only --insert-iso OR --insert-for-old-plugins allowed!");
			Quit(1)
		endif
	  insert_iso = 1
  elseif ( temp == "--insert-for-old-plugins" )
		if ( insert_iso == 1 )
			Print()
			Print("Only --insert-iso OR --insert-for-old-plugins allowed!");
			Quit(1)
		endif
		insert_for_old_plugins = 1
	elseif ( temp == "--gen-default" )
		Print()
		Print("Creating default VDRSymbolsSans.ttf...")
		gen_default = 1
		gen_default_bold = 0
	elseif ( temp == "--gen-default-bold" )
		Print()
		Print("Creating default VDRSymbolsSans-Bold.ttf...")
		gen_default = 1
		gen_default_bold = 1
	elseif ( file_from == "" )
	  file_from = temp
	elseif ( file_to == "" )
	  file_to = temp
	else
		Print()
		Print("Usage: insert_vdr_symbols.pe [--insert-iso|--insert-for-old-plugins] <source font> <destination font>")
		Quit(1)
  endif
  shift
endloop

if ( file_from == "")
	Print()
	Print("Usage: insert_vdr_symbols.pe [--insert-iso|--insert-for-old-plugins] <source font> <destination font>")
	Quit(1)
endif
if ( file_to == "")
	Print()
	Print("Exporting font to TTF")
	if ( Strcasecmp(Strsub(file_from, Strlen(file_from) - 4), ".ttf") == 0 )
		Print()
		Print("ERROR: Cannot export TTF to TTF!")
		Quit(1)
	endif
	file_to = Strsub(file_from, 0, Strlen(file_from) - 4) + ".ttf"
	export_only = 1
endif

Open(file_from)
if ( export_only == 1 )
	Generate(file_to)
	new_fontname = $fontname
	new_familyname = $familyname
	new_fullname = $fullname
	new_filename = file_to
endif
Select(uni_from, uni_to)
Copy()
Close()

Open(file_to)
if ( export_only == 0 )
	if ( gen_default == 1 )
		if ( gen_default_bold == 0 )
			new_fontname = "VDRSymbolsSans"
			new_familyname = "VDRSymbols Sans"
			new_fullname = "VDRSymbols Sans"
			new_filename = "VDRSymbolsSans.ttf"
		elseif ( gen_default_bold == 1 )
			new_fontname = "VDRSymbolsSans-Bold"
			new_familyname = "VDRSymbols Sans"
			new_fullname = "VDRSymbols Sans Bold"
			new_filename = "VDRSymbolsSans-Bold.ttf"
		endif

		new_fontversion = $fontversion + "-" + Strftime("%Y%m%d")
		new_copyright = $copyright + "\nCopyright (c) 2010 by Andreas Mair. All Rights Reserved.\nVDRSymbols changes are in public domain"

		SetFontNames(new_fontname, new_familyname, new_fullname, $weight, new_copyright, new_fontversion)

		# See http://fontforge.sourceforge.net/scripting-alpha.html#SetTTFName
		SetTTFName(0x409, 0, new_copyright)                             # Copyright
		SetTTFName(0x409, 5, "Version " + new_fontversion)              # Version
		SetTTFName(0x409, 8, "Andreas Mair")                            # Manufacturer
		SetTTFName(0x409, 11, "http://andreas.vdr-developer.org/fonts") # Vendor URL
	else
		new_fontname = "VDR" + $fontname
		new_familyname = "VDR" + $familyname
		new_fullname = "VDR" + $fullname
		new_filename = "VDR" + file_to

		SetFontNames(new_fontname, new_familyname, new_fullname)
	endif

	# See http://fontforge.sourceforge.net/scripting-alpha.html#SetTTFName
	SetTTFName(0x409, 3, new_familyname)  # Unique font identifier
	SetTTFName(0x409, 16, new_familyname) # Prefered family
	SetUniqueID(0)
endif

Print("Inserting symbols from " + ToString(uni_from) + " to " + ToString(uni_to));
Select(uni_from, uni_to)
Paste()

if ( Strcasecmp(Strsub(new_filename, Strlen(new_filename) - 4), ".ttf") != 0 )
	new_filename = new_filename + ".ttf"
endif

# (optionally) copy characters to positions suggested by Martin Prochnow (nordlicht)
if ( insert_iso == 1 )
	Print("Inserting symbols from " + ToString(iso_from) + " to " + ToString(iso_to));
	Select(iso_from, iso_to)
	Paste()
endif

# (optionally) copy characters to bytes 129...
if ( insert_for_old_plugins == 1 )
	Print("Inserting symbols at old locations");
	# Resume
	Select(0ue000)
	Copy()
	Select(128)
	Paste()

  # DVD
	Select(0ue001)
	Copy()
	Select(129)
	Paste()

  # Folder
	Select(0ue002)
	Copy()
	Select(130)
	Paste()

  # Space
	Select(0ue003)
	Copy()
	Select(131)
	Paste()

  # Cutting
	Select(0ue004)
	Copy()
	Select(132)
	Paste()

  # Move
	Select(0ue005)
	Copy()
	Select(133)
	Paste()

  ## Move folder
	Select(0ue006)
	Copy()
	Select(134)
	Paste()

  # Progressbar 
	#Select(0ue007)
	#Copy()
	#Select()
	#Paste()
	#Select(0ue008)
	#Copy()
	#Select()
	#Paste()
	#Select(0ue009)
	#Copy()
	#Select()
	#Paste()
	#Select(0ue00A)
	#Copy()
	#Select()
	#Paste()

  # REC
	Select(0ue00B)
	Copy()
	Select(249)
	Paste()

  # Clock
	Select(0ue00C)
	Copy()
	Select(253)
	Paste()

  # TV crypted
	Select(0ue00D)
	Copy()
	Select(239)
	Paste()

  # Radio
	Select(0ue00E)
	Copy()
	Select(244)
	Paste()

  # TV
	Select(0ue00F)
	Copy()
	Select(245)
	Paste()

  # NEW
	Select(0ue010)
	Copy()
	Select(250)
	Paste()

  # Repeating Timer
	Select(0ue011)
	Copy()
	Select(255)
	Paste()

  # Running
	Select(0ue012)
	Copy()
	Select(251)
	Paste()

  # HDD archive
	Select(0ue01c)
	Copy()
	Select(251)
	Paste()
endif

Print("Writing " + new_filename);
Generate(new_filename)
Close()

Quit(0)