Changeset a81d480 in mainline
- Timestamp:
- 2020-09-27T10:59:23Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f13f1495
- Parents:
- d8cdaf1b
- Location:
- uspace/app/fontedit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/fontedit/fontedit.c
rd8cdaf1b ra81d480 135 135 } 136 136 137 /** Duplicate previously selected glyph to the current glyph. 138 * 139 * @param fedit Font editor 140 */ 141 static void font_edit_copy_paste(font_edit_t *fedit) 142 { 143 gfx_glyph_bmp_t *src_bmp; 144 gfx_glyph_metrics_t gmetrics; 145 gfx_rect_t rect; 146 gfx_coord_t x, y; 147 int pix; 148 errno_t rc; 149 150 /* If source and destination are the same, there is nothing to do. */ 151 if (fedit->glyph == fedit->src_glyph) 152 return; 153 154 rc = gfx_glyph_bmp_open(fedit->src_glyph, &src_bmp); 155 if (rc != EOK) { 156 printf("Error opening source glyph.\n"); 157 return; 158 } 159 160 gfx_glyph_bmp_get_rect(src_bmp, &rect); 161 162 rc = gfx_glyph_bmp_clear(fedit->gbmp); 163 if (rc != EOK) { 164 printf("Error clearing glyph bitmap.\n"); 165 return; 166 } 167 168 for (y = rect.p0.y; y < rect.p1.y; y++) { 169 for (x = rect.p0.x; x < rect.p1.x; x++) { 170 pix = gfx_glyph_bmp_getpix(src_bmp, x, y); 171 rc = gfx_glyph_bmp_setpix(fedit->gbmp, x, y, pix); 172 if (rc != EOK) { 173 printf("Error setting pixel.\n"); 174 return; 175 } 176 } 177 } 178 179 /* Copy metrics over */ 180 gfx_glyph_get_metrics(fedit->src_glyph, &gmetrics); 181 (void) gfx_glyph_set_metrics(fedit->glyph, &gmetrics); 182 183 font_edit_paint(fedit); 184 185 } 186 137 187 /** Handle font editor control-key press. 138 188 * … … 170 220 (void) gfx_glyph_bmp_clear(fedit->gbmp); 171 221 font_edit_paint(fedit); 222 break; 223 case KC_C: 224 /* Select source glyph for copying */ 225 fedit->src_glyph = fedit->glyph; 226 break; 227 case KC_V: 228 /* Duplicate another glyph */ 229 font_edit_copy_paste(fedit); 172 230 break; 173 231 default: -
uspace/app/fontedit/fontedit.h
rd8cdaf1b ra81d480 64 64 /** Glyph bitmap */ 65 65 gfx_glyph_bmp_t *gbmp; 66 /** Glyph used as source for copy/paste */ 67 gfx_glyph_t *src_glyph; 66 68 } font_edit_t; 67 69
Note:
See TracChangeset
for help on using the changeset viewer.