Class: TkFont
Overview
Defined Under Namespace
Modules: Chooser, CoreMethods
Classes: DescendantFont
Constant Summary
collapse
- TkCommandNames =
['font'.freeze].freeze
- Tk_FontNameTBL =
TkCore::INTERP.create_table
- Tk_FontUseTBL =
TkCore::INTERP.create_table
- OptionType =
option_type : default => string
Hash.new(?s)
- MetricType =
metric_type : default => num_or_str
Hash.new(?n)
- SYSTEM_FONT_NAMES =
[]
Constants included
from TkCore
TkCore::EventFlag, TkCore::INTERP, TkCore::INTERP_MUTEX, TkCore::INTERP_ROOT_CHECK, TkCore::INTERP_THREAD, TkCore::INTERP_THREAD_STATUS, TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD, TkCore::WIDGET_DESTROY_HOOK, TkCore::WITH_ENCODING, TkCore::WITH_RUBY_VM
Constants included
from TkComm
TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames
Constants included
from TkUtil
TkUtil::None, TkUtil::RELEASE_DATE
Constants included
from Tk
Tk::AUTO_PATH, Tk::Fontchooser, Tk::INTERP, Tk::JAPANIZED_TK, Tk::LIBRARY_PATH, Tk::MAINLOOP, Tk::PACKAGE_PATH, Tk::RELEASE_DATE, Tk::TCL_LIBRARY_PATH, Tk::TCL_MAJOR_VERSION, Tk::TCL_MINOR_VERSION, Tk::TCL_PACKAGE_PATH, Tk::TCL_PATCHLEVEL, Tk::TCL_PRECISION, Tk::TCL_VERSION, Tk::TK_MAJOR_VERSION, Tk::TK_MINOR_VERSION, Tk::TK_PATCHLEVEL, Tk::TK_VERSION, Tk::Tkextlib_RELEASE_DATE, Tk::TreeCtrl_Widget, Tk::X_Scrollable, Tk::Y_Scrollable
Tk::Encoding::BINARY, Tk::Encoding::BINARY_NAME, Tk::Encoding::DEFAULT_EXTERNAL_NAME, Tk::Encoding::DEFAULT_INTERNAL_NAME, Tk::Encoding::ENCODING_TABLE, Tk::Encoding::RubyEncoding, Tk::Encoding::UNKNOWN, Tk::Encoding::UTF8_NAME
Class Method Summary
collapse
-
.actual(fnt, option = nil) ⇒ Object
-
.actual_displayof(fnt, win, option = nil) ⇒ Object
-
.actual_hash(fnt, option = nil) ⇒ Object
-
.actual_hash_displayof(fnt, option = nil) ⇒ Object
-
.configinfo(fnt, slot = nil) ⇒ Object
-
.configure(fnt, slot, value = None) ⇒ Object
-
.create_copy(font) ⇒ Object
-
.current_configinfo(fnt, slot = nil) ⇒ Object
-
.failsafe(font) ⇒ Object
-
.families(win = nil) ⇒ Object
-
.get_obj(name) ⇒ Object
-
.init_widget_font(pathname, *args) ⇒ Object
-
.is_system_font?(fnt) ⇒ Boolean
-
.measure(fnt, text) ⇒ Object
-
.measure_displayof(fnt, win, text) ⇒ Object
-
.metrics(fnt, option = nil) ⇒ Object
-
.metrics_displayof(fnt, win, option = nil) ⇒ Object
-
.metrics_hash(fnt, option = nil) ⇒ Object
-
.metrics_hash_displayof(fnt, win, option = nil) ⇒ Object
-
.names ⇒ Object
-
.used_on(path = nil) ⇒ Object
Instance Method Summary
collapse
-
#[](slot) ⇒ Object
-
#[]=(slot, val) ⇒ Object
-
#actual(option = nil) ⇒ Object
-
#actual_displayof(win, option = nil) ⇒ Object
-
#actual_hash(option = nil) ⇒ Object
-
#actual_hash_displayof(win, option = nil) ⇒ Object
-
#call_font_configure(path, *args) ⇒ Object
-
#configinfo(slot = nil) ⇒ Object
-
#configure(slot, value = None) ⇒ Object
-
#current_configinfo(slot = nil) ⇒ Object
-
#delete ⇒ Object
-
#font ⇒ Object
(also: #font_id, #name, #to_s)
-
#id ⇒ Object
-
#inspect ⇒ Object
-
#kanji_actual(option = nil) ⇒ Object
-
#kanji_actual_displayof(win, option = nil) ⇒ Object
-
#kanji_actual_hash(option = nil) ⇒ Object
-
#kanji_actual_hash_displayof(win, option = nil) ⇒ Object
-
#kanji_configinfo(slot = nil) ⇒ Object
-
#kanji_configure(slot, value = None) ⇒ Object
-
#kanji_current_configinfo(slot = nil) ⇒ Object
-
#kanji_font ⇒ Object
(also: #kanjifont)
-
#kanji_font_id ⇒ Object
-
#kanji_metrics(option = nil) ⇒ Object
-
#kanji_metrics_displayof(win, option = nil) ⇒ Object
-
#kanji_metrics_hash(option = nil) ⇒ Object
-
#kanji_metrics_hash_displayof(win, option = nil) ⇒ Object
-
#kanji_replace(knj) ⇒ Object
-
#latin_actual(option = nil) ⇒ Object
(also: #ascii_actual)
-
#latin_actual_displayof(win, option = nil) ⇒ Object
(also: #ascii_actual_displayof)
-
#latin_actual_hash(option = nil) ⇒ Object
-
#latin_actual_hash_displayof(win, option = nil) ⇒ Object
-
#latin_configinfo(slot = nil) ⇒ Object
(also: #ascii_configinfo)
-
#latin_configure(slot, value = None) ⇒ Object
(also: #ascii_configure)
-
#latin_current_configinfo(slot = nil) ⇒ Object
-
#latin_font ⇒ Object
(also: #latinfont, #ascii_font)
-
#latin_font_id ⇒ Object
-
#latin_metrics(option = nil) ⇒ Object
(also: #ascii_metrics)
-
#latin_metrics_displayof(win, option = nil) ⇒ Object
-
#latin_metrics_hash(option = nil) ⇒ Object
-
#latin_metrics_hash_displayof(win, option = nil) ⇒ Object
-
#latin_replace(ltn) ⇒ Object
(also: #ascii_replace)
-
#measure(text) ⇒ Object
-
#measure_displayof(win, text) ⇒ Object
-
#method_missing(id, *args) ⇒ Object
-
#metrics(option = nil) ⇒ Object
-
#metrics_displayof(win, option = nil) ⇒ Object
-
#metrics_hash(option = nil) ⇒ Object
-
#metrics_hash_displayof(win, option = nil) ⇒ Object
-
#replace(ltn, knj = None) ⇒ Object
-
#reset_pointadjust ⇒ Object
-
#to_eval ⇒ Object
-
#used ⇒ Object
Methods included from TkCore
_tk_call_to_list_core, after, after_cancel, after_idle, appname, appsend, appsend_deny, appsend_displayof, callback, callback_break, callback_continue, callback_return, chooseColor, chooseDirectory, do_one_event, event_generate, getMultipleOpenFile, getMultipleSaveFile, getOpenFile, getSaveFile, get_eventloop_tick, get_eventloop_weight, get_no_event_wait, inactive, inactive_displayof, info, ip_eval, ip_eval_with_enc, ip_eval_without_enc, ip_invoke, ip_invoke_with_enc, ip_invoke_without_enc, is_mainloop?, load_cmd_on_ip, mainloop, mainloop_exist?, mainloop_thread?, mainloop_watchdog, messageBox, rb_appsend, rb_appsend_displayof, reset_inactive, reset_inactive_displayof, restart, scaling, scaling_displayof, set_eventloop_tick, set_eventloop_weight, set_no_event_wait, tk_call, tk_call_to_list, tk_call_to_list_with_enc, tk_call_to_list_without_enc, tk_call_to_simplelist, tk_call_to_simplelist_with_enc, tk_call_to_simplelist_without_enc, tk_call_with_enc, tk_call_without_enc, windowingsystem
Methods included from TkComm
_at, _callback_entry?, _callback_entry_class?, _curr_cmd_id, _fromUTF8, _genobj_for_tkwidget, _next_cmd_id, _toUTF8, array2tk_list, #bind, #bind_all, #bind_append, #bind_append_all, #bind_remove, #bind_remove_all, #bindinfo, #bindinfo_all, bool, image_obj, #install_cmd, install_cmd, list, num_or_nil, num_or_str, number, procedure, simplelist, slice_ary, string, #subst, tk_tcl2ruby, uninstall_cmd, #uninstall_cmd, window
Methods included from TkEvent
#install_bind, #install_bind_for_event_class
Methods included from TkUtil
#_conv_args, _conv_args, #_fromUTF8, #_get_eval_enc_str, _get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, #bool, bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, #num_or_nil, num_or_nil, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd, untrust
Methods included from Tk
BinaryString, EncodedString, #Grid, #Pack, #Place, UTF8_String, __create_widget_set__, __disable_toplevel_control__, __import_toplevel_aliases__, __regist_toplevel_aliases__, __remove_toplevel_aliases__, __reset_toplevel_owner__, __set_loaded_toplevel_aliases__, __set_toplevel_aliases__, __toplevel_alias_setup_proc__, _replace_toplevel_aliases, add_kinsoku, backup_current_topdef, bell, bell_on_display, const_missing, current_grabs, cursor_display, default_widget_set, default_widget_set=, define_topalias, define_topobj, delete_kinsoku, destroy, #encoding, #encoding=, errorCode, errorInfo, exit, focus, focus_lastfor, focus_next, focus_prev, focus_to, fromUTF8, grid, grid_forget, has_mainwindow?, load_tcllibrary, load_tclscript, load_tclscript_rsrc, load_tclscript_rsrcid, lower_window, pack, pack_forget, pkgconfig_get, pkgconfig_list, place, place_forget, raise_window, regist_sym_for_loaded_file, replace_topalias, replace_topobj, #root, set_topalias, show_kinsoku, sleep, strictMotif, subst_tk_backslash, subst_utf_backslash, tcl_pkgconfig_get, tcl_pkgconfig_list, thread_update, thread_update_idletasks, tk_pkgconfig_get, tk_pkgconfig_list, toUTF8, to_backslash_sequence, topalias_defined?, toplevel_aliases_on_widget_set, topobj_defined?, ungrid, unload_tcllibrary, unpack, unplace, update, #update, update_idletasks, utf_to_backslash, utf_to_backslash_sequence, wakeup, widget_set_symbols
#default_encoding=, #encoding=, #encoding_convertfrom, #encoding_convertto, #encoding_dirs, #encoding_dirs=, #encoding_name, #encoding_names, #encoding_obj, #encoding_objs, #encoding_system=, #encoding_system_name, #encoding_system_obj, #force_default_encoding, #force_default_encoding=, #force_default_encoding?, #tk_encoding_names
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args) ⇒ Object
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
|
# File 'lib/tk/font.rb', line 1016
def method_missing(id, *args)
name = id.id2name
case args.length
when 1
if name[-1] == ?=
configure name[0..-2], args[0]
args[0]
else
configure name, args[0]
self
end
when 0
begin
configinfo name
rescue
super(id, *args)
end
else
super(id, *args)
end
end
|
Class Method Details
.actual(fnt, option = nil) ⇒ Object
205
206
207
208
209
210
211
212
|
# File 'lib/tk/font.rb', line 205
def TkFont.actual(fnt, option=nil)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
fnt.actual(option)
else
actual_core(fnt, nil, option)
end
end
|
.actual_displayof(fnt, win, option = nil) ⇒ Object
217
218
219
220
221
222
223
224
225
|
# File 'lib/tk/font.rb', line 217
def TkFont.actual_displayof(fnt, win, option=nil)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
fnt.actual_displayof(win, option)
else
win = '.' unless win
actual_core(fnt, win, option)
end
end
|
.actual_hash(fnt, option = nil) ⇒ Object
213
214
215
|
# File 'lib/tk/font.rb', line 213
def TkFont.actual_hash(fnt, option=nil)
Hash[TkFont.actual(fnt, option)]
end
|
.actual_hash_displayof(fnt, option = nil) ⇒ Object
.configinfo(fnt, slot = nil) ⇒ Object
239
240
241
242
243
244
245
|
# File 'lib/tk/font.rb', line 239
def TkFont.configinfo(fnt, slot=nil)
if fnt.kind_of?(TkFont)
fnt.configinfo(fnt, slot)
else
configinfo_core(fnt, slot)
end
end
|
230
231
232
233
234
235
236
237
|
# File 'lib/tk/font.rb', line 230
def TkFont.configure(fnt, slot, value=None)
if fnt.kind_of?(TkFont)
fnt.configure(fnt, slot, value)
else
configure_core(fnt, slot, value)
end
fnt
end
|
.create_copy(font) ⇒ Object
378
379
380
381
382
383
384
385
386
387
|
# File 'lib/tk/font.rb', line 378
def TkFont.create_copy(font)
fail 'source-font must be a TkFont object' unless font.kind_of? TkFont
if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
keys = {}
font.configinfo.each{|key,value| keys[key] = value }
TkFont.new(font.latin_font_id, font.kanji_font_id, keys)
else TkFont.new(font.latin_font_id, font.kanji_font_id, font.configinfo)
end
end
|
.current_configinfo(fnt, slot = nil) ⇒ Object
247
248
249
250
251
252
253
|
# File 'lib/tk/font.rb', line 247
def TkFont.current_configinfo(fnt, slot=nil)
if fnt.kind_of?(TkFont)
fnt.current_configinfo(fnt, slot)
else
current_configinfo_core(fnt, slot)
end
end
|
.failsafe(font) ⇒ Object
527
528
529
530
531
532
533
534
|
# File 'lib/tk/font.rb', line 527
def TkFont.failsafe(font)
begin
if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
tk_call('font', 'failsafe', font)
end
rescue
end
end
|
.families(win = nil) ⇒ Object
347
348
349
350
351
352
353
354
355
356
357
358
359
|
# File 'lib/tk/font.rb', line 347
def TkFont.families(win=nil)
case (Tk::TK_VERSION)
when /^4\..*/
['fixed']
when /^8\..*/
if win
tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
else
tk_split_simplelist(tk_call('font', 'families'))
end
end
end
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
# File 'lib/tk/font.rb', line 402
def TkFont.init_widget_font(pathname, *args)
win, tag, key = pathname.split(';')
key = 'font' if key == nil || key == ''
path = [win, tag, key].join(';')
case (Tk::TK_VERSION)
when /^4\..*/
regexp = /^-(|kanji)#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
find_all{|prop| prop =~ regexp}.
collect{|prop| tk_split_simplelist(prop)}
if conf_list.size == 0
raise RuntimeError, "the widget may not support 'font' option"
end
args << {}
ltn_key = "-#{key}"
knj_key = "-kanji#{key}"
ltn_info = conf_list.find{|conf| conf[0] == ltn_key}
ltn = ltn_info[-1]
ltn = nil if ltn == [] || ltn == ""
knj_info = conf_list.find{|conf| conf[0] == knj_key}
knj = knj_info[-1]
knj = nil if knj == [] || knj == ""
TkFont.new(ltn, knj).call_font_configure([path, key], *args)
when /^8\.[0-4]/
regexp = /^-#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
find_all{|prop| prop =~ regexp}.
collect{|prop| tk_split_simplelist(prop)}
if conf_list.size == 0
raise RuntimeError, "the widget may not support 'font' option"
end
args << {}
optkey = "-#{key}"
info = conf_list.find{|conf| conf[0] == optkey}
fnt = info[-1]
fnt = nil if fnt == [] || fnt == ""
unless fnt
dummy_fnt = TkFont.allocate
dummy_fnt.instance_eval{ init_dummy_fontobj() }
dummy_fnt
else
begin
compound = tk_split_simplelist(
Hash[*tk_split_simplelist(tk_call('font', 'configure',
fnt))].collect{|k,v|
[k[1..-1], v]
}.assoc('compound')[1])
rescue
compound = []
end
if compound == []
if TkFont.is_system_font?(fnt)
TkNamedFont.new(fnt).call_font_configure([path, key], *args)
else
TkFont.new(fnt).call_font_configure([path, key], *args)
end
else
TkFont.new(compound[0],
compound[1]).call_font_configure([path, key], *args)
end
end
when /^8\.[5-9]/, /^9\..*/
regexp = /^-#{key} /
conf_list = tk_split_simplelist(tk_call(*args)).
find_all{|prop| prop =~ regexp}.
collect{|prop| tk_split_simplelist(prop)}
if conf_list.size == 0
raise RuntimeError, "the widget may not support 'font' option"
end
args << {}
optkey = "-#{key}"
info = conf_list.find{|conf| conf[0] == optkey}
fnt = info[-1]
fnt = nil if fnt == [] || fnt == ""
unless fnt
dummy_fnt = TkFont.allocate
dummy_fnt.instance_eval{ init_dummy_fontobj() }
dummy_fnt
else
if TkFont.is_system_font?(fnt)
TkNamedFont.new(fnt).call_font_configure([path, key], *args)
else
TkFont.new(fnt).call_font_configure([path, key], *args)
end
end
end
end
|
.is_system_font?(fnt) ⇒ Boolean
197
198
199
200
201
202
203
|
# File 'lib/tk/font.rb', line 197
def TkFont.is_system_font?(fnt)
fnt = fnt.to_s
SYSTEM_FONT_NAMES.include?(fnt) && self.names.index(fnt) && true
end
|
.measure(fnt, text) ⇒ Object
255
256
257
258
259
260
261
262
|
# File 'lib/tk/font.rb', line 255
def TkFont.measure(fnt, text)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
fnt.measure(text)
else
measure_core(fnt, nil, text)
end
end
|
.measure_displayof(fnt, win, text) ⇒ Object
264
265
266
267
268
269
270
271
272
|
# File 'lib/tk/font.rb', line 264
def TkFont.measure_displayof(fnt, win, text)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
fnt.measure_displayof(win, text)
else
win = '.' unless win
measure_core(fnt, win, text)
end
end
|
.metrics(fnt, option = nil) ⇒ Object
274
275
276
277
278
279
280
281
|
# File 'lib/tk/font.rb', line 274
def TkFont.metrics(fnt, option=nil)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
fnt.metrics(option)
else
metrics_core(fnt, nil, option)
end
end
|
.metrics_displayof(fnt, win, option = nil) ⇒ Object
310
311
312
313
314
315
316
317
318
|
# File 'lib/tk/font.rb', line 310
def TkFont.metrics_displayof(fnt, win, option=nil)
fnt = '{}' if fnt == ''
if fnt.kind_of?(TkFont)
font.metrics_displayof(win, option=nil)
else
win = '.' unless win
metrics_core(fnt, win, option)
end
end
|
.metrics_hash(fnt, option = nil) ⇒ Object
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
# File 'lib/tk/font.rb', line 282
def TkFont.metrics_hash(fnt, option=nil)
if option
val = TkFont.metrics(fnt, option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[TkFont.metrics(fnt)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
.metrics_hash_displayof(fnt, win, option = nil) ⇒ Object
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
# File 'lib/tk/font.rb', line 361
def TkFont.names
case (Tk::TK_VERSION)
when /^4\..*/
r = ['fixed']
r += ['a14', 'k14'] if JAPANIZED_TK
Tk_FontNameTBL.mutex.synchronize{
Tk_FontNameTBL.each_value{|obj| r.push(obj)}
}
r.uniq
when /^8\..*/
tk_split_simplelist(tk_call('font', 'names'))
end
end
|
Instance Method Details
1256
1257
1258
|
# File 'lib/tk/font.rb', line 1256
def [](slot)
configinfo slot
end
|
#[]=(slot, val) ⇒ Object
1260
1261
1262
1263
|
# File 'lib/tk/font.rb', line 1260
def []=(slot, val)
configure slot, val
val
end
|
#actual(option = nil) ⇒ Object
1189
1190
1191
|
# File 'lib/tk/font.rb', line 1189
def actual(option=nil)
actual_core(@compoundfont, nil, option)
end
|
#actual_displayof(win, option = nil) ⇒ Object
1196
1197
1198
1199
|
# File 'lib/tk/font.rb', line 1196
def actual_displayof(win, option=nil)
win = '.' unless win
actual_core(@compoundfont, win, option)
end
|
#actual_hash(option = nil) ⇒ Object
1192
1193
1194
|
# File 'lib/tk/font.rb', line 1192
def actual_hash(option=nil)
Hash[actual(option)]
end
|
#actual_hash_displayof(win, option = nil) ⇒ Object
1200
1201
1202
|
# File 'lib/tk/font.rb', line 1200
def actual_hash_displayof(win, option=nil)
Hash[actual_displayof(win, option)]
end
|
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
|
# File 'lib/tk/font.rb', line 1040
def call_font_configure(path, *args)
if path.kind_of?(Array)
win, tag = path[0].split(';')
optkey = path[1].to_s
else
win, tag, optkey = path.split(';')
end
fontslot = _symbolkey2str(@fontslot)
if optkey && optkey != ""
ltn = fontslot.delete('font')
knj = fontslot.delete('kanjifont')
fontslot[optkey] = ltn if ltn
fontslot["kanji#{optkey}"] = knj if knj
end
keys = _symbolkey2str(args.pop).update(fontslot)
args.concat(hash_kv(keys))
begin
tk_call(*args)
rescue => e
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
fail e
end
end
Tk_FontUseTBL.mutex.synchronize{
Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
}
self
end
|
#configinfo(slot = nil) ⇒ Object
1270
1271
1272
|
# File 'lib/tk/font.rb', line 1270
def configinfo(slot=nil)
configinfo_core(@compoundfont, slot)
end
|
1265
1266
1267
1268
|
# File 'lib/tk/font.rb', line 1265
def configure(slot, value=None)
configure_core(@compoundfont, slot, value)
self
end
|
#current_configinfo(slot = nil) ⇒ Object
1274
1275
1276
|
# File 'lib/tk/font.rb', line 1274
def current_configinfo(slot=nil)
current_configinfo_core(@compoundfont, slot)
end
|
1278
1279
1280
|
# File 'lib/tk/font.rb', line 1278
def delete
delete_core
end
|
#font ⇒ Object
Also known as:
font_id, name, to_s
1140
1141
1142
|
# File 'lib/tk/font.rb', line 1140
def font
@compoundfont
end
|
1132
1133
1134
|
# File 'lib/tk/font.rb', line 1132
def id
@id
end
|
1012
1013
1014
|
# File 'lib/tk/font.rb', line 1012
def inspect
sprintf("#<%s:%0x:%s>", self.class.inspect, self.__id__, @compoundfont)
end
|
#kanji_actual(option = nil) ⇒ Object
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
|
# File 'lib/tk/font.rb', line 1227
def kanji_actual(option=nil)
if @kanjifont == nil
actual_core(@compoundfont, nil, option) elsif @kanjifont != ""
actual_core(@kanjifont, nil, option)
else
actual_core_tk4x(nil, nil, option)
end
end
|
#kanji_actual_displayof(win, option = nil) ⇒ Object
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
|
# File 'lib/tk/font.rb', line 1241
def kanji_actual_displayof(win, option=nil)
if @kanjifont == nil
actual_core(@compoundfont, nil, option) elsif @kanjifont != ""
win = '.' unless win
actual_core(@kanjifont, win, option)
else
actual_core_tk4x(nil, win, option)
end
end
|
#kanji_actual_hash(option = nil) ⇒ Object
1237
1238
1239
|
# File 'lib/tk/font.rb', line 1237
def kanji_actual_hash(option=nil)
Hash[kanji_actual(option)]
end
|
#kanji_actual_hash_displayof(win, option = nil) ⇒ Object
1252
1253
1254
|
# File 'lib/tk/font.rb', line 1252
def kanji_actual_hash_displayof(win, option=nil)
Hash[kanji_actual_displayof(win, option)]
end
|
#kanji_configinfo(slot = nil) ⇒ Object
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
|
# File 'lib/tk/font.rb', line 1316
def kanji_configinfo(slot=nil)
if @kanjifont == nil
configure_core(@compoundfont, slot) elsif @kanjifont != ""
configinfo_core(@kanjifont, slot)
else
configinfo(slot)
end
end
|
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
|
# File 'lib/tk/font.rb', line 1302
def kanji_configure(slot, value=None)
if @kanjifont == nil
configure_core(@compoundfont, slot, value) elsif @kanjifont != ""
configure_core(@kanjifont, slot, value)
configure('size'=>configinfo('size')) else
configure(slot, value)
end
self
end
|
#kanji_current_configinfo(slot = nil) ⇒ Object
1327
1328
1329
|
# File 'lib/tk/font.rb', line 1327
def kanji_current_configinfo(slot=nil)
Hash[kanji_configinfo(slot)]
end
|
#kanji_font ⇒ Object
Also known as:
kanjifont
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
|
# File 'lib/tk/font.rb', line 1172
def kanji_font
if @descendant[1] @descendant[1]
else
@descendant[1] = DescendantFont.new(self, 'kanji')
end
=begin
if @kanji_descendant
@kanji_descendant
else
@kanji_descendant = DescendantFont.new(self, 'kanji')
end
=end
end
|
#kanji_font_id ⇒ Object
1168
1169
1170
|
# File 'lib/tk/font.rb', line 1168
def kanji_font_id
@kanjifont
end
|
#kanji_metrics(option = nil) ⇒ Object
1511
1512
1513
1514
1515
1516
1517
1518
1519
|
# File 'lib/tk/font.rb', line 1511
def kanji_metrics(option=nil)
if @latinfont == nil
metrics_core(@compoundfont, nil, option) elsif JAPANIZED_TK
metrics_core(@kanjifont, nil, option)
else
metrics_core_tk4x(nil, nil, option)
end
end
|
#kanji_metrics_displayof(win, option = nil) ⇒ Object
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
|
# File 'lib/tk/font.rb', line 1548
def kanji_metrics_displayof(win, option=nil)
win = '.' unless win
if @latinfont == nil
metrics_core(@compoundfont, win, option) elsif JAPANIZED_TK
metrics_core(@kanjifont, win, option)
else
metrics_core_tk4x(nil, win, option)
end
end
|
#kanji_metrics_hash(option = nil) ⇒ Object
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
|
# File 'lib/tk/font.rb', line 1520
def kanji_metrics_hash(option=nil)
if option
val = kanji_metrics(option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[kanji_metrics(option)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
#kanji_metrics_hash_displayof(win, option = nil) ⇒ Object
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
|
# File 'lib/tk/font.rb', line 1558
def kanji_metrics_hash_displayof(win, option=nil)
if option
val = kanji_metrics_displayof(win, option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[kanji_metrics_displayof(win, option)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
#kanji_replace(knj) ⇒ Object
1361
1362
1363
1364
1365
1366
|
# File 'lib/tk/font.rb', line 1361
def kanji_replace(knj)
return self unless @kanjifont kanji_replace_core(knj)
reset_pointadjust
self
end
|
#latin_actual(option = nil) ⇒ Object
Also known as:
ascii_actual
1204
1205
1206
1207
1208
1209
1210
|
# File 'lib/tk/font.rb', line 1204
def latin_actual(option=nil)
if @latinfont == nil
actual_core(@compoundfont, nil, option) else
actual_core(@latinfont, nil, option)
end
end
|
#latin_actual_displayof(win, option = nil) ⇒ Object
Also known as:
ascii_actual_displayof
1215
1216
1217
1218
1219
1220
1221
1222
|
# File 'lib/tk/font.rb', line 1215
def latin_actual_displayof(win, option=nil)
win = '.' unless win
if @latinfont == nil
actual_core(@compoundfont, win, option) else
actual_core(@latinfont, win, option)
end
end
|
#latin_actual_hash(option = nil) ⇒ Object
1211
1212
1213
|
# File 'lib/tk/font.rb', line 1211
def latin_actual_hash(option=nil)
Hash[latin_actual(option)]
end
|
#latin_actual_hash_displayof(win, option = nil) ⇒ Object
1223
1224
1225
|
# File 'lib/tk/font.rb', line 1223
def latin_actual_hash_displayof(win, option=nil)
Hash[latin_actual_displayof(win, option)]
end
|
#latin_configinfo(slot = nil) ⇒ Object
Also known as:
ascii_configinfo
1291
1292
1293
1294
1295
1296
1297
|
# File 'lib/tk/font.rb', line 1291
def latin_configinfo(slot=nil)
if JAPANIZED_TK
configinfo_core(@latinfont, slot)
else
configinfo(slot)
end
end
|
1282
1283
1284
1285
1286
1287
1288
1289
|
# File 'lib/tk/font.rb', line 1282
def latin_configure(slot, value=None)
if JAPANIZED_TK
configure_core(@latinfont, slot, value)
else
configure(slot, value)
end
self
end
|
#latin_current_configinfo(slot = nil) ⇒ Object
1298
1299
1300
|
# File 'lib/tk/font.rb', line 1298
def latin_current_configinfo(slot=nil)
Hash[latin_configinfo(slot)]
end
|
#latin_font ⇒ Object
Also known as:
latinfont, ascii_font
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
|
# File 'lib/tk/font.rb', line 1151
def latin_font
if @descendant[0] @descendant[0]
else
@descendant[0] = DescendantFont.new(self, 'latin')
end
=begin
if @latin_descendant
@latin_descendant
else
@latin_descendant = DescendantFont.new(self, 'latin')
end
=end
end
|
#latin_font_id ⇒ Object
1147
1148
1149
|
# File 'lib/tk/font.rb', line 1147
def latin_font_id
@latinfont
end
|
#latin_metrics(option = nil) ⇒ Object
Also known as:
ascii_metrics
1440
1441
1442
1443
1444
1445
1446
|
# File 'lib/tk/font.rb', line 1440
def latin_metrics(option=nil)
if @latinfont == nil
metrics_core(@compoundfont, nil, option) else
metrics_core(@latinfont, nil, option)
end
end
|
#latin_metrics_displayof(win, option = nil) ⇒ Object
1475
1476
1477
1478
1479
1480
1481
1482
|
# File 'lib/tk/font.rb', line 1475
def latin_metrics_displayof(win, option=nil)
win = '.' unless win
if @latinfont == nil
metrics_core(@compoundfont, win, option) else
metrics_core(@latinfont, win, option)
end
end
|
#latin_metrics_hash(option = nil) ⇒ Object
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
|
# File 'lib/tk/font.rb', line 1447
def latin_metrics_hash(option=nil)
if option
val = latin_metrics(option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[latin_metrics(option)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
#latin_metrics_hash_displayof(win, option = nil) ⇒ Object
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
|
# File 'lib/tk/font.rb', line 1483
def latin_metrics_hash_displayof(win, option=nil)
if option
val = latin_metrics_displayof(win, option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[latin_metrics_displayof(win, option)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
#latin_replace(ltn) ⇒ Object
Also known as:
ascii_replace
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
|
# File 'lib/tk/font.rb', line 1338
def latin_replace(ltn)
if @latinfont
latin_replace_core(ltn)
reset_pointadjust
else
latinkeys = {}
begin
actual_core(ltn).each{|key,val| latinkeys[key] = val}
rescue
latinkeys = {}
end
begin
tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
rescue
tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys))
end
end
self
end
|
#measure(text) ⇒ Object
1368
1369
1370
|
# File 'lib/tk/font.rb', line 1368
def measure(text)
measure_core(@compoundfont, nil, text)
end
|
#measure_displayof(win, text) ⇒ Object
1372
1373
1374
1375
|
# File 'lib/tk/font.rb', line 1372
def measure_displayof(win, text)
win = '.' unless win
measure_core(@compoundfont, win, text)
end
|
#metrics(option = nil) ⇒ Object
1377
1378
1379
|
# File 'lib/tk/font.rb', line 1377
def metrics(option=nil)
metrics_core(@compoundfont, nil, option)
end
|
#metrics_displayof(win, option = nil) ⇒ Object
1408
1409
1410
1411
|
# File 'lib/tk/font.rb', line 1408
def metrics_displayof(win, option=nil)
win = '.' unless win
metrics_core(@compoundfont, win, option)
end
|
#metrics_hash(option = nil) ⇒ Object
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
|
# File 'lib/tk/font.rb', line 1380
def metrics_hash(option=nil)
if option
val = metrics(option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[metrics(option)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
#metrics_hash_displayof(win, option = nil) ⇒ Object
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
|
# File 'lib/tk/font.rb', line 1412
def metrics_hash_displayof(win, option=nil)
if option
val = metrics_displayof(win, option)
case TkFont::MetricsType[option.to_s]
when ?n
val = TkComm::num_or_str(val)
when ?b
val = TkComm::bool(val)
else
end
return val
end
h = Hash[metrics_displayof(win, option)]
h.keys.each{|k|
case TkFont::MetricsType[k.to_s]
when ?n
h[k] = TkComm::num_or_str(h[k])
when ?b
h[k] = TkComm::bool(h[k])
else
end
}
h
end
|
#replace(ltn, knj = None) ⇒ Object
1331
1332
1333
1334
1335
1336
|
# File 'lib/tk/font.rb', line 1331
def replace(ltn, knj=None)
knj = ltn if knj == None
latin_replace(ltn)
kanji_replace(knj)
self
end
|
#reset_pointadjust ⇒ Object
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
|
# File 'lib/tk/font.rb', line 1586
def reset_pointadjust
begin
if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
kanji_actual.assoc('size')[1].to_f )
end
rescue
end
self
end
|
1136
1137
1138
|
# File 'lib/tk/font.rb', line 1136
def to_eval
font
end
|
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
|
# File 'lib/tk/font.rb', line 1072
def used
ret = []
table = nil
Tk_FontUseTBL.mutex.synchronize{
table = Tk_FontUseTBL.clone }
table.each{|key,value|
next unless self == value
if key.include?(';')
win, tag, optkey = key.split(';')
winobj = tk_tcl2ruby(win)
if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
if optkey
ret.push([winobj, winobj.tagid2obj(tag), optkey])
else
ret.push([winobj, winobj.tagid2obj(tag)])
end
elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
if optkey
ret.push([winobj, tagobj, optkey])
else
ret.push([winobj, tagobj])
end
elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem
if optkey
ret.push([winobj, tagobj, optkey])
else
ret.push([winobj, tagobj])
end
else
if optkey
ret.push([winobj, tag, optkey])
else
ret.push([winobj, tag])
end
end
elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
if optkey
ret.push([winobj, tag, optkey])
else
ret.push([winobj, tag])
end
else
if optkey
ret.push([win, tag, optkey])
else
ret.push([win, tag])
end
end
else
ret.push(tk_tcl2ruby(key))
end
}
ret
end
|