Module: TkTreatFont
- Included in:
- TkConfigMethod
- Defined in:
- lib/tk.rb
Instance Method Summary collapse
- #font_configinfo(key = nil) ⇒ Object (also: #fontobj)
- #font_configure(slot) ⇒ Object
- #font_copy(win, wintag = nil, winkey = nil, targetkey = nil) ⇒ Object
- #kanjifont_configure(knj, keys = nil) ⇒ Object
- #kanjifont_copy(win, wintag = nil, winkey = nil, targetkey = nil) ⇒ Object
- #latinfont_configure(ltn, keys = nil) ⇒ Object (also: #asciifont_configure)
- #latinfont_copy(win, wintag = nil, winkey = nil, targetkey = nil) ⇒ Object (also: #asciifont_copy)
Instance Method Details
#font_configinfo(key = nil) ⇒ Object Also known as: fontobj
3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 |
# File 'lib/tk.rb', line 3445 def font_configinfo(key = nil) optkeys = __font_optkeys if key && !optkeys.find{|opt| opt.to_s == key.to_s} fail ArgumentError, "unknown font option name `#{key}'" end win, tag = __pathname.split(':') if key pathname = [win, tag, key].join(';') TkFont.used_on(pathname) || TkFont.(pathname, *__confinfo_cmd) elsif optkeys.size == 1 pathname = [win, tag, optkeys[0]].join(';') TkFont.used_on(pathname) || TkFont.(pathname, *__confinfo_cmd) else fonts = {} optkeys.each{|k| k = k.to_s pathname = [win, tag, k].join(';') fonts[k] = TkFont.used_on(pathname) || TkFont.(pathname, *__confinfo_cmd) } fonts end end |
#font_configure(slot) ⇒ Object
3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 |
# File 'lib/tk.rb', line 3475 def font_configure(slot) pathname = __pathname slot = _symbolkey2str(slot) __font_optkeys.each{|optkey| optkey = optkey.to_s l_optkey = 'latin' << optkey a_optkey = 'ascii' << optkey k_optkey = 'kanji' << optkey if slot.key?(optkey) fnt = slot.delete(optkey) if fnt.kind_of?(TkFont) slot.delete(l_optkey) slot.delete(a_optkey) slot.delete(k_optkey) fnt.call_font_configure([pathname, optkey], *(__config_cmd << {})) next else if fnt if (slot.key?(l_optkey) || slot.key?(a_optkey) || slot.key?(k_optkey)) fnt = TkFont.new(fnt) lfnt = slot.delete(l_optkey) lfnt = slot.delete(a_optkey) if slot.key?(a_optkey) kfnt = slot.delete(k_optkey) fnt.latin_replace(lfnt) if lfnt fnt.kanji_replace(kfnt) if kfnt fnt.call_font_configure([pathname, optkey], *(__config_cmd << {})) next else fnt = hash_kv(fnt) if fnt.kind_of?(Hash) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ tk_call(*(__config_cmd << "-#{optkey}" << fnt)) else begin tk_call(*(__config_cmd << "-#{optkey}" << fnt)) rescue # ignore end end end end next end end lfnt = slot.delete(l_optkey) lfnt = slot.delete(a_optkey) if slot.key?(a_optkey) kfnt = slot.delete(k_optkey) if lfnt && kfnt TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], *(__config_cmd << {})) elsif lfnt latinfont_configure([lfnt, optkey]) elsif kfnt kanjifont_configure([kfnt, optkey]) end } # configure other (without font) options tk_call(*(__config_cmd.concat(hash_kv(slot)))) if slot != {} self end |
#font_copy(win, wintag = nil, winkey = nil, targetkey = nil) ⇒ Object
3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 |
# File 'lib/tk.rb', line 3667 def font_copy(win, wintag=nil, winkey=nil, targetkey=nil) if wintag if winkey fnt = win.tagfontobj(wintag, winkey).dup else fnt = win.tagfontobj(wintag).dup end else if winkey fnt = win.fontobj(winkey).dup else fnt = win.fontobj.dup end end if targetkey fnt.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) else fnt.call_font_configure(__pathname, *(__config_cmd << {})) end self end |
#kanjifont_configure(knj, keys = nil) ⇒ Object
3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 |
# File 'lib/tk.rb', line 3608 def kanjifont_configure(knj, keys=nil) if knj.kind_of?(Array) key = knj[1] knj = knj[0] else key = nil end optkeys = __font_optkeys if key && !optkeys.find{|opt| opt.to_s == key.to_s} fail ArgumentError, "unknown font option name `#{key}'" end win, tag = __pathname.split(':') optkeys = [key] if key optkeys.each{|optkey| optkey = optkey.to_s pathname = [win, tag, optkey].join(';') if (fobj = TkFont.used_on(pathname)) fobj = TkFont.new(fobj) # create a new TkFont object elsif Tk::JAPANIZED_TK fobj = fontobj # create a new TkFont object else knj = hash_kv(knj) if knj.kind_of?(Hash) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ tk_call(*(__config_cmd << "-#{optkey}" << knj)) else begin tk_call(*(__config_cmd << "-#{optkey}" << knj)) rescue => e # ignore end end next end if fobj.kind_of?(TkFont) if knj.kind_of?(TkFont) conf = {} knj.kanji_configinfo.each{|k,val| conf[k] = val} if keys fobj.kanji_configure(conf.update(keys)) else fobj.kanji_configure(conf) end else fobj.kanji_replace(knj) end end fobj.call_font_configure([pathname, optkey], *(__config_cmd << {})) } self end |
#kanjifont_copy(win, wintag = nil, winkey = nil, targetkey = nil) ⇒ Object
3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 |
# File 'lib/tk.rb', line 3715 def kanjifont_copy(win, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) else fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) end if wintag if winkey fontobj.kanji_replace(win.tagfontobj(wintag, winkey).kanji_font_id) else fontobj.kanji_replace(win.tagfontobj(wintag).kanji_font_id) end else if winkey fontobj.kanji_replace(win.fontobj(winkey).kanji_font_id) else fontobj.kanji_replace(win.fontobj.kanji_font_id) end end self end |
#latinfont_configure(ltn, keys = nil) ⇒ Object Also known as: asciifont_configure
3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 |
# File 'lib/tk.rb', line 3548 def latinfont_configure(ltn, keys=nil) if ltn.kind_of?(Array) key = ltn[1] ltn = ltn[0] else key = nil end optkeys = __font_optkeys if key && !optkeys.find{|opt| opt.to_s == key.to_s} fail ArgumentError, "unknown font option name `#{key}'" end win, tag = __pathname.split(':') optkeys = [key] if key optkeys.each{|optkey| optkey = optkey.to_s pathname = [win, tag, optkey].join(';') if (fobj = TkFont.used_on(pathname)) fobj = TkFont.new(fobj) # create a new TkFont object elsif Tk::JAPANIZED_TK fobj = fontobj # create a new TkFont object else ltn = hash_kv(ltn) if ltn.kind_of?(Hash) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ tk_call(*(__config_cmd << "-#{optkey}" << ltn)) else begin tk_call(*(__config_cmd << "-#{optkey}" << ltn)) rescue => e # ignore end end next end if fobj.kind_of?(TkFont) if ltn.kind_of?(TkFont) conf = {} ltn.latin_configinfo.each{|k,val| conf[k] = val} if keys fobj.latin_configure(conf.update(keys)) else fobj.latin_configure(conf) end else fobj.latin_replace(ltn) end end fobj.call_font_configure([pathname, optkey], *(__config_cmd << {})) } self end |
#latinfont_copy(win, wintag = nil, winkey = nil, targetkey = nil) ⇒ Object Also known as: asciifont_copy
3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 |
# File 'lib/tk.rb', line 3690 def latinfont_copy(win, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) else fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) end if wintag if winkey fontobj.latin_replace(win.tagfontobj(wintag, winkey).latin_font_id) else fontobj.latin_replace(win.tagfontobj(wintag).latin_font_id) end else if winkey fontobj.latin_replace(win.fontobj(winkey).latin_font_id) else fontobj.latin_replace(win.fontobj.latin_font_id) end end self end |