MPLABĀ® Harmony Graphics Suite
legato_stringtable.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
30 #ifndef LEGATO_STRINGTABLE_H
31 #define LEGATO_STRINGTABLE_H
32 
35 
36 // defines meta data sizes for the string table, don't change!
37 #define LE_STRING_ARRAY_SIZE 4
38 #define LE_STRING_ENTRY_SIZE 2
39 #define LE_STRING_MAX_CHAR_WIDTH 6
40 
41 // *****************************************************************************
47 {
48  LE_STRING_ENCODING_ASCII,
49  LE_STRING_ENCODING_UTF8,
50  LE_STRING_ENCODING_UTF16
52 
53 // *****************************************************************************
54 /* Structure:
55  leStringTable
56 
57  Summary:
58  Describes a string table asset. There is typically only ever one of these
59  defined at any one time.
60 
61  header - standard asset header
62  languageCount - the number of languages in the string table
63  stringCount - the number of strings in the string table
64  stringIndexTable - the pointer to the string index table. the string index
65  table is a table that contains all of the unique strings
66  defined in the string table.
67  fontTable - the font table contains an array of pointers to all defined
68  font assets that the string table references
69  fontIndexTable - the font index table is a table that maps strings to font
70  indices which can then be used to get an actual font pointer
71  from the font table
72  encodingMode - indicates how strings are encoded in the stringIndexTable
73 */
79 typedef struct leStringTable
80 {
81  leStreamDescriptor header;
82  uint8_t* stringTableData;
83  leFont** fontTable;
84  leStringEncodingMode encodingMode;
86 
87 // *****************************************************************************
88 /* Structure:
89  struct leStringInfo
90 
91  Summary:
92  Struct containing the details of a string table entry
93 
94  Remarks:
95  None.
96 */
101 typedef struct leStringInfo
102 {
103  uint32_t stringIndex;
104  uint32_t languageID;
105  uint32_t offset;
106  uint8_t* data;
107  uint32_t dataSize;
108  uint32_t length;
110 
111 // *****************************************************************************
122 LIB_EXPORT uint32_t leStringTable_GetStringCount(const leStringTable* table);
123 
124 // *****************************************************************************
135 LIB_EXPORT uint32_t leStringTable_GetLanguageCount(const leStringTable* table);
136 
137 // *****************************************************************************
151 LIB_EXPORT uint32_t leStringTable_GetStringOffset(const leStringTable* table,
152  uint32_t stringID,
153  uint32_t languageID);
154 
155 // *****************************************************************************
168 LIB_EXPORT uint32_t leStringTable_GetActiveStringOffset(const leStringTable* table,
169  uint32_t stringID);
170 
171 // *****************************************************************************
188 LIB_EXPORT leFont* leStringTable_GetStringFont(const leStringTable* table,
189  uint32_t stringID,
190  uint32_t languageID);
191 
192 // *****************************************************************************
205 LIB_EXPORT leResult leStringTable_StringLookup(const leStringTable* table,
206  leStringInfo* info);
207 
208 // *****************************************************************************
223  leStringInfo* info);
224 
225 
226 #endif /* LEGATO_STRINGTABLE_H */
LE_HALIGN_RIGHT
@ LE_HALIGN_RIGHT
Definition: legato_common.h:209
leStringTableIndex
Definition: legato_stringtable.c:38
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leRect
This struct represents a rectangle.
Definition: legato_common.h:405
leStringTable_GetStringOffset
LIB_EXPORT uint32_t leStringTable_GetStringOffset(const leStringTable *table, uint32_t stringID, uint32_t languageID)
Get offset of a string in table by string and language ID.
Definition: legato_stringtable.c:73
leHAlignment
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:206
leStringTableEntry
Definition: legato_stringtable.c:44
legato_string_renderer.h
String Renderer.
legato_stringtable.h
String table functions and definitions.
leStringTable_StringLookup
LIB_EXPORT leResult leStringTable_StringLookup(const leStringTable *table, leStringInfo *info)
Get info for a string table string.
Definition: legato_stringtable.c:184
LE_HALIGN_CENTER
@ LE_HALIGN_CENTER
Definition: legato_common.h:208
leFont
This struct represents a font object.
Definition: legato_font.h:136
leRasterFont
This struct represents a rasterized font object.
Definition: legato_font.h:167
leString
This struct represents a string.
Definition: legato_string.h:108
leStringEncodingMode
leStringEncodingMode
This enum represents string encoding modes.
Definition: legato_stringtable.h:47
leBool
leBool
This enum represents booleans.
Definition: legato_common.h:157
leStringRenderRequest
This struct represents a string render request.
Definition: legato_string_renderer.h:59
leFontGlyph
This struct represents a font glyph.
Definition: legato_font.h:90
leStringTable_GetStringFont
LIB_EXPORT leFont * leStringTable_GetStringFont(const leStringTable *table, uint32_t stringID, uint32_t languageID)
Get font for a string table string.
Definition: legato_stringtable.c:110
leStringTable
struct leStringTable leStringTable
This struct represents string a string table.
leStringTable_GetStringCount
LIB_EXPORT uint32_t leStringTable_GetStringCount(const leStringTable *table)
Gets the number of strings in a string table.
Definition: legato_stringtable.c:49
leGetStringLanguage
LIB_EXPORT uint32_t leGetStringLanguage()
Get language index.
Definition: legato_state.c:449
leFont_GetGlyphInfo
leResult leFont_GetGlyphInfo(const leFont *fnt, uint32_t codepoint, leFontGlyph *glyph)
Get glyph info.
Definition: legato_font.c:171
leStringInfo
struct leStringInfo leStringInfo
This struct represents string a string table entry.
legato_stringutils.h
String utility functions and definitions.
leStringTable_GetActiveStringOffset
LIB_EXPORT uint32_t leStringTable_GetActiveStringOffset(const leStringTable *table, uint32_t stringID)
Get offset of a string in table using active global language.
Definition: legato_stringtable.c:104
leStringTable_GetStringLength
LIB_EXPORT leResult leStringTable_GetStringLength(const leStringTable *table, leStringInfo *info)
Get length of a string in the string table in codepoints.
Definition: legato_stringtable.c:214
leStreamDescriptor
This struct represents a stream descriptor.
Definition: legato_stream.h:57
LE_TRUE
@ LE_TRUE
Definition: legato_common.h:159
legato_font.h
Font functions and definitions.
legato_common.h
Common macros and definitions used by Legato.
leString::fn
const leStringVTable * fn
Definition: legato_string.h:109
leStringTableHeader
Definition: legato_stringtable.c:32
legato_state.h
leStringTable
This struct represents string a string table.
Definition: legato_stringtable.h:80
leStringTable_GetLanguageCount
LIB_EXPORT uint32_t leStringTable_GetLanguageCount(const leStringTable *table)
Get number of languages in a string table.
Definition: legato_stringtable.c:61
leStringInfo
This struct represents string a string table entry.
Definition: legato_stringtable.h:102