Method: TkTreatFont#latinfont_configure

Defined in:
lib/tk.rb

#latinfont_configure(ltn, keys = nil) ⇒ Object Also known as: asciifont_configure



3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
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
# File 'lib/tk.rb', line 3536

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