… | |
… | |
185 | |
185 | |
186 | static void |
186 | static void |
187 | layout_update_font (DC__Layout self) |
187 | layout_update_font (DC__Layout self) |
188 | { |
188 | { |
189 | /* use a random scale factor to account for unknown descenders, 0.8 works |
189 | /* use a random scale factor to account for unknown descenders, 0.8 works |
190 | * reasonably well with bitstream vera |
190 | * reasonably well with dejavu/bistream fonts |
191 | */ |
191 | */ |
192 | PangoFontDescription *font = self->font ? self->font : default_font; |
192 | PangoFontDescription *font = self->font ? self->font : default_font; |
193 | |
193 | |
194 | pango_font_description_set_absolute_size (font, |
194 | pango_font_description_set_absolute_size (font, |
195 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
195 | MAX (MIN_FONT_HEIGHT, self->base_height) * (PANGO_SCALE * 8 / 10)); |
… | |
… | |
2292 | else |
2292 | else |
2293 | *data++ = 0; |
2293 | *data++ = 0; |
2294 | } |
2294 | } |
2295 | } |
2295 | } |
2296 | |
2296 | |
|
|
2297 | /* if size is w*h + 5 then no data has been found */ |
|
|
2298 | if (data - (uint8_t *)SvPVX (data_sv) != w * h + 5) |
|
|
2299 | { |
2297 | SvPOK_only (data_sv); |
2300 | SvPOK_only (data_sv); |
2298 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
2301 | SvCUR_set (data_sv, data - (uint8_t *)SvPVX (data_sv)); |
|
|
2302 | } |
|
|
2303 | |
2299 | RETVAL = data_sv; |
2304 | RETVAL = data_sv; |
2300 | } |
2305 | } |
2301 | OUTPUT: |
2306 | OUTPUT: |
2302 | RETVAL |
2307 | RETVAL |
2303 | |
2308 | |
2304 | void |
2309 | void |
2305 | set_rect (DC::Map self, int x0, int y0, uint8_t *data) |
2310 | set_rect (DC::Map self, int x0, int y0, SV *data_sv) |
2306 | PPCODE: |
2311 | PPCODE: |
2307 | { |
2312 | { |
2308 | int x, y, z; |
2313 | int x, y, z; |
2309 | int w, h; |
2314 | int w, h; |
2310 | int x1, y1; |
2315 | int x1, y1; |
|
|
2316 | STRLEN len; |
|
|
2317 | uint8_t *data, *end; |
|
|
2318 | |
|
|
2319 | len = SvLEN (data_sv); |
|
|
2320 | SvGROW (data_sv, len + 8); // reserve at least 7+ bytes more |
|
|
2321 | data = SvPVbyte_nolen (data_sv); |
|
|
2322 | end = data + len + 8; |
|
|
2323 | |
|
|
2324 | if (len < 5) |
|
|
2325 | XSRETURN_EMPTY; |
2311 | |
2326 | |
2312 | if (*data++ != 0) |
2327 | if (*data++ != 0) |
2313 | XSRETURN_EMPTY; /* version mismatch */ |
2328 | XSRETURN_EMPTY; /* version mismatch */ |
2314 | |
2329 | |
2315 | w = *data++ << 8; w |= *data++; |
2330 | w = *data++ << 8; w |= *data++; |
… | |
… | |
2330 | { |
2345 | { |
2331 | maprow *row = map_get_row (self, y); |
2346 | maprow *row = map_get_row (self, y); |
2332 | |
2347 | |
2333 | for (x = x0; x < x1; x++) |
2348 | for (x = x0; x < x1; x++) |
2334 | { |
2349 | { |
|
|
2350 | uint8_t flags; |
|
|
2351 | |
|
|
2352 | if (data + 7 >= end) |
|
|
2353 | XSRETURN_EMPTY; |
|
|
2354 | |
2335 | uint8_t flags = *data++; |
2355 | flags = *data++; |
2336 | |
2356 | |
2337 | if (flags) |
2357 | if (flags) |
2338 | { |
2358 | { |
2339 | mapcell *cell = row_get_cell (row, x); |
2359 | mapcell *cell = row_get_cell (row, x); |
2340 | tileid tile[3] = { 0, 0, 0 }; |
2360 | tileid tile[3] = { 0, 0, 0 }; |
… | |
… | |
2343 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2363 | if (flags & 2) { tile[1] = *data++ << 8; tile[1] |= *data++; } |
2344 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2364 | if (flags & 4) { tile[2] = *data++ << 8; tile[2] |= *data++; } |
2345 | |
2365 | |
2346 | if (cell->darkness == 0) |
2366 | if (cell->darkness == 0) |
2347 | { |
2367 | { |
2348 | cell->darkness = 0; |
2368 | /*cell->darkness = 0;*/ |
|
|
2369 | EXTEND (SP, 3); |
2349 | |
2370 | |
2350 | for (z = 0; z <= 2; z++) |
2371 | for (z = 0; z <= 2; z++) |
2351 | { |
2372 | { |
2352 | tileid t = tile [z]; |
2373 | tileid t = tile [z]; |
2353 | |
2374 | |
2354 | if (t >= self->texs || (t && !self->tex [t].name)) |
2375 | if (t >= self->texs || (t && !self->tex [t].name)) |
2355 | { |
2376 | { |
2356 | XPUSHs (sv_2mortal (newSViv (t))); |
2377 | PUSHs (sv_2mortal (newSViv (t))); |
2357 | need_texid (self, t); |
2378 | need_texid (self, t); |
2358 | } |
2379 | } |
2359 | |
2380 | |
2360 | cell->tile [z] = t; |
2381 | cell->tile [z] = t; |
2361 | } |
2382 | } |