Font: add strikethroughPosition and strikethroughThickness

Similar to underlinePosition and underlineThickness
This commit is contained in:
Josh Tynjala
2025-08-25 14:11:47 -07:00
parent 8d81a0fc8e
commit 9b6f81d006
6 changed files with 120 additions and 3 deletions

View File

@@ -56,6 +56,8 @@ namespace lime {
int GetNumGlyphs ();
int GetUnderlinePosition ();
int GetUnderlineThickness ();
int GetStrikethroughPosition ();
int GetStrikethroughThickness ();
int GetUnitsPerEM ();
int RenderGlyph (int index, Bytes *bytes, int offset = 0);
int RenderGlyphs (value indices, Bytes *bytes);

View File

@@ -1363,6 +1363,54 @@ namespace lime {
}
int lime_font_get_strikethrough_position (value fontHandle) {
#ifdef LIME_FREETYPE
Font *font = (Font*)val_data (fontHandle);
return font->GetStrikethroughPosition ();
#else
return 0;
#endif
}
HL_PRIM int HL_NAME(hl_font_get_strikethrough_position) (HL_CFFIPointer* fontHandle) {
#ifdef LIME_FREETYPE
Font *font = (Font*)fontHandle->ptr;
return font->GetStrikethroughPosition ();
#else
return 0;
#endif
}
int lime_font_get_strikethrough_thickness (value fontHandle) {
#ifdef LIME_FREETYPE
Font *font = (Font*)val_data (fontHandle);
return font->GetStrikethroughThickness ();
#else
return 0;
#endif
}
HL_PRIM int HL_NAME(hl_font_get_strikethrough_thickness) (HL_CFFIPointer* fontHandle) {
#ifdef LIME_FREETYPE
Font *font = (Font*)fontHandle->ptr;
return font->GetStrikethroughThickness ();
#else
return 0;
#endif
}
int lime_font_get_units_per_em (value fontHandle) {
#ifdef LIME_FREETYPE
@@ -4000,6 +4048,8 @@ namespace lime {
DEFINE_PRIME1 (lime_font_get_num_glyphs);
DEFINE_PRIME1 (lime_font_get_underline_position);
DEFINE_PRIME1 (lime_font_get_underline_thickness);
DEFINE_PRIME1 (lime_font_get_strikethrough_position);
DEFINE_PRIME1 (lime_font_get_strikethrough_thickness);
DEFINE_PRIME1 (lime_font_get_units_per_em);
DEFINE_PRIME1 (lime_font_load);
DEFINE_PRIME1 (lime_font_load_bytes);
@@ -4191,6 +4241,8 @@ namespace lime {
DEFINE_HL_PRIM (_I32, hl_font_get_num_glyphs, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, hl_font_get_underline_position, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, hl_font_get_underline_thickness, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, hl_font_get_strikethrough_position, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, hl_font_get_strikethrough_thickness, _TCFFIPOINTER);
DEFINE_HL_PRIM (_I32, hl_font_get_units_per_em, _TCFFIPOINTER);
// DEFINE_PRIME1 (lime_font_load);
DEFINE_HL_PRIM (_TCFFIPOINTER, hl_font_load_bytes, _TBYTES);

View File

@@ -1268,6 +1268,37 @@ namespace lime {
}
int Font::GetStrikethroughPosition () {
TT_OS2* os2 = (TT_OS2*)FT_Get_Sfnt_Table(((FT_Face)face), ft_sfnt_os2);
if (os2 && os2->version != 0xFFFFU)
{
return os2->yStrikeoutPosition;
}
return 0;
}
int Font::GetStrikethroughThickness () {
TT_OS2* os2 = (TT_OS2*)FT_Get_Sfnt_Table(((FT_Face)face), ft_sfnt_os2);
if (os2 && os2->version != 0xFFFFU)
{
return os2->yStrikeoutSize;
}
return 0;
}
int Font::GetUnitsPerEM () {
return ((FT_Face)face)->units_per_EM;

View File

@@ -135,6 +135,10 @@ class NativeCFFI
@:cffi private static function lime_font_get_underline_thickness(handle:Dynamic):Int;
@:cffi private static function lime_font_get_strikethrough_position(handle:Dynamic):Int;
@:cffi private static function lime_font_get_strikethrough_thickness(handle:Dynamic):Int;
@:cffi private static function lime_font_get_units_per_em(handle:Dynamic):Int;
@:cffi private static function lime_font_load(data:Dynamic):Dynamic;
@@ -433,6 +437,10 @@ class NativeCFFI
"oi", false));
private static var lime_font_get_underline_thickness = new cpp.Callable<cpp.Object->Int>(cpp.Prime._loadPrime("lime", "lime_font_get_underline_thickness",
"oi", false));
private static var lime_font_get_strikethrough_position = new cpp.Callable<cpp.Object->Int>(cpp.Prime._loadPrime("lime", "lime_font_get_strikethrough_position",
"oi", false));
private static var lime_font_get_strikethrough_thickness = new cpp.Callable<cpp.Object->Int>(cpp.Prime._loadPrime("lime", "lime_font_get_strikethrough_thickness",
"oi", false));
private static var lime_font_get_units_per_em = new cpp.Callable<cpp.Object->Int>(cpp.Prime._loadPrime("lime", "lime_font_get_units_per_em", "oi", false));
private static var lime_font_load = new cpp.Callable<cpp.Object->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_font_load", "oo", false));
private static var lime_font_load_bytes = new cpp.Callable<cpp.Object->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_font_load_bytes", "oo", false));
@@ -672,6 +680,8 @@ class NativeCFFI
private static var lime_font_get_num_glyphs = CFFI.load("lime", "lime_font_get_num_glyphs", 1);
private static var lime_font_get_underline_position = CFFI.load("lime", "lime_font_get_underline_position", 1);
private static var lime_font_get_underline_thickness = CFFI.load("lime", "lime_font_get_underline_thickness", 1);
private static var lime_font_get_strikethrough_position = CFFI.load("lime", "lime_font_get_strikethrough_position", 1);
private static var lime_font_get_strikethrough_thickness = CFFI.load("lime", "lime_font_get_strikethrough_thickness", 1);
private static var lime_font_get_units_per_em = CFFI.load("lime", "lime_font_get_units_per_em", 1);
private static var lime_font_load = CFFI.load("lime", "lime_font_load", 1);
private static var lime_font_load_bytes = CFFI.load("lime", "lime_font_load_bytes", 1);
@@ -970,6 +980,16 @@ class NativeCFFI
return 0;
}
@:hlNative("lime", "hl_font_get_strikethrough_position") private static function lime_font_get_strikethrough_position(handle:CFFIPointer):Int
{
return 0;
}
@:hlNative("lime", "hl_font_get_strikethrough_thickness") private static function lime_font_get_strikethrough_thickness(handle:CFFIPointer):Int
{
return 0;
}
@:hlNative("lime", "hl_font_get_units_per_em") private static function lime_font_get_units_per_em(handle:CFFIPointer):Int
{
return 0;

View File

@@ -38,12 +38,12 @@ class Font
* The ascender value of the font.
*/
public var ascender:Int;
/**
* The descender value of the font.
*/
public var descender:Int;
/**
* The height of the font.
*/
@@ -59,7 +59,7 @@ class Font
*/
public var numGlyphs:Int;
public var src:Dynamic;
/**
@@ -72,6 +72,16 @@ class Font
*/
public var underlineThickness:Int;
/**
* The underline position of the font.
*/
public var strikethroughPosition:Int;
/**
* The underline thickness of the font.
*/
public var strikethroughThickness:Int;
/**
* The units per EM of the font.
*/
@@ -612,6 +622,8 @@ class Font
numGlyphs = NativeCFFI.lime_font_get_num_glyphs(src);
underlinePosition = NativeCFFI.lime_font_get_underline_position(src);
underlineThickness = NativeCFFI.lime_font_get_underline_thickness(src);
strikethroughPosition = NativeCFFI.lime_font_get_strikethrough_position(src);
strikethroughThickness = NativeCFFI.lime_font_get_strikethrough_thickness(src);
unitsPerEM = NativeCFFI.lime_font_get_units_per_em(src);
}
#end

BIN
tools/tools.n Normal file

Binary file not shown.