view src/luan/modules/swing/Font.luan @ 1811:55d89a183c82 default tip

remove line_diff from luan
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 15 May 2024 18:02:28 -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