| 129 | } |
| 130 | |
| 131 | void PiuStyleLookupFont(PiuStyle* self) |
| 132 | { |
| 133 | xsMachine* the = (*self)->the; |
| 134 | void* archive = NULL; |
| 135 | PiuFontList* fontList; |
| 136 | PiuFont* font = NULL; |
| 137 | xsStringValue name; |
| 138 | char path[256]; |
| 139 | void* buffer; |
| 140 | size_t bufferSize; |
| 141 | int32_t ascent, descent, leading; |
| 142 | |
| 143 | if ((*self)->archive) { |
| 144 | xsResult = xsReference((*self)->archive); |
| 145 | archive = xsGetHostData(xsResult); |
| 146 | } |
| 147 | xsResult = xsGet(xsGlobal, xsID_fonts); |
| 148 | if (xsTest(xsResult)) |
| 149 | fontList = PIU(FontList, xsResult); |
| 150 | else { |
| 151 | gCFE = CFENew(); |
| 152 | PiuFontListNew(the); |
| 153 | xsSet(xsGlobal, xsID_fonts, xsResult); |
| 154 | fontList = PIU(FontList, xsResult); |
| 155 | } |
| 156 | font = (*fontList)->first; |
| 157 | while (font) { |
| 158 | if (((*font)->family == (*self)->family) |
| 159 | && ((*font)->size == (*self)->size) |
| 160 | && ((*font)->weight == (*self)->weight) |
| 161 | && ((*font)->flags == ((*self)->flags & piuStyleBits))) { |
| 162 | (*self)->font = font; |
| 163 | return; |
| 164 | } |
| 165 | font = (*font)->next; |
| 166 | } |
| 167 | |
| 168 | name = xsName((*self)->family); |
| 169 | if (name) |
| 170 | c_strcpy(path, name); |
| 171 | else |
| 172 | c_strcpy(path, "undefined"); |
| 173 | if (((*self)->flags & (piuStyleCondensedBit | piuStyleItalicBit)) || ((*self)->weight) || ((*self)->size)) { |
| 174 | xsIntegerValue flag = 0; |
| 175 | c_strcat(path, "-"); |
| 176 | if ((*self)->flags & piuStyleCondensedBit) |
| 177 | c_strcat(path, "Condensed"); |
| 178 | else |
| 179 | flag |= 1; |
| 180 | switch ((*self)->weight) { |
| 181 | case 1: c_strcat(path, "Ultralight"); break; |
| 182 | case 2: c_strcat(path, "Thin"); break; |
| 183 | case 3: c_strcat(path, "Light"); break; |
| 184 | case 5: c_strcat(path, "Medium");break; |
| 185 | case 6: c_strcat(path, "Semibold"); break; |
| 186 | case 7: c_strcat(path, "Bold");break; |
| 187 | case 8: c_strcat(path, "Heavy"); break; |
| 188 | case 9: c_strcat(path, "Black");break; |
nothing calls this directly
no test coverage detected