Skip to content

Commit

Permalink
Fix fontname
Browse files Browse the repository at this point in the history
  • Loading branch information
klsruan committed Nov 30, 2024
1 parent cb27188 commit 356bbca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/ILL/ILL/Font/Win.moon
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,17 @@ class WindowsGDI extends Init

-- Convert family from utf8 to utf16
family = utf8_to_utf16 @family
if tonumber(C.wcslen family) > 31
error "family name to long", 2

-- Fix family length
lfFaceName = ffi.new "WCHAR[?]", FONT_LF_FACESIZE
familyLen = C.wcslen family
if familyLen >= FONT_LF_FACESIZE
ffi.copy lfFaceName, family, (FONT_LF_FACESIZE-1) * ffi.sizeof "WCHAR"
else
ffi.copy lfFaceName, family, (familyLen+1) * ffi.sizeof "WCHAR"

-- Create font handle
font = C.CreateFontW @size * FONT_UPSCALE, 0, 0, 0, @bold and C.FW_BOLD_ILL or C.FW_NORMAL_ILL, @italic and 1 or 0, @underline and 1 or 0, @strikeout and 1 or 0, C.DEFAULT_CHARSET_ILL, C.OUT_TT_PRECIS_ILL, C.CLIP_DEFAULT_PRECIS_ILL, C.ANTIALIASED_QUALITY_ILL, C.DEFAULT_PITCH_ILL + C.FF_DONTCARE_ILL, family
font = C.CreateFontW @size * FONT_UPSCALE, 0, 0, 0, @bold and C.FW_BOLD_ILL or C.FW_NORMAL_ILL, @italic and 1 or 0, @underline and 1 or 0, @strikeout and 1 or 0, C.DEFAULT_CHARSET_ILL, C.OUT_TT_PRECIS_ILL, C.CLIP_DEFAULT_PRECIS_ILL, C.ANTIALIASED_QUALITY_ILL, C.DEFAULT_PITCH_ILL + C.FF_DONTCARE_ILL, lfFaceName

-- Set new font to device context
old_font = C.SelectObject @dc, font
Expand Down

0 comments on commit 356bbca

Please sign in to comment.