Change types where possible to the correct ones

This commit is contained in:
gingerBill
2025-06-20 09:29:41 +01:00
parent a449ad8ed8
commit 9d15170928
2 changed files with 42 additions and 34 deletions
+9 -2
View File
@@ -52,14 +52,21 @@ PlaceShapeState :: proc "c" (Memory: []byte) -> ^shape_state {
} }
@(require_results) @(require_results)
DecodeUtf8 :: proc "contextless" (String: string) -> (Codepoint: rune, SourceCharactersConsumed: u32, Valid: b32) { DecodeUtf8 :: proc "contextless" (String: string) -> (Codepoint: rune, SourceCharactersConsumed: u32, Valid: bool) {
decode :: struct {
Codepoint: rune,
SourceCharactersConsumed: u32,
Valid: b32,
}
@(default_calling_convention="c", require_results) @(default_calling_convention="c", require_results)
foreign lib { foreign lib {
kbts_DecodeUtf8 :: proc(Utf8: [^]byte, Length: uint) -> decode --- kbts_DecodeUtf8 :: proc(Utf8: [^]byte, Length: uint) -> decode ---
} }
Decode := kbts_DecodeUtf8(raw_data(String), len(String)) Decode := kbts_DecodeUtf8(raw_data(String), len(String))
return Decode.Codepoint, Decode.SourceCharactersConsumed, Decode.Valid return Decode.Codepoint, Decode.SourceCharactersConsumed, bool(Decode.Valid)
} }
+33 -32
View File
@@ -1519,14 +1519,14 @@ lookup_subtable_info :: struct {
} }
font :: struct { font :: struct {
FileBase: [^]byte, FileBase: [^]byte,
Head: ^head, Head: ^head,
Cmap: ^u16, Cmap: ^u16,
Gdef: ^gdef, Gdef: ^gdef,
Cmap14: ^cmap_14, Cmap14: ^cmap_14,
ShapingTables: [shaping_table]^gsub_gpos, ShapingTables: [shaping_table]^gsub_gpos,
Fvar: rawptr, Fvar: rawptr,
Maxp: ^maxp, Maxp: ^maxp,
Hea: [orientation]^hea, Hea: [orientation]^hea,
Mtx: [orientation]^u16, Mtx: [orientation]^u16,
@@ -1537,10 +1537,11 @@ font :: struct {
LookupCount: u32, LookupCount: u32,
SubtableCount: u32, SubtableCount: u32,
GlyphLookupMatrix: [^]u32, // [LookupCount * GlyphCount] bitmap GlyphLookupMatrix: [^]u32, // [LookupCount * GlyphCount] bitmap
GlyphLookupSubtableMatrix: [^]u32, // [LookupSubtableCount * GlyphCount] bitmap GlyphLookupSubtableMatrix: [^]u32, // [LookupSubtableCount * GlyphCount] bitmap
LookupSubtableIndexOffsets: [^]u32, // [LookupCount] LookupSubtableIndexOffsets: [^]u32, // [LookupCount]
SubtableInfos: [^]lookup_subtable_info, // [LookupSubtableCount] SubtableInfos: [^]lookup_subtable_info, // [LookupSubtableCount]
GposLookupIndexOffset: u32, GposLookupIndexOffset: u32,
Error: c.int, Error: c.int,
@@ -1600,7 +1601,7 @@ glyph :: struct {
// Unicode properties filled in by CodepointToGlyph. // Unicode properties filled in by CodepointToGlyph.
JoiningType: unicode_joining_type, JoiningType: unicode_joining_type,
Script: u8, Script: u8,
UnicodeFlags: u8, UnicodeFlags: unicode_flags,
SyllabicClass: u8, SyllabicClass: u8,
SyllabicPosition: u8, SyllabicPosition: u8,
UseClass: u8, UseClass: u8,
@@ -1622,10 +1623,17 @@ op_state_normalize :: struct {
AboveBaseGlyphCount: un, AboveBaseGlyphCount: un,
} }
skip_flags :: distinct bit_set[skip_flag; u32]
skip_flag :: enum {
ZWNJ = 0,
ZWJ = 1,
}
op_state_gsub :: struct { op_state_gsub :: struct {
LookupIndex: un, LookupIndex: un,
GlyphFilter: u32, GlyphFilter: glyph_flags,
SkipFlags: u32, SkipFlags: skip_flags,
} }
op_state_normalize_hangul :: struct { op_state_normalize_hangul :: struct {
@@ -1640,9 +1648,9 @@ op_state_op_specific :: struct #raw_union {
} }
lookup_indices :: struct { lookup_indices :: struct {
FeatureId: u32, FeatureId: feature_id,
SkipFlags: u32, SkipFlags: skip_flags,
GlyphFilter: u32, GlyphFilter: glyph_flags,
Count: u32, Count: u32,
Indices: [^]u16 `fmt:"v,Count"`, Indices: [^]u16 `fmt:"v,Count"`,
} }
@@ -1673,14 +1681,14 @@ op_state :: struct {
// LeftoverMemory: [LeftoverMemorySize]u8, // LeftoverMemory: [LeftoverMemorySize]u8,
} }
op_list :: struct { op_list :: struct { // TODO(bill): is this actually a slice? e.g. `op_list :: []op_kind`
Ops: [^]u8, Ops: [^]op_kind,
Length: un, Length: un,
} }
indic_script_properties :: struct { indic_script_properties :: struct {
ViramaCodepoint: rune, ViramaCodepoint: rune,
BlwfPostOnly: u8, BlwfPostOnly: b8,
RephPosition: reph_position, RephPosition: reph_position,
RephEncoding: reph_encoding, RephEncoding: reph_encoding,
RightSideMatraPosition: syllabic_position, RightSideMatraPosition: syllabic_position,
@@ -1691,13 +1699,13 @@ indic_script_properties :: struct {
langsys :: struct {} langsys :: struct {}
shape_config :: struct { shape_config :: struct {
Font: ^font, Font: ^font,
Script: script, Script: script,
Language: language, Language: language,
Langsys: [shaping_table]^langsys, Langsys: [shaping_table]^langsys,
OpLists: [4]op_list, OpLists: [4]op_list,
Shaper: shaper, Shaper: shaper,
ShaperProperties: ^shaper_properties, ShaperProperties: ^shaper_properties,
IndicScriptProperties: indic_script_properties, IndicScriptProperties: indic_script_properties,
@@ -1729,7 +1737,7 @@ shape_state :: struct {
GlyphArray: glyph_array, GlyphArray: glyph_array,
ClusterGlyphArray: glyph_array, ClusterGlyphArray: glyph_array,
DottedCircleInsertIndex: u32, DottedCircleInsertIndex: u32,
GlyphCountStartingFromCurrentCluster: u32, GlyphCountStartingFromCurrentCluster: u32,
@@ -1833,10 +1841,3 @@ break_state :: struct {
LastWordBreakClass: u8, LastWordBreakClass: u8,
LastWordBreakClassIncludingIgnored: u8, LastWordBreakClassIncludingIgnored: u8,
} }
decode :: struct {
Codepoint: rune,
SourceCharactersConsumed: u32,
Valid: b32,
}