Changeset 313ac8e in mainline for uspace/lib/gfxfont/src/font.c
- Timestamp:
- 2020-09-17T15:28:03Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7bef2d8
- Parents:
- 414020d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfxfont/src/font.c
r414020d9 r313ac8e 271 271 * 272 272 * This is used to resize a glyph in the font bitmap. This changes 273 * the bitmap widht andmight also make the bitmap taller.274 * Width and height of the glyph is also adjusted accordingly.273 * the bitmap widht might also make the bitmap taller. 274 * Dimensions of the glyph are also adjusted according to @a nrect. 275 275 * 276 276 * @param font Font 277 277 * @param glyph Glyph to replace 278 * @param width Width of replacement space 279 * @param height Height of replacement space 278 * @param nrect Replacement rectangle 280 279 */ 281 280 errno_t gfx_font_splice_at_glyph(gfx_font_t *font, gfx_glyph_t *glyph, 282 gfx_ coord_t width, gfx_coord_t height)281 gfx_rect_t *nrect) 283 282 { 284 283 gfx_glyph_t *g; … … 286 285 gfx_bitmap_params_t params; 287 286 gfx_coord_t dwidth; 287 gfx_coord_t x0; 288 288 errno_t rc; 289 289 290 290 /* Change of width of glyph */ 291 dwidth = width - (glyph->rect.p1.x - glyph->rect.p0.x); 291 dwidth = (nrect->p1.x - nrect->p0.x) - 292 (glyph->rect.p1.x - glyph->rect.p0.x); 292 293 293 294 /* Create new font bitmap, wider by dwidth pixels */ … … 295 296 params.rect = font->rect; 296 297 params.rect.p1.x += dwidth; 297 if ( height> params.rect.p1.y)298 params.rect.p1.y = height;298 if (nrect->p1.y - nrect->p0.y > params.rect.p1.y) 299 params.rect.p1.y = nrect->p1.y - nrect->p0.y; 299 300 300 301 rc = gfx_bitmap_create(font->typeface->gc, ¶ms, NULL, &nbitmap); 301 302 if (rc != EOK) 302 303 goto error; 304 305 /* 306 * In x0 we compute the left margin of @a glyph. We start with 307 * zero and then, if there are any preceding glyphs, we set it 308 * to the right margin of the last one. 309 */ 310 x0 = 0; 303 311 304 312 /* Transfer glyphs before @a glyph */ … … 310 318 if (rc != EOK) 311 319 goto error; 320 321 /* Left margin of the next glyph */ 322 x0 = g->rect.p1.x; 312 323 313 324 g = gfx_font_next_glyph(g); … … 331 342 } 332 343 333 /* Update glyph width and height */ 334 glyph->rect.p1.x = glyph->rect.p0.x + width; 335 glyph->rect.p1.y = glyph->rect.p0.y + height; 344 /* Place glyph rectangle inside the newly created space */ 345 glyph->origin.x = x0 - nrect->p0.x; 346 glyph->origin.y = 0 - nrect->p0.y; 347 gfx_rect_translate(&glyph->origin, nrect, &glyph->rect); 336 348 337 349 /* Update font bitmap */
Note:
See TracChangeset
for help on using the changeset viewer.