| 211 | #endif |
| 212 | |
| 213 | void PiuStyleLookupFont(PiuStyle* self) |
| 214 | { |
| 215 | xsMachine* the = (*self)->the; |
| 216 | void* archive = NULL; |
| 217 | PiuFontList* fontList; |
| 218 | PiuFont* font = NULL; |
| 219 | xsStringValue name; |
| 220 | char path[256]; |
| 221 | void* buffer; |
| 222 | size_t bufferSize; |
| 223 | int32_t ascent, descent, leading; |
| 224 | |
| 225 | if ((*self)->archive) { |
| 226 | xsResult = xsReference((*self)->archive); |
| 227 | archive = xsGetHostData(xsResult); |
| 228 | } |
| 229 | xsResult = xsGet(xsGlobal, xsID_fonts); |
| 230 | if (xsTest(xsResult)) { |
| 231 | fontList = PIU(FontList, xsResult); |
| 232 | font = (*fontList)->first; |
| 233 | while (font) { |
| 234 | if (((*font)->family == (*self)->family) |
| 235 | && ((*font)->size == (*self)->size) |
| 236 | && ((*font)->weight == (*self)->weight) |
| 237 | && ((*font)->flags == ((*self)->flags & piuStyleBits))) { |
| 238 | // fprintf(stderr, "CACHE\n"); |
| 239 | (*self)->font = font; |
| 240 | return; |
| 241 | } |
| 242 | font = (*font)->next; |
| 243 | } |
| 244 | } |
| 245 | else { |
| 246 | gCFEUseCount++; |
| 247 | if (!gCFE) |
| 248 | gCFE = CFENew(); |
| 249 | PiuFontListNew(the); |
| 250 | xsSet(xsGlobal, xsID_fonts, xsResult); |
| 251 | fontList = PIU(FontList, xsResult); |
| 252 | } |
| 253 | |
| 254 | name = xsName((*self)->family); |
| 255 | if (name) |
| 256 | c_strcpy(path, name); |
| 257 | else |
| 258 | c_strcpy(path, "undefined"); |
| 259 | if (((*self)->flags & (piuStyleCondensedBit | piuStyleItalicBit)) || ((*self)->weight) || ((*self)->size)) { |
| 260 | xsIntegerValue flag = 0; |
| 261 | c_strcat(path, "-"); |
| 262 | if ((*self)->flags & piuStyleCondensedBit) |
| 263 | c_strcat(path, "Condensed"); |
| 264 | else |
| 265 | flag |= 1; |
| 266 | switch ((*self)->weight) { |
| 267 | case 1: c_strcat(path, "Ultralight"); break; |
| 268 | case 2: c_strcat(path, "Thin"); break; |
| 269 | case 3: c_strcat(path, "Light"); break; |
| 270 | case 5: c_strcat(path, "Medium");break; |
no test coverage detected