view src/luan/modules/swing/Font.luan @ 1745:f8950d99f47d default tip

add Lucene.type.float
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 06 Dec 2022 11:53:18 -0700
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