Method: TkTreatFont#font_configure

Defined in:
lib/tk.rb

#font_configure(slot) ⇒ Object



3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
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
# File 'lib/tk.rb', line 3463

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