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
3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 |
# File 'lib/tk.rb', line 3179 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{|key| key = key.to_s pathname = [win, tag, key].join(';') fonts[key] = TkFont.used_on(pathname) || TkFont.(pathname, *__confinfo_cmd) } fonts end end |
#font_configure(slot) ⇒ Object
3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 |
# File 'lib/tk.rb', line 3209 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
3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 |
# File 'lib/tk.rb', line 3401 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
3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 |
# File 'lib/tk.rb', line 3342 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{|key,val| conf[key] = 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
3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 |
# File 'lib/tk.rb', line 3449 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
3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 |
# File 'lib/tk.rb', line 3282 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{|key,val| conf[key] = 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
3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 |
# File 'lib/tk.rb', line 3424 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 |