view src/luan/modules/swing/Font.luan @ 1722:7d2ab44f7a59 default tip

remove String regex fns
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 29 Jul 2022 14:12:01 -0600
parents 915cb538e2a3
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local pairs = Luan.pairs or error()
require "java"
local JFont = require "java:java.awt.Font"
local TextAttribute = require "java:java.awt.font.TextAttribute"


local Font = {}

local keys = {
	family = TextAttribute.FAMILY
	size = TextAttribute.SIZE
}

function Font.get(attrs)
	local jattrs = {}
	for key, val in pairs(attrs) do
		key = keys[key] or error("invalid font key: "..key)
		jattrs[key] = val
	end
	return JFont.getFont(jattrs)
end

return Font