diff options
-rw-r--r-- | struct.c | 145 |
1 files changed, 79 insertions, 66 deletions
@@ -36,40 +36,42 @@ makeFont(void) if(font == NULL) return NULL; - font->numNames = 0; - font->names = NULL; - font->flags = 0; - font->weight = 500; - font->width = 5; - font->italicAngle = 0; - font->pxMetrics.height = UNDEF; - font->pxMetrics.maxX = UNDEF; - font->pxMetrics.minX = UNDEF; - font->pxMetrics.maxY = UNDEF; - font->pxMetrics.minY = UNDEF; - font->pxMetrics.xHeight = UNDEF; - font->pxMetrics.capHeight = UNDEF; - font->pxMetrics.maxAwidth = UNDEF; - font->pxMetrics.awidth = UNDEF; - font->pxMetrics.ascent = UNDEF; - font->pxMetrics.descent = UNDEF; - font->pxMetrics.underlinePosition = UNDEF; - font->pxMetrics.underlineThickness = UNDEF; - font->metrics.height = UNDEF; - font->metrics.maxX = UNDEF; - font->metrics.minX = UNDEF; - font->metrics.maxY = UNDEF; - font->metrics.minY = UNDEF; - font->metrics.xHeight = UNDEF; - font->metrics.capHeight = UNDEF; - font->metrics.maxAwidth = UNDEF; - font->metrics.awidth = UNDEF; - font->metrics.ascent = UNDEF; - font->metrics.descent = UNDEF; - font->metrics.underlinePosition = UNDEF; - font->metrics.underlineThickness = UNDEF; - font->foundry = makeName("UNKN"); - font->strikes = NULL; + *font = (FontRec) { + .numNames = 0, + .names = NULL, + .flags = 0, + .weight = 500, + .width = 5, + .italicAngle = 0, + .pxMetrics.height = UNDEF, + .pxMetrics.maxX = UNDEF, + .pxMetrics.minX = UNDEF, + .pxMetrics.maxY = UNDEF, + .pxMetrics.minY = UNDEF, + .pxMetrics.xHeight = UNDEF, + .pxMetrics.capHeight = UNDEF, + .pxMetrics.maxAwidth = UNDEF, + .pxMetrics.awidth = UNDEF, + .pxMetrics.ascent = UNDEF, + .pxMetrics.descent = UNDEF, + .pxMetrics.underlinePosition = UNDEF, + .pxMetrics.underlineThickness = UNDEF, + .metrics.height = UNDEF, + .metrics.maxX = UNDEF, + .metrics.minX = UNDEF, + .metrics.maxY = UNDEF, + .metrics.minY = UNDEF, + .metrics.xHeight = UNDEF, + .metrics.capHeight = UNDEF, + .metrics.maxAwidth = UNDEF, + .metrics.awidth = UNDEF, + .metrics.ascent = UNDEF, + .metrics.descent = UNDEF, + .metrics.underlinePosition = UNDEF, + .metrics.underlineThickness = UNDEF, + .foundry = makeName("UNKN"), + .strikes = NULL, + }; return font; } @@ -90,22 +92,27 @@ makeStrike(FontPtr font, int sizeX, int sizeY) strike = malloc(sizeof(StrikeRec)); if(strike == NULL) return NULL; - strike->sizeX = sizeX; - strike->sizeY = sizeY; - strike->bitmaps = - calloc(FONT_CODES / FONT_SEGMENT_SIZE, sizeof(BitmapPtr*)); - if(strike->bitmaps == NULL) { - free(strike); - return NULL; + else { + BitmapPtr **bitmaps = + calloc(FONT_CODES / FONT_SEGMENT_SIZE, sizeof(BitmapPtr*)); + if (bitmaps == NULL) { + free(strike); + return NULL; + } + *strike = (StrikeRec) { + .sizeX = sizeX, + .sizeY = sizeY, + .bitmaps = bitmaps, + .numSbits = 0, + .next = NULL, + .bitmapSizeTableLocation = 0xDEADFACE, + .indexSubTables = NULL, + }; + if (last_strike) + last_strike->next = strike; + else + font->strikes = strike; } - strike->numSbits = 0; - strike->next = NULL; - strike->bitmapSizeTableLocation = 0xDEADFACE; - strike->indexSubTables = NULL; - if(last_strike) - last_strike->next = strike; - else - font->strikes = strike; return strike; } @@ -123,12 +130,14 @@ makeBitmap(StrikePtr strike, int code, if(bitmap == NULL) return NULL; - bitmap->index = -1; - bitmap->width = 0; - bitmap->height = 0; - bitmap->stride = 0; - bitmap->raster = NULL; - bitmap->location = 0xDEADFACE; + *bitmap = (BitmapRec) { + .index = -1, + .width = 0, + .height = 0, + .stride = 0, + .raster = NULL, + .location = 0xDEADFACE, + }; i = code / FONT_SEGMENT_SIZE; j = code % FONT_SEGMENT_SIZE; @@ -299,12 +308,14 @@ makeIndexSubTables(StrikePtr strike, CmapPtr cmap) constantMetrics = 0; table = malloc(sizeof(IndexSubTableRec)); - table->firstGlyphIndex = index; - table->lastGlyphIndex = index + n - 1; - table->constantMetrics = constantMetrics; - table->location = 0xDEADFACE; - table->lastLocation = 0xDEADFACE; - table->next = NULL; + *table = (IndexSubTableRec) { + .firstGlyphIndex = index, + .lastGlyphIndex = index + n - 1, + .constantMetrics = constantMetrics, + .location = 0xDEADFACE, + .lastLocation = 0xDEADFACE, + .next = NULL, + }; if(first == NULL) { first = table; @@ -359,11 +370,13 @@ makeCmap(FontPtr font) cmap = malloc(sizeof(CmapRec)); if(cmap == NULL) return NULL; - cmap->startCode = code; - cmap->endCode = code + i - 1; - cmap->index = index; - cmap->next = NULL; - cmap->maxindex = 0; + *cmap = (CmapRec) { + .startCode = code, + .endCode = code + i - 1, + .index = index, + .next = NULL, + .maxindex = 0, + }; if(maxindex < index + i - 1) maxindex = index + i - 1; if(cmap_head == NULL) |